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

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 (110) hide show
  1. package/dest/client/sequencer-client.d.ts +25 -25
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +65 -51
  4. package/dest/config.d.ts +6 -14
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +50 -54
  7. package/dest/global_variable_builder/global_builder.d.ts +11 -6
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +39 -34
  10. package/dest/index.d.ts +1 -2
  11. package/dest/index.d.ts.map +1 -1
  12. package/dest/index.js +1 -2
  13. package/dest/publisher/config.d.ts +6 -8
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +19 -17
  16. package/dest/publisher/index.d.ts +2 -0
  17. package/dest/publisher/index.d.ts.map +1 -1
  18. package/dest/publisher/index.js +3 -0
  19. package/dest/publisher/sequencer-publisher-factory.d.ts +43 -0
  20. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
  21. package/dest/publisher/sequencer-publisher-factory.js +51 -0
  22. package/dest/publisher/sequencer-publisher-metrics.d.ts +2 -1
  23. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  24. package/dest/publisher/sequencer-publisher-metrics.js +37 -2
  25. package/dest/publisher/sequencer-publisher.d.ts +102 -69
  26. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  27. package/dest/publisher/sequencer-publisher.js +606 -212
  28. package/dest/sequencer/block_builder.d.ts +27 -0
  29. package/dest/sequencer/block_builder.d.ts.map +1 -0
  30. package/dest/sequencer/block_builder.js +130 -0
  31. package/dest/sequencer/config.d.ts +5 -0
  32. package/dest/sequencer/config.d.ts.map +1 -1
  33. package/dest/sequencer/errors.d.ts +11 -0
  34. package/dest/sequencer/errors.d.ts.map +1 -0
  35. package/dest/sequencer/errors.js +15 -0
  36. package/dest/sequencer/index.d.ts +1 -1
  37. package/dest/sequencer/index.d.ts.map +1 -1
  38. package/dest/sequencer/index.js +1 -1
  39. package/dest/sequencer/metrics.d.ts +18 -11
  40. package/dest/sequencer/metrics.d.ts.map +1 -1
  41. package/dest/sequencer/metrics.js +84 -50
  42. package/dest/sequencer/sequencer.d.ts +120 -81
  43. package/dest/sequencer/sequencer.d.ts.map +1 -1
  44. package/dest/sequencer/sequencer.js +589 -359
  45. package/dest/sequencer/timetable.d.ts +32 -20
  46. package/dest/sequencer/timetable.d.ts.map +1 -1
  47. package/dest/sequencer/timetable.js +57 -30
  48. package/dest/sequencer/utils.d.ts +11 -35
  49. package/dest/sequencer/utils.d.ts.map +1 -1
  50. package/dest/sequencer/utils.js +9 -47
  51. package/dest/test/index.d.ts +7 -0
  52. package/dest/test/index.d.ts.map +1 -1
  53. package/dest/test/index.js +0 -4
  54. package/dest/tx_validator/nullifier_cache.d.ts +0 -2
  55. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
  56. package/dest/tx_validator/tx_validator_factory.d.ts +9 -10
  57. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  58. package/dest/tx_validator/tx_validator_factory.js +27 -24
  59. package/package.json +42 -43
  60. package/src/client/sequencer-client.ts +94 -84
  61. package/src/config.ts +57 -61
  62. package/src/global_variable_builder/global_builder.ts +44 -23
  63. package/src/index.ts +6 -2
  64. package/src/publisher/config.ts +26 -24
  65. package/src/publisher/index.ts +4 -0
  66. package/src/publisher/sequencer-publisher-factory.ts +90 -0
  67. package/src/publisher/sequencer-publisher-metrics.ts +24 -2
  68. package/src/publisher/sequencer-publisher.ts +729 -235
  69. package/src/sequencer/block_builder.ts +218 -0
  70. package/src/sequencer/config.ts +7 -0
  71. package/src/sequencer/errors.ts +21 -0
  72. package/src/sequencer/index.ts +1 -1
  73. package/src/sequencer/metrics.ts +109 -55
  74. package/src/sequencer/sequencer.ts +766 -415
  75. package/src/sequencer/timetable.ts +98 -33
  76. package/src/sequencer/utils.ts +17 -58
  77. package/src/test/index.ts +11 -4
  78. package/src/tx_validator/tx_validator_factory.ts +44 -32
  79. package/dest/sequencer/allowed.d.ts +0 -3
  80. package/dest/sequencer/allowed.d.ts.map +0 -1
  81. package/dest/sequencer/allowed.js +0 -27
  82. package/dest/slasher/factory.d.ts +0 -7
  83. package/dest/slasher/factory.d.ts.map +0 -1
  84. package/dest/slasher/factory.js +0 -8
  85. package/dest/slasher/index.d.ts +0 -3
  86. package/dest/slasher/index.d.ts.map +0 -1
  87. package/dest/slasher/index.js +0 -2
  88. package/dest/slasher/slasher_client.d.ts +0 -75
  89. package/dest/slasher/slasher_client.d.ts.map +0 -1
  90. package/dest/slasher/slasher_client.js +0 -132
  91. package/dest/tx_validator/archive_cache.d.ts +0 -14
  92. package/dest/tx_validator/archive_cache.d.ts.map +0 -1
  93. package/dest/tx_validator/archive_cache.js +0 -22
  94. package/dest/tx_validator/gas_validator.d.ts +0 -14
  95. package/dest/tx_validator/gas_validator.d.ts.map +0 -1
  96. package/dest/tx_validator/gas_validator.js +0 -78
  97. package/dest/tx_validator/phases_validator.d.ts +0 -12
  98. package/dest/tx_validator/phases_validator.d.ts.map +0 -1
  99. package/dest/tx_validator/phases_validator.js +0 -80
  100. package/dest/tx_validator/test_utils.d.ts +0 -23
  101. package/dest/tx_validator/test_utils.d.ts.map +0 -1
  102. package/dest/tx_validator/test_utils.js +0 -26
  103. package/src/sequencer/allowed.ts +0 -36
  104. package/src/slasher/factory.ts +0 -15
  105. package/src/slasher/index.ts +0 -2
  106. package/src/slasher/slasher_client.ts +0 -193
  107. package/src/tx_validator/archive_cache.ts +0 -28
  108. package/src/tx_validator/gas_validator.ts +0 -101
  109. package/src/tx_validator/phases_validator.ts +0 -98
  110. package/src/tx_validator/test_utils.ts +0 -48
@@ -1,29 +1,34 @@
1
1
  import {
2
2
  type L1ContractsConfig,
3
3
  type L1ReaderConfig,
4
+ RollupContract,
4
5
  type ViemPublicClient,
5
6
  createEthereumChain,
6
7
  } from '@aztec/ethereum';
7
8
  import type { EthAddress } from '@aztec/foundation/eth-address';
8
9
  import { Fr } from '@aztec/foundation/fields';
9
10
  import { createLogger } from '@aztec/foundation/log';
10
- import { RollupAbi } from '@aztec/l1-artifacts';
11
11
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
12
12
  import { GasFees } from '@aztec/stdlib/gas';
13
13
  import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
14
14
  import { GlobalVariables } from '@aztec/stdlib/tx';
15
15
 
16
- import { type GetContractReturnType, createPublicClient, fallback, getAddress, getContract, http } from 'viem';
16
+ import { createPublicClient, fallback, http } from 'viem';
17
17
 
18
18
  /**
19
19
  * Simple global variables builder.
20
20
  */
21
21
  export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
22
22
  private log = createLogger('sequencer:global_variable_builder');
23
+ private currentBaseFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
24
+ private currentL1BlockNumber: bigint | undefined = undefined;
23
25
 
24
- private rollupContract: GetContractReturnType<typeof RollupAbi, ViemPublicClient>;
25
- private publicClient: ViemPublicClient;
26
- private ethereumSlotDuration: number;
26
+ private readonly rollupContract: RollupContract;
27
+ private readonly publicClient: ViemPublicClient;
28
+ private readonly ethereumSlotDuration: number;
29
+
30
+ private chainId?: Fr;
31
+ private version?: Fr;
27
32
 
28
33
  constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>) {
29
34
  const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
@@ -38,28 +43,46 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
38
43
  pollingInterval: config.viemPollingIntervalMS,
39
44
  });
40
45
 
41
- this.rollupContract = getContract({
42
- address: getAddress(l1Contracts.rollupAddress.toString()),
43
- abi: RollupAbi,
44
- client: this.publicClient,
45
- });
46
+ this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
46
47
  }
47
48
 
48
49
  /**
49
50
  * Computes the "current" base fees, e.g., the price that you currently should pay to get include in the next block
50
- * @returns Base fees for the expected next block
51
+ * @returns Base fees for the next block
51
52
  */
52
- public async getCurrentBaseFees(): Promise<GasFees> {
53
+ private async computeCurrentBaseFees(): Promise<GasFees> {
53
54
  // Since this might be called in the middle of a slot where a block might have been published,
54
55
  // we need to fetch the last block written, and estimate the earliest timestamp for the next block.
55
56
  // The timestamp of that last block will act as a lower bound for the next block.
56
57
 
57
- const lastBlock = await this.rollupContract.read.getBlock([await this.rollupContract.read.getPendingBlockNumber()]);
58
- const earliestTimestamp = await this.rollupContract.read.getTimestampForSlot([lastBlock.slotNumber + 1n]);
58
+ const lastBlock = await this.rollupContract.getBlock(await this.rollupContract.getBlockNumber());
59
+ const earliestTimestamp = await this.rollupContract.getTimestampForSlot(lastBlock.slotNumber + 1n);
59
60
  const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
60
61
  const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
61
62
 
62
- return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.read.getManaBaseFeeAt([timestamp, true])));
63
+ return new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
64
+ }
65
+
66
+ public async getCurrentBaseFees(): Promise<GasFees> {
67
+ // Get the current block number
68
+ const blockNumber = await this.publicClient.getBlockNumber();
69
+
70
+ // If the L1 block number has changed then chain a new promise to get the current base fees
71
+ if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
72
+ this.currentL1BlockNumber = blockNumber;
73
+ this.currentBaseFees = this.currentBaseFees.then(() => this.computeCurrentBaseFees());
74
+ }
75
+ return this.currentBaseFees;
76
+ }
77
+
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 };
63
86
  }
64
87
 
65
88
  /**
@@ -71,33 +94,31 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
71
94
  * @returns The global variables for the given block number.
72
95
  */
73
96
  public async buildGlobalVariables(
74
- blockNumber: Fr,
97
+ blockNumber: number,
75
98
  coinbase: EthAddress,
76
99
  feeRecipient: AztecAddress,
77
100
  slotNumber?: bigint,
78
101
  ): Promise<GlobalVariables> {
79
- const version = new Fr(await this.rollupContract.read.getVersion());
80
- const chainId = new Fr(this.publicClient.chain.id);
102
+ const { chainId, version } = await this.getGlobalConstantVariables();
81
103
 
82
104
  if (slotNumber === undefined) {
83
105
  const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
84
- slotNumber = await this.rollupContract.read.getSlotAt([ts]);
106
+ slotNumber = await this.rollupContract.getSlotAt(ts);
85
107
  }
86
108
 
87
- const timestamp = await this.rollupContract.read.getTimestampForSlot([slotNumber]);
109
+ const timestamp = await this.rollupContract.getTimestampForSlot(slotNumber);
88
110
 
89
111
  const slotFr = new Fr(slotNumber);
90
- const timestampFr = new Fr(timestamp);
91
112
 
92
113
  // We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
93
- const gasFees = new GasFees(Fr.ZERO, new Fr(await this.rollupContract.read.getManaBaseFeeAt([timestamp, true])));
114
+ const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
94
115
 
95
116
  const globalVariables = new GlobalVariables(
96
117
  chainId,
97
118
  version,
98
119
  blockNumber,
99
120
  slotFr,
100
- timestampFr,
121
+ timestamp,
101
122
  coinbase,
102
123
  feeRecipient,
103
124
  gasFees,
package/src/index.ts CHANGED
@@ -1,9 +1,13 @@
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
+ Sequencer,
7
+ SequencerState,
8
+ type SequencerEvents,
9
+ } from './sequencer/index.js';
4
10
  export * from './tx_validator/tx_validator_factory.js';
5
- export * from './slasher/index.js';
6
- export { Sequencer, SequencerState, getDefaultAllowedSetupFunctions } from './sequencer/index.js';
7
11
 
8
12
  // Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
9
13
  // ISSUE(#9832)
@@ -2,11 +2,15 @@ import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/cli
2
2
  import {
3
3
  type L1ReaderConfig,
4
4
  type L1TxUtilsConfig,
5
- NULL_KEY,
6
5
  l1ReaderConfigMappings,
7
6
  l1TxUtilsConfigMappings,
8
7
  } from '@aztec/ethereum';
9
- import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
8
+ import {
9
+ type ConfigMappingsType,
10
+ SecretValue,
11
+ booleanConfigHelper,
12
+ getConfigFromMappings,
13
+ } from '@aztec/foundation/config';
10
14
  import { EthAddress } from '@aztec/foundation/eth-address';
11
15
 
12
16
  /**
@@ -16,12 +20,12 @@ export type TxSenderConfig = L1ReaderConfig & {
16
20
  /**
17
21
  * The private key to be used by the publisher.
18
22
  */
19
- publisherPrivateKey: `0x${string}`;
23
+ publisherPrivateKeys?: SecretValue<`0x${string}`>[];
20
24
 
21
25
  /**
22
- * The address of the custom forwarder contract.
26
+ * Publisher addresses to be used with a remote signer
23
27
  */
24
- customForwarderContractAddress: EthAddress;
28
+ publisherAddresses?: EthAddress[];
25
29
  };
26
30
 
27
31
  /**
@@ -29,27 +33,26 @@ export type TxSenderConfig = L1ReaderConfig & {
29
33
  */
30
34
  export type PublisherConfig = L1TxUtilsConfig &
31
35
  BlobSinkConfig & {
32
- /**
33
- * The interval to wait between publish retries.
34
- */
35
- l1PublishRetryIntervalMS: number;
36
+ /** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
37
+ publisherAllowInvalidStates?: boolean;
36
38
  };
37
39
 
38
40
  export const getTxSenderConfigMappings: (
39
41
  scope: 'PROVER' | 'SEQ',
40
42
  ) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
41
43
  ...l1ReaderConfigMappings,
42
- customForwarderContractAddress: {
43
- env: `CUSTOM_FORWARDER_CONTRACT_ADDRESS`,
44
- parseEnv: (val: string) => EthAddress.fromString(val),
45
- description: 'The address of the custom forwarder contract.',
46
- defaultValue: EthAddress.ZERO,
44
+ publisherPrivateKeys: {
45
+ env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEYS` : `SEQ_PUBLISHER_PRIVATE_KEYS`,
46
+ description: 'The private keys to be used by the publisher.',
47
+ parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
48
+ defaultValue: [],
49
+ fallback: [scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`],
47
50
  },
48
- publisherPrivateKey: {
49
- env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`,
50
- description: 'The private key to be used by the publisher.',
51
- parseEnv: (val: string) => (val ? `0x${val.replace('0x', '')}` : NULL_KEY),
52
- defaultValue: NULL_KEY,
51
+ publisherAddresses: {
52
+ env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
53
+ description: 'The addresses of the publishers to use with remote signers',
54
+ parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
55
+ defaultValue: [],
53
56
  },
54
57
  });
55
58
 
@@ -60,11 +63,10 @@ export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSender
60
63
  export const getPublisherConfigMappings: (
61
64
  scope: 'PROVER' | 'SEQ',
62
65
  ) => ConfigMappingsType<PublisherConfig & L1TxUtilsConfig> = scope => ({
63
- l1PublishRetryIntervalMS: {
64
- env: scope === `PROVER` ? `PROVER_PUBLISH_RETRY_INTERVAL_MS` : `SEQ_PUBLISH_RETRY_INTERVAL_MS`,
65
- parseEnv: (val: string) => +val,
66
- defaultValue: 1000,
67
- description: 'The interval to wait between publish retries.',
66
+ publisherAllowInvalidStates: {
67
+ description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
68
+ env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
69
+ ...booleanConfigHelper(true),
68
70
  },
69
71
  ...l1TxUtilsConfigMappings,
70
72
  ...blobSinkConfigMapping,
@@ -1 +1,5 @@
1
1
  export { SequencerPublisher } from './sequencer-publisher.js';
2
+ export { SequencerPublisherFactory } from './sequencer-publisher-factory.js';
3
+
4
+ // Used for tests
5
+ export { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
@@ -0,0 +1,90 @@
1
+ import { EthAddress } from '@aztec/aztec.js/addresses';
2
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
+ import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
4
+ import type { EpochCache } from '@aztec/epoch-cache';
5
+ import type { GovernanceProposerContract, PublisherFilter, PublisherManager, RollupContract } from '@aztec/ethereum';
6
+ import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
7
+ import type { DateProvider } from '@aztec/foundation/timer';
8
+ import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
9
+ import type { TelemetryClient } from '@aztec/telemetry-client';
10
+ import { NodeKeystoreAdapter } from '@aztec/validator-client';
11
+
12
+ import type { SequencerClientConfig } from '../config.js';
13
+ import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
14
+ import { type Action, SequencerPublisher } from './sequencer-publisher.js';
15
+
16
+ export type AttestorPublisherPair = {
17
+ attestorAddress: EthAddress;
18
+ publisher: SequencerPublisher;
19
+ };
20
+
21
+ export class SequencerPublisherFactory {
22
+ private publisherMetrics: SequencerPublisherMetrics;
23
+
24
+ /** Stores the last slot in which every action was carried out by a publisher */
25
+ private lastActions: Partial<Record<Action, bigint>> = {};
26
+
27
+ private logger: Logger;
28
+
29
+ constructor(
30
+ private sequencerConfig: SequencerClientConfig,
31
+ private deps: {
32
+ telemetry: TelemetryClient;
33
+ publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
34
+ blobSinkClient?: BlobSinkClientInterface;
35
+ dateProvider: DateProvider;
36
+ epochCache: EpochCache;
37
+ rollupContract: RollupContract;
38
+ governanceProposerContract: GovernanceProposerContract;
39
+ slashFactoryContract: SlashFactoryContract;
40
+ nodeKeyStore: NodeKeystoreAdapter;
41
+ logger?: Logger;
42
+ },
43
+ ) {
44
+ this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
45
+ this.logger = deps.logger ?? createLogger('sequencer');
46
+ }
47
+ /**
48
+ * Creates a new SequencerPublisher instance.
49
+ * @param _validatorAddress - The address of the validator that will be using the publisher.
50
+ * @returns A new SequencerPublisher instance.
51
+ */
52
+ public async create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair> {
53
+ // If we have been given an attestor address we must only allow publishers permitted for that attestor
54
+
55
+ const allowedPublishers = !validatorAddress ? [] : this.deps.nodeKeyStore.getPublisherAddresses(validatorAddress);
56
+ const filter: PublisherFilter<L1TxUtilsWithBlobs> = !validatorAddress
57
+ ? () => true
58
+ : (utils: L1TxUtilsWithBlobs) => {
59
+ const publisherAddress = utils.getSenderAddress();
60
+ return allowedPublishers.some(allowedPublisher => allowedPublisher.equals(publisherAddress));
61
+ };
62
+
63
+ const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
64
+ const attestorAddress =
65
+ validatorAddress ?? this.deps.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
66
+
67
+ const rollup = this.deps.rollupContract;
68
+ const slashingProposerContract = await rollup.getSlashingProposer();
69
+
70
+ const publisher = new SequencerPublisher(this.sequencerConfig, {
71
+ l1TxUtils: l1Publisher,
72
+ telemetry: this.deps.telemetry,
73
+ blobSinkClient: this.deps.blobSinkClient,
74
+ rollupContract: this.deps.rollupContract,
75
+ epochCache: this.deps.epochCache,
76
+ governanceProposerContract: this.deps.governanceProposerContract,
77
+ slashingProposerContract,
78
+ slashFactoryContract: this.deps.slashFactoryContract,
79
+ dateProvider: this.deps.dateProvider,
80
+ metrics: this.publisherMetrics,
81
+ lastActions: this.lastActions,
82
+ log: this.logger.createChild('publisher'),
83
+ });
84
+
85
+ return {
86
+ attestorAddress,
87
+ publisher,
88
+ };
89
+ }
90
+ }
@@ -1,4 +1,4 @@
1
- import { createLogger } from '@aztec/aztec.js';
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
2
  import type { L1PublishBlockStats, L1PublishStats } from '@aztec/stdlib/stats';
