@aztec/aztec 1.0.0-staging.3 → 1.0.0
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/bin/index.js +4 -2
- package/dest/cli/chain_l2_config.d.ts +6 -45
- package/dest/cli/chain_l2_config.d.ts.map +1 -1
- package/dest/cli/chain_l2_config.js +21 -115
- package/dest/cli/util.d.ts +1 -12
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +15 -71
- package/package.json +30 -30
- package/src/bin/index.ts +6 -3
- package/src/cli/chain_l2_config.ts +26 -188
- package/src/cli/util.ts +16 -64
package/dest/bin/index.js
CHANGED
|
@@ -8,7 +8,6 @@ import { injectCommands as injectInfrastructureCommands } from '@aztec/cli/infra
|
|
|
8
8
|
import { injectCommands as injectL1Commands } from '@aztec/cli/l1';
|
|
9
9
|
import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
|
|
10
10
|
import { injectCommands as injectPXECommands } from '@aztec/cli/pxe';
|
|
11
|
-
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
12
11
|
import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
13
12
|
import { Command } from 'commander';
|
|
14
13
|
import { NETWORK_FLAG } from '../cli/aztec_start_options.js';
|
|
@@ -30,7 +29,10 @@ const debugLogger = createLogger('cli');
|
|
|
30
29
|
if (networkIndex !== -1) {
|
|
31
30
|
networkValue = args[networkIndex].split('=')[1] || args[networkIndex + 1];
|
|
32
31
|
}
|
|
33
|
-
|
|
32
|
+
networkValue = networkValue || process.env.NETWORK;
|
|
33
|
+
if (networkValue !== undefined) {
|
|
34
|
+
await enrichEnvironmentWithChainConfig(networkValue);
|
|
35
|
+
}
|
|
34
36
|
const cliVersion = getCliVersion();
|
|
35
37
|
let program = new Command('aztec');
|
|
36
38
|
program.description('Aztec command line interface').version(cliVersion);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { NetworkNames } from '@aztec/foundation/config';
|
|
2
1
|
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
2
|
+
export type NetworkNames = 'testnet-ignition' | 'alpha-testnet';
|
|
3
3
|
export type L2ChainConfig = {
|
|
4
4
|
l1ChainId: number;
|
|
5
|
+
ethereumSlotDuration: number;
|
|
6
|
+
aztecSlotDuration: number;
|
|
7
|
+
aztecEpochDuration: number;
|
|
8
|
+
aztecProofSubmissionEpochs: number;
|
|
5
9
|
testAccounts: boolean;
|
|
6
10
|
sponsoredFPC: boolean;
|
|
7
11
|
p2pEnabled: boolean;
|
|
@@ -16,53 +20,10 @@ export type L2ChainConfig = {
|
|
|
16
20
|
autoUpdate: SharedNodeConfig['autoUpdate'];
|
|
17
21
|
autoUpdateUrl?: string;
|
|
18
22
|
maxTxPoolSize: number;
|
|
19
|
-
publicIncludeMetrics?: string[];
|
|
20
|
-
publicMetricsCollectorUrl?: string;
|
|
21
|
-
publicMetricsCollectFrom?: string[];
|
|
22
|
-
/** How many seconds an L1 slot lasts. */
|
|
23
|
-
ethereumSlotDuration: number;
|
|
24
|
-
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
|
|
25
|
-
aztecSlotDuration: number;
|
|
26
|
-
/** How many L2 slots an epoch lasts. */
|
|
27
|
-
aztecEpochDuration: number;
|
|
28
|
-
/** The target validator committee size. */
|
|
29
|
-
aztecTargetCommitteeSize: number;
|
|
30
|
-
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
31
|
-
aztecProofSubmissionEpochs: number;
|
|
32
|
-
/** The deposit amount for a validator */
|
|
33
|
-
depositAmount: bigint;
|
|
34
|
-
/** The minimum stake for a validator. */
|
|
35
|
-
minimumStake: bigint;
|
|
36
|
-
/** The slashing quorum */
|
|
37
|
-
slashingQuorum: number;
|
|
38
|
-
/** The slashing round size */
|
|
39
|
-
slashingRoundSize: number;
|
|
40
|
-
/** Governance proposing quorum */
|
|
41
|
-
governanceProposerQuorum: number;
|
|
42
|
-
/** Governance proposing round size */
|
|
43
|
-
governanceProposerRoundSize: number;
|
|
44
|
-
/** The mana target for the rollup */
|
|
45
|
-
manaTarget: bigint;
|
|
46
|
-
/** The proving cost per mana */
|
|
47
|
-
provingCostPerMana: bigint;
|
|
48
|
-
slashPayloadTtlSeconds: number;
|
|
49
|
-
slashPruneEnabled: boolean;
|
|
50
|
-
slashPrunePenalty: bigint;
|
|
51
|
-
slashPruneMaxPenalty: bigint;
|
|
52
|
-
slashInactivityEnabled: boolean;
|
|
53
|
-
slashInactivityCreateTargetPercentage: number;
|
|
54
|
-
slashInactivitySignalTargetPercentage: number;
|
|
55
|
-
slashInactivityCreatePenalty: bigint;
|
|
56
|
-
slashInvalidBlockEnabled: boolean;
|
|
57
|
-
slashInvalidBlockPenalty: bigint;
|
|
58
|
-
slashInvalidBlockMaxPenalty: bigint;
|
|
59
23
|
};
|
|
60
24
|
export declare const testnetIgnitionL2ChainConfig: L2ChainConfig;
|
|
61
25
|
export declare const alphaTestnetL2ChainConfig: L2ChainConfig;
|
|
62
26
|
export declare function getBootnodes(networkName: NetworkNames): Promise<any>;
|
|
63
|
-
export declare function getL2ChainConfig(networkName: NetworkNames): Promise<
|
|
64
|
-
config: L2ChainConfig;
|
|
65
|
-
networkName: string;
|
|
66
|
-
} | undefined>;
|
|
27
|
+
export declare function getL2ChainConfig(networkName: NetworkNames): Promise<L2ChainConfig | undefined>;
|
|
67
28
|
export declare function enrichEnvironmentWithChainConfig(networkName: NetworkNames): Promise<void>;
|
|
68
29
|
//# sourceMappingURL=chain_l2_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/cli/chain_l2_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/cli/chain_l2_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,eAAe,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,aAoB1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,aAoBvC,CAAC;AAEF,wBAAsB,YAAY,CAAC,WAAW,EAAE,YAAY,gBAW3D;AAED,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAWpG;AAmBD,wBAAsB,gCAAgC,CAAC,WAAW,EAAE,YAAY,iBAiC/E"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
-
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
3
2
|
import path from 'path';
|
|
4
|
-
import publicIncludeMetrics from '../../public_include_metric_prefixes.json' with {
|
|
5
|
-
type: 'json'
|
|
6
|
-
};
|
|
7
3
|
export const testnetIgnitionL2ChainConfig = {
|
|
8
4
|
l1ChainId: 11155111,
|
|
5
|
+
ethereumSlotDuration: 12,
|
|
6
|
+
aztecSlotDuration: 36,
|
|
7
|
+
aztecEpochDuration: 32,
|
|
8
|
+
aztecProofSubmissionEpochs: 1,
|
|
9
9
|
testAccounts: true,
|
|
10
10
|
sponsoredFPC: false,
|
|
11
11
|
p2pEnabled: true,
|
|
@@ -19,36 +19,14 @@ export const testnetIgnitionL2ChainConfig = {
|
|
|
19
19
|
snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/',
|
|
20
20
|
autoUpdate: 'disabled',
|
|
21
21
|
autoUpdateUrl: undefined,
|
|
22
|
-
maxTxPoolSize: 100_000_000
|
|
23
|
-
// Deployment stuff
|
|
24
|
-
/** How many seconds an L1 slot lasts. */ ethereumSlotDuration: 12,
|
|
25
|
-
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 36,
|
|
26
|
-
/** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
|
|
27
|
-
/** The target validator committee size. */ aztecTargetCommitteeSize: 48,
|
|
28
|
-
/** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
|
|
29
|
-
/** The deposit amount for a validator */ depositAmount: DefaultL1ContractsConfig.depositAmount,
|
|
30
|
-
/** The minimum stake for a validator. */ minimumStake: DefaultL1ContractsConfig.minimumStake,
|
|
31
|
-
/** The slashing quorum */ slashingQuorum: DefaultL1ContractsConfig.slashingQuorum,
|
|
32
|
-
/** The slashing round size */ slashingRoundSize: DefaultL1ContractsConfig.slashingRoundSize,
|
|
33
|
-
/** Governance proposing quorum */ governanceProposerQuorum: DefaultL1ContractsConfig.governanceProposerQuorum,
|
|
34
|
-
/** Governance proposing round size */ governanceProposerRoundSize: DefaultL1ContractsConfig.governanceProposerRoundSize,
|
|
35
|
-
/** The mana target for the rollup */ manaTarget: 0n,
|
|
36
|
-
/** The proving cost per mana */ provingCostPerMana: 0n,
|
|
37
|
-
// slashing stuff
|
|
38
|
-
slashInactivityEnabled: false,
|
|
39
|
-
slashInactivityCreateTargetPercentage: 0,
|
|
40
|
-
slashInactivitySignalTargetPercentage: 0,
|
|
41
|
-
slashInactivityCreatePenalty: 0n,
|
|
42
|
-
slashInvalidBlockEnabled: false,
|
|
43
|
-
slashPayloadTtlSeconds: 0,
|
|
44
|
-
slashPruneEnabled: false,
|
|
45
|
-
slashPrunePenalty: 0n,
|
|
46
|
-
slashPruneMaxPenalty: 0n,
|
|
47
|
-
slashInvalidBlockPenalty: 0n,
|
|
48
|
-
slashInvalidBlockMaxPenalty: 0n
|
|
22
|
+
maxTxPoolSize: 100_000_000
|
|
49
23
|
};
|
|
50
24
|
export const alphaTestnetL2ChainConfig = {
|
|
51
25
|
l1ChainId: 11155111,
|
|
26
|
+
ethereumSlotDuration: 12,
|
|
27
|
+
aztecSlotDuration: 36,
|
|
28
|
+
aztecEpochDuration: 32,
|
|
29
|
+
aztecProofSubmissionEpochs: 1,
|
|
52
30
|
testAccounts: false,
|
|
53
31
|
sponsoredFPC: true,
|
|
54
32
|
p2pEnabled: true,
|
|
@@ -62,38 +40,7 @@ export const alphaTestnetL2ChainConfig = {
|
|
|
62
40
|
snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/',
|
|
63
41
|
autoUpdate: 'config-and-version',
|
|
64
42
|
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/alpha-testnet.json',
|
|
65
|
-
maxTxPoolSize:
|
|
66
|
-
publicIncludeMetrics,
|
|
67
|
-
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec.network',
|
|
68
|
-
publicMetricsCollectFrom: [
|
|
69
|
-
'sequencer'
|
|
70
|
-
],
|
|
71
|
-
// Deployment stuff
|
|
72
|
-
/** How many seconds an L1 slot lasts. */ ethereumSlotDuration: 12,
|
|
73
|
-
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */ aztecSlotDuration: 36,
|
|
74
|
-
/** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
|
|
75
|
-
/** The target validator committee size. */ aztecTargetCommitteeSize: 48,
|
|
76
|
-
/** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
|
|
77
|
-
/** The deposit amount for a validator */ depositAmount: DefaultL1ContractsConfig.depositAmount,
|
|
78
|
-
/** The minimum stake for a validator. */ minimumStake: DefaultL1ContractsConfig.minimumStake,
|
|
79
|
-
/** The slashing quorum */ slashingQuorum: 101,
|
|
80
|
-
/** The slashing round size */ slashingRoundSize: 200,
|
|
81
|
-
/** Governance proposing quorum */ governanceProposerQuorum: 151,
|
|
82
|
-
/** Governance proposing round size */ governanceProposerRoundSize: 300,
|
|
83
|
-
/** The mana target for the rollup */ manaTarget: DefaultL1ContractsConfig.manaTarget,
|
|
84
|
-
/** The proving cost per mana */ provingCostPerMana: DefaultL1ContractsConfig.provingCostPerMana,
|
|
85
|
-
// slashing stuff
|
|
86
|
-
slashPayloadTtlSeconds: 36 * 32 * 24,
|
|
87
|
-
slashPruneEnabled: true,
|
|
88
|
-
slashPrunePenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
|
|
89
|
-
slashPruneMaxPenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
|
|
90
|
-
slashInactivityEnabled: true,
|
|
91
|
-
slashInactivityCreateTargetPercentage: 1,
|
|
92
|
-
slashInactivitySignalTargetPercentage: 1,
|
|
93
|
-
slashInactivityCreatePenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
|
|
94
|
-
slashInvalidBlockEnabled: true,
|
|
95
|
-
slashInvalidBlockPenalty: DefaultL1ContractsConfig.depositAmount,
|
|
96
|
-
slashInvalidBlockMaxPenalty: DefaultL1ContractsConfig.depositAmount
|
|
43
|
+
maxTxPoolSize: 2 * 1024 * 1024 * 1024
|
|
97
44
|
};
|
|
98
45
|
export async function getBootnodes(networkName) {
|
|
99
46
|
const url = `http://static.aztec.network/${networkName}/bootnodes.json`;
|
|
@@ -110,19 +57,13 @@ export async function getL2ChainConfig(networkName) {
|
|
|
110
57
|
...testnetIgnitionL2ChainConfig
|
|
111
58
|
};
|
|
112
59
|
config.p2pBootstrapNodes = await getBootnodes(networkName);
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
networkName
|
|
116
|
-
};
|
|
117
|
-
} else if (networkName === 'alpha-testnet' || networkName === 'testnet') {
|
|
60
|
+
return config;
|
|
61
|
+
} else if (networkName === 'alpha-testnet') {
|
|
118
62
|
const config = {
|
|
119
63
|
...alphaTestnetL2ChainConfig
|
|
120
64
|
};
|
|
121
|
-
config.p2pBootstrapNodes = await getBootnodes(
|
|
122
|
-
return
|
|
123
|
-
config,
|
|
124
|
-
networkName: 'alpha-testnet'
|
|
125
|
-
};
|
|
65
|
+
config.p2pBootstrapNodes = await getBootnodes(networkName);
|
|
66
|
+
return config;
|
|
126
67
|
}
|
|
127
68
|
return undefined;
|
|
128
69
|
}
|
|
@@ -142,14 +83,14 @@ function enrichEthAddressVar(envVar, value) {
|
|
|
142
83
|
enrichVar(envVar, value);
|
|
143
84
|
}
|
|
144
85
|
export async function enrichEnvironmentWithChainConfig(networkName) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
const result = await getL2ChainConfig(networkName);
|
|
149
|
-
if (!result) {
|
|
86
|
+
const config = await getL2ChainConfig(networkName);
|
|
87
|
+
if (!config) {
|
|
150
88
|
throw new Error(`Unknown network name: ${networkName}`);
|
|
151
89
|
}
|
|
152
|
-
|
|
90
|
+
enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
|
|
91
|
+
enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
|
|
92
|
+
enrichVar('AZTEC_EPOCH_DURATION', config.aztecEpochDuration.toString());
|
|
93
|
+
enrichVar('AZTEC_PROOF_SUBMISSION_EPOCHS', config.aztecProofSubmissionEpochs.toString());
|
|
153
94
|
enrichVar('BOOTSTRAP_NODES', config.p2pBootstrapNodes.join(','));
|
|
154
95
|
enrichVar('TEST_ACCOUNTS', config.testAccounts.toString());
|
|
155
96
|
enrichVar('SPONSORED_FPC', config.sponsoredFPC.toString());
|
|
@@ -157,7 +98,7 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
|
|
|
157
98
|
enrichVar('L1_CHAIN_ID', config.l1ChainId.toString());
|
|
158
99
|
enrichVar('SEQ_MIN_TX_PER_BLOCK', config.seqMinTxsPerBlock.toString());
|
|
159
100
|
enrichVar('SEQ_MAX_TX_PER_BLOCK', config.seqMaxTxsPerBlock.toString());
|
|
160
|
-
enrichVar('DATA_DIRECTORY', path.join(process.env.HOME || '~', '.aztec',
|
|
101
|
+
enrichVar('DATA_DIRECTORY', path.join(process.env.HOME || '~', '.aztec', networkName, 'data'));
|
|
161
102
|
enrichVar('PROVER_REAL_PROOFS', config.realProofs.toString());
|
|
162
103
|
enrichVar('PXE_PROVER_ENABLED', config.realProofs.toString());
|
|
163
104
|
enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl);
|
|
@@ -168,42 +109,7 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
|
|
|
168
109
|
if (config.autoUpdateUrl) {
|
|
169
110
|
enrichVar('AUTO_UPDATE_URL', config.autoUpdateUrl);
|
|
170
111
|
}
|
|
171
|
-
if (config.publicIncludeMetrics) {
|
|
172
|
-
enrichVar('PUBLIC_OTEL_INCLUDE_METRICS', config.publicIncludeMetrics.join(','));
|
|
173
|
-
}
|
|
174
|
-
if (config.publicMetricsCollectorUrl) {
|
|
175
|
-
enrichVar('PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT', config.publicMetricsCollectorUrl);
|
|
176
|
-
}
|
|
177
|
-
if (config.publicMetricsCollectFrom) {
|
|
178
|
-
enrichVar('PUBLIC_OTEL_COLLECT_FROM', config.publicMetricsCollectFrom.join(','));
|
|
179
|
-
}
|
|
180
112
|
enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', config.registryAddress);
|
|
181
113
|
enrichEthAddressVar('SLASH_FACTORY_CONTRACT_ADDRESS', config.slashFactoryAddress);
|
|
182
114
|
enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', config.feeAssetHandlerAddress);
|
|
183
|
-
// Deployment stuff
|
|
184
|
-
enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
|
|
185
|
-
enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
|
|
186
|
-
enrichVar('AZTEC_EPOCH_DURATION', config.aztecEpochDuration.toString());
|
|
187
|
-
enrichVar('AZTEC_TARGET_COMMITTEE_SIZE', config.aztecTargetCommitteeSize.toString());
|
|
188
|
-
enrichVar('AZTEC_PROOF_SUBMISSION_EPOCHS', config.aztecProofSubmissionEpochs.toString());
|
|
189
|
-
enrichVar('AZTEC_DEPOSIT_AMOUNT', config.depositAmount.toString());
|
|
190
|
-
enrichVar('AZTEC_MINIMUM_STAKE', config.minimumStake.toString());
|
|
191
|
-
enrichVar('AZTEC_SLASHING_QUORUM', config.slashingQuorum.toString());
|
|
192
|
-
enrichVar('AZTEC_SLASHING_ROUND_SIZE', config.slashingRoundSize.toString());
|
|
193
|
-
enrichVar('AZTEC_GOVERNANCE_PROPOSER_QUORUM', config.governanceProposerQuorum.toString());
|
|
194
|
-
enrichVar('AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE', config.governanceProposerRoundSize.toString());
|
|
195
|
-
enrichVar('AZTEC_MANA_TARGET', config.manaTarget.toString());
|
|
196
|
-
enrichVar('AZTEC_PROVING_COST_PER_MANA', config.provingCostPerMana.toString());
|
|
197
|
-
// Slashing
|
|
198
|
-
enrichVar('SLASH_PAYLOAD_TTL_SECONDS', config.slashPayloadTtlSeconds.toString());
|
|
199
|
-
enrichVar('SLASH_PRUNE_ENABLED', config.slashPruneEnabled.toString());
|
|
200
|
-
enrichVar('SLASH_PRUNE_PENALTY', config.slashPrunePenalty.toString());
|
|
201
|
-
enrichVar('SLASH_PRUNE_MAX_PENALTY', config.slashPruneMaxPenalty.toString());
|
|
202
|
-
enrichVar('SLASH_INACTIVITY_ENABLED', config.slashInactivityEnabled.toString());
|
|
203
|
-
enrichVar('SLASH_INACTIVITY_CREATE_TARGET_PERCENTAGE', config.slashInactivityCreateTargetPercentage.toString());
|
|
204
|
-
enrichVar('SLASH_INACTIVITY_SIGNAL_TARGET_PERCENTAGE', config.slashInactivitySignalTargetPercentage.toString());
|
|
205
|
-
enrichVar('SLASH_INACTIVITY_CREATE_PENALTY', config.slashInactivityCreatePenalty.toString());
|
|
206
|
-
enrichVar('SLASH_INVALID_BLOCK_ENABLED', config.slashInvalidBlockEnabled.toString());
|
|
207
|
-
enrichVar('SLASH_INVALID_BLOCK_PENALTY', config.slashInvalidBlockPenalty.toString());
|
|
208
|
-
enrichVar('SLASH_INVALID_BLOCK_MAX_PENALTY', config.slashInvalidBlockMaxPenalty.toString());
|
|
209
115
|
}
|
package/dest/cli/util.d.ts
CHANGED
|
@@ -8,18 +8,6 @@ import type { PXEService } from '@aztec/pxe/server';
|
|
|
8
8
|
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
|
|
9
9
|
import type { Command } from 'commander';
|
|
10
10
|
import { type AztecStartOption } from './aztec_start_options.js';
|
|
11
|
-
export declare const enum ExitCode {
|
|
12
|
-
SUCCESS = 0,
|
|
13
|
-
ERROR = 1,
|
|
14
|
-
ROLLUP_UPGRADE = 78,// EX_CONFIG from FreeBSD (https://man.freebsd.org/cgi/man.cgi?query=sysexits)
|
|
15
|
-
VERSION_UPGRADE = 79,// prev + 1 because there's nothing better
|
|
16
|
-
SIGHUP = 129,
|
|
17
|
-
SIGINT = 130,
|
|
18
|
-
SIGQUIT = 131,
|
|
19
|
-
SIGTERM = 143
|
|
20
|
-
}
|
|
21
|
-
export declare function shutdown(logFn: LogFn, exitCode: ExitCode, cb?: Array<() => Promise<void>>): Promise<never>;
|
|
22
|
-
export declare function isShuttingDown(): boolean;
|
|
23
11
|
export declare const installSignalHandlers: (logFn: LogFn, cb?: Array<() => Promise<void>>) => void;
|
|
24
12
|
/**
|
|
25
13
|
* Creates logs for the initial accounts
|
|
@@ -72,4 +60,5 @@ export declare function preloadCrsDataForVerifying({ realProofs }: Pick<AztecNod
|
|
|
72
60
|
*/
|
|
73
61
|
export declare function preloadCrsDataForServerSideProving({ realProofs }: Pick<ProverConfig, 'realProofs'>, log: LogFn): Promise<void>;
|
|
74
62
|
export declare function setupUpdateMonitor(autoUpdateMode: SharedNodeConfig['autoUpdate'], updatesLocation: URL, followsCanonicalRollup: boolean, publicClient: ViemClient, registryContractAddress: EthAddress, signalHandlers: Array<() => Promise<void>>, updateNodeConfig?: (config: object) => Promise<void>): Promise<void>;
|
|
63
|
+
export declare function shutdown(logFn: LogFn, cb?: Array<() => Promise<void>>): Promise<void>;
|
|
75
64
|
//# sourceMappingURL=util.d.ts.map
|
package/dest/cli/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/cli/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAKpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,0BAA0B,CAAC;AAEpF,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/cli/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAKpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,0BAA0B,CAAC;AAEpF,eAAO,MAAM,qBAAqB,GAAI,OAAO,KAAK,EAAE,KAAK,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,SAOlF,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,sBAAsB,EAAE;IACtB;;OAEG;IACH,OAAO,EAAE,cAAc,CAAC;IACxB;;OAEG;IACH,SAAS,EAAE,EAAE,CAAC;CACf,EAAE,EACH,GAAG,EAAE,UAAU,qBAyBhB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;CAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAiB/F;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAKR;AAmBD,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,EAAE,SAAS,gBAAgB,EAAE,SASnE,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAwBnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,WAAW,MAAM,wBASvF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,EACtC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,UAAU,kBAAkB,CAAC,CAAC,CAAC,EAC/B,WAAW,MAAM,KAChB,CA8BF,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,EACnD,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,IAAI,CAAC,CAKf;AAED;;;;GAIG;AACH,wBAAsB,kCAAkC,CACtD,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,EAChD,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,kBAAkB,CACtC,cAAc,EAAE,gBAAgB,CAAC,YAAY,CAAC,EAC9C,eAAe,EAAE,GAAG,EACpB,sBAAsB,EAAE,OAAO,EAC/B,YAAY,EAAE,UAAU,EACxB,uBAAuB,EAAE,UAAU,EACnC,cAAc,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAC1C,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,iBA+DrD;AAED,wBAAsB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,iBAM3E"}
|
package/dest/cli/util.js
CHANGED
|
@@ -3,63 +3,13 @@ import { UpdateChecker } from '@aztec/stdlib/update-checker';
|
|
|
3
3
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { aztecStartOptions } from './aztec_start_options.js';
|
|
6
|
-
export var ExitCode = /*#__PURE__*/ function(ExitCode) {
|
|
7
|
-
ExitCode[ExitCode["SUCCESS"] = 0] = "SUCCESS";
|
|
8
|
-
ExitCode[ExitCode["ERROR"] = 1] = "ERROR";
|
|
9
|
-
ExitCode[ExitCode["ROLLUP_UPGRADE"] = 78] = "ROLLUP_UPGRADE";
|
|
10
|
-
ExitCode[ExitCode["VERSION_UPGRADE"] = 79] = "VERSION_UPGRADE";
|
|
11
|
-
// 128 + int(SIGNAL)
|
|
12
|
-
ExitCode[ExitCode["SIGHUP"] = 129] = "SIGHUP";
|
|
13
|
-
ExitCode[ExitCode["SIGINT"] = 130] = "SIGINT";
|
|
14
|
-
ExitCode[ExitCode["SIGQUIT"] = 131] = "SIGQUIT";
|
|
15
|
-
ExitCode[ExitCode["SIGTERM"] = 143] = "SIGTERM";
|
|
16
|
-
return ExitCode;
|
|
17
|
-
}({});
|
|
18
|
-
let shutdownPromise;
|
|
19
|
-
export function shutdown(logFn, exitCode, cb) {
|
|
20
|
-
if (shutdownPromise) {
|
|
21
|
-
logFn('Already shutting down.');
|
|
22
|
-
return shutdownPromise;
|
|
23
|
-
}
|
|
24
|
-
logFn('Shutting down...', {
|
|
25
|
-
exitCode
|
|
26
|
-
});
|
|
27
|
-
if (cb) {
|
|
28
|
-
shutdownPromise = Promise.allSettled(cb).then(()=>process.exit(exitCode));
|
|
29
|
-
} else {
|
|
30
|
-
// synchronously shuts down the process
|
|
31
|
-
// no need to set shutdownPromise on this branch of the if statement because no more code will be executed
|
|
32
|
-
process.exit(exitCode);
|
|
33
|
-
}
|
|
34
|
-
return shutdownPromise;
|
|
35
|
-
}
|
|
36
|
-
export function isShuttingDown() {
|
|
37
|
-
return shutdownPromise !== undefined;
|
|
38
|
-
}
|
|
39
6
|
export const installSignalHandlers = (logFn, cb)=>{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'SIGTERM',
|
|
47
|
-
143
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
'SIGHUP',
|
|
51
|
-
129
|
|
52
|
-
],
|
|
53
|
-
[
|
|
54
|
-
'SIQUIT',
|
|
55
|
-
131
|
|
56
|
-
]
|
|
57
|
-
];
|
|
58
|
-
for (const [signal, exitCode] of signals){
|
|
59
|
-
process.removeAllListeners(signal);
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
61
|
-
process.once(signal, ()=>shutdown(logFn, exitCode, cb));
|
|
62
|
-
}
|
|
7
|
+
process.removeAllListeners('SIGINT');
|
|
8
|
+
process.removeAllListeners('SIGTERM');
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
10
|
+
process.once('SIGINT', ()=>shutdown(logFn, cb));
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
12
|
+
process.once('SIGTERM', ()=>shutdown(logFn, cb));
|
|
63
13
|
};
|
|
64
14
|
/**
|
|
65
15
|
* Creates logs for the initial accounts
|
|
@@ -233,9 +183,6 @@ export async function setupUpdateMonitor(autoUpdateMode, updatesLocation, follow
|
|
|
233
183
|
});
|
|
234
184
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
235
185
|
checker.on('newRollupVersion', async ({ latestVersion, currentVersion })=>{
|
|
236
|
-
if (isShuttingDown()) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
186
|
// if node follows canonical rollup then this is equivalent to a config update
|
|
240
187
|
if (!followsCanonicalRollup) {
|
|
241
188
|
return;
|
|
@@ -245,7 +192,7 @@ export async function setupUpdateMonitor(autoUpdateMode, updatesLocation, follow
|
|
|
245
192
|
latestVersion,
|
|
246
193
|
currentVersion
|
|
247
194
|
});
|
|
248
|
-
await shutdown(logger.info,
|
|
195
|
+
await shutdown(logger.info, signalHandlers);
|
|
249
196
|
} else if (autoUpdateMode === 'notify') {
|
|
250
197
|
logger.warn(`New rollup detected. Please restart the node`, {
|
|
251
198
|
latestVersion,
|
|
@@ -255,15 +202,12 @@ export async function setupUpdateMonitor(autoUpdateMode, updatesLocation, follow
|
|
|
255
202
|
});
|
|
256
203
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
257
204
|
checker.on('newNodeVersion', async ({ latestVersion, currentVersion })=>{
|
|
258
|
-
if (isShuttingDown()) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
205
|
if (autoUpdateMode === 'config-and-version') {
|
|
262
206
|
logger.info(`New node version detected. Please update and restart the node`, {
|
|
263
207
|
latestVersion,
|
|
264
208
|
currentVersion
|
|
265
209
|
});
|
|
266
|
-
await shutdown(logger.info,
|
|
210
|
+
await shutdown(logger.info, signalHandlers);
|
|
267
211
|
} else if (autoUpdateMode === 'notify') {
|
|
268
212
|
logger.info(`New node version detected. Please update and restart the node`, {
|
|
269
213
|
latestVersion,
|
|
@@ -273,9 +217,6 @@ export async function setupUpdateMonitor(autoUpdateMode, updatesLocation, follow
|
|
|
273
217
|
});
|
|
274
218
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
275
219
|
checker.on('updateNodeConfig', async (config)=>{
|
|
276
|
-
if (isShuttingDown()) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
220
|
if ((autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') && updateNodeConfig) {
|
|
280
221
|
logger.warn(`Config change detected. Updating node`, config);
|
|
281
222
|
try {
|
|
@@ -296,10 +237,6 @@ export async function setupUpdateMonitor(autoUpdateMode, updatesLocation, follow
|
|
|
296
237
|
if (Array.isArray(publicIncludeMetrics) && publicIncludeMetrics.every((m)=>typeof m === 'string')) {
|
|
297
238
|
getTelemetryClient().setExportedPublicTelemetry(publicIncludeMetrics);
|
|
298
239
|
}
|
|
299
|
-
const publicMetricsCollectFrom = config.publicMetricsCollectFrom;
|
|
300
|
-
if (Array.isArray(publicMetricsCollectFrom) && publicMetricsCollectFrom.every((m)=>typeof m === 'string')) {
|
|
301
|
-
getTelemetryClient().setPublicTelemetryCollectFrom(publicMetricsCollectFrom);
|
|
302
|
-
}
|
|
303
240
|
} catch (err) {
|
|
304
241
|
logger.warn('Failed to update config', {
|
|
305
242
|
err
|
|
@@ -310,3 +247,10 @@ export async function setupUpdateMonitor(autoUpdateMode, updatesLocation, follow
|
|
|
310
247
|
});
|
|
311
248
|
checker.start();
|
|
312
249
|
}
|
|
250
|
+
export async function shutdown(logFn, cb) {
|
|
251
|
+
logFn('Shutting down...');
|
|
252
|
+
if (cb) {
|
|
253
|
+
await Promise.all(cb);
|
|
254
|
+
}
|
|
255
|
+
process.exit(0);
|
|
256
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js"
|
|
@@ -27,35 +27,35 @@
|
|
|
27
27
|
"../package.common.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@aztec/accounts": "1.0.0
|
|
31
|
-
"@aztec/archiver": "1.0.0
|
|
32
|
-
"@aztec/aztec-faucet": "1.0.0
|
|
33
|
-
"@aztec/aztec-node": "1.0.0
|
|
34
|
-
"@aztec/aztec.js": "1.0.0
|
|
35
|
-
"@aztec/bb-prover": "1.0.0
|
|
36
|
-
"@aztec/bb.js": "1.0.0
|
|
37
|
-
"@aztec/blob-sink": "1.0.0
|
|
38
|
-
"@aztec/bot": "1.0.0
|
|
39
|
-
"@aztec/builder": "1.0.0
|
|
40
|
-
"@aztec/cli": "1.0.0
|
|
41
|
-
"@aztec/cli-wallet": "1.0.0
|
|
42
|
-
"@aztec/constants": "1.0.0
|
|
43
|
-
"@aztec/entrypoints": "1.0.0
|
|
44
|
-
"@aztec/ethereum": "1.0.0
|
|
45
|
-
"@aztec/foundation": "1.0.0
|
|
46
|
-
"@aztec/kv-store": "1.0.0
|
|
47
|
-
"@aztec/noir-contracts.js": "1.0.0
|
|
48
|
-
"@aztec/noir-protocol-circuits-types": "1.0.0
|
|
49
|
-
"@aztec/p2p": "1.0.0
|
|
50
|
-
"@aztec/p2p-bootstrap": "1.0.0
|
|
51
|
-
"@aztec/protocol-contracts": "1.0.0
|
|
52
|
-
"@aztec/prover-client": "1.0.0
|
|
53
|
-
"@aztec/prover-node": "1.0.0
|
|
54
|
-
"@aztec/pxe": "1.0.0
|
|
55
|
-
"@aztec/stdlib": "1.0.0
|
|
56
|
-
"@aztec/telemetry-client": "1.0.0
|
|
57
|
-
"@aztec/txe": "1.0.0
|
|
58
|
-
"@aztec/world-state": "1.0.0
|
|
30
|
+
"@aztec/accounts": "1.0.0",
|
|
31
|
+
"@aztec/archiver": "1.0.0",
|
|
32
|
+
"@aztec/aztec-faucet": "1.0.0",
|
|
33
|
+
"@aztec/aztec-node": "1.0.0",
|
|
34
|
+
"@aztec/aztec.js": "1.0.0",
|
|
35
|
+
"@aztec/bb-prover": "1.0.0",
|
|
36
|
+
"@aztec/bb.js": "1.0.0",
|
|
37
|
+
"@aztec/blob-sink": "1.0.0",
|
|
38
|
+
"@aztec/bot": "1.0.0",
|
|
39
|
+
"@aztec/builder": "1.0.0",
|
|
40
|
+
"@aztec/cli": "1.0.0",
|
|
41
|
+
"@aztec/cli-wallet": "1.0.0",
|
|
42
|
+
"@aztec/constants": "1.0.0",
|
|
43
|
+
"@aztec/entrypoints": "1.0.0",
|
|
44
|
+
"@aztec/ethereum": "1.0.0",
|
|
45
|
+
"@aztec/foundation": "1.0.0",
|
|
46
|
+
"@aztec/kv-store": "1.0.0",
|
|
47
|
+
"@aztec/noir-contracts.js": "1.0.0",
|
|
48
|
+
"@aztec/noir-protocol-circuits-types": "1.0.0",
|
|
49
|
+
"@aztec/p2p": "1.0.0",
|
|
50
|
+
"@aztec/p2p-bootstrap": "1.0.0",
|
|
51
|
+
"@aztec/protocol-contracts": "1.0.0",
|
|
52
|
+
"@aztec/prover-client": "1.0.0",
|
|
53
|
+
"@aztec/prover-node": "1.0.0",
|
|
54
|
+
"@aztec/pxe": "1.0.0",
|
|
55
|
+
"@aztec/stdlib": "1.0.0",
|
|
56
|
+
"@aztec/telemetry-client": "1.0.0",
|
|
57
|
+
"@aztec/txe": "1.0.0",
|
|
58
|
+
"@aztec/world-state": "1.0.0",
|
|
59
59
|
"@types/chalk": "^2.2.0",
|
|
60
60
|
"abitype": "^0.8.11",
|
|
61
61
|
"chalk": "^5.3.0",
|
package/src/bin/index.ts
CHANGED
|
@@ -8,13 +8,12 @@ import { injectCommands as injectInfrastructureCommands } from '@aztec/cli/infra
|
|
|
8
8
|
import { injectCommands as injectL1Commands } from '@aztec/cli/l1';
|
|
9
9
|
import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
|
|
10
10
|
import { injectCommands as injectPXECommands } from '@aztec/cli/pxe';
|
|
11
|
-
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
12
11
|
import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
13
12
|
|
|
14
13
|
import { Command } from 'commander';
|
|
15
14
|
|
|
16
15
|
import { NETWORK_FLAG } from '../cli/aztec_start_options.js';
|
|
17
|
-
import { enrichEnvironmentWithChainConfig } from '../cli/chain_l2_config.js';
|
|
16
|
+
import { type NetworkNames, enrichEnvironmentWithChainConfig } from '../cli/chain_l2_config.js';
|
|
18
17
|
import { injectAztecCommands } from '../cli/index.js';
|
|
19
18
|
import { getCliVersion } from '../cli/release_version.js';
|
|
20
19
|
|
|
@@ -39,7 +38,11 @@ async function main() {
|
|
|
39
38
|
networkValue = args[networkIndex].split('=')[1] || args[networkIndex + 1];
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
networkValue = networkValue || process.env.NETWORK;
|
|
42
|
+
|
|
43
|
+
if (networkValue !== undefined) {
|
|
44
|
+
await enrichEnvironmentWithChainConfig(networkValue as NetworkNames);
|
|
45
|
+
}
|
|
43
46
|
|
|
44
47
|
const cliVersion = getCliVersion();
|
|
45
48
|
let program = new Command('aztec');
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/aztec.js';
|
|
2
|
-
import {
|
|
3
|
-
import type { EnvVar, NetworkNames } from '@aztec/foundation/config';
|
|
2
|
+
import type { EnvVar } from '@aztec/foundation/config';
|
|
4
3
|
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
5
4
|
|
|
6
5
|
import path from 'path';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
export type NetworkNames = 'testnet-ignition' | 'alpha-testnet';
|
|
9
8
|
|
|
10
9
|
export type L2ChainConfig = {
|
|
11
10
|
l1ChainId: number;
|
|
11
|
+
ethereumSlotDuration: number;
|
|
12
|
+
aztecSlotDuration: number;
|
|
13
|
+
aztecEpochDuration: number;
|
|
14
|
+
aztecProofSubmissionEpochs: number;
|
|
12
15
|
testAccounts: boolean;
|
|
13
16
|
sponsoredFPC: boolean;
|
|
14
17
|
p2pEnabled: boolean;
|
|
@@ -23,55 +26,14 @@ export type L2ChainConfig = {
|
|
|
23
26
|
autoUpdate: SharedNodeConfig['autoUpdate'];
|
|
24
27
|
autoUpdateUrl?: string;
|
|
25
28
|
maxTxPoolSize: number;
|
|
26
|
-
publicIncludeMetrics?: string[];
|
|
27
|
-
publicMetricsCollectorUrl?: string;
|
|
28
|
-
publicMetricsCollectFrom?: string[];
|
|
29
|
-
|
|
30
|
-
// Deployment stuff
|
|
31
|
-
|
|
32
|
-
/** How many seconds an L1 slot lasts. */
|
|
33
|
-
ethereumSlotDuration: number;
|
|
34
|
-
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
|
|
35
|
-
aztecSlotDuration: number;
|
|
36
|
-
/** How many L2 slots an epoch lasts. */
|
|
37
|
-
aztecEpochDuration: number;
|
|
38
|
-
/** The target validator committee size. */
|
|
39
|
-
aztecTargetCommitteeSize: number;
|
|
40
|
-
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
41
|
-
aztecProofSubmissionEpochs: number;
|
|
42
|
-
/** The deposit amount for a validator */
|
|
43
|
-
depositAmount: bigint;
|
|
44
|
-
/** The minimum stake for a validator. */
|
|
45
|
-
minimumStake: bigint;
|
|
46
|
-
/** The slashing quorum */
|
|
47
|
-
slashingQuorum: number;
|
|
48
|
-
/** The slashing round size */
|
|
49
|
-
slashingRoundSize: number;
|
|
50
|
-
/** Governance proposing quorum */
|
|
51
|
-
governanceProposerQuorum: number;
|
|
52
|
-
/** Governance proposing round size */
|
|
53
|
-
governanceProposerRoundSize: number;
|
|
54
|
-
/** The mana target for the rollup */
|
|
55
|
-
manaTarget: bigint;
|
|
56
|
-
/** The proving cost per mana */
|
|
57
|
-
provingCostPerMana: bigint;
|
|
58
|
-
|
|
59
|
-
// slashing stuff
|
|
60
|
-
slashPayloadTtlSeconds: number;
|
|
61
|
-
slashPruneEnabled: boolean;
|
|
62
|
-
slashPrunePenalty: bigint;
|
|
63
|
-
slashPruneMaxPenalty: bigint;
|
|
64
|
-
slashInactivityEnabled: boolean;
|
|
65
|
-
slashInactivityCreateTargetPercentage: number;
|
|
66
|
-
slashInactivitySignalTargetPercentage: number;
|
|
67
|
-
slashInactivityCreatePenalty: bigint;
|
|
68
|
-
slashInvalidBlockEnabled: boolean;
|
|
69
|
-
slashInvalidBlockPenalty: bigint;
|
|
70
|
-
slashInvalidBlockMaxPenalty: bigint;
|
|
71
29
|
};
|
|
72
30
|
|
|
73
31
|
export const testnetIgnitionL2ChainConfig: L2ChainConfig = {
|
|
74
32
|
l1ChainId: 11155111,
|
|
33
|
+
ethereumSlotDuration: 12,
|
|
34
|
+
aztecSlotDuration: 36,
|
|
35
|
+
aztecEpochDuration: 32,
|
|
36
|
+
aztecProofSubmissionEpochs: 1,
|
|
75
37
|
testAccounts: true,
|
|
76
38
|
sponsoredFPC: false,
|
|
77
39
|
p2pEnabled: true,
|
|
@@ -86,51 +48,14 @@ export const testnetIgnitionL2ChainConfig: L2ChainConfig = {
|
|
|
86
48
|
autoUpdate: 'disabled',
|
|
87
49
|
autoUpdateUrl: undefined,
|
|
88
50
|
maxTxPoolSize: 100_000_000, // 100MB
|
|
51
|
+
};
|
|
89
52
|
|
|
90
|
-
|
|
91
|
-
|
|
53
|
+
export const alphaTestnetL2ChainConfig: L2ChainConfig = {
|
|
54
|
+
l1ChainId: 11155111,
|
|
92
55
|
ethereumSlotDuration: 12,
|
|
93
|
-
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
|
|
94
56
|
aztecSlotDuration: 36,
|
|
95
|
-
/** How many L2 slots an epoch lasts. */
|
|
96
57
|
aztecEpochDuration: 32,
|
|
97
|
-
/** The target validator committee size. */
|
|
98
|
-
aztecTargetCommitteeSize: 48,
|
|
99
|
-
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
100
58
|
aztecProofSubmissionEpochs: 1,
|
|
101
|
-
/** The deposit amount for a validator */
|
|
102
|
-
depositAmount: DefaultL1ContractsConfig.depositAmount,
|
|
103
|
-
/** The minimum stake for a validator. */
|
|
104
|
-
minimumStake: DefaultL1ContractsConfig.minimumStake,
|
|
105
|
-
/** The slashing quorum */
|
|
106
|
-
slashingQuorum: DefaultL1ContractsConfig.slashingQuorum,
|
|
107
|
-
/** The slashing round size */
|
|
108
|
-
slashingRoundSize: DefaultL1ContractsConfig.slashingRoundSize,
|
|
109
|
-
/** Governance proposing quorum */
|
|
110
|
-
governanceProposerQuorum: DefaultL1ContractsConfig.governanceProposerQuorum,
|
|
111
|
-
/** Governance proposing round size */
|
|
112
|
-
governanceProposerRoundSize: DefaultL1ContractsConfig.governanceProposerRoundSize,
|
|
113
|
-
/** The mana target for the rollup */
|
|
114
|
-
manaTarget: 0n,
|
|
115
|
-
/** The proving cost per mana */
|
|
116
|
-
provingCostPerMana: 0n,
|
|
117
|
-
|
|
118
|
-
// slashing stuff
|
|
119
|
-
slashInactivityEnabled: false,
|
|
120
|
-
slashInactivityCreateTargetPercentage: 0,
|
|
121
|
-
slashInactivitySignalTargetPercentage: 0,
|
|
122
|
-
slashInactivityCreatePenalty: 0n,
|
|
123
|
-
slashInvalidBlockEnabled: false,
|
|
124
|
-
slashPayloadTtlSeconds: 0,
|
|
125
|
-
slashPruneEnabled: false,
|
|
126
|
-
slashPrunePenalty: 0n,
|
|
127
|
-
slashPruneMaxPenalty: 0n,
|
|
128
|
-
slashInvalidBlockPenalty: 0n,
|
|
129
|
-
slashInvalidBlockMaxPenalty: 0n,
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export const alphaTestnetL2ChainConfig: L2ChainConfig = {
|
|
133
|
-
l1ChainId: 11155111,
|
|
134
59
|
testAccounts: false,
|
|
135
60
|
sponsoredFPC: true,
|
|
136
61
|
p2pEnabled: true,
|
|
@@ -144,51 +69,7 @@ export const alphaTestnetL2ChainConfig: L2ChainConfig = {
|
|
|
144
69
|
snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/',
|
|
145
70
|
autoUpdate: 'config-and-version',
|
|
146
71
|
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/alpha-testnet.json',
|
|
147
|
-
maxTxPoolSize:
|
|
148
|
-
publicIncludeMetrics,
|
|
149
|
-
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec.network',
|
|
150
|
-
publicMetricsCollectFrom: ['sequencer'],
|
|
151
|
-
|
|
152
|
-
// Deployment stuff
|
|
153
|
-
/** How many seconds an L1 slot lasts. */
|
|
154
|
-
ethereumSlotDuration: 12,
|
|
155
|
-
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
|
|
156
|
-
aztecSlotDuration: 36,
|
|
157
|
-
/** How many L2 slots an epoch lasts. */
|
|
158
|
-
aztecEpochDuration: 32,
|
|
159
|
-
/** The target validator committee size. */
|
|
160
|
-
aztecTargetCommitteeSize: 48,
|
|
161
|
-
/** The number of epochs after an epoch ends that proofs are still accepted. */
|
|
162
|
-
aztecProofSubmissionEpochs: 1,
|
|
163
|
-
/** The deposit amount for a validator */
|
|
164
|
-
depositAmount: DefaultL1ContractsConfig.depositAmount,
|
|
165
|
-
/** The minimum stake for a validator. */
|
|
166
|
-
minimumStake: DefaultL1ContractsConfig.minimumStake,
|
|
167
|
-
/** The slashing quorum */
|
|
168
|
-
slashingQuorum: 101,
|
|
169
|
-
/** The slashing round size */
|
|
170
|
-
slashingRoundSize: 200,
|
|
171
|
-
/** Governance proposing quorum */
|
|
172
|
-
governanceProposerQuorum: 151,
|
|
173
|
-
/** Governance proposing round size */
|
|
174
|
-
governanceProposerRoundSize: 300,
|
|
175
|
-
/** The mana target for the rollup */
|
|
176
|
-
manaTarget: DefaultL1ContractsConfig.manaTarget,
|
|
177
|
-
/** The proving cost per mana */
|
|
178
|
-
provingCostPerMana: DefaultL1ContractsConfig.provingCostPerMana,
|
|
179
|
-
|
|
180
|
-
// slashing stuff
|
|
181
|
-
slashPayloadTtlSeconds: 36 * 32 * 24, // 24 epochs
|
|
182
|
-
slashPruneEnabled: true,
|
|
183
|
-
slashPrunePenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
|
|
184
|
-
slashPruneMaxPenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
|
|
185
|
-
slashInactivityEnabled: true,
|
|
186
|
-
slashInactivityCreateTargetPercentage: 1,
|
|
187
|
-
slashInactivitySignalTargetPercentage: 1,
|
|
188
|
-
slashInactivityCreatePenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
|
|
189
|
-
slashInvalidBlockEnabled: true,
|
|
190
|
-
slashInvalidBlockPenalty: DefaultL1ContractsConfig.depositAmount,
|
|
191
|
-
slashInvalidBlockMaxPenalty: DefaultL1ContractsConfig.depositAmount,
|
|
72
|
+
maxTxPoolSize: 2 * 1024 * 1024 * 1024, // 2GB
|
|
192
73
|
};
|
|
193
74
|
|
|
194
75
|
export async function getBootnodes(networkName: NetworkNames) {
|
|
@@ -204,17 +85,15 @@ export async function getBootnodes(networkName: NetworkNames) {
|
|
|
204
85
|
return json['bootnodes'];
|
|
205
86
|
}
|
|
206
87
|
|
|
207
|
-
export async function getL2ChainConfig(
|
|
208
|
-
networkName: NetworkNames,
|
|
209
|
-
): Promise<{ config: L2ChainConfig; networkName: string } | undefined> {
|
|
88
|
+
export async function getL2ChainConfig(networkName: NetworkNames): Promise<L2ChainConfig | undefined> {
|
|
210
89
|
if (networkName === 'testnet-ignition') {
|
|
211
90
|
const config = { ...testnetIgnitionL2ChainConfig };
|
|
212
91
|
config.p2pBootstrapNodes = await getBootnodes(networkName);
|
|
213
|
-
return
|
|
214
|
-
} else if (networkName === 'alpha-testnet'
|
|
92
|
+
return config;
|
|
93
|
+
} else if (networkName === 'alpha-testnet') {
|
|
215
94
|
const config = { ...alphaTestnetL2ChainConfig };
|
|
216
|
-
config.p2pBootstrapNodes = await getBootnodes(
|
|
217
|
-
return
|
|
95
|
+
config.p2pBootstrapNodes = await getBootnodes(networkName);
|
|
96
|
+
return config;
|
|
218
97
|
}
|
|
219
98
|
return undefined;
|
|
220
99
|
}
|
|
@@ -237,15 +116,14 @@ function enrichEthAddressVar(envVar: EnvVar, value: string) {
|
|
|
237
116
|
}
|
|
238
117
|
|
|
239
118
|
export async function enrichEnvironmentWithChainConfig(networkName: NetworkNames) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const result = await getL2ChainConfig(networkName);
|
|
245
|
-
if (!result) {
|
|
119
|
+
const config = await getL2ChainConfig(networkName);
|
|
120
|
+
if (!config) {
|
|
246
121
|
throw new Error(`Unknown network name: ${networkName}`);
|
|
247
122
|
}
|
|
248
|
-
|
|
123
|
+
enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
|
|
124
|
+
enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
|
|
125
|
+
enrichVar('AZTEC_EPOCH_DURATION', config.aztecEpochDuration.toString());
|
|
126
|
+
enrichVar('AZTEC_PROOF_SUBMISSION_EPOCHS', config.aztecProofSubmissionEpochs.toString());
|
|
249
127
|
enrichVar('BOOTSTRAP_NODES', config.p2pBootstrapNodes.join(','));
|
|
250
128
|
enrichVar('TEST_ACCOUNTS', config.testAccounts.toString());
|
|
251
129
|
enrichVar('SPONSORED_FPC', config.sponsoredFPC.toString());
|
|
@@ -253,7 +131,7 @@ export async function enrichEnvironmentWithChainConfig(networkName: NetworkNames
|
|
|
253
131
|
enrichVar('L1_CHAIN_ID', config.l1ChainId.toString());
|
|
254
132
|
enrichVar('SEQ_MIN_TX_PER_BLOCK', config.seqMinTxsPerBlock.toString());
|
|
255
133
|
enrichVar('SEQ_MAX_TX_PER_BLOCK', config.seqMaxTxsPerBlock.toString());
|
|
256
|
-
enrichVar('DATA_DIRECTORY', path.join(process.env.HOME || '~', '.aztec',
|
|
134
|
+
enrichVar('DATA_DIRECTORY', path.join(process.env.HOME || '~', '.aztec', networkName, 'data'));
|
|
257
135
|
enrichVar('PROVER_REAL_PROOFS', config.realProofs.toString());
|
|
258
136
|
enrichVar('PXE_PROVER_ENABLED', config.realProofs.toString());
|
|
259
137
|
enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl);
|
|
@@ -267,47 +145,7 @@ export async function enrichEnvironmentWithChainConfig(networkName: NetworkNames
|
|
|
267
145
|
enrichVar('AUTO_UPDATE_URL', config.autoUpdateUrl);
|
|
268
146
|
}
|
|
269
147
|
|
|
270
|
-
if (config.publicIncludeMetrics) {
|
|
271
|
-
enrichVar('PUBLIC_OTEL_INCLUDE_METRICS', config.publicIncludeMetrics.join(','));
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (config.publicMetricsCollectorUrl) {
|
|
275
|
-
enrichVar('PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT', config.publicMetricsCollectorUrl);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (config.publicMetricsCollectFrom) {
|
|
279
|
-
enrichVar('PUBLIC_OTEL_COLLECT_FROM', config.publicMetricsCollectFrom.join(','));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
148
|
enrichEthAddressVar('REGISTRY_CONTRACT_ADDRESS', config.registryAddress);
|
|
283
149
|
enrichEthAddressVar('SLASH_FACTORY_CONTRACT_ADDRESS', config.slashFactoryAddress);
|
|
284
150
|
enrichEthAddressVar('FEE_ASSET_HANDLER_CONTRACT_ADDRESS', config.feeAssetHandlerAddress);
|
|
285
|
-
|
|
286
|
-
// Deployment stuff
|
|
287
|
-
enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
|
|
288
|
-
enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
|
|
289
|
-
enrichVar('AZTEC_EPOCH_DURATION', config.aztecEpochDuration.toString());
|
|
290
|
-
enrichVar('AZTEC_TARGET_COMMITTEE_SIZE', config.aztecTargetCommitteeSize.toString());
|
|
291
|
-
enrichVar('AZTEC_PROOF_SUBMISSION_EPOCHS', config.aztecProofSubmissionEpochs.toString());
|
|
292
|
-
enrichVar('AZTEC_DEPOSIT_AMOUNT', config.depositAmount.toString());
|
|
293
|
-
enrichVar('AZTEC_MINIMUM_STAKE', config.minimumStake.toString());
|
|
294
|
-
enrichVar('AZTEC_SLASHING_QUORUM', config.slashingQuorum.toString());
|
|
295
|
-
enrichVar('AZTEC_SLASHING_ROUND_SIZE', config.slashingRoundSize.toString());
|
|
296
|
-
enrichVar('AZTEC_GOVERNANCE_PROPOSER_QUORUM', config.governanceProposerQuorum.toString());
|
|
297
|
-
enrichVar('AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE', config.governanceProposerRoundSize.toString());
|
|
298
|
-
enrichVar('AZTEC_MANA_TARGET', config.manaTarget.toString());
|
|
299
|
-
enrichVar('AZTEC_PROVING_COST_PER_MANA', config.provingCostPerMana.toString());
|
|
300
|
-
|
|
301
|
-
// Slashing
|
|
302
|
-
enrichVar('SLASH_PAYLOAD_TTL_SECONDS', config.slashPayloadTtlSeconds.toString());
|
|
303
|
-
enrichVar('SLASH_PRUNE_ENABLED', config.slashPruneEnabled.toString());
|
|
304
|
-
enrichVar('SLASH_PRUNE_PENALTY', config.slashPrunePenalty.toString());
|
|
305
|
-
enrichVar('SLASH_PRUNE_MAX_PENALTY', config.slashPruneMaxPenalty.toString());
|
|
306
|
-
enrichVar('SLASH_INACTIVITY_ENABLED', config.slashInactivityEnabled.toString());
|
|
307
|
-
enrichVar('SLASH_INACTIVITY_CREATE_TARGET_PERCENTAGE', config.slashInactivityCreateTargetPercentage.toString());
|
|
308
|
-
enrichVar('SLASH_INACTIVITY_SIGNAL_TARGET_PERCENTAGE', config.slashInactivitySignalTargetPercentage.toString());
|
|
309
|
-
enrichVar('SLASH_INACTIVITY_CREATE_PENALTY', config.slashInactivityCreatePenalty.toString());
|
|
310
|
-
enrichVar('SLASH_INVALID_BLOCK_ENABLED', config.slashInvalidBlockEnabled.toString());
|
|
311
|
-
enrichVar('SLASH_INVALID_BLOCK_PENALTY', config.slashInvalidBlockPenalty.toString());
|
|
312
|
-
enrichVar('SLASH_INVALID_BLOCK_MAX_PENALTY', config.slashInvalidBlockMaxPenalty.toString());
|
|
313
151
|
}
|
package/src/cli/util.ts
CHANGED
|
@@ -14,54 +14,13 @@ import type { Command } from 'commander';
|
|
|
14
14
|
|
|
15
15
|
import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';
|
|
16
16
|
|
|
17
|
-
export const enum ExitCode {
|
|
18
|
-
SUCCESS = 0,
|
|
19
|
-
ERROR = 1,
|
|
20
|
-
ROLLUP_UPGRADE = 78, // EX_CONFIG from FreeBSD (https://man.freebsd.org/cgi/man.cgi?query=sysexits)
|
|
21
|
-
VERSION_UPGRADE = 79, // prev + 1 because there's nothing better
|
|
22
|
-
// 128 + int(SIGNAL)
|
|
23
|
-
SIGHUP = 129,
|
|
24
|
-
SIGINT = 130,
|
|
25
|
-
SIGQUIT = 131,
|
|
26
|
-
SIGTERM = 143,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let shutdownPromise: Promise<never> | undefined;
|
|
30
|
-
export function shutdown(logFn: LogFn, exitCode: ExitCode, cb?: Array<() => Promise<void>>): Promise<never> {
|
|
31
|
-
if (shutdownPromise) {
|
|
32
|
-
logFn('Already shutting down.');
|
|
33
|
-
return shutdownPromise;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
logFn('Shutting down...', { exitCode });
|
|
37
|
-
if (cb) {
|
|
38
|
-
shutdownPromise = Promise.allSettled(cb).then(() => process.exit(exitCode));
|
|
39
|
-
} else {
|
|
40
|
-
// synchronously shuts down the process
|
|
41
|
-
// no need to set shutdownPromise on this branch of the if statement because no more code will be executed
|
|
42
|
-
process.exit(exitCode);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return shutdownPromise;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function isShuttingDown(): boolean {
|
|
49
|
-
return shutdownPromise !== undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
17
|
export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<void>>) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
for (const [signal, exitCode] of signals) {
|
|
61
|
-
process.removeAllListeners(signal);
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
63
|
-
process.once(signal, () => shutdown(logFn, exitCode, cb));
|
|
64
|
-
}
|
|
18
|
+
process.removeAllListeners('SIGINT');
|
|
19
|
+
process.removeAllListeners('SIGTERM');
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
21
|
+
process.once('SIGINT', () => shutdown(logFn, cb));
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
23
|
+
process.once('SIGTERM', () => shutdown(logFn, cb));
|
|
65
24
|
};
|
|
66
25
|
|
|
67
26
|
/**
|
|
@@ -303,10 +262,6 @@ export async function setupUpdateMonitor(
|
|
|
303
262
|
|
|
304
263
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
305
264
|
checker.on('newRollupVersion', async ({ latestVersion, currentVersion }) => {
|
|
306
|
-
if (isShuttingDown()) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
265
|
// if node follows canonical rollup then this is equivalent to a config update
|
|
311
266
|
if (!followsCanonicalRollup) {
|
|
312
267
|
return;
|
|
@@ -314,7 +269,7 @@ export async function setupUpdateMonitor(
|
|
|
314
269
|
|
|
315
270
|
if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
|
|
316
271
|
logger.info(`New rollup version detected. Please restart the node`, { latestVersion, currentVersion });
|
|
317
|
-
await shutdown(logger.info,
|
|
272
|
+
await shutdown(logger.info, signalHandlers);
|
|
318
273
|
} else if (autoUpdateMode === 'notify') {
|
|
319
274
|
logger.warn(`New rollup detected. Please restart the node`, { latestVersion, currentVersion });
|
|
320
275
|
}
|
|
@@ -322,12 +277,9 @@ export async function setupUpdateMonitor(
|
|
|
322
277
|
|
|
323
278
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
324
279
|
checker.on('newNodeVersion', async ({ latestVersion, currentVersion }) => {
|
|
325
|
-
if (isShuttingDown()) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
280
|
if (autoUpdateMode === 'config-and-version') {
|
|
329
281
|
logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
|
|
330
|
-
await shutdown(logger.info,
|
|
282
|
+
await shutdown(logger.info, signalHandlers);
|
|
331
283
|
} else if (autoUpdateMode === 'notify') {
|
|
332
284
|
logger.info(`New node version detected. Please update and restart the node`, { latestVersion, currentVersion });
|
|
333
285
|
}
|
|
@@ -335,10 +287,6 @@ export async function setupUpdateMonitor(
|
|
|
335
287
|
|
|
336
288
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
337
289
|
checker.on('updateNodeConfig', async config => {
|
|
338
|
-
if (isShuttingDown()) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
290
|
if ((autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') && updateNodeConfig) {
|
|
343
291
|
logger.warn(`Config change detected. Updating node`, config);
|
|
344
292
|
try {
|
|
@@ -358,10 +306,6 @@ export async function setupUpdateMonitor(
|
|
|
358
306
|
if (Array.isArray(publicIncludeMetrics) && publicIncludeMetrics.every(m => typeof m === 'string')) {
|
|
359
307
|
getTelemetryClient().setExportedPublicTelemetry(publicIncludeMetrics);
|
|
360
308
|
}
|
|
361
|
-
const publicMetricsCollectFrom: unknown = (config as any).publicMetricsCollectFrom;
|
|
362
|
-
if (Array.isArray(publicMetricsCollectFrom) && publicMetricsCollectFrom.every(m => typeof m === 'string')) {
|
|
363
|
-
getTelemetryClient().setPublicTelemetryCollectFrom(publicMetricsCollectFrom);
|
|
364
|
-
}
|
|
365
309
|
} catch (err) {
|
|
366
310
|
logger.warn('Failed to update config', { err });
|
|
367
311
|
}
|
|
@@ -371,3 +315,11 @@ export async function setupUpdateMonitor(
|
|
|
371
315
|
|
|
372
316
|
checker.start();
|
|
373
317
|
}
|
|
318
|
+
|
|
319
|
+
export async function shutdown(logFn: LogFn, cb?: Array<() => Promise<void>>) {
|
|
320
|
+
logFn('Shutting down...');
|
|
321
|
+
if (cb) {
|
|
322
|
+
await Promise.all(cb);
|
|
323
|
+
}
|
|
324
|
+
process.exit(0);
|
|
325
|
+
}
|