@aztec/sequencer-client 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec

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 (102) hide show
  1. package/dest/client/index.d.ts +1 -1
  2. package/dest/client/sequencer-client.d.ts +10 -9
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +32 -24
  5. package/dest/config.d.ts +12 -5
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +75 -28
  8. package/dest/global_variable_builder/global_builder.d.ts +19 -13
  9. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  10. package/dest/global_variable_builder/global_builder.js +41 -28
  11. package/dest/global_variable_builder/index.d.ts +1 -1
  12. package/dest/index.d.ts +2 -2
  13. package/dest/index.d.ts.map +1 -1
  14. package/dest/index.js +1 -1
  15. package/dest/publisher/config.d.ts +9 -4
  16. package/dest/publisher/config.d.ts.map +1 -1
  17. package/dest/publisher/config.js +14 -3
  18. package/dest/publisher/index.d.ts +1 -1
  19. package/dest/publisher/sequencer-publisher-factory.d.ts +5 -4
  20. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  21. package/dest/publisher/sequencer-publisher-factory.js +1 -1
  22. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  23. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  24. package/dest/publisher/sequencer-publisher.d.ts +66 -53
  25. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  26. package/dest/publisher/sequencer-publisher.js +230 -120
  27. package/dest/sequencer/block_builder.d.ts +4 -5
  28. package/dest/sequencer/block_builder.d.ts.map +1 -1
  29. package/dest/sequencer/block_builder.js +9 -10
  30. package/dest/sequencer/checkpoint_builder.d.ts +63 -0
  31. package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
  32. package/dest/sequencer/checkpoint_builder.js +131 -0
  33. package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
  34. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  35. package/dest/sequencer/checkpoint_proposal_job.js +642 -0
  36. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  37. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  38. package/dest/sequencer/checkpoint_voter.js +85 -0
  39. package/dest/sequencer/config.d.ts +3 -2
  40. package/dest/sequencer/config.d.ts.map +1 -1
  41. package/dest/sequencer/errors.d.ts +1 -1
  42. package/dest/sequencer/errors.d.ts.map +1 -1
  43. package/dest/sequencer/events.d.ts +46 -0
  44. package/dest/sequencer/events.d.ts.map +1 -0
  45. package/dest/sequencer/events.js +1 -0
  46. package/dest/sequencer/index.d.ts +5 -1
  47. package/dest/sequencer/index.d.ts.map +1 -1
  48. package/dest/sequencer/index.js +4 -0
  49. package/dest/sequencer/metrics.d.ts +32 -3
  50. package/dest/sequencer/metrics.d.ts.map +1 -1
  51. package/dest/sequencer/metrics.js +192 -0
  52. package/dest/sequencer/sequencer.d.ts +96 -138
  53. package/dest/sequencer/sequencer.d.ts.map +1 -1
  54. package/dest/sequencer/sequencer.js +247 -479
  55. package/dest/sequencer/timetable.d.ts +54 -14
  56. package/dest/sequencer/timetable.d.ts.map +1 -1
  57. package/dest/sequencer/timetable.js +148 -59
  58. package/dest/sequencer/types.d.ts +3 -0
  59. package/dest/sequencer/types.d.ts.map +1 -0
  60. package/dest/sequencer/types.js +1 -0
  61. package/dest/sequencer/utils.d.ts +14 -8
  62. package/dest/sequencer/utils.d.ts.map +1 -1
  63. package/dest/sequencer/utils.js +7 -4
  64. package/dest/test/index.d.ts +4 -2
  65. package/dest/test/index.d.ts.map +1 -1
  66. package/dest/test/mock_checkpoint_builder.d.ts +83 -0
  67. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  68. package/dest/test/mock_checkpoint_builder.js +179 -0
  69. package/dest/test/utils.d.ts +49 -0
  70. package/dest/test/utils.d.ts.map +1 -0
  71. package/dest/test/utils.js +94 -0
  72. package/dest/tx_validator/nullifier_cache.d.ts +1 -1
  73. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
  74. package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
  75. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  76. package/dest/tx_validator/tx_validator_factory.js +1 -1
  77. package/package.json +31 -30
  78. package/src/client/sequencer-client.ts +28 -38
  79. package/src/config.ts +81 -32
  80. package/src/global_variable_builder/global_builder.ts +56 -48
  81. package/src/index.ts +2 -0
  82. package/src/publisher/config.ts +20 -9
  83. package/src/publisher/sequencer-publisher-factory.ts +7 -5
  84. package/src/publisher/sequencer-publisher-metrics.ts +2 -2
  85. package/src/publisher/sequencer-publisher.ts +328 -161
  86. package/src/sequencer/README.md +531 -0
  87. package/src/sequencer/block_builder.ts +12 -13
  88. package/src/sequencer/checkpoint_builder.ts +217 -0
  89. package/src/sequencer/checkpoint_proposal_job.ts +706 -0
  90. package/src/sequencer/checkpoint_voter.ts +105 -0
  91. package/src/sequencer/config.ts +2 -1
  92. package/src/sequencer/events.ts +27 -0
  93. package/src/sequencer/index.ts +4 -0
  94. package/src/sequencer/metrics.ts +254 -3
  95. package/src/sequencer/sequencer.ts +360 -674
  96. package/src/sequencer/timetable.ts +173 -79
  97. package/src/sequencer/types.ts +6 -0
  98. package/src/sequencer/utils.ts +18 -9
  99. package/src/test/index.ts +3 -1
  100. package/src/test/mock_checkpoint_builder.ts +247 -0
  101. package/src/test/utils.ts +137 -0
  102. package/src/tx_validator/tx_validator_factory.ts +3 -2
