Skip to content

Commit d2eb157

Browse files
committed
feat(dkg): implement validators
1 parent fda390d commit d2eb157

6 files changed

Lines changed: 415 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/dkg/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ bon.workspace = true
1414
libp2p.workspace = true
1515
futures.workspace = true
1616
tokio.workspace = true
17+
chrono.workspace = true
1718
sha2.workspace = true
1819
tracing.workspace = true
1920
either.workspace = true
@@ -22,8 +23,10 @@ tokio-util.workspace = true
2223
pluto-k1util.workspace = true
2324
pluto-p2p.workspace = true
2425
pluto-cluster.workspace = true
26+
pluto-core.workspace = true
2527
pluto-app.workspace = true
2628
pluto-crypto.workspace = true
29+
pluto-eth2api.workspace = true
2730
pluto-eth1wrap.workspace = true
2831
pluto-eth2util.workspace = true
2932
pluto-tracing.workspace = true
@@ -48,6 +51,7 @@ pluto-tracing.workspace = true
4851
serde_json.workspace = true
4952
tokio-util.workspace = true
5053
tempfile.workspace = true
54+
wiremock.workspace = true
5155

5256
[lints]
5357
workspace = true

crates/dkg/src/aggregate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::HashMap;
22

33
use pluto_core::{
44
signeddata::{SignedDataError, VersionedSignedValidatorRegistration},
5-
types::{ParSignedData, PubKey, Signature as CoreSignature},
5+
types::{ParSignedData, PubKey},
66
};
77
use pluto_crypto::{
88
blst_impl::BlstImpl,
@@ -213,7 +213,7 @@ pub fn agg_validator_registrations(
213213

214214
res.push(set_registration_signature(
215215
msg,
216-
CoreSignature::new(agg_sig),
216+
pluto_core::types::Signature::new(agg_sig),
217217
)?);
218218
}
219219

@@ -309,7 +309,7 @@ mod tests {
309309
}
310310

311311
fn partial_signature(sig: Signature, share_idx: u64) -> ParSignedData {
312-
ParSignedData::new(CoreSignature::new(sig), share_idx)
312+
ParSignedData::new(pluto_core::types::Signature::new(sig), share_idx)
313313
}
314314

315315
#[test]

crates/dkg/src/dkg.rs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
use std::{path, time::Duration};
22

33
use bon::Builder;
4+
use libp2p::PeerId;
45
use tokio_util::sync::CancellationToken;
5-
use tracing::warn;
6+
use tracing::{info, warn};
7+
8+
pub use crate::{
9+
aggregate::{AggregateError, agg_deposit_data, agg_lock_hash_sig, agg_validator_registrations},
10+
publish::{PublishError, write_lock_to_api},
11+
signing::{SigningError, sign_deposit_msgs, sign_lock_hash, sign_validator_registrations},
12+
validators::{
13+
ValidatorsError, builder_registration_from_eth2, create_dist_validators,
14+
set_registration_signature,
15+
},
16+
};
617

718
const DEFAULT_DATA_DIR: &str = ".charon";
819
const DEFAULT_DEFINITION_FILE: &str = ".charon/cluster-definition.json";
@@ -212,6 +223,49 @@ fn validate_keymanager_flags(conf: &Config) -> Result<(), DkgError> {
212223
Ok(())
213224
}
214225

226+
/// Logs peer summary with peer names and operator addresses.
227+
pub fn log_peer_summary(
228+
current_peer: PeerId,
229+
peers: &[pluto_p2p::peer::Peer],
230+
operators: &[pluto_cluster::operator::Operator],
231+
) {
232+
for (idx, peer) in peers.iter().enumerate() {
233+
let address = operators
234+
.get(idx)
235+
.filter(|operator| !operator.address.is_empty())
236+
.map(|operator| operator.address.as_str());
237+
let is_current_peer = peer.id == current_peer;
238+
239+
if let Some(address) = address {
240+
if is_current_peer {
241+
info!(
242+
peer = peer.name,
243+
index = peer.index,
244+
address,
245+
you = "⭐️",
246+
"Peer summary"
247+
);
248+
} else {
249+
info!(
250+
peer = peer.name,
251+
index = peer.index,
252+
address,
253+
"Peer summary"
254+
);
255+
}
256+
} else if is_current_peer {
257+
info!(
258+
peer = peer.name,
259+
index = peer.index,
260+
you = "⭐️",
261+
"Peer summary"
262+
);
263+
} else {
264+
info!(peer = peer.name, index = peer.index, "Peer summary");
265+
}
266+
}
267+
}
268+
215269
async fn verify_keymanager_connection(conf: &Config) -> Result<(), DkgError> {
216270
let addr = conf.keymanager.address.as_str();
217271

crates/dkg/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ pub mod dkgpb;
1111
/// Reliable broadcast protocol for DKG messages.
1212
pub mod bcast;
1313

14+
/// Partial-signature verification and aggregation helpers.
15+
mod aggregate;
16+
1417
/// General DKG IO operations.
1518
pub mod disk;
1619

1720
/// Main DKG protocol implementation.
1821
pub mod dkg;
1922

23+
/// Lock publishing helpers.
24+
mod publish;
25+
2026
/// Shares distributed to each node in the cluster.
2127
pub mod share;
28+
29+
/// Local DKG signing helpers.
30+
mod signing;
31+
32+
/// Registration conversion and distributed-validator assembly helpers.
33+
mod validators;

0 commit comments

Comments
 (0)