Skip to content

Commit

Permalink
fix(op-extcodesize): Fix op-extcodesize
Browse files Browse the repository at this point in the history
  • Loading branch information
fborello-lambda committed Apr 22, 2024
1 parent 566232e commit a043847
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function _getRawCodeHash(account) -> hash {
}

// Basically performs an extcodecopy, while returning the length of the bytecode.
// it is not an actual extcodecopy, since the first 32bytes are skipped
function _fetchDeployedCode(addr, _offset, _len) -> codeLen {
let codeHash := _getRawCodeHash(addr)

Expand Down
6 changes: 4 additions & 2 deletions system-contracts/contracts/EvmInterpreterLoop.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ for { } true { } {
// TODO: check, the .sol uses extcodesize directly, but it doesnt seem to work
// if a contract is created it works, but if the address is a zkSync's contract
// what happens?

sp := pushStackItem(sp, _fetchDeployedCodeLen(addr))
switch _isEVM(addr)
case 0 { sp := pushStackItem(sp, extcodesize(addr)) }
default { sp := pushStackItem(sp, _fetchDeployedCodeLen(addr)) }
}
case 0x3C { // OP_EXTCODECOPY
let addr, dest, offset, len
Expand All @@ -425,6 +426,7 @@ for { } true { } {
default {
dynamicGas := 2600
}

dynamicGas := add(dynamicGas, add(mul(3, shr(5, add(len, 31))), expandMemory(add(offset, len))))
evmGasLeft := chargeGas(evmGasLeft, dynamicGas)

Expand Down

0 comments on commit a043847

Please sign in to comment.