Skip to content

Commit

Permalink
Fix syncMonitor's BlockMetadataByNumber response for arb classic bloc…
Browse files Browse the repository at this point in the history
…k numbers
  • Loading branch information
ganeshvanahalli committed Feb 11, 2025
1 parent c7fc9d4 commit 2d943af
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions execution/gethexec/sync_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/execution"
)

Expand Down Expand Up @@ -127,12 +128,13 @@ func (s *SyncMonitor) SetConsensusInfo(consensus execution.ConsensusInfo) {
}

func (s *SyncMonitor) BlockMetadataByNumber(blockNum uint64) (common.BlockMetadata, error) {
count, err := s.exec.BlockNumberToMessageIndex(blockNum)
if err != nil {
return nil, err
genesis := s.exec.GetGenesisBlockNumber()
if blockNum < genesis { // Arbitrum classic block
return nil, nil
}
pos := arbutil.MessageIndex(blockNum - genesis)
if s.consensus != nil {
return s.consensus.BlockMetadataAtCount(count + 1)
return s.consensus.BlockMetadataAtCount(pos + 1)
}
log.Debug("FullConsensusClient is not accessible to execution, BlockMetadataByNumber will return nil")
return nil, nil
Expand Down

0 comments on commit 2d943af

Please sign in to comment.