diff --git a/CHANGELOG.md b/CHANGELOG.md index 5919e5d..e0916b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/manul/src/protocol.rs b/manul/src/protocol.rs index 5c19d70..f1b063f 100644 --- a/manul/src/protocol.rs +++ b/manul/src/protocol.rs @@ -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; diff --git a/manul/src/protocol/round.rs b/manul/src/protocol/round.rs index ddc3011..bc58e0a 100644 --- a/manul/src/protocol/round.rs +++ b/manul/src/protocol/round.rs @@ -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`. @@ -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);