Skip to content

Commit

Permalink
chore: Update EVM emulator-related code (#3127)
Browse files Browse the repository at this point in the history
## What ❔

Updates after latest changes. 

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] 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`.
  • Loading branch information
0xVolosnikov authored Oct 18, 2024
1 parent 37f209f commit 650361a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions core/bin/system-constants-generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -176,10 +176,10 @@ fn read_bootloader_test_code(test: &str) -> Vec<u8> {
)){
contract
} else {
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
read_yul_bytecode(
"contracts/system-contracts/bootloader/tests/artifacts",
test
))
)
}
}

Expand Down
19 changes: 10 additions & 9 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
}
}
Expand All @@ -313,10 +314,10 @@ pub fn read_bootloader_code(bootloader_type: &str) -> Vec<u8> {
{
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<u8> {
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion core/lib/types/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ pub struct ProtocolVersion {
/// Verifier configuration
#[deprecated]
pub verification_keys_hashes: Option<L1VerifierConfig>,
/// 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<BaseSystemContractsHashes>,
/// Bootloader code hash
Expand Down
2 changes: 1 addition & 1 deletion core/lib/types/src/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion core/node/node_sync/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/node/vm_runner/src/impls/bwip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 650361a

Please sign in to comment.