@aztec/sequencer-client 0.55.1 → 0.57.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 (53) hide show
  1. package/dest/block_builder/index.d.ts +5 -24
  2. package/dest/block_builder/index.d.ts.map +1 -1
  3. package/dest/block_builder/index.js +3 -40
  4. package/dest/block_builder/light.d.ts +26 -0
  5. package/dest/block_builder/light.d.ts.map +1 -0
  6. package/dest/block_builder/light.js +60 -0
  7. package/dest/block_builder/orchestrator.d.ts +23 -0
  8. package/dest/block_builder/orchestrator.d.ts.map +1 -0
  9. package/dest/block_builder/orchestrator.js +33 -0
  10. package/dest/client/sequencer-client.d.ts +2 -1
  11. package/dest/client/sequencer-client.d.ts.map +1 -1
  12. package/dest/client/sequencer-client.js +3 -3
  13. package/dest/config.js +8 -5
  14. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  15. package/dest/global_variable_builder/global_builder.js +2 -1
  16. package/dest/publisher/config.d.ts.map +1 -1
  17. package/dest/publisher/config.js +7 -2
  18. package/dest/publisher/index.d.ts +1 -1
  19. package/dest/publisher/index.d.ts.map +1 -1
  20. package/dest/publisher/index.js +1 -1
  21. package/dest/publisher/l1-publisher.d.ts +46 -34
  22. package/dest/publisher/l1-publisher.d.ts.map +1 -1
  23. package/dest/publisher/l1-publisher.js +259 -116
  24. package/dest/publisher/utils.d.ts +1 -1
  25. package/dest/publisher/utils.js +1 -1
  26. package/dest/sequencer/sequencer.d.ts +7 -3
  27. package/dest/sequencer/sequencer.d.ts.map +1 -1
  28. package/dest/sequencer/sequencer.js +62 -23
  29. package/dest/tx_validator/gas_validator.d.ts +1 -0
  30. package/dest/tx_validator/gas_validator.d.ts.map +1 -1
  31. package/dest/tx_validator/gas_validator.js +13 -8
  32. package/dest/tx_validator/phases_validator.d.ts +1 -0
  33. package/dest/tx_validator/phases_validator.d.ts.map +1 -1
  34. package/dest/tx_validator/phases_validator.js +20 -20
  35. package/dest/tx_validator/test_utils.js +4 -4
  36. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  37. package/dest/tx_validator/tx_validator_factory.js +5 -4
  38. package/package.json +22 -19
  39. package/src/block_builder/index.ts +5 -49
  40. package/src/block_builder/light.ts +102 -0
  41. package/src/block_builder/orchestrator.ts +38 -0
  42. package/src/client/sequencer-client.ts +4 -3
  43. package/src/config.ts +7 -4
  44. package/src/global_variable_builder/global_builder.ts +1 -0
  45. package/src/publisher/config.ts +6 -1
  46. package/src/publisher/index.ts +1 -1
  47. package/src/publisher/l1-publisher.ts +373 -144
  48. package/src/publisher/utils.ts +1 -1
  49. package/src/sequencer/sequencer.ts +74 -26
  50. package/src/tx_validator/gas_validator.ts +13 -10
  51. package/src/tx_validator/phases_validator.ts +5 -6
  52. package/src/tx_validator/test_utils.ts +3 -3
  53. package/src/tx_validator/tx_validator_factory.ts +5 -4
@@ -1,51 +1,7 @@
1
- import { TestCircuitProver } from '@aztec/bb-prover';
2
- import {
3
- type BlockSimulator,
4
- type MerkleTreeOperations,
5
- type ProcessedTx,
6
- type ProvingTicket,
7
- type SimulationBlockResult,
8
- } from '@aztec/circuit-types';
9
- import { type Fr, type GlobalVariables } from '@aztec/circuits.js';
10
- import { ProvingOrchestrator } from '@aztec/prover-client/orchestrator';
11
- import { type SimulationProvider } from '@aztec/simulator';
12
- import { type TelemetryClient } from '@aztec/telemetry-client';
13
- import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
1
+ import { type BlockBuilder, type MerkleTreeOperations } from '@aztec/circuit-types';
14
2
 
15
- /**
16
- * Implements a block simulator using a test circuit prover under the hood, which just simulates circuits and outputs empty proofs.
17
- * This class is temporary and should die once we switch from tx effects to tx objects submissions, since sequencers won't have
18
- * the need to create L2 block headers to submit to L1. When we do that, we should also remove the references to the
19
- * prover-client and bb-prover packages from this package.
20
- */
21
- export class BlockBuilder implements BlockSimulator {
22
- private orchestrator: ProvingOrchestrator;
23
- constructor(db: MerkleTreeOperations, simulationProvider: SimulationProvider, telemetry: TelemetryClient) {
24
- const testProver = new TestCircuitProver(telemetry, simulationProvider);
25
- this.orchestrator = new ProvingOrchestrator(db, testProver, telemetry);
26
- }
27
-
28
- startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<ProvingTicket> {
29
- return this.orchestrator.startNewBlock(numTxs, globalVariables, l1ToL2Messages);
30
- }
31
- cancelBlock(): void {
32
- this.orchestrator.cancelBlock();
33
- }
34
- finaliseBlock(): Promise<SimulationBlockResult> {
35
- return this.orchestrator.finaliseBlock();
36
- }
37
- setBlockCompleted(): Promise<void> {
38
- return this.orchestrator.setBlockCompleted();
39
- }
40
- addNewTx(tx: ProcessedTx): Promise<void> {
41
- return this.orchestrator.addNewTx(tx);
42
- }
43
- }
44
-
45
- export class BlockBuilderFactory {
46
- constructor(private simulationProvider: SimulationProvider, private telemetry?: TelemetryClient) {}
47
-
48
- create(db: MerkleTreeOperations): BlockSimulator {
49
- return new BlockBuilder(db, this.simulationProvider, this.telemetry ?? new NoopTelemetryClient());
50
- }
3
+ export * from './orchestrator.js';
4
+ export * from './light.js';
5
+ export interface BlockBuilderFactory {
6
+ create(db: MerkleTreeOperations): BlockBuilder;
51
7
  }
@@ -0,0 +1,102 @@
1
+ import { createDebugLogger } from '@aztec/aztec.js';
2
+ import {
3
+ type BlockBuilder,
4
+ Body,
5
+ L2Block,
6
+ MerkleTreeId,
7
+ type MerkleTreeOperations,
8
+ type ProcessedTx,
9
+ type TxEffect,
10
+ makeEmptyProcessedTx,
11
+ toTxEffect,
12
+ } from '@aztec/circuit-types';
13
+ import {
14
+ Fr,
15
+ type GlobalVariables,
16
+ NESTED_RECURSIVE_PROOF_LENGTH,
17
+ NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
18
+ VerificationKeyData,
19
+ makeEmptyRecursiveProof,
20
+ } from '@aztec/circuits.js';
21
+ import { padArrayEnd } from '@aztec/foundation/collection';
22
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
23
+ import { buildBaseRollupInput, buildHeaderFromTxEffects, getTreeSnapshot } from '@aztec/prover-client/helpers';
24
+ import { type TelemetryClient } from '@aztec/telemetry-client';
25
+ import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
26
+
27
+ /**
28
+ * Builds a block and its header from a set of processed tx without running any circuits.
29
+ */
30
+ export class LightweightBlockBuilder implements BlockBuilder {
31
+ private numTxs?: number;
32
+ private globalVariables?: GlobalVariables;
33
+ private l1ToL2Messages?: Fr[];
34
+
35
+ private readonly txs: ProcessedTx[] = [];
36
+
37
+ private readonly logger = createDebugLogger('aztec:sequencer-client:block_builder_light');
38
+
39
+ constructor(private db: MerkleTreeOperations, private telemetry: TelemetryClient) {}
40
+
41
+ async startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
42
+ this.logger.verbose('Starting new block', { numTxs, globalVariables, l1ToL2Messages });
43
+ this.numTxs = numTxs;
44
+ this.globalVariables = globalVariables;
45
+ this.l1ToL2Messages = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
46
+
47
+ // Update L1 to L2 tree
48
+ await this.db.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.l1ToL2Messages!);
49
+ }
50
+
51
+ async addNewTx(tx: ProcessedTx): Promise<void> {
52
+ this.logger.verbose('Adding new tx to block', { txHash: tx.hash.toString() });
53
+ this.txs.push(tx);
54
+ await buildBaseRollupInput(
55
+ tx,
56
+ makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
57
+ this.globalVariables!,
58
+ this.db,
59
+ VerificationKeyData.makeFake(),
60
+ );
61
+ }
62
+
63
+ async setBlockCompleted(): Promise<L2Block> {
64
+ const paddingTxCount = this.numTxs! - this.txs.length;
65
+ this.logger.verbose(`Setting block as completed and adding ${paddingTxCount} padding txs`);
66
+ for (let i = 0; i < paddingTxCount; i++) {
67
+ await this.addNewTx(
68
+ makeEmptyProcessedTx(
69
+ this.db.getInitialHeader(),
70
+ this.globalVariables!.chainId,
71
+ this.globalVariables!.version,
72
+ getVKTreeRoot(),
73
+ ),
74
+ );
75
+ }
76
+
77
+ return this.buildBlock();
78
+ }
79
+
80
+ private async buildBlock(): Promise<L2Block> {
81
+ this.logger.verbose(`Finalising block`);
82
+ const nonEmptyTxEffects: TxEffect[] = this.txs
83
+ .map(tx => toTxEffect(tx, this.globalVariables!.gasFees))
84
+ .filter(txEffect => !txEffect.isEmpty());
85
+ const body = new Body(nonEmptyTxEffects);
86
+ const header = await buildHeaderFromTxEffects(body, this.globalVariables!, this.l1ToL2Messages!, this.db);
87
+
88
+ await this.db.updateArchive(header);
89
+ const newArchive = await getTreeSnapshot(MerkleTreeId.ARCHIVE, this.db);
90
+
91
+ const block = new L2Block(newArchive, header, body);
92
+ return block;
93
+ }
94
+ }
95
+
96
+ export class LightweightBlockBuilderFactory {
97
+ constructor(private telemetry?: TelemetryClient) {}
98
+
99
+ create(db: MerkleTreeOperations): BlockBuilder {
100
+ return new LightweightBlockBuilder(db, this.telemetry ?? new NoopTelemetryClient());
101
+ }
102
+ }
@@ -0,0 +1,38 @@
1
+ import { TestCircuitProver } from '@aztec/bb-prover';
2
+ import { type BlockBuilder, type L2Block, type MerkleTreeOperations, type ProcessedTx } from '@aztec/circuit-types';
3
+ import { type Fr, type GlobalVariables } from '@aztec/circuits.js';
4
+ import { ProvingOrchestrator } from '@aztec/prover-client/orchestrator';
5
+ import { type SimulationProvider } from '@aztec/simulator';
6
+ import { type TelemetryClient } from '@aztec/telemetry-client';
7
+ import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
8
+
9
+ /**
10
+ * Implements a block simulator using a test circuit prover under the hood, which just simulates circuits and outputs empty proofs.
11
+ * This class is unused at the moment, but could be leveraged by a prover-node to ascertain that it can prove a block before
12
+ * committing to proving it by sending a quote.
13
+ */
14
+ export class OrchestratorBlockBuilder implements BlockBuilder {
15
+ private orchestrator: ProvingOrchestrator;
16
+ constructor(db: MerkleTreeOperations, simulationProvider: SimulationProvider, telemetry: TelemetryClient) {
17
+ const testProver = new TestCircuitProver(telemetry, simulationProvider);
18
+ this.orchestrator = new ProvingOrchestrator(db, testProver, telemetry);
19
+ }
20
+
21
+ startNewBlock(numTxs: number, globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void> {
22
+ return this.orchestrator.startNewBlock(numTxs, globalVariables, l1ToL2Messages);
23
+ }
24
+ setBlockCompleted(): Promise<L2Block> {
25
+ return this.orchestrator.setBlockCompleted();
26
+ }
27
+ addNewTx(tx: ProcessedTx): Promise<void> {
28
+ return this.orchestrator.addNewTx(tx);
29
+ }
30
+ }
31
+
32
+ export class OrchestratorBlockBuilderFactory {
33
+ constructor(private simulationProvider: SimulationProvider, private telemetry?: TelemetryClient) {}
34
+
35
+ create(db: MerkleTreeOperations): BlockBuilder {
36
+ return new OrchestratorBlockBuilder(db, this.simulationProvider, this.telemetry ?? new NoopTelemetryClient());
37
+ }
38
+ }
@@ -1,11 +1,12 @@
1
1
  import { type L1ToL2MessageSource, type L2BlockSource, type WorldStateSynchronizer } from '@aztec/circuit-types';
2
+ import { type EthAddress } from '@aztec/foundation/eth-address';
2
3
  import { type P2P } from '@aztec/p2p';
3
4
  import { PublicProcessorFactory, type SimulationProvider } from '@aztec/simulator';
4
5
  import { type TelemetryClient } from '@aztec/telemetry-client';
5
6
  import { type ContractDataSource } from '@aztec/types/contracts';
6
7
  import { type ValidatorClient } from '@aztec/validator-client';
7
8
 
8
- import { BlockBuilderFactory } from '../block_builder/index.js';
9
+ import { LightweightBlockBuilderFactory } from '../block_builder/index.js';
9
10
  import { type SequencerClientConfig } from '../config.js';
10
11
  import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
11
12
  import { L1Publisher } from '../publisher/index.js';
@@ -59,7 +60,7 @@ export class SequencerClient {
59
60
  globalsBuilder,
60
61
  p2pClient,
61
62
  worldStateSynchronizer,
62
- new BlockBuilderFactory(simulationProvider, telemetryClient),
63
+ new LightweightBlockBuilderFactory(telemetryClient),
63
64
  l2BlockSource,
64
65
  l1ToL2MessageSource,
65
66
  publicProcessorFactory,
@@ -99,7 +100,7 @@ export class SequencerClient {
99
100
  this.sequencer.restart();
100
101
  }
101
102
 
102
- get coinbase() {
103
+ get coinbase(): EthAddress {
103
104
  return this.sequencer.coinbase;
104
105
  }
105
106
 
package/src/config.ts CHANGED
@@ -117,9 +117,9 @@ export const chainConfigMappings: ConfigMappingsType<ChainConfig> = {
117
117
 
118
118
  export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
119
119
  ...sequencerConfigMappings,
120
+ ...l1ReaderConfigMappings,
120
121
  ...getTxSenderConfigMappings('SEQ'),
121
122
  ...getPublisherConfigMappings('SEQ'),
122
- ...l1ReaderConfigMappings,
123
123
  ...chainConfigMappings,
124
124
  };
125
125
 
@@ -189,16 +189,19 @@ function getDefaultAllowedSetupFunctions(): AllowedElement[] {
189
189
  // needed for claiming on the same tx as a spend
190
190
  {
191
191
  address: FeeJuiceAddress,
192
- selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'),
192
+ // We can't restrict the selector because public functions get routed via dispatch.
193
+ // selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'),
193
194
  },
194
195
  // needed for private transfers via FPC
195
196
  {
196
197
  classId: getContractClassFromArtifact(TokenContractArtifact).id,
197
- selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'),
198
+ // We can't restrict the selector because public functions get routed via dispatch.
199
+ // selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'),
198
200
  },
199
201
  {
200
202
  classId: getContractClassFromArtifact(FPCContract.artifact).id,
201
- selector: FunctionSelector.fromSignature('prepare_fee((Field),Field,(Field),Field)'),
203
+ // We can't restrict the selector because public functions get routed via dispatch.
204
+ // selector: FunctionSelector.fromSignature('prepare_fee((Field),Field,(Field),Field)'),
202
205
  },
203
206
  ];
204
207
  }
@@ -39,6 +39,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
39
39
  this.publicClient = createPublicClient({
40
40
  chain: chain.chainInfo,
41
41
  transport: http(chain.rpcUrl),
42
+ pollingInterval: config.viemPollingIntervalMS,
42
43
  });
43
44
 
44
45
  this.rollupContract = getContract({
@@ -1,5 +1,5 @@
1
1
  import { type L1ReaderConfig, NULL_KEY } from '@aztec/ethereum';
2
- import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
2
+ import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
3
3
 
4
4
  /**
5
5
  * The configuration of the rollup transaction publisher.
@@ -51,6 +51,11 @@ export const getTxSenderConfigMappings: (
51
51
  defaultValue: 1,
52
52
  description: 'The number of confirmations required.',
53
53
  },
54
+ viemPollingIntervalMS: {
55
+ env: `${scope}_VIEM_POLLING_INTERVAL_MS`,
56
+ description: 'The polling interval viem uses in ms',
57
+ ...numberConfigHelper(1_000),
58
+ },
54
59
  });
55
60
 
56
61
  export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSenderConfig, 'l1Contracts'> {
@@ -1,2 +1,2 @@
1
- export { L1Publisher } from './l1-publisher.js';
1
+ export { L1Publisher, L1SubmitEpochProofArgs } from './l1-publisher.js';
2
2
  export * from './config.js';