From bc8d461f6fc20c55aa94647dc671ecb59f52cad2 Mon Sep 17 00:00:00 2001 From: Lasse Herskind <16536249+LHerskind@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:59:56 +0100 Subject: [PATCH] refactor: remove ARCHIVER_L1_START_BLOCK (#8554) Fixes #8552. Adds an immutable to the contract such that we can just read it instead of defaulting to a config value. --- l1-contracts/src/core/Rollup.sol | 2 ++ l1-contracts/src/core/interfaces/IRollup.sol | 2 ++ yarn-project/archiver/src/archiver/archiver.ts | 13 +++++++++++-- yarn-project/archiver/src/archiver/config.ts | 10 ---------- yarn-project/aztec/terraform/node/main.tf | 4 ---- yarn-project/aztec/terraform/prover-node/main.tf | 1 - yarn-project/foundation/src/config/env_var.ts | 1 - 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index a730dfe38db..f2f6f13c12d 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -46,6 +46,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup { // @todo #8018 uint256 public constant TIMELINESS_PROVING_IN_SLOTS = 100; + uint256 public immutable L1_BLOCK_AT_GENESIS; IRegistry public immutable REGISTRY; IInbox public immutable INBOX; IOutbox public immutable OUTBOX; @@ -84,6 +85,7 @@ contract Rollup is Leonidas, IRollup, ITestRollup { OUTBOX = new Outbox(address(this)); vkTreeRoot = _vkTreeRoot; VERSION = 1; + L1_BLOCK_AT_GENESIS = block.number; // Genesis block blocks[0] = BlockLog({ diff --git a/l1-contracts/src/core/interfaces/IRollup.sol b/l1-contracts/src/core/interfaces/IRollup.sol index 18ebf7ee776..baad94fe07c 100644 --- a/l1-contracts/src/core/interfaces/IRollup.sol +++ b/l1-contracts/src/core/interfaces/IRollup.sol @@ -35,6 +35,8 @@ interface IRollup { function OUTBOX() external view returns (IOutbox); + function L1_BLOCK_AT_GENESIS() external view returns (uint256); + function propose( bytes calldata _header, bytes32 _archive, diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 5015c0a1e35..7b993f2bb51 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -30,6 +30,7 @@ import { Fr } from '@aztec/foundation/fields'; import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { RunningPromise } from '@aztec/foundation/running-promise'; import { Timer } from '@aztec/foundation/timer'; +import { RollupAbi } from '@aztec/l1-artifacts'; import { ClassRegistererAddress } from '@aztec/protocol-contracts/class-registerer'; import { type TelemetryClient } from '@aztec/telemetry-client'; import { @@ -42,7 +43,7 @@ import { } from '@aztec/types/contracts'; import groupBy from 'lodash.groupby'; -import { type Chain, type HttpTransport, type PublicClient, createPublicClient, http } from 'viem'; +import { type Chain, type HttpTransport, type PublicClient, createPublicClient, getContract, http } from 'viem'; import { type ArchiverDataStore } from './archiver_store.js'; import { type ArchiverConfig } from './config.js'; @@ -109,6 +110,14 @@ export class Archiver implements ArchiveSource { pollingInterval: config.viemPollingIntervalMS, }); + const rollup = getContract({ + address: config.l1Contracts.rollupAddress.toString(), + abi: RollupAbi, + client: publicClient, + }); + + const l1StartBlock = await rollup.read.L1_BLOCK_AT_GENESIS(); + const archiver = new Archiver( publicClient, config.l1Contracts.rollupAddress, @@ -117,7 +126,7 @@ export class Archiver implements ArchiveSource { archiverStore, config.archiverPollingIntervalMS, new ArchiverInstrumentation(telemetry), - BigInt(config.archiverL1StartBlock), + BigInt(l1StartBlock), ); await archiver.start(blockUntilSynced); return archiver; diff --git a/yarn-project/archiver/src/archiver/config.ts b/yarn-project/archiver/src/archiver/config.ts index 3b067f4e4ae..f4ec61d3106 100644 --- a/yarn-project/archiver/src/archiver/config.ts +++ b/yarn-project/archiver/src/archiver/config.ts @@ -22,11 +22,6 @@ export type ArchiverConfig = { */ archiverPollingIntervalMS?: number; - /** - * The L1 block to start reading from - */ - archiverL1StartBlock: number; - /** * The polling interval viem uses in ms */ @@ -57,11 +52,6 @@ export const archiverConfigMappings: ConfigMappingsType = { description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.', ...numberConfigHelper(1000), }, - archiverL1StartBlock: { - env: 'ARCHIVER_L1_START_BLOCK', - description: 'The L1 block the archiver should start reading logs from', - ...numberConfigHelper(0), - }, viemPollingIntervalMS: { env: 'ARCHIVER_VIEM_POLLING_INTERVAL_MS', description: 'The polling interval viem uses in ms', diff --git a/yarn-project/aztec/terraform/node/main.tf b/yarn-project/aztec/terraform/node/main.tf index 3eb57d2db32..2711e562aa9 100644 --- a/yarn-project/aztec/terraform/node/main.tf +++ b/yarn-project/aztec/terraform/node/main.tf @@ -264,10 +264,6 @@ resource "aws_ecs_task_definition" "aztec-node" { name = "ARCHIVER_POLLING_INTERVAL" value = "10000" }, - { - name = "ARCHIVER_L1_START_BLOCK", - value = "15918000" - }, { name = "SEQ_RETRY_INTERVAL" value = "10000" diff --git a/yarn-project/aztec/terraform/prover-node/main.tf b/yarn-project/aztec/terraform/prover-node/main.tf index 106ef0684e0..fa64d3df4e7 100644 --- a/yarn-project/aztec/terraform/prover-node/main.tf +++ b/yarn-project/aztec/terraform/prover-node/main.tf @@ -251,7 +251,6 @@ resource "aws_ecs_task_definition" "aztec-prover-node" { // Archiver { name = "ARCHIVER_POLLING_INTERVAL", value = "10000" }, - { name = "ARCHIVER_L1_START_BLOCK", value = "15918000" }, // Aztec node to pull clientivc proofs from (to be replaced with a p2p connection) { name = "TX_PROVIDER_NODE_URL", value = "http://${var.DEPLOY_TAG}-aztec-node-${count.index + 1}.local/${var.DEPLOY_TAG}/aztec-node-${count.index + 1}/${var.API_KEY}" }, diff --git a/yarn-project/foundation/src/config/env_var.ts b/yarn-project/foundation/src/config/env_var.ts index 6f99551a29d..16646956a47 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -49,7 +49,6 @@ export type EnvVar = | 'ARCHIVER_POLLING_INTERVAL_MS' | 'ARCHIVER_VIEM_POLLING_INTERVAL_MS' | 'ARCHIVER_MAX_LOGS' - | 'ARCHIVER_L1_START_BLOCK' | 'SEQ_TX_POLLING_INTERVAL_MS' | 'SEQ_MAX_TX_PER_BLOCK' | 'SEQ_MIN_TX_PER_BLOCK'