@aztec/prover-client 0.76.4 → 0.77.0-testnet-ignition.21

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 (136) hide show
  1. package/dest/bin/get-proof-inputs.js +18 -17
  2. package/dest/block_builder/index.d.ts +1 -1
  3. package/dest/block_builder/index.d.ts.map +1 -1
  4. package/dest/block_builder/index.js +0 -1
  5. package/dest/block_builder/light.d.ts +4 -2
  6. package/dest/block_builder/light.d.ts.map +1 -1
  7. package/dest/block_builder/light.js +28 -15
  8. package/dest/config.d.ts +2 -2
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +10 -12
  11. package/dest/index.d.ts +1 -1
  12. package/dest/index.d.ts.map +1 -1
  13. package/dest/index.js +0 -1
  14. package/dest/mocks/fixtures.d.ts +4 -3
  15. package/dest/mocks/fixtures.d.ts.map +1 -1
  16. package/dest/mocks/fixtures.js +37 -30
  17. package/dest/mocks/test_context.d.ts +16 -12
  18. package/dest/mocks/test_context.d.ts.map +1 -1
  19. package/dest/mocks/test_context.js +85 -62
  20. package/dest/orchestrator/block-building-helpers.d.ts +12 -7
  21. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  22. package/dest/orchestrator/block-building-helpers.js +98 -87
  23. package/dest/orchestrator/block-proving-state.d.ts +13 -8
  24. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  25. package/dest/orchestrator/block-proving-state.js +101 -73
  26. package/dest/orchestrator/epoch-proving-state.d.ts +10 -6
  27. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  28. package/dest/orchestrator/epoch-proving-state.js +57 -41
  29. package/dest/orchestrator/index.js +0 -1
  30. package/dest/orchestrator/orchestrator.d.ts +7 -5
  31. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  32. package/dest/orchestrator/orchestrator.js +656 -654
  33. package/dest/orchestrator/orchestrator_metrics.js +4 -3
  34. package/dest/orchestrator/tx-proving-state.d.ts +7 -4
  35. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  36. package/dest/orchestrator/tx-proving-state.js +54 -52
  37. package/dest/prover-client/factory.d.ts +2 -2
  38. package/dest/prover-client/factory.d.ts.map +1 -1
  39. package/dest/prover-client/factory.js +0 -1
  40. package/dest/prover-client/index.js +0 -1
  41. package/dest/prover-client/prover-client.d.ts +3 -3
  42. package/dest/prover-client/prover-client.d.ts.map +1 -1
  43. package/dest/prover-client/prover-client.js +31 -26
  44. package/dest/prover-client/server-epoch-prover.d.ts +8 -5
  45. package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
  46. package/dest/prover-client/server-epoch-prover.js +4 -4
  47. package/dest/proving_broker/broker_prover_facade.d.ts +5 -3
  48. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  49. package/dest/proving_broker/broker_prover_facade.js +80 -67
  50. package/dest/proving_broker/config.d.ts +15 -2
  51. package/dest/proving_broker/config.d.ts.map +1 -1
  52. package/dest/proving_broker/config.js +49 -44
  53. package/dest/proving_broker/factory.d.ts +2 -2
  54. package/dest/proving_broker/factory.d.ts.map +1 -1
  55. package/dest/proving_broker/factory.js +1 -6
  56. package/dest/proving_broker/fixtures.d.ts +1 -1
  57. package/dest/proving_broker/fixtures.d.ts.map +1 -1
  58. package/dest/proving_broker/fixtures.js +2 -2
  59. package/dest/proving_broker/index.js +0 -1
  60. package/dest/proving_broker/proof_store/factory.d.ts +1 -1
  61. package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
  62. package/dest/proving_broker/proof_store/factory.js +9 -12
  63. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +3 -2
  64. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
  65. package/dest/proving_broker/proof_store/gcs_proof_store.js +12 -7
  66. package/dest/proving_broker/proof_store/index.js +0 -1
  67. package/dest/proving_broker/proof_store/inline_proof_store.d.ts +3 -2
  68. package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
  69. package/dest/proving_broker/proof_store/inline_proof_store.js +11 -7
  70. package/dest/proving_broker/proof_store/proof_store.d.ts +2 -1
  71. package/dest/proving_broker/proof_store/proof_store.d.ts.map +1 -1
  72. package/dest/proving_broker/proof_store/proof_store.js +3 -2
  73. package/dest/proving_broker/proving_agent.d.ts +3 -2
  74. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  75. package/dest/proving_broker/proving_agent.js +121 -124
  76. package/dest/proving_broker/proving_agent_instrumentation.d.ts +1 -1
  77. package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +1 -1
  78. package/dest/proving_broker/proving_agent_instrumentation.js +6 -6
  79. package/dest/proving_broker/proving_broker.d.ts +4 -11
  80. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  81. package/dest/proving_broker/proving_broker.js +490 -446
  82. package/dest/proving_broker/proving_broker_database/memory.d.ts +2 -2
  83. package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
  84. package/dest/proving_broker/proving_broker_database/memory.js +19 -13
  85. package/dest/proving_broker/proving_broker_database/persisted.d.ts +3 -3
  86. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  87. package/dest/proving_broker/proving_broker_database/persisted.js +62 -29
  88. package/dest/proving_broker/proving_broker_database.d.ts +1 -1
  89. package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
  90. package/dest/proving_broker/proving_broker_database.js +3 -2
  91. package/dest/proving_broker/proving_broker_instrumentation.d.ts +6 -2
  92. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  93. package/dest/proving_broker/proving_broker_instrumentation.js +47 -22
  94. package/dest/proving_broker/proving_job_controller.d.ts +2 -1
  95. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  96. package/dest/proving_broker/proving_job_controller.js +81 -62
  97. package/dest/proving_broker/rpc.d.ts +4 -3
  98. package/dest/proving_broker/rpc.d.ts.map +1 -1
  99. package/dest/proving_broker/rpc.js +29 -25
  100. package/dest/test/mock_prover.d.ts +7 -5
  101. package/dest/test/mock_prover.d.ts.map +1 -1
  102. package/dest/test/mock_prover.js +13 -9
  103. package/package.json +16 -15
  104. package/src/bin/get-proof-inputs.ts +5 -6
  105. package/src/block_builder/index.ts +1 -1
  106. package/src/block_builder/light.ts +7 -10
  107. package/src/config.ts +2 -2
  108. package/src/index.ts +1 -1
  109. package/src/mocks/fixtures.ts +13 -15
  110. package/src/mocks/test_context.ts +60 -102
  111. package/src/orchestrator/block-building-helpers.ts +50 -45
  112. package/src/orchestrator/block-proving-state.ts +18 -22
  113. package/src/orchestrator/epoch-proving-state.ts +11 -16
  114. package/src/orchestrator/orchestrator.ts +26 -33
  115. package/src/orchestrator/tx-proving-state.ts +10 -13
  116. package/src/prover-client/factory.ts +2 -2
  117. package/src/prover-client/prover-client.ts +12 -12
  118. package/src/prover-client/server-epoch-prover.ts +8 -5
  119. package/src/proving_broker/broker_prover_facade.ts +29 -31
  120. package/src/proving_broker/config.ts +31 -3
  121. package/src/proving_broker/factory.ts +3 -11
  122. package/src/proving_broker/fixtures.ts +2 -1
  123. package/src/proving_broker/proof_store/factory.ts +1 -1
  124. package/src/proving_broker/proof_store/gcs_proof_store.ts +3 -3
  125. package/src/proving_broker/proof_store/inline_proof_store.ts +5 -5
  126. package/src/proving_broker/proof_store/proof_store.ts +9 -9
  127. package/src/proving_broker/proving_agent.ts +11 -11
  128. package/src/proving_broker/proving_agent_instrumentation.ts +5 -5
  129. package/src/proving_broker/proving_broker.ts +35 -32
  130. package/src/proving_broker/proving_broker_database/memory.ts +2 -2
  131. package/src/proving_broker/proving_broker_database/persisted.ts +8 -8
  132. package/src/proving_broker/proving_broker_database.ts +1 -1
  133. package/src/proving_broker/proving_broker_instrumentation.ts +24 -2
  134. package/src/proving_broker/proving_job_controller.ts +7 -7
  135. package/src/proving_broker/rpc.ts +6 -7
  136. package/src/test/mock_prover.ts +28 -30
