Skip to content

refactor(pxe): skip redundant getBlock RPC when querying at anchor block#23100

Merged
nchamo merged 1 commit into
merge-train/fairiesfrom
nchamo/block-rpc-optimizations
May 8, 2026
Merged

refactor(pxe): skip redundant getBlock RPC when querying at anchor block#23100
nchamo merged 1 commit into
merge-train/fairiesfrom
nchamo/block-rpc-optimizations

Conversation

@nchamo

@nchamo nchamo commented May 8, 2026

Copy link
Copy Markdown
Contributor

Why

During tx simulation, #queryWithBlockHashNotAfterAnchor fires a getBlock RPC on every oracle call to validate the queried block isn't ahead of the anchor. In practice, 5 of the 6 call sites always pass the anchor block hash itself, making this validation a no-op.

The fix

Before running the full validation, compare the incoming blockHash against the anchor block's own hash. If they match, skip the getBlock RPC entirely and run the query directly — a block can never be ahead of itself, so the validation is a tautology.

When the hashes don't match (e.g. getFromPublicStorage called with a historical block header from get_block_header_at()), the original validation path runs unchanged.

Details

BlockHeader.hash() caches its result internally via _cachedHash, so repeated calls to this.anchorBlockHeader.hash() are effectively free after the first computation.

@nchamo nchamo self-assigned this May 8, 2026
@nchamo nchamo force-pushed the nchamo/block-rpc-optimizations branch from d0cbb19 to eeacc9d Compare May 8, 2026 16:19
@nchamo nchamo requested a review from Thunkar May 8, 2026 16:50
@nchamo nchamo merged commit c073308 into merge-train/fairies May 8, 2026
35 of 37 checks passed
@nchamo nchamo deleted the nchamo/block-rpc-optimizations branch May 8, 2026 16:58
@AztecBot

AztecBot commented May 8, 2026

Copy link
Copy Markdown
Collaborator

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

AztecBot added a commit that referenced this pull request May 9, 2026
BEGIN_COMMIT_OVERRIDE
fix(aztec-up): Aztec installer does not shadow user installed binaries
on PATH (#22902)
fix: include sqlite binary in its npm package (#23039)
chore: backport #23041 (add sendMessagesAs to wallet api schemas) to
v4-next (#23081)
chore: backport DeployMethod refactor (#22985) to v4-next (#23029)
refactor(pxe): deduplicate tx hash lookups in MessageContextService
(#23075)
refactor(pxe): batch tagged private log queries across all secrets
(#23048)
refactor(pxe): batch log RPC calls in LogService.fetchLogsByTag (#23088)
feat(aztec-nr): Initial handshake registry contract with non interactive
handshake function (#22854)
fix: add Tag.random() helper required by backported #23088 tests
(#23094)
chore: backport: fix(aztec-up): installer does not shadow user binaries
on PATH (#22902) (#23060)
chore: backport handshake registry contract (#22854) to v4-next (#23063)
feat: deploy method refactor 2 (#23033)
refactor(pxe): skip redundant getBlock RPC when querying at anchor block
(#23100)
port(v4-next): feat(docs): autogenerate node JSON-RPC API reference
(#22543) (#23046)
chore: backport feat: deploy method refactor 2 (#23033) to v4-next
(#23103)
port(v4-next): feat(ci): Snapshots for aztec-nr contract compilation
failures and nargo expand (#23061) (#23104)
feat(txe): allow authorizing cross-contract utility calls in nr tests
(#23064)
END_COMMIT_OVERRIDE
github-merge-queue Bot pushed a commit that referenced this pull request May 10, 2026
BEGIN_COMMIT_OVERRIDE
fix: include sqlite binary in its npm package (#23039)
fix: add sendMessagesAs to wallet api schemas (#23041)
refactor(pxe): deduplicate tx hash lookups in MessageContextService
(#23075)
refactor(pxe): batch tagged private log queries across all secrets
(#23048)
refactor(pxe): batch log RPC calls in LogService.fetchLogsByTag (#23088)
feat(pxe,nr): flesh out account stubs and don't exclude syncing for
overrides (#23054)
feat: deploy method refactor 2 (#23033)
feat: fastForwardContractUpdate cheatcode for simulating contract
updates (#22905)
refactor(stdlib): consolidate find-function-by-selector helpers (#23008)
feat(ci): Snapshots for aztec-nr contract compilation failures and nargo
expand (#23061)
chore: kv store test fully on vitest (#23096)
refactor(pxe): skip redundant getBlock RPC when querying at anchor block
(#23100)
chore(playground): bump main chunk size limit 1750 → 1800 KB (#23107)
feat(txe): allow authorizing cross-contract utility calls in nr tests
(#23064)
chore: bench public fns with emit repro (#23105)
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.

3 participants