Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(evm): non-deterministic gas usage #2110

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ tests for race conditions within funtoken precompile
- [#2107](https://github.com/NibiruChain/nibiru/pull/2107) -
feat(evm-funtoken-precompile): Implement methods: balance, bankBalance, whoAmI
- [#2108](https://github.com/NibiruChain/nibiru/pull/2108) - fix(evm): removed deprecated root key from eth_getTransactionReceipt

- [#2108](https://github.com/NibiruChain/nibiru/pull/2110) - fix(evm): get rid of non-deterministic gas usage of NibiruBankKeeper
k-yang marked this conversation as resolved.
Show resolved Hide resolved

#### Nibiru EVM | Before Audit 1 - 2024-10-18

Expand Down
2 changes: 1 addition & 1 deletion x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (k Keeper) EstimateGasForEvmCallType(
return nil, fmt.Errorf("gas required exceeds allowance (%d)", gasCap)
}

return nil, fmt.Errorf("Estimgate gas VMError: %s", result.VmError)
return nil, fmt.Errorf("Estimate gas VMError: %s", result.VmError)
}
}

Expand Down
6 changes: 6 additions & 0 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ func (k *Keeper) ApplyEvmMsg(ctx sdk.Context,
vmErr error // vm errors do not effect consensus and are therefore not assigned to err
)

// save a reference to return to the previous stateDB
oldStateDb := k.Bank.StateDB
defer func() {
k.Bank.StateDB = oldStateDb
}()

stateDB := k.NewStateDB(ctx, txConfig)
evmObj = k.NewEVM(ctx, msg, evmConfig, tracer, stateDB)

Expand Down
Loading