Fix TOCTOU race condition for duplicate attestations#10210
Merged
Conversation
rolfyone
reviewed
Dec 9, 2025
| ### Bug Fixes | ||
| - Fixed a storage issue which sometimes caused Teku to crash during shut down. | ||
| - Fixed `peer_count` metric when using `--metrics-publish-endpoint` feature. | ||
| - Fixed attestation validation checks to avoid broadcasting attestations already seen. |
Contributor
There was a problem hiding this comment.
we can remove this, the fix is gloas only and for payload attestations (PTC) not attestations.
rolfyone
approved these changes
Dec 9, 2025
rolfyone
left a comment
Contributor
There was a problem hiding this comment.
LGTM just remove changelog imo.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
PR Description
When validating attestations, the node should not propagate an attestation that was previously seen. In our current implementation, the check if the attestation was seen and the resulting validation was not done atomically, which could lead to a race condition where we check two similar attestations but don't consider them seen.
This fix relies on our synchronised
seenPayloadAttestationssetadd()function to perform a second check if the attestation has been seen.Fixed Issue(s)
N/A
Documentation
doc-change-requiredlabel to this PR if updates are required.Changelog
Note
Makes duplicate payload attestation detection atomic in the gossip validator and adds tests to cover the race scenario.
seenPayloadAttestations.add(key)post-validation; returnignore(...)if already present.ignoreAttestationAlreadySeenValidationResult(...)helper and reuse it afteradd(...).ignoreAttestationAlreadySeenValidationResult(...)to centralize logging and ignore result.shouldIgnore_whenAlreadySeen_AfterInitialCheckto simulate concurrent validations and verify ignore-on-second.Written by Cursor Bugbot for commit 9c7b946. This will update automatically on new commits. Configure here.