From 24ba819cd18dcd2c3902478ce1eb1753e2255e26 Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 31 Oct 2023 12:54:57 +0700 Subject: [PATCH] More meaningful error message of processBlockBeaconRoot --- nimbus/core/executor/process_transaction.nim | 5 +++-- nimbus/transaction/call_common.nim | 12 ++++++++---- nimbus/transaction/call_evm.nim | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/nimbus/core/executor/process_transaction.nim b/nimbus/core/executor/process_transaction.nim index 65acd71dc..a1537aab6 100644 --- a/nimbus/core/executor/process_transaction.nim +++ b/nimbus/core/executor/process_transaction.nim @@ -156,8 +156,9 @@ proc processBeaconBlockRoot*(vmState: BaseVMState, beaconRoot: Hash256): ) # runComputation a.k.a syscall/evm.call - if call.runComputation().isError: - return err("processBeaconBlockRoot: syscall error") + let res = call.runComputation() + if res.isError: + return err("processBeaconBlockRoot: " & res.error) statedb.persist(clearEmptyAccount = true, clearCache = false) ok() diff --git a/nimbus/transaction/call_common.nim b/nimbus/transaction/call_common.nim index 8c680109e..2cda33525 100644 --- a/nimbus/transaction/call_common.nim +++ b/nimbus/transaction/call_common.nim @@ -47,7 +47,7 @@ type # Standard call result. (Some fields are beyond what EVMC can return, # and must only be used from tests because they will not always be set). CallResult* = object - isError*: bool # True if the call failed. + error*: string # Something if the call failed. gasUsed*: GasInt # Gas used by the call. contractAddress*: EthAddress # Created account (when `isCreate`). output*: seq[byte] # Output data. @@ -55,6 +55,9 @@ type stack*: Stack # EVM stack on return (for test only). memory*: Memory # EVM memory on return (for test only). +func isError*(cr: CallResult): bool = + cr.error.len > 0 + proc hostToComputationMessage*(msg: EvmcMessage): Message = Message( kind: CallKind(msg.kind.ord), @@ -182,7 +185,7 @@ proc setupHost(call: CallParams): TransactionHost = let cMsg = hostToComputationMessage(host.msg) host.computation = newComputation(vmState, call.sysCall, cMsg, code) - shallowCopy(host.code, code) + host.code = system.move(code) else: if call.input.len > 0: @@ -284,9 +287,10 @@ proc finishRunningComputation(host: TransactionHost, call: CallParams): CallResu let gasUsed = host.msg.gas - gasRemaining host.vmState.captureEnd(c, c.output, gasUsed, c.errorOpt) - result.isError = c.isError + if c.isError: + result.error = c.error.info result.gasUsed = call.gasLimit - gasRemaining - shallowCopy(result.output, c.output) + result.output = system.move(c.output) result.contractAddress = if call.isCreate: c.msg.contractAddress else: default(HostAddress) result.logEntries = host.vmState.stateDB.logEntries() diff --git a/nimbus/transaction/call_evm.nim b/nimbus/transaction/call_evm.nim index 60efa60bf..6e86669af 100644 --- a/nimbus/transaction/call_evm.nim +++ b/nimbus/transaction/call_evm.nim @@ -18,6 +18,9 @@ import ../common/common, ./call_common +export + call_common + type RpcCallData* = object source* : Option[EthAddress]