mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 05:14:14 +00:00
implement EIP 2315 opcodes
This commit is contained in:
parent
5a78b8a5a7
commit
a38882a9a0
@ -544,15 +544,34 @@ op jumpDest, inline = true:
|
||||
|
||||
op beginSub, inline = true:
|
||||
## 0x5c, Marks the entry point to a subroutine
|
||||
discard
|
||||
raise newException(OutOfGas, "Abort: Attempt to execute BeginSub opcode")
|
||||
|
||||
op returnSub, inline = true:
|
||||
## 0x5d, Returns control to the caller of a subroutine.
|
||||
discard
|
||||
if c.returnStack.len == 0:
|
||||
raise newException(OutOfGas, "Abort: invalid returnStack during ReturnSub")
|
||||
# Other than the check that the return stack is not empty, there is no
|
||||
# need to validate the pc from 'returns', since we only ever push valid
|
||||
# values onto it via jumpsub.
|
||||
c.code.pc = c.returnStack.popInt().safeInt
|
||||
|
||||
op jumpSub, inline = true:
|
||||
op jumpSub, inline = true, jumpTarget:
|
||||
## 0x5e, Transfers control to a subroutine.
|
||||
discard
|
||||
if jumpTarget >= c.code.len.u256:
|
||||
raise newException(InvalidJumpDestination, "JumpSub destination exceeds code len")
|
||||
|
||||
let jt = jumpTarget.truncate(int)
|
||||
c.code.pc = jt
|
||||
|
||||
let nextOpcode = c.code.peek
|
||||
if nextOpcode != BeginSub:
|
||||
raise newException(InvalidJumpDestination, "Invalid JumpSub destination")
|
||||
|
||||
if c.returnStack.len == 1023:
|
||||
raise newException(FullStack, "Out of returnStack")
|
||||
|
||||
push: jt + 1
|
||||
inc c.code.pc
|
||||
|
||||
# ##########################################
|
||||
# 60s & 70s: Push Operations.
|
||||
|
Loading…
x
Reference in New Issue
Block a user