From 4d3a88fb5697e5f3e8e05bee94fba6f6a17b0763 Mon Sep 17 00:00:00 2001 From: Gianbelinche <39842759+gianbelinche@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:27:43 -0300 Subject: [PATCH] Remove invalid todos --- .../contracts/EvmInterpreterLoop.template.yul | 10 ++-------- .../contracts/EvmInterpreterPreprocessed.yul | 20 ++++--------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/system-contracts/contracts/EvmInterpreterLoop.template.yul b/system-contracts/contracts/EvmInterpreterLoop.template.yul index dc3346988..0c57658e1 100644 --- a/system-contracts/contracts/EvmInterpreterLoop.template.yul +++ b/system-contracts/contracts/EvmInterpreterLoop.template.yul @@ -410,10 +410,6 @@ for { } true { } { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - checkMultipleOverflow(offset,size,MEM_OFFSET_INNER(), evmGasLeft) - checkMultipleOverflow(destOffset,size,MEM_OFFSET_INNER(), evmGasLeft) - - // TODO invalid? if or(gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_POSSIBLE_MEM()), gt(add(add(destOffset, size), MEM_OFFSET_INNER()), MAX_POSSIBLE_MEM())) { $llvm_AlwaysInline_llvm$_memsetToZero(add(destOffset, MEM_OFFSET_INNER()), size) } @@ -812,7 +808,6 @@ for { } true { } { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - // TODO overflow checks checkMemOverflowByOffset(add(offset, size), evmGasLeft) checkMemOverflowByOffset(add(destOffset, size), evmGasLeft) @@ -1444,11 +1439,10 @@ for { } true { } { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - // TODO invalid? - ensureAcceptableMemLocation(offset) - ensureAcceptableMemLocation(size) + checkOverflow(offset,size, evmGasLeft) evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size))) + checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft) offset := add(offset, MEM_OFFSET_INNER()) offset,size := addGasIfEvmRevert(isCallerEVM,offset,size,evmGasLeft) diff --git a/system-contracts/contracts/EvmInterpreterPreprocessed.yul b/system-contracts/contracts/EvmInterpreterPreprocessed.yul index 6d1fe6fe9..6b67c5c49 100644 --- a/system-contracts/contracts/EvmInterpreterPreprocessed.yul +++ b/system-contracts/contracts/EvmInterpreterPreprocessed.yul @@ -1947,10 +1947,6 @@ object "EVMInterpreter" { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - checkMultipleOverflow(offset,size,MEM_OFFSET_INNER(), evmGasLeft) - checkMultipleOverflow(destOffset,size,MEM_OFFSET_INNER(), evmGasLeft) - - // TODO invalid? if or(gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_POSSIBLE_MEM()), gt(add(add(destOffset, size), MEM_OFFSET_INNER()), MAX_POSSIBLE_MEM())) { $llvm_AlwaysInline_llvm$_memsetToZero(add(destOffset, MEM_OFFSET_INNER()), size) } @@ -2349,7 +2345,6 @@ object "EVMInterpreter" { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - // TODO overflow checks checkMemOverflowByOffset(add(offset, size), evmGasLeft) checkMemOverflowByOffset(add(destOffset, size), evmGasLeft) @@ -2981,11 +2976,10 @@ object "EVMInterpreter" { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - // TODO invalid? - ensureAcceptableMemLocation(offset) - ensureAcceptableMemLocation(size) + checkOverflow(offset,size, evmGasLeft) evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size))) + checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft) offset := add(offset, MEM_OFFSET_INNER()) offset,size := addGasIfEvmRevert(isCallerEVM,offset,size,evmGasLeft) @@ -4913,10 +4907,6 @@ object "EVMInterpreter" { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - checkMultipleOverflow(offset,size,MEM_OFFSET_INNER(), evmGasLeft) - checkMultipleOverflow(destOffset,size,MEM_OFFSET_INNER(), evmGasLeft) - - // TODO invalid? if or(gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_POSSIBLE_MEM()), gt(add(add(destOffset, size), MEM_OFFSET_INNER()), MAX_POSSIBLE_MEM())) { $llvm_AlwaysInline_llvm$_memsetToZero(add(destOffset, MEM_OFFSET_INNER()), size) } @@ -5315,7 +5305,6 @@ object "EVMInterpreter" { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - // TODO overflow checks checkMemOverflowByOffset(add(offset, size), evmGasLeft) checkMemOverflowByOffset(add(destOffset, size), evmGasLeft) @@ -5947,11 +5936,10 @@ object "EVMInterpreter" { offset, sp := popStackItemWithoutCheck(sp) size, sp := popStackItemWithoutCheck(sp) - // TODO invalid? - ensureAcceptableMemLocation(offset) - ensureAcceptableMemLocation(size) + checkOverflow(offset,size, evmGasLeft) evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size))) + checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft) offset := add(offset, MEM_OFFSET_INNER()) offset,size := addGasIfEvmRevert(isCallerEVM,offset,size,evmGasLeft)