@aztec/aztec 1.2.0 → 2.0.0-nightly.20250813

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 (43) hide show
  1. package/dest/cli/chain_l2_config.d.ts +6 -2
  2. package/dest/cli/chain_l2_config.d.ts.map +1 -1
  3. package/dest/cli/chain_l2_config.js +25 -13
  4. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  5. package/dest/cli/cmds/start_node.js +9 -2
  6. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
  7. package/dest/cli/cmds/start_p2p_bootstrap.js +3 -2
  8. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  9. package/dest/cli/cmds/start_prover_agent.js +0 -5
  10. package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
  11. package/dest/cli/cmds/start_prover_node.js +0 -5
  12. package/dest/examples/token.js +21 -10
  13. package/dest/sandbox/banana_fpc.js +5 -3
  14. package/dest/sandbox/sandbox.d.ts.map +1 -1
  15. package/dest/sandbox/sandbox.js +10 -2
  16. package/dest/sandbox/sponsored_fpc.d.ts.map +1 -1
  17. package/dest/sandbox/sponsored_fpc.js +2 -2
  18. package/dest/testing/anvil_test_watcher.d.ts +34 -0
  19. package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
  20. package/dest/testing/anvil_test_watcher.js +143 -0
  21. package/dest/testing/aztec_cheat_codes.d.ts +59 -0
  22. package/dest/testing/aztec_cheat_codes.d.ts.map +1 -0
  23. package/dest/testing/aztec_cheat_codes.js +62 -0
  24. package/dest/testing/cheat_codes.d.ts +44 -0
  25. package/dest/testing/cheat_codes.d.ts.map +1 -0
  26. package/dest/testing/cheat_codes.js +63 -0
  27. package/dest/testing/index.d.ts +5 -0
  28. package/dest/testing/index.d.ts.map +1 -0
  29. package/dest/testing/index.js +4 -0
  30. package/package.json +33 -31
  31. package/src/cli/chain_l2_config.ts +39 -15
  32. package/src/cli/cmds/start_node.ts +8 -2
  33. package/src/cli/cmds/start_p2p_bootstrap.ts +9 -2
  34. package/src/cli/cmds/start_prover_agent.ts +0 -6
  35. package/src/cli/cmds/start_prover_node.ts +1 -7
  36. package/src/examples/token.ts +11 -10
  37. package/src/sandbox/banana_fpc.ts +5 -5
  38. package/src/sandbox/sandbox.ts +8 -2
  39. package/src/sandbox/sponsored_fpc.ts +7 -2
  40. package/src/testing/anvil_test_watcher.ts +167 -0
  41. package/src/testing/aztec_cheat_codes.ts +77 -0
  42. package/src/testing/cheat_codes.ts +79 -0
  43. package/src/testing/index.ts +4 -0
