Skip to content

Conversation

@spalladino
Copy link
Contributor

@spalladino spalladino commented Jan 30, 2026

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 tryAddCheckpointAttestation

Merges multiple checkpoint attestation methods into a single atomic tryAddCheckpointAttestation method, following the same pattern used for proposals:

  • Renames TryAddProposalResultTryAddResult (reused for both proposals and attestations)
  • Adds tryAddCheckpointAttestation(attestation, committeeSize) that atomically checks existence, validates cap, and adds
  • Removes deprecated methods: hasCheckpointAttestation, canAddCheckpointAttestation, hasReachedCheckpointAttestationCap
  • Adds validateAndStoreCheckpointAttestation to LibP2P service (mirrors the proposal pattern)
  • Updates processCheckpointAttestationFromPeer to use the new atomic method

2. refactor(p2p): remove InMemoryAttestationPool, use KvAttestationPool everywhere

Removes the in-memory implementation in favor of using the KV-backed pool everywhere:

  • Adds createTestAttestationPool() factory function for tests (uses temp KV store)
  • Updates all test files to use the factory function
  • Deletes memory_attestation_pool.ts and memory_attestation_pool.test.ts
  • Keeps minimal mock in testbench-utils.ts for benchmarking

3. refactor(p2p): remove AttestationPool interface, rename KvAttestationPool to AttestationPool

Removes the interface abstraction and uses the class directly:

  • Renames KvAttestationPoolAttestationPool
  • Renames kv_attestation_pool.tsattestation_pool.ts
  • Moves TryAddResult type to the class file
  • Adds AttestationPoolApi type alias for mocking in tests
  • Updates all imports across the codebase

Test Plan

  • yarn build passes
  • yarn format clean
  • yarn lint p2p clean
  • Attestation pool tests: 32/32 pass
  • LibP2P service tests: 32/32 pass
  • Block txs protocol tests: 24/24 pass
  • Attestation validator tests: 16/16 pass

🤖 Generated with Claude Code

…ointAttestation

Replace separate hasCheckpointAttestation, canAddCheckpointAttestation, and
hasReachedCheckpointAttestationCap methods with a single tryAddCheckpointAttestation
method that handles all validation and addition in one atomic operation.

This simplifies the API and ensures consistent behavior between checking
and adding attestations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@spalladino spalladino added ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure ci-no-squash labels Jan 30, 2026
spalladino and others added 2 commits January 30, 2026 16:36
…everywhere

- Delete memory_attestation_pool.ts and memory_attestation_pool.test.ts
- Add createTestAttestationPool() factory function for test setup
- Update p2p_client.test.ts to use createTestAttestationPool()
- Update index.ts exports to export KvAttestationPool instead of InMemoryAttestationPool

The InMemoryAttestationPool in test-helpers/testbench-utils.ts is kept as a
minimal mock for benchmarking purposes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…Pool to AttestationPool

- Merge KvAttestationPool class into attestation_pool.ts and rename to AttestationPool
- Move TryAddResult type definition to the class file
- Delete kv_attestation_pool.ts and kv_attestation_pool.test.ts files
- Add AttestationPoolApi type alias for typing mocks and test implementations
- Update all imports across the codebase to use the renamed class
- Update MemPools and P2PClientDeps types to use AttestationPoolApi for flexibility
- Rename test file from kv_attestation_pool.test.ts to attestation_pool.test.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@spalladino spalladino force-pushed the palla/refactor-attestation-pool branch from f996732 to eaf3e65 Compare January 30, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure ci-no-squash

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants