fixes generateChildComputation

This commit is contained in:
andri lim 2019-02-14 21:48:28 +07:00 committed by zah
parent 5701c8bacb
commit e38b1bf803

View File

@ -216,17 +216,24 @@ proc applyCreateMessage(fork: Fork, computation: var BaseComputation, opCode: st
proc generateChildComputation*(fork: Fork, computation: BaseComputation, childMsg: Message, opCode: static[Op]): BaseComputation = proc generateChildComputation*(fork: Fork, computation: BaseComputation, childMsg: Message, opCode: static[Op]): BaseComputation =
var childComp = newBaseComputation( var childComp = newBaseComputation(
computation.vmState, computation.vmState,
computation.vmState.blockHeader.blockNumber, computation.vmState.blockNumber,
childMsg, childMsg,
some(fork)) some(fork))
# Copy the fork op code executor proc (assumes child computation is in the same fork) # Copy the fork op code executor proc (assumes child computation is in the same fork)
childComp.opCodeExec = computation.opCodeExec childComp.opCodeExec = computation.opCodeExec
if childMsg.isCreate: try:
fork.applyCreateMessage(childComp, opCode) if childMsg.isCreate:
else: fork.applyCreateMessage(childComp, opCode)
applyMessage(childComp, opCode) else:
applyMessage(childComp, opCode)
except VMError:
# weird Nim bug
type T = vm_types.Error
childComp.error = T(info: getCurrentExceptionMsg())
debug "applyMesage() failed", error = getCurrentExceptionMsg()
return childComp return childComp
proc addChildComputation(fork: Fork, computation: BaseComputation, child: BaseComputation) = proc addChildComputation(fork: Fork, computation: BaseComputation, child: BaseComputation) =
@ -249,7 +256,7 @@ proc getFork*(computation: BaseComputation): Fork =
if computation.forkOverride.isSome: if computation.forkOverride.isSome:
computation.forkOverride.get computation.forkOverride.get
else: else:
computation.vmState.blockHeader.blockNumber.toFork computation.vmState.blockNumber.toFork
proc applyChildComputation*(computation: BaseComputation, childMsg: Message, opCode: static[Op]): BaseComputation = proc applyChildComputation*(computation: BaseComputation, childMsg: Message, opCode: static[Op]): BaseComputation =
## Apply the vm message childMsg as a child computation. ## Apply the vm message childMsg as a child computation.