@aztec/aztec 0.0.1-commit.8f9871590 → 0.0.1-commit.934299a21
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 +23 -6
- 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_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +58 -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/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/local-network/local-network.d.ts +3 -1
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +25 -4
- 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/package.json +34 -34
- 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 +25 -5
- 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_node.ts +49 -7
- package/src/cli/cmds/utils/artifacts.ts +44 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/local-network/local-network.ts +38 -7
- package/src/testing/anvil_test_watcher.ts +59 -15
- 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
|
@@ -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,eyJ2ZXJza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G,SAAS,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,SAAS,EAAE,kBAAkB,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 */ }
|
|
@@ -4,4 +4,4 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
4
4
|
export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn): Promise<{
|
|
5
5
|
config: AztecNodeConfig;
|
|
6
6
|
}>;
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUE2QyxNQUFNLG1CQUFtQixDQUFDO0FBTXBHLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUF3Qm5ELHdCQUFzQixTQUFTLENBQzdCLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLGFBQWEsRUFBRSxxQkFBcUIsRUFDcEMsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZUFBZSxDQUFBO0NBQUUsQ0FBQyxDQThKdEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAMpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAMpG,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,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CA8JtC"}
|
|
@@ -5,14 +5,18 @@ import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
|
5
5
|
import { getL1Config } from '@aztec/cli/config';
|
|
6
6
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
7
7
|
import { SecretValue } from '@aztec/foundation/config';
|
|
8
|
+
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
9
|
+
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
8
10
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
9
11
|
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 { P2PApiSchema, ProverNodeApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
13
|
+
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
12
14
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
13
15
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
14
16
|
import { createAztecNode } from '../../local-network/index.js';
|
|
15
17
|
import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying, setupUpdateMonitor } from '../util.js';
|
|
18
|
+
import { getVersions } from '../versioning.js';
|
|
19
|
+
import { startProverBroker } from './start_prover_broker.js';
|
|
16
20
|
export async function startNode(options, signalHandlers, services, adminServices, userLog) {
|
|
17
21
|
// All options set from environment variables
|
|
18
22
|
const configFromEnvVars = getConfigEnvVars();
|
|
@@ -23,9 +27,40 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
23
27
|
...configFromEnvVars,
|
|
24
28
|
...relevantOptions
|
|
25
29
|
};
|
|
30
|
+
// Prover node configuration and broker setup
|
|
31
|
+
// REFACTOR: Move the broker setup out of here and into the prover-node factory
|
|
32
|
+
let broker = undefined;
|
|
26
33
|
if (options.proverNode) {
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
nodeConfig.enableProverNode = true;
|
|
35
|
+
if (nodeConfig.proverAgentCount === 0) {
|
|
36
|
+
userLog(`Running prover node without local prover agent. Connect prover agents or pass --proverAgent.proverAgentCount`);
|
|
37
|
+
}
|
|
38
|
+
if (nodeConfig.proverBrokerUrl) {
|
|
39
|
+
// at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
|
|
40
|
+
// set a lower connection limit such that we don't overload the server
|
|
41
|
+
// Keep retrying up to 30s
|
|
42
|
+
const fetch = makeTracedFetch([
|
|
43
|
+
1,
|
|
44
|
+
2,
|
|
45
|
+
3,
|
|
46
|
+
3,
|
|
47
|
+
3,
|
|
48
|
+
3,
|
|
49
|
+
3,
|
|
50
|
+
3,
|
|
51
|
+
3,
|
|
52
|
+
3,
|
|
53
|
+
3
|
|
54
|
+
], false, makeUndiciFetch(new Agent({
|
|
55
|
+
connections: 100
|
|
56
|
+
})));
|
|
57
|
+
broker = createProvingJobBrokerClient(nodeConfig.proverBrokerUrl, getVersions(nodeConfig), fetch);
|
|
58
|
+
} else if (options.proverBroker) {
|
|
59
|
+
({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
|
|
60
|
+
} else {
|
|
61
|
+
userLog(`--prover-broker-url or --prover-broker is required to start a Prover Node`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
29
64
|
}
|
|
30
65
|
await preloadCrsDataForVerifying(nodeConfig, userLog);
|
|
31
66
|
const testAccounts = nodeConfig.testAccounts ? (await getInitialTestAccountsData()).map((a)=>a.address) : [];
|
|
@@ -62,14 +97,14 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
62
97
|
...extractNamespacedOptions(options, 'sequencer')
|
|
63
98
|
};
|
|
64
99
|
// If no publisher private keys have been given, use the first validator key
|
|
65
|
-
if (sequencerConfig.
|
|
100
|
+
if (sequencerConfig.sequencerPublisherPrivateKeys === undefined || !sequencerConfig.sequencerPublisherPrivateKeys.length) {
|
|
66
101
|
if (sequencerConfig.validatorPrivateKeys?.getValue().length) {
|
|
67
|
-
sequencerConfig.
|
|
102
|
+
sequencerConfig.sequencerPublisherPrivateKeys = [
|
|
68
103
|
new SecretValue(sequencerConfig.validatorPrivateKeys.getValue()[0])
|
|
69
104
|
];
|
|
70
105
|
}
|
|
71
106
|
}
|
|
72
|
-
nodeConfig.
|
|
107
|
+
nodeConfig.sequencerPublisherPrivateKeys = sequencerConfig.sequencerPublisherPrivateKeys;
|
|
73
108
|
}
|
|
74
109
|
if (nodeConfig.p2pEnabled) {
|
|
75
110
|
// ensure bootstrapNodes is an array
|
|
@@ -81,7 +116,8 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
81
116
|
const telemetry = await initTelemetryClient(telemetryConfig);
|
|
82
117
|
// Create and start Aztec Node
|
|
83
118
|
const node = await createAztecNode(nodeConfig, {
|
|
84
|
-
telemetry
|
|
119
|
+
telemetry,
|
|
120
|
+
proverBroker: broker
|
|
85
121
|
}, {
|
|
86
122
|
prefilledPublicData
|
|
87
123
|
});
|
|
@@ -98,6 +134,20 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
98
134
|
node,
|
|
99
135
|
AztecNodeAdminApiSchema
|
|
100
136
|
];
|
|
137
|
+
// Register prover-node services if the prover node subsystem is running
|
|
138
|
+
const proverNode = node.getProverNode();
|
|
139
|
+
if (proverNode) {
|
|
140
|
+
services.prover = [
|
|
141
|
+
proverNode,
|
|
142
|
+
ProverNodeApiSchema
|
|
143
|
+
];
|
|
144
|
+
if (!nodeConfig.proverBrokerUrl) {
|
|
145
|
+
services.provingJobSource = [
|
|
146
|
+
proverNode.getProver().getProvingJobSource(),
|
|
147
|
+
ProvingJobConsumerSchema
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
101
151
|
// Add node stop function to signal handlers
|
|
102
152
|
signalHandlers.push(node.stop.bind(node));
|
|
103
153
|
// Add a txs bot if requested
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CompiledArtifact {
|
|
2
|
+
noir_version: string;
|
|
3
|
+
file_map: unknown;
|
|
4
|
+
functions: ContractFunction[];
|
|
5
|
+
bytecode?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ContractFunction {
|
|
8
|
+
name: string;
|
|
9
|
+
abi: unknown;
|
|
10
|
+
bytecode: string;
|
|
11
|
+
debug_symbols: unknown;
|
|
12
|
+
is_unconstrained?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ArtifactFile {
|
|
15
|
+
name: string;
|
|
16
|
+
filePath: string;
|
|
17
|
+
content: CompiledArtifact;
|
|
18
|
+
}
|
|
19
|
+
/** Reads all JSON artifact files from a target directory and returns their parsed contents. */
|
|
20
|
+
export declare function readArtifactFiles(targetDir: string): Promise<ArtifactFile[]>;
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJ0aWZhY3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvYXJ0aWZhY3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE1BQU0sV0FBVyxnQkFBZ0I7SUFDL0IsWUFBWSxFQUFFLE1BQU0sQ0FBQztJQUNyQixRQUFRLEVBQUUsT0FBTyxDQUFDO0lBQ2xCLFNBQVMsRUFBRSxnQkFBZ0IsRUFBRSxDQUFDO0lBQzlCLFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUNuQjtBQUVELE1BQU0sV0FBVyxnQkFBZ0I7SUFDL0IsSUFBSSxFQUFFLE1BQU0sQ0FBQztJQUNiLEdBQUcsRUFBRSxPQUFPLENBQUM7SUFDYixRQUFRLEVBQUUsTUFBTSxDQUFDO0lBQ2pCLGFBQWEsRUFBRSxPQUFPLENBQUM7SUFDdkIsZ0JBQWdCLENBQUMsRUFBRSxPQUFPLENBQUM7Q0FDNUI7QUFFRCxNQUFNLFdBQVcsWUFBWTtJQUMzQixJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ2IsUUFBUSxFQUFFLE1BQU0sQ0FBQztJQUNqQixPQUFPLEVBQUUsZ0JBQWdCLENBQUM7Q0FDM0I7QUFFRCwrRkFBK0Y7QUFDL0Ysd0JBQXNCLGlCQUFpQixDQUFDLFNBQVMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFDLENBa0JsRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/artifacts.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,+FAA+F;AAC/F,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAkBlF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile, readdir } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
/** Reads all JSON artifact files from a target directory and returns their parsed contents. */ export async function readArtifactFiles(targetDir) {
|
|
4
|
+
let entries;
|
|
5
|
+
try {
|
|
6
|
+
entries = (await readdir(targetDir)).filter((f)=>f.endsWith('.json'));
|
|
7
|
+
} catch (err) {
|
|
8
|
+
if (err?.code === 'ENOENT') {
|
|
9
|
+
throw new Error(`Target directory '${targetDir}' does not exist. Compile first with 'aztec compile'.`);
|
|
10
|
+
}
|
|
11
|
+
throw err;
|
|
12
|
+
}
|
|
13
|
+
const artifacts = [];
|
|
14
|
+
for (const file of entries){
|
|
15
|
+
const filePath = join(targetDir, file);
|
|
16
|
+
const content = JSON.parse(await readFile(filePath, 'utf-8'));
|
|
17
|
+
artifacts.push({
|
|
18
|
+
name: file.replace('.json', ''),
|
|
19
|
+
filePath,
|
|
20
|
+
content
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return artifacts;
|
|
24
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Spawns a command with inherited stdio and rejects on non-zero exit. */
|
|
2
|
+
export declare function run(cmd: string, args: string[]): Promise<void>;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhd24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jbGkvY21kcy91dGlscy9zcGF3bi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSwwRUFBMEU7QUFDMUUsd0JBQWdCLEdBQUcsQ0FBQyxHQUFHLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxNQUFNLEVBQUUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBWTlEIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/spawn.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAY9D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
/** Spawns a command with inherited stdio and rejects on non-zero exit. */ export function run(cmd, args) {
|
|
3
|
+
return new Promise((resolve, reject)=>{
|
|
4
|
+
const child = spawn(cmd, args, {
|
|
5
|
+
stdio: 'inherit'
|
|
6
|
+
});
|
|
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
|
+
}
|
|
@@ -6,6 +6,7 @@ import { type BlobClientInterface } from '@aztec/blob-client/client';
|
|
|
6
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
7
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
8
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
|
+
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
9
10
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
10
11
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
11
12
|
import { type Hex } from 'viem';
|
|
@@ -65,7 +66,8 @@ export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?
|
|
|
65
66
|
telemetry?: TelemetryClient;
|
|
66
67
|
blobClient?: BlobClientInterface;
|
|
67
68
|
dateProvider?: DateProvider;
|
|
69
|
+
proverBroker?: ProvingJobBroker;
|
|
68
70
|
}, options?: {
|
|
69
71
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
70
72
|
}): Promise<AztecNodeService>;
|
|
71
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtbmV0d29yay5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvY2FsLW5ldHdvcmsvbG9jYWwtbmV0d29yay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsT0FB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LE1BQU0sQ0FBQztJQUNuQiw2REFBNkQ7SUFDN0QsWUFBWSxFQUFFLE9BQU8sQ0FBQztDQUN2QixDQUFDO0FBRUY7Ozs7R0FJRztBQUNILHdCQUFzQixrQkFBa0IsQ0FBQyxNQUFNLHlDQUFrQyxFQUFFLE9BQU8sRUFBRSxLQUFLOzs7R0FnSmhHO0FBRUQ7OztHQUdHO0FBQ0gsd0JBQXNCLGVBQWUsQ0FDbkMsTUFBTSxHQUFFLE9BQU8sQ0FBQyxlQUFlLENBQU0sRUFDckMsSUFBSSxHQUFFO0lBQ0osU0FBUyxDQUFDLEVBQUUsZUFBZSxDQUFDO0lBQzVCLFVBQVUsQ0FBQyxFQUFFLG1CQUFtQixDQUFDO0lBQ2pDLFlBQVksQ0FBQyxFQUFFLFlBQVksQ0FBQztJQUM1QixZQUFZLENBQUMsRUFBRSxnQkFBZ0IsQ0FBQztDQUM1QixFQUNOLE9BQU8sR0FBRTtJQUFFLG1CQUFtQixDQUFDLEVBQUUsa0JBQWtCLEVBQUUsQ0FBQTtDQUFPLDZCQWU3RCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-network.d.ts","sourceRoot":"","sources":["../../src/local-network/local-network.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAE5C,OAAO,EAAE,KAAK,mBAAmB,EAAoB,MAAM,2BAA2B,CAAC;AASvF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAoB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"local-network.d.ts","sourceRoot":"","sources":["../../src/local-network/local-network.ts"],"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AC5B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAC5B,EACN,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAe7D"}
|
|
@@ -17,6 +17,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
17
17
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
18
18
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
19
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
|
+
import { SequencerState } from '@aztec/sequencer-client';
|
|
20
21
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
21
22
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
22
23
|
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
@@ -71,9 +72,9 @@ const localAnvil = foundry;
|
|
|
71
72
|
...config
|
|
72
73
|
};
|
|
73
74
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
74
|
-
if (aztecNodeConfig.
|
|
75
|
+
if (aztecNodeConfig.sequencerPublisherPrivateKeys == undefined || !aztecNodeConfig.sequencerPublisherPrivateKeys.length || aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY) {
|
|
75
76
|
const privKey = hdAccount.getHdKey().privateKey;
|
|
76
|
-
aztecNodeConfig.
|
|
77
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys = [
|
|
77
78
|
new SecretValue(`0x${Buffer.from(privKey).toString('hex')}`)
|
|
78
79
|
];
|
|
79
80
|
}
|
|
@@ -141,6 +142,20 @@ const localAnvil = foundry;
|
|
|
141
142
|
}, {
|
|
142
143
|
prefilledPublicData
|
|
143
144
|
});
|
|
145
|
+
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
146
|
+
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
147
|
+
// warping time out from under an in-progress block.
|
|
148
|
+
watcher?.setGetPendingTxCount(()=>node.getPendingTxCount());
|
|
149
|
+
const sequencer = node.getSequencer()?.getSequencer();
|
|
150
|
+
if (sequencer) {
|
|
151
|
+
const idleStates = new Set([
|
|
152
|
+
SequencerState.STOPPED,
|
|
153
|
+
SequencerState.STOPPING,
|
|
154
|
+
SequencerState.IDLE,
|
|
155
|
+
SequencerState.SYNCHRONIZING
|
|
156
|
+
]);
|
|
157
|
+
watcher?.setIsSequencerBuilding(()=>!idleStates.has(sequencer.getState()));
|
|
158
|
+
}
|
|
144
159
|
let epochTestSettler;
|
|
145
160
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
146
161
|
epochTestSettler = new EpochTestSettler(cheatcodes, rollupAddress, node.getBlockSource(), logger.createChild('epoch-settler'), {
|
|
@@ -152,7 +167,8 @@ const localAnvil = foundry;
|
|
|
152
167
|
const wallet = await EmbeddedWallet.create(node, {
|
|
153
168
|
pxeConfig: {
|
|
154
169
|
proverEnabled: aztecNodeConfig.realProofs
|
|
155
|
-
}
|
|
170
|
+
},
|
|
171
|
+
ephemeral: true
|
|
156
172
|
});
|
|
157
173
|
userLog('Setting up funded test accounts...');
|
|
158
174
|
const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
|
|
@@ -187,6 +203,11 @@ const localAnvil = foundry;
|
|
|
187
203
|
...config.l1Contracts
|
|
188
204
|
}
|
|
189
205
|
};
|
|
190
|
-
const node = await AztecNodeService.createAndSync(aztecNodeConfig,
|
|
206
|
+
const node = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
207
|
+
...deps,
|
|
208
|
+
proverNodeDeps: {
|
|
209
|
+
broker: deps.proverBroker
|
|
210
|
+
}
|
|
211
|
+
}, options);
|
|
191
212
|
return node;
|
|
192
213
|
}
|
|
@@ -21,14 +21,22 @@ export declare class AnvilTestWatcher {
|
|
|
21
21
|
private markingAsProvenRunningPromise?;
|
|
22
22
|
private logger;
|
|
23
23
|
private isMarkingAsProven;
|
|
24
|
+
private getPendingTxCount?;
|
|
25
|
+
private isSequencerBuilding?;
|
|
26
|
+
private unfilledSlotFirstSeen?;
|
|
24
27
|
constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l1Client: ViemClient, dateProvider?: TestDateProvider | undefined);
|
|
25
28
|
setIsMarkingAsProven(isMarkingAsProven: boolean): void;
|
|
26
29
|
setisLocalNetwork(isLocalNetwork: boolean): void;
|
|
30
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */
|
|
31
|
+
setGetPendingTxCount(fn: () => Promise<number>): void;
|
|
32
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */
|
|
33
|
+
setIsSequencerBuilding(fn: () => boolean): void;
|
|
27
34
|
start(): Promise<void>;
|
|
28
35
|
stop(): Promise<void>;
|
|
29
36
|
trigger(): Promise<void>;
|
|
30
37
|
markAsProven(): Promise<void>;
|
|
31
38
|
syncDateProviderToL1IfBehind(): Promise<void>;
|
|
32
39
|
warpTimeIfNeeded(): Promise<void>;
|
|
40
|
+
private warpToTimestamp;
|
|
33
41
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW52aWxfdGVzdF93YXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9hbnZpbF90ZXN0X3dhdGNoZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBb0IsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUV4RCxPQUFPLEtBQUssRUF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lBRUQsdUdBQXVHO0lBQ3ZHLHNCQUFzQixDQUFDLEVBQUUsRUFBRSxNQUFNLE9BQU8sUUFFdkM7SUFFSyxLQUFLLGtCQXlCVjtJQUVLLElBQUksa0JBSVQ7SUFFSyxPQUFPLGtCQUlaO0lBRUssWUFBWSxrQkFLakI7SUFFSyw0QkFBNEIsa0JBZWpDO0lBRUssZ0JBQWdCLGtCQXlEckI7WUFFYSxlQUFlO0NBTzlCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/testing/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE;;;;;;GAMG;AACH,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/testing/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAyBzB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,YAAY,CAAC;IA3BvB,OAAO,CAAC,cAAc,CAAkB;IAExC,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAU;IAEhC,OAAO,CAAC,oBAAoB,CAAC,CAAiB;IAC9C,OAAO,CAAC,uBAAuB,CAAC,CAAiB;IACjD,OAAO,CAAC,6BAA6B,CAAC,CAAiB;IAEvD,OAAO,CAAC,MAAM,CAAiD;IAE/D,OAAO,CAAC,iBAAiB,CAAQ;IAGjC,OAAO,CAAC,iBAAiB,CAAC,CAAwB;IAGlD,OAAO,CAAC,mBAAmB,CAAC,CAAgB;IAG5C,OAAO,CAAC,qBAAqB,CAAC,CAAqC;IAEnE,YACU,UAAU,EAAE,aAAa,EACjC,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,UAAU,EACZ,YAAY,CAAC,8BAAkB,EAaxC;IAED,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,QAG9C;IAED,iBAAiB,CAAC,cAAc,EAAE,OAAO,QAExC;IAED,yGAAyG;IACzG,oBAAoB,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAE7C;IAED,uGAAuG;IACvG,sBAAsB,CAAC,EAAE,EAAE,MAAM,OAAO,QAEvC;IAEK,KAAK,kBAyBV;IAEK,IAAI,kBAIT;IAEK,OAAO,kBAIZ;IAEK,YAAY,kBAKjB;IAEK,4BAA4B,kBAejC;IAEK,gBAAgB,kBAyDrB;YAEa,eAAe;CAO9B"}
|
|
@@ -22,6 +22,12 @@ import { getAddress, getContract } from 'viem';
|
|
|
22
22
|
markingAsProvenRunningPromise;
|
|
23
23
|
logger;
|
|
24
24
|
isMarkingAsProven;
|
|
25
|
+
// Optional callback to check if there are pending txs in the mempool.
|
|
26
|
+
getPendingTxCount;
|
|
27
|
+
// Optional callback to check if the sequencer is actively building a block.
|
|
28
|
+
isSequencerBuilding;
|
|
29
|
+
// Tracks when we first observed the current unfilled slot with pending txs (real wall time).
|
|
30
|
+
unfilledSlotFirstSeen;
|
|
25
31
|
constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
|
|
26
32
|
this.cheatcodes = cheatcodes;
|
|
27
33
|
this.dateProvider = dateProvider;
|
|
@@ -45,6 +51,12 @@ import { getAddress, getContract } from 'viem';
|
|
|
45
51
|
setisLocalNetwork(isLocalNetwork) {
|
|
46
52
|
this.isLocalNetwork = isLocalNetwork;
|
|
47
53
|
}
|
|
54
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */ setGetPendingTxCount(fn) {
|
|
55
|
+
this.getPendingTxCount = fn;
|
|
56
|
+
}
|
|
57
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */ setIsSequencerBuilding(fn) {
|
|
58
|
+
this.isSequencerBuilding = fn;
|
|
59
|
+
}
|
|
48
60
|
async start() {
|
|
49
61
|
if (this.filledRunningPromise) {
|
|
50
62
|
throw new Error('Watcher already watching for filled slot');
|
|
@@ -111,14 +123,8 @@ import { getAddress, getContract } from 'viem';
|
|
|
111
123
|
BigInt(nextSlot)
|
|
112
124
|
]));
|
|
113
125
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
117
|
-
resetBlockInterval: true
|
|
118
|
-
});
|
|
119
|
-
} catch (e) {
|
|
120
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
121
|
-
}
|
|
126
|
+
// The current slot has been filled, we should jump to the next slot.
|
|
127
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
122
128
|
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
123
129
|
return;
|
|
124
130
|
}
|
|
@@ -126,19 +132,50 @@ import { getAddress, getContract } from 'viem';
|
|
|
126
132
|
if (!this.isLocalNetwork) {
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
135
|
+
// If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
|
|
136
|
+
// sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
|
|
137
|
+
// the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
|
|
138
|
+
// to avoid invalidating its in-progress work.
|
|
139
|
+
if (this.getPendingTxCount) {
|
|
140
|
+
const pendingTxs = await this.getPendingTxCount();
|
|
141
|
+
if (pendingTxs > 0) {
|
|
142
|
+
if (this.isSequencerBuilding?.()) {
|
|
143
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const realNow = Date.now();
|
|
147
|
+
if (!this.unfilledSlotFirstSeen || this.unfilledSlotFirstSeen.slot !== currentSlot) {
|
|
148
|
+
this.unfilledSlotFirstSeen = {
|
|
149
|
+
slot: currentSlot,
|
|
150
|
+
realTime: realNow
|
|
151
|
+
};
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
155
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
156
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
157
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
129
163
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
130
164
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
131
|
-
|
|
132
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
133
|
-
resetBlockInterval: true
|
|
134
|
-
});
|
|
135
|
-
} catch (e) {
|
|
136
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
137
|
-
}
|
|
165
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
138
166
|
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
139
167
|
}
|
|
140
168
|
} catch {
|
|
141
169
|
this.logger.error('mineIfSlotFilled failed');
|
|
142
170
|
}
|
|
143
171
|
}
|
|
172
|
+
async warpToTimestamp(timestamp) {
|
|
173
|
+
try {
|
|
174
|
+
await this.cheatcodes.warp(timestamp, {
|
|
175
|
+
resetBlockInterval: true
|
|
176
|
+
});
|
|
177
|
+
} catch (e) {
|
|
178
|
+
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
144
181
|
}
|