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 certificate to VoteSync response #859

Draft
wants to merge 2 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
)
.await?;
} else {
for vote in vote_set.votes {
Copy link
Member Author

Choose a reason for hiding this comment

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

@ancazamfir I don't believe we need to process both the votes and the certificate, but perhaps I am mistaken?

.cloned()
.collect::<Vec<_>>();

if votes.is_empty() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if this is wrong, in case we have a polka certificate for a previous round?

self.polka_certificates
.iter()
.filter(|c| c.round <= round)
.last()
Copy link
Member Author

Choose a reason for hiding this comment

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

Here I did something similar as we do for commit certificates but it feels very hacky and I am not convinced it is right. Will check the Quint spec again to see whether or not this is correct.

/// 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

❌ 10 Tests Failed:

Tests completed Failed Passed Skipped
149 10 139 0
View the top 3 failed test(s) by shortest run time
informalsystems-malachitebft-test::it wal::non_proposer_crashes_after_voting_parts_only
Stack Traces | 7.65s run time
No failure message available
informalsystems-malachitebft-test::it wal::restart_with_byzantine_proposer_1_request_response
Stack Traces | 60s run time
No failure message available
informalsystems-malachitebft-test::it vote_sync_bcast::crash_restart_from_latest
Stack Traces | 60s run time
No failure message available

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@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

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.

@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.

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.

2 participants