Skip to content

refactor(archiver): refactor archiver modules and test suite#19564

Merged
spalladino merged 3 commits intonextfrom
palla/archiver-final-cleanup
Jan 14, 2026
Merged

refactor(archiver): refactor archiver modules and test suite#19564
spalladino merged 3 commits intonextfrom
palla/archiver-final-cleanup

Conversation

@spalladino
Copy link
Contributor

Extracts L1 synchronizer and factory

Extracts L1 synchronization logic out of the archiver and into a separate class. Also extracts the createAndSync method into the archiver factory, and lifts some more methods to the ArchiveSourceBase.

Created Files

  • archiver/src/archiver/archiver_l1_synchronizer.ts (~800 lines): New class that extracts all L1 synchronization logic from the Archiver, including:
    • syncFromL1() - Main sync orchestration
    • handleCheckpoints() - Checkpoint retrieval and validation
    • handleL1ToL2Messages() - L1→L2 message fetching
    • handleEpochPrune() - Epoch pruning detection
    • Implements Traceable interface for distributed tracing

Modified Files

  • archiver/src/archiver/archiver.ts: Removed ~630 lines of L1 sync code; constructor now accepts synchronizer and events as injected dependencies
  • archiver/src/factory.ts: Consolidated Archiver.createAndSync() logic into createArchiver(); creates synchronizer/events and injects them
  • archiver/src/archiver/index.ts: Added export for ArchiverL1Synchronizer
  • aztec/src/cli/cmds/start_archiver.ts: Changed from Archiver.createAndSync() to createArchiver()
  • archiver/src/archiver/archiver.sync.test.ts and archiver.test.ts: Updated to create synchronizer and events before creating Archiver

Architectural Change

  • L1 sync logic is now separated from the Archiver into ArchiverL1Synchronizer
  • Factory is the single entry point for creating an archiver with all its dependencies
  • Dependency injection pattern for synchronizer and event emitter

This aligns with the plan goal of "clean separation of the archiver into syncing (L1 sync) vs datastore (storage + reads)".

Simplifies test suite

Consolidated duplicated test helpers into archiver/src/test/mock_structs.ts.

Function Purpose
makeBlockHash Deterministic block hash from number
makeStateForBlock StateReference with proper noteHashTree index
makeL1PublishedData L1PublishedData with deterministic values
makePublishedCheckpoint Wraps checkpoint with L1 data + attestations
makeChainedCheckpoints Multiple checkpoints with chained archives
makeSignedPublishedCheckpoint Checkpoint with signed attestations
makeInboxMessagesWithFullBlocks Inbox messages distributed across blocks
makePrivateLogTag / makePrivateLog Private log test data
makePublicLogTag / makePublicLog Public log test data
mockPrivateLogs / mockPublicLogs Multiple logs for a tx
mockCheckpointWithLogs Checkpoint with configurable logs

Also cleaned up the archiver.test.ts suite to not depend on L1 synchronization, and just test the store getters after manually inserting data.

Reorganize files

Flattened the archiver package structure by removing the nested archiver/ folder.

  • Removed nesting: Moved files from src/archiver/ to src/
  • Deleted unused: Removed rpc/ folder
  • New modules/ folder: Groups internal helpers (instrumentation, validation, l1_synchronizer, data_store_updater, data_source_base)
  • Renamed store/: kv_archiver_store/store/
  • Renamed files: archiver.sync.test.tsarchiver-sync.test.ts, etc.

Structure Before → After

  • src/archiver/archiver.ts → src/archiver.ts
  • src/archiver/l1/ → src/l1/
  • src/archiver/kv_archiver_store → src/store/
  • src/archiver/structs/ → src/structs/
  • (new) → src/modules/

Cleans up the archiver test suite that tested data store getters, so no
L1 data is required. Also extracts common test factory methods to a
separate file.
Removes unneeded `archiver` nested folder, deletes unused `rpc`, moves
helpers under a `modules` subfolder, renames a few internal classes, and
moves a lot of files around within the archiver package.
@spalladino spalladino force-pushed the palla/archiver-final-cleanup branch from 2f3cb28 to 77948df Compare January 13, 2026 21:13
@AztecBot
Copy link
Collaborator

AztecBot commented Jan 13, 2026

Flakey Tests

