From a20d845d35715816ddc889fb9a75fb9fba4fc356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Fri, 14 Jun 2024 12:19:38 +0100 Subject: [PATCH] chore: replace sibling path read with leaf read (#6834) Follow up to the closing of https://github.com/AztecProtocol/aztec-packages/issues/4320, it seems this function was missed while replacing the `getPublicDataTreeWitness` calls. --- .../src/client/client_execution_context.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/yarn-project/simulator/src/client/client_execution_context.ts b/yarn-project/simulator/src/client/client_execution_context.ts index 161a4f06c53..ab66af72af1 100644 --- a/yarn-project/simulator/src/client/client_execution_context.ts +++ b/yarn-project/simulator/src/client/client_execution_context.ts @@ -21,7 +21,7 @@ import { type TxContext, } from '@aztec/circuits.js'; import { Aes128 } from '@aztec/circuits.js/barretenberg'; -import { computePublicDataTreeLeafSlot, computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash'; +import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash'; import { type FunctionAbi, type FunctionArtifact, countArgumentsSize } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { pedersenHash } from '@aztec/foundation/crypto'; @@ -676,20 +676,13 @@ export class ClientExecutionContext extends ViewDataOracle { * @param numberOfElements - Number of elements to read from the starting storage slot. */ public override async storageRead(startStorageSlot: Fr, numberOfElements: number): Promise { - // TODO(#4320): This is a hack to work around not having directly access to the public data tree but - // still having access to the witnesses - const bn = await this.db.getBlockNumber(); - const values = []; for (let i = 0n; i < numberOfElements; i++) { const storageSlot = new Fr(startStorageSlot.value + i); - const leafSlot = computePublicDataTreeLeafSlot(this.callContext.storageContractAddress, storageSlot); - const witness = await this.db.getPublicDataTreeWitness(bn, leafSlot); - if (!witness) { - throw new Error(`No witness for slot ${storageSlot.toString()}`); - } - const value = witness.leafPreimage.value; + + const value = await this.aztecNode.getPublicStorageAt(this.callContext.storageContractAddress, storageSlot); this.log.debug(`Oracle storage read: slot=${storageSlot.toString()} value=${value}`); + values.push(value); } return values;