Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a1a2c8e
Initial `dkg/disk` module
emlautarom1 Mar 11, 2026
0a9c61c
Add `write_to_keymanager`
emlautarom1 Mar 11, 2026
8bcf24c
Add `write_keys_to_disk`
emlautarom1 Mar 11, 2026
211fcb4
Add `write_lock`
emlautarom1 Mar 11, 2026
123947a
Add `check_clear_data_dir`
emlautarom1 Mar 11, 2026
c1caa5d
Add `check_writes`
emlautarom1 Mar 11, 2026
450cf6e
Test `clear_data_dir_does_not_exist`
emlautarom1 Mar 11, 2026
b6931b7
Test `clear_data_dir_is_file`
emlautarom1 Mar 11, 2026
9691bf3
Test `clear_data_dir_contains_validator_keys_file`
emlautarom1 Mar 11, 2026
f0c9bf6
Test `clear_data_dir_contains_validator_keys_dir`
emlautarom1 Mar 11, 2026
f4b8350
Test `clear_data_dir_contains_validator_keys_dir`
emlautarom1 Mar 11, 2026
8b3016a
Test `clear_data_dir_contains_cluster_lock`
emlautarom1 Mar 11, 2026
a67baec
Test `clear_data_dir_contains_deposit_data`
emlautarom1 Mar 11, 2026
d9c8e0d
Test `clear_data_dir_missing_private_key`
emlautarom1 Mar 11, 2026
75600c7
Test `clear_data_dir_contains_private_key`
emlautarom1 Mar 11, 2026
da2c43e
Formatting
emlautarom1 Mar 11, 2026
f5cdb1c
Fix clippy lints
emlautarom1 Mar 11, 2026
269888a
Test `load_definition_file_does_not_exist`
emlautarom1 Mar 11, 2026
3fee2d6
Test `load_definition_invalid_file`
emlautarom1 Mar 11, 2026
73aa6d6
Merge remote-tracking branch 'origin/main' into emlautarom1/dkg-disk-…
emlautarom1 Mar 13, 2026
771fd61
Add `Generalized Parameter Types` rule
emlautarom1 Mar 13, 2026
72c476e
Replace `todo!` with actual calls
emlautarom1 Mar 13, 2026
47a8a98
Make `test_cluster` non test-only
emlautarom1 Mar 13, 2026
acb72da
Update module docs
emlautarom1 Mar 13, 2026
65c4aa9
Test `load_definition_valid`
emlautarom1 Mar 13, 2026
64f9fe8
Use defaults when key is missing
emlautarom1 Mar 13, 2026
c586136
Test `load_definition_invalid_definition_no_verify`
emlautarom1 Mar 13, 2026
05f0121
Test `load_definition_invalid_definition_verify`
emlautarom1 Mar 13, 2026
0952f9a
Add `ShareMsg`
emlautarom1 Mar 13, 2026
2d53e6b
Update `Cargo.lock`
emlautarom1 Mar 13, 2026
5557910
Allow unwrap in test code
emlautarom1 Mar 13, 2026
29ab234
Adjust visibility and docs
emlautarom1 Mar 13, 2026
ffc492c
Fix clippy lints
emlautarom1 Mar 13, 2026
23e7ebf
Use `File::create` instead of `File::open`
emlautarom1 Mar 13, 2026
5b8f9a9
Persist readonly permissions
emlautarom1 Mar 13, 2026
ac3a971
Resolve TODOs in module docs
emlautarom1 Mar 13, 2026
7127fc4
Prefer `AsRef<Path>`
emlautarom1 Mar 13, 2026
13d3eed
Fix typo
emlautarom1 Mar 13, 2026
b1391c1
Reduce visibility of utility
emlautarom1 Mar 13, 2026
495bf5f
Use `PathBuf` for the data_dir
emlautarom1 Mar 13, 2026
f1aa06e
Simplify error handling
emlautarom1 Mar 13, 2026
9146957
Add `Debug` and `Clone` to `Share` and `ShareMsg`
emlautarom1 Mar 13, 2026
cc6d2a3
Fix typo & formatting
emlautarom1 Mar 13, 2026
4e1d71f
feat: make test-cluster be feature based
varex83 Mar 17, 2026
d361ca4
feat: update dkg Cargo.toml to split testing and release versions of …
varex83 Mar 17, 2026
fdbcd96
Remove inlined definitions
emlautarom1 Mar 17, 2026
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
37 changes: 37 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,43 @@ Rules:
- Prefer copying doc comments from Go and adapting to Rust conventions (avoid “Type is a …”).
- Avoid leaving TODOs in merged code. If a short-lived internal note is necessary, use `// TODO:` and remove before PR merge.

