Skip to content

Commit

Permalink
genesis split
Browse files Browse the repository at this point in the history
  • Loading branch information
sanekmelnikov committed Sep 27, 2024
1 parent 859ce92 commit 3b09f5b
Show file tree
Hide file tree
Showing 15 changed files with 424 additions and 210 deletions.
3 changes: 1 addition & 2 deletions docs/guides/external-node/00_quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ cd docker-compose-examples
docker compose --file testnet-external-node-docker-compose.yml down --volumes
```

You can see the status of the node (after recovery) in
[local grafana dashboard](http://localhost:3000/dashboards).
You can see the status of the node (after recovery) in [local grafana dashboard](http://localhost:3000/dashboards).

Those commands start ZKsync node locally inside docker.

Expand Down
33 changes: 4 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6903,7 +6903,7 @@ jest-each@^29.7.0:
jest-util "^29.7.0"
pretty-format "^29.7.0"

jest-environment-node@^29.7.0:
jest-environment-node@^29.0.3, jest-environment-node@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-29.7.0.tgz#0b93e111dda8ec120bc8300e6d1fb9576e164376"
integrity sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==
Expand Down Expand Up @@ -9816,7 +9816,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -9833,15 +9833,6 @@ string-width@^2.1.0, string-width@^2.1.1:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"

string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -9908,7 +9899,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -9929,13 +9920,6 @@ strip-ansi@^5.1.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -10781,16 +10765,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down
34 changes: 34 additions & 0 deletions zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Context;
use clap::Parser;
use common::{db::DatabaseConfig, Prompt};
use config::ChainConfig;
Expand Down Expand Up @@ -78,6 +79,39 @@ impl GenesisArgs {
}
}

pub fn fill_values_with_secrets(
mut self,
chain_config: &ChainConfig,
) -> anyhow::Result<GenesisArgsFinal> {
let secrets = chain_config.get_secrets_config()?;
let database = secrets
.database
.context("Database secrets must be present")?;

let (server_db_url, server_db_name) = if let Some(db_full_url) = database.server_url {
let db_config = DatabaseConfig::from_url(db_full_url.expose_url())
.context("Invalid server database URL")?;
(Some(db_config.url), Some(db_config.name))
} else {
(None, None)
};

let (prover_db_url, prover_db_name) = if let Some(db_full_url) = database.prover_url {
let db_config = DatabaseConfig::from_url(db_full_url.expose_url())
.context("Invalid prover database URL")?;
(Some(db_config.url), Some(db_config.name))
} else {
(None, None)
};

self.server_db_url = self.server_db_url.or(server_db_url);
self.server_db_name = self.server_db_name.or(server_db_name);
self.prover_db_url = self.prover_db_url.or(prover_db_url);
self.prover_db_name = self.prover_db_name.or(prover_db_name);

Ok(self.fill_values_with_prompt(chain_config))
}

pub fn reset_db_names(&mut self) {
self.prover_db_name = None;
self.prover_db_url = None;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ pub struct InitArgs {
pub l1_rpc_url: Option<String>,
#[clap(long, help = MSG_PORT_OFFSET_HELP)]
pub port_offset: Option<PortOffset>,
/// Only create chain configs
#[clap(long, default_value_t = false)]
pub configs_only: bool,
}

impl InitArgs {
Expand Down Expand Up @@ -93,7 +90,6 @@ impl InitArgs {
.port_offset
.unwrap_or(PortOffset::from_chain_id(config.id as u16))
.into(),
configs_only: self.configs_only,
}
}
}
Expand All @@ -105,5 +101,4 @@ pub struct InitArgsFinal {
pub deploy_paymaster: bool,
pub l1_rpc_url: String,
pub port_offset: u16,
pub configs_only: bool,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use clap::Parser;
use common::Prompt;
use config::ChainConfig;
use serde::{Deserialize, Serialize};
use types::L1Network;
use url::Url;

use super::{genesis::GenesisArgsFinal, init::InitArgsFinal};
use crate::{
commands::chain::args::{genesis::GenesisArgs, init::PortOffset},
defaults::LOCAL_RPC_URL,
messages::{
MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR,
MSG_L1_RPC_URL_PROMPT,
},
};

#[derive(Debug, Clone, Serialize, Deserialize, Parser)]
pub struct InitConfigsArgs {
#[clap(flatten, next_help_heading = MSG_GENESIS_ARGS_HELP)]
#[serde(flatten)]
pub genesis_args: GenesisArgs,
#[clap(long, help = MSG_L1_RPC_URL_HELP)]
pub l1_rpc_url: Option<String>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct InitConfigsArgsFinal {
pub genesis_args: GenesisArgsFinal,
pub l1_rpc_url: String,
pub port_offset: u16,
}

impl InitConfigsArgs {
pub fn fill_values_with_prompt(self, config: &ChainConfig) -> InitConfigsArgsFinal {
let l1_rpc_url = self.l1_rpc_url.unwrap_or_else(|| {
let mut prompt = Prompt::new(MSG_L1_RPC_URL_PROMPT);
if config.l1_network == L1Network::Localhost {
prompt = prompt.default(LOCAL_RPC_URL);
}
prompt
.validate_with(|val: &String| -> Result<(), String> {
Url::parse(val)
.map(|_| ())
.map_err(|_| MSG_L1_RPC_URL_INVALID_ERR.to_string())
})
.ask()
});

InitConfigsArgsFinal {
genesis_args: self.genesis_args.fill_values_with_prompt(config),
l1_rpc_url,
port_offset: PortOffset::from_chain_id(config.id as u16).into(),
}
}
}

impl InitConfigsArgsFinal {
pub fn from_chain_init_args(init_args: &InitArgsFinal) -> InitConfigsArgsFinal {
InitConfigsArgsFinal {
genesis_args: init_args.genesis_args.clone(),
l1_rpc_url: init_args.l1_rpc_url.clone(),
port_offset: init_args.port_offset.clone(),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pub mod build_transactions;
pub mod create;
pub mod genesis;
pub mod init;
pub mod init_configs;
Loading

0 comments on commit 3b09f5b

Please sign in to comment.