From eeacc9da68e025081e9b39dec2ef533f3f9243c6 Mon Sep 17 00:00:00 2001 From: Nico Chamo Date: Fri, 8 May 2026 13:09:28 -0300 Subject: [PATCH] refactor(pxe): skip redundant getBlock RPC when querying at anchor block --- .../oracle/utility_execution_oracle.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts index 688ae67ef1c1..d59d6c4d1995 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts @@ -995,6 +995,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra /** Runs a query concurrently with a validation that the block hash is not ahead of the anchor block. */ async #queryWithBlockHashNotAfterAnchor(blockHash: BlockHash, query: () => Promise): Promise { + const anchorHash = await this.anchorBlockHeader.hash(); + if (blockHash.equals(anchorHash)) { + return query(); + } + const [response] = await Promise.all([ query(), (async () => { @@ -1006,7 +1011,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra if (header.getBlockNumber() > this.anchorBlockHeader.getBlockNumber()) { throw new Error( - `Made a node query with a reference block hash ${blockHash} with block number ${header.getBlockNumber()}, which is ahead of the anchor block number ${this.anchorBlockHeader.getBlockNumber()} (from anchor block hash ${await this.anchorBlockHeader.hash()}).`, + `Made a node query with a reference block hash ${blockHash} with block number ${header.getBlockNumber()}, which is ahead of the anchor block number ${this.anchorBlockHeader.getBlockNumber()} (from anchor block hash ${anchorHash}).`, ); } })(),