@aztec/sequencer-client 0.0.0-test.1 → 0.0.1-commit.03f7ef2

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 (141) hide show
  1. package/dest/client/index.d.ts +1 -1
  2. package/dest/client/sequencer-client.d.ts +30 -29
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +82 -60
  5. package/dest/config.d.ts +15 -16
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +113 -70
  8. package/dest/global_variable_builder/global_builder.d.ts +25 -14
  9. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  10. package/dest/global_variable_builder/global_builder.js +60 -42
  11. package/dest/global_variable_builder/index.d.ts +1 -1
  12. package/dest/index.d.ts +2 -3
  13. package/dest/index.d.ts.map +1 -1
  14. package/dest/index.js +1 -2
  15. package/dest/publisher/config.d.ts +15 -12
  16. package/dest/publisher/config.d.ts.map +1 -1
  17. package/dest/publisher/config.js +32 -19
  18. package/dest/publisher/index.d.ts +3 -1
  19. package/dest/publisher/index.d.ts.map +1 -1
  20. package/dest/publisher/index.js +3 -0
  21. package/dest/publisher/sequencer-publisher-factory.d.ts +44 -0
  22. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
  23. package/dest/publisher/sequencer-publisher-factory.js +51 -0
  24. package/dest/publisher/sequencer-publisher-metrics.d.ts +5 -4
  25. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  26. package/dest/publisher/sequencer-publisher-metrics.js +37 -2
  27. package/dest/publisher/sequencer-publisher.d.ts +132 -86
  28. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  29. package/dest/publisher/sequencer-publisher.js +755 -248
  30. package/dest/sequencer/block_builder.d.ts +26 -0
  31. package/dest/sequencer/block_builder.d.ts.map +1 -0
  32. package/dest/sequencer/block_builder.js +129 -0
  33. package/dest/sequencer/checkpoint_builder.d.ts +63 -0
  34. package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
  35. package/dest/sequencer/checkpoint_builder.js +131 -0
  36. package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
  37. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  38. package/dest/sequencer/checkpoint_proposal_job.js +640 -0
  39. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  40. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  41. package/dest/sequencer/checkpoint_voter.js +85 -0
  42. package/dest/sequencer/config.d.ts +7 -1
  43. package/dest/sequencer/config.d.ts.map +1 -1
  44. package/dest/sequencer/errors.d.ts +11 -0
  45. package/dest/sequencer/errors.d.ts.map +1 -0
  46. package/dest/sequencer/errors.js +15 -0
  47. package/dest/sequencer/events.d.ts +46 -0
  48. package/dest/sequencer/events.d.ts.map +1 -0
  49. package/dest/sequencer/events.js +1 -0
  50. package/dest/sequencer/index.d.ts +6 -2
  51. package/dest/sequencer/index.d.ts.map +1 -1
  52. package/dest/sequencer/index.js +5 -1
  53. package/dest/sequencer/metrics.d.ts +48 -12
  54. package/dest/sequencer/metrics.d.ts.map +1 -1
  55. package/dest/sequencer/metrics.js +274 -48
  56. package/dest/sequencer/sequencer.d.ts +132 -135
  57. package/dest/sequencer/sequencer.d.ts.map +1 -1
  58. package/dest/sequencer/sequencer.js +519 -521
  59. package/dest/sequencer/timetable.d.ts +76 -24
  60. package/dest/sequencer/timetable.d.ts.map +1 -1
  61. package/dest/sequencer/timetable.js +177 -61
  62. package/dest/sequencer/types.d.ts +3 -0
  63. package/dest/sequencer/types.d.ts.map +1 -0
  64. package/dest/sequencer/types.js +1 -0
  65. package/dest/sequencer/utils.d.ts +20 -38
  66. package/dest/sequencer/utils.d.ts.map +1 -1
  67. package/dest/sequencer/utils.js +12 -47
  68. package/dest/test/index.d.ts +10 -1
  69. package/dest/test/index.d.ts.map +1 -1
  70. package/dest/test/index.js +0 -4
  71. package/dest/test/mock_checkpoint_builder.d.ts +83 -0
  72. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  73. package/dest/test/mock_checkpoint_builder.js +179 -0
  74. package/dest/test/utils.d.ts +49 -0
  75. package/dest/test/utils.d.ts.map +1 -0
  76. package/dest/test/utils.js +94 -0
  77. package/dest/tx_validator/nullifier_cache.d.ts +1 -3
  78. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
  79. package/dest/tx_validator/tx_validator_factory.d.ts +11 -11
  80. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  81. package/dest/tx_validator/tx_validator_factory.js +28 -25
  82. package/package.json +45 -45
  83. package/src/client/sequencer-client.ts +105 -105
  84. package/src/config.ts +126 -81
  85. package/src/global_variable_builder/global_builder.ts +82 -53
  86. package/src/index.ts +8 -2
  87. package/src/publisher/config.ts +45 -32
  88. package/src/publisher/index.ts +4 -0
  89. package/src/publisher/sequencer-publisher-factory.ts +92 -0
  90. package/src/publisher/sequencer-publisher-metrics.ts +26 -4
  91. package/src/publisher/sequencer-publisher.ts +955 -293
  92. package/src/sequencer/README.md +531 -0
  93. package/src/sequencer/block_builder.ts +217 -0
  94. package/src/sequencer/checkpoint_builder.ts +217 -0
  95. package/src/sequencer/checkpoint_proposal_job.ts +703 -0
  96. package/src/sequencer/checkpoint_voter.ts +105 -0
  97. package/src/sequencer/config.ts +8 -0
  98. package/src/sequencer/errors.ts +21 -0
  99. package/src/sequencer/events.ts +27 -0
  100. package/src/sequencer/index.ts +5 -1
  101. package/src/sequencer/metrics.ts +355 -50
  102. package/src/sequencer/sequencer.ts +631 -594
  103. package/src/sequencer/timetable.ts +221 -62
  104. package/src/sequencer/types.ts +6 -0
  105. package/src/sequencer/utils.ts +28 -60
  106. package/src/test/index.ts +13 -4
  107. package/src/test/mock_checkpoint_builder.ts +247 -0
  108. package/src/test/utils.ts +137 -0
  109. package/src/tx_validator/tx_validator_factory.ts +46 -33
  110. package/dest/sequencer/allowed.d.ts +0 -3
  111. package/dest/sequencer/allowed.d.ts.map +0 -1
  112. package/dest/sequencer/allowed.js +0 -27
  113. package/dest/slasher/factory.d.ts +0 -7
  114. package/dest/slasher/factory.d.ts.map +0 -1
  115. package/dest/slasher/factory.js +0 -8
  116. package/dest/slasher/index.d.ts +0 -3
  117. package/dest/slasher/index.d.ts.map +0 -1
  118. package/dest/slasher/index.js +0 -2
  119. package/dest/slasher/slasher_client.d.ts +0 -75
  120. package/dest/slasher/slasher_client.d.ts.map +0 -1
  121. package/dest/slasher/slasher_client.js +0 -132
  122. package/dest/tx_validator/archive_cache.d.ts +0 -14
  123. package/dest/tx_validator/archive_cache.d.ts.map +0 -1
  124. package/dest/tx_validator/archive_cache.js +0 -22
  125. package/dest/tx_validator/gas_validator.d.ts +0 -14
  126. package/dest/tx_validator/gas_validator.d.ts.map +0 -1
  127. package/dest/tx_validator/gas_validator.js +0 -78
  128. package/dest/tx_validator/phases_validator.d.ts +0 -12
  129. package/dest/tx_validator/phases_validator.d.ts.map +0 -1
  130. package/dest/tx_validator/phases_validator.js +0 -80
  131. package/dest/tx_validator/test_utils.d.ts +0 -23
  132. package/dest/tx_validator/test_utils.d.ts.map +0 -1
  133. package/dest/tx_validator/test_utils.js +0 -26
  134. package/src/sequencer/allowed.ts +0 -36
  135. package/src/slasher/factory.ts +0 -15
  136. package/src/slasher/index.ts +0 -2
  137. package/src/slasher/slasher_client.ts +0 -193
  138. package/src/tx_validator/archive_cache.ts +0 -28
  139. package/src/tx_validator/gas_validator.ts +0 -101
  140. package/src/tx_validator/phases_validator.ts +0 -98
  141. package/src/tx_validator/test_utils.ts +0 -48
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.0.0-test.1",
3
+ "version": "0.0.1-commit.03f7ef2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -18,63 +18,59 @@
18
18
  "../package.common.json"
