From cc0cfbf8ccc3a4f80e25cff5b66f44c321b8469b Mon Sep 17 00:00:00 2001 From: Thomas Nguy Date: Thu, 25 Nov 2021 15:35:51 +0900 Subject: [PATCH 1/3] fix BlockMaxGasFromConsensusParams --- rpc/ethereum/backend/backend.go | 2 +- rpc/ethereum/types/utils.go | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) 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..862ad745a7 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" @@ -131,10 +129,8 @@ func EthTransactionsFromTendermint(clientCtx client.Context, txs []tmtypes.Tx) ( } // 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) +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 } From 51d37fa353e1cba814543e423c8d62aff2178a39 Mon Sep 17 00:00:00 2001 From: Thomas Nguy Date: Thu, 25 Nov 2021 16:05:27 +0900 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 From 000b5778d389fef195f8fdccd0ef392d71723f52 Mon Sep 17 00:00:00 2001 From: Thomas Nguy Date: Thu, 25 Nov 2021 16:06:42 +0900 Subject: [PATCH 3/3] update comment --- rpc/ethereum/types/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/ethereum/types/utils.go b/rpc/ethereum/types/utils.go index 862ad745a7..0909741109 100644 --- a/rpc/ethereum/types/utils.go +++ b/rpc/ethereum/types/utils.go @@ -128,7 +128,7 @@ 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. +// 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 {