@aztec/aztec 0.0.1-commit.e588bc7e5 → 0.0.1-commit.e5a3663dd
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/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 +13 -4
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +13 -6
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +1 -14
- package/dest/cli/cmds/profile.d.ts +1 -1
- package/dest/cli/cmds/profile.d.ts.map +1 -1
- package/dest/cli/cmds/profile.js +1 -1
- package/dest/cli/cmds/profile_gates.d.ts +2 -2
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +21 -3
- package/dest/cli/cmds/standby.d.ts +1 -1
- package/dest/cli/cmds/standby.js +2 -2
- 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 +3 -1
- 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 +3 -5
- package/dest/cli/cmds/start_prover_agent.js +2 -2
- package/dest/cli/cmds/start_prover_broker.js +2 -2
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +4 -3
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +2 -2
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -1
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +33 -12
- package/dest/local-network/local-network.d.ts +3 -4
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +3 -3
- package/dest/testing/anvil_test_watcher.d.ts +7 -3
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +39 -13
- package/dest/testing/cheat_codes.d.ts +11 -15
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +33 -31
- package/dest/testing/index.d.ts +2 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/package.json +33 -33
- package/scripts/add_crate.sh +8 -58
- package/scripts/aztec.sh +5 -1
- package/scripts/init.sh +5 -5
- package/scripts/new.sh +2 -2
- package/scripts/setup_workspace.sh +3 -2
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/cli/aztec_start_action.ts +7 -4
- package/src/cli/aztec_start_options.ts +20 -11
- package/src/cli/cmds/compile.ts +1 -17
- package/src/cli/cmds/profile.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +20 -4
- package/src/cli/cmds/standby.ts +2 -2
- package/src/cli/cmds/start_archiver.ts +7 -1
- package/src/cli/cmds/start_node.ts +2 -4
- package/src/cli/cmds/start_prover_agent.ts +2 -2
- package/src/cli/cmds/start_prover_broker.ts +2 -2
- package/src/cli/cmds/start_txe.ts +5 -3
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +35 -12
- package/src/local-network/local-network.ts +5 -5
- package/src/testing/anvil_test_watcher.ts +43 -12
- package/src/testing/cheat_codes.ts +41 -35
- package/src/testing/index.ts +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
use aztec::macros::aztec;
|
|
2
|
+
|
|
3
|
+
#[aztec]
|
|
4
|
+
pub contract Counter {
|
|
5
|
+
use aztec::{
|
|
6
|
+
macros::{functions::{external, initializer}, storage::storage},
|
|
7
|
+
messages::message_delivery::MessageDelivery,
|
|
8
|
+
protocol::address::AztecAddress,
|
|
9
|
+
state_vars::Owned,
|
|
10
|
+
};
|
|
11
|
+
use balance_set::BalanceSet;
|
|
12
|
+
|
|
13
|
+
#[storage]
|
|
14
|
+
struct Storage<Context> {
|
|
15
|
+
// Each owner has their own counter, stored as private encrypted notes.
|
|
16
|
+
// Owned: dictates who will receive the encrypted notes.
|
|
17
|
+
// BalanceSet: manages the underlying notes, providing add/sub/balance_of.
|
|
18
|
+
counters: Owned<BalanceSet<Context>, Context>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Sets the owner's counter to an initial value.
|
|
22
|
+
//
|
|
23
|
+
// #[external("private")]: executes on the user's device, inputs are hidden from everyone.
|
|
24
|
+
#[initializer]
|
|
25
|
+
#[external("private")]
|
|
26
|
+
fn constructor(initial_value: u128, owner: AztecAddress) {
|
|
27
|
+
// Delivers the note to the recipient onchain with provable correctness.
|
|
28
|
+
// Without delivery, the recipient can't find or decrypt the note.
|
|
29
|
+
self.storage.counters.at(owner).add(initial_value).deliver(
|
|
30
|
+
MessageDelivery.ONCHAIN_CONSTRAINED,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Adds 1 to the owner's counter.
|
|
35
|
+
#[external("private")]
|
|
36
|
+
fn increment(owner: AztecAddress) {
|
|
37
|
+
self.storage.counters.at(owner).add(1).deliver(MessageDelivery.ONCHAIN_CONSTRAINED);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Returns the current value of the owner's counter.
|
|
41
|
+
//
|
|
42
|
+
// #[external("utility")]: runs off-chain, no transaction created, no cost.
|
|
43
|
+
// Only the owner can decrypt and read their own counter.
|
|
44
|
+
#[external("utility")]
|
|
45
|
+
unconstrained fn get_counter(owner: AztecAddress) -> u128 {
|
|
46
|
+
self.storage.counters.at(owner).balance_of()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
use aztec::{protocol::address::AztecAddress, test::helpers::test_environment::TestEnvironment};
|
|
2
|
+
use __CRATE_NAME___contract::Counter;
|
|
3
|
+
|
|
4
|
+
unconstrained fn setup(initial_value: u128) -> (TestEnvironment, AztecAddress, AztecAddress) {
|
|
5
|
+
let mut env = TestEnvironment::new();
|
|
6
|
+
let owner = env.create_light_account();
|
|
7
|
+
|
|
8
|
+
let contract_address = env.deploy("@__CRATE_NAME___contract/Counter")
|
|
9
|
+
.with_private_initializer(owner, Counter::interface().constructor(initial_value, owner));
|
|
10
|
+
|
|
11
|
+
(env, contract_address, owner)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
unconstrained fn test_constructor() {
|
|
16
|
+
let initial_value = 5;
|
|
17
|
+
let (env, contract_address, owner) = setup(initial_value);
|
|
18
|
+
|
|
19
|
+
let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
|
|
20
|
+
assert_eq(counter, initial_value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[test]
|
|
24
|
+
unconstrained fn test_increment() {
|
|
25
|
+
let initial_value = 5;
|
|
26
|
+
let (mut env, contract_address, owner) = setup(initial_value);
|
|
27
|
+
|
|
28
|
+
env.call_private(owner, Counter::at(contract_address).increment(owner));
|
|
29
|
+
|
|
30
|
+
let counter = env.execute_utility(Counter::at(contract_address).get_counter(owner));
|
|
31
|
+
assert_eq(counter, initial_value + 1);
|
|
32
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@aztec/foundation/json-rpc/server';
|
|
8
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
9
9
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
10
|
-
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
10
|
+
import { AztecNodeAdminApiSchema, AztecNodeApiSchema, AztecNodeDebugApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
11
11
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
12
12
|
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
|
|
13
13
|
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
@@ -27,8 +27,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
27
27
|
let config: ChainConfig | undefined = undefined;
|
|
28
28
|
|
|
29
29
|
if (options.localNetwork) {
|
|
30
|
-
const localNetwork = extractNamespacedOptions(options, '
|
|
31
|
-
localNetwork.testAccounts = true;
|
|
30
|
+
const localNetwork = extractNamespacedOptions(options, 'localNetwork');
|
|
32
31
|
userLog(`${splash}\n${github}\n\n`);
|
|
33
32
|
userLog(`Setting up Aztec local network ${packageVersion ?? 'unknown'}, please stand by...`);
|
|
34
33
|
|
|
@@ -51,6 +50,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
51
50
|
signalHandlers.push(stop);
|
|
52
51
|
services.node = [node, AztecNodeApiSchema];
|
|
53
52
|
adminServices.node = [node, AztecNodeAdminApiSchema];
|
|
53
|
+
services.nodeDebug = [node, AztecNodeDebugApiSchema];
|
|
54
54
|
} else {
|
|
55
55
|
// Route --prover-node through startNode
|
|
56
56
|
if (options.proverNode && !options.node) {
|
|
@@ -61,6 +61,9 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
61
61
|
const { startNode } = await import('./cmds/start_node.js');
|
|
62
62
|
const networkName = getActiveNetworkName(options.network);
|
|
63
63
|
({ config } = await startNode(options, signalHandlers, services, adminServices, userLog, networkName));
|
|
64
|
+
if (options.nodeDebug && services.node) {
|
|
65
|
+
services.nodeDebug = [services.node[0], AztecNodeDebugApiSchema];
|
|
66
|
+
}
|
|
64
67
|
} else if (options.bot) {
|
|
65
68
|
const { startBot } = await import('./cmds/start_bot.js');
|
|
66
69
|
await startBot(options, signalHandlers, services, userLog);
|
|
@@ -78,7 +81,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
78
81
|
await startProverBroker(options, signalHandlers, services, userLog);
|
|
79
82
|
} else if (options.txe) {
|
|
80
83
|
const { startTXE } = await import('./cmds/start_txe.js');
|
|
81
|
-
await startTXE(options, debugLogger);
|
|
84
|
+
await startTXE(options, signalHandlers, debugLogger);
|
|
82
85
|
} else if (options.sequencer) {
|
|
83
86
|
userLog(`Cannot run a standalone sequencer without a node`);
|
|
84
87
|
process.exit(1);
|
|
@@ -36,7 +36,7 @@ export interface AztecStartOption {
|
|
|
36
36
|
parseVal?: (val: string) => any;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping
|
|
39
|
+
export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping<unknown>>) => {
|
|
40
40
|
const options: AztecStartOption[] = [];
|
|
41
41
|
for (const [key, { env, defaultValue: def, parseEnv, description, printDefault, fallback }] of Object.entries(
|
|
42
42
|
configMappings,
|
|
@@ -58,7 +58,11 @@ export const getOptions = (namespace: string, configMappings: Record<string, Con
|
|
|
58
58
|
return options;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const configToFlag = (
|
|
61
|
+
const configToFlag = (
|
|
62
|
+
flag: string,
|
|
63
|
+
configMapping: ConfigMapping<unknown>,
|
|
64
|
+
overrideDefaultValue?: any,
|
|
65
|
+
): AztecStartOption => {
|
|
62
66
|
if (!configMapping.isBoolean) {
|
|
63
67
|
flag += ' <value>';
|
|
64
68
|
}
|
|
@@ -125,6 +129,12 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
125
129
|
defaultValue: DefaultMnemonic,
|
|
126
130
|
env: 'MNEMONIC',
|
|
127
131
|
},
|
|
132
|
+
{
|
|
133
|
+
flag: '--local-network.testAccounts',
|
|
134
|
+
description: 'Deploy test accounts on local network start',
|
|
135
|
+
env: 'TEST_ACCOUNTS',
|
|
136
|
+
...booleanConfigHelper(true),
|
|
137
|
+
},
|
|
128
138
|
],
|
|
129
139
|
API: [
|
|
130
140
|
{
|
|
@@ -165,6 +175,13 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
165
175
|
env: 'AZTEC_RESET_ADMIN_API_KEY',
|
|
166
176
|
parseVal: val => val === 'true' || val === '1',
|
|
167
177
|
},
|
|
178
|
+
{
|
|
179
|
+
flag: '--node-debug',
|
|
180
|
+
description: 'Expose debug endpoints (e.g. mineBlock) on the main RPC port',
|
|
181
|
+
defaultValue: false,
|
|
182
|
+
env: 'AZTEC_NODE_DEBUG',
|
|
183
|
+
parseVal: val => val === undefined || val === 'true' || val === '1',
|
|
184
|
+
},
|
|
168
185
|
{
|
|
169
186
|
flag: '--api-prefix <value>',
|
|
170
187
|
description: 'Prefix for API routes on any service that is started',
|
|
@@ -309,15 +326,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
309
326
|
},
|
|
310
327
|
...getOptions('bot', botConfigMappings),
|
|
311
328
|
],
|
|
312
|
-
PXE: [
|
|
313
|
-
{
|
|
314
|
-
flag: '--pxe',
|
|
315
|
-
description: 'Starts Aztec PXE with options',
|
|
316
|
-
defaultValue: undefined,
|
|
317
|
-
env: undefined,
|
|
318
|
-
},
|
|
319
|
-
...getOptions('pxe', allPxeConfigMappings),
|
|
320
|
-
],
|
|
329
|
+
PXE: [...getOptions('pxe', allPxeConfigMappings)],
|
|
321
330
|
TXE: [
|
|
322
331
|
{
|
|
323
332
|
flag: '--txe',
|
package/src/cli/cmds/compile.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
3
3
|
|
|
4
4
|
import { execFileSync } from 'child_process';
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
-
import { readFile
|
|
6
|
+
import { readFile } from 'fs/promises';
|
|
7
7
|
import { join } from 'path';
|
|
8
8
|
|
|
9
9
|
import { readArtifactFiles } from './utils/artifacts.js';
|
|
@@ -25,19 +25,6 @@ async function collectContractArtifacts(): Promise<string[]> {
|
|
|
25
25
|
return files.filter(f => Array.isArray(f.content.functions)).map(f => f.filePath);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/** Strips the `__aztec_nr_internals__` prefix from function names in contract artifacts. */
|
|
29
|
-
async function stripInternalPrefixes(artifactPaths: string[]): Promise<void> {
|
|
30
|
-
for (const path of artifactPaths) {
|
|
31
|
-
const artifact = JSON.parse(await readFile(path, 'utf-8'));
|
|
32
|
-
for (const fn of artifact.functions) {
|
|
33
|
-
if (typeof fn.name === 'string') {
|
|
34
|
-
fn.name = fn.name.replace(/^__aztec_nr_internals__/, '');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
28
|
/** Returns the set of package names that are contract crates in the current workspace. */
|
|
42
29
|
async function getContractPackageNames(): Promise<Set<string>> {
|
|
43
30
|
const contractNames = new Set<string>();
|
|
@@ -161,9 +148,6 @@ async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<vo
|
|
|
161
148
|
log('Postprocessing contracts...');
|
|
162
149
|
const bbArgs = artifacts.flatMap(a => ['-i', a]);
|
|
163
150
|
await run(bb, ['aztec_process', ...bbArgs]);
|
|
164
|
-
|
|
165
|
-
// TODO: This should be part of bb aztec_process!
|
|
166
|
-
await stripInternalPrefixes(artifacts);
|
|
167
151
|
}
|
|
168
152
|
|
|
169
153
|
log('Compilation complete!');
|
package/src/cli/cmds/profile.ts
CHANGED
|
@@ -11,8 +11,9 @@ export function injectProfileCommand(program: Command, log: LogFn): Command {
|
|
|
11
11
|
profile
|
|
12
12
|
.command('gates')
|
|
13
13
|
.argument('[target-dir]', 'Path to the compiled artifacts directory', './target')
|
|
14
|
+
.option('--json', 'Output gate counts as JSON instead of a table', false)
|
|
14
15
|
.description('Display gate counts for all compiled Aztec artifacts in a target directory.')
|
|
15
|
-
.action((targetDir: string) => profileGates(targetDir, log));
|
|
16
|
+
.action((targetDir: string, options: { json: boolean }) => profileGates(targetDir, options.json, log));
|
|
16
17
|
|
|
17
18
|
profile
|
|
18
19
|
.command('flamegraph')
|
|
@@ -6,12 +6,13 @@ import { execFile as execFileCb } from 'child_process';
|
|
|
6
6
|
import { rm } from 'fs/promises';
|
|
7
7
|
import { promisify } from 'util';
|
|
8
8
|
|
|
9
|
-
import { MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
|
|
9
|
+
import { type DiscoveredArtifact, MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
|
|
10
10
|
|
|
11
11
|
const execFile = promisify(execFileCb);
|
|
12
12
|
|
|
13
13
|
interface GateCountResult {
|
|
14
14
|
name: string;
|
|
15
|
+
type: DiscoveredArtifact['type'];
|
|
15
16
|
gateCount: number;
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -32,24 +33,39 @@ async function getGateCount(bb: string, artifactPath: string): Promise<number> {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/** Profiles all compiled artifacts in a target directory and prints gate counts. */
|
|
35
|
-
export async function profileGates(targetDir: string, log: LogFn): Promise<void> {
|
|
36
|
+
export async function profileGates(targetDir: string, json: boolean, log: LogFn): Promise<void> {
|
|
36
37
|
const bb = process.env.BB ?? findBbBinary() ?? 'bb';
|
|
37
38
|
const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
|
|
38
39
|
|
|
39
40
|
if (artifacts.length === 0) {
|
|
40
|
-
|
|
41
|
+
if (json) {
|
|
42
|
+
log('[]');
|
|
43
|
+
} else {
|
|
44
|
+
log('No artifacts found in target directory.');
|
|
45
|
+
}
|
|
41
46
|
return;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
try {
|
|
45
50
|
const results: GateCountResult[] = await asyncPool(MAX_CONCURRENT, artifacts, async artifact => ({
|
|
46
51
|
name: artifact.name,
|
|
52
|
+
type: artifact.type,
|
|
47
53
|
gateCount: await getGateCount(bb, artifact.filePath),
|
|
48
54
|
}));
|
|
49
55
|
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
50
56
|
|
|
51
57
|
if (results.length === 0) {
|
|
52
|
-
|
|
58
|
+
if (json) {
|
|
59
|
+
log('[]');
|
|
60
|
+
} else {
|
|
61
|
+
log('No constrained circuits found.');
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (json) {
|
|
67
|
+
const entries = results.map(r => ({ name: r.name, type: r.type, gates: r.gateCount }));
|
|
68
|
+
log(JSON.stringify(entries, null, 2));
|
|
53
69
|
return;
|
|
54
70
|
}
|
|
55
71
|
|
package/src/cli/cmds/standby.ts
CHANGED
|
@@ -28,11 +28,11 @@ export async function computeExpectedGenesisRoot(config: GenesisStateConfig, use
|
|
|
28
28
|
|
|
29
29
|
userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
|
|
30
30
|
|
|
31
|
-
const { genesisArchiveRoot,
|
|
31
|
+
const { genesisArchiveRoot, genesis } = await getGenesisValues(initialFundedAccounts);
|
|
32
32
|
|
|
33
33
|
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
34
34
|
|
|
35
|
-
return { genesisArchiveRoot,
|
|
35
|
+
return { genesisArchiveRoot, genesis };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async function checkRollupCompatibility(
|
|
@@ -20,7 +20,13 @@ export async function startArchiver(
|
|
|
20
20
|
const envConfig = getArchiverConfigFromEnv();
|
|
21
21
|
const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
|
|
22
22
|
options,
|
|
23
|
-
{
|
|
23
|
+
{
|
|
24
|
+
// dataConfigMappings must come first: its l1Contracts only maps rollupAddress,
|
|
25
|
+
// while archiverConfigMappings (spread later) maps all L1 contract addresses.
|
|
26
|
+
...dataConfigMappings,
|
|
27
|
+
...archiverConfigMappings,
|
|
28
|
+
...blobClientConfigMapping,
|
|
29
|
+
},
|
|
24
30
|
'archiver',
|
|
25
31
|
);
|
|
26
32
|
|
|
@@ -83,7 +83,7 @@ export async function startNode(
|
|
|
83
83
|
await preloadCrsDataForVerifying(nodeConfig, userLog);
|
|
84
84
|
|
|
85
85
|
const genesisConfig = getGenesisStateConfigEnvVars();
|
|
86
|
-
const { genesisArchiveRoot,
|
|
86
|
+
const { genesisArchiveRoot, genesis } = await computeExpectedGenesisRoot(genesisConfig, userLog);
|
|
87
87
|
|
|
88
88
|
const followsCanonicalRollup =
|
|
89
89
|
typeof nodeConfig.rollupVersion !== 'number' || (nodeConfig.rollupVersion as unknown as string) === 'canonical';
|
|
@@ -116,12 +116,10 @@ export async function startNode(
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// TODO(#12272): will clean this up.
|
|
120
119
|
nodeConfig = {
|
|
121
120
|
...nodeConfig,
|
|
122
121
|
l1Contracts: {
|
|
123
122
|
...addresses,
|
|
124
|
-
slashFactoryAddress: nodeConfig.l1Contracts.slashFactoryAddress,
|
|
125
123
|
},
|
|
126
124
|
...config,
|
|
127
125
|
};
|
|
@@ -158,7 +156,7 @@ export async function startNode(
|
|
|
158
156
|
const telemetry = await initTelemetryClient(telemetryConfig);
|
|
159
157
|
|
|
160
158
|
// Create and start Aztec Node
|
|
161
|
-
const node = await createAztecNode(nodeConfig, { telemetry, proverBroker: broker }, {
|
|
159
|
+
const node = await createAztecNode(nodeConfig, { telemetry, proverBroker: broker }, { genesis });
|
|
162
160
|
|
|
163
161
|
// Add node and p2p to services list
|
|
164
162
|
services.node = [node, AztecNodeApiSchema];
|
|
@@ -24,8 +24,8 @@ export async function startProverAgent(
|
|
|
24
24
|
services: NamespacedApiHandlers,
|
|
25
25
|
userLog: LogFn,
|
|
26
26
|
) {
|
|
27
|
-
if (options.node || options.sequencer || options.
|
|
28
|
-
userLog(`Starting a prover agent with --node, --sequencer, --
|
|
27
|
+
if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
|
|
28
|
+
userLog(`Starting a prover agent with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -24,8 +24,8 @@ export async function startProverBroker(
|
|
|
24
24
|
services: NamespacedApiHandlers,
|
|
25
25
|
userLog: LogFn,
|
|
26
26
|
): Promise<{ broker: ProvingJobBroker; config: ProverBrokerConfig }> {
|
|
27
|
-
if (options.node || options.sequencer || options.
|
|
28
|
-
userLog(`Starting a prover broker with --node, --sequencer, --
|
|
27
|
+
if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
|
|
28
|
+
userLog(`Starting a prover broker with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
|
|
29
29
|
process.exit(1);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -2,14 +2,16 @@ import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { createTXERpcServer } from '@aztec/txe';
|
|
4
4
|
|
|
5
|
-
export async function startTXE(options: any, debugLogger: Logger) {
|
|
5
|
+
export async function startTXE(options: any, signalHandlers: Array<() => Promise<void>>, debugLogger: Logger) {
|
|
6
6
|
debugLogger.info(`Setting up TXE...`);
|
|
7
7
|
|
|
8
8
|
const txeServer = createTXERpcServer(debugLogger);
|
|
9
|
-
const
|
|
9
|
+
const httpServer = await startHttpRpcServer(txeServer, {
|
|
10
10
|
port: options.port,
|
|
11
11
|
timeoutMs: 1e3 * 60 * 5,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
signalHandlers.push(() => new Promise<void>(resolve => httpServer.close(() => resolve())));
|
|
15
|
+
|
|
16
|
+
debugLogger.info(`TXE listening on port ${httpServer.port}`);
|
|
15
17
|
}
|
|
@@ -7,7 +7,25 @@ import { join } from 'path';
|
|
|
7
7
|
|
|
8
8
|
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/** Returns true if the given git URL points to the AztecProtocol/aztec-nr repository. */
|
|
11
|
+
function isAztecNrGitUrl(gitUrl: string): boolean {
|
|
12
|
+
let url: URL;
|
|
13
|
+
try {
|
|
14
|
+
url = new URL(gitUrl);
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (url.hostname !== 'github.com') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const repoPath = url.pathname
|
|
22
|
+
.replace(/^\//, '')
|
|
23
|
+
.replace(/\.git$/, '')
|
|
24
|
+
.replace(/\/$/, '');
|
|
25
|
+
return repoPath === 'AztecProtocol/aztec-nr';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Warns if any aztec-nr git dependency in a crate's Nargo.toml has a tag that doesn't match the CLI version. */
|
|
11
29
|
export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
|
|
12
30
|
const version = cliVersion ?? getPackageVersion();
|
|
13
31
|
if (!version) {
|
|
@@ -16,7 +34,7 @@ export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string
|
|
|
16
34
|
}
|
|
17
35
|
|
|
18
36
|
const expectedTag = `v${version}`;
|
|
19
|
-
const mismatches: { file: string; tag: string }[] = [];
|
|
37
|
+
const mismatches: { file: string; depName: string; tag: string }[] = [];
|
|
20
38
|
|
|
21
39
|
const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
|
|
22
40
|
|
|
@@ -30,23 +48,28 @@ export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string
|
|
|
30
48
|
}
|
|
31
49
|
|
|
32
50
|
const parsed = TOML.parse(content) as Record<string, any>;
|
|
33
|
-
const
|
|
34
|
-
if (!aztecDep || typeof aztecDep !== 'object' || typeof aztecDep.tag !== 'string') {
|
|
35
|
-
// If a dep called "aztec" doesn't exist or it does not get parsed to an object or it doesn't have a tag defined
|
|
36
|
-
// we skip the check.
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
51
|
+
const deps = (parsed.dependencies as Record<string, any>) ?? {};
|
|
39
52
|
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
for (const [depName, dep] of Object.entries(deps)) {
|
|
54
|
+
// Skip non-object deps (e.g. malformed entries) and anything that isn't a tagged git dep.
|
|
55
|
+
if (!dep || typeof dep !== 'object' || typeof dep.git !== 'string' || typeof dep.tag !== 'string') {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// Only flag deps that are sourced from the aztec-nr repo.
|
|
59
|
+
if (!isAztecNrGitUrl(dep.git)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (dep.tag !== expectedTag) {
|
|
63
|
+
mismatches.push({ file: tomlPath, depName, tag: dep.tag });
|
|
64
|
+
}
|
|
42
65
|
}
|
|
43
66
|
}
|
|
44
67
|
|
|
45
68
|
if (mismatches.length > 0) {
|
|
46
|
-
const details = mismatches.map(m => ` ${m.file} (${m.tag})`).join('\n');
|
|
69
|
+
const details = mismatches.map(m => ` ${m.file} — ${m.depName} (${m.tag})`).join('\n');
|
|
47
70
|
log(
|
|
48
71
|
`WARNING: Aztec dependency version mismatch detected.\n` +
|
|
49
|
-
`The following
|
|
72
|
+
`The following aztec-nr dependencies do not match the CLI version (${expectedTag}):\n` +
|
|
50
73
|
`${details}\n\n` +
|
|
51
74
|
`See https://docs.aztec.network/errors/9 for how to update your dependencies.`,
|
|
52
75
|
);
|
|
@@ -21,7 +21,7 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
|
21
21
|
import { SequencerState } from '@aztec/sequencer-client';
|
|
22
22
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
23
23
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
24
|
-
import type {
|
|
24
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
25
25
|
import {
|
|
26
26
|
type TelemetryClient,
|
|
27
27
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
@@ -70,7 +70,7 @@ export async function deployContractsToL1(
|
|
|
70
70
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
71
71
|
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
72
72
|
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
73
|
-
|
|
73
|
+
slasherEnabled: false, // no slashing in local network
|
|
74
74
|
realVerifier: false,
|
|
75
75
|
});
|
|
76
76
|
|
|
@@ -151,7 +151,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
151
151
|
...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
|
|
152
152
|
...prefundAddresses,
|
|
153
153
|
];
|
|
154
|
-
const { genesisArchiveRoot,
|
|
154
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
155
155
|
|
|
156
156
|
const dateProvider = new TestDateProvider();
|
|
157
157
|
|
|
@@ -190,7 +190,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
190
190
|
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
191
191
|
// Create a local blob client client inside the local network, no http connectivity
|
|
192
192
|
const blobClient = createBlobClient();
|
|
193
|
-
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, {
|
|
193
|
+
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
|
|
194
194
|
|
|
195
195
|
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
196
196
|
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
@@ -259,7 +259,7 @@ export async function createAztecNode(
|
|
|
259
259
|
dateProvider?: DateProvider;
|
|
260
260
|
proverBroker?: ProvingJobBroker;
|
|
261
261
|
} = {},
|
|
262
|
-
options: {
|
|
262
|
+
options: { genesis?: GenesisData } = {},
|
|
263
263
|
) {
|
|
264
264
|
// TODO(#12272): will clean this up. This is criminal.
|
|
265
265
|
const { l1Contracts, ...rest } = getConfigEnvVars();
|
|
@@ -9,6 +9,11 @@ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
|
9
9
|
|
|
10
10
|
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
11
11
|
|
|
12
|
+
export type AnvilTestWatcherOpts = {
|
|
13
|
+
isLocalNetwork?: boolean;
|
|
14
|
+
isMarkingAsProven?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
12
17
|
/**
|
|
13
18
|
* Represents a watcher for a rollup contract.
|
|
14
19
|
*
|
|
@@ -17,7 +22,8 @@ import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
|
17
22
|
* block within the slot. And if so, it will time travel into the next slot.
|
|
18
23
|
*/
|
|
19
24
|
export class AnvilTestWatcher {
|
|
20
|
-
private isLocalNetwork
|
|
25
|
+
private isLocalNetwork;
|
|
26
|
+
private isMarkingAsProven;
|
|
21
27
|
|
|
22
28
|
private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
23
29
|
private rollupCheatCodes: RollupCheatCodes;
|
|
@@ -29,8 +35,6 @@ export class AnvilTestWatcher {
|
|
|
29
35
|
|
|
30
36
|
private logger: Logger = createLogger(`aztecjs:utils:watcher`);
|
|
31
37
|
|
|
32
|
-
private isMarkingAsProven = true;
|
|
33
|
-
|
|
34
38
|
// Optional callback to check if there are pending txs in the mempool.
|
|
35
39
|
private getPendingTxCount?: () => Promise<number>;
|
|
36
40
|
|
|
@@ -45,6 +49,7 @@ export class AnvilTestWatcher {
|
|
|
45
49
|
rollupAddress: EthAddress,
|
|
46
50
|
l1Client: ViemClient,
|
|
47
51
|
private dateProvider?: TestDateProvider,
|
|
52
|
+
opts: AnvilTestWatcherOpts = {},
|
|
48
53
|
) {
|
|
49
54
|
this.rollup = getContract({
|
|
50
55
|
address: getAddress(rollupAddress.toString()),
|
|
@@ -56,6 +61,9 @@ export class AnvilTestWatcher {
|
|
|
56
61
|
rollupAddress,
|
|
57
62
|
});
|
|
58
63
|
|
|
64
|
+
this.isLocalNetwork = opts.isLocalNetwork ?? false;
|
|
65
|
+
this.isMarkingAsProven = opts.isMarkingAsProven ?? true;
|
|
66
|
+
|
|
59
67
|
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
60
68
|
}
|
|
61
69
|
|
|
@@ -136,8 +144,15 @@ export class AnvilTestWatcher {
|
|
|
136
144
|
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
137
145
|
this.dateProvider.setTime(l1Time);
|
|
138
146
|
} else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
// Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
|
|
148
|
+
// `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
|
|
149
|
+
// `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
|
|
150
|
+
// a second apart and one of them is then rejected by anvil as non-monotonic.
|
|
151
|
+
const wallSec = Math.floor(wallTime / 1000);
|
|
152
|
+
const targetSlot = await this.rollup.read.getSlotAt([BigInt(wallSec)]);
|
|
153
|
+
const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([targetSlot]));
|
|
154
|
+
this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
|
|
155
|
+
await this.warpToTimestamp(targetTimestamp);
|
|
141
156
|
}
|
|
142
157
|
}
|
|
143
158
|
|
|
@@ -151,8 +166,9 @@ export class AnvilTestWatcher {
|
|
|
151
166
|
|
|
152
167
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
153
168
|
// The current slot has been filled, we should jump to the next slot.
|
|
154
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
155
|
-
|
|
169
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
170
|
+
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
171
|
+
}
|
|
156
172
|
return;
|
|
157
173
|
}
|
|
158
174
|
|
|
@@ -180,9 +196,10 @@ export class AnvilTestWatcher {
|
|
|
180
196
|
}
|
|
181
197
|
|
|
182
198
|
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
183
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
199
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
200
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
201
|
+
}
|
|
184
202
|
this.unfilledSlotFirstSeen = undefined;
|
|
185
|
-
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
186
203
|
}
|
|
187
204
|
|
|
188
205
|
return;
|
|
@@ -192,19 +209,33 @@ export class AnvilTestWatcher {
|
|
|
192
209
|
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
193
210
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
194
211
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
195
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
196
|
-
|
|
212
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
213
|
+
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
214
|
+
}
|
|
197
215
|
}
|
|
198
216
|
} catch {
|
|
199
217
|
this.logger.error('mineIfSlotFilled failed');
|
|
200
218
|
}
|
|
201
219
|
}
|
|
202
220
|
|
|
203
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
|
|
223
|
+
* happened, false when skipped or on error. Callers use the return value to gate success logs.
|
|
224
|
+
*/
|
|
225
|
+
private async warpToTimestamp(timestamp: number): Promise<boolean> {
|
|
204
226
|
try {
|
|
227
|
+
// Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
|
|
228
|
+
// watcher loops can race and pick targets a fraction of a second apart; skip here rather than
|
|
229
|
+
// letting the second one error out noisily.
|
|
230
|
+
const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
|
|
231
|
+
if (timestamp <= lastTimestamp) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
205
234
|
await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
|
|
235
|
+
return true;
|
|
206
236
|
} catch (e) {
|
|
207
237
|
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
238
|
+
return false;
|
|
208
239
|
}
|
|
209
240
|
}
|
|
210
241
|
}
|