From 3b75cf0f21ec86121e7adc93dfef713d479895e3 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 31 Jul 2024 00:06:39 +0100 Subject: [PATCH 01/11] BFT-496: Start polling the DB/API for attestation status --- core/node/consensus/src/config.rs | 1 + core/node/consensus/src/en.rs | 46 ++++++++++++- core/node/consensus/src/mn.rs | 19 +++++- core/node/consensus/src/storage/connection.rs | 11 ++++ core/node/consensus/src/storage/store.rs | 65 +++++++------------ core/node/consensus/src/tests.rs | 7 +- 6 files changed, 101 insertions(+), 48 deletions(-) diff --git a/core/node/consensus/src/config.rs b/core/node/consensus/src/config.rs index a46b1ab5afa7..c2fa13472066 100644 --- a/core/node/consensus/src/config.rs +++ b/core/node/consensus/src/config.rs @@ -147,5 +147,6 @@ pub(super) fn executor( rpc, // TODO: Add to configuration debug_page: None, + batch_poll_interval: time::Duration::seconds(1), }) } diff --git a/core/node/consensus/src/en.rs b/core/node/consensus/src/en.rs index 66bdc822c058..242efa5f0319 100644 --- a/core/node/consensus/src/en.rs +++ b/core/node/consensus/src/en.rs @@ -1,7 +1,14 @@ +use std::sync::Arc; + use anyhow::Context as _; +use async_trait::async_trait; use zksync_concurrency::{ctx, error::Wrap as _, scope, time}; -use zksync_consensus_executor as executor; -use zksync_consensus_roles::validator; +use zksync_consensus_executor::{ + self as executor, + attestation::{AttestationStatusClient, AttestationStatusRunner}, +}; +use zksync_consensus_network::gossip::AttestationStatusWatch; +use zksync_consensus_roles::{attester, validator}; use zksync_consensus_storage::{BatchStore, BlockStore}; use zksync_node_sync::{ fetcher::FetchedBlock, sync_action::ActionQueueSender, MainNodeClient, SyncState, @@ -99,6 +106,18 @@ impl EN { .wrap("BatchStore::new()")?; s.spawn_bg(async { Ok(runner.run(ctx).await?) }); + let (attestation_status, runner) = { + let status = Arc::new(AttestationStatusWatch::default()); + let client = MainNodeAttestationStatus(self.client.clone()); + let runner = AttestationStatusRunner::new( + status.clone(), + Box::new(client), + time::Duration::seconds(5), + ); + (status, runner) + }; + s.spawn_bg(async { Ok(runner.run(ctx).await?) }); + let executor = executor::Executor { config: config::executor(&cfg, &secrets)?, block_store, @@ -111,6 +130,7 @@ impl EN { payload_manager: Box::new(store.clone()), }), attester, + attestation_status, }; executor.run(ctx).await?; @@ -238,3 +258,25 @@ impl EN { Ok(()) } } + +/// Wrapper to call [MainNodeClient::fetch_attestation_status] and adapt the return value to [AttestationStatusClient::next_batch_to_attest]. +pub struct MainNodeAttestationStatus(Box>); + +#[async_trait] +impl AttestationStatusClient for MainNodeAttestationStatus { + async fn next_batch_to_attest( + &self, + ctx: &ctx::Ctx, + ) -> ctx::Result> { + match ctx.wait(self.0.fetch_attestation_status()).await? { + Ok(bn) => { + let bn: u64 = bn.next_batch_to_attest.0.into(); + Ok(Some(attester::BatchNumber(bn))) + } + Err(err) => { + tracing::warn!("AttestationStatus call to main node HTTP RPC failed: {err}"); + Ok(None) + } + } + } +} diff --git a/core/node/consensus/src/mn.rs b/core/node/consensus/src/mn.rs index 29cacf7a548f..68f4ee4e3512 100644 --- a/core/node/consensus/src/mn.rs +++ b/core/node/consensus/src/mn.rs @@ -1,7 +1,10 @@ +use std::sync::Arc; + use anyhow::Context as _; -use zksync_concurrency::{ctx, error::Wrap as _, scope}; +use zksync_concurrency::{ctx, error::Wrap as _, scope, time}; use zksync_config::configs::consensus::{ConsensusConfig, ConsensusSecrets}; -use zksync_consensus_executor::{self as executor, Attester}; +use zksync_consensus_executor::{self as executor, attestation::AttestationStatusRunner, Attester}; +use zksync_consensus_network::gossip::AttestationStatusWatch; use zksync_consensus_roles::validator; use zksync_consensus_storage::{BatchStore, BlockStore}; @@ -61,6 +64,17 @@ pub async fn run_main_node( .wrap("BatchStore::new()")?; s.spawn_bg(runner.run(ctx)); + let (attestation_status, runner) = { + let status = Arc::new(AttestationStatusWatch::default()); + let runner = AttestationStatusRunner::new_from_store( + status.clone(), + batch_store.clone(), + time::Duration::seconds(1), + ); + (status, runner) + }; + s.spawn_bg(runner.run(ctx)); + let executor = executor::Executor { config: config::executor(&cfg, &secrets)?, block_store, @@ -71,6 +85,7 @@ pub async fn run_main_node( payload_manager: Box::new(store.clone()), }), attester, + attestation_status, }; executor.run(ctx).await }) diff --git a/core/node/consensus/src/storage/connection.rs b/core/node/consensus/src/storage/connection.rs index 6bae0a490508..67897268434c 100644 --- a/core/node/consensus/src/storage/connection.rs +++ b/core/node/consensus/src/storage/connection.rs @@ -429,4 +429,15 @@ impl<'a> Connection<'a> { last, }) } + + /// Wrapper for `consensus_dal().next_batch_to_attest()`. + pub async fn next_batch_to_attest( + &mut self, + ctx: &ctx::Ctx, + ) -> ctx::Result { + Ok(ctx + .wait(self.0.consensus_dal().next_batch_to_attest()) + .await? + .context("next_batch_to_attest()")?) + } } diff --git a/core/node/consensus/src/storage/store.rs b/core/node/consensus/src/storage/store.rs index ce73c946a029..bd3329ad48ae 100644 --- a/core/node/consensus/src/storage/store.rs +++ b/core/node/consensus/src/storage/store.rs @@ -444,44 +444,18 @@ impl storage::PersistentBatchStore for Store { self.batches_persisted.clone() } - /// Get the earliest L1 batch number which has to be signed by attesters. - async fn earliest_batch_number_to_sign( + /// Get the next L1 batch number which has to be signed by attesters. + async fn next_batch_to_attest( &self, ctx: &ctx::Ctx, ) -> ctx::Result> { - // This is the rough roadmap of how this logic will evolve: - // 1. Make best effort at gossiping and collecting votes; the `BatchVotes` in consensus only considers the last vote per attesters. - // Still, we can re-sign more than the last batch, anticipating step 2. - // 2. Ask the Main Node what is the earliest batch number that it still expects votes for (ie. what is the last submission + 1). - // 3. Change `BatchVotes` to handle multiple pending batch numbers, anticipating that batch intervals might decrease dramatically. - // 4. Once QC is required to submit to L1, Look at L1 to figure out what is the last submission, and sign after that. - - // Originally this method returned all unsigned batch numbers by doing a DAL query, but we decided it should be okay and cheap - // to resend signatures for already signed batches, and we don't have to worry about skipping them. Because of that, we also - // didn't think it makes sense to query the database for the earliest unsigned batch *after* the submission, because we might - // as well just re-sign everything. Until we have a way to argue about the "last submission" we just re-sign the last 10 to - // try to produce as many QCs as the voting register allows, within reason. - - // The latest decision is not to store batches with gaps between in the database *of the main node*. - // Once we have an API to serve to external nodes the earliest number the main node wants them to sign, - // we can get rid of this method: on the main node we can sign from what `last_batch_qc` returns, and - // while external nodes we can go from whatever the API returned. - - const NUM_BATCHES_TO_SIGN: u64 = 10; - - let Some(last_batch_number) = self - .conn(ctx) - .await? - .get_last_batch_number(ctx) - .await - .wrap("get_last_batch_number")? - else { - return Ok(None); - }; - - Ok(Some(attester::BatchNumber( - last_batch_number.0.saturating_sub(NUM_BATCHES_TO_SIGN), - ))) + Ok(Some( + self.conn(ctx) + .await? + .next_batch_to_attest(ctx) + .await + .wrap("next_batch_to_attest")?, + )) } /// Get the L1 batch QC from storage with the highest number. @@ -524,16 +498,21 @@ impl storage::PersistentBatchStore for Store { ctx: &ctx::Ctx, number: attester::BatchNumber, ) -> ctx::Result> { - let Some(hash) = self - .conn(ctx) - .await? - .batch_hash(ctx, number) - .await - .wrap("batch_hash()")? - else { + let mut conn = self.conn(ctx).await?; + + let Some(hash) = conn.batch_hash(ctx, number).await.wrap("batch_hash()")? else { return Ok(None); }; - Ok(Some(attester::Batch { number, hash })) + + let Some(genesis) = conn.genesis(ctx).await.wrap("genesis()")? else { + return Ok(None); + }; + + Ok(Some(attester::Batch { + number, + hash, + genesis: genesis.hash(), + })) } /// Returns the QC of the batch with the given number. diff --git a/core/node/consensus/src/tests.rs b/core/node/consensus/src/tests.rs index 27c3a7175c7a..a2905b355040 100644 --- a/core/node/consensus/src/tests.rs +++ b/core/node/consensus/src/tests.rs @@ -725,9 +725,14 @@ async fn test_attestation_status_api(version: ProtocolVersionId) { let mut conn = pool.connection(ctx).await?; let number = status.next_batch_to_attest; let hash = conn.batch_hash(ctx, number).await?.unwrap(); + let genesis = conn.genesis(ctx).await?.unwrap().hash(); let cert = attester::BatchQC { signatures: attester::MultiSig::default(), - message: attester::Batch { number, hash }, + message: attester::Batch { + number, + hash, + genesis, + }, }; conn.insert_batch_certificate(ctx, &cert) .await From 5cc23c64f6eab051765d2bfc845c0e06e9a5a385 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 31 Jul 2024 15:42:00 +0100 Subject: [PATCH 02/11] Update the era-consensus ref --- Cargo.lock | 40 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 15 ++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index aa29ded2275b..e03e82059de6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8131,8 +8131,12 @@ dependencies = [ [[package]] name = "zksync_concurrency" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50302b77192891256d180ff2551dc0c3bc4144958b49e9a16c50a0dc218958ba" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "once_cell", @@ -8166,8 +8170,12 @@ dependencies = [ [[package]] name = "zksync_consensus_bft" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2325c7486a8280db1c26c10020350bead6eecb3de03f8bbfd878060f000cdce7" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "async-trait", @@ -8188,8 +8196,12 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5cb8ed0d59593f6147085b77142628e459ba673aa4d48fce064d5b96e31eb36" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "blst", @@ -8212,8 +8224,12 @@ dependencies = [ [[package]] name = "zksync_consensus_executor" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "247b70ec255781b3b740acb744236e771a192922ffbaa52c462b84c4ea67609f" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "rand 0.8.5", @@ -8232,8 +8248,12 @@ dependencies = [ [[package]] name = "zksync_consensus_network" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f10626b79885a9b096cd19ee83d85ef9b0554f061a9db6946f2b7c9d1b2f49ea" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "async-trait", @@ -8267,8 +8287,12 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ffe3e47d99eb943eb94f2f5c9d929b1192bf3e8d1434de0fa6f0090f9c1197e" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "bit-vec", @@ -8289,8 +8313,12 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ae9a0ec64ce9c0af346e50cc87dc257c30259101ce9675b408cb883e096087" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "async-trait", @@ -8309,8 +8337,12 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24dc6135abeefa80f617eb2903fe43d137d362bf673f0651b4894b17069d1fb1" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "rand 0.8.5", @@ -9249,8 +9281,12 @@ dependencies = [ [[package]] name = "zksync_protobuf" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1e7c7820f290db565a1b4ff73aa1175cd7d31498fca8d859eb5aceebd33468c" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "bit-vec", @@ -9270,8 +9306,12 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" version = "0.1.0-rc.4" +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6cafeec1150ae91f1a37c8f0dce6b71b92b93e0c4153d32b4c37e2fd71bce2f" +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" +>>>>>>> 1ada9d3b3 (Update the era-consensus ref) dependencies = [ "anyhow", "heck 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index 8c94e29c4630..ec0e3fe21e15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -181,7 +181,7 @@ tower-http = "0.5.2" tracing = "0.1" tracing-subscriber = "0.3" tracing-opentelemetry = "0.25.0" -time = "0.3.36" # Has to be same as used by `tracing-subscriber` +time = "0.3.36" # Has to be same as used by `tracing-subscriber` url = "2" web3 = "0.19.0" fraction = "0.15.3" @@ -289,3 +289,16 @@ zksync_contract_verification_server = { version = "0.1.0", path = "core/node/con zksync_node_api_server = { version = "0.1.0", path = "core/node/api_server" } zksync_tee_verifier_input_producer = { version = "0.1.0", path = "core/node/tee_verifier_input_producer" } zksync_base_token_adjuster = { version = "0.1.0", path = "core/node/base_token_adjuster" } + +# TODO: Release era-consensus 0.1.0-rc.5 +[patch.crates-io] +zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } From 2f92f9a7558d4b87d78c6e23e311f54119476a3c Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 31 Jul 2024 16:01:48 +0100 Subject: [PATCH 03/11] BFT-496: Use AttesterStatusRunner::init and parse JSON --- core/node/consensus/src/en.rs | 26 +++++++++---------- core/node/consensus/src/mn.rs | 14 +++++----- core/node/consensus/src/storage/connection.rs | 10 +++---- core/node/consensus/src/storage/store.rs | 14 +++++----- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/core/node/consensus/src/en.rs b/core/node/consensus/src/en.rs index 242efa5f0319..ad2ec959aaa1 100644 --- a/core/node/consensus/src/en.rs +++ b/core/node/consensus/src/en.rs @@ -1,5 +1,3 @@ -use std::sync::Arc; - use anyhow::Context as _; use async_trait::async_trait; use zksync_concurrency::{ctx, error::Wrap as _, scope, time}; @@ -7,7 +5,6 @@ use zksync_consensus_executor::{ self as executor, attestation::{AttestationStatusClient, AttestationStatusRunner}, }; -use zksync_consensus_network::gossip::AttestationStatusWatch; use zksync_consensus_roles::{attester, validator}; use zksync_consensus_storage::{BatchStore, BlockStore}; use zksync_node_sync::{ @@ -107,14 +104,14 @@ impl EN { s.spawn_bg(async { Ok(runner.run(ctx).await?) }); let (attestation_status, runner) = { - let status = Arc::new(AttestationStatusWatch::default()); - let client = MainNodeAttestationStatus(self.client.clone()); - let runner = AttestationStatusRunner::new( - status.clone(), - Box::new(client), + AttestationStatusRunner::init( + ctx, + Box::new(MainNodeAttestationStatus(self.client.clone())), time::Duration::seconds(5), - ); - (status, runner) + ) + .await + .map_err(ctx::Error::Canceled) + .wrap("AttestationStatusRunner::init()")? }; s.spawn_bg(async { Ok(runner.run(ctx).await?) }); @@ -269,10 +266,13 @@ impl AttestationStatusClient for MainNodeAttestationStatus { ctx: &ctx::Ctx, ) -> ctx::Result> { match ctx.wait(self.0.fetch_attestation_status()).await? { - Ok(bn) => { - let bn: u64 = bn.next_batch_to_attest.0.into(); - Ok(Some(attester::BatchNumber(bn))) + Ok(Some(status)) => { + let status: zksync_dal::consensus_dal::AttestationStatus = + zksync_protobuf::serde::deserialize(&status.0) + .context("deserialize(AttestationStatus)")?; + Ok(Some(status.next_batch_to_attest)) } + Ok(None) => Ok(None), Err(err) => { tracing::warn!("AttestationStatus call to main node HTTP RPC failed: {err}"); Ok(None) diff --git a/core/node/consensus/src/mn.rs b/core/node/consensus/src/mn.rs index 68f4ee4e3512..0f1bb8dcb33b 100644 --- a/core/node/consensus/src/mn.rs +++ b/core/node/consensus/src/mn.rs @@ -1,10 +1,7 @@ -use std::sync::Arc; - use anyhow::Context as _; use zksync_concurrency::{ctx, error::Wrap as _, scope, time}; use zksync_config::configs::consensus::{ConsensusConfig, ConsensusSecrets}; use zksync_consensus_executor::{self as executor, attestation::AttestationStatusRunner, Attester}; -use zksync_consensus_network::gossip::AttestationStatusWatch; use zksync_consensus_roles::validator; use zksync_consensus_storage::{BatchStore, BlockStore}; @@ -65,13 +62,14 @@ pub async fn run_main_node( s.spawn_bg(runner.run(ctx)); let (attestation_status, runner) = { - let status = Arc::new(AttestationStatusWatch::default()); - let runner = AttestationStatusRunner::new_from_store( - status.clone(), + AttestationStatusRunner::init_from_store( + ctx, batch_store.clone(), time::Duration::seconds(1), - ); - (status, runner) + ) + .await + .map_err(ctx::Error::Canceled) + .wrap("AttestationStatusRunner::init_from_store()")? }; s.spawn_bg(runner.run(ctx)); diff --git a/core/node/consensus/src/storage/connection.rs b/core/node/consensus/src/storage/connection.rs index 67897268434c..07f82ed4fd23 100644 --- a/core/node/consensus/src/storage/connection.rs +++ b/core/node/consensus/src/storage/connection.rs @@ -430,14 +430,14 @@ impl<'a> Connection<'a> { }) } - /// Wrapper for `consensus_dal().next_batch_to_attest()`. - pub async fn next_batch_to_attest( + /// Wrapper for `consensus_dal().attestation_status()`. + pub async fn attestation_status( &mut self, ctx: &ctx::Ctx, - ) -> ctx::Result { + ) -> ctx::Result> { Ok(ctx - .wait(self.0.consensus_dal().next_batch_to_attest()) + .wait(self.0.consensus_dal().attestation_status()) .await? - .context("next_batch_to_attest()")?) + .context("attestation_status()")?) } } diff --git a/core/node/consensus/src/storage/store.rs b/core/node/consensus/src/storage/store.rs index bd3329ad48ae..0e7d403e9c68 100644 --- a/core/node/consensus/src/storage/store.rs +++ b/core/node/consensus/src/storage/store.rs @@ -449,13 +449,13 @@ impl storage::PersistentBatchStore for Store { &self, ctx: &ctx::Ctx, ) -> ctx::Result> { - Ok(Some( - self.conn(ctx) - .await? - .next_batch_to_attest(ctx) - .await - .wrap("next_batch_to_attest")?, - )) + Ok(self + .conn(ctx) + .await? + .attestation_status(ctx) + .await + .wrap("next_batch_to_attest")? + .map(|s| s.next_batch_to_attest)) } /// Get the L1 batch QC from storage with the highest number. From e36e7bbd3b37976c7ec2754657f7d850f309bac8 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 31 Jul 2024 16:14:30 +0100 Subject: [PATCH 04/11] BFT-496: Validate the genesis hash coming from the API --- core/node/consensus/src/en.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/core/node/consensus/src/en.rs b/core/node/consensus/src/en.rs index ad2ec959aaa1..159629a3ae25 100644 --- a/core/node/consensus/src/en.rs +++ b/core/node/consensus/src/en.rs @@ -1,11 +1,14 @@ -use anyhow::Context as _; +use anyhow::{anyhow, Context as _}; use async_trait::async_trait; use zksync_concurrency::{ctx, error::Wrap as _, scope, time}; use zksync_consensus_executor::{ self as executor, attestation::{AttestationStatusClient, AttestationStatusRunner}, }; -use zksync_consensus_roles::{attester, validator}; +use zksync_consensus_roles::{ + attester::{self, GenesisHash}, + validator, +}; use zksync_consensus_storage::{BatchStore, BlockStore}; use zksync_node_sync::{ fetcher::FetchedBlock, sync_action::ActionQueueSender, MainNodeClient, SyncState, @@ -51,6 +54,7 @@ impl EN { // Initialize genesis. let genesis = self.fetch_genesis(ctx).await.wrap("fetch_genesis()")?; + let genesis_hash = genesis.hash(); let mut conn = self.pool.connection(ctx).await.wrap("connection()")?; conn.try_update_genesis(ctx, &genesis) @@ -106,7 +110,10 @@ impl EN { let (attestation_status, runner) = { AttestationStatusRunner::init( ctx, - Box::new(MainNodeAttestationStatus(self.client.clone())), + Box::new(MainNodeAttestationStatus { + client: self.client.clone(), + genesis: genesis_hash, + }), time::Duration::seconds(5), ) .await @@ -257,7 +264,10 @@ impl EN { } /// Wrapper to call [MainNodeClient::fetch_attestation_status] and adapt the return value to [AttestationStatusClient::next_batch_to_attest]. -pub struct MainNodeAttestationStatus(Box>); +struct MainNodeAttestationStatus { + client: Box>, + genesis: GenesisHash, +} #[async_trait] impl AttestationStatusClient for MainNodeAttestationStatus { @@ -265,11 +275,21 @@ impl AttestationStatusClient for MainNodeAttestationStatus { &self, ctx: &ctx::Ctx, ) -> ctx::Result> { - match ctx.wait(self.0.fetch_attestation_status()).await? { + match ctx.wait(self.client.fetch_attestation_status()).await? { Ok(Some(status)) => { let status: zksync_dal::consensus_dal::AttestationStatus = zksync_protobuf::serde::deserialize(&status.0) .context("deserialize(AttestationStatus)")?; + + if status.genesis != self.genesis { + return Err(anyhow!( + "the main node API has different genesis hash than the local one: {:?} != {:?}", + status.genesis, + self.genesis + ) + .into()); + }; + Ok(Some(status.next_batch_to_attest)) } Ok(None) => Ok(None), From cf95843651f089c794e732ba02e5318351f41cc8 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Wed, 31 Jul 2024 23:13:33 +0100 Subject: [PATCH 05/11] Update the era-consensus dependency to runner fix --- Cargo.lock | 40 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 20 ++++++++++---------- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e03e82059de6..c45cdc0d0108 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8132,11 +8132,15 @@ dependencies = [ name = "zksync_concurrency" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50302b77192891256d180ff2551dc0c3bc4144958b49e9a16c50a0dc218958ba" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "once_cell", @@ -8171,11 +8175,15 @@ dependencies = [ name = "zksync_consensus_bft" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2325c7486a8280db1c26c10020350bead6eecb3de03f8bbfd878060f000cdce7" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "async-trait", @@ -8197,11 +8205,15 @@ dependencies = [ name = "zksync_consensus_crypto" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5cb8ed0d59593f6147085b77142628e459ba673aa4d48fce064d5b96e31eb36" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "blst", @@ -8225,11 +8237,15 @@ dependencies = [ name = "zksync_consensus_executor" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "247b70ec255781b3b740acb744236e771a192922ffbaa52c462b84c4ea67609f" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "rand 0.8.5", @@ -8249,11 +8265,15 @@ dependencies = [ name = "zksync_consensus_network" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f10626b79885a9b096cd19ee83d85ef9b0554f061a9db6946f2b7c9d1b2f49ea" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "async-trait", @@ -8288,11 +8308,15 @@ dependencies = [ name = "zksync_consensus_roles" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ffe3e47d99eb943eb94f2f5c9d929b1192bf3e8d1434de0fa6f0090f9c1197e" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "bit-vec", @@ -8314,11 +8338,15 @@ dependencies = [ name = "zksync_consensus_storage" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ae9a0ec64ce9c0af346e50cc87dc257c30259101ce9675b408cb883e096087" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "async-trait", @@ -8338,11 +8366,15 @@ dependencies = [ name = "zksync_consensus_utils" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24dc6135abeefa80f617eb2903fe43d137d362bf673f0651b4894b17069d1fb1" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "rand 0.8.5", @@ -9282,11 +9314,15 @@ dependencies = [ name = "zksync_protobuf" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1e7c7820f290db565a1b4ff73aa1175cd7d31498fca8d859eb5aceebd33468c" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "bit-vec", @@ -9307,11 +9343,15 @@ dependencies = [ name = "zksync_protobuf_build" version = "0.1.0-rc.4" <<<<<<< HEAD +<<<<<<< HEAD source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6cafeec1150ae91f1a37c8f0dce6b71b92b93e0c4153d32b4c37e2fd71bce2f" ======= source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" >>>>>>> 1ada9d3b3 (Update the era-consensus ref) +======= +source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" +>>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) dependencies = [ "anyhow", "heck 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index ec0e3fe21e15..e1d61a190130 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -292,13 +292,13 @@ zksync_base_token_adjuster = { version = "0.1.0", path = "core/node/base_token_a # TODO: Release era-consensus 0.1.0-rc.5 [patch.crates-io] -zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } -zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "638b23e291a35fe9109c68d42f277903aaae0c42" } +zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } From 0f2e524a9035d8561052154f40c2e811426b9186 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Thu, 1 Aug 2024 00:34:23 +0100 Subject: [PATCH 06/11] BFT-496: Prune the external node instead of the main in the test --- core/lib/dal/src/consensus_dal.rs | 1 + core/node/consensus/src/en.rs | 1 + core/node/consensus/src/mn.rs | 2 ++ core/node/consensus/src/tests.rs | 10 +++++++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/lib/dal/src/consensus_dal.rs b/core/lib/dal/src/consensus_dal.rs index 28559e8a62d2..15c4c18b5d88 100644 --- a/core/lib/dal/src/consensus_dal.rs +++ b/core/lib/dal/src/consensus_dal.rs @@ -536,6 +536,7 @@ impl ConsensusDal<'_, '_> { } .await? else { + tracing::info!(%genesis.first_block, "genesis block not found"); return Ok(None); }; Ok(Some(AttestationStatus { diff --git a/core/node/consensus/src/en.rs b/core/node/consensus/src/en.rs index 159629a3ae25..5127ab12352f 100644 --- a/core/node/consensus/src/en.rs +++ b/core/node/consensus/src/en.rs @@ -136,6 +136,7 @@ impl EN { attester, attestation_status, }; + tracing::info!("running the external node executor"); executor.run(ctx).await?; Ok(()) diff --git a/core/node/consensus/src/mn.rs b/core/node/consensus/src/mn.rs index 0f1bb8dcb33b..6023231c9764 100644 --- a/core/node/consensus/src/mn.rs +++ b/core/node/consensus/src/mn.rs @@ -85,6 +85,8 @@ pub async fn run_main_node( attester, attestation_status, }; + + tracing::info!("running the main node executor"); executor.run(ctx).await }) .await diff --git a/core/node/consensus/src/tests.rs b/core/node/consensus/src/tests.rs index a2905b355040..8e1594393eac 100644 --- a/core/node/consensus/src/tests.rs +++ b/core/node/consensus/src/tests.rs @@ -616,8 +616,16 @@ async fn test_with_pruning(version: ProtocolVersionId) { .wait_for_batch(ctx, validator.last_sealed_batch()) .await?; + // The main node is not supposed to be pruned. In particular `ConsensusDal::attestation_status` + // does not look for where the last prune happened at, and thus if we prune the block genesis + // points at, we might never be able to start the Executor. + tracing::info!("Wait until the external node has all the batches we want to prune"); + node_pool + .wait_for_batch(ctx, to_prune.next()) + .await + .context("wait_for_batch()")?; tracing::info!("Prune some blocks and sync more"); - validator_pool + node_pool .prune_batches(ctx, to_prune) .await .context("prune_batches")?; From 9e8ae6ac248a9a3b573e7f551fef088c5934a401 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Thu, 1 Aug 2024 08:54:53 +0100 Subject: [PATCH 07/11] BFT-496: Nits --- core/node/consensus/src/en.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/node/consensus/src/en.rs b/core/node/consensus/src/en.rs index 5127ab12352f..f6dcd653cc92 100644 --- a/core/node/consensus/src/en.rs +++ b/core/node/consensus/src/en.rs @@ -1,14 +1,11 @@ -use anyhow::{anyhow, Context as _}; +use anyhow::Context as _; use async_trait::async_trait; use zksync_concurrency::{ctx, error::Wrap as _, scope, time}; use zksync_consensus_executor::{ self as executor, attestation::{AttestationStatusClient, AttestationStatusRunner}, }; -use zksync_consensus_roles::{ - attester::{self, GenesisHash}, - validator, -}; +use zksync_consensus_roles::{attester, validator}; use zksync_consensus_storage::{BatchStore, BlockStore}; use zksync_node_sync::{ fetcher::FetchedBlock, sync_action::ActionQueueSender, MainNodeClient, SyncState, @@ -267,7 +264,7 @@ impl EN { /// Wrapper to call [MainNodeClient::fetch_attestation_status] and adapt the return value to [AttestationStatusClient::next_batch_to_attest]. struct MainNodeAttestationStatus { client: Box>, - genesis: GenesisHash, + genesis: attester::GenesisHash, } #[async_trait] @@ -283,7 +280,7 @@ impl AttestationStatusClient for MainNodeAttestationStatus { .context("deserialize(AttestationStatus)")?; if status.genesis != self.genesis { - return Err(anyhow!( + return Err(anyhow::format_err!( "the main node API has different genesis hash than the local one: {:?} != {:?}", status.genesis, self.genesis From abd883fdb62c0b72c2970639b16ac43078d532d1 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Thu, 1 Aug 2024 09:05:06 +0100 Subject: [PATCH 08/11] Update the era-consensus dependency to main after fix --- Cargo.lock | 111 ++++++----------------------------------------------- Cargo.toml | 20 +++++----- 2 files changed, 21 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c45cdc0d0108..a0feb0477f8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8131,16 +8131,7 @@ dependencies = [ [[package]] name = "zksync_concurrency" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50302b77192891256d180ff2551dc0c3bc4144958b49e9a16c50a0dc218958ba" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "once_cell", @@ -8174,16 +8165,7 @@ dependencies = [ [[package]] name = "zksync_consensus_bft" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2325c7486a8280db1c26c10020350bead6eecb3de03f8bbfd878060f000cdce7" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "async-trait", @@ -8204,16 +8186,7 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5cb8ed0d59593f6147085b77142628e459ba673aa4d48fce064d5b96e31eb36" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "blst", @@ -8236,18 +8209,10 @@ dependencies = [ [[package]] name = "zksync_consensus_executor" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "247b70ec255781b3b740acb744236e771a192922ffbaa52c462b84c4ea67609f" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", + "async-trait", "rand 0.8.5", "tracing", "vise", @@ -8264,16 +8229,7 @@ dependencies = [ [[package]] name = "zksync_consensus_network" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f10626b79885a9b096cd19ee83d85ef9b0554f061a9db6946f2b7c9d1b2f49ea" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "async-trait", @@ -8307,16 +8263,7 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ffe3e47d99eb943eb94f2f5c9d929b1192bf3e8d1434de0fa6f0090f9c1197e" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "bit-vec", @@ -8337,16 +8284,7 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ae9a0ec64ce9c0af346e50cc87dc257c30259101ce9675b408cb883e096087" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "async-trait", @@ -8365,16 +8303,7 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24dc6135abeefa80f617eb2903fe43d137d362bf673f0651b4894b17069d1fb1" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "rand 0.8.5", @@ -9313,16 +9242,7 @@ dependencies = [ [[package]] name = "zksync_protobuf" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e7c7820f290db565a1b4ff73aa1175cd7d31498fca8d859eb5aceebd33468c" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "bit-vec", @@ -9342,16 +9262,7 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" version = "0.1.0-rc.4" -<<<<<<< HEAD -<<<<<<< HEAD -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6cafeec1150ae91f1a37c8f0dce6b71b92b93e0c4153d32b4c37e2fd71bce2f" -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=638b23e291a35fe9109c68d42f277903aaae0c42#638b23e291a35fe9109c68d42f277903aaae0c42" ->>>>>>> 1ada9d3b3 (Update the era-consensus ref) -======= -source = "git+https://github.com/matter-labs/era-consensus.git?rev=f0b265c1327aaad392d5a795b65b46a207162e1b#f0b265c1327aaad392d5a795b65b46a207162e1b" ->>>>>>> 43390c398 (Update the era-consensus dependency to runner fix) +source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" dependencies = [ "anyhow", "heck 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index e1d61a190130..171cb8094fbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -292,13 +292,13 @@ zksync_base_token_adjuster = { version = "0.1.0", path = "core/node/base_token_a # TODO: Release era-consensus 0.1.0-rc.5 [patch.crates-io] -zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } -zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "f0b265c1327aaad392d5a795b65b46a207162e1b" } +zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } From 7c49b3759ffc70e8a0035a2b8a586d7ff8b232b6 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Thu, 1 Aug 2024 14:50:00 +0100 Subject: [PATCH 09/11] Update the era-consensus dependency to main after GenesisHash added to client --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0feb0477f8e..4bb61bf9c9a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8131,7 +8131,7 @@ dependencies = [ [[package]] name = "zksync_concurrency" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "once_cell", @@ -8165,7 +8165,7 @@ dependencies = [ [[package]] name = "zksync_consensus_bft" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "async-trait", @@ -8186,7 +8186,7 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "blst", @@ -8209,7 +8209,7 @@ dependencies = [ [[package]] name = "zksync_consensus_executor" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "async-trait", @@ -8229,7 +8229,7 @@ dependencies = [ [[package]] name = "zksync_consensus_network" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "async-trait", @@ -8263,7 +8263,7 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "bit-vec", @@ -8284,7 +8284,7 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "async-trait", @@ -8303,7 +8303,7 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "rand 0.8.5", @@ -9242,7 +9242,7 @@ dependencies = [ [[package]] name = "zksync_protobuf" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "bit-vec", @@ -9262,7 +9262,7 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=aa29e87de0f87a55d2917d4e1e4de99d04364934#aa29e87de0f87a55d2917d4e1e4de99d04364934" +source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" dependencies = [ "anyhow", "heck 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index 171cb8094fbd..0e3f7e32e82c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -181,7 +181,7 @@ tower-http = "0.5.2" tracing = "0.1" tracing-subscriber = "0.3" tracing-opentelemetry = "0.25.0" -time = "0.3.36" # Has to be same as used by `tracing-subscriber` +time = "0.3.36" # Has to be same as used by `tracing-subscriber` url = "2" web3 = "0.19.0" fraction = "0.15.3" @@ -292,13 +292,13 @@ zksync_base_token_adjuster = { version = "0.1.0", path = "core/node/base_token_a # TODO: Release era-consensus 0.1.0-rc.5 [patch.crates-io] -zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } -zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "aa29e87de0f87a55d2917d4e1e4de99d04364934" } +zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } +zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } From dd028624ac2b842d477bec71fb579bfbe2548fd0 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Thu, 1 Aug 2024 14:52:58 +0100 Subject: [PATCH 10/11] Update AttesterStatusRunner initialisation to pass genesis --- core/node/consensus/src/en.rs | 44 ++++++++++++++--------------------- core/node/consensus/src/mn.rs | 2 +- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/core/node/consensus/src/en.rs b/core/node/consensus/src/en.rs index f6dcd653cc92..eeb2117f0e9b 100644 --- a/core/node/consensus/src/en.rs +++ b/core/node/consensus/src/en.rs @@ -5,8 +5,10 @@ use zksync_consensus_executor::{ self as executor, attestation::{AttestationStatusClient, AttestationStatusRunner}, }; -use zksync_consensus_roles::{attester, validator}; +use zksync_consensus_network::gossip; +use zksync_consensus_roles::validator; use zksync_consensus_storage::{BatchStore, BlockStore}; +use zksync_dal::consensus_dal; use zksync_node_sync::{ fetcher::FetchedBlock, sync_action::ActionQueueSender, MainNodeClient, SyncState, }; @@ -107,14 +109,11 @@ impl EN { let (attestation_status, runner) = { AttestationStatusRunner::init( ctx, - Box::new(MainNodeAttestationStatus { - client: self.client.clone(), - genesis: genesis_hash, - }), + Box::new(MainNodeAttestationStatus(self.client.clone())), time::Duration::seconds(5), + genesis_hash, ) .await - .map_err(ctx::Error::Canceled) .wrap("AttestationStatusRunner::init()")? }; s.spawn_bg(async { Ok(runner.run(ctx).await?) }); @@ -261,34 +260,27 @@ impl EN { } } -/// Wrapper to call [MainNodeClient::fetch_attestation_status] and adapt the return value to [AttestationStatusClient::next_batch_to_attest]. -struct MainNodeAttestationStatus { - client: Box>, - genesis: attester::GenesisHash, -} +/// Wrapper to call [MainNodeClient::fetch_attestation_status] and adapt the return value to [AttestationStatusClient]. +struct MainNodeAttestationStatus(Box>); #[async_trait] impl AttestationStatusClient for MainNodeAttestationStatus { - async fn next_batch_to_attest( + async fn attestation_status( &self, ctx: &ctx::Ctx, - ) -> ctx::Result> { - match ctx.wait(self.client.fetch_attestation_status()).await? { + ) -> ctx::Result> { + match ctx.wait(self.0.fetch_attestation_status()).await? { Ok(Some(status)) => { - let status: zksync_dal::consensus_dal::AttestationStatus = + // If this fails the AttestationStatusRunner will log it an retry it later, + // but it won't stop the whole node. + let status: consensus_dal::AttestationStatus = zksync_protobuf::serde::deserialize(&status.0) - .context("deserialize(AttestationStatus)")?; - - if status.genesis != self.genesis { - return Err(anyhow::format_err!( - "the main node API has different genesis hash than the local one: {:?} != {:?}", - status.genesis, - self.genesis - ) - .into()); + .context("deserialize(AttestationStatus")?; + let status = gossip::AttestationStatus { + genesis: status.genesis, + next_batch_to_attest: status.next_batch_to_attest, }; - - Ok(Some(status.next_batch_to_attest)) + Ok(Some(status)) } Ok(None) => Ok(None), Err(err) => { diff --git a/core/node/consensus/src/mn.rs b/core/node/consensus/src/mn.rs index 6023231c9764..b5e76afd63e1 100644 --- a/core/node/consensus/src/mn.rs +++ b/core/node/consensus/src/mn.rs @@ -66,9 +66,9 @@ pub async fn run_main_node( ctx, batch_store.clone(), time::Duration::seconds(1), + block_store.genesis().hash(), ) .await - .map_err(ctx::Error::Canceled) .wrap("AttestationStatusRunner::init_from_store()")? }; s.spawn_bg(runner.run(ctx)); From 5b82b8c849d695afb292e5265f452a8300cc7b8e Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Thu, 1 Aug 2024 16:37:41 +0100 Subject: [PATCH 11/11] Update era-consensus to 0.1.0-rc.5 --- Cargo.lock | 50 ++++++++++++++++++++++++++----------------- Cargo.toml | 33 +++++++++------------------- prover/Cargo.lock | 28 ++++++++++++------------ zk_toolbox/Cargo.lock | 16 +++++++------- zk_toolbox/Cargo.toml | 8 +++++-- 5 files changed, 68 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d578412c3d7..85a5efa3a9ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8142,8 +8142,9 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cf1d63d29e467457781bc08763c0348ab86c7a14713df7af5e6cc3ba88632c3" dependencies = [ "anyhow", "once_cell", @@ -8176,8 +8177,9 @@ dependencies = [ [[package]] name = "zksync_consensus_bft" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e8b6a76b90b909d9fec814ff980e03ea6179139821bd6edc3df3e1b08d8e765" dependencies = [ "anyhow", "async-trait", @@ -8197,8 +8199,9 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037bdb8bf5543676306b2faaa6dc60197a3f9335bbd1af1765d0eae4312ed427" dependencies = [ "anyhow", "blst", @@ -8220,8 +8223,9 @@ dependencies = [ [[package]] name = "zksync_consensus_executor" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fe50d7722e70f0ab5ca5af55a749b3c7f1207ce6e0320239699ff3384593690" dependencies = [ "anyhow", "async-trait", @@ -8240,8 +8244,9 @@ dependencies = [ [[package]] name = "zksync_consensus_network" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f89466c9523fcd1146d93a0d0b10d46b0388466c42bf4f18ca99a22ddcbe04b" dependencies = [ "anyhow", "async-trait", @@ -8274,8 +8279,9 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ade360294fd4b8191adb24b034c9dd87742c70d1859a2a405d24f1d1fb5ecaf" dependencies = [ "anyhow", "bit-vec", @@ -8295,8 +8301,9 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632a5a54e7359ff29ca34185859c766dab2d531e01f583d0b1bff343249254ef" dependencies = [ "anyhow", "async-trait", @@ -8314,8 +8321,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d12966b4cfa166abbc1d702640cefea59fa15f8509e2c959f06e2cfde97ef429" dependencies = [ "anyhow", "rand 0.8.5", @@ -9253,8 +9261,9 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eba9cb290dbef9542175ed5da58da349d9eb0efb4a2d41942e530e7c775a81b" dependencies = [ "anyhow", "bit-vec", @@ -9273,8 +9282,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.1.0-rc.4" -source = "git+https://github.com/matter-labs/era-consensus.git?rev=ecbabff2d0de26470da639622f7563cf84c79a1b#ecbabff2d0de26470da639622f7563cf84c79a1b" +version = "0.1.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d02f1226c102c9ec0745fd65e51f0fc388ef8f20c7df192167462bad0524d2f" dependencies = [ "anyhow", "heck 0.5.0", diff --git a/Cargo.toml b/Cargo.toml index fc08b524d086..1427c4b6678c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -212,16 +212,16 @@ zk_evm_1_4_1 = { package = "zk_evm", version = "0.141.0" } zk_evm_1_5_0 = { package = "zk_evm", version = "0.150.0" } # Consensus dependencies. -zksync_concurrency = "=0.1.0-rc.4" -zksync_consensus_bft = "=0.1.0-rc.4" -zksync_consensus_crypto = "=0.1.0-rc.4" -zksync_consensus_executor = "=0.1.0-rc.4" -zksync_consensus_network = "=0.1.0-rc.4" -zksync_consensus_roles = "=0.1.0-rc.4" -zksync_consensus_storage = "=0.1.0-rc.4" -zksync_consensus_utils = "=0.1.0-rc.4" -zksync_protobuf = "=0.1.0-rc.4" -zksync_protobuf_build = "=0.1.0-rc.4" +zksync_concurrency = "=0.1.0-rc.5" +zksync_consensus_bft = "=0.1.0-rc.5" +zksync_consensus_crypto = "=0.1.0-rc.5" +zksync_consensus_executor = "=0.1.0-rc.5" +zksync_consensus_network = "=0.1.0-rc.5" +zksync_consensus_roles = "=0.1.0-rc.5" +zksync_consensus_storage = "=0.1.0-rc.5" +zksync_consensus_utils = "=0.1.0-rc.5" +zksync_protobuf = "=0.1.0-rc.5" +zksync_protobuf_build = "=0.1.0-rc.5" # "Local" dependencies zksync_multivm = { version = "0.1.0", path = "core/lib/multivm" } @@ -290,16 +290,3 @@ zksync_contract_verification_server = { version = "0.1.0", path = "core/node/con zksync_node_api_server = { version = "0.1.0", path = "core/node/api_server" } zksync_tee_verifier_input_producer = { version = "0.1.0", path = "core/node/tee_verifier_input_producer" } zksync_base_token_adjuster = { version = "0.1.0", path = "core/node/base_token_adjuster" } - -# TODO: Release era-consensus 0.1.0-rc.5 -[patch.crates-io] -zksync_concurrency = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_consensus_bft = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_consensus_crypto = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_consensus_executor = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_consensus_network = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_consensus_roles = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_consensus_storage = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_consensus_utils = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_protobuf = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } -zksync_protobuf_build = { git = "https://github.com/matter-labs/era-consensus.git", rev = "ecbabff2d0de26470da639622f7563cf84c79a1b" } diff --git a/prover/Cargo.lock b/prover/Cargo.lock index c46bf4372326..2fd8a1d1c328 100644 --- a/prover/Cargo.lock +++ b/prover/Cargo.lock @@ -7722,9 +7722,9 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50302b77192891256d180ff2551dc0c3bc4144958b49e9a16c50a0dc218958ba" +checksum = "4cf1d63d29e467457781bc08763c0348ab86c7a14713df7af5e6cc3ba88632c3" dependencies = [ "anyhow", "once_cell", @@ -7757,9 +7757,9 @@ dependencies = [ [[package]] name = "zksync_consensus_crypto" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5cb8ed0d59593f6147085b77142628e459ba673aa4d48fce064d5b96e31eb36" +checksum = "037bdb8bf5543676306b2faaa6dc60197a3f9335bbd1af1765d0eae4312ed427" dependencies = [ "anyhow", "blst", @@ -7781,9 +7781,9 @@ dependencies = [ [[package]] name = "zksync_consensus_roles" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ffe3e47d99eb943eb94f2f5c9d929b1192bf3e8d1434de0fa6f0090f9c1197e" +checksum = "5ade360294fd4b8191adb24b034c9dd87742c70d1859a2a405d24f1d1fb5ecaf" dependencies = [ "anyhow", "bit-vec", @@ -7803,9 +7803,9 @@ dependencies = [ [[package]] name = "zksync_consensus_storage" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ae9a0ec64ce9c0af346e50cc87dc257c30259101ce9675b408cb883e096087" +checksum = "632a5a54e7359ff29ca34185859c766dab2d531e01f583d0b1bff343249254ef" dependencies = [ "anyhow", "async-trait", @@ -7823,9 +7823,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24dc6135abeefa80f617eb2903fe43d137d362bf673f0651b4894b17069d1fb1" +checksum = "d12966b4cfa166abbc1d702640cefea59fa15f8509e2c959f06e2cfde97ef429" dependencies = [ "anyhow", "rand 0.8.5", @@ -8133,9 +8133,9 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e7c7820f290db565a1b4ff73aa1175cd7d31498fca8d859eb5aceebd33468c" +checksum = "1eba9cb290dbef9542175ed5da58da349d9eb0efb4a2d41942e530e7c775a81b" dependencies = [ "anyhow", "bit-vec", @@ -8154,9 +8154,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6cafeec1150ae91f1a37c8f0dce6b71b92b93e0c4153d32b4c37e2fd71bce2f" +checksum = "6d02f1226c102c9ec0745fd65e51f0fc388ef8f20c7df192167462bad0524d2f" dependencies = [ "anyhow", "heck 0.5.0", diff --git a/zk_toolbox/Cargo.lock b/zk_toolbox/Cargo.lock index 35e3067482e1..cb2ea03e5c64 100644 --- a/zk_toolbox/Cargo.lock +++ b/zk_toolbox/Cargo.lock @@ -6336,9 +6336,9 @@ dependencies = [ [[package]] name = "zksync_concurrency" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50302b77192891256d180ff2551dc0c3bc4144958b49e9a16c50a0dc218958ba" +checksum = "4cf1d63d29e467457781bc08763c0348ab86c7a14713df7af5e6cc3ba88632c3" dependencies = [ "anyhow", "once_cell", @@ -6370,9 +6370,9 @@ dependencies = [ [[package]] name = "zksync_consensus_utils" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24dc6135abeefa80f617eb2903fe43d137d362bf673f0651b4894b17069d1fb1" +checksum = "d12966b4cfa166abbc1d702640cefea59fa15f8509e2c959f06e2cfde97ef429" dependencies = [ "anyhow", "rand", @@ -6421,9 +6421,9 @@ dependencies = [ [[package]] name = "zksync_protobuf" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e7c7820f290db565a1b4ff73aa1175cd7d31498fca8d859eb5aceebd33468c" +checksum = "1eba9cb290dbef9542175ed5da58da349d9eb0efb4a2d41942e530e7c775a81b" dependencies = [ "anyhow", "bit-vec", @@ -6442,9 +6442,9 @@ dependencies = [ [[package]] name = "zksync_protobuf_build" -version = "0.1.0-rc.4" +version = "0.1.0-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6cafeec1150ae91f1a37c8f0dce6b71b92b93e0c4153d32b4c37e2fd71bce2f" +checksum = "6d02f1226c102c9ec0745fd65e51f0fc388ef8f20c7df192167462bad0524d2f" dependencies = [ "anyhow", "heck", diff --git a/zk_toolbox/Cargo.toml b/zk_toolbox/Cargo.toml index ef47b9f7015a..c1ba531c0bb5 100644 --- a/zk_toolbox/Cargo.toml +++ b/zk_toolbox/Cargo.toml @@ -30,7 +30,7 @@ types = { path = "crates/types" } zksync_config = { path = "../core/lib/config" } zksync_protobuf_config = { path = "../core/lib/protobuf_config" } zksync_basic_types = { path = "../core/lib/basic_types" } -zksync_protobuf = "=0.1.0-rc.4" +zksync_protobuf = "=0.1.0-rc.5" # External dependencies anyhow = "1.0.82" @@ -47,7 +47,11 @@ rand = "0.8.5" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.9" -sqlx = { version = "0.8.0", features = ["runtime-tokio", "migrate", "postgres"] } +sqlx = { version = "0.8.0", features = [ + "runtime-tokio", + "migrate", + "postgres", +] } strum = { version = "0.26", features = ["derive"] } thiserror = "1.0.57" tokio = { version = "1.37", features = ["full"] }