Skip to content

Commit

Permalink
fi(EVM): Fix EXTCODECOPY zeroing offset (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov authored Dec 4, 2024
1 parent 17e46ab commit 7afaf45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions system-contracts/contracts/EvmEmulator.yul
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,8 @@ object "EvmEmulator" {

evmGasLeft := chargeGas(evmGasLeft, dynamicGas)

dstOffset := add(dstOffset, MEM_OFFSET())

if gt(srcOffset, MAX_UINT64()) {
srcOffset := MAX_UINT64()
}
Expand All @@ -1725,7 +1727,7 @@ object "EvmEmulator" {
let copiedLen
if getRawCodeHash(addr) {
// Gets the code from the addr
copiedLen := fetchDeployedCode(addr, add(dstOffset, MEM_OFFSET()), srcOffset, len)
copiedLen := fetchDeployedCode(addr, dstOffset, srcOffset, len)
}

if lt(copiedLen, len) {
Expand Down Expand Up @@ -4789,6 +4791,8 @@ object "EvmEmulator" {

evmGasLeft := chargeGas(evmGasLeft, dynamicGas)

dstOffset := add(dstOffset, MEM_OFFSET())

if gt(srcOffset, MAX_UINT64()) {
srcOffset := MAX_UINT64()
}
Expand All @@ -4797,7 +4801,7 @@ object "EvmEmulator" {
let copiedLen
if getRawCodeHash(addr) {
// Gets the code from the addr
copiedLen := fetchDeployedCode(addr, add(dstOffset, MEM_OFFSET()), srcOffset, len)
copiedLen := fetchDeployedCode(addr, dstOffset, srcOffset, len)
}

if lt(copiedLen, len) {
Expand Down
4 changes: 3 additions & 1 deletion system-contracts/evm-emulator/EvmEmulatorLoop.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ for { } true { } {

evmGasLeft := chargeGas(evmGasLeft, dynamicGas)

dstOffset := add(dstOffset, MEM_OFFSET())

if gt(srcOffset, MAX_UINT64()) {
srcOffset := MAX_UINT64()
}
Expand All @@ -501,7 +503,7 @@ for { } true { } {
let copiedLen
if getRawCodeHash(addr) {
// Gets the code from the addr
copiedLen := fetchDeployedCode(addr, add(dstOffset, MEM_OFFSET()), srcOffset, len)
copiedLen := fetchDeployedCode(addr, dstOffset, srcOffset, len)
}

if lt(copiedLen, len) {
Expand Down

0 comments on commit 7afaf45

Please sign in to comment.