Skip to content

Conversation

@xinyuan-dev
Copy link
Contributor

Implement the test cases that QC and NEC must not form on the same high certificate (TC). The tests would fail if the mutual exclusive property breaks down.

Specifically, two tests are implemented:

  1. test_qc_xor_nec ensures that when NEC forms, QC must not form and vise versa.
  2. test_refuse_to_vote_on_mismatched_tc ensures that validators never vote for fresh proposal whose FPC is not the same as their local high certificate.

Quoting the @omegablitz's original note:

  QC and NECs must be formed on the same high_certificate (TC) for any given same round
    1. only send NE for round r if haven’t voted for round r
    2. if sent a NE for round r, only send Vote if proposal(round=r).high_certificate = recovery_request.tc
    4. this is to disallow:
        1. collect NEs on TC_1(r-1), make fresh proposal with TC_2(r-1)
        2. collect NEs on TC_1(r-1), make fresh proposal with QC(r-1)

Copilot AI review requested due to automatic review settings November 10, 2025 09:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements support for fresh proposals in the consensus protocol, introducing the FreshProposalCertificate mechanism that allows leaders to make fresh proposals after timeouts using either a No Endorsement Certificate (NEC) or a No Tip Certificate (NTC).

Key changes:

  • Added FreshProposalCertificate parameter to proposal generation to support fresh proposals with NECs or NTCs
  • Implemented conditional round advancement logic that distinguishes between QC-based proposals, TC-based fresh proposals, and same-round reproposals
  • Added helper methods (extract_vote(), try_into_no_tip_certificate(), from_nes(), try_form()) to support certificate construction and validation
  • Added comprehensive test coverage for QC/NEC exclusivity and TC matching validation

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
monad-validator/src/validator_mapping.rs Added Clone derive to ValidatorMapping to support cloning in tests
monad-testutil/src/proposal.rs Modified next_proposal to accept FreshProposalCertificate parameter and implement conditional round advancement logic; added set_last_tc helper method
monad-consensus/src/validation/safety.rs Added clarifying comment for is_safe_to_no_endorse method
monad-consensus-types/src/timeout.rs Added extract_vote() and try_into_no_tip_certificate() helper methods; added documentation for NoTipCertificate
monad-consensus-types/src/quorum_certificate.rs Added QCConditionUnmet enum and try_form() method for conditional QC formation with validation
monad-consensus-types/src/no_endorsement.rs Added new() and from_nes() methods to NoEndorsementCertificate for certificate construction
monad-consensus-state/src/timestamp.rs Added Clone derive to BlockTimestamp to support cloning in tests
monad-consensus-state/src/lib.rs Refactored timeout handling to use extract_vote() method; added Clone constraint on SCT type parameter; added comprehensive tests for fresh proposal functionality
monad-consensus-state/Cargo.toml Added test dependencies (alloy-rlp, tracing-subscriber)
Cargo.lock Updated lockfile with new dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xinyuan-dev xinyuan-dev force-pushed the xinyuan/bft-v2-nec-tests branch from b0b9a20 to 88452fe Compare November 10, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants