Skip to content

Commit

Permalink
Rename MessageBundle to Message, and rename internal types accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
fjarri committed Oct 30, 2024
1 parent 0fc723b commit 6ba72bd
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 126 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `EchoBroadcast` and `DirectMessage` now use `ProtocolMessagePart` trait for their methods. ([#47])
- Added normal broadcasts support in addition to echo ones; signatures of `Round` methods changed accordingly; added `Round::make_normal_broadcast()`. ([#47])
- Serialization format is a part of `SessionParameters` now; `Round` and `Protocol` methods receive dynamic serializers/deserializers. ([#33])
- Renamed `(Verified)MessageBundle` to `(Verified)Message`. ([#56])


### Added
Expand Down
8 changes: 4 additions & 4 deletions examples/tests/async_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use alloc::collections::{BTreeMap, BTreeSet};
use manul::{
protocol::Protocol,
session::{
signature::Keypair, CanFinalize, LocalError, MessageBundle, RoundOutcome, Session, SessionId,
SessionParameters, SessionReport,
signature::Keypair, CanFinalize, LocalError, Message, RoundOutcome, Session, SessionId, SessionParameters,
SessionReport,
},
testing::{BinaryFormat, TestSessionParams, TestSigner},
};
Expand All @@ -23,12 +23,12 @@ use tracing_subscriber::{util::SubscriberInitExt, EnvFilter};
struct MessageOut<SP: SessionParameters> {
from: SP::Verifier,
to: SP::Verifier,
message: MessageBundle,
message: Message,
}

struct MessageIn<SP: SessionParameters> {
from: SP::Verifier,
message: MessageBundle,
message: Message,
}

/// Runs a session. Simulates what each participating party would run as the protocol progresses.
Expand Down
4 changes: 2 additions & 2 deletions manul/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ mod wire_format;

pub use crate::protocol::{LocalError, RemoteError};
pub use evidence::{Evidence, EvidenceError};
pub use message::MessageBundle;
pub use message::{VerifiedMessage, Message};
pub use session::{CanFinalize, RoundAccumulator, RoundOutcome, Session, SessionId, SessionParameters};
pub use transcript::{SessionOutcome, SessionReport};
pub use wire_format::WireFormat;

pub(crate) use echo::EchoRoundError;

pub use signature;
pub use digest;
pub use signature;
14 changes: 7 additions & 7 deletions manul/src/session/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
use tracing::debug;

use super::{
message::{MessageVerificationError, SignedMessage},
message::{MessageVerificationError, SignedMessagePart},
session::SessionParameters,
LocalError,
};
Expand Down Expand Up @@ -42,8 +42,8 @@ pub(crate) enum EchoRoundError<Id> {
MismatchedBroadcasts {
guilty_party: Id,
error: MismatchedBroadcastsError,
we_received: SignedMessage<EchoBroadcast>,
echoed_to_us: SignedMessage<EchoBroadcast>,
we_received: SignedMessagePart<EchoBroadcast>,
echoed_to_us: SignedMessagePart<EchoBroadcast>,
},
}

Expand All @@ -68,7 +68,7 @@ pub(crate) enum MismatchedBroadcastsError {

#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) struct EchoRoundMessage<SP: SessionParameters> {
pub(super) echo_broadcasts: SerializableMap<SP::Verifier, SignedMessage<EchoBroadcast>>,
pub(super) echo_broadcasts: SerializableMap<SP::Verifier, SignedMessagePart<EchoBroadcast>>,
}

/// Each protocol round can contain one `EchoRound` with "echo messages" that are sent to all
Expand All @@ -77,7 +77,7 @@ pub(crate) struct EchoRoundMessage<SP: SessionParameters> {
#[derive_where::derive_where(Debug)]
pub struct EchoRound<P, SP: SessionParameters> {
verifier: SP::Verifier,
echo_broadcasts: BTreeMap<SP::Verifier, SignedMessage<EchoBroadcast>>,
echo_broadcasts: BTreeMap<SP::Verifier, SignedMessagePart<EchoBroadcast>>,
destinations: BTreeSet<SP::Verifier>,
expected_echos: BTreeSet<SP::Verifier>,
main_round: Box<dyn ObjectSafeRound<SP::Verifier, Protocol = P>>,
Expand All @@ -92,8 +92,8 @@ where
{
pub fn new(
verifier: SP::Verifier,
my_echo_broadcast: SignedMessage<EchoBroadcast>,
echo_broadcasts: BTreeMap<SP::Verifier, SignedMessage<EchoBroadcast>>,
my_echo_broadcast: SignedMessagePart<EchoBroadcast>,
echo_broadcasts: BTreeMap<SP::Verifier, SignedMessagePart<EchoBroadcast>>,
main_round: Box<dyn ObjectSafeRound<SP::Verifier, Protocol = P>>,
payloads: BTreeMap<SP::Verifier, Payload>,
artifacts: BTreeMap<SP::Verifier, Artifact>,
Expand Down
42 changes: 21 additions & 21 deletions manul/src/session/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};

use super::{
echo::{EchoRound, EchoRoundError, EchoRoundMessage, MismatchedBroadcastsError},
message::{MessageVerificationError, MissingMessage, SignedMessage},
message::{MessageVerificationError, SignedMessagePart},
session::SessionParameters,
transcript::Transcript,
LocalError,
Expand Down Expand Up @@ -89,9 +89,9 @@ where
{
pub(crate) fn new_protocol_error(
verifier: &SP::Verifier,
echo_broadcast: SignedMessage<EchoBroadcast>,
normal_broadcast: SignedMessage<NormalBroadcast>,
direct_message: SignedMessage<DirectMessage>,
echo_broadcast: SignedMessagePart<EchoBroadcast>,
normal_broadcast: SignedMessagePart<NormalBroadcast>,
direct_message: SignedMessagePart<DirectMessage>,
error: P::ProtocolError,
transcript: &Transcript<P, SP>,
) -> Result<Self, LocalError> {
Expand Down Expand Up @@ -155,7 +155,7 @@ where

pub(crate) fn new_echo_round_error(
verifier: &SP::Verifier,
normal_broadcast: SignedMessage<NormalBroadcast>,
normal_broadcast: SignedMessagePart<NormalBroadcast>,
error: EchoRoundError<SP::Verifier>,
) -> Result<Self, LocalError> {
let description = format!("Echo round error: {}", error.description());
Expand Down Expand Up @@ -187,7 +187,7 @@ where

pub(crate) fn new_invalid_direct_message(
verifier: &SP::Verifier,
direct_message: SignedMessage<DirectMessage>,
direct_message: SignedMessagePart<DirectMessage>,
error: DirectMessageError,
) -> Self {
Self {
Expand All @@ -202,7 +202,7 @@ where

pub(crate) fn new_invalid_echo_broadcast(
verifier: &SP::Verifier,
echo_broadcast: SignedMessage<EchoBroadcast>,
echo_broadcast: SignedMessagePart<EchoBroadcast>,
error: EchoBroadcastError,
) -> Self {
Self {
Expand All @@ -217,7 +217,7 @@ where

pub(crate) fn new_invalid_normal_broadcast(
verifier: &SP::Verifier,
normal_broadcast: SignedMessage<NormalBroadcast>,
normal_broadcast: SignedMessagePart<NormalBroadcast>,
error: NormalBroadcastError,
) -> Self {
Self {
Expand Down Expand Up @@ -271,7 +271,7 @@ enum EvidenceEnum<P: Protocol, SP: SessionParameters> {
#[derive_where::derive_where(Debug)]
#[derive(Clone, Serialize, Deserialize)]
pub struct InvalidEchoPackEvidence<SP: SessionParameters> {
normal_broadcast: SignedMessage<NormalBroadcast>,
normal_broadcast: SignedMessagePart<NormalBroadcast>,
invalid_echo_sender: SP::Verifier,
}

Expand Down Expand Up @@ -315,8 +315,8 @@ where
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MismatchedBroadcastsEvidence {
error: MismatchedBroadcastsError,
we_received: SignedMessage<EchoBroadcast>,
echoed_to_us: SignedMessage<EchoBroadcast>,
we_received: SignedMessagePart<EchoBroadcast>,
echoed_to_us: SignedMessagePart<EchoBroadcast>,
}

impl MismatchedBroadcastsEvidence {
Expand Down Expand Up @@ -351,7 +351,7 @@ impl MismatchedBroadcastsEvidence {
#[derive_where::derive_where(Debug)]
#[derive(Clone, Serialize, Deserialize)]
pub struct InvalidDirectMessageEvidence<P: Protocol> {
direct_message: SignedMessage<DirectMessage>,
direct_message: SignedMessagePart<DirectMessage>,
phantom: core::marker::PhantomData<P>,
}

Expand Down Expand Up @@ -381,7 +381,7 @@ where
#[derive_where::derive_where(Debug)]
#[derive(Clone, Serialize, Deserialize)]
pub struct InvalidEchoBroadcastEvidence<P: Protocol> {
echo_broadcast: SignedMessage<EchoBroadcast>,
echo_broadcast: SignedMessagePart<EchoBroadcast>,
phantom: core::marker::PhantomData<P>,
}

Expand Down Expand Up @@ -411,7 +411,7 @@ where
#[derive_where::derive_where(Debug)]
#[derive(Clone, Serialize, Deserialize)]
pub struct InvalidNormalBroadcastEvidence<P: Protocol> {
normal_broadcast: SignedMessage<NormalBroadcast>,
normal_broadcast: SignedMessagePart<NormalBroadcast>,
phantom: core::marker::PhantomData<P>,
}

Expand Down Expand Up @@ -445,13 +445,13 @@ where
#[derive(Clone, Serialize, Deserialize)]
struct ProtocolEvidence<P: Protocol> {
error: P::ProtocolError,
direct_message: SignedMessage<DirectMessage>,
echo_broadcast: SignedMessage<EchoBroadcast>,
normal_broadcast: SignedMessage<NormalBroadcast>,
direct_messages: SerializableMap<RoundId, SignedMessage<DirectMessage>>,
echo_broadcasts: SerializableMap<RoundId, SignedMessage<EchoBroadcast>>,
normal_broadcasts: SerializableMap<RoundId, SignedMessage<NormalBroadcast>>,
combined_echos: SerializableMap<RoundId, SignedMessage<NormalBroadcast>>,
direct_message: SignedMessagePart<DirectMessage>,
echo_broadcast: SignedMessagePart<EchoBroadcast>,
normal_broadcast: SignedMessagePart<NormalBroadcast>,
direct_messages: SerializableMap<RoundId, SignedMessagePart<DirectMessage>>,
echo_broadcasts: SerializableMap<RoundId, SignedMessagePart<EchoBroadcast>>,
normal_broadcasts: SerializableMap<RoundId, SignedMessagePart<NormalBroadcast>>,
combined_echos: SerializableMap<RoundId, SignedMessagePart<NormalBroadcast>>,
}

impl<P> ProtocolEvidence<P>
Expand Down
Loading

0 comments on commit 6ba72bd

Please sign in to comment.