Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump circuits, USE_TURBO, acirHash, bump circuits.js timeout #263

Merged
merged 14 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
2 changes: 1 addition & 1 deletion circuits
Submodule circuits updated 138 files
5 changes: 3 additions & 2 deletions yarn-project/aztec-rpc/src/account_state/account_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AcirSimulator } from '@aztec/acir-simulator';
import { AztecNode } from '@aztec/aztec-node';
import { Grumpkin } from '@aztec/barretenberg.js/crypto';
import { KERNEL_NEW_COMMITMENTS_LENGTH, OldTreeRoots, TxRequest } from '@aztec/circuits.js';
import { AztecAddress, Fr, Point, createDebugLogger } from '@aztec/foundation';
import { AztecAddress, Fr, Point, keccak, createDebugLogger } from '@aztec/foundation';
import { INITIAL_L2_BLOCK_NUM } from '@aztec/l1-contracts';
import { L2BlockContext } from '@aztec/types';
import { UnverifiedData } from '@aztec/types';
Expand Down Expand Up @@ -63,6 +63,7 @@ export class AccountState {
if (!functionDao) {
throw new Error('Unknown function.');
}
const acirHash = keccak(Buffer.from(functionDao.bytecode, 'hex'));

const oldRoots = new OldTreeRoots(Fr.ZERO, Fr.ZERO, Fr.ZERO, Fr.ZERO); // TODO - get old roots from the database/node

Expand All @@ -76,7 +77,7 @@ export class AccountState {
oldRoots,
);

return { contract, oldRoots, executionResult };
return { contract, oldRoots, executionResult, acirHash };
}

