Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Dec 19, 2024
1 parent 0dcbc1d commit f1828dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions noir-projects/aztec-nr/aztec/src/oracle/pxe_store.nr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[oracle(store)]
unconstrained fn store_oracle<let N: u32>(key: Field, values: [Field; N]) -> Field {}
unconstrained fn store_oracle<let N: u32>(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<let N: u32>(key: Field, values: [Field; N]) {
let _ = store_oracle(key, values);
store_oracle(key, values);
}

#[oracle(load)]
Expand Down
10 changes: 4 additions & 6 deletions yarn-project/end-to-end/src/e2e_pxe_store.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<void>;
Expand All @@ -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);
});
Expand Down
12 changes: 12 additions & 0 deletions yarn-project/simulator/src/acvm/oracle/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ACVMField[]> {
const values = await this.typedOracle.load(fromACVMField(key));
return values.map(toACVMField);
}
}

0 comments on commit f1828dc

Please sign in to comment.