From 5869331d0c742a771316af212faa1e5a27cf8c03 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Mon, 2 Dec 2024 16:55:09 +0100 Subject: [PATCH] fix(EVM): Fix DUP1 underflow check (#1110) --- system-contracts/contracts/EvmEmulator.yul | 4 ++-- system-contracts/evm-emulator/EvmEmulatorLoop.template.yul | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system-contracts/contracts/EvmEmulator.yul b/system-contracts/contracts/EvmEmulator.yul index 0f0d6b15d..a966924bb 100644 --- a/system-contracts/contracts/EvmEmulator.yul +++ b/system-contracts/contracts/EvmEmulator.yul @@ -2396,7 +2396,7 @@ object "EvmEmulator" { } case 0x80 { // OP_DUP1 evmGasLeft := chargeGas(evmGasLeft, 3) - sp, stackHead := pushStackItem(sp, stackHead, stackHead) + sp, stackHead := pushStackItem(sp, accessStackHead(sp, stackHead), stackHead) ip := add(ip, 1) } case 0x81 { // OP_DUP2 @@ -5456,7 +5456,7 @@ object "EvmEmulator" { } case 0x80 { // OP_DUP1 evmGasLeft := chargeGas(evmGasLeft, 3) - sp, stackHead := pushStackItem(sp, stackHead, stackHead) + sp, stackHead := pushStackItem(sp, accessStackHead(sp, stackHead), stackHead) ip := add(ip, 1) } case 0x81 { // OP_DUP2 diff --git a/system-contracts/evm-emulator/EvmEmulatorLoop.template.yul b/system-contracts/evm-emulator/EvmEmulatorLoop.template.yul index 0c3196a9e..c1ba325c1 100644 --- a/system-contracts/evm-emulator/EvmEmulatorLoop.template.yul +++ b/system-contracts/evm-emulator/EvmEmulatorLoop.template.yul @@ -1174,7 +1174,7 @@ for { } true { } { } case 0x80 { // OP_DUP1 evmGasLeft := chargeGas(evmGasLeft, 3) - sp, stackHead := pushStackItem(sp, stackHead, stackHead) + sp, stackHead := pushStackItem(sp, accessStackHead(sp, stackHead), stackHead) ip := add(ip, 1) } case 0x81 { // OP_DUP2