refactor(p2p): attestation pool refactoring #20083
Open
+526
−864
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.
Summary
Refactors the attestation pool to simplify the API, and remove unnecessary abstractions.
Built on #20027
Changes by Commit
1.
refactor(p2p): merge checkpoint attestation methods into tryAddCheckpointAttestationMerges multiple checkpoint attestation methods into a single atomic
tryAddCheckpointAttestationmethod, following the same pattern used for proposals:TryAddProposalResult→TryAddResult(reused for both proposals and attestations)tryAddCheckpointAttestation(attestation, committeeSize)that atomically checks existence, validates cap, and addshasCheckpointAttestation,canAddCheckpointAttestation,hasReachedCheckpointAttestationCapvalidateAndStoreCheckpointAttestationto LibP2P service (mirrors the proposal pattern)processCheckpointAttestationFromPeerto use the new atomic method2.
refactor(p2p): remove InMemoryAttestationPool, use KvAttestationPool everywhereRemoves the in-memory implementation in favor of using the KV-backed pool everywhere:
createTestAttestationPool()factory function for tests (uses temp KV store)memory_attestation_pool.tsandmemory_attestation_pool.test.tstestbench-utils.tsfor benchmarking3.
refactor(p2p): remove AttestationPool interface, rename KvAttestationPool to AttestationPoolRemoves the interface abstraction and uses the class directly:
KvAttestationPool→AttestationPoolkv_attestation_pool.ts→attestation_pool.tsTryAddResulttype to the class fileAttestationPoolApitype alias for mocking in testsTest Plan
yarn buildpassesyarn formatcleanyarn lint p2pclean🤖 Generated with Claude Code