Skip to content

[Fix] Properly handle late-arriving signatures#4202

Draft
kaimast wants to merge 1 commit intofeat/batch-triggersfrom
fix/log-unknown-batch-id
Draft

[Fix] Properly handle late-arriving signatures#4202
kaimast wants to merge 1 commit intofeat/batch-triggersfrom
fix/log-unknown-batch-id

Conversation

@kaimast
Copy link
Copy Markdown
Contributor

@kaimast kaimast commented Apr 3, 2026

This PR fixes #4092 by introducing a ProposedBatchState enum that properly handles the different states of certification a new batch can be in. Requires #4190 to be merged first.

It also moves signatures handling to a dedicated Primary::add_signature_to_batch method and adds unit tests for it. The test coverage is almost a little excessive, but it is a critical part of the code and the tests only take about two seconds to run on my machine.

Comment thread node/bft/src/primary.rs
// Save the current proposal cache to disk.
let proposal_cache = {
let proposal = self.proposed_batch.write().take();
// Only persist a Certifying batch; a Certified batch will appear in pending_certificates.
Copy link
Copy Markdown
Collaborator

@vicsn vicsn Apr 10, 2026

Choose a reason for hiding this comment

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

Can this theoretically be in a race condition with certification/storage insertion? If yes would having this as a duplicate in the cache as proposal and certificate be a problem? If so this would have been an issue independent already before this PR

Comment thread node/bft/src/primary.rs
Comment on lines +1254 to +1255
self_.add_signature_to_batch(std::mem::take(&mut *proposed_batch), peer_ip, batch_id, signature);
*proposed_batch = new_state;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are there existing or hypothetical scenario's where it's a problem that proposed_batch is temporarily empty?

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