## Generalized Parameter Types

Prefer generic parameters over concrete types when a function only needs the behavior of a trait. This mirrors the standard library's own conventions and makes functions callable with a wider range of inputs without extra allocations.

| Instead of | Prefer | Accepts |
| --- | --- | --- |
| `&str` | `impl AsRef<str>` | `&str`, `String`, `&String`, … |
| `&Path` | `impl AsRef<Path>` | `&str`, `String`, `PathBuf`, `&Path`, … |
| `&[u8]` | `impl AsRef<[u8]>` | `&[u8]`, `Vec<u8>`, arrays, … |
| `&Vec<T>` | `impl AsRef<[T]>` | `Vec<T>`, slices, arrays, … |
| `String` (owned, read-only) | `impl Into<String>` | `&str`, `String`, … |

Examples:

```rust
// accepts &str, String, PathBuf, &Path, …
fn read_file(path: impl AsRef<std::path::Path>) -> std::io::Result<String> {
std::fs::read_to_string(path.as_ref())
}

// accepts &str, String, &String, …
fn print_message(msg: impl AsRef<str>) {
println!(“{}”, msg.as_ref());
}

// accepts &[u8], Vec<u8>, arrays, …
fn hash_bytes(data: impl AsRef<[u8]>) -> [u8; 32] {
sha256(data.as_ref())
}
```

Rules:

- Call `.as_ref()` once at the top of the function and bind it to a local variable when the value is used in multiple places.
- Do not use `impl AsRef<T>` if the function immediately converts to an owned type anyway — use `impl Into<T>` (or just accept the owned type) in that case.
- Applies to public and private functions alike; the gain is ergonomics, not just API surface.

## Testing

- Translate Go tests to Rust where applicable; keep similar test names for cross-reference.
Expand Down
22 changes: 17 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions crates/cluster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluto-core.workspace = true
pluto-crypto.workspace = true
pluto-eth2api.workspace = true
thiserror.workspace = true
rand_core.workspace = true
rand.workspace = true
libp2p.workspace = true
pluto-p2p.workspace = true
pluto-eth2util.workspace = true
Expand All @@ -28,16 +28,21 @@ pluto-k1util.workspace = true
k256.workspace = true
tokio.workspace = true
reqwest = { workspace = true, features = ["json"] }
# Workaround to use test code from different crate.
# See: https://github.com/NethermindEth/pluto/pull/285
pluto-testutil = { workspace = true, optional = true }

[build-dependencies]
prost-build.workspace = true

[dev-dependencies]
test-case.workspace = true
pluto-testutil.workspace = true
rand.workspace = true
tempfile.workspace = true
wiremock.workspace = true

[lints]
workspace = true

[features]
test-cluster = []
12 changes: 12 additions & 0 deletions crates/cluster/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,10 +933,12 @@ pub struct DefinitionV1x2or3 {
/// Config hash uniquely identifies a cluster definition excluding operator
/// ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub config_hash: Vec<u8>,
/// Definition hash uniquely identifies a cluster definition including
/// operator ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub definition_hash: Vec<u8>,
}

Expand Down Expand Up @@ -1047,10 +1049,12 @@ pub struct DefinitionV1x4 {
/// Config hash uniquely identifies a cluster definition excluding operator
/// ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub config_hash: Vec<u8>,
/// Definition hash uniquely identifies a cluster definition including
/// operator ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub definition_hash: Vec<u8>,
}

Expand Down Expand Up @@ -1159,10 +1163,12 @@ pub struct DefinitionV1x5to7 {
/// Config hash uniquely identifies a cluster definition excluding operator
/// ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub config_hash: Vec<u8>,
/// Definition hash uniquely identifies a cluster definition including
/// operator ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub definition_hash: Vec<u8>,
}

Expand Down Expand Up @@ -1260,10 +1266,12 @@ pub struct DefinitionV1x8 {
/// ConfigHash uniquely identifies a cluster definition excluding operator
/// ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub config_hash: Vec<u8>,
/// DefinitionHash uniquely identifies a cluster definition including
/// operator ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub definition_hash: Vec<u8>,
}

