@aztec/sequencer-client 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dest/block_builder/solo_block_builder.d.ts.map +1 -1
  2. package/dest/block_builder/solo_block_builder.js +5 -3
  3. package/dest/client/sequencer-client.js +2 -2
  4. package/dest/index.d.ts +1 -1
  5. package/dest/index.js +1 -1
  6. package/dest/publisher/l1-publisher.d.ts.map +1 -1
  7. package/dest/publisher/l1-publisher.js +11 -6
  8. package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
  9. package/dest/publisher/viem-tx-sender.js +6 -5
  10. package/dest/sequencer/config.d.ts +1 -17
  11. package/dest/sequencer/config.d.ts.map +1 -1
  12. package/dest/sequencer/public_processor.d.ts +6 -6
  13. package/dest/sequencer/public_processor.d.ts.map +1 -1
  14. package/dest/sequencer/public_processor.js +32 -24
  15. package/dest/sequencer/sequencer.d.ts.map +1 -1
  16. package/dest/sequencer/sequencer.js +19 -10
  17. package/dest/simulator/public_executor.d.ts +35 -9
  18. package/dest/simulator/public_executor.d.ts.map +1 -1
  19. package/dest/simulator/public_executor.js +31 -17
  20. package/dest/simulator/public_kernel.d.ts +2 -2
  21. package/dest/simulator/public_kernel.d.ts.map +1 -1
  22. package/dest/simulator/public_kernel.js +7 -5
  23. package/dest/simulator/rollup.d.ts +2 -2
  24. package/dest/simulator/rollup.d.ts.map +1 -1
  25. package/dest/simulator/rollup.js +5 -10
  26. package/package.json +12 -13
  27. package/src/block_builder/solo_block_builder.ts +6 -2
  28. package/src/client/sequencer-client.ts +2 -2
  29. package/src/index.ts +1 -1
  30. package/src/publisher/l1-publisher.ts +15 -5
  31. package/src/publisher/viem-tx-sender.ts +6 -4
  32. package/src/sequencer/config.ts +1 -17
  33. package/src/sequencer/public_processor.ts +38 -29
  34. package/src/sequencer/sequencer.ts +27 -9
  35. package/src/simulator/public_executor.ts +34 -33
  36. package/src/simulator/public_kernel.ts +8 -4
  37. package/src/simulator/rollup.ts +4 -11
@@ -1,35 +1,9 @@
1
- import {
2
- CommitmentsDB,
3
- MessageLoadOracleInputs,
4
- PublicContractsDB,
5
- PublicExecutor,
6
- PublicStateDB,
7
- } from '@aztec/acir-simulator';
8
- import { AztecAddress, EthAddress, Fr, FunctionSelector, HistoricBlockData } from '@aztec/circuits.js';
1
+ import { CommitmentsDB, MessageLoadOracleInputs, PublicContractsDB, PublicStateDB } from '@aztec/acir-simulator';
2
+ import { AztecAddress, EthAddress, Fr, FunctionSelector } from '@aztec/circuits.js';
9
3
  import { computePublicDataTreeIndex } from '@aztec/circuits.js/abis';
10
4
  import { ContractDataSource, ExtendedContractData, L1ToL2MessageSource, MerkleTreeId, Tx } from '@aztec/types';
11
5
  import { MerkleTreeOperations } from '@aztec/world-state';
12
6
 
13
- /**
14
- * Returns a new PublicExecutor simulator backed by the supplied merkle tree db and contract data source.
15
- * @param merkleTree - A merkle tree database.
16
- * @param contractDataSource - A contract data source.
17
- * @returns A new instance of a PublicExecutor.
18
- */
19
- export function getPublicExecutor(
20
- merkleTree: MerkleTreeOperations,
21
- publicContractsDB: PublicContractsDB,
22
- l1toL2MessageSource: L1ToL2MessageSource,
23
- blockData: HistoricBlockData,
24
- ) {
25
- return new PublicExecutor(
26
- new WorldStatePublicDB(merkleTree),
27
- publicContractsDB,
28
- new WorldStateDB(merkleTree, l1toL2MessageSource),
29
- blockData,
30
- );
31
- }
32
-
33
7
  /**
34
8
  * Implements the PublicContractsDB using a ContractDataSource.
35
9
  * Progressively records contracts in transaction as they are processed in a block.
@@ -95,8 +69,9 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB {
95
69
  /**
96
70
  * Implements the PublicStateDB using a world-state database.
97
71
  */
