@aztec/aztec-node 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2c0ee1788

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.
@@ -0,0 +1,131 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import {
3
+ type BlockData,
4
+ type BlockDataWithCheckpointContext,
5
+ type CheckpointedL2Block,
6
+ type CommitteeAttestation,
7
+ L2Block,
8
+ } from '@aztec/stdlib/block';
9
+ import type { CheckpointData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
10
+ import {
11
+ type BlockIncludeOptions,
12
+ type BlockResponse,
13
+ type CheckpointIncludeOptions,
14
+ type CheckpointResponse,
15
+ l1PublishInfoFromL1PublishedData,
16
+ } from '@aztec/stdlib/interfaces/client';
17
+
18
+ /** Projects a full {@link L2Block} into a {@link BlockResponse}, attaching L1 / attestation context when provided. */
19
+ export async function blockResponseFromL2Block(
20
+ block: L2Block,
21
+ options: BlockIncludeOptions,
22
+ context?: { l1?: BlockDataWithCheckpointContext['l1']; attestations?: CommitteeAttestation[] },
23
+ ): Promise<BlockResponse> {
24
+ const response: BlockResponse = {
25
+ header: block.header,
26
+ archive: block.archive,
27
+ hash: await block.hash(),
28
+ checkpointNumber: block.checkpointNumber,
29
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
30
+ number: block.number,
31
+ };
32
+ if (options.includeTransactions) {
33
+ (response as BlockResponse).body = block.body;
34
+ }
35
+ if (options.includeL1PublishInfo) {
36
+ (response as BlockResponse).l1 = l1PublishInfoFromL1PublishedData(context?.l1);
37
+ }
38
+ if (options.includeAttestations) {
39
+ (response as BlockResponse).attestations = context?.attestations ?? [];
40
+ }
41
+ return response;
42
+ }
43
+
44
+ /** Projects metadata-only {@link BlockData} into a {@link BlockResponse}. */
45
+ export function blockResponseFromBlockData(
46
+ data: BlockData,
47
+ blockNumber: BlockNumber,
48
+ options: BlockIncludeOptions,
49
+ context?: { l1?: BlockDataWithCheckpointContext['l1']; attestations?: CommitteeAttestation[] },
50
+ ): BlockResponse {
51
+ const response: BlockResponse = {
52
+ header: data.header,
53
+ archive: data.archive,
54
+ hash: data.blockHash,
55
+ checkpointNumber: data.checkpointNumber,
56
+ indexWithinCheckpoint: data.indexWithinCheckpoint,
57
+ number: blockNumber,
58
+ };
59
+ if (options.includeL1PublishInfo) {
60
+ (response as BlockResponse).l1 = l1PublishInfoFromL1PublishedData(context?.l1);
61
+ }
62
+ if (options.includeAttestations) {
63
+ (response as BlockResponse).attestations = context?.attestations ?? [];
64
+ }
65
+ return response;
66
+ }
67
+
68
+ /** Projects a {@link CheckpointedL2Block} into a {@link BlockResponse}. */
69
+ export function blockResponseFromCheckpointedL2Block(
70
+ cp: CheckpointedL2Block,
71
+ options: BlockIncludeOptions,
72
+ ): Promise<BlockResponse> {
73
+ return blockResponseFromL2Block(cp.block, options, { l1: cp.l1, attestations: cp.attestations });
74
+ }
75
+
76
+ /** Projects a {@link PublishedCheckpoint} into a {@link CheckpointResponse}. */
77
+ export async function checkpointResponseFromPublishedCheckpoint(
78
+ pc: PublishedCheckpoint,
79
+ options: CheckpointIncludeOptions,
80
+ ): Promise<CheckpointResponse> {
81
+ const response: CheckpointResponse = {
82
+ number: pc.checkpoint.number,
83
+ header: pc.checkpoint.header,
84
+ archive: pc.checkpoint.archive,
85
+ checkpointOutHash: pc.checkpoint.getCheckpointOutHash(),
86
+ startBlock: pc.checkpoint.blocks[0]?.number ?? BlockNumber.ZERO,
87
+ blockCount: pc.checkpoint.blocks.length,
88
+ feeAssetPriceModifier: pc.checkpoint.feeAssetPriceModifier,
89
+ };
90
+ if (options.includeBlocks) {
91
+ (response as CheckpointResponse).blocks = await Promise.all(
92
+ pc.checkpoint.blocks.map(block =>
93
+ blockResponseFromL2Block(block, {
94
+ includeTransactions: options.includeTransactions,
95
+ includeL1PublishInfo: false,
96
+ includeAttestations: false,
97
+ }),
98
+ ),
99
+ );
100
+ }
101
+ if (options.includeL1PublishInfo) {
102
+ (response as CheckpointResponse).l1 = l1PublishInfoFromL1PublishedData(pc.l1);
103
+ }
104
+ if (options.includeAttestations) {
105
+ (response as CheckpointResponse).attestations = pc.attestations;
106
+ }
107
+ return response;
108
+ }
109
+
110
+ /** Projects metadata-only {@link CheckpointData} into a {@link CheckpointResponse}. `includeBlocks` is ignored (no blocks loaded). */
111
+ export function checkpointResponseFromCheckpointData(
112
+ cd: CheckpointData,
113
+ options: CheckpointIncludeOptions,
114
+ ): CheckpointResponse {
115
+ const response: CheckpointResponse = {
116
+ number: cd.checkpointNumber,
117
+ header: cd.header,
118
+ archive: cd.archive,
119
+ checkpointOutHash: cd.checkpointOutHash,
120
+ startBlock: cd.startBlock,
121
+ blockCount: cd.blockCount,
122
+ feeAssetPriceModifier: cd.feeAssetPriceModifier,
123
+ };
124
+ if (options.includeL1PublishInfo) {
125
+ (response as CheckpointResponse).l1 = l1PublishInfoFromL1PublishedData(cd.l1);
126
+ }
127
+ if (options.includeAttestations) {
128
+ (response as CheckpointResponse).attestations = cd.attestations;
129
+ }
130
+ return response;
131
+ }
@@ -3,7 +3,6 @@ import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethe
3
3
  import { type L1ContractAddresses, l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
4
4
  import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
5
5
  import { EthAddress } from '@aztec/foundation/eth-address';
6
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
7
6
  import {
8
7
  type KeyStore,
9
8
  type ValidatorKeyStore,
@@ -13,15 +12,21 @@ import {
13
12
  import { type SharedNodeConfig, sharedNodeConfigMappings } from '@aztec/node-lib/config';
14
13
  import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
15
14
  import { type ProverClientUserConfig, proverClientConfigMappings } from '@aztec/prover-client/config';
15
+ import {
16
+ type ProverNodeConfig,
17
+ proverNodeConfigMappings,
18
+ specificProverNodeConfigMappings,
19
+ } from '@aztec/prover-node/config';
16
20
  import {
17
21
  type SequencerClientConfig,
18
- type TxSenderConfig,
22
+ type SequencerTxSenderConfig,
19
23
  sequencerClientConfigMappings,
20
24
  } from '@aztec/sequencer-client/config';
21
25
  import { slasherConfigMappings } from '@aztec/slasher';
22
26
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
23
27
  import { type NodeRPCConfig, nodeRpcConfigMappings } from '@aztec/stdlib/config';
24
28
  import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
29
+ import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
25
30
  import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
26
31
  import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state/config';
27
32
 
@@ -46,16 +51,18 @@ export type AztecNodeConfig = ArchiverConfig &
46
51
  SharedNodeConfig &
47
52
  GenesisStateConfig &
48
53
  NodeRPCConfig &
49
- SlasherConfig & {
54
+ SlasherConfig &
55
+ ProverNodeConfig & {
50
56
  /** L1 contracts addresses */
51
57
  l1Contracts: L1ContractAddresses;
52
58
  /** Whether the validator is disabled for this node */
53
59
  disableValidator: boolean;
54
60
  /** Whether to skip waiting for the archiver to be fully synced before starting other services */
55
61
  skipArchiverInitialSync: boolean;
56
-
57
62
  /** A flag to force verification of tx Chonk proofs. Only used for testnet */
58
63
  debugForceTxProofVerification: boolean;
64
+ /** Whether to enable the prover node as a subsystem. */
65
+ enableProverNode: boolean;
59
66
  };
60
67
 
61
68
  export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
@@ -63,6 +70,7 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
63
70
  ...keyStoreConfigMappings,
64
71
  ...archiverConfigMappings,
65
72
  ...sequencerClientConfigMappings,
73
+ ...proverNodeConfigMappings,
66
74
  ...validatorClientConfigMappings,
67
75
  ...proverClientConfigMappings,
68
76
  ...worldStateConfigMappings,
@@ -72,6 +80,7 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
72
80
  ...genesisStateConfigMappings,
73
81
  ...nodeRpcConfigMappings,
74
82
  ...slasherConfigMappings,
83
+ ...specificProverNodeConfigMappings,
75
84
  l1Contracts: {
76
85
  description: 'The deployed L1 contract addresses',
77
86
  nested: l1ContractAddressesMapping,
@@ -91,6 +100,11 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
91
100
  description: 'Whether to skip waiting for the archiver to be fully synced before starting other services.',
92
101
  ...booleanConfigHelper(false),
93
102
  },
103
+ enableProverNode: {
104
+ env: 'ENABLE_PROVER_NODE',
105
+ description: 'Whether to enable the prover node as a subsystem.',
106
+ ...booleanConfigHelper(false),
107
+ },
94
108
  };
95
109
 
96
110
  /**
@@ -101,7 +115,7 @@ export function getConfigEnvVars(): AztecNodeConfig {
101
115
  return getConfigFromMappings<AztecNodeConfig>(aztecNodeConfigMappings);
102
116
  }
103
117
 
104
- type ConfigRequiredToBuildKeyStore = TxSenderConfig & SequencerClientConfig & SharedNodeConfig & ValidatorClientConfig;
118
+ type ConfigRequiredToBuildKeyStore = SequencerClientConfig & SharedNodeConfig & ValidatorClientConfig;
105
119
 
106
120
  function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): KeyStore | undefined {
107
121
  const validatorKeyStores: ValidatorKeyStore[] = [];
@@ -120,7 +134,7 @@ function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): Ke
120
134
  feeRecipient: config.feeRecipient ?? AztecAddress.ZERO,
121
135
  coinbase: config.coinbase ?? config.validatorAddresses[0],
122
136
  remoteSigner: config.web3SignerUrl,
123
- publisher: config.publisherAddresses ?? [],
137
+ publisher: config.sequencerPublisherAddresses ?? [],
124
138
  });
125
139
 
126
140
  const keyStore: KeyStore = {
@@ -145,8 +159,10 @@ function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): K
145
159
  const coinbase = config.coinbase ?? EthAddress.fromString(privateKeyToAddress(ethPrivateKeys[0]));
146
160
  const feeRecipient = config.feeRecipient ?? AztecAddress.ZERO;
147
161
 
148
- const publisherKeys = config.publisherPrivateKeys
149
- ? config.publisherPrivateKeys.map((k: { getValue: () => string }) => ethPrivateKeySchema.parse(k.getValue()))
162
+ const publisherKeys = config.sequencerPublisherPrivateKeys
163
+ ? config.sequencerPublisherPrivateKeys.map((k: { getValue: () => string }) =>
164
+ ethPrivateKeySchema.parse(k.getValue()),
165
+ )
150
166
  : [];
151
167
 
152
168
  validatorKeyStores.push({
@@ -168,7 +184,7 @@ function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): K
168
184
  }
169
185
 
170
186
  export function createKeyStoreForValidator(
171
- config: TxSenderConfig & SequencerClientConfig & SharedNodeConfig,
187
+ config: SequencerTxSenderConfig & SequencerClientConfig & SharedNodeConfig,
172
188
  ): KeyStore | undefined {
173
189
  if (config.web3SignerUrl !== undefined && config.web3SignerUrl.length > 0) {
174
190
  return createKeyStoreFromWeb3Signer(config);
@@ -1,4 +1,11 @@
1
- import { Attributes, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
1
+ import {
2
+ Attributes,
3
+ type Histogram,
4
+ Metrics,
5
+ type TelemetryClient,
6
+ type UpDownCounter,
7
+ createUpDownCounterWithDefault,
8
+ } from '@aztec/telemetry-client';
2
9
 
3
10
  export class NodeMetrics {
4
11
  private receiveTxCount: UpDownCounter;
@@ -9,14 +16,14 @@ export class NodeMetrics {
9
16
 
10
17
  constructor(client: TelemetryClient, name = 'AztecNode') {
11
18
  const meter = client.getMeter(name);
12
- this.receiveTxCount = meter.createUpDownCounter(Metrics.NODE_RECEIVE_TX_COUNT);
19
+ this.receiveTxCount = createUpDownCounterWithDefault(meter, Metrics.NODE_RECEIVE_TX_COUNT, {
20
+ [Attributes.OK]: [true, false],
21
+ });
13
22
  this.receiveTxDuration = meter.createHistogram(Metrics.NODE_RECEIVE_TX_DURATION);
14
23
 
15
24
  this.snapshotDuration = meter.createHistogram(Metrics.NODE_SNAPSHOT_DURATION);
16
25
 
17
- this.snapshotErrorCount = meter.createUpDownCounter(Metrics.NODE_SNAPSHOT_ERROR_COUNT);
18
-
19
- this.snapshotErrorCount.add(0);
26
+ this.snapshotErrorCount = createUpDownCounterWithDefault(meter, Metrics.NODE_SNAPSHOT_ERROR_COUNT);
20
27
  }
21
28
 
22
29
  receivedTx(durationMs: number, isAccepted: boolean) {