@aztec/aztec 0.0.0-test.1 → 0.0.1-commit.b655e406

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.
Files changed (111) hide show
  1. package/dest/bin/index.js +20 -12
  2. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  3. package/dest/cli/aztec_start_action.js +32 -33
  4. package/dest/cli/aztec_start_options.d.ts +4 -2
  5. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  6. package/dest/cli/aztec_start_options.js +137 -207
  7. package/dest/cli/cli.d.ts.map +1 -1
  8. package/dest/cli/cli.js +4 -0
  9. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  10. package/dest/cli/cmds/start_archiver.js +18 -10
  11. package/dest/cli/cmds/start_blob_sink.d.ts.map +1 -1
  12. package/dest/cli/cmds/start_blob_sink.js +17 -1
  13. package/dest/cli/cmds/start_bot.d.ts +3 -6
  14. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  15. package/dest/cli/cmds/start_bot.js +24 -13
  16. package/dest/cli/cmds/start_node.d.ts +1 -1
  17. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  18. package/dest/cli/cmds/start_node.js +66 -79
  19. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  20. package/dest/cli/cmds/start_p2p_bootstrap.js +9 -4
  21. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  22. package/dest/cli/cmds/start_prover_agent.js +31 -2
  23. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  24. package/dest/cli/cmds/start_prover_broker.js +9 -3
  25. package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
  26. package/dest/cli/cmds/start_prover_node.js +43 -45
  27. package/dest/cli/preload_crs.d.ts +3 -0
  28. package/dest/cli/preload_crs.d.ts.map +1 -0
  29. package/dest/cli/preload_crs.js +6 -0
  30. package/dest/cli/release_version.d.ts +2 -0
  31. package/dest/cli/release_version.d.ts.map +1 -0
  32. package/dest/cli/release_version.js +14 -0
  33. package/dest/cli/util.d.ts +36 -5
  34. package/dest/cli/util.d.ts.map +1 -1
  35. package/dest/cli/util.js +198 -28
  36. package/dest/cli/versioning.js +3 -3
  37. package/dest/examples/token.js +31 -18
  38. package/dest/examples/util.d.ts +4 -5
  39. package/dest/examples/util.d.ts.map +1 -1
  40. package/dest/examples/util.js +5 -6
  41. package/dest/index.d.ts +1 -1
  42. package/dest/index.d.ts.map +1 -1
  43. package/dest/index.js +1 -1
  44. package/dest/sandbox/banana_fpc.d.ts +4 -5
  45. package/dest/sandbox/banana_fpc.d.ts.map +1 -1
  46. package/dest/sandbox/banana_fpc.js +19 -21
  47. package/dest/sandbox/index.d.ts +2 -3
  48. package/dest/sandbox/index.d.ts.map +1 -1
  49. package/dest/sandbox/index.js +2 -3
  50. package/dest/sandbox/sandbox.d.ts +25 -27
  51. package/dest/sandbox/sandbox.d.ts.map +1 -1
  52. package/dest/sandbox/sandbox.js +51 -49
  53. package/dest/sandbox/sponsored_fpc.d.ts +3 -5
  54. package/dest/sandbox/sponsored_fpc.d.ts.map +1 -1
  55. package/dest/sandbox/sponsored_fpc.js +10 -18
  56. package/dest/testing/anvil_test_watcher.d.ts +34 -0
  57. package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
  58. package/dest/testing/anvil_test_watcher.js +142 -0
  59. package/dest/testing/cheat_codes.d.ts +43 -0
  60. package/dest/testing/cheat_codes.d.ts.map +1 -0
  61. package/dest/testing/cheat_codes.js +62 -0
  62. package/dest/testing/index.d.ts +4 -0
  63. package/dest/testing/index.d.ts.map +1 -0
  64. package/dest/testing/index.js +3 -0
  65. package/package.json +47 -41
  66. package/src/bin/index.ts +24 -12
  67. package/src/cli/aztec_start_action.ts +27 -30
  68. package/src/cli/aztec_start_options.ts +155 -207
  69. package/src/cli/cli.ts +8 -0
  70. package/src/cli/cmds/start_archiver.ts +19 -13
  71. package/src/cli/cmds/start_blob_sink.ts +27 -1
  72. package/src/cli/cmds/start_bot.ts +35 -12
  73. package/src/cli/cmds/start_node.ts +89 -84
  74. package/src/cli/cmds/start_p2p_bootstrap.ts +12 -4
  75. package/src/cli/cmds/start_prover_agent.ts +22 -2
  76. package/src/cli/cmds/start_prover_broker.ts +23 -3
  77. package/src/cli/cmds/start_prover_node.ts +53 -50
  78. package/src/cli/preload_crs.ts +7 -0
  79. package/src/cli/release_version.ts +21 -0
  80. package/src/cli/util.ts +208 -34
  81. package/src/cli/versioning.ts +3 -3
  82. package/src/examples/token.ts +23 -19
  83. package/src/examples/util.ts +6 -8
  84. package/src/index.ts +3 -4
  85. package/src/sandbox/banana_fpc.ts +20 -25
  86. package/src/sandbox/index.ts +5 -3
  87. package/src/sandbox/sandbox.ts +70 -57
  88. package/src/sandbox/sponsored_fpc.ts +12 -25
  89. package/src/testing/anvil_test_watcher.ts +164 -0
  90. package/src/testing/cheat_codes.ts +78 -0
  91. package/src/testing/index.ts +3 -0
  92. package/dest/cli/chain_l2_config.d.ts +0 -19
  93. package/dest/cli/chain_l2_config.d.ts.map +0 -1
  94. package/dest/cli/chain_l2_config.js +0 -56
  95. package/dest/cli/cmds/start_faucet.d.ts +0 -4
  96. package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
  97. package/dest/cli/cmds/start_faucet.js +0 -20
  98. package/dest/cli/cmds/start_pxe.d.ts +0 -16
  99. package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
  100. package/dest/cli/cmds/start_pxe.js +0 -95
  101. package/dest/cli/get_l1_config.d.ts +0 -7
  102. package/dest/cli/get_l1_config.d.ts.map +0 -1
  103. package/dest/cli/get_l1_config.js +0 -13
  104. package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
  105. package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
  106. package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
  107. package/src/cli/chain_l2_config.ts +0 -74
  108. package/src/cli/cmds/start_faucet.ts +0 -34
  109. package/src/cli/cmds/start_pxe.ts +0 -129
  110. package/src/cli/get_l1_config.ts +0 -18
  111. package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
