Skip to content

Commit

Permalink
feat: added check for own message receival, warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaMasych committed Sep 10, 2024
1 parent 67fd502 commit 2d36dee
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/party.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,26 @@ impl<V: Value, VS: ValueSelector<V>> Party<V, VS> {
sleep(self.cfg.grace_period).await;
if let Some(msg) = msg {
let meta = (msg.routing.msg_type, msg.routing.sender);
if !self.rate_limiter.contains(&meta){
debug!("Party {} received {} from party {}", self.id, meta.0, meta.1);
if let Err(err) = self.update_state(&msg) {
// Shouldn't fail the party, since invalid message
// may be sent by anyone. Furthermore, since in consensus
// we are relying on redundancy of parties, we actually may need
// less messages than from every party to transit to next status.
warn!("Failed to update state for party {} with {}, got error: {err}", self.id, meta.0)
}
self.rate_limiter.insert(meta);
debug!("Party {} received {} from party {}", self.id, meta.0, meta.1);

if self.id == meta.1{
warn!("Received own message {}, intended to be broadcasted.", meta.0);
continue
}
if self.rate_limiter.contains(&meta){
warn!("Party {} hit rate limit in party {} for message {}", meta.1, self.id, meta.0);
continue
}

if let Err(err) = self.update_state(&msg) {
// Shouldn't fail the party, since invalid message
// may be sent by anyone. Furthermore, since in consensus
// we are relying on redundancy of parties, we actually may need
// less messages than from every party to transit to next status.
warn!("Failed to update state for party {} with {}, got error: {err}", self.id, meta.0)
}
self.rate_limiter.insert(meta);

}else if self.msg_in_receiver.is_closed(){
self.status = PartyStatus::Failed;
return Err(MessageChannelClosed)
Expand Down

0 comments on commit 2d36dee

Please sign in to comment.