Skip to content

Commit

Permalink
feat: add EFS file storage to devnet nodes (#3584)
Browse files Browse the repository at this point in the history
Closes #3568 

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
spypsy authored Dec 6, 2023
1 parent 9773e8c commit 5b590eb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
4 changes: 2 additions & 2 deletions yarn-project/aztec-node/src/aztec-node/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { AztecNodeConfig } from './config.js';
export const createMemDown = () => (memdown as any)() as MemDown<any, any>;
export const createLevelDown = (path: string) => (leveldown as any)(path) as LevelDown;

const DB_SUBDIR = 'aztec-node';
const WORLD_STATE_SUBDIR = 'aztec-world-state';
const DB_SUBDIR = 'aztec-node-db';
const WORLD_STATE_SUBDIR = 'aztec-world-state-db';
const NODE_METADATA_KEY = '@@aztec_node_metadata';

/**
Expand Down
55 changes: 53 additions & 2 deletions yarn-project/aztec-node/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ locals {
"/dns4/${var.DEPLOY_TAG}-aztec-bootstrap-${i + 1}.local/tcp/${var.BOOTNODE_LISTEN_PORT + i}/p2p/${local.bootnode_ids[i]}"
]
combined_bootnodes = join(",", local.bootnodes)
data_dir = "/usr/src/yarn-project/aztec-sandbox/data"
}

resource "aws_cloudwatch_log_group" "aztec-node-log-group" {
Expand Down Expand Up @@ -101,9 +102,37 @@ resource "aws_service_discovery_service" "aztec-node" {
}
}

# Configure an EFS filesystem.
resource "aws_efs_file_system" "node_data_store" {
count = local.node_count
creation_token = "${var.DEPLOY_TAG}-node-${count.index + 1}-data"
throughput_mode = "provisioned"
provisioned_throughput_in_mibps = 20

tags = {
Name = "${var.DEPLOY_TAG}-node-data"
}

lifecycle_policy {
transition_to_ia = "AFTER_14_DAYS"
}
}

resource "aws_efs_mount_target" "private_az1" {
count = local.node_count
file_system_id = aws_efs_file_system.node_data_store[count.index].id
subnet_id = data.terraform_remote_state.setup_iac.outputs.subnet_az1_private_id
security_groups = [data.terraform_remote_state.setup_iac.outputs.security_group_private_id]
}

resource "aws_efs_mount_target" "private_az2" {
file_system_id = aws_efs_file_system.node_data_store[count.index].id
subnet_id = data.terraform_remote_state.setup_iac.outputs.subnet_az2_private_id
security_groups = [data.terraform_remote_state.setup_iac.outputs.security_group_private_id]
}

# Define task definitions for each node.
resource "aws_ecs_task_definition" "aztec-node" {
# for_each = var.node_keys
count = local.node_count
family = "${var.DEPLOY_TAG}-aztec-node-${count.index + 1}"
requires_compatibilities = ["FARGATE"]
Expand All @@ -112,7 +141,15 @@ resource "aws_ecs_task_definition" "aztec-node" {
memory = "4096"
execution_role_arn = data.terraform_remote_state.setup_iac.outputs.ecs_task_execution_role_arn
task_role_arn = data.terraform_remote_state.aztec2_iac.outputs.cloudwatch_logging_ecs_role_arn
container_definitions = <<DEFINITIONS

volume {
name = "efs-data-store"
efs_volume_configuration {
file_system_id = aws_efs_file_system.node_data_store[count.index].id
}
}

container_definitions = <<DEFINITIONS
[
{
"name": "${var.DEPLOY_TAG}-aztec-node-${count.index + 1}",
Expand Down Expand Up @@ -156,6 +193,10 @@ resource "aws_ecs_task_definition" "aztec-node" {
"name": "ETHEREUM_HOST",
"value": "https://${var.DEPLOY_TAG}-mainnet-fork.aztec.network:8545/${var.API_KEY}"
},
{
"name": "DATA_DIRECTORY",
"value": "${local.data_dir}"
},
{
"name": "ARCHIVER_POLLING_INTERVAL",
"value": "10000"
Expand Down Expand Up @@ -188,6 +229,10 @@ resource "aws_ecs_task_definition" "aztec-node" {
"name": "INBOX_CONTRACT_ADDRESS",
"value": "${data.terraform_remote_state.l1_contracts.outputs.inbox_contract_address}"
},
{
"name": "OUTBOX_CONTRACT_ADDRESS",
"value": "${data.terraform_remote_state.l1_contracts.outputs.outbox_contract_address}"
},
{
"name": "REGISTRY_CONTRACT_ADDRESS",
"value": "${data.terraform_remote_state.l1_contracts.outputs.registry_contract_address}"
Expand Down Expand Up @@ -241,6 +286,12 @@ resource "aws_ecs_task_definition" "aztec-node" {
"value": "${var.P2P_MAX_PEERS}"
}
],
"mountPoints": [
{
"containerPath": "${local.data_dir}",
"sourceVolume": "efs-data-store"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
Expand Down

0 comments on commit 5b590eb

Please sign in to comment.