Skip to content

feat(archiver): add getL2ToL1MembershipWitness node RPC#23646

Merged
spalladino merged 1 commit into
merge-train/spartanfrom
spl/outbox-trees-resolver
Jun 1, 2026
Merged

feat(archiver): add getL2ToL1MembershipWitness node RPC#23646
spalladino merged 1 commit into
merge-train/spartanfrom
spl/outbox-trees-resolver

Conversation

@spalladino

@spalladino spalladino commented May 28, 2026

Copy link
Copy Markdown
Contributor

Motivation

Building an L2-to-L1 message membership witness is currently a client-side responsibility: callers hand computeL2ToL1MembershipWitness an OutboxRootsReader plus a node, and the helper reads the L1 Outbox and rebuilds the full four-level message tree on every call, which involves sending all messages for an entire epoch to the client. This adds a node JSON-RPC method that does the work centrally, behind a cache.

As of this PR, the cache only caches reads to the Outbox and for a single L1 slot, but the intent is to eventually cache the individual L2-to-L1 trees so we don't have to recompute them on every request, as well as permanently cache data for an epoch once it's finalized.

Fixes A-653

Approach

A new OutboxTreesResolver in the archiver resolves witness requests. Roots are fetched lazily on request and re-fetched only when the node's synced L1 block has advanced. The four tree levels are rebuilt per request by delegating to the existing, unchanged computeL2ToL1MembershipWitness helper with the cached roots array, so there is no second cache to keep consistent. The resolver is exposed through the archiver (the node's block source) and surfaced as AztecNode.getL2ToL1MembershipWitness.

Changes

  • archiver: New OutboxTreesResolver (lazy roots cache, single-flight de-duplication, witness assembly).
  • stdlib: Add getL2ToL1MembershipWitness to the AztecNode / L2BlockSource / archiver interfaces and schemas; export L2ToL1MembershipWitnessSchema. The computeL2ToL1MembershipWitness helper is unchanged.
  • aztec-node: AztecNodeService.getL2ToL1MembershipWitness passthrough to the block source.
  • ethereum: OutboxContract.getRoots gains an optional { blockNumber } read option so reads can be pinned to the node's synced L1 block.
  • end-to-end (tests): Migrate computeL2ToL1MembershipWitness call sites to the new RPC, wrapped in retryUntil for the cache's eventual consistency. The synthetic-roots case in epochs_partial_proof_multi_root keeps using the helper directly.
  • archiver (tests): New outbox_trees_resolver.test.ts covering the lazy cache (refresh-on-advance, seal/finalize permanence, not-synced handling), single-flight, witness correctness across partial-proof depths and block-level compression, and transient-vs-genuine root mismatch handling.

