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

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 (112) hide show
  1. package/dest/client/index.d.ts +1 -1
  2. package/dest/client/sequencer-client.d.ts +26 -26
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +66 -51
  5. package/dest/config.d.ts +7 -15
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +59 -54
  8. package/dest/global_variable_builder/global_builder.d.ts +12 -10
  9. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  10. package/dest/global_variable_builder/global_builder.js +43 -35
  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 +9 -9
  16. package/dest/publisher/config.d.ts.map +1 -1
  17. package/dest/publisher/config.js +24 -17
  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 +43 -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 +3 -2
  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 +112 -73
  28. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  29. package/dest/publisher/sequencer-publisher.js +681 -236
  30. package/dest/sequencer/block_builder.d.ts +27 -0
  31. package/dest/sequencer/block_builder.d.ts.map +1 -0
  32. package/dest/sequencer/block_builder.js +134 -0
  33. package/dest/sequencer/config.d.ts +6 -1
  34. package/dest/sequencer/config.d.ts.map +1 -1
  35. package/dest/sequencer/errors.d.ts +11 -0
  36. package/dest/sequencer/errors.d.ts.map +1 -0
  37. package/dest/sequencer/errors.js +15 -0
  38. package/dest/sequencer/index.d.ts +2 -2
  39. package/dest/sequencer/index.d.ts.map +1 -1
  40. package/dest/sequencer/index.js +1 -1
  41. package/dest/sequencer/metrics.d.ts +28 -12
  42. package/dest/sequencer/metrics.d.ts.map +1 -1
  43. package/dest/sequencer/metrics.js +122 -50
  44. package/dest/sequencer/sequencer.d.ts +122 -91
  45. package/dest/sequencer/sequencer.d.ts.map +1 -1
  46. package/dest/sequencer/sequencer.js +723 -370
  47. package/dest/sequencer/timetable.d.ts +33 -21
  48. package/dest/sequencer/timetable.d.ts.map +1 -1
  49. package/dest/sequencer/timetable.js +57 -30
  50. package/dest/sequencer/utils.d.ts +12 -36
  51. package/dest/sequencer/utils.d.ts.map +1 -1
  52. package/dest/sequencer/utils.js +9 -47
  53. package/dest/test/index.d.ts +8 -1
  54. package/dest/test/index.d.ts.map +1 -1
  55. package/dest/test/index.js +0 -4
  56. package/dest/tx_validator/nullifier_cache.d.ts +1 -3
  57. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
  58. package/dest/tx_validator/tx_validator_factory.d.ts +10 -11
  59. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  60. package/dest/tx_validator/tx_validator_factory.js +27 -24
  61. package/package.json +45 -45
  62. package/src/client/sequencer-client.ts +95 -85
  63. package/src/config.ts +67 -61
  64. package/src/global_variable_builder/global_builder.ts +52 -27
  65. package/src/index.ts +6 -2
  66. package/src/publisher/config.ts +34 -24
  67. package/src/publisher/index.ts +4 -0
  68. package/src/publisher/sequencer-publisher-factory.ts +91 -0
  69. package/src/publisher/sequencer-publisher-metrics.ts +24 -2
  70. package/src/publisher/sequencer-publisher.ts +817 -268
  71. package/src/sequencer/block_builder.ts +222 -0
  72. package/src/sequencer/config.ts +7 -0
  73. package/src/sequencer/errors.ts +21 -0
  74. package/src/sequencer/index.ts +1 -1
  75. package/src/sequencer/metrics.ts +156 -53
  76. package/src/sequencer/sequencer.ts +918 -423
  77. package/src/sequencer/timetable.ts +98 -33
  78. package/src/sequencer/utils.ts +17 -58
  79. package/src/test/index.ts +11 -4
  80. package/src/tx_validator/tx_validator_factory.ts +44 -32
  81. package/dest/sequencer/allowed.d.ts +0 -3
  82. package/dest/sequencer/allowed.d.ts.map +0 -1
  83. package/dest/sequencer/allowed.js +0 -27
  84. package/dest/slasher/factory.d.ts +0 -7
  85. package/dest/slasher/factory.d.ts.map +0 -1
  86. package/dest/slasher/factory.js +0 -8
  87. package/dest/slasher/index.d.ts +0 -3
  88. package/dest/slasher/index.d.ts.map +0 -1
  89. package/dest/slasher/index.js +0 -2
  90. package/dest/slasher/slasher_client.d.ts +0 -75
  91. package/dest/slasher/slasher_client.d.ts.map +0 -1
  92. package/dest/slasher/slasher_client.js +0 -132
  93. package/dest/tx_validator/archive_cache.d.ts +0 -14
  94. package/dest/tx_validator/archive_cache.d.ts.map +0 -1
  95. package/dest/tx_validator/archive_cache.js +0 -22
  96. package/dest/tx_validator/gas_validator.d.ts +0 -14
  97. package/dest/tx_validator/gas_validator.d.ts.map +0 -1
  98. package/dest/tx_validator/gas_validator.js +0 -78
  99. package/dest/tx_validator/phases_validator.d.ts +0 -12
  100. package/dest/tx_validator/phases_validator.d.ts.map +0 -1
  101. package/dest/tx_validator/phases_validator.js +0 -80
  102. package/dest/tx_validator/test_utils.d.ts +0 -23
  103. package/dest/tx_validator/test_utils.d.ts.map +0 -1
  104. package/dest/tx_validator/test_utils.js +0 -26
  105. package/src/sequencer/allowed.ts +0 -36
  106. package/src/slasher/factory.ts +0 -15
  107. package/src/slasher/index.ts +0 -2
  108. package/src/slasher/slasher_client.ts +0 -193
  109. package/src/tx_validator/archive_cache.ts +0 -28
  110. package/src/tx_validator/gas_validator.ts +0 -101
  111. package/src/tx_validator/phases_validator.ts +0 -98
  112. package/src/tx_validator/test_utils.ts +0 -48