@@ -30,9 +30,9 @@ export type L2ChainConfig = {
30
30
  /** The number of epochs after an epoch ends that proofs are still accepted. */
31
31
  aztecProofSubmissionEpochs: number;
32
32
  /** The deposit amount for a validator */
33
- depositAmount: bigint;
33
+ activationThreshold: bigint;
34
34
  /** The minimum stake for a validator. */
35
- minimumStake: bigint;
35
+ ejectionThreshold: bigint;
36
36
  /** The slashing quorum */
37
37
  slashingQuorum: number;
38
38
  /** The slashing round size */
@@ -57,6 +57,10 @@ export type L2ChainConfig = {
57
57
  slashInvalidBlockEnabled: boolean;
58
58
  slashInvalidBlockPenalty: bigint;
59
59
  slashInvalidBlockMaxPenalty: bigint;
60
+ slashProposeInvalidAttestationsPenalty: bigint;
61
+ slashProposeInvalidAttestationsMaxPenalty: bigint;
62
+ slashAttestDescendantOfInvalidPenalty: bigint;
63
+ slashAttestDescendantOfInvalidMaxPenalty: bigint;
60
64
  sentinelEnabled: boolean;
61
65
  };
62
66
  export declare const testnetIgnitionL2ChainConfig: L2ChainConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/cli/chain_l2_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAO/D,MAAM,MAAM,aAAa,GAAG;IAC1B,S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ChC,qCAAqC,EAAE,MAAM,CAAC;IAC9C,qCAAqC,EAAE,MAAM,CAAC;IAC9C,4BAA4B,EAAE,MAAM,CAAC;IACrC,yBAAyB,EAAE,MAAM,CAAC;IAClC,wBAAwB,EAAE,OAAO,CAAC;IAClC,wBAAwB,EAAE,MAAM,CAAC;IACjC,2BAA2B,EAAE,MAAM,CAAC;IACpC,sCAAsC,EAAE,MAAM,CAAC;IAC/C,yCAAyC,EAAE,MAAM,CAAC;IAClD,qCAAqC,EAAE,MAAM,CAAC;IAC9C,wCAAwC,EAAE,MAAM,CAAC;IAEjD,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,aA+D1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,aAkEvC,CAAC;AAIF,wBAAsB,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,gBAgC9E;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAWpC;AAgCD,wBAAsB,gCAAgC,CAAC,WAAW,EAAE,YAAY,iBAyF/E"}
@@ -27,8 +27,8 @@ export const testnetIgnitionL2ChainConfig = {
27
27
  /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
28
28
  /** The target validator committee size. */ aztecTargetCommitteeSize: 48,
29
29
  /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
30
- /** The deposit amount for a validator */ depositAmount: DefaultL1ContractsConfig.depositAmount,
31
- /** The minimum stake for a validator. */ minimumStake: DefaultL1ContractsConfig.minimumStake,
30
+ /** The deposit amount for a validator */ activationThreshold: DefaultL1ContractsConfig.activationThreshold,
31
+ /** The minimum stake for a validator. */ ejectionThreshold: DefaultL1ContractsConfig.ejectionThreshold,
32
32
  /** The slashing quorum */ slashingQuorum: DefaultL1ContractsConfig.slashingQuorum,
33
33
  /** The slashing round size */ slashingRoundSize: DefaultL1ContractsConfig.slashingRoundSize,
34
34
  /** Governance proposing quorum */ governanceProposerQuorum: DefaultL1ContractsConfig.governanceProposerQuorum,
@@ -48,6 +48,10 @@ export const testnetIgnitionL2ChainConfig = {
48
48
  slashPruneMaxPenalty: 0n,
49
49
  slashInvalidBlockPenalty: 0n,
50
50
  slashInvalidBlockMaxPenalty: 0n,
51
+ slashProposeInvalidAttestationsPenalty: 0n,
52
+ slashProposeInvalidAttestationsMaxPenalty: 0n,
53
+ slashAttestDescendantOfInvalidPenalty: 0n,
54
+ slashAttestDescendantOfInvalidMaxPenalty: 0n,
51
55
  sentinelEnabled: false
52
56
  };
53
57
  export const alphaTestnetL2ChainConfig = {
@@ -77,8 +81,8 @@ export const alphaTestnetL2ChainConfig = {
77
81
  /** How many L2 slots an epoch lasts. */ aztecEpochDuration: 32,
78
82
  /** The target validator committee size. */ aztecTargetCommitteeSize: 48,
79
83
  /** The number of epochs after an epoch ends that proofs are still accepted. */ aztecProofSubmissionEpochs: 1,
80
- /** The deposit amount for a validator */ depositAmount: DefaultL1ContractsConfig.depositAmount,
81
- /** The minimum stake for a validator. */ minimumStake: DefaultL1ContractsConfig.minimumStake,
84
+ /** The deposit amount for a validator */ activationThreshold: DefaultL1ContractsConfig.activationThreshold,
85
+ /** The minimum stake for a validator. */ ejectionThreshold: DefaultL1ContractsConfig.ejectionThreshold,
82
86
  /** The slashing quorum */ slashingQuorum: 101,
83
87
  /** The slashing round size */ slashingRoundSize: 200,
84
88
  /** Governance proposing quorum */ governanceProposerQuorum: 151,
@@ -88,16 +92,20 @@ export const alphaTestnetL2ChainConfig = {
88
92
  // slashing stuff
89
93
  slashPayloadTtlSeconds: 36 * 32 * 24,
90
94
  slashPruneEnabled: true,
91
- slashPrunePenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
92
- slashPruneMaxPenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
95
+ slashPrunePenalty: 17n * (DefaultL1ContractsConfig.activationThreshold / 100n),
96
+ slashPruneMaxPenalty: 17n * (DefaultL1ContractsConfig.activationThreshold / 100n),
93
97
  slashInactivityEnabled: true,
94
98
  slashInactivityCreateTargetPercentage: 1,
95
- slashInactivitySignalTargetPercentage: 1,
96
- slashInactivityCreatePenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
97
- slashInactivityMaxPenalty: 17n * (DefaultL1ContractsConfig.depositAmount / 100n),
99
+ slashInactivitySignalTargetPercentage: 0.67,
100
+ slashInactivityCreatePenalty: 17n * (DefaultL1ContractsConfig.activationThreshold / 100n),
101
+ slashInactivityMaxPenalty: 17n * (DefaultL1ContractsConfig.activationThreshold / 100n),
98
102
  slashInvalidBlockEnabled: true,
99
- slashInvalidBlockPenalty: DefaultL1ContractsConfig.depositAmount,
100
- slashInvalidBlockMaxPenalty: DefaultL1ContractsConfig.depositAmount,
103
+ slashInvalidBlockPenalty: DefaultL1ContractsConfig.activationThreshold,
104
+ slashInvalidBlockMaxPenalty: DefaultL1ContractsConfig.activationThreshold,
105
+ slashProposeInvalidAttestationsPenalty: DefaultL1ContractsConfig.activationThreshold,
106
+ slashProposeInvalidAttestationsMaxPenalty: DefaultL1ContractsConfig.activationThreshold,
107
+ slashAttestDescendantOfInvalidPenalty: DefaultL1ContractsConfig.activationThreshold,
108
+ slashAttestDescendantOfInvalidMaxPenalty: DefaultL1ContractsConfig.activationThreshold,
101
109
  sentinelEnabled: true
102
110
  };
103
111
  const BOOTNODE_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour;
@@ -218,8 +226,8 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
218
226
  enrichVar('AZTEC_EPOCH_DURATION', config.aztecEpochDuration.toString());
219
227
  enrichVar('AZTEC_TARGET_COMMITTEE_SIZE', config.aztecTargetCommitteeSize.toString());
220
228
  enrichVar('AZTEC_PROOF_SUBMISSION_EPOCHS', config.aztecProofSubmissionEpochs.toString());
221
- enrichVar('AZTEC_DEPOSIT_AMOUNT', config.depositAmount.toString());
222
- enrichVar('AZTEC_MINIMUM_STAKE', config.minimumStake.toString());
229
+ enrichVar('AZTEC_ACTIVATION_THRESHOLD', config.activationThreshold.toString());
230
+ enrichVar('AZTEC_EJECTION_THRESHOLD', config.ejectionThreshold.toString());
223
231
  enrichVar('AZTEC_SLASHING_QUORUM', config.slashingQuorum.toString());
224
232
  enrichVar('AZTEC_SLASHING_ROUND_SIZE', config.slashingRoundSize.toString());
225
233
  enrichVar('AZTEC_GOVERNANCE_PROPOSER_QUORUM', config.governanceProposerQuorum.toString());
@@ -239,5 +247,9 @@ export async function enrichEnvironmentWithChainConfig(networkName) {
239
247
  enrichVar('SLASH_INVALID_BLOCK_ENABLED', config.slashInvalidBlockEnabled.toString());
240
248
  enrichVar('SLASH_INVALID_BLOCK_PENALTY', config.slashInvalidBlockPenalty.toString());
241
249
  enrichVar('SLASH_INVALID_BLOCK_MAX_PENALTY', config.slashInvalidBlockMaxPenalty.toString());
250
+ enrichVar('SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY', config.slashProposeInvalidAttestationsPenalty.toString());
251
+ enrichVar('SLASH_PROPOSE_INVALID_ATTESTATIONS_MAX_PENALTY', config.slashProposeInvalidAttestationsMaxPenalty.toString());
252
+ enrichVar('SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY', config.slashAttestDescendantOfInvalidPenalty.toString());
253
+ enrichVar('SLASH_ATTEST_DESCENDANT_OF_INVALID_MAX_PENALTY', config.slashAttestDescendantOfInvalidMaxPenalty.toString());
242
254
  enrichVar('SENTINEL_ENABLED', config.sentinelEnabled.toString());
243
255
  }
@@ -1 +1 @@
1
- {"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAKpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAqBnD,wBAAsB,SAAS,CAC7B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,qBAAqB,EACpC,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CAyKtC"}
1
+ {"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAKpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAsBnD,wBAAsB,SAAS,CAC7B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,qBAAqB,EACpC,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CA8KtC"}
@@ -4,6 +4,7 @@ import { EthAddress, Fr } from '@aztec/aztec.js';
4
4
  import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
5
5
  import { NULL_KEY, getAddressFromPrivateKey, getPublicClient } from '@aztec/ethereum';
6
6
  import { SecretValue } from '@aztec/foundation/config';
7
+ import { bufferToHex } from '@aztec/foundation/string';
7
8
  import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
8
9
  import { P2PApiSchema } from '@aztec/stdlib/interfaces/server';
9
10
  import { initTelemetryClient, telemetryClientConfigMappings } from '@aztec/telemetry-client';
@@ -74,7 +75,6 @@ export async function startNode(options, signalHandlers, services, adminServices
74
75
  ...config
75
76
  };
76
77
  }
77
- // if no publisher private key, then use l1Mnemonic
78
78
  if (!options.archiver) {
79
79
  // expect archiver url in node config
80
80
  const archiverUrl = nodeConfig.archiverUrl;
@@ -93,7 +93,7 @@ export async function startNode(options, signalHandlers, services, adminServices
93
93
  };
94
94
  let account;
95
95
  if (sequencerConfig.publisherPrivateKey.getValue() === NULL_KEY) {
96
- if (sequencerConfig.validatorPrivateKeys.getValue().length) {
96
+ if (sequencerConfig.validatorPrivateKeys?.getValue().length) {
97
97
  sequencerConfig.publisherPrivateKey = new SecretValue(sequencerConfig.validatorPrivateKeys.getValue()[0]);
98
98
  } else if (!options.l1Mnemonic) {
99
99
  userLog('--sequencer.publisherPrivateKey or --l1-mnemonic is required to start Aztec Node with --sequencer option');
@@ -107,6 +107,13 @@ export async function startNode(options, signalHandlers, services, adminServices
107
107
  nodeConfig.publisherPrivateKey = sequencerConfig.publisherPrivateKey;
108
108
  nodeConfig.coinbase ??= EthAddress.fromString(getAddressFromPrivateKey(nodeConfig.publisherPrivateKey.getValue()));
109
109
  }
110
+ // If we dont have a slasher private key, derive one from the mnemonic if provided, using account index 1 (zero was used for the sequencer)
111
+ if (options.l1Mnemonic && (!nodeConfig.slasherPrivateKey || nodeConfig.slasherPrivateKey.getValue() === NULL_KEY)) {
112
+ const account = mnemonicToAccount(options.l1Mnemonic, {
113
+ accountIndex: 1
114
+ });
115
+ nodeConfig.slasherPrivateKey = new SecretValue(bufferToHex(Buffer.from(account.getHdKey().privateKey)));
116
+ }
110
117
  if (nodeConfig.p2pEnabled) {
111
118
  // ensure bootstrapNodes is an array
112
119
  if (nodeConfig.bootstrapNodes && typeof nodeConfig.bootstrapNodes === 'string') {
@@ -1 +1 @@
1
- {"version":3,"file":"start_p2p_bootstrap.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_p2p_bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AASjE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK;;GAcf"}
1
+ {"version":3,"file":"start_p2p_bootstrap.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_p2p_bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AAajE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK;;GAiBf"}
@@ -4,7 +4,7 @@ import { createStore } from '@aztec/kv-store/lmdb-v2';
4
4
  import { BootstrapNode, bootnodeConfigMappings } from '@aztec/p2p';
5
5
  import { emptyChainConfig } from '@aztec/stdlib/config';
6
6
  import { P2PBootstrapApiSchema } from '@aztec/stdlib/interfaces/server';
7
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
7
+ import { initTelemetryClient, telemetryClientConfigMappings } from '@aztec/telemetry-client';
8
8
  import { extractRelevantOptions } from '../util.js';
9
9
  export async function startP2PBootstrap(options, signalHandlers, services, userLog) {
10
10
  // Start a P2P bootstrap node.
@@ -14,7 +14,8 @@ export async function startP2PBootstrap(options, signalHandlers, services, userL
14
14
  peerIdPrivateKey: '<redacted>'
15
15
  };
16
16
  userLog(`Starting P2P bootstrap node with config: ${jsonStringify(safeConfig)}`);
17
- const telemetryClient = initTelemetryClient(getTelemetryClientConfig());
17
+ const telemetryConfig = extractRelevantOptions(options, telemetryClientConfigMappings, 'tel');
18
+ const telemetryClient = initTelemetryClient(telemetryConfig);
18
19
  const store = await createStore('p2p-bootstrap', 1, config, createLogger('p2p:bootstrap:store'));
19
20
  const node = new BootstrapNode(store, telemetryClient);
20
21
  await node.start(config);
@@ -1 +1 @@
1
- {"version":3,"file":"start_prover_agent.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAgBnD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,iBAiEf"}
1
+ {"version":3,"file":"start_prover_agent.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAgBnD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,iBA2Df"}
@@ -12,11 +12,6 @@ export async function startProverAgent(options, signalHandlers, services, userLo
12
12
  userLog(`Starting a prover agent with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
13
13
  process.exit(1);
14
14
  }
15
- // Check if running on ARM and fast-fail if so.
16
- if (process.arch.startsWith('arm')) {
17
- userLog(`Prover agent is not supported on ARM architecture (detected: ${process.arch}). Exiting.`);
18
- process.exit(1);
19
- }
20
15
  const config = {
21
16
  ...getProverNodeAgentConfigFromEnv(),
22
17
  ...extractRelevantOptions(options, proverAgentConfigMappings, 'proverAgent')
@@ -1 +1 @@
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;AAY5B,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+GvC"}
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;AAY5B,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,CAyGvC"}
@@ -19,11 +19,6 @@ export async function startProverNode(options, signalHandlers, services, userLog
19
19
  userLog(`Starting a prover-node with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
20
20
  process.exit(1);
21
21
  }
22
- // Check if running on ARM and fast-fail if so.
23
- if (process.arch.startsWith('arm')) {
24
- userLog(`Prover node is not supported on ARM architecture (detected: ${process.arch}). Exiting.`);
25
- process.exit(1);
26
- }
27
22
  let proverConfig = {
28
23
  ...getProverNodeConfigFromEnv(),
29
24
  ...extractRelevantOptions(options, proverNodeConfigMappings, 'proverNode')
@@ -12,29 +12,40 @@ const TRANSFER_AMOUNT = 33n;
12
12
  */ async function main() {
13
13
  logger.info('Running token contract test on HTTP interface.');
14
14
  const [aliceWallet, bobWallet] = await getDeployedTestAccountsWallets(pxe);
15
- const alice = aliceWallet.getCompleteAddress();
16
- const bob = bobWallet.getCompleteAddress();
17
- logger.info(`Fetched Alice and Bob accounts: ${alice.address.toString()}, ${bob.address.toString()}`);
15
+ const alice = aliceWallet.getAddress();
16
+ const bob = bobWallet.getAddress();
17
+ logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
18
18
  logger.info('Deploying Token...');
19
- const token = await TokenContract.deploy(aliceWallet, alice, 'TokenName', 'TokenSymbol', 18).send().deployed();
19
+ const token = await TokenContract.deploy(aliceWallet, alice, 'TokenName', 'TokenSymbol', 18).send({
20
+ from: alice
21
+ }).deployed();
20
22
  logger.info('Token deployed');
21
23
  // Create the contract abstraction and link it to Alice's and Bob's wallet for future signing
22
24
  const tokenAlice = await TokenContract.at(token.address, aliceWallet);
23
25
  const tokenBob = await TokenContract.at(token.address, bobWallet);
24
26
  // Mint tokens to Alice
25
27
  logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
26
- const from = aliceWallet.getAddress(); // we are setting from to Alice here because we need a sender to calculate the tag
27
- await tokenAlice.methods.mint_to_private(from, aliceWallet.getAddress(), ALICE_MINT_BALANCE).send().wait();
28
+ await tokenAlice.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({
29
+ from: alice
30
+ }).wait();
28
31
  logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
29
- const balanceAfterMint = await tokenAlice.methods.balance_of_private(alice).simulate();
32
+ const balanceAfterMint = await tokenAlice.methods.balance_of_private(alice).simulate({
33
+ from: alice
34
+ });
30
35
  logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
31
36
  // We will now transfer tokens from Alice to Bob
32
37
  logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
33
- await tokenAlice.methods.transfer(bob, TRANSFER_AMOUNT).send().wait();
38
+ await tokenAlice.methods.transfer(bob, TRANSFER_AMOUNT).send({
39
+ from: alice
40
+ }).wait();
34
41
  // Check the new balances
35
- const aliceBalance = await tokenAlice.methods.balance_of_private(alice).simulate();
42
+ const aliceBalance = await tokenAlice.methods.balance_of_private(alice).simulate({
43
+ from: alice
44
+ });
36
45
  logger.info(`Alice's balance ${aliceBalance}`);
37
- const bobBalance = await tokenBob.methods.balance_of_private(bob).simulate();
46
+ const bobBalance = await tokenBob.methods.balance_of_private(bob).simulate({
47
+ from: bob
48
+ });
38
49
  logger.info(`Bob's balance ${bobBalance}`);
39
50
  }
40
51
  main().then(()=>{
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/fields';
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 { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
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 getContractInstanceFromDeployParams(TokenContract.artifact, {
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 getContractInstanceFromDeployParams(FPCContract.artifact, {
35
+ return await getContractInstanceFromInstantiationParams(FPCContract.artifact, {
36
36
  constructorArgs: [
37
37
  bananaCoin,
38
38
  admin
@@ -48,10 +48,12 @@ export async function setupBananaFPC(initialAccounts, deployer, log) {
48
48
  const admin = getBananaAdmin(initialAccounts);
49
49
  const [bananaCoin, fpc] = await Promise.all([
50
50
  TokenContract.deploy(deployer, 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
55
  FPCContract.deploy(deployer, bananaCoinAddress, admin).send({
56
+ from: admin,
55
57
  contractAddressSalt: BANANA_FPC_SALT,
56
58
  universalDeploy: true
57
59
  }).deployed()
@@ -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;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,EAAE,KAAK,gBAAgB,EAAyC,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,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E,OAAO,CAAC;IACf,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;;;;GA0GtF;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;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM,mDAI3F"}
@@ -2,11 +2,11 @@
2
2
  import { getSchnorrWallet } from '@aztec/accounts/schnorr';
3
3
  import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
4
4
  import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
- import { AnvilTestWatcher, EthCheatCodes } from '@aztec/aztec.js/testing';
6
5
  import { createBlobSinkClient } from '@aztec/blob-sink/client';
7
6
  import { setupSponsoredFPC } from '@aztec/cli/cli-utils';
8
7
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
9
8
  import { NULL_KEY, createEthereumChain, deployL1Contracts, deployMulticall3, getL1ContractsConfigEnvVars, waitForPublicClient } from '@aztec/ethereum';
9
+ import { EthCheatCodes } from '@aztec/ethereum/test';
10
10
  import { SecretValue } from '@aztec/foundation/config';
11
11
  import { Fr } from '@aztec/foundation/fields';
12
12
  import { createLogger } from '@aztec/foundation/log';
@@ -21,6 +21,7 @@ import { mnemonicToAccount } from 'viem/accounts';
21
21
  import { foundry } from 'viem/chains';
22
22
  import { createAccountLogs } from '../cli/util.js';
23
23
  import { DefaultMnemonic } from '../mnemonic.js';
24
+ import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
24
25
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
25
26
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
26
27
  const logger = createLogger('sandbox');
@@ -72,12 +73,19 @@ const localAnvil = foundry;
72
73
  const privKey = hdAccount.getHdKey().privateKey;
73
74
  aztecNodeConfig.publisherPrivateKey = new SecretValue(`0x${Buffer.from(privKey).toString('hex')}`);
74
75
  }
75
- if (!aztecNodeConfig.validatorPrivateKeys.getValue().length) {
76
+ if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
76
77
  const privKey = hdAccount.getHdKey().privateKey;
77
78
  aztecNodeConfig.validatorPrivateKeys = new SecretValue([
78
79
  `0x${Buffer.from(privKey).toString('hex')}`
79
80
  ]);
80
81
  }
82
+ if (!aztecNodeConfig.slasherPrivateKey?.getValue() || aztecNodeConfig.slasherPrivateKey?.getValue() === NULL_KEY) {
83
+ const account = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic, {
84
+ accountIndex: 1
85
+ });
86
+ const privKey = account.getHdKey().privateKey;
87
+ aztecNodeConfig.slasherPrivateKey = new SecretValue(`0x${Buffer.from(privKey).toString('hex')}`);
88
+ }
81
89
  const initialAccounts = await (async ()=>{
82
90
  if (config.testAccounts === true || config.testAccounts === undefined) {
83
91
  if (aztecNodeConfig.p2pEnabled) {
@@ -1 +1 @@
1
- {"version":3,"file":"sponsored_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,GAAG,EAAuC,MAAM,iBAAiB,CAAC;AAUtH,wBAAsB,sBAAsB,oDAE3C;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":"AAAA,OAAO,EAGL,KAAK,GAAG,EAET,MAAM,iBAAiB,CAAC;AAUzB,wBAAsB,sBAAsB,oDAE3C;AAED,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,GAAG,mDAO5D"}
@@ -1,8 +1,8 @@
1
- import { Fr, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
1
+ import { Fr, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js';
2
2
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
3
3
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
4
4
  async function getSponsoredFPCInstance() {
5
- return await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
5
+ return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
6
6
  salt: new Fr(SPONSORED_FPC_SALT)
7
7
  });
8
8
  }
@@ -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;IAI/C,YAAY,CAAC,SAAS,EAAE,OAAO;IAIzB,KAAK;IA2BL,IAAI;IAMJ,OAAO;IAMP,YAAY;IAOZ,4BAA4B;IAiB5B,gBAAgB;CA4CvB"}
@@ -0,0 +1,143 @@
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.isMarkingAsProven = isMarkingAsProven;
42
+ }
43
+ setIsSandbox(isSandbox) {
44
+ this.isSandbox = isSandbox;
45
+ }
46
+ async start() {
47
+ if (this.filledRunningPromise) {
48
+ throw new Error('Watcher already watching for filled slot');
49
+ }
50
+ const config = await this.rollupCheatCodes.getConfig();
51
+ this.l2SlotDuration = config.slotDuration;
52
+ // If auto mining is not supported (e.g., we are on a real network), then we
53
+ // will simple do nothing. But if on an anvil or the like, this make sure that
54
+ // the sandbox and tests don't break because time is frozen and we never get to
55
+ // the next slot.
56
+ const isAutoMining = await this.cheatcodes.isAutoMining();
57
+ if (isAutoMining) {
58
+ this.filledRunningPromise = new RunningPromise(()=>this.warpTimeIfNeeded(), this.logger, 200);
59
+ this.filledRunningPromise.start();
60
+ this.syncDateProviderPromise = new RunningPromise(()=>this.syncDateProviderToL1IfBehind(), this.logger, 200);
61
+ this.syncDateProviderPromise.start();
62
+ this.markingAsProvenRunningPromise = new RunningPromise(()=>this.markAsProven(), this.logger, 200);
63
+ this.markingAsProvenRunningPromise.start();
64
+ this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
65
+ } else {
66
+ this.logger.info(`Watcher not started because not auto mining`);
67
+ }
68
+ }
69
+ async stop() {
70
+ await this.filledRunningPromise?.stop();
71
+ await this.syncDateProviderPromise?.stop();
72
+ await this.markingAsProvenRunningPromise?.stop();
73
+ }
74
+ async trigger() {
75
+ await this.filledRunningPromise?.trigger();
76
+ await this.syncDateProviderPromise?.trigger();
77
+ await this.markingAsProvenRunningPromise?.trigger();
78
+ }
79
+ async markAsProven() {
80
+ if (!this.isMarkingAsProven) {
81
+ return;
82
+ }
83
+ await this.rollupCheatCodes.markAsProven();
84
+ }
85
+ async syncDateProviderToL1IfBehind() {
86
+ // this doesn't apply to the sandbox, because we don't have a date provider in the sandbox
87
+ if (!this.dateProvider) {
88
+ return;
89
+ }
90
+ const l1Time = await this.cheatcodes.timestamp() * 1000;
91
+ const wallTime = this.dateProvider.now();
92
+ if (l1Time > wallTime) {
93
+ this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
94
+ this.dateProvider.setTime(l1Time);
95
+ } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
96
+ this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
97
+ await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
98
+ }
99
+ }
100
+ async warpTimeIfNeeded() {
101
+ try {
102
+ const currentSlot = await this.rollup.read.getCurrentSlot();
103
+ const pendingBlockNumber = BigInt(await this.rollup.read.getPendingBlockNumber());
104
+ const blockLog = await this.rollup.read.getBlock([
105
+ pendingBlockNumber
106
+ ]);
107
+ const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([
108
+ currentSlot + 1n
109
+ ]));
110
+ if (currentSlot === blockLog.slotNumber) {
111
+ // We should jump to the next slot
112
+ try {
113
+ await this.cheatcodes.warp(nextSlotTimestamp, {
114
+ resetBlockInterval: true,
115
+ updateDateProvider: this.dateProvider
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
+ updateDateProvider: this.dateProvider
133
+ });
134
+ } catch (e) {
135
+ this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
136
+ }
137
+ this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
138
+ }
139
+ } catch {
140
+ this.logger.error('mineIfSlotFilled failed');
141
+ }
142
+ }
143
+ }
@@ -0,0 +1,59 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
4
+ import type { Note } from '@aztec/stdlib/note';
5
+ /**
6
+ * A class that provides utility functions for interacting with the aztec chain.
7
+ */
8
+ export declare class AztecCheatCodes {
9
+ /**
10
+ * The PXE Service to use for interacting with the chain
11
+ */
12
+ pxe: PXE;
13
+ /**
14
+ * The logger to use for the aztec cheatcodes
15
+ */
16
+ logger: import("@aztec/foundation/log").Logger;
17
+ constructor(
18
+ /**
19
+ * The PXE Service to use for interacting with the chain
20
+ */
21
+ pxe: PXE,
22
+ /**
23
+ * The logger to use for the aztec cheatcodes
24
+ */
25
+ logger?: import("@aztec/foundation/log").Logger);
26
+ /**
27
+ * Computes the slot value for a given map and key.
28
+ * @param mapSlot - The slot of the map (specified in Aztec.nr contract)
29
+ * @param key - The key to lookup in the map
30
+ * @returns The storage slot of the value in the map
31
+ */
32
+ computeSlotInMap(mapSlot: Fr | bigint, key: Fr | bigint | AztecAddress): Promise<Fr>;
33
+ /**
34
+ * Get the current blocknumber
35
+ * @returns The current block number
36
+ */
37
+ blockNumber(): Promise<number>;
38
+ /**
39
+ * Get the current timestamp
40
+ * @returns The current timestamp
41
+ */
42
+ timestamp(): Promise<number>;
43
+ /**
44
+ * Loads the value stored at the given slot in the public storage of the given contract.
45
+ * @param who - The address of the contract
46
+ * @param slot - The storage slot to lookup
47
+ * @returns The value stored at the given slot
48
+ */
49
+ loadPublic(who: AztecAddress, slot: Fr | bigint): Promise<Fr>;
50
+ /**
51
+ * Loads the value stored at the given slot in the private storage of the given contract.
52
+ * @param contract - The address of the contract
53
+ * @param recipient - The address whose public key was used to encrypt the note
54
+ * @param slot - The storage slot to lookup
55
+ * @returns The notes stored at the given slot
56
+ */
57
+ loadPrivate(recipient: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]>;
58
+ }
59
+ //# sourceMappingURL=aztec_cheat_codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aztec_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/testing/aztec_cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,qBAAa,eAAe;IAExB;;OAEG;IACI,GAAG,EAAE,GAAG;IACf;;OAEG;IACI,MAAM;;IAPb;;OAEG;IACI,GAAG,EAAE,GAAG;IACf;;OAEG;IACI,MAAM,yCAAsC;IAGrD;;;;;OAKG;IACI,gBAAgB,CAAC,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;IAK3F;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzC;;;;;OAKG;IACU,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAK1E;;;;;;OAMG;IACU,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAQ9G"}