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

Support for dynamic attester committee #175

Merged
merged 34 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d375cbf
simplified setup
pompon0 Jul 31, 2024
eb1ab15
before removing persist_batch_qc
pompon0 Aug 1, 2024
13a4ca8
looks nice
pompon0 Aug 1, 2024
dfda9a9
wip
pompon0 Aug 1, 2024
031e863
somewhat compiles
pompon0 Aug 2, 2024
b558ddc
compiles
pompon0 Aug 2, 2024
7baf2ce
tests wip
pompon0 Aug 2, 2024
723a1b0
Merge remote-tracking branch 'origin/main' into gprusak-dynamic-attes…
pompon0 Aug 6, 2024
9e59da7
plugged in pull votes server
pompon0 Aug 6, 2024
7580272
migrated to protobuf registry
pompon0 Aug 6, 2024
7ff09d0
deprecated old push_batch_votes
pompon0 Aug 6, 2024
9876d97
more passing tests
pompon0 Aug 7, 2024
f9cc649
wip
pompon0 Aug 7, 2024
226d6f3
test works
pompon0 Aug 7, 2024
a384bb0
before single RPC
pompon0 Aug 7, 2024
e7c9598
introduced diff
pompon0 Aug 7, 2024
1f87297
reduced rpc
pompon0 Aug 7, 2024
ce9527d
tests work
pompon0 Aug 7, 2024
a2f38c4
cargo fmt
pompon0 Aug 7, 2024
f6fb67a
log instead of disconnect
pompon0 Aug 9, 2024
5ff6a00
Merge remote-tracking branch 'origin/main' into gprusak-dynamic-attes…
pompon0 Aug 9, 2024
d56cb00
adjusted metrics
pompon0 Aug 9, 2024
3bb3e19
clippy
pompon0 Aug 9, 2024
10f1fab
removed rust-toolchain
pompon0 Aug 12, 2024
92095f1
applied some comments
pompon0 Aug 13, 2024
f5a1337
fixed test
pompon0 Aug 13, 2024
b1b6cbf
cargo_fmt
pompon0 Aug 13, 2024
f627a3c
unused file
pompon0 Aug 13, 2024
356b881
applied comment
pompon0 Aug 13, 2024
7e8af7c
Update node/tools/src/config.rs
pompon0 Aug 13, 2024
80d12e4
removed comment
pompon0 Aug 14, 2024
dbb9fac
Merge remote-tracking branch 'origin/main' into gprusak-dynamic-attes…
pompon0 Aug 14, 2024
cd7bcf7
applied comments, expanded example
pompon0 Aug 14, 2024
eb21f6a
applied comments
pompon0 Aug 14, 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
256 changes: 0 additions & 256 deletions node/actors/executor/src/attestation.rs

This file was deleted.

6 changes: 3 additions & 3 deletions node/actors/executor/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ impl Dispatcher {
}

/// Method to start the IO dispatcher. It is simply a loop to receive messages from the actors and then forward them.
pub(super) async fn run(mut self, ctx: &ctx::Ctx) -> anyhow::Result<()> {
scope::run!(ctx, |ctx, s| async {
pub(super) async fn run(mut self, ctx: &ctx::Ctx) {
let _: ctx::OrCanceled<()> = scope::run!(ctx, |ctx, s| async {
// Start a task to handle the messages from the consensus actor.
s.spawn(async {
while let Ok(msg) = self.consensus_output.recv(ctx).await {
Expand Down Expand Up @@ -65,6 +65,6 @@ impl Dispatcher {

Ok(())
})
.await
.await;
}
}
47 changes: 11 additions & 36 deletions node/actors/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
use crate::io::Dispatcher;
use anyhow::Context as _;
use network::http;
pub use network::RpcConfig;
pub use network::{gossip::attestation, RpcConfig};
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};
use zksync_concurrency::{ctx, limiter, net, scope, time};
use zksync_consensus_bft as bft;
use zksync_consensus_network::{self as network, gossip::AttestationStatusWatch};
use zksync_consensus_roles::{attester, node, validator};
use zksync_consensus_network as network;
use zksync_consensus_roles::{node, validator};
use zksync_consensus_storage::{BatchStore, BlockStore, ReplicaStore};
use zksync_consensus_utils::pipe;
use zksync_protobuf::kB;

pub mod attestation;
mod io;
#[cfg(test)]
mod tests;
Expand All @@ -31,13 +30,6 @@ pub struct Validator {
pub payload_manager: Box<dyn bft::PayloadManager>,
}

/// Validator-related part of [`Executor`].
#[derive(Debug)]
pub struct Attester {
/// Consensus network configuration.
pub key: attester::SecretKey,
}

/// Config of the node executor.
#[derive(Debug)]
pub struct Config {
Expand Down Expand Up @@ -98,10 +90,9 @@ pub struct Executor {
pub batch_store: Arc<BatchStore>,
/// Validator-specific node data.
pub validator: Option<Validator>,
/// Validator-specific node data.
pub attester: Option<Attester>,
/// Status showing where the main node wants attester to cast their votes.
pub attestation_status: Arc<AttestationStatusWatch>,
/// Attestation controller. Caller should actively configure the batch
/// for which the attestation votes should be collected.
pub attestation: Arc<attestation::Controller>,
}

impl Executor {
Expand All @@ -112,7 +103,6 @@ impl Executor {
public_addr: self.config.public_addr.clone(),
gossip: self.config.gossip(),
validator_key: self.validator.as_ref().map(|v| v.key.clone()),
attester_key: self.attester.as_ref().map(|a| a.key.clone()),
ping_timeout: Some(time::Duration::seconds(10)),
max_block_size: self.config.max_payload_size.saturating_add(kB),
max_batch_size: self.config.max_batch_size.saturating_add(kB),
Expand All @@ -137,35 +127,20 @@ impl Executor {

tracing::debug!("Starting actors in separate threads.");
scope::run!(ctx, |ctx, s| async {
s.spawn(async { dispatcher.run(ctx).await.context("IO Dispatcher stopped") });
s.spawn(async {
dispatcher.run(ctx).await;
Ok(())
});
let (net, runner) = network::Network::new(
network_config,
self.block_store.clone(),
self.batch_store.clone(),
network_actor_pipe,
self.attestation_status.clone(),
self.attestation,
);
net.register_metrics();
s.spawn(async { runner.run(ctx).await.context("Network stopped") });

if let Some(attester) = self.attester {
tracing::info!("Running the node in attester mode.");
let runner = attestation::AttesterRunner::new(
self.block_store.clone(),
self.batch_store.clone(),
attester,
net.batch_vote_publisher(),
self.attestation_status.subscribe(),
self.config.batch_poll_interval,
);
s.spawn(async {
runner.run(ctx).await?;
Ok(())
});
} else {
tracing::info!("Running the node in non-attester mode.");
}

if let Some(debug_config) = self.config.debug_page {
s.spawn(async {
http::DebugPageServer::new(debug_config, net)
Expand Down
Loading
Loading