Skip to content

Commit

Permalink
Move register chain
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Nov 16, 2024
1 parent 87f95ab commit 181f009
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub struct RegisterChainL1Config {
contracts_config: Contracts,
deployed_addresses: DeployedAddresses,
chain: ChainL1Config,
owner_address: Address,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
Expand All @@ -46,8 +45,11 @@ pub struct ChainL1Config {
impl ZkStackConfig for RegisterChainL1Config {}

impl RegisterChainL1Config {
pub fn new(chain_config: &ChainConfig, contracts: &ContractsConfig) -> anyhow::Result<Self> {
let wallets_config = chain_config.get_wallets_config()?;
pub fn new(
chain_id: L2ChainId,
contracts: &ContractsConfig,
proposal_author: Address,
) -> anyhow::Result<Self> {
Ok(Self {
contracts_config: Contracts {
diamond_cut_data: contracts.ecosystem_contracts.diamond_cut_data.clone(),
Expand All @@ -65,11 +67,10 @@ impl RegisterChainL1Config {
chain_registrar: contracts.ecosystem_contracts.chain_registrar,
},
chain: ChainL1Config {
chain_chain_id: chain_config.chain_id,
proposal_author: wallets_config.governor.address,
chain_chain_id: chain_id,
proposal_author,
bridgehub_create_new_chain_salt: rand::thread_rng().gen_range(0..=i64::MAX) as u64,
},
owner_address: wallets_config.governor.address,
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::PathBuf;

use clap::Parser;
use common::{config::global_config, forge::ForgeScriptArgs, Prompt};
use ethers::abi::Address;
use serde::{Deserialize, Serialize};
use url::Url;

Expand All @@ -24,6 +25,8 @@ pub struct BuildTransactionsArgs {
pub forge_args: ForgeScriptArgs,
#[clap(long, help = MSG_L1_RPC_URL_HELP)]
pub l1_rpc_url: Option<String>,
#[clap(long)]
pub proposal_author: Option<Address>,
}

impl BuildTransactionsArgs {
Expand All @@ -48,6 +51,7 @@ impl BuildTransactionsArgs {
.join(chain_name.unwrap_or(default_chain)),
forge_args: self.forge_args,
l1_rpc_url,
proposal_author: self.proposal_author,
}
}
}
Expand All @@ -57,4 +61,5 @@ pub struct BuildTransactionsArgsFinal {
pub out: PathBuf,
pub forge_args: ForgeScriptArgs,
pub l1_rpc_url: String,
pub proposal_author: Option<Address>,
}

This file was deleted.

29 changes: 16 additions & 13 deletions zkstack_cli/crates/zkstack/src/commands/chain/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ use zksync_basic_types::L2ChainId;

use crate::{
accept_ownership::accept_admin,
commands::chain::{
args::init::{
configs::{InitConfigsArgs, InitConfigsArgsFinal},
InitArgs, InitArgsFinal,
commands::{
chain::{
args::init::{
configs::{InitConfigsArgs, InitConfigsArgsFinal},
InitArgs, InitArgsFinal,
},
common::{distribute_eth, mint_base_token},
deploy_l2_contracts, deploy_paymaster,
genesis::genesis,
init::configs::init_configs,
propose_chain,
setup_legacy_bridge::setup_legacy_bridge,
},
common::{distribute_eth, mint_base_token},
deploy_l2_contracts, deploy_paymaster,
genesis::genesis,
init::configs::init_configs,
propose_chain,
register_chain::register_chain,
setup_legacy_bridge::setup_legacy_bridge,
ecosystem::register_chain::register_chain,
},
messages::{
msg_initializing_chain, MSG_ACCEPTING_ADMIN_SPINNER, MSG_CHAIN_INITIALIZED,
Expand Down Expand Up @@ -89,7 +91,7 @@ pub async fn init(
chain_config,
contracts_config.ecosystem_contracts.chain_registrar,
init_args.l1_rpc_url.clone(),
wallet,
&wallet,
)
.await?;

Expand All @@ -99,10 +101,11 @@ pub async fn init(
shell,
init_args.forge_args.clone(),
ecosystem_config,
chain_config,
&contracts_config,
chain_config.chain_id,
init_args.l1_rpc_url.clone(),
None,
wallet.address,
true,
)
.await?;
Expand Down
12 changes: 0 additions & 12 deletions zkstack_cli/crates/zkstack/src/commands/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,24 @@ use crate::commands::chain::{

mod accept_chain_ownership;
pub(crate) mod args;
mod build_transactions;
mod common;
mod create;
pub mod deploy_l2_contracts;
pub mod deploy_paymaster;
pub mod genesis;
pub mod init;
pub mod propose_chain;
pub mod register_chain;
mod set_token_multiplier_setter;
mod setup_legacy_bridge;

#[derive(Subcommand, Debug)]
pub enum ChainCommands {
/// Create a new chain, setting the necessary configurations for later initialization
Create(ChainCreateArgs),
/// Create unsigned transactions for chain deployment
BuildTransactions(BuildTransactionsArgs),
/// Initialize chain, deploying necessary contracts and performing on-chain operations
Init(Box<ChainInitCommand>),
/// Run server genesis
Genesis(GenesisCommand),
/// 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`
#[command(alias = "register")]
RegisterChain(ForgeScriptArgs),
/// Deploy all L2 contracts (executed by L1 governor).
#[command(alias = "l2")]
DeployL2Contracts(ForgeScriptArgs),
Expand Down Expand Up @@ -77,9 +67,7 @@ pub(crate) async fn run(shell: &Shell, args: ChainCommands) -> anyhow::Result<()
match args {
ChainCommands::Create(args) => create::run(args, shell),
ChainCommands::Init(args) => init::run(*args, shell).await,
ChainCommands::BuildTransactions(args) => build_transactions::run(args, shell).await,
ChainCommands::Genesis(args) => genesis::run(args, shell).await,
ChainCommands::RegisterChain(args) => register_chain::run(args, shell).await,
ChainCommands::DeployL2Contracts(args) => {
deploy_l2_contracts::run(args, shell, Deploy2ContractsOption::All).await
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub async fn run(shell: &Shell, args: ProposeRegistrationArgs) -> anyhow::Result
&chain_config,
args.chain_registrar,
args.l1_rpc_url,
args.main_wallet,
&args.main_wallet,
)
.await
}
Expand All @@ -28,7 +28,7 @@ pub async fn run_propose_chain_registration(
chain_config: &ChainConfig,
chain_registrar: Address,
l1_rpc_url: String,
wallet: Wallet,
wallet: &Wallet,
) -> anyhow::Result<()> {
let wallets = chain_config.get_wallets_config()?;
let spinner = Spinner::new(MSG_REGISTERING_CHAIN_SPINNER);
Expand Down
89 changes: 0 additions & 89 deletions zkstack_cli/crates/zkstack/src/commands/chain/register_chain.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pub mod build_transactions;
pub mod change_default;
pub mod create;
pub mod init;
pub mod register_chain;
Loading

0 comments on commit 181f009

Please sign in to comment.