soroban-cli
soroban-cli copied to clipboard
CLI: inconsistencies in logging results and events from invocations
Expected behavior when invoking a contract using soroban contract invoke
(for all cases: sandbox or network, success or failure):
- Contract events should be logged at INFO level
- Diagnostic events should be logged at DEBUG level (requiring the --verbose flag)
- Return value should be printed to stdout (Error values to stderr, maybe?)
Current behavior:
- Sandbox success: All events, diagnostic included, are logged at INFO level. Result printed to stdout.
- Sandbox error: No events, not diagnostic nor contract, are logged. Error value printed to stdout
- Network success: Events appear twice (kinda) in a less friendly format. First lumped together as simulatedEvents at DEBUG level. Again after the transaction result, but that appears to only be the first event, at DEBUG level. Result printed to stdout.
- Network error (in preflight): All events printed to stdout. Error value is not printed at all, but a cryptic stack trace is printed to stdout:
Backtrace (newest first):
0: soroban_env_host::host::frame::<impl soroban_env_host::host::Host>::call_n_internal
1: soroban_env_host::host::frame::<impl soroban_env_host::host::Host>::invoke_function
2: preflight::preflight_invoke_hf_op::{{closure}}
3: preflight::catch_preflight_panic
4: _cgo_a3255893d7fd_Cfunc_preflight_invoke_hf_op
at tmp/go-build/cgo-gcc-prolog:99:11
5: runtime.asmcgocall
at ./runtime/asm_amd64.s:848
On top of that, panics are not displayed anymore (I'm fairly certain they were before an upgrade, I'll try to spin older testnet during the weekend to confirm).
Simple token transfer which should panic when insufficient balance returns only InternalError
:
https://github.com/stellar/soroban-examples/blob/bddac245ed6f3ae660f011a16133167d38ecfbd2/token/src/balance.rs#L30-L35
$ soroban contract deploy \
--wasm soroban_token_contract.wasm \
--source alice \
--network futurenet
CBGQEK2B7NZSM6UVCQCYQMGETKJU5UWPMUX3UB5JSVU6GYGGTLDAS6H5
// (...) initialized and minted 10k tokens
$ soroban contract invoke \
--id CBGQEK2B7NZSM6UVCQCYQMGETKJU5UWPMUX3UB5JSVU6GYGGTLDAS6H5 \
--source alice \
--network futurenet \
-- balance --id $(soroban config identity address alice)
"10000"
$ soroban contract invoke \
> --id CBGQEK2B7NZSM6UVCQCYQMGETKJU5UWPMUX3UB5JSVU6GYGGTLDAS6H5 \
--source alice \
--network futurenet \
-- \
transfer --from $(soroban config identity address alice) --to $(soroban config identity address bob) --amount 10001 # more then balance
error: transaction simulation failed: HostError: Error(WasmVm, InternalError)
DebugInfo not available
Even --very-verbose
mode doesn't display anything useful.
Playing with official test lumen token:
soroban contract invoke \
--id CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT \
--source alice \
--network futurenet \
-- balance --id $(soroban config identity address alice)
"99996626629"
$ soroban contract invoke \
--id CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT \
--source alice \
--network futurenet \
-- transfer --from $(soroban config identity address alice) --to $(soroban config identity address bob) --amount 99996626630 # one more then balance
error: transaction simulation failed: HostError: Error(Value, InvalidInput)
DebugInfo not available
So official token at least returns an InvalidInput
error (still not precise...)