2
  import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
3
+ import { EthAddress } from '@aztec/aztec.js/addresses';
3
4
  import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
4
5
  import { Fr } from '@aztec/foundation/fields';
5
6
  import { type LogFn } from '@aztec/foundation/log';
6
- import { type PXEServiceConfig } from '@aztec/pxe/server';
7
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
+ import { DateProvider } from '@aztec/foundation/timer';
8
8
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
9
9
  import { type TelemetryClient } from '@aztec/telemetry-client';
10
10
  import { type HDAccount, type PrivateKeyAccount } from 'viem';
@@ -13,38 +13,41 @@ import { type HDAccount, type PrivateKeyAccount } from 'viem';
13
13
  * @param aztecNodeConfig - The Aztec Node Config
14
14
  * @param hdAccount - Account for publishing L1 contracts
15
15
  */
16
- export declare function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, hdAccount: HDAccount | PrivateKeyAccount, contractDeployLogger?: import("@aztec/aztec.js").Logger, opts?: {
16
+ export declare function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, hdAccount: HDAccount | PrivateKeyAccount, contractDeployLogger?: import("@aztec/foundation/log").Logger, opts?: {
17
17
  assumeProvenThroughBlockNumber?: number;
18
18
  salt?: number;
19
19
  genesisArchiveRoot?: Fr;
20
- genesisBlockHash?: Fr;
20
+ feeJuicePortalInitialBalance?: bigint;
21
21
  }): Promise<{
22
- rollupAddress: import("@aztec/aztec.js").EthAddress;
23
- registryAddress: import("@aztec/aztec.js").EthAddress;
24
- inboxAddress: import("@aztec/aztec.js").EthAddress;
25
- outboxAddress: import("@aztec/aztec.js").EthAddress;
26
- feeJuiceAddress: import("@aztec/aztec.js").EthAddress;
27
- feeJuicePortalAddress: import("@aztec/aztec.js").EthAddress;
28
- coinIssuerAddress: import("@aztec/aztec.js").EthAddress;
29
- rewardDistributorAddress: import("@aztec/aztec.js").EthAddress;
30
- governanceProposerAddress: import("@aztec/aztec.js").EthAddress;
31
- governanceAddress: import("@aztec/aztec.js").EthAddress;
32
- stakingAssetAddress: import("@aztec/aztec.js").EthAddress;
22
+ rollupAddress: EthAddress;
23
+ registryAddress: EthAddress;
24
+ inboxAddress: EthAddress;
25
+ outboxAddress: EthAddress;
26
+ feeJuiceAddress: EthAddress;
27
+ feeJuicePortalAddress: EthAddress;
28
+ coinIssuerAddress: EthAddress;
29
+ rewardDistributorAddress: EthAddress;
30
+ governanceProposerAddress: EthAddress;
31
+ governanceAddress: EthAddress;
32
+ stakingAssetAddress: EthAddress;
33
33
  } & {
34
- slashFactoryAddress?: import("@aztec/aztec.js").EthAddress | undefined;
34
+ slashFactoryAddress?: EthAddress | undefined;
35
+ feeAssetHandlerAddress?: EthAddress | undefined;
36
+ stakingAssetHandlerAddress?: EthAddress | undefined;
37
+ zkPassportVerifierAddress?: EthAddress | undefined;
38
+ gseAddress?: EthAddress | undefined;
39
+ dateGatedRelayerAddress?: EthAddress | undefined;
35
40
  } & {
36
- rollupAddress: import("@aztec/aztec.js").EthAddress;
41
+ rollupAddress: EthAddress;
37
42
  } & {
38
- rollupAddress: import("@aztec/aztec.js").EthAddress;
43
+ rollupAddress: EthAddress;
39
44
  }>;
