Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6e0d8a5
Copy consensus secrets
matias-gonz Sep 6, 2024
8049f39
Copy consensus config
matias-gonz Sep 6, 2024
f0c0dc2
Add consensus to external_node::run
matias-gonz Sep 6, 2024
068f191
Merge branch 'main' into matias-zki-consensus
matias-gonz Sep 6, 2024
f277585
Fix consensus secrets
matias-gonz Sep 6, 2024
15b1a54
Merge branch 'matias-zki-consensus' of github.com:matter-labs/zksync-…
matias-gonz Sep 6, 2024
a51a3e3
Add generate_consensus_secrets
matias-gonz Sep 9, 2024
e5bf82f
Add consensus config
matias-gonz Sep 9, 2024
c0b6053
Set en consensus config
matias-gonz Sep 9, 2024
b3866ba
impl SaveConfig for ConsensusConfig
matias-gonz Sep 10, 2024
ecae56e
Generate consensus_secrets
matias-gonz Sep 10, 2024
a1bb148
Remove unused CONSENSUS_SECRETS_PATH
matias-gonz Sep 10, 2024
b6a99e1
Fix public addr parse
matias-gonz Sep 10, 2024
f54c1cf
set correct key configs
Deniallugo Sep 10, 2024
7892527
Merge pull request #2831 from matter-labs/deniallugo-set-correct-key-…
matias-gonz Sep 10, 2024
b8523bf
remove unused params
matias-gonz Sep 10, 2024
8f5b3aa
Switch order
matias-gonz Sep 10, 2024
a3bafe3
Update public and server address
matias-gonz Sep 10, 2024
ec7dbb4
move consensus keys
matias-gonz Sep 10, 2024
149fafb
Fix main node server and public address ports
matias-gonz Sep 10, 2024
b580b11
Make consensus config optional
matias-gonz Sep 10, 2024
9b4fb26
Add update_port_in_host
matias-gonz Sep 10, 2024
ace46fa
Merge branch 'main' of github.com:matter-labs/zksync-era into matias-…
matias-gonz Sep 10, 2024
90d6305
Merge branch 'main' into matias-zki-consensus
matias-gonz Sep 11, 2024
1a1c47a
Add consensus to ci
matias-gonz Sep 11, 2024
ef57ee7
Merge branch 'matias-zki-consensus' of github.com:matter-labs/zksync-…
matias-gonz Sep 11, 2024
36b46e6
Add basic_witness_input_producer to RocksDbs
matias-gonz Sep 11, 2024
69bf960
Create consensus chain with custom token
matias-gonz Sep 11, 2024
318b240
Create consensus utils
matias-gonz Sep 11, 2024
5ed80d7
Update consensus utils
matias-gonz Sep 11, 2024
82068e0
Add get_consensus_config
matias-gonz Sep 11, 2024
c3fe95e
Make strucs pub
matias-gonz Sep 11, 2024
5a2a394
Use Url::parse in update_port_in_host
matias-gonz Sep 11, 2024
e3b4052
Use SocketAddr instead of strings
matias-gonz Sep 11, 2024
fabd6b9
Update constants
matias-gonz Sep 11, 2024
43bcc1a
Merge branch 'main' into matias-zki-consensus
Deniallugo Sep 11, 2024
76d5574
Update constants
matias-gonz Sep 12, 2024
fc4bd6a
Merge branch 'matias-zki-consensus' of github.com:matter-labs/zksync-…
matias-gonz Sep 12, 2024
7df30b6
Change SecretKeys to ConsensusSecretKeys
matias-gonz Sep 12, 2024
3ee92a1
Change let if to map
matias-gonz Sep 12, 2024
8c1c48d
fmt
matias-gonz Sep 12, 2024
729388e
Merge branch 'main' into matias-zki-consensus
Deniallugo Sep 12, 2024
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
2 changes: 2 additions & 0 deletions zk_toolbox/crates/common/src/external_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub fn run(
config_path: &str,
secrets_path: &str,
en_config_path: &str,
consensus_args: Vec<String>,
additional_args: Vec<String>,
) -> anyhow::Result<()> {
let _dir = shell.push_dir(code_path);
Expand All @@ -22,6 +23,7 @@ pub fn run(
--external-node-config-path {en_config_path}
"
)
.args(consensus_args)
.args(additional_args)
.env_remove("RUSTUP_TOOLCHAIN"),
)
Expand Down
7 changes: 7 additions & 0 deletions zk_toolbox/crates/config/src/consensus_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use zksync_config::configs::consensus::ConsensusConfig;