19
19
  ],
20
20
  "scripts": {
21
- "build": "yarn clean && tsc -b",
22
- "build:dev": "tsc -b --watch",
21
+ "build": "yarn clean && ../scripts/tsc.sh",
22
+ "build:dev": "../scripts/tsc.sh --watch",
23
23
  "clean": "rm -rf ./dest .tsbuildinfo",
24
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
25
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
26
24
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
27
25
  "test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
28
26
  "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
29
27
  },
30
28
  "dependencies": {
31
- "@aztec/aztec.js": "0.0.0-test.1",
32
- "@aztec/bb-prover": "0.0.0-test.1",
33
- "@aztec/blob-lib": "0.0.0-test.1",
34
- "@aztec/blob-sink": "0.0.0-test.1",
35
- "@aztec/constants": "0.0.0-test.1",
36
- "@aztec/epoch-cache": "0.0.0-test.1",
37
- "@aztec/ethereum": "0.0.0-test.1",
38
- "@aztec/foundation": "0.0.0-test.1",
39
- "@aztec/l1-artifacts": "0.0.0-test.1",
40
- "@aztec/merkle-tree": "0.0.0-test.1",
41
- "@aztec/noir-contracts.js": "0.0.0-test.1",
42
- "@aztec/noir-protocol-circuits-types": "0.0.0-test.1",
43
- "@aztec/p2p": "0.0.0-test.1",
44
- "@aztec/protocol-contracts": "0.0.0-test.1",
45
- "@aztec/prover-client": "0.0.0-test.1",
46
- "@aztec/simulator": "0.0.0-test.1",
47
- "@aztec/stdlib": "0.0.0-test.1",
48
- "@aztec/telemetry-client": "0.0.0-test.1",
49
- "@aztec/validator-client": "0.0.0-test.1",
50
- "@aztec/world-state": "0.0.0-test.1",
29
+ "@aztec/aztec.js": "0.0.1-commit.03f7ef2",
30
+ "@aztec/bb-prover": "0.0.1-commit.03f7ef2",
31
+ "@aztec/blob-client": "0.0.1-commit.03f7ef2",
32
+ "@aztec/blob-lib": "0.0.1-commit.03f7ef2",
33
+ "@aztec/constants": "0.0.1-commit.03f7ef2",
34
+ "@aztec/epoch-cache": "0.0.1-commit.03f7ef2",
35
+ "@aztec/ethereum": "0.0.1-commit.03f7ef2",
36
+ "@aztec/foundation": "0.0.1-commit.03f7ef2",
37
+ "@aztec/l1-artifacts": "0.0.1-commit.03f7ef2",
38
+ "@aztec/merkle-tree": "0.0.1-commit.03f7ef2",
39
+ "@aztec/node-keystore": "0.0.1-commit.03f7ef2",
40
+ "@aztec/noir-acvm_js": "0.0.1-commit.03f7ef2",
41
+ "@aztec/noir-contracts.js": "0.0.1-commit.03f7ef2",
42
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.03f7ef2",
43
+ "@aztec/noir-types": "0.0.1-commit.03f7ef2",
44
+ "@aztec/p2p": "0.0.1-commit.03f7ef2",
45
+ "@aztec/protocol-contracts": "0.0.1-commit.03f7ef2",
46
+ "@aztec/prover-client": "0.0.1-commit.03f7ef2",
47
+ "@aztec/simulator": "0.0.1-commit.03f7ef2",
48
+ "@aztec/slasher": "0.0.1-commit.03f7ef2",
49
+ "@aztec/stdlib": "0.0.1-commit.03f7ef2",
50
+ "@aztec/telemetry-client": "0.0.1-commit.03f7ef2",
51
+ "@aztec/validator-client": "0.0.1-commit.03f7ef2",
52
+ "@aztec/world-state": "0.0.1-commit.03f7ef2",
51
53
  "lodash.chunk": "^4.2.0",
52
- "lodash.pick": "^4.4.0",
53
54
  "tslib": "^2.4.0",
54
- "viem": "2.22.8",
55
- "@aztec/noir-acvm_js": "0.0.0-test.1",
56
- "@aztec/noir-types": "0.0.0-test.1"
55
+ "viem": "npm:@aztec/viem@2.38.2"
57
56
  },
