Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Commit

Permalink
feat: make the TooOld error more intelligible by mentioning the rou…
Browse files Browse the repository at this point in the history
…nd target (#734)

Fixes #516
  • Loading branch information
huitseeker committed Aug 12, 2022
1 parent c249df1 commit bc21b32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions primary/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl Core {
);
ensure!(
self.gc_round < header.round,
DagError::TooOld(header.id.into(), header.round)
DagError::TooOld(header.id.into(), header.round, self.gc_round)
);

// Verify the header's signature.
Expand All @@ -476,7 +476,7 @@ impl Core {
);
ensure!(
self.current_header.round <= vote.round,
DagError::TooOld(vote.digest().into(), vote.round)
DagError::VoteTooOld(vote.digest().into(), vote.round, self.current_header.round)
);

// Ensure we receive a vote on the expected header.
Expand Down Expand Up @@ -504,7 +504,11 @@ impl Core {
);
ensure!(
self.gc_round < certificate.round(),
DagError::TooOld(certificate.digest().into(), certificate.round())
DagError::TooOld(
certificate.digest().into(),
certificate.round(),
self.gc_round
)
);

// Verify the certificate (and the embedded header).
Expand Down
7 changes: 5 additions & 2 deletions types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ pub enum DagError {
#[error("Parents of header {0} are not a quorum")]
HeaderRequiresQuorum(HeaderDigest),

#[error("Message {0} (round {1}) too old")]
TooOld(Digest, Round),
#[error("Message {0} (round {1}) too old for GC round {2}")]
TooOld(Digest, Round, Round),

#[error("Vote {0} (round {1}) too old for round {2}")]
VoteTooOld(Digest, Round, Round),

#[error("Invalid epoch (expected {expected}, received {received})")]
InvalidEpoch { expected: Epoch, received: Epoch },
Expand Down

0 comments on commit bc21b32

Please sign in to comment.