Commit 0eaae3bf authored by Joshua Gutow's avatar Joshua Gutow Committed by GitHub

op-node: Remove BlockIDRange (#3640)

This function was not being used and could be safely removed.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 1bcd11e9
......@@ -2,7 +2,6 @@ package sources
import (
"context"
"errors"
"fmt"
"github.com/ethereum-optimism/optimism/op-node/client"
......@@ -248,53 +247,6 @@ func (s *EthClient) Fetch(ctx context.Context, blockHash common.Hash) (eth.Block
return info, txs, r, nil
}
// BlockIDRange returns a range of block IDs from the provided begin up to max blocks after the begin.
// This batch-requests all blocks by number in the range at once, and then verifies the consistency
func (s *EthClient) BlockIDRange(ctx context.Context, begin eth.BlockID, max uint64) ([]eth.BlockID, error) {
headerRequests := make([]rpc.BatchElem, max)
for i := uint64(0); i < max; i++ {
headerRequests[i] = rpc.BatchElem{
Method: "eth_getBlockByNumber",
Args: []interface{}{hexutil.EncodeUint64(begin.Number + 1 + i), false},
Result: new(*rpcHeader),
Error: nil,
}
}
if err := s.client.BatchCallContext(ctx, headerRequests); err != nil {
return nil, err
}
out := make([]eth.BlockID, 0, max)
// try to cache everything we have before halting on the results with errors
for i := 0; i < len(headerRequests); i++ {
result := *headerRequests[i].Result.(**rpcHeader)
if headerRequests[i].Error == nil {
if result == nil {
break // no more headers from here
}
info, err := result.Info(s.trustRPC, s.mustBePostMerge)
if err != nil {
return nil, fmt.Errorf("bad header data for block %s: %w", headerRequests[i].Args[0], err)
}
s.headersCache.Add(info.Hash(), info)
out = append(out, info.ID())
prev := begin
if i > 0 {
prev = out[i-1]
}
if prev.Hash != info.ParentHash() {
return nil, fmt.Errorf("inconsistent results from L1 chain range request, block %s not expected parent %s of %s", prev, info.ParentHash(), info.ID())
}
} else if errors.Is(headerRequests[i].Error, ethereum.NotFound) {
break // no more headers from here
} else {
return nil, fmt.Errorf("failed to retrieve block: %s: %w", headerRequests[i].Args[0], headerRequests[i].Error)
}
}
return out, nil
}
func (s *EthClient) GetProof(ctx context.Context, address common.Address, blockTag string) (*eth.AccountResult, error) {
var getProofResponse *eth.AccountResult
err := s.client.CallContext(ctx, &getProofResponse, "eth_getProof", address, []common.Hash{}, blockTag)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment