diff --git a/.changeset/fast-actors-allow.md b/.changeset/fast-actors-allow.md new file mode 100644 index 000000000000..f5b7fa39a64b --- /dev/null +++ b/.changeset/fast-actors-allow.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/l2geth': patch +--- + +Fix `eth_getBlockRange` diff --git a/l2geth/internal/ethapi/api.go b/l2geth/internal/ethapi/api.go index 3b191a50c867..a99fc73f7e24 100644 --- a/l2geth/internal/ethapi/api.go +++ b/l2geth/internal/ethapi/api.go @@ -51,8 +51,9 @@ import ( ) var ( - errNoSequencerURL = errors.New("sequencer transaction forwarding not configured") - errStillSyncing = errors.New("sequencer still syncing, cannot accept transactions") + errNoSequencerURL = errors.New("sequencer transaction forwarding not configured") + errStillSyncing = errors.New("sequencer still syncing, cannot accept transactions") + errBlockNotIndexed = errors.New("block in range not indexed, this should never happen") ) const ( @@ -780,9 +781,12 @@ func (s *PublicBlockChainAPI) GetBlockRange(ctx context.Context, startNumber rpc // For each block in range, get block and append to array. for number := startNumber; number <= endNumber; number++ { block, err := s.GetBlockByNumber(ctx, number, fullTx) - if block == nil || err != nil { + if err != nil { return nil, err } + if block == nil { + return nil, errBlockNotIndexed + } blocks = append(blocks, block) } return blocks, nil