fix EVM stack.[] bug

This commit is contained in:
jangko 2022-05-24 10:43:31 +07:00
parent f219c69840
commit 8b0d700b45
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 17 additions and 2 deletions

View File

@ -124,7 +124,7 @@ proc `$`*(stack: Stack): string =
&"Stack:\n{values}"
proc `[]`*(stack: Stack, i: BackwardsIndex, T: typedesc): T =
# This should be used only for tracer/test/debugging
ensurePop(stack, int(i))
fromStackElement(stack.values[i], result)
proc peekInt*(stack: Stack): UInt256 =

View File

@ -124,7 +124,7 @@ proc `$`*(stack: Stack): string =
&"Stack:\n{values}"
proc `[]`*(stack: Stack, i: BackwardsIndex, T: typedesc): T =
# This should be used only for tracer/test/debugging
ensurePop(stack, int(i))
fromStackElement(stack.values[i], result)
proc peekInt*(stack: Stack): UInt256 =

View File

@ -8,6 +8,21 @@ proc opEnvMain*() =
suite "Environmental Information Opcodes":
let (vmState, chainDB) = initDatabase()
assembler: # EVM bug reported in discord
title: "stack's operator [] bug"
code:
PUSH1 "0x0A"
DUP1
RETURNDATASIZE
MSIZE
ADDRESS
GAS
STATICCALL
CALL
fork: london
success: false
memory: "0x0000000000000000000000000000000000000000000000000000000000000000"
assembler: # CODECOPY OP
title: "CODECOPY_1"
code: