@aztec/sequencer-client 0.0.1-commit.6230efd → 0.0.1-commit.64b6bbb

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 (76) hide show
  1. package/dest/client/sequencer-client.d.ts +4 -5
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +1 -1
  4. package/dest/config.d.ts +1 -2
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +10 -9
  7. package/dest/global_variable_builder/global_builder.d.ts +4 -4
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +13 -13
  10. package/dest/index.d.ts +2 -3
  11. package/dest/index.d.ts.map +1 -1
  12. package/dest/index.js +1 -2
  13. package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
  14. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  15. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  16. package/dest/publisher/sequencer-publisher.d.ts +17 -17
  17. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  18. package/dest/publisher/sequencer-publisher.js +481 -67
  19. package/dest/sequencer/checkpoint_proposal_job.d.ts +40 -12
  20. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  21. package/dest/sequencer/checkpoint_proposal_job.js +606 -57
  22. package/dest/sequencer/checkpoint_voter.d.ts +3 -2
  23. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  24. package/dest/sequencer/checkpoint_voter.js +34 -10
  25. package/dest/sequencer/index.d.ts +1 -3
  26. package/dest/sequencer/index.d.ts.map +1 -1
  27. package/dest/sequencer/index.js +0 -2
  28. package/dest/sequencer/metrics.d.ts +4 -4
  29. package/dest/sequencer/metrics.d.ts.map +1 -1
  30. package/dest/sequencer/metrics.js +48 -129
  31. package/dest/sequencer/sequencer.d.ts +27 -15
  32. package/dest/sequencer/sequencer.d.ts.map +1 -1
  33. package/dest/sequencer/sequencer.js +492 -43
  34. package/dest/sequencer/timetable.d.ts +1 -4
  35. package/dest/sequencer/timetable.d.ts.map +1 -1
  36. package/dest/sequencer/timetable.js +1 -4
  37. package/dest/test/index.d.ts +2 -3
  38. package/dest/test/index.d.ts.map +1 -1
  39. package/dest/test/mock_checkpoint_builder.d.ts +23 -11
  40. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  41. package/dest/test/mock_checkpoint_builder.js +50 -9
  42. package/dest/test/utils.d.ts +13 -9
  43. package/dest/test/utils.d.ts.map +1 -1
  44. package/dest/test/utils.js +26 -17
  45. package/package.json +30 -28
  46. package/src/client/sequencer-client.ts +4 -5
  47. package/src/config.ts +14 -11
  48. package/src/global_variable_builder/global_builder.ts +13 -13
  49. package/src/index.ts +1 -9
  50. package/src/publisher/sequencer-publisher-metrics.ts +17 -69
  51. package/src/publisher/sequencer-publisher.ts +118 -91
  52. package/src/sequencer/checkpoint_proposal_job.ts +258 -87
  53. package/src/sequencer/checkpoint_voter.ts +32 -7
  54. package/src/sequencer/index.ts +0 -2
  55. package/src/sequencer/metrics.ts +48 -138
  56. package/src/sequencer/sequencer.ts +133 -43
  57. package/src/sequencer/timetable.ts +6 -5
  58. package/src/test/index.ts +1 -2
  59. package/src/test/mock_checkpoint_builder.ts +91 -29
  60. package/src/test/utils.ts +55 -28
  61. package/dest/sequencer/block_builder.d.ts +0 -26
  62. package/dest/sequencer/block_builder.d.ts.map +0 -1
  63. package/dest/sequencer/block_builder.js +0 -129
  64. package/dest/sequencer/checkpoint_builder.d.ts +0 -63
  65. package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
  66. package/dest/sequencer/checkpoint_builder.js +0 -131
  67. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  68. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  69. package/dest/tx_validator/nullifier_cache.js +0 -24
  70. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  71. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  72. package/dest/tx_validator/tx_validator_factory.js +0 -53
  73. package/src/sequencer/block_builder.ts +0 -217
  74. package/src/sequencer/checkpoint_builder.ts +0 -217
  75. package/src/tx_validator/nullifier_cache.ts +0 -30
  76. package/src/tx_validator/tx_validator_factory.ts +0 -133
package/src/config.ts CHANGED
@@ -11,8 +11,14 @@ import { EthAddress } from '@aztec/foundation/eth-address';
11
11
  import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
12
12
  import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
