diff --git a/noir-projects/aztec-nr/aztec/src/oracle/pxe_store.nr b/noir-projects/aztec-nr/aztec/src/oracle/pxe_store.nr index 46c43bb2ed1f..5d0c9fad50ca 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/pxe_store.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/pxe_store.nr @@ -1,9 +1,9 @@ #[oracle(store)] -unconstrained fn store_oracle(key: Field, values: [Field; N]) -> Field {} +unconstrained fn store_oracle(key: Field, values: [Field; N]) {} /// Store an array of values in local PXE database. The data is scoped to the current contract. pub unconstrained fn store(key: Field, values: [Field; N]) { - let _ = store_oracle(key, values); + store_oracle(key, values); } #[oracle(load)] diff --git a/yarn-project/end-to-end/src/e2e_pxe_store.test.ts b/yarn-project/end-to-end/src/e2e_pxe_store.test.ts index 0430e7cd35cc..37c28b00295c 100644 --- a/yarn-project/end-to-end/src/e2e_pxe_store.test.ts +++ b/yarn-project/end-to-end/src/e2e_pxe_store.test.ts @@ -1,6 +1,4 @@ -import { - type Wallet -} from '@aztec/aztec.js'; +import { type Wallet } from '@aztec/aztec.js'; import { TestContract } from '@aztec/noir-contracts.js/Test'; import { jest } from '@jest/globals'; @@ -11,7 +9,7 @@ const TIMEOUT = 120_000; // TODO(#10724): Nuke this once the linked issue is implemented. Made this ugly test to check it works when first // implementing this. -describe('Keys', () => { +describe('PXE store', () => { jest.setTimeout(TIMEOUT); let teardown: () => Promise; @@ -26,9 +24,9 @@ describe('Keys', () => { afterAll(() => teardown()); - describe('using nsk_app to detect nullification', async () => { + it('stores and loads data', async () => { const key = 6n; - const value = [268n, 862n, 268n ]; + const value = [268n, 862n, 268n]; await testContract.methods.store_in_pxe_store(key, value).simulate(); expect(await testContract.methods.load_from_pxe_store(key).simulate()).toEqual(value); }); diff --git a/yarn-project/simulator/src/acvm/oracle/oracle.ts b/yarn-project/simulator/src/acvm/oracle/oracle.ts index 254b91fb3abb..623282c1ab98 100644 --- a/yarn-project/simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/oracle.ts @@ -393,4 +393,16 @@ export class Oracle { async syncNotes() { await this.typedOracle.syncNotes(); } + + async store([key]: ACVMField[], values: ACVMField[]) { + const processedValues = values.map(fromACVMField); + const processedKey = fromACVMField(key); + await this.typedOracle.store(processedKey, processedValues); + return toACVMField(0); + } + + async load([key]: ACVMField[]): Promise { + const values = await this.typedOracle.load(fromACVMField(key)); + return values.map(toACVMField); + } }