40
45
  /** Sandbox settings. */
41
46
  export type SandboxConfig = AztecNodeConfig & {
42
47
  /** Mnemonic used to derive the L1 deployer private key.*/
43
48
  l1Mnemonic: string;
44
49
  /** Salt used to deploy L1 contracts.*/
45
- l1Salt: string;
46
- /** Whether to expose PXE service on sandbox start.*/
47
- noPXE: boolean;
50
+ deployAztecContractsSalt: string;
48
51
  /** Whether to deploy test accounts on sandbox start.*/
49
52
  testAccounts: boolean;
50
53
  };
@@ -55,7 +58,6 @@ export type SandboxConfig = AztecNodeConfig & {
55
58
  */
56
59
  export declare function createSandbox(config: Partial<SandboxConfig> | undefined, userLog: LogFn): Promise<{
57
60
  node: AztecNodeService;
58
- pxe: import("@aztec/pxe/server").PXEService;
59
61
  stop: () => Promise<void>;
60
62
  }>;
61
63
  /**
@@ -65,12 +67,8 @@ export declare function createSandbox(config: Partial<SandboxConfig> | undefined
65
67
  export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?: {
66
68
  telemetry?: TelemetryClient;
67
69
  blobSinkClient?: BlobSinkClientInterface;
70
+ dateProvider?: DateProvider;
68
71
  }, options?: {
69
72
  prefilledPublicData?: PublicDataTreeLeaf[];
70
73
  }): Promise<AztecNodeService>;
71
- /**
72
- * Create and start a new Aztec PXE HTTP Server
73
- * @param config - Optional PXE settings.
74
- */
75
- export declare function createAztecPXE(node: AztecNode, config?: Partial<PXEServiceConfig>): Promise<import("@aztec/pxe/server").PXEService>;
76
74
  //# sourceMappingURL=sandbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAU7F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAE,KAAK,gBAAgB,EAAyC,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAA2D,MAAM,MAAM,CAAC;AAavH;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GAAG,iBAAiB,EACxC,oBAAoB,mCAAS,EAC7B,IAAI,GAAE;IAAE,8BAA8B,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;IAAC,gBAAgB,CAAC,EAAE,EAAE,CAAA;CAAO;;;;;;;;;;;;;;;;;;GA6BtH;AAED,wBAAwB;AACxB,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,oCAA6B,EAAE,OAAO,EAAE,KAAK;;;;GAkGtF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAO,EACpF,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAY7D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM,mDAI3F"}
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAY7F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAoB,MAAM,yBAAyB,CAAC;AAGzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAA2D,MAAM,MAAM,CAAC;AAcvH;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GAAG,iBAAiB,EACxC,oBAAoB,yCAAS,EAC7B,IAAI,GAAE;IACJ,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,EAAE,CAAC;IACxB,4BAA4B,CAAC,EAAE,MAAM,CAAC;CAClC;;;;;;;;;;;;;;;;;;;;;;;GAkCP;AAED,wBAAwB;AACxB,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,wBAAwB,EAAE,MAAM,CAAC;IACjC,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,YAAK,EAAE,OAAO,EAAE,KAAK;;;GAgHtF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,cAAc,CAAC,EAAE,uBAAuB,CAAC;IAAC,YAAY,CAAC,EAAE,YAAY,CAAA;CAAO,EACjH,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAW7D"}
@@ -1,26 +1,28 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
- import { getSchnorrWallet } from '@aztec/accounts/schnorr';
3
- import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
4
3
  import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
- import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet } from '@aztec/aztec.js';
4
+ import { EthAddress } from '@aztec/aztec.js/addresses';
6
5
  import { createBlobSinkClient } from '@aztec/blob-sink/client';
