implement EIP 1344 stub
This commit is contained in:
parent
cda3e2811f
commit
0bb6c73bdb
|
@ -436,6 +436,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
|
|||
Number: fixed GasBase,
|
||||
Difficulty: fixed GasBase,
|
||||
GasLimit: fixed GasBase,
|
||||
ChainID: fixed GasBase,
|
||||
|
||||
# 50s: Stack, Memory, Storage and Flow Operations
|
||||
Pop: fixed GasBase,
|
||||
|
|
|
@ -79,6 +79,8 @@ fill_enum_holes:
|
|||
Difficulty = 0x44, # Get the block's difficulty.
|
||||
GasLimit = 0x45, # Get the block's gas limit.
|
||||
|
||||
ChainID = 0x46, # Get current chain’s EIP-155 unique identifier.
|
||||
|
||||
# 50s: Stack, Memory, Storage and Flow Operations
|
||||
Pop = 0x50, # Remove item from stack.
|
||||
Mload = 0x51, # Load word from memory.
|
||||
|
|
|
@ -372,6 +372,11 @@ op gasLimit, inline = true:
|
|||
## 0x45, Get the block's gas limit
|
||||
push: computation.vmState.gasLimit
|
||||
|
||||
op chainID, inline = true:
|
||||
## 0x46, Get current chain’s EIP-155 unique identifier.
|
||||
# TODO: this is a stub
|
||||
push: 0
|
||||
|
||||
# ##########################################
|
||||
# 50s: Stack, Memory, Storage and Flow Operations
|
||||
|
||||
|
|
|
@ -215,6 +215,12 @@ proc genConstantinopleJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.c
|
|||
|
||||
let ConstantinopleOpDispatch {.compileTime.}: array[Op, NimNode] = genConstantinopleJumpTable(ByzantiumOpDispatch)
|
||||
|
||||
proc genIstanbulJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compileTime.} =
|
||||
result = ops
|
||||
result[ChainID] = newIdentNode "chainID"
|
||||
|
||||
let IstanbulOpDispatch {.compileTime.}: array[Op, NimNode] = genIstanbulJumpTable(ConstantinopleOpDispatch)
|
||||
|
||||
proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNode =
|
||||
|
||||
let instr = quote do: `computation`.instr
|
||||
|
@ -288,6 +294,9 @@ macro genByzantiumDispatch(computation: BaseComputation): untyped =
|
|||
macro genConstantinopleDispatch(computation: BaseComputation): untyped =
|
||||
result = opTableToCaseStmt(ConstantinopleOpDispatch, computation)
|
||||
|
||||
macro genIstanbulDispatch(computation: BaseComputation): untyped =
|
||||
result = opTableToCaseStmt(IstanbulOpDispatch, computation)
|
||||
|
||||
proc frontierVM(computation: BaseComputation) =
|
||||
genFrontierDispatch(computation)
|
||||
|
||||
|
@ -306,6 +315,9 @@ proc byzantiumVM(computation: BaseComputation) {.gcsafe.} =
|
|||
proc constantinopleVM(computation: BaseComputation) {.gcsafe.} =
|
||||
genConstantinopleDispatch(computation)
|
||||
|
||||
proc istanbulVM(computation: BaseComputation) {.gcsafe.} =
|
||||
genIstanbulDispatch(computation)
|
||||
|
||||
proc selectVM(computation: BaseComputation, fork: Fork) {.gcsafe.} =
|
||||
# TODO: Optimise getting fork and updating opCodeExec only when necessary
|
||||
case fork
|
||||
|
@ -317,10 +329,12 @@ proc selectVM(computation: BaseComputation, fork: Fork) {.gcsafe.} =
|
|||
computation.tangerineVM()
|
||||
of FkSpurious:
|
||||
computation.spuriousVM()
|
||||
of FKByzantium:
|
||||
of FkByzantium:
|
||||
computation.byzantiumVM()
|
||||
else:
|
||||
of FkConstantinople:
|
||||
computation.constantinopleVM()
|
||||
else:
|
||||
computation.istanbulVM()
|
||||
|
||||
proc executeOpcodes(computation: BaseComputation) =
|
||||
let fork = computation.getFork
|
||||
|
|
Loading…
Reference in New Issue