From cc8ab6f265b96252ace5fd780717e2e5b4253329 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Mon, 9 Dec 2024 08:14:16 +0100 Subject: [PATCH 1/3] Add section about EXTCODEHASH --- .../70.differences/10.evm-instructions.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/content/20.zksync-protocol/70.differences/10.evm-instructions.md b/content/20.zksync-protocol/70.differences/10.evm-instructions.md index cd49a639..5155a728 100644 --- a/content/20.zksync-protocol/70.differences/10.evm-instructions.md +++ b/content/20.zksync-protocol/70.differences/10.evm-instructions.md @@ -263,6 +263,15 @@ Contract bytecode cannot be accessed on zkEVM architecture. Only its size is acc `EXTCODECOPY` always produces a compile-time error with the zkEVM compiler. +## `EXTCODEHASH` + +Retrieving the code hash of a smart contract in the zkEVM protocol differs slightly from EVM. In EVM hash of non-existing account is always `0`, and hash of existing account is `keccak("")`. Nonexisting contracts have no code, and their nonce and balance are both zero. + +In zkEVM `EXTCODEHASH` operation has the following differences: +- It doesn't check the balance of account. +- All contracts in precompiles space (plus `0x00`) are treated as existing empty accounts. + + ## `DATASIZE`, `DATAOFFSET`, `DATACOPY` Contract deployment is handled by two parts of the zkEVM protocol: the compiler front end and the system contract called `ContractDeployer`. From f8c1e0e99604a4f3ccb248e6a27583625beaaf87 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Mon, 9 Dec 2024 08:26:54 +0100 Subject: [PATCH 2/3] Fixes --- .../70.differences/10.evm-instructions.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/content/20.zksync-protocol/70.differences/10.evm-instructions.md b/content/20.zksync-protocol/70.differences/10.evm-instructions.md index 5155a728..37a1a4ac 100644 --- a/content/20.zksync-protocol/70.differences/10.evm-instructions.md +++ b/content/20.zksync-protocol/70.differences/10.evm-instructions.md @@ -265,13 +265,15 @@ Contract bytecode cannot be accessed on zkEVM architecture. Only its size is acc ## `EXTCODEHASH` -Retrieving the code hash of a smart contract in the zkEVM protocol differs slightly from EVM. In EVM hash of non-existing account is always `0`, and hash of existing account is `keccak("")`. Nonexisting contracts have no code, and their nonce and balance are both zero. +Retrieving the code hash of a smart contract in the zkEVM protocol differs slightly from EVM. In EVM hash of non-existing account +is always `0`, and hash of existing account without code is `keccak("")`. Nonexisting contracts have no code, and their nonce and +balance are both zero. In zkEVM `EXTCODEHASH` operation has the following differences: + - It doesn't check the balance of account. - All contracts in precompiles space (plus `0x00`) are treated as existing empty accounts. - ## `DATASIZE`, `DATAOFFSET`, `DATACOPY` Contract deployment is handled by two parts of the zkEVM protocol: the compiler front end and the system contract called `ContractDeployer`. From 9b64009a99b3f83bee894b29f64f1dbc3e5473ac Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Mon, 9 Dec 2024 08:32:26 +0100 Subject: [PATCH 3/3] Add info about versionedCodeHash --- content/20.zksync-protocol/70.differences/10.evm-instructions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/content/20.zksync-protocol/70.differences/10.evm-instructions.md b/content/20.zksync-protocol/70.differences/10.evm-instructions.md index 37a1a4ac..5ccd7195 100644 --- a/content/20.zksync-protocol/70.differences/10.evm-instructions.md +++ b/content/20.zksync-protocol/70.differences/10.evm-instructions.md @@ -273,6 +273,7 @@ In zkEVM `EXTCODEHASH` operation has the following differences: - It doesn't check the balance of account. - All contracts in precompiles space (plus `0x00`) are treated as existing empty accounts. +- For zkEVM contracts with bytecode it returns a versioned code hash based on sha3, rather than the keccak256 of the bytecode specified in EIP-1052. ## `DATASIZE`, `DATAOFFSET`, `DATACOPY`