Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: IAC for a prototype devnet #2720

Merged
merged 26 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,28 @@ jobs:
echo "export DOCKER_BUILDKIT=" > $BASH_ENV
build aztec-sandbox false arm64

aztec-p2p-bootstrap:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
steps:
- *checkout
- *setup_env
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now be built by yarn-project I think. You would be able to grab the build from there

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't yarn-project just produce a single image yarn-project with all of the built code? And if we want an actual deployable package image we need to have a Dockerfile which extracts the relevant built code for that package?

- run:
name: "Build and test"
command: build p2p-bootstrap | add_timestamps

aztec-node:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Build and test"
command: build aztec-node | add_timestamps

pxe-x86_64:
machine:
image: ubuntu-2204:2023.07.2
Expand Down Expand Up @@ -1024,6 +1046,17 @@ jobs:
name: "yarn-project"
command: yarn-project/deploy_npm.sh

deploy-ecr:
machine:
image: ubuntu-2204:2023.07.2
resource_class: medium
steps:
- *checkout
- *setup_env
- run:
name: "yarn-project"
command: yarn-project/deploy_ecr.sh

deploy-dockerhub:
machine:
image: ubuntu-2204:2023.07.2
Expand Down Expand Up @@ -1244,6 +1277,16 @@ workflows:
- yarn-project
<<: *defaults

- aztec-p2p-bootstrap:
requires:
- yarn-project
<<: *defaults

- aztec-node:
requires:
- yarn-project
<<: *defaults

- pxe-x86_64:
requires:
- yarn-project
Expand Down Expand Up @@ -1374,6 +1417,10 @@ workflows:
requires:
- e2e-end
<<: *deploy_defaults
- deploy-ecr:
requires:
- e2e-end
<<: *deploy_defaults

- deploy-end:
requires:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ node_modules
build/
.idea
cmake-build-debug
.terraform
.terraform*
.bootstrapped
12 changes: 12 additions & 0 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ end-to-end:
dependencies:
- yarn-project

aztec-node:
buildDir: yarn-project
projectDir: yarn-project/aztec-node
dependencies:
- yarn-project

p2p-bootstrap:
buildDir: yarn-project
projectDir: yarn-project/p2p-bootstrap
dependencies:
- yarn-project

docs:
buildDir: .
dockerfile: docs/Dockerfile
Expand Down
61 changes: 61 additions & 0 deletions iac/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
terraform {
backend "s3" {
bucket = "aztec-terraform"
key = "aztec-network/iac"
region = "eu-west-2"
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.74.2"
}
}
}

data "terraform_remote_state" "setup_iac" {
backend = "s3"
config = {
bucket = "aztec-terraform"
key = "setup/setup-iac"
region = "eu-west-2"
}
}

provider "aws" {
profile = "default"
region = "eu-west-2"
}

# Create our load balancer.
resource "aws_lb" "aztec-network" {
name = "aztec-network"
internal = false
load_balancer_type = "network"
security_groups = [
data.terraform_remote_state.setup_iac.outputs.security_group_public_id, aws_security_group.security-group-p2p.id
]
subnets = [
data.terraform_remote_state.setup_iac.outputs.subnet_az1_id,
data.terraform_remote_state.setup_iac.outputs.subnet_az2_id
]

access_logs {
bucket = "aztec-logs"
prefix = "aztec-network-nlb-logs"
enabled = false
}

tags = {
Name = "aztec-network"
}
}

resource "aws_security_group" "security-group-p2p" {
name = "security-group-p2p"
description = "Allow inbound p2p traffic"
vpc_id = data.terraform_remote_state.setup_iac.outputs.vpc_id

tags = {
Name = "allow-p2p"
}
}
11 changes: 11 additions & 0 deletions iac/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "nlb_arn" {
value = "${aws_lb.aztec-network.arn}"
}

output "nlb_dns" {
value = "${aws_lb.aztec-network.dns_name}"
}

output "p2p_security_group_id" {
value = "${aws_security_group.security-group-p2p.id}"
}
14 changes: 14 additions & 0 deletions yarn-project/aztec-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project AS builder

WORKDIR /usr/src/yarn-project/aztec-node

# Productionify. See comment in yarn-project-base/Dockerfile.
RUN yarn cache clean && yarn workspaces focus --production

# Create final, minimal size image.
FROM node:18-alpine
COPY --from=builder /usr/src/ /usr/src/
WORKDIR /usr/src/yarn-project/aztec-node
ENTRYPOINT ["yarn"]
CMD [ "start" ]
EXPOSE 8080
11 changes: 10 additions & 1 deletion yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ export class AztecNodeService implements AztecNode {
protected readonly globalVariableBuilder: GlobalVariableBuilder,
protected readonly merkleTreesDb: levelup.LevelUp,
private log = createDebugLogger('aztec:node'),
) {}
) {
const message =
`Started Aztec Node with contracts - \n` +
`Rollup: ${config.l1Contracts.rollupAddress.toString()}\n` +
`Registry: ${config.l1Contracts.registryAddress.toString()}\n` +
`Inbox: ${config.l1Contracts.inboxAddress.toString()}\n` +
`Outbox: ${config.l1Contracts.outboxAddress.toString()}\n` +
`Contract Emitter: ${config.l1Contracts.contractDeploymentEmitterAddress.toString()}`;
this.log(message);
}

/**
* initializes the Aztec Node, wait for component to sync.
Expand Down
Loading