58
57
  "devDependencies": {
59
- "@aztec/archiver": "0.0.0-test.1",
60
- "@aztec/kv-store": "0.0.0-test.1",
61
- "@jest/globals": "^29.5.0",
62
- "@types/jest": "^29.5.0",
63
- "@types/levelup": "^5.1.2",
58
+ "@aztec/archiver": "0.0.1-commit.03f7ef2",
59
+ "@aztec/kv-store": "0.0.1-commit.03f7ef2",
60
+ "@jest/globals": "^30.0.0",
61
+ "@types/jest": "^30.0.0",
64
62
  "@types/lodash.chunk": "^4.2.7",
65
63
  "@types/lodash.pick": "^4.4.7",
66
- "@types/memdown": "^3.0.0",
67
- "@types/node": "^18.7.23",
64
+ "@types/node": "^22.15.17",
65
+ "@typescript/native-preview": "7.0.0-dev.20251126.1",
68
66
  "concurrently": "^7.6.0",
69
- "eslint": "^8.37.0",
70
- "express": "^4.21.1",
71
- "jest": "^29.5.0",
72
- "jest-mock-extended": "^3.0.3",
73
- "levelup": "^5.1.1",
74
- "memdown": "^6.1.1",
75
- "prettier": "^2.8.7",
67
+ "eslint": "^9.26.0",
68
+ "express": "^4.21.2",
69
+ "jest": "^30.0.0",
70
+ "jest-mock-extended": "^4.0.0",
71
+ "prettier": "^3.5.3",
76
72
  "ts-node": "^10.9.1",
77
- "typescript": "^5.0.4"
73
+ "typescript": "^5.3.3"
78
74
  },
