Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
}

// Most contracts query state at the "current" block, which is the anchor. Skip the RPC when we can.
if (blockNumber === anchorBlockNumber) {
return this.anchorBlockHeader;
}

const block = await this.aztecNode.getBlock(blockNumber);
return block?.header;
}
Expand Down Expand Up @@ -995,6 +1000,7 @@ 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<T>(blockHash: BlockHash, query: () => Promise<T>): Promise<T> {
// Most contracts query state at the "current" block, which is the anchor. Skip the validation when we can.
const anchorHash = await this.anchorBlockHeader.hash();
if (blockHash.equals(anchorHash)) {
return query();
Expand Down
Loading