diff --git a/CHANGELOG.md b/CHANGELOG.md index d826053950..58670c60aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,8 +39,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes -- [tharsis#782](https://github.com/tharsis/ethermint/pull/782) web3 rpc api returns wrong block gas limit -- [tharsis#781](https://github.com/tharsis/ethermint/pull/781) fix empty transactions in getBlock +- [tharsis#781](https://github.com/tharsis/ethermint/pull/781) fix empty transactions in getBlock +- [crypto-org-chain/ethermint#15](https://github.com/crypto-org-chain/ethermint/pull/15) web3 rpc api returns wrong block gas limit +- [crypto-org-chain/ethermint#16](https://github.com/crypto-org-chain/ethermint/pull/16) fix unwrap context panic in BlockMaxGasFromConsensusParams ## [v0.7.2-cronos-2] - 2021-11-17 diff --git a/rpc/ethereum/backend/backend.go b/rpc/ethereum/backend/backend.go index 40889e0e75..9c3b98ae8d 100644 --- a/rpc/ethereum/backend/backend.go +++ b/rpc/ethereum/backend/backend.go @@ -337,7 +337,7 @@ func (e *EVMBackend) EthBlockFromTendermint( validatorAddr := common.BytesToAddress(addr) - gasLimit, err := types.BlockMaxGasFromConsensusParams(ctx, e.clientCtx) + gasLimit, err := types.BlockMaxGasFromConsensusParams(ctx, e.clientCtx, &block.Height) if err != nil { e.logger.Error("failed to query consensus params", "error", err.Error()) } diff --git a/rpc/ethereum/types/utils.go b/rpc/ethereum/types/utils.go index d038f5e42c..0909741109 100644 --- a/rpc/ethereum/types/utils.go +++ b/rpc/ethereum/types/utils.go @@ -6,8 +6,6 @@ import ( "fmt" "math/big" - sdk "github.com/cosmos/cosmos-sdk/types" - tmbytes "github.com/tendermint/tendermint/libs/bytes" tmtypes "github.com/tendermint/tendermint/types" @@ -130,11 +128,9 @@ func EthTransactionsFromTendermint(clientCtx client.Context, txs []tmtypes.Tx) ( return transactionHashes, gasUsed, nil } -// BlockMaxGasFromConsensusParams returns the gas limit for the latest block from the chain consensus params. -func BlockMaxGasFromConsensusParams(goCtx context.Context, clientCtx client.Context) (int64, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - blockHeight := ctx.BlockHeight() - resConsParams, err := clientCtx.Client.ConsensusParams(goCtx, &blockHeight) +// BlockMaxGasFromConsensusParams returns the gas limit for the current block from the chain consensus params. +func BlockMaxGasFromConsensusParams(ctx context.Context, clientCtx client.Context, height *int64) (int64, error) { + resConsParams, err := clientCtx.Client.ConsensusParams(ctx, height) if err != nil { return int64(^uint32(0)), err }