package/src/config.ts CHANGED
@@ -1,9 +1,5 @@
1
- import {
2
- type L1ContractsConfig,
3
- type L1ReaderConfig,
4
- l1ContractsConfigMappings,
5
- l1ReaderConfigMappings,
6
- } from '@aztec/ethereum';
1
+ import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
2
+ import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
7
3
  import {
8
4
  type ConfigMappingsType,
9
5
  booleanConfigHelper,
@@ -12,11 +8,12 @@ import {
12
8
  pickConfigMappings,
13
9
  } from '@aztec/foundation/config';
14
10
  import { EthAddress } from '@aztec/foundation/eth-address';
15
- import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore';
16
- import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p';
11
+ import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
12
+ import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
17
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
18
14
  import { type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
19
- import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client';
15
+ import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
16
+ import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
20
17
 
21
18
  import {
22
19
  type PublisherConfig,
@@ -30,6 +27,31 @@ export type { SequencerConfig };
30
27
 
31
28
  export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
32
29
 
30
+ /**
31
+ * Default values for SequencerConfig.
32
+ * Centralized location for all sequencer configuration defaults.
33
+ */
34
+ export const DefaultSequencerConfig: ResolvedSequencerConfig = {
35
+ sequencerPollingIntervalMS: 500,
36
+ maxTxsPerBlock: 32,
37
+ minTxsPerBlock: 1,
38
+ buildCheckpointIfEmpty: false,
39
+ publishTxsWithProposals: false,
40
+ maxL2BlockGas: 10e9,
41
+ maxDABlockGas: 10e9,
42
+ maxBlockSizeInBytes: 1024 * 1024,
43
+ enforceTimeTable: true,
44
+ attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
45
+ secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
46
+ secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
47
+ skipCollectingAttestations: false,
48
+ skipInvalidateBlockAsProposer: false,
49
+ broadcastInvalidBlockProposal: false,
50
+ injectFakeAttestation: false,
51
+ fishermanMode: false,
52
+ shuffleAttestationOrdering: false,
53
+ };
54
+
33
55
  /**
34
56
  * Configuration settings for the SequencerClient.
35
57
  */
@@ -44,35 +66,39 @@ export type SequencerClientConfig = PublisherConfig &
44
66
  Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
45
67
 
46
68
  export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
47
- transactionPollingIntervalMS: {
48
- env: 'SEQ_TX_POLLING_INTERVAL_MS',
49
- description: 'The number of ms to wait between polling for pending txs.',
50
- ...numberConfigHelper(500),
69
+ sequencerPollingIntervalMS: {
70
+ env: 'SEQ_POLLING_INTERVAL_MS',
71
+ description: 'The number of ms to wait between polling for checking to build on the next slot.',
72
+ ...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
51
73
  },
52
74
  maxTxsPerBlock: {
53
75
  env: 'SEQ_MAX_TX_PER_BLOCK',
54
76
  description: 'The maximum number of txs to include in a block.',
55
- ...numberConfigHelper(32),
77
+ ...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
56
78
  },
57
79
  minTxsPerBlock: {
58
80
  env: 'SEQ_MIN_TX_PER_BLOCK',
59
81
  description: 'The minimum number of txs to include in a block.',
60
- ...numberConfigHelper(1),
82
+ ...numberConfigHelper(DefaultSequencerConfig.minTxsPerBlock),
83
+ },
84
+ minValidTxsPerBlock: {
85
+ description:
86
+ 'The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock.',
61
87
  },
62
88
  publishTxsWithProposals: {
63
89
  env: 'SEQ_PUBLISH_TXS_WITH_PROPOSALS',
64
90
  description: 'Whether to publish txs with proposals.',
65
- ...booleanConfigHelper(false),
91
+ ...booleanConfigHelper(DefaultSequencerConfig.publishTxsWithProposals),
66
92
  },
67
93
  maxL2BlockGas: {
68
94
  env: 'SEQ_MAX_L2_BLOCK_GAS',
69
95
  description: 'The maximum L2 block gas.',
70
- ...numberConfigHelper(10e9),
96
+ ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
71
97
  },
72
98
  maxDABlockGas: {
73
99
  env: 'SEQ_MAX_DA_BLOCK_GAS',
74
100
  description: 'The maximum DA block gas.',
75
- ...numberConfigHelper(10e9),
101
+ ...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
76
102
  },
77
103
  coinbase: {
78
104
  env: 'COINBASE',
@@ -95,63 +121,86 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
95
121
  maxBlockSizeInBytes: {
96
122
  env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
97
123
  description: 'Max block size',
98
- ...numberConfigHelper(1024 * 1024),
124
+ ...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
99
125
  },
100
126
  enforceTimeTable: {
101
127
  env: 'SEQ_ENFORCE_TIME_TABLE',
102
128
  description: 'Whether to enforce the time table when building blocks',
103
- ...booleanConfigHelper(),
104
- defaultValue: true,
129
+ ...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable),
105
130
  },
106
131
  governanceProposerPayload: {
107
132
  env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
108
133
  description: 'The address of the payload for the governanceProposer',
109
134
  parseEnv: (val: string) => EthAddress.fromString(val),
110
- defaultValue: EthAddress.ZERO,
111
135
  },
112
- maxL1TxInclusionTimeIntoSlot: {
113
- env: 'SEQ_MAX_L1_TX_INCLUSION_TIME_INTO_SLOT',
114
- description: 'How many seconds into an L1 slot we can still send a tx and get it mined.',
136
+ l1PublishingTime: {
137
+ env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
138
+ description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
115
139
  parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
116
140
  },
117
141
  attestationPropagationTime: {
118
142
  env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
119
143
  description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
120
- ...numberConfigHelper(DEFAULT_ATTESTATION_PROPAGATION_TIME),
144
+ ...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
121
145
  },
122
146
  fakeProcessingDelayPerTxMs: {
123
147
  description: 'Used for testing to introduce a fake delay after processing each tx',
124
148
  },
149
+ fakeThrowAfterProcessingTxCount: {
150
+ description: 'Used for testing to throw an error after processing N txs',
151
+ },
125
152
  secondsBeforeInvalidatingBlockAsCommitteeMember: {
126
153
  env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER',
127
154
  description:
128
155
  'How many seconds to wait before trying to invalidate a block from the pending chain as a committee member (zero to never invalidate).' +
129
156
  ' The next proposer is expected to invalidate, so the committee acts as a fallback.',
130
- ...numberConfigHelper(144), // 12 L1 blocks
157
+ ...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsCommitteeMember),
131
158
  },
132
159
  secondsBeforeInvalidatingBlockAsNonCommitteeMember: {
133
160
  env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER',
134
161
  description:
135
162
  'How many seconds to wait before trying to invalidate a block from the pending chain as a non-committee member (zero to never invalidate).' +
136
163
  ' The next proposer is expected to invalidate, then the committee, so other sequencers act as a fallback.',
137
- ...numberConfigHelper(432), // 36 L1 blocks
164
+ ...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsNonCommitteeMember),
138
165
  },
139
166
  skipCollectingAttestations: {
140
167
  description:
141
168
  'Whether to skip collecting attestations from validators and only use self-attestations (for testing only)',
142
- ...booleanConfigHelper(false),
169
+ ...booleanConfigHelper(DefaultSequencerConfig.skipCollectingAttestations),
143
170
  },
144
171
  skipInvalidateBlockAsProposer: {
145
172
  description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
146
- ...booleanConfigHelper(false),
173
+ ...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
147
174
  },
148
175
  broadcastInvalidBlockProposal: {
149
176
  description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
150
- ...booleanConfigHelper(false),
177
+ ...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
151
178
  },
152
179
  injectFakeAttestation: {
153
180
  description: 'Inject a fake attestation (for testing only)',
154
- ...booleanConfigHelper(false),
181
+ ...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
182
+ },
183
+ fishermanMode: {
184
+ env: 'FISHERMAN_MODE',
185
+ description:
186
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
187
+ ...booleanConfigHelper(DefaultSequencerConfig.fishermanMode),
188
+ },
189
+ shuffleAttestationOrdering: {
190
+ description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
191
+ ...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
192
+ },
193
+ blockDurationMs: {
194
+ env: 'SEQ_BLOCK_DURATION_MS',
195
+ description:
196
+ 'Duration per block in milliseconds when building multiple blocks per slot. ' +
197
+ 'If undefined (default), builds a single block per slot using the full slot duration.',
198
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
199
+ },
200
+ buildCheckpointIfEmpty: {
201
+ env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
202
+ description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
203
+ ...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
155
204
  },
156
205
  ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
157
206
  };
@@ -1,16 +1,19 @@
1
- import {
2
- type L1ContractsConfig,
3
- type L1ReaderConfig,
4
- RollupContract,
5
- type ViemPublicClient,
6
- createEthereumChain,
7
- } from '@aztec/ethereum';
1
+ import { createEthereumChain } from '@aztec/ethereum/chain';
2
+ import type { L1ContractsConfig } from '@aztec/ethereum/config';
3
+ import { RollupContract } from '@aztec/ethereum/contracts';
4
+ import type { L1ReaderConfig } from '@aztec/ethereum/l1-reader';
5
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
6
+ import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
7
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
8
  import type { EthAddress } from '@aztec/foundation/eth-address';
9
- import { Fr } from '@aztec/foundation/fields';
10
9
  import { createLogger } from '@aztec/foundation/log';
11
10
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
11
+ import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
12
12
  import { GasFees } from '@aztec/stdlib/gas';
13
- import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
13
+ import type {
14
+ CheckpointGlobalVariables,
15
+ GlobalVariableBuilder as GlobalVariableBuilderInterface,
16
+ } from '@aztec/stdlib/tx';
14
17
  import { GlobalVariables } from '@aztec/stdlib/tx';
15
18
 
16
19
  import { createPublicClient, fallback, http } from 'viem';
@@ -26,20 +29,31 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
26
29
  private readonly rollupContract: RollupContract;
27
30
  private readonly publicClient: ViemPublicClient;
28
31
  private readonly ethereumSlotDuration: number;
32
+ private readonly aztecSlotDuration: number;
33
+ private readonly l1GenesisTime: bigint;
29
34
 
30
- private chainId?: Fr;
31
- private version?: Fr;
35
+ private chainId: Fr;
36
+ private version: Fr;
32
37
 
33
- constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>) {
38
+ constructor(
39
+ config: L1ReaderConfig &
40
+ Pick<L1ContractsConfig, 'ethereumSlotDuration'> &
41
+ Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
42
+ ) {
34
43
  const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
35
44
 
36
45
  const chain = createEthereumChain(l1RpcUrls, chainId);
37
46
 
47
+ this.version = new Fr(config.rollupVersion);
48
+ this.chainId = new Fr(chainId);
49
+
38
50
  this.ethereumSlotDuration = config.ethereumSlotDuration;
51
+ this.aztecSlotDuration = config.slotDuration;
52
+ this.l1GenesisTime = config.l1GenesisTime;
39
53
 
40
54
  this.publicClient = createPublicClient({
41
55
  chain: chain.chainInfo,
42
- transport: fallback(chain.rpcUrls.map(url => http(url))),
56
+ transport: fallback(chain.rpcUrls.map(url => http(url, { batch: false }))),
43
57
  pollingInterval: config.viemPollingIntervalMS,
44
58
  });
45
59
 
@@ -55,8 +69,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
55
69
  // we need to fetch the last block written, and estimate the earliest timestamp for the next block.
56
70
  // The timestamp of that last block will act as a lower bound for the next block.
57
71
 
58
- const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
59
- const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
72
+ const lastBlock = await this.rollupContract.getPendingCheckpoint();
73
+ const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
74
+ SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
75
+ );
60
76
  const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
61
77
  const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
62
78
 
@@ -75,18 +91,8 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
75
91
  return this.currentBaseFees;
76
92
  }
77
93
 
78
- public async getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>> {
79
- if (!this.chainId) {
80
- this.chainId = new Fr(this.publicClient.chain.id);
81
- }
82
- if (!this.version) {
83
- this.version = new Fr(await this.rollupContract.getVersion());
84
- }
85
- return { chainId: this.chainId, version: this.version };
86
- }
87
-
88
94
  /**
89
- * Simple builder of global variables that use the minimum time possible.
95
+ * Simple builder of global variables.
90
96
  * @param blockNumber - The block number to build global variables for.
91
97
  * @param coinbase - The address to receive block reward.
92
98
  * @param feeRecipient - The address to receive fees.
@@ -94,36 +100,38 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
94
100
  * @returns The global variables for the given block number.
95
101
  */
96
102
  public async buildGlobalVariables(
97
- blockNumber: number,
103
+ blockNumber: BlockNumber,
98
104
  coinbase: EthAddress,
99
105
  feeRecipient: AztecAddress,
100
- slotNumber?: bigint,
106
+ maybeSlot?: SlotNumber,
101
107
  ): Promise<GlobalVariables> {
102
- const { chainId, version } = await this.getGlobalConstantVariables();
103
-
104
- if (slotNumber === undefined) {
105
- const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
106
- slotNumber = await this.rollupContract.getSlotAt(ts);
107
- }
108
+ const slot: SlotNumber =
109
+ maybeSlot ??
110
+ (await this.rollupContract.getSlotAt(
111
+ BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)),
112
+ ));
113
+
114
+ const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
115
+ return GlobalVariables.from({ blockNumber, ...checkpointGlobalVariables });
116
+ }
108
117
 
