Skip to content

Commit

Permalink
feat(zk_toolbox): Add external_node consensus support (#2821)
Browse files Browse the repository at this point in the history
## What ❔
Add external_node consensus support

---------

Signed-off-by: Danil <deniallugo@gmail.com>
Co-authored-by: Danil <deniallugo@gmail.com>
  • Loading branch information
matias-gonz and Deniallugo authored Sep 12, 2024
1 parent 93b4e08 commit 4a10d7d
Show file tree
Hide file tree
Showing 24 changed files with 640 additions and 66 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci-zk-toolbox-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ jobs:
--prover-db-name=zksync_prover_localhost_custom_token \
--port-offset 3000 \
--chain custom_token
- name: Create and initialize Consensus chain
run: |
ci_run zk_inception chain create \
--chain-name consensus \
--chain-id sequential \
--prover-mode no-proofs \
--wallet-creation localhost \
--l1-batch-commit-data-generator-mode validium \
--base-token-address ${{ env.address }} \
--base-token-price-nominator 3 \
--base-token-price-denominator 2 \
--set-as-default false \
--ignore-prerequisites
ci_run zk_inception chain init \
--deploy-paymaster \
--l1-rpc-url=http://localhost:8545 \
--server-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
--server-db-name=zksync_server_localhost_consensus \
--prover-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
--prover-db-name=zksync_prover_localhost_consensus \
--port-offset 4000 \
--chain consensus
- name: Build test dependencies
run: |
Expand All @@ -142,6 +166,10 @@ jobs:
ci_run zk_inception server --ignore-prerequisites --chain era &> ${{ env.SERVER_LOGS_DIR }}/rollup.log &
ci_run zk_inception server --ignore-prerequisites --chain validium &> ${{ env.SERVER_LOGS_DIR }}/validium.log &
ci_run zk_inception server --ignore-prerequisites --chain custom_token &> ${{ env.SERVER_LOGS_DIR }}/custom_token.log &
ci_run zk_inception server --ignore-prerequisites --chain consensus \
--components=api,tree,eth,state_keeper,housekeeper,commitment_generator,vm_runner_protective_reads,vm_runner_bwip,vm_playground,da_dispatcher,consensus \
&> ${{ env.SERVER_LOGS_DIR }}/consensus.log &
ci_run sleep 5
- name: Run integration tests
Expand All @@ -155,9 +183,13 @@ jobs:
ci_run zk_supervisor test integration --no-deps --ignore-prerequisites --chain custom_token &> ${{ env.INTEGRATION_TESTS_LOGS_DIR }}/custom_token.log &
PID3=$!
ci_run zk_supervisor test integration --no-deps --ignore-prerequisites --chain consensus &> ${{ env.INTEGRATION_TESTS_LOGS_DIR }}/consensus.log &
PID4=$!
wait $PID1
wait $PID2
wait $PID3
wait $PID4
- name: Init external nodes
run: |
Expand All @@ -173,6 +205,10 @@ jobs:
--db-name=zksync_en_localhost_era_custom_token --l1-rpc-url=http://localhost:8545 --chain custom_token
ci_run zk_inception external-node init --ignore-prerequisites --chain custom_token
ci_run zk_inception external-node configs --db-url=postgres://postgres:notsecurepassword@localhost:5432 \
--db-name=zksync_en_localhost_era_consensus --l1-rpc-url=http://localhost:8545 --chain consensus
ci_run zk_inception external-node init --ignore-prerequisites --chain consensus
- name: Run recovery tests (from snapshot)
run: |
Expand All @@ -185,9 +221,13 @@ jobs:
ci_run zk_supervisor test recovery --snapshot --no-deps --ignore-prerequisites --verbose --chain custom_token &> ${{ env.SNAPSHOT_RECOVERY_LOGS_DIR }}//custom_token.log &
PID3=$!
ci_run zk_supervisor test recovery --snapshot --no-deps --ignore-prerequisites --verbose --chain consensus &> ${{ env.SNAPSHOT_RECOVERY_LOGS_DIR }}//consensus.log &
PID4=$!
wait $PID1
wait $PID2
wait $PID3
wait $PID4
- name: Run recovery tests (from genesis)
run: |
Expand All @@ -200,15 +240,20 @@ jobs:
ci_run zk_supervisor test recovery --no-deps --no-kill --ignore-prerequisites --verbose --chain custom_token &> ${{ env.GENESIS_RECOVERY_LOGS_DIR }}/custom_token.log &
PID3=$!
ci_run zk_supervisor test recovery --no-deps --no-kill --ignore-prerequisites --verbose --chain consensus &> ${{ env.GENESIS_RECOVERY_LOGS_DIR }}/consensus.log &
PID4=$!
wait $PID1
wait $PID2
wait $PID3
wait $PID4
- name: Run external node server
run: |
ci_run zk_inception external-node run --ignore-prerequisites --chain era &> ${{ env.EXTERNAL_NODE_LOGS_DIR }}/rollup.log &
ci_run zk_inception external-node run --ignore-prerequisites --chain validium &> ${{ env.EXTERNAL_NODE_LOGS_DIR }}/validium.log &
ci_run zk_inception external-node run --ignore-prerequisites --chain custom_token &> ${{ env.EXTERNAL_NODE_LOGS_DIR }}/custom_token.log &
ci_run zk_inception external-node run --ignore-prerequisites --chain consensus --enable-consensus &> ${{ env.EXTERNAL_NODE_LOGS_DIR }}/consensus.log &
ci_run sleep 5
- name: Run integration tests en
Expand All @@ -222,9 +267,13 @@ jobs:
ci_run zk_supervisor test integration --no-deps --ignore-prerequisites --external-node --chain custom_token &> ${{ env.INTEGRATION_TESTS_EN_LOGS_DIR }}/custom_token.log &
PID3=$!
ci_run zk_supervisor test integration --no-deps --ignore-prerequisites --external-node --chain consensus &> ${{ env.INTEGRATION_TESTS_EN_LOGS_DIR }}/consensus.log &
PID4=$!
wait $PID1
wait $PID2
wait $PID3
wait $PID4
- name: Run revert tests
run: |
Expand All @@ -239,10 +288,14 @@ jobs:
ci_run zk_supervisor test revert --no-deps --external-node --no-kill --ignore-prerequisites --chain custom_token &> ${{ env.REVERT_LOGS_DIR }}/custom_token.log &
PID3=$!
ci_run zk_supervisor test revert --no-deps --external-node --no-kill --ignore-prerequisites --chain consensus &> ${{ env.REVERT_LOGS_DIR }}/consensus.log &
PID4=$!
wait $PID1
wait $PID2
wait $PID3
wait $PID4
# Upgrade tests should run last, because as soon as they
Expand Down
8 changes: 7 additions & 1 deletion core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,7 @@ pub(crate) struct ExternalNodeConfig<R = RemoteENConfig> {
pub observability: ObservabilityENConfig,
pub experimental: ExperimentalENConfig,
pub consensus: Option<ConsensusConfig>,
pub consensus_secrets: Option<ConsensusSecrets>,
pub api_component: ApiComponentConfig,
pub tree_component: TreeComponentConfig,
pub remote: R,
Expand All @@ -1240,6 +1241,8 @@ impl ExternalNodeConfig<()> {
tree_component: envy::prefixed("EN_TREE_")
.from_env::<TreeComponentConfig>()
.context("could not load external node config (tree component params)")?,
consensus_secrets: read_consensus_secrets()
.context("config::read_consensus_secrets()")?,
remote: (),
})
}
Expand All @@ -1262,7 +1265,7 @@ impl ExternalNodeConfig<()> {
.map(read_yaml_repr::<proto::consensus::Config>)
.transpose()
.context("failed decoding consensus YAML config")?;

let consensus_secrets = secrets_config.consensus.clone();
let required = RequiredENConfig::from_configs(
&general_config,
&external_node_config,
Expand Down Expand Up @@ -1298,6 +1301,7 @@ impl ExternalNodeConfig<()> {
consensus,
api_component,
tree_component,
consensus_secrets,
remote: (),
})
}
Expand Down Expand Up @@ -1332,6 +1336,7 @@ impl ExternalNodeConfig<()> {
consensus: self.consensus,
tree_component: self.tree_component,
api_component: self.api_component,
consensus_secrets: self.consensus_secrets,
remote,
})
}
Expand All @@ -1348,6 +1353,7 @@ impl ExternalNodeConfig {
observability: ObservabilityENConfig::default(),
experimental: ExperimentalENConfig::mock(),
consensus: None,
consensus_secrets: None,
api_component: ApiComponentConfig {
tree_api_remote_url: None,
},
Expand Down
9 changes: 2 additions & 7 deletions core/bin/external_node/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ use zksync_node_framework::{
};
use zksync_state::RocksdbStorageOptions;

use crate::{
config::{self, ExternalNodeConfig},
metrics::framework::ExternalNodeMetricsLayer,
Component,
};
use crate::{config::ExternalNodeConfig, metrics::framework::ExternalNodeMetricsLayer, Component};

/// Builder for the external node.
#[derive(Debug)]
Expand Down Expand Up @@ -240,8 +236,7 @@ impl ExternalNodeBuilder {

fn add_consensus_layer(mut self) -> anyhow::Result<Self> {
let config = self.config.consensus.clone();
let secrets =
config::read_consensus_secrets().context("config::read_consensus_secrets()")?;
let secrets = self.config.consensus_secrets.clone();
let layer = ExternalNodeConsensusLayer {
build_version: crate::metadata::SERVER_VERSION
.parse()
Expand Down
3 changes: 2 additions & 1 deletion core/lib/config/src/configs/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::{BTreeMap, BTreeSet};

use secrecy::{ExposeSecret as _, Secret};
use secrecy::ExposeSecret as _;
pub use secrecy::Secret;
use zksync_basic_types::{ethabi, L2ChainId};
use zksync_concurrency::{limiter, time};

Expand Down
Loading

0 comments on commit 4a10d7d

Please sign in to comment.