Skip to content

Commit

Permalink
Remove unnecesary memory checks
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla committed Sep 13, 2024
1 parent f17241f commit f5dae8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions system-contracts/contracts/EvmInterpreter.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2966,7 +2966,8 @@ object "EVMInterpreter" {
evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size)))

returnLen := size
checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft)

// Don't check overflow here since previous checks are enough to ensure this is safe
returnOffset := add(MEM_OFFSET_INNER(), offset)
break
}
Expand Down Expand Up @@ -3006,7 +3007,8 @@ object "EVMInterpreter" {
checkMemOverflowByOffset(add(offset, size), evmGasLeft)
evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size)))

checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft)

// Don't check overflow here since previous checks are enough to ensure this is safe
offset := add(offset, MEM_OFFSET_INNER())
offset,size := addGasIfEvmRevert(isCallerEVM,offset,size,evmGasLeft)

Expand Down Expand Up @@ -5940,7 +5942,8 @@ object "EVMInterpreter" {
evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size)))

returnLen := size
checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft)

// Don't check overflow here since previous checks are enough to ensure this is safe
returnOffset := add(MEM_OFFSET_INNER(), offset)
break
}
Expand Down Expand Up @@ -5980,7 +5983,8 @@ object "EVMInterpreter" {
checkMemOverflowByOffset(add(offset, size), evmGasLeft)
evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size)))

checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft)

// Don't check overflow here since previous checks are enough to ensure this is safe
offset := add(offset, MEM_OFFSET_INNER())
offset,size := addGasIfEvmRevert(isCallerEVM,offset,size,evmGasLeft)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,8 @@ for { } true { } {
evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size)))

returnLen := size
checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft)

// Don't check overflow here since previous checks are enough to ensure this is safe
returnOffset := add(MEM_OFFSET_INNER(), offset)
break
}
Expand Down Expand Up @@ -1446,7 +1447,8 @@ for { } true { } {
checkMemOverflowByOffset(add(offset, size), evmGasLeft)
evmGasLeft := chargeGas(evmGasLeft,expandMemory(add(offset,size)))

checkOverflow(offset,MEM_OFFSET_INNER(), evmGasLeft)

// Don't check overflow here since previous checks are enough to ensure this is safe
offset := add(offset, MEM_OFFSET_INNER())
offset,size := addGasIfEvmRevert(isCallerEVM,offset,size,evmGasLeft)

Expand Down

0 comments on commit f5dae8e

Please sign in to comment.