@spalladino spalladino added the ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure label May 28, 2026
@spalladino spalladino requested review from a team and just-mitch as code owners May 28, 2026 22:08
@spalladino spalladino removed the request for review from just-mitch May 29, 2026 01:32
Base automatically changed from mitch/tmnt-521-rollup-gate-contract to next May 29, 2026 20:41
@spalladino spalladino force-pushed the spl/outbox-trees-resolver branch from 2b25c4c to 70aed7d Compare May 29, 2026 21:26
@spalladino spalladino changed the base branch from next to merge-train/spartan May 29, 2026 21:26
@spalladino spalladino force-pushed the spl/outbox-trees-resolver branch from 3dc43b8 to c1f2f13 Compare May 29, 2026 22:28
*/
export class OutboxTreesResolver {
/** In-memory cache of per-epoch Outbox roots, keyed by epoch number. */
#cache: Map<number, CachedRoots> = new Map();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use a branded type for the key?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Done.

@spalladino spalladino force-pushed the spl/outbox-trees-resolver branch from c1f2f13 to 2219238 Compare June 1, 2026 15:10
@spalladino spalladino enabled auto-merge (squash) June 1, 2026 15:38
@spalladino spalladino force-pushed the spl/outbox-trees-resolver branch from 2219238 to e580e59 Compare June 1, 2026 16:05
Adds a node RPC returning the L2-to-L1 message membership witness for a message
in a tx, built by the archiver against the smallest partial-proof Outbox root
covering the tx's checkpoint. Outbox roots are fetched lazily and cached in
memory, pinned to the node's synced L1 block and re-fetched once it advances.
The witness receipt (epoch / block / txIndex) is derived from getTxEffect.
@spalladino spalladino force-pushed the spl/outbox-trees-resolver branch from e580e59 to 581464f Compare June 1, 2026 17:27
@spalladino spalladino merged commit 7fd840d into merge-train/spartan Jun 1, 2026
14 checks passed
@spalladino spalladino deleted the spl/outbox-trees-resolver branch June 1, 2026 17:55
danielntmd pushed a commit to danielntmd/aztec-packages that referenced this pull request Jun 4, 2026
BEGIN_COMMIT_OVERRIDE
chore: deploy next-net and reuse contracts (AztecProtocol#23761)
chore: turn on autoscaling (AztecProtocol#23706)
chore: rename staging-public to staging (AztecProtocol#23767)
chore(p2p): use sync hash for tx validation hashing (AztecProtocol#23768)
test(e2e): wait warmup slots in slashing tests (AztecProtocol#23719)
feat(api)!: make getTxReceipt the single tx-lookup API (AztecProtocol#23660)
fix: cap cloned n_tps fees within sponsored FPC balance (AztecProtocol#23770)
fix: protect HA validator Postgres from cluster scale-down (AztecProtocol#23772)
refactor: remove non-pipelining sequencer code path (AztecProtocol#23665)
feat(archiver): add getL2ToL1MembershipWitness node RPC (AztecProtocol#23646)
fix(p2p)!: revamp BLOCK_TXS validations (AztecProtocol#23778)
chore: name the bots (AztecProtocol#23795)
fix(e2e): ensure BBSync init (AztecProtocol#23793)
fix(p2p)!: fix BLOCK_TXS response under proposer equivocation (AztecProtocol#23786)
fix: reconnect L1 port-forward after epoch-boundary sleep in n_tps_prove
(AztecProtocol#23800)
chore: add empty vscode settings for yarn-project (AztecProtocol#23808)
fix(sequencer): only warn about missing proposed checkpoint once overdue
(AztecProtocol#23807)
fix: refresh n_tps fee quotes during sustained benchmark (AztecProtocol#23797)
fix(sequencer): enforce build-frame deadlines and align
attestation/publish windows (AztecProtocol#23776)
END_COMMIT_OVERRIDE
spalladino added a commit that referenced this pull request Jun 4, 2026
## Motivation

`v5-next` was cut from `next` at cbc99df (Jun 1), so PRs merged to
`merge-train/spartan` after the cut never flowed into it. This backports
all of them (authored by @spalladino and @fcarreiro) to keep v5-next
current with the spartan train.

## Approach

Each PR is cherry-picked from its squashed merge commit on
`merge-train/spartan`, in merge order, preserving the original commit
message and PR number — one commit per backported PR. All 11 applied
cleanly with no conflicts; patches are identical to the originals
(verified via `git patch-id`), and `bootstrap.sh build yarn-project`
passes on the result. Labeled `ci-no-squash` to preserve the per-PR
commits.

## Backported PRs

- #23768 — chore(p2p): use sync hash for tx validation hashing
- #23719 — test(e2e): wait warmup slots in slashing tests
- #23660 — feat(api)!: make getTxReceipt the single tx-lookup API
- #23665 — refactor: remove non-pipelining sequencer code path
- #23646 — feat(archiver): add getL2ToL1MembershipWitness node RPC
- #23778 — fix(p2p)!: revamp BLOCK_TXS validations
- #23786 — fix(p2p)!: fix BLOCK_TXS response under proposer equivocation
- #23808 — chore: add empty vscode settings for yarn-project
- #23807 — fix(sequencer): only warn about missing proposed checkpoint
once overdue
- #23776 — fix(sequencer): enforce build-frame deadlines and align
attestation/publish windows
- #23818 — chore(p2p): BlockTxsRequest comment

Note #23660, #23778, and #23786 are breaking changes (node RPC +
tx-effect db format, and p2p wire format respectively), as they were on
`next`.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants