fixes related to EIP-4399/EIP-3675

- fix `RANDOM` opcode export
- fix `difficulty` return value in VMState
This commit is contained in:
jangko 2022-02-05 16:15:50 +07:00
parent 6869eafce6
commit d3fbe1d94d
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 12 additions and 3 deletions

View File

@ -12,7 +12,7 @@
import
./interpreter/opcode_values as vmo
export
vmo.Op
vmo.Op, vmo.Random
# see vm_message

View File

@ -308,7 +308,11 @@ method blockNumber*(vmState: BaseVMState): BlockNumber {.base, gcsafe.} =
vmState.parent.blockNumber + 1
method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
if vmState.fork >= FkPostMerge:
# EIP-4399/EIP-3675
0.u256
else:
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
method baseFee*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
if vmState.fee.isSome:

View File

@ -295,7 +295,11 @@ method blockNumber*(vmState: BaseVMState): BlockNumber {.base, gcsafe.} =
vmState.parent.blockNumber + 1
method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
if vmState.fork >= FkPostMerge:
# EIP-4399/EIP-3675
0.u256
else:
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
method baseFee*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
if vmState.fee.isSome:

View File

@ -133,6 +133,7 @@ else:
eGmt.refundGas,
eGmt.returnGas,
fVmo.Op,
fVmo.Random,
gVmg.isCreate,
hStk.Stack,
hStk.`$`,