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

Module driver alex #2

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions etc/env/file_based/wallets/mainnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Wallets for the ecosystem with official Mainnet shared bridge
# All L1 transactions needs to be approved and executed by MatterLabs team
deployer:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
operator:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
blob_operator:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
fee_account:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
governor:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
token_multiplier_setter:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
20 changes: 20 additions & 0 deletions etc/env/file_based/wallets/sepolia.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Wallets for the ecosystem with official Sepolia shared bridge
# All L1 transactions needs to be approved and executed by MatterLabs team
deployer:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
operator:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
blob_operator:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
fee_account:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
governor:
address: 0xd64e136566a9e04eb05b30184ff577f52682d182
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
token_multiplier_setter:
address: 0x0000000000000000000000000000000000000000
private_key: 0x0000000000000000000000000000000000000000000000000000000000000000
1 change: 1 addition & 0 deletions zk_toolbox/Cargo.lock

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

7 changes: 6 additions & 1 deletion zk_toolbox/crates/config/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pub const ZKSYNC_ERA_GIT_REPO: &str = "https://github.com/matter-labs/zksync-era
pub const DOCKER_COMPOSE_FILE: &str = "docker-compose.yml";
/// Path to the config file with mnemonic for localhost wallets
pub(crate) const CONFIGS_PATH: &str = "etc/env/file_based";
pub(crate) const WALLETS_DIR: &str = "wallets/";
pub const MAINNET_FILE: &str = "mainnet.yaml";
pub const SEPOLIA_FILE: &str = "sepolia.yaml";
/// Path to the docker-compose file for grafana
pub const ERA_OBSERVABILITY_COMPOSE_FILE: &str = "era-observability/docker-compose.yml";
/// Path to era observability repository
Expand Down Expand Up @@ -73,12 +76,14 @@ pub const EXPLORER_WORKER_DOCKER_IMAGE: &str = "matterlabs/block-explorer-worker
pub const EXPLORER_BATCHES_PROCESSING_POLLING_INTERVAL: u64 = 1000;

/// Path to ecosystem contacts
pub(crate) const ECOSYSTEM_PATH: &str = "etc/env/ecosystems";
pub const ECOSYSTEM_PATH: &str = "etc/env/ecosystems";

/// Path to l1 contracts foundry folder inside zksync-era
pub(crate) const L1_CONTRACTS_FOUNDRY: &str = "contracts/l1-contracts";

pub(crate) const ERA_CHAIN_ID: u32 = 270;
pub(crate) const ZKSYNC_MAINNET_CHAIN_ID: u32 = 324;
pub(crate) const ZKSYNC_SEPOLIA_CHAIN_ID: u32 = 300;

