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

Read-only transaction reporting #1120

Merged
merged 2 commits into from
Jan 25, 2025
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
6 changes: 4 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3078,8 +3078,10 @@ struct controller_impl {
} else {
transaction_receipt_header r;
r.status = transaction_receipt::executed;
r.cpu_usage_us = trx_context.billed_cpu_time_us;
r.net_usage_words = trace->net_usage / 8;
if (!trx->is_read_only()) {
r.cpu_usage_us = trx_context.billed_cpu_time_us;
r.net_usage_words = trace->net_usage / 8;
}
trace->receipt = r;
}

Expand Down
38 changes: 26 additions & 12 deletions programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,20 +679,33 @@ void print_result( const fc::variant& result ) { try {
}

cerr << status << " transaction: " << transaction_id << " ";
if( net < 0 ) {
cerr << "<unknown>";
} else {
cerr << net;
}
cerr << " bytes ";
if( cpu < 0 ) {
cerr << "<unknown>";
if (!tx_read) {
if( net < 0 ) {
cerr << "<unknown>";
} else {
cerr << net;
}
cerr << " bytes ";
if( cpu < 0 ) {
cerr << "<unknown>";
} else {
cerr << cpu;
}
cerr << " us\n";
} else {
cerr << cpu;
int64_t elapsed = -1;
if (processed.get_object().contains( "elapsed" )) {
elapsed = processed["elapsed"].as_int64();
}
cerr << " elapsed ";
if (elapsed < 0) {
cerr << "<unknown>";
} else {
cerr << elapsed;
}
cerr << " us\n";
}

cerr << " us\n";

if( status == "failed" ) {
auto soft_except = processed["except"].as<std::optional<fc::exception>>();
if( soft_except ) {
Expand All @@ -703,7 +716,8 @@ void print_result( const fc::variant& result ) { try {
for( const auto& a : actions ) {
print_action_tree( a );
}
wlog( "\rwarning: transaction executed locally, but may not be confirmed by the network yet" );
if (!tx_read && !tx_dry_run)
wlog( "\rwarning: transaction executed locally, but may not be confirmed by the network yet" );
}
} else {
cerr << fc::json::to_pretty_string( result ) << endl;
Expand Down
Loading