From 7d91c5a960fda1c1372590176722eba1a0fb3df4 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Tue, 26 Nov 2024 09:40:26 +0530 Subject: [PATCH] fix(precompile-funtoken.go): Fixes a bug where the err != nil check is missing in the bankBalance precompile method (#2116) --- CHANGELOG.md | 4 ++-- evm-e2e/justfile | 3 +++ x/evm/precompile/funtoken.go | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6727ecb2..bf07037ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,12 +101,12 @@ tests for race conditions within funtoken precompile - [#2101](https://github.com/NibiruChain/nibiru/pull/2101) - fix(evm): tx receipt proper marshalling - [#2105](https://github.com/NibiruChain/nibiru/pull/2105) - test(evm): precompile call with revert - [#2106](https://github.com/NibiruChain/nibiru/pull/2106) - chore: scheduled basic e2e tests for evm testnet endpoint -- [#2107](https://github.com/NibiruChain/nibiru/pull/2107) - -feat(evm-funtoken-precompile): Implement methods: balance, bankBalance, whoAmI +- [#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 - [#2110](https://github.com/NibiruChain/nibiru/pull/2110) - fix(evm): Restore StateDB to its state prior to ApplyEvmMsg call to ensure deterministic gas usage. This fixes an issue where the StateDB pointer field in NibiruBankKeeper was being updated during readonly query endpoints like eth_estimateGas, leading to non-deterministic gas usage in subsequent transactions. - [#2111](https://github.com/NibiruChain/nibiru/pull/2111) - fix: e2e-evm-cron.yml - [#2114](https://github.com/NibiruChain/nibiru/pull/2114) - fix(evm): make gas cost zero in conditional bank keeper flow +- [#2116](https://github.com/NibiruChain/nibiru/pull/2116) - fix(precompile-funtoken.go): Fixes a bug where the err != nil check is missing in the bankBalance precompile method #### Nibiru EVM | Before Audit 1 - 2024-10-18 diff --git a/evm-e2e/justfile b/evm-e2e/justfile index ce1a88523..396488f58 100644 --- a/evm-e2e/justfile +++ b/evm-e2e/justfile @@ -23,3 +23,6 @@ test-basic: # Format fmt: npm run format + +gen-types: + npx hardhat typechain diff --git a/x/evm/precompile/funtoken.go b/x/evm/precompile/funtoken.go index 7aa22af09..4407b26d7 100644 --- a/x/evm/precompile/funtoken.go +++ b/x/evm/precompile/funtoken.go @@ -118,6 +118,7 @@ func (p precompileFunToken) sendToBank( erc20, amount, to, err := p.parseArgsSendToBank(args) if err != nil { + err = ErrInvalidArgs(err) return } @@ -376,6 +377,10 @@ func (p precompileFunToken) bankBalance( } addrEth, addrBech32, bankDenom, err := p.parseArgsBankBalance(args) + if err != nil { + err = ErrInvalidArgs(err) + return + } bankBal := p.evmKeeper.Bank.GetBalance(ctx, addrBech32, bankDenom).Amount.BigInt() return method.Outputs.Pack([]any{ @@ -455,7 +460,8 @@ func (p precompileFunToken) whoAmI( addrEth, addrBech32, err := p.parseArgsWhoAmI(args) if err != nil { - return bz, err + err = ErrInvalidArgs(err) + return } return method.Outputs.Pack([]any{