Skip to content

Commit e8b8fca

Browse files
committed
Only send messages to non-banned nodes
1 parent 325ab2d commit e8b8fca

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

manul/src/session/session.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub struct Session<P: Protocol<SP::Verifier>, SP: SessionParameters> {
113113
verifier: SP::Verifier,
114114
format: BoxedFormat,
115115
round: BoxedRound<SP::Verifier, P>,
116+
message_destinations: BTreeSet<SP::Verifier>,
116117
communication_info: CommunicationInfo<SP::Verifier>,
117118
echo_round_info: Option<EchoRoundInfo<SP::Verifier>>,
118119
echo_broadcast: SignedMessagePart<EchoBroadcast>,
@@ -174,6 +175,11 @@ where
174175
let normal_broadcast = SignedMessagePart::new::<SP>(rng, &signer, &session_id, &transition_info.id(), normal)?;
175176

176177
let communication_info = round.as_ref().communication_info();
178+
let message_destinations = communication_info
179+
.message_destinations
180+
.difference(&transcript.banned_ids())
181+
.cloned()
182+
.collect::<BTreeSet<_>>();
177183

178184
let round_sends_echo_broadcast = !echo_broadcast.payload().is_none();
179185
let echo_round_info = match &communication_info.echo_round_participation {
@@ -212,6 +218,7 @@ where
212218
echo_broadcast,
213219
normal_broadcast,
214220
transition_info,
221+
message_destinations,
215222
communication_info,
216223
echo_round_info,
217224
transcript,
@@ -230,7 +237,7 @@ where
230237

231238
/// Returns the set of message destinations for the current round.
232239
pub fn message_destinations(&self) -> &BTreeSet<SP::Verifier> {
233-
&self.communication_info.message_destinations
240+
&self.message_destinations
234241
}
235242

236243
/// Creates the message to be sent to the given destination.
@@ -241,6 +248,12 @@ where
241248
rng: &mut impl CryptoRngCore,
242249
destination: &SP::Verifier,
243250
) -> Result<(Message<SP::Verifier>, ProcessedArtifact<SP>), LocalError> {
251+
if !self.message_destinations.contains(destination) {
252+
return Err(LocalError::new(
253+
"Destination {destination} is not in the set of message destinations for this round",
254+
));
255+
}
256+
244257
let (direct_message, artifact) = self
245258
.round
246259
.as_ref()

0 commit comments

Comments
 (0)