@aztec/aztec 0.0.1-commit.7d4e6cd → 0.0.1-commit.8227e42
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 +5 -1
- 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 +46 -10
- 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 +27 -8
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +0 -1
- 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 +160 -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/start_archiver.d.ts +1 -1
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +5 -7
- 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 +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +62 -10
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +2 -2
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +1 -2
- 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 +2 -2
- 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/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 +5 -14
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +11 -6
- package/dest/examples/token.js +5 -5
- package/dest/local-network/banana_fpc.d.ts +1 -1
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +2 -2
- package/dest/local-network/local-network.d.ts +4 -3
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +34 -16
- 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/cheat_codes.d.ts +3 -1
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.d.ts +4 -2
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +15 -5
- package/package.json +35 -35
- package/scripts/aztec.sh +7 -4
- package/scripts/init.sh +23 -13
- package/scripts/new.sh +17 -16
- package/scripts/setup_workspace.sh +124 -0
- package/src/bin/index.ts +5 -1
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +50 -6
- package/src/cli/aztec_start_options.ts +28 -6
- package/src/cli/cli.ts +0 -1
- package/src/cli/cmds/compile.ts +184 -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/start_archiver.ts +2 -13
- package/src/cli/cmds/start_bot.ts +8 -5
- package/src/cli/cmds/start_node.ts +51 -9
- package/src/cli/cmds/start_p2p_bootstrap.ts +2 -2
- package/src/cli/cmds/start_prover_agent.ts +2 -2
- package/src/cli/cmds/start_prover_broker.ts +5 -1
- package/src/cli/cmds/utils/artifacts.ts +44 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/cli/util.ts +15 -20
- package/src/examples/token.ts +5 -7
- package/src/local-network/banana_fpc.ts +10 -6
- package/src/local-network/local-network.ts +49 -20
- package/src/testing/anvil_test_watcher.ts +59 -15
- package/src/testing/epoch_test_settler.ts +16 -4
- 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/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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
2
2
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
3
|
-
import {
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
4
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
5
5
|
import { type BootnodeConfig, BootstrapNode, bootnodeConfigMappings } from '@aztec/p2p';
|
|
6
6
|
import { emptyChainConfig } from '@aztec/stdlib/config';
|
|
@@ -27,7 +27,7 @@ export async function startP2PBootstrap(
|
|
|
27
27
|
const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
|
|
28
28
|
const telemetryClient = await initTelemetryClient(telemetryConfig);
|
|
29
29
|
|
|
30
|
-
const store = await createStore('p2p-bootstrap', 1, config
|
|
30
|
+
const store = await createStore('p2p-bootstrap', 1, config);
|
|
31
31
|
const node = new BootstrapNode(store, telemetryClient);
|
|
32
32
|
await node.start(config);
|
|
33
33
|
signalHandlers.push(() => node.stop());
|
|
@@ -4,9 +4,9 @@ import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
|
4
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
5
|
import { buildServerCircuitProver } from '@aztec/prover-client';
|
|
6
6
|
import {
|
|
7
|
-
InlineProofStore,
|
|
8
7
|
type ProverAgentConfig,
|
|
9
8
|
ProvingAgent,
|
|
9
|
+
createProofStore,
|
|
10
10
|
createProvingJobBrokerClient,
|
|
11
11
|
proverAgentConfigMappings,
|
|
12
12
|
} from '@aztec/prover-client/broker';
|
|
@@ -55,7 +55,7 @@ export async function startProverAgent(
|
|
|
55
55
|
|
|
56
56
|
const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
57
57
|
const prover = await buildServerCircuitProver(config, telemetry);
|
|
58
|
-
const proofStore =
|
|
58
|
+
const proofStore = await createProofStore(config.proofStore);
|
|
59
59
|
const agents = times(
|
|
60
60
|
config.proverAgentCount,
|
|
61
61
|
() => new ProvingAgent(broker, proofStore, prover, config.proverAgentProofTypes, config.proverAgentPollIntervalMs),
|
|
@@ -5,6 +5,7 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
5
5
|
import {
|
|
6
6
|
type ProverBrokerConfig,
|
|
7
7
|
ProvingJobBrokerSchema,
|
|
8
|
+
ProvingJobBrokerSchemaWithDebug,
|
|
8
9
|
createAndStartProvingBroker,
|
|
9
10
|
proverBrokerConfigMappings,
|
|
10
11
|
} from '@aztec/prover-client/broker';
|
|
@@ -59,7 +60,10 @@ export async function startProverBroker(
|
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
services.proverBroker = [
|
|
63
|
+
services.proverBroker = [
|
|
64
|
+
broker,
|
|
65
|
+
config.proverBrokerDebugReplayEnabled ? ProvingJobBrokerSchemaWithDebug : ProvingJobBrokerSchema,
|
|
66
|
+
];
|
|
63
67
|
signalHandlers.push(() => broker.stop());
|
|
64
68
|
|
|
65
69
|
return { broker, config };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { readFile, readdir } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
export interface CompiledArtifact {
|
|
5
|
+
noir_version: string;
|
|
6
|
+
file_map: unknown;
|
|
7
|
+
functions: ContractFunction[];
|
|
8
|
+
bytecode?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ContractFunction {
|
|
12
|
+
name: string;
|
|
13
|
+
abi: unknown;
|
|
14
|
+
bytecode: string;
|
|
15
|
+
debug_symbols: unknown;
|
|
16
|
+
is_unconstrained?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ArtifactFile {
|
|
20
|
+
name: string;
|
|
21
|
+
filePath: string;
|
|
22
|
+
content: CompiledArtifact;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Reads all JSON artifact files from a target directory and returns their parsed contents. */
|
|
26
|
+
export async function readArtifactFiles(targetDir: string): Promise<ArtifactFile[]> {
|
|
27
|
+
let entries: string[];
|
|
28
|
+
try {
|
|
29
|
+
entries = (await readdir(targetDir)).filter(f => f.endsWith('.json'));
|
|
30
|
+
} catch (err: any) {
|
|
31
|
+
if (err?.code === 'ENOENT') {
|
|
32
|
+
throw new Error(`Target directory '${targetDir}' does not exist. Compile first with 'aztec compile'.`);
|
|
33
|
+
}
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const artifacts: ArtifactFile[] = [];
|
|
38
|
+
for (const file of entries) {
|
|
39
|
+
const filePath = join(targetDir, file);
|
|
40
|
+
const content = JSON.parse(await readFile(filePath, 'utf-8')) as CompiledArtifact;
|
|
41
|
+
artifacts.push({ name: file.replace('.json', ''), filePath, content });
|
|
42
|
+
}
|
|
43
|
+
return artifacts;
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
|
|
3
|
+
/** Spawns a command with inherited stdio and rejects on non-zero exit. */
|
|
4
|
+
export function run(cmd: string, args: string[]): Promise<void> {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const child = spawn(cmd, args, { stdio: 'inherit' });
|
|
7
|
+
child.on('error', reject);
|
|
8
|
+
child.on('close', code => {
|
|
9
|
+
if (code !== 0) {
|
|
10
|
+
reject(new Error(`${cmd} exited with code ${code}`));
|
|
11
|
+
} else {
|
|
12
|
+
resolve();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
package/src/cli/util.ts
CHANGED
|
@@ -2,13 +2,13 @@ import type { AztecNodeConfig } from '@aztec/aztec-node';
|
|
|
2
2
|
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
3
3
|
import type { ViemClient } from '@aztec/ethereum/types';
|
|
4
4
|
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
5
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
7
7
|
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
8
8
|
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
9
9
|
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
|
|
10
10
|
import { getTelemetryClient } from '@aztec/telemetry-client/start';
|
|
11
|
-
import type {
|
|
11
|
+
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
12
12
|
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import type { Command } from 'commander';
|
|
@@ -36,7 +36,7 @@ export function shutdown(logFn: LogFn, exitCode: ExitCode, cb?: Array<() => Prom
|
|
|
36
36
|
|
|
37
37
|
logFn('Shutting down...', { exitCode });
|
|
38
38
|
if (cb) {
|
|
39
|
-
shutdownPromise = Promise.allSettled(cb).then(() => process.exit(exitCode));
|
|
39
|
+
shutdownPromise = Promise.allSettled(cb.map(fn => fn())).then(() => process.exit(exitCode));
|
|
40
40
|
} else {
|
|
41
41
|
// synchronously shuts down the process
|
|
42
42
|
// no need to set shutdownPromise on this branch of the if statement because no more code will be executed
|
|
@@ -68,30 +68,19 @@ export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<voi
|
|
|
68
68
|
/**
|
|
69
69
|
* Creates logs for the initial accounts
|
|
70
70
|
* @param accounts - The initial accounts
|
|
71
|
-
* @param wallet - A
|
|
71
|
+
* @param wallet - A EmbeddedWallet instance to get the registered accounts
|
|
72
72
|
* @returns A string array containing the initial accounts details
|
|
73
73
|
*/
|
|
74
|
-
export async function createAccountLogs(
|
|
75
|
-
accountsWithSecretKeys: {
|
|
76
|
-
/**
|
|
77
|
-
* The account object
|
|
78
|
-
*/
|
|
79
|
-
account: AccountManager;
|
|
80
|
-
/**
|
|
81
|
-
* The secret key of the account
|
|
82
|
-
*/
|
|
83
|
-
secretKey: Fr;
|
|
84
|
-
}[],
|
|
85
|
-
wallet: TestWallet,
|
|
86
|
-
) {
|
|
74
|
+
export async function createAccountLogs(accountManagers: AccountManager[], wallet: EmbeddedWallet) {
|
|
87
75
|
const registeredAccounts = await wallet.getAccounts();
|
|
88
76
|
const accountLogStrings = [`Initial Accounts:\n\n`];
|
|
89
|
-
for (const
|
|
90
|
-
const
|
|
77
|
+
for (const accountManager of accountManagers) {
|
|
78
|
+
const account = await accountManager.getAccount();
|
|
79
|
+
const completeAddress = account.getCompleteAddress();
|
|
91
80
|
if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
|
|
92
81
|
accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
|
|
93
82
|
accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
|
|
94
|
-
accountLogStrings.push(` Secret Key: ${
|
|
83
|
+
accountLogStrings.push(` Secret Key: ${account.getSecretKey().toString()}\n`);
|
|
95
84
|
accountLogStrings.push(
|
|
96
85
|
` Master nullifier public key: ${completeAddress.publicKeys.masterNullifierPublicKey.toString()}\n`,
|
|
97
86
|
);
|
|
@@ -388,3 +377,9 @@ export async function setupUpdateMonitor(
|
|
|
388
377
|
|
|
389
378
|
checker.start();
|
|
390
379
|
}
|
|
380
|
+
|
|
381
|
+
export function stringifyConfig(config: object): string {
|
|
382
|
+
return Object.entries(config)
|
|
383
|
+
.map(([key, value]) => `${key}=${jsonStringify(value)}`)
|
|
384
|
+
.join(' ');
|
|
385
|
+
}
|
package/src/examples/token.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
|
2
2
|
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
-
import {
|
|
5
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
6
6
|
|
|
7
7
|
const logger = createLogger('example:token');
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ const TRANSFER_AMOUNT = 33n;
|
|
|
19
19
|
async function main() {
|
|
20
20
|
logger.info('Running token contract test on HTTP interface.');
|
|
21
21
|
|
|
22
|
-
const wallet = await
|
|
22
|
+
const wallet = await EmbeddedWallet.create(node);
|
|
23
23
|
|
|
24
24
|
// During local network setup we deploy a few accounts. Below we add them to our wallet.
|
|
25
25
|
const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
|
|
@@ -32,14 +32,12 @@ async function main() {
|
|
|
32
32
|
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
33
33
|
|
|
34
34
|
logger.info('Deploying Token...');
|
|
35
|
-
const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18)
|
|
36
|
-
.send({ from: alice })
|
|
37
|
-
.deployed();
|
|
35
|
+
const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({ from: alice });
|
|
38
36
|
logger.info('Token deployed');
|
|
39
37
|
|
|
40
38
|
// Mint tokens to Alice
|
|
41
39
|
logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
|
|
42
|
-
await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice })
|
|
40
|
+
await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice });
|
|
43
41
|
|
|
44
42
|
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
45
43
|
|
|
@@ -48,7 +46,7 @@ async function main() {
|
|
|
48
46
|
|
|
49
47
|
// We will now transfer tokens from Alice to Bob
|
|
50
48
|
logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
|
|
51
|
-
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice })
|
|
49
|
+
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
|
|
52
50
|
|
|
53
51
|
// Check the new balances
|
|
54
52
|
const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
@@ -49,12 +49,16 @@ export async function setupBananaFPC(initialAccounts: InitialAccountData[], wall
|
|
|
49
49
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
50
50
|
const admin = getBananaAdmin(initialAccounts);
|
|
51
51
|
const [bananaCoin, fpc] = await Promise.all([
|
|
52
|
-
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
|
|
53
|
+
from: admin,
|
|
54
|
+
contractAddressSalt: BANANA_COIN_SALT,
|
|
55
|
+
universalDeploy: true,
|
|
56
|
+
}),
|
|
57
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
|
|
58
|
+
from: admin,
|
|
59
|
+
contractAddressSalt: BANANA_FPC_SALT,
|
|
60
|
+
universalDeploy: true,
|
|
61
|
+
}),
|
|
58
62
|
]);
|
|
59
63
|
|
|
60
64
|
log(`BananaCoin: ${bananaCoin.address}`);
|
|
@@ -18,13 +18,16 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
18
18
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
19
19
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
20
20
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
21
|
+
import { SequencerState } from '@aztec/sequencer-client';
|
|
22
|
+
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
21
23
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
22
24
|
import {
|
|
23
25
|
type TelemetryClient,
|
|
24
26
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
25
27
|
initTelemetryClient,
|
|
26
28
|
} from '@aztec/telemetry-client';
|
|
27
|
-
import {
|
|
29
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
30
|
+
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
28
31
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
29
32
|
|
|
30
33
|
import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
@@ -51,7 +54,6 @@ export async function deployContractsToL1(
|
|
|
51
54
|
aztecNodeConfig: AztecNodeConfig,
|
|
52
55
|
privateKey: Hex,
|
|
53
56
|
opts: {
|
|
54
|
-
assumeProvenThroughBlockNumber?: number;
|
|
55
57
|
genesisArchiveRoot?: Fr;
|
|
56
58
|
feeJuicePortalInitialBalance?: bigint;
|
|
57
59
|
} = {},
|
|
@@ -105,12 +107,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
105
107
|
};
|
|
106
108
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
107
109
|
if (
|
|
108
|
-
aztecNodeConfig.
|
|
109
|
-
!aztecNodeConfig.
|
|
110
|
-
aztecNodeConfig.
|
|
110
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys == undefined ||
|
|
111
|
+
!aztecNodeConfig.sequencerPublisherPrivateKeys.length ||
|
|
112
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY
|
|
111
113
|
) {
|
|
112
114
|
const privKey = hdAccount.getHdKey().privateKey;
|
|
113
|
-
aztecNodeConfig.
|
|
115
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys = [
|
|
116
|
+
new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const),
|
|
117
|
+
];
|
|
114
118
|
}
|
|
115
119
|
if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
|
|
116
120
|
const privKey = hdAccount.getHdKey().privateKey;
|
|
@@ -149,7 +153,6 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
149
153
|
aztecNodeConfig,
|
|
150
154
|
aztecNodeConfig.validatorPrivateKeys.getValue()[0],
|
|
151
155
|
{
|
|
152
|
-
assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
|
|
153
156
|
genesisArchiveRoot,
|
|
154
157
|
feeJuicePortalInitialBalance: fundingNeeded,
|
|
155
158
|
},
|
|
@@ -179,25 +182,42 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
179
182
|
const blobClient = createBlobClient();
|
|
180
183
|
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
|
|
181
184
|
|
|
185
|
+
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
186
|
+
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
187
|
+
// warping time out from under an in-progress block.
|
|
188
|
+
watcher?.setGetPendingTxCount(() => node.getPendingTxCount());
|
|
189
|
+
const sequencer = node.getSequencer()?.getSequencer();
|
|
190
|
+
if (sequencer) {
|
|
191
|
+
const idleStates: Set<string> = new Set([
|
|
192
|
+
SequencerState.STOPPED,
|
|
193
|
+
SequencerState.STOPPING,
|
|
194
|
+
SequencerState.IDLE,
|
|
195
|
+
SequencerState.SYNCHRONIZING,
|
|
196
|
+
]);
|
|
197
|
+
watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
|
|
198
|
+
}
|
|
199
|
+
|
|
182
200
|
let epochTestSettler: EpochTestSettler | undefined;
|
|
183
201
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
184
|
-
epochTestSettler = new EpochTestSettler(
|
|
185
|
-
|
|
186
|
-
|
|
202
|
+
epochTestSettler = new EpochTestSettler(
|
|
203
|
+
cheatcodes!,
|
|
204
|
+
rollupAddress!,
|
|
205
|
+
node.getBlockSource(),
|
|
206
|
+
logger.createChild('epoch-settler'),
|
|
207
|
+
{ pollingIntervalMs: 200 },
|
|
208
|
+
);
|
|
187
209
|
await epochTestSettler.start();
|
|
188
210
|
}
|
|
189
211
|
|
|
190
212
|
if (initialAccounts.length) {
|
|
191
|
-
const
|
|
192
|
-
|
|
213
|
+
const wallet = await EmbeddedWallet.create(node, {
|
|
214
|
+
pxeConfig: { proverEnabled: aztecNodeConfig.realProofs },
|
|
215
|
+
ephemeral: true,
|
|
216
|
+
});
|
|
193
217
|
|
|
194
218
|
userLog('Setting up funded test accounts...');
|
|
195
|
-
const accountManagers = await deployFundedSchnorrAccounts(wallet,
|
|
196
|
-
const
|
|
197
|
-
account: manager,
|
|
198
|
-
secretKey: initialAccounts[i].secret,
|
|
199
|
-
}));
|
|
200
|
-
const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
|
|
219
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
|
|
220
|
+
const accLogs = await createAccountLogs(accountManagers, wallet);
|
|
201
221
|
userLog(accLogs.join(''));
|
|
202
222
|
|
|
203
223
|
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
@@ -223,7 +243,12 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
223
243
|
*/
|
|
224
244
|
export async function createAztecNode(
|
|
225
245
|
config: Partial<AztecNodeConfig> = {},
|
|
226
|
-
deps: {
|
|
246
|
+
deps: {
|
|
247
|
+
telemetry?: TelemetryClient;
|
|
248
|
+
blobClient?: BlobClientInterface;
|
|
249
|
+
dateProvider?: DateProvider;
|
|
250
|
+
proverBroker?: ProvingJobBroker;
|
|
251
|
+
} = {},
|
|
227
252
|
options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
|
|
228
253
|
) {
|
|
229
254
|
// TODO(#12272): will clean this up. This is criminal.
|
|
@@ -233,6 +258,10 @@ export async function createAztecNode(
|
|
|
233
258
|
...config,
|
|
234
259
|
l1Contracts: { ...l1Contracts, ...config.l1Contracts },
|
|
235
260
|
};
|
|
236
|
-
const node = await AztecNodeService.createAndSync(
|
|
261
|
+
const node = await AztecNodeService.createAndSync(
|
|
262
|
+
aztecNodeConfig,
|
|
263
|
+
{ ...deps, proverNodeDeps: { broker: deps.proverBroker } },
|
|
264
|
+
options,
|
|
265
|
+
);
|
|
237
266
|
return node;
|
|
238
267
|
}
|
|
@@ -31,6 +31,15 @@ export class AnvilTestWatcher {
|
|
|
31
31
|
|
|
32
32
|
private isMarkingAsProven = true;
|
|
33
33
|
|
|
34
|
+
// Optional callback to check if there are pending txs in the mempool.
|
|
35
|
+
private getPendingTxCount?: () => Promise<number>;
|
|
36
|
+
|
|
37
|
+
// Optional callback to check if the sequencer is actively building a block.
|
|
38
|
+
private isSequencerBuilding?: () => boolean;
|
|
39
|
+
|
|
40
|
+
// Tracks when we first observed the current unfilled slot with pending txs (real wall time).
|
|
41
|
+
private unfilledSlotFirstSeen?: { slot: number; realTime: number };
|
|
42
|
+
|
|
34
43
|
constructor(
|
|
35
44
|
private cheatcodes: EthCheatCodes,
|
|
36
45
|
rollupAddress: EthAddress,
|
|
@@ -59,6 +68,16 @@ export class AnvilTestWatcher {
|
|
|
59
68
|
this.isLocalNetwork = isLocalNetwork;
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */
|
|
72
|
+
setGetPendingTxCount(fn: () => Promise<number>) {
|
|
73
|
+
this.getPendingTxCount = fn;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */
|
|
77
|
+
setIsSequencerBuilding(fn: () => boolean) {
|
|
78
|
+
this.isSequencerBuilding = fn;
|
|
79
|
+
}
|
|
80
|
+
|
|
62
81
|
async start() {
|
|
63
82
|
if (this.filledRunningPromise) {
|
|
64
83
|
throw new Error('Watcher already watching for filled slot');
|
|
@@ -131,15 +150,8 @@ export class AnvilTestWatcher {
|
|
|
131
150
|
const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]));
|
|
132
151
|
|
|
133
152
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
137
|
-
resetBlockInterval: true,
|
|
138
|
-
});
|
|
139
|
-
} catch (e) {
|
|
140
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
153
|
+
// The current slot has been filled, we should jump to the next slot.
|
|
154
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
143
155
|
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
144
156
|
return;
|
|
145
157
|
}
|
|
@@ -149,18 +161,50 @@ export class AnvilTestWatcher {
|
|
|
149
161
|
return;
|
|
150
162
|
}
|
|
151
163
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
// If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
|
|
165
|
+
// sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
|
|
166
|
+
// the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
|
|
167
|
+
// to avoid invalidating its in-progress work.
|
|
168
|
+
if (this.getPendingTxCount) {
|
|
169
|
+
const pendingTxs = await this.getPendingTxCount();
|
|
170
|
+
if (pendingTxs > 0) {
|
|
171
|
+
if (this.isSequencerBuilding?.()) {
|
|
172
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const realNow = Date.now();
|
|
177
|
+
if (!this.unfilledSlotFirstSeen || this.unfilledSlotFirstSeen.slot !== currentSlot) {
|
|
178
|
+
this.unfilledSlotFirstSeen = { slot: currentSlot, realTime: realNow };
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
183
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
184
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
185
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return;
|
|
158
189
|
}
|
|
190
|
+
}
|
|
159
191
|
|
|
192
|
+
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
193
|
+
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
194
|
+
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
195
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
160
196
|
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
161
197
|
}
|
|
162
198
|
} catch {
|
|
163
199
|
this.logger.error('mineIfSlotFilled failed');
|
|
164
200
|
}
|
|
165
201
|
}
|
|
202
|
+
|
|
203
|
+
private async warpToTimestamp(timestamp: number) {
|
|
204
|
+
try {
|
|
205
|
+
await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
|
|
206
|
+
} catch (e) {
|
|
207
|
+
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
166
210
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
2
|
import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
3
3
|
import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
5
|
import { EpochMonitor } from '@aztec/prover-node';
|
|
5
6
|
import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
|
|
6
7
|
import { computeL2ToL1MembershipWitnessFromMessagesInEpoch } from '@aztec/stdlib/messaging';
|
|
@@ -13,6 +14,7 @@ export class EpochTestSettler {
|
|
|
13
14
|
cheatcodes: EthCheatCodes,
|
|
14
15
|
rollupAddress: EthAddress,
|
|
15
16
|
private l2BlockSource: L2BlockSource,
|
|
17
|
+
private log: Logger,
|
|
16
18
|
private options: { pollingIntervalMs: number; provingDelayMs?: number },
|
|
17
19
|
) {
|
|
18
20
|
this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, { rollupAddress });
|
|
@@ -29,10 +31,16 @@ export class EpochTestSettler {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
|
|
32
|
-
const
|
|
34
|
+
const checkpointedBlocks = await this.l2BlockSource.getCheckpointedBlocksForEpoch(epoch);
|
|
35
|
+
const blocks = checkpointedBlocks.map(b => b.block);
|
|
36
|
+
this.log.info(
|
|
37
|
+
`Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`,
|
|
38
|
+
{ blocks: blocks.map(b => b.toBlockInfo()) },
|
|
39
|
+
);
|
|
33
40
|
const messagesInEpoch: Fr[][][][] = [];
|
|
34
41
|
let previousSlotNumber = SlotNumber.ZERO;
|
|
35
42
|
let checkpointIndex = -1;
|
|
43
|
+
|
|
36
44
|
for (const block of blocks) {
|
|
37
45
|
const slotNumber = block.header.globalVariables.slotNumber;
|
|
38
46
|
if (slotNumber !== previousSlotNumber) {
|
|
@@ -47,11 +55,15 @@ export class EpochTestSettler {
|
|
|
47
55
|
if (firstMessage) {
|
|
48
56
|
const { root: outHash } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, firstMessage);
|
|
49
57
|
await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
|
|
58
|
+
} else {
|
|
59
|
+
this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
await this.rollupCheatCodes.markAsProven(
|
|
62
|
+
const lastCheckpoint = checkpointedBlocks.at(-1)?.checkpointNumber;
|
|
63
|
+
if (lastCheckpoint !== undefined) {
|
|
64
|
+
await this.rollupCheatCodes.markAsProven(lastCheckpoint);
|
|
65
|
+
} else {
|
|
66
|
+
this.log.warn(`No checkpoint found for epoch ${epoch}`);
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
return true;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
2
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
import { type ProverNodeConfig } from '@aztec/prover-node';
|
|
4
|
-
export declare function startProverNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, userLog: LogFn): Promise<{
|
|
5
|
-
config: ProverNodeConfig;
|
|
6
|
-
}>;
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX25vZGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbGkvY21kcy9zdGFydF9wcm92ZXJfbm9kZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBRS9FLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELE9BQU8sRUFDTCxLQUFLLGdCQUFnQixFQUl0QixNQUFNLG9CQUFvQixDQUFDO0FBUzVCLHdCQUFzQixlQUFlLENBQ25DLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLE9BQU8sRUFBRSxLQUFLLEdBQ2IsT0FBTyxDQUFDO0lBQUUsTUFBTSxFQUFFLGdCQUFnQixDQUFBO0NBQUUsQ0FBQyxDQStGdkMifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start_prover_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_node.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,KAAK,gBAAgB,EAItB,MAAM,oBAAoB,CAAC;AAS5B,wBAAsB,eAAe,CACnC,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,CAAA;CAAE,CAAC,CA+FvC"}
|