13
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
- import { type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
14
+ import {
15
+ type ChainConfig,
16
+ type SequencerConfig,
17
+ chainConfigMappings,
18
+ sharedSequencerConfigMappings,
19
+ } from '@aztec/stdlib/config';
15
20
  import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
21
+ import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
16
22
  import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
17
23
 
18
24
  import {
@@ -25,8 +31,6 @@ import {
25
31
  export * from './publisher/config.js';
26
32
  export type { SequencerConfig };
27
33
 
28
- export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
29
-
30
34
  /**
31
35
  * Default values for SequencerConfig.
32
36
  * Centralized location for all sequencer configuration defaults.
@@ -41,7 +45,7 @@ export const DefaultSequencerConfig: ResolvedSequencerConfig = {
41
45
  maxDABlockGas: 10e9,
42
46
  maxBlockSizeInBytes: 1024 * 1024,
43
47
  enforceTimeTable: true,
44
- attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
48
+ attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
45
49
  secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
46
50
  secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
47
51
  skipCollectingAttestations: false,
@@ -50,6 +54,7 @@ export const DefaultSequencerConfig: ResolvedSequencerConfig = {
50
54
  injectFakeAttestation: false,
51
55
  fishermanMode: false,
52
56
  shuffleAttestationOrdering: false,
57
+ skipPushProposedBlocksToArchiver: false,
53
58
  };
54
59
 
55
60
  /**
@@ -190,18 +195,16 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
190
195
  description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
191
196
  ...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
192
197
  },
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
- },
198
+ ...sharedSequencerConfigMappings,
200
199
  buildCheckpointIfEmpty: {
201
200
  env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
202
201
  description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
203
202
  ...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
204
203
  },
204
+ skipPushProposedBlocksToArchiver: {
205
+ description: 'Skip pushing proposed blocks to archiver (default: true)',
206
+ ...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
207
+ },
205
208
  ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
206
209
  };
207
210
 
@@ -23,7 +23,7 @@ import { createPublicClient, fallback, http } from 'viem';
23
23
  */
24
24
  export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
25
25
  private log = createLogger('sequencer:global_variable_builder');
26
- private currentBaseFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
26
+ private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
27
27
  private currentL1BlockNumber: bigint | undefined = undefined;
28
28
 
29
29
  private readonly rollupContract: RollupContract;
@@ -61,34 +61,34 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
61
61
  }
62
62
 
63
63
  /**
64
- * Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
65
- * @returns Base fees for the next block
64
+ * Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
65
+ * @returns Min fees for the next block
66
66
  */
67
- private async computeCurrentBaseFees(): Promise<GasFees> {
67
+ private async computeCurrentMinFees(): Promise<GasFees> {
68
68
  // Since this might be called in the middle of a slot where a block might have been published,
69
69
  // we need to fetch the last block written, and estimate the earliest timestamp for the next block.
70
70
  // The timestamp of that last block will act as a lower bound for the next block.
71
71
 
72
- const lastBlock = await this.rollupContract.getPendingCheckpoint();
72
+ const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
73
73
  const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
74
- SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
74
+ SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
75
75
  );
76
76
  const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
77
77
  const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
78
78
 
79
- return new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
79
+ return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
80
80
  }
81
81
 
82
- public async getCurrentBaseFees(): Promise<GasFees> {
82
+ public async getCurrentMinFees(): Promise<GasFees> {
83
83
  // Get the current block number
84
84
  const blockNumber = await this.publicClient.getBlockNumber();
85
85
 
86
- // If the L1 block number has changed then chain a new promise to get the current base fees
86
+ // If the L1 block number has changed then chain a new promise to get the current min fees
87
87
  if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
88
88
  this.currentL1BlockNumber = blockNumber;
89
- this.currentBaseFees = this.currentBaseFees.then(() => this.computeCurrentBaseFees());
89
+ this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
90
90
  }
91
- return this.currentBaseFees;
91
+ return this.currentMinFees;
92
92
  }
93
93
 
94
94
  /**
@@ -128,9 +128,9 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
128
128
  l1GenesisTime: this.l1GenesisTime,
129
129
  });
130
130
 
131
- // We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
131
+ // We can skip much of the logic in getCurrentMinFees since it we already check that we are not within a slot elsewhere.
132
132
  // TODO(palla/mbps): Can we use a cached value here?
133
- const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
133
+ const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
134
134
 
135
135
  return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
136
136
  }
package/src/index.ts CHANGED
@@ -1,15 +1,7 @@
1
1
  export * from './client/index.js';
2
2
  export * from './config.js';
3
3
  export * from './publisher/index.js';
4
- export {
5
- FullNodeBlockBuilder as BlockBuilder,
6
- FullNodeCheckpointsBuilder as CheckpointsBuilder,
7
- CheckpointBuilder,
8
- Sequencer,
9
- SequencerState,
10
- type SequencerEvents,
11
- } from './sequencer/index.js';
12
- export * from './tx_validator/tx_validator_factory.js';
4
+ export { Sequencer, SequencerState, type SequencerEvents } from './sequencer/index.js';
13
5
 
14
6
  // Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
15
7
  // ISSUE(#9832)
@@ -7,7 +7,7 @@ import {
7
7
  Metrics,
8
8
  type TelemetryClient,
9
9
  type UpDownCounter,
10
- ValueType,
10
+ createUpDownCounterWithDefault,
11
11
  } from '@aztec/telemetry-client';
12
12
 
13
13
  import { formatEther } from 'viem/utils';
@@ -40,88 +40,36 @@ export class SequencerPublisherMetrics {
40
40
  ) {
41
41
  const meter = client.getMeter(name);
42
42
 
43
- this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE, {
44
- description: 'The gas price used for transactions',
45
- unit: 'gwei',
46
- valueType: ValueType.DOUBLE,
47
- });
43
+ this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
48
44
 
49
- this.txCount = meter.createUpDownCounter(Metrics.L1_PUBLISHER_TX_COUNT, {
50
- description: 'The number of transactions processed',
45
+ this.txCount = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_TX_COUNT, {
46
+ [Attributes.L1_TX_TYPE]: ['process'],
47
+ [Attributes.OK]: [true, false],
51
48
  });
52
49
 
53
- this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION, {
54
- description: 'The duration of transaction processing',
55
- unit: 'ms',
56
- valueType: ValueType.INT,
57
- });
50
+ this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
58
51
 
59
- this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS, {
60
- description: 'The gas consumed by transactions',
61
- unit: 'gas',
62
- valueType: ValueType.INT,
63
- });
52
+ this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
64
53
 
65
- this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE, {
66
- description: 'The size of the calldata in transactions',
67
- unit: 'By',
68
- valueType: ValueType.INT,
69
- });
54
+ this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
70
55
 
71
- this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS, {
72
- description: 'The gas consumed by the calldata in transactions',
73
- unit: 'gas',
74
- valueType: ValueType.INT,
75
- });
56
+ this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
76
57
 
77
- this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED, {
78
- description: 'The amount of blob gas used in transactions',
79
- unit: 'gas',
80
- valueType: ValueType.INT,
81
- });
58
+ this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
82
59
 
83
- this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST, {
84
- description: 'The gas cost of blobs in transactions',
85
- unit: 'gwei',
86
- valueType: ValueType.INT,
87
- });
60
+ this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
88
61
 
89
- this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT, {
90
- description: 'Number of blobs in L1 transactions',
91
- unit: 'blobs',
92
- valueType: ValueType.INT,
93
- });
62
+ this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT);
94
63
 
95
- this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS, {
96
- description: 'Number of L1 blocks between blob tx submission and inclusion',
97
- unit: 'blocks',
98
- valueType: ValueType.INT,
99
- });
64
+ this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS);
100
65
 
101
- this.blobTxSuccessCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS, {
102
- description: 'Number of successful L1 transactions with blobs',
103
- });
66
+ this.blobTxSuccessCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS);
104
67
 
105
- this.blobTxFailureCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_FAILURE, {
106
- description: 'Number of failed L1 transactions with blobs',
107
- });
68
+ this.blobTxFailureCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_FAILURE);
108
69
 
109
- this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, {
110
- description: 'How much L1 tx costs',
111
- unit: 'eth',
112
- valueType: ValueType.DOUBLE,
113
- advice: {
114
- explicitBucketBoundaries: [
115
- 0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2,
116
- ],
117
- },
118
- });
70
+ this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
119
71
 
120
- this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
121
- unit: 'eth',
122
- description: 'The balance of the sender address',
123
- valueType: ValueType.DOUBLE,
124
- });
72
+ this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
125
73
  }
126
74
 
127
75
  recordFailedTx(txType: L1TxType) {