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

feat(zk_toolbox): Add holesky testnet as layer1 network #2632

Merged
6 changes: 6 additions & 0 deletions core/lib/basic_types/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum Network {
Goerli,
/// Ethereum Sepolia testnet.
Sepolia,
/// Ethereum Holešky testnet.
Holesky,
/// Self-hosted Ethereum network.
Localhost,
/// Self-hosted L2 network.
Expand All @@ -48,6 +50,7 @@ impl FromStr for Network {
"localhost" => Self::Localhost,
"localhostL2" => Self::LocalhostL2,
"sepolia" => Self::Sepolia,
"holesky" => Self::Holesky,
"test" => Self::Test,
another => return Err(another.to_owned()),
})
Expand All @@ -64,6 +67,7 @@ impl fmt::Display for Network {
Self::Localhost => write!(f, "localhost"),
Self::LocalhostL2 => write!(f, "localhostL2"),
Self::Sepolia => write!(f, "sepolia"),
Self::Holesky => write!(f, "holesky"),
Self::Unknown => write!(f, "unknown"),
Self::Test => write!(f, "test"),
}
Expand All @@ -80,6 +84,7 @@ impl Network {
5 => Self::Goerli,
9 => Self::Localhost,
11155111 => Self::Sepolia,
17000 => Self::Holesky,
270 => Self::LocalhostL2,
_ => Self::Unknown,
}
Expand All @@ -94,6 +99,7 @@ impl Network {
Self::Goerli => SLChainId(5),
Self::Localhost => SLChainId(9),
Self::Sepolia => SLChainId(11155111),
Self::Holesky => SLChainId(17000),
Self::LocalhostL2 => SLChainId(270),
Self::Unknown => panic!("Unknown chain ID"),
Self::Test => panic!("Test chain ID"),
Expand Down
2 changes: 2 additions & 0 deletions zk_toolbox/crates/types/src/l1_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum L1Network {
#[default]
Localhost,
Sepolia,
Holesky,
Mainnet,
}

Expand All @@ -30,6 +31,7 @@ impl L1Network {
match self {
L1Network::Localhost => 9,
L1Network::Sepolia => 11_155_111,
L1Network::Holesky => 17000,
L1Network::Mainnet => 1,
}
}
Expand Down
2 changes: 1 addition & 1 deletion zk_toolbox/crates/zk_inception/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Create a new ecosystem and chain, setting necessary configurations for later ini
- `--ecosystem-name <ECOSYSTEM_NAME>`
- `--l1-network <L1_NETWORK>` — L1 Network

Possible values: `localhost`, `sepolia`, `mainnet`
Possible values: `localhost`, `sepolia`, `holesky`, `mainnet`

- `--link-to-code <LINK_TO_CODE>` — Code link
- `--chain-name <CHAIN_NAME>`
Expand Down
28 changes: 21 additions & 7 deletions zk_toolbox/crates/zk_inception/src/commands/ecosystem/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ use crate::{
},
},
messages::{
msg_ecosystem_initialized, msg_initializing_chain, MSG_CHAIN_NOT_INITIALIZED,
msg_ecosystem_initialized, msg_ecosystem_no_found_preexisting_contract,
msg_initializing_chain, MSG_CHAIN_NOT_INITIALIZED,
MSG_DEPLOYING_ECOSYSTEM_CONTRACTS_SPINNER, MSG_DEPLOYING_ERC20,
MSG_DEPLOYING_ERC20_SPINNER, MSG_ECOSYSTEM_CONTRACTS_PATH_INVALID_ERR,
MSG_ECOSYSTEM_CONTRACTS_PATH_PROMPT, MSG_INITIALIZING_ECOSYSTEM,
Expand Down Expand Up @@ -242,17 +243,30 @@ async fn deploy_ecosystem(
}
};

let ecosystem_preexisting_configs_path =
ecosystem_config
.get_preexisting_configs_path()
.join(format!(
"{}.yaml",
ecosystem_config.l1_network.to_string().to_lowercase()
));

// currently there are not some preexisting ecosystem contracts in
// chains, so we need check if this file exists.
if ecosystem_contracts_path.is_none() && !ecosystem_preexisting_configs_path.exists() {
anyhow::bail!(msg_ecosystem_no_found_preexisting_contract(
&ecosystem_config.l1_network.to_string()
))
}

let ecosystem_contracts_path =
ecosystem_contracts_path.unwrap_or_else(|| match ecosystem_config.l1_network {
L1Network::Localhost => {
ContractsConfig::get_path_with_base_path(&ecosystem_config.config)
}
L1Network::Sepolia | L1Network::Mainnet => ecosystem_config
fyInALT marked this conversation as resolved.
Show resolved Hide resolved
.get_preexisting_configs_path()
.join(format!(
"{}.yaml",
ecosystem_config.l1_network.to_string().to_lowercase()
)),
L1Network::Sepolia | L1Network::Holesky | L1Network::Mainnet => {
ecosystem_preexisting_configs_path
}
});

ContractsConfig::read(shell, ecosystem_contracts_path)
Expand Down
4 changes: 4 additions & 0 deletions zk_toolbox/crates/zk_inception/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ pub(super) const MSG_ERA_OBSERVABILITY_ALREADY_SETUP: &str = "Era observability
pub(super) const MSG_DOWNLOADING_ERA_OBSERVABILITY_SPINNER: &str =
"Downloading era observability...";

pub(super) fn msg_ecosystem_no_found_preexisting_contract(chains: &str) -> String {
format!("Not found preexisting ecosystem Contracts with chains {chains}")
}

pub(super) fn msg_initializing_chain(chain_name: &str) -> String {
format!("Initializing chain {chain_name}")
}
Expand Down
Loading