From b9d60f5e3054a6a70c830824c09021ceec366c02 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 11 Dec 2024 15:06:09 +0100 Subject: [PATCH 01/17] Fix genesis without EVM emulator --- zkstack_cli/crates/config/src/genesis.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/zkstack_cli/crates/config/src/genesis.rs b/zkstack_cli/crates/config/src/genesis.rs index 2d9ac7fcdc66..e9a2150b9bcc 100644 --- a/zkstack_cli/crates/config/src/genesis.rs +++ b/zkstack_cli/crates/config/src/genesis.rs @@ -20,14 +20,6 @@ pub fn update_from_chain_config( // TODO(EVM-676): for now, the settlement layer is always the same as the L1 network genesis.l1_chain_id = L1ChainId(config.l1_network.chain_id()); genesis.l1_batch_commit_data_generator_mode = config.l1_batch_commit_data_generator_mode; - genesis.evm_emulator_hash = if config.evm_emulator { - Some(genesis.evm_emulator_hash.context( - "impossible to initialize a chain with EVM emulator: the template genesis config \ - does not contain EVM emulator hash", - )?) - } else { - None - }; Ok(()) } From 93e8e2a6f0f2c2dddf4b660b9b0fa90d69513c07 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 12:12:26 +0100 Subject: [PATCH 02/17] Add new EVM enable flow to zkstack_cli --- .../enable_evm_emulator/mod.rs | 12 ++++ .../src/forge_interface/script_params.rs | 7 ++ .../src/commands/chain/enable_evm_emulator.rs | 40 +++++++++++ .../zkstack/src/commands/chain/init/mod.rs | 17 ++++- .../crates/zkstack/src/commands/chain/mod.rs | 1 + .../crates/zkstack/src/enable_evm_emulator.rs | 67 +++++++++++++++++++ zkstack_cli/crates/zkstack/src/main.rs | 1 + zkstack_cli/crates/zkstack/src/messages.rs | 5 ++ 8 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs create mode 100644 zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs create mode 100644 zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs diff --git a/zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs b/zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs new file mode 100644 index 000000000000..61c794afe600 --- /dev/null +++ b/zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs @@ -0,0 +1,12 @@ +use ethers::types::Address; +use serde::{Deserialize, Serialize}; + +use crate::traits::ZkStackConfig; + +impl ZkStackConfig for EnableEvmEmulatorInput {} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct EnableEvmEmulatorInput { + pub target_addr: Address, + pub governor: Address, +} diff --git a/zkstack_cli/crates/config/src/forge_interface/script_params.rs b/zkstack_cli/crates/config/src/forge_interface/script_params.rs index e7e21ad132b8..fd8d353f87f5 100644 --- a/zkstack_cli/crates/config/src/forge_interface/script_params.rs +++ b/zkstack_cli/crates/config/src/forge_interface/script_params.rs @@ -67,3 +67,10 @@ pub const SETUP_LEGACY_BRIDGE: ForgeScriptParams = ForgeScriptParams { output: "script-out/setup-legacy-bridge.toml", script_path: "deploy-scripts/dev/SetupLegacyBridge.s.sol", }; + +pub const ENABLE_EVM_EMULATOR_PARAMS: ForgeScriptParams = ForgeScriptParams { + input: "script-config/enable-evm-emulator.toml", + output: "script-out/output-enable-evm-emulator.toml", + script_path: "deploy-scripts/EnableEvmEmulator.s.sol", +}; + diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs new file mode 100644 index 000000000000..b20822c3a890 --- /dev/null +++ b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs @@ -0,0 +1,40 @@ +use anyhow::Context; +use common::{forge::ForgeScriptArgs, logger, spinner::Spinner}; +use config::EcosystemConfig; +use xshell::Shell; + +use crate::{ + enable_evm_emulator::enable_evm_emulator, + messages::{ + MSG_ENABLING_EVM_EMULATOR, MSG_CHAIN_NOT_INITIALIZED, MSG_EVM_EMULATOR_ENABLED, + MSG_L1_SECRETS_MUST_BE_PRESENTED, + }, +}; + +pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> { + let ecosystem_config = EcosystemConfig::from_file(shell)?; + let chain_config = ecosystem_config + .load_current_chain() + .context(MSG_CHAIN_NOT_INITIALIZED)?; + let contracts = chain_config.get_contracts_config()?; + let secrets = chain_config.get_secrets_config()?; + let l1_rpc_url = secrets + .l1 + .context(MSG_L1_SECRETS_MUST_BE_PRESENTED)? + .l1_rpc_url + .expose_str() + .to_string(); + + enable_evm_emulator( + shell, + &ecosystem_config, + contracts.l1.chain_admin_addr, + &chain_config.get_wallets_config()?.governor, + contracts.l1.diamond_proxy_addr, + &args, + l1_rpc_url.clone(), + ) + .await?; + logger::success(MSG_EVM_EMULATOR_ENABLED); + Ok(()) +} diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs index d92c56d2eb10..a48f44b48066 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs @@ -7,6 +7,7 @@ use xshell::Shell; use crate::{ accept_ownership::accept_admin, + enable_evm_emulator::enable_evm_emulator, commands::chain::{ args::init::{ configs::{InitConfigsArgs, InitConfigsArgsFinal}, @@ -21,7 +22,7 @@ use crate::{ setup_legacy_bridge::setup_legacy_bridge, }, messages::{ - msg_initializing_chain, MSG_ACCEPTING_ADMIN_SPINNER, MSG_CHAIN_INITIALIZED, + msg_initializing_chain, MSG_ACCEPTING_ADMIN_SPINNER, MSG_CHAIN_INITIALIZED, MSG_ENABLING_EVM_EMULATOR, MSG_CHAIN_NOT_FOUND_ERR, MSG_DEPLOYING_PAYMASTER, MSG_GENESIS_DATABASE_ERR, MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG, MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER, MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND, @@ -136,6 +137,20 @@ pub async fn init( spinner.finish(); } + // Enable EVM emulation if needed (run by L2 Governor) + if chain_config.evm_emulator { + enable_evm_emulator( + shell, + ecosystem_config, + contracts_config.l1.chain_admin_addr, + &chain_config.get_wallets_config()?.governor, + contracts_config.l1.diamond_proxy_addr, + &init_args.forge_args.clone(), + init_args.l1_rpc_url.clone(), + ) + .await?; + } + // Deploy L2 contracts: L2SharedBridge, L2DefaultUpgrader, ... (run by L1 Governor) deploy_l2_contracts::deploy_l2_contracts( shell, diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs index 82b8656154ab..9c696c15719d 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs @@ -11,6 +11,7 @@ use crate::commands::chain::{ }; mod accept_chain_ownership; +mod enable_evm_emulator; pub(crate) mod args; mod build_transactions; mod common; diff --git a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs new file mode 100644 index 000000000000..93cacf66e55c --- /dev/null +++ b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs @@ -0,0 +1,67 @@ +use common::{ + forge::{Forge, ForgeScript, ForgeScriptArgs}, + spinner::Spinner, + wallets::Wallet, +}; +use config::{forge_interface::script_params::ENABLE_EVM_EMULATOR_PARAMS, EcosystemConfig}; +use ethers::{abi::parse_abi, contract::BaseContract, types::Address}; +use lazy_static::lazy_static; +use xshell::Shell; + +use crate::{ + messages::MSG_ENABLING_EVM_EMULATOR, + utils::forge::{check_the_balance, fill_forge_private_key, WalletOwner}, +}; + +lazy_static! { + static ref ENABLE_EVM_EMULATOR: BaseContract = BaseContract::from( + parse_abi(&[ + "function chainAllowEvmEmulation(address chainAdmin, address target) public", + ]) + .unwrap(), + ); +} + +pub async fn enable_evm_emulator( + shell: &Shell, + ecosystem_config: &EcosystemConfig, + admin: Address, + governor: &Wallet, + target_address: Address, + forge_args: &ForgeScriptArgs, + l1_rpc_url: String, +) -> anyhow::Result<()> { + // Resume for accept admin doesn't work properly. Foundry assumes that if signature of the function is the same, + // than it's the same call, but because we are calling this function multiple times during the init process, + // code assumes that doing only once is enough, but actually we need to accept admin multiple times + let mut forge_args = forge_args.clone(); + forge_args.resume = false; + + let calldata = ENABLE_EVM_EMULATOR + .encode("chainAllowEvmEmulation", (admin, target_address)) + .unwrap(); + let foundry_contracts_path = ecosystem_config.path_to_foundry(); + let forge = Forge::new(&foundry_contracts_path) + .script( + &ENABLE_EVM_EMULATOR_PARAMS.script(), + forge_args.clone(), + ) + .with_ffi() + .with_rpc_url(l1_rpc_url) + .with_broadcast() + .with_calldata(&calldata); + enable_evm_inner(shell, governor, forge).await +} + +async fn enable_evm_inner( + shell: &Shell, + governor: &Wallet, + mut forge: ForgeScript, +) -> anyhow::Result<()> { + forge = fill_forge_private_key(forge, Some(governor), WalletOwner::Governor)?; + check_the_balance(&forge).await?; + let spinner = Spinner::new(MSG_ENABLING_EVM_EMULATOR); + forge.run(shell)?; + spinner.finish(); + Ok(()) +} diff --git a/zkstack_cli/crates/zkstack/src/main.rs b/zkstack_cli/crates/zkstack/src/main.rs index 8a115201fc81..2009e50a6b58 100644 --- a/zkstack_cli/crates/zkstack/src/main.rs +++ b/zkstack_cli/crates/zkstack/src/main.rs @@ -20,6 +20,7 @@ use crate::commands::{ }; pub mod accept_ownership; +pub mod enable_evm_emulator; mod commands; mod consts; mod defaults; diff --git a/zkstack_cli/crates/zkstack/src/messages.rs b/zkstack_cli/crates/zkstack/src/messages.rs index 14b89be773f1..b2b5c1a3f68f 100644 --- a/zkstack_cli/crates/zkstack/src/messages.rs +++ b/zkstack_cli/crates/zkstack/src/messages.rs @@ -85,6 +85,8 @@ pub(super) const MSG_CHAIN_INITIALIZED: &str = "Chain initialized successfully"; pub(super) const MSG_CHAIN_CONFIGS_INITIALIZED: &str = "Chain configs were initialized"; pub(super) const MSG_CHAIN_OWNERSHIP_TRANSFERRED: &str = "Chain ownership was transferred successfully"; +pub(super) const MSG_EVM_EMULATOR_ENABLED: &str = + "EVM emulator enabled successfully"; pub(super) const MSG_CHAIN_REGISTERED: &str = "Chain registraion was successful"; pub(super) const MSG_DISTRIBUTING_ETH_SPINNER: &str = "Distributing eth..."; pub(super) const MSG_MINT_BASE_TOKEN_SPINNER: &str = @@ -272,6 +274,9 @@ pub(super) const MSG_SERVER_URING_HELP: &str = "Enables uring support for RocksD /// Accept ownership related messages pub(super) const MSG_ACCEPTING_GOVERNANCE_SPINNER: &str = "Accepting governance..."; +/// EVM emulator related messages +pub(super) const MSG_ENABLING_EVM_EMULATOR: &str = "Enabling EVM emulator..."; + /// Containers related messages pub(super) const MSG_STARTING_CONTAINERS: &str = "Starting containers"; pub(super) const MSG_STARTING_DOCKER_CONTAINERS_SPINNER: &str = From d8ed659635c22a6b0b5a19b4029d0052fce26136 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 23 Oct 2024 19:50:42 +0200 Subject: [PATCH 03/17] Change EVM emulation activation flow --- infrastructure/zk/src/contract.ts | 7 +++++-- infrastructure/zk/src/init.ts | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/infrastructure/zk/src/contract.ts b/infrastructure/zk/src/contract.ts index ba9fe08041db..943248cdd5a2 100644 --- a/infrastructure/zk/src/contract.ts +++ b/infrastructure/zk/src/contract.ts @@ -216,10 +216,12 @@ export async function erc20BridgeFinish(args: any[] = []): Promise { export async function registerHyperchain({ baseTokenName, - deploymentMode + deploymentMode, + allowEvmEmulator }: { baseTokenName?: string; deploymentMode?: DeploymentMode; + allowEvmEmulator?: boolean; }): Promise { await utils.confirmAction(); @@ -241,7 +243,8 @@ export async function registerHyperchain({ privateKey ? `--private-key ${privateKey}` : '', baseTokenName ? `--base-token-name ${baseTokenName}` : '', deploymentMode == DeploymentMode.Validium ? '--validium-mode' : '', - tokenMultiplierSetterAddress ? `--token-multiplier-setter-address ${tokenMultiplierSetterAddress}` : '' + tokenMultiplierSetterAddress ? `--token-multiplier-setter-address ${tokenMultiplierSetterAddress}` : '', + allowEvmEmulator ? '--allow-evm-emulation' : '' ]; await utils.spawn(`yarn l1-contracts register-hyperchain ${args.join(' ')} | tee registerHyperchain.log`); const deployLog = fs.readFileSync('registerHyperchain.log').toString(); diff --git a/infrastructure/zk/src/init.ts b/infrastructure/zk/src/init.ts index 6dbad67b489c..a1c937510616 100644 --- a/infrastructure/zk/src/init.ts +++ b/infrastructure/zk/src/init.ts @@ -106,14 +106,16 @@ type InitHyperchainOptions = { baseTokenName?: string; localLegacyBridgeTesting?: boolean; deploymentMode: DeploymentMode; + allowEvmEmulator?: boolean }; const initHyperchain = async ({ includePaymaster, baseTokenName, localLegacyBridgeTesting, - deploymentMode + deploymentMode, + allowEvmEmulator }: InitHyperchainOptions): Promise => { - await announced('Registering Hyperchain', contract.registerHyperchain({ baseTokenName, deploymentMode })); + await announced('Registering Hyperchain', contract.registerHyperchain({ baseTokenName, deploymentMode, allowEvmEmulator})); await announced('Reloading env', env.reload()); await announced('Running server genesis setup', server.genesisFromSources()); await announced( @@ -146,6 +148,7 @@ type InitDevCmdActionOptions = InitSetupOptions & { validiumMode?: boolean; localLegacyBridgeTesting?: boolean; shouldCheckPostgres: boolean; // Whether to perform `cargo sqlx prepare --check` + allowEvmEmulator?: boolean; }; export const initDevCmdAction = async ({ skipEnvSetup, @@ -157,7 +160,8 @@ export const initDevCmdAction = async ({ runObservability, validiumMode, localLegacyBridgeTesting, - shouldCheckPostgres + shouldCheckPostgres, + allowEvmEmulator }: InitDevCmdActionOptions): Promise => { if (localLegacyBridgeTesting) { await makeEraChainIdSameAsCurrent(); @@ -181,7 +185,8 @@ export const initDevCmdAction = async ({ includePaymaster: true, baseTokenName, localLegacyBridgeTesting, - deploymentMode + deploymentMode, + allowEvmEmulator }); if (localLegacyBridgeTesting) { await makeEraAddressSameAsCurrent(); @@ -214,13 +219,15 @@ type InitHyperCmdActionOptions = { baseTokenName?: string; runObservability: boolean; deploymentMode: DeploymentMode; + allowEvmEmulator?: boolean; }; export const initHyperCmdAction = async ({ skipSetupCompletely, bumpChainId, baseTokenName, runObservability, - deploymentMode + deploymentMode, + allowEvmEmulator }: InitHyperCmdActionOptions): Promise => { if (bumpChainId) { config.bumpChainId(); @@ -237,7 +244,8 @@ export const initHyperCmdAction = async ({ await initHyperchain({ includePaymaster: true, baseTokenName, - deploymentMode + deploymentMode, + allowEvmEmulator }); }; @@ -254,6 +262,7 @@ export const initCommand = new Command('init') 'used to test LegacyBridge compatibily. The chain will have the same id as the era chain id, while eraChainId in L2SharedBridge will be 0' ) .option('--should-check-postgres', 'Whether to perform cargo sqlx prepare --check during database setup', true) + .option('--allow-evm-emulator', 'allow deployment of EVM contracts') .description('Deploys the shared bridge and registers a hyperchain locally, as quickly as possible.') .action(initDevCmdAction); @@ -278,4 +287,5 @@ initCommand .option('--base-token-name ', 'base token name') .option('--validium-mode', 'deploy contracts in Validium mode') .option('--run-observability', 'run observability suite') + .option('--allow-evm-emulator', 'allow deployment of EVM contracts') .action(initHyperCmdAction); From 73823afd24c11e612cd61090b955e54cfe0c6d2d Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:00:35 +0100 Subject: [PATCH 04/17] Cargo fmt --- .../config/src/forge_interface/script_params.rs | 1 - .../zkstack/src/commands/chain/enable_evm_emulator.rs | 2 +- .../crates/zkstack/src/commands/chain/init/mod.rs | 8 ++++---- zkstack_cli/crates/zkstack/src/commands/chain/mod.rs | 2 +- zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs | 11 +++-------- zkstack_cli/crates/zkstack/src/main.rs | 2 +- zkstack_cli/crates/zkstack/src/messages.rs | 3 +-- 7 files changed, 11 insertions(+), 18 deletions(-) diff --git a/zkstack_cli/crates/config/src/forge_interface/script_params.rs b/zkstack_cli/crates/config/src/forge_interface/script_params.rs index fd8d353f87f5..9c84bbe431b4 100644 --- a/zkstack_cli/crates/config/src/forge_interface/script_params.rs +++ b/zkstack_cli/crates/config/src/forge_interface/script_params.rs @@ -73,4 +73,3 @@ pub const ENABLE_EVM_EMULATOR_PARAMS: ForgeScriptParams = ForgeScriptParams { output: "script-out/output-enable-evm-emulator.toml", script_path: "deploy-scripts/EnableEvmEmulator.s.sol", }; - diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs index b20822c3a890..00cc8139368d 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs @@ -6,7 +6,7 @@ use xshell::Shell; use crate::{ enable_evm_emulator::enable_evm_emulator, messages::{ - MSG_ENABLING_EVM_EMULATOR, MSG_CHAIN_NOT_INITIALIZED, MSG_EVM_EMULATOR_ENABLED, + MSG_CHAIN_NOT_INITIALIZED, MSG_ENABLING_EVM_EMULATOR, MSG_EVM_EMULATOR_ENABLED, MSG_L1_SECRETS_MUST_BE_PRESENTED, }, }; diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs index a48f44b48066..f11bee9d9ce1 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs @@ -7,7 +7,6 @@ use xshell::Shell; use crate::{ accept_ownership::accept_admin, - enable_evm_emulator::enable_evm_emulator, commands::chain::{ args::init::{ configs::{InitConfigsArgs, InitConfigsArgsFinal}, @@ -21,10 +20,11 @@ use crate::{ set_token_multiplier_setter::set_token_multiplier_setter, setup_legacy_bridge::setup_legacy_bridge, }, + enable_evm_emulator::enable_evm_emulator, messages::{ - msg_initializing_chain, MSG_ACCEPTING_ADMIN_SPINNER, MSG_CHAIN_INITIALIZED, MSG_ENABLING_EVM_EMULATOR, - MSG_CHAIN_NOT_FOUND_ERR, MSG_DEPLOYING_PAYMASTER, MSG_GENESIS_DATABASE_ERR, - MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG, + msg_initializing_chain, MSG_ACCEPTING_ADMIN_SPINNER, MSG_CHAIN_INITIALIZED, + MSG_CHAIN_NOT_FOUND_ERR, MSG_DEPLOYING_PAYMASTER, MSG_ENABLING_EVM_EMULATOR, + MSG_GENESIS_DATABASE_ERR, MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG, MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER, MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND, }, }; diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs index 9c696c15719d..4aa17fe9fad8 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs @@ -11,13 +11,13 @@ use crate::commands::chain::{ }; mod accept_chain_ownership; -mod enable_evm_emulator; pub(crate) mod args; mod build_transactions; mod common; mod create; pub mod deploy_l2_contracts; pub mod deploy_paymaster; +mod enable_evm_emulator; pub mod genesis; pub mod init; pub mod register_chain; diff --git a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs index 93cacf66e55c..9fc843cbf831 100644 --- a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs @@ -15,10 +15,8 @@ use crate::{ lazy_static! { static ref ENABLE_EVM_EMULATOR: BaseContract = BaseContract::from( - parse_abi(&[ - "function chainAllowEvmEmulation(address chainAdmin, address target) public", - ]) - .unwrap(), + parse_abi(&["function chainAllowEvmEmulation(address chainAdmin, address target) public",]) + .unwrap(), ); } @@ -42,10 +40,7 @@ pub async fn enable_evm_emulator( .unwrap(); let foundry_contracts_path = ecosystem_config.path_to_foundry(); let forge = Forge::new(&foundry_contracts_path) - .script( - &ENABLE_EVM_EMULATOR_PARAMS.script(), - forge_args.clone(), - ) + .script(&ENABLE_EVM_EMULATOR_PARAMS.script(), forge_args.clone()) .with_ffi() .with_rpc_url(l1_rpc_url) .with_broadcast() diff --git a/zkstack_cli/crates/zkstack/src/main.rs b/zkstack_cli/crates/zkstack/src/main.rs index 2009e50a6b58..ff4589a99cc5 100644 --- a/zkstack_cli/crates/zkstack/src/main.rs +++ b/zkstack_cli/crates/zkstack/src/main.rs @@ -20,10 +20,10 @@ use crate::commands::{ }; pub mod accept_ownership; -pub mod enable_evm_emulator; mod commands; mod consts; mod defaults; +pub mod enable_evm_emulator; pub mod external_node; mod messages; mod utils; diff --git a/zkstack_cli/crates/zkstack/src/messages.rs b/zkstack_cli/crates/zkstack/src/messages.rs index b2b5c1a3f68f..216c4bd64d3a 100644 --- a/zkstack_cli/crates/zkstack/src/messages.rs +++ b/zkstack_cli/crates/zkstack/src/messages.rs @@ -85,8 +85,7 @@ pub(super) const MSG_CHAIN_INITIALIZED: &str = "Chain initialized successfully"; pub(super) const MSG_CHAIN_CONFIGS_INITIALIZED: &str = "Chain configs were initialized"; pub(super) const MSG_CHAIN_OWNERSHIP_TRANSFERRED: &str = "Chain ownership was transferred successfully"; -pub(super) const MSG_EVM_EMULATOR_ENABLED: &str = - "EVM emulator enabled successfully"; +pub(super) const MSG_EVM_EMULATOR_ENABLED: &str = "EVM emulator enabled successfully"; pub(super) const MSG_CHAIN_REGISTERED: &str = "Chain registraion was successful"; pub(super) const MSG_DISTRIBUTING_ETH_SPINNER: &str = "Distributing eth..."; pub(super) const MSG_MINT_BASE_TOKEN_SPINNER: &str = From daaef6daea7a704076ececabb998640f5c42f74d Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Tue, 10 Dec 2024 17:28:13 +0100 Subject: [PATCH 05/17] Update zkstack cli --- .../crates/config/src/forge_interface/register_chain/input.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs b/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs index fb7c606a4569..bbe7d23af57b 100644 --- a/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs +++ b/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs @@ -48,6 +48,7 @@ pub struct ChainL1Config { pub base_token_gas_price_multiplier_denominator: u64, pub governance_security_council_address: Address, pub governance_min_delay: u64, + pub allow_evm_emulator: bool } impl ZkStackConfig for RegisterChainL1Config {} @@ -84,6 +85,7 @@ impl RegisterChainL1Config { == L1BatchCommitmentMode::Validium, validator_sender_operator_commit_eth: wallets_config.operator.address, validator_sender_operator_blobs_eth: wallets_config.blob_operator.address, + allow_evm_emulator: chain_config.evm_emulator }, owner_address: wallets_config.governor.address, }) From bbd844037e4c50b4227b6c9b1341df7e07a3a897 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:04:24 +0100 Subject: [PATCH 06/17] Cargo fmt --- .../crates/config/src/forge_interface/register_chain/input.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs b/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs index bbe7d23af57b..7d30c7f49a70 100644 --- a/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs +++ b/zkstack_cli/crates/config/src/forge_interface/register_chain/input.rs @@ -48,7 +48,7 @@ pub struct ChainL1Config { pub base_token_gas_price_multiplier_denominator: u64, pub governance_security_council_address: Address, pub governance_min_delay: u64, - pub allow_evm_emulator: bool + pub allow_evm_emulator: bool, } impl ZkStackConfig for RegisterChainL1Config {} @@ -85,7 +85,7 @@ impl RegisterChainL1Config { == L1BatchCommitmentMode::Validium, validator_sender_operator_commit_eth: wallets_config.operator.address, validator_sender_operator_blobs_eth: wallets_config.blob_operator.address, - allow_evm_emulator: chain_config.evm_emulator + allow_evm_emulator: chain_config.evm_emulator, }, owner_address: wallets_config.governor.address, }) From 2729367be776e63c1a053b2cb6428853aa8a4cc4 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:07:14 +0100 Subject: [PATCH 07/17] Formatting --- infrastructure/zk/src/init.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/infrastructure/zk/src/init.ts b/infrastructure/zk/src/init.ts index a1c937510616..fc0e550dd84b 100644 --- a/infrastructure/zk/src/init.ts +++ b/infrastructure/zk/src/init.ts @@ -106,7 +106,7 @@ type InitHyperchainOptions = { baseTokenName?: string; localLegacyBridgeTesting?: boolean; deploymentMode: DeploymentMode; - allowEvmEmulator?: boolean + allowEvmEmulator?: boolean; }; const initHyperchain = async ({ includePaymaster, @@ -115,7 +115,10 @@ const initHyperchain = async ({ deploymentMode, allowEvmEmulator }: InitHyperchainOptions): Promise => { - await announced('Registering Hyperchain', contract.registerHyperchain({ baseTokenName, deploymentMode, allowEvmEmulator})); + await announced( + 'Registering Hyperchain', + contract.registerHyperchain({ baseTokenName, deploymentMode, allowEvmEmulator }) + ); await announced('Reloading env', env.reload()); await announced('Running server genesis setup', server.genesisFromSources()); await announced( From 04335c782f1b9a00519626d045f45b1f50cc9b6f Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:13:48 +0100 Subject: [PATCH 08/17] Cleanup --- zkstack_cli/crates/config/src/genesis.rs | 1 - .../crates/zkstack/src/commands/chain/enable_evm_emulator.rs | 5 ++--- zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/zkstack_cli/crates/config/src/genesis.rs b/zkstack_cli/crates/config/src/genesis.rs index e9a2150b9bcc..e457f3d1924c 100644 --- a/zkstack_cli/crates/config/src/genesis.rs +++ b/zkstack_cli/crates/config/src/genesis.rs @@ -1,6 +1,5 @@ use std::path::Path; -use anyhow::Context as _; use xshell::Shell; use zksync_basic_types::L1ChainId; pub use zksync_config::GenesisConfig; diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs index 00cc8139368d..5986c4e782c3 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs @@ -1,13 +1,12 @@ use anyhow::Context; -use common::{forge::ForgeScriptArgs, logger, spinner::Spinner}; +use common::{forge::ForgeScriptArgs, logger}; use config::EcosystemConfig; use xshell::Shell; use crate::{ enable_evm_emulator::enable_evm_emulator, messages::{ - MSG_CHAIN_NOT_INITIALIZED, MSG_ENABLING_EVM_EMULATOR, MSG_EVM_EMULATOR_ENABLED, - MSG_L1_SECRETS_MUST_BE_PRESENTED, + MSG_CHAIN_NOT_INITIALIZED, MSG_EVM_EMULATOR_ENABLED, MSG_L1_SECRETS_MUST_BE_PRESENTED, }, }; diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs index f11bee9d9ce1..bd815caceabf 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs @@ -23,8 +23,8 @@ use crate::{ enable_evm_emulator::enable_evm_emulator, messages::{ msg_initializing_chain, MSG_ACCEPTING_ADMIN_SPINNER, MSG_CHAIN_INITIALIZED, - MSG_CHAIN_NOT_FOUND_ERR, MSG_DEPLOYING_PAYMASTER, MSG_ENABLING_EVM_EMULATOR, - MSG_GENESIS_DATABASE_ERR, MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG, + MSG_CHAIN_NOT_FOUND_ERR, MSG_DEPLOYING_PAYMASTER, MSG_GENESIS_DATABASE_ERR, + MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG, MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER, MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND, }, }; From fac030c080b3a7b6b3828d9d7d2c78878387373f Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:16:13 +0100 Subject: [PATCH 09/17] Add separate EnableEvmEmulator command --- zkstack_cli/crates/zkstack/src/commands/chain/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs index 4aa17fe9fad8..84b189e5a8bd 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs @@ -68,6 +68,8 @@ pub enum ChainCommands { DeployPaymaster(ForgeScriptArgs), /// Update Token Multiplier Setter address on L1 UpdateTokenMultiplierSetter(ForgeScriptArgs), + /// Enable EVM emulation on chain + EnableEvmEmulator(ForgeScriptArgs), } pub(crate) async fn run(shell: &Shell, args: ChainCommands) -> anyhow::Result<()> { @@ -100,5 +102,6 @@ pub(crate) async fn run(shell: &Shell, args: ChainCommands) -> anyhow::Result<() ChainCommands::UpdateTokenMultiplierSetter(args) => { set_token_multiplier_setter::run(args, shell).await } + ChainCommands::EnableEvmEmulator(args) => enable_evm_emulator::run(args, shell).await, } } From d963fba8072bd2b2c0d13cacdab172b5b8a7f952 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:35:38 +0100 Subject: [PATCH 10/17] Forbid command if EVM emulator not supported --- .../src/commands/chain/enable_evm_emulator.rs | 15 +++++++++++++-- .../crates/zkstack/src/enable_evm_emulator.rs | 6 ------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs index 5986c4e782c3..f1bab14f2969 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs @@ -1,12 +1,13 @@ use anyhow::Context; use common::{forge::ForgeScriptArgs, logger}; -use config::EcosystemConfig; +use config::{traits::ReadConfigWithBasePath, EcosystemConfig, GenesisConfig}; use xshell::Shell; use crate::{ enable_evm_emulator::enable_evm_emulator, messages::{ - MSG_CHAIN_NOT_INITIALIZED, MSG_EVM_EMULATOR_ENABLED, MSG_L1_SECRETS_MUST_BE_PRESENTED, + MSG_CHAIN_NOT_INITIALIZED, MSG_EVM_EMULATOR_ENABLED, MSG_EVM_EMULATOR_HASH_MISSING_ERR, + MSG_L1_SECRETS_MUST_BE_PRESENTED, }, }; @@ -15,6 +16,16 @@ pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> { let chain_config = ecosystem_config .load_current_chain() .context(MSG_CHAIN_NOT_INITIALIZED)?; + + let default_genesis_config = GenesisConfig::read_with_base_path( + shell, + EcosystemConfig::default_configs_path(&chain_config.link_to_code), + )?; + let has_evm_emulation_support = default_genesis_config.evm_emulator_hash.is_some(); + if !has_evm_emulation_support { + anyhow::bail!(MSG_EVM_EMULATOR_HASH_MISSING_ERR); + } + let contracts = chain_config.get_contracts_config()?; let secrets = chain_config.get_secrets_config()?; let l1_rpc_url = secrets diff --git a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs index 9fc843cbf831..7a733c4e3881 100644 --- a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs @@ -29,12 +29,6 @@ pub async fn enable_evm_emulator( forge_args: &ForgeScriptArgs, l1_rpc_url: String, ) -> anyhow::Result<()> { - // Resume for accept admin doesn't work properly. Foundry assumes that if signature of the function is the same, - // than it's the same call, but because we are calling this function multiple times during the init process, - // code assumes that doing only once is enough, but actually we need to accept admin multiple times - let mut forge_args = forge_args.clone(); - forge_args.resume = false; - let calldata = ENABLE_EVM_EMULATOR .encode("chainAllowEvmEmulation", (admin, target_address)) .unwrap(); From b2890a76cbd435447a1437e0aeea91212702b7f7 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:37:33 +0100 Subject: [PATCH 11/17] Update autocompletion --- .../crates/zkstack/completion/_zkstack.zsh | 43 ++++++++++ .../crates/zkstack/completion/zkstack.fish | 51 ++++++----- .../crates/zkstack/completion/zkstack.sh | 85 ++++++++++++++++++- 3 files changed, 157 insertions(+), 22 deletions(-) diff --git a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh index fc6f29851e66..84d704b8ea83 100644 --- a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh +++ b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh @@ -603,6 +603,23 @@ _arguments "${_arguments_options[@]}" : \ '--help[Print help (see more with '\''--help'\'')]' \ && ret=0 ;; +(enable-evm-emulator) +_arguments "${_arguments_options[@]}" : \ +'--verify=[Verify deployed contracts]' \ +'--verifier=[Verifier to use]:VERIFIER:(etherscan sourcify blockscout oklink)' \ +'--verifier-url=[Verifier URL, if using a custom provider]:VERIFIER_URL:_default' \ +'--verifier-api-key=[Verifier API key]:VERIFIER_API_KEY:_default' \ +'*-a+[List of additional arguments that can be passed through the CLI]:ADDITIONAL_ARGS:_default' \ +'*--additional-args=[List of additional arguments that can be passed through the CLI]:ADDITIONAL_ARGS:_default' \ +'--chain=[Chain to use]:CHAIN:_default' \ +'--resume[]' \ +'-v[Verbose mode]' \ +'--verbose[Verbose mode]' \ +'--ignore-prerequisites[Ignores prerequisites checks]' \ +'-h[Print help (see more with '\''--help'\'')]' \ +'--help[Print help (see more with '\''--help'\'')]' \ +&& ret=0 +;; (help) _arguments "${_arguments_options[@]}" : \ ":: :_zkstack__chain__help_commands" \ @@ -707,6 +724,10 @@ _arguments "${_arguments_options[@]}" : \ _arguments "${_arguments_options[@]}" : \ && ret=0 ;; +(enable-evm-emulator) +_arguments "${_arguments_options[@]}" : \ +&& ret=0 +;; (help) _arguments "${_arguments_options[@]}" : \ && ret=0 @@ -2705,6 +2726,10 @@ _arguments "${_arguments_options[@]}" : \ (update-token-multiplier-setter) _arguments "${_arguments_options[@]}" : \ && ret=0 +;; +(enable-evm-emulator) +_arguments "${_arguments_options[@]}" : \ +&& ret=0 ;; esac ;; @@ -3234,6 +3259,7 @@ _zkstack__chain_commands() { 'deploy-upgrader:Deploy Default Upgrader' \ 'deploy-paymaster:Deploy paymaster smart contract' \ 'update-token-multiplier-setter:Update Token Multiplier Setter address on L1' \ +'enable-evm-emulator:Enable EVM emulation on chain' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'zkstack chain commands' commands "$@" @@ -3283,6 +3309,11 @@ _zkstack__chain__deploy-upgrader_commands() { local commands; commands=() _describe -t commands 'zkstack chain deploy-upgrader commands' commands "$@" } +(( $+functions[_zkstack__chain__enable-evm-emulator_commands] )) || +_zkstack__chain__enable-evm-emulator_commands() { + local commands; commands=() + _describe -t commands 'zkstack chain enable-evm-emulator commands' commands "$@" +} (( $+functions[_zkstack__chain__genesis_commands] )) || _zkstack__chain__genesis_commands() { local commands; commands=( @@ -3343,6 +3374,7 @@ _zkstack__chain__help_commands() { 'deploy-upgrader:Deploy Default Upgrader' \ 'deploy-paymaster:Deploy paymaster smart contract' \ 'update-token-multiplier-setter:Update Token Multiplier Setter address on L1' \ +'enable-evm-emulator:Enable EVM emulation on chain' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'zkstack chain help commands' commands "$@" @@ -3392,6 +3424,11 @@ _zkstack__chain__help__deploy-upgrader_commands() { local commands; commands=() _describe -t commands 'zkstack chain help deploy-upgrader commands' commands "$@" } +(( $+functions[_zkstack__chain__help__enable-evm-emulator_commands] )) || +_zkstack__chain__help__enable-evm-emulator_commands() { + local commands; commands=() + _describe -t commands 'zkstack chain help enable-evm-emulator commands' commands "$@" +} (( $+functions[_zkstack__chain__help__genesis_commands] )) || _zkstack__chain__help__genesis_commands() { local commands; commands=( @@ -4661,6 +4698,7 @@ _zkstack__help__chain_commands() { 'deploy-upgrader:Deploy Default Upgrader' \ 'deploy-paymaster:Deploy paymaster smart contract' \ 'update-token-multiplier-setter:Update Token Multiplier Setter address on L1' \ +'enable-evm-emulator:Enable EVM emulation on chain' \ ) _describe -t commands 'zkstack help chain commands' commands "$@" } @@ -4709,6 +4747,11 @@ _zkstack__help__chain__deploy-upgrader_commands() { local commands; commands=() _describe -t commands 'zkstack help chain deploy-upgrader commands' commands "$@" } +(( $+functions[_zkstack__help__chain__enable-evm-emulator_commands] )) || +_zkstack__help__chain__enable-evm-emulator_commands() { + local commands; commands=() + _describe -t commands 'zkstack help chain enable-evm-emulator commands' commands "$@" +} (( $+functions[_zkstack__help__chain__genesis_commands] )) || _zkstack__help__chain__genesis_commands() { local commands; commands=( diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.fish b/zkstack_cli/crates/zkstack/completion/zkstack.fish index 8a5b338fcda2..b4fc52167fb1 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.fish +++ b/zkstack_cli/crates/zkstack/completion/zkstack.fish @@ -129,25 +129,26 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_se complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from help" -f -a "change-default-chain" -d 'Change the default chain' complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from help" -f -a "setup-observability" -d 'Setup observability for the ecosystem, downloading Grafana dashboards from the era-observability repo' complete -c zkstack -n "__fish_zkstack_using_subcommand ecosystem; and __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -l chain -d 'Chain to use' -r -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -s v -l verbose -d 'Verbose mode' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -l ignore-prerequisites -d 'Ignores prerequisites checks' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -s h -l help -d 'Print help' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "create" -d 'Create a new chain, setting the necessary configurations for later initialization' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "build-transactions" -d 'Create unsigned transactions for chain deployment' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "init" -d 'Initialize chain, deploying necessary contracts and performing on-chain operations' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "genesis" -d 'Run server genesis' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "register-chain" -d 'Register a new chain on L1 (executed by L1 governor). This command deploys and configures Governance, ChainAdmin, and DiamondProxy contracts, registers chain with BridgeHub and sets pending admin for DiamondProxy. Note: After completion, L2 governor can accept ownership by running `accept-chain-ownership`' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "deploy-l2-contracts" -d 'Deploy all L2 contracts (executed by L1 governor)' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "accept-chain-ownership" -d 'Accept ownership of L2 chain (executed by L2 governor). This command should be run after `register-chain` to accept ownership of newly created DiamondProxy contract' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "initialize-bridges" -d 'Initialize bridges on L2' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "deploy-consensus-registry" -d 'Deploy L2 consensus registry' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "deploy-multicall3" -d 'Deploy L2 multicall3' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "deploy-timestamp-asserter" -d 'Deploy L2 TimestampAsserter' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "deploy-upgrader" -d 'Deploy Default Upgrader' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "deploy-paymaster" -d 'Deploy paymaster smart contract' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "update-token-multiplier-setter" -d 'Update Token Multiplier Setter address on L1' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -l chain -d 'Chain to use' -r +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -s v -l verbose -d 'Verbose mode' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -l ignore-prerequisites -d 'Ignores prerequisites checks' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -s h -l help -d 'Print help' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "create" -d 'Create a new chain, setting the necessary configurations for later initialization' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "build-transactions" -d 'Create unsigned transactions for chain deployment' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "init" -d 'Initialize chain, deploying necessary contracts and performing on-chain operations' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "genesis" -d 'Run server genesis' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "register-chain" -d 'Register a new chain on L1 (executed by L1 governor). This command deploys and configures Governance, ChainAdmin, and DiamondProxy contracts, registers chain with BridgeHub and sets pending admin for DiamondProxy. Note: After completion, L2 governor can accept ownership by running `accept-chain-ownership`' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-l2-contracts" -d 'Deploy all L2 contracts (executed by L1 governor)' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "accept-chain-ownership" -d 'Accept ownership of L2 chain (executed by L2 governor). This command should be run after `register-chain` to accept ownership of newly created DiamondProxy contract' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "initialize-bridges" -d 'Initialize bridges on L2' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-consensus-registry" -d 'Deploy L2 consensus registry' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-multicall3" -d 'Deploy L2 multicall3' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-timestamp-asserter" -d 'Deploy L2 TimestampAsserter' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-upgrader" -d 'Deploy Default Upgrader' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-paymaster" -d 'Deploy paymaster smart contract' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "update-token-multiplier-setter" -d 'Update Token Multiplier Setter address on L1' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l chain-name -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l chain-id -d 'Chain ID' -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l prover-mode -d 'Prover options' -r -f -a "{no-proofs\t'',gpu\t''}" @@ -306,6 +307,16 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_s complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from update-token-multiplier-setter" -s v -l verbose -d 'Verbose mode' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from update-token-multiplier-setter" -l ignore-prerequisites -d 'Ignores prerequisites checks' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from update-token-multiplier-setter" -s h -l help -d 'Print help (see more with \'--help\')' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -l verify -d 'Verify deployed contracts' -r -f -a "{true\t'',false\t''}" +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -l verifier -d 'Verifier to use' -r -f -a "{etherscan\t'',sourcify\t'',blockscout\t'',oklink\t''}" +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -l verifier-url -d 'Verifier URL, if using a custom provider' -r +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -l verifier-api-key -d 'Verifier API key' -r +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -s a -l additional-args -d 'List of additional arguments that can be passed through the CLI' -r +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -l chain -d 'Chain to use' -r +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -l resume +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -s v -l verbose -d 'Verbose mode' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -l ignore-prerequisites -d 'Ignores prerequisites checks' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from enable-evm-emulator" -s h -l help -d 'Print help (see more with \'--help\')' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "create" -d 'Create a new chain, setting the necessary configurations for later initialization' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "build-transactions" -d 'Create unsigned transactions for chain deployment' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "init" -d 'Initialize chain, deploying necessary contracts and performing on-chain operations' @@ -320,6 +331,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_s complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "deploy-upgrader" -d 'Deploy Default Upgrader' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "deploy-paymaster" -d 'Deploy paymaster smart contract' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "update-token-multiplier-setter" -d 'Update Token Multiplier Setter address on L1' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and not __fish_seen_subcommand_from database test clean snapshot lint fmt prover contracts config-writer send-transactions status generate-genesis help" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and not __fish_seen_subcommand_from database test clean snapshot lint fmt prover contracts config-writer send-transactions status generate-genesis help" -s v -l verbose -d 'Verbose mode' @@ -747,6 +759,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_su complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "deploy-upgrader" -d 'Deploy Default Upgrader' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "deploy-paymaster" -d 'Deploy paymaster smart contract' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "update-token-multiplier-setter" -d 'Update Token Multiplier Setter address on L1' +complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from dev" -f -a "database" -d 'Database related commands' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from dev" -f -a "test" -d 'Run tests' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from dev" -f -a "clean" -d 'Clean artifacts' diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.sh b/zkstack_cli/crates/zkstack/completion/zkstack.sh index bb373c3f63eb..03d28a0fc689 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.sh +++ b/zkstack_cli/crates/zkstack/completion/zkstack.sh @@ -84,6 +84,9 @@ _zkstack() { zkstack__chain,deploy-upgrader) cmd="zkstack__chain__deploy__upgrader" ;; + zkstack__chain,enable-evm-emulator) + cmd="zkstack__chain__enable__evm__emulator" + ;; zkstack__chain,genesis) cmd="zkstack__chain__genesis" ;; @@ -147,6 +150,9 @@ _zkstack() { zkstack__chain__help,deploy-upgrader) cmd="zkstack__chain__help__deploy__upgrader" ;; + zkstack__chain__help,enable-evm-emulator) + cmd="zkstack__chain__help__enable__evm__emulator" + ;; zkstack__chain__help,genesis) cmd="zkstack__chain__help__genesis" ;; @@ -789,6 +795,9 @@ _zkstack() { zkstack__help__chain,deploy-upgrader) cmd="zkstack__help__chain__deploy__upgrader" ;; + zkstack__help__chain,enable-evm-emulator) + cmd="zkstack__help__chain__enable__evm__emulator" + ;; zkstack__help__chain,genesis) cmd="zkstack__help__chain__genesis" ;; @@ -1135,7 +1144,7 @@ _zkstack() { return 0 ;; zkstack__chain) - opts="-v -h --verbose --chain --ignore-prerequisites --help create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" + opts="-v -h --verbose --chain --ignore-prerequisites --help create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1573,6 +1582,48 @@ _zkstack() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + zkstack__chain__enable__evm__emulator) + opts="-a -v -h --verify --verifier --verifier-url --verifier-api-key --resume --additional-args --verbose --chain --ignore-prerequisites --help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --verify) + COMPREPLY=($(compgen -W "true false" -- "${cur}")) + return 0 + ;; + --verifier) + COMPREPLY=($(compgen -W "etherscan sourcify blockscout oklink" -- "${cur}")) + return 0 + ;; + --verifier-url) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --verifier-api-key) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --additional-args) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -a) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --chain) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; zkstack__chain__genesis) opts="-d -d -v -h --server-db-url --server-db-name --dev --dont-drop --verbose --chain --ignore-prerequisites --help init-database server help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -1700,7 +1751,7 @@ _zkstack() { return 0 ;; zkstack__chain__help) - opts="create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter help" + opts="create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -1839,6 +1890,20 @@ _zkstack() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + zkstack__chain__help__enable__evm__emulator) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; zkstack__chain__help__genesis) opts="init-database server" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then @@ -5608,7 +5673,7 @@ _zkstack() { return 0 ;; zkstack__help__chain) - opts="create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter" + opts="create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -5747,6 +5812,20 @@ _zkstack() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + zkstack__help__chain__enable__evm__emulator) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; zkstack__help__chain__genesis) opts="init-database server" if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then From 4f842a08a9f805945c561dfc6d2530c8ee6f4b64 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:39:39 +0100 Subject: [PATCH 12/17] Update comment for enable-evm-emulator --- zkstack_cli/crates/zkstack/completion/_zkstack.zsh | 6 +++--- zkstack_cli/crates/zkstack/completion/zkstack.fish | 6 +++--- zkstack_cli/crates/zkstack/src/commands/chain/mod.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh index 84d704b8ea83..a1d45121905e 100644 --- a/zkstack_cli/crates/zkstack/completion/_zkstack.zsh +++ b/zkstack_cli/crates/zkstack/completion/_zkstack.zsh @@ -3259,7 +3259,7 @@ _zkstack__chain_commands() { 'deploy-upgrader:Deploy Default Upgrader' \ 'deploy-paymaster:Deploy paymaster smart contract' \ 'update-token-multiplier-setter:Update Token Multiplier Setter address on L1' \ -'enable-evm-emulator:Enable EVM emulation on chain' \ +'enable-evm-emulator:Enable EVM emulation on chain (Not supported yet)' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'zkstack chain commands' commands "$@" @@ -3374,7 +3374,7 @@ _zkstack__chain__help_commands() { 'deploy-upgrader:Deploy Default Upgrader' \ 'deploy-paymaster:Deploy paymaster smart contract' \ 'update-token-multiplier-setter:Update Token Multiplier Setter address on L1' \ -'enable-evm-emulator:Enable EVM emulation on chain' \ +'enable-evm-emulator:Enable EVM emulation on chain (Not supported yet)' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'zkstack chain help commands' commands "$@" @@ -4698,7 +4698,7 @@ _zkstack__help__chain_commands() { 'deploy-upgrader:Deploy Default Upgrader' \ 'deploy-paymaster:Deploy paymaster smart contract' \ 'update-token-multiplier-setter:Update Token Multiplier Setter address on L1' \ -'enable-evm-emulator:Enable EVM emulation on chain' \ +'enable-evm-emulator:Enable EVM emulation on chain (Not supported yet)' \ ) _describe -t commands 'zkstack help chain commands' commands "$@" } diff --git a/zkstack_cli/crates/zkstack/completion/zkstack.fish b/zkstack_cli/crates/zkstack/completion/zkstack.fish index b4fc52167fb1..92d083566465 100644 --- a/zkstack_cli/crates/zkstack/completion/zkstack.fish +++ b/zkstack_cli/crates/zkstack/completion/zkstack.fish @@ -147,7 +147,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_se complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-upgrader" -d 'Deploy Default Upgrader' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "deploy-paymaster" -d 'Deploy paymaster smart contract' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "update-token-multiplier-setter" -d 'Update Token Multiplier Setter address on L1' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain (Not supported yet)' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and not __fish_seen_subcommand_from create build-transactions init genesis register-chain deploy-l2-contracts accept-chain-ownership initialize-bridges deploy-consensus-registry deploy-multicall3 deploy-timestamp-asserter deploy-upgrader deploy-paymaster update-token-multiplier-setter enable-evm-emulator help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l chain-name -r complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from create" -l chain-id -d 'Chain ID' -r @@ -331,7 +331,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_s complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "deploy-upgrader" -d 'Deploy Default Upgrader' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "deploy-paymaster" -d 'Deploy paymaster smart contract' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "update-token-multiplier-setter" -d 'Update Token Multiplier Setter address on L1' -complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain' +complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain (Not supported yet)' complete -c zkstack -n "__fish_zkstack_using_subcommand chain; and __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and not __fish_seen_subcommand_from database test clean snapshot lint fmt prover contracts config-writer send-transactions status generate-genesis help" -l chain -d 'Chain to use' -r complete -c zkstack -n "__fish_zkstack_using_subcommand dev; and not __fish_seen_subcommand_from database test clean snapshot lint fmt prover contracts config-writer send-transactions status generate-genesis help" -s v -l verbose -d 'Verbose mode' @@ -759,7 +759,7 @@ complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_su complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "deploy-upgrader" -d 'Deploy Default Upgrader' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "deploy-paymaster" -d 'Deploy paymaster smart contract' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "update-token-multiplier-setter" -d 'Update Token Multiplier Setter address on L1' -complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain' +complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from chain" -f -a "enable-evm-emulator" -d 'Enable EVM emulation on chain (Not supported yet)' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from dev" -f -a "database" -d 'Database related commands' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from dev" -f -a "test" -d 'Run tests' complete -c zkstack -n "__fish_zkstack_using_subcommand help; and __fish_seen_subcommand_from dev" -f -a "clean" -d 'Clean artifacts' diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs index 84b189e5a8bd..c7d31ddf7dbc 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/mod.rs @@ -68,7 +68,7 @@ pub enum ChainCommands { DeployPaymaster(ForgeScriptArgs), /// Update Token Multiplier Setter address on L1 UpdateTokenMultiplierSetter(ForgeScriptArgs), - /// Enable EVM emulation on chain + /// Enable EVM emulation on chain (Not supported yet) EnableEvmEmulator(ForgeScriptArgs), } From 2862cbfb29ad02f674be2395a05fe30bd1dffeef Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Wed, 18 Dec 2024 13:41:57 +0100 Subject: [PATCH 13/17] Update comments in zk --- infrastructure/zk/src/init.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/zk/src/init.ts b/infrastructure/zk/src/init.ts index fc0e550dd84b..71ae7e1d7469 100644 --- a/infrastructure/zk/src/init.ts +++ b/infrastructure/zk/src/init.ts @@ -265,7 +265,7 @@ export const initCommand = new Command('init') 'used to test LegacyBridge compatibily. The chain will have the same id as the era chain id, while eraChainId in L2SharedBridge will be 0' ) .option('--should-check-postgres', 'Whether to perform cargo sqlx prepare --check during database setup', true) - .option('--allow-evm-emulator', 'allow deployment of EVM contracts') + .option('--allow-evm-emulator', 'allow deployment of EVM contracts (not supported yet)') .description('Deploys the shared bridge and registers a hyperchain locally, as quickly as possible.') .action(initDevCmdAction); @@ -290,5 +290,5 @@ initCommand .option('--base-token-name ', 'base token name') .option('--validium-mode', 'deploy contracts in Validium mode') .option('--run-observability', 'run observability suite') - .option('--allow-evm-emulator', 'allow deployment of EVM contracts') + .option('--allow-evm-emulator', 'allow deployment of EVM contracts (not supported yet)') .action(initHyperCmdAction); From e253b8241afc00f25a0af5661d38b5ad8bbfbb70 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Thu, 19 Dec 2024 15:15:28 +0100 Subject: [PATCH 14/17] Remove unused code from zkstack_cli --- .../src/forge_interface/enable_evm_emulator/mod.rs | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs diff --git a/zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs b/zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs deleted file mode 100644 index 61c794afe600..000000000000 --- a/zkstack_cli/crates/config/src/forge_interface/enable_evm_emulator/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -use ethers::types::Address; -use serde::{Deserialize, Serialize}; - -use crate::traits::ZkStackConfig; - -impl ZkStackConfig for EnableEvmEmulatorInput {} - -#[derive(Debug, Deserialize, Serialize, Clone)] -pub struct EnableEvmEmulatorInput { - pub target_addr: Address, - pub governor: Address, -} From d4dfd7f8f33a052ba43cf9a53fbba08872fb2c6b Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Thu, 19 Dec 2024 15:20:47 +0100 Subject: [PATCH 15/17] Simplify enable_evm_emulator.rs --- .../crates/zkstack/src/enable_evm_emulator.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs index 7a733c4e3881..cd55882c013e 100644 --- a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs @@ -5,7 +5,6 @@ use common::{ }; use config::{forge_interface::script_params::ENABLE_EVM_EMULATOR_PARAMS, EcosystemConfig}; use ethers::{abi::parse_abi, contract::BaseContract, types::Address}; -use lazy_static::lazy_static; use xshell::Shell; use crate::{ @@ -13,13 +12,6 @@ use crate::{ utils::forge::{check_the_balance, fill_forge_private_key, WalletOwner}, }; -lazy_static! { - static ref ENABLE_EVM_EMULATOR: BaseContract = BaseContract::from( - parse_abi(&["function chainAllowEvmEmulation(address chainAdmin, address target) public",]) - .unwrap(), - ); -} - pub async fn enable_evm_emulator( shell: &Shell, ecosystem_config: &EcosystemConfig, @@ -29,7 +21,11 @@ pub async fn enable_evm_emulator( forge_args: &ForgeScriptArgs, l1_rpc_url: String, ) -> anyhow::Result<()> { - let calldata = ENABLE_EVM_EMULATOR + let enable_evm_emulator_contract = BaseContract::from( + parse_abi(&["function chainAllowEvmEmulation(address chainAdmin, address target) public",]) + .unwrap(), + ); + let calldata = enable_evm_emulator_contract .encode("chainAllowEvmEmulation", (admin, target_address)) .unwrap(); let foundry_contracts_path = ecosystem_config.path_to_foundry(); From ca9ce5a4b32ad3b47b5b6af1086d70ee9607bc74 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Thu, 19 Dec 2024 15:21:09 +0100 Subject: [PATCH 16/17] Cargo fmt --- zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs index cd55882c013e..67ff43b75546 100644 --- a/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/enable_evm_emulator.rs @@ -22,7 +22,7 @@ pub async fn enable_evm_emulator( l1_rpc_url: String, ) -> anyhow::Result<()> { let enable_evm_emulator_contract = BaseContract::from( - parse_abi(&["function chainAllowEvmEmulation(address chainAdmin, address target) public",]) + parse_abi(&["function chainAllowEvmEmulation(address chainAdmin, address target) public"]) .unwrap(), ); let calldata = enable_evm_emulator_contract From 7fe089535de1edba80def408b015476252e7ee93 Mon Sep 17 00:00:00 2001 From: Vladislav Volosnikov Date: Thu, 19 Dec 2024 16:53:08 +0100 Subject: [PATCH 17/17] Address nits --- .../zkstack/src/commands/chain/enable_evm_emulator.rs | 7 +++---- zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs index f1bab14f2969..a6bbd2c9dc70 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/enable_evm_emulator.rs @@ -21,10 +21,9 @@ pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> { shell, EcosystemConfig::default_configs_path(&chain_config.link_to_code), )?; + let has_evm_emulation_support = default_genesis_config.evm_emulator_hash.is_some(); - if !has_evm_emulation_support { - anyhow::bail!(MSG_EVM_EMULATOR_HASH_MISSING_ERR); - } + anyhow::ensure!(has_evm_emulation_support, MSG_EVM_EMULATOR_HASH_MISSING_ERR); let contracts = chain_config.get_contracts_config()?; let secrets = chain_config.get_secrets_config()?; @@ -42,7 +41,7 @@ pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> { &chain_config.get_wallets_config()?.governor, contracts.l1.diamond_proxy_addr, &args, - l1_rpc_url.clone(), + l1_rpc_url, ) .await?; logger::success(MSG_EVM_EMULATOR_ENABLED); diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs index bd815caceabf..b582f49cf4a4 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs @@ -110,7 +110,7 @@ pub async fn init( contracts_config.l1.chain_admin_addr, &chain_config.get_wallets_config()?.governor, contracts_config.l1.diamond_proxy_addr, - &init_args.forge_args.clone(), + &init_args.forge_args, init_args.l1_rpc_url.clone(), ) .await?; @@ -130,7 +130,7 @@ pub async fn init( .token_multiplier_setter .context(MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND)? .address, - &init_args.forge_args.clone(), + &init_args.forge_args, init_args.l1_rpc_url.clone(), ) .await?; @@ -145,7 +145,7 @@ pub async fn init( contracts_config.l1.chain_admin_addr, &chain_config.get_wallets_config()?.governor, contracts_config.l1.diamond_proxy_addr, - &init_args.forge_args.clone(), + &init_args.forge_args, init_args.l1_rpc_url.clone(), ) .await?;