109
- const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
118
+ /** Builds global variables that are constant throughout a checkpoint. */
119
+ public async buildCheckpointGlobalVariables(
120
+ coinbase: EthAddress,
121
+ feeRecipient: AztecAddress,
122
+ slotNumber: SlotNumber,
123
+ ): Promise<CheckpointGlobalVariables & { timestamp: bigint }> {
124
+ const { chainId, version } = this;
110
125
 
111
- const slotFr = new Fr(slotNumber);
126
+ const timestamp = getTimestampForSlot(slotNumber, {
127
+ slotDuration: this.aztecSlotDuration,
128
+ l1GenesisTime: this.l1GenesisTime,
129
+ });
112
130
 
113
131
  // We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
132
+ // TODO(palla/mbps): Can we use a cached value here?
114
133
  const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
115
134
 
116
- const globalVariables = new GlobalVariables(
117
- chainId,
118
- version,
119
- blockNumber,
120
- slotFr,
121
- timestamp,
122
- coinbase,
123
- feeRecipient,
124
- gasFees,
125
- );
126
-
127
- return globalVariables;
135
+ return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
128
136
  }
129
137
  }
package/src/index.ts CHANGED
@@ -3,6 +3,8 @@ export * from './config.js';
3
3
  export * from './publisher/index.js';
