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

fix(driver): fix a potential error which will happen when restarting a node #88

Merged
merged 3 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions driver/chain_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,16 @@ func (s *L2ChainSyncer) AheadOfProtocolVerifiedHead() bool {
// NewPayloadV1.
verifiedHeightToCompare -= 1
}
return (s.state.GetL2Head().Number.Uint64() >= verifiedHeightToCompare) &&
(s.state.GetL2Head().Number.Uint64() >= s.syncProgressTracker.LastSyncedVerifiedBlockHeight().Uint64())

if s.state.GetL2Head().Number.Uint64() < verifiedHeightToCompare {
return false
}

if s.syncProgressTracker.LastSyncedVerifiedBlockHeight() != nil {
return s.state.GetL2Head().Number.Uint64() >= s.syncProgressTracker.LastSyncedVerifiedBlockHeight().Uint64()
}

return true
}

// ProcessL1Blocks fetches all `TaikoL1.BlockProposed` events between given
Expand Down
8 changes: 8 additions & 0 deletions driver/sync_progress_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ func (s *BeaconSyncProgressTracker) LastSyncedVerifiedBlockID() *big.Int {
s.mutex.RLock()
defer s.mutex.RUnlock()

if s.lastSyncedVerifiedBlockID == nil {
return nil
}

return new(big.Int).Set(s.lastSyncedVerifiedBlockID)
}

Expand All @@ -199,6 +203,10 @@ func (s *BeaconSyncProgressTracker) LastSyncedVerifiedBlockHeight() *big.Int {
s.mutex.RLock()
defer s.mutex.RUnlock()

if s.lastSyncedVerifiedBlockHeight == nil {
return nil
}

return new(big.Int).Set(s.lastSyncedVerifiedBlockHeight)
}

Expand Down