diff --git a/CHANGELOG.md b/CHANGELOG.md
index a431d1a..c6e3baf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Serialization format is a part of `SessionParameters` now; `Round` and `Protocol` methods receive dynamic serializers/deserializers. ([#33])
- Renamed `(Verified)MessageBundle` to `(Verified)Message`. Both are now generic over `Verifier`. ([#56])
- `Session::preprocess_message()` now returns a `PreprocessOutcome` instead of just an `Option`. ([#57])
+- `Session::terminate_due_to_errors()` replaces `terminate()`; `terminate()` now signals user interrupt. ([#58])
### Added
@@ -41,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#47]: https://github.com/entropyxyz/manul/pull/47
[#56]: https://github.com/entropyxyz/manul/pull/56
[#57]: https://github.com/entropyxyz/manul/pull/57
+[#58]: https://github.com/entropyxyz/manul/pull/58
## [0.0.1] - 2024-10-12
diff --git a/examples/tests/async_runner.rs b/examples/tests/async_runner.rs
index 1074b18..67d094e 100644
--- a/examples/tests/async_runner.rs
+++ b/examples/tests/async_runner.rs
@@ -112,7 +112,7 @@ where
// Terminating.
CanFinalize::Never => {
tracing::warn!("{key:?}: This session cannot ever be finalized. Terminating.");
- return session.terminate(accum);
+ return session.terminate_due_to_errors(accum);
}
}
diff --git a/manul/src/session/session.rs b/manul/src/session/session.rs
index c415d7d..96621ae 100644
--- a/manul/src/session/session.rs
+++ b/manul/src/session/session.rs
@@ -410,8 +410,11 @@ where
RoundAccumulator::new(self.round.expecting_messages_from())
}
- /// Terminates the session.
- pub fn terminate(self, accum: RoundAccumulator
) -> Result, LocalError> {
+ fn terminate_inner(
+ self,
+ accum: RoundAccumulator,
+ not_enough_messages: bool,
+ ) -> Result, LocalError> {
let round_id = self.round_id();
let transcript = self.transcript.update(
round_id,
@@ -422,7 +425,26 @@ where
accum.unprovable_errors,
accum.still_have_not_sent_messages,
)?;
- Ok(SessionReport::new(SessionOutcome::NotEnoughMessages, transcript))
+ let outcome = if not_enough_messages {
+ SessionOutcome::NotEnoughMessages
+ } else {
+ SessionOutcome::Terminated
+ };
+ Ok(SessionReport::new(outcome, transcript))
+ }
+
+ /// Terminates the session, recording the reason as a user decision.
+ pub fn terminate(self, accum: RoundAccumulator) -> Result, LocalError> {
+ self.terminate_inner(accum, false)
+ }
+
+ /// Terminates the session, recording the reason as the session being not possible to finalize
+ /// due to the number of misbehaving nodes.
+ ///
+ /// Will be usually called after receiving [`CanFinalize::Never`] from
+ /// [`can_finalize`](`Self::can_finalize`).
+ pub fn terminate_due_to_errors(self, accum: RoundAccumulator) -> Result, LocalError> {
+ self.terminate_inner(accum, false)
}
/// Attempts to finalize the current round.
diff --git a/manul/src/session/transcript.rs b/manul/src/session/transcript.rs
index a1d2cfe..382448d 100644
--- a/manul/src/session/transcript.rs
+++ b/manul/src/session/transcript.rs
@@ -174,10 +174,13 @@ pub enum SessionOutcome {
/// The execution stalled because of an unattributable error,
/// but the protocol created a proof that this node performed its duties correctly.
///
- /// This protocol is supposed to be passed to a third party for adjudication.
+ /// This proof is supposed to be passed to a third party for adjudication,
+ /// along with the proofs from the other nodes.
StalledWithProof(P::CorrectnessProof),
/// The execution stalled because not enough messages were received to finalize the round.
NotEnoughMessages,
+ /// The execution was terminated by the user.
+ Terminated,
}
/// The report of a session execution.
diff --git a/manul/src/testing/run_sync.rs b/manul/src/testing/run_sync.rs
index e04dc24..b14301f 100644
--- a/manul/src/testing/run_sync.rs
+++ b/manul/src/testing/run_sync.rs
@@ -68,7 +68,7 @@ where
}
}
CanFinalize::NotYet => break State::InProgress { session, accum },
- CanFinalize::Never => break State::Finished(session.terminate(accum)?),
+ CanFinalize::Never => break State::Finished(session.terminate_due_to_errors(accum)?),
}
let destinations = session.message_destinations();