@aztec/aztec 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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 +14 -9
- 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 +59 -34
- 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 +46 -45
- 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 +95 -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/start_archiver.d.ts +1 -1
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +12 -14
- package/dest/cli/cmds/start_bot.d.ts +4 -7
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +18 -18
- 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 +71 -27
- 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 +4 -4
- 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 +4 -4
- package/dest/cli/cmds/start_txe.d.ts +1 -1
- package/dest/cli/index.d.ts +1 -1
- package/dest/cli/preload_crs.d.ts +1 -1
- package/dest/cli/release_version.d.ts +1 -1
- package/dest/cli/util.d.ts +12 -19
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +16 -11
- package/dest/cli/versioning.d.ts +1 -1
- package/dest/cli/versioning.js +3 -3
- package/dest/examples/token.d.ts +1 -1
- package/dest/examples/token.js +21 -19
- package/dest/examples/util.d.ts +3 -3
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +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/banana_fpc.d.ts +10 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/banana_fpc.js +17 -21
- package/dest/local-network/index.d.ts +4 -0
- package/dest/local-network/index.d.ts.map +1 -0
- package/dest/local-network/index.js +3 -0
- package/dest/local-network/local-network.d.ts +73 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/{sandbox/sandbox.js → local-network/local-network.js} +83 -66
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/sponsored_fpc.js +7 -8
- package/dest/mnemonic.d.ts +1 -1
- package/dest/splash.d.ts +1 -1
- package/dest/testing/anvil_test_watcher.d.ts +12 -4
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +69 -31
- package/dest/testing/cheat_codes.d.ts +7 -8
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +9 -10
- 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 +62 -0
- package/dest/testing/index.d.ts +2 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -1
- package/package.json +41 -37
- package/scripts/aztec.sh +62 -0
- package/scripts/extract_function.js +47 -0
- package/scripts/flamegraph.sh +59 -0
- package/scripts/init.sh +35 -0
- package/scripts/new.sh +59 -0
- package/scripts/setup_project.sh +31 -0
- package/src/bin/index.ts +15 -9
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +62 -26
- package/src/cli/aztec_start_options.ts +47 -43
- package/src/cli/cli.ts +11 -11
- package/src/cli/cmds/compile.ts +107 -0
- package/src/cli/cmds/migrate_ha_db.ts +43 -0
- package/src/cli/cmds/start_archiver.ts +8 -19
- package/src/cli/cmds/start_bot.ts +27 -15
- package/src/cli/cmds/start_node.ts +64 -23
- package/src/cli/cmds/start_p2p_bootstrap.ts +3 -3
- package/src/cli/cmds/start_prover_agent.ts +4 -12
- package/src/cli/cmds/start_prover_broker.ts +7 -3
- package/src/cli/util.ts +23 -26
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +20 -19
- package/src/examples/util.ts +2 -2
- package/src/index.ts +5 -5
- package/src/{sandbox → local-network}/banana_fpc.ts +24 -25
- package/src/local-network/index.ts +7 -0
- package/src/local-network/local-network.ts +267 -0
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/testing/anvil_test_watcher.ts +77 -34
- package/src/testing/cheat_codes.ts +13 -13
- package/src/testing/epoch_test_settler.ts +71 -0
- package/src/testing/index.ts +1 -1
- 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/cmds/start_pxe.d.ts +0 -16
- package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
- package/dest/cli/cmds/start_pxe.js +0 -31
- package/dest/sandbox/banana_fpc.d.ts +0 -11
- 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/index.js +0 -3
- package/dest/sandbox/sandbox.d.ts +0 -84
- package/dest/sandbox/sandbox.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fpc.d.ts +0 -4
- package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
- package/dest/testing/aztec_cheat_codes.d.ts +0 -59
- package/dest/testing/aztec_cheat_codes.d.ts.map +0 -1
- package/dest/testing/aztec_cheat_codes.js +0 -62
- package/src/cli/cmds/start_blob_sink.ts +0 -57
- package/src/cli/cmds/start_prover_node.ts +0 -124
- package/src/cli/cmds/start_pxe.ts +0 -49
- package/src/sandbox/index.ts +0 -4
- package/src/sandbox/sandbox.ts +0 -253
- package/src/sandbox/sponsored_fpc.ts +0 -27
- package/src/testing/aztec_cheat_codes.ts +0 -77
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js';
|
|
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 getInitialTestAccounts()).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 tube 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,49 +0,0 @@
|
|
|
1
|
-
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
2
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
type CliPXEOptions,
|
|
5
|
-
type PXEService,
|
|
6
|
-
type PXEServiceConfig,
|
|
7
|
-
allPxeConfigMappings,
|
|
8
|
-
createPXEService,
|
|
9
|
-
} from '@aztec/pxe/server';
|
|
10
|
-
import { type AztecNode, PXESchema, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
11
|
-
import { makeTracedFetch } from '@aztec/telemetry-client';
|
|
12
|
-
|
|
13
|
-
import { extractRelevantOptions } from '../util.js';
|
|
14
|
-
import { getVersions } from '../versioning.js';
|
|
15
|
-
|
|
16
|
-
export type { PXEServiceConfig, CliPXEOptions };
|
|
17
|
-
|
|
18
|
-
export async function startPXE(
|
|
19
|
-
options: any,
|
|
20
|
-
signalHandlers: (() => Promise<void>)[],
|
|
21
|
-
services: NamespacedApiHandlers,
|
|
22
|
-
userLog: LogFn,
|
|
23
|
-
): Promise<{ pxe: PXEService; config: PXEServiceConfig & CliPXEOptions }> {
|
|
24
|
-
return await addPXE(options, signalHandlers, services, userLog, {});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function addPXE(
|
|
28
|
-
options: any,
|
|
29
|
-
_signalHandlers: (() => Promise<void>)[],
|
|
30
|
-
services: NamespacedApiHandlers,
|
|
31
|
-
userLog: LogFn,
|
|
32
|
-
deps: { node?: AztecNode } = {},
|
|
33
|
-
): Promise<{ pxe: PXEService; config: PXEServiceConfig & CliPXEOptions }> {
|
|
34
|
-
const pxeConfig = extractRelevantOptions<PXEServiceConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
|
|
35
|
-
const nodeUrl = pxeConfig.nodeUrl;
|
|
36
|
-
|
|
37
|
-
if (!nodeUrl && !deps.node) {
|
|
38
|
-
userLog('Aztec Node URL (nodeUrl | AZTEC_NODE_URL) option is required to start PXE without --node option');
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const node = deps.node ?? createAztecNodeClient(nodeUrl!, getVersions(pxeConfig), makeTracedFetch([1, 2, 3], true));
|
|
43
|
-
const pxe = await createPXEService(node, pxeConfig as PXEServiceConfig);
|
|
44
|
-
|
|
45
|
-
// Add PXE to services list
|
|
46
|
-
services.pxe = [pxe, PXESchema];
|
|
47
|
-
|
|
48
|
-
return { pxe, config: pxeConfig };
|
|
49
|
-
}
|
package/src/sandbox/index.ts
DELETED
package/src/sandbox/sandbox.ts
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S node --no-warnings
|
|
2
|
-
import { getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
3
|
-
import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
4
|
-
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
|
-
import { EthAddress } from '@aztec/aztec.js';
|
|
6
|
-
import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
7
|
-
import { setupSponsoredFPC } from '@aztec/cli/cli-utils';
|
|
8
|
-
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
|
-
import {
|
|
10
|
-
NULL_KEY,
|
|
11
|
-
createEthereumChain,
|
|
12
|
-
deployL1Contracts,
|
|
13
|
-
deployMulticall3,
|
|
14
|
-
getL1ContractsConfigEnvVars,
|
|
15
|
-
waitForPublicClient,
|
|
16
|
-
} from '@aztec/ethereum';
|
|
17
|
-
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
18
|
-
import { SecretValue } from '@aztec/foundation/config';
|
|
19
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
20
|
-
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
21
|
-
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
22
|
-
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
23
|
-
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
24
|
-
import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
25
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
26
|
-
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
27
|
-
import {
|
|
28
|
-
type TelemetryClient,
|
|
29
|
-
getConfigEnvVars as getTelemetryClientConfig,
|
|
30
|
-
initTelemetryClient,
|
|
31
|
-
} from '@aztec/telemetry-client';
|
|
32
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
33
|
-
|
|
34
|
-
import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
35
|
-
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
36
|
-
import { foundry } from 'viem/chains';
|
|
37
|
-
|
|
38
|
-
import { createAccountLogs } from '../cli/util.js';
|
|
39
|
-
import { DefaultMnemonic } from '../mnemonic.js';
|
|
40
|
-
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
41
|
-
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
42
|
-
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
43
|
-
|
|
44
|
-
const logger = createLogger('sandbox');
|
|
45
|
-
|
|
46
|
-
const localAnvil = foundry;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Function to deploy our L1 contracts to the sandbox L1
|
|
50
|
-
* @param aztecNodeConfig - The Aztec Node Config
|
|
51
|
-
* @param hdAccount - Account for publishing L1 contracts
|
|
52
|
-
*/
|
|
53
|
-
export async function deployContractsToL1(
|
|
54
|
-
aztecNodeConfig: AztecNodeConfig,
|
|
55
|
-
hdAccount: HDAccount | PrivateKeyAccount,
|
|
56
|
-
contractDeployLogger = logger,
|
|
57
|
-
opts: {
|
|
58
|
-
assumeProvenThroughBlockNumber?: number;
|
|
59
|
-
salt?: number;
|
|
60
|
-
genesisArchiveRoot?: Fr;
|
|
61
|
-
feeJuicePortalInitialBalance?: bigint;
|
|
62
|
-
} = {},
|
|
63
|
-
) {
|
|
64
|
-
const chain =
|
|
65
|
-
aztecNodeConfig.l1RpcUrls.length > 0
|
|
66
|
-
? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId)
|
|
67
|
-
: { chainInfo: localAnvil };
|
|
68
|
-
|
|
69
|
-
await waitForPublicClient(aztecNodeConfig);
|
|
70
|
-
|
|
71
|
-
const l1Contracts = await deployL1Contracts(
|
|
72
|
-
aztecNodeConfig.l1RpcUrls,
|
|
73
|
-
hdAccount,
|
|
74
|
-
chain.chainInfo,
|
|
75
|
-
contractDeployLogger,
|
|
76
|
-
{
|
|
77
|
-
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
78
|
-
...aztecNodeConfig,
|
|
79
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
80
|
-
protocolContractTreeRoot,
|
|
81
|
-
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
82
|
-
salt: opts.salt,
|
|
83
|
-
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
84
|
-
aztecTargetCommitteeSize: 0, // no committee in sandbox
|
|
85
|
-
slasherFlavor: 'none', // no slashing in sandbox
|
|
86
|
-
realVerifier: false,
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
await deployMulticall3(l1Contracts.l1Client, logger);
|
|
91
|
-
|
|
92
|
-
aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
|
|
93
|
-
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
94
|
-
|
|
95
|
-
return aztecNodeConfig.l1Contracts;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Sandbox settings. */
|
|
99
|
-
export type SandboxConfig = AztecNodeConfig & {
|
|
100
|
-
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
101
|
-
l1Mnemonic: string;
|
|
102
|
-
/** Salt used to deploy L1 contracts.*/
|
|
103
|
-
deployAztecContractsSalt: string;
|
|
104
|
-
/** Whether to expose PXE service on sandbox start.*/
|
|
105
|
-
noPXE: boolean;
|
|
106
|
-
/** Whether to deploy test accounts on sandbox start.*/
|
|
107
|
-
testAccounts: boolean;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
112
|
-
* Does not start any HTTP services nor populate any initial accounts.
|
|
113
|
-
* @param config - Optional Sandbox settings.
|
|
114
|
-
*/
|
|
115
|
-
export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog: LogFn) {
|
|
116
|
-
// sandbox is meant for test envs. We should only need one l1RpcUrl
|
|
117
|
-
const l1RpcUrl = config.l1RpcUrls?.[0];
|
|
118
|
-
if (!l1RpcUrl) {
|
|
119
|
-
throw new Error('An L1 RPC URL is required');
|
|
120
|
-
}
|
|
121
|
-
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
122
|
-
logger.warn(`Multiple L1 RPC URLs provided. Sandbox will only use the first one: ${l1RpcUrl}`);
|
|
123
|
-
}
|
|
124
|
-
const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
|
|
125
|
-
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
126
|
-
if (
|
|
127
|
-
aztecNodeConfig.publisherPrivateKeys == undefined ||
|
|
128
|
-
!aztecNodeConfig.publisherPrivateKeys.length ||
|
|
129
|
-
aztecNodeConfig.publisherPrivateKeys[0].getValue() === NULL_KEY
|
|
130
|
-
) {
|
|
131
|
-
const privKey = hdAccount.getHdKey().privateKey;
|
|
132
|
-
aztecNodeConfig.publisherPrivateKeys = [new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const)];
|
|
133
|
-
}
|
|
134
|
-
if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
|
|
135
|
-
const privKey = hdAccount.getHdKey().privateKey;
|
|
136
|
-
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${Buffer.from(privKey!).toString('hex')}`]);
|
|
137
|
-
}
|
|
138
|
-
aztecNodeConfig.coinbase = EthAddress.fromString(
|
|
139
|
-
privateKeyToAddress(aztecNodeConfig.validatorPrivateKeys.getValue()[0]),
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
const initialAccounts = await (async () => {
|
|
143
|
-
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
144
|
-
if (aztecNodeConfig.p2pEnabled) {
|
|
145
|
-
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
146
|
-
} else {
|
|
147
|
-
userLog(`Setting up test accounts`);
|
|
148
|
-
return await getInitialTestAccounts();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return [];
|
|
152
|
-
})();
|
|
153
|
-
|
|
154
|
-
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
155
|
-
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
156
|
-
const fundedAddresses = initialAccounts.length
|
|
157
|
-
? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC]
|
|
158
|
-
: [];
|
|
159
|
-
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
160
|
-
|
|
161
|
-
let watcher: AnvilTestWatcher | undefined = undefined;
|
|
162
|
-
const dateProvider = new TestDateProvider();
|
|
163
|
-
if (!aztecNodeConfig.p2pEnabled) {
|
|
164
|
-
const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
|
|
165
|
-
assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
|
|
166
|
-
genesisArchiveRoot,
|
|
167
|
-
salt: config.deployAztecContractsSalt ? parseInt(config.deployAztecContractsSalt) : undefined,
|
|
168
|
-
feeJuicePortalInitialBalance: fundingNeeded,
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const chain =
|
|
172
|
-
aztecNodeConfig.l1RpcUrls.length > 0
|
|
173
|
-
? createEthereumChain([l1RpcUrl], aztecNodeConfig.l1ChainId)
|
|
174
|
-
: { chainInfo: localAnvil };
|
|
175
|
-
|
|
176
|
-
const publicClient = createPublicClient({
|
|
177
|
-
chain: chain.chainInfo,
|
|
178
|
-
transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
watcher = new AnvilTestWatcher(
|
|
182
|
-
new EthCheatCodes([l1RpcUrl]),
|
|
183
|
-
l1ContractAddresses.rollupAddress,
|
|
184
|
-
publicClient,
|
|
185
|
-
dateProvider,
|
|
186
|
-
);
|
|
187
|
-
watcher.setIsSandbox(true);
|
|
188
|
-
await watcher.start();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
192
|
-
// Create a local blob sink client inside the sandbox, no http connectivity
|
|
193
|
-
const blobSinkClient = createBlobSinkClient();
|
|
194
|
-
const node = await createAztecNode(
|
|
195
|
-
aztecNodeConfig,
|
|
196
|
-
{ telemetry, blobSinkClient, dateProvider },
|
|
197
|
-
{ prefilledPublicData },
|
|
198
|
-
);
|
|
199
|
-
const pxeServiceConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
200
|
-
const pxe = await createAztecPXE(node, pxeServiceConfig);
|
|
201
|
-
|
|
202
|
-
if (initialAccounts.length) {
|
|
203
|
-
userLog('Setting up funded test accounts...');
|
|
204
|
-
const accounts = await deployFundedSchnorrAccounts(pxe, initialAccounts);
|
|
205
|
-
const accountsWithSecrets = accounts.map((account, i) => ({
|
|
206
|
-
account,
|
|
207
|
-
secretKey: initialAccounts[i].secret,
|
|
208
|
-
}));
|
|
209
|
-
const accLogs = await createAccountLogs(accountsWithSecrets, pxe);
|
|
210
|
-
userLog(accLogs.join(''));
|
|
211
|
-
|
|
212
|
-
const deployer = await getSchnorrWallet(pxe, initialAccounts[0].address, initialAccounts[0].signingKey);
|
|
213
|
-
await setupBananaFPC(initialAccounts, deployer, userLog);
|
|
214
|
-
await setupSponsoredFPC(pxe, userLog);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const stop = async () => {
|
|
218
|
-
await node.stop();
|
|
219
|
-
await watcher?.stop();
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
return { node, pxe, stop };
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Create and start a new Aztec RPC HTTP Server
|
|
227
|
-
* @param config - Optional Aztec node settings.
|
|
228
|
-
*/
|
|
229
|
-
export async function createAztecNode(
|
|
230
|
-
config: Partial<AztecNodeConfig> = {},
|
|
231
|
-
deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface; dateProvider?: DateProvider } = {},
|
|
232
|
-
options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
|
|
233
|
-
) {
|
|
234
|
-
// TODO(#12272): will clean this up. This is criminal.
|
|
235
|
-
const { l1Contracts, ...rest } = getConfigEnvVars();
|
|
236
|
-
const aztecNodeConfig: AztecNodeConfig = {
|
|
237
|
-
...rest,
|
|
238
|
-
...config,
|
|
239
|
-
l1Contracts: { ...l1Contracts, ...config.l1Contracts },
|
|
240
|
-
};
|
|
241
|
-
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
|
|
242
|
-
return node;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Create and start a new Aztec PXE HTTP Server
|
|
247
|
-
* @param config - Optional PXE settings.
|
|
248
|
-
*/
|
|
249
|
-
export async function createAztecPXE(node: AztecNode, config: Partial<PXEServiceConfig> = {}) {
|
|
250
|
-
const pxeServiceConfig: PXEServiceConfig = { ...getPXEServiceConfig(), ...config };
|
|
251
|
-
const pxe = await createPXEService(node, pxeServiceConfig);
|
|
252
|
-
return pxe;
|
|
253
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ContractInstanceWithAddress,
|
|
3
|
-
Fr,
|
|
4
|
-
type PXE,
|
|
5
|
-
getContractInstanceFromInstantiationParams,
|
|
6
|
-
} from '@aztec/aztec.js';
|
|
7
|
-
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
8
|
-
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
9
|
-
|
|
10
|
-
async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
|
|
11
|
-
return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
12
|
-
salt: new Fr(SPONSORED_FPC_SALT),
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function getSponsoredFPCAddress() {
|
|
17
|
-
return (await getSponsoredFPCInstance()).address;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function getDeployedSponsoredFPCAddress(pxe: PXE) {
|
|
21
|
-
const fpc = await getSponsoredFPCAddress();
|
|
22
|
-
const contracts = await pxe.getContracts();
|
|
23
|
-
if (!contracts.find(c => c.equals(fpc))) {
|
|
24
|
-
throw new Error('SponsoredFPC not deployed.');
|
|
25
|
-
}
|
|
26
|
-
return fpc;
|
|
27
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
|
5
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import type { Note } from '@aztec/stdlib/note';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A class that provides utility functions for interacting with the aztec chain.
|
|
10
|
-
*/
|
|
11
|
-
export class AztecCheatCodes {
|
|
12
|
-
constructor(
|
|
13
|
-
/**
|
|
14
|
-
* The PXE Service to use for interacting with the chain
|
|
15
|
-
*/
|
|
16
|
-
public pxe: PXE,
|
|
17
|
-
/**
|
|
18
|
-
* The logger to use for the aztec cheatcodes
|
|
19
|
-
*/
|
|
20
|
-
public logger = createLogger('aztecjs:cheat_codes'),
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Computes the slot value for a given map and key.
|
|
25
|
-
* @param mapSlot - The slot of the map (specified in Aztec.nr contract)
|
|
26
|
-
* @param key - The key to lookup in the map
|
|
27
|
-
* @returns The storage slot of the value in the map
|
|
28
|
-
*/
|
|
29
|
-
public computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Promise<Fr> {
|
|
30
|
-
const keyFr = typeof key === 'bigint' ? new Fr(key) : key.toField();
|
|
31
|
-
return deriveStorageSlotInMap(mapSlot, keyFr);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Get the current blocknumber
|
|
36
|
-
* @returns The current block number
|
|
37
|
-
*/
|
|
38
|
-
public async blockNumber(): Promise<number> {
|
|
39
|
-
return await this.pxe.getBlockNumber();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get the current timestamp
|
|
44
|
-
* @returns The current timestamp
|
|
45
|
-
*/
|
|
46
|
-
public async timestamp(): Promise<number> {
|
|
47
|
-
const res = await this.pxe.getBlock(await this.blockNumber());
|
|
48
|
-
return Number(res?.header.globalVariables.timestamp ?? 0);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Loads the value stored at the given slot in the public storage of the given contract.
|
|
53
|
-
* @param who - The address of the contract
|
|
54
|
-
* @param slot - The storage slot to lookup
|
|
55
|
-
* @returns The value stored at the given slot
|
|
56
|
-
*/
|
|
57
|
-
public async loadPublic(who: AztecAddress, slot: Fr | bigint): Promise<Fr> {
|
|
58
|
-
const storageValue = await this.pxe.getPublicStorageAt(who, new Fr(slot));
|
|
59
|
-
return storageValue;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Loads the value stored at the given slot in the private storage of the given contract.
|
|
64
|
-
* @param contract - The address of the contract
|
|
65
|
-
* @param recipient - The address whose public key was used to encrypt the note
|
|
66
|
-
* @param slot - The storage slot to lookup
|
|
67
|
-
* @returns The notes stored at the given slot
|
|
68
|
-
*/
|
|
69
|
-
public async loadPrivate(recipient: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]> {
|
|
70
|
-
const extendedNotes = await this.pxe.getNotes({
|
|
71
|
-
recipient,
|
|
72
|
-
contractAddress: contract,
|
|
73
|
-
storageSlot: new Fr(slot),
|
|
74
|
-
});
|
|
75
|
-
return extendedNotes.map(extendedNote => extendedNote.note);
|
|
76
|
-
}
|
|
77
|
-
}
|