EVMC: Using `{.show.}` trace all calls from the host into the EVM
Show calls from the host into the EVM. Shows the call, `evmc_message` fields, and `evmc_result` fields when the call returns. (When `show_tx_calls` is manually set to true.) Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
ffd34a69fe
commit
a5dc0bd283
|
@ -90,7 +90,8 @@ proc evmc_create_nimbus_evm(): ptr evmc_vm {.cdecl, importc.}
|
|||
# a separate library yet.
|
||||
import ./evmc_vm_glue
|
||||
|
||||
proc evmcExecComputation*(host: TransactionHost): EvmcResult =
|
||||
# This must be named `call` to show as "call" when traced by the `show` macro.
|
||||
proc call(host: TransactionHost): EvmcResult {.show, inline.} =
|
||||
let vm = evmc_create_nimbus_evm()
|
||||
if vm.isNil:
|
||||
echo "Warning: No EVM"
|
||||
|
@ -121,3 +122,6 @@ proc evmcExecComputation*(host: TransactionHost): EvmcResult =
|
|||
evmc_revision(host.vmState.fork), host.msg,
|
||||
if host.code.len > 0: host.code[0].unsafeAddr else: nil,
|
||||
host.code.len.csize_t)
|
||||
|
||||
proc evmcExecComputation*(host: TransactionHost): EvmcResult =
|
||||
call(host)
|
||||
|
|
|
@ -18,6 +18,7 @@ func `$`(address: HostAddress): string = toHex(address)
|
|||
func `$`(txc: EvmcTxContext): string = &"gas_price={txc.tx_gas_price.fromEvmc}"
|
||||
func `$`(n: typeof(EvmcMessage().sender)): string = $n.fromEvmc
|
||||
func `$`(n: typeof(EvmcMessage().value)): string = $n.fromEvmc
|
||||
func `$`(host: TransactionHost): string = &"(fork={host.vmState.fork} message=${host.msg})"
|
||||
|
||||
macro show*(fn: untyped): auto =
|
||||
if not show_tx_calls:
|
||||
|
|
Loading…
Reference in New Issue