Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1430acc
feat: add deadline.rs
varex83 Mar 11, 2026
364977e
feat: deadline tests
varex83 Mar 11, 2026
368177c
fix: remove comments
varex83 Mar 11, 2026
f4b6893
Merge remote-tracking branch 'origin/main' into bohdan/deadline
varex83 Mar 11, 2026
de6dba4
wip: add parasig db and some tests
varex83 Mar 12, 2026
d71c885
refactor: remove old app/deadline
varex83 Mar 12, 2026
13de57a
feat: add rust docs
varex83 Mar 17, 2026
fc85e63
feat: add clone box and clone eq
varex83 Mar 17, 2026
5767cc1
Merge branch 'bohdan/update-signeddata-trait' into bohdan/parasigdb
varex83 Mar 18, 2026
e214d6f
Merge remote-tracking branch 'origin/main' into bohdan/deadline
varex83 Mar 18, 2026
7aced94
Merge branch 'bohdan/deadline' into bohdan/parasigdb
varex83 Mar 18, 2026
288f63c
feat: finish tests
varex83 Mar 18, 2026
8a3780e
feat: add parsigex [wip]
varex83 Mar 19, 2026
a4c4bb2
fix: typo
varex83 Mar 19, 2026
1b0711f
Merge branch 'bohdan/parasigdb' into bohdan/dkg-parsigex
varex83 Mar 19, 2026
6e9d224
fix: parsigex
varex83 Mar 20, 2026
52cbe10
Merge remote-tracking branch 'origin/main' into bohdan/dkg-parsigex
varex83 Apr 6, 2026
0247655
refactor: parsigex
varex83 Apr 9, 2026
eb5615e
fix: linter
varex83 Apr 9, 2026
6d3e20b
feat: add subscribe
varex83agent Apr 13, 2026
e643bd1
feat: add documentation for parsigex
varex83 Apr 13, 2026
e5f1750
fix: review comments
varex83 Apr 20, 2026
b0721f8
fix: review comments
varex83 Apr 20, 2026
ac01508
fix: review comments
varex83 Apr 20, 2026
b07a460
fix: cargo deny
varex83 Apr 20, 2026
0de6cdc
fix: linter
varex83 Apr 20, 2026
4a95b0b
Merge remote-tracking branch 'origin/main' into bohdan/dkg-parsigex
varex83 Apr 21, 2026
d248c45
fix: remove unused deps
varex83 Apr 21, 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
71 changes: 51 additions & 20 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"crates/app",
"crates/parsigex",
"crates/build-proto",
"crates/cli",
"crates/cluster",
Expand Down Expand Up @@ -99,6 +100,7 @@ wiremock = "0.6"

# Crates in the workspace
pluto-app = { path = "crates/app" }
pluto-parsigex = { path = "crates/parsigex" }
pluto-build-proto = { path = "crates/build-proto" }
pluto-cli = { path = "crates/cli" }
pluto-cluster = { path = "crates/cluster" }
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ hex.workspace = true
chrono.workspace = true
test-case.workspace = true
pluto-eth2util.workspace = true
pluto-p2p.workspace = true
pluto-testutil.workspace = true
tokio = { workspace = true, features = ["test-util"] }
wiremock.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ pub mod deadline;
/// parsigdb
pub mod parsigdb;

mod parsigex_codec;

pub use parsigex_codec::ParSigExCodecError;

/// Test utilities.
#[cfg(test)]
pub mod testutils;
120 changes: 120 additions & 0 deletions crates/core/src/parsigex_codec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
//! Partial signature exchange codec helpers used by core types.

use std::any::Any;

use crate::{
signeddata::{
Attestation, BeaconCommitteeSelection, SignedAggregateAndProof, SignedRandao,
SignedSyncContributionAndProof, SignedSyncMessage, SignedVoluntaryExit,
SyncCommitteeSelection, VersionedAttestation, VersionedSignedAggregateAndProof,
VersionedSignedProposal, VersionedSignedValidatorRegistration,
},
types::{DutyType, Signature, SignedData},
};

