Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fb84a68
systemcontracts: apply baseFee from policy contract for burning
chenquanyu May 24, 2024
1799246
add log for baseFee and minGasTipCap
chenquanyu May 31, 2024
0dff337
reuse state in worker
chenquanyu May 31, 2024
fe076a0
rename neoxburn to neoXBurn
chenquanyu May 31, 2024
9c95808
move basefee check to VerifyBlock
chenquanyu Jun 11, 2024
311f60f
t8ntool: properly handle BaseFee set in the env config
AnnaShaleva Jun 14, 2024
922b774
consensus: squash VerifyEIP1559Header and VerifyEIP1559HeaderDBFT
AnnaShaleva Jun 14, 2024
ce0c073
core: adjust the documentation
AnnaShaleva Jun 14, 2024
e427cda
gasprice: cache BaseFee and MinGasTipCap inside Oracle service
AnnaShaleva Jun 14, 2024
e8ef782
ethapi: add BaseFee cache
AnnaShaleva Jun 18, 2024
1d2c47d
privnet: enable NeoXBurn hardfork from genesis
AnnaShaleva Jun 26, 2024
f005f6b
eth: remove useless comment
AnnaShaleva Jun 26, 2024
2016088
gasprice: return in case of nil block
AnnaShaleva Jun 26, 2024
8e44e1d
filters: properly process nil current block on pending txs retrieval
AnnaShaleva Jun 26, 2024
5a90cd9
t8ntool: get back the baseFee setter for London
AnnaShaleva Jun 26, 2024
5f8252e
gasprice: do not keep Oracle's lastBaseFee and lastMinGasTip empty
AnnaShaleva Jun 26, 2024
47d2712
gasprice: move policy-based minGasPrice retrieval our of NeoXBurn
AnnaShaleva Jul 2, 2024
97a454b
t8ntool: extend the list of valid forks with NeoXBurn
AnnaShaleva Jul 5, 2024
458efcb
eth: return Policy's minGasTipCap from suggestTipCap
AnnaShaleva Jul 8, 2024
1636589
Merge pull request #230 from bane-labs/adjust-basefee
AnnaShaleva Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/systemcontracts"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -156,9 +157,12 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
GasLimit: pre.Env.GasLimit,
GetHash: getHash,
}
// If currentBaseFee is defined, add it to the vmContext.
// If currentBaseFee is defined, add it to the vmContext and to the state DB.
if pre.Env.BaseFee != nil {
vmContext.BaseFee = new(big.Int).Set(pre.Env.BaseFee)
if chainConfig.IsNeoXBurn(vmContext.BlockNumber, vmContext.Time) {
statedb.SetState(systemcontracts.PolicyProxyHash, systemcontracts.GetBaseFeeStateHash(), common.BigToHash(pre.Env.BaseFee))
}
}
// If random is defined, add it to the vmContext.
if pre.Env.Random != nil {
Expand Down
14 changes: 14 additions & 0 deletions cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func Transition(ctx *cli.Context) error {
if err := applyLondonChecks(&prestate.Env, chainConfig); err != nil {
return err
}
if err := applyNeoXBurnChecks(&prestate.Env, chainConfig); err != nil {
return err
}
if err := applyShanghaiChecks(&prestate.Env, chainConfig); err != nil {
return err
}
Expand All @@ -194,6 +197,17 @@ func Transition(ctx *cli.Context) error {
return dispatchOutput(ctx, baseDir, result, collector, body)
}

func applyNeoXBurnChecks(env *stEnv, chainConfig *params.ChainConfig) error {
if !chainConfig.IsNeoXBurn(big.NewInt(int64(env.Number)), env.Timestamp) {
return nil
}
// Sanity check, to not `panic` in state_transition
if env.BaseFee == nil {
return NewError(ErrorConfig, errors.New("NeoXBurn config but missing 'currentBaseFee' in env section"))
}
return nil
}

func applyLondonChecks(env *stEnv, chainConfig *params.ChainConfig) error {
if !chainConfig.IsLondon(big.NewInt(int64(env.Number))) {
return nil
Expand Down
2 changes: 1 addition & 1 deletion consensus/dbft/chainreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ChainHeaderReader interface {
HasBlock(hash common.Hash, number uint64) bool
GetBlockByNumber(uint64) *types.Block
VerifyBlock(block *types.Block) (*state.StateDB, types.Receipts, error)
ProcessState(block *types.Block) (*state.StateDB, types.Receipts, []*types.Log, uint64, error)
ProcessState(block *types.Block, statedb *state.StateDB) (*state.StateDB, types.Receipts, []*types.Log, uint64, error)
}

// ChainHeaderWriter is a Blockchain API abstraction needed for proper blockQueue
Expand Down
2 changes: 1 addition & 1 deletion consensus/dbft/dbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func New(config *params.DBFTConfig, _ ethdb.Database) (*DBFT, error) {
dbftBlock.transactions = c.sealingTransactions
ethBlock := dbftBlock.ToEthBlock()

state, _, _, _, err := c.chain.ProcessState(ethBlock)
state, _, _, _, err := c.chain.ProcessState(ethBlock, nil)
if err != nil {
log.Crit("failed to process state from proposal",
"err", err,
Expand Down
16 changes: 16 additions & 0 deletions consensus/misc/eip1559/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/systemcontracts"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
)
Expand All @@ -44,6 +46,11 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
if header.BaseFee == nil {
return errors.New("header is missing baseFee")
}
// For NeoXBurn block BaseFee verification is performed by consensus nodes and hence
// not included into the state-independent ordinary block verification rules.
if config.IsNeoXBurn(parent.Number, parent.Time) {
return nil
}
// Verify the baseFee is correct based on the parent header.
expectedBaseFee := CalcBaseFee(config, parent)
if header.BaseFee.Cmp(expectedBaseFee) != 0 {
Expand Down Expand Up @@ -93,3 +100,12 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
return math.BigMax(baseFee, common.Big0)
}
}

// CalcBaseFeeDBFT calculates the basefee of the header.
// if is neoXBurn fork, get basefee from Policy contract.
func CalcBaseFeeDBFT(config *params.ChainConfig, parent *types.Header, state *state.StateDB) *big.Int {
if !config.IsNeoXBurn(parent.Number, parent.Time) {
return CalcBaseFee(config, parent)
}
return state.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetBaseFeeStateHash()).Big()
}
38 changes: 31 additions & 7 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/common/prque"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
Expand Down Expand Up @@ -2452,23 +2453,35 @@ func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
return time.Duration(bc.flushInterval.Load())
}

// ProcessState processes the state changes according to the Ethereum rules by running
// the transaction messages using the statedb and applying any rewards to both
// the processor (coinbase) and any included uncles. It doesn't persist any data.
func (bc *BlockChain) ProcessState(block *types.Block) (*state.StateDB, types.Receipts, []*types.Log, uint64, error) {
// getParentState retrieves statedb and parent header by hash or block number
func (bc *BlockChain) getParentState(block *types.Block) (*state.StateDB, *types.Header, error) {
parent := bc.GetBlockByHash(block.ParentHash())
if parent == nil {
log.Error("failed to retrieve parent by hash to process block state",
"parent number", block.NumberU64()-1,
"parent hash", block.ParentHash().String())
parent = bc.GetBlockByNumber(block.NumberU64() - 1)
if parent == nil {
return nil, nil, nil, 0, fmt.Errorf("failed to retrieve canonical parent by number to process block state (number %d, hash %s)", block.NumberU64()-1, block.ParentHash().String())
return nil, nil, fmt.Errorf("failed to retrieve canonical parent by number to process block state (number %d, hash %s)", block.NumberU64()-1, block.ParentHash().String())
}
}
statedb, err := bc.StateAt(parent.Root())
if err != nil {
return nil, nil, nil, 0, fmt.Errorf("failed to retrieve state at %d, %s: %w", parent.NumberU64(), parent.Root(), err)
return nil, parent.Header(), fmt.Errorf("failed to retrieve state at %d, %s: %w", parent.NumberU64(), parent.Root(), err)
}
return statedb, parent.Header(), nil
}

// ProcessState processes the state changes according to the Ethereum rules by running
// the transaction messages using the statedb (if given) and applying any rewards to both
// the processor (coinbase) and any included uncles. It doesn't persist any data.
func (bc *BlockChain) ProcessState(block *types.Block, statedb *state.StateDB) (*state.StateDB, types.Receipts, []*types.Log, uint64, error) {
var err error
if statedb == nil {
statedb, _, err = bc.getParentState(block)
if err != nil {
return nil, nil, nil, 0, err
}
}

receipts, logs, usedGas, err := bc.processor.Process(block, statedb, bc.vmConfig)
Expand All @@ -2485,7 +2498,18 @@ func (bc *BlockChain) VerifyBlock(block *types.Block) (*state.StateDB, types.Rec
return nil, nil, fmt.Errorf("failed to validate body: %w", err)
}

statedb, receipts, _, usedGas, err := bc.ProcessState(block)
statedb, parentHeader, err := bc.getParentState(block)
if err != nil {
return nil, nil, err
}

// verify baseFee
baseFee := eip1559.CalcBaseFeeDBFT(bc.chainConfig, parentHeader, statedb)
if block.BaseFee().Cmp(baseFee) != 0 {
return nil, nil, fmt.Errorf("failed to verify policy baseFee, expected: %v, current: %v", baseFee, block.BaseFee())
}

statedb, receipts, _, usedGas, err := bc.ProcessState(block, statedb)
if err != nil {
return nil, nil, fmt.Errorf("failed to process block state: %w", err)
}
Expand Down
17 changes: 10 additions & 7 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,6 @@ func (st *StateTransition) preCheck() error {
return fmt.Errorf("%w: address %v, codehash: %s", ErrSenderNoEOA,
msg.From.Hex(), codeHash)
}
// Ensure the transaction is allowed by policy
// Apply policy minimum gas tip cap
var minGasTipCap = st.state.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetMinGasTipCapStateHash())
if msg.GasTipCap.Cmp(minGasTipCap.Big()) < 0 {
return fmt.Errorf("%w: address %v, gastipcap %v", ErrUnderpriced,
msg.From.Hex(), msg.GasTipCap)
}
// Apply policy blacklist
var blocked = st.state.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetBlackListStateHash(msg.From))
if blocked != (common.Hash{}) {
Expand Down Expand Up @@ -331,6 +324,16 @@ func (st *StateTransition) preCheck() error {
return fmt.Errorf("%w: address %v, maxFeePerGas: %s, baseFee: %s", ErrFeeCapTooLow,
msg.From.Hex(), msg.GasFeeCap, st.evm.Context.BaseFee)
}
// Ensure the transaction is allowed by policy, only for neoXBurn fork
if st.evm.ChainConfig().IsNeoXBurn(st.evm.Context.BlockNumber, st.evm.Context.Time) {
// Apply policy minimum gas tip cap
// For LegacyTx, GasFeeCap and GasPrice are equal, so checking GasTipCap and GasFeeCap is enough
var minGasTipCap = st.state.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetMinGasTipCapStateHash()).Big()
if cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)).Cmp(minGasTipCap) < 0 {
return fmt.Errorf("%w: address %v, gasTipCap %v, gasFeeCap %v, policy minGasTipCap %v, baseFee %v ", ErrUnderpriced,
msg.From.Hex(), msg.GasTipCap, msg.GasFeeCap, minGasTipCap, st.evm.Context.BaseFee)
}
}
}
}
// Check the blob version validity
Expand Down
4 changes: 2 additions & 2 deletions core/txpool/blobpool/blobpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (p *BlobPool) Init(gasTip *big.Int, head *types.Header, reserve txpool.Addr
p.recheck(addr, nil)
}
var (
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head))
basefee = uint256.MustFromBig(eip1559.CalcBaseFeeDBFT(p.chain.Config(), p.head, p.state))
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
)
if p.head.ExcessBlobGas != nil {
Expand Down Expand Up @@ -782,7 +782,7 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) {
}
// Reset the price heap for the new set of basefee/blobfee pairs
var (
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), newHead))
basefee = uint256.MustFromBig(eip1559.CalcBaseFeeDBFT(p.chain.Config(), newHead, p.state))
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
)
if newHead.ExcessBlobGas != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
pool.demoteUnexecutables()
if reset.newHead != nil {
if pool.chainconfig.IsLondon(new(big.Int).Add(reset.newHead.Number, big.NewInt(1))) {
pendingBaseFee := eip1559.CalcBaseFee(pool.chainconfig, reset.newHead)
pendingBaseFee := eip1559.CalcBaseFeeDBFT(pool.chainconfig, reset.newHead, pool.currentState)
pool.priced.SetBaseFee(pendingBaseFee)
} else {
pool.priced.Reheap()
Expand Down
10 changes: 7 additions & 3 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/systemcontracts"
Expand Down Expand Up @@ -203,9 +204,12 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
}
// Ensure the transaction is allowed by policy
// Apply policy minimum gas tip cap
var minGasTipCap = opts.State.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetMinGasTipCapStateHash())
if tx.GasTipCap().Cmp(minGasTipCap.Big()) < 0 {
return fmt.Errorf("%w: policy needed %v, tip permitted %v", ErrUnderpriced, minGasTipCap.Big(), tx.GasTipCap())
// For LegacyTx, GasFeeCap and GasPrice are equal, so checking GasTipCap and GasFeeCap is enough
var minGasTipCap = opts.State.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetMinGasTipCapStateHash()).Big()
var baseFee = opts.State.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetBaseFeeStateHash()).Big()
if math.BigMin(tx.GasTipCap(), new(big.Int).Sub(tx.GasFeeCap(), baseFee)).Cmp(minGasTipCap) < 0 {
return fmt.Errorf("%w: policy minGasTipCap needed %v, baseFee needed %v, gasTipCap %v, gasFeeCap %v ",
ErrUnderpriced, minGasTipCap, baseFee, tx.GasTipCap(), tx.GasFeeCap())
}
// Apply policy blacklist
var blocked = opts.State.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetBlackListStateHash(from))
Expand Down
12 changes: 4 additions & 8 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
cmath "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/bloombits"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/systemcontracts"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
Expand Down Expand Up @@ -365,16 +363,14 @@ func (b *EthAPIBackend) SyncProgress() ethereum.SyncProgress {
}

