@aztec/sequencer-client 0.30.1 → 0.32.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 (111) hide show
  1. package/dest/client/sequencer-client.d.ts +5 -1
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +7 -35
  4. package/dest/config.d.ts.map +1 -1
  5. package/dest/config.js +7 -3
  6. package/dest/index.d.ts +0 -7
  7. package/dest/index.d.ts.map +1 -1
  8. package/dest/index.js +1 -8
  9. package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
  10. package/dest/publisher/viem-tx-sender.js +2 -3
  11. package/dest/sequencer/abstract_phase_manager.d.ts +3 -5
  12. package/dest/sequencer/abstract_phase_manager.d.ts.map +1 -1
  13. package/dest/sequencer/abstract_phase_manager.js +13 -17
  14. package/dest/sequencer/app_logic_phase_manager.d.ts +1 -3
  15. package/dest/sequencer/app_logic_phase_manager.d.ts.map +1 -1
  16. package/dest/sequencer/app_logic_phase_manager.js +3 -4
  17. package/dest/sequencer/phase_manager_factory.d.ts +2 -3
  18. package/dest/sequencer/phase_manager_factory.d.ts.map +1 -1
  19. package/dest/sequencer/phase_manager_factory.js +9 -9
  20. package/dest/sequencer/public_processor.d.ts +4 -9
  21. package/dest/sequencer/public_processor.d.ts.map +1 -1
  22. package/dest/sequencer/public_processor.js +9 -12
  23. package/dest/sequencer/sequencer.d.ts +8 -6
  24. package/dest/sequencer/sequencer.d.ts.map +1 -1
  25. package/dest/sequencer/sequencer.js +24 -23
  26. package/dest/sequencer/setup_phase_manager.d.ts +1 -3
  27. package/dest/sequencer/setup_phase_manager.d.ts.map +1 -1
  28. package/dest/sequencer/setup_phase_manager.js +3 -4
  29. package/dest/sequencer/tail_phase_manager.d.ts +1 -3
  30. package/dest/sequencer/tail_phase_manager.d.ts.map +1 -1
  31. package/dest/sequencer/tail_phase_manager.js +3 -4
  32. package/dest/sequencer/teardown_phase_manager.d.ts +1 -3
  33. package/dest/sequencer/teardown_phase_manager.d.ts.map +1 -1
  34. package/dest/sequencer/teardown_phase_manager.js +3 -4
  35. package/dest/sequencer/tx_validator.d.ts +9 -3
  36. package/dest/sequencer/tx_validator.d.ts.map +1 -1
  37. package/dest/sequencer/tx_validator.js +68 -20
  38. package/dest/sequencer/tx_validator_factory.d.ts +12 -0
  39. package/dest/sequencer/tx_validator_factory.d.ts.map +1 -0
  40. package/dest/sequencer/tx_validator_factory.js +17 -0
  41. package/dest/simulator/index.d.ts +1 -37
  42. package/dest/simulator/index.d.ts.map +1 -1
  43. package/dest/simulator/index.js +2 -2
  44. package/dest/simulator/public_executor.d.ts +3 -4
  45. package/dest/simulator/public_executor.d.ts.map +1 -1
  46. package/dest/simulator/public_executor.js +27 -18
  47. package/dest/simulator/public_kernel.d.ts +1 -1
  48. package/dest/simulator/public_kernel.d.ts.map +1 -1
  49. package/dest/simulator/public_kernel.js +2 -2
  50. package/package.json +13 -13
  51. package/src/client/sequencer-client.ts +10 -49
  52. package/src/config.ts +7 -1
  53. package/src/index.ts +0 -9
  54. package/src/publisher/viem-tx-sender.ts +1 -2
  55. package/src/sequencer/abstract_phase_manager.ts +17 -19
  56. package/src/sequencer/app_logic_phase_manager.ts +1 -3
  57. package/src/sequencer/phase_manager_factory.ts +0 -9
  58. package/src/sequencer/public_processor.ts +14 -19
  59. package/src/sequencer/sequencer.ts +25 -25
  60. package/src/sequencer/setup_phase_manager.ts +1 -3
  61. package/src/sequencer/tail_phase_manager.ts +1 -3
  62. package/src/sequencer/teardown_phase_manager.ts +1 -3
  63. package/src/sequencer/tx_validator.ts +94 -26
  64. package/src/sequencer/tx_validator_factory.ts +32 -0
  65. package/src/simulator/index.ts +0 -45
  66. package/src/simulator/public_executor.ts +33 -22
  67. package/src/simulator/public_kernel.ts +2 -2
  68. package/dest/block_builder/index.d.ts +0 -19
  69. package/dest/block_builder/index.d.ts.map +0 -1
  70. package/dest/block_builder/index.js +0 -2
  71. package/dest/block_builder/solo_block_builder.d.ts +0 -78
  72. package/dest/block_builder/solo_block_builder.d.ts.map +0 -1
  73. package/dest/block_builder/solo_block_builder.js +0 -489
  74. package/dest/block_builder/types.d.ts +0 -10
  75. package/dest/block_builder/types.d.ts.map +0 -1
  76. package/dest/block_builder/types.js +0 -2
  77. package/dest/mocks/verification_keys.d.ts +0 -28
  78. package/dest/mocks/verification_keys.d.ts.map +0 -1
  79. package/dest/mocks/verification_keys.js +0 -14
  80. package/dest/prover/empty.d.ts +0 -53
  81. package/dest/prover/empty.d.ts.map +0 -1
  82. package/dest/prover/empty.js +0 -75
  83. package/dest/prover/index.d.ts +0 -52
  84. package/dest/prover/index.d.ts.map +0 -1
  85. package/dest/prover/index.js +0 -2
  86. package/dest/sequencer/processed_tx.d.ts +0 -81
  87. package/dest/sequencer/processed_tx.d.ts.map +0 -1
  88. package/dest/sequencer/processed_tx.js +0 -98
  89. package/dest/simulator/acvm_native.d.ts +0 -20
  90. package/dest/simulator/acvm_native.d.ts.map +0 -1
  91. package/dest/simulator/acvm_native.js +0 -96
  92. package/dest/simulator/acvm_wasm.d.ts +0 -7
  93. package/dest/simulator/acvm_wasm.d.ts.map +0 -1
  94. package/dest/simulator/acvm_wasm.js +0 -23
  95. package/dest/simulator/rollup.d.ts +0 -43
  96. package/dest/simulator/rollup.d.ts.map +0 -1
  97. package/dest/simulator/rollup.js +0 -78
  98. package/dest/simulator/simulation_provider.d.ts +0 -9
  99. package/dest/simulator/simulation_provider.d.ts.map +0 -1
  100. package/dest/simulator/simulation_provider.js +0 -2
  101. package/src/block_builder/index.ts +0 -20
  102. package/src/block_builder/solo_block_builder.ts +0 -812
  103. package/src/block_builder/types.ts +0 -8
  104. package/src/mocks/verification_keys.ts +0 -36
  105. package/src/prover/empty.ts +0 -97
  106. package/src/prover/index.ts +0 -70
  107. package/src/sequencer/processed_tx.ts +0 -210
  108. package/src/simulator/acvm_native.ts +0 -112
  109. package/src/simulator/acvm_wasm.ts +0 -31
  110. package/src/simulator/rollup.ts +0 -127
  111. package/src/simulator/simulation_provider.ts +0 -10
