Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

* (rpc) [#963](https://github.com/crypto-org-chain/ethermint/pull/963) fix(rpc): align eth_feeHistory response with execution-apis spec.
* (ante) [#948](https://github.com/crypto-org-chain/ethermint/pull/948) fix(ante): enforce eip-1559 cost balance check even if it is not checkTx.
* (evm) [#948](https://github.com/crypto-org-chain/ethermint/pull/948) fix(evm): fix SetCodeTx nil pointer panics, missing AuthList in Copy.
* (evm) [#951](https://github.com/crypto-org-chain/ethermint/pull/951) chore(evm): preallocate slices in AccessList conversion functions.
Expand Down
16 changes: 12 additions & 4 deletions rpc/backend/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (b *Backend) FeeHistory(
}
maxBlockCount := int64(b.cfg.JSONRPC.FeeHistoryCap)
if blocks > maxBlockCount {
return nil, fmt.Errorf("FeeHistory user block count %d higher than %d", blocks, maxBlockCount)
blocks = maxBlockCount
Comment thread
songgaoye marked this conversation as resolved.
}
if blockEnd < math.MaxInt64 && blockEnd+1 < blocks {
blocks = blockEnd + 1
Expand Down Expand Up @@ -317,10 +317,18 @@ func (b *Backend) FeeHistory(
}
}

thisBlobBaseFee := make([]*hexutil.Big, blocks+1)
Comment thread
songgaoye marked this conversation as resolved.
for i := range thisBlobBaseFee {
thisBlobBaseFee[i] = (*hexutil.Big)(new(big.Int))
}
thisBlobGasUsedRatio := make([]float64, blocks)

feeHistory := rpctypes.FeeHistoryResult{
OldestBlock: oldestBlock,
BaseFee: thisBaseFee,
GasUsedRatio: thisGasUsedRatio,
OldestBlock: oldestBlock,
BaseFee: thisBaseFee,
GasUsedRatio: thisGasUsedRatio,
BlobBaseFee: thisBlobBaseFee,
BlobGasUsedRatio: thisBlobGasUsedRatio,
}

if calculateRewards {
Expand Down
43 changes: 28 additions & 15 deletions rpc/backend/chain_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (suite *BackendTestSuite) TestFeeHistory() {
nil,
},
{
"fail - user block count higher than max block count ",
"pass - user block count higher than max block count is silently capped",
func(validator sdk.AccAddress) {
var header metadata.MD
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
Expand All @@ -356,9 +356,16 @@ func (suite *BackendTestSuite) TestFeeHistory() {
},
1,
-1,
&rpc.FeeHistoryResult{
OldestBlock: (*hexutil.Big)(big.NewInt(2)),
BaseFee: []*hexutil.Big{nil},
GasUsedRatio: []float64{},
Reward: [][]*hexutil.Big{},
BlobBaseFee: []*hexutil.Big{(*hexutil.Big)(new(big.Int))},
BlobGasUsedRatio: []float64{},
},
nil,
nil,
false,
true,
nil,
},
{
Expand Down Expand Up @@ -433,10 +440,12 @@ func (suite *BackendTestSuite) TestFeeHistory() {
1,
1,
&rpc.FeeHistoryResult{
OldestBlock: (*hexutil.Big)(big.NewInt(1)),
BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(new(big.Int).SetBits([]big.Word{}))},
GasUsedRatio: []float64{0},
Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}},
OldestBlock: (*hexutil.Big)(big.NewInt(1)),
BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(new(big.Int).SetBits([]big.Word{}))},
GasUsedRatio: []float64{0},
Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}},
BlobBaseFee: []*hexutil.Big{(*hexutil.Big)(new(big.Int)), (*hexutil.Big)(new(big.Int))},
BlobGasUsedRatio: []float64{0},
},
sdk.AccAddress(tests.GenerateAddress().Bytes()),
true,
Expand All @@ -463,10 +472,12 @@ func (suite *BackendTestSuite) TestFeeHistory() {
1,
1,
&rpc.FeeHistoryResult{
OldestBlock: (*hexutil.Big)(big.NewInt(1)),
BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(1)), (*hexutil.Big)(big.NewInt(1))},
GasUsedRatio: []float64{0},
Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}},
OldestBlock: (*hexutil.Big)(big.NewInt(1)),
BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(1)), (*hexutil.Big)(big.NewInt(1))},
GasUsedRatio: []float64{0},
Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}},
BlobBaseFee: []*hexutil.Big{(*hexutil.Big)(new(big.Int)), (*hexutil.Big)(new(big.Int))},
BlobGasUsedRatio: []float64{0},
},
sdk.AccAddress(tests.GenerateAddress().Bytes()),
true,
Expand All @@ -493,10 +504,12 @@ func (suite *BackendTestSuite) TestFeeHistory() {
1,
1,
&rpc.FeeHistoryResult{
OldestBlock: (*hexutil.Big)(big.NewInt(1)),
BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(1)), (*hexutil.Big)(big.NewInt(0))},
GasUsedRatio: []float64{0},
Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}},
OldestBlock: (*hexutil.Big)(big.NewInt(1)),
BaseFee: []*hexutil.Big{(*hexutil.Big)(big.NewInt(1)), (*hexutil.Big)(big.NewInt(0))},
GasUsedRatio: []float64{0},
Reward: [][]*hexutil.Big{{(*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0)), (*hexutil.Big)(big.NewInt(0))}},
BlobBaseFee: []*hexutil.Big{(*hexutil.Big)(new(big.Int)), (*hexutil.Big)(new(big.Int))},
BlobGasUsedRatio: []float64{0},
},
sdk.AccAddress(tests.GenerateAddress().Bytes()),
true,
Expand Down
10 changes: 6 additions & 4 deletions rpc/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ type OverrideAccount struct {
}

type FeeHistoryResult struct {
OldestBlock *hexutil.Big `json:"oldestBlock"`
Reward [][]*hexutil.Big `json:"reward,omitempty"`
BaseFee []*hexutil.Big `json:"baseFeePerGas,omitempty"`
GasUsedRatio []float64 `json:"gasUsedRatio"`
OldestBlock *hexutil.Big `json:"oldestBlock"`
Reward [][]*hexutil.Big `json:"reward,omitempty"`
BaseFee []*hexutil.Big `json:"baseFeePerGas,omitempty"`
GasUsedRatio []float64 `json:"gasUsedRatio"`
BlobBaseFee []*hexutil.Big `json:"baseFeePerBlobGas,omitempty"`
BlobGasUsedRatio []float64 `json:"blobGasUsedRatio,omitempty"`
Comment thread
songgaoye marked this conversation as resolved.
Outdated
}

// SignTransactionResult represents a RLP encoded signed transaction.
Expand Down
Loading