pub(crate) const TEST_CONFIG_PATH: &str = "etc/test_config/constant/eth.json";
pub(crate) const BASE_PATH: &str = "m/44'/60'/0'";
11 changes: 10 additions & 1 deletion zk_toolbox/crates/config/src/ecosystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use crate::{
consts::{
CONFIGS_PATH, CONFIG_NAME, CONTRACTS_FILE, ECOSYSTEM_PATH, ERA_CHAIN_ID,
ERC20_CONFIGS_FILE, ERC20_DEPLOYMENT_FILE, INITIAL_DEPLOYMENT_FILE, L1_CONTRACTS_FOUNDRY,
LOCAL_ARTIFACTS_PATH, LOCAL_DB_PATH, WALLETS_FILE,
LOCAL_ARTIFACTS_PATH, LOCAL_DB_PATH, WALLETS_FILE, ZKSYNC_MAINNET_CHAIN_ID,
ZKSYNC_SEPOLIA_CHAIN_ID,
},
create_localhost_wallets,
forge_interface::deploy_ecosystem::{
Expand Down Expand Up @@ -278,6 +279,14 @@ pub fn get_default_era_chain_id() -> L2ChainId {
L2ChainId::from(ERA_CHAIN_ID)
}

pub fn get_official_zksync_chain_id(network: L1Network) -> anyhow::Result<L2ChainId> {
match network {
L1Network::Mainnet => Ok(L2ChainId::from(ZKSYNC_MAINNET_CHAIN_ID)),
L1Network::Sepolia => Ok(L2ChainId::from(ZKSYNC_SEPOLIA_CHAIN_ID)),
_ => anyhow::bail!("Unsupported network"),
}
}

// Find file in all parents repository and return necessary path or an empty error if nothing has been found
fn find_file(shell: &Shell, path_buf: PathBuf, file_name: &str) -> Result<PathBuf, ()> {
let _dir = shell.push_dir(path_buf);
Expand Down
31 changes: 27 additions & 4 deletions zk_toolbox/crates/config/src/wallet_creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::path::{Path, PathBuf};

use common::wallets::Wallet;
use rand::thread_rng;
use types::WalletCreation;
use types::{L1Network, WalletCreation};
use xshell::Shell;

use crate::{
consts::{BASE_PATH, TEST_CONFIG_PATH},
consts::{BASE_PATH, CONFIGS_PATH, MAINNET_FILE, SEPOLIA_FILE, TEST_CONFIG_PATH, WALLETS_DIR},
traits::{ReadConfig, SaveConfigWithBasePath},
EthMnemonicConfig, WalletsConfig,
};
Expand All @@ -18,11 +18,17 @@ pub fn create_wallets(
id: u32,
wallet_creation: WalletCreation,
initial_wallet_path: Option<PathBuf>,
wallets: Option<WalletsConfig>,
) -> anyhow::Result<()> {
let wallets = match wallet_creation {
WalletCreation::Random => {
let rng = &mut thread_rng();
WalletsConfig::random(rng)
match wallets {
None => {
let rng = &mut thread_rng();
WalletsConfig::random(rng)
}
Some(i) => i
}
}
WalletCreation::Empty => WalletsConfig::empty(),
// Use id of chain for creating
Expand Down Expand Up @@ -65,3 +71,20 @@ pub fn create_localhost_wallets(
)?),
})
}

pub fn copy_official_zksync_wallets(
shell: &Shell,
base_path: &Path,
link_to_code: &Path,
network: L1Network,
) -> anyhow::Result<()> {
let path = link_to_code.join(CONFIGS_PATH).join(WALLETS_DIR);
let wallets_path = match network {
L1Network::Mainnet => path.join(MAINNET_FILE),
L1Network::Sepolia => path.join(SEPOLIA_FILE),
_ => anyhow::bail!("Official bridge is only available for sepolia and mainnet"),
};
let wallets = WalletsConfig::read(shell, wallets_path)?;
wallets.save_with_base_path(shell, base_path)?;
Ok(())
}
1 change: 1 addition & 0 deletions zk_toolbox/crates/zk_inception/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ serde.workspace = true
serde_json.workspace = true
xshell.workspace = true
ethers.workspace = true
rand.workspace = true
common.workspace = true
tokio.workspace = true
types.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl ChainCreateArgs {
.ask()
});

