@aztec/aztec 0.0.1-commit.f146247c → 0.0.1-commit.f224bb98b
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 +7 -3
- package/dest/cli/admin_api_key_store.d.ts +45 -0
- package/dest/cli/admin_api_key_store.d.ts.map +1 -0
- package/dest/cli/admin_api_key_store.js +98 -0
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +51 -13
- package/dest/cli/aztec_start_options.d.ts +1 -1
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +25 -9
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +3 -4
- package/dest/cli/cmds/compile.d.ts +4 -0
- package/dest/cli/cmds/compile.d.ts.map +1 -0
- package/dest/cli/cmds/compile.js +165 -0
- package/dest/cli/cmds/profile.d.ts +4 -0
- package/dest/cli/cmds/profile.d.ts.map +1 -0
- package/dest/cli/cmds/profile.js +8 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
- package/dest/cli/cmds/profile_flamegraph.js +51 -0
- package/dest/cli/cmds/profile_gates.d.ts +4 -0
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
- package/dest/cli/cmds/profile_gates.js +57 -0
- package/dest/cli/cmds/profile_utils.d.ts +18 -0
- package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
- package/dest/cli/cmds/profile_utils.js +50 -0
- package/dest/cli/cmds/standby.d.ts +27 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +78 -0
- package/dest/cli/cmds/start_archiver.d.ts +2 -2
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +1 -1
- package/dest/cli/cmds/start_bot.d.ts +3 -3
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +9 -5
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +77 -27
- package/dest/cli/cmds/start_prover_agent.js +2 -2
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +8 -8
- package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
- package/dest/cli/cmds/utils/artifacts.js +24 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +124 -0
- package/dest/cli/cmds/utils/spawn.d.ts +3 -0
- package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
- package/dest/cli/cmds/utils/spawn.js +16 -0
- package/dest/cli/util.d.ts +7 -18
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +50 -86
- package/dest/examples/token.js +6 -6
- package/dest/local-network/banana_fpc.js +1 -1
- package/dest/local-network/local-network.d.ts +4 -2
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +50 -18
- package/dest/testing/anvil_test_watcher.d.ts +9 -1
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +52 -15
- package/dest/testing/index.d.ts +2 -1
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -0
- package/dest/testing/token_allowed_setup.d.ts +7 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +20 -0
- package/package.json +35 -34
- package/scripts/add_crate.sh +102 -0
- package/scripts/aztec.sh +11 -5
- package/scripts/init.sh +23 -19
- package/scripts/new.sh +48 -24
- package/scripts/setup_workspace.sh +68 -0
- package/src/bin/index.ts +7 -3
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +55 -9
- package/src/cli/aztec_start_options.ts +27 -8
- package/src/cli/cli.ts +3 -4
- package/src/cli/cmds/compile.ts +190 -0
- package/src/cli/cmds/profile.ts +25 -0
- package/src/cli/cmds/profile_flamegraph.ts +63 -0
- package/src/cli/cmds/profile_gates.ts +67 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/standby.ts +111 -0
- package/src/cli/cmds/start_archiver.ts +1 -1
- package/src/cli/cmds/start_bot.ts +8 -5
- package/src/cli/cmds/start_node.ts +76 -33
- package/src/cli/cmds/start_prover_agent.ts +2 -2
- package/src/cli/cmds/start_prover_broker.ts +12 -15
- package/src/cli/cmds/utils/artifacts.ts +44 -0
- package/src/cli/cmds/utils/needs_recompile.ts +139 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/cli/util.ts +57 -95
- package/src/examples/token.ts +8 -6
- package/src/local-network/banana_fpc.ts +1 -1
- package/src/local-network/local-network.ts +54 -17
- package/src/testing/anvil_test_watcher.ts +59 -15
- package/src/testing/index.ts +1 -0
- package/src/testing/token_allowed_setup.ts +19 -0
- package/dest/cli/cmds/start_prover_node.d.ts +0 -7
- package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
- package/dest/cli/cmds/start_prover_node.js +0 -108
- package/dest/cli/release_version.d.ts +0 -2
- package/dest/cli/release_version.d.ts.map +0 -1
- package/dest/cli/release_version.js +0 -14
- package/scripts/compile.sh +0 -44
- package/scripts/extract_function.js +0 -47
- package/scripts/flamegraph.sh +0 -59
- package/scripts/setup_project.sh +0 -31
- package/src/cli/cmds/start_prover_node.ts +0 -124
- package/src/cli/release_version.ts +0 -21
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { readFile, rename, rm, writeFile } from 'fs/promises';
|
|
2
|
+
import { basename, dirname, join } from 'path';
|
|
3
|
+
import { makeFunctionArtifact } from './profile_utils.js';
|
|
4
|
+
import { run } from './utils/spawn.js';
|
|
5
|
+
/** Generates a gate count flamegraph SVG for a single contract function. */ export async function profileFlamegraph(artifactPath, functionName, log) {
|
|
6
|
+
const raw = await readFile(artifactPath, 'utf-8');
|
|
7
|
+
const artifact = JSON.parse(raw);
|
|
8
|
+
if (!Array.isArray(artifact.functions)) {
|
|
9
|
+
throw new Error(`${artifactPath} does not appear to be a contract artifact (no functions array)`);
|
|
10
|
+
}
|
|
11
|
+
const func = artifact.functions.find((f)=>f.name === functionName);
|
|
12
|
+
if (!func) {
|
|
13
|
+
const available = artifact.functions.map((f)=>f.name).join(', ');
|
|
14
|
+
throw new Error(`Function "${functionName}" not found in artifact. Available: ${available}`);
|
|
15
|
+
}
|
|
16
|
+
if (func.is_unconstrained) {
|
|
17
|
+
throw new Error(`Function "${functionName}" is unconstrained and cannot be profiled`);
|
|
18
|
+
}
|
|
19
|
+
const outputDir = dirname(artifactPath);
|
|
20
|
+
const contractName = basename(artifactPath, '.json');
|
|
21
|
+
const functionArtifact = join(outputDir, `${contractName}-${functionName}.json`);
|
|
22
|
+
try {
|
|
23
|
+
await writeFile(functionArtifact, makeFunctionArtifact(artifact, func));
|
|
24
|
+
const profiler = process.env.PROFILER_PATH ?? 'noir-profiler';
|
|
25
|
+
const bb = process.env.BB ?? 'bb';
|
|
26
|
+
await run(profiler, [
|
|
27
|
+
'gates',
|
|
28
|
+
'--artifact-path',
|
|
29
|
+
functionArtifact,
|
|
30
|
+
'--backend-path',
|
|
31
|
+
bb,
|
|
32
|
+
'--backend-gates-command',
|
|
33
|
+
'gates',
|
|
34
|
+
'--output',
|
|
35
|
+
outputDir,
|
|
36
|
+
'--scheme',
|
|
37
|
+
'chonk',
|
|
38
|
+
'--include_gates_per_opcode'
|
|
39
|
+
]);
|
|
40
|
+
// noir-profiler names the SVG using the internal function name which
|
|
41
|
+
// retains the __aztec_nr_internals__ prefix in the bytecode metadata.
|
|
42
|
+
const srcSvg = join(outputDir, `__aztec_nr_internals__${functionName}_gates.svg`);
|
|
43
|
+
const destSvg = join(outputDir, `${contractName}-${functionName}-flamegraph.svg`);
|
|
44
|
+
await rename(srcSvg, destSvg);
|
|
45
|
+
log(`Flamegraph written to ${destSvg}`);
|
|
46
|
+
} finally{
|
|
47
|
+
await rm(functionArtifact, {
|
|
48
|
+
force: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
/** Profiles all compiled artifacts in a target directory and prints gate counts. */
|
|
3
|
+
export declare function profileGates(targetDir: string, log: LogFn): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV9nYXRlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3Byb2ZpbGVfZ2F0ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUErQm5ELG9GQUFvRjtBQUNwRix3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLEtBQUssR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBaUMvRSJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile_gates.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AA+BnD,oFAAoF;AACpF,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/E"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
2
|
+
import { execFile as execFileCb } from 'child_process';
|
|
3
|
+
import { rm } from 'fs/promises';
|
|
4
|
+
import { promisify } from 'util';
|
|
5
|
+
import { MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
|
|
6
|
+
const execFile = promisify(execFileCb);
|
|
7
|
+
/** Parses circuit_size from bb gates JSON output: { "functions": [{ "circuit_size": N }] } */ function parseGateCount(stdout) {
|
|
8
|
+
const parsed = JSON.parse(stdout);
|
|
9
|
+
const size = parsed?.functions?.[0]?.circuit_size;
|
|
10
|
+
if (typeof size !== 'number') {
|
|
11
|
+
throw new Error('Failed to parse circuit_size from bb gates output');
|
|
12
|
+
}
|
|
13
|
+
return size;
|
|
14
|
+
}
|
|
15
|
+
/** Runs bb gates on a single artifact file and returns the gate count. */ async function getGateCount(bb, artifactPath) {
|
|
16
|
+
const { stdout } = await execFile(bb, [
|
|
17
|
+
'gates',
|
|
18
|
+
'--scheme',
|
|
19
|
+
'chonk',
|
|
20
|
+
'-b',
|
|
21
|
+
artifactPath
|
|
22
|
+
]);
|
|
23
|
+
return parseGateCount(stdout);
|
|
24
|
+
}
|
|
25
|
+
/** Profiles all compiled artifacts in a target directory and prints gate counts. */ export async function profileGates(targetDir, log) {
|
|
26
|
+
const bb = process.env.BB ?? 'bb';
|
|
27
|
+
const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
|
|
28
|
+
if (artifacts.length === 0) {
|
|
29
|
+
log('No artifacts found in target directory.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const results = await asyncPool(MAX_CONCURRENT, artifacts, async (artifact)=>({
|
|
34
|
+
name: artifact.name,
|
|
35
|
+
gateCount: await getGateCount(bb, artifact.filePath)
|
|
36
|
+
}));
|
|
37
|
+
results.sort((a, b)=>a.name.localeCompare(b.name));
|
|
38
|
+
if (results.length === 0) {
|
|
39
|
+
log('No constrained circuits found.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const maxNameLen = Math.max(...results.map((r)=>r.name.length));
|
|
43
|
+
log('');
|
|
44
|
+
log('Gate counts:');
|
|
45
|
+
log('-'.repeat(maxNameLen + 16));
|
|
46
|
+
for (const { name, gateCount } of results){
|
|
47
|
+
log(`${name.padEnd(maxNameLen)} ${gateCount.toLocaleString().padStart(12)}`);
|
|
48
|
+
}
|
|
49
|
+
log('-'.repeat(maxNameLen + 16));
|
|
50
|
+
log(`Total: ${results.length} circuit(s)`);
|
|
51
|
+
} finally{
|
|
52
|
+
await rm(tmpDir, {
|
|
53
|
+
recursive: true,
|
|
54
|
+
force: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CompiledArtifact, ContractFunction } from './utils/artifacts.js';
|
|
2
|
+
export declare const MAX_CONCURRENT = 4;
|
|
3
|
+
export interface DiscoveredArtifact {
|
|
4
|
+
name: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
type: 'contract-function' | 'program';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Reads a target directory and returns a list of discovered artifacts with temp files
|
|
10
|
+
* created for contract functions. Caller must clean up tmpDir when done.
|
|
11
|
+
*/
|
|
12
|
+
export declare function discoverArtifacts(targetDir: string): Promise<{
|
|
13
|
+
artifacts: DiscoveredArtifact[];
|
|
14
|
+
tmpDir: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** Extracts a contract function as a standalone program artifact JSON string. */
|
|
17
|
+
export declare function makeFunctionArtifact(artifact: CompiledArtifact, func: ContractFunction): string;
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV91dGlscy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbW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B,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB9D;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,UAWtF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { mkdtemp, writeFile } from 'fs/promises';
|
|
2
|
+
import { tmpdir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { readArtifactFiles } from './utils/artifacts.js';
|
|
5
|
+
export const MAX_CONCURRENT = 4;
|
|
6
|
+
/**
|
|
7
|
+
* Reads a target directory and returns a list of discovered artifacts with temp files
|
|
8
|
+
* created for contract functions. Caller must clean up tmpDir when done.
|
|
9
|
+
*/ export async function discoverArtifacts(targetDir) {
|
|
10
|
+
const files = await readArtifactFiles(targetDir);
|
|
11
|
+
const tmpDir = await mkdtemp(join(tmpdir(), 'aztec-profile-'));
|
|
12
|
+
const artifacts = [];
|
|
13
|
+
for (const file of files){
|
|
14
|
+
if (Array.isArray(file.content.functions)) {
|
|
15
|
+
for (const func of file.content.functions){
|
|
16
|
+
if (!func.bytecode || func.is_unconstrained) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const name = `${file.name}::${func.name}`;
|
|
20
|
+
const tmpPath = join(tmpDir, `${file.name}-${func.name}.json`);
|
|
21
|
+
await writeFile(tmpPath, makeFunctionArtifact(file.content, func));
|
|
22
|
+
artifacts.push({
|
|
23
|
+
name,
|
|
24
|
+
filePath: tmpPath,
|
|
25
|
+
type: 'contract-function'
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
} else if (file.content.bytecode) {
|
|
29
|
+
artifacts.push({
|
|
30
|
+
name: file.name,
|
|
31
|
+
filePath: file.filePath,
|
|
32
|
+
type: 'program'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
artifacts,
|
|
38
|
+
tmpDir
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Extracts a contract function as a standalone program artifact JSON string. */ export function makeFunctionArtifact(artifact, func) {
|
|
42
|
+
/* eslint-disable camelcase */ return JSON.stringify({
|
|
43
|
+
noir_version: artifact.noir_version,
|
|
44
|
+
hash: 0,
|
|
45
|
+
abi: func.abi,
|
|
46
|
+
bytecode: func.bytecode,
|
|
47
|
+
debug_symbols: func.debug_symbols,
|
|
48
|
+
file_map: artifact.file_map
|
|
49
|
+
});
|
|
50
|
+
/* eslint-enable camelcase */ }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
+
import type { GenesisStateConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
5
|
+
/**
|
|
6
|
+
* Computes the expected genesis archive root from the genesis state config.
|
|
7
|
+
* Reads test accounts and sponsored FPC addresses as specified, then computes
|
|
8
|
+
* the genesis values including the archive root and prefilled public data.
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeExpectedGenesisRoot(config: GenesisStateConfig, userLog: LogFn): Promise<{
|
|
11
|
+
genesisArchiveRoot: Fr;
|
|
12
|
+
prefilledPublicData: import("@aztec/stdlib/trees").PublicDataTreeLeaf[];
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
16
|
+
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
17
|
+
* starts a lightweight HTTP server for K8s liveness probes and polls every 60s until a compatible rollup appears.
|
|
18
|
+
*/
|
|
19
|
+
export declare function waitForCompatibleRollup(config: {
|
|
20
|
+
l1RpcUrls: string[];
|
|
21
|
+
l1ChainId: number;
|
|
22
|
+
l1Contracts: {
|
|
23
|
+
registryAddress: EthAddress;
|
|
24
|
+
};
|
|
25
|
+
rollupVersion?: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|
+
{"version":3,"file":"standby.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/standby.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK;;;GAa1F;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QAAE,eAAe,EAAE,UAAU,CAAA;KAAE,CAAC;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,EACD,mBAAmB,EAAE,EAAE,EACvB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,KAAK,GACb,OAAO,CAAC,IAAI,CAAC,CA0Df"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
3
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
4
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
6
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
7
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
9
|
+
import Koa from 'koa';
|
|
10
|
+
const ROLLUP_POLL_INTERVAL_S = 60;
|
|
11
|
+
/**
|
|
12
|
+
* Computes the expected genesis archive root from the genesis state config.
|
|
13
|
+
* Reads test accounts and sponsored FPC addresses as specified, then computes
|
|
14
|
+
* the genesis values including the archive root and prefilled public data.
|
|
15
|
+
*/ export async function computeExpectedGenesisRoot(config, userLog) {
|
|
16
|
+
const testAccounts = config.testAccounts ? (await getInitialTestAccountsData()).map((a)=>a.address) : [];
|
|
17
|
+
const sponsoredFPCAccounts = config.sponsoredFPC ? [
|
|
18
|
+
await getSponsoredFPCAddress()
|
|
19
|
+
] : [];
|
|
20
|
+
const prefundAddresses = (config.prefundAddresses ?? []).map((a)=>AztecAddress.fromString(a));
|
|
21
|
+
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses);
|
|
22
|
+
userLog(`Initial funded accounts: ${initialFundedAccounts.map((a)=>a.toString()).join(', ')}`);
|
|
23
|
+
const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
24
|
+
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
25
|
+
return {
|
|
26
|
+
genesisArchiveRoot,
|
|
27
|
+
prefilledPublicData
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
32
|
+
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
33
|
+
* starts a lightweight HTTP server for K8s liveness probes and polls every 60s until a compatible rollup appears.
|
|
34
|
+
*/ export async function waitForCompatibleRollup(config, expectedGenesisRoot, port, userLog) {
|
|
35
|
+
const publicClient = getPublicClient(config);
|
|
36
|
+
const rollupVersion = config.rollupVersion ?? 'canonical';
|
|
37
|
+
const registry = new RegistryContract(publicClient, config.l1Contracts.registryAddress);
|
|
38
|
+
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
39
|
+
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
40
|
+
let l1GenesisRoot;
|
|
41
|
+
try {
|
|
42
|
+
l1GenesisRoot = await rollup.getGenesisArchiveTreeRoot();
|
|
43
|
+
} catch (err) {
|
|
44
|
+
throw new Error(`Could not retrieve genesis archive root from canonical rollup at ${rollupAddress}: ${err.message}`);
|
|
45
|
+
}
|
|
46
|
+
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
userLog(`Genesis root mismatch: expected ${expectedGenesisRoot}, got ${l1GenesisRoot} from rollup at ${rollupAddress}. ` + `Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_S}s for a compatible rollup...`);
|
|
50
|
+
const standbyServer = await startHttpRpcServer({
|
|
51
|
+
getApp: ()=>new Koa(),
|
|
52
|
+
isHealthy: ()=>true
|
|
53
|
+
}, {
|
|
54
|
+
port
|
|
55
|
+
});
|
|
56
|
+
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
57
|
+
try {
|
|
58
|
+
await retryUntil(async ()=>{
|
|
59
|
+
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
60
|
+
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
61
|
+
let currentGenesisRoot;
|
|
62
|
+
try {
|
|
63
|
+
currentGenesisRoot = await currentRollup.getGenesisArchiveTreeRoot();
|
|
64
|
+
} catch {
|
|
65
|
+
userLog(`Failed to fetch genesis root from rollup at ${currentRollupAddress}. Retrying...`);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (currentGenesisRoot.equals(expectedGenesisRoot)) {
|
|
69
|
+
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
userLog(`Still waiting. Rollup at ${currentRollupAddress} has genesis root ${currentGenesisRoot}.`);
|
|
73
|
+
return undefined;
|
|
74
|
+
}, 'compatible rollup', 0, ROLLUP_POLL_INTERVAL_S);
|
|
75
|
+
} finally{
|
|
76
|
+
await new Promise((resolve, reject)=>standbyServer.close((err)=>err ? reject(err) : resolve()));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ArchiverConfig } from '@aztec/archiver';
|
|
2
2
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
3
|
-
import { type DataStoreConfig } from '@aztec/kv-store
|
|
3
|
+
import { type DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
4
4
|
export type { ArchiverConfig, DataStoreConfig };
|
|
5
5
|
/** Starts a standalone archiver. */
|
|
6
6
|
export declare function startArchiver(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers): Promise<{
|
|
7
7
|
config: ArchiverConfig & DataStoreConfig;
|
|
8
8
|
}>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYXJjaGl2ZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbGkvY21kcy9zdGFydF9hcmNoaXZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxjQUFjLEVBQW9FLE1BQU0saUJBQWlCLENBQUM7QUFJeEgsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUUvRSxPQUFPLEVBQUUsS0FBSyxlQUFlLEVBQXNCLE1BQU0sd0JBQXdCLENBQUM7QUFLbEYsWUFBWSxFQUFFLGNBQWMsRUFBRSxlQUFlLEVBQUUsQ0FBQztBQUVoRCxvQ0FBb0M7QUFDcEMsd0JBQXNCLGFBQWEsQ0FDakMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsR0FDOUIsT0FBTyxDQUFDO0lBQUUsTUFBTSxFQUFFLGNBQWMsR0FBRyxlQUFlLENBQUE7Q0FBRSxDQUFDLENBK0J2RCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAoE,MAAM,iBAAiB,CAAC;AAIxH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAoE,MAAM,iBAAiB,CAAC;AAIxH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAKlF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAEhD,oCAAoC;AACpC,wBAAsB,aAAa,CACjC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC;IAAE,MAAM,EAAE,cAAc,GAAG,eAAe,CAAA;CAAE,CAAC,CA+BvD"}
|
|
@@ -2,8 +2,8 @@ import { archiverConfigMappings, createArchiver, getArchiverConfigFromEnv } from
|
|
|
2
2
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
3
3
|
import { blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
|
|
4
4
|
import { getL1Config } from '@aztec/cli/config';
|
|
5
|
-
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
6
5
|
import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
7
7
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
8
8
|
import { extractRelevantOptions } from '../util.js';
|
|
9
9
|
/** Starts a standalone archiver. */ export async function startArchiver(options, signalHandlers, services) {
|
|
@@ -2,7 +2,7 @@ import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
3
|
import { type AztecNode, type AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
4
4
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
5
|
-
import {
|
|
5
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
6
6
|
export declare function startBot(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, userLog: LogFn): Promise<void>;
|
|
7
|
-
export declare function addBot(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, wallet:
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
export declare function addBot(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, wallet: EmbeddedWallet, aztecNode: AztecNode, telemetry: TelemetryClient, aztecNodeAdmin?: AztecNodeAdmin, userLog?: LogFn): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYm90LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfYm90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFDL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQ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
+
{"version":3,"file":"start_bot.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_bot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAyB,MAAM,iCAAiC,CAAC;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAM/D,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAKzD,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,iBAwBf;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,eAAe,EAC1B,cAAc,CAAC,EAAE,cAAc,EAC/B,OAAO,CAAC,EAAE,KAAK,iBAmBhB"}
|
|
@@ -3,8 +3,8 @@ import { createStore, openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
3
3
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
4
4
|
import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
5
5
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient, makeTracedFetch } from '@aztec/telemetry-client';
|
|
6
|
-
import {
|
|
7
|
-
import { extractRelevantOptions } from '../util.js';
|
|
6
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
7
|
+
import { extractRelevantOptions, stringifyConfig } from '../util.js';
|
|
8
8
|
import { getVersions } from '../versioning.js';
|
|
9
9
|
export async function startBot(options, signalHandlers, services, userLog) {
|
|
10
10
|
const { proverNode, archiver, sequencer, p2pBootstrap, txe, prover } = options;
|
|
@@ -23,12 +23,16 @@ export async function startBot(options, signalHandlers, services, userLog) {
|
|
|
23
23
|
}
|
|
24
24
|
const aztecNode = createAztecNodeClient(config.nodeUrl, getVersions(), fetch);
|
|
25
25
|
const pxeConfig = extractRelevantOptions(options, allPxeConfigMappings, 'pxe');
|
|
26
|
-
|
|
26
|
+
userLog(`Creating bot wallet with config ${stringifyConfig(pxeConfig)}`);
|
|
27
|
+
const wallet = await EmbeddedWallet.create(aztecNode, {
|
|
28
|
+
pxeConfig
|
|
29
|
+
});
|
|
27
30
|
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
28
|
-
await addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, undefined);
|
|
31
|
+
await addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, undefined, userLog);
|
|
29
32
|
}
|
|
30
|
-
export async function addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, aztecNodeAdmin) {
|
|
33
|
+
export async function addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, aztecNodeAdmin, userLog) {
|
|
31
34
|
const config = extractRelevantOptions(options, botConfigMappings, 'bot');
|
|
35
|
+
userLog?.(`Starting bot with config ${stringifyConfig(config)}`);
|
|
32
36
|
const db = await (config.dataDirectory ? createStore('bot', BotStore.SCHEMA_VERSION, config) : openTmpStore('bot', true, config.dataStoreMapSizeKb));
|
|
33
37
|
const store = new BotStore(db);
|
|
34
38
|
await store.cleanupOldClaims();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type AztecNodeConfig } from '@aztec/aztec-node';
|
|
2
|
+
import { type NetworkNames } from '@aztec/foundation/config';
|
|
2
3
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
3
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
-
export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn): Promise<{
|
|
5
|
+
export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn, networkName: NetworkNames): Promise<{
|
|
5
6
|
config: AztecNodeConfig;
|
|
6
7
|
}>;
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUE2QyxNQUFNLG1CQUFtQixDQUFDO0FBS3BHLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBZSxNQUFNLDBCQUEwQixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUF3Qm5ELHdCQUFzQixTQUFTLENBQzdCLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLGFBQWEsRUFBRSxxQkFBcUIsRUFDcEMsT0FBTyxFQUFFLEtBQUssRUFDZCxXQUFXLEVBQUUsWUFBWSxHQUN4QixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZUFBZSxDQUFBO0NBQUUsQ0FBQyxDQStKdEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAKpG,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAwBnD,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,EACd,WAAW,EAAE,YAAY,GACxB,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CA+JtC"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
1
|
import { aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
|
|
3
2
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
-
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
5
3
|
import { getL1Config } from '@aztec/cli/config';
|
|
6
4
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
|
+
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
7
6
|
import { SecretValue } from '@aztec/foundation/config';
|
|
7
|
+
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
8
|
+
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
8
9
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
9
10
|
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
10
|
-
import { P2PApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import { initTelemetryClient, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
12
|
-
import {
|
|
13
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
11
|
+
import { P2PApiSchema, ProverNodeApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
12
|
+
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
13
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
14
14
|
import { createAztecNode } from '../../local-network/index.js';
|
|
15
|
-
import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying,
|
|
16
|
-
|
|
15
|
+
import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying, setupVersionChecker } from '../util.js';
|
|
16
|
+
import { getVersions } from '../versioning.js';
|
|
17
|
+
import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
|
|
18
|
+
import { startProverBroker } from './start_prover_broker.js';
|
|
19
|
+
export async function startNode(options, signalHandlers, services, adminServices, userLog, networkName) {
|
|
17
20
|
// All options set from environment variables
|
|
18
21
|
const configFromEnvVars = getConfigEnvVars();
|
|
19
22
|
// Extract relevant options from command line arguments
|
|
@@ -23,23 +26,51 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
23
26
|
...configFromEnvVars,
|
|
24
27
|
...relevantOptions
|
|
25
28
|
};
|
|
29
|
+
// Prover node configuration and broker setup
|
|
30
|
+
// REFACTOR: Move the broker setup out of here and into the prover-node factory
|
|
31
|
+
let broker = undefined;
|
|
26
32
|
if (options.proverNode) {
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
nodeConfig.enableProverNode = true;
|
|
34
|
+
if (nodeConfig.proverAgentCount === 0) {
|
|
35
|
+
userLog(`Running prover node without local prover agent. Connect prover agents or pass --proverAgent.proverAgentCount`);
|
|
36
|
+
}
|
|
37
|
+
if (nodeConfig.proverBrokerUrl) {
|
|
38
|
+
// at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
|
|
39
|
+
// set a lower connection limit such that we don't overload the server
|
|
40
|
+
// Keep retrying up to 30s
|
|
41
|
+
const fetch = makeTracedFetch([
|
|
42
|
+
1,
|
|
43
|
+
2,
|
|
44
|
+
3,
|
|
45
|
+
3,
|
|
46
|
+
3,
|
|
47
|
+
3,
|
|
48
|
+
3,
|
|
49
|
+
3,
|
|
50
|
+
3,
|
|
51
|
+
3,
|
|
52
|
+
3
|
|
53
|
+
], false, makeUndiciFetch(new Agent({
|
|
54
|
+
connections: 100
|
|
55
|
+
})));
|
|
56
|
+
broker = createProvingJobBrokerClient(nodeConfig.proverBrokerUrl, getVersions(nodeConfig), fetch);
|
|
57
|
+
} else if (options.proverBroker) {
|
|
58
|
+
({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
|
|
59
|
+
} else {
|
|
60
|
+
userLog(`--prover-broker-url or --prover-broker is required to start a Prover Node`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
29
63
|
}
|
|
30
64
|
await preloadCrsDataForVerifying(nodeConfig, userLog);
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
await getSponsoredFPCAddress()
|
|
34
|
-
] : [];
|
|
35
|
-
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
|
|
36
|
-
userLog(`Initial funded accounts: ${initialFundedAccounts.map((a)=>a.toString()).join(', ')}`);
|
|
37
|
-
const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
38
|
-
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
65
|
+
const genesisConfig = getGenesisStateConfigEnvVars();
|
|
66
|
+
const { genesisArchiveRoot, prefilledPublicData } = await computeExpectedGenesisRoot(genesisConfig, userLog);
|
|
39
67
|
const followsCanonicalRollup = typeof nodeConfig.rollupVersion !== 'number' || nodeConfig.rollupVersion === 'canonical';
|
|
40
68
|
if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
|
|
41
69
|
throw new Error('L1 registry address is required to start Aztec Node');
|
|
42
70
|
}
|
|
71
|
+
// Wait for a compatible rollup before proceeding with full L1 config fetch.
|
|
72
|
+
// This prevents crashes when the canonical rollup hasn't been upgraded yet.
|
|
73
|
+
await waitForCompatibleRollup(nodeConfig, genesisArchiveRoot, options.port, userLog);
|
|
43
74
|
const { addresses, config } = await getL1Config(nodeConfig.l1Contracts.registryAddress, nodeConfig.l1RpcUrls, nodeConfig.l1ChainId, nodeConfig.rollupVersion);
|
|
44
75
|
process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
|
|
45
76
|
if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
|
|
@@ -62,14 +93,14 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
62
93
|
...extractNamespacedOptions(options, 'sequencer')
|
|
63
94
|
};
|
|
64
95
|
// If no publisher private keys have been given, use the first validator key
|
|
65
|
-
if (sequencerConfig.
|
|
96
|
+
if (sequencerConfig.sequencerPublisherPrivateKeys === undefined || !sequencerConfig.sequencerPublisherPrivateKeys.length) {
|
|
66
97
|
if (sequencerConfig.validatorPrivateKeys?.getValue().length) {
|
|
67
|
-
sequencerConfig.
|
|
98
|
+
sequencerConfig.sequencerPublisherPrivateKeys = [
|
|
68
99
|
new SecretValue(sequencerConfig.validatorPrivateKeys.getValue()[0])
|
|
69
100
|
];
|
|
70
101
|
}
|
|
71
102
|
}
|
|
72
|
-
nodeConfig.
|
|
103
|
+
nodeConfig.sequencerPublisherPrivateKeys = sequencerConfig.sequencerPublisherPrivateKeys;
|
|
73
104
|
}
|
|
74
105
|
if (nodeConfig.p2pEnabled) {
|
|
75
106
|
// ensure bootstrapNodes is an array
|
|
@@ -81,7 +112,8 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
81
112
|
const telemetry = await initTelemetryClient(telemetryConfig);
|
|
82
113
|
// Create and start Aztec Node
|
|
83
114
|
const node = await createAztecNode(nodeConfig, {
|
|
84
|
-
telemetry
|
|
115
|
+
telemetry,
|
|
116
|
+
proverBroker: broker
|
|
85
117
|
}, {
|
|
86
118
|
prefilledPublicData
|
|
87
119
|
});
|
|
@@ -98,19 +130,37 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
98
130
|
node,
|
|
99
131
|
AztecNodeAdminApiSchema
|
|
100
132
|
];
|
|
133
|
+
// Register prover-node services if the prover node subsystem is running
|
|
134
|
+
const proverNode = node.getProverNode();
|
|
135
|
+
if (proverNode) {
|
|
136
|
+
services.prover = [
|
|
137
|
+
proverNode,
|
|
138
|
+
ProverNodeApiSchema
|
|
139
|
+
];
|
|
140
|
+
if (!nodeConfig.proverBrokerUrl) {
|
|
141
|
+
services.provingJobSource = [
|
|
142
|
+
proverNode.getProver().getProvingJobSource(),
|
|
143
|
+
ProvingJobConsumerSchema
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
101
147
|
// Add node stop function to signal handlers
|
|
102
148
|
signalHandlers.push(node.stop.bind(node));
|
|
103
149
|
// Add a txs bot if requested
|
|
104
150
|
if (options.bot) {
|
|
105
151
|
const { addBot } = await import('./start_bot.js');
|
|
106
152
|
const pxeConfig = extractRelevantOptions(options, allPxeConfigMappings, 'pxe');
|
|
107
|
-
const wallet = await
|
|
153
|
+
const wallet = await EmbeddedWallet.create(node, {
|
|
154
|
+
pxeConfig
|
|
155
|
+
});
|
|
108
156
|
await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
|
|
109
157
|
}
|
|
110
|
-
if (nodeConfig.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
158
|
+
if (nodeConfig.enableVersionCheck && networkName !== 'local') {
|
|
159
|
+
const cacheDir = process.env.DATA_DIRECTORY ? `${process.env.DATA_DIRECTORY}/cache` : undefined;
|
|
160
|
+
try {
|
|
161
|
+
await setupVersionChecker(networkName, followsCanonicalRollup, getPublicClient(nodeConfig), signalHandlers, cacheDir);
|
|
162
|
+
} catch {
|
|
163
|
+
/* no-op */ }
|
|
114
164
|
}
|
|
115
165
|
return {
|
|
116
166
|
config: nodeConfig
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { times } from '@aztec/foundation/collection';
|
|
2
2
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
3
3
|
import { buildServerCircuitProver } from '@aztec/prover-client';
|
|
4
|
-
import {
|
|
4
|
+
import { ProvingAgent, createProofStore, createProvingJobBrokerClient, proverAgentConfigMappings } from '@aztec/prover-client/broker';
|
|
5
5
|
import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node';
|
|
6
6
|
import { ProverAgentApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
7
7
|
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
@@ -44,7 +44,7 @@ export async function startProverAgent(options, signalHandlers, services, userLo
|
|
|
44
44
|
const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
|
|
45
45
|
const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
46
46
|
const prover = await buildServerCircuitProver(config, telemetry);
|
|
47
|
-
const proofStore =
|
|
47
|
+
const proofStore = await createProofStore(config.proofStore);
|
|
48
48
|
const agents = times(config.proverAgentCount, ()=>new ProvingAgent(broker, proofStore, prover, config.proverAgentProofTypes, config.proverAgentPollIntervalMs));
|
|
49
49
|
// expose all agents as individual services
|
|
50
50
|
for(let i = 0; i < agents.length; i++){
|
|
@@ -6,4 +6,4 @@ export declare function startProverBroker(options: any, signalHandlers: (() => P
|
|
|
6
6
|
broker: ProvingJobBroker;
|
|
7
7
|
config: ProverBrokerConfig;
|
|
8
8
|
}>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX2Jyb2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X3Byb3Zlcl9icm9rZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFLeEIsTUFBTSw2QkFBNkIsQ0FBQztBQUVyQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBTXhFLHdCQUFzQixpQkFBaUIsQ0FDckMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZ0JBQWdCLENBQUM7SUFBQyxNQUFNLEVBQUUsa0JBQWtCLENBQUE7Q0FBRSxDQUFDLENBdUNuRSJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_prover_broker.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_broker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"start_prover_broker.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_broker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMxE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAuCnE"}
|