Skip to content

Commit

Permalink
l2geth: fix eth_getBlockRange (ethereum-optimism#2390)
Browse files Browse the repository at this point in the history
  • Loading branch information
tynes committed May 2, 2022
1 parent cc0594c commit 1bcee8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-actors-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/l2geth': patch
---

Fix `eth_getBlockRange`
10 changes: 7 additions & 3 deletions l2geth/internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1bcee8f

Please sign in to comment.