Skip to content

Commit 267f06b

Browse files
authored
Merge pull request #494 from EspressoSystems/tw/drop-late-deliveries
Drop delayed candidate list deliveries.
2 parents d289b8c + 11cd8ce commit 267f06b

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

timeboost-sequencer/src/lib.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use timeboost_types::{CandidateList, CandidateListBytes, InclusionList};
2626
use tokio::select;
2727
use tokio::sync::mpsc::{self, Receiver, Sender};
2828
use tokio::task::{JoinHandle, spawn};
29-
use tracing::{error, info, warn};
29+
use tracing::{debug, error, info, warn};
3030

3131
use decrypt::{Decrypter, DecrypterError};
3232
use include::Includer;
@@ -78,6 +78,7 @@ struct Task {
7878
commands: Receiver<Command>,
7979
output: Sender<Output>,
8080
mode: Mode,
81+
round: Option<RoundNumber>,
8182
}
8283

8384
enum Command {
@@ -188,6 +189,7 @@ impl Sequencer {
188189
output: tx,
189190
commands: cr,
190191
mode: Mode::Passive,
192+
round: None,
191193
};
192194

193195
Ok(Self {
@@ -374,9 +376,23 @@ impl Task {
374376
if let Action::Deliver(payload) = action {
375377
match payload.data().decode::<MAX_MESSAGE_SIZE>() {
376378
Ok(data) => {
377-
round = payload.round().num();
378-
evidence = payload.into_evidence();
379-
lists.push(data)
379+
if self
380+
.round
381+
.map(|r| r < payload.round().num())
382+
.unwrap_or(true)
383+
{
384+
round = payload.round().num();
385+
evidence = payload.into_evidence();
386+
lists.push(data)
387+
} else {
388+
debug!(
389+
node = %self.label,
390+
ours = ?self.round.map(u64::from),
391+
theirs = %payload.round().num(),
392+
src = %payload.source(),
393+
"dropping delayed payload"
394+
);
395+
}
380396
}
381397
Err(err) => {
382398
warn!(
@@ -393,6 +409,8 @@ impl Task {
393409
}
394410
}
395411
if !lists.is_empty() {
412+
debug_assert!(self.round < Some(round));
413+
self.round = Some(round);
396414
candidates.push((round, evidence, lists))
397415
}
398416
while let Some(action) = actions.pop_front() {

0 commit comments

Comments
 (0)