This commit is contained in:
Unseen 2026-04-23 21:54:57 -07:00 committed by GitHub
commit 6d485f1b18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 2 additions and 33 deletions

View file

@ -29,7 +29,6 @@ import (
"github.com/ethereum/go-ethereum/consensus/misc/eip4844" "github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/filtermaps" "github.com/ethereum/go-ethereum/core/filtermaps"
"github.com/ethereum/go-ethereum/core/history"
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/txpool" "github.com/ethereum/go-ethereum/core/txpool"
@ -155,11 +154,7 @@ func (b *EthAPIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumbe
if number == rpc.EarliestBlockNumber { if number == rpc.EarliestBlockNumber {
bn = b.HistoryPruningCutoff() bn = b.HistoryPruningCutoff()
} }
block := b.eth.blockchain.GetBlockByNumber(bn) return b.eth.blockchain.GetBlockByNumber(bn), nil
if block == nil && bn < b.HistoryPruningCutoff() {
return nil, &history.PrunedHistoryError{}
}
return block, nil
} }
func (b *EthAPIBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) { func (b *EthAPIBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
@ -167,11 +162,7 @@ func (b *EthAPIBackend) BlockByHash(ctx context.Context, hash common.Hash) (*typ
if number == nil { if number == nil {
return nil, nil return nil, nil
} }
block := b.eth.blockchain.GetBlock(hash, *number) return b.eth.blockchain.GetBlock(hash, *number), nil
if block == nil && *number < b.HistoryPruningCutoff() {
return nil, &history.PrunedHistoryError{}
}
return block, nil
} }
// GetBody returns body of a block. It does not resolve special block numbers. // GetBody returns body of a block. It does not resolve special block numbers.
@ -181,9 +172,6 @@ func (b *EthAPIBackend) GetBody(ctx context.Context, hash common.Hash, number rp
} }
body := b.eth.blockchain.GetBody(hash) body := b.eth.blockchain.GetBody(hash)
if body == nil { if body == nil {
if uint64(number) < b.HistoryPruningCutoff() {
return nil, &history.PrunedHistoryError{}
}
return nil, errors.New("block body not found") return nil, errors.New("block body not found")
} }
return body, nil return body, nil
@ -205,9 +193,6 @@ func (b *EthAPIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash r
} }
block := b.eth.blockchain.GetBlock(hash, header.Number.Uint64()) block := b.eth.blockchain.GetBlock(hash, header.Number.Uint64())
if block == nil { if block == nil {
if header.Number.Uint64() < b.HistoryPruningCutoff() {
return nil, &history.PrunedHistoryError{}
}
return nil, errors.New("header found, but block body is missing") return nil, errors.New("header found, but block body is missing")
} }
return block, nil return block, nil

View file

@ -28,7 +28,6 @@ import (
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/history"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/internal/ethapi" "github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
@ -481,9 +480,6 @@ func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*type
if begin > 0 && end > 0 && begin > end { if begin > 0 && end > 0 && begin > end {
return nil, errInvalidBlockRange return nil, errInvalidBlockRange
} }
if begin >= 0 && begin < int64(api.events.backend.HistoryPruningCutoff()) {
return nil, &history.PrunedHistoryError{}
}
// Construct the range filter // Construct the range filter
filter = api.sys.NewRangeFilter(begin, end, crit.Addresses, crit.Topics, api.rangeLimit) filter = api.sys.NewRangeFilter(begin, end, crit.Addresses, crit.Topics, api.rangeLimit)
} }
@ -536,9 +532,6 @@ func (api *FilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Lo
if f.crit.ToBlock != nil { if f.crit.ToBlock != nil {
end = f.crit.ToBlock.Int64() end = f.crit.ToBlock.Int64()
} }
if begin >= 0 && begin < int64(api.events.backend.HistoryPruningCutoff()) {
return nil, &history.PrunedHistoryError{}
}
// Construct the range filter // Construct the range filter
filter = api.sys.NewRangeFilter(begin, end, f.crit.Addresses, f.crit.Topics, api.rangeLimit) filter = api.sys.NewRangeFilter(begin, end, f.crit.Addresses, f.crit.Topics, api.rangeLimit)
} }

View file

@ -27,7 +27,6 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/filtermaps" "github.com/ethereum/go-ethereum/core/filtermaps"
"github.com/ethereum/go-ethereum/core/history"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
@ -90,9 +89,6 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
if header == nil { if header == nil {
return nil, errUnknownBlock return nil, errUnknownBlock
} }
if header.Number.Uint64() < f.sys.backend.HistoryPruningCutoff() {
return nil, &history.PrunedHistoryError{}
}
return f.blockLogs(ctx, header) return f.blockLogs(ctx, header)
} }

View file

@ -30,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/common/lru"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/filtermaps" "github.com/ethereum/go-ethereum/core/filtermaps"
"github.com/ethereum/go-ethereum/core/history"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
@ -328,10 +327,6 @@ func (es *EventSystem) SubscribeLogs(crit ethereum.FilterQuery, logs chan []*typ
if from == rpc.EarliestBlockNumber { if from == rpc.EarliestBlockNumber {
from = rpc.BlockNumber(es.backend.HistoryPruningCutoff()) from = rpc.BlockNumber(es.backend.HistoryPruningCutoff())
} }
// Queries beyond the pruning cutoff are not supported.
if uint64(from) < es.backend.HistoryPruningCutoff() {
return nil, &history.PrunedHistoryError{}
}
// only interested in new mined logs // only interested in new mined logs
if from == rpc.LatestBlockNumber && to == rpc.LatestBlockNumber { if from == rpc.LatestBlockNumber && to == rpc.LatestBlockNumber {