let wallet_path: Option<PathBuf> = if self.wallet_creation == Some(WalletCreation::InFile) {
let wallet_path: Option<PathBuf> = if wallet_creation == WalletCreation::InFile {
Some(self.wallet_path.unwrap_or_else(|| {
Prompt::new(MSG_WALLET_PATH_PROMPT)
.validate_with(|val: &String| {
Expand Down
16 changes: 16 additions & 0 deletions zk_toolbox/crates/zk_inception/src/commands/chain/args/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ pub struct InitArgs {
pub l1_rpc_url: Option<String>,
#[clap(long, help = MSG_PORT_OFFSET_HELP)]
pub port_offset: Option<PortOffset>,
#[arg(
long,
help = "Adhoc flag to run chain registraion from L1 side",
default_value_t = false
)]
pub only_l1: bool,
#[arg(
long,
help = "Adhoc flag to continue chain registraion from L2 side",
default_value_t = false
)]
pub only_l2: bool,
}

impl InitArgs {
Expand Down Expand Up @@ -90,6 +102,8 @@ impl InitArgs {
.port_offset
.unwrap_or(PortOffset::from_chain_id(config.id as u16))
.into(),
only_l1: self.only_l1,
only_l2: self.only_l2,
}
}
}
Expand All @@ -101,4 +115,6 @@ pub struct InitArgsFinal {
pub deploy_paymaster: bool,
pub l1_rpc_url: String,
pub port_offset: u16,
pub only_l1: bool,
pub only_l2: bool,
}
6 changes: 4 additions & 2 deletions zk_toolbox/crates/zk_inception/src/commands/chain/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Context;
use common::{logger, spinner::Spinner};
use config::{
create_local_configs_dir, create_wallets, traits::SaveConfigWithBasePath, ChainConfig,
EcosystemConfig,
EcosystemConfig, WalletsConfig,
};
use xshell::Shell;
use zksync_basic_types::L2ChainId;
Expand Down Expand Up @@ -42,7 +42,7 @@ fn create(
let spinner = Spinner::new(MSG_CREATING_CHAIN_CONFIGURATIONS_SPINNER);
let name = args.chain_name.clone();
let set_as_default = args.set_as_default;
create_chain_inner(args, ecosystem_config, shell)?;
create_chain_inner(args, ecosystem_config, shell, None)?;
if set_as_default {
ecosystem_config.default_chain = name;
ecosystem_config.save_with_base_path(shell, ".")?;
Expand All @@ -58,6 +58,7 @@ pub(crate) fn create_chain_inner(
args: ChainCreateArgsFinal,
ecosystem_config: &EcosystemConfig,
shell: &Shell,
wallets: Option<WalletsConfig>,
) -> anyhow::Result<()> {
if args.legacy_bridge {
logger::warn("WARNING!!! You are creating a chain with legacy bridge, use it only for testing compatibility")
Expand Down Expand Up @@ -98,6 +99,7 @@ pub(crate) fn create_chain_inner(
internal_id,
args.wallet_creation,
args.wallet_path,
wallets,
)?;

chain_config.save_with_base_path(shell, chain_path)?;
Expand Down
61 changes: 0 additions & 61 deletions zk_toolbox/crates/zk_inception/src/commands/chain/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,67 +102,6 @@ pub async fn genesis(
"prover_db_config": args.prover_db,
})),
);
logger::info(MSG_STARTING_GENESIS);

let spinner = Spinner::new(MSG_INITIALIZING_DATABASES_SPINNER);
initialize_databases(
shell,
&args.server_db,
&args.prover_db,
config.link_to_code.clone(),
args.dont_drop,
)
.await?;
spinner.finish();

let spinner = Spinner::new(MSG_STARTING_GENESIS_SPINNER);
run_server_genesis(config, shell)?;
spinner.finish();

Ok(())
}

async fn initialize_databases(
shell: &Shell,
server_db_config: &DatabaseConfig,
prover_db_config: &DatabaseConfig,
link_to_code: PathBuf,
dont_drop: bool,
) -> anyhow::Result<()> {
let path_to_server_migration = link_to_code.join(SERVER_MIGRATIONS);

if global_config().verbose {
logger::debug(MSG_INITIALIZING_SERVER_DATABASE)
}
if !dont_drop {
drop_db_if_exists(server_db_config)
.await
.context(MSG_FAILED_TO_DROP_SERVER_DATABASE_ERR)?;
init_db(server_db_config).await?;
}
migrate_db(
shell,
path_to_server_migration,
&server_db_config.full_url(),
)
.await?;

if global_config().verbose {
logger::debug(MSG_INITIALIZING_PROVER_DATABASE)
}
if !dont_drop {
drop_db_if_exists(prover_db_config)
.await
.context(MSG_FAILED_TO_DROP_PROVER_DATABASE_ERR)?;
init_db(prover_db_config).await?;
}
let path_to_prover_migration = link_to_code.join(PROVER_MIGRATIONS);
migrate_db(
shell,
path_to_prover_migration,
&prover_db_config.full_url(),
)
.await?;

Ok(())
}
Expand Down
Loading
Loading