Skip to content

Commit

Permalink
feat: Optimise sandbox startup time by only initialising the BB solve…
Browse files Browse the repository at this point in the history
…r once. (#2240)

This PR ensures that we only perform BB solver initialisation once
within the acir simulator.

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
PhilWindle authored Sep 12, 2023
1 parent 676a0be commit e9cac9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit e9cac9c

Please sign in to comment.