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

rpcdaemon: fix in ots_getTransactionError #2034

Merged
merged 2 commits into from
May 24, 2024
Merged
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
29 changes: 20 additions & 9 deletions silkworm/rpc/core/evm_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,8 @@ Task<TraceEntriesResult> TraceCallExecutor::trace_transaction_entries(const Tran
}

Task<std::string> TraceCallExecutor::trace_transaction_error(const TransactionWithBlock& transaction_with_block) {
auto block_number = transaction_with_block.block_with_hash->block.header.number;
const auto& block = transaction_with_block.block_with_hash->block;
const auto block_number = block.header.number;

const auto chain_config_ptr = co_await chain_storage_.read_chain_config();
ensure(chain_config_ptr.has_value(), "cannot read chain config");
Expand All @@ -1488,15 +1489,25 @@ Task<std::string> TraceCallExecutor::trace_transaction_error(const TransactionWi
auto curr_state = tx_.create_state(current_executor, database_reader_, chain_storage_, block_number - 1);
EVMExecutor executor{*chain_config_ptr, workers_, curr_state};
Tracers tracers{};

const auto execution_result = executor.call(transaction_with_block.block_with_hash->block,
transaction_with_block.transaction,
tracers,
/*refund=*/true, /*gas_bailout=*/true);

bool found = false;
ExecutionResult execution_result{};

for (size_t idx = 0; idx < block.transactions.size(); idx++) {
const auto& txn = block.transactions.at(idx);
execution_result = executor.call(block, txn, tracers, /*refund=*/true, /*gas_bailout=*/false);
if (transaction_with_block.transaction.transaction_index == idx) {
found = true;
break;
}
}
std::string result = "0x";
if (execution_result.error_code != evmc_status_code::EVMC_SUCCESS) {
result = "0x" + silkworm::to_hex(execution_result.data);
if (found) {
if (execution_result.error_code != evmc_status_code::EVMC_SUCCESS) {
result = "0x" + silkworm::to_hex(execution_result.data);
}
return result;
} else {
SILK_ERROR << "trace_transaction_error: transaction idx: " << transaction_with_block.transaction.transaction_index << " not found";
}
return result;
});
Expand Down
Loading