Skip to content

Commit

Permalink
chore: replace sibling path read with leaf read (#6834)
Browse files Browse the repository at this point in the history
Follow up to the closing of
#4320, it seems
this function was missed while replacing the `getPublicDataTreeWitness`
calls.
  • Loading branch information
nventuro authored Jun 14, 2024
1 parent 6237ddd commit a20d845
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions yarn-project/simulator/src/client/client_execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<Fr[]> {
// 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;
Expand Down

0 comments on commit a20d845

Please sign in to comment.