98
- class WorldStatePublicDB implements PublicStateDB {
99
- private writeCache: Map<bigint, Fr> = new Map();
72
+ export class WorldStatePublicDB implements PublicStateDB {
73
+ private commitedWriteCache: Map<bigint, Fr> = new Map();
74
+ private uncommitedWriteCache: Map<bigint, Fr> = new Map();
100
75
 
101
76
  constructor(private db: MerkleTreeOperations) {}
102
77
 
@@ -108,8 +83,14 @@ class WorldStatePublicDB implements PublicStateDB {
108
83
  */
109
84
  public async storageRead(contract: AztecAddress, slot: Fr): Promise<Fr> {
110
85
  const index = computePublicDataTreeIndex(contract, slot).value;
111
- const cached = this.writeCache.get(index);
112
- if (cached !== undefined) return cached;
86
+ const uncommited = this.uncommitedWriteCache.get(index);
87
+ if (uncommited !== undefined) {
88
+ return uncommited;
89
+ }
90
+ const commited = this.commitedWriteCache.get(index);
91
+ if (commited !== undefined) {
92
+ return commited;
93
+ }
113
94
  const value = await this.db.getLeafValue(MerkleTreeId.PUBLIC_DATA_TREE, index);
114
95
  return value ? Fr.fromBuffer(value) : Fr.ZERO;
115
96
  }
@@ -122,7 +103,27 @@ class WorldStatePublicDB implements PublicStateDB {
122
103
  */
123
104
  public storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<void> {
124
105
  const index = computePublicDataTreeIndex(contract, slot).value;
125
- this.writeCache.set(index, newValue);
106
+ this.uncommitedWriteCache.set(index, newValue);
107
+ return Promise.resolve();
108
+ }
109
+
110
+ /**
111
+ * Commit the pending changes to the DB.
112
+ * @returns Nothing.
113
+ */
114
+ commit(): Promise<void> {
115
+ for (const [k, v] of this.uncommitedWriteCache) {
116
+ this.commitedWriteCache.set(k, v);
117
+ }
118
+ return this.rollback();
119
+ }
120
+
121
+ /**
122
+ * Rollback the pending changes.
123
+ * @returns Nothing.
124
+ */
125
+ rollback(): Promise<void> {
126
+ this.uncommitedWriteCache = new Map<bigint, Fr>();
126
127
  return Promise.resolve();
127
128
  }
128
129
  }
@@ -7,9 +7,9 @@ import { CircuitSimulationStats } from '@aztec/types/stats';
7
7
  import { PublicKernelCircuitSimulator } from './index.js';
8
8
 
9
9
  /**
10
- * Implements the PublicKernelCircuitSimulator by calling the wasm implementations of the circuits.
10
+ * Implements the PublicKernelCircuitSimulator.
11
11
  */
12
- export class WasmPublicKernelCircuitSimulator implements PublicKernelCircuitSimulator {
12
+ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimulator {
13
13
  private log = createDebugLogger('aztec:public-kernel-simulator');
14
14
 
15
15
  /**
@@ -18,7 +18,9 @@ export class WasmPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
18
18
  * @returns The public inputs as outputs of the simulation.
19
19
  */
20
20
  public async publicKernelCircuitPrivateInput(input: PublicKernelInputs): Promise<PublicKernelPublicInputs> {
21
- if (!input.previousKernel.publicInputs.isPrivate) throw new Error(`Expected private kernel previous inputs`);
21
+ if (!input.previousKernel.publicInputs.isPrivate) {
22
+ throw new Error(`Expected private kernel previous inputs`);
23
+ }
22
24
  const [duration, result] = await elapsed(() => executePublicKernelPrivatePrevious(input));
23
25
  this.log(`Simulated public kernel circuit with private input`, {
24
26
  eventName: 'circuit-simulation',
@@ -36,7 +38,9 @@ export class WasmPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
36
38
  * @returns The public inputs as outputs of the simulation.
37
39
  */
38
40
  public async publicKernelCircuitNonFirstIteration(input: PublicKernelInputs): Promise<PublicKernelPublicInputs> {
39
- if (input.previousKernel.publicInputs.isPrivate) throw new Error(`Expected public kernel previous inputs`);
41
+ if (input.previousKernel.publicInputs.isPrivate) {
42
+ throw new Error(`Expected public kernel previous inputs`);
43
+ }
40
44
  const [duration, result] = await elapsed(() => executePublicKernelPublicPrevious(input));
41
45
  this.log(`Simulated public kernel circuit non-first iteration`, {
42
46
  eventName: 'circuit-simulation',
@@ -1,24 +1,21 @@
1
1
  import {
2
2
  BaseOrMergeRollupPublicInputs,
3
3
  BaseRollupInputs,
4
- CircuitError,
5
- CircuitsWasm,
6
4
  MergeRollupInputs,
7
5
  RootRollupInputs,
8
6
  RootRollupPublicInputs,
9
- baseRollupSim,
10
7
  } from '@aztec/circuits.js';
11
8
  import { createDebugLogger } from '@aztec/foundation/log';
12
9
  import { elapsed } from '@aztec/foundation/timer';
13
- import { executeMergeRollup, executeRootRollup } from '@aztec/noir-protocol-circuits';
10
+ import { executeBaseRollup, executeMergeRollup, executeRootRollup } from '@aztec/noir-protocol-circuits';
14
11
  import { CircuitSimulationStats } from '@aztec/types/stats';
15
12
 
16
13
  import { RollupSimulator } from './index.js';
17
14
 
18
15
  /**
19
- * Implements the rollup circuit simulator using the wasm circuits implementation.
16
+ * Implements the rollup circuit simulator.
20
17
  */
21
- export class WasmRollupCircuitSimulator implements RollupSimulator {
18
+ export class RealRollupCircuitSimulator implements RollupSimulator {
22
19
  private log = createDebugLogger('aztec:rollup-simulator');
23
20
 
24
21
  /**
@@ -27,11 +24,7 @@ export class WasmRollupCircuitSimulator implements RollupSimulator {
27
24
  * @returns The public inputs as outputs of the simulation.
28
25
  */
29
26
  public async baseRollupCircuit(input: BaseRollupInputs): Promise<BaseOrMergeRollupPublicInputs> {
30
- const wasm = await CircuitsWasm.get();
31
- const [duration, result] = await elapsed(() => baseRollupSim(wasm, input));
32
- if (result instanceof CircuitError) {
33
- throw new CircuitError(result.code, result.message);
34
- }
27
+ const [duration, result] = await elapsed(() => executeBaseRollup(input));
35
28
 
36
29
  this.log(`Simulated base rollup circuit`, {
37
30
  eventName: 'circuit-simulation',