Skip to content

Conversation

@linh2931
Copy link
Contributor

@linh2931 linh2931 commented Jul 11, 2025

Add cleos support to display call traces and console logs.

Please note: in dev-preview-2, expand_console() will be combined with the one in trace.cpp class.

Resolves #1628

An example cleos session looks like

./cleos push action caller addaction '[10, 20]' -p caller@active
executed transaction: 7845a14b0cb16071f858c65a5dc7ebee104e26a27b4b1e1e4cfc4b098fbc0ead  104 bytes  682 us
#                   caller <= caller::addaction         {"x":10,"y":20}
#              callee::add <= caller                    {"x":10,"y":20}
=>                                return value: 30

CONSOLE OUTPUT BEGIN =====================
before add()
[caller->(callee,add)]: CALL BEGIN ======
inside add()
[caller->(callee,add)]: CALL END   ======
after add()
CONSOLE OUTPUT END   =====================
warn  2025-07-11T13:04:52.128 cleos     main.cpp:935                  print_result        warning: transaction executed locally, but may not be confirmed by the network yet

The addaction action is

[[eosio::action]]
void addaction(uint32_t x, uint32_t y) {
   sync_callee::add_func add{ "callee"_n };
   eosio::print("before add()");
   eosio::check(add(x, y) == x + y, "x + y was not correct");
   eosio::print("after add()");
}

The add sync call function is

[[eosio::call]]
uint32_t sync_callee::add(uint32_t x, uint32_t y) {
   eosio::print("inside add()");
   return x + y;
}

@linh2931 linh2931 requested review from heifner and spoonincode July 11, 2025 02:38
@linh2931 linh2931 linked an issue Jul 11, 2025 that may be closed by this pull request
@linh2931 linh2931 marked this pull request as draft July 11, 2025 11:22
@linh2931 linh2931 marked this pull request as ready for review July 11, 2025 13:29
Base automatically changed from long_names to sync_call July 14, 2025 17:38
@linh2931 linh2931 merged commit 8f38931 into sync_call Jul 14, 2025
28 checks passed
@linh2931 linh2931 deleted the cleos_support branch July 14, 2025 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SC: Cleos support for Sync Calls

4 participants