diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index eba02b712c..d1f242d94c 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -361,11 +361,15 @@ func (bc *BlockChain) SubscribeAcceptedTransactionEvent(ch chan<- NewTxsEvent) e } // GetFeeConfigAt returns the fee configuration and the last changed block number at [parent]. +// If Subnet-EVM is not activated, returns default fee config and nil block number. // If FeeManager is activated at [parent], returns the fee config in the precompile contract state. // Otherwise returns the fee config in the chain config. // Assumes that a valid configuration is stored when the precompile is activated. func (bc *BlockChain) GetFeeConfigAt(parent *types.Header) (commontype.FeeConfig, *big.Int, error) { config := bc.Config() + if !config.IsSubnetEVM(parent.Time) { + return params.DefaultFeeConfig, nil, nil + } if !config.IsPrecompileEnabled(feemanager.ContractAddress, parent.Time) { return config.FeeConfig, common.Big0, nil } diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 47ddf2632b..3d8b91e62e 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1818,6 +1818,8 @@ func (pool *LegacyPool) periodicBaseFeeUpdate() { } } +// updateBaseFee updates the base fee in the tx pool based on the current head block. +// should only be called when the chain is in Subnet EVM. func (pool *LegacyPool) updateBaseFee() { pool.mu.Lock() defer pool.mu.Unlock() @@ -1829,6 +1831,7 @@ func (pool *LegacyPool) updateBaseFee() { } // assumes lock is already held +// should only be called when the chain is in Subnet EVM. func (pool *LegacyPool) updateBaseFeeAt(head *types.Header) error { feeConfig, _, err := pool.chain.GetFeeConfigAt(head) if err != nil { diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index 818c4623f1..8b6cc86b55 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -192,12 +192,8 @@ func NewOracle(backend OracleBackend, config Config) (*Oracle, error) { } }() feeConfig, _, err := backend.GetFeeConfigAt(backend.LastAcceptedBlock().Header()) - var minBaseFee *big.Int if err != nil { - // resort back to chain config return nil, fmt.Errorf("failed getting fee config in the oracle: %w", err) - } else { - minBaseFee = feeConfig.MinBaseFee } feeInfoProvider, err := newFeeInfoProvider(backend, minGasUsed.Uint64(), config.Blocks) if err != nil { @@ -206,7 +202,7 @@ func NewOracle(backend OracleBackend, config Config) (*Oracle, error) { return &Oracle{ backend: backend, lastPrice: minPrice, - lastBaseFee: new(big.Int).Set(minBaseFee), + lastBaseFee: new(big.Int).Set(feeConfig.MinBaseFee), minPrice: minPrice, maxPrice: maxPrice, checkBlocks: blocks,