From 67c38b02757ce8ec7dd64f67545b21b8123db704 Mon Sep 17 00:00:00 2001 From: andri lim Date: Wed, 6 Feb 2019 14:47:05 +0700 Subject: [PATCH] fixes NUMBER opcode --- nimbus/vm_state.nim | 4 +++- tests/test_op_custom.nim | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nimbus/vm_state.nim b/nimbus/vm_state.nim index 822abb1dc..e8b6e235d 100644 --- a/nimbus/vm_state.nim +++ b/nimbus/vm_state.nim @@ -49,7 +49,9 @@ method timestamp*(vmState: BaseVMState): EthTime {.base, gcsafe.} = vmState.blockHeader.timestamp method blockNumber*(vmState: BaseVMState): BlockNumber {.base, gcsafe.} = - vmState.blockHeader.blockNumber + # it should return current block number + # and not head.blockNumber + vmState.blockHeader.blockNumber + 1 method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} = vmState.blockHeader.difficulty diff --git a/tests/test_op_custom.nim b/tests/test_op_custom.nim index 3f5a8fe16..74512d71e 100644 --- a/tests/test_op_custom.nim +++ b/tests/test_op_custom.nim @@ -264,12 +264,12 @@ suite "Custom Opcodes Test": TimeStamp stack: "0x0000000000000000000000000000000000000000000000000000000055c46bb3" - # current number or parent number? + # it should be current block number assembler: # NUMBER OP title: "NUMBER_1" code: Number - stack: "0x000000000000000000000000000000000000000000000000000000000000b864" + stack: "0x000000000000000000000000000000000000000000000000000000000000b865" # current difficulty or parent dificulty? assembler: # DIFFICULTY OP