@@ -1,45 +1,16 @@
1
1
  import { L1ToL2MessageSource, L2BlockSource } from '@aztec/circuit-types';
2
- import { createDebugLogger } from '@aztec/foundation/log';
2
+ import { BlockProver } from '@aztec/circuit-types/interfaces';
3
3
  import { P2P } from '@aztec/p2p';
4
+ import { SimulationProvider } from '@aztec/simulator';
4
5
  import { ContractDataSource } from '@aztec/types/contracts';
5
6
  import { WorldStateSynchronizer } from '@aztec/world-state';
6
7
 
7
- import * as fs from 'fs/promises';
8
-
9
- import { SoloBlockBuilder } from '../block_builder/solo_block_builder.js';
10
8
  import { SequencerClientConfig } from '../config.js';
11
9
  import { getGlobalVariableBuilder } from '../global_variable_builder/index.js';
12
- import { getVerificationKeys } from '../mocks/verification_keys.js';
13
- import { EmptyRollupProver } from '../prover/empty.js';
14
10
  import { getL1Publisher } from '../publisher/index.js';
15
11
  import { Sequencer, SequencerConfig } from '../sequencer/index.js';
16
12
  import { PublicProcessorFactory } from '../sequencer/public_processor.js';
17
- import { NativeACVMSimulator } from '../simulator/acvm_native.js';
18
- import { WASMSimulator } from '../simulator/acvm_wasm.js';
19
- import { RealRollupCircuitSimulator } from '../simulator/rollup.js';
20
- import { SimulationProvider } from '../simulator/simulation_provider.js';
21
-
22
- const logger = createDebugLogger('aztec:sequencer-client');
23
-
24
- /**
25
- * Factory function to create a simulation provider. Will attempt to use native binary simulation falling back to WASM if unavailable.
26
- * @param config - The provided sequencer client configuration
27
- * @returns The constructed simulation provider
28
- */
29
- async function getSimulationProvider(config: SequencerClientConfig): Promise<SimulationProvider> {
30
- if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
31
- try {
32
- await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
33
- await fs.mkdir(config.acvmWorkingDirectory, { recursive: true });
34
- logger(`Using native ACVM at ${config.acvmBinaryPath}`);
35
- return new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath);
36
- } catch {
37
- logger(`Failed to access ACVM at ${config.acvmBinaryPath}, falling back to WASM`);
38
- }
39
- }
40
- logger('Using WASM ACVM simulation');
41
- return new WASMSimulator();
42
- }
13
+ import { TxValidatorFactory } from '../sequencer/tx_validator_factory.js';
43
14
 
44
15
  /**
45
16
  * Encapsulates the full sequencer and publisher.
@@ -55,6 +26,8 @@ export class SequencerClient {
55
26
  * @param contractDataSource - Provides access to contract bytecode for public executions.
56
27
  * @param l2BlockSource - Provides information about the previously published blocks.
57
28
  * @param l1ToL2MessageSource - Provides access to L1 to L2 messages.
29
+ * @param prover - An instance of a block prover
30
+ * @param simulationProvider - An instance of a simulation provider
58
31
  * @returns A new running instance.
59
32
  */