Expand Down Expand Up @@ -1365,10 +1373,12 @@ pub struct DefinitionV1x9 {
/// ConfigHash uniquely identifies a cluster definition excluding operator
/// ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub config_hash: Vec<u8>,
/// DefinitionHash uniquely identifies a cluster definition including
/// operator ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub definition_hash: Vec<u8>,
}

Expand Down Expand Up @@ -1477,10 +1487,12 @@ pub struct DefinitionV1x10 {
/// Config hash uniquely identifies a cluster definition excluding operator
/// ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub config_hash: Vec<u8>,
/// Definition hash uniquely identifies a cluster definition including
/// operator ENRs and signatures.
#[serde_as(as = "EthHex")]
#[serde(default)]
pub definition_hash: Vec<u8>,
}

Expand Down
6 changes: 4 additions & 2 deletions crates/cluster/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ pub async fn fetch_definition(
/// Creates a new directory for validator keys.
/// If the directory "validator_keys" exists, it checks if the directory is
/// empty.
pub async fn create_validator_keys_dir(parent_dir: &std::path::Path) -> std::io::Result<PathBuf> {
let vk_dir = parent_dir.join("validator_keys");
pub async fn create_validator_keys_dir(
parent_dir: impl AsRef<std::path::Path>,
) -> std::io::Result<PathBuf> {
let vk_dir = parent_dir.as_ref().join("validator_keys");

if let Err(e) = tokio::fs::create_dir(&vk_dir).await {
if e.kind() != std::io::ErrorKind::AlreadyExists {
Expand Down
37 changes: 22 additions & 15 deletions crates/cluster/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,39 @@
//! This crate handles the formation, management, and coordination of validator
//! clusters in the Charon network.

/// Cluster definition management and coordination.
/// `Definition` type representing the intended cluster configuration
/// (operators, validators, fork version) with EIP-712 hashing and verification.
pub mod definition;
/// Cluster deposit management and coordination.
/// `DepositData` type for activating validators.
pub mod deposit;
/// Cluster distributed validator management and coordination.
/// `DistValidator` type representing a distributed validator with its group
/// public key, per-node public shares, and deposit data.
pub mod distvalidator;
/// Cluster EIP-712 signatures management and coordination.
/// EIP-712 typed data construction and signing for cluster definition config
/// hashes and operator ENR signatures.
pub mod eip712sigs;
/// Cluster helpers management and coordination.
/// General helper utilities.
pub mod helpers;
/// Cluster lock management and coordination.
/// `Lock` type representing the finalized cluster configuration, including
/// distributed validators and node signatures.
pub mod lock;
/// Manifest
/// Cluster manifest types, loading, mutation, and materialization.
pub mod manifest;
/// Manifest protocol buffers.
/// Generated protobuf types for the cluster manifest (v1).
pub mod manifestpb;
/// Cluster operator management and coordination.
/// `Operator` type representing a charon node operator with Ethereum address,
/// ENR, and config/ENR signatures.
pub mod operator;
/// Cluster registration management and coordination.
/// `BuilderRegistration` and `Registration` types for pre-generated signed
/// validator registrations sent to the builder network.
pub mod registration;
/// Cluster SSZ management and coordination.
/// SSZ serialization for various cluster types.
pub mod ssz;
/// Cluster SSZ hashing management and coordination.
/// Core SSZ utilities.
pub mod ssz_hasher;
/// Cluster test cluster management and coordination.
#[cfg(test)]
/// Factory for constructing deterministic or random cluster locks for use in
/// tests.
#[cfg(any(test, feature = "test-cluster"))]
pub mod test_cluster;
/// Cluster version management and coordination.
/// Supported cluster definition version constants and feature-flag helpers.
pub mod version;
2 changes: 2 additions & 0 deletions crates/cluster/src/test_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::unwrap_used, reason = "test code")]

use crate::{definition, distvalidator, helpers, lock, operator, registration, version};
use chrono::{TimeZone, Utc};
use pluto_crypto::tbls::Tbls;
Expand Down
16 changes: 16 additions & 0 deletions crates/dkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,25 @@ publish.workspace = true
[dependencies]
prost.workspace = true
prost-types.workspace = true
pluto-cluster.workspace = true
pluto-crypto.workspace = true
pluto-eth1wrap.workspace = true
pluto-eth2util.workspace = true
hex.workspace = true
rand.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
url.workspace = true

[build-dependencies]
pluto-build-proto.workspace = true

[dev-dependencies]
pluto-cluster = { workspace = true, features = ["test-cluster"] }
tempfile.workspace = true

[lints]
workspace = true
Loading
Loading