Skip to content

Commit

Permalink
Enforce narwhal header timestamp monotonic with respect to it's paren…
Browse files Browse the repository at this point in the history
  • Loading branch information
andll authored Mar 30, 2023
1 parent e76948d commit bce0c14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions narwhal/primary/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,10 @@ impl PrimaryReceiverHandler {
parent.round() + 1 == header.round(),
DagError::HeaderHasInvalidParentRoundNumbers(header.digest())
);
ensure!(
header.created_at() >= parent.header().created_at(),
DagError::HeaderHasInvalidParentTimestamp(header.digest())
);
ensure!(
parent_authorities.insert(parent.header().author()),
DagError::HeaderHasDuplicateParentAuthorities(header.digest())
Expand Down
3 changes: 3 additions & 0 deletions narwhal/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub enum DagError {
#[error("Header {0} has parents with invalid round numbers")]
HeaderHasInvalidParentRoundNumbers(HeaderDigest),

#[error("Header {0} has parents with invalid timestamp")]
HeaderHasInvalidParentTimestamp(HeaderDigest),

#[error("Header {0} has more than one parent certificate with the same authority")]
HeaderHasDuplicateParentAuthorities(HeaderDigest),

Expand Down

0 comments on commit bce0c14

Please sign in to comment.