Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try using parent.GasLimit in plugin/evm/header #1472

Draft
wants to merge 15 commits into
base: merge-coreth-master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
return default fee if not subnet-evm
ceyonur committed Feb 28, 2025
commit 098c2552077f4a779bd1b04cb92695ae09f3f52a
4 changes: 4 additions & 0 deletions core/blockchain_reader.go
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
@@ -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 {
6 changes: 1 addition & 5 deletions eth/gasprice/gasprice.go
Original file line number Diff line number Diff line change
@@ -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,