@aztec/aztec-node 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05
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.
- package/dest/aztec-node/block_response_helpers.d.ts +21 -0
- package/dest/aztec-node/block_response_helpers.d.ts.map +1 -0
- package/dest/aztec-node/block_response_helpers.js +88 -0
- package/dest/aztec-node/config.d.ts +12 -6
- package/dest/aztec-node/config.d.ts.map +1 -1
- package/dest/aztec-node/config.js +18 -4
- package/dest/aztec-node/node_metrics.d.ts +1 -1
- package/dest/aztec-node/node_metrics.d.ts.map +1 -1
- package/dest/aztec-node/node_metrics.js +9 -16
- package/dest/aztec-node/server.d.ts +87 -178
- package/dest/aztec-node/server.d.ts.map +1 -1
- package/dest/aztec-node/server.js +1338 -431
- package/dest/sentinel/factory.d.ts +4 -3
- package/dest/sentinel/factory.d.ts.map +1 -1
- package/dest/sentinel/factory.js +1 -1
- package/dest/sentinel/sentinel.d.ts +11 -7
- package/dest/sentinel/sentinel.d.ts.map +1 -1
- package/dest/sentinel/sentinel.js +97 -60
- package/dest/sentinel/store.d.ts +2 -2
- package/dest/sentinel/store.d.ts.map +1 -1
- package/dest/sentinel/store.js +11 -7
- package/package.json +29 -28
- package/src/aztec-node/block_response_helpers.ts +131 -0
- package/src/aztec-node/config.ts +35 -15
- package/src/aztec-node/node_metrics.ts +6 -17
- package/src/aztec-node/server.ts +1153 -566
- package/src/sentinel/factory.ts +4 -8
- package/src/sentinel/sentinel.ts +119 -65
- package/src/sentinel/store.ts +12 -12
|
@@ -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
|
+
}
|
package/src/aztec-node/config.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type L1ContractAddresses,
|
|
5
|
-
genesisStateConfigMappings,
|
|
6
|
-
l1ContractAddressesMapping,
|
|
7
|
-
} from '@aztec/ethereum';
|
|
2
|
+
import { type GenesisStateConfig, genesisStateConfigMappings } from '@aztec/ethereum/config';
|
|
3
|
+
import { type L1ContractAddresses, l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
8
4
|
import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config';
|
|
9
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
11
6
|
import {
|
|
12
7
|
type KeyStore,
|
|
13
8
|
type ValidatorKeyStore,
|
|
@@ -17,15 +12,21 @@ import {
|
|
|
17
12
|
import { type SharedNodeConfig, sharedNodeConfigMappings } from '@aztec/node-lib/config';
|
|
18
13
|
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
19
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';
|
|
20
20
|
import {
|
|
21
21
|
type SequencerClientConfig,
|
|
22
|
-
type
|
|
22
|
+
type SequencerTxSenderConfig,
|
|
23
23
|
sequencerClientConfigMappings,
|
|
24
24
|
} from '@aztec/sequencer-client/config';
|
|
25
25
|
import { slasherConfigMappings } from '@aztec/slasher';
|
|
26
26
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
27
27
|
import { type NodeRPCConfig, nodeRpcConfigMappings } from '@aztec/stdlib/config';
|
|
28
28
|
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
29
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
29
30
|
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
30
31
|
import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state/config';
|
|
31
32
|
|
|
@@ -50,13 +51,18 @@ export type AztecNodeConfig = ArchiverConfig &
|
|
|
50
51
|
SharedNodeConfig &
|
|
51
52
|
GenesisStateConfig &
|
|
52
53
|
NodeRPCConfig &
|
|
53
|
-
SlasherConfig &
|
|
54
|
+
SlasherConfig &
|
|
55
|
+
ProverNodeConfig & {
|
|
54
56
|
/** L1 contracts addresses */
|
|
55
57
|
l1Contracts: L1ContractAddresses;
|
|
56
58
|
/** Whether the validator is disabled for this node */
|
|
57
59
|
disableValidator: boolean;
|
|
58
60
|
/** Whether to skip waiting for the archiver to be fully synced before starting other services */
|
|
59
61
|
skipArchiverInitialSync: boolean;
|
|
62
|
+
/** A flag to force verification of tx Chonk proofs. Only used for testnet */
|
|
63
|
+
debugForceTxProofVerification: boolean;
|
|
64
|
+
/** Whether to enable the prover node as a subsystem. */
|
|
65
|
+
enableProverNode: boolean;
|
|
60
66
|
};
|
|
61
67
|
|
|
62
68
|
export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
|
|
@@ -64,6 +70,7 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
|
|
|
64
70
|
...keyStoreConfigMappings,
|
|
65
71
|
...archiverConfigMappings,
|
|
66
72
|
...sequencerClientConfigMappings,
|
|
73
|
+
...proverNodeConfigMappings,
|
|
67
74
|
...validatorClientConfigMappings,
|
|
68
75
|
...proverClientConfigMappings,
|
|
69
76
|
...worldStateConfigMappings,
|
|
@@ -73,6 +80,7 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
|
|
|
73
80
|
...genesisStateConfigMappings,
|
|
74
81
|
...nodeRpcConfigMappings,
|
|
75
82
|
...slasherConfigMappings,
|
|
83
|
+
...specificProverNodeConfigMappings,
|
|
76
84
|
l1Contracts: {
|
|
77
85
|
description: 'The deployed L1 contract addresses',
|
|
78
86
|
nested: l1ContractAddressesMapping,
|
|
@@ -87,6 +95,16 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
|
|
|
87
95
|
description: 'Whether to skip waiting for the archiver to be fully synced before starting other services.',
|
|
88
96
|
...booleanConfigHelper(false),
|
|
89
97
|
},
|
|
98
|
+
debugForceTxProofVerification: {
|
|
99
|
+
env: 'DEBUG_FORCE_TX_PROOF_VERIFICATION',
|
|
100
|
+
description: 'Whether to skip waiting for the archiver to be fully synced before starting other services.',
|
|
101
|
+
...booleanConfigHelper(false),
|
|
102
|
+
},
|
|
103
|
+
enableProverNode: {
|
|
104
|
+
env: 'ENABLE_PROVER_NODE',
|
|
105
|
+
description: 'Whether to enable the prover node as a subsystem.',
|
|
106
|
+
...booleanConfigHelper(false),
|
|
107
|
+
},
|
|
90
108
|
};
|
|
91
109
|
|
|
92
110
|
/**
|
|
@@ -97,7 +115,7 @@ export function getConfigEnvVars(): AztecNodeConfig {
|
|
|
97
115
|
return getConfigFromMappings<AztecNodeConfig>(aztecNodeConfigMappings);
|
|
98
116
|
}
|
|
99
117
|
|
|
100
|
-
type ConfigRequiredToBuildKeyStore =
|
|
118
|
+
type ConfigRequiredToBuildKeyStore = SequencerClientConfig & SharedNodeConfig & ValidatorClientConfig;
|
|
101
119
|
|
|
102
120
|
function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): KeyStore | undefined {
|
|
103
121
|
const validatorKeyStores: ValidatorKeyStore[] = [];
|
|
@@ -116,7 +134,7 @@ function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): Ke
|
|
|
116
134
|
feeRecipient: config.feeRecipient ?? AztecAddress.ZERO,
|
|
117
135
|
coinbase: config.coinbase ?? config.validatorAddresses[0],
|
|
118
136
|
remoteSigner: config.web3SignerUrl,
|
|
119
|
-
publisher: config.
|
|
137
|
+
publisher: config.sequencerPublisherAddresses ?? [],
|
|
120
138
|
});
|
|
121
139
|
|
|
122
140
|
const keyStore: KeyStore = {
|
|
@@ -132,7 +150,7 @@ function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): Ke
|
|
|
132
150
|
function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): KeyStore | undefined {
|
|
133
151
|
const validatorKeyStores: ValidatorKeyStore[] = [];
|
|
134
152
|
const ethPrivateKeys = config.validatorPrivateKeys
|
|
135
|
-
? config.validatorPrivateKeys.getValue().map(x => ethPrivateKeySchema.parse(x))
|
|
153
|
+
? config.validatorPrivateKeys.getValue().map((x: string) => ethPrivateKeySchema.parse(x))
|
|
136
154
|
: [];
|
|
137
155
|
|
|
138
156
|
if (!ethPrivateKeys.length) {
|
|
@@ -141,8 +159,10 @@ function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): K
|
|
|
141
159
|
const coinbase = config.coinbase ?? EthAddress.fromString(privateKeyToAddress(ethPrivateKeys[0]));
|
|
142
160
|
const feeRecipient = config.feeRecipient ?? AztecAddress.ZERO;
|
|
143
161
|
|
|
144
|
-
const publisherKeys = config.
|
|
145
|
-
? config.
|
|
162
|
+
const publisherKeys = config.sequencerPublisherPrivateKeys
|
|
163
|
+
? config.sequencerPublisherPrivateKeys.map((k: { getValue: () => string }) =>
|
|
164
|
+
ethPrivateKeySchema.parse(k.getValue()),
|
|
165
|
+
)
|
|
146
166
|
: [];
|
|
147
167
|
|
|
148
168
|
validatorKeyStores.push({
|
|
@@ -164,7 +184,7 @@ function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): K
|
|
|
164
184
|
}
|
|
165
185
|
|
|
166
186
|
export function createKeyStoreForValidator(
|
|
167
|
-
config:
|
|
187
|
+
config: SequencerTxSenderConfig & SequencerClientConfig & SharedNodeConfig,
|
|
168
188
|
): KeyStore | undefined {
|
|
169
189
|
if (config.web3SignerUrl !== undefined && config.web3SignerUrl.length > 0) {
|
|
170
190
|
return createKeyStoreFromWeb3Signer(config);
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Metrics,
|
|
5
5
|
type TelemetryClient,
|
|
6
6
|
type UpDownCounter,
|
|
7
|
-
|
|
7
|
+
createUpDownCounterWithDefault,
|
|
8
8
|
} from '@aztec/telemetry-client';
|
|
9
9
|
|
|
10
10
|
export class NodeMetrics {
|
|
@@ -16,25 +16,14 @@ export class NodeMetrics {
|
|
|
16
16
|
|
|
17
17
|
constructor(client: TelemetryClient, name = 'AztecNode') {
|
|
18
18
|
const meter = client.getMeter(name);
|
|
19
|
-
this.receiveTxCount = meter
|
|
20
|
-
|
|
21
|
-
description: 'The duration of the receiveTx method',
|
|
22
|
-
unit: 'ms',
|
|
23
|
-
valueType: ValueType.INT,
|
|
19
|
+
this.receiveTxCount = createUpDownCounterWithDefault(meter, Metrics.NODE_RECEIVE_TX_COUNT, {
|
|
20
|
+
[Attributes.OK]: [true, false],
|
|
24
21
|
});
|
|
22
|
+
this.receiveTxDuration = meter.createHistogram(Metrics.NODE_RECEIVE_TX_DURATION);
|
|
25
23
|
|
|
26
|
-
this.snapshotDuration = meter.createHistogram(Metrics.NODE_SNAPSHOT_DURATION
|
|
27
|
-
description: 'How long taking a snapshot takes',
|
|
28
|
-
unit: 'ms',
|
|
29
|
-
valueType: ValueType.INT,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
this.snapshotErrorCount = meter.createUpDownCounter(Metrics.NODE_SNAPSHOT_ERROR_COUNT, {
|
|
33
|
-
description: 'How many snapshot errors have happened',
|
|
34
|
-
valueType: ValueType.INT,
|
|
35
|
-
});
|
|
24
|
+
this.snapshotDuration = meter.createHistogram(Metrics.NODE_SNAPSHOT_DURATION);
|
|
36
25
|
|
|
37
|
-
this.snapshotErrorCount.
|
|
26
|
+
this.snapshotErrorCount = createUpDownCounterWithDefault(meter, Metrics.NODE_SNAPSHOT_ERROR_COUNT);
|
|
38
27
|
}
|
|
39
28
|
|
|
40
29
|
receivedTx(durationMs: number, isAccepted: boolean) {
|