3
3
  import {
4
4
  Attributes,
@@ -24,6 +24,7 @@ export class SequencerPublisherMetrics {
24
24
  private txCalldataGas: Histogram;
25
25
  private txBlobDataGasUsed: Histogram;
26
26
  private txBlobDataGasCost: Histogram;
27
+ private txTotalFee: Histogram;
27
28
 
28
29
  private readonly blobCountHistogram: Histogram;
29
30
  private readonly blobInclusionBlocksHistogram: Histogram;
@@ -105,6 +106,17 @@ export class SequencerPublisherMetrics {
105
106
  description: 'Number of failed L1 transactions with blobs',
106
107
  });
107
108
 
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
+ });
119
+
108
120
  this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
109
121
  unit: 'eth',
110
122
  description: 'The balance of the sender address',
@@ -169,7 +181,17 @@ export class SequencerPublisherMetrics {
169
181
 
170
182
  try {
171
183
  this.gasPrice.record(parseInt(formatEther(stats.gasPrice, 'gwei'), 10));
172
- } catch (e) {
184
+ } catch {
185
+ // ignore
186
+ }
187
+
188
+ const executionFee = stats.gasUsed * stats.gasPrice;
189
+ const blobFee = stats.blobGasUsed * stats.blobDataGas;
190
+ const totalFee = executionFee + blobFee;
191
+
192
+ try {
193
+ this.txTotalFee.record(parseFloat(formatEther(totalFee)));
194
+ } catch {
173
195
  // ignore
174
196
  }
175
197
  }