From 226dddf183221b3f7737f5a4b835d13f4b01118b Mon Sep 17 00:00:00 2001 From: Max Revitt Date: Mon, 19 Aug 2024 08:06:41 +0100 Subject: [PATCH] feat(forkid): wait for finalised on l1 closes #849 (#974) --- zk/stages/stage_sequence_execute.go | 7 +++++++ zk/stages/stage_sequence_execute_utils.go | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/zk/stages/stage_sequence_execute.go b/zk/stages/stage_sequence_execute.go index 64f46b3bf35..2aa293410e1 100644 --- a/zk/stages/stage_sequence_execute.go +++ b/zk/stages/stage_sequence_execute.go @@ -56,6 +56,13 @@ func SpawnSequencingStage( return err } + // stage loop should continue until we get the forkid from the L1 in a finalised block + if forkId == 0 { + log.Warn(fmt.Sprintf("[%s] ForkId is 0. Waiting for L1 to finalise a block...", logPrefix)) + time.Sleep(10 * time.Second) + return nil + } + var block *types.Block runLoopBlocks := true batchContext := newBatchContext(ctx, &cfg, &historyCfg, s, sdb) diff --git a/zk/stages/stage_sequence_execute_utils.go b/zk/stages/stage_sequence_execute_utils.go index 40b9697ff3f..a84bc72b3e0 100644 --- a/zk/stages/stage_sequence_execute_utils.go +++ b/zk/stages/stage_sequence_execute_utils.go @@ -188,7 +188,8 @@ func prepareForkId(lastBatch, executionAt uint64, hermezDb forkDb) (uint64, erro } if latest == 0 { - return 0, fmt.Errorf("could not find a suitable fork for batch %v, cannot start sequencer, check contract configuration", lastBatch+1) + // not an error, need to wait for the block to finalize on the L1 + return 0, nil } // now we need to check the last batch to see if we need to update the fork id