7
- import { setupCanonicalL2FeeJuice } from '@aztec/cli/setup-contracts';
8
- import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
9
- import { NULL_KEY, createEthereumChain, deployL1Contracts, getL1ContractsConfigEnvVars, waitForPublicClient } from '@aztec/ethereum';
6
+ import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
7
+ import { NULL_KEY, createEthereumChain, deployL1Contracts, deployMulticall3, getL1ContractsConfigEnvVars, waitForPublicClient } from '@aztec/ethereum';
8
+ import { EthCheatCodes } from '@aztec/ethereum/test';
9
+ import { SecretValue } from '@aztec/foundation/config';
10
10
  import { Fr } from '@aztec/foundation/fields';
11
11
  import { createLogger } from '@aztec/foundation/log';
12
+ import { TestDateProvider } from '@aztec/foundation/timer';
12
13
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
13
- import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
14
- import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
14
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
15
15
  import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
16
+ import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
16
17
  import { getGenesisValues } from '@aztec/world-state/testing';
17
18
  import { createPublicClient, fallback, http as httpViemTransport } from 'viem';
18
- import { mnemonicToAccount } from 'viem/accounts';
19
+ import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
19
20
  import { foundry } from 'viem/chains';
20
21
  import { createAccountLogs } from '../cli/util.js';
21
22
  import { DefaultMnemonic } from '../mnemonic.js';
23
+ import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
22
24
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
23
- import { getSponsoredFPCAddress, setupSponsoredFPC } from './sponsored_fpc.js';
25
+ import { getSponsoredFPCAddress } from './sponsored_fpc.js';
24
26
  const logger = createLogger('sandbox');
25
27
  const localAnvil = foundry;
26
28
  /**
@@ -35,14 +37,18 @@ const localAnvil = foundry;
35
37
  const l1Contracts = await deployL1Contracts(aztecNodeConfig.l1RpcUrls, hdAccount, chain.chainInfo, contractDeployLogger, {
36
38
  ...getL1ContractsConfigEnvVars(),
37
39
  ...aztecNodeConfig,
38
- l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
39
40
  vkTreeRoot: getVKTreeRoot(),
40
- protocolContractTreeRoot,
41
+ protocolContractsHash,
41
42
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
42
- genesisBlockHash: opts.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
43
- salt: opts.salt
43
+ salt: opts.salt,
44
+ feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
45
+ aztecTargetCommitteeSize: 0,
46
+ slasherFlavor: 'none',
47
+ realVerifier: false
44
48
  });
49
+ await deployMulticall3(l1Contracts.l1Client, logger);
45
50
  aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
51
+ aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
46
52
  return aztecNodeConfig.l1Contracts;
47
53
  }
48
54
  /**
@@ -63,22 +69,26 @@ const localAnvil = foundry;
63
69
  ...config
64
70
  };
65
71
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
66
- if (!aztecNodeConfig.publisherPrivateKey || aztecNodeConfig.publisherPrivateKey === NULL_KEY) {
72
+ if (aztecNodeConfig.publisherPrivateKeys == undefined || !aztecNodeConfig.publisherPrivateKeys.length || aztecNodeConfig.publisherPrivateKeys[0].getValue() === NULL_KEY) {
67
73
  const privKey = hdAccount.getHdKey().privateKey;
68
- aztecNodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey).toString('hex')}`;
74
+ aztecNodeConfig.publisherPrivateKeys = [
75
+ new SecretValue(`0x${Buffer.from(privKey).toString('hex')}`)
76
+ ];
69
77
  }
70
- if (!aztecNodeConfig.validatorPrivateKey || aztecNodeConfig.validatorPrivateKey === NULL_KEY) {
78
+ if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
71
79
  const privKey = hdAccount.getHdKey().privateKey;
72
- aztecNodeConfig.validatorPrivateKey = `0x${Buffer.from(privKey).toString('hex')}`;
80
+ aztecNodeConfig.validatorPrivateKeys = new SecretValue([
81
+ `0x${Buffer.from(privKey).toString('hex')}`
82
+ ]);
73
83
  }
84
+ aztecNodeConfig.coinbase = EthAddress.fromString(privateKeyToAddress(aztecNodeConfig.validatorPrivateKeys.getValue()[0]));
74
85
  const initialAccounts = await (async ()=>{
75
- if (config.testAccounts) {
86
+ if (config.testAccounts === true || config.testAccounts === undefined) {
76
87
  if (aztecNodeConfig.p2pEnabled) {
77
88
  userLog(`Not setting up test accounts as we are connecting to a network`);
78
- } else if (config.noPXE) {
79
- userLog(`Not setting up test accounts as we are not exposing a PXE`);
80
89
  } else {
81
- return await getInitialTestAccounts();
90
+ userLog(`Setting up test accounts`);
91
+ return await getInitialTestAccountsData();
82
92
  }
83
93
  }
84
94
  return [];
@@ -90,14 +100,15 @@ const localAnvil = foundry;
90
100
  bananaFPC,
91
101
  sponsoredFPC
92
102
  ] : [];
93
- const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(fundedAddresses);
103
+ const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
94
104
  let watcher = undefined;
105
+ const dateProvider = new TestDateProvider();
95
106
  if (!aztecNodeConfig.p2pEnabled) {
96
107
  const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
97
108
  assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
98
109
  genesisArchiveRoot,
99
- genesisBlockHash,
100
- salt: config.l1Salt ? parseInt(config.l1Salt) : undefined
110
+ salt: config.deployAztecContractsSalt ? parseInt(config.deployAztecContractsSalt) : undefined,
111
+ feeJuicePortalInitialBalance: fundingNeeded
101
112
  });
102
113
  const chain = aztecNodeConfig.l1RpcUrls.length > 0 ? createEthereumChain([
103
114
  l1RpcUrl
@@ -112,7 +123,7 @@ const localAnvil = foundry;
112
123
  });
113
124
  watcher = new AnvilTestWatcher(new EthCheatCodes([
114
125
  l1RpcUrl
115
- ]), l1ContractAddresses.rollupAddress, publicClient);
126
+ ], dateProvider), l1ContractAddresses.rollupAddress, publicClient, dateProvider);
116
127
  watcher.setIsSandbox(true);
117
128
  await watcher.start();
118
129
  }
@@ -121,24 +132,28 @@ const localAnvil = foundry;
121
132
  const blobSinkClient = createBlobSinkClient();
122
133
  const node = await createAztecNode(aztecNodeConfig, {
123
134
  telemetry,
124
- blobSinkClient
135
+ blobSinkClient,
136
+ dateProvider
125
137
  }, {
126
138
  prefilledPublicData
127
139
  });
128
- const pxe = await createAztecPXE(node);
129
- await setupCanonicalL2FeeJuice(new SignerlessWallet(pxe), aztecNodeConfig.l1Contracts.feeJuicePortalAddress, undefined, logger.info);
130
140
  if (initialAccounts.length) {
141
+ const PXEConfig = {
142
+ proverEnabled: aztecNodeConfig.realProofs
143
+ };
144
+ const wallet = await TestWallet.create(node, PXEConfig);
131
145
  userLog('Setting up funded test accounts...');
132
- const accounts = await deployFundedSchnorrAccounts(pxe, initialAccounts);
133
- const accountsWithSecrets = accounts.map((account, i)=>({
134
- account,
146
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
147
+ const accountsWithSecrets = accountManagers.map((manager, i)=>({
148
+ account: manager,
135
149
  secretKey: initialAccounts[i].secret
136
150
  }));
137
- const accLogs = await createAccountLogs(accountsWithSecrets, pxe);
151
+ const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
138
152
  userLog(accLogs.join(''));
139
- const deployer = await getSchnorrWallet(pxe, initialAccounts[0].address, initialAccounts[0].signingKey);
140
- await setupBananaFPC(initialAccounts, deployer, userLog);
141
- await setupSponsoredFPC(deployer, userLog);
153
+ await setupBananaFPC(initialAccounts, wallet, userLog);
154
+ userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
155
+ // We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
156
+ await wallet.stop();
142
157
  }
143
158
  const stop = async ()=>{
144
159
  await node.stop();
@@ -146,7 +161,6 @@ const localAnvil = foundry;
146
161
  };
147
162
  return {
148
163
  node,
149
- pxe,
150
164
  stop
151
165
  };
152
166
  }
@@ -164,18 +178,6 @@ const localAnvil = foundry;
164
178
  ...config.l1Contracts
165
179
  }
166
180
  };
167
- logger.info('createAztecNode', aztecNodeConfig);
168
181
  const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
169
182
  return node;
170
183
  }
171
- /**
172
- * Create and start a new Aztec PXE HTTP Server
173
- * @param config - Optional PXE settings.
174
- */ export async function createAztecPXE(node, config = {}) {
175
- const pxeServiceConfig = {
176
- ...getPXEServiceConfig(),
177
- ...config
178
- };
179
- const pxe = await createPXEService(node, pxeServiceConfig);
180
- return pxe;
181
- }
@@ -1,6 +1,4 @@
1
- import { type PXE, type Wallet } from '@aztec/aztec.js';
2
- import type { LogFn } from '@aztec/foundation/log';
3
- export declare function getSponsoredFPCAddress(): Promise<import("@aztec/aztec.js").AztecAddress>;
4
- export declare function setupSponsoredFPC(deployer: Wallet, log: LogFn): Promise<void>;
5
- export declare function getDeployedSponsoredFPCAddress(pxe: PXE): Promise<import("@aztec/aztec.js").AztecAddress>;
1
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
+ export declare function getSponsoredFPCAddress(): Promise<import("@aztec/aztec.js/addresses").AztecAddress>;
3
+ export declare function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet): Promise<import("@aztec/aztec.js/addresses").AztecAddress>;
6
4
  //# sourceMappingURL=sponsored_fpc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sponsored_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAWnD,wBAAsB,sBAAsB,oDAE3C;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAMnE;AAED,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,GAAG,mDAO5D"}
1
+ {"version":3,"file":"sponsored_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fpc.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAUrD,wBAAsB,sBAAsB,8DAE3C;AAED,wBAAsB,iDAAiD,CAAC,MAAM,EAAE,MAAM,6DAKrF"}
@@ -1,26 +1,18 @@
1
- import { Fr, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
1
+ import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import { SPONSORED_FPC_SALT } from '@aztec/constants';
2
4
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
3
- const SPONSORED_FPC_SALT = new Fr(0);
4
5
  async function getSponsoredFPCInstance() {
5
- return await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
6
- salt: SPONSORED_FPC_SALT
6
+ return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
7
+ salt: new Fr(SPONSORED_FPC_SALT)
7
8
  });
8
9
  }
9
10
  export async function getSponsoredFPCAddress() {
10
11
  return (await getSponsoredFPCInstance()).address;
11
12
  }
12
- export async function setupSponsoredFPC(deployer, log) {
13
- const deployed = await SponsoredFPCContract.deploy(deployer).send({
14
- contractAddressSalt: SPONSORED_FPC_SALT,
15
- universalDeploy: true
16
- }).deployed();
17
- log(`SponsoredFPC: ${deployed.address}`);
18
- }
19
- export async function getDeployedSponsoredFPCAddress(pxe) {
20
- const fpc = await getSponsoredFPCAddress();
21
- const contracts = await pxe.getContracts();
22
- if (!contracts.find((c)=>c.equals(fpc))) {
23
- throw new Error('SponsoredFPC not deployed.');
24
- }
25
- return fpc;
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;
26
18
  }
@@ -0,0 +1,34 @@
1
+ import type { ViemClient } from '@aztec/ethereum';
2
+ import { EthCheatCodes } from '@aztec/ethereum/test';
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 isSandbox;
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
+ setIsSandbox(isSandbox: 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=anvil_test_watcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anvil_test_watcher.d.ts","sourceRoot":"","sources":["../../src/testing/anvil_test_watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAgBzB,OAAO,CAAC,UAAU;IAGlB,OAAO,CAAC,YAAY,CAAC;IAlBvB,OAAO,CAAC,SAAS,CAAkB;IAEnC,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAU;IAEhC,OAAO,CAAC,oBAAoB,CAAC,CAAiB;IAC9C,OAAO,CAAC,uBAAuB,CAAC,CAAiB;IACjD,OAAO,CAAC,6BAA6B,CAAC,CAAiB;IAEvD,OAAO,CAAC,MAAM,CAAiD;IAE/D,OAAO,CAAC,iBAAiB,CAAQ;gBAGvB,UAAU,EAAE,aAAa,EACjC,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,UAAU,EACZ,YAAY,CAAC,EAAE,gBAAgB,YAAA;IAezC,oBAAoB,CAAC,iBAAiB,EAAE,OAAO;IAK/C,YAAY,CAAC,SAAS,EAAE,OAAO;IAIzB,KAAK;IA2BL,IAAI;IAMJ,OAAO;IAMP,YAAY;IAOZ,4BAA4B;IAiB5B,gBAAgB;CAwCvB"}
@@ -0,0 +1,142 @@
1
+ import { RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { RunningPromise } from '@aztec/foundation/running-promise';
4
+ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
5
+ import { getAddress, getContract } from 'viem';
6
+ /**
7
+ * Represents a watcher for a rollup contract.
8
+ *
9
+ * It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
10
+ * it will periodically check if the current slot have already been filled, e.g., there was an L2
11
+ * block within the slot. And if so, it will time travel into the next slot.
12
+ */ export class AnvilTestWatcher {
13
+ cheatcodes;
14
+ dateProvider;
15
+ isSandbox;
16
+ rollup;
17
+ rollupCheatCodes;
18
+ l2SlotDuration;
19
+ filledRunningPromise;
20
+ syncDateProviderPromise;
21
+ markingAsProvenRunningPromise;
22
+ logger;
23
+ isMarkingAsProven;
24
+ constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
25
+ this.cheatcodes = cheatcodes;
26
+ this.dateProvider = dateProvider;
27
+ this.isSandbox = false;
28
+ this.logger = createLogger(`aztecjs:utils:watcher`);
29
+ this.isMarkingAsProven = true;
30
+ this.rollup = getContract({
31
+ address: getAddress(rollupAddress.toString()),
32
+ abi: RollupAbi,
33
+ client: l1Client
34
+ });
35
+ this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
36
+ rollupAddress
37
+ });
38
+ this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
39
+ }
40
+ setIsMarkingAsProven(isMarkingAsProven) {
41
+ this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
42
+ this.isMarkingAsProven = isMarkingAsProven;
43
+ }
44
+ setIsSandbox(isSandbox) {
45
+ this.isSandbox = isSandbox;
46
+ }
47
+ async start() {
48
+ if (this.filledRunningPromise) {
49
+ throw new Error('Watcher already watching for filled slot');
50
+ }
51
+ const config = await this.rollupCheatCodes.getConfig();
52
+ this.l2SlotDuration = config.slotDuration;
53
+ // If auto mining is not supported (e.g., we are on a real network), then we
54
+ // will simple do nothing. But if on an anvil or the like, this make sure that
55
+ // the sandbox and tests don't break because time is frozen and we never get to
56
+ // the next slot.
57
+ const isAutoMining = await this.cheatcodes.isAutoMining();
58
+ if (isAutoMining) {
59
+ this.filledRunningPromise = new RunningPromise(()=>this.warpTimeIfNeeded(), this.logger, 200);
60
+ this.filledRunningPromise.start();
61
+ this.syncDateProviderPromise = new RunningPromise(()=>this.syncDateProviderToL1IfBehind(), this.logger, 200);
62
+ this.syncDateProviderPromise.start();
63
+ this.markingAsProvenRunningPromise = new RunningPromise(()=>this.markAsProven(), this.logger, 200);
64
+ this.markingAsProvenRunningPromise.start();
65
+ this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
66
+ } else {
67
+ this.logger.info(`Watcher not started because not auto mining`);
68
+ }
69
+ }
70
+ async stop() {
71
+ await this.filledRunningPromise?.stop();
72
+ await this.syncDateProviderPromise?.stop();
73
+ await this.markingAsProvenRunningPromise?.stop();
74
+ }
75
+ async trigger() {
76
+ await this.filledRunningPromise?.trigger();
77
+ await this.syncDateProviderPromise?.trigger();
78
+ await this.markingAsProvenRunningPromise?.trigger();
79
+ }
80
+ async markAsProven() {
81
+ if (!this.isMarkingAsProven) {
82
+ return;
83
+ }
84
+ await this.rollupCheatCodes.markAsProven();
85
+ }
86
+ async syncDateProviderToL1IfBehind() {
87
+ // this doesn't apply to the sandbox, because we don't have a date provider in the sandbox
88
+ if (!this.dateProvider) {
89
+ return;
90
+ }
91
+ const l1Time = await this.cheatcodes.timestamp() * 1000;
92
+ const wallTime = this.dateProvider.now();
93
+ if (l1Time > wallTime) {
94
+ this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
95
+ this.dateProvider.setTime(l1Time);
96
+ } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
97
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
98
+ await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
99
+ }
100
+ }
101
+ async warpTimeIfNeeded() {
102
+ try {
103
+ const currentSlot = await this.rollup.read.getCurrentSlot();
104
+ const pendingBlockNumber = BigInt(await this.rollup.read.getPendingBlockNumber());
105
+ const blockLog = await this.rollup.read.getBlock([
106
+ pendingBlockNumber
107
+ ]);
108
+ const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([
109
+ currentSlot + 1n
110
+ ]));
111
+ if (currentSlot === blockLog.slotNumber) {
112
+ // We should jump to the next slot
113
+ try {
114
+ await this.cheatcodes.warp(nextSlotTimestamp, {
115
+ resetBlockInterval: true
116
+ });
117
+ } catch (e) {
118
+ this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
119
+ }
120
+ this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
121
+ return;
122
+ }
123
+ // If we are not in sandbox, we don't need to warp time
124
+ if (!this.isSandbox) {
125
+ return;
126
+ }
127
+ const currentTimestamp = this.dateProvider?.now() ?? Date.now();
128
+ if (currentTimestamp > nextSlotTimestamp * 1000) {
129
+ try {
130
+ await this.cheatcodes.warp(nextSlotTimestamp, {
131
+ resetBlockInterval: true
132
+ });
133
+ } catch (e) {
134
+ this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
135
+ }
136
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
137
+ }
138
+ } catch {
139
+ this.logger.error('mineIfSlotFilled failed');
140
+ }
141
+ }
142
+ }
@@ -0,0 +1,43 @@
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
+ /** Cheat codes for L1.*/
13
+ eth: EthCheatCodes;
14
+ /** Cheat codes for the Aztec Rollup contract on L1. */
15
+ rollup: RollupCheatCodes;
16
+ constructor(
17
+ /** Cheat codes for L1.*/
18
+ eth: EthCheatCodes,
19
+ /** Cheat codes for the Aztec Rollup contract on L1. */
20
+ rollup: RollupCheatCodes);
21
+ static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes>;
22
+ /**
23
+ * Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
24
+ * the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
25
+ * by the slot number, which advances in fixed intervals.
26
+ * This is useful for testing time-dependent contract behavior.
27
+ * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
28
+ * @param node - The Aztec node used to query if a new block has been mined.
29
+ * @param targetTimestamp - The target timestamp to warp to (in seconds)
30
+ */
31
+ warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number): Promise<void>;
32
+ /**
33
+ * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
34
+ * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
35
+ * number, which advances in fixed intervals.
36
+ * This is useful for testing time-dependent contract behavior.
37
+ * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
38
+ * @param node - The Aztec node used to query if a new block has been mined.
39
+ * @param duration - The duration to advance time by (in seconds)
40
+ */
41
+ warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number): Promise<void>;
42
+ }
43
+ //# sourceMappingURL=cheat_codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cheat_codes.d.ts","sourceRoot":"","sources":["../../src/testing/cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE;;;;;GAKG;AACH,qBAAa,UAAU;IAEnB,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB;;IAH/B,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB;WAGpB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;IASxG;;;;;;;;OAQG;IACG,mBAAmB,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM;IAyB7G;;;;;;;;OAQG;IACG,mBAAmB,CAAC,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAKvG"}
@@ -0,0 +1,62 @@
1
+ import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import { retryUntil } from '@aztec/foundation/retry';
3
+ /**
4
+ * A class that provides utility functions for interacting with the chain.
5
+ * @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
6
+ * they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
7
+ * codes, please consider whether it makes sense to just introduce new utils in your tests instead.
8
+ */ export class CheatCodes {
9
+ eth;
10
+ rollup;
11
+ constructor(/** Cheat codes for L1.*/ eth, /** Cheat codes for the Aztec Rollup contract on L1. */ rollup){
12
+ this.eth = eth;
13
+ this.rollup = rollup;
14
+ }
15
+ static async create(rpcUrls, node, dateProvider) {
16
+ const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
17
+ const rollupCheatCodes = new RollupCheatCodes(ethCheatCodes, await node.getNodeInfo().then((n)=>n.l1ContractAddresses));
18
+ return new CheatCodes(ethCheatCodes, rollupCheatCodes);
19
+ }
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
+ */ async warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp) {
29
+ const currentL2BlockNumber = await node.getBlockNumber();
30
+ // We warp the L1 timestamp
31
+ await this.eth.warp(targetTimestamp, {
32
+ resetBlockInterval: true
33
+ });
34
+ // Wait until an L2 block is mined
35
+ const sequencer = sequencerClient.getSequencer();
36
+ const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
37
+ sequencer.updateConfig({
38
+ minTxsPerBlock: 0
39
+ });
40
+ await retryUntil(async ()=>{
41
+ const newL2BlockNumber = await node.getBlockNumber();
42
+ return newL2BlockNumber > currentL2BlockNumber;
43
+ }, 'new block after warping L2 time', 36, 1);
44
+ // Restore original minTxsPerBlock
45
+ sequencer.updateConfig({
46
+ minTxsPerBlock
47
+ });
48
+ }
49
+ /**
50
+ * Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
51
+ * least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
52
+ * number, which advances in fixed intervals.
53
+ * This is useful for testing time-dependent contract behavior.
54
+ * @param sequencerClient - The sequencer client to use to force an empty block to be mined.
55
+ * @param node - The Aztec node used to query if a new block has been mined.
56
+ * @param duration - The duration to advance time by (in seconds)
57
+ */ async warpL2TimeAtLeastBy(sequencerClient, node, duration) {
58
+ const currentTimestamp = await this.eth.timestamp();
59
+ const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
60
+ await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
61
+ }
62
+ }
@@ -0,0 +1,4 @@
1
+ export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
+ export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ export { CheatCodes } from './cheat_codes.js';
4
+ //# sourceMappingURL=index.d.ts.map