fix(ante): fix reCheckTx gas wanted (#1566)

* fix(abci): fix reCheckTx gas wanted'

* fix(ante): add changelog entry
This commit is contained in:
Tomas Guerra 2022-12-22 05:07:52 -03:00 committed by GitHub
parent 0e366db2e2
commit bd0319760d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -107,7 +107,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (analytics) [#1434](https://github.com/evmos/ethermint/pull/1434) Remove unbound labels from custom tendermint metrics. * (analytics) [#1434](https://github.com/evmos/ethermint/pull/1434) Remove unbound labels from custom tendermint metrics.
* (rpc) [#1484](https://github.com/evmos/ethermint/pull/1484) Align empty account result for old blocks as ethereum instead of return account not found error. * (rpc) [#1484](https://github.com/evmos/ethermint/pull/1484) Align empty account result for old blocks as ethereum instead of return account not found error.
* (rpc) [#1503](https://github.com/evmos/ethermint/pull/1503) Fix block hashes returned on JSON-RPC filter `eth_newBlockFilter`. * (rpc) [#1503](https://github.com/evmos/ethermint/pull/1503) Fix block hashes returned on JSON-RPC filter `eth_newBlockFilter`.
* (ante) [#1566](https://github.com/evmos/ethermint/pull/1566) Fix `gasWanted` on `EthGasConsumeDecorator` ante handler when running transaction in `ReCheckMode`
## [v0.19.3] - 2022-10-14 ## [v0.19.3] - 2022-10-14

View File

@ -135,10 +135,18 @@ func NewEthGasConsumeDecorator(
// - sets the gas meter limit // - sets the gas meter limit
// - gas limit is greater than the block gas meter limit // - gas limit is greater than the block gas meter limit
func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
gasWanted := uint64(0)
// gas consumption limit already checked during CheckTx so there's no need to // gas consumption limit already checked during CheckTx so there's no need to
// verify it again during ReCheckTx // verify it again during ReCheckTx
if ctx.IsReCheckTx() { if ctx.IsReCheckTx() {
return next(ctx, tx, simulate) // Use new context with gasWanted = 0
// Otherwise, there's an error on txmempool.postCheck (tendermint)
// that is not bubbled up. Thus, the Tx never runs on DeliverMode
// Error: "gas wanted -1 is negative"
// For more information, see issue #1554
// https://github.com/evmos/ethermint/issues/1554
newCtx := ctx.WithGasMeter(ethermint.NewInfiniteGasMeterWithLimit(gasWanted))
return next(newCtx, tx, simulate)
} }
chainCfg := egcd.evmKeeper.GetChainConfig(ctx) chainCfg := egcd.evmKeeper.GetChainConfig(ctx)
@ -147,7 +155,6 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
blockHeight := big.NewInt(ctx.BlockHeight()) blockHeight := big.NewInt(ctx.BlockHeight())
homestead := ethCfg.IsHomestead(blockHeight) homestead := ethCfg.IsHomestead(blockHeight)
istanbul := ethCfg.IsIstanbul(blockHeight) istanbul := ethCfg.IsIstanbul(blockHeight)
gasWanted := uint64(0)
var events sdk.Events var events sdk.Events
// Use the lowest priority of all the messages as the final one. // Use the lowest priority of all the messages as the final one.