60
33
  public static async new(
@@ -64,38 +37,26 @@ export class SequencerClient {
64
37
  contractDataSource: ContractDataSource,
65
38
  l2BlockSource: L2BlockSource,
66
39
  l1ToL2MessageSource: L1ToL2MessageSource,
40
+ prover: BlockProver,
41
+ simulationProvider: SimulationProvider,
67
42
  ) {
68
43
  const publisher = getL1Publisher(config);
69
44
  const globalsBuilder = getGlobalVariableBuilder(config);
70
45
  const merkleTreeDb = worldStateSynchronizer.getLatest();
71
46
 
72
- const simulationProvider = await getSimulationProvider(config);
73
-
74
- const blockBuilder = new SoloBlockBuilder(
75
- merkleTreeDb,
76
- getVerificationKeys(),
77
- new RealRollupCircuitSimulator(simulationProvider),
78
- new EmptyRollupProver(),
79
- );
80
-
81
- const publicProcessorFactory = new PublicProcessorFactory(
82
- merkleTreeDb,
83
- contractDataSource,
84
- l1ToL2MessageSource,
85
- simulationProvider,
86
- );
47
+ const publicProcessorFactory = new PublicProcessorFactory(merkleTreeDb, contractDataSource, simulationProvider);
87
48
 
88
49
  const sequencer = new Sequencer(
89
50
  publisher,
90
51
  globalsBuilder,
91
52
  p2pClient,
92
53
  worldStateSynchronizer,
93
- blockBuilder,
54
+ prover,
94
55
  l2BlockSource,
95
56
  l1ToL2MessageSource,
96
57
  publicProcessorFactory,
58
+ new TxValidatorFactory(merkleTreeDb, contractDataSource, config.l1Contracts.gasPortalAddress),
97
59
  config,
98
- config.l1Contracts.gasPortalAddress,
99
60
  );
100
61
 
101
62
  await sequencer.start();
package/src/config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AztecAddress } from '@aztec/circuits.js';
1
+ import { AztecAddress, Fr } from '@aztec/circuits.js';
2
2
  import { L1ContractAddresses, NULL_KEY } from '@aztec/ethereum';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
 
@@ -40,6 +40,8 @@ export function getConfigEnvVars(): SequencerClientConfig {
40
40
  SEQ_TX_POLLING_INTERVAL_MS,
41
41
  SEQ_MAX_TX_PER_BLOCK,
42
42
  SEQ_MIN_TX_PER_BLOCK,
43
+ SEQ_FPC_CLASSES,
44
+ SEQ_FPC_INSTANCES,
43
45
  AVAILABILITY_ORACLE_CONTRACT_ADDRESS,
44
46
  ROLLUP_CONTRACT_ADDRESS,
45
47
  REGISTRY_CONTRACT_ADDRESS,
@@ -88,5 +90,9 @@ export function getConfigEnvVars(): SequencerClientConfig {
88
90
  feeRecipient: FEE_RECIPIENT ? AztecAddress.fromString(FEE_RECIPIENT) : undefined,
89
91
  acvmWorkingDirectory: ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : undefined,
90
92
  acvmBinaryPath: ACVM_BINARY_PATH ? ACVM_BINARY_PATH : undefined,
93
+ allowedFeePaymentContractClasses: SEQ_FPC_CLASSES ? SEQ_FPC_CLASSES.split(',').map(Fr.fromString) : [],
94
+ allowedFeePaymentContractInstances: SEQ_FPC_INSTANCES
95
+ ? SEQ_FPC_INSTANCES.split(',').map(AztecAddress.fromString)
96
+ : [],
91
97
  };
92
98
  }
package/src/index.ts CHANGED
@@ -1,17 +1,8 @@
1
1
  export * from './client/index.js';
2
2
  export * from './config.js';
3
- export * from './mocks/verification_keys.js';
4
3
  export * from './publisher/index.js';
5
4
  export * from './sequencer/index.js';
6
5
 
7
6
  // Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
8
7
  export * from './global_variable_builder/index.js';
9
8
  export * from './sequencer/public_processor.js';
10
-
11
- // Used by publisher test in e2e
12
- export { SoloBlockBuilder } from './block_builder/solo_block_builder.js';
13
- export { EmptyRollupProver } from './prover/empty.js';
14
- export { makeEmptyProcessedTx, makeProcessedTx, partitionReverts } from './sequencer/processed_tx.js';
15
- export { WASMSimulator } from './simulator/acvm_wasm.js';
16
- export { RealRollupCircuitSimulator } from './simulator/rollup.js';
17
- export { SimulationProvider } from './simulator/simulation_provider.js';
@@ -77,7 +77,7 @@ export class ViemTxSender implements L1PublisherTxSender {
77
77
  }
78
78
 
79
79
  checkIfTxsAreAvailable(block: L2Block): Promise<boolean> {
80
- const args = [`0x${block.body.getTxsEffectsHash().toString('hex')}`] as const;
80
+ const args = [`0x${block.body.getTxsEffectsHash().toString('hex').padStart(64, '0')}`] as const;
81
81
  return this.availabilityOracleContract.read.isAvailable(args);
82
82
  }
83
83
 
@@ -145,7 +145,6 @@ export class ViemTxSender implements L1PublisherTxSender {
145
145
  const args = [
146
146
  `0x${encodedData.header.toString('hex')}`,
147
147
  `0x${encodedData.archive.toString('hex')}`,
148
- `0x${encodedData.body.toString('hex')}`,
149
148
  `0x${encodedData.proof.toString('hex')}`,
150
149
  ] as const;
151
150
 
@@ -1,4 +1,4 @@
1
- import { FunctionL2Logs, MerkleTreeId, SimulationError, Tx } from '@aztec/circuit-types';
1
+ import { MerkleTreeId, SimulationError, Tx, UnencryptedFunctionL2Logs } from '@aztec/circuit-types';
2
2
  import {
3
3
  AztecAddress,
4
4
  CallRequest,
@@ -34,14 +34,17 @@ import {
34
34
  PublicKernelTailCircuitPrivateInputs,
35
35
  RETURN_VALUES_LENGTH,
36
36
  ReadRequest,
37
+ RevertCode,
37
38
  SideEffect,
38
39
  SideEffectLinkedToNoteHash,
39
40
  VK_TREE_HEIGHT,
41
+ VerificationKey,
42
+ makeEmptyProof,
40
43
  } from '@aztec/circuits.js';
41
44
  import { computeVarArgsHash } from '@aztec/circuits.js/hash';
42
45
  import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
43
46
  import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
44
- import { Tuple, to2Fields } from '@aztec/foundation/serialize';
47
+ import { Tuple } from '@aztec/foundation/serialize';
45
48
  import {
46
49
  PublicExecution,
47
50
  PublicExecutionResult,
@@ -52,10 +55,6 @@ import {
52
55
  } from '@aztec/simulator';
53
56
  import { MerkleTreeOperations } from '@aztec/world-state';
54
57
 
55
- import { env } from 'process';
56
-
57
- import { getVerificationKeys } from '../mocks/verification_keys.js';
58
- import { PublicProver } from '../prover/index.js';
59
58
  import { PublicKernelCircuitSimulator } from '../simulator/index.js';
60
59
  import { HintsBuilder } from './hints_builder.js';
61
60
  import { lastSideEffectCounter } from './utils.js';
@@ -81,7 +80,6 @@ export abstract class AbstractPhaseManager {
81
80
  protected db: MerkleTreeOperations,
82
81
  protected publicExecutor: PublicExecutor,
83
82
  protected publicKernel: PublicKernelCircuitSimulator,
84
- protected publicProver: PublicProver,
85
83
  protected globalVariables: GlobalVariables,
86
84
  protected historicalHeader: Header,
87
85
  public phase: PublicKernelPhase,
@@ -182,7 +180,7 @@ export abstract class AbstractPhaseManager {
182
180
  tx: Tx,
183
181
  previousPublicKernelOutput: PublicKernelCircuitPublicInputs,
184
182
  previousPublicKernelProof: Proof,
185
- ): Promise<[PublicKernelCircuitPublicInputs, Proof, FunctionL2Logs[], SimulationError | undefined]> {
183
+ ): Promise<[PublicKernelCircuitPublicInputs, Proof, UnencryptedFunctionL2Logs[], SimulationError | undefined]> {
186
184
  let kernelOutput = previousPublicKernelOutput;
187
185
  let kernelProof = previousPublicKernelProof;
188
186
 
@@ -192,7 +190,7 @@ export abstract class AbstractPhaseManager {
192
190
  return [kernelOutput, kernelProof, [], undefined];
193
191
  }
194
192
 
195
- const newUnencryptedFunctionLogs: FunctionL2Logs[] = [];
193
+ const newUnencryptedFunctionLogs: UnencryptedFunctionL2Logs[] = [];
196
194
 
197
195
  // TODO(#1684): Should multiple separately enqueued public calls be treated as
198
196
  // separate public callstacks to be proven by separate public kernel sequences
@@ -209,9 +207,9 @@ export abstract class AbstractPhaseManager {
209
207
  const isExecutionRequest = !isPublicExecutionResult(current);
210
208
 
211
209
  const sideEffectCounter = lastSideEffectCounter(tx) + 1;
212
- // NOTE: temporary glue to incorporate avm execution calls
210
+ // NOTE: temporary glue to incorporate avm execution calls.
213
211
  const simulator = (execution: PublicExecution, globalVariables: GlobalVariables) =>
214
- env.AVM_ENABLED
212
+ execution.functionData.isTranspiled
215
213
  ? this.publicExecutor.simulateAvm(execution, globalVariables, sideEffectCounter)
216
214
  : this.publicExecutor.simulate(execution, globalVariables, sideEffectCounter);
217
215
 
@@ -240,7 +238,7 @@ export abstract class AbstractPhaseManager {
240
238
  // sanity check. Note we can't expect them to just be equal, because e.g.
241
239
  // if the simulator reverts in app logic, it "resets" and result.reverted will be false when we run teardown,
242
240
  // but the kernel carries the reverted flag forward. But if the simulator reverts, so should the kernel.
243
- if (result.reverted && !kernelOutput.reverted) {
241
+ if (result.reverted && kernelOutput.endNonRevertibleData.revertCode.isOK()) {
244
242
  throw new Error(
245
243
  `Public kernel circuit did not revert on ${result.execution.contractAddress.toString()}:${functionSelector}, but simulator did.`,
246
244
  );
@@ -278,8 +276,7 @@ export abstract class AbstractPhaseManager {
278
276
  callData?: PublicCallData,
279
277
  ): Promise<[PublicKernelCircuitPublicInputs, Proof]> {
280
278
  const output = await this.getKernelCircuitOutput(previousOutput, previousProof, callData);
281
- const proof = await this.publicProver.getPublicKernelCircuitProof(output);
282
- return [output, proof];
279
+ return [output, makeEmptyProof()];
283
280
  }
284
281
 
285
282
  protected async getKernelCircuitOutput(
@@ -330,7 +327,8 @@ export abstract class AbstractPhaseManager {
330
327
  previousOutput: PublicKernelCircuitPublicInputs,
331
328
  previousProof: Proof,
332
329
  ): PublicKernelData {
333
- const vk = getVerificationKeys().publicKernelCircuit;
330
+ // TODO(@PhilWindle) Fix once we move this to prover-client
331
+ const vk = VerificationKey.makeFake();
334
332
  const vkIndex = 0;
335
333
  const vkSiblingPath = MembershipWitness.random(VK_TREE_HEIGHT).siblingPath;
336
334
  return new PublicKernelData(previousOutput, previousProof, vk, vkIndex, vkSiblingPath);
@@ -348,7 +346,7 @@ export abstract class AbstractPhaseManager {
348
346
  );
349
347
 
350
348
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165) --> set this in Noir
351
- const unencryptedLogsHash = to2Fields(result.unencryptedLogs.hash());
349
+ const unencryptedLogsHash = Fr.fromBuffer(result.unencryptedLogs.hash());
352
350
  const unencryptedLogPreimagesLength = new Fr(result.unencryptedLogs.getSerializedLength());
353
351
 
354
352
  return PublicCircuitPublicInputs.from({
@@ -385,7 +383,8 @@ export abstract class AbstractPhaseManager {
385
383
  unencryptedLogsHash,
386
384
  unencryptedLogPreimagesLength,
387
385
  historicalHeader: this.historicalHeader,
388
- reverted: result.reverted,
386
+ // TODO(@just-mitch): need better mapping from simulator to revert code.
387
+ revertCode: result.reverted ? RevertCode.REVERTED : RevertCode.OK,
389
388
  });
390
389
  }
391
390
 
@@ -432,8 +431,7 @@ export abstract class AbstractPhaseManager {
432
431
  );
433
432
  const publicCallStack = padArrayEnd(publicCallRequests, CallRequest.empty(), MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL);
434
433
  const portalContractAddress = result.execution.callContext.portalContractAddress.toField();
435
- const proof = await this.publicProver.getPublicCircuitProof(callStackItem.publicInputs);
436
- return new PublicCallData(callStackItem, publicCallStack, proof, portalContractAddress, bytecodeHash);
434
+ return new PublicCallData(callStackItem, publicCallStack, makeEmptyProof(), portalContractAddress, bytecodeHash);
437
435
  }
438
436
  }
439
437
 
@@ -3,7 +3,6 @@ import { GlobalVariables, Header, Proof, PublicKernelCircuitPublicInputs } from
3
3
  import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
4
4
  import { MerkleTreeOperations } from '@aztec/world-state';
5
5
 
6
- import { PublicProver } from '../prover/index.js';
7
6
  import { PublicKernelCircuitSimulator } from '../simulator/index.js';
8
7
  import { ContractsDataSourcePublicDB } from '../simulator/public_executor.js';
9
8
  import { AbstractPhaseManager, PublicKernelPhase } from './abstract_phase_manager.js';
@@ -16,14 +15,13 @@ export class AppLogicPhaseManager extends AbstractPhaseManager {
16
15
  protected db: MerkleTreeOperations,
17
16
  protected publicExecutor: PublicExecutor,
18
17
  protected publicKernel: PublicKernelCircuitSimulator,
19
- protected publicProver: PublicProver,
20
18
  protected globalVariables: GlobalVariables,
21
19
  protected historicalHeader: Header,
22
20
  protected publicContractsDB: ContractsDataSourcePublicDB,
23
21
  protected publicStateDB: PublicStateDB,
24
22
  public phase: PublicKernelPhase = PublicKernelPhase.APP_LOGIC,
25
23
  ) {
26
- super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader, phase);
24
+ super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase);
27
25
  }
28
26
 
29
27
  override async handle(
@@ -3,7 +3,6 @@ import { GlobalVariables, Header, PublicKernelCircuitPublicInputs } from '@aztec
3
3
  import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
4
4
  import { MerkleTreeOperations } from '@aztec/world-state';
5
5
 
6
- import { PublicProver } from '../prover/index.js';
7
6
  import { PublicKernelCircuitSimulator } from '../simulator/index.js';
8
7
  import { ContractsDataSourcePublicDB } from '../simulator/public_executor.js';
9
8
  import { AbstractPhaseManager, PublicKernelPhase } from './abstract_phase_manager.js';
@@ -30,7 +29,6 @@ export class PhaseManagerFactory {
30
29
  db: MerkleTreeOperations,
31
30
  publicExecutor: PublicExecutor,
32
31
  publicKernel: PublicKernelCircuitSimulator,
33
- publicProver: PublicProver,
34
32
  globalVariables: GlobalVariables,
35
33
  historicalHeader: Header,
36
34
  publicContractsDB: ContractsDataSourcePublicDB,
@@ -41,7 +39,6 @@ export class PhaseManagerFactory {
41
39
  db,
42
40
  publicExecutor,
43
41
  publicKernel,
44
- publicProver,
45
42
  globalVariables,
46
43
  historicalHeader,
47
44
  publicContractsDB,
@@ -52,7 +49,6 @@ export class PhaseManagerFactory {
52
49
  db,
53
50
  publicExecutor,
54
51
  publicKernel,
55
- publicProver,
56
52
  globalVariables,
57
53
  historicalHeader,
58
54
  publicContractsDB,
@@ -63,7 +59,6 @@ export class PhaseManagerFactory {
63
59
  db,
64
60
  publicExecutor,
65
61
  publicKernel,
66
- publicProver,
67
62
  globalVariables,
68
63
  historicalHeader,
69
64
  publicContractsDB,
@@ -80,7 +75,6 @@ export class PhaseManagerFactory {
80
75
  db: MerkleTreeOperations,
81
76
  publicExecutor: PublicExecutor,
82
77
  publicKernel: PublicKernelCircuitSimulator,
83
- publicProver: PublicProver,
84
78
  globalVariables: GlobalVariables,
85
79
  historicalHeader: Header,
86
80
  publicContractsDB: ContractsDataSourcePublicDB,
@@ -96,7 +90,6 @@ export class PhaseManagerFactory {
96
90
  db,
97
91
  publicExecutor,
98
92
  publicKernel,
99
- publicProver,
100
93
  globalVariables,
101
94
  historicalHeader,
102
95
  publicContractsDB,
@@ -110,7 +103,6 @@ export class PhaseManagerFactory {
110
103
  db,
111
104
  publicExecutor,
112
105
  publicKernel,
113
- publicProver,
114
106
  globalVariables,
115
107
  historicalHeader,
116
108
  publicContractsDB,
@@ -121,7 +113,6 @@ export class PhaseManagerFactory {
121
113
  db,
122
114
  publicExecutor,
123
115
  publicKernel,
124
- publicProver,
125
116
  globalVariables,
126
117
  historicalHeader,
127
118
  publicContractsDB,
@@ -1,28 +1,27 @@
1
- import { L1ToL2MessageSource, SimulationError, Tx } from '@aztec/circuit-types';
1
+ import {
2
+ FailedTx,
3
+ ProcessedTx,
4
+ SimulationError,
5
+ Tx,
6
+ getPreviousOutputAndProof,
7
+ makeEmptyProcessedTx,
8
+ makeProcessedTx,
9
+ toTxEffect,
10
+ validateProcessedTx,
11
+ } from '@aztec/circuit-types';
2
12
  import { TxSequencerProcessingStats } from '@aztec/circuit-types/stats';
3
13
  import { GlobalVariables, Header } from '@aztec/circuits.js';
4
14
  import { createDebugLogger } from '@aztec/foundation/log';
5
15
  import { Timer } from '@aztec/foundation/timer';
6
- import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
16
+ import { PublicExecutor, PublicStateDB, SimulationProvider } from '@aztec/simulator';
7
17
  import { ContractDataSource } from '@aztec/types/contracts';
8
18
  import { MerkleTreeOperations } from '@aztec/world-state';
9
19
 
10
- import { EmptyPublicProver } from '../prover/empty.js';
11
- import { PublicProver } from '../prover/index.js';
12
20
  import { PublicKernelCircuitSimulator } from '../simulator/index.js';
13
21
  import { ContractsDataSourcePublicDB, WorldStateDB, WorldStatePublicDB } from '../simulator/public_executor.js';
14
22
  import { RealPublicKernelCircuitSimulator } from '../simulator/public_kernel.js';
15
- import { SimulationProvider } from '../simulator/simulation_provider.js';
16
23
  import { AbstractPhaseManager } from './abstract_phase_manager.js';
17
24
  import { PhaseManagerFactory } from './phase_manager_factory.js';
18
- import {
19
- FailedTx,
20
- ProcessedTx,
21
- getPreviousOutputAndProof,
22
- makeEmptyProcessedTx,
23
- makeProcessedTx,
24
- validateProcessedTx,
25
- } from './processed_tx.js';
26
25
 
27
26
  /**
28
27
  * Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
@@ -31,7 +30,6 @@ export class PublicProcessorFactory {
31
30
  constructor(
32
31
  private merkleTree: MerkleTreeOperations,
33
32
  private contractDataSource: ContractDataSource,
34
- private l1Tol2MessagesDataSource: L1ToL2MessageSource,
35
33
  private simulator: SimulationProvider,
36
34
  ) {}
37
35
 
@@ -50,13 +48,12 @@ export class PublicProcessorFactory {
50
48
 
51
49
  const publicContractsDB = new ContractsDataSourcePublicDB(this.contractDataSource);
52
50
  const worldStatePublicDB = new WorldStatePublicDB(this.merkleTree);
53
- const worldStateDB = new WorldStateDB(this.merkleTree, this.l1Tol2MessagesDataSource);
51
+ const worldStateDB = new WorldStateDB(this.merkleTree);
54
52
  const publicExecutor = new PublicExecutor(worldStatePublicDB, publicContractsDB, worldStateDB, historicalHeader);
55
53
  return new PublicProcessor(
56
54
  this.merkleTree,
57
55
  publicExecutor,
58
56
  new RealPublicKernelCircuitSimulator(this.simulator),
59
- new EmptyPublicProver(),
60
57
  globalVariables,
61
58
  historicalHeader,
62
59
  publicContractsDB,
@@ -74,7 +71,6 @@ export class PublicProcessor {
74
71
  protected db: MerkleTreeOperations,
75
72
  protected publicExecutor: PublicExecutor,
76
73
  protected publicKernel: PublicKernelCircuitSimulator,
77
- protected publicProver: PublicProver,
78
74
  protected globalVariables: GlobalVariables,
79
75
  protected historicalHeader: Header,
80
76
  protected publicContractsDB: ContractsDataSourcePublicDB,
@@ -100,7 +96,6 @@ export class PublicProcessor {
100
96
  this.db,
101
97
  this.publicExecutor,
102
98
  this.publicKernel,
103
- this.publicProver,
104
99
  this.globalVariables,
105
100
  this.historicalHeader,
106
101
  this.publicContractsDB,
@@ -122,7 +117,6 @@ export class PublicProcessor {
122
117
  this.db,
123
118
  this.publicExecutor,
124
119
  this.publicKernel,
125
- this.publicProver,
126
120
  this.globalVariables,
127
121
  this.historicalHeader,
128
122
  this.publicContractsDB,
@@ -138,6 +132,7 @@ export class PublicProcessor {
138
132
  this.log(`Processed public part of ${tx.data.endNonRevertibleData.newNullifiers[0].value}`, {
139
133
  eventName: 'tx-sequencer-processing',
140
134
  duration: timer.ms(),
135
+ effectsSize: toTxEffect(processedTransaction).toBuffer().length,
141
136
  publicDataUpdateRequests:
142
137
  processedTransaction.data.combinedData.publicDataUpdateRequests.filter(x => !x.leafSlot.isZero()).length ??
143
138
  0,
@@ -1,7 +1,7 @@
1
- import { L1ToL2MessageSource, L2Block, L2BlockSource, MerkleTreeId, Tx } from '@aztec/circuit-types';
1
+ import { L1ToL2MessageSource, L2Block, L2BlockSource, ProcessedTx, Tx } from '@aztec/circuit-types';
2
+ import { BlockProver, PROVING_STATUS } from '@aztec/circuit-types/interfaces';
2
3
  import { L2BlockBuiltStats } from '@aztec/circuit-types/stats';
3
4
  import { AztecAddress, EthAddress, GlobalVariables } from '@aztec/circuits.js';
4
- import { times } from '@aztec/foundation/collection';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
  import { createDebugLogger } from '@aztec/foundation/log';
7
7
  import { RunningPromise } from '@aztec/foundation/running-promise';
@@ -9,15 +9,12 @@ import { Timer, elapsed } from '@aztec/foundation/timer';
9
9
  import { P2P } from '@aztec/p2p';
10
10
  import { WorldStateStatus, WorldStateSynchronizer } from '@aztec/world-state';
11
11
 
12
- import { BlockBuilder } from '../block_builder/index.js';
13
12
  import { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
14
13
  import { L1Publisher } from '../publisher/l1-publisher.js';
15
- import { WorldStatePublicDB } from '../simulator/public_executor.js';
16
- import { ceilPowerOfTwo } from '../utils.js';
17
14
  import { SequencerConfig } from './config.js';
18
- import { ProcessedTx } from './processed_tx.js';
19
15
  import { PublicProcessorFactory } from './public_processor.js';
20
16
  import { TxValidator } from './tx_validator.js';
17
+ import { TxValidatorFactory } from './tx_validator_factory.js';
21
18
 
22
19
  /**
23
20
  * Sequencer client
@@ -38,18 +35,20 @@ export class Sequencer {
38
35
  private _feeRecipient = AztecAddress.ZERO;
39
36
  private lastPublishedBlock = 0;
40
37
  private state = SequencerState.STOPPED;
38
+ private allowedFeePaymentContractClasses: Fr[] = [];
39
+ private allowedFeePaymentContractInstances: AztecAddress[] = [];
41
40
 
42
41
  constructor(
43
42
  private publisher: L1Publisher,
44
43
  private globalsBuilder: GlobalVariableBuilder,
45
44
  private p2pClient: P2P,
46
45
  private worldState: WorldStateSynchronizer,
47
- private blockBuilder: BlockBuilder,
46
+ private prover: BlockProver,
48
47
  private l2BlockSource: L2BlockSource,
49
48
  private l1ToL2MessageSource: L1ToL2MessageSource,
50
49
  private publicProcessorFactory: PublicProcessorFactory,
50
+ private txValidatorFactory: TxValidatorFactory,
51
51
  config: SequencerConfig = {},
52
- private gasPortalAddress = EthAddress.ZERO,
53
52
  private log = createDebugLogger('aztec:sequencer'),
54
53
  ) {
55
54
  this.updateConfig(config);
@@ -76,6 +75,12 @@ export class Sequencer {
76
75
  if (config.feeRecipient) {
77
76
  this._feeRecipient = config.feeRecipient;
78
77
  }
78
+ if (config.allowedFeePaymentContractClasses) {
79
+ this.allowedFeePaymentContractClasses = config.allowedFeePaymentContractClasses;
80
+ }
81
+ if (config.allowedFeePaymentContractInstances) {
82
+ this.allowedFeePaymentContractInstances = config.allowedFeePaymentContractInstances;
83
+ }
79
84
  }
80
85
 
81
86
  /**
@@ -173,17 +178,10 @@ export class Sequencer {
173
178
  this._feeRecipient,
174
179
  );
175
180
 
176
- // Filter out invalid txs
177
- const trees = this.worldState.getLatest();
178
- const txValidator = new TxValidator(
179
- {
180
- getNullifierIndex(nullifier: Fr): Promise<bigint | undefined> {
181
- return trees.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
182
- },
183
- },
184
- new WorldStatePublicDB(trees),
185
- this.gasPortalAddress,
181
+ const txValidator = this.txValidatorFactory.buildTxValidator(
186
182
  newGlobalVariables,
183
+ this.allowedFeePaymentContractClasses,
184
+ this.allowedFeePaymentContractInstances,
187
185
  );
188
186
 
189
187
  // TODO: It should be responsibility of the P2P layer to validate txs before passing them on here
@@ -305,15 +303,17 @@ export class Sequencer {
305
303
  emptyTx: ProcessedTx,
306
304
  globalVariables: GlobalVariables,
307
305
  ) {
308
- // Pad the txs array with empty txs to be a power of two, at least 2
309
- const txsTargetSize = Math.max(ceilPowerOfTwo(txs.length), 2);
310
- const emptyTxCount = txsTargetSize - txs.length;
306
+ const blockTicket = await this.prover.startNewBlock(txs.length, globalVariables, l1ToL2Messages, emptyTx);
311
307
 
312
- const allTxs = [...txs, ...times(emptyTxCount, () => emptyTx)];
313
- this.log(`Building block ${globalVariables.blockNumber.toBigInt()}`);
308
+ for (const tx of txs) {
309
+ await this.prover.addNewTx(tx);
310
+ }
314
311
 
315
- const [block] = await this.blockBuilder.buildL2Block(globalVariables, allTxs, l1ToL2Messages);
316
- return block;
312
+ const result = await blockTicket.provingPromise;
313
+ if (result.status === PROVING_STATUS.FAILURE) {
314
+ throw new Error(`Block proving failed, reason: ${result.reason}`);
315
+ }
316
+ return result.block;
317
317
  }
318
318
 
319
319
  get coinbase(): EthAddress {
@@ -3,7 +3,6 @@ import { GlobalVariables, Header, Proof, PublicKernelCircuitPublicInputs } from
3
3
  import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
4
4
  import { MerkleTreeOperations } from '@aztec/world-state';
5
5
 
6
- import { PublicProver } from '../prover/index.js';
7
6
  import { PublicKernelCircuitSimulator } from '../simulator/index.js';
8
7
  import { ContractsDataSourcePublicDB } from '../simulator/public_executor.js';
9
8
  import { AbstractPhaseManager, PublicKernelPhase } from './abstract_phase_manager.js';
@@ -16,14 +15,13 @@ export class SetupPhaseManager extends AbstractPhaseManager {
16
15
  protected db: MerkleTreeOperations,
17
16
  protected publicExecutor: PublicExecutor,
18
17
  protected publicKernel: PublicKernelCircuitSimulator,
19
- protected publicProver: PublicProver,
20
18
  protected globalVariables: GlobalVariables,
21
19
  protected historicalHeader: Header,
22
20
  protected publicContractsDB: ContractsDataSourcePublicDB,
23
21
  protected publicStateDB: PublicStateDB,
24
22
  public phase: PublicKernelPhase = PublicKernelPhase.SETUP,
25
23
  ) {
26
- super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader, phase);
24
+ super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase);
27
25
  }
28
26
 
29
27
  override async handle(
@@ -3,7 +3,6 @@ import { GlobalVariables, Header, Proof, PublicKernelCircuitPublicInputs } from
3
3
  import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
4
4
  import { MerkleTreeOperations } from '@aztec/world-state';
5
5
 
6
- import { PublicProver } from '../prover/index.js';
7
6
  import { PublicKernelCircuitSimulator } from '../simulator/index.js';
8
7
  import { ContractsDataSourcePublicDB } from '../simulator/public_executor.js';
9
8
  import { AbstractPhaseManager, PublicKernelPhase } from './abstract_phase_manager.js';
@@ -13,14 +12,13 @@ export class TailPhaseManager extends AbstractPhaseManager {
13
12
  protected db: MerkleTreeOperations,
14
13
  protected publicExecutor: PublicExecutor,
15
14
  protected publicKernel: PublicKernelCircuitSimulator,
16
- protected publicProver: PublicProver,
17
15
  protected globalVariables: GlobalVariables,
18
16
  protected historicalHeader: Header,
19
17
  protected publicContractsDB: ContractsDataSourcePublicDB,
20
18
  protected publicStateDB: PublicStateDB,
21
19
  public readonly phase: PublicKernelPhase = PublicKernelPhase.TAIL,
22
20
  ) {
23
- super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader, phase);
21
+ super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase);
24
22
  }
25
23
 
26
24
  async handle(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs, previousPublicKernelProof: Proof) {
@@ -3,7 +3,6 @@ import { GlobalVariables, Header, Proof, PublicKernelCircuitPublicInputs } from
3
3
  import { PublicExecutor, PublicStateDB } from '@aztec/simulator';
4
4
  import { MerkleTreeOperations } from '@aztec/world-state';
5
5
 
6
- import { PublicProver } from '../prover/index.js';
7
6
  import { PublicKernelCircuitSimulator } from '../simulator/index.js';
8
7
  import { ContractsDataSourcePublicDB } from '../simulator/public_executor.js';
9
8
  import { AbstractPhaseManager, PublicKernelPhase } from './abstract_phase_manager.js';
@@ -16,14 +15,13 @@ export class TeardownPhaseManager extends AbstractPhaseManager {
16
15
  protected db: MerkleTreeOperations,
17
16
  protected publicExecutor: PublicExecutor,
18
17
  protected publicKernel: PublicKernelCircuitSimulator,
19
- protected publicProver: PublicProver,
20
18
  protected globalVariables: GlobalVariables,
21
19
  protected historicalHeader: Header,
22
20
  protected publicContractsDB: ContractsDataSourcePublicDB,
23
21
  protected publicStateDB: PublicStateDB,
24
22
  public phase: PublicKernelPhase = PublicKernelPhase.TEARDOWN,
25
23
  ) {
26
- super(db, publicExecutor, publicKernel, publicProver, globalVariables, historicalHeader, phase);
24
+ super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase);
27
25
  }
28
26
 
29
27
  override async handle(