🤖 says: This CI run detected 4 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/e27d7a59c93ce703�e27d7a59c93ce7038;;�): yarn-project/end-to-end/scripts/run_test.sh web3signer src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts (39s) (code: 1) (\033Santiago Palladino\033: refactor(archiver): refactor archiver modules and test suite (#19564))
\033FLAKED\033 (8;;http://ci.aztec-labs.com/46ba981685278f9e�46ba981685278f9e8;;�): yarn-project/scripts/run_test.sh stdlib/src/p2p/topics.test.ts (1s) (code: 1) group:e2e-p2p-epoch-flakes (\033Santiago Palladino\033: refactor(archiver): refactor archiver modules and test suite (#19564))
\033FLAKED\033 (8;;http://ci.aztec-labs.com/bec53ed5751e62b2�bec53ed5751e62b28;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/gossip_network.test.ts (500s) (code: 1) group:e2e-p2p-epoch-flakes (\033Santiago Palladino\033: refactor(archiver): refactor archiver modules and test suite (#19564))
\033FLAKED\033 (8;;http://ci.aztec-labs.com/5e17133efe5a7d8e�5e17133efe5a7d8e8;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_epochs/epochs_invalidate_block.parallel.test.ts "proposer invalidates multiple blocks" (605s) (code: 124) group:e2e-p2p-epoch-flakes (\033Santiago Palladino\033: refactor(archiver): refactor archiver modules and test suite (#19564))

@PhilWindle PhilWindle added this pull request to the merge queue Jan 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 14, 2026
@spalladino spalladino added this pull request to the merge queue Jan 14, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 14, 2026
## Extracts L1 synchronizer and factory

Extracts L1 synchronization logic out of the archiver and into a
separate class. Also extracts the `createAndSync` method into the
archiver factory, and lifts some more methods to the
`ArchiveSourceBase`.

  ### Created Files
- **`archiver/src/archiver/archiver_l1_synchronizer.ts`** (~800 lines):
New class that extracts all L1 synchronization logic from the Archiver,
including:
    - `syncFromL1()` - Main sync orchestration
    - `handleCheckpoints()` - Checkpoint retrieval and validation
    - `handleL1ToL2Messages()` - L1→L2 message fetching
    - `handleEpochPrune()` - Epoch pruning detection
    - Implements `Traceable` interface for distributed tracing

  ### Modified Files
- **`archiver/src/archiver/archiver.ts`**: Removed ~630 lines of L1 sync
code; constructor now accepts `synchronizer` and `events` as injected
dependencies
- **`archiver/src/factory.ts`**: Consolidated `Archiver.createAndSync()`
logic into `createArchiver()`; creates synchronizer/events and injects
them
- **`archiver/src/archiver/index.ts`**: Added export for
`ArchiverL1Synchronizer`
- **`aztec/src/cli/cmds/start_archiver.ts`**: Changed from
`Archiver.createAndSync()` to `createArchiver()`
- **`archiver/src/archiver/archiver.sync.test.ts`** and
**`archiver.test.ts`**: Updated to create synchronizer and events before
creating Archiver

  ### Architectural Change
- L1 sync logic is now separated from the Archiver into
`ArchiverL1Synchronizer`
- Factory is the single entry point for creating an archiver with all
its dependencies
  - Dependency injection pattern for synchronizer and event emitter

This aligns with the plan goal of "clean separation of the archiver into
syncing (L1 sync) vs datastore (storage + reads)".

## Simplifies test suite

Consolidated duplicated test helpers into
`archiver/src/test/mock_structs.ts`.

  | Function | Purpose |
  |----------|---------|
  | `makeBlockHash` | Deterministic block hash from number |
| `makeStateForBlock` | StateReference with proper noteHashTree index |
  | `makeL1PublishedData` | L1PublishedData with deterministic values |
| `makePublishedCheckpoint` | Wraps checkpoint with L1 data +
attestations |
| `makeChainedCheckpoints` | Multiple checkpoints with chained archives
|
| `makeSignedPublishedCheckpoint` | Checkpoint with signed attestations
|
| `makeInboxMessagesWithFullBlocks` | Inbox messages distributed across
blocks |
  | `makePrivateLogTag` / `makePrivateLog` | Private log test data |
  | `makePublicLogTag` / `makePublicLog` | Public log test data |
  | `mockPrivateLogs` / `mockPublicLogs` | Multiple logs for a tx |
  | `mockCheckpointWithLogs` | Checkpoint with configurable logs |

Also cleaned up the `archiver.test.ts` suite to not depend on L1
synchronization, and just test the store getters after manually
inserting data.

## Reorganize files

Flattened the archiver package structure by removing the nested
`archiver/` folder.

  - **Removed nesting**: Moved files from `src/archiver/` to `src/`
  - **Deleted unused**: Removed `rpc/` folder
- **New `modules/` folder**: Groups internal helpers (`instrumentation`,
`validation`, `l1_synchronizer`, `data_store_updater`,
`data_source_base`)
  - **Renamed `store/`**: `kv_archiver_store/` → `store/`
- **Renamed files**: `archiver.sync.test.ts` → `archiver-sync.test.ts`,
etc.

  ### Structure Before → After

-   src/archiver/archiver.ts       → src/archiver.ts
-   src/archiver/l1/               → src/l1/
-   src/archiver/kv_archiver_store → src/store/
-   src/archiver/structs/          → src/structs/
-   (new)                          → src/modules/
Merged via the queue into next with commit b0e6d6c Jan 14, 2026
17 checks passed
@spalladino spalladino deleted the palla/archiver-final-cleanup branch January 14, 2026 14:55
ludamad added a commit that referenced this pull request Feb 23, 2026
Slide 19 (§4 insights · PR correlation): two-column layout showing which
PRs caused each weekly flake spike and which fixes produced each recovery:

Spikes:
- W02 (2,647 flakes): Santiago refactors #19532/#19509/#19564 exposed
  timing races across p2p/epoch simultaneously
- W04 (935 flakes): PhilWindle #19982 added cross-chain mbps tests
  without pre-deflaking — valid_epoch_pruned_slash 0→346 events
- W06 (850 flakes): three high-risk PRs merged same day (#20047 peer
  scoring, #20241 max checkpoints→32, #20257 hash constants)

Fixes:
- W03 recovery: Santiago #19914 — checkpointed chain tip for PXE
  (root fix; PXE was using latest not checkpointed block)
- W05 recovery: Santiago #20088 slasher multi-block fix + #20140
  discv5 deflake + GCP step-down (−6 testbed namespaces)
- W07 improvement: Santiago #20351 mbps fix (p2p_client 311→0),
  #20462 remove hardcoded 10s timeout, ludamad #20613 CI parallelism

Also: correct three factual errors spotted during full review —
- Summary: next P50 is growing (+10% in 3 weeks), not stable
- Flake trend W07 note: e2e-p2p-epoch-flakes dropped 373×, not just
  "251 flakes lowest since December"
- Gaps slide: replaced stale "ci_phases broken" card with GCP egress
  costs gap (bc→awk fix is deployed; egress attribution is the gap now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants