Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
29ba730
fix: add array overflow composer error
Maddiaa0 Jun 6, 2023
0e4ed78
fix: add negative test case for array overflow
Maddiaa0 Jun 6, 2023
67beb49
fix: update ts tests
Maddiaa0 Jun 6, 2023
8c597f7
fix: snapshot
Maddiaa0 Jun 6, 2023
2fc0721
feat: add new_commitments aggregation to public kernel
Maddiaa0 Jun 5, 2023
855d7c8
fix: update ts gen
Maddiaa0 Jun 5, 2023
2d6dd13
fix: update snapshot
Maddiaa0 Jun 5, 2023
4f1807b
fix: hack cbind compiler output
Maddiaa0 Jun 6, 2023
53db311
fix: lint bindings a posteriori
Maddiaa0 Jun 6, 2023
21a712d
feat(): include l2 to l1 message propagation
Maddiaa0 Jun 6, 2023
ea6d959
fix: reduce init number of l2 to l1 messages in test prev kernel test
Maddiaa0 Jun 6, 2023
1fcde70
fix: lint
Maddiaa0 Jun 6, 2023
829c0a4
fix: dont create full public circuits for the tests
Maddiaa0 Jun 6, 2023
5364b22
fix: we appease the linter
Maddiaa0 Jun 6, 2023
34d0742
fix: update snapshot to be half full
Maddiaa0 Jun 6, 2023
2038413
fix: review nits
Maddiaa0 Jun 6, 2023
5c1606c
cleanup
Maddiaa0 Jun 7, 2023
caa9527
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Maddiaa0 Jun 7, 2023
4ed27be
fix: update merge snapshots
Maddiaa0 Jun 7, 2023
ff13b71
Merge branch 'md/array-push-assertions' into md/new-commitments-public
Maddiaa0 Jun 7, 2023
0faef39
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Maddiaa0 Jun 7, 2023
288748f
lint
Maddiaa0 Jun 7, 2023
314cd67
Merge branch 'master' into md/new-commitments-public
Maddiaa0 Jun 7, 2023
a609186
fix: drop stack from l2 to l1 messages
Maddiaa0 Jun 7, 2023
b58ee32
fix: add nullifiers
Maddiaa0 Jun 7, 2023
e2853f8
feat: add test for static call nullifier | commitment creation
Maddiaa0 Jun 7, 2023
cba25a1
fix: re-run generator
Maddiaa0 Jun 7, 2023
4d6c8ed
fix: update snapshot with new nullifiers
Maddiaa0 Jun 7, 2023
9a9eee1
fix: update private call stack item value
Maddiaa0 Jun 7, 2023
58b0d0b
temp
Maddiaa0 Jun 7, 2023
625de5e
init commit
Maddiaa0 Jun 8, 2023
70a6dde
feat: update noir public context to have access to tree roots
Maddiaa0 Jun 8, 2023
80fbd4d
feat: update public execution tets
Maddiaa0 Jun 8, 2023
50c97bd
Merge branch 'master' into md/create-commitment-in-public
Maddiaa0 Jun 8, 2023
4313112
fix: update all noir contracts
Maddiaa0 Jun 8, 2023
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
3 changes: 3 additions & 0 deletions yarn-project/acir-simulator/src/acvm/acvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export interface ACIRCallback {
storageWrite(params: ACVMField[]): Promise<[ACVMField]>;
viewNotesPage(params: ACVMField[]): Promise<ACVMField[]>;
getL1ToL2Message(params: ACVMField[]): Promise<ACVMField[]>;
// TODO(SEAN): change the transparent note syntax stuff
getTransparentMessage(params: ACVMField[]): Promise<ACVMField[]>;
notifyCreatedTransparentMessage(params: ACVMField[]): Promise<ACVMField[]>;
/**
* Logging utility for logging data.
*/
Expand Down
91 changes: 0 additions & 91 deletions yarn-project/acir-simulator/src/client/client_execution_context.ts

This file was deleted.

25 changes: 23 additions & 2 deletions yarn-project/acir-simulator/src/client/db_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ export interface MessageLoadOracleInputs {
index: bigint;
}

// TODO(Maddiaa): Think about renaming these
/**
* The database oracle interface.
* Client Oracle
*/
export interface DBOracle {
export interface ClientOracle extends KeyOracle, DBOracle, ClientContractOracle{}


/**
* The Key oracle interface
*/
export interface KeyOracle {
getSecretKey(contractAddress: AztecAddress, address: AztecAddress): Promise<Buffer>;
getNotes(
contractAddress: AztecAddress,
Expand All @@ -56,7 +63,21 @@ export interface DBOracle {
/** The notes. */
notes: NoteLoadOracleInputs[];
}>;
}


/**
* Client Contract oracle
*/
export interface ClientContractOracle {
getFunctionABI(contractAddress: AztecAddress, functionSelector: Buffer): Promise<FunctionAbi>;
getPortalContractAddress(contractAddress: AztecAddress): Promise<EthAddress>;
}

/**
* The database oracle interface.
* TODO(Maddiaa): This should be more generalised and not restricted to the local execution
*/
export interface DBOracle {
getL1ToL2Message(msgKey: Fr): Promise<MessageLoadOracleInputs>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ import { default as levelup } from 'levelup';
import { default as memdown, type MemDown } from 'memdown';
import { encodeArguments } from '../abi_coder/index.js';
import { NoirPoint, computeSlotForMapping, toPublicKey } from '../utils.js';
import { DBOracle } from './db_oracle.js';
import { ClientOracle } from './db_oracle.js';
import { AcirSimulator } from './simulator.js';
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';

const createMemDown = () => (memdown as any)() as MemDown<any, any>;

describe('Private Execution test suite', () => {
let bbWasm: BarretenbergWasm;
let oracle: ReturnType<typeof mock<DBOracle>>;
let oracle: ReturnType<typeof mock<ClientOracle>>;
let acirSimulator: AcirSimulator;
let logger: DebugLogger;

Expand All @@ -52,7 +52,7 @@ describe('Private Execution test suite', () => {
});

beforeEach(() => {
oracle = mock<DBOracle>();
oracle = mock<ClientOracle>();
acirSimulator = new AcirSimulator(oracle);
});

Expand Down
18 changes: 11 additions & 7 deletions yarn-project/acir-simulator/src/client/private_execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import {
toAcvmEnqueuePublicFunctionResult,
} from '../acvm/index.js';
import { sizeOfType } from '../index.js';
import { PrivateExecutionContext } from '../execution_context.js';
import { fieldsToFormattedStr } from './debug.js';
import { ClientTxExecutionContext } from './client_execution_context.js';
import { Tuple, assertLength } from '@aztec/foundation/serialize';
import { TxExecutionRequest } from '@aztec/types';

/**
* The contents of a new note.
Expand Down Expand Up @@ -103,7 +104,8 @@ const notAvailable = () => {
*/
export class PrivateFunctionExecution {
constructor(
private context: ClientTxExecutionContext,
private context: PrivateExecutionContext,
private request: TxExecutionRequest,
private abi: FunctionAbi,
private contractAddress: AztecAddress,
private functionData: FunctionData,
Expand Down Expand Up @@ -173,7 +175,7 @@ export class PrivateFunctionExecution {
return toAcvmCallPrivateStackItem(childExecutionResult.callStackItem);
},
getL1ToL2Message: ([msgKey]: ACVMField[]) => this.context.getL1ToL2Message(fromACVMField(msgKey)),

getTransparentMessage: ([msgKey]: ACVMField[]) => this.context.getMessage(fromACVMField(msgKey)),
debugLog: (fields: ACVMField[]) => {
this.log(fieldsToFormattedStr(fields));
return Promise.resolve([ZERO_ACVM_FIELD]);
Expand All @@ -193,6 +195,7 @@ export class PrivateFunctionExecution {
enqueuedPublicFunctionCalls.push(enqueuedRequest);
return toAcvmEnqueuePublicFunctionResult(enqueuedRequest);
},
notifyCreatedTransparentMessage: notAvailable,
viewNotesPage: notAvailable,
storageRead: notAvailable,
storageWrite: notAvailable,
Expand Down Expand Up @@ -249,10 +252,10 @@ export class PrivateFunctionExecution {
this.callContext.portalContractAddress,
this.callContext.storageContractAddress,

this.context.request.txContext.contractDeploymentData.constructorVkHash,
this.context.request.txContext.contractDeploymentData.contractAddressSalt,
this.context.request.txContext.contractDeploymentData.functionTreeRoot,
this.context.request.txContext.contractDeploymentData.portalContractAddress,
this.request.txContext.contractDeploymentData.constructorVkHash,
this.request.txContext.contractDeploymentData.contractAddressSalt,
this.request.txContext.contractDeploymentData.functionTreeRoot,
this.request.txContext.contractDeploymentData.portalContractAddress,

this.context.historicRoots.contractTreeRoot,
this.context.historicRoots.l1ToL2MessagesTreeRoot,
Expand Down Expand Up @@ -285,6 +288,7 @@ export class PrivateFunctionExecution {

const nestedExecution = new PrivateFunctionExecution(
this.context,
this.request,
targetAbi,
targetContractAddress,
targetFunctionData,
Expand Down
12 changes: 7 additions & 5 deletions yarn-project/acir-simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { AztecAddress } from '@aztec/foundation/aztec-address';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { TxExecutionRequest } from '@aztec/types';
import { ClientTxExecutionContext } from './client_execution_context.js';
import { DBOracle } from './db_oracle.js';
import { BaseExecutionContext, PrivateExecutionContext } from '../execution_context.js';
import { ClientOracle, DBOracle } from './db_oracle.js';
import { ExecutionResult, PrivateFunctionExecution } from './private_execution.js';
import { UnconstrainedFunctionExecution } from './unconstrained_execution.js';

Expand All @@ -21,7 +21,7 @@ const OUTER_NULLIFIER_GENERATOR_INDEX = 7;
* The ACIR simulator.
*/
export class AcirSimulator {
constructor(private db: DBOracle) {}
constructor(private db: ClientOracle) {}

/**
* Runs a private function.
Expand Down Expand Up @@ -53,7 +53,8 @@ export class AcirSimulator {
);

const execution = new PrivateFunctionExecution(
new ClientTxExecutionContext(this.db, request, historicRoots),
new PrivateExecutionContext(this.db, historicRoots),
request,
entryPointABI,
contractAddress,
request.functionData,
Expand Down Expand Up @@ -92,8 +93,9 @@ export class AcirSimulator {
request.functionData.isConstructor,
);

// TODO(Maddiaa): double check syntax here, maybe compose with the base context.
const execution = new UnconstrainedFunctionExecution(
new ClientTxExecutionContext(this.db, request, historicRoots),
new PrivateExecutionContext(this.db, historicRoots),
entryPointABI,
contractAddress,
request.functionData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ import { TxExecutionRequest } from '@aztec/types';
import { mock } from 'jest-mock-extended';
import { encodeArguments } from '../abi_coder/index.js';
import { NoirPoint, toPublicKey } from '../utils.js';
import { DBOracle } from './db_oracle.js';
import { ClientOracle } from './db_oracle.js';
import { AcirSimulator } from './simulator.js';

describe('Unconstrained Execution test suite', () => {
let bbWasm: BarretenbergWasm;
let oracle: ReturnType<typeof mock<DBOracle>>;
let oracle: ReturnType<typeof mock<ClientOracle>>;
let acirSimulator: AcirSimulator;

beforeAll(async () => {
bbWasm = await BarretenbergWasm.get();
});

beforeEach(() => {
oracle = mock<DBOracle>();
oracle = mock<ClientOracle>();
acirSimulator = new AcirSimulator(oracle);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { frToAztecAddress, frToNumber } from '../acvm/deserialize.js';
import { FunctionAbi } from '@aztec/foundation/abi';
import { createDebugLogger } from '@aztec/foundation/log';
import { decodeReturnValues } from '../abi_coder/decoder.js';
import { ClientTxExecutionContext } from './client_execution_context.js';
import { PrivateExecutionContext } from '../execution_context.js';
import { select_return_flattened as selectReturnFlattened } from '@noir-lang/noir_util_wasm';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';
Expand All @@ -19,7 +19,7 @@ const notAvailable = () => {
*/
export class UnconstrainedFunctionExecution {
constructor(
private context: ClientTxExecutionContext,
private context: PrivateExecutionContext,
private abi: FunctionAbi,
private contractAddress: AztecAddress,
private functionData: FunctionData,
Expand Down Expand Up @@ -61,6 +61,10 @@ export class UnconstrainedFunctionExecution {
return Promise.resolve([ZERO_ACVM_FIELD]);
},
getL1ToL2Message: ([msgKey]: ACVMField[]) => this.context.getL1ToL2Message(fromACVMField(msgKey)),

getTransparentMessage: notAvailable,
notifyCreatedTransparentMessage: notAvailable,

enqueuePublicFunctionCall: notAvailable,
notifyCreatedNote: notAvailable,
notifyNullifiedNote: notAvailable,
Expand Down
Loading