From b5df857244c94040a3fb6a0ed7df877c41a5f3a8 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 1 Aug 2023 14:42:00 +0800 Subject: [PATCH 1/2] feat(driver): update `l1Current` check in `ProcessL1Blocks` --- driver/chain_syncer/calldata/syncer.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/driver/chain_syncer/calldata/syncer.go b/driver/chain_syncer/calldata/syncer.go index d76c504bf..e349ca48b 100644 --- a/driver/chain_syncer/calldata/syncer.go +++ b/driver/chain_syncer/calldata/syncer.go @@ -80,19 +80,20 @@ func (s *Syncer) ProcessL1Blocks(ctx context.Context, l1End *types.Header) error s.reorgDetectedFlag = false firstTry = false - startHeight := s.state.GetL1Current().Number + startL1Current := s.state.GetL1Current() // If there is a L1 reorg, sometimes this will happen. - if startHeight.Uint64() >= l1End.Number.Uint64() { - startHeight = new(big.Int).Sub(l1End.Number, common.Big1) - newL1Current, err := s.rpc.L1.HeaderByNumber(ctx, startHeight) + if startL1Current.Number.Uint64() >= l1End.Number.Uint64() && startL1Current.Hash() != l1End.Hash() { + newL1Current, err := s.rpc.L1.HeaderByNumber(ctx, new(big.Int).Sub(l1End.Number, common.Big1)) if err != nil { return err } log.Info( "Reorg detected", - "oldL1Current", s.state.GetL1Current().Number, - "newL1Current", startHeight, + "oldL1CurrentHeight", s.state.GetL1Current().Number, + "oldL1CurrentHash", s.state.GetL1Current().Hash(), + "newL1CurrentHeight", newL1Current.Number, + "newL1CurrentHash", newL1Current.Hash(), "l1Head", l1End.Number, ) @@ -103,7 +104,7 @@ func (s *Syncer) ProcessL1Blocks(ctx context.Context, l1End *types.Header) error iter, err := eventIterator.NewBlockProposedIterator(ctx, &eventIterator.BlockProposedIteratorConfig{ Client: s.rpc.L1, TaikoL1: s.rpc.TaikoL1, - StartHeight: startHeight, + StartHeight: s.state.GetL1Current().Number, EndHeight: l1End.Number, FilterQuery: nil, OnBlockProposedEvent: s.onBlockProposed, From 4e74a31edcf465678620fa1b6aecfdb3c02220d1 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 1 Aug 2023 15:18:50 +0800 Subject: [PATCH 2/2] feat: update ProcessL1Blocks --- driver/chain_syncer/calldata/syncer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/driver/chain_syncer/calldata/syncer.go b/driver/chain_syncer/calldata/syncer.go index e349ca48b..ab45fa7ae 100644 --- a/driver/chain_syncer/calldata/syncer.go +++ b/driver/chain_syncer/calldata/syncer.go @@ -90,8 +90,8 @@ func (s *Syncer) ProcessL1Blocks(ctx context.Context, l1End *types.Header) error log.Info( "Reorg detected", - "oldL1CurrentHeight", s.state.GetL1Current().Number, - "oldL1CurrentHash", s.state.GetL1Current().Hash(), + "oldL1CurrentHeight", startL1Current.Number, + "oldL1CurrentHash", startL1Current.Hash(), "newL1CurrentHeight", newL1Current.Number, "newL1CurrentHash", newL1Current.Hash(), "l1Head", l1End.Number,