Skip to content

refactor(pxe): batch RPC calls for note and event validation#22988

Merged
nchamo merged 3 commits into
merge-train/fairiesfrom
nicolasc/rpc-calls-optimization
May 7, 2026
Merged

refactor(pxe): batch RPC calls for note and event validation#22988
nchamo merged 3 commits into
merge-train/fairiesfrom
nicolasc/rpc-calls-optimization

Conversation

@nchamo

@nchamo nchamo commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactors note and event validation in the PXE to prefetch tx effects once per unique tx hash and pass them as a map to batch methods, eliminating redundant RPC calls when multiple notes/events share a transaction
  • Consolidates nullifier lookups into a chunked batch helper, replacing per-note RPC calls with a single batched call
  • Adds a uniqueBy utility to the foundation collection library for deduplicating arrays by a key function

@nchamo nchamo self-assigned this May 6, 2026
@nchamo nchamo requested a review from Thunkar May 6, 2026 13:57

@Thunkar Thunkar left a comment

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.

Lovely! Would feel better if @mverzilli took a look too though

@nchamo nchamo requested a review from mverzilli May 6, 2026 14:45
*/
async #fetchTxEffects(txHashes: TxHash[]): Promise<Map<string, IndexedTxEffect>> {
const uniqueTxHashes = uniqueBy(txHashes, h => h.toString());
const fetched = await Promise.all(uniqueTxHashes.map(h => this.aztecNode.getTxEffect(h)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some thoughts that came to mind looking at this:

  1. "oh it would be nice if the node let us ask for a bunch of txeffects in one request"
  2. "oh but that could damage privacy"
  3. "oh but if the node wanted to harm us actually they would see a history of very close txeffects anyway in their logs"

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.

We assume that the node has good intentions, so we could consider this in the future

@mverzilli mverzilli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lovely!

@nchamo nchamo merged commit dd5c71e into merge-train/fairies May 7, 2026
14 checks passed
@nchamo nchamo deleted the nicolasc/rpc-calls-optimization branch May 7, 2026 10:59
@AztecBot

AztecBot commented May 7, 2026

Copy link
Copy Markdown
Collaborator

✅ Successfully backported to backport-to-v4-next-staging #23032.

Thunkar added a commit that referenced this pull request May 7, 2026
BEGIN_COMMIT_OVERRIDE
refactor(pxe): batch RPC calls for note and event validation (#22988)
END_COMMIT_OVERRIDE
rangozd pushed a commit to rangozd/aztec-packages that referenced this pull request May 16, 2026
BEGIN_COMMIT_OVERRIDE
refactor: `getPackageVersion` fn cleanup (AztecProtocol#22941)
fix(ci): skip acceptance test for canary -commit. tags (AztecProtocol#22951)
fix: closing db, correct stub side effects (AztecProtocol#22939)
feat: wallet-sdk heartbeat (AztecProtocol#22948)
chore: pxe db schema compatibility test (AztecProtocol#22872)
feat: stamping aztec version into contract artifacts (AztecProtocol#22550)
fix: add aztecVersion to PXE schema_tests fixture (AztecProtocol#22960)
feat(pxe): deduplicate class ID verification per contract (AztecProtocol#22966)
chore: add noirfmt.toml to noir-contracts and run nargo fmt (AztecProtocol#22971)
feat(aztec-nr): Initial handshake registry contract with non interactive
handshake function (AztecProtocol#22854)
chore: merge next into merge-train/fairies (AztecProtocol#22991)
fix(aztec-up): Aztec installer does not shadow user installed binaries
on PATH (AztecProtocol#22902)
test(ci): drop e2e_kernelless_simulation from backwards-compat e2e
(AztecProtocol#23005)
feat(ci): notify #team-fairies when backwards-compat e2e fails on
nightly (AztecProtocol#23006)
chore: merge next into merge-train/fairies (AztecProtocol#23021)
fix: better DeployMethod (AztecProtocol#22985)
refactor(pxe): batch RPC calls for note and event validation (AztecProtocol#22988)
END_COMMIT_OVERRIDE
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.

4 participants