use crate::{traits::FileConfigWithDefaultName, CONSENSUS_CONFIG_FILE};

impl FileConfigWithDefaultName for ConsensusConfig {
const FILE_NAME: &'static str = CONSENSUS_CONFIG_FILE;
}
14 changes: 14 additions & 0 deletions zk_toolbox/crates/config/src/consensus_secrets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::path::Path;

use xshell::Shell;
use zksync_config::configs::consensus::ConsensusSecrets;
use zksync_protobuf_config::decode_yaml_repr;

use crate::traits::ReadConfig;

impl ReadConfig for ConsensusSecrets {
fn read(shell: &Shell, path: impl AsRef<Path>) -> anyhow::Result<Self> {
let path = shell.current_dir().join(path);
decode_yaml_repr::<zksync_protobuf_config::proto::secrets::ConsensusSecrets>(&path, false)
}
}
2 changes: 2 additions & 0 deletions zk_toolbox/crates/config/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub const GENESIS_FILE: &str = "genesis.yaml";

// Name of external node specific config
pub const EN_CONFIG_FILE: &str = "external_node.yaml";
// Name of consensus config
pub const CONSENSUS_CONFIG_FILE: &str = "consensus_config.yaml";
pub(crate) const ERC20_CONFIGS_FILE: &str = "erc20.yaml";
/// Name of the initial deployments config file
pub(crate) const INITIAL_DEPLOYMENT_FILE: &str = "initial_deployments.yaml";
Expand Down
2 changes: 2 additions & 0 deletions zk_toolbox/crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ mod secrets;
mod wallet_creation;
mod wallets;

pub mod consensus_config;
pub mod consensus_secrets;
pub mod docker_compose;
pub mod explorer;
pub mod explorer_compose;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use clap::Parser;
use serde::{Deserialize, Serialize};

use crate::messages::{MSG_SERVER_ADDITIONAL_ARGS_HELP, MSG_SERVER_COMPONENTS_HELP};
use crate::messages::{
MSG_ENABLE_CONSENSUS_HELP, MSG_SERVER_ADDITIONAL_ARGS_HELP, MSG_SERVER_COMPONENTS_HELP,
};

#[derive(Debug, Serialize, Deserialize, Parser)]
pub struct RunExternalNodeArgs {
#[clap(long)]
pub reinit: bool,
#[clap(long, help = MSG_SERVER_COMPONENTS_HELP)]
pub components: Option<Vec<String>>,
#[clap(long, help = MSG_ENABLE_CONSENSUS_HELP, default_missing_value = "true", num_args = 0..=1)]
pub enable_consensus: Option<bool>,
#[clap(long, short)]
#[arg(trailing_var_arg = true, allow_hyphen_values = true, hide = false, help = MSG_SERVER_ADDITIONAL_ARGS_HELP)]
pub additional_args: Vec<String>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
use std::{path::Path, str::FromStr};

use anyhow::Context;
use common::{config::global_config, logger};
use common::{cmd::Cmd, config::global_config, logger};
use config::{
external_node::ENConfig, ports_config, set_rocks_db_config, traits::SaveConfigWithBasePath,
external_node::ENConfig,
ports_config, set_rocks_db_config,
traits::{ReadConfig, SaveConfigWithBasePath},
update_ports, ChainConfig, EcosystemConfig, SecretsConfig,
};
use xshell::Shell;
use xshell::{cmd, Shell};
use zksync_basic_types::url::SensitiveUrl;
use zksync_config::configs::{DatabaseSecrets, L1Secrets};
use zksync_config::configs::{consensus::ConsensusSecrets, DatabaseSecrets, L1Secrets};

use crate::{
commands::external_node::args::prepare_configs::{PrepareConfigArgs, PrepareConfigFinal},
consts::{CONSENSUS_CONFIG_PATH, CONSENSUS_SECRETS_PATH},
messages::{
msg_preparing_en_config_is_done, MSG_CHAIN_NOT_INITIALIZED, MSG_PREPARING_EN_CONFIGS,
},
Expand Down Expand Up @@ -71,8 +74,14 @@ fn prepare_configs(
.context("da")?
.next_empty_ports_config(),
)?;

let consensus_config_path = config.link_to_code.join(CONSENSUS_CONFIG_PATH);
Cmd::new(cmd!(shell, "cp {consensus_config_path} {en_configs_path}")).run()?;

let consensus_secrets_path = config.link_to_code.join(CONSENSUS_SECRETS_PATH);
let consensus_secrets = ConsensusSecrets::read(shell, consensus_secrets_path)?;
let secrets = SecretsConfig {
consensus: None,
consensus: Some(consensus_secrets),
database: Some(DatabaseSecrets {
server_url: Some(args.db.full_url().into()),
prover_url: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async fn run_external_node(
if args.reinit {
init::init(shell, chain_config).await?
}
let enable_consensus = args.enable_consensus.unwrap_or(false);
let server = RunExternalNode::new(args.components.clone(), chain_config)?;
server.run(shell, args.additional_args.clone())
server.run(shell, enable_consensus, args.additional_args.clone())
}
3 changes: 3 additions & 0 deletions zk_toolbox/crates/zk_inception/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ pub const DEFAULT_PROOF_STORE_DIR: &str = "artifacts";
pub const BELLMAN_CUDA_DIR: &str = "era-bellman-cuda";
pub const L2_BASE_TOKEN_ADDRESS: &str = "0x000000000000000000000000000000000000800A";

pub const CONSENSUS_CONFIG_PATH: &str = "etc/env/consensus_config.yaml";
pub const CONSENSUS_SECRETS_PATH: &str = "etc/env/consensus_secrets.yaml";

/// Path to the JS runtime config for the block-explorer-app docker container to be mounted to
pub const EXPLORER_APP_DOCKER_CONFIG_PATH: &str = "/usr/src/app/packages/app/dist/config.js";
pub const EXPLORER_APP_DOCKER_IMAGE: &str = "matterlabs/block-explorer-app";
Expand Down
18 changes: 17 additions & 1 deletion zk_toolbox/crates/zk_inception/src/external_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use config::{
SecretsConfig,
};
use xshell::Shell;
use zksync_config::configs::consensus::ConsensusConfig;

use crate::messages::MSG_FAILED_TO_RUN_SERVER_ERR;

Expand All @@ -15,6 +16,7 @@ pub struct RunExternalNode {
general_config: PathBuf,
secrets: PathBuf,
en_config: PathBuf,
consensus_config: PathBuf,
}

impl RunExternalNode {
Expand All @@ -29,31 +31,45 @@ impl RunExternalNode {
let general_config = GeneralConfig::get_path_with_base_path(&en_path);
let secrets = SecretsConfig::get_path_with_base_path(&en_path);
let enconfig = ENConfig::get_path_with_base_path(&en_path);
let consensus_config = ConsensusConfig::get_path_with_base_path(&en_path);

Ok(Self {
components,
code_path: chain_config.link_to_code.clone(),
general_config,
secrets,
en_config: enconfig,
consensus_config,
})
}

pub fn run(&self, shell: &Shell, mut additional_args: Vec<String>) -> anyhow::Result<()> {
pub fn run(
&self,
shell: &Shell,
enable_consensus: bool,
mut additional_args: Vec<String>,
) -> anyhow::Result<()> {
let code_path = self.code_path.to_str().unwrap();
let config_general_config = &self.general_config.to_str().unwrap();
let en_config = &self.en_config.to_str().unwrap();
let secrets = &self.secrets.to_str().unwrap();
let consensus_config = &self.consensus_config.to_str().unwrap();
if let Some(components) = self.components() {
additional_args.push(format!("--components={}", components))
}
let mut consensus_args = vec![];
if enable_consensus {
consensus_args.push("--enable-consensus".to_string());
consensus_args.push(format!("--consensus-path={}", consensus_config))
}

common::external_node::run(
shell,
code_path,
config_general_config,
secrets,
en_config,
consensus_args,
additional_args,
)
.context(MSG_FAILED_TO_RUN_SERVER_ERR)
Expand Down
1 change: 1 addition & 0 deletions zk_toolbox/crates/zk_inception/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ pub(super) const MSG_DEPLOYING_PAYMASTER: &str = "Deploying paymaster";

/// Run server related messages
pub(super) const MSG_SERVER_COMPONENTS_HELP: &str = "Components of server to run";
pub(super) const MSG_ENABLE_CONSENSUS_HELP: &str = "Enable consensus";
pub(super) const MSG_SERVER_GENESIS_HELP: &str = "Run server in genesis mode";
pub(super) const MSG_SERVER_ADDITIONAL_ARGS_HELP: &str =
"Additional arguments that can be passed through the CLI";
Expand Down
Loading