Skip to content

Commit 098c255

Browse files
committed
return default fee if not subnet-evm
1 parent 3073c3c commit 098c255

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

core/blockchain_reader.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,15 @@ func (bc *BlockChain) SubscribeAcceptedTransactionEvent(ch chan<- NewTxsEvent) e
361361
}
362362

363363
// GetFeeConfigAt returns the fee configuration and the last changed block number at [parent].
364+
// If Subnet-EVM is not activated, returns default fee config and nil block number.
364365
// If FeeManager is activated at [parent], returns the fee config in the precompile contract state.
365366
// Otherwise returns the fee config in the chain config.
366367
// Assumes that a valid configuration is stored when the precompile is activated.
367368
func (bc *BlockChain) GetFeeConfigAt(parent *types.Header) (commontype.FeeConfig, *big.Int, error) {
368369
config := bc.Config()
370+
if !config.IsSubnetEVM(parent.Time) {
371+
return params.DefaultFeeConfig, nil, nil
372+
}
369373
if !config.IsPrecompileEnabled(feemanager.ContractAddress, parent.Time) {
370374
return config.FeeConfig, common.Big0, nil
371375
}

core/txpool/legacypool/legacypool.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,8 @@ func (pool *LegacyPool) periodicBaseFeeUpdate() {
18181818
}
18191819
}
18201820

1821+
// updateBaseFee updates the base fee in the tx pool based on the current head block.
1822+
// should only be called when the chain is in Subnet EVM.
18211823
func (pool *LegacyPool) updateBaseFee() {
18221824
pool.mu.Lock()
18231825
defer pool.mu.Unlock()
@@ -1829,6 +1831,7 @@ func (pool *LegacyPool) updateBaseFee() {
18291831
}
18301832

18311833
// assumes lock is already held
1834+
// should only be called when the chain is in Subnet EVM.
18321835
func (pool *LegacyPool) updateBaseFeeAt(head *types.Header) error {
18331836
feeConfig, _, err := pool.chain.GetFeeConfigAt(head)
18341837
if err != nil {

eth/gasprice/gasprice.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,8 @@ func NewOracle(backend OracleBackend, config Config) (*Oracle, error) {
192192
}
193193
}()
194194
feeConfig, _, err := backend.GetFeeConfigAt(backend.LastAcceptedBlock().Header())
195-
var minBaseFee *big.Int
196195
if err != nil {
197-
// resort back to chain config
198196
return nil, fmt.Errorf("failed getting fee config in the oracle: %w", err)
199-
} else {
200-
minBaseFee = feeConfig.MinBaseFee
201197
}
202198
feeInfoProvider, err := newFeeInfoProvider(backend, minGasUsed.Uint64(), config.Blocks)
203199
if err != nil {
@@ -206,7 +202,7 @@ func NewOracle(backend OracleBackend, config Config) (*Oracle, error) {
206202
return &Oracle{
207203
backend: backend,
208204
lastPrice: minPrice,
209-
lastBaseFee: new(big.Int).Set(minBaseFee),
205+
lastBaseFee: new(big.Int).Set(feeConfig.MinBaseFee),
210206
minPrice: minPrice,
211207
maxPrice: maxPrice,
212208
checkBlocks: blocks,

0 commit comments

Comments
 (0)