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

feat: Optimise sandbox startup time by only initialising the BB solver once. #2240

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions yarn-project/acir-simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { UnconstrainedFunctionExecution } from './unconstrained_execution.js';
* The ACIR simulator.
*/
export class AcirSimulator {
private static solver: WasmBlackBoxFunctionSolver; // ACVM's backend
private static solver: Promise<WasmBlackBoxFunctionSolver>; // ACVM's backend
private log: DebugLogger;

constructor(private db: DBOracle) {
Expand All @@ -42,8 +42,8 @@ export class AcirSimulator {
*
* @returns ACVM WasmBlackBoxFunctionSolver
*/
public static async getSolver(): Promise<WasmBlackBoxFunctionSolver> {
if (!this.solver) this.solver = await createBlackBoxSolver();
public static getSolver(): Promise<WasmBlackBoxFunctionSolver> {
if (!this.solver) this.solver = createBlackBoxSolver();
return this.solver;
}

Expand Down
5 changes: 3 additions & 2 deletions yarn-project/sequencer-client/src/sequencer/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ export class Sequencer {
return;
}

this.log(`Processing ${validTxs.length} txs...`);
const blockNumber = (await this.l2BlockSource.getBlockNumber()) + 1;

this.log.info(`Building block ${blockNumber} with ${validTxs.length} transactions...`);
this.state = SequencerState.CREATING_BLOCK;

const blockNumber = (await this.l2BlockSource.getBlockNumber()) + 1;
const newGlobalVariables = await this.globalsBuilder.buildGlobalVariables(new Fr(blockNumber));
const prevGlobalVariables = (await this.l2BlockSource.getL2Block(-1))?.globalVariables ?? GlobalVariables.empty();

Expand Down