From 2d943af3b22787641e231aef87c9f807fcd339d0 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Tue, 11 Feb 2025 18:03:19 +0530 Subject: [PATCH] Fix syncMonitor's BlockMetadataByNumber response for arb classic block numbers --- execution/gethexec/sync_monitor.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/execution/gethexec/sync_monitor.go b/execution/gethexec/sync_monitor.go index 07c05351d1..744aa14acd 100644 --- a/execution/gethexec/sync_monitor.go +++ b/execution/gethexec/sync_monitor.go @@ -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" ) @@ -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