From 0d83677a7f9a9e434fa0048029fe2988dd49bc4c Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Fri, 13 Oct 2023 03:49:46 +0000 Subject: [PATCH] remove search start block --- yarn-project/archiver/src/archiver/archiver.ts | 15 +++++++++++++-- yarn-project/archiver/src/archiver/config.ts | 7 ------- yarn-project/archiver/src/index.ts | 4 ++-- yarn-project/aztec-node/terraform/main.tf | 8 -------- .../aztec-sandbox/docker-compose-fork.yml | 1 - .../canary/scripts/docker-compose-browser.yml | 1 - .../canary/scripts/docker-compose-e2e-sandbox.yml | 2 -- yarn-project/canary/scripts/docker-compose.yml | 2 -- .../src/uniswap_trade_on_l1_from_l2.test.ts | 2 -- .../docker-compose-e2e-sandbox-browser.yml | 2 -- .../scripts/docker-compose-e2e-sandbox.yml | 2 -- .../end-to-end/scripts/docker-compose.yml | 1 - .../src/uniswap_trade_on_l1_from_l2.test.ts | 2 -- 13 files changed, 15 insertions(+), 34 deletions(-) diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 9fd05cd1830..fcf397b63ba 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -5,6 +5,7 @@ import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { RunningPromise } from '@aztec/foundation/running-promise'; +import { RegistryAbi } from '@aztec/l1-artifacts'; import { ContractData, ContractDataSource, @@ -24,7 +25,7 @@ import { } from '@aztec/types'; import omit from 'lodash.omit'; -import { Chain, HttpTransport, PublicClient, createPublicClient, http } from 'viem'; +import { Chain, HttpTransport, PublicClient, createPublicClient, getContract, http } from 'viem'; import { ArchiverDataStore, MemoryArchiverStore } from './archiver_store.js'; import { ArchiverConfig } from './config.js'; @@ -101,6 +102,16 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource transport: http(chain.rpcUrl), pollingInterval: config.viemPollingIntervalMS, }); + + // ask the registry for the block number when the rollup was deployed + // this is the block from which archiver has to search from + const registryContract = getContract({ + address: config.l1Contracts.registryAddress.toString(), + abi: RegistryAbi, + publicClient, + }); + const searchStartBlock = Number((await registryContract.read.getCurrentSnapshot()).blockNumber); + const archiverStore = new MemoryArchiverStore(config.maxLogs ?? 1000); const archiver = new Archiver( publicClient, @@ -108,7 +119,7 @@ export class Archiver implements L2BlockSource, L2LogsSource, ContractDataSource config.l1Contracts.inboxAddress, config.l1Contracts.registryAddress, config.l1Contracts.contractDeploymentEmitterAddress, - config.searchStartBlock, + searchStartBlock, archiverStore, config.archiverPollingIntervalMS, ); diff --git a/yarn-project/archiver/src/archiver/config.ts b/yarn-project/archiver/src/archiver/config.ts index 61b91368f15..669827c685a 100644 --- a/yarn-project/archiver/src/archiver/config.ts +++ b/yarn-project/archiver/src/archiver/config.ts @@ -32,11 +32,6 @@ export interface ArchiverConfig { */ viemPollingIntervalMS?: number; - /** - * Eth block from which we start scanning for L2Blocks. - */ - searchStartBlock: number; - /** * The deployed L1 contract addresses */ @@ -63,7 +58,6 @@ export function getConfigEnvVars(): ArchiverConfig { ARCHIVER_VIEM_POLLING_INTERVAL_MS, ROLLUP_CONTRACT_ADDRESS, CONTRACT_DEPLOYMENT_EMITTER_ADDRESS, - SEARCH_START_BLOCK, API_KEY, INBOX_CONTRACT_ADDRESS, OUTBOX_CONTRACT_ADDRESS, @@ -85,7 +79,6 @@ export function getConfigEnvVars(): ArchiverConfig { rpcUrl: ETHEREUM_HOST || 'http://127.0.0.1:8545/', archiverPollingIntervalMS: ARCHIVER_POLLING_INTERVAL_MS ? +ARCHIVER_POLLING_INTERVAL_MS : 1_000, viemPollingIntervalMS: ARCHIVER_VIEM_POLLING_INTERVAL_MS ? +ARCHIVER_VIEM_POLLING_INTERVAL_MS : 1_000, - searchStartBlock: SEARCH_START_BLOCK ? +SEARCH_START_BLOCK : 0, apiKey: API_KEY, l1Contracts: addresses, dataDirectory: DATA_DIRECTORY, diff --git a/yarn-project/archiver/src/index.ts b/yarn-project/archiver/src/index.ts index 0f206b45ca0..144cd9210a7 100644 --- a/yarn-project/archiver/src/index.ts +++ b/yarn-project/archiver/src/index.ts @@ -17,7 +17,7 @@ const log = createDebugLogger('aztec:archiver'); // eslint-disable-next-line require-await async function main() { const config = getConfigEnvVars(); - const { rpcUrl, l1Contracts, searchStartBlock } = config; + const { rpcUrl, l1Contracts } = config; const publicClient = createPublicClient({ chain: localhost, @@ -32,7 +32,7 @@ async function main() { l1Contracts.inboxAddress, l1Contracts.registryAddress, l1Contracts.contractDeploymentEmitterAddress, - searchStartBlock, + 0, // searchStartBlock archiverStore, ); diff --git a/yarn-project/aztec-node/terraform/main.tf b/yarn-project/aztec-node/terraform/main.tf index 7f64a6d9f1d..920a11664c1 100644 --- a/yarn-project/aztec-node/terraform/main.tf +++ b/yarn-project/aztec-node/terraform/main.tf @@ -167,10 +167,6 @@ resource "aws_ecs_task_definition" "aztec-node-1" { "name": "API_PREFIX", "value": "/${var.DEPLOY_TAG}/aztec-node-1" }, - { - "name": "SEARCH_START_BLOCK", - "value": "15920300" - }, { "name": "P2P_TCP_LISTEN_PORT", "value": "${var.NODE_1_TCP_PORT}" @@ -460,10 +456,6 @@ resource "aws_ecs_task_definition" "aztec-node-2" { "name": "API_PREFIX", "value": "/${var.DEPLOY_TAG}/aztec-node-2" }, - { - "name": "SEARCH_START_BLOCK", - "value": "15920300" - }, { "name": "P2P_TCP_LISTEN_PORT", "value": "${var.NODE_2_TCP_PORT}" diff --git a/yarn-project/aztec-sandbox/docker-compose-fork.yml b/yarn-project/aztec-sandbox/docker-compose-fork.yml index 33c6c94416c..69660298029 100644 --- a/yarn-project/aztec-sandbox/docker-compose-fork.yml +++ b/yarn-project/aztec-sandbox/docker-compose-fork.yml @@ -19,4 +19,3 @@ services: SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - SEARCH_START_BLOCK: 17514288 diff --git a/yarn-project/canary/scripts/docker-compose-browser.yml b/yarn-project/canary/scripts/docker-compose-browser.yml index bb8c3b1ecc5..77279f629c0 100644 --- a/yarn-project/canary/scripts/docker-compose-browser.yml +++ b/yarn-project/canary/scripts/docker-compose-browser.yml @@ -24,7 +24,6 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: - '8080:8080' diff --git a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml index 9fcde2a195a..e9d8f75c5b3 100644 --- a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml @@ -24,7 +24,6 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: - '8080:8080' @@ -34,5 +33,4 @@ services: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 PXE_URL: http://sandbox:8080 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/e2e_deploy_contract.test.ts} diff --git a/yarn-project/canary/scripts/docker-compose.yml b/yarn-project/canary/scripts/docker-compose.yml index 9839b101560..2a06ec65107 100644 --- a/yarn-project/canary/scripts/docker-compose.yml +++ b/yarn-project/canary/scripts/docker-compose.yml @@ -24,7 +24,6 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: - '8080:8080' @@ -34,5 +33,4 @@ services: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 PXE_URL: http://sandbox:8080 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/uniswap_trade_on_l1_from_l2.test.ts} diff --git a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts index 4b5d5256af6..063485d1ae3 100644 --- a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts @@ -10,8 +10,6 @@ export const MNEMONIC = 'test test test test test test test test test test test const hdAccount = mnemonicToAccount(MNEMONIC); // This tests works on forked mainnet, configured on the CI. const EXPECTED_FORKED_BLOCK = 17514288; -// We tell the archiver to only sync from this block. -process.env.SEARCH_START_BLOCK = EXPECTED_FORKED_BLOCK.toString(); const setupRPC = async (): Promise => { const logger = createDebugLogger('aztec:canary_uniswap'); diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml index 2663326eb1c..5d1e8dbc13b 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml @@ -24,7 +24,6 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: - '8080:8080' @@ -36,7 +35,6 @@ services: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 PXE_URL: http://sandbox:8080 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} entrypoint: ['./scripts/start_e2e_ci_browser.sh', './src/e2e_aztec_js_browser.test.ts'] volumes: - ../log:/usr/src/yarn-project/end-to-end/log:rw diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml index 2cc503da61c..b357f9bef83 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml @@ -24,7 +24,6 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: - '8080:8080' @@ -36,7 +35,6 @@ services: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 PXE_URL: http://sandbox:8080 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/e2e_deploy_contract.test.ts} volumes: - ../log:/usr/src/yarn-project/end-to-end/log:rw diff --git a/yarn-project/end-to-end/scripts/docker-compose.yml b/yarn-project/end-to-end/scripts/docker-compose.yml index eaea6050e00..bd2020709e5 100644 --- a/yarn-project/end-to-end/scripts/docker-compose.yml +++ b/yarn-project/end-to-end/scripts/docker-compose.yml @@ -25,7 +25,6 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/e2e_deploy_contract.test.ts} volumes: - ../log:/usr/src/yarn-project/end-to-end/log:rw diff --git a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts index 7d9c139a6c0..b96cf35b4cd 100644 --- a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts @@ -6,8 +6,6 @@ import { setup as e2eSetup } from './fixtures/utils.js'; const dumpedState = 'src/fixtures/dumps/uniswap_state'; // When taking a dump use the block number of the fork to improve speed. const EXPECTED_FORKED_BLOCK = 0; //17514288; -// We tell the archiver to only sync from this block. -process.env.SEARCH_START_BLOCK = EXPECTED_FORKED_BLOCK.toString(); let teardown: () => Promise;