@@ -1,42 +1,31 @@
1
- import { type BBProverConfig } from '@aztec/bb-prover';
2
- import {
3
- type L2Block,
4
- type ProcessedTx,
5
- type PublicExecutionRequest,
6
- type ServerCircuitProver,
7
- type Tx,
8
- } from '@aztec/circuit-types';
9
- import { makeBloatedProcessedTx } from '@aztec/circuit-types/test';
10
- import {
11
- type AppendOnlyTreeSnapshot,
12
- type BlockHeader,
13
- type Gas,
14
- type GlobalVariables,
15
- TreeSnapshots,
16
- } from '@aztec/circuits.js';
1
+ import type { BBProverConfig } from '@aztec/bb-prover';
17
2
  import { times, timesParallel } from '@aztec/foundation/collection';
18
3
  import { Fr } from '@aztec/foundation/fields';
19
- import { type Logger } from '@aztec/foundation/log';
4
+ import type { Logger } from '@aztec/foundation/log';
20
5
  import { TestDateProvider } from '@aztec/foundation/timer';
21
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
6
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
22
7
  import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
8
+ import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
23
9
  import {
24
10
  PublicProcessor,
11
+ PublicTxSimulationTester,
25
12
  PublicTxSimulator,
26
- type SimulationProvider,
27
- WASMSimulatorWithBlobs,
28
- type WorldStateDB,
13
+ SimpleContractDataSource,
14
+ WorldStateDB,
29
15
  } from '@aztec/simulator/server';
