Skip to content

Commit a0620f1

Browse files
authored
eth: fix calls to HistoryPruningCutoff (#31552)
These were caused by crossed merges of recent PRs #31414 and #31361
1 parent db9be56 commit a0620f1

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

eth/api_backend.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (b *EthAPIBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumb
9494
}
9595
var bn uint64
9696
if number == rpc.EarliestBlockNumber {
97-
bn = b.eth.blockchain.HistoryPruningCutoff()
97+
bn = b.HistoryPruningCutoff()
9898
} else {
9999
bn = uint64(number)
100100
}
@@ -152,10 +152,10 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe
152152
}
153153
bn := uint64(number) // the resolved number
154154
if number == rpc.EarliestBlockNumber {
155-
bn = b.eth.blockchain.HistoryPruningCutoff()
155+
bn = b.HistoryPruningCutoff()
156156
}
157157
block := b.eth.blockchain.GetBlockByNumber(bn)
158-
if block == nil && bn < b.eth.blockchain.HistoryPruningCutoff() {
158+
if block == nil && bn < b.HistoryPruningCutoff() {
159159
return nil, &ethconfig.PrunedHistoryError{}
160160
}
161161
return block, nil
@@ -167,7 +167,7 @@ func (b *EthAPIBackend) BlockByHash(ctx context.Context, hash common.Hash) (*typ
167167
return nil, nil
168168
}
169169
block := b.eth.blockchain.GetBlock(hash, *number)
170-
if block == nil && *number < b.eth.blockchain.HistoryPruningCutoff() {
170+
if block == nil && *number < b.HistoryPruningCutoff() {
171171
return nil, &ethconfig.PrunedHistoryError{}
172172
}
173173
return block, nil
@@ -180,7 +180,7 @@ func (b *EthAPIBackend) GetBody(ctx context.Context, hash common.Hash, number rp
180180
}
181181
body := b.eth.blockchain.GetBody(hash)
182182
if body == nil {
183-
if uint64(number) < b.eth.blockchain.HistoryPruningCutoff() {
183+
if uint64(number) < b.HistoryPruningCutoff() {
184184
return nil, &ethconfig.PrunedHistoryError{}
185185
}
186186
return nil, errors.New("block body not found")
@@ -202,7 +202,7 @@ func (b *EthAPIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash r
202202
}
203203
block := b.eth.blockchain.GetBlock(hash, header.Number.Uint64())
204204
if block == nil {
205-
if header.Number.Uint64() < b.eth.blockchain.HistoryPruningCutoff() {
205+
if header.Number.Uint64() < b.HistoryPruningCutoff() {
206206
return nil, &ethconfig.PrunedHistoryError{}
207207
}
208208
return nil, errors.New("header found, but block body is missing")
@@ -265,7 +265,8 @@ func (b *EthAPIBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockN
265265
}
266266

267267
func (b *EthAPIBackend) HistoryPruningCutoff() uint64 {
268-
return b.eth.blockchain.HistoryPruningCutoff()
268+
bn, _ := b.eth.blockchain.HistoryPruningCutoff()
269+
return bn
269270
}
270271

271272
func (b *EthAPIBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {

internal/ethapi/api_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,10 @@ func (b testBackend) NewMatcherBackend() filtermaps.MatcherBackend {
623623
panic("implement me")
624624
}
625625

626-
func (b testBackend) HistoryPruningCutoff() uint64 { return b.chain.HistoryPruningCutoff() }
626+
func (b testBackend) HistoryPruningCutoff() uint64 {
627+
bn, _ := b.chain.HistoryPruningCutoff()
628+
return bn
629+
}
627630

628631
func TestEstimateGas(t *testing.T) {
629632
t.Parallel()

0 commit comments

Comments
 (0)