Skip to content

Commit 30ee7df

Browse files
boicotinhofabiotdf
authored andcommitted
Full nodes blocksync peers - prune old groups
1 parent 59aa414 commit 30ee7df

File tree

8 files changed

+611
-17
lines changed

8 files changed

+611
-17
lines changed

monad-blocksync/src/blocksync.rs

Lines changed: 583 additions & 10 deletions
Large diffs are not rendered by default.

monad-executor-glue/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ where
887887
},
888888
/// Events for secondary raptorcast updates
889889
SecondaryRaptorcastPeersUpdate {
890+
expiry_round: Round,
890891
confirm_group_peers: Vec<NodeId<SCT::NodeIdPubKey>>,
891892
},
892893
}
@@ -930,9 +931,11 @@ where
930931
.field("response", response)
931932
.finish(),
932933
Self::SecondaryRaptorcastPeersUpdate {
934+
expiry_round,
933935
confirm_group_peers,
934936
} => f
935937
.debug_struct("BlockSyncSecondaryRaptorcastEvent")
938+
.field("expiry_round", expiry_round)
936939
.field("confirm_group_peers", confirm_group_peers)
937940
.finish(),
938941
Self::Timeout(request) => f.debug_struct("Timeout").field("request", request).finish(),
@@ -979,9 +982,10 @@ where
979982
encode_list::<_, dyn Encodable>(&enc, out);
980983
}
981984
Self::SecondaryRaptorcastPeersUpdate {
985+
expiry_round,
982986
confirm_group_peers,
983987
} => {
984-
let enc: [&dyn Encodable; 2] = [&7u8, &confirm_group_peers];
988+
let enc: [&dyn Encodable; 3] = [&7u8, &expiry_round, &confirm_group_peers];
985989
encode_list::<_, dyn Encodable>(&enc, out);
986990
}
987991
}
@@ -1031,8 +1035,10 @@ where
10311035
Ok(Self::SelfResponse { response })
10321036
}
10331037
7 => {
1038+
let expiry_round = Round::decode(&mut payload)?;
10341039
let confirm_group_peers = Vec::<NodeId<SCT::NodeIdPubKey>>::decode(&mut payload)?;
10351040
Ok(Self::SecondaryRaptorcastPeersUpdate {
1041+
expiry_round,
10361042
confirm_group_peers,
10371043
})
10381044
}

monad-raptorcast/examples/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ where
257257
RaptorCastEvent::PeerManagerResponse(_peer_manager_response) => {
258258
unimplemented!()
259259
}
260-
RaptorCastEvent::SecondaryRaptorcastPeersUpdate(_event) => {
260+
RaptorCastEvent::SecondaryRaptorcastPeersUpdate(..) => {
261261
unimplemented!()
262262
}
263263
}

monad-raptorcast/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub enum PeerManagerResponse<ST: CertificateSignatureRecoverable> {
116116
pub enum RaptorCastEvent<E, ST: CertificateSignatureRecoverable> {
117117
Message(E),
118118
PeerManagerResponse(PeerManagerResponse<ST>),
119-
SecondaryRaptorcastPeersUpdate(Vec<NodeId<CertificateSignaturePubKey<ST>>>),
119+
SecondaryRaptorcastPeersUpdate(Round, Vec<NodeId<CertificateSignaturePubKey<ST>>>),
120120
}
121121

122122
impl<ST, M, OM, SE, PD> RaptorCast<ST, M, OM, SE, PD>
@@ -982,8 +982,9 @@ where
982982
),
983983
}
984984
}
985-
RaptorCastEvent::SecondaryRaptorcastPeersUpdate(confirm_group_peers) => {
985+
RaptorCastEvent::SecondaryRaptorcastPeersUpdate(expiry_round, confirm_group_peers) => {
986986
MonadEvent::BlockSyncEvent(BlockSyncEvent::SecondaryRaptorcastPeersUpdate {
987+
expiry_round,
987988
confirm_group_peers,
988989
})
989990
}

monad-raptorcast/src/raptorcast_secondary/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ where
486486

487487
ret = Poll::Ready(Some(
488488
RaptorCastEvent::SecondaryRaptorcastPeersUpdate(
489+
confirm_msg.prepare.end_round,
489490
participated_nodes.into_iter().collect(),
490491
)
491492
.into(),

monad-raptorcast/tests/raptorcast_instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ where
439439
RaptorCastEvent::PeerManagerResponse(_peer_manager_response) => {
440440
unimplemented!()
441441
}
442-
RaptorCastEvent::SecondaryRaptorcastPeersUpdate(_event) => {
442+
RaptorCastEvent::SecondaryRaptorcastPeersUpdate { .. } => {
443443
unimplemented!()
444444
}
445445
}

monad-state/src/blocksync.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,14 @@ where
136136
}
137137
BlockSyncEvent::Timeout(request) => block_sync_wrapper.handle_timeout(request),
138138
BlockSyncEvent::SecondaryRaptorcastPeersUpdate {
139+
expiry_round,
139140
confirm_group_peers,
140141
} => {
141-
self.block_sync
142-
.set_secondary_raptorcast_peers(confirm_group_peers);
142+
self.block_sync.set_secondary_raptorcast_peers(
143+
confirm_group_peers,
144+
expiry_round,
145+
self.consensus.current_round(),
146+
);
143147
Vec::new()
144148
}
145149
};

monad-state/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,15 @@ where
361361
ConsensusMode::Live(consensus) => consensus.get_current_epoch(),
362362
}
363363
}
364+
365+
fn current_round(&self) -> Round {
366+
match self {
367+
ConsensusMode::Sync {
368+
high_certificate, ..
369+
} => high_certificate.round() + Round(1),
370+
ConsensusMode::Live(consensus) => consensus.get_current_round(),
371+
}
372+
}
364373
}
365374

366375
#[derive(Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)