Skip to content

Commit

Permalink
fix: fix wording for returndatacopy behavior (#229)
Browse files Browse the repository at this point in the history
The previous wording was ambiguous, the new one is more explicit.
  • Loading branch information
popzxc authored Sep 26, 2024
1 parent 88ea12d commit 0ecb3a2
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ deployed to the same the Ethereum-matching addresses on ZKsync.

For calls, you specify a memory slice to write the return data to, e.g. `out` and `outsize` arguments for
`call(g, a, v, in, insize, out, outsize)`. In EVM, if `outsize != 0`, the allocated memory will grow to `out + outsize`
(rounded up to the words) regardless of the `returndatasize`. On ZKsync Era, `returndatacopy`, similar to `calldatacopy`,
is implemented as a cycle iterating over return data with a few additional checks and triggering a panic if
`out + outsize > returndatasize` to simulate the same behavior as in EVM.
(rounded up to the words) regardless of the `returndatasize`.

On ZKsync Era, `returndatacopy`, similar to `calldatacopy`, is implemented as a cycle iterating over return data with a
few additional checks: a call `returndatacopy(destOffset, offset, size)` will trigger a panic if
`offset + size > returndatasize` to simulate the same behavior as in EVM. See
[EIP-211](https://eips.ethereum.org/EIPS/eip-211) for more details.

Thus, unlike EVM where memory growth occurs before the call itself, on ZKsync Era, the necessary copying of return data
happens only after the call has ended, leading to a difference in `msize()` and sometimes ZKsync Era not panicking where
Expand Down

0 comments on commit 0ecb3a2

Please sign in to comment.