From 650361ae456f67fd7e10d1c4ab92647d7f397fc1 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Fri, 18 Oct 2024 23:09:37 +0200 Subject: [PATCH] chore: Update EVM emulator-related code (#3127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Updates after latest changes. ## Why ❔ ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --- .../system-constants-generator/src/utils.rs | 8 ++++---- core/lib/contracts/src/lib.rs | 19 ++++++++++--------- core/lib/types/src/api/mod.rs | 2 +- core/lib/types/src/system_contracts.rs | 2 +- core/node/node_sync/src/genesis.rs | 2 +- core/node/vm_runner/src/impls/bwip.rs | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/bin/system-constants-generator/src/utils.rs b/core/bin/system-constants-generator/src/utils.rs index ce7182a3aa4a..800da68ee50d 100644 --- a/core/bin/system-constants-generator/src/utils.rs +++ b/core/bin/system-constants-generator/src/utils.rs @@ -3,7 +3,7 @@ use std::{cell::RefCell, rc::Rc}; use once_cell::sync::Lazy; use zksync_contracts::{ load_sys_contract, read_bootloader_code, read_bytecode_from_path, read_sys_contract_bytecode, - read_zbin_bytecode, BaseSystemContracts, ContractLanguage, SystemContractCode, + read_yul_bytecode, BaseSystemContracts, ContractLanguage, SystemContractCode, }; use zksync_multivm::{ interface::{ @@ -176,10 +176,10 @@ fn read_bootloader_test_code(test: &str) -> Vec { )){ contract } else { - read_zbin_bytecode(format!( - "contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin", + read_yul_bytecode( + "contracts/system-contracts/bootloader/tests/artifacts", test - )) + ) } } diff --git a/core/lib/contracts/src/lib.rs b/core/lib/contracts/src/lib.rs index a9e7324d5af6..0ee773abcd4a 100644 --- a/core/lib/contracts/src/lib.rs +++ b/core/lib/contracts/src/lib.rs @@ -295,10 +295,11 @@ impl SystemContractsRepo { ))) { contract } else { - read_zbin_bytecode_from_path(self.root.join(format!( - "contracts-preprocessed/{0}artifacts/{1}.yul.zbin", - directory, name - ))) + read_yul_bytecode_by_path( + self.root + .join(format!("contracts-preprocessed/{directory}artifacts")), + name, + ) } } } @@ -313,10 +314,10 @@ pub fn read_bootloader_code(bootloader_type: &str) -> Vec { { return contract; }; - read_zbin_bytecode(format!( - "contracts/system-contracts/bootloader/build/artifacts/{}.yul.zbin", - bootloader_type - )) + read_yul_bytecode( + "contracts/system-contracts/bootloader/build/artifacts", + bootloader_type, + ) } fn read_proved_batch_bootloader_bytecode() -> Vec { @@ -438,7 +439,7 @@ impl BaseSystemContracts { /// Loads the latest EVM emulator for these base system contracts. Logically, it only makes sense to do for the latest protocol version. pub fn with_latest_evm_emulator(mut self) -> Self { - let bytecode = read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Yul); + let bytecode = read_sys_contract_bytecode("", "EvmEmulator", ContractLanguage::Yul); let hash = hash_bytecode(&bytecode); self.evm_emulator = Some(SystemContractCode { code: bytes_to_be_words(bytecode), diff --git a/core/lib/types/src/api/mod.rs b/core/lib/types/src/api/mod.rs index 1c7672264cb4..b8f8a2f05841 100644 --- a/core/lib/types/src/api/mod.rs +++ b/core/lib/types/src/api/mod.rs @@ -644,7 +644,7 @@ pub struct ProtocolVersion { /// Verifier configuration #[deprecated] pub verification_keys_hashes: Option, - /// Hashes of base system contracts (bootloader, default account and evm simulator) + /// Hashes of base system contracts (bootloader, default account and evm emulator) #[deprecated] pub base_system_contracts: Option, /// Bootloader code hash diff --git a/core/lib/types/src/system_contracts.rs b/core/lib/types/src/system_contracts.rs index 4329680991c8..4d1ff9b554ea 100644 --- a/core/lib/types/src/system_contracts.rs +++ b/core/lib/types/src/system_contracts.rs @@ -151,7 +151,7 @@ static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 26] = [ "", "EvmGasManager", EVM_GAS_MANAGER_ADDRESS, - ContractLanguage::Sol, + ContractLanguage::Yul, ), // For now, only zero address and the bootloader address have empty bytecode at the init // In the future, we might want to set all of the system contracts this way. diff --git a/core/node/node_sync/src/genesis.rs b/core/node/node_sync/src/genesis.rs index 0ff8d0d448c0..c5d4869175df 100644 --- a/core/node/node_sync/src/genesis.rs +++ b/core/node/node_sync/src/genesis.rs @@ -109,7 +109,7 @@ async fn fetch_base_system_contracts( let bytes = client .fetch_system_contract_by_hash(hash) .await? - .context("EVM Simulator bytecode is missing on main node")?; + .context("EVM emulator bytecode is missing on main node")?; Some(SystemContractCode { code: zksync_utils::bytes_to_be_words(bytes), hash, diff --git a/core/node/vm_runner/src/impls/bwip.rs b/core/node/vm_runner/src/impls/bwip.rs index dc94752d9886..a2cf126f5499 100644 --- a/core/node/vm_runner/src/impls/bwip.rs +++ b/core/node/vm_runner/src/impls/bwip.rs @@ -248,7 +248,7 @@ async fn get_updates_manager_witness_input_data( .factory_deps_dal() .get_sealed_factory_dep(evm_emulator) .await? - .ok_or_else(|| anyhow!("EVM Simulator bytecode should exist"))?; + .ok_or_else(|| anyhow!("EVM emulator bytecode should exist"))?; let evm_emulator_bytecode = bytes_to_chunks(&evm_emulator_bytecode); used_bytecodes.insert(evm_emulator_code_hash, evm_emulator_bytecode); }