From e8ae47804d25937befb9294ff05a359fad22bc50 Mon Sep 17 00:00:00 2001 From: Ardit Marku Date: Wed, 6 Nov 2024 13:23:02 +0200 Subject: [PATCH] Set a non-zero BaseFeePerGas on block responses Also update the eth_maxPriorityFeePerGas to return the configured gas price. --- api/api.go | 9 +++++---- tests/web3js/eth_non_interactive_test.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/api.go b/api/api.go index 1c0d84042..e1e61c1fd 100644 --- a/api/api.go +++ b/api/api.go @@ -32,6 +32,8 @@ import ( const maxFeeHistoryBlockCount = 1024 +var baseFeesPerGas = big.NewInt(1) + // A map containing all the valid method names that are found // in the Ethereum JSON-RPC API specification. // Update accordingly if any new methods are added/removed. @@ -937,7 +939,7 @@ func (b *BlockChainAPI) FeeHistory( oldestBlock = (*hexutil.Big)(big.NewInt(int64(block.Height))) } - baseFees = append(baseFees, (*hexutil.Big)(big.NewInt(0))) + baseFees = append(baseFees, (*hexutil.Big)(baseFeesPerGas)) rewards = append(rewards, blockRewards) @@ -1053,7 +1055,7 @@ func (b *BlockChainAPI) prepareBlockResponse( GasLimit: hexutil.Uint64(blockGasLimit), Nonce: types.BlockNonce{0x1}, Timestamp: hexutil.Uint64(block.Timestamp), - BaseFeePerGas: hexutil.Big(*big.NewInt(0)), + BaseFeePerGas: hexutil.Big(*baseFeesPerGas), LogsBloom: types.LogsBloom([]*types.Log{}), Miner: evmTypes.CoinbaseAddress.ToCommon(), Sha3Uncles: types.EmptyUncleHash, @@ -1230,8 +1232,7 @@ func (b *BlockChainAPI) GetUncleByBlockNumberAndIndex( // MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions. func (b *BlockChainAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error) { - fee := hexutil.Big(*big.NewInt(1)) - return &fee, nil + return (*hexutil.Big)(b.config.GasPrice), nil } // Mining returns true if client is actively mining new blocks. diff --git a/tests/web3js/eth_non_interactive_test.js b/tests/web3js/eth_non_interactive_test.js index 2cff8052e..8cde10279 100644 --- a/tests/web3js/eth_non_interactive_test.js +++ b/tests/web3js/eth_non_interactive_test.js @@ -379,7 +379,7 @@ it('get fee history', async () => { { oldestBlock: 1n, reward: [['0x96'], ['0x96'], ['0x96']], // gas price is 150 during testing - baseFeePerGas: [0n, 0n, 0n], + baseFeePerGas: [1n, 1n, 1n], gasUsedRatio: [0, 0, 0.006205458333333334] } )