From 0102cce8e8bd0e183b09897625e070bd328771d8 Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Fri, 6 Dec 2024 17:26:34 +0530 Subject: [PATCH] clean up PR --- CHANGELOG.md | 2 +- x/evm/keeper/bank_extension_test.go | 6 +----- x/evm/keeper/msg_server.go | 2 +- x/evm/keeper/statedb.go | 10 ---------- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 001109469..5ee83562c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Nibiru EVM -- [#2xxx](https://github.com/NibiruChain/nibiru/pull/2xxx) - fix(evm): Guarantee +- [#2119](https://github.com/NibiruChain/nibiru/pull/2119) - fix(evm): Guarantee that gas consumed during any send operation of the "NibiruBankKeeper" depends only on the "bankkeeper.BaseKeeper"'s gas consumption. diff --git a/x/evm/keeper/bank_extension_test.go b/x/evm/keeper/bank_extension_test.go index dd15941de..64ae4dea9 100644 --- a/x/evm/keeper/bank_extension_test.go +++ b/x/evm/keeper/bank_extension_test.go @@ -11,11 +11,6 @@ import ( "github.com/NibiruChain/nibiru/v2/x/evm/evmtest" ) -// TODO: UD-DEBUG: -// non-nil StaetDB bank send and record gas consumed -// nil StaetDB bank send and record gas consumed -// Both should be equal. - // TestGasConsumedInvariantSend: The "NibiruBankKeeper" is defined such that // send operations are meant to have consistent gas consumption regardless of the // whether the active "StateDB" instance is defined or undefined (nil). This is @@ -214,6 +209,7 @@ func (f FunctionalGasConsumedInvariantScenario) Run(s *Suite) { ) } +// See [Suite.TestGasConsumedInvariantSend]. func (s *Suite) TestGasConsumedInvariantOther() { to := evmtest.NewEthPrivAcc() // arbitrary constant bankDenom := evm.EVMBankDenom diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 96e6616a8..e1d9dccb7 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -269,7 +269,7 @@ func (k *Keeper) ApplyEvmMsg(ctx sdk.Context, ) defer func() { - if commit && err == nil && !resp.Failed() { + if commit && err == nil && resp != nil && !resp.Failed() { k.Bank.StateDB = stateDB } else { k.Bank.StateDB = oldStateDB diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index 0396f19d9..b85a595a5 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -184,16 +184,6 @@ func (k *Keeper) DeleteAccount(ctx sdk.Context, addr gethcommon.Address) error { return nil } -func GaslessOperation(ctx sdk.Context, op func(ctx sdk.Context)) { - gasMeterBeforeOp := ctx.GasMeter() - defer func() { - ctx = ctx.WithGasMeter(gasMeterBeforeOp) - }() - - freeGasCtx := ctx.WithGasMeter(sdk.NewGasMeter(gasMeterBeforeOp.Limit())) - op(freeGasCtx) -} - // GetAccountWithoutBalance load nonce and codehash without balance, // more efficient in cases where balance is not needed. func (k *Keeper) GetAccountWithoutBalance(ctx sdk.Context, addr gethcommon.Address) *statedb.Account {