refactor(fork-choice): enumerate payload key union without copying values - #1137
Merged
tcoratger merged 1 commit intoJun 17, 2026
Merged
Conversation
…lues Promoting pending aggregate proofs iterated a throwaway merged dict built only to walk its keys, copying every set value just to discard it. Enumerate the key union directly with an order-preserving construction. The new enumeration yields keys in exactly the same order as the old merged dict: all counted-pool keys in insertion order, then pending-pool keys not already present, in their insertion order. This preserves the LMD determinism invariant, where equal-slot ties resolve by first-seen insertion order. A set union would not preserve that order. just check passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
When promoting pending aggregate proofs into the counted pool, the dict comprehension iterated
{**known_payloads, **new_payloads}purely to enumerate the union of attestation-data keys. Building that merged dict copies every set value only to discard it (the comprehension re-fetches via.get()). This replaces it withdict.fromkeys((*known_payloads, *new_payloads)), which enumerates the same keys without copying any values.Why this is behavior- and order-preserving
dict.fromkeys((*known_payloads, *new_payloads))yields keys in exactly the same order the merged-dict spread did: all counted-pool keys in insertion order, then pending-pool keys not already present, in their insertion order. The resultingmerged_aggregated_payloadstherefore has identical key insertion order.This matters because of the LMD determinism invariant: equal-slot fork-choice ties resolve by first-seen insertion order. A set-union (
known_payloads.keys() | new_payloads.keys()) was deliberately avoided here because set iteration order is hash-seeded and would not preserve that order.just checkpasses (lint, format, type check, codespell, mdformat, lock).🤖 Generated with Claude Code