func (b *EthAPIBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
suggestTipCap, err := b.gpo.SuggestTipCap(ctx)
suggestTipCap, minGasTipCap, err := b.gpo.SuggestTipCap(ctx)
if err != nil {
return nil, err
}
stateDb, _, err := b.StateAndHeaderByNumber(ctx, rpc.LatestBlockNumber)
if err != nil {
return nil, err
if minGasTipCap != nil && minGasTipCap.Sign() > 0 {
return minGasTipCap, nil
}
minGasTipCap := stateDb.GetState(systemcontracts.PolicyProxyHash, systemcontracts.GetMinGasTipCapStateHash()).Big()
return cmath.BigMax(suggestTipCap, minGasTipCap), nil
return suggestTipCap, nil
}

func (b *EthAPIBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (firstBlock *big.Int, reward [][]*big.Int, baseFee []*big.Int, gasUsedRatio []float64, err error) {
Expand Down
34 changes: 31 additions & 3 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
)

Expand Down Expand Up @@ -162,16 +164,33 @@ func (api *FilterAPI) NewPendingTransactions(ctx context.Context, fullTx *bool)
defer pendingTxSub.Unsubscribe()

chainConfig := api.sys.backend.ChainConfig()
currHeader := api.sys.backend.CurrentHeader()
state, _, err := api.sys.backend.StateAndHeaderByNumber(context.Background(), rpc.BlockNumber(currHeader.Number.Int64()))
if err != nil {
log.Error("Failed to get state to handle pending transactions", "err", err, "header number", currHeader.Number)
return
}
baseFee := eip1559.CalcBaseFeeDBFT(chainConfig, currHeader, state)

for {
select {
case txs := <-txs:
// Update base fee cache only if new block is available.
if latestHeader := api.sys.backend.CurrentHeader(); latestHeader.Number.Cmp(currHeader.Number) > 0 {
currHeader = latestHeader
state, _, err = api.sys.backend.StateAndHeaderByNumber(context.Background(), rpc.BlockNumber(currHeader.Number.Int64()))
if err != nil {
// We're toast, use the old base fee value.
log.Error("Failed to get state to handle pending transactions", "err", err, "header number", currHeader.Number)
} else {
baseFee = eip1559.CalcBaseFeeDBFT(chainConfig, currHeader, state)
}
}
// To keep the original behaviour, send a single tx hash in one notification.
// TODO(rjl493456442) Send a batch of tx hashes in one notification
latest := api.sys.backend.CurrentHeader()
for _, tx := range txs {
if fullTx != nil && *fullTx {
rpcTx := ethapi.NewRPCPendingTransaction(tx, latest, chainConfig)
rpcTx := ethapi.NewRPCPendingTransaction(tx, currHeader, chainConfig, baseFee)
notifier.Notify(rpcSub.ID, rpcTx)
} else {
notifier.Notify(rpcSub.ID, tx.Hash())
Expand Down Expand Up @@ -446,8 +465,17 @@ func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
case PendingTransactionsSubscription:
if f.fullTx {
txs := make([]*ethapi.RPCTransaction, 0, len(f.txs))
var baseFee *big.Int
if latest != nil {
state, _, err := api.sys.backend.StateAndHeaderByNumber(context.Background(), rpc.BlockNumber(latest.Number.Int64()))
if err != nil {
log.Error("Failed to get state to retrieve filter changes", "err", err, "header number", latest.Number)
return txs, err
}
baseFee = eip1559.CalcBaseFeeDBFT(chainConfig, latest, state)
}
for _, tx := range f.txs {
txs = append(txs, ethapi.NewRPCPendingTransaction(tx, latest, chainConfig))
txs = append(txs, ethapi.NewRPCPendingTransaction(tx, latest, chainConfig, baseFee))
}
f.txs = nil
return txs, nil
Expand Down
3 changes: 3 additions & 0 deletions eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/bloombits"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
Expand Down Expand Up @@ -74,6 +75,8 @@ type Backend interface {

BloomStatus() (uint64, uint64)
ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)

StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)
}

// FilterSystem holds resources shared by all filters.
Expand Down
6 changes: 6 additions & 0 deletions eth/filters/filter_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/bloombits"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
Expand Down Expand Up @@ -180,6 +181,11 @@ func (b *testBackend) ServiceFilter(ctx context.Context, session *bloombits.Matc
}()
}

func (b *testBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error) {
header, err := b.HeaderByNumber(ctx, number)
return nil, header, err
}

func newTestFilterSystem(t testing.TB, db ethdb.Database, cfg Config) (*testBackend, *FilterSystem) {
backend := &testBackend{db: db}
sys := NewFilterSystem(backend, cfg)
Expand Down
Loading