@@ -1,29 +1,35 @@
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';
8
+ import { SlotNumber } from '@aztec/foundation/branded-types';
7
9
  import type { EthAddress } from '@aztec/foundation/eth-address';
8
10
  import { Fr } from '@aztec/foundation/fields';
9
11
  import { createLogger } from '@aztec/foundation/log';
10
- import { RollupAbi } from '@aztec/l1-artifacts';
11
12
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
12
13
  import { GasFees } from '@aztec/stdlib/gas';
13
14
  import type { GlobalVariableBuilder as GlobalVariableBuilderInterface } from '@aztec/stdlib/tx';
14
15
  import { GlobalVariables } from '@aztec/stdlib/tx';
15
16
 
16
- import { type GetContractReturnType, createPublicClient, fallback, getAddress, getContract, http } from 'viem';
17
+ import { createPublicClient, fallback, http } from 'viem';
17
18
 
18
19
  /**
19
20
  * Simple global variables builder.
20
21
  */
21
22
  export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
22
23
  private log = createLogger('sequencer:global_variable_builder');
24
+ private currentBaseFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
25
+ private currentL1BlockNumber: bigint | undefined = undefined;
23
26
 
24
- private rollupContract: GetContractReturnType<typeof RollupAbi, ViemPublicClient>;
25
- private publicClient: ViemPublicClient;
26
- private ethereumSlotDuration: number;
27
+ private readonly rollupContract: RollupContract;
28
+ private readonly publicClient: ViemPublicClient;
29
+ private readonly ethereumSlotDuration: number;
30
+
31
+ private chainId?: Fr;
32
+ private version?: Fr;
27
33
 
28
34
  constructor(config: L1ReaderConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>) {
29
35
  const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
@@ -38,28 +44,48 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
38
44
  pollingInterval: config.viemPollingIntervalMS,
39
45
  });
40
46
 
41
- this.rollupContract = getContract({
42
- address: getAddress(l1Contracts.rollupAddress.toString()),
43
- abi: RollupAbi,
44
- client: this.publicClient,
45
- });
47
+ this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
46
48
  }
47
49
 
48
50
  /**
49
51
  * 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
52
+ * @returns Base fees for the next block
51
53
  */
