Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

feat(driver): update l1Current check in ProcessL1Blocks #340

Merged
merged 4 commits into from
Aug 1, 2023
Merged
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
15 changes: 8 additions & 7 deletions driver/chain_syncer/calldata/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

cyberhorsey marked this conversation as resolved.
Show resolved Hide resolved
log.Info(
"Reorg detected",
"oldL1Current", s.state.GetL1Current().Number,
"newL1Current", startHeight,
"oldL1CurrentHeight", startL1Current.Number,
"oldL1CurrentHash", startL1Current.Hash(),
"newL1CurrentHeight", newL1Current.Number,
"newL1CurrentHash", newL1Current.Hash(),
"l1Head", l1End.Number,
)

Expand All @@ -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,
Expand Down