From 9d13a98c22480e3f65498a66178b81cab03e6f8e Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 4 Nov 2024 11:33:45 +0800 Subject: [PATCH] Problem: no trace detail on insufficient balance skip check simple reproduce --- CHANGELOG.md | 1 + .../hardhat/contracts/FeeCollector.sol | 10 +++++ tests/integration_tests/test_tracers.py | 37 ++++++++++++++++++- tests/integration_tests/utils.py | 1 + x/evm/keeper/grpc_query.go | 6 --- 5 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 tests/integration_tests/hardhat/contracts/FeeCollector.sol diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e57d8ded..ab3de97e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (rpc) [#521](https://github.com/crypto-org-chain/ethermint/pull/521) Align hash and miner in subscribe newHeads with eth_getBlockByNumber. * (rpc) [#527](https://github.com/crypto-org-chain/ethermint/pull/527) Fix balance consistency between trace-block and state machine. * (rpc) [#545](https://github.com/crypto-org-chain/ethermint/pull/545) Fix state overwrite in debug trace APIs. +* (rpc) [#554](https://github.com/crypto-org-chain/ethermint/pull/554) No trace detail on insufficient balance. ### Improvements diff --git a/tests/integration_tests/hardhat/contracts/FeeCollector.sol b/tests/integration_tests/hardhat/contracts/FeeCollector.sol new file mode 100644 index 0000000000..71027eed74 --- /dev/null +++ b/tests/integration_tests/hardhat/contracts/FeeCollector.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract FeeCollector { + event TokensMinted(address indexed to, uint256 amount); + + function mint(uint256 amount) public payable { + emit TokensMinted(msg.sender, amount); + } +} diff --git a/tests/integration_tests/test_tracers.py b/tests/integration_tests/test_tracers.py index 9b1281491b..ec82f36a92 100644 --- a/tests/integration_tests/test_tracers.py +++ b/tests/integration_tests/test_tracers.py @@ -19,8 +19,10 @@ deploy_contract, derive_new_account, derive_random_account, + send_raw_transactions, send_transaction, send_txs, + sign_transaction, w3_wait_for_new_blocks, ) @@ -156,6 +158,39 @@ def process(w3): assert res[0] == res[-1], res +def test_trace_tx_reverse_transfer(ethermint): + print("reproduce only") + return + method = "debug_traceTransaction" + tracer = {"tracer": "callTracer"} + acc = derive_new_account(11) + w3 = ethermint.w3 + fund_acc(w3, acc, fund=40000000000000000) + contract, _ = deploy_contract(w3, CONTRACTS["FeeCollector"]) + amt = 18633908679862681 + raw_transactions = [] + nonce = w3.eth.get_transaction_count(acc.address) + tx = contract.functions.mint(amt).build_transaction( + { + "from": acc.address, + "value": hex(amt), + "nonce": nonce, + } + ) + raw_transactions.append(sign_transaction(w3, tx, acc.key).rawTransaction) + tx = tx | {"nonce": nonce + 1} + raw_transactions.append(sign_transaction(w3, tx, acc.key).rawTransaction) + w3_wait_for_new_blocks(w3, 1) + sended_hash_set = send_raw_transactions(w3, raw_transactions) + for h in sended_hash_set: + tx_hash = h.hex() + tx_res = w3.provider.make_request( + method, + [tx_hash, tracer], + ) + print(tx_res) + + def test_tracecall_insufficient_funds(ethermint, geth): method = "debug_traceCall" acc = derive_random_account() @@ -526,7 +561,7 @@ def test_refund_unused_gas_when_contract_tx_reverted_state_overrides(ethermint): "balance": hex(balance), "nonce": hex(nonce), } - } + }, }, ], ) diff --git a/tests/integration_tests/utils.py b/tests/integration_tests/utils.py index 5e51235469..b926e16fd6 100644 --- a/tests/integration_tests/utils.py +++ b/tests/integration_tests/utils.py @@ -41,6 +41,7 @@ "Calculator": "Calculator.sol", "Caller": "Caller.sol", "Random": "Random.sol", + "FeeCollector": "FeeCollector.sol", } diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 1a077fc285..7221f5e5f4 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -712,12 +712,6 @@ func (k *Keeper) prepareTrace( return nil, 0, status.Error(codes.Internal, err.Error()) } - if res.VmError != "" { - if res.VmError == vm.ErrInsufficientBalance.Error() { - return nil, 0, status.Error(codes.Internal, res.VmError) - } - } - var result interface{} result, err = tracer.GetResult() if err != nil {