52
- public async getCurrentBaseFees(): Promise<GasFees> {
54
+ private async computeCurrentBaseFees(): Promise<GasFees> {
53
55
  // Since this might be called in the middle of a slot where a block might have been published,
54
56
  // we need to fetch the last block written, and estimate the earliest timestamp for the next block.
55
57
  // The timestamp of that last block will act as a lower bound for the next block.
56
58
 
57
- const lastBlock = await this.rollupContract.read.getBlock([await this.rollupContract.read.getPendingBlockNumber()]);
58
- const earliestTimestamp = await this.rollupContract.read.getTimestampForSlot([lastBlock.slotNumber + 1n]);
59
+ const lastBlock = await this.rollupContract.getCheckpoint(await this.rollupContract.getCheckpointNumber());
60
+ const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
61
+ SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
62
+ );
59
63
  const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
60
64
  const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
61
65
 
62
- return new GasFees(Fr.ZERO, new Fr(await this.rollupContract.read.getManaBaseFeeAt([timestamp, true])));
66
+ return new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
67
+ }
68
+
69
+ public async getCurrentBaseFees(): Promise<GasFees> {
70
+ // Get the current block number
71
+ const blockNumber = await this.publicClient.getBlockNumber();
72
+
73
+ // If the L1 block number has changed then chain a new promise to get the current base fees
74
+ if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
75
+ this.currentL1BlockNumber = blockNumber;
76
+ this.currentBaseFees = this.currentBaseFees.then(() => this.computeCurrentBaseFees());
77
+ }
78
+ return this.currentBaseFees;
79
+ }
80
+
81
+ public async getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>> {
82
+ if (!this.chainId) {
83
+ this.chainId = new Fr(this.publicClient.chain.id);
84
+ }
85
+ if (!this.version) {
86
+ this.version = new Fr(await this.rollupContract.getVersion());
87
+ }
88
+ return { chainId: this.chainId, version: this.version };
63
89
  }
64
90
 
65
91
  /**
@@ -71,33 +97,32 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
71
97
  * @returns The global variables for the given block number.
72
98
  */
