You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: get l2 block number from storage write logs (#110)
* feat: get l2 block number from storage write logs
* doc: make comment into code doc
* doc: clarify `l1_batch_number`
* chore: don't panic on missing l2 batch number
* fix: set l1 batch number not l2 batch number
let latest_l1_batch_number = self.database.get_latest_l1_batch_number()?;
41
-
// L1 batch number is calculated from the batch number where the
42
-
// DiamondProxy contract was deployed (`GENESIS_BLOCK`).
43
-
let l1_batch_number = latest_l1_batch_number - GENESIS_BLOCK;
44
-
let l2_batch_number = self.database.get_latest_l2_batch_number()?;
39
+
let l2_batch_number = self
40
+
.database
41
+
.get_latest_l2_batch_number()?
42
+
.ok_or_eyre("no latest l2 batch number in snapshot db")?;
43
+
let l2_block_number = self.database.get_latest_l2_block_number()?.unwrap_or({
44
+
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.");
45
+
U64::from(0)
46
+
});
45
47
letmut header = SnapshotHeader{
46
-
l1_batch_number: l1_batch_number.as_u64(),
47
-
miniblock_number: l2_batch_number.as_u64(),
48
+
// NOTE: `l1_batch_number` in the snapshot header actually refers
49
+
// to the ZKsync batch number and not the Ethereum batch height we
50
+
// store in the snapshot database. In the snapshot database this
0 commit comments