30
- import { type MerkleTreeAdminDatabase } from '@aztec/world-state';
16
+ import { PublicDataWrite } from '@aztec/stdlib/avm';
17
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
18
+ import type { L2Block } from '@aztec/stdlib/block';
19
+ import type { ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
20
+ import { makeBloatedProcessedTx } from '@aztec/stdlib/testing';
21
+ import { type AppendOnlyTreeSnapshot, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
22
+ import { type BlockHeader, type GlobalVariables, type ProcessedTx, TreeSnapshots, type Tx } from '@aztec/stdlib/tx';
23
+ import type { MerkleTreeAdminDatabase } from '@aztec/world-state';
31
24
  import { NativeWorldStateService } from '@aztec/world-state/native';
32
25
 
33
- import { jest } from '@jest/globals';
34
26
  import { promises as fs } from 'fs';
35
- import { mock } from 'jest-mock-extended';
36
27
 
37
28
  import { TestCircuitProver } from '../../../bb-prover/src/test/test_circuit_prover.js';
38
- import { AvmFinalizedCallResult } from '../../../simulator/src/avm/avm_contract_call_result.js';
39
- import { type AvmPersistableStateManager } from '../../../simulator/src/avm/journal/journal.js';
40
29
  import { buildBlock } from '../block_builder/light.js';
41
30
  import { ProvingOrchestrator } from '../orchestrator/index.js';
42
31
  import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
@@ -45,21 +34,26 @@ import { getEnvironmentConfig, getSimulationProvider, makeGlobals, updateExpecte
45
34
 
46
35
  export class TestContext {
47
36
  private headers: Map<number, BlockHeader> = new Map();
37
+ private feePayerBalance: Fr;
48
38
 
49
39
  constructor(
50
40
  public publicTxSimulator: PublicTxSimulator,
51
41
  public worldState: MerkleTreeAdminDatabase,
52
42
  public publicProcessor: PublicProcessor,
53
- public simulationProvider: SimulationProvider,
54
43
  public globalVariables: GlobalVariables,
55
44
  public prover: ServerCircuitProver,
56
45
  public broker: TestBroker,
57
46
  public brokerProverFacade: BrokerCircuitProverFacade,
58
47
  public orchestrator: TestProvingOrchestrator,
59
48
  public blockNumber: number,
49
+ public feePayer: AztecAddress,
50
+ initialFeePayerBalance: Fr,
60
51
  public directoriesToCleanup: string[],
52
+ public tester: PublicTxSimulationTester,
61
53
  public logger: Logger,
62
- ) {}
54
+ ) {
55
+ this.feePayerBalance = initialFeePayerBalance;
56
+ }
63
57
 
64
58
  public get epochProver() {
65
59
  return this.orchestrator;
@@ -68,20 +62,30 @@ export class TestContext {
68
62
  static async new(
69
63
  logger: Logger,
70
64
  proverCount = 4,
71
- createProver: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver> = _ =>
72
- Promise.resolve(new TestCircuitProver(new WASMSimulatorWithBlobs())),
65
+ createProver: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver> = async (bbConfig: BBProverConfig) =>
66
+ new TestCircuitProver(await getSimulationProvider(bbConfig, logger)),
73
67
  blockNumber = 1,
74
68
  ) {
75
69
  const directoriesToCleanup: string[] = [];
76
70
  const globalVariables = makeGlobals(blockNumber);
77
71
 
78
- const worldStateDB = mock<WorldStateDB>();
72
+ const feePayer = AztecAddress.fromNumber(42222);
73
+ const initialFeePayerBalance = new Fr(10n ** 20n);
74
+ const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer);
75
+ const prefilledPublicData = [new PublicDataTreeLeaf(feePayerSlot, initialFeePayerBalance)];
79
76
 
80
77
  // Separated dbs for public processor and prover - see public_processor for context
81
- const ws = await NativeWorldStateService.tmp();
78
+ const ws = await NativeWorldStateService.tmp(
79
+ undefined /* rollupAddress */,
80
+ true /* cleanupTmpDir */,
81
+ prefilledPublicData,
82
+ );
82
83
  const publicDb = await ws.fork();
83
84
 
84
- worldStateDB.getMerkleInterface.mockReturnValue(publicDb);
85
+ const contractDataSource = new SimpleContractDataSource();
86
+ const worldStateDB = new WorldStateDB(publicDb, contractDataSource);
87
+
88
+ const tester = new PublicTxSimulationTester(worldStateDB, contractDataSource, publicDb);
85
89
 
86
90
  const publicTxSimulator = new PublicTxSimulator(publicDb, worldStateDB, globalVariables, true);
87
91
  const processor = new PublicProcessor(
@@ -94,12 +98,8 @@ export class TestContext {
94
98
 
95
99
  let localProver: ServerCircuitProver;
96
100
  const config = await getEnvironmentConfig(logger);
97
- const simulationProvider = await getSimulationProvider({
98
- acvmWorkingDirectory: config?.acvmWorkingDirectory,
99
- acvmBinaryPath: config?.expectedAcvmPath,
100
- });
101
101
  if (!config) {
102
- localProver = new TestCircuitProver(simulationProvider);
102
+ localProver = new TestCircuitProver();
103
103
  } else {
104
104
  const bbConfig: BBProverConfig = {
105
105
  acvmBinaryPath: config.expectedAcvmPath,
@@ -126,14 +126,16 @@ export class TestContext {
126
126
  publicTxSimulator,
127
127
  ws,
128
128
  processor,
129
- simulationProvider,
130
129
  globalVariables,
131
130
  localProver,
132
131
  broker,
133
132
  facade,
134
133
  orchestrator,
135
134
  blockNumber,
135
+ feePayer,
136
+ initialFeePayerBalance,
136
137
  directoriesToCleanup,
138
+ tester,
137
139
  logger,
138
140
  );
139
141
  }
@@ -156,23 +158,36 @@ export class TestContext {
156
158
  await this.brokerProverFacade.stop();
157
159
  await this.broker.stop();
158
160
  for (const dir of this.directoriesToCleanup.filter(x => x !== '')) {
159
- await fs.rm(dir, { recursive: true, force: true });
161
+ try {
162
+ await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 });
163
+ } catch (err) {
164
+ this.logger.warn(`Failed to delete tmp directory $dir}: ${err}`);
165
+ }
160
166
  }
161
167
  }
162
168
 
163
- public makeProcessedTx(opts?: Parameters<typeof makeBloatedProcessedTx>[0]): Promise<ProcessedTx>;
164
- public makeProcessedTx(seed?: number): Promise<ProcessedTx>;
165
- public makeProcessedTx(seedOrOpts?: Parameters<typeof makeBloatedProcessedTx>[0] | number): Promise<ProcessedTx> {
169
+ public async makeProcessedTx(opts?: Parameters<typeof makeBloatedProcessedTx>[0]): Promise<ProcessedTx>;
170
+ public async makeProcessedTx(seed?: number): Promise<ProcessedTx>;
171
+ public async makeProcessedTx(
172
+ seedOrOpts?: Parameters<typeof makeBloatedProcessedTx>[0] | number,
173
+ ): Promise<ProcessedTx> {
166
174
  const opts = typeof seedOrOpts === 'number' ? { seed: seedOrOpts } : seedOrOpts;
167
175
  const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber.toNumber();
168
176
  const header = this.getBlockHeader(blockNum - 1);
169
- return makeBloatedProcessedTx({
177
+ const tx = await makeBloatedProcessedTx({
170
178
  header,
171
179
  vkTreeRoot: getVKTreeRoot(),
172
180
  protocolContractTreeRoot,
173
181
  globalVariables: this.globalVariables,
182
+ feePayer: this.feePayer,
174
183
  ...opts,
175
184
  });
185
+ this.feePayerBalance = new Fr(this.feePayerBalance.toBigInt() - tx.txEffect.transactionFee.toBigInt());
186
+ if (opts?.privateOnly) {
187
+ const feePayerSlot = await computeFeePayerBalanceLeafSlot(this.feePayer);
188
+ tx.txEffect.publicDataWrites[0] = new PublicDataWrite(feePayerSlot, this.feePayerBalance);
189
+ }
190
+ return tx;
176
191
  }
177
192
 
178
193
  /** Creates a block with the given number of txs and adds it to world-state */
@@ -198,32 +213,7 @@ export class TestContext {
198
213
  }
199
214
 
200
215
  public async processPublicFunctions(txs: Tx[], maxTransactions: number) {
201
- const defaultExecutorImplementation = (
202
- _stateManager: AvmPersistableStateManager,
203
- executionRequest: PublicExecutionRequest,
204
- allocatedGas: Gas,
205
- _transactionFee: Fr,
206
- _fnName: string,
207
- ) => {
208
- for (const tx of txs) {
209
- const allCalls = tx.publicTeardownFunctionCall.isEmpty()
210
- ? tx.enqueuedPublicFunctionCalls
211
- : [...tx.enqueuedPublicFunctionCalls, tx.publicTeardownFunctionCall];
212
- for (const request of allCalls) {
213
- if (executionRequest.callContext.equals(request.callContext)) {
214
- return Promise.resolve(
215
- new AvmFinalizedCallResult(/*reverted=*/ false, /*output=*/ [], /*gasLeft=*/ allocatedGas),
216
- );
217
- }
218
- }
219
- }
220
- throw new Error(`Unexpected execution request: ${executionRequest}`);
221
- };
222
- return await this.processPublicFunctionsWithMockExecutorImplementation(
223
- txs,
224
- maxTransactions,
225
- defaultExecutorImplementation,
226
- );
216
+ return await this.publicProcessor.process(txs, { maxTransactions });
227
217
  }
228
218
 
229
219
  public async setTreeRoots(txs: ProcessedTx[]) {
@@ -248,38 +238,6 @@ export class TestContext {
248
238
  }
249
239
  }
250
240
  }
251
-
252
- private async processPublicFunctionsWithMockExecutorImplementation(
253
- txs: Tx[],
254
- maxTransactions: number,
255
- executorMock?: (
256
- stateManager: AvmPersistableStateManager,
257
- executionRequest: PublicExecutionRequest,
258
- allocatedGas: Gas,
259
- transactionFee: Fr,
260
- fnName: string,
261
- ) => Promise<AvmFinalizedCallResult>,
262
- ) {
263
- // Mock the internal private function. Borrowed from https://stackoverflow.com/a/71033167
264
- const simulateInternal: jest.SpiedFunction<
265
- (
266
- stateManager: AvmPersistableStateManager,
267
- executionResult: any,
268
- allocatedGas: Gas,
269
- transactionFee: any,
270
- fnName: any,
271
- ) => Promise<AvmFinalizedCallResult>
272
- > = jest.spyOn(
273
- this.publicTxSimulator as unknown as {
274
- simulateEnqueuedCallInternal: PublicTxSimulator['simulateEnqueuedCallInternal'];
275
- },
276
- 'simulateEnqueuedCallInternal',
277
- );
278
- if (executorMock) {
279
- simulateInternal.mockImplementation(executorMock);
280
- }
281
- return await this.publicProcessor.process(txs, { maxTransactions });
282
- }
283
241
  }
284
242
 
285
243
  class TestProvingOrchestrator extends ProvingOrchestrator {
@@ -1,39 +1,32 @@
1
- import { Blob } from '@aztec/blob-lib';
2
- import {
3
- Body,
4
- MerkleTreeId,
5
- type MerkleTreeWriteOperations,
6
- type ProcessedTx,
7
- TxEffect,
8
- getTreeHeight,
9
- } from '@aztec/circuit-types';
1
+ import { Blob, type SpongeBlob } from '@aztec/blob-lib';
10
2
  import {
11
3
  ARCHIVE_HEIGHT,
12
- AppendOnlyTreeSnapshot,
13
- BlockHeader,
14
- ContentCommitment,
15
- Fr,
16
- type GlobalVariables,
4
+ MAX_CONTRACT_CLASS_LOGS_PER_TX,
17
5
  MAX_NOTE_HASHES_PER_TX,
18
6
  MAX_NULLIFIERS_PER_TX,
19
- MembershipWitness,
20
- MerkleTreeCalculator,
21
7
  NOTE_HASH_SUBTREE_HEIGHT,
22
8
  NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH,
23
9
  NULLIFIER_SUBTREE_HEIGHT,
24
10
  NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH,
25
11
  NULLIFIER_TREE_HEIGHT,
26
12
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
27
- NullifierLeafPreimage,
28
13
  PUBLIC_DATA_TREE_HEIGHT,
29
- type ParityPublicInputs,
30
- PartialStateReference,
31
- PublicDataHint,
32
- PublicDataTreeLeaf,
33
- PublicDataTreeLeafPreimage,
34
- StateReference,
35
- } from '@aztec/circuits.js';
36
- import { type SpongeBlob } from '@aztec/circuits.js/blobs';
14
+ } from '@aztec/constants';
15
+ import { makeTuple } from '@aztec/foundation/array';
16
+ import { padArrayEnd } from '@aztec/foundation/collection';
17
+ import { sha256Trunc } from '@aztec/foundation/crypto';
18
+ import { Fr } from '@aztec/foundation/fields';
19
+ import type { Logger } from '@aztec/foundation/log';
20
+ import { type Tuple, assertLength, serializeToBuffer, toFriendlyJSON } from '@aztec/foundation/serialize';
21
+ import { MembershipWitness, MerkleTreeCalculator, computeUnbalancedMerkleRoot } from '@aztec/foundation/trees';
22
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
23
+ import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
24
+ import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
25
+ import { PublicDataHint } from '@aztec/stdlib/avm';
26
+ import { Body } from '@aztec/stdlib/block';
27
+ import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
28
+ import { ContractClassLog } from '@aztec/stdlib/logs';
29
+ import type { ParityPublicInputs } from '@aztec/stdlib/parity';
37
30
  import {
38
31
  type BaseOrMergeRollupPublicInputs,
39
32
  type BlockRootOrBlockMergePublicInputs,
@@ -41,18 +34,26 @@ import {
41
34
  PrivateBaseRollupHints,
42
35
  PrivateBaseStateDiffHints,
43
36
  PublicBaseRollupHints,
44
- } from '@aztec/circuits.js/rollup';
45
- import { makeTuple } from '@aztec/foundation/array';
46
- import { padArrayEnd } from '@aztec/foundation/collection';
47
- import { sha256Trunc } from '@aztec/foundation/crypto';
48
- import { type Logger } from '@aztec/foundation/log';
49
- import { type Tuple, assertLength, serializeToBuffer, toFriendlyJSON } from '@aztec/foundation/serialize';
50
- import { computeUnbalancedMerkleRoot } from '@aztec/foundation/trees';
51
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
52
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
53
- import { computeFeePayerBalanceLeafSlot } from '@aztec/simulator/server';
37
+ } from '@aztec/stdlib/rollup';
38
+ import {
39
+ AppendOnlyTreeSnapshot,
40
+ MerkleTreeId,
41
+ NullifierLeafPreimage,
42
+ PublicDataTreeLeaf,
43
+ PublicDataTreeLeafPreimage,
44
+ getTreeHeight,
45
+ } from '@aztec/stdlib/trees';
46
+ import {
47
+ BlockHeader,
48
+ ContentCommitment,
49
+ type GlobalVariables,
50
+ PartialStateReference,
51
+ type ProcessedTx,
52
+ StateReference,
53
+ TxEffect,
54
+ } from '@aztec/stdlib/tx';
54
55
  import { Attributes, type Span, runInSpan } from '@aztec/telemetry-client';
55
- import { type MerkleTreeReadOperations } from '@aztec/world-state';
56
+ import type { MerkleTreeReadOperations } from '@aztec/world-state';
56
57
 
57
58
  import { inspect } from 'util';
58
59
 
@@ -100,6 +101,10 @@ export const buildBaseRollupHints = runInSpan(
100
101
  const noteHashes = padArrayEnd(tx.txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX);
101
102
  await db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, noteHashes);
102
103
 
104
+ // Create data hint for reading fee payer initial balance in Fee Juice
105
+ const leafSlot = await computeFeePayerBalanceLeafSlot(tx.data.feePayer);
106
+ const feePayerFeeJuiceBalanceReadHint = await getPublicDataHint(db, leafSlot.toBigInt());
107
+
103
108
  // The read witnesses for a given TX should be generated before the writes of the same TX are applied.
104
109
  // All reads that refer to writes in the same tx are transient and can be simplified out.
105
110
  const txPublicDataUpdateRequestInfo = await processPublicDataUpdateRequests(tx, db);
@@ -136,6 +141,11 @@ export const buildBaseRollupHints = runInSpan(
136
141
  const inputSpongeBlob = startSpongeBlob.clone();
137
142
  await startSpongeBlob.absorb(tx.txEffect.toBlobFields());
138
143
 
144
+ const contractClassLogsPreimages = makeTuple(
145
+ MAX_CONTRACT_CLASS_LOGS_PER_TX,
146
+ i => tx.txEffect.contractClassLogs[i] || ContractClassLog.empty(),
147
+ );
148
+
139
149
  if (tx.avmProvingRequest) {
140
150
  const blockHash = await tx.constants.historicalHeader.hash();
141
151
  const archiveRootMembershipWitness = await getMembershipWitnessFor(
@@ -148,6 +158,7 @@ export const buildBaseRollupHints = runInSpan(
148
158
  return PublicBaseRollupHints.from({
149
159
  startSpongeBlob: inputSpongeBlob,
150
160
  archiveRootMembershipWitness,
161
+ contractClassLogsPreimages,
151
162
  constants,
152
163
  });
153
164
  } else {
@@ -159,13 +170,6 @@ export const buildBaseRollupHints = runInSpan(
159
170
  throw new Error(`More than one public data write in a private only tx`);
160
171
  }
161
172
 
162
- // Create data hint for reading fee payer initial balance in Fee Juice
163
- // If no fee payer is set, read hint should be empty
164
- const leafSlot = await computeFeePayerBalanceLeafSlot(tx.data.feePayer);
165
- const feePayerFeeJuiceBalanceReadHint = tx.data.feePayer.isZero()
166
- ? PublicDataHint.empty()
167
- : await getPublicDataHint(db, leafSlot.toBigInt());
168
-
169
173
  const feeWriteLowLeafPreimage =
170
174
  txPublicDataUpdateRequestInfo.lowPublicDataWritesPreimages[0] || PublicDataTreeLeafPreimage.empty();
171
175
  const feeWriteLowLeafMembershipWitness =
@@ -207,8 +211,9 @@ export const buildBaseRollupHints = runInSpan(
207
211
  start,
208
212
  startSpongeBlob: inputSpongeBlob,
209
213
  stateDiffHints,
210
- feePayerFeeJuiceBalanceReadHint: feePayerFeeJuiceBalanceReadHint,
214
+ feePayerFeeJuiceBalanceReadHint,
211
215
  archiveRootMembershipWitness,
216
+ contractClassLogsPreimages,
212
217
  constants,
213
218
  });
214
219
  }
@@ -347,7 +352,7 @@ export const buildHeaderAndBodyFromTxs = runInSpan(
347
352
  const contentCommitment = new ContentCommitment(new Fr(numTxs), blobsHash, parityShaRoot, outHash);
348
353
 
349
354
  const fees = body.txEffects.reduce((acc, tx) => acc.add(tx.transactionFee), Fr.ZERO);
350
- const manaUsed = txs.reduce((acc, tx) => acc.add(new Fr(tx.gasUsed.totalGas.l2Gas)), Fr.ZERO);
355
+ const manaUsed = txs.reduce((acc, tx) => acc.add(new Fr(tx.gasUsed.billedGas.l2Gas)), Fr.ZERO);
351
356
 
352
357
  const header = new BlockHeader(previousArchive, contentCommitment, stateReference, globalVariables, fees, manaUsed);
353
358
 
@@ -1,25 +1,24 @@
1
- import { type L2Block, type MerkleTreeId, type PublicInputsAndRecursiveProof } from '@aztec/circuit-types';
2
- import { type CircuitName } from '@aztec/circuit-types/stats';
1
+ import { SpongeBlob } from '@aztec/blob-lib';
3
2
  import {
4
3
  type ARCHIVE_HEIGHT,
5
- type AppendOnlyTreeSnapshot,
6
4
  BLOBS_PER_BLOCK,
7
- type BlockHeader,
8
5
  FIELDS_PER_BLOB,
9
- Fr,
10
- type GlobalVariables,
11
6
  type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
12
- MembershipWitness,
13
7
  type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
14
8
  NUM_BASE_PARITY_PER_ROOT_PARITY,
15
- type ParityPublicInputs,
16
9
  type RECURSIVE_PROOF_LENGTH,
17
- RootParityInput,
18
- RootParityInputs,
19
- StateReference,
20
10
  VK_TREE_HEIGHT,
21
- } from '@aztec/circuits.js';
22
- import { SpongeBlob } from '@aztec/circuits.js/blobs';
11
+ } from '@aztec/constants';
12
+ import { padArrayEnd } from '@aztec/foundation/collection';
13
+ import { Fr } from '@aztec/foundation/fields';
14
+ import type { Logger } from '@aztec/foundation/log';
15
+ import type { Tuple } from '@aztec/foundation/serialize';
16
+ import { MembershipWitness, type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
17
+ import { getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
18
+ import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
19
+ import type { L2Block } from '@aztec/stdlib/block';
20
+ import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
21
+ import { type ParityPublicInputs, RootParityInput, RootParityInputs } from '@aztec/stdlib/parity';
23
22
  import {
24
23
  type BaseOrMergeRollupPublicInputs,
25
24
  type BlockRootOrBlockMergePublicInputs,
@@ -31,17 +30,14 @@ import {
31
30
  MergeRollupInputs,
32
31
  PreviousRollupData,
33
32
  SingleTxBlockRootRollupInputs,
34
- } from '@aztec/circuits.js/rollup';
35
- import { padArrayEnd } from '@aztec/foundation/collection';
36
- import { type Logger } from '@aztec/foundation/log';
37
- import { type Tuple } from '@aztec/foundation/serialize';
38
- import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
39
- import { getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
40
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
33
+ } from '@aztec/stdlib/rollup';
34
+ import type { CircuitName } from '@aztec/stdlib/stats';
35
+ import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
36
+ import { type BlockHeader, type GlobalVariables, StateReference } from '@aztec/stdlib/tx';
41
37
 
42
38
  import { buildBlobHints, buildHeaderFromCircuitOutputs } from './block-building-helpers.js';
43
- import { type EpochProvingState } from './epoch-proving-state.js';
44
- import { type TxProvingState } from './tx-proving-state.js';
39
+ import type { EpochProvingState } from './epoch-proving-state.js';
40
+ import type { TxProvingState } from './tx-proving-state.js';
45
41
 
46
42
  export type TreeSnapshots = Map<MerkleTreeId, AppendOnlyTreeSnapshot>;
47
43
 
@@ -1,30 +1,25 @@
1
- import {
2
- type MerkleTreeId,
3
- type ProofAndVerificationKey,
4
- type PublicInputsAndRecursiveProof,
5
- } from '@aztec/circuit-types';
6
1
  import {
7
2
  type ARCHIVE_HEIGHT,
8
- type AppendOnlyTreeSnapshot,
9
- type BlockHeader,
10
- type Fr,
11
- type GlobalVariables,
12
3
  type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
13
- MembershipWitness,
14
4
  type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
15
5
  type TUBE_PROOF_LENGTH,
16
6
  VK_TREE_HEIGHT,
17
- } from '@aztec/circuits.js';
7
+ } from '@aztec/constants';
8
+ import type { Fr } from '@aztec/foundation/fields';
9
+ import type { Tuple } from '@aztec/foundation/serialize';
10
+ import { MembershipWitness, type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
11
+ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
12
+ import type { ProofAndVerificationKey, PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
13
+ import type { Proof } from '@aztec/stdlib/proofs';
18
14
  import {
19
15
  BlockMergeRollupInputs,
20
16
  type BlockRootOrBlockMergePublicInputs,
21
17
  PreviousRollupBlockData,
22
18
  RootRollupInputs,
23
19
  type RootRollupPublicInputs,
24
- } from '@aztec/circuits.js/rollup';
25
- import { type Tuple } from '@aztec/foundation/serialize';
26
- import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
27
- import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vks';
20
+ } from '@aztec/stdlib/rollup';
21
+ import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
22
+ import type { BlockHeader, GlobalVariables } from '@aztec/stdlib/tx';
28
23
 
29
24
  import { BlockProvingState } from './block-proving-state.js';
30
25
 
@@ -184,7 +179,7 @@ export class EpochProvingState {
184
179
  return this.blocks.find(block => block?.blockNumber === blockNumber);
185
180
  }
186
181
 
187
- public getEpochProofResult() {
182
+ public getEpochProofResult(): { proof: Proof; publicInputs: RootRollupPublicInputs } {
188
183
  if (!this.rootRollupProvingOutput) {
189
184
  throw new Error('Unable to get epoch proof result. Root rollup is not ready.');
190
185
  }
@@ -1,50 +1,43 @@
1
- import {
2
- L2Block,
3
- MerkleTreeId,
4
- type ProcessedTx,
5
- type ServerCircuitProver,
6
- type Tx,
7
- toNumBlobFields,
8
- } from '@aztec/circuit-types';
9
- import {
10
- type EpochProver,
11
- type ForkMerkleTreeOperations,
12
- type MerkleTreeWriteOperations,
13
- type ProofAndVerificationKey,
14
- } from '@aztec/circuit-types/interfaces';
15
- import { type CircuitName } from '@aztec/circuit-types/stats';
16
1
  import {
17
2
  AVM_PROOF_LENGTH_IN_FIELDS,
18
3
  AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS,
19
- type AppendOnlyTreeSnapshot,
20
- BaseParityInputs,
21
- type BlockHeader,
22
- Fr,
23
- type GlobalVariables,
24
4
  L1_TO_L2_MSG_SUBTREE_HEIGHT,
25
5
  L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
26
6
  NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
27
7
  NUM_BASE_PARITY_PER_ROOT_PARITY,
28
8
  type TUBE_PROOF_LENGTH,
29
- VerificationKeyData,
30
- makeEmptyRecursiveProof,
31
- } from '@aztec/circuits.js';
32
- import {
33
- type BaseRollupHints,
34
- EmptyBlockRootRollupInputs,
35
- PrivateBaseRollupInputs,
36
- SingleTxBlockRootRollupInputs,
37
- TubeInputs,
38
- } from '@aztec/circuits.js/rollup';
9
+ } from '@aztec/constants';
39
10
  import { padArrayEnd, times } from '@aztec/foundation/collection';
40
11
  import { AbortError } from '@aztec/foundation/error';
12
+ import { Fr } from '@aztec/foundation/fields';
41
13
  import { createLogger } from '@aztec/foundation/log';
42
14
  import { promiseWithResolvers } from '@aztec/foundation/promise';
43
15
  import { assertLength } from '@aztec/foundation/serialize';
44
16
  import { pushTestData } from '@aztec/foundation/testing';
45
17
  import { elapsed } from '@aztec/foundation/timer';
46
- import { type TreeNodeLocation } from '@aztec/foundation/trees';
47
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
18
+ import type { TreeNodeLocation } from '@aztec/foundation/trees';
19
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
20
+ import { L2Block } from '@aztec/stdlib/block';
21
+ import type {
22
+ EpochProver,
23
+ ForkMerkleTreeOperations,
24
+ MerkleTreeWriteOperations,
25
+ ProofAndVerificationKey,
26
+ ServerCircuitProver,
27
+ } from '@aztec/stdlib/interfaces/server';
28
+ import { BaseParityInputs } from '@aztec/stdlib/parity';
29
+ import { makeEmptyRecursiveProof } from '@aztec/stdlib/proofs';
30
+ import {
31
+ type BaseRollupHints,
32
+ EmptyBlockRootRollupInputs,
33
+ PrivateBaseRollupInputs,
34
+ SingleTxBlockRootRollupInputs,
35
+ TubeInputs,
36
+ } from '@aztec/stdlib/rollup';
37
+ import type { CircuitName } from '@aztec/stdlib/stats';
38
+ import { type AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
39
+ import { type BlockHeader, type GlobalVariables, type ProcessedTx, type Tx, toNumBlobFields } from '@aztec/stdlib/tx';
40
+ import { VerificationKeyData } from '@aztec/stdlib/vks';
48
41
  import {
49
42
  Attributes,
50
43
  type TelemetryClient,
@@ -65,7 +58,7 @@ import {
65
58
  validatePartialState,
66
59
  validateTx,
67
60
  } from './block-building-helpers.js';
68
- import { type BlockProvingState } from './block-proving-state.js';
61
+ import type { BlockProvingState } from './block-proving-state.js';
69
62
  import { EpochProvingState, type ProvingResult, type TreeSnapshots } from './epoch-proving-state.js';
70
63
  import { ProvingOrchestratorMetrics } from './orchestrator_metrics.js';
71
64
  import { TxProvingState } from './tx-proving-state.js';
@@ -1,13 +1,7 @@
1
- import { type MerkleTreeId, type ProcessedTx, type ProofAndVerificationKey } from '@aztec/circuit-types';
2
- import { type CircuitName } from '@aztec/circuit-types/stats';
3
- import {
4
- type AVM_PROOF_LENGTH_IN_FIELDS,
5
- AVM_VK_INDEX,
6
- type AppendOnlyTreeSnapshot,
7
- type TUBE_PROOF_LENGTH,
8
- TUBE_VK_INDEX,
9
- VkWitnessData,
10
- } from '@aztec/circuits.js';
1
+ import { type AVM_PROOF_LENGTH_IN_FIELDS, AVM_VK_INDEX, type TUBE_PROOF_LENGTH, TUBE_VK_INDEX } from '@aztec/constants';
2
+ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
3
+ import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
4
+ import type { ProofAndVerificationKey } from '@aztec/stdlib/interfaces/server';
11
5
  import {
12
6
  AvmProofData,
13
7
  type BaseRollupHints,
@@ -18,8 +12,11 @@ import {
18
12
  PublicBaseRollupInputs,
19
13
  PublicTubeData,
20
14
  TubeInputs,
21
- } from '@aztec/circuits.js/rollup';
22
- import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vks';
15
+ } from '@aztec/stdlib/rollup';
16
+ import type { CircuitName } from '@aztec/stdlib/stats';
17
+ import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
18
+ import type { ProcessedTx } from '@aztec/stdlib/tx';
19
+ import { VkWitnessData } from '@aztec/stdlib/vks';
23
20
 
24
21
  /**
25
22
  * Helper class to manage the proving cycle of a transaction
@@ -48,7 +45,7 @@ export class TxProvingState {
48
45
  return new TubeInputs(this.processedTx.clientIvcProof);
49
46
  }
50
47
 
51
- public getAvmInputs() {
48
+ public getAvmInputs(): AvmCircuitInputs {
52
49
  return this.processedTx.avmProvingRequest!.inputs;
53
50
  }
54
51