public createUnverifiedData(contract: AztecAddress, newNotes: { preimage: Fr[]; storageSlot: Fr }[]): UnverifiedData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class AztecRPCServer implements AztecRPCClient {
public async createTx(txRequest: TxRequest, signature: EcdsaSignature) {
const accountState = this.ensureAccount(txRequest.from);

const { executionResult, oldRoots, contract } = await accountState.simulate(txRequest);
const { executionResult, oldRoots, contract, acirHash } = await accountState.simulate(txRequest);

this.log(`Executing Prover...`);
const { publicInputs } = await this.kernelProver.prove(
Expand All @@ -215,6 +215,7 @@ export class AztecRPCServer implements AztecRPCClient {
(committment: Buffer) => {
return this.getContractSiblingPath(committment);
},
acirHash,
);

this.log(`Proof completed!`);
Expand Down
5 changes: 1 addition & 4 deletions yarn-project/circuits.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests --testTimeout=15000"
},
"inherits": [
"../package.common.json"
],
dbanks12 marked this conversation as resolved.
Show resolved Hide resolved
"jest": {
"preset": "ts-jest/presets/default-esm",
"globals": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ leaf_index: 8225
sibling_path: [ 0x2021 0x2022 0x2023 0x2024 ]

portal_contract_address: 0x4141414141414141414141414141414141414141
acir_hash: 0x2061

"
`;
Expand Down
4 changes: 1 addition & 3 deletions yarn-project/circuits.js/src/structs/kernel.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expectSerializeToMatchSnapshot } from '../tests/expectSerialize.js';
import { makePreviousKernelData, makePrivateKernelInputs, makePrivateKernelPublicInputs } from '../tests/factories.js';
import { CircuitsWasm } from '../wasm/circuits_wasm.js';

describe('structs/kernel', () => {
it(`serializes and prints previous_kernel_data`, async () => {
Expand All @@ -19,8 +18,7 @@ describe('structs/kernel', () => {
);
});

// TODO: Reenable once we can move back to circuits master and have this c_bind available
it.skip(`serializes and prints private_kernel_public_inputs`, async () => {
it(`serializes and prints private_kernel_public_inputs`, async () => {
const kernelInputs = makePrivateKernelPublicInputs();
await expectSerializeToMatchSnapshot(
kernelInputs.toBuffer(),
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/circuits.js/src/structs/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export class PrivateCallData {
public functionLeafMembershipWitness: MembershipWitness<typeof FUNCTION_TREE_HEIGHT>,
public contractLeafMembershipWitness: MembershipWitness<typeof CONTRACT_TREE_HEIGHT>,
public portalContractAddress: EthAddress,
public acirHash: Fr,
) {
assertLength(this, 'privateCallStackPreimages', PRIVATE_CALL_STACK_LENGTH);
}
Expand All @@ -318,6 +319,7 @@ export class PrivateCallData {
fields.functionLeafMembershipWitness,
fields.contractLeafMembershipWitness,
fields.portalContractAddress,
fields.acirHash,
] as const;
}

Expand Down
7 changes: 4 additions & 3 deletions yarn-project/circuits.js/src/tests/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ export function makePrivateCallData(seed = 1): PrivateCallData {
return PrivateCallData.from({
callStackItem: makeCallStackItem(seed),
privateCallStackPreimages: range(PRIVATE_CALL_STACK_LENGTH, seed + 0x10).map(makeCallStackItem),
contractLeafMembershipWitness: makeMembershipWitness(CONTRACT_TREE_HEIGHT, seed + 0x20),
functionLeafMembershipWitness: makeMembershipWitness(FUNCTION_TREE_HEIGHT, seed + 0x30),
portalContractAddress: makeEthAddress(seed + 0x40),
proof: makeDynamicSizeBuffer(16, seed + 0x50),
vk: makeVerificationKey(),
functionLeafMembershipWitness: makeMembershipWitness(FUNCTION_TREE_HEIGHT, seed + 0x30),
contractLeafMembershipWitness: makeMembershipWitness(CONTRACT_TREE_HEIGHT, seed + 0x20),
portalContractAddress: makeEthAddress(seed + 0x40),
acirHash: fr(seed + 0x60),
});
}

Expand Down
7 changes: 6 additions & 1 deletion yarn-project/foundation/src/wasm/wasm/async_call_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export class AsyncCallState {
private ASYNCIFY_DATA_SIZE = 16 * 1024;
private asyncifyDataAddr!: number;
private asyncPromise?: Promise<any>;
// For debug purposes, the last running function
private debugLastFuncName?: string;
private wasm!: WasmModule;
private state?: AsyncFnState;
private callExport!: (...args: any[]) => number;
Expand Down Expand Up @@ -84,9 +86,12 @@ export class AsyncCallState {
*/
public async call(name: string, ...args: any) {
if (this.state) {
throw new Error(`Can only handle one async call at a time: ${name}(${args})`);
throw new Error(
`Can only handle one async call at a time: Can't run ${name}(${args}) because we are still running ${this.debugLastFuncName}`,
);
}
this.state = { continuation: false };
this.debugLastFuncName = name;
let result = this.callExport(name, ...args);

while (this.asyncPromise) {
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/kernel-prover/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class KernelProver {
oldRoots: OldTreeRoots,
getFunctionTreeInfo: (callStackItem: PrivateCallStackItem) => Promise<FunctionTreeInfo>,
getContractSiblingPath: (committment: Buffer) => Promise<MembershipWitness<typeof CONTRACT_TREE_HEIGHT>>,
acirHash: Buffer,
): Promise<{ publicInputs: PrivateKernelPublicInputs; proof: Buffer }> {
const wasm = await CircuitsWasm.get();
// TODO: implement this
Expand All @@ -63,6 +64,7 @@ export class KernelProver {
functionTreeInfo.membershipWitness,
contractLeafMembershipWitness,
txRequest.txContext.contractDeploymentData.portalContractAddress,
Fr.fromBuffer(Buffer.alloc(32, 0)),//acirHash, // FIXME: https://github.com/AztecProtocol/aztec3-packages/issues/262
);

const previousKernelData: PreviousKernelData = await DummyPreviousKernelData.getDummyPreviousKernelData(wasm);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"docs": "typedoc --out docs/dist && cd docs && yarn serve",
"formatting": "yarn workspaces foreach -v run formatting",
"formatting:fix": "yarn workspaces foreach -v run formatting:fix",
"test": "yarn workspaces foreach -v run test",
"test": "yarn build && yarn workspaces foreach -v run test",
dbanks12 marked this conversation as resolved.
Show resolved Hide resolved
"build": "tsc -b tsconfig.json",
"build:dev": "tsc -b tsconfig.json --watch",
"clean": "yarn workspaces foreach -v run clean"
Expand Down