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

chore: update l2 block addresses #112

Merged
merged 1 commit into from
Aug 1, 2024
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
2 changes: 1 addition & 1 deletion src/processor/snapshot/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
Expand Down
5 changes: 3 additions & 2 deletions src/processor/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions state-reconstruct-fetcher/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
];
}