Skip to content

Commit

Permalink
2117 - activate msgpack cbind method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Sep 11, 2023
1 parent 1cd0805 commit 2d017ab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
18 changes: 14 additions & 4 deletions yarn-project/circuits.js/src/rollup/rollup_wasm_wrapper.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { AggregationObject, CircuitError, MergeRollupInputs, RootRollupInputs, VerificationKey } from '../index.js';
import {
AggregationObject,
CircuitError,
MergeRollupInputs,
RootRollupInputs,
RootRollupPublicInputs,
VerificationKey,
} from '../index.js';
import { makeBaseRollupInputs, makeMergeRollupInputs, makeRootRollupInputs } from '../tests/factories.js';
import { CircuitsWasm } from '../wasm/circuits_wasm.js';
import { RollupWasmWrapper, mergeRollupSim } from './rollup_wasm_wrapper.js';
import { RollupWasmWrapper, mergeRollupSim, rootRollupSim } from './rollup_wasm_wrapper.js';

describe('rollup/rollup_wasm_wrapper', () => {
let wasm: CircuitsWasm;
Expand Down Expand Up @@ -101,8 +108,11 @@ describe('rollup/rollup_wasm_wrapper', () => {
}
fixPreviousRollupInputs(input);

const output = rollupWasm.simulateRootRollup(input);
expect(output.startNullifierTreeSnapshot).toEqual(
const output = rootRollupSim(wasm, input);
expect(output instanceof RootRollupPublicInputs).toBeTruthy();

const publicInputs = output as RootRollupPublicInputs;
expect(publicInputs.startNullifierTreeSnapshot).toEqual(
input.previousRollupData[0].baseOrMergeRollupPublicInputs.startNullifierTreeSnapshot,
);
}, 15_000);
Expand Down
11 changes: 1 addition & 10 deletions yarn-project/circuits.js/src/rollup/rollup_wasm_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BaseOrMergeRollupPublicInputs, BaseRollupInputs, RootRollupInputs, Root
import { callWasm } from '../utils/call_wasm.js';
import { CircuitsWasm } from '../wasm/circuits_wasm.js';

export { mergeRollupSim } from '../cbind/circuits.gen.js';
export { mergeRollupSim, rootRollupSim } from '../cbind/circuits.gen.js';

/**
* A wrapper around `CircuitsWasm` used to expose only the functions relevant for rollup circuits.
Expand All @@ -19,13 +19,4 @@ export class RollupWasmWrapper {
public simulateBaseRollup(baseRollupInputs: BaseRollupInputs): BaseOrMergeRollupPublicInputs {
return callWasm(this.wasm, 'base_rollup__sim', baseRollupInputs, BaseOrMergeRollupPublicInputs);
}

/**
* Simulates the root rollup circuit from its inputs.
* @param rootRollupInputs - Inputs to the circuit.
* @returns Public inputs of the root rollup circuit.
*/
public simulateRootRollup(rootRollupInputs: RootRollupInputs): RootRollupPublicInputs {
return callWasm(this.wasm, 'root_rollup__sim', rootRollupInputs, RootRollupPublicInputs);
}
}
8 changes: 7 additions & 1 deletion yarn-project/sequencer-client/src/simulator/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
RootRollupInputs,
RootRollupPublicInputs,
mergeRollupSim,
rootRollupSim,
} from '@aztec/circuits.js';

import { RollupSimulator } from './index.js';
Expand Down Expand Up @@ -60,6 +61,11 @@ export class WasmRollupCircuitSimulator implements RollupSimulator {
* @returns The public inputs as outputs of the simulation.
*/
rootRollupCircuit(input: RootRollupInputs): Promise<RootRollupPublicInputs> {
return Promise.resolve(this.rollupWasmWrapper.simulateRootRollup(input));
const result = rootRollupSim(this.wasm, input);
if (result instanceof CircuitError) {
throw new CircuitError(result.code, result.message);
}

return Promise.resolve(result);
}
}

0 comments on commit 2d017ab

Please sign in to comment.