refactor(archiver): refactor archiver modules and test suite#19564
Merged
spalladino merged 3 commits intonextfrom Jan 14, 2026
Merged
refactor(archiver): refactor archiver modules and test suite#19564spalladino merged 3 commits intonextfrom
spalladino merged 3 commits intonextfrom
Conversation
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.
This was referenced Jan 13, 2026
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.
2f3cb28 to
77948df
Compare
Collaborator
Flakey Tests🤖 says: This CI run detected 4 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
PhilWindle
approved these changes
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/
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)
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.
Extracts L1 synchronizer and factory
Extracts L1 synchronization logic out of the archiver and into a separate class. Also extracts the
createAndSyncmethod into the archiver factory, and lifts some more methods to theArchiveSourceBase.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 orchestrationhandleCheckpoints()- Checkpoint retrieval and validationhandleL1ToL2Messages()- L1→L2 message fetchinghandleEpochPrune()- Epoch pruning detectionTraceableinterface for distributed tracingModified Files
archiver/src/archiver/archiver.ts: Removed ~630 lines of L1 sync code; constructor now acceptssynchronizerandeventsas injected dependenciesarchiver/src/factory.ts: ConsolidatedArchiver.createAndSync()logic intocreateArchiver(); creates synchronizer/events and injects themarchiver/src/archiver/index.ts: Added export forArchiverL1Synchronizeraztec/src/cli/cmds/start_archiver.ts: Changed fromArchiver.createAndSync()tocreateArchiver()archiver/src/archiver/archiver.sync.test.tsandarchiver.test.ts: Updated to create synchronizer and events before creating ArchiverArchitectural Change
ArchiverL1SynchronizerThis 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.makeBlockHashmakeStateForBlockmakeL1PublishedDatamakePublishedCheckpointmakeChainedCheckpointsmakeSignedPublishedCheckpointmakeInboxMessagesWithFullBlocksmakePrivateLogTag/makePrivateLogmakePublicLogTag/makePublicLogmockPrivateLogs/mockPublicLogsmockCheckpointWithLogsAlso cleaned up the
archiver.test.tssuite 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.src/archiver/tosrc/rpc/foldermodules/folder: Groups internal helpers (instrumentation,validation,l1_synchronizer,data_store_updater,data_source_base)store/:kv_archiver_store/→store/archiver.sync.test.ts→archiver-sync.test.ts, etc.Structure Before → After