Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Evm equivalence Yul #227

Open
wants to merge 90 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
1cc42fd
[WIP] Initial EVM equivalence changes
jrchatruc Aug 9, 2024
3987a07
Merge branch 'main' into evm-equivalence-yul-new
jrchatruc Aug 9, 2024
1cc576c
Remove prints
jrchatruc Aug 9, 2024
1e716b0
Fix some more missing dal inserts
jrchatruc Aug 9, 2024
8e68c43
Update contracts submodule
IAvecilla Aug 9, 2024
6b3b8ff
Update support for evm simulator
IAvecilla Aug 9, 2024
c4ae99d
Update commit for contracts submodule
IAvecilla Aug 12, 2024
3c36c88
Update cached bootloader contracts for v1.5.0 of the vm
IAvecilla Aug 14, 2024
2a10e16
Add support for EVM contracts deployment (#231)
IAvecilla Aug 14, 2024
2ac29bd
Comment out hash checks for easier debug
IAvecilla Aug 14, 2024
5ecfe1b
Update compiled and cached multivm bootloader contracts
IAvecilla Aug 15, 2024
d1be203
Add evm gas manager to the system contract list
IAvecilla Aug 15, 2024
092ef15
Update evm deploy compatibility
IAvecilla Aug 15, 2024
55bd93a
Update base system contract hashes
IAvecilla Aug 15, 2024
c93f229
Add evm deploy tracer to default tracers
IAvecilla Aug 16, 2024
8df3b0e
Fix format
IAvecilla Aug 16, 2024
21c08d3
Update decommit process for new factory deps
IAvecilla Aug 16, 2024
4b8774a
Update contracts submodule
IAvecilla Aug 16, 2024
0c39609
Update contracts hash in config file
IAvecilla Aug 19, 2024
864a67e
Fix format
IAvecilla Aug 19, 2024
d8cc2b4
Add inital integration reversioning
gianbelinche Aug 19, 2024
4f28e85
Remove old fix me comments
IAvecilla Aug 19, 2024
6b2dcb5
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Aug 19, 2024
c578625
Fix format
IAvecilla Aug 19, 2024
e094019
Make evm tests compile
gianbelinche Aug 19, 2024
3561a5b
Format code
gianbelinche Aug 19, 2024
0e95d8d
Fix some tests
gianbelinche Aug 19, 2024
0c93909
Format code
gianbelinche Aug 19, 2024
167c581
Use EVM simulator name for consistency
IAvecilla Aug 20, 2024
cdcf570
Fix remaining tests
gianbelinche Aug 20, 2024
91bf9ca
Format code
gianbelinche Aug 20, 2024
56b5082
Merge branch 'evm-equivalence-yul-new' into evm-integration-tests-new
gianbelinche Aug 20, 2024
c40ac2d
Remove evm debug tracer
IAvecilla Aug 20, 2024
43aa7c6
Change hashes
gianbelinche Aug 20, 2024
4e1df20
Modify hashes
gianbelinche Aug 20, 2024
4078be8
Add newlines
gianbelinche Aug 20, 2024
6a785da
Merge pull request #237 from lambdaclass/evm-integration-tests-new
IAvecilla Aug 20, 2024
db04c02
Update contracts submodule
IAvecilla Aug 20, 2024
9ab6171
Update contracts submodule
IAvecilla Aug 22, 2024
2275e75
Update contracts submodule after merge with dev
IAvecilla Aug 22, 2024
d18e0d8
Resolve conflicts with contracts submodule
IAvecilla Aug 22, 2024
6513092
Update contracts submodule
IAvecilla Aug 23, 2024
a049e93
Update outdated comment
IAvecilla Aug 23, 2024
2aaedaa
Update toml hashes and multivm_bootloaders
jrchatruc Aug 26, 2024
330a13f
Fix lint errors
IAvecilla Aug 26, 2024
469131d
Update contracts submodule
IAvecilla Aug 26, 2024
4d9d0d2
Remove unused import
IAvecilla Aug 26, 2024
be4b069
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Aug 26, 2024
1c747dd
Update base system contracts hashes and commitment hash
IAvecilla Aug 26, 2024
d3b2598
Remove unused imports
IAvecilla Aug 26, 2024
7dc510d
Fix lint for all core components
IAvecilla Aug 26, 2024
8a687eb
Update genesis proto message to mantain compatibility with older version
IAvecilla Aug 26, 2024
4f1b3aa
Update system contracts hashes for state keeper test
IAvecilla Aug 26, 2024
ce520c0
Increase timeout for ts tests
IAvecilla Aug 26, 2024
af2a348
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Aug 27, 2024
4ca6c76
Merge remote-tracking branch 'matter-labs/main' into evm-equivalence-…
IAvecilla Aug 27, 2024
cf92e7b
Update contracts submodule
IAvecilla Aug 27, 2024
97cdba8
Fix rust lints
IAvecilla Aug 27, 2024
7a8ca0a
Fix format for sol files
IAvecilla Aug 27, 2024
83b0307
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Aug 28, 2024
77d66b4
Fix errors from merge adding execute address as Option
IAvecilla Aug 28, 2024
caf6c58
Fix mocked multicall response for tests
IAvecilla Aug 28, 2024
80ad08a
Fix proposed upgrades tests
IAvecilla Aug 28, 2024
58f1dd5
Update tests for latest and fast vm
IAvecilla Aug 28, 2024
61c31b1
Update prepare to decommit function and test circuits expected values
IAvecilla Aug 29, 2024
f97e26f
Update test aux function to get known bytecodes without base system c…
IAvecilla Aug 29, 2024
f964da1
Update system contracts, root and commitment hashes
IAvecilla Aug 29, 2024
3d8eb6d
Update cached multivm bootloaders for vm 1.5.0
IAvecilla Aug 29, 2024
eb83e9f
Update contracts submodule
IAvecilla Aug 29, 2024
d8fd5bc
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Aug 29, 2024
4c11c21
Delete migration module
IAvecilla Aug 29, 2024
f927c26
EVM Simulator code hash in witness data (#249)
IAvecilla Aug 30, 2024
2a57dfa
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Aug 30, 2024
808df90
Fix format
IAvecilla Aug 30, 2024
06b88c6
Add evm simulator hash to dummy snapshot used for tests
IAvecilla Aug 30, 2024
35440d7
EVM Simulator Flag (#244)
gianbelinche Aug 30, 2024
00f2325
Fix lints
IAvecilla Aug 30, 2024
c248a71
Add evm simulator to aux protocol version used for tests
IAvecilla Aug 31, 2024
2f92e1d
Add simulator code hash to genesis yaml file
IAvecilla Aug 31, 2024
9a807e6
Remove panic for older vms and return empty vec for decommiter instead
IAvecilla Aug 31, 2024
feb47f9
Add evm simulator code hash to metaparameters in json test files
IAvecilla Sep 2, 2024
bf54e4d
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Sep 4, 2024
9eea1c0
Merge branch 'main' into evm-equivalence-yul-new
IAvecilla Sep 4, 2024
8e9a05d
Update new rust tests for evm simulator changes
IAvecilla Sep 4, 2024
7e77047
Update commitment and contract hashes in configs
jrchatruc Sep 10, 2024
4ccf296
Merge remote-tracking branch 'upstream/main' into evm-equivalence-yul…
jrchatruc Sep 10, 2024
d863e9f
Fix compilation for all targets
jrchatruc Sep 10, 2024
539c1fd
Update submodule and genesis/root commitments
jrchatruc Sep 11, 2024
4c6f40b
Update contracts submodule
IAvecilla Sep 16, 2024
08606d3
Update system contracts hashes
IAvecilla Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 366 files
1 change: 1 addition & 0 deletions core/bin/genesis_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ async fn generate_new_config(
genesis_commitment: None,
bootloader_hash: Some(base_system_contracts.bootloader),
default_aa_hash: Some(base_system_contracts.default_aa),
evm_simulator_hash: Some(base_system_contracts.evm_simulator),
..genesis_config
};

Expand Down
20 changes: 18 additions & 2 deletions core/bin/system-constants-generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,19 @@ pub static GAS_TEST_SYSTEM_CONTRACTS: Lazy<BaseSystemContracts> = Lazy::new(|| {

let bytecode = read_sys_contract_bytecode("", "DefaultAccount", ContractLanguage::Sol);
let hash = hash_bytecode(&bytecode);
let evm_simulator_bytecode =
read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Yul);
let evm_simulator_hash = hash_bytecode(&evm_simulator_bytecode);
BaseSystemContracts {
default_aa: SystemContractCode {
code: bytes_to_be_words(bytecode),
hash,
},
bootloader,
evm_simulator: SystemContractCode {
code: bytes_to_be_words(evm_simulator_bytecode),
hash: evm_simulator_hash,
},
}
});

Expand All @@ -89,7 +96,7 @@ pub(super) fn get_l2_tx(
pubdata_price: u32,
) -> L2Tx {
L2Tx::new_signed(
contract_address,
Some(contract_address),
vec![],
Nonce(0),
Fee {
Expand Down Expand Up @@ -134,7 +141,7 @@ pub(super) fn get_l1_tx(
) -> L1Tx {
L1Tx {
execute: Execute {
contract_address,
contract_address: Some(contract_address),
calldata: custom_calldata.unwrap_or_default(),
value: U256::from(0),
factory_deps,
Expand Down Expand Up @@ -219,9 +226,18 @@ pub(super) fn execute_internal_transfer_test() -> u32 {
hash,
};

let evm_simulator_bytecode =
read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Yul);
let evm_simulator_hash = hash_bytecode(&evm_simulator_bytecode);
let evm_simulator = SystemContractCode {
code: bytes_to_be_words(evm_simulator_bytecode),
hash: evm_simulator_hash,
};

let base_system_smart_contracts = BaseSystemContracts {
bootloader,
default_aa,
evm_simulator,
};

let system_env = SystemEnv {
Expand Down
3 changes: 3 additions & 0 deletions core/lib/config/src/configs/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pub struct StateKeeperConfig {
pub bootloader_hash: Option<H256>,
#[deprecated(note = "Use GenesisConfig::default_aa_hash instead")]
pub default_aa_hash: Option<H256>,
#[deprecated(note = "Use GenesisConfig::evm_simulator_hash instead")]
pub evm_simulator_hash: Option<H256>,
#[deprecated(note = "Use GenesisConfig::l1_batch_commit_data_generator_mode instead")]
#[serde(default)]
pub l1_batch_commit_data_generator_mode: L1BatchCommitmentMode,
Expand Down Expand Up @@ -178,6 +180,7 @@ impl StateKeeperConfig {
protective_reads_persistence_enabled: true,
bootloader_hash: None,
default_aa_hash: None,
evm_simulator_hash: None,
l1_batch_commit_data_generator_mode: L1BatchCommitmentMode::Rollup,
}
}
Expand Down
2 changes: 2 additions & 0 deletions core/lib/config/src/configs/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct GenesisConfig {
pub genesis_commitment: Option<H256>,
pub bootloader_hash: Option<H256>,
pub default_aa_hash: Option<H256>,
pub evm_simulator_hash: Option<H256>,
pub l1_chain_id: L1ChainId,
pub sl_chain_id: Option<SLChainId>,
pub l2_chain_id: L2ChainId,
Expand Down Expand Up @@ -49,6 +50,7 @@ impl GenesisConfig {
genesis_commitment: Some(H256::repeat_byte(0x17)),
bootloader_hash: Default::default(),
default_aa_hash: Default::default(),
evm_simulator_hash: Default::default(),
l1_chain_id: L1ChainId(9),
sl_chain_id: None,
protocol_version: Some(ProtocolSemanticVersion {
Expand Down
1 change: 1 addition & 0 deletions core/lib/config/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub mod pruning;
pub mod secrets;
pub mod snapshot_recovery;
pub mod snapshots_creator;
pub mod use_evm_simulator;
pub mod utils;
pub mod vm_runner;
pub mod wallets;
Expand Down
7 changes: 7 additions & 0 deletions core/lib/config/src/configs/use_evm_simulator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use serde::Deserialize;

/// Configuration for the use evm simulator
#[derive(Debug, Deserialize, Clone, PartialEq)]
pub struct UseEvmSimulator {
pub use_evm_simulator: bool,
}
2 changes: 2 additions & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl Distribution<configs::chain::StateKeeperConfig> for EncodeDist {
fee_account_addr: None,
bootloader_hash: None,
default_aa_hash: None,
evm_simulator_hash: None,
l1_batch_commit_data_generator_mode: Default::default(),
}
}
Expand Down Expand Up @@ -724,6 +725,7 @@ impl Distribution<configs::GenesisConfig> for EncodeDist {
genesis_commitment: Some(rng.gen()),
bootloader_hash: Some(rng.gen()),
default_aa_hash: Some(rng.gen()),
evm_simulator_hash: Some(rng.gen()),
fee_account: rng.gen(),
l1_chain_id: L1ChainId(self.sample(rng)),
sl_chain_id: None,
Expand Down
5 changes: 5 additions & 0 deletions core/lib/constants/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ pub const CODE_ORACLE_ADDRESS: Address = H160([
0x00, 0x00, 0x80, 0x12,
]);

pub const EVM_GAS_MANAGER_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x13,
]);

/// Note, that the `Create2Factory` is explicitly deployed on a non-system-contract address.
pub const CREATE2_FACTORY_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
2 changes: 2 additions & 0 deletions core/lib/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ categories.workspace = true

[dependencies]
zksync_utils.workspace = true
zksync_config.workspace = true
zksync_env_config.workspace = true

ethabi.workspace = true
serde_json.workspace = true
Expand Down
26 changes: 26 additions & 0 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use ethabi::{
};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use zksync_config::configs::use_evm_simulator::UseEvmSimulator;
use zksync_env_config::FromEnv;
use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, workspace_dir_or_current_dir};

pub mod test_contracts;
Expand Down Expand Up @@ -193,6 +195,10 @@ pub fn deployer_contract() -> Contract {
load_sys_contract("ContractDeployer")
}

pub fn known_code_storage_contract() -> Contract {
load_sys_contract("KnownCodesStorage")
}

pub fn l1_messenger_contract() -> Contract {
load_sys_contract("L1Messenger")
}
Expand Down Expand Up @@ -303,18 +309,21 @@ pub struct SystemContractCode {
pub struct BaseSystemContracts {
pub bootloader: SystemContractCode,
pub default_aa: SystemContractCode,
pub evm_simulator: SystemContractCode,
}

#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq)]
pub struct BaseSystemContractsHashes {
pub bootloader: H256,
pub default_aa: H256,
pub evm_simulator: H256,
}

impl PartialEq for BaseSystemContracts {
fn eq(&self, other: &Self) -> bool {
self.bootloader.hash == other.bootloader.hash
&& self.default_aa.hash == other.default_aa.hash
&& self.evm_simulator.hash == other.evm_simulator.hash
}
}

Expand All @@ -335,9 +344,25 @@ impl BaseSystemContracts {
hash,
};

let mut evm_simulator_bytecode =
read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Yul);
let evm_simulator_hash = hash_bytecode(&evm_simulator_bytecode);

let use_evm_simulator =
UseEvmSimulator::from_env().expect("USE EVM SIMULATOR FLAG SHOULD BE SET");
if !use_evm_simulator.use_evm_simulator {
evm_simulator_bytecode = vec![];
}

let evm_simulator = SystemContractCode {
code: bytes_to_be_words(evm_simulator_bytecode),
hash: evm_simulator_hash,
};

BaseSystemContracts {
bootloader,
default_aa,
evm_simulator,
}
}
// BaseSystemContracts with proved bootloader - for handling transactions.
Expand Down Expand Up @@ -474,6 +499,7 @@ impl BaseSystemContracts {
BaseSystemContractsHashes {
bootloader: self.bootloader.hash,
default_aa: self.default_aa.hash,
evm_simulator: self.evm_simulator.hash,
}
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading