Skip to content

Commit

Permalink
Merge PR: Improve the accuracy of gas estimation (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
summerpro authored Feb 19, 2021
1 parent b0b27b7 commit 136361d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x/evm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func handleMsgEthereumTx(ctx sdk.Context, k *Keeper, msg types.MsgEthereumTx) (*
k.Bloom.Or(k.Bloom, executionResult.Bloom)

// update transaction logs in KVStore
err = k.SetLogs(ctx, common.BytesToHash(txHash), executionResult.Logs)
err = k.SetLogs(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()), common.BytesToHash(txHash), executionResult.Logs)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -225,7 +225,7 @@ func handleMsgEthermint(ctx sdk.Context, k *Keeper, msg types.MsgEthermint) (*sd
k.Bloom.Or(k.Bloom, executionResult.Bloom)

// update transaction logs in KVStore
err = k.SetLogs(ctx, common.BytesToHash(txHash), executionResult.Logs)
err = k.SetLogs(ctx.WithGasMeter(sdk.NewInfiniteGasMeter()), common.BytesToHash(txHash), executionResult.Logs)
if err != nil {
panic(err)
}
Expand Down
3 changes: 3 additions & 0 deletions x/evm/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,12 @@ func (suite *EvmTestSuite) TestSendTransaction() {
err = tx.Sign(big.NewInt(3), priv.ToECDSA())
suite.Require().NoError(err)

suite.ctx = suite.ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
result, err := suite.handler(suite.ctx, tx)
suite.Require().NoError(err)
suite.Require().NotNil(result)
var expectedGas uint64 = 5387
suite.Require().EqualValues(expectedGas, suite.ctx.GasMeter().GasConsumed())
}

func (suite *EvmTestSuite) TestOutOfGasWhenDeployContract() {
Expand Down

0 comments on commit 136361d

Please sign in to comment.