More meaningful error message of processBlockBeaconRoot

This commit is contained in:
jangko 2023-10-31 12:54:57 +07:00
parent 5d50bb9a2b
commit 24ba819cd1
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 14 additions and 6 deletions

View File

@ -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()

View File

@ -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()

View File

@ -18,6 +18,9 @@ import
../common/common,
./call_common
export
call_common
type
RpcCallData* = object
source* : Option[EthAddress]