@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
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
|
-
|
|
2
|
+
createLocalNetwork,
|
|
3
3
|
registerDeployedBananaCoinInWalletAndGetAddress,
|
|
4
4
|
registerDeployedBananaFPCInWalletAndGetAddress,
|
|
5
5
|
registerDeployedSponsoredFPCInWalletAndGetAddress,
|
|
6
|
-
} from './
|
|
6
|
+
} from './local-network/index.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
|
|
7
|
+
export async function publishStandardAuthRegistry(
|
|
8
|
+
wallet: Wallet,
|
|
9
|
+
from: AztecAddress,
|
|
10
|
+
waitOpts?: WaitOpts,
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
const { instance, contractClass } = await getStandardAuthRegistry();
|
|
13
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
14
|
+
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
|
|
15
|
+
}
|
|
16
|
+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
|
|
17
|
+
await publishInstance(wallet, instance).send({ from, wait: waitOpts });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
6
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
6
7
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
@@ -45,16 +46,23 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
45
46
|
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
export async function setupBananaFPC(
|
|
49
|
+
export async function setupBananaFPC(
|
|
50
|
+
initialAccounts: InitialAccountData[],
|
|
51
|
+
wallet: Wallet,
|
|
52
|
+
log: LogFn,
|
|
53
|
+
waitOpts?: WaitOpts,
|
|
54
|
+
) {
|
|
49
55
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
50
56
|
const admin = getBananaAdmin(initialAccounts);
|
|
51
|
-
const [bananaCoin, fpc] = await Promise.all([
|
|
52
|
-
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
58
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
|
|
59
|
+
salt: BANANA_COIN_SALT,
|
|
60
|
+
universalDeploy: true,
|
|
61
|
+
}).send({ from: admin, wait: waitOpts }),
|
|
62
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
|
|
63
|
+
from: admin,
|
|
64
|
+
wait: waitOpts,
|
|
65
|
+
}),
|
|
58
66
|
]);
|
|
59
67
|
|
|
60
68
|
log(`BananaCoin: ${bananaCoin.address}`);
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
|
+
import { createAztecNodeService } from '@aztec/aztec-node';
|
|
4
|
+
import { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
7
|
+
import { type BlobClientInterface, createBlobClient } from '@aztec/blob-client/client';
|
|
8
|
+
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
|
+
import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
10
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
11
|
+
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
12
|
+
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
13
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
14
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
15
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
16
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
17
|
+
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
18
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
22
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
23
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
24
|
+
import {
|
|
25
|
+
type TelemetryClient,
|
|
26
|
+
getConfigEnvVars as getTelemetryClientConfig,
|
|
27
|
+
initTelemetryClient,
|
|
28
|
+
} from '@aztec/telemetry-client';
|
|
29
|
+
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
30
|
+
import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
|
|
31
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
32
|
+
|
|
33
|
+
import type { Hex } from 'viem';
|
|
34
|
+
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
35
|
+
import { foundry } from 'viem/chains';
|
|
36
|
+
|
|
37
|
+
import { createAccountLogs } from '../cli/util.js';
|
|
38
|
+
import { DefaultMnemonic } from '../mnemonic.js';
|
|
39
|
+
import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
|
|
40
|
+
import { publishStandardAuthRegistry } from './auth_registry.js';
|
|
41
|
+
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
42
|
+
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
43
|
+
|
|
44
|
+
const logger = createLogger('local-network');
|
|
45
|
+
|
|
46
|
+
// The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
|
|
47
|
+
// proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
|
|
48
|
+
// pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
|
|
49
|
+
// P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
|
|
50
|
+
const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Function to deploy our L1 contracts to the local network L1
|
|
54
|
+
* @param aztecNodeConfig - The Aztec Node Config
|
|
55
|
+
* @param hdAccount - Account for publishing L1 contracts
|
|
56
|
+
*/
|
|
57
|
+
export async function deployContractsToL1(
|
|
58
|
+
aztecNodeConfig: AztecNodeConfig,
|
|
59
|
+
privateKey: Hex,
|
|
60
|
+
opts: {
|
|
61
|
+
genesisArchiveRoot?: Fr;
|
|
62
|
+
feeJuicePortalInitialBalance?: bigint;
|
|
63
|
+
} = {},
|
|
64
|
+
): Promise<L1ContractAddresses> {
|
|
65
|
+
await waitForPublicClient(aztecNodeConfig);
|
|
66
|
+
|
|
67
|
+
const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
|
|
68
|
+
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
69
|
+
...aztecNodeConfig,
|
|
70
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
71
|
+
protocolContractsHash,
|
|
72
|
+
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
73
|
+
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
74
|
+
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
75
|
+
slasherEnabled: false, // no slashing in local network
|
|
76
|
+
realVerifier: false,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
|
|
80
|
+
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
81
|
+
|
|
82
|
+
return l1Contracts.l1ContractAddresses;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Local network settings. */
|
|
86
|
+
export type LocalNetworkConfig = AztecNodeConfig & {
|
|
87
|
+
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
88
|
+
l1Mnemonic: string;
|
|
89
|
+
/** Whether to deploy test accounts on local network start.*/
|
|
90
|
+
testAccounts: boolean;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
95
|
+
* Does not start any HTTP services nor populate any initial accounts.
|
|
96
|
+
* @param config - Optional local network settings.
|
|
97
|
+
*/
|
|
98
|
+
export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {}, userLog: LogFn) {
|
|
99
|
+
// local network is meant for test envs. We should only need one l1RpcUrl
|
|
100
|
+
const l1RpcUrl = config.l1RpcUrls?.[0];
|
|
101
|
+
if (!l1RpcUrl) {
|
|
102
|
+
throw new Error('An L1 RPC URL is required');
|
|
103
|
+
}
|
|
104
|
+
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
105
|
+
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
109
|
+
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
110
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
111
|
+
|
|
112
|
+
const envConfig = getConfigEnvVars();
|
|
113
|
+
const aztecNodeConfig: AztecNodeConfig = {
|
|
114
|
+
...envConfig,
|
|
115
|
+
...config,
|
|
116
|
+
skipOrphanProposedBlockPruning: true,
|
|
117
|
+
// The local network builds node config from env without a DATA_DIRECTORY, so the validator's
|
|
118
|
+
// local signing protection runs against an ephemeral store. That is acceptable for this dev
|
|
119
|
+
// network; production validators must persist it and fail-fast when the data directory is unset.
|
|
120
|
+
allowEphemeralSigningProtection: config.allowEphemeralSigningProtection ?? true,
|
|
121
|
+
txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
|
|
122
|
+
// The local network runs against anvil with no committee, so it defaults to the deterministic
|
|
123
|
+
// AutomineSequencer, which owns L1 time control (warps the dateProvider and L1 timestamps to slot
|
|
124
|
+
// boundaries as it builds), replacing the deleted AnvilTestWatcher. This remains true when p2p is
|
|
125
|
+
// enabled for local peer testing; local-network is not a mode for connecting to an existing network.
|
|
126
|
+
useAutomineSequencer: config.useAutomineSequencer ?? true,
|
|
127
|
+
// The AutomineSequencer owns epoch proving in the local network — it writes epoch out hashes to
|
|
128
|
+
// the L1 Outbox and advances the proven tip as checkpoints land, through the same serial queue as
|
|
129
|
+
// its builds — replacing the standalone EpochTestSettler that used to race the build loop.
|
|
130
|
+
automineEnableProveEpoch: config.automineEnableProveEpoch ?? true,
|
|
131
|
+
// Defaults for the local network / sandbox; callers (e.g. the CLI) may override. No real proving
|
|
132
|
+
// happens here — the AutomineSequencer synthetically settles epochs. Short epochs let it write out
|
|
133
|
+
// hashes quickly (so users can consume L2-to-L1 messages without a long wait), with a wider
|
|
134
|
+
// proof-submission window so the synthetic settler has headroom before the rollup would prune an
|
|
135
|
+
// unproven checkpoint.
|
|
136
|
+
realProofs: config.realProofs ?? false,
|
|
137
|
+
aztecEpochDuration: config.aztecEpochDuration ?? 4,
|
|
138
|
+
aztecProofSubmissionEpochs: config.aztecProofSubmissionEpochs ?? 2,
|
|
139
|
+
};
|
|
140
|
+
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
141
|
+
if (
|
|
142
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys == undefined ||
|
|
143
|
+
!aztecNodeConfig.sequencerPublisherPrivateKeys.length ||
|
|
144
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY
|
|
145
|
+
) {
|
|
146
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
147
|
+
aztecNodeConfig.sequencerPublisherPrivateKeys = [
|
|
148
|
+
new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const),
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
|
|
152
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
153
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${Buffer.from(privKey!).toString('hex')}`]);
|
|
154
|
+
}
|
|
155
|
+
aztecNodeConfig.coinbase = EthAddress.fromString(
|
|
156
|
+
privateKeyToAddress(aztecNodeConfig.validatorPrivateKeys.getValue()[0]),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const initialAccounts = await (async () => {
|
|
160
|
+
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
161
|
+
if (aztecNodeConfig.p2pEnabled) {
|
|
162
|
+
userLog(`Not setting up test accounts when p2p is enabled`);
|
|
163
|
+
} else {
|
|
164
|
+
userLog(`Setting up test accounts`);
|
|
165
|
+
return await getInitialTestAccountsData();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return [];
|
|
169
|
+
})();
|
|
170
|
+
|
|
171
|
+
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
172
|
+
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
173
|
+
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a));
|
|
174
|
+
const fundedAddresses = [
|
|
175
|
+
...initialAccounts.map(a => a.address),
|
|
176
|
+
...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
|
|
177
|
+
...prefundAddresses,
|
|
178
|
+
];
|
|
179
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
180
|
+
|
|
181
|
+
const dateProvider = new TestDateProvider();
|
|
182
|
+
|
|
183
|
+
if (!aztecNodeConfig.p2pEnabled) {
|
|
184
|
+
await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
|
|
185
|
+
genesisArchiveRoot,
|
|
186
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
191
|
+
// Create a local blob client client inside the local network, no http connectivity
|
|
192
|
+
const blobClient = createBlobClient();
|
|
193
|
+
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
|
|
194
|
+
|
|
195
|
+
if (initialAccounts.length) {
|
|
196
|
+
const wallet = await EmbeddedWallet.create(node, {
|
|
197
|
+
pxeConfig: { proverEnabled: aztecNodeConfig.realProofs },
|
|
198
|
+
ephemeral: true,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
userLog('Setting up funded test accounts...');
|
|
202
|
+
const accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccounts);
|
|
203
|
+
const accLogs = await createAccountLogs(accountManagers, wallet);
|
|
204
|
+
userLog(accLogs.join(''));
|
|
205
|
+
|
|
206
|
+
userLog('Publishing standard AuthRegistry contract...');
|
|
207
|
+
await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
|
|
208
|
+
|
|
209
|
+
await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
|
|
210
|
+
|
|
211
|
+
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
212
|
+
|
|
213
|
+
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
214
|
+
await wallet.stop();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const stop = async () => {
|
|
218
|
+
await node.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: {
|
|
231
|
+
telemetry?: TelemetryClient;
|
|
232
|
+
blobClient?: BlobClientInterface;
|
|
233
|
+
dateProvider?: DateProvider;
|
|
234
|
+
proverBroker?: ProvingJobBroker;
|
|
235
|
+
} = {},
|
|
236
|
+
options: { genesis?: GenesisData } = {},
|
|
237
|
+
) {
|
|
238
|
+
// TODO(#12272): will clean this up. This is criminal.
|
|
239
|
+
// Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
|
|
240
|
+
const aztecNodeConfig: AztecNodeConfig = {
|
|
241
|
+
...getConfigEnvVars(),
|
|
242
|
+
...config,
|
|
243
|
+
};
|
|
244
|
+
const node = await createAztecNodeService(
|
|
245
|
+
aztecNodeConfig,
|
|
246
|
+
{ ...deps, proverNodeDeps: { broker: deps.proverBroker } },
|
|
247
|
+
options,
|
|
248
|
+
);
|
|
249
|
+
return node;
|
|
250
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
1
2
|
import {
|
|
2
3
|
type ContractInstanceWithAddress,
|
|
3
4
|
getContractInstanceFromInstantiationParams,
|
|
@@ -13,11 +14,11 @@ async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
|
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export async function getSponsoredFPCAddress() {
|
|
17
|
+
export async function getSponsoredFPCAddress(): Promise<AztecAddress> {
|
|
17
18
|
return (await getSponsoredFPCInstance()).address;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet) {
|
|
21
|
+
export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet): Promise<AztecAddress> {
|
|
21
22
|
const fpc = await getSponsoredFPCInstance();
|
|
22
23
|
// The following is no-op if the contract is already registered
|
|
23
24
|
await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
2
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
-
import type {
|
|
5
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @deprecated
|
|
10
|
-
* they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
|
|
11
|
-
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
6
|
+
* Wrapper for Aztec Debug API.
|
|
7
|
+
* @deprecated use the AztecNode debug API directly.
|
|
12
8
|
*/
|
|
13
9
|
export class CheatCodes {
|
|
14
10
|
constructor(
|
|
@@ -28,51 +24,25 @@ export class CheatCodes {
|
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
/**
|
|
31
|
-
* Warps the L1 timestamp to
|
|
32
|
-
* the target
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
* @param node - The Aztec node used to query if a new block has been mined.
|
|
37
|
-
* @param targetTimestamp - The target timestamp to warp to (in seconds)
|
|
27
|
+
* Warps the L1 timestamp to at least `targetTimestamp` and mines an L2 block advancing the L2 timestamp to at least
|
|
28
|
+
* the target. Forwards to the node's debug API, which serializes the warp through the automine sequencer queue.
|
|
29
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
30
|
+
* @param targetTimestamp - The target timestamp to warp to (in seconds).
|
|
31
|
+
* @deprecated Call `node.warpL2TimeAtLeastTo(targetTimestamp)` on the node debug API directly.
|
|
38
32
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// We warp the L1 timestamp
|
|
43
|
-
await this.eth.warp(targetTimestamp, { resetBlockInterval: true });
|
|
44
|
-
|
|
45
|
-
// Wait until an L2 block is mined
|
|
46
|
-
const sequencer = sequencerClient.getSequencer();
|
|
47
|
-
const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
|
|
48
|
-
sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
49
|
-
|
|
50
|
-
await retryUntil(
|
|
51
|
-
async () => {
|
|
52
|
-
const newL2BlockNumber = await node.getBlockNumber();
|
|
53
|
-
return newL2BlockNumber > currentL2BlockNumber;
|
|
54
|
-
},
|
|
55
|
-
'new block after warping L2 time',
|
|
56
|
-
36,
|
|
57
|
-
1,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Restore original minTxsPerBlock
|
|
61
|
-
sequencer.updateConfig({ minTxsPerBlock });
|
|
33
|
+
warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number): Promise<void> {
|
|
34
|
+
return node.warpL2TimeAtLeastTo(Number(targetTimestamp));
|
|
62
35
|
}
|
|
63
36
|
|
|
64
37
|
/**
|
|
65
|
-
* Warps the L1 timestamp forward by
|
|
66
|
-
* least by the duration.
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @param
|
|
70
|
-
* @
|
|
71
|
-
* @param duration - The duration to advance time by (in seconds)
|
|
38
|
+
* Warps the L1 timestamp forward by at least `duration` seconds and mines an L2 block advancing the L2 timestamp at
|
|
39
|
+
* least by the duration. Forwards to the node's debug API, which serializes the warp through the automine sequencer
|
|
40
|
+
* queue.
|
|
41
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
42
|
+
* @param duration - The duration to advance time by (in seconds).
|
|
43
|
+
* @deprecated Call `node.warpL2TimeAtLeastBy(duration)` on the node debug API directly.
|
|
72
44
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
|
|
76
|
-
await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
|
|
45
|
+
warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number): Promise<void> {
|
|
46
|
+
return node.warpL2TimeAtLeastBy(Number(duration));
|
|
77
47
|
}
|
|
78
48
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
import { settleEpochOutbox } from '@aztec/prover-client/test';
|
|
5
|
+
import { EpochMonitor } from '@aztec/prover-node';
|
|
6
|
+
import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
|
|
7
|
+
|
|
8
|
+
export class EpochTestSettler {
|
|
9
|
+
private rollupCheatCodes: RollupCheatCodes;
|
|
10
|
+
private epochMonitor?: EpochMonitor;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
cheatcodes: EthCheatCodes,
|
|
14
|
+
rollupAddress: EthAddress,
|
|
15
|
+
private l2BlockSource: L2BlockSource,
|
|
16
|
+
private log: Logger,
|
|
17
|
+
private options: { pollingIntervalMs: number; provingDelayMs?: number },
|
|
18
|
+
) {
|
|
19
|
+
this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, { rollupAddress });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async start() {
|
|
23
|
+
const { epochDuration } = await this.rollupCheatCodes.getConfig();
|
|
24
|
+
this.epochMonitor = new EpochMonitor(this.l2BlockSource, { epochDuration: Number(epochDuration) }, this.options);
|
|
25
|
+
this.epochMonitor.start(this);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async stop() {
|
|
29
|
+
await this.epochMonitor?.stop();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
|
|
33
|
+
const lastCheckpoint = await settleEpochOutbox({
|
|
34
|
+
rollupCheatCodes: this.rollupCheatCodes,
|
|
35
|
+
l2BlockSource: this.l2BlockSource,
|
|
36
|
+
epoch,
|
|
37
|
+
log: this.log,
|
|
38
|
+
});
|
|
39
|
+
if (lastCheckpoint !== undefined) {
|
|
40
|
+
await this.rollupCheatCodes.markAsProven(lastCheckpoint);
|
|
41
|
+
} else {
|
|
42
|
+
this.log.warn(`No checkpoint found for epoch ${epoch}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/testing/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { AnvilTestWatcher } from './anvil_test_watcher.js';
|
|
2
1
|
export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
3
2
|
export { CheatCodes } from './cheat_codes.js';
|
|
3
|
+
export { EpochTestSettler } from './epoch_test_settler.js';
|
|
4
|
+
export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
2
|
+
import { buildAllowedElement } from '@aztec/p2p/msg_validators';
|
|
3
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
4
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the allowlist entries needed for FPC-based fee payments, keyed by the contract class of
|
|
9
|
+
* the `artifact` actually deployed as the fee token (defaults to canonical Token). The setup-phase
|
|
10
|
+
* validator matches these entries by class id, so a test deploying the codegen'd TestToken as its
|
|
11
|
+
* fee vehicle must pass `TestTokenContract.artifact` here -- otherwise the FPC fee calls are matched
|
|
12
|
+
* against the wrong class and rejected. Test-only: FPC fee payment with custom tokens won't work on
|
|
13
|
+
* mainnet alpha.
|
|
14
|
+
*/
|
|
15
|
+
export async function getTokenAllowedSetupFunctions(
|
|
16
|
+
artifact: ContractArtifact = TokenContractArtifact,
|
|
17
|
+
): Promise<AllowedElement[]> {
|
|
18
|
+
const tokenClassId = (await getContractClassFromArtifact(artifact)).id;
|
|
19
|
+
const target = { classId: tokenClassId };
|
|
20
|
+
return Promise.all([
|
|
21
|
+
// needed for private transfers via FPC (transfer_to_public enqueues this)
|
|
22
|
+
buildAllowedElement(artifact, target, '_increase_public_balance', { onlySelf: true }),
|
|
23
|
+
// needed for public transfers via FPC (fee_entrypoint_public enqueues this)
|
|
24
|
+
buildAllowedElement(artifact, target, 'transfer_in_public'),
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type ArchiverConfig } from '@aztec/archiver';
|
|
2
|
-
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
3
|
-
import { type DataStoreConfig } from '@aztec/kv-store/config';
|
|
4
|
-
export type { ArchiverConfig, DataStoreConfig };
|
|
5
|
-
/** Starts a standalone archiver. */
|
|
6
|
-
export declare function startArchiver(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers): Promise<{
|
|
7
|
-
config: ArchiverConfig & DataStoreConfig;
|
|
8
|
-
}>;
|
|
9
|
-
//# sourceMappingURL=start_archiver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start_archiver.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAIpB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAOlF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAEhD,oCAAoC;AACpC,wBAAsB,aAAa,CACjC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC;IAAE,MAAM,EAAE,cAAc,GAAG,eAAe,CAAA;CAAE,CAAC,CAmCvD"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Archiver, KVArchiverDataStore, archiverConfigMappings, getArchiverConfigFromEnv } from '@aztec/archiver';
|
|
2
|
-
import { createLogger } from '@aztec/aztec.js/log';
|
|
3
|
-
import { blobSinkConfigMapping, createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
4
|
-
import { getL1Config } from '@aztec/cli/config';
|
|
5
|
-
import { dataConfigMappings } from '@aztec/kv-store/config';
|
|
6
|
-
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
7
|
-
import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
8
|
-
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
9
|
-
import { extractRelevantOptions } from '../util.js';
|
|
10
|
-
/** Starts a standalone archiver. */ export async function startArchiver(options, signalHandlers, services) {
|
|
11
|
-
const envConfig = getArchiverConfigFromEnv();
|
|
12
|
-
const cliOptions = extractRelevantOptions(options, {
|
|
13
|
-
...archiverConfigMappings,
|
|
14
|
-
...dataConfigMappings,
|
|
15
|
-
...blobSinkConfigMapping
|
|
16
|
-
}, 'archiver');
|
|
17
|
-
let archiverConfig = {
|
|
18
|
-
...envConfig,
|
|
19
|
-
...cliOptions
|
|
20
|
-
};
|
|
21
|
-
archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
|
|
22
|
-
if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
|
|
23
|
-
throw new Error('L1 registry address is required to start an Archiver');
|
|
24
|
-
}
|
|
25
|
-
const { addresses, config: l1Config } = await getL1Config(archiverConfig.l1Contracts.registryAddress, archiverConfig.l1RpcUrls, archiverConfig.l1ChainId);
|
|
26
|
-
archiverConfig.l1Contracts = addresses;
|
|
27
|
-
archiverConfig = {
|
|
28
|
-
...archiverConfig,
|
|
29
|
-
...l1Config
|
|
30
|
-
};
|
|
31
|
-
const storeLog = createLogger('archiver:lmdb');
|
|
32
|
-
const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
|
|
33
|
-
const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
|
|
34
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
35
|
-
const blobSinkClient = createBlobSinkClient(archiverConfig, {
|
|
36
|
-
logger: createLogger('archiver:blob-sink:client')
|
|
37
|
-
});
|
|
38
|
-
const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, {
|
|
39
|
-
telemetry,
|
|
40
|
-
blobSinkClient
|
|
41
|
-
}, true);
|
|
42
|
-
services.archiver = [
|
|
43
|
-
archiver,
|
|
44
|
-
ArchiverApiSchema
|
|
45
|
-
];
|
|
46
|
-
signalHandlers.push(archiver.stop);
|
|
47
|
-
return {
|
|
48
|
-
config: archiverConfig
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start_blob_sink.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_blob_sink.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,wBAAsB,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,iBA4CxG"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { blobSinkConfigMappings, createBlobSinkServer, getBlobSinkConfigFromEnv } from '@aztec/blob-sink/server';
|
|
2
|
-
import { getL1Config } from '@aztec/cli/config';
|
|
3
|
-
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
-
import { extractRelevantOptions } from '../util.js';
|
|
5
|
-
export async function startBlobSink(options, signalHandlers, userLog) {
|
|
6
|
-
if (options.prover || options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
|
|
7
|
-
userLog(`Starting a blob sink with --node, --sequencer, --pxe, --p2p-bootstrap, --prover or --txe is not supported.`);
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
let blobSinkConfig = {
|
|
11
|
-
...getBlobSinkConfigFromEnv(),
|
|
12
|
-
...extractRelevantOptions(options, blobSinkConfigMappings, 'blobSink')
|
|
13
|
-
};
|
|
14
|
-
if (!blobSinkConfig.l1Contracts?.registryAddress || blobSinkConfig.l1Contracts.registryAddress.isZero()) {
|
|
15
|
-
throw new Error('REGISTRY_CONTRACT_ADDRESS not set');
|
|
16
|
-
}
|
|
17
|
-
if (!blobSinkConfig.l1RpcUrls || blobSinkConfig.l1RpcUrls.length === 0) {
|
|
18
|
-
throw new Error('ETHEREUM_HOSTS not set');
|
|
19
|
-
}
|
|
20
|
-
if (typeof blobSinkConfig.l1ChainId !== 'number') {
|
|
21
|
-
throw new Error('L1_CHAIN_ID');
|
|
22
|
-
}
|
|
23
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
24
|
-
const { config: chainConfig, addresses } = await getL1Config(blobSinkConfig.l1Contracts.registryAddress, blobSinkConfig.l1RpcUrls, blobSinkConfig.l1ChainId, blobSinkConfig.rollupVersion);
|
|
25
|
-
blobSinkConfig = {
|
|
26
|
-
...blobSinkConfig,
|
|
27
|
-
l1Contracts: addresses,
|
|
28
|
-
...chainConfig
|
|
29
|
-
};
|
|
30
|
-
const blobSink = await createBlobSinkServer(blobSinkConfig, telemetry);
|
|
31
|
-
signalHandlers.push(blobSink.stop.bind(blobSink));
|
|
32
|
-
await blobSink.start();
|
|
33
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
2
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
import { type ProverNodeConfig } from '@aztec/prover-node';
|
|
4
|
-
export declare function startProverNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, userLog: LogFn): Promise<{
|
|
5
|
-
config: ProverNodeConfig;
|
|
6
|
-
}>;
|
|
7
|
-
//# sourceMappingURL=start_prover_node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start_prover_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_node.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,KAAK,gBAAgB,EAItB,MAAM,oBAAoB,CAAC;AAS5B,wBAAsB,eAAe,CACnC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC,CA+FvC"}
|