[Fix] Properly handle late-arriving signatures#4202
Draft
kaimast wants to merge 1 commit intofeat/batch-triggersfrom
Draft
[Fix] Properly handle late-arriving signatures#4202kaimast wants to merge 1 commit intofeat/batch-triggersfrom
kaimast wants to merge 1 commit intofeat/batch-triggersfrom
Conversation
vicsn
reviewed
Apr 10, 2026
| // 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. |
Collaborator
There was a problem hiding this comment.
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 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; |
Collaborator
There was a problem hiding this comment.
Are there existing or hypothetical scenario's where it's a problem that proposed_batch is temporarily empty?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #4092 by introducing a
ProposedBatchStateenum 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_batchmethod 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.