Skip to content

perf(archiver): avoid loading full blocks during checkpoint ingestion - #439

Draft
spalladino wants to merge 1 commit into
mainfrom
spl/faster-block-ingestion
Draft

spalladino wants to merge 1 commit into
mainfrom
spl/faster-block-ingestion

Conversation

@spalladino

@spalladino spalladino commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Stack

Bottom to top, each PR targets the branch below it:

Context

Part of A-1817. Redoes AztecProtocol/aztec-packages#25279 (closed after the repo split).

The archiver ingests each checkpoint inside one transactionAsync, so ingestion time directly delays any read queued behind it, notably getLogsByTags. The biggest cost was getPreviousCheckpointBlock loading the previous checkpoint's last block as a full L2Block (one native round trip and deserialization per tx effect) when validation only reads four header-level fields.

Approach

  • getPreviousCheckpointBlock reads the lightweight block data and returns only the chaining info (number, checkpointNumber, indexWithinCheckpoint, archive). L2Block satisfies that shape, so validation is unchanged.
  • LogStore.addLogs serializes txHash once per tx and blockHash once per block and passes them pre-serialized to the codec. The stored byte format is unchanged.

The original PR measured per-checkpoint ingestion dropping ~42-49% (36 txs/block: ~82 → ~42ms; 120 txs/block: ~246 → ~142ms).

The archiver ingests each checkpoint inside one write transaction, so ingestion time directly delays every read
queued behind it. `getPreviousCheckpointBlock` loaded the previous checkpoint's last block as a full `L2Block`
(one store round trip and a deserialization per tx effect), although `validateCheckpointBlocks` only needs its
number, checkpoint number, index within the checkpoint and archive. It now reads the lightweight block data instead.

`LogStore.addLogs` also serialized the same tx hash once per log and the same block hash once per log in the
block. Both are now serialized once and passed to `encodeValue` pre-serialized; the stored byte format is unchanged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant