Skip to content

Commit

Permalink
Add a dummy CorrectnessProof trait, to be extended elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
fjarri committed Nov 3, 2024
1 parent 7738979 commit 623ac9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `Message::destination()`. ([#56])
- `PartyId` trait alias for the combination of bounds needed for a party identifier. ([#59])
- An impl of `ProtocolError` for `()` for protocols that don't use errors. ([#60])
- A dummy `CorrectnessProof` trait. ([#60])


[#32]: https://github.com/entropyxyz/manul/pull/32
Expand Down
4 changes: 3 additions & 1 deletion manul/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ pub use errors::{
};
pub use message::{DirectMessage, EchoBroadcast, NormalBroadcast, ProtocolMessagePart};
pub use object_safe::BoxedRound;
pub use round::{Artifact, EntryPoint, FinalizeOutcome, PartyId, Payload, Protocol, ProtocolError, Round, RoundId};
pub use round::{
Artifact, CorrectnessProof, EntryPoint, FinalizeOutcome, PartyId, Payload, Protocol, ProtocolError, Round, RoundId,
};
pub use serialization::{Deserializer, Serializer};

pub(crate) use errors::ReceiveErrorType;
Expand Down
14 changes: 13 additions & 1 deletion manul/src/protocol/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub trait Protocol: 'static {
/// An object of this type will be returned when an unattributable error happens during [`Round::finalize`].
///
/// It proves that the node did its job correctly, to be adjudicated by a third party.
type CorrectnessProof: Send + Serialize + for<'de> Deserialize<'de> + Debug;
type CorrectnessProof: CorrectnessProof + Serialize + for<'de> Deserialize<'de>;

/// Returns `Ok(())` if the given direct message cannot be deserialized
/// assuming it is a direct message from the round `round_id`.
Expand Down Expand Up @@ -223,6 +223,18 @@ impl ProtocolError for () {
}
}

/// Describes unattributable errors originating during protocol execution.
///
/// In the situations where no specific message can be blamed for an error,
/// each node must generate a correctness proof proving that they performed their duties correctly,
/// and the collection of proofs is verified by a third party.
/// One of the proofs will be necessarily missing or invalid.
pub trait CorrectnessProof: Debug + Clone + Send {}

// A convenience implementation for protocols that don't define any errors.
// Have to do it for `()`, since `!` is unstable.
impl CorrectnessProof for () {}

/// Message payload created in [`Round::receive_message`].
#[derive(Debug)]
pub struct Payload(pub Box<dyn Any + Send + Sync>);
Expand Down

0 comments on commit 623ac9b

Please sign in to comment.