EIP-1153: Fix tload stack underflow bug

This commit is contained in:
jangko 2023-09-20 20:10:40 +07:00
parent a72141ccdf
commit 19ace7309a
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 24 additions and 2 deletions

View File

@ -289,9 +289,9 @@ const
tloadOp: Vm2OpFn = proc (k: var Vm2Ctx) =
## 0x5c, Load word from transient storage.
let
slot = k.cpt.stack.peek()
slot = k.cpt.stack.popInt()
val = k.cpt.getTransientStorage(slot)
k.cpt.stack.top(val)
k.cpt.stack.push: val
tstoreOp: Vm2OpFn = proc (k: var Vm2Ctx) =
## 0x5d, Save word to transient storage.

View File

@ -920,5 +920,27 @@ proc opMemoryMain*() =
"0x0000010203040506070000000000000000000000000000000000000000000000"
fork: Cancun
assembler:
title: "TSTORE/TLOAD"
code:
PUSH1 "0xAA"
PUSH1 "0xBB"
TSTORE
PUSH1 "0xBB"
TLOAD
stack:
"0x00000000000000000000000000000000000000000000000000000000000000AA"
fork: Cancun
assembler:
title: "TLOAD stack underflow not crash"
code:
PUSH1 "0xAA"
PUSH1 "0xBB"
TSTORE
TLOAD
success: false
fork: Cancun
when isMainModule:
opMemoryMain()