Skip to content

feat(pxe): speculatively sync predicted contract call trees - #25252

Merged
nchamo merged 1 commit into
merge-train/fairiesfrom
cb/port-25214-fairies
Aug 18, 2026
Merged

feat(pxe): speculatively sync predicted contract call trees#25252
nchamo merged 1 commit into
merge-train/fairiesfrom
cb/port-25214-fairies

Conversation

@AztecBot

Copy link
Copy Markdown
Collaborator

Port of #25214 onto merge-train/fairies.

Note on the two-commit request: The cherry-pick applied cleanly with no conflicts, so there's nothing to split into a separate resolution commit. Single squashed commit only — happy to redo it as a two-commit stack if you'd rather see an explicit empty-resolution commit, but that would just be a no-op.

Original description:

PXE syncs contracts serially as execution reaches them: each nested call discovers the next contract only after the previous sync completes, so multi-contract transactions pay one sync round trip per hop.

PXE learns a per-function call graph from the calls each committed job observed (ContractCallGraph). When a sync request arrives, the sync service speculatively starts the syncs of every contract the invoked function is predicted to call, recursing through each callee's own predictions, and also speculates from each contract's sync_state, which runs during the sync itself (#25164). A per-job set of already-speculated functions stops the recursion when the predicted graph has a cycle. Mispredicting is cheap: the extra node requests batch into round trips the job already makes, and the synced data goes unused.

Beyond the straight port, settle changes semantics vs #25126: it tracks only the speculative syncs and rejects with an AggregateError when any failed, so the job discards its staged writes instead of committing them. A speculative failure might not be surfaced by any request, and a sync that fails midway can leave partial staged writes. Stacked on #25208, whose allToCompletion runs the parallel staged-write branches to completion on failure.

The feature is gated behind PXE_CONCURRENT_CONTRACT_SYNC_ENABLED (default off, experimental).

Cherry-pick of merge commit cee7f40ca9c7d53b0d6af2d0175139606cc48f7c (git cherry-pick -m 1), applied cleanly on top of merge-train/fairies.


Created by claudebox · group: slackbot · requested by Nico Chamo · Slack thread

## Why we are doing this

Port of #25126 and #25164 to the v5 line. PXE syncs contracts serially
as execution reaches them: each nested call discovers the next contract
only after the previous sync completes, so multi-contract transactions
pay one sync round trip per hop.

## Our fix

PXE learns a per-function call graph from the calls each committed job
observed (`ContractCallGraph`). When a sync request arrives, the sync
service speculatively starts the syncs of every contract the invoked
function is predicted to call, recursing through each callee's own
predictions, and also speculates from each contract's `sync_state`,
which runs during the sync itself (#25164). A per-job set of
already-speculated functions stops the recursion when the predicted
graph has a cycle. Mispredicting is cheap: the extra node requests batch
into round trips the job already makes, and the synced data goes unused.

Beyond the straight port, `settle` changes semantics vs #25126: it
tracks only the speculative syncs and rejects with an `AggregateError`
when any failed, so the job discards its staged writes instead of
committing them. A speculative failure might not be surfaced by any
request, and a sync that fails midway can leave partial staged writes.
Stacked on #25208, whose `allToCompletion` runs the parallel
staged-write branches to completion on failure.

The feature is gated behind `PXE_CONCURRENT_CONTRACT_SYNC_ENABLED`
(default off, experimental).
@AztecBot AztecBot added ci-draft Run CI on draft PRs. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure claudebox Owned by claudebox. it can push to this PR. labels Aug 18, 2026
@nchamo
nchamo marked this pull request as ready for review August 18, 2026 07:57
@nchamo
nchamo enabled auto-merge (squash) August 18, 2026 07:58
@nchamo
nchamo merged commit cd8bd6d into merge-train/fairies Aug 18, 2026
35 of 41 checks passed
@nchamo
nchamo deleted the cb/port-25214-fairies branch August 18, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants