diff --git a/rpc/ethereum/backend/backend.go b/rpc/ethereum/backend/backend.go index a1ab9854..d2b91815 100644 --- a/rpc/ethereum/backend/backend.go +++ b/rpc/ethereum/backend/backend.go @@ -238,9 +238,8 @@ func (e *EVMBackend) EthBlockFromTendermint( ctx := types.ContextWithHeight(block.Height) - bfRes, err := e.queryClient.FeeMarket.BaseFee(ctx, &feemarkettypes.QueryBaseFeeRequest{}) + baseFee, err := e.BaseFee() if err != nil { - e.logger.Debug("failed to base fee", "height", block.Height, "error", err.Error()) return nil, err } @@ -270,7 +269,7 @@ func (e *EVMBackend) EthBlockFromTendermint( common.BytesToHash(block.Hash()), uint64(block.Height), uint64(i), - bfRes.BaseFee.BigInt(), + baseFee, ) if err != nil { e.logger.Debug("NewTransactionFromData for receipt failed", "hash", tx.Hash().Hex(), "error", err.Error()) @@ -327,7 +326,7 @@ func (e *EVMBackend) EthBlockFromTendermint( formattedBlock := types.FormatBlock( block.Header, block.Size(), gasLimit, new(big.Int).SetUint64(gasUsed), - ethRPCTxs, bloom, validatorAddr, bfRes.BaseFee.BigInt(), + ethRPCTxs, bloom, validatorAddr, baseFee, ) return formattedBlock, nil } diff --git a/x/evm/types/dynamic_fee_tx.go b/x/evm/types/dynamic_fee_tx.go index 34ddbc18..9609c109 100644 --- a/x/evm/types/dynamic_fee_tx.go +++ b/x/evm/types/dynamic_fee_tx.go @@ -5,8 +5,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/tharsis/ethermint/types" ) @@ -228,12 +230,12 @@ func (tx DynamicFeeTx) Validate() error { return nil } -// Fee panics as it requires the base fee amount to calculate +// Fee returns gasprice * gaslimit. func (tx DynamicFeeTx) Fee() *big.Int { - panic("fee can only be called manually by providing the base fee") + return fee(tx.GetGasPrice(), tx.GasLimit) } // Cost returns amount + gasprice * gaslimit. func (tx DynamicFeeTx) Cost() *big.Int { - panic("cost can only be called manually by providing the base fee") + return cost(tx.Fee(), tx.GetValue()) }