@aztec/aztec 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa
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/README.md +1 -1
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +15 -6
- 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 +73 -35
- 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 +60 -53
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.js +7 -7
- 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 +174 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
- package/dest/cli/cmds/migrate_ha_db.js +27 -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 +52 -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 +76 -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/prover.d.ts +4 -0
- package/dest/cli/cmds/prover.d.ts.map +1 -0
- package/dest/cli/cmds/prover.js +24 -0
- package/dest/cli/cmds/standby.d.ts +56 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +140 -0
- 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 +18 -10
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +85 -54
- 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 +2 -3
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +8 -20
- 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 +25 -16
- 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 +6 -5
- package/dest/cli/cmds/utils/artifacts.d.ts +26 -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/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/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/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 +61 -0
- package/dest/cli/index.d.ts +1 -1
- package/dest/cli/preload_crs.d.ts +1 -1
- package/dest/cli/util.d.ts +17 -23
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +38 -101
- package/dest/cli/versioning.d.ts +1 -1
- package/dest/examples/token.d.ts +1 -1
- package/dest/examples/token.js +12 -12
- package/dest/examples/util.d.ts +2 -2
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +11 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/banana_fpc.js +14 -10
- package/dest/local-network/index.d.ts +4 -0
- package/dest/local-network/index.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/index.js +1 -1
- package/dest/local-network/local-network.d.ts +49 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/local-network/local-network.js +205 -0
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/mnemonic.d.ts +1 -1
- package/dest/splash.d.ts +1 -1
- package/dest/testing/cheat_codes.d.ts +17 -23
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +17 -43
- package/dest/testing/epoch_test_settler.d.ts +19 -0
- package/dest/testing/epoch_test_settler.d.ts.map +1 -0
- package/dest/testing/epoch_test_settler.js +42 -0
- package/dest/testing/index.d.ts +3 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +2 -1
- package/dest/testing/token_allowed_setup.d.ts +12 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +24 -0
- package/package.json +42 -37
- package/scripts/add_crate.sh +53 -0
- package/scripts/aztec.sh +73 -0
- package/scripts/init.sh +39 -0
- package/scripts/new.sh +83 -0
- package/scripts/setup_workspace.sh +69 -0
- 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/bin/index.ts +16 -6
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +74 -28
- package/src/cli/aztec_start_options.ts +68 -59
- package/src/cli/cli.ts +11 -11
- package/src/cli/cmds/compile.ts +205 -0
- package/src/cli/cmds/migrate_ha_db.ts +43 -0
- package/src/cli/cmds/profile.ts +26 -0
- package/src/cli/cmds/profile_flamegraph.ts +64 -0
- package/src/cli/cmds/profile_gates.ts +84 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/prover.ts +42 -0
- package/src/cli/cmds/standby.ts +184 -0
- package/src/cli/cmds/start_bot.ts +18 -12
- package/src/cli/cmds/start_node.ts +95 -55
- package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
- package/src/cli/cmds/start_prover_agent.ts +9 -20
- package/src/cli/cmds/start_prover_broker.ts +29 -26
- package/src/cli/cmds/start_txe.ts +7 -5
- package/src/cli/cmds/utils/artifacts.ts +49 -0
- 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/spawn.ts +16 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
- package/src/cli/util.ts +41 -120
- package/src/examples/token.ts +13 -13
- package/src/examples/util.ts +1 -1
- package/src/index.ts +2 -2
- package/src/local-network/auth_registry.ts +19 -0
- package/src/{sandbox → local-network}/banana_fpc.ts +17 -9
- package/src/{sandbox → local-network}/index.ts +1 -1
- package/src/local-network/local-network.ts +250 -0
- package/src/{sandbox → local-network}/sponsored_fpc.ts +3 -2
- package/src/testing/cheat_codes.ts +18 -48
- package/src/testing/epoch_test_settler.ts +47 -0
- package/src/testing/index.ts +2 -1
- package/src/testing/token_allowed_setup.ts +26 -0
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -50
- package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
- package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
- package/dest/cli/cmds/start_blob_sink.js +0 -33
- package/dest/cli/cmds/start_prover_node.d.ts +0 -7
- package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
- package/dest/cli/cmds/start_prover_node.js +0 -108
- package/dest/cli/release_version.d.ts +0 -2
- package/dest/cli/release_version.d.ts.map +0 -1
- package/dest/cli/release_version.js +0 -14
- package/dest/sandbox/banana_fpc.d.ts +0 -10
- package/dest/sandbox/banana_fpc.d.ts.map +0 -1
- package/dest/sandbox/index.d.ts +0 -4
- package/dest/sandbox/index.d.ts.map +0 -1
- package/dest/sandbox/sandbox.d.ts +0 -74
- package/dest/sandbox/sandbox.d.ts.map +0 -1
- package/dest/sandbox/sandbox.js +0 -183
- package/dest/sandbox/sponsored_fpc.d.ts +0 -4
- package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.d.ts +0 -34
- package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.js +0 -142
- package/src/cli/cmds/start_archiver.ts +0 -61
- package/src/cli/cmds/start_blob_sink.ts +0 -57
- package/src/cli/cmds/start_prover_node.ts +0 -124
- package/src/cli/release_version.ts +0 -21
- package/src/sandbox/sandbox.ts +0 -242
- package/src/testing/anvil_test_watcher.ts +0 -164
- /package/dest/{sandbox → local-network}/sponsored_fpc.js +0 -0
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Archiver,
|
|
3
|
-
type ArchiverConfig,
|
|
4
|
-
KVArchiverDataStore,
|
|
5
|
-
archiverConfigMappings,
|
|
6
|
-
getArchiverConfigFromEnv,
|
|
7
|
-
} from '@aztec/archiver';
|
|
8
|
-
import { createLogger } from '@aztec/aztec.js/log';
|
|
9
|
-
import { type BlobSinkConfig, blobSinkConfigMapping, createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
10
|
-
import { getL1Config } from '@aztec/cli/config';
|
|
11
|
-
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
12
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
13
|
-
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
14
|
-
import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
15
|
-
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
16
|
-
|
|
17
|
-
import { extractRelevantOptions } from '../util.js';
|
|
18
|
-
|
|
19
|
-
export type { ArchiverConfig, DataStoreConfig };
|
|
20
|
-
|
|
21
|
-
/** Starts a standalone archiver. */
|
|
22
|
-
export async function startArchiver(
|
|
23
|
-
options: any,
|
|
24
|
-
signalHandlers: (() => Promise<void>)[],
|
|
25
|
-
services: NamespacedApiHandlers,
|
|
26
|
-
): Promise<{ config: ArchiverConfig & DataStoreConfig }> {
|
|
27
|
-
const envConfig = getArchiverConfigFromEnv();
|
|
28
|
-
const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobSinkConfig>(
|
|
29
|
-
options,
|
|
30
|
-
{ ...archiverConfigMappings, ...dataConfigMappings, ...blobSinkConfigMapping },
|
|
31
|
-
'archiver',
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
let archiverConfig = { ...envConfig, ...cliOptions };
|
|
35
|
-
archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
|
|
36
|
-
|
|
37
|
-
if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
|
|
38
|
-
throw new Error('L1 registry address is required to start an Archiver');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const { addresses, config: l1Config } = await getL1Config(
|
|
42
|
-
archiverConfig.l1Contracts.registryAddress,
|
|
43
|
-
archiverConfig.l1RpcUrls,
|
|
44
|
-
archiverConfig.l1ChainId,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
archiverConfig.l1Contracts = addresses;
|
|
48
|
-
archiverConfig = { ...archiverConfig, ...l1Config };
|
|
49
|
-
|
|
50
|
-
const storeLog = createLogger('archiver:lmdb');
|
|
51
|
-
const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
|
|
52
|
-
const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
|
|
53
|
-
|
|
54
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
55
|
-
const blobSinkClient = createBlobSinkClient(archiverConfig, { logger: createLogger('archiver:blob-sink:client') });
|
|
56
|
-
const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, { telemetry, blobSinkClient }, true);
|
|
57
|
-
services.archiver = [archiver, ArchiverApiSchema];
|
|
58
|
-
signalHandlers.push(archiver.stop);
|
|
59
|
-
|
|
60
|
-
return { config: archiverConfig };
|
|
61
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type BlobSinkConfig,
|
|
3
|
-
blobSinkConfigMappings,
|
|
4
|
-
createBlobSinkServer,
|
|
5
|
-
getBlobSinkConfigFromEnv,
|
|
6
|
-
} from '@aztec/blob-sink/server';
|
|
7
|
-
import { getL1Config } from '@aztec/cli/config';
|
|
8
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
9
|
-
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
-
|
|
11
|
-
import { extractRelevantOptions } from '../util.js';
|
|
12
|
-
|
|
13
|
-
export async function startBlobSink(options: any, signalHandlers: (() => Promise<void>)[], userLog: LogFn) {
|
|
14
|
-
if (options.prover || options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
|
|
15
|
-
userLog(
|
|
16
|
-
`Starting a blob sink with --node, --sequencer, --pxe, --p2p-bootstrap, --prover or --txe is not supported.`,
|
|
17
|
-
);
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let blobSinkConfig: BlobSinkConfig = {
|
|
22
|
-
...getBlobSinkConfigFromEnv(), // get default config from env
|
|
23
|
-
...extractRelevantOptions<BlobSinkConfig>(options, blobSinkConfigMappings, 'blobSink'), // override with command line options
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (!blobSinkConfig.l1Contracts?.registryAddress || blobSinkConfig.l1Contracts.registryAddress.isZero()) {
|
|
27
|
-
throw new Error('REGISTRY_CONTRACT_ADDRESS not set');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!blobSinkConfig.l1RpcUrls || blobSinkConfig.l1RpcUrls.length === 0) {
|
|
31
|
-
throw new Error('ETHEREUM_HOSTS not set');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (typeof blobSinkConfig.l1ChainId !== 'number') {
|
|
35
|
-
throw new Error('L1_CHAIN_ID');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
39
|
-
|
|
40
|
-
const { config: chainConfig, addresses } = await getL1Config(
|
|
41
|
-
blobSinkConfig.l1Contracts.registryAddress,
|
|
42
|
-
blobSinkConfig.l1RpcUrls,
|
|
43
|
-
blobSinkConfig.l1ChainId,
|
|
44
|
-
blobSinkConfig.rollupVersion,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
blobSinkConfig = {
|
|
48
|
-
...blobSinkConfig,
|
|
49
|
-
l1Contracts: addresses,
|
|
50
|
-
...chainConfig,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const blobSink = await createBlobSinkServer(blobSinkConfig, telemetry);
|
|
54
|
-
signalHandlers.push(blobSink.stop.bind(blobSink));
|
|
55
|
-
|
|
56
|
-
await blobSink.start();
|
|
57
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
4
|
-
import { getL1Config } from '@aztec/cli/config';
|
|
5
|
-
import { getPublicClient } from '@aztec/ethereum';
|
|
6
|
-
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
7
|
-
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
8
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
9
|
-
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
10
|
-
import {
|
|
11
|
-
type ProverNodeConfig,
|
|
12
|
-
createProverNode,
|
|
13
|
-
getProverNodeConfigFromEnv,
|
|
14
|
-
proverNodeConfigMappings,
|
|
15
|
-
} from '@aztec/prover-node';
|
|
16
|
-
import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
17
|
-
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
18
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
19
|
-
|
|
20
|
-
import { extractRelevantOptions, preloadCrsDataForVerifying, setupUpdateMonitor } from '../util.js';
|
|
21
|
-
import { getVersions } from '../versioning.js';
|
|
22
|
-
import { startProverBroker } from './start_prover_broker.js';
|
|
23
|
-
|
|
24
|
-
export async function startProverNode(
|
|
25
|
-
options: any,
|
|
26
|
-
signalHandlers: (() => Promise<void>)[],
|
|
27
|
-
services: NamespacedApiHandlers,
|
|
28
|
-
userLog: LogFn,
|
|
29
|
-
): Promise<{ config: ProverNodeConfig }> {
|
|
30
|
-
if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
|
|
31
|
-
userLog(`Starting a prover-node with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let proverConfig = {
|
|
36
|
-
...getProverNodeConfigFromEnv(), // get default config from env
|
|
37
|
-
...extractRelevantOptions<ProverNodeConfig>(options, proverNodeConfigMappings, 'proverNode'), // override with command line options
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
if (!proverConfig.l1Contracts.registryAddress || proverConfig.l1Contracts.registryAddress.isZero()) {
|
|
41
|
-
throw new Error('L1 registry address is required to start a Prover Node');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const followsCanonicalRollup = typeof proverConfig.rollupVersion !== 'number';
|
|
45
|
-
const { addresses, config } = await getL1Config(
|
|
46
|
-
proverConfig.l1Contracts.registryAddress,
|
|
47
|
-
proverConfig.l1RpcUrls,
|
|
48
|
-
proverConfig.l1ChainId,
|
|
49
|
-
proverConfig.rollupVersion,
|
|
50
|
-
);
|
|
51
|
-
process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
|
|
52
|
-
proverConfig.l1Contracts = addresses;
|
|
53
|
-
proverConfig = { ...proverConfig, ...config };
|
|
54
|
-
|
|
55
|
-
const testAccounts = proverConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
|
|
56
|
-
const sponsoredFPCAccounts = proverConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
|
|
57
|
-
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
|
|
58
|
-
|
|
59
|
-
userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
|
|
60
|
-
const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
61
|
-
|
|
62
|
-
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
63
|
-
|
|
64
|
-
if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
`The computed genesis archive tree root ${genesisArchiveRoot} does not match the expected genesis archive tree root ${config.genesisArchiveTreeRoot} for the rollup deployed at ${addresses.rollupAddress}`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
71
|
-
|
|
72
|
-
let broker: ProvingJobBroker;
|
|
73
|
-
if (proverConfig.proverBrokerUrl) {
|
|
74
|
-
// at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
|
|
75
|
-
// set a lower connection limit such that we don't overload the server
|
|
76
|
-
// Keep retrying up to 30s
|
|
77
|
-
const fetch = makeTracedFetch(
|
|
78
|
-
[1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
|
|
79
|
-
false,
|
|
80
|
-
makeUndiciFetch(new Agent({ connections: 100 })),
|
|
81
|
-
);
|
|
82
|
-
broker = createProvingJobBrokerClient(proverConfig.proverBrokerUrl, getVersions(proverConfig), fetch);
|
|
83
|
-
} else if (options.proverBroker) {
|
|
84
|
-
({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
|
|
85
|
-
} else {
|
|
86
|
-
userLog(`--prover-broker-url or --prover-broker is required to start a Prover Node`);
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (proverConfig.proverAgentCount === 0) {
|
|
91
|
-
userLog(
|
|
92
|
-
`Running prover node without local prover agent. Connect one or more prover agents to this node or pass --proverAgent.proverAgentCount`,
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
await preloadCrsDataForVerifying(proverConfig, userLog);
|
|
97
|
-
|
|
98
|
-
const proverNode = await createProverNode(proverConfig, { telemetry, broker }, { prefilledPublicData });
|
|
99
|
-
services.proverNode = [proverNode, ProverNodeApiSchema];
|
|
100
|
-
|
|
101
|
-
if (proverNode.getP2P()) {
|
|
102
|
-
services.p2p = [proverNode.getP2P(), P2PApiSchema];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!proverConfig.proverBrokerUrl) {
|
|
106
|
-
services.provingJobSource = [proverNode.getProver().getProvingJobSource(), ProvingJobConsumerSchema];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
signalHandlers.push(proverNode.stop.bind(proverNode));
|
|
110
|
-
|
|
111
|
-
await proverNode.start();
|
|
112
|
-
|
|
113
|
-
if (proverConfig.autoUpdate !== 'disabled' && proverConfig.autoUpdateUrl) {
|
|
114
|
-
await setupUpdateMonitor(
|
|
115
|
-
proverConfig.autoUpdate,
|
|
116
|
-
new URL(proverConfig.autoUpdateUrl),
|
|
117
|
-
followsCanonicalRollup,
|
|
118
|
-
getPublicClient(proverConfig),
|
|
119
|
-
proverConfig.l1Contracts.registryAddress,
|
|
120
|
-
signalHandlers,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
return { config: proverConfig };
|
|
124
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
2
|
-
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
4
|
-
import { dirname, resolve } from 'path';
|
|
5
|
-
|
|
6
|
-
export const getCliVersion = () => {
|
|
7
|
-
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
|
|
8
|
-
const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
9
|
-
|
|
10
|
-
// If the version is 0.1.0, this is a placeholder version and we are in a docker container; query release please for the latest version
|
|
11
|
-
if (cliVersion === '0.1.0') {
|
|
12
|
-
const releasePleasePath = resolve(
|
|
13
|
-
dirname(fileURLToPath(import.meta.url)),
|
|
14
|
-
'../../../../.release-please-manifest.json',
|
|
15
|
-
);
|
|
16
|
-
const releaseVersion = JSON.parse(readFileSync(releasePleasePath).toString())['.'];
|
|
17
|
-
return releaseVersion;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return cliVersion;
|
|
21
|
-
};
|
package/src/sandbox/sandbox.ts
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S node --no-warnings
|
|
2
|
-
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
|
-
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
-
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
5
|
-
import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
6
|
-
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
7
|
-
import {
|
|
8
|
-
NULL_KEY,
|
|
9
|
-
createEthereumChain,
|
|
10
|
-
deployL1Contracts,
|
|
11
|
-
deployMulticall3,
|
|
12
|
-
getL1ContractsConfigEnvVars,
|
|
13
|
-
waitForPublicClient,
|
|
14
|
-
} from '@aztec/ethereum';
|
|
15
|
-
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
16
|
-
import { SecretValue } from '@aztec/foundation/config';
|
|
17
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
18
|
-
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
19
|
-
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
20
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
21
|
-
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
22
|
-
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
23
|
-
import {
|
|
24
|
-
type TelemetryClient,
|
|
25
|
-
getConfigEnvVars as getTelemetryClientConfig,
|
|
26
|
-
initTelemetryClient,
|
|
27
|
-
} from '@aztec/telemetry-client';
|
|
28
|
-
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
29
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
30
|
-
|
|
31
|
-
import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
32
|
-
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
33
|
-
import { foundry } from 'viem/chains';
|
|
34
|
-
|
|
35
|
-
import { createAccountLogs } from '../cli/util.js';
|
|
36
|
-
import { DefaultMnemonic } from '../mnemonic.js';
|
|
37
|
-
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
38
|
-
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
39
|
-
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
40
|
-
|
|
41
|
-
const logger = createLogger('sandbox');
|
|
42
|
-
|
|
43
|
-
const localAnvil = foundry;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Function to deploy our L1 contracts to the sandbox L1
|
|
47
|
-
* @param aztecNodeConfig - The Aztec Node Config
|
|
48
|
-
* @param hdAccount - Account for publishing L1 contracts
|
|
49
|
-
*/
|
|
50
|
-
export async function deployContractsToL1(
|
|
51
|
-
aztecNodeConfig: AztecNodeConfig,
|
|
52
|
-
hdAccount: HDAccount | PrivateKeyAccount,
|
|
53
|
-
contractDeployLogger = logger,
|
|
54
|
-
opts: {
|
|
55
|
-
assumeProvenThroughBlockNumber?: number;
|
|
56
|
-
salt?: number;
|
|
57
|
-
genesisArchiveRoot?: Fr;
|
|
58
|
-
feeJuicePortalInitialBalance?: bigint;
|
|
59
|
-
} = {},
|
|
60
|
-
) {
|
|
61
|
-
const chain =
|
|
62
|
-
aztecNodeConfig.l1RpcUrls.length > 0
|
|
63
|
-
? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId)
|
|
64
|
-
: { chainInfo: localAnvil };
|
|
65
|
-
|
|
66
|
-
await waitForPublicClient(aztecNodeConfig);
|
|
67
|
-
|
|
68
|
-
const l1Contracts = await deployL1Contracts(
|
|
69
|
-
aztecNodeConfig.l1RpcUrls,
|
|
70
|
-
hdAccount,
|
|
71
|
-
chain.chainInfo,
|
|
72
|
-
contractDeployLogger,
|
|
73
|
-
{
|
|
74
|
-
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
75
|
-
...aztecNodeConfig,
|
|
76
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
77
|
-
protocolContractsHash,
|
|
78
|
-
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
79
|
-
salt: opts.salt,
|
|
80
|
-
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
81
|
-
aztecTargetCommitteeSize: 0, // no committee in sandbox
|
|
82
|
-
slasherFlavor: 'none', // no slashing in sandbox
|
|
83
|
-
realVerifier: false,
|
|
84
|
-
},
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
await deployMulticall3(l1Contracts.l1Client, logger);
|
|
88
|
-
|
|
89
|
-
aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
|
|
90
|
-
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
91
|
-
|
|
92
|
-
return aztecNodeConfig.l1Contracts;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** Sandbox settings. */
|
|
96
|
-
export type SandboxConfig = AztecNodeConfig & {
|
|
97
|
-
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
98
|
-
l1Mnemonic: string;
|
|
99
|
-
/** Salt used to deploy L1 contracts.*/
|
|
100
|
-
deployAztecContractsSalt: string;
|
|
101
|
-
/** Whether to deploy test accounts on sandbox start.*/
|
|
102
|
-
testAccounts: boolean;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
107
|
-
* Does not start any HTTP services nor populate any initial accounts.
|
|
108
|
-
* @param config - Optional Sandbox settings.
|
|
109
|
-
*/
|
|
110
|
-
export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog: LogFn) {
|
|
111
|
-
// sandbox is meant for test envs. We should only need one l1RpcUrl
|
|
112
|
-
const l1RpcUrl = config.l1RpcUrls?.[0];
|
|
113
|
-
if (!l1RpcUrl) {
|
|
114
|
-
throw new Error('An L1 RPC URL is required');
|
|
115
|
-
}
|
|
116
|
-
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
117
|
-
logger.warn(`Multiple L1 RPC URLs provided. Sandbox will only use the first one: ${l1RpcUrl}`);
|
|
118
|
-
}
|
|
119
|
-
const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
|
|
120
|
-
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
121
|
-
if (
|
|
122
|
-
aztecNodeConfig.publisherPrivateKeys == undefined ||
|
|
123
|
-
!aztecNodeConfig.publisherPrivateKeys.length ||
|
|
124
|
-
aztecNodeConfig.publisherPrivateKeys[0].getValue() === NULL_KEY
|
|
125
|
-
) {
|
|
126
|
-
const privKey = hdAccount.getHdKey().privateKey;
|
|
127
|
-
aztecNodeConfig.publisherPrivateKeys = [new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const)];
|
|
128
|
-
}
|
|
129
|
-
if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
|
|
130
|
-
const privKey = hdAccount.getHdKey().privateKey;
|
|
131
|
-
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${Buffer.from(privKey!).toString('hex')}`]);
|
|
132
|
-
}
|
|
133
|
-
aztecNodeConfig.coinbase = EthAddress.fromString(
|
|
134
|
-
privateKeyToAddress(aztecNodeConfig.validatorPrivateKeys.getValue()[0]),
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const initialAccounts = await (async () => {
|
|
138
|
-
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
139
|
-
if (aztecNodeConfig.p2pEnabled) {
|
|
140
|
-
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
141
|
-
} else {
|
|
142
|
-
userLog(`Setting up test accounts`);
|
|
143
|
-
return await getInitialTestAccountsData();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return [];
|
|
147
|
-
})();
|
|
148
|
-
|
|
149
|
-
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
150
|
-
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
151
|
-
const fundedAddresses = initialAccounts.length
|
|
152
|
-
? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC]
|
|
153
|
-
: [];
|
|
154
|
-
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
155
|
-
|
|
156
|
-
let watcher: AnvilTestWatcher | undefined = undefined;
|
|
157
|
-
const dateProvider = new TestDateProvider();
|
|
158
|
-
if (!aztecNodeConfig.p2pEnabled) {
|
|
159
|
-
const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
|
|
160
|
-
assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
|
|
161
|
-
genesisArchiveRoot,
|
|
162
|
-
salt: config.deployAztecContractsSalt ? parseInt(config.deployAztecContractsSalt) : undefined,
|
|
163
|
-
feeJuicePortalInitialBalance: fundingNeeded,
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const chain =
|
|
167
|
-
aztecNodeConfig.l1RpcUrls.length > 0
|
|
168
|
-
? createEthereumChain([l1RpcUrl], aztecNodeConfig.l1ChainId)
|
|
169
|
-
: { chainInfo: localAnvil };
|
|
170
|
-
|
|
171
|
-
const publicClient = createPublicClient({
|
|
172
|
-
chain: chain.chainInfo,
|
|
173
|
-
transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
watcher = new AnvilTestWatcher(
|
|
177
|
-
new EthCheatCodes([l1RpcUrl], dateProvider),
|
|
178
|
-
l1ContractAddresses.rollupAddress,
|
|
179
|
-
publicClient,
|
|
180
|
-
dateProvider,
|
|
181
|
-
);
|
|
182
|
-
watcher.setIsSandbox(true);
|
|
183
|
-
await watcher.start();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
187
|
-
// Create a local blob sink client inside the sandbox, no http connectivity
|
|
188
|
-
const blobSinkClient = createBlobSinkClient();
|
|
189
|
-
const node = await createAztecNode(
|
|
190
|
-
aztecNodeConfig,
|
|
191
|
-
{ telemetry, blobSinkClient, dateProvider },
|
|
192
|
-
{ prefilledPublicData },
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
if (initialAccounts.length) {
|
|
196
|
-
const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
197
|
-
const wallet = await TestWallet.create(node, PXEConfig);
|
|
198
|
-
|
|
199
|
-
userLog('Setting up funded test accounts...');
|
|
200
|
-
const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
|
|
201
|
-
const accountsWithSecrets = accountManagers.map((manager, i) => ({
|
|
202
|
-
account: manager,
|
|
203
|
-
secretKey: initialAccounts[i].secret,
|
|
204
|
-
}));
|
|
205
|
-
const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
|
|
206
|
-
userLog(accLogs.join(''));
|
|
207
|
-
|
|
208
|
-
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
209
|
-
|
|
210
|
-
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
211
|
-
|
|
212
|
-
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
213
|
-
await wallet.stop();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const stop = async () => {
|
|
217
|
-
await node.stop();
|
|
218
|
-
await watcher?.stop();
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
return { node, stop };
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Create and start a new Aztec RPC HTTP Server
|
|
226
|
-
* @param config - Optional Aztec node settings.
|
|
227
|
-
*/
|
|
228
|
-
export async function createAztecNode(
|
|
229
|
-
config: Partial<AztecNodeConfig> = {},
|
|
230
|
-
deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface; dateProvider?: DateProvider } = {},
|
|
231
|
-
options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
|
|
232
|
-
) {
|
|
233
|
-
// TODO(#12272): will clean this up. This is criminal.
|
|
234
|
-
const { l1Contracts, ...rest } = getConfigEnvVars();
|
|
235
|
-
const aztecNodeConfig: AztecNodeConfig = {
|
|
236
|
-
...rest,
|
|
237
|
-
...config,
|
|
238
|
-
l1Contracts: { ...l1Contracts, ...config.l1Contracts },
|
|
239
|
-
};
|
|
240
|
-
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
|
|
241
|
-
return node;
|
|
242
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import type { ViemClient } from '@aztec/ethereum';
|
|
2
|
-
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
3
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
6
|
-
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
|
-
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
8
|
-
|
|
9
|
-
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Represents a watcher for a rollup contract.
|
|
13
|
-
*
|
|
14
|
-
* It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
|
|
15
|
-
* it will periodically check if the current slot have already been filled, e.g., there was an L2
|
|
16
|
-
* block within the slot. And if so, it will time travel into the next slot.
|
|
17
|
-
*/
|
|
18
|
-
export class AnvilTestWatcher {
|
|
19
|
-
private isSandbox: boolean = false;
|
|
20
|
-
|
|
21
|
-
private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
22
|
-
private rollupCheatCodes: RollupCheatCodes;
|
|
23
|
-
private l2SlotDuration!: bigint;
|
|
24
|
-
|
|
25
|
-
private filledRunningPromise?: RunningPromise;
|
|
26
|
-
private syncDateProviderPromise?: RunningPromise;
|
|
27
|
-
private markingAsProvenRunningPromise?: RunningPromise;
|
|
28
|
-
|
|
29
|
-
private logger: Logger = createLogger(`aztecjs:utils:watcher`);
|
|
30
|
-
|
|
31
|
-
private isMarkingAsProven = true;
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
private cheatcodes: EthCheatCodes,
|
|
35
|
-
rollupAddress: EthAddress,
|
|
36
|
-
l1Client: ViemClient,
|
|
37
|
-
private dateProvider?: TestDateProvider,
|
|
38
|
-
) {
|
|
39
|
-
this.rollup = getContract({
|
|
40
|
-
address: getAddress(rollupAddress.toString()),
|
|
41
|
-
abi: RollupAbi,
|
|
42
|
-
client: l1Client,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
|
|
46
|
-
rollupAddress,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
setIsMarkingAsProven(isMarkingAsProven: boolean) {
|
|
53
|
-
this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
|
|
54
|
-
this.isMarkingAsProven = isMarkingAsProven;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
setIsSandbox(isSandbox: boolean) {
|
|
58
|
-
this.isSandbox = isSandbox;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async start() {
|
|
62
|
-
if (this.filledRunningPromise) {
|
|
63
|
-
throw new Error('Watcher already watching for filled slot');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const config = await this.rollupCheatCodes.getConfig();
|
|
67
|
-
this.l2SlotDuration = config.slotDuration;
|
|
68
|
-
|
|
69
|
-
// If auto mining is not supported (e.g., we are on a real network), then we
|
|
70
|
-
// will simple do nothing. But if on an anvil or the like, this make sure that
|
|
71
|
-
// the sandbox and tests don't break because time is frozen and we never get to
|
|
72
|
-
// the next slot.
|
|
73
|
-
const isAutoMining = await this.cheatcodes.isAutoMining();
|
|
74
|
-
|
|
75
|
-
if (isAutoMining) {
|
|
76
|
-
this.filledRunningPromise = new RunningPromise(() => this.warpTimeIfNeeded(), this.logger, 200);
|
|
77
|
-
this.filledRunningPromise.start();
|
|
78
|
-
this.syncDateProviderPromise = new RunningPromise(() => this.syncDateProviderToL1IfBehind(), this.logger, 200);
|
|
79
|
-
this.syncDateProviderPromise.start();
|
|
80
|
-
this.markingAsProvenRunningPromise = new RunningPromise(() => this.markAsProven(), this.logger, 200);
|
|
81
|
-
this.markingAsProvenRunningPromise.start();
|
|
82
|
-
this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
|
|
83
|
-
} else {
|
|
84
|
-
this.logger.info(`Watcher not started because not auto mining`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async stop() {
|
|
89
|
-
await this.filledRunningPromise?.stop();
|
|
90
|
-
await this.syncDateProviderPromise?.stop();
|
|
91
|
-
await this.markingAsProvenRunningPromise?.stop();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async trigger() {
|
|
95
|
-
await this.filledRunningPromise?.trigger();
|
|
96
|
-
await this.syncDateProviderPromise?.trigger();
|
|
97
|
-
await this.markingAsProvenRunningPromise?.trigger();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async markAsProven() {
|
|
101
|
-
if (!this.isMarkingAsProven) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
await this.rollupCheatCodes.markAsProven();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async syncDateProviderToL1IfBehind() {
|
|
108
|
-
// this doesn't apply to the sandbox, because we don't have a date provider in the sandbox
|
|
109
|
-
if (!this.dateProvider) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const l1Time = (await this.cheatcodes.timestamp()) * 1000;
|
|
114
|
-
const wallTime = this.dateProvider.now();
|
|
115
|
-
if (l1Time > wallTime) {
|
|
116
|
-
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
117
|
-
this.dateProvider.setTime(l1Time);
|
|
118
|
-
} else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
|
|
119
|
-
this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
|
|
120
|
-
await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async warpTimeIfNeeded() {
|
|
125
|
-
try {
|
|
126
|
-
const currentSlot = await this.rollup.read.getCurrentSlot();
|
|
127
|
-
const pendingBlockNumber = BigInt(await this.rollup.read.getPendingBlockNumber());
|
|
128
|
-
const blockLog = await this.rollup.read.getBlock([pendingBlockNumber]);
|
|
129
|
-
const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([currentSlot + 1n]));
|
|
130
|
-
|
|
131
|
-
if (currentSlot === blockLog.slotNumber) {
|
|
132
|
-
// We should jump to the next slot
|
|
133
|
-
try {
|
|
134
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
135
|
-
resetBlockInterval: true,
|
|
136
|
-
});
|
|
137
|
-
} catch (e) {
|
|
138
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// If we are not in sandbox, we don't need to warp time
|
|
146
|
-
if (!this.isSandbox) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
151
|
-
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
152
|
-
try {
|
|
153
|
-
await this.cheatcodes.warp(nextSlotTimestamp, { resetBlockInterval: true });
|
|
154
|
-
} catch (e) {
|
|
155
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
159
|
-
}
|
|
160
|
-
} catch {
|
|
161
|
-
this.logger.error('mineIfSlotFilled failed');
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
File without changes
|