Skip to content

Commit 59cb712

Browse files
authored
feat: gracefully handle commit/finalize genesis batch event (#383)
1 parent 1146460 commit 59cb712

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

crates/primitives/src/node/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ pub const DEV_SYSTEM_CONTRACT_ADDRESS: Address =
5353
address!("000000000000000000000000000000000003dead");
5454

5555
/// The L1 start block for Mainnet.
56-
pub const MAINNET_L1_START_BLOCK_NUMBER: u64 = 18318215;
56+
pub const MAINNET_L1_START_BLOCK_NUMBER: u64 = 18306000;
5757

5858
/// The L1 start block for Sepolia.
59-
pub const SEPOLIA_L1_START_BLOCK_NUMBER: u64 = 4041343;
59+
pub const SEPOLIA_L1_START_BLOCK_NUMBER: u64 = 4038000;
6060

6161
/// The L1 start block for Devnet.
6262
pub const DEV_L1_START_BLOCK_NUMBER: u64 = 0;

crates/watcher/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,14 @@ where
429429
/// Handles the batch commits events.
430430
#[tracing::instrument(skip_all)]
431431
async fn handle_batch_commits(&self, logs: &[Log]) -> L1WatcherResult<Vec<L1Notification>> {
432-
// filter commit logs.
432+
// filter commit logs and skip genesis batch (batch_index == 0).
433433
let mut commit_logs_with_tx = logs
434434
.iter()
435435
.map(|l| (l, l.transaction_hash))
436436
.filter_map(|(log, tx_hash)| {
437437
let tx_hash = tx_hash?;
438438
try_decode_log::<CommitBatch>(&log.inner)
439+
.filter(|decoded| !decoded.data.batch_index.is_zero())
439440
.map(|decoded| (log, decoded.data, tx_hash))
440441
})
441442
.collect::<Vec<_>>();
@@ -509,11 +510,13 @@ where
509510
&self,
510511
logs: &[Log],
511512
) -> L1WatcherResult<Vec<L1Notification>> {
512-
// filter finalize logs.
513+
// filter finalize logs and skip genesis batch (batch_index == 0).
513514
logs.iter()
514515
.map(|l| (l, l.block_number))
515516
.filter_map(|(log, bn)| {
516-
try_decode_log::<FinalizeBatch>(&log.inner).map(|decoded| (decoded.data, bn))
517+
try_decode_log::<FinalizeBatch>(&log.inner)
518+
.filter(|decoded| !decoded.data.batch_index.is_zero())
519+
.map(|decoded| (decoded.data, bn))
517520
})
518521
.map(|(decoded_log, maybe_block_number)| {
519522
// fetch the finalize transaction.

0 commit comments

Comments
 (0)