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 external_node consensus support #2821

Merged
merged 42 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
1 change: 1 addition & 0 deletions prover/crates/lib/keystore/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub fn calculate_snark_vk_hash(keystore: &Keystore) -> anyhow::Result<H256> {
#[cfg(test)]
mod tests {
use std::str::FromStr;

use zksync_utils::env::Workspace;

use super::*;
Expand Down
Loading
Loading