fix NUMBER opcode regression

This commit is contained in:
andri lim 2019-02-07 10:56:57 +07:00 committed by zah
parent fdc9a15785
commit d8db3d74d0
2 changed files with 14 additions and 1 deletions

View File

@ -140,6 +140,17 @@ proc makeReceipt(vmState: BaseVMState, cumulativeGasUsed: GasInt, fork = FkFront
result.logs = vmState.getAndClearLogEntries()
result.bloom = logsBloom(result.logs).value.toByteArrayBE
proc prepareVMState(vmState: BaseVMState, header: BlockHeader) =
# TODO: move this proc to somewhere else if it already complete
# blockNumber returned from VM should be current block number
# and not something else
vmState.blockHeader.blockNumber = header.blockNumber
# time stamp?
# gas limit?
# etc?
proc processBlock*(chainDB: BaseChainDB, head, header: BlockHeader, body: BlockBody, vmState: BaseVMState): ValidationResult =
let blockReward = 5.u256 * pow(10.u256, 18) # 5 ETH
@ -147,6 +158,8 @@ proc processBlock*(chainDB: BaseChainDB, head, header: BlockHeader, body: BlockB
debug "Mismatched txRoot", blockNumber=header.blockNumber
return ValidationResult.Error
prepareVMState(vmState, header)
var stateDb = vmState.accountDb
if header.txRoot != BLANK_ROOT_HASH:
if body.transactions.len == 0:

View File

@ -51,7 +51,7 @@ method timestamp*(vmState: BaseVMState): EthTime {.base, gcsafe.} =
method blockNumber*(vmState: BaseVMState): BlockNumber {.base, gcsafe.} =
# it should return current block number
# and not head.blockNumber
vmState.blockHeader.blockNumber + 1
vmState.blockHeader.blockNumber
method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
vmState.blockHeader.difficulty