Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(code): Add polka certificates to VoteSync response #859

Draft
wants to merge 20 commits into
base: anca/temp_byzantine_proposer
Choose a base branch
from

Conversation

romac
Copy link
Member

@romac romac commented Feb 18, 2025

No description provided.

@romac romac added the work in progress Work in progress label Feb 18, 2025
/// The value that the Polka is for
pub value_id: ValueId<Ctx>,
/// The votes that make up the Polka
pub votes: Vec<SignedVote<Ctx>>,
Copy link
Member Author

Choose a reason for hiding this comment

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

Right now I am just storing the votes like this, we can switch to an aggregated signature at a later stage if needed.

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.17%. Comparing base (65757e4) to head (ea61aa6).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                       Coverage Diff                        @@
##           anca/temp_byzantine_proposer     #859      +/-   ##
================================================================
- Coverage                         83.06%   82.17%   -0.89%     
================================================================
  Files                               188      191       +3     
  Lines                             16219    16601     +382     
================================================================
+ Hits                              13471    13641     +170     
- Misses                             2748     2960     +212     
Flag Coverage Δ
integration 81.99% <ø> (-0.91%) ⬇️
mbt 8.08% <ø> (-0.32%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core ∅ <ø> (∅)
engine ∅ <ø> (∅)
app ∅ <ø> (∅)
starknet ∅ <ø> (∅)

@romac romac mentioned this pull request Feb 19, 2025
4 tasks
@romac romac changed the title code: Add polka certificate to VoteSync response feat(code): Add polka certificate to VoteSync response Feb 19, 2025
@romac
Copy link
Member Author

romac commented Feb 19, 2025

Ignore the Rust / Standalone CI failure, it is expected because of the debug statements I added in the driver.

@romac
Copy link
Member Author

romac commented Feb 19, 2025

Looks like I broke the Starknet tests, which is unexpected.

@romac romac force-pushed the romac/polka-certificate branch from f6b9dae to 80556c4 Compare February 19, 2025 16:39
if round_input == RoundInput::NoInput {
return Ok(None);
}

self.apply_input(vote_round, round_input)
}

fn store_polka_certificate(&mut self, vote_round: Round, value_id: &ValueId<Ctx>) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Ref:

pure def getCertificate(keeper: Bookkeeper, vkout: VoteKeeperOutput) : Certificate =

Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Check that the certificate we have constructed is valid.

Copy link
Member Author

@romac romac Feb 26, 2025

Choose a reason for hiding this comment

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

TODO: Rename this method to get_polka_certificate

Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: Move this method to the VoteKeeper and only store the certificate in polka_certificates here

@@ -216,6 +216,41 @@ where
None
}

pub(crate) fn store_and_multiplex_polka_certificate(
Copy link
Member Author

Choose a reason for hiding this comment

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

Ref:

pure def applyCertificate(keeper: Bookkeeper, certificate: Set[Vote], currentRound: Round): { bookkeeper: Bookkeeper, output: VoteKeeperOutput } =

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the spec again, I believe this method is not correct. Instead of sending a ProposalAndPolkaCurrent to the state machine, we should instead follow the same logic as the spec and override the votes in the vote keeper.

We should add the apply_certificate method to the VoteKeeper struct and implement that logic there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can do that. But we can also store/ retrieve the certificate as you do here. In this case we also have to change multiplex_proposal() and how we determine polka_current and polka_previous.

@romac
Copy link
Member Author

romac commented Feb 26, 2025

Note: The two relevant integration tests for this PR are:

  • wal::restart_with_byzantine_proposer_1_request_response
  • wal::restart_with_byzantine_proposer_2_request_response

They can be run with:

$ cargo nextest run -p informalsystems-malachitebft-test --no-capture wal::restart_with_byzantine_proposer_1_request_response --retries 0
$ cargo nextest run -p informalsystems-malachitebft-test --no-capture wal::restart_with_byzantine_proposer_2_request_response --retries 0

(Requires cargo-nextest, can be installed with cargo install cargo-nextest)

@nenadmilosevic95
Copy link
Contributor

Hey @romac, I think it will be very useful if we add a description to this PR. As from what I understood it is not a bug fix but rather a change that should not only unstuck consensus in case of a Byzantine behavior observed 2nd scenario in #850 but also lead to the consensus decision.

I can maybe help with writing this description but I need more context, for example where can I learn how vote sync works and when it is triggered?

@romac
Copy link
Member Author

romac commented Feb 26, 2025

I can maybe help with writing this description but I need more context, for example where can I learn how vote sync works and when it is triggered?

We do not have a spec for this yet, but the tracking issue for it has some background info: #576 Let me know if that helps, otherwise I can provide more details.

@cason
Copy link
Contributor

cason commented Feb 28, 2025

Recall that we might need a Polka certificate for a previous round (vr < round_p) in case of line 28.

ancazamfir and others added 13 commits March 3, 2025 16:36
Bumps [prost](https://github.com/tokio-rs/prost) from 0.13.4 to 0.13.5.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Changelog](https://github.com/tokio-rs/prost/blob/master/CHANGELOG.md)
- [Commits](tokio-rs/prost@v0.13.4...v0.13.5)

---
updated-dependencies:
- dependency-name: prost
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore: Add detailed contributing informations

* Code review

* Fix
…#872)

* feat(code): Applications now define their own configuration

* Cleanup

* Ignore unuspported tests

* Fix unit tests

* Fix init and testnet commands

* Post-merge fixes

* Override VoteSync mode from test params for Starknet test app

* Update VoteSync tests

* Re-instate `distributed-testnet` command for Starknet app

* Embed discovery config directly in `MakeConfigSettings`

* Cleanup
…e capacity (#878)

* fix(code/engine): Use custom version of `OutputPort` with configurable capacity

* Disallow use of ractor's output port
@romac
Copy link
Member Author

romac commented Mar 5, 2025

The wal::restart_with_byzantine_proposer_1_request_response test has passed on CI but it does not pass reliably locally. Need to investigate further.

@ancazamfir Can you give it a go when you have time and see if you see the same?

$ cargo nextest run -p informalsystems-malachitebft-test --no-capture --retries 0 wal::restart_with_byzantine_proposer_1_request_response

@romac
Copy link
Member Author

romac commented Mar 5, 2025

It's also surprising that the wal::restart_with_byzantine_proposer_2_rebroadcast test has passed on CI, where I would have expected that we'd need to include the polka certificates in the rebroadcast for it to pass.

@romac romac changed the title feat(code): Add polka certificate to VoteSync response feat(code): Add polka certificates to VoteSync response Mar 5, 2025
@ancazamfir
Copy link
Collaborator

The wal::restart_with_byzantine_proposer_1_request_response test has passed on CI but it does not pass reliably locally. Need to investigate further.

@ancazamfir Can you give it a go when you have time and see if you see the same?

$ cargo nextest run -p informalsystems-malachitebft-test --no-capture --retries 0 wal::restart_with_byzantine_proposer_1_request_response

It passes for me, it was passing even when CI was failing it. I tried today again 10 times and was about to ask you to try it :)

@ancazamfir
Copy link
Collaborator

It's also surprising that the wal::restart_with_byzantine_proposer_2_rebroadcast test has passed on CI, where I would have expected that we'd need to include the polka certificates in the rebroadcast for it to pass.

The test is not there yet. There are a few things:

  • since we fixed the vote equivocation we cannot generate the scenario, we will need the byzantine node to be configured to equivocate on votes in addition to proposals
  • will also need code changes to store equivocating proposals in the driver (currently we only store them before in the full_proposal module)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work in progress Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants