@aztec/aztec 0.0.0-test.1 → 0.0.1-commit.1142ef1
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 +23 -12
- 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 +40 -40
- package/dest/cli/aztec_start_options.d.ts +5 -3
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +143 -224
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +12 -7
- 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 +20 -12
- 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 +25 -14
- package/dest/cli/cmds/start_node.d.ts +2 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +68 -81
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +9 -4
- 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 +33 -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 +10 -4
- package/dest/cli/cmds/start_prover_node.d.ts +1 -1
- package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_node.js +44 -46
- 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 +3 -0
- package/dest/cli/preload_crs.d.ts.map +1 -0
- package/dest/cli/preload_crs.js +6 -0
- package/dest/cli/release_version.d.ts +2 -0
- package/dest/cli/release_version.d.ts.map +1 -0
- package/dest/cli/release_version.js +14 -0
- package/dest/cli/util.d.ts +38 -7
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +198 -28
- 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 +31 -18
- package/dest/examples/util.d.ts +5 -6
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +5 -6
- 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 +20 -22
- 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 +72 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/local-network/local-network.js +195 -0
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/local-network/sponsored_fpc.js +18 -0
- package/dest/mnemonic.d.ts +1 -1
- package/dest/splash.d.ts +1 -1
- package/dest/testing/anvil_test_watcher.d.ts +34 -0
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
- package/dest/testing/anvil_test_watcher.js +144 -0
- package/dest/testing/cheat_codes.d.ts +41 -0
- package/dest/testing/cheat_codes.d.ts.map +1 -0
- package/dest/testing/cheat_codes.js +62 -0
- package/dest/testing/epoch_test_settler.d.ts +17 -0
- package/dest/testing/epoch_test_settler.d.ts.map +1 -0
- package/dest/testing/epoch_test_settler.js +52 -0
- package/dest/testing/index.d.ts +5 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +4 -0
- package/package.json +55 -45
- package/scripts/aztec.sh +63 -0
- package/scripts/compile.sh +44 -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 +28 -12
- package/src/cli/aztec_start_action.ts +36 -38
- package/src/cli/aztec_start_options.ts +159 -222
- package/src/cli/cli.ts +20 -11
- package/src/cli/cmds/migrate_ha_db.ts +43 -0
- package/src/cli/cmds/start_archiver.ts +21 -15
- package/src/cli/cmds/start_bot.ts +36 -13
- package/src/cli/cmds/start_node.ts +91 -86
- package/src/cli/cmds/start_p2p_bootstrap.ts +12 -4
- package/src/cli/cmds/start_prover_agent.ts +24 -12
- package/src/cli/cmds/start_prover_broker.ts +24 -4
- package/src/cli/cmds/start_prover_node.ts +54 -51
- package/src/cli/preload_crs.ts +7 -0
- package/src/cli/release_version.ts +21 -0
- package/src/cli/util.ts +208 -34
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +23 -19
- package/src/examples/util.ts +6 -8
- package/src/index.ts +5 -6
- package/src/{sandbox → local-network}/banana_fpc.ts +21 -26
- package/src/local-network/index.ts +7 -0
- package/src/local-network/local-network.ts +238 -0
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/testing/anvil_test_watcher.ts +166 -0
- package/src/testing/cheat_codes.ts +79 -0
- package/src/testing/epoch_test_settler.ts +59 -0
- package/src/testing/index.ts +4 -0
- package/dest/cli/chain_l2_config.d.ts +0 -19
- package/dest/cli/chain_l2_config.d.ts.map +0 -1
- package/dest/cli/chain_l2_config.js +0 -56
- 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 -17
- package/dest/cli/cmds/start_faucet.d.ts +0 -4
- package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
- package/dest/cli/cmds/start_faucet.js +0 -20
- 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 -95
- package/dest/cli/get_l1_config.d.ts +0 -7
- package/dest/cli/get_l1_config.d.ts.map +0 -1
- package/dest/cli/get_l1_config.js +0 -13
- 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 -5
- package/dest/sandbox/index.d.ts.map +0 -1
- package/dest/sandbox/index.js +0 -4
- package/dest/sandbox/sandbox.d.ts +0 -76
- package/dest/sandbox/sandbox.d.ts.map +0 -1
- package/dest/sandbox/sandbox.js +0 -181
- package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
- package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
- package/dest/sandbox/sponsored_fpc.d.ts +0 -6
- package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fpc.js +0 -26
- package/src/cli/chain_l2_config.ts +0 -74
- package/src/cli/cmds/start_blob_sink.ts +0 -31
- package/src/cli/cmds/start_faucet.ts +0 -34
- package/src/cli/cmds/start_pxe.ts +0 -129
- package/src/cli/get_l1_config.ts +0 -18
- package/src/sandbox/index.ts +0 -5
- package/src/sandbox/sandbox.ts +0 -229
- package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
- package/src/sandbox/sponsored_fpc.ts +0 -38
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
4
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import {
|
|
6
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
7
7
|
const BANANA_COIN_SALT = new Fr(0);
|
|
8
8
|
const bananaCoinArgs = {
|
|
9
9
|
name: 'BC',
|
|
@@ -16,7 +16,7 @@ function getBananaAdmin(initialAccounts) {
|
|
|
16
16
|
}
|
|
17
17
|
async function getBananaCoinInstance(initialAccounts) {
|
|
18
18
|
const admin = getBananaAdmin(initialAccounts);
|
|
19
|
-
return await
|
|
19
|
+
return await getContractInstanceFromInstantiationParams(TokenContract.artifact, {
|
|
20
20
|
constructorArgs: [
|
|
21
21
|
admin,
|
|
22
22
|
bananaCoinArgs.name,
|
|
@@ -32,7 +32,7 @@ export async function getBananaCoinAddress(initialAccounts) {
|
|
|
32
32
|
async function getBananaFPCInstance(initialAccounts) {
|
|
33
33
|
const bananaCoin = await getBananaCoinAddress(initialAccounts);
|
|
34
34
|
const admin = getBananaAdmin(initialAccounts);
|
|
35
|
-
return await
|
|
35
|
+
return await getContractInstanceFromInstantiationParams(FPCContract.artifact, {
|
|
36
36
|
constructorArgs: [
|
|
37
37
|
bananaCoin,
|
|
38
38
|
admin
|
|
@@ -43,15 +43,17 @@ async function getBananaFPCInstance(initialAccounts) {
|
|
|
43
43
|
export async function getBananaFPCAddress(initialAccounts) {
|
|
44
44
|
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
45
45
|
}
|
|
46
|
-
export async function setupBananaFPC(initialAccounts,
|
|
46
|
+
export async function setupBananaFPC(initialAccounts, wallet, log) {
|
|
47
47
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
48
48
|
const admin = getBananaAdmin(initialAccounts);
|
|
49
49
|
const [bananaCoin, fpc] = await Promise.all([
|
|
50
|
-
TokenContract.deploy(
|
|
50
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
|
|
51
|
+
from: admin,
|
|
51
52
|
contractAddressSalt: BANANA_COIN_SALT,
|
|
52
53
|
universalDeploy: true
|
|
53
54
|
}).deployed(),
|
|
54
|
-
FPCContract.deploy(
|
|
55
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
|
|
56
|
+
from: admin,
|
|
55
57
|
contractAddressSalt: BANANA_FPC_SALT,
|
|
56
58
|
universalDeploy: true
|
|
57
59
|
}).deployed()
|
|
@@ -59,21 +61,17 @@ export async function setupBananaFPC(initialAccounts, deployer, log) {
|
|
|
59
61
|
log(`BananaCoin: ${bananaCoin.address}`);
|
|
60
62
|
log(`FPC: ${fpc.address}`);
|
|
61
63
|
}
|
|
62
|
-
export async function
|
|
63
|
-
const initialAccounts = await
|
|
64
|
-
const bananaCoin = await
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
return bananaCoin;
|
|
64
|
+
export async function registerDeployedBananaCoinInWalletAndGetAddress(wallet) {
|
|
65
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
66
|
+
const bananaCoin = await getBananaCoinInstance(initialAccounts);
|
|
67
|
+
// The following is no-op if the contract is already registered
|
|
68
|
+
await wallet.registerContract(bananaCoin, TokenContract.artifact);
|
|
69
|
+
return bananaCoin.address;
|
|
70
70
|
}
|
|
71
|
-
export async function
|
|
72
|
-
const initialAccounts = await
|
|
71
|
+
export async function registerDeployedBananaFPCInWalletAndGetAddress(wallet) {
|
|
72
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
73
73
|
const fpc = await getBananaFPCInstance(initialAccounts);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throw new Error('BananaFPC not deployed.');
|
|
77
|
-
}
|
|
74
|
+
// The following is no-op if the contract is already registered
|
|
75
|
+
await wallet.registerContract(fpc, FPCContract.artifact);
|
|
78
76
|
return fpc.address;
|
|
79
77
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './local-network.js';
|
|
2
|
+
export { registerDeployedBananaCoinInWalletAndGetAddress, registerDeployedBananaFPCInWalletAndGetAddress, } from './banana_fpc.js';
|
|
3
|
+
export { registerDeployedSponsoredFPCInWalletAndGetAddress } from './sponsored_fpc.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sb2NhbC1uZXR3b3JrL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsb0JBQW9CLENBQUM7QUFFbkMsT0FBTyxFQUNMLCtDQUErQyxFQUMvQyw4Q0FBOEMsR0FDL0MsTUFBTSxpQkFBaUIsQ0FBQztBQUN6QixPQUFPLEVBQUUsaURBQWlELEVBQUUsTUFBTSxvQkFBb0IsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/local-network/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,+CAA+C,EAC/C,8CAA8C,GAC/C,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iDAAiD,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
import { AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
+
import { type AztecNodeConfig } from '@aztec/aztec-node/config';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import { type BlobClientInterface } from '@aztec/blob-client/client';
|
|
6
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
8
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
|
+
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
10
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
11
|
+
import { type Hex } from 'viem';
|
|
12
|
+
/**
|
|
13
|
+
* Function to deploy our L1 contracts to the local network L1
|
|
14
|
+
* @param aztecNodeConfig - The Aztec Node Config
|
|
15
|
+
* @param hdAccount - Account for publishing L1 contracts
|
|
16
|
+
*/
|
|
17
|
+
export declare function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, privateKey: Hex, opts?: {
|
|
18
|
+
assumeProvenThroughBlockNumber?: number;
|
|
19
|
+
genesisArchiveRoot?: Fr;
|
|
20
|
+
feeJuicePortalInitialBalance?: bigint;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
coinIssuerAddress: EthAddress;
|
|
23
|
+
feeJuiceAddress: EthAddress;
|
|
24
|
+
feeJuicePortalAddress: EthAddress;
|
|
25
|
+
governanceAddress: EthAddress;
|
|
26
|
+
governanceProposerAddress: EthAddress;
|
|
27
|
+
inboxAddress: EthAddress;
|
|
28
|
+
outboxAddress: EthAddress;
|
|
29
|
+
registryAddress: EthAddress;
|
|
30
|
+
rewardDistributorAddress: EthAddress;
|
|
31
|
+
rollupAddress: EthAddress;
|
|
32
|
+
stakingAssetAddress: EthAddress;
|
|
33
|
+
} & {
|
|
34
|
+
slashFactoryAddress?: EthAddress | undefined;
|
|
35
|
+
feeAssetHandlerAddress?: EthAddress | undefined;
|
|
36
|
+
stakingAssetHandlerAddress?: EthAddress | undefined;
|
|
37
|
+
zkPassportVerifierAddress?: EthAddress | undefined;
|
|
38
|
+
gseAddress?: EthAddress | undefined;
|
|
39
|
+
dateGatedRelayerAddress?: EthAddress | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
rollupAddress: EthAddress;
|
|
42
|
+
} & {
|
|
43
|
+
rollupAddress: EthAddress;
|
|
44
|
+
}>;
|
|
45
|
+
/** Local network settings. */
|
|
46
|
+
export type LocalNetworkConfig = AztecNodeConfig & {
|
|
47
|
+
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
48
|
+
l1Mnemonic: string;
|
|
49
|
+
/** Whether to deploy test accounts on local network start.*/
|
|
50
|
+
testAccounts: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
54
|
+
* Does not start any HTTP services nor populate any initial accounts.
|
|
55
|
+
* @param config - Optional local network settings.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createLocalNetwork(config: Partial<LocalNetworkConfig> | undefined, userLog: LogFn): Promise<{
|
|
58
|
+
node: AztecNodeService;
|
|
59
|
+
stop: () => Promise<void>;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Create and start a new Aztec RPC HTTP Server
|
|
63
|
+
* @param config - Optional Aztec node settings.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?: {
|
|
66
|
+
telemetry?: TelemetryClient;
|
|
67
|
+
blobClient?: BlobClientInterface;
|
|
68
|
+
dateProvider?: DateProvider;
|
|
69
|
+
}, options?: {
|
|
70
|
+
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
71
|
+
}): Promise<AztecNodeService>;
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtbmV0d29yay5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvY2FsLW5ldHdvcmsvbG9jYWwtbmV0d29yay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDckQsT0FBTyxFQU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UAAU,EAAE,GAAG,EACf,IAAI,GAAE;IACJ,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,kBAAkB,CAAC,EAAE,EAAE,CAAC;IACxB,4BAA4B,CAAC,EAAE,MAAM,CAAC;CAClC;;;;;;;;;;;;;;;;;;;;;;;GAoBP;AAED,8BAA8B;AAC9B,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,yCAAkC,EAAE,OAAO,EAAE,KAAK;;;GA8HhG;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC;IAAC,YAAY,CAAC,EAAE,YAAY,CAAA;CAAO,EACzG,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAW7D"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
|
+
import { AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
+
import { getConfigEnvVars } from '@aztec/aztec-node/config';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
7
|
+
import { createBlobClient } from '@aztec/blob-client/client';
|
|
8
|
+
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
10
|
+
import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
11
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
12
|
+
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
13
|
+
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
14
|
+
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
15
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
16
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
|
+
import { 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 { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
21
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
22
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
23
|
+
import { createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
24
|
+
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
25
|
+
import { foundry } from 'viem/chains';
|
|
26
|
+
import { createAccountLogs } from '../cli/util.js';
|
|
27
|
+
import { DefaultMnemonic } from '../mnemonic.js';
|
|
28
|
+
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
29
|
+
import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
30
|
+
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
31
|
+
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
32
|
+
const logger = createLogger('local-network');
|
|
33
|
+
const localAnvil = foundry;
|
|
34
|
+
/**
|
|
35
|
+
* Function to deploy our L1 contracts to the local network L1
|
|
36
|
+
* @param aztecNodeConfig - The Aztec Node Config
|
|
37
|
+
* @param hdAccount - Account for publishing L1 contracts
|
|
38
|
+
*/ export async function deployContractsToL1(aztecNodeConfig, privateKey, opts = {}) {
|
|
39
|
+
await waitForPublicClient(aztecNodeConfig);
|
|
40
|
+
const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
|
|
41
|
+
...getL1ContractsConfigEnvVars(),
|
|
42
|
+
...aztecNodeConfig,
|
|
43
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
44
|
+
protocolContractsHash,
|
|
45
|
+
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
46
|
+
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
47
|
+
aztecTargetCommitteeSize: 0,
|
|
48
|
+
slasherFlavor: 'none',
|
|
49
|
+
realVerifier: false
|
|
50
|
+
});
|
|
51
|
+
aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
|
|
52
|
+
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
53
|
+
return aztecNodeConfig.l1Contracts;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
57
|
+
* Does not start any HTTP services nor populate any initial accounts.
|
|
58
|
+
* @param config - Optional local network settings.
|
|
59
|
+
*/ export async function createLocalNetwork(config = {}, userLog) {
|
|
60
|
+
// local network is meant for test envs. We should only need one l1RpcUrl
|
|
61
|
+
const l1RpcUrl = config.l1RpcUrls?.[0];
|
|
62
|
+
if (!l1RpcUrl) {
|
|
63
|
+
throw new Error('An L1 RPC URL is required');
|
|
64
|
+
}
|
|
65
|
+
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
66
|
+
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
67
|
+
}
|
|
68
|
+
const aztecNodeConfig = {
|
|
69
|
+
...getConfigEnvVars(),
|
|
70
|
+
...config
|
|
71
|
+
};
|
|
72
|
+
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
73
|
+
if (aztecNodeConfig.publisherPrivateKeys == undefined || !aztecNodeConfig.publisherPrivateKeys.length || aztecNodeConfig.publisherPrivateKeys[0].getValue() === NULL_KEY) {
|
|
74
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
75
|
+
aztecNodeConfig.publisherPrivateKeys = [
|
|
76
|
+
new SecretValue(`0x${Buffer.from(privKey).toString('hex')}`)
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
|
|
80
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
81
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([
|
|
82
|
+
`0x${Buffer.from(privKey).toString('hex')}`
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
aztecNodeConfig.coinbase = EthAddress.fromString(privateKeyToAddress(aztecNodeConfig.validatorPrivateKeys.getValue()[0]));
|
|
86
|
+
const initialAccounts = await (async ()=>{
|
|
87
|
+
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
88
|
+
if (aztecNodeConfig.p2pEnabled) {
|
|
89
|
+
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
90
|
+
} else {
|
|
91
|
+
userLog(`Setting up test accounts`);
|
|
92
|
+
return await getInitialTestAccountsData();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
})();
|
|
97
|
+
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
98
|
+
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
99
|
+
const fundedAddresses = initialAccounts.length ? [
|
|
100
|
+
...initialAccounts.map((a)=>a.address),
|
|
101
|
+
bananaFPC,
|
|
102
|
+
sponsoredFPC
|
|
103
|
+
] : [];
|
|
104
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
105
|
+
const dateProvider = new TestDateProvider();
|
|
106
|
+
let cheatcodes;
|
|
107
|
+
let rollupAddress;
|
|
108
|
+
let watcher;
|
|
109
|
+
if (!aztecNodeConfig.p2pEnabled) {
|
|
110
|
+
({ rollupAddress } = await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
|
|
111
|
+
assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
|
|
112
|
+
genesisArchiveRoot,
|
|
113
|
+
feeJuicePortalInitialBalance: fundingNeeded
|
|
114
|
+
}));
|
|
115
|
+
const chain = aztecNodeConfig.l1RpcUrls.length > 0 ? createEthereumChain([
|
|
116
|
+
l1RpcUrl
|
|
117
|
+
], aztecNodeConfig.l1ChainId) : {
|
|
118
|
+
chainInfo: localAnvil
|
|
119
|
+
};
|
|
120
|
+
const publicClient = createPublicClient({
|
|
121
|
+
chain: chain.chainInfo,
|
|
122
|
+
transport: fallback([
|
|
123
|
+
httpViemTransport(l1RpcUrl)
|
|
124
|
+
])
|
|
125
|
+
});
|
|
126
|
+
cheatcodes = new EthCheatCodes([
|
|
127
|
+
l1RpcUrl
|
|
128
|
+
], dateProvider);
|
|
129
|
+
watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
|
|
130
|
+
watcher.setisLocalNetwork(true);
|
|
131
|
+
watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
|
|
132
|
+
await watcher.start();
|
|
133
|
+
}
|
|
134
|
+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
135
|
+
// Create a local blob client client inside the local network, no http connectivity
|
|
136
|
+
const blobClient = createBlobClient();
|
|
137
|
+
const node = await createAztecNode(aztecNodeConfig, {
|
|
138
|
+
telemetry,
|
|
139
|
+
blobClient,
|
|
140
|
+
dateProvider
|
|
141
|
+
}, {
|
|
142
|
+
prefilledPublicData
|
|
143
|
+
});
|
|
144
|
+
let epochTestSettler;
|
|
145
|
+
if (!aztecNodeConfig.p2pEnabled) {
|
|
146
|
+
epochTestSettler = new EpochTestSettler(cheatcodes, rollupAddress, node.getBlockSource(), {
|
|
147
|
+
pollingIntervalMs: 200
|
|
148
|
+
});
|
|
149
|
+
await epochTestSettler.start();
|
|
150
|
+
}
|
|
151
|
+
if (initialAccounts.length) {
|
|
152
|
+
const PXEConfig = {
|
|
153
|
+
proverEnabled: aztecNodeConfig.realProofs
|
|
154
|
+
};
|
|
155
|
+
const wallet = await TestWallet.create(node, PXEConfig);
|
|
156
|
+
userLog('Setting up funded test accounts...');
|
|
157
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
|
|
158
|
+
const accountsWithSecrets = accountManagers.map((manager, i)=>({
|
|
159
|
+
account: manager,
|
|
160
|
+
secretKey: initialAccounts[i].secret
|
|
161
|
+
}));
|
|
162
|
+
const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
|
|
163
|
+
userLog(accLogs.join(''));
|
|
164
|
+
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
165
|
+
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
166
|
+
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
167
|
+
await wallet.stop();
|
|
168
|
+
}
|
|
169
|
+
const stop = async ()=>{
|
|
170
|
+
await node.stop();
|
|
171
|
+
await watcher?.stop();
|
|
172
|
+
await epochTestSettler?.stop();
|
|
173
|
+
};
|
|
174
|
+
return {
|
|
175
|
+
node,
|
|
176
|
+
stop
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Create and start a new Aztec RPC HTTP Server
|
|
181
|
+
* @param config - Optional Aztec node settings.
|
|
182
|
+
*/ export async function createAztecNode(config = {}, deps = {}, options = {}) {
|
|
183
|
+
// TODO(#12272): will clean this up. This is criminal.
|
|
184
|
+
const { l1Contracts, ...rest } = getConfigEnvVars();
|
|
185
|
+
const aztecNodeConfig = {
|
|
186
|
+
...rest,
|
|
187
|
+
...config,
|
|
188
|
+
l1Contracts: {
|
|
189
|
+
...l1Contracts,
|
|
190
|
+
...config.l1Contracts
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
|
|
194
|
+
return node;
|
|
195
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
|
+
export declare function getSponsoredFPCAddress(): Promise<AztecAddress>;
|
|
4
|
+
export declare function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet): Promise<AztecAddress>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3BvbnNvcmVkX2ZwYy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvY2FsLW5ldHdvcmsvc3BvbnNvcmVkX2ZwYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQU05RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQVVyRCx3QkFBc0Isc0JBQXNCLElBQUksT0FBTyxDQUFDLFlBQVksQ0FBQyxDQUVwRTtBQUVELHdCQUFzQixpREFBaUQsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FLN0cifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sponsored_fpc.d.ts","sourceRoot":"","sources":["../../src/local-network/sponsored_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAUrD,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,YAAY,CAAC,CAEpE;AAED,wBAAsB,iDAAiD,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAK7G"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
4
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
5
|
+
async function getSponsoredFPCInstance() {
|
|
6
|
+
return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
7
|
+
salt: new Fr(SPONSORED_FPC_SALT)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export async function getSponsoredFPCAddress() {
|
|
11
|
+
return (await getSponsoredFPCInstance()).address;
|
|
12
|
+
}
|
|
13
|
+
export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet) {
|
|
14
|
+
const fpc = await getSponsoredFPCInstance();
|
|
15
|
+
// The following is no-op if the contract is already registered
|
|
16
|
+
await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
|
|
17
|
+
return fpc.address;
|
|
18
|
+
}
|
package/dest/mnemonic.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const DefaultMnemonic = "test test test test test test test test test test test junk";
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW5lbW9uaWMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9tbmVtb25pYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxlQUFPLE1BQU0sZUFBZSxnRUFBZ0UsQ0FBQyJ9
|
package/dest/splash.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const splash: string;
|
|
2
2
|
export declare const github = "https://github.com/AztecProtocol";
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3BsYXNoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvc3BsYXNoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGVBQU8sTUFBTSxNQUFNLEVBQUUsTUFPa0IsQ0FBQztBQUV4QyxlQUFPLE1BQU0sTUFBTSxxQ0FBcUMsQ0FBQyJ9
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import type { ViemClient } from '@aztec/ethereum/types';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a watcher for a rollup contract.
|
|
7
|
+
*
|
|
8
|
+
* It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
|
|
9
|
+
* it will periodically check if the current slot have already been filled, e.g., there was an L2
|
|
10
|
+
* block within the slot. And if so, it will time travel into the next slot.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AnvilTestWatcher {
|
|
13
|
+
private cheatcodes;
|
|
14
|
+
private dateProvider?;
|
|
15
|
+
private isLocalNetwork;
|
|
16
|
+
private rollup;
|
|
17
|
+
private rollupCheatCodes;
|
|
18
|
+
private l2SlotDuration;
|
|
19
|
+
private filledRunningPromise?;
|
|
20
|
+
private syncDateProviderPromise?;
|
|
21
|
+
private markingAsProvenRunningPromise?;
|
|
22
|
+
private logger;
|
|
23
|
+
private isMarkingAsProven;
|
|
24
|
+
constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l1Client: ViemClient, dateProvider?: TestDateProvider | undefined);
|
|
25
|
+
setIsMarkingAsProven(isMarkingAsProven: boolean): void;
|
|
26
|
+
setisLocalNetwork(isLocalNetwork: boolean): void;
|
|
27
|
+
start(): Promise<void>;
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
trigger(): Promise<void>;
|
|
30
|
+
markAsProven(): Promise<void>;
|
|
31
|
+
syncDateProviderToL1IfBehind(): Promise<void>;
|
|
32
|
+
warpTimeIfNeeded(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW52aWxfdGVzdF93YXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9hbnZpbF90ZXN0X3dhdGNoZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBb0IsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUV4RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUdoRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBS2hFOzs7Ozs7R0FNRztBQUNILHFCQUFhLGdCQUFnQjtJQWdCekIsT0FBTyxDQUFDLFVBQVU7SUFHbEIsT0FBTyxDQUFDLFlBQVksQ0FBQztJQWxCdkIsT0FBTyxDQUFDLGNBQWMsQ0FBa0I7SUFFeEMsT0FBTyxDQUFDLE1BQU0sQ0FBc0Q7SUFDcEUsT0FBTyxDQUFDLGdCQUFnQixDQUFtQjtJQUMzQyxPQUFPLENBQUMsY0FBYyxDQUFVO0lBRWhDLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQUFpQjtJQUM5QyxPQUFPLENBQUMsdUJBQXVCLENBQUMsQ0FBaUI7SUFDakQsT0FBT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;IACjD,OAAO,CAAC,6BAA6B,CAAC,CAAiB;IAEvD,OAAO,CAAC,MAAM,CAAiD;IAE/D,OAAO,CAAC,iBAAiB,CAAQ;IAEjC,YACU,UAAU,EAAE,aAAa,EACjC,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,UAAU,EACZ,YAAY,CAAC,8BAAkB,EAaxC;IAED,oBAAoB,CAAC,iBAAiB,EAAE,OAAO,QAG9C;IAED,iBAAiB,CAAC,cAAc,EAAE,OAAO,QAExC;IAEK,KAAK,kBAyBV;IAEK,IAAI,kBAIT;IAEK,OAAO,kBAIZ;IAEK,YAAY,kBAKjB;IAEK,4BAA4B,kBAejC;IAEK,gBAAgB,kBAwCrB;CACF"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
5
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
|
+
import { getAddress, getContract } from 'viem';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a watcher for a rollup contract.
|
|
9
|
+
*
|
|
10
|
+
* It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
|
|
11
|
+
* it will periodically check if the current slot have already been filled, e.g., there was an L2
|
|
12
|
+
* block within the slot. And if so, it will time travel into the next slot.
|
|
13
|
+
*/ export class AnvilTestWatcher {
|
|
14
|
+
cheatcodes;
|
|
15
|
+
dateProvider;
|
|
16
|
+
isLocalNetwork;
|
|
17
|
+
rollup;
|
|
18
|
+
rollupCheatCodes;
|
|
19
|
+
l2SlotDuration;
|
|
20
|
+
filledRunningPromise;
|
|
21
|
+
syncDateProviderPromise;
|
|
22
|
+
markingAsProvenRunningPromise;
|
|
23
|
+
logger;
|
|
24
|
+
isMarkingAsProven;
|
|
25
|
+
constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
|
|
26
|
+
this.cheatcodes = cheatcodes;
|
|
27
|
+
this.dateProvider = dateProvider;
|
|
28
|
+
this.isLocalNetwork = false;
|
|
29
|
+
this.logger = createLogger(`aztecjs:utils:watcher`);
|
|
30
|
+
this.isMarkingAsProven = true;
|
|
31
|
+
this.rollup = getContract({
|
|
32
|
+
address: getAddress(rollupAddress.toString()),
|
|
33
|
+
abi: RollupAbi,
|
|
34
|
+
client: l1Client
|
|
35
|
+
});
|
|
36
|
+
this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
|
|
37
|
+
rollupAddress
|
|
38
|
+
});
|
|
39
|
+
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
40
|
+
}
|
|
41
|
+
setIsMarkingAsProven(isMarkingAsProven) {
|
|
42
|
+
this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
|
|
43
|
+
this.isMarkingAsProven = isMarkingAsProven;
|
|
44
|
+
}
|
|
45
|
+
setisLocalNetwork(isLocalNetwork) {
|
|
46
|
+
this.isLocalNetwork = isLocalNetwork;
|
|
47
|
+
}
|
|
48
|
+
async start() {
|
|
49
|
+
if (this.filledRunningPromise) {
|
|
50
|
+
throw new Error('Watcher already watching for filled slot');
|
|
51
|
+
}
|
|
52
|
+
const config = await this.rollupCheatCodes.getConfig();
|
|
53
|
+
this.l2SlotDuration = config.slotDuration;
|
|
54
|
+
// If auto mining is not supported (e.g., we are on a real network), then we
|
|
55
|
+
// will simple do nothing. But if on an anvil or the like, this make sure that
|
|
56
|
+
// the local network and tests don't break because time is frozen and we never get to
|
|
57
|
+
// the next slot.
|
|
58
|
+
const isAutoMining = await this.cheatcodes.isAutoMining();
|
|
59
|
+
if (isAutoMining) {
|
|
60
|
+
this.filledRunningPromise = new RunningPromise(()=>this.warpTimeIfNeeded(), this.logger, 200);
|
|
61
|
+
this.filledRunningPromise.start();
|
|
62
|
+
this.syncDateProviderPromise = new RunningPromise(()=>this.syncDateProviderToL1IfBehind(), this.logger, 200);
|
|
63
|
+
this.syncDateProviderPromise.start();
|
|
64
|
+
this.markingAsProvenRunningPromise = new RunningPromise(()=>this.markAsProven(), this.logger, 200);
|
|
65
|
+
this.markingAsProvenRunningPromise.start();
|
|
66
|
+
this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
|
|
67
|
+
} else {
|
|
68
|
+
this.logger.info(`Watcher not started because not auto mining`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async stop() {
|
|
72
|
+
await this.filledRunningPromise?.stop();
|
|
73
|
+
await this.syncDateProviderPromise?.stop();
|
|
74
|
+
await this.markingAsProvenRunningPromise?.stop();
|
|
75
|
+
}
|
|
76
|
+
async trigger() {
|
|
77
|
+
await this.filledRunningPromise?.trigger();
|
|
78
|
+
await this.syncDateProviderPromise?.trigger();
|
|
79
|
+
await this.markingAsProvenRunningPromise?.trigger();
|
|
80
|
+
}
|
|
81
|
+
async markAsProven() {
|
|
82
|
+
if (!this.isMarkingAsProven) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
await this.rollupCheatCodes.markAsProven();
|
|
86
|
+
}
|
|
87
|
+
async syncDateProviderToL1IfBehind() {
|
|
88
|
+
// this doesn't apply to the local network, because we don't have a date provider in the local network
|
|
89
|
+
if (!this.dateProvider) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const l1Time = await this.cheatcodes.timestamp() * 1000;
|
|
93
|
+
const wallTime = this.dateProvider.now();
|
|
94
|
+
if (l1Time > wallTime) {
|
|
95
|
+
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
96
|
+
this.dateProvider.setTime(l1Time);
|
|
97
|
+
} else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
|
|
98
|
+
this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
|
|
99
|
+
await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async warpTimeIfNeeded() {
|
|
103
|
+
try {
|
|
104
|
+
const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
105
|
+
const pendingCheckpointNumber = await this.rollup.read.getPendingCheckpointNumber();
|
|
106
|
+
const checkpointLog = await this.rollup.read.getCheckpoint([
|
|
107
|
+
pendingCheckpointNumber
|
|
108
|
+
]);
|
|
109
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
110
|
+
const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([
|
|
111
|
+
BigInt(nextSlot)
|
|
112
|
+
]));
|
|
113
|
+
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
114
|
+
// We should jump to the next slot
|
|
115
|
+
try {
|
|
116
|
+
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
117
|
+
resetBlockInterval: true
|
|
118
|
+
});
|
|
119
|
+
} catch (e) {
|
|
120
|
+
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
121
|
+
}
|
|
122
|
+
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// If we are not in local network, we don't need to warp time
|
|
126
|
+
if (!this.isLocalNetwork) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
130
|
+
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
131
|
+
try {
|
|
132
|
+
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
133
|
+
resetBlockInterval: true
|
|
134
|
+
});
|
|
135
|
+
} catch (e) {
|
|
136
|
+
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
137
|
+
}
|
|
138
|
+
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
139
|
+
}
|
|
140
|
+
} catch {
|
|
141
|
+
this.logger.error('mineIfSlotFilled failed');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
4
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
/**
|
|
6
|
+
* A class that provides utility functions for interacting with the chain.
|
|
7
|
+
* @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
|
|
8
|
+
* they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
|
|
9
|
+
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CheatCodes {
|
|
12
|
+
eth: EthCheatCodes;
|
|
13
|
+
rollup: RollupCheatCodes;
|
|
14
|
+
constructor(
|
|
15
|
+
/** Cheat codes for L1.*/
|
|
16
|
+
eth: EthCheatCodes,
|
|
17
|
+
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
18
|
+
rollup: RollupCheatCodes);
|
|
19
|
+
static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes>;
|
|
20
|
+
/**
|
|
21
|
+
* Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
|
|
22
|
+
* the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
|
|
23
|
+
* by the slot number, which advances in fixed intervals.
|
|
24
|
+
* This is useful for testing time-dependent contract behavior.
|
|
25
|
+
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
26
|
+
* @param node - The Aztec node used to query if a new block has been mined.
|
|
27
|
+
* @param targetTimestamp - The target timestamp to warp to (in seconds)
|
|
28
|
+
*/
|
|
29
|
+
warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
|
|
32
|
+
* least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
|
|
33
|
+
* number, which advances in fixed intervals.
|
|
34
|
+
* This is useful for testing time-dependent contract behavior.
|
|
35
|
+
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
36
|
+
* @param node - The Aztec node used to query if a new block has been mined.
|
|
37
|
+
* @param duration - The duration to advance time by (in seconds)
|
|
38
|
+
*/
|
|
39
|
+
warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlYXRfY29kZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2NoZWF0X2NvZGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUd2RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUMvRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVqRTs7Ozs7R0FLRztBQUNILHFCQUFhLFVBQVU7SUFHWixHQUFHLEVBQUUsYUFBYTtJQUVsQixNQUFNLEVBQUUsZ0JBQWdCO0lBSmpDO0lBQ0UseUJBQXlCO0lBQ2xCLEdBQUcsRUFBRSxhQUFhO0lBQ3pCLHVEQUF1RDtJQUNoRCxNQUFNLEVBQUU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