4
4
  export {
5
5
  FullNodeBlockBuilder as BlockBuilder,
6
+ FullNodeCheckpointsBuilder as CheckpointsBuilder,
7
+ CheckpointBuilder,
6
8
  Sequencer,
7
9
  SequencerState,
8
10
  type SequencerEvents,
@@ -1,10 +1,6 @@
1
- import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
2
- import {
3
- type L1ReaderConfig,
4
- type L1TxUtilsConfig,
5
- l1ReaderConfigMappings,
6
- l1TxUtilsConfigMappings,
7
- } from '@aztec/ethereum';
1
+ import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
2
+ import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
3
+ import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
8
4
  import {
9
5
  type ConfigMappingsType,
10
6
  SecretValue,
@@ -32,9 +28,13 @@ export type TxSenderConfig = L1ReaderConfig & {
32
28
  * Configuration of the L1Publisher.
33
29
  */
34
30
  export type PublisherConfig = L1TxUtilsConfig &
35
- BlobSinkConfig & {
31
+ BlobClientConfig & {
36
32
  /** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
37
33
  publisherAllowInvalidStates?: boolean;
34
+ /** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
35
+ fishermanMode?: boolean;
36
+ /** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
37
+ publisherForwarderAddress?: EthAddress;
38
38
  };
39
39
 
40
40
  export const getTxSenderConfigMappings: (
@@ -68,8 +68,19 @@ export const getPublisherConfigMappings: (
68
68
  env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
69
69
  ...booleanConfigHelper(true),
70
70
  },
71
+ fishermanMode: {
72
+ env: 'FISHERMAN_MODE',
73
+ description:
74
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
75
+ ...booleanConfigHelper(false),
76
+ },
77
+ publisherForwarderAddress: {
78
+ env: scope === `PROVER` ? `PROVER_PUBLISHER_FORWARDER_ADDRESS` : `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
79
+ description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
80
+ parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
81
+ },
71
82
  ...l1TxUtilsConfigMappings,
72
- ...blobSinkConfigMapping,
83
+ ...blobClientConfigMapping,
73
84
  });
74
85
 
75
86
  export function getPublisherConfigFromEnv(scope: 'PROVER' | 'SEQ'): PublisherConfig {
@@ -1,9 +1,11 @@
1
1
  import { EthAddress } from '@aztec/aztec.js/addresses';
2
2
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
- import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
3
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
4
4
  import type { EpochCache } from '@aztec/epoch-cache';
5
- import type { GovernanceProposerContract, PublisherFilter, PublisherManager, RollupContract } from '@aztec/ethereum';
5
+ import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
6
6
  import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
7
+ import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
8
+ import { SlotNumber } from '@aztec/foundation/branded-types';
7
9
  import type { DateProvider } from '@aztec/foundation/timer';
8
10
  import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
9
11
  import type { TelemetryClient } from '@aztec/telemetry-client';
@@ -22,7 +24,7 @@ export class SequencerPublisherFactory {
22
24
  private publisherMetrics: SequencerPublisherMetrics;
23
25
 
24
26
  /** Stores the last slot in which every action was carried out by a publisher */
25
- private lastActions: Partial<Record<Action, bigint>> = {};
27
+ private lastActions: Partial<Record<Action, SlotNumber>> = {};
26
28
 
27
29
  private logger: Logger;
28
30
 
@@ -31,7 +33,7 @@ export class SequencerPublisherFactory {
31
33
  private deps: {
32
34
  telemetry: TelemetryClient;
33
35
  publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
34
- blobSinkClient?: BlobSinkClientInterface;
36
+ blobClient: BlobClientInterface;
35
37
  dateProvider: DateProvider;
36
38
  epochCache: EpochCache;
37
39
  rollupContract: RollupContract;
@@ -70,7 +72,7 @@ export class SequencerPublisherFactory {
70
72
  const publisher = new SequencerPublisher(this.sequencerConfig, {
71
73
  l1TxUtils: l1Publisher,
72
74
  telemetry: this.deps.telemetry,
73
- blobSinkClient: this.deps.blobSinkClient,
75
+ blobClient: this.deps.blobClient,
74
76
  rollupContract: this.deps.rollupContract,
75
77
  epochCache: this.deps.epochCache,
76
78
  governanceProposerContract: this.deps.governanceProposerContract,
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from '@aztec/aztec.js/log';
2
- import type { L1PublishBlockStats, L1PublishStats } from '@aztec/stdlib/stats';
2
+ import type { L1PublishCheckpointStats, L1PublishStats } from '@aztec/stdlib/stats';
3
3
  import {
4
4
  Attributes,
5
5
  type Gauge,
@@ -135,7 +135,7 @@ export class SequencerPublisherMetrics {
135
135
  }
136
136
  }
137
137
 
138
- recordProcessBlockTx(durationMs: number, stats: L1PublishBlockStats) {
138
+ recordProcessBlockTx(durationMs: number, stats: L1PublishCheckpointStats) {
139
139
  this.recordTx('process', durationMs, stats);
140
140
 
141
141
  if (stats.blobCount && stats.blobCount > 0) {