79
75
  "files": [
80
76
  "dest",
@@ -83,7 +79,7 @@
83
79
  ],
84
80
  "types": "./dest/index.d.ts",
85
81
  "engines": {
86
- "node": ">=18"
82
+ "node": ">=20.10"
87
83
  },
88
84
  "jest": {
89
85
  "extensionsToTreatAsEsm": [
@@ -116,6 +112,10 @@
116
112
  "testTimeout": 120000,
117
113
  "setupFiles": [
118
114
  "../../foundation/src/jest/setup.mjs"
115
+ ],
116
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
117
+ "setupFilesAfterEnv": [
118
+ "../../foundation/src/jest/setupAfterEnv.mjs"
119
119
  ]
120
120
  }
121
121
  }
@@ -1,43 +1,43 @@
1
- import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
1
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
2
2
  import { EpochCache } from '@aztec/epoch-cache';
3
- import {
4
- ForwarderContract,
5
- GovernanceProposerContract,
6
- RollupContract,
7
- SlashingProposerContract,
8
- createEthereumChain,
9
- createL1Clients,
10
- isAnvilTestChain,
11
- } from '@aztec/ethereum';
3
+ import { isAnvilTestChain } from '@aztec/ethereum/chain';
4
+ import { getPublicClient } from '@aztec/ethereum/client';
5
+ import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
12
6
  import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
7
+ import { PublisherManager } from '@aztec/ethereum/publisher-manager';
13
8
  import { EthAddress } from '@aztec/foundation/eth-address';
14
9
  import { createLogger } from '@aztec/foundation/log';
15
10
  import type { DateProvider } from '@aztec/foundation/timer';
11
+ import type { KeystoreManager } from '@aztec/node-keystore';
16
12
  import type { P2P } from '@aztec/p2p';