/// Error type for partial signature exchange codec operations.
#[derive(Debug, thiserror::Error)]
pub enum ParSigExCodecError {
/// Missing duty or data set fields.
#[error("invalid parsigex msg fields")]
InvalidMessageFields,

/// Invalid partial signed data set proto.
#[error("invalid partial signed data set proto fields")]
InvalidParSignedDataSetFields,

/// Invalid duty type.
#[error("invalid duty")]
InvalidDuty,

/// Unsupported duty type.
#[error("unsupported duty type")]
UnsupportedDutyType,

/// Deprecated builder proposer duty.
#[error("deprecated duty builder proposer")]
DeprecatedBuilderProposer,

/// Failed to parse a public key.
#[error("invalid public key: {0}")]
InvalidPubKey(String),

/// Invalid share index.
#[error("invalid share index")]
InvalidShareIndex,

/// Serialization failed.
#[error("marshal signed data: {0}")]
Serialize(#[from] serde_json::Error),

/// Failed to extract the signature from signed data.
#[error("invalid signature: {0}")]
InvalidSignature(String),
}

pub(crate) fn serialize_signed_data(data: &dyn SignedData) -> Result<Vec<u8>, ParSigExCodecError> {
Comment thread
varex83agent marked this conversation as resolved.
Comment thread
varex83 marked this conversation as resolved.
let any = data as &dyn Any;

macro_rules! serialize_as {
($ty:ty) => {
if let Some(value) = any.downcast_ref::<$ty>() {
return Ok(serde_json::to_vec(value)?);
}
};
}

serialize_as!(Attestation);
serialize_as!(VersionedAttestation);
serialize_as!(VersionedSignedProposal);
serialize_as!(VersionedSignedValidatorRegistration);
serialize_as!(SignedVoluntaryExit);
serialize_as!(SignedRandao);
serialize_as!(Signature);
serialize_as!(BeaconCommitteeSelection);
serialize_as!(SignedAggregateAndProof);
serialize_as!(VersionedSignedAggregateAndProof);
serialize_as!(SignedSyncMessage);
serialize_as!(SyncCommitteeSelection);
serialize_as!(SignedSyncContributionAndProof);

Err(ParSigExCodecError::UnsupportedDutyType)
}

pub(crate) fn deserialize_signed_data(
duty_type: &DutyType,
bytes: &[u8],
) -> Result<Box<dyn SignedData>, ParSigExCodecError> {
macro_rules! deserialize_json {
($ty:ty) => {
serde_json::from_slice::<$ty>(bytes)
.map(|value| Box::new(value) as Box<dyn SignedData>)
.map_err(ParSigExCodecError::from)
};
}

match duty_type {
// Match Go order: old Attestation format first, then VersionedAttestation.
DutyType::Attester => deserialize_json!(Attestation)
.or_else(|_| deserialize_json!(VersionedAttestation))
.map_err(|_| ParSigExCodecError::UnsupportedDutyType),
DutyType::Proposer => deserialize_json!(VersionedSignedProposal),
DutyType::BuilderProposer => Err(ParSigExCodecError::DeprecatedBuilderProposer),
DutyType::BuilderRegistration => deserialize_json!(VersionedSignedValidatorRegistration),
DutyType::Exit => deserialize_json!(SignedVoluntaryExit),
DutyType::Randao => deserialize_json!(SignedRandao),
DutyType::Signature => deserialize_json!(Signature),
DutyType::PrepareAggregator => deserialize_json!(BeaconCommitteeSelection),
// Match Go order: old SignedAggregateAndProof format first, then versioned.
DutyType::Aggregator => deserialize_json!(SignedAggregateAndProof)
.or_else(|_| deserialize_json!(VersionedSignedAggregateAndProof))
.map_err(|_| ParSigExCodecError::UnsupportedDutyType),
DutyType::SyncMessage => deserialize_json!(SignedSyncMessage),
DutyType::PrepareSyncContribution => deserialize_json!(SyncCommitteeSelection),
DutyType::SyncContribution => deserialize_json!(SignedSyncContributionAndProof),
// InfoSync is not used in parsigex in Go (handled via a separate channel);
// Unknown and DutySentinel are sentinel/invalid values that are never transmitted.
DutyType::Unknown | DutyType::DutySentinel(_) | DutyType::InfoSync => {
Err(ParSigExCodecError::UnsupportedDutyType)
}
}
}
3 changes: 3 additions & 0 deletions crates/core/src/signeddata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub enum SignedDataError {
/// Invalid attestation wrapper JSON.
#[error("unmarshal attestation")]
AttestationJson,
/// Custom error.
#[error("{0}")]
Custom(Box<dyn std::error::Error + Send + Sync>),
}

fn hash_root<T: TreeHash>(value: &T) -> [u8; 32] {
Expand Down
Loading
Loading