@aztec/aztec 4.0.2 → 4.0.3
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.
|
@@ -4,4 +4,4 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
4
4
|
export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn): Promise<{
|
|
5
5
|
config: AztecNodeConfig;
|
|
6
6
|
}>;
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUE2QyxNQUFNLG1CQUFtQixDQUFDO0FBUXBHLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFHL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUE2Rm5ELHdCQUFzQixTQUFTLENBQzdCLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLGFBQWEsRUFBRSxxQkFBcUIsRUFDcEMsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZUFBZSxDQUFBO0NBQUUsQ0FBQyxDQTRLdEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAQpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AA6FnD,wBAAsB,SAAS,CAC7B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,qBAAqB,EACpC,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CA4KtC"}
|
|
@@ -4,8 +4,11 @@ import { Fr } from '@aztec/aztec.js/fields';
|
|
|
4
4
|
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
5
5
|
import { getL1Config } from '@aztec/cli/config';
|
|
6
6
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
7
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
7
8
|
import { SecretValue } from '@aztec/foundation/config';
|
|
9
|
+
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
8
10
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
11
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
9
12
|
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
10
13
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
11
14
|
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
@@ -13,10 +16,58 @@ import { P2PApiSchema, ProverNodeApiSchema } from '@aztec/stdlib/interfaces/serv
|
|
|
13
16
|
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
14
17
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
15
18
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
19
|
+
import Koa from 'koa';
|
|
16
20
|
import { createAztecNode } from '../../local-network/index.js';
|
|
17
21
|
import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying, setupUpdateMonitor } from '../util.js';
|
|
18
22
|
import { getVersions } from '../versioning.js';
|
|
19
23
|
import { startProverBroker } from './start_prover_broker.js';
|
|
24
|
+
const ROLLUP_POLL_INTERVAL_MS = 600_000;
|
|
25
|
+
/**
|
|
26
|
+
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
27
|
+
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
28
|
+
* starts a lightweight HTTP server for K8s liveness probes and polls until a compatible rollup appears.
|
|
29
|
+
*/ async function waitForCompatibleRollup(publicClient, registryAddress, rollupVersion, expectedGenesisRoot, port, userLog) {
|
|
30
|
+
const registry = new RegistryContract(publicClient, registryAddress);
|
|
31
|
+
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
32
|
+
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
33
|
+
let l1GenesisRoot;
|
|
34
|
+
try {
|
|
35
|
+
l1GenesisRoot = await rollup.getGenesisArchiveTreeRoot();
|
|
36
|
+
} catch (err) {
|
|
37
|
+
throw new Error(`Could not retrieve genesis archive root from canonical rollup at ${rollupAddress}: ${err.message}`);
|
|
38
|
+
}
|
|
39
|
+
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
userLog(`Genesis root mismatch: expected ${expectedGenesisRoot}, got ${l1GenesisRoot} from rollup at ${rollupAddress}. ` + `Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_MS / 1000}s for a compatible rollup...`);
|
|
43
|
+
const standbyServer = await startHttpRpcServer({
|
|
44
|
+
getApp: ()=>new Koa(),
|
|
45
|
+
isHealthy: ()=>true
|
|
46
|
+
}, {
|
|
47
|
+
port
|
|
48
|
+
});
|
|
49
|
+
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
50
|
+
try {
|
|
51
|
+
while(true){
|
|
52
|
+
await sleep(ROLLUP_POLL_INTERVAL_MS);
|
|
53
|
+
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
54
|
+
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
55
|
+
try {
|
|
56
|
+
l1GenesisRoot = await currentRollup.getGenesisArchiveTreeRoot();
|
|
57
|
+
} catch {
|
|
58
|
+
userLog(`Failed to fetch genesis root from rollup at ${currentRollupAddress}. Retrying...`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
62
|
+
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
userLog(`Still waiting. Rollup at ${currentRollupAddress} has genesis root ${l1GenesisRoot}.`);
|
|
66
|
+
}
|
|
67
|
+
} finally{
|
|
68
|
+
await new Promise((resolve, reject)=>standbyServer.close((err)=>err ? reject(err) : resolve()));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
20
71
|
export async function startNode(options, signalHandlers, services, adminServices, userLog) {
|
|
21
72
|
// All options set from environment variables
|
|
22
73
|
const configFromEnvVars = getConfigEnvVars();
|
|
@@ -75,6 +126,11 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
75
126
|
if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
|
|
76
127
|
throw new Error('L1 registry address is required to start Aztec Node');
|
|
77
128
|
}
|
|
129
|
+
// Wait for a compatible rollup before proceeding with full L1 config fetch.
|
|
130
|
+
// This prevents crashes when the canonical rollup hasn't been upgraded yet.
|
|
131
|
+
const publicClient = getPublicClient(nodeConfig);
|
|
132
|
+
const rollupVersion = nodeConfig.rollupVersion ?? 'canonical';
|
|
133
|
+
await waitForCompatibleRollup(publicClient, nodeConfig.l1Contracts.registryAddress, rollupVersion, genesisArchiveRoot, options.port, userLog);
|
|
78
134
|
const { addresses, config } = await getL1Config(nodeConfig.l1Contracts.registryAddress, nodeConfig.l1RpcUrls, nodeConfig.l1ChainId, nodeConfig.rollupVersion);
|
|
79
135
|
process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
|
|
80
136
|
if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -28,39 +28,39 @@
|
|
|
28
28
|
"../package.common.json"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/accounts": "4.0.
|
|
32
|
-
"@aztec/archiver": "4.0.
|
|
33
|
-
"@aztec/aztec-faucet": "4.0.
|
|
34
|
-
"@aztec/aztec-node": "4.0.
|
|
35
|
-
"@aztec/aztec.js": "4.0.
|
|
36
|
-
"@aztec/bb-prover": "4.0.
|
|
37
|
-
"@aztec/bb.js": "4.0.
|
|
38
|
-
"@aztec/blob-client": "4.0.
|
|
39
|
-
"@aztec/bot": "4.0.
|
|
40
|
-
"@aztec/builder": "4.0.
|
|
41
|
-
"@aztec/cli": "4.0.
|
|
42
|
-
"@aztec/constants": "4.0.
|
|
43
|
-
"@aztec/entrypoints": "4.0.
|
|
44
|
-
"@aztec/ethereum": "4.0.
|
|
45
|
-
"@aztec/foundation": "4.0.
|
|
46
|
-
"@aztec/kv-store": "4.0.
|
|
47
|
-
"@aztec/l1-artifacts": "4.0.
|
|
48
|
-
"@aztec/node-lib": "4.0.
|
|
49
|
-
"@aztec/noir-contracts.js": "4.0.
|
|
50
|
-
"@aztec/noir-protocol-circuits-types": "4.0.
|
|
51
|
-
"@aztec/p2p": "4.0.
|
|
52
|
-
"@aztec/p2p-bootstrap": "4.0.
|
|
53
|
-
"@aztec/protocol-contracts": "4.0.
|
|
54
|
-
"@aztec/prover-client": "4.0.
|
|
55
|
-
"@aztec/prover-node": "4.0.
|
|
56
|
-
"@aztec/pxe": "4.0.
|
|
57
|
-
"@aztec/sequencer-client": "4.0.
|
|
58
|
-
"@aztec/stdlib": "4.0.
|
|
59
|
-
"@aztec/telemetry-client": "4.0.
|
|
60
|
-
"@aztec/txe": "4.0.
|
|
61
|
-
"@aztec/validator-ha-signer": "4.0.
|
|
62
|
-
"@aztec/wallets": "4.0.
|
|
63
|
-
"@aztec/world-state": "4.0.
|
|
31
|
+
"@aztec/accounts": "4.0.3",
|
|
32
|
+
"@aztec/archiver": "4.0.3",
|
|
33
|
+
"@aztec/aztec-faucet": "4.0.3",
|
|
34
|
+
"@aztec/aztec-node": "4.0.3",
|
|
35
|
+
"@aztec/aztec.js": "4.0.3",
|
|
36
|
+
"@aztec/bb-prover": "4.0.3",
|
|
37
|
+
"@aztec/bb.js": "4.0.3",
|
|
38
|
+
"@aztec/blob-client": "4.0.3",
|
|
39
|
+
"@aztec/bot": "4.0.3",
|
|
40
|
+
"@aztec/builder": "4.0.3",
|
|
41
|
+
"@aztec/cli": "4.0.3",
|
|
42
|
+
"@aztec/constants": "4.0.3",
|
|
43
|
+
"@aztec/entrypoints": "4.0.3",
|
|
44
|
+
"@aztec/ethereum": "4.0.3",
|
|
45
|
+
"@aztec/foundation": "4.0.3",
|
|
46
|
+
"@aztec/kv-store": "4.0.3",
|
|
47
|
+
"@aztec/l1-artifacts": "4.0.3",
|
|
48
|
+
"@aztec/node-lib": "4.0.3",
|
|
49
|
+
"@aztec/noir-contracts.js": "4.0.3",
|
|
50
|
+
"@aztec/noir-protocol-circuits-types": "4.0.3",
|
|
51
|
+
"@aztec/p2p": "4.0.3",
|
|
52
|
+
"@aztec/p2p-bootstrap": "4.0.3",
|
|
53
|
+
"@aztec/protocol-contracts": "4.0.3",
|
|
54
|
+
"@aztec/prover-client": "4.0.3",
|
|
55
|
+
"@aztec/prover-node": "4.0.3",
|
|
56
|
+
"@aztec/pxe": "4.0.3",
|
|
57
|
+
"@aztec/sequencer-client": "4.0.3",
|
|
58
|
+
"@aztec/stdlib": "4.0.3",
|
|
59
|
+
"@aztec/telemetry-client": "4.0.3",
|
|
60
|
+
"@aztec/txe": "4.0.3",
|
|
61
|
+
"@aztec/validator-ha-signer": "4.0.3",
|
|
62
|
+
"@aztec/wallets": "4.0.3",
|
|
63
|
+
"@aztec/world-state": "4.0.3",
|
|
64
64
|
"@types/chalk": "^2.2.0",
|
|
65
65
|
"abitype": "^0.8.11",
|
|
66
66
|
"chalk": "^5.3.0",
|
|
@@ -4,10 +4,14 @@ import { Fr } from '@aztec/aztec.js/fields';
|
|
|
4
4
|
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
5
5
|
import { getL1Config } from '@aztec/cli/config';
|
|
6
6
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
7
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
7
8
|
import { SecretValue } from '@aztec/foundation/config';
|
|
9
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
10
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
11
|
+
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
9
12
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
10
13
|
import type { LogFn } from '@aztec/foundation/log';
|
|
14
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
11
15
|
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
12
16
|
import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
|
|
13
17
|
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
@@ -21,6 +25,8 @@ import {
|
|
|
21
25
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
22
26
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
23
27
|
|
|
28
|
+
import Koa from 'koa';
|
|
29
|
+
|
|
24
30
|
import { createAztecNode } from '../../local-network/index.js';
|
|
25
31
|
import {
|
|
26
32
|
extractNamespacedOptions,
|
|
@@ -31,6 +37,72 @@ import {
|
|
|
31
37
|
import { getVersions } from '../versioning.js';
|
|
32
38
|
import { startProverBroker } from './start_prover_broker.js';
|
|
33
39
|
|
|
40
|
+
const ROLLUP_POLL_INTERVAL_MS = 600_000;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
44
|
+
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
45
|
+
* starts a lightweight HTTP server for K8s liveness probes and polls until a compatible rollup appears.
|
|
46
|
+
*/
|
|
47
|
+
async function waitForCompatibleRollup(
|
|
48
|
+
publicClient: ReturnType<typeof getPublicClient>,
|
|
49
|
+
registryAddress: EthAddress,
|
|
50
|
+
rollupVersion: number | 'canonical',
|
|
51
|
+
expectedGenesisRoot: Fr,
|
|
52
|
+
port: number | undefined,
|
|
53
|
+
userLog: LogFn,
|
|
54
|
+
): Promise<void> {
|
|
55
|
+
const registry = new RegistryContract(publicClient, registryAddress);
|
|
56
|
+
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
57
|
+
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
58
|
+
|
|
59
|
+
let l1GenesisRoot: Fr;
|
|
60
|
+
try {
|
|
61
|
+
l1GenesisRoot = await rollup.getGenesisArchiveTreeRoot();
|
|
62
|
+
} catch (err: any) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`Could not retrieve genesis archive root from canonical rollup at ${rollupAddress}: ${err.message}`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
userLog(
|
|
73
|
+
`Genesis root mismatch: expected ${expectedGenesisRoot}, got ${l1GenesisRoot} from rollup at ${rollupAddress}. ` +
|
|
74
|
+
`Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_MS / 1000}s for a compatible rollup...`,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const standbyServer = await startHttpRpcServer({ getApp: () => new Koa(), isHealthy: () => true }, { port });
|
|
78
|
+
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
while (true) {
|
|
82
|
+
await sleep(ROLLUP_POLL_INTERVAL_MS);
|
|
83
|
+
|
|
84
|
+
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
85
|
+
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
l1GenesisRoot = await currentRollup.getGenesisArchiveTreeRoot();
|
|
89
|
+
} catch {
|
|
90
|
+
userLog(`Failed to fetch genesis root from rollup at ${currentRollupAddress}. Retrying...`);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
95
|
+
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
userLog(`Still waiting. Rollup at ${currentRollupAddress} has genesis root ${l1GenesisRoot}.`);
|
|
100
|
+
}
|
|
101
|
+
} finally {
|
|
102
|
+
await new Promise<void>((resolve, reject) => standbyServer.close(err => (err ? reject(err) : resolve())));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
34
106
|
export async function startNode(
|
|
35
107
|
options: any,
|
|
36
108
|
signalHandlers: (() => Promise<void>)[],
|
|
@@ -96,6 +168,20 @@ export async function startNode(
|
|
|
96
168
|
if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
|
|
97
169
|
throw new Error('L1 registry address is required to start Aztec Node');
|
|
98
170
|
}
|
|
171
|
+
|
|
172
|
+
// Wait for a compatible rollup before proceeding with full L1 config fetch.
|
|
173
|
+
// This prevents crashes when the canonical rollup hasn't been upgraded yet.
|
|
174
|
+
const publicClient = getPublicClient(nodeConfig);
|
|
175
|
+
const rollupVersion: number | 'canonical' = nodeConfig.rollupVersion ?? 'canonical';
|
|
176
|
+
await waitForCompatibleRollup(
|
|
177
|
+
publicClient,
|
|
178
|
+
nodeConfig.l1Contracts.registryAddress,
|
|
179
|
+
rollupVersion,
|
|
180
|
+
genesisArchiveRoot,
|
|
181
|
+
options.port,
|
|
182
|
+
userLog,
|
|
183
|
+
);
|
|
184
|
+
|
|
99
185
|
const { addresses, config } = await getL1Config(
|
|
100
186
|
nodeConfig.l1Contracts.registryAddress,
|
|
101
187
|
nodeConfig.l1RpcUrls,
|