From 0ecb3a20c94bd01677b50d6f9e2dc456009b6d62 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Thu, 26 Sep 2024 13:58:19 +0400 Subject: [PATCH] fix: fix wording for returndatacopy behavior (#229) The previous wording was ambiguous, the new one is more explicit. --- .../30.ethereum-differences/10.evm-instructions.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/content/00.build/65.developer-reference/30.ethereum-differences/10.evm-instructions.md b/content/00.build/65.developer-reference/30.ethereum-differences/10.evm-instructions.md index 822ff9f1..90f4955f 100644 --- a/content/00.build/65.developer-reference/30.ethereum-differences/10.evm-instructions.md +++ b/content/00.build/65.developer-reference/30.ethereum-differences/10.evm-instructions.md @@ -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