More meaningful error message of processBlockBeaconRoot
This commit is contained in:
parent
5d50bb9a2b
commit
24ba819cd1
|
@ -156,8 +156,9 @@ proc processBeaconBlockRoot*(vmState: BaseVMState, beaconRoot: Hash256):
|
||||||
)
|
)
|
||||||
|
|
||||||
# runComputation a.k.a syscall/evm.call
|
# runComputation a.k.a syscall/evm.call
|
||||||
if call.runComputation().isError:
|
let res = call.runComputation()
|
||||||
return err("processBeaconBlockRoot: syscall error")
|
if res.isError:
|
||||||
|
return err("processBeaconBlockRoot: " & res.error)
|
||||||
|
|
||||||
statedb.persist(clearEmptyAccount = true, clearCache = false)
|
statedb.persist(clearEmptyAccount = true, clearCache = false)
|
||||||
ok()
|
ok()
|
||||||
|
|
|
@ -47,7 +47,7 @@ type
|
||||||
# Standard call result. (Some fields are beyond what EVMC can return,
|
# 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).
|
# and must only be used from tests because they will not always be set).
|
||||||
CallResult* = object
|
CallResult* = object
|
||||||
isError*: bool # True if the call failed.
|
error*: string # Something if the call failed.
|
||||||
gasUsed*: GasInt # Gas used by the call.
|
gasUsed*: GasInt # Gas used by the call.
|
||||||
contractAddress*: EthAddress # Created account (when `isCreate`).
|
contractAddress*: EthAddress # Created account (when `isCreate`).
|
||||||
output*: seq[byte] # Output data.
|
output*: seq[byte] # Output data.
|
||||||
|
@ -55,6 +55,9 @@ type
|
||||||
stack*: Stack # EVM stack on return (for test only).
|
stack*: Stack # EVM stack on return (for test only).
|
||||||
memory*: Memory # EVM memory 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 =
|
proc hostToComputationMessage*(msg: EvmcMessage): Message =
|
||||||
Message(
|
Message(
|
||||||
kind: CallKind(msg.kind.ord),
|
kind: CallKind(msg.kind.ord),
|
||||||
|
@ -182,7 +185,7 @@ proc setupHost(call: CallParams): TransactionHost =
|
||||||
let cMsg = hostToComputationMessage(host.msg)
|
let cMsg = hostToComputationMessage(host.msg)
|
||||||
host.computation = newComputation(vmState, call.sysCall, cMsg, code)
|
host.computation = newComputation(vmState, call.sysCall, cMsg, code)
|
||||||
|
|
||||||
shallowCopy(host.code, code)
|
host.code = system.move(code)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if call.input.len > 0:
|
if call.input.len > 0:
|
||||||
|
@ -284,9 +287,10 @@ proc finishRunningComputation(host: TransactionHost, call: CallParams): CallResu
|
||||||
let gasUsed = host.msg.gas - gasRemaining
|
let gasUsed = host.msg.gas - gasRemaining
|
||||||
host.vmState.captureEnd(c, c.output, gasUsed, c.errorOpt)
|
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
|
result.gasUsed = call.gasLimit - gasRemaining
|
||||||
shallowCopy(result.output, c.output)
|
result.output = system.move(c.output)
|
||||||
result.contractAddress = if call.isCreate: c.msg.contractAddress
|
result.contractAddress = if call.isCreate: c.msg.contractAddress
|
||||||
else: default(HostAddress)
|
else: default(HostAddress)
|
||||||
result.logEntries = host.vmState.stateDB.logEntries()
|
result.logEntries = host.vmState.stateDB.logEntries()
|
||||||
|
|
|
@ -18,6 +18,9 @@ import
|
||||||
../common/common,
|
../common/common,
|
||||||
./call_common
|
./call_common
|
||||||
|
|
||||||
|
export
|
||||||
|
call_common
|
||||||
|
|
||||||
type
|
type
|
||||||
RpcCallData* = object
|
RpcCallData* = object
|
||||||
source* : Option[EthAddress]
|
source* : Option[EthAddress]
|
||||||
|
|
Loading…
Reference in New Issue