-
Notifications
You must be signed in to change notification settings - Fork 19
[2.0] print inline evm tx error in hex #841
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
Changes from 5 commits
9b3b3b4
5268417
0b249cd
bf060d8
eed5db9
ae13760
8b07fdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,7 +264,8 @@ Receipt evm_contract::execute_tx(const runtime_config& rc, eosio::name miner, Bl | |
| check_result( r, tx, "validate_transaction error" ); | ||
|
|
||
| Receipt receipt; | ||
| const auto res = ep.execute_transaction(tx, receipt, gas_params); | ||
| CallResult call_result; | ||
| const auto res = ep.execute_transaction(tx, receipt, gas_params, call_result); | ||
|
|
||
| // Calculate the miner portion of the actual gas fee (if necessary): | ||
| std::optional<intx::uint256> gas_fee_miner_portion; | ||
|
|
@@ -287,8 +288,30 @@ Receipt evm_contract::execute_tx(const runtime_config& rc, eosio::name miner, Bl | |
| } | ||
| } | ||
|
|
||
| if (rc.abort_on_failure) | ||
| eosio::check(receipt.success, "tx executed inline by contract must succeed"); | ||
| if (rc.abort_on_failure) { | ||
| if (receipt.success == false) { | ||
| size_t size = (int)call_result.data.length(); | ||
| constexpr size_t max_print_size = 292;/*max printable solidity error msg size=224*/ | ||
| std::string errmsg; | ||
| errmsg.reserve(1024); | ||
| errmsg += "inline evm tx failed, evmc_status_code:"; | ||
| errmsg += std::to_string((int)call_result.status); | ||
| errmsg += ", data:["; | ||
| errmsg += std::to_string(size); | ||
| errmsg += "]"; | ||
| size_t i = 0; | ||
| for (; i < max_print_size && i < size; ++i ) { | ||
|
||
| static const char hex_chars[] = "0123456789ABCDEF"; | ||
| errmsg += " "; | ||
|
||
| errmsg += hex_chars[((uint8_t)call_result.data[i]) >> 4]; | ||
| errmsg += hex_chars[((uint8_t)call_result.data[i]) & 0xf]; | ||
| } | ||
| if (i < size) { | ||
| errmsg += "..."; | ||
| } | ||
| eosio::check(false, errmsg); | ||
| } | ||
| } | ||
|
|
||
| if(!ep.state().reserved_objects().empty()) { | ||
| intx::uint256 total_egress; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does the 292 come from?