Skip to content

Commit

Permalink
Problem: no trace detail on insufficient balance
Browse files Browse the repository at this point in the history
skip check

simple reproduce
  • Loading branch information
mmsqe committed Nov 8, 2024
1 parent 1e621c7 commit 9d13a98
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions tests/integration_tests/hardhat/contracts/FeeCollector.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
37 changes: 36 additions & 1 deletion tests/integration_tests/test_tracers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -526,7 +561,7 @@ def test_refund_unused_gas_when_contract_tx_reverted_state_overrides(ethermint):
"balance": hex(balance),
"nonce": hex(nonce),
}
}
},
},
],
)
Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"Calculator": "Calculator.sol",
"Caller": "Caller.sol",
"Random": "Random.sol",
"FeeCollector": "FeeCollector.sol",
}


Expand Down
6 changes: 0 additions & 6 deletions x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9d13a98

Please sign in to comment.