From b194c862bf7132fdf10b5c4a6a8cfbb6cc562f92 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Fri, 3 Jan 2025 12:40:17 +0100 Subject: [PATCH] fix(EVM): Check bytecodehash version in create functions of ContractDeployer (#1182) --- system-contracts/contracts/ContractDeployer.sol | 5 ++++- system-contracts/contracts/SystemContractErrors.sol | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/system-contracts/contracts/ContractDeployer.sol b/system-contracts/contracts/ContractDeployer.sol index 7a360b926..96691da99 100644 --- a/system-contracts/contracts/ContractDeployer.sol +++ b/system-contracts/contracts/ContractDeployer.sol @@ -10,7 +10,7 @@ import {Utils} from "./libraries/Utils.sol"; import {EfficientCall} from "./libraries/EfficientCall.sol"; import {SystemContractHelper} from "./libraries/SystemContractHelper.sol"; import {SystemContractBase} from "./abstract/SystemContractBase.sol"; -import {Unauthorized, InvalidNonceOrderingChange, ValueMismatch, EmptyBytes32, EVMEmulationNotSupported, NotAllowedToDeployInKernelSpace, HashIsNonZero, NonEmptyAccount, UnknownCodeHash, NonEmptyMsgValue} from "./SystemContractErrors.sol"; +import {Unauthorized, InvalidNonceOrderingChange, ValueMismatch, EmptyBytes32, EVMBytecodeHash, EVMEmulationNotSupported, NotAllowedToDeployInKernelSpace, HashIsNonZero, NonEmptyAccount, UnknownCodeHash, NonEmptyMsgValue} from "./SystemContractErrors.sol"; /** * @author Matter Labs @@ -398,6 +398,9 @@ contract ContractDeployer is IContractDeployer, SystemContractBase { if (_bytecodeHash == bytes32(0x0)) { revert EmptyBytes32(); } + if (Utils.isCodeHashEVM(_bytecodeHash)) { + revert EVMBytecodeHash(); + } if (uint160(_newAddress) <= MAX_SYSTEM_CONTRACT_ADDRESS) { revert NotAllowedToDeployInKernelSpace(); } diff --git a/system-contracts/contracts/SystemContractErrors.sol b/system-contracts/contracts/SystemContractErrors.sol index 2ba8eed26..e6bdb473e 100644 --- a/system-contracts/contracts/SystemContractErrors.sol +++ b/system-contracts/contracts/SystemContractErrors.sol @@ -34,6 +34,8 @@ error EmptyVirtualBlocks(); error EncodedAndRealBytecodeChunkNotEqual(uint64 expected, uint64 provided); // 0x2bfbfc11 error EncodedLengthNotFourTimesSmallerThanOriginal(); +// 0x39bae0e6 +error EVMBytecodeHash(); // 0xb9e6e31f error EVMEmulationNotSupported(); // 0xe95a1fbe