17
- import { LightweightBlockBuilderFactory } from '@aztec/prover-client/block-builder';
18
- import { PublicProcessorFactory } from '@aztec/simulator/server';
19
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
13
+ import type { SlasherClientInterface } from '@aztec/slasher';
20
14
  import type { L2BlockSource } from '@aztec/stdlib/block';
21
- import type { ContractDataSource } from '@aztec/stdlib/contract';
22
- import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
15
+ import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
16
+ import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
23
17
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
24
- import type { TelemetryClient } from '@aztec/telemetry-client';
25
- import type { ValidatorClient } from '@aztec/validator-client';
18
+ import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
19
+ import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
26
20
 
27
21
  import type { SequencerClientConfig } from '../config.js';
28
22
  import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
29
- import { SequencerPublisher } from '../publisher/index.js';
23
+ import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
24
+ import { FullNodeCheckpointsBuilder } from '../sequencer/checkpoint_builder.js';
30
25
  import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
31
- import type { SlasherClient } from '../slasher/index.js';
32
26
 
33
27
  /**
34
28
  * Encapsulates the full sequencer and publisher.
35
29
  */
36
30
  export class SequencerClient {
37
- constructor(protected sequencer: Sequencer) {}
31
+ constructor(
32
+ protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
33
+ protected sequencer: Sequencer,
34
+ protected checkpointsBuilder: FullNodeCheckpointsBuilder,
35
+ protected validatorClient?: ValidatorClient,
36
+ private l1Metrics?: L1Metrics,
37
+ ) {}
38
38
 
39
39
  /**
40
- * Initializes and starts a new instance.
40
+ * Initializes a new instance.
41
41
  * @param config - Configuration for the sequencer, publisher, and L1 tx sender.
42
42
  * @param p2pClient - P2P client that provides the txs to be sequenced.
43
43
  * @param validatorClient - Validator client performs attestation duties when rotating proposers.
@@ -46,25 +46,25 @@ export class SequencerClient {
46
46
  * @param l2BlockSource - Provides information about the previously published blocks.
47
47
  * @param l1ToL2MessageSource - Provides access to L1 to L2 messages.
48
48
  * @param prover - An instance of a block prover
49
- * @param simulationProvider - An instance of a simulation provider
50
49
  * @returns A new running instance.
51
50
  */
52
51
  public static async new(
53
52
  config: SequencerClientConfig,
54
53
  deps: {
55
- validatorClient: ValidatorClient | undefined; // allowed to be undefined while we migrate
54
+ validatorClient: ValidatorClient;
56
55
  p2pClient: P2P;
57
56
  worldStateSynchronizer: WorldStateSynchronizer;
58
- slasherClient: SlasherClient;
59
- contractDataSource: ContractDataSource;
57
+ slasherClient: SlasherClientInterface | undefined;
58
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
60
59
  l2BlockSource: L2BlockSource;
61
60
  l1ToL2MessageSource: L1ToL2MessageSource;
62
61
  telemetry: TelemetryClient;
63
- publisher?: SequencerPublisher;
64
- blobSinkClient?: BlobSinkClientInterface;
62
+ publisherFactory?: SequencerPublisherFactory;
63
+ blobClient?: BlobClientInterface;
65
64
  dateProvider: DateProvider;
66
65
  epochCache?: EpochCache;
67
- l1TxUtils?: L1TxUtilsWithBlobs;
66
+ l1TxUtils: L1TxUtilsWithBlobs[];
67
+ nodeKeyStore: KeystoreManager;
68
68
  },
69
69
  ) {
70
70
  const {
@@ -72,42 +72,33 @@ export class SequencerClient {
72
72
  p2pClient,
73
73
  worldStateSynchronizer,
74
74
  slasherClient,
75
- contractDataSource,
75
+ checkpointsBuilder,
76
76
  l2BlockSource,
77
77
  l1ToL2MessageSource,
78
78
  telemetry: telemetryClient,
79
79
  } = deps;
80
- const { l1RpcUrls: rpcUrls, l1ChainId: chainId, publisherPrivateKey } = config;
81
- const chain = createEthereumChain(rpcUrls, chainId);
82
- const log = createLogger('sequencer-client');
83
- const { publicClient, walletClient } = createL1Clients(rpcUrls, publisherPrivateKey, chain.chainInfo);
84
- const l1TxUtils = deps.l1TxUtils ?? new L1TxUtilsWithBlobs(publicClient, walletClient, log, config);
80
+ const { l1RpcUrls: rpcUrls, l1ChainId: chainId } = config;
81
+ const log = createLogger('sequencer');
82
+ const publicClient = getPublicClient(config);
83
+ const l1TxUtils = deps.l1TxUtils;
84
+ const l1Metrics = new L1Metrics(
85
+ telemetryClient.getMeter('L1PublisherMetrics'),
86
+ publicClient,
87
+ l1TxUtils.map(x => x.getSenderAddress()),
88
+ );
89
+ const publisherManager = new PublisherManager(l1TxUtils, config);
85
90
  const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
86
- const [l1GenesisTime, slotDuration] = await Promise.all([
91
+ const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
87
92
  rollupContract.getL1GenesisTime(),
88
93
  rollupContract.getSlotDuration(),
94
+ rollupContract.getVersion(),
95
+ rollupContract.getManaLimit().then(Number),
89
96
  ] as const);
90
- const forwarderContract =
91
- config.customForwarderContractAddress && config.customForwarderContractAddress !== EthAddress.ZERO
92
- ? new ForwarderContract(
93
- publicClient,
94
- config.customForwarderContractAddress.toString(),
95
- config.l1Contracts.rollupAddress.toString(),
96
- )
97
- : await ForwarderContract.create(
98
- walletClient.account.address,
99
- walletClient,
100
- publicClient,
101
- log,
102
- config.l1Contracts.rollupAddress.toString(),
103
- );
104
97
 
105
98
  const governanceProposerContract = new GovernanceProposerContract(
106
99
  publicClient,
107
100
  config.l1Contracts.governanceProposerAddress.toString(),
108
101
  );
109
- const slashingProposerAddress = await rollupContract.getSlashingProposerAddress();
110
- const slashingProposerContract = new SlashingProposerContract(publicClient, slashingProposerAddress.toString());
111
102
  const epochCache =
112
103
  deps.epochCache ??
113
104
  (await EpochCache.create(
@@ -116,74 +107,92 @@ export class SequencerClient {
116
107
  l1RpcUrls: rpcUrls,
117
108
  l1ChainId: chainId,
118
109
  viemPollingIntervalMS: config.viemPollingIntervalMS,
119
- aztecSlotDuration: config.aztecSlotDuration,
120
110
  ethereumSlotDuration: config.ethereumSlotDuration,
121
- aztecEpochDuration: config.aztecEpochDuration,
122
111
  },
123
112
  { dateProvider: deps.dateProvider },
124
113
  ));
125
114
 
126
- const publisher =
127
- deps.publisher ??
128
- new SequencerPublisher(config, {
129
- l1TxUtils,
115
+ const slashFactoryContract = new SlashFactoryContract(
116
+ publicClient,
117
+ config.l1Contracts.slashFactoryAddress?.toString() ?? EthAddress.ZERO.toString(),
118
+ );
119
+
120
+ const publisherFactory =
121
+ deps.publisherFactory ??
122
+ new SequencerPublisherFactory(config, {
130
123
  telemetry: telemetryClient,
131
- blobSinkClient: deps.blobSinkClient,
132
- rollupContract,
124
+ blobClient: deps.blobClient,
133
125
  epochCache,
134
- forwarderContract,
135
126
  governanceProposerContract,
136
- slashingProposerContract,
127
+ slashFactoryContract,
128
+ rollupContract,
129
+ dateProvider: deps.dateProvider,
130
+ publisherManager,
131
+ nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
132
+ logger: log,
137
133
  });
138
- const globalsBuilder = new GlobalVariableBuilder(config);
139
-
140
- const publicProcessorFactory = new PublicProcessorFactory(contractDataSource, deps.dateProvider, telemetryClient);
141
134
 
142
135
  const ethereumSlotDuration = config.ethereumSlotDuration;
136
+ const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
137
+
138
+ const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
143
139
 
144
- // When running in anvil, assume we can post a tx up until the very last second of an L1 slot.
145
- // Otherwise, assume we must have broadcasted the tx before the slot started (we use a default
146
- // maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
140
+ let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
141
+ if (sequencerManaLimit > rollupManaLimit) {
142
+ log.warn(
143
+ `Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
144
+ );
145
+ sequencerManaLimit = rollupManaLimit;
146
+ }
147
+
148
+ // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
149
+ // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
147
150
  // In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
148
- // make it with a propagation time into slot equal to 4s. However, we prefer being conservative.
151
+ // reduce the publishing time allowance. However, we prefer being conservative.
149
152
  // See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
150
- const maxL1TxInclusionTimeIntoSlot =
151
- config.maxL1TxInclusionTimeIntoSlot ?? isAnvilTestChain(config.l1ChainId) ? ethereumSlotDuration : 0;
152
-
153
- const l1Constants = {
154
- l1GenesisTime,
155
- slotDuration: Number(slotDuration),
156
- ethereumSlotDuration,
157
- };
153
+ const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
154
+ const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
158
155
 
159
156
  const sequencer = new Sequencer(
160
- publisher,
157
+ publisherFactory,
161
158
  validatorClient,
162
159
  globalsBuilder,
163
160
  p2pClient,
164
161
  worldStateSynchronizer,
165
162
  slasherClient,
166
- new LightweightBlockBuilderFactory(telemetryClient),
167
163
  l2BlockSource,
168
164
  l1ToL2MessageSource,
169
- publicProcessorFactory,
170
- contractDataSource,
165
+ checkpointsBuilder,
171
166
  l1Constants,
172
167
  deps.dateProvider,
173
- { ...config, maxL1TxInclusionTimeIntoSlot },
168
+ epochCache,
169
+ rollupContract,
170
+ { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
174
171
  telemetryClient,
172
+ log,
175
173
  );
176
- await validatorClient?.start();
177
- await sequencer.start();
178
- return new SequencerClient(sequencer);
174
+
175
+ await sequencer.init();
176
+
177
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
179
178
  }
180
179
 
181
180
  /**
182
- * Updates sequencer config.
181
+ * Updates sequencer and validator client config.
183
182
  * @param config - New parameters.
184
183
  */
185
- public updateSequencerConfig(config: SequencerConfig) {
186
- return this.sequencer.updateConfig(config);
184
+ public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
185
+ this.sequencer.updateConfig(config);
186
+ this.checkpointsBuilder.updateConfig(config);
187
+ this.validatorClient?.updateConfig(config);
188
+ }
189
+
190
+ /** Starts the sequencer. */
191
+ public async start() {
192
+ await this.validatorClient?.start();
193
+ this.sequencer.start();
194
+ this.l1Metrics?.start();
195
+ await this.publisherManager.loadState();
187
196
  }
188
197
 
189
198
  /**
@@ -191,29 +200,20 @@ export class SequencerClient {
191
200
  */
192
201
  public async stop() {
193
202
  await this.sequencer.stop();
203
+ await this.validatorClient?.stop();
204
+ this.publisherManager.interrupt();
205
+ this.l1Metrics?.stop();
194
206
  }
195
207
 
196
- /** Forces the sequencer to bypass all time and tx count checks for the next block and build anyway. */
197
- public flush() {
198
- this.sequencer.flush();
199
- }
200
-
201
- /**
202
- * Restarts the sequencer after being stopped.
203
- */
204
- public restart() {
205
- this.sequencer.restart();
206
- }
207
-
208
- get coinbase(): EthAddress {
209
- return this.sequencer.coinbase;
208
+ public getSequencer(): Sequencer {
209
+ return this.sequencer;
210
210
  }
211
211
 
212
- get feeRecipient(): AztecAddress {
213
- return this.sequencer.feeRecipient;
212
+ get validatorAddresses(): EthAddress[] | undefined {
213
+ return this.sequencer.getValidatorAddresses();
214
214
  }
215
215
 
216
- get forwarderAddress(): EthAddress {
217
- return this.sequencer.getForwarderAddress();
216
+ get maxL2BlockGas(): number | undefined {
217
+ return this.sequencer.maxL2BlockGas;
218
218
  }
219
219
  }