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

Problem: no trace detail on insufficient balance #554

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (cli) [#537](https://github.com/crypto-org-chain/ethermint/pull/537) Fix unsuppored sign mode SIGN_MODE_TEXTUAL for bank transfer.
* (cli) [#543](https://github.com/crypto-org-chain/ethermint/pull/543) Fix graceful shutdown.
* (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 @@
assert res[0] == res[-1], res


def test_trace_tx_reverse_transfer(ethermint):
print("reproduce only")
return
method = "debug_traceTransaction"

Check warning

Code scanning / CodeQL

Unreachable code Warning test

This statement is unreachable.
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 @@ -540,7 +575,7 @@
"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 @@ -44,6 +44,7 @@
"Caller": "Caller.sol",
"Random": "Random.sol",
"TestBlockTxProperties": "TestBlockTxProperties.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 @@ -728,12 +728,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
Loading