@aztec/aztec 0.0.1-commit.ef17749e1 → 0.0.1-commit.f1b29a41e
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 +12 -5
- 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 +9 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
- package/dest/cli/cmds/profile_flamegraph.js +2 -1
- package/dest/cli/cmds/profile_gates.d.ts +1 -1
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +2 -1
- package/dest/cli/cmds/standby.d.ts +10 -5
- package/dest/cli/cmds/standby.d.ts.map +1 -1
- package/dest/cli/cmds/standby.js +33 -14
- 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 +7 -1
- 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 +7 -1
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -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 +90 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +41 -0
- package/dest/testing/anvil_test_watcher.js +1 -1
- package/dest/testing/cheat_codes.js +1 -1
- package/dest/testing/epoch_test_settler.d.ts +1 -1
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +3 -4
- package/package.json +34 -34
- package/scripts/aztec.sh +4 -1
- package/src/cli/aztec_start_action.ts +7 -5
- package/src/cli/cmds/compile.ts +11 -1
- package/src/cli/cmds/profile_flamegraph.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +2 -1
- package/src/cli/cmds/standby.ts +37 -16
- package/src/cli/cmds/start_node.ts +8 -1
- package/src/cli/cmds/start_prover_broker.ts +8 -1
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +54 -0
- package/src/testing/anvil_test_watcher.ts +1 -1
- package/src/testing/cheat_codes.ts +1 -1
- package/src/testing/epoch_test_settler.ts +3 -4
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { readdir, stat } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
|
|
4
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if recompilation is needed: either no artifacts exist in target/ or any .nr or Nargo.toml source file
|
|
8
|
+
* (including path-based dependencies) is newer than the oldest artifact. We compare against the oldest artifact so
|
|
9
|
+
* that a source change between the oldest and newest compilation (e.g. in a multi-contract workspace) still triggers
|
|
10
|
+
* a recompile.
|
|
11
|
+
*
|
|
12
|
+
* Note: The above implies that if there is a random json file in the target dir we would be always recompiling.
|
|
13
|
+
*/
|
|
14
|
+
export async function needsRecompile(): Promise<boolean> {
|
|
15
|
+
const oldestArtifactMs = await getOldestArtifactModificationTime('target');
|
|
16
|
+
if (oldestArtifactMs === undefined) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Git deps are pinned to a specific tag in Nargo.toml and nargo always fetches an exact tag, so their contents never
|
|
21
|
+
// change without Nargo.toml itself changing — and Nargo.toml is already tracked as a source file. Hence we can
|
|
22
|
+
// safely ignore checking source files of git deps.
|
|
23
|
+
const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
|
|
24
|
+
return hasNewerSourceFile(crateDirs, oldestArtifactMs);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the last modification time (timestamp in ms) of the oldest .json artifact in targetDir, or undefined if
|
|
29
|
+
* none exist.
|
|
30
|
+
*/
|
|
31
|
+
async function getOldestArtifactModificationTime(targetDir: string): Promise<number | undefined> {
|
|
32
|
+
let entries: string[];
|
|
33
|
+
try {
|
|
34
|
+
entries = (await readdir(targetDir)).filter(f => f.endsWith('.json'));
|
|
35
|
+
} catch (err: any) {
|
|
36
|
+
if (err?.code === 'ENOENT') {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (entries.length === 0) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let oldest = Infinity;
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
const s = await stat(join(targetDir, entry));
|
|
49
|
+
if (s.mtimeMs < oldest) {
|
|
50
|
+
oldest = s.mtimeMs;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return oldest;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Walks crate dirs looking for .nr and Nargo.toml files newer than thresholdMs. Short-circuits on the first match.
|
|
58
|
+
*/
|
|
59
|
+
async function hasNewerSourceFile(crateDirs: string[], thresholdMs: number): Promise<boolean> {
|
|
60
|
+
// Returns true if it find a new file than thresholdMs, false otherwise
|
|
61
|
+
async function walkForNewer(dir: string): Promise<boolean> {
|
|
62
|
+
let entries;
|
|
63
|
+
try {
|
|
64
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// We iterate over the entries in the dir
|
|
70
|
+
for (const entry of entries) {
|
|
71
|
+
const fullPath = join(dir, entry.name);
|
|
72
|
+
if (entry.isDirectory()) {
|
|
73
|
+
// If the entry is a dir and it's not called `target` we recursively enter it
|
|
74
|
+
if (entry.name === 'target') {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (await walkForNewer(fullPath)) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
} else if (entry.name === 'Nargo.toml' || entry.name.endsWith('.nr')) {
|
|
81
|
+
// The entry is a Nargo.toml file or *.nr file so we check the timestamp
|
|
82
|
+
const s = await stat(fullPath);
|
|
83
|
+
if (s.mtimeMs > thresholdMs) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// We search through the crate dirs
|
|
92
|
+
for (const dir of crateDirs) {
|
|
93
|
+
if (await walkForNewer(dir)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
3
|
+
|
|
4
|
+
import TOML from '@iarna/toml';
|
|
5
|
+
import { readFile } from 'fs/promises';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
|
|
8
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
9
|
+
|
|
10
|
+
/** Warns if the `aztec` dependency tag in any crate's Nargo.toml doesn't match the CLI version. */
|
|
11
|
+
export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
|
|
12
|
+
const version = cliVersion ?? getPackageVersion();
|
|
13
|
+
if (!version) {
|
|
14
|
+
log(`WARNING: aztec CLI version not found. Skipping dependency compatibility check.`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const expectedTag = `v${version}`;
|
|
19
|
+
const mismatches: { file: string; tag: string }[] = [];
|
|
20
|
+
|
|
21
|
+
const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
|
|
22
|
+
|
|
23
|
+
for (const dir of crateDirs) {
|
|
24
|
+
const tomlPath = join(dir, 'Nargo.toml');
|
|
25
|
+
let content: string;
|
|
26
|
+
try {
|
|
27
|
+
content = await readFile(tomlPath, 'utf-8');
|
|
28
|
+
} catch {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const parsed = TOML.parse(content) as Record<string, any>;
|
|
33
|
+
const aztecDep = (parsed.dependencies as Record<string, any>)?.aztec;
|
|
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
|
+
}
|
|
39
|
+
|
|
40
|
+
if (aztecDep.tag !== expectedTag) {
|
|
41
|
+
mismatches.push({ file: tomlPath, tag: aztecDep.tag });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (mismatches.length > 0) {
|
|
46
|
+
const details = mismatches.map(m => ` ${m.file} (${m.tag})`).join('\n');
|
|
47
|
+
log(
|
|
48
|
+
`WARNING: Aztec dependency version mismatch detected.\n` +
|
|
49
|
+
`The following crates have an aztec dependency that does not match the CLI version (${expectedTag}):\n` +
|
|
50
|
+
`${details}\n\n` +
|
|
51
|
+
`See https://docs.aztec.network/errors/9 for how to update your dependencies.`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -130,7 +130,7 @@ export class AnvilTestWatcher {
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
const l1Time = (await this.cheatcodes.
|
|
133
|
+
const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
|
|
134
134
|
const wallTime = this.dateProvider.now();
|
|
135
135
|
if (l1Time > wallTime) {
|
|
136
136
|
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
@@ -72,7 +72,7 @@ export class CheatCodes {
|
|
|
72
72
|
* @param duration - The duration to advance time by (in seconds)
|
|
73
73
|
*/
|
|
74
74
|
async warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number) {
|
|
75
|
-
const currentTimestamp = await this.eth.
|
|
75
|
+
const currentTimestamp = await this.eth.lastBlockTimestamp();
|
|
76
76
|
const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
|
|
77
77
|
await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
|
|
78
78
|
}
|
|
@@ -4,7 +4,7 @@ import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
|
4
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
5
5
|
import { EpochMonitor } from '@aztec/prover-node';
|
|
6
6
|
import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
|
|
7
|
-
import {
|
|
7
|
+
import { computeEpochOutHash } from '@aztec/stdlib/messaging';
|
|
8
8
|
|
|
9
9
|
export class EpochTestSettler {
|
|
10
10
|
private rollupCheatCodes: RollupCheatCodes;
|
|
@@ -51,9 +51,8 @@ export class EpochTestSettler {
|
|
|
51
51
|
messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
const { root: outHash } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, firstMessage);
|
|
54
|
+
const outHash = computeEpochOutHash(messagesInEpoch);
|
|
55
|
+
if (!outHash.isZero()) {
|
|
57
56
|
await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
|
|
58
57
|
} else {
|
|
59
58
|
this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
|