From 334a9cf222ff1b8717c5364b6902cbd78cfcefeb Mon Sep 17 00:00:00 2001 From: zeapoz Date: Thu, 1 Aug 2024 15:07:32 +0200 Subject: [PATCH] chore: update l2 block addresses --- src/processor/snapshot/exporter.rs | 2 +- src/processor/snapshot/mod.rs | 5 +++-- state-reconstruct-fetcher/src/constants.rs | 9 ++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/processor/snapshot/exporter.rs b/src/processor/snapshot/exporter.rs index 6654690..a37ab82 100644 --- a/src/processor/snapshot/exporter.rs +++ b/src/processor/snapshot/exporter.rs @@ -40,7 +40,7 @@ impl SnapshotExporter { .database .get_latest_l1_batch_number()? .ok_or_eyre("no latest l1 batch number in snapshot db")?; - let l2_block_number = self.database.get_latest_l2_block_number()?.unwrap_or({ + let l2_block_number = self.database.get_latest_l2_block_number()?.unwrap_or_else(|| { tracing::warn!("WARNING: the database contains no l2 block number entry and will not be compatible with the ZKSync External Node! To export a compatible snapshot, please let the prepare-snapshot command run until an l2 block number can be found."); U64::from(0) }); diff --git a/src/processor/snapshot/mod.rs b/src/processor/snapshot/mod.rs index f016926..07c2943 100644 --- a/src/processor/snapshot/mod.rs +++ b/src/processor/snapshot/mod.rs @@ -10,7 +10,7 @@ use blake2::{Blake2s256, Digest}; use ethers::types::{Address, H256, U256, U64}; use eyre::Result; use state_reconstruct_fetcher::{ - constants::{ethereum, storage, zksync::L2_BLOCK_NUMBER_ADDRESS}, + constants::{ethereum, storage, zksync::L2_BLOCK_NUMBER_ADDRESSES}, types::CommitBlock, }; use state_reconstruct_storage::{ @@ -97,7 +97,8 @@ impl Processor for SnapshotBuilder { .expect("failed to get key from database"); // We make sure to track writes to the L2 block number address. - if hex::encode(key) == L2_BLOCK_NUMBER_ADDRESS { + let hex_key = hex::encode(key); + if L2_BLOCK_NUMBER_ADDRESSES.contains(&hex_key.as_ref()) { let (block_number, _timestamp) = unpack_block_info(h256_to_u256(value)); self.database .set_latest_l2_block_number(block_number) diff --git a/state-reconstruct-fetcher/src/constants.rs b/state-reconstruct-fetcher/src/constants.rs index 057b814..a002edb 100644 --- a/state-reconstruct-fetcher/src/constants.rs +++ b/state-reconstruct-fetcher/src/constants.rs @@ -41,7 +41,10 @@ pub mod zksync { /// The number of trailing bytes to ignore when using calldata post-blobs. Contains unused blob commitments. pub const CALLDATA_SOURCE_TAIL_SIZE: usize = 32; - /// The storage address where the latest L2 block number is written to. - pub const L2_BLOCK_NUMBER_ADDRESS: &str = - "5e5a67d1b864c576f39bb2b77c6537744c0f03515abce63b473bb7c56ad07d8e"; + /// NOTE: There could be more but this covers a good chunk. + /// The storage addresses where the latest L2 block number is written to. + pub const L2_BLOCK_NUMBER_ADDRESSES: [&str; 2] = [ + "5e5a67d1b864c576f39bb2b77c6537744c0f03515abce63b473bb7c56ad07d8e", + "ecfc4e86b2e01c263feada4f8f53d2dab45c66b0f4d1d7ab0f2f8ec32f207c48", + ]; }