73
99
  public async buildGlobalVariables(
74
- blockNumber: Fr,
100
+ blockNumber: number,
75
101
  coinbase: EthAddress,
76
102
  feeRecipient: AztecAddress,
77
- slotNumber?: bigint,
103
+ slotNumber?: SlotNumber,
78
104
  ): Promise<GlobalVariables> {
79
- const version = new Fr(await this.rollupContract.read.getVersion());
80
- const chainId = new Fr(this.publicClient.chain.id);
105
+ const { chainId, version } = await this.getGlobalConstantVariables();
81
106
 
107
+ let slot: SlotNumber;
82
108
  if (slotNumber === undefined) {
83
109
  const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
84
- slotNumber = await this.rollupContract.read.getSlotAt([ts]);
110
+ slot = await this.rollupContract.getSlotAt(ts);
111
+ } else {
112
+ slot = slotNumber;
85
113
  }
86
114
 
87
- const timestamp = await this.rollupContract.read.getTimestampForSlot([slotNumber]);
88
-
89
- const slotFr = new Fr(slotNumber);
90
- const timestampFr = new Fr(timestamp);
115
+ const timestamp = await this.rollupContract.getTimestampForSlot(slot);
91
116
 
92
117
  // 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])));
118
+ const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
94
119
 
95
120
  const globalVariables = new GlobalVariables(
96
121
  chainId,
97
122
  version,
98
123
  blockNumber,
99
- slotFr,
100
- timestampFr,
124
+ slot,
125
+ timestamp,
101
126
  coinbase,
102
127
  feeRecipient,
103
128
  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,28 @@ 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;
38
+ /** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1 */
39
+ fishermanMode?: boolean;
36
40
  };
37
41
 
38
42
  export const getTxSenderConfigMappings: (
39
43
  scope: 'PROVER' | 'SEQ',
40
44
  ) => ConfigMappingsType<Omit<TxSenderConfig, 'l1Contracts'>> = (scope: 'PROVER' | 'SEQ') => ({
41
45
  ...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,
46
+ publisherPrivateKeys: {
47
+ env: scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEYS` : `SEQ_PUBLISHER_PRIVATE_KEYS`,
48
+ description: 'The private keys to be used by the publisher.',
49
+ parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
50
+ defaultValue: [],
51
+ fallback: [scope === 'PROVER' ? `PROVER_PUBLISHER_PRIVATE_KEY` : `SEQ_PUBLISHER_PRIVATE_KEY`],
47
52
  },
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,
53
+ publisherAddresses: {
54
+ env: scope === 'PROVER' ? `PROVER_PUBLISHER_ADDRESSES` : `SEQ_PUBLISHER_ADDRESSES`,
55
+ description: 'The addresses of the publishers to use with remote signers',
56
+ parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
57
+ defaultValue: [],
53
58
  },
54
59
  });
55
60
 
@@ -60,11 +65,16 @@ export function getTxSenderConfigFromEnv(scope: 'PROVER' | 'SEQ'): Omit<TxSender
60
65
  export const getPublisherConfigMappings: (
61
66
  scope: 'PROVER' | 'SEQ',
62
67
  ) => 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.',
68
+ publisherAllowInvalidStates: {
69
+ description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
70
+ env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
71
+ ...booleanConfigHelper(true),
72
+ },
73
+ fishermanMode: {
74
+ env: 'FISHERMAN_MODE',
75
+ description:
76
+ 'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
77
+ ...booleanConfigHelper(false),
68
78
  },
69
79
  ...l1TxUtilsConfigMappings,
70
80
  ...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,91 @@
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 { SlotNumber } from '@aztec/foundation/branded-types';
8
+ import type { DateProvider } from '@aztec/foundation/timer';
9
+ import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
10
+ import type { TelemetryClient } from '@aztec/telemetry-client';
11
+ import { NodeKeystoreAdapter } from '@aztec/validator-client';
12
+
13
+ import type { SequencerClientConfig } from '../config.js';
14
+ import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
15
+ import { type Action, SequencerPublisher } from './sequencer-publisher.js';
16
+
17
+ export type AttestorPublisherPair = {
18
+ attestorAddress: EthAddress;
19
+ publisher: SequencerPublisher;
20
+ };
21
+
22
+ export class SequencerPublisherFactory {
23
+ private publisherMetrics: SequencerPublisherMetrics;
24
+
25
+ /** Stores the last slot in which every action was carried out by a publisher */
26
+ private lastActions: Partial<Record<Action, SlotNumber>> = {};
27
+
28
+ private logger: Logger;
29
+
30
+ constructor(
31
+ private sequencerConfig: SequencerClientConfig,
32
+ private deps: {
33
+ telemetry: TelemetryClient;
34
+ publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
35
+ blobSinkClient?: BlobSinkClientInterface;
36
+ dateProvider: DateProvider;
37
+ epochCache: EpochCache;
38
+ rollupContract: RollupContract;
39
+ governanceProposerContract: GovernanceProposerContract;
40
+ slashFactoryContract: SlashFactoryContract;
41
+ nodeKeyStore: NodeKeystoreAdapter;
42
+ logger?: Logger;
43
+ },
44
+ ) {
45
+ this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
46
+ this.logger = deps.logger ?? createLogger('sequencer');
47
+ }
48
+ /**
49
+ * Creates a new SequencerPublisher instance.
50
+ * @param _validatorAddress - The address of the validator that will be using the publisher.
51
+ * @returns A new SequencerPublisher instance.
52
+ */
53
+ public async create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair> {
54
+ // If we have been given an attestor address we must only allow publishers permitted for that attestor
55
+
56
+ const allowedPublishers = !validatorAddress ? [] : this.deps.nodeKeyStore.getPublisherAddresses(validatorAddress);
57
+ const filter: PublisherFilter<L1TxUtilsWithBlobs> = !validatorAddress
58
+ ? () => true
59
+ : (utils: L1TxUtilsWithBlobs) => {
60
+ const publisherAddress = utils.getSenderAddress();
61
+ return allowedPublishers.some(allowedPublisher => allowedPublisher.equals(publisherAddress));
62
+ };
63
+
64
+ const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
65
+ const attestorAddress =
66
+ validatorAddress ?? this.deps.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
67
+
68
+ const rollup = this.deps.rollupContract;
69
+ const slashingProposerContract = await rollup.getSlashingProposer();
70
+
71
+ const publisher = new SequencerPublisher(this.sequencerConfig, {
72
+ l1TxUtils: l1Publisher,
73
+ telemetry: this.deps.telemetry,
74
+ blobSinkClient: this.deps.blobSinkClient,
75
+ rollupContract: this.deps.rollupContract,
76
+ epochCache: this.deps.epochCache,
77
+ governanceProposerContract: this.deps.governanceProposerContract,
78
+ slashingProposerContract,
79
+ slashFactoryContract: this.deps.slashFactoryContract,
80
+ dateProvider: this.deps.dateProvider,
81
+ metrics: this.publisherMetrics,
82
+ lastActions: this.lastActions,
83
+ log: this.logger.createChild('publisher'),
84
+ });
85
+
86
+ return {
87
+ attestorAddress,
88
+ publisher,
89
+ };
90
+ }
91
+ }
@@ -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
  }