@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c

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 (156) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +60 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +261 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +69 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +315 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +99 -0
  13. package/dest/bench/utils.d.ts +10 -27
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +27 -43
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -7
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +66 -38
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +34 -53
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +9 -6
  25. package/dest/e2e_epochs/epochs_test.d.ts +56 -17
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +222 -42
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +60 -0
  31. package/dest/e2e_fees/fees_test.d.ts +16 -5
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +87 -88
  34. package/dest/e2e_l1_publisher/write_json.d.ts +8 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +57 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +5 -5
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +132 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +56 -21
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +154 -125
  49. package/dest/e2e_p2p/shared.d.ts +41 -3
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +146 -6
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +10 -5
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +51 -24
  55. package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
  58. package/dest/fixtures/fixtures.d.ts +5 -6
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +4 -3
  61. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  62. package/dest/fixtures/get_acvm_config.js +2 -14
  63. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  64. package/dest/fixtures/get_bb_config.js +8 -15
  65. package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
  66. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  67. package/dest/fixtures/l1_to_l2_messaging.js +44 -18
  68. package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
  69. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  70. package/dest/fixtures/setup_l1_contracts.js +3 -3
  71. package/dest/fixtures/setup_p2p_test.d.ts +14 -6
  72. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  73. package/dest/fixtures/setup_p2p_test.js +73 -21
  74. package/dest/fixtures/snapshot_manager.d.ts +8 -3
  75. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  76. package/dest/fixtures/snapshot_manager.js +120 -104
  77. package/dest/fixtures/token_utils.d.ts +4 -3
  78. package/dest/fixtures/token_utils.d.ts.map +1 -1
  79. package/dest/fixtures/token_utils.js +24 -7
  80. package/dest/fixtures/utils.d.ts +65 -22
  81. package/dest/fixtures/utils.d.ts.map +1 -1
  82. package/dest/fixtures/utils.js +439 -318
  83. package/dest/fixtures/web3signer.d.ts +5 -0
  84. package/dest/fixtures/web3signer.d.ts.map +1 -0
  85. package/dest/fixtures/web3signer.js +42 -0
  86. package/dest/shared/cross_chain_test_harness.d.ts +28 -18
  87. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  88. package/dest/shared/cross_chain_test_harness.js +97 -41
  89. package/dest/shared/gas_portal_test_harness.d.ts +23 -18
  90. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  91. package/dest/shared/gas_portal_test_harness.js +43 -25
  92. package/dest/shared/submit-transactions.d.ts.map +1 -1
  93. package/dest/shared/uniswap_l1_l2.d.ts +5 -6
  94. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  95. package/dest/shared/uniswap_l1_l2.js +136 -90
  96. package/dest/simulators/lending_simulator.d.ts +5 -6
  97. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  98. package/dest/simulators/lending_simulator.js +11 -15
  99. package/dest/simulators/token_simulator.d.ts +2 -1
  100. package/dest/simulators/token_simulator.d.ts.map +1 -1
  101. package/dest/simulators/token_simulator.js +16 -13
  102. package/dest/spartan/setup_test_wallets.d.ts +8 -1
  103. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  104. package/dest/spartan/setup_test_wallets.js +108 -22
  105. package/dest/spartan/utils.d.ts +60 -307
  106. package/dest/spartan/utils.d.ts.map +1 -1
  107. package/dest/spartan/utils.js +200 -115
  108. package/package.json +60 -56
  109. package/src/bench/client_flows/benchmark.ts +341 -0
  110. package/src/bench/client_flows/client_flows_benchmark.ts +422 -0
  111. package/src/bench/client_flows/config.ts +61 -0
  112. package/src/bench/client_flows/data_extractor.ts +111 -0
  113. package/src/bench/utils.ts +26 -52
  114. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
  115. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
  116. package/src/e2e_deploy_contract/deploy_test.ts +11 -8
  117. package/src/e2e_epochs/epochs_test.ts +276 -54
  118. package/src/e2e_fees/bridging_race.notest.ts +75 -0
  119. package/src/e2e_fees/fees_test.ts +121 -108
  120. package/src/e2e_l1_publisher/write_json.ts +74 -0
  121. package/src/e2e_multi_validator/utils.ts +258 -0
  122. package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
  123. package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
  124. package/src/e2e_p2p/p2p_network.ts +212 -144
  125. package/src/e2e_p2p/shared.ts +234 -14
  126. package/src/e2e_token_contract/token_contract_test.ts +42 -38
  127. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  128. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
  129. package/src/fixtures/fixtures.ts +4 -3
  130. package/src/fixtures/get_acvm_config.ts +2 -10
  131. package/src/fixtures/get_bb_config.ts +15 -11
  132. package/src/fixtures/l1_to_l2_messaging.ts +53 -23
  133. package/src/fixtures/setup_l1_contracts.ts +5 -6
  134. package/src/fixtures/setup_p2p_test.ts +112 -30
  135. package/src/fixtures/snapshot_manager.ts +150 -102
  136. package/src/fixtures/token_utils.ts +33 -8
  137. package/src/fixtures/utils.ts +530 -352
  138. package/src/fixtures/web3signer.ts +46 -0
  139. package/src/guides/up_quick_start.sh +4 -4
  140. package/src/shared/cross_chain_test_harness.ts +92 -52
  141. package/src/shared/gas_portal_test_harness.ts +47 -31
  142. package/src/shared/uniswap_l1_l2.ts +127 -124
  143. package/src/simulators/lending_simulator.ts +11 -15
  144. package/src/simulators/token_simulator.ts +17 -12
  145. package/src/spartan/DEVELOP.md +116 -0
  146. package/src/spartan/setup_test_wallets.ts +144 -29
  147. package/src/spartan/utils.ts +194 -116
  148. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  149. package/dest/sample-dapp/connect.js +0 -12
  150. package/dest/sample-dapp/contracts.js +0 -10
  151. package/dest/sample-dapp/deploy.js +0 -35
  152. package/dest/sample-dapp/index.js +0 -98
  153. package/src/sample-dapp/connect.mjs +0 -16
  154. package/src/sample-dapp/contracts.mjs +0 -14
  155. package/src/sample-dapp/deploy.mjs +0 -40
  156. package/src/sample-dapp/index.mjs +0 -128
@@ -1,93 +1,113 @@
1
1
  import { getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
2
- import { ChainMonitor } from '@aztec/aztec.js/ethereum';
3
- import { RollupContract, getExpectedAddress, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
4
- import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
5
- import { EthCheatCodesWithState } from '@aztec/ethereum/test';
2
+ import { EthAddress, Fr } from '@aztec/aztec.js';
3
+ import { GSEContract, MultiAdderArtifact, RollupContract, createL1TxUtilsFromViemWallet, deployL1Contract, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
4
+ import { ChainMonitor } from '@aztec/ethereum/test';
5
+ import { SecretValue } from '@aztec/foundation/config';
6
6
  import { createLogger } from '@aztec/foundation/log';
7
- import { ForwarderAbi, ForwarderBytecode, RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
8
- import { SpamContract } from '@aztec/noir-contracts.js/Spam';
7
+ import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
8
+ import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
9
9
  import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
10
+ import { tryStop } from '@aztec/stdlib/interfaces/server';
11
+ import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
12
+ import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
10
13
  import { getGenesisValues } from '@aztec/world-state/testing';
11
14
  import getPort from 'get-port';
12
- import { getContract } from 'viem';
15
+ import { getAddress, getContract } from 'viem';
13
16
  import { privateKeyToAccount } from 'viem/accounts';
14
- import { ATTESTER_PRIVATE_KEYS_START_INDEX, PROPOSER_PRIVATE_KEYS_START_INDEX, createValidatorConfig, generatePrivateKeys } from '../fixtures/setup_p2p_test.js';
17
+ import { ATTESTER_PRIVATE_KEYS_START_INDEX, createValidatorConfig, generatePrivateKeys } from '../fixtures/setup_p2p_test.js';
15
18
  import { createSnapshotManager, deployAccounts } from '../fixtures/snapshot_manager.js';
16
- import { getPrivateKeyFromIndex } from '../fixtures/utils.js';
19
+ import { getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
17
20
  import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
18
21
  // Use a fixed bootstrap node private key so that we can re-use the same snapshot and the nodes can find each other
19
22
  const BOOTSTRAP_NODE_PRIVATE_KEY = '080212208f988fc0899e4a73a5aee4d271a5f20670603a756ad8d84f2c94263a6427c591';
20
23
  const l1ContractsConfig = getL1ContractsConfigEnvVars();
21
24
  export const WAIT_FOR_TX_TIMEOUT = l1ContractsConfig.aztecSlotDuration * 3;
22
- export const SHORTENED_BLOCK_TIME_CONFIG = {
25
+ export const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES = {
23
26
  aztecSlotDuration: 12,
24
- ethereumSlotDuration: 4
27
+ ethereumSlotDuration: 4,
28
+ aztecProofSubmissionWindow: 640
25
29
  };
26
30
  export class P2PNetworkTest {
31
+ testName;
27
32
  bootstrapNodeEnr;
28
33
  bootNodePort;
34
+ numberOfValidators;
29
35
  numberOfNodes;
30
36
  metricsPort;
31
37
  snapshotManager;
38
+ baseAccountPrivateKey;
32
39
  baseAccount;
33
40
  logger;
34
41
  monitor;
35
42
  ctx;
36
43
  attesterPrivateKeys;
37
44
  attesterPublicKeys;
38
- proposerPrivateKeys;
39
45
  peerIdPrivateKeys;
46
+ validators;
40
47
  deployedAccounts;
41
48
  prefilledPublicData;
42
49
  // The re-execution test needs a wallet and a spam contract
43
50
  wallet;
51
+ defaultAccountAddress;
44
52
  spamContract;
45
53
  bootstrapNode;
46
- cleanupInterval;
47
- gasUtils;
48
- constructor(testName, bootstrapNodeEnr, bootNodePort, numberOfNodes, initialValidatorConfig, // If set enable metrics collection
49
- metricsPort){
54
+ constructor(testName, bootstrapNodeEnr, bootNodePort, numberOfValidators, initialValidatorConfig, numberOfNodes = 0, // If set enable metrics collection
55
+ metricsPort, startProverNode, mockZkPassportVerifier){
56
+ this.testName = testName;
50
57
  this.bootstrapNodeEnr = bootstrapNodeEnr;
51
58
  this.bootNodePort = bootNodePort;
59
+ this.numberOfValidators = numberOfValidators;
52
60
  this.numberOfNodes = numberOfNodes;
53
61
  this.metricsPort = metricsPort;
54
62
  this.attesterPrivateKeys = [];
55
63
  this.attesterPublicKeys = [];
56
- this.proposerPrivateKeys = [];
57
64
  this.peerIdPrivateKeys = [];
65
+ this.validators = [];
58
66
  this.deployedAccounts = [];
59
67
  this.prefilledPublicData = [];
60
- this.cleanupInterval = undefined;
61
- this.gasUtils = undefined;
62
68
  this.logger = createLogger(`e2e:e2e_p2p:${testName}`);
63
69
  // Set up the base account and node private keys for the initial network deployment
64
- this.baseAccount = privateKeyToAccount(`0x${getPrivateKeyFromIndex(0).toString('hex')}`);
65
- this.proposerPrivateKeys = generatePrivateKeys(PROPOSER_PRIVATE_KEYS_START_INDEX, numberOfNodes);
66
- this.attesterPrivateKeys = generatePrivateKeys(ATTESTER_PRIVATE_KEYS_START_INDEX, numberOfNodes);
70
+ this.baseAccountPrivateKey = `0x${getPrivateKeyFromIndex(1).toString('hex')}`;
71
+ this.baseAccount = privateKeyToAccount(this.baseAccountPrivateKey);
72
+ this.attesterPrivateKeys = generatePrivateKeys(ATTESTER_PRIVATE_KEYS_START_INDEX + numberOfNodes, numberOfValidators);
67
73
  this.attesterPublicKeys = this.attesterPrivateKeys.map((privateKey)=>privateKeyToAccount(privateKey).address);
74
+ const zkPassportParams = ZkPassportProofParams.random();
68
75
  this.snapshotManager = createSnapshotManager(`e2e_p2p_network/${testName}`, process.env.E2E_DATA_PATH, {
69
76
  ...initialValidatorConfig,
70
77
  ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
71
78
  aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
72
79
  aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
73
- aztecProofSubmissionWindow: initialValidatorConfig.aztecProofSubmissionWindow ?? l1ContractsConfig.aztecProofSubmissionWindow,
80
+ aztecProofSubmissionEpochs: initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
81
+ slashingRoundSizeInEpochs: initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
82
+ slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
83
+ aztecTargetCommitteeSize: numberOfValidators,
74
84
  salt: 420,
75
85
  metricsPort: metricsPort,
76
- numberOfInitialFundedAccounts: 1
86
+ numberOfInitialFundedAccounts: 2,
87
+ startProverNode
77
88
  }, {
89
+ ...initialValidatorConfig,
78
90
  aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
91
+ slashingRoundSizeInEpochs: initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
92
+ slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
79
93
  ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
80
94
  aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
81
- aztecProofSubmissionWindow: initialValidatorConfig.aztecProofSubmissionWindow ?? l1ContractsConfig.aztecProofSubmissionWindow,
82
- initialValidators: []
95
+ aztecProofSubmissionEpochs: initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
96
+ aztecTargetCommitteeSize: numberOfValidators,
97
+ initialValidators: [],
98
+ zkPassportArgs: {
99
+ mockZkPassportVerifier,
100
+ zkPassportDomain: zkPassportParams.domain,
101
+ zkPassportScope: zkPassportParams.scope
102
+ }
83
103
  });
84
104
  }
85
- static async create({ testName, numberOfNodes, basePort, metricsPort, initialConfig }) {
105
+ static async create({ testName, numberOfNodes, numberOfValidators, basePort, metricsPort, initialConfig, startProverNode, mockZkPassportVerifier }) {
86
106
  const port = basePort || await getPort();
87
107
  const bootstrapNodeENR = await getBootstrapNodeEnr(BOOTSTRAP_NODE_PRIVATE_KEY, port);
88
108
  const bootstrapNodeEnr = bootstrapNodeENR.encodeTxt();
89
109
  const initialValidatorConfig = await createValidatorConfig(initialConfig ?? {}, bootstrapNodeEnr);
90
- return new P2PNetworkTest(testName, bootstrapNodeEnr, port, numberOfNodes, initialValidatorConfig, metricsPort);
110
+ return new P2PNetworkTest(testName, bootstrapNodeEnr, port, numberOfValidators, initialValidatorConfig, numberOfNodes, metricsPort, startProverNode, mockZkPassportVerifier);
91
111
  }
92
112
  get fundedAccount() {
93
113
  if (!this.deployedAccounts[0]) {
@@ -95,103 +115,88 @@ export class P2PNetworkTest {
95
115
  }
96
116
  return this.deployedAccounts[0];
97
117
  }
98
- /**
99
- * Start a loop to sync the mock system time with the L1 block time
100
- */ startSyncMockSystemTimeInterval() {
101
- this.cleanupInterval = setInterval(()=>{
102
- void this.syncMockSystemTime().catch((err)=>this.logger.error('Error syncing mock system time', err));
103
- }, l1ContractsConfig.aztecSlotDuration * 1000);
104
- }
105
- /**
106
- * When using fake timers, we need to keep the system and anvil clocks in sync.
107
- */ async syncMockSystemTime() {
108
- this.logger.info('Syncing mock system time');
109
- const { dateProvider, deployL1ContractsValues } = this.ctx;
110
- // Send a tx and only update the time after the tx is mined, as eth time is not continuous
111
- const { receipt } = await this.gasUtils.sendAndMonitorTransaction({
112
- to: this.baseAccount.address,
113
- data: '0x',
114
- value: 1n
115
- });
116
- const timestamp = await deployL1ContractsValues.publicClient.getBlock({
117
- blockNumber: receipt.blockNumber
118
- });
119
- this.logger.info(`Timestamp: ${timestamp.timestamp}`);
120
- dateProvider.setTime(Number(timestamp.timestamp) * 1000);
121
- }
122
- async applyBaseSnapshots() {
118
+ async addBootstrapNode() {
123
119
  await this.snapshotManager.snapshot('add-bootstrap-node', async ({ aztecNodeConfig })=>{
124
120
  const telemetry = getEndToEndTestTelemetryClient(this.metricsPort);
125
121
  this.bootstrapNode = await createBootstrapNodeFromPrivateKey(BOOTSTRAP_NODE_PRIVATE_KEY, this.bootNodePort, telemetry, aztecNodeConfig);
126
122
  // Overwrite enr with updated info
127
123
  this.bootstrapNodeEnr = this.bootstrapNode.getENR().encodeTxt();
128
124
  });
129
- await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, aztecNodeConfig, dateProvider })=>{
125
+ }
126
+ getValidators() {
127
+ const validators = [];
128
+ for(let i = 0; i < this.numberOfValidators; i++){
129
+ const keyIndex = i;
130
+ const attester = privateKeyToAccount(this.attesterPrivateKeys[keyIndex]);
131
+ validators.push({
132
+ attester: EthAddress.fromString(attester.address),
133
+ withdrawer: EthAddress.fromString(attester.address),
134
+ bn254SecretKey: new SecretValue(Fr.random().toBigInt())
135
+ });
136
+ this.logger.info(`Adding attester ${attester.address} as validator`);
137
+ }
138
+ return {
139
+ validators
140
+ };
141
+ }
142
+ async applyBaseSnapshots() {
143
+ await this.addBootstrapNode();
144
+ await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, dateProvider, cheatCodes })=>{
130
145
  const rollup = getContract({
131
146
  address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
132
147
  abi: RollupAbi,
133
- client: deployL1ContractsValues.walletClient
148
+ client: deployL1ContractsValues.l1Client
134
149
  });
135
- this.logger.verbose(`Adding ${this.numberOfNodes} validators`);
150
+ this.logger.info(`Adding ${this.numberOfValidators} validators`);
136
151
  const stakingAsset = getContract({
137
152
  address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
138
153
  abi: TestERC20Abi,
139
- client: deployL1ContractsValues.walletClient
154
+ client: deployL1ContractsValues.l1Client
155
+ });
156
+ const { address: multiAdderAddress } = await deployL1Contract(deployL1ContractsValues.l1Client, MultiAdderArtifact.contractAbi, MultiAdderArtifact.contractBytecode, [
157
+ rollup.address,
158
+ deployL1ContractsValues.l1Client.account.address
159
+ ]);
160
+ const multiAdder = getContract({
161
+ address: multiAdderAddress.toString(),
162
+ abi: MultiAdderArtifact.contractAbi,
163
+ client: deployL1ContractsValues.l1Client
140
164
  });
141
- const stakeNeeded = l1ContractsConfig.minimumStake * BigInt(this.numberOfNodes);
165
+ const stakeNeeded = await rollup.read.getActivationThreshold() * BigInt(this.numberOfValidators);
142
166
  await Promise.all([
143
167
  await stakingAsset.write.mint([
144
- deployL1ContractsValues.walletClient.account.address,
145
- stakeNeeded
146
- ], {}),
147
- await stakingAsset.write.approve([
148
- deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
168
+ multiAdder.address,
149
169
  stakeNeeded
150
170
  ], {})
151
- ].map((txHash)=>deployL1ContractsValues.publicClient.waitForTransactionReceipt({
171
+ ].map((txHash)=>deployL1ContractsValues.l1Client.waitForTransactionReceipt({
152
172
  hash: txHash
153
173
  })));
154
- const validators = [];
155
- for(let i = 0; i < this.numberOfNodes; i++){
156
- const attester = privateKeyToAccount(this.attesterPrivateKeys[i]);
157
- const proposerEOA = privateKeyToAccount(this.proposerPrivateKeys[i]);
158
- const forwarder = getExpectedAddress(ForwarderAbi, ForwarderBytecode, [
159
- proposerEOA.address
160
- ], proposerEOA.address).address;
161
- validators.push({
162
- attester: attester.address,
163
- proposer: forwarder,
164
- withdrawer: attester.address,
165
- amount: l1ContractsConfig.minimumStake
166
- });
167
- this.logger.verbose(`Adding (attester, proposer) pair: (${attester.address}, ${forwarder}) as validator`);
174
+ const { validators } = this.getValidators();
175
+ this.validators = validators;
176
+ const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress;
177
+ if (!gseAddress) {
178
+ throw new Error('GSE contract not deployed');
168
179
  }
169
- await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
170
- hash: await rollup.write.cheat__InitialiseValidatorSet([
171
- validators
180
+ const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
181
+ const makeValidatorTuples = async (validator)=>{
182
+ const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
183
+ return {
184
+ attester: validator.attester.toString(),
185
+ withdrawer: validator.withdrawer.toString(),
186
+ ...registrationTuple
187
+ };
188
+ };
189
+ const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
190
+ await deployL1ContractsValues.l1Client.waitForTransactionReceipt({
191
+ hash: await multiAdder.write.addValidators([
192
+ validatorTuples
172
193
  ])
173
194
  });
174
- const slotsInEpoch = await rollup.read.getEpochDuration();
175
- const timestamp = await rollup.read.getTimestampForSlot([
176
- slotsInEpoch
177
- ]);
178
- const cheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
179
- try {
180
- await cheatCodes.warp(Number(timestamp));
181
- } catch (err) {
182
- this.logger.debug('Warp failed, time already satisfied');
183
- }
184
- // Send and await a tx to make sure we mine a block for the warp to correctly progress.
185
- await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
186
- hash: await deployL1ContractsValues.walletClient.sendTransaction({
187
- to: this.baseAccount.address,
188
- value: 1n,
189
- account: this.baseAccount
190
- })
195
+ await cheatCodes.rollup.advanceToEpoch(await cheatCodes.rollup.getEpoch() + await rollup.read.getLagInEpochs() + 1n, {
196
+ updateDateProvider: dateProvider
191
197
  });
192
- // Set the system time in the node, only after we have warped the time and waited for a block
193
- // Time is only set in the NEXT block
194
- dateProvider.setTime(Number(timestamp) * 1000);
198
+ // Send and await a tx to make sure we mine a block for the warp to correctly progress.
199
+ await this._sendDummyTx(deployL1ContractsValues.l1Client);
195
200
  });
196
201
  }
197
202
  async setupAccount() {
@@ -199,6 +204,7 @@ export class P2PNetworkTest {
199
204
  this.deployedAccounts = deployedAccounts;
200
205
  const [account] = deployedAccounts;
201
206
  this.wallet = await getSchnorrWalletWithSecretKey(pxe, account.secret, account.signingKey, account.salt);
207
+ this.defaultAccountAddress = this.wallet.getAddress();
202
208
  });
203
209
  }
204
210
  async deploySpamContract() {
@@ -206,7 +212,9 @@ export class P2PNetworkTest {
206
212
  if (!this.wallet) {
207
213
  throw new Error('Call snapshot t.setupAccount before deploying account contract');
208
214
  }
209
- const spamContract = await SpamContract.deploy(this.wallet).send().deployed();
215
+ const spamContract = await SpamContract.deploy(this.wallet).send({
216
+ from: this.defaultAccountAddress
217
+ }).deployed();
210
218
  return {
211
219
  contractAddress: spamContract.address
212
220
  };
@@ -218,34 +226,38 @@ export class P2PNetworkTest {
218
226
  });
219
227
  }
220
228
  async removeInitialNode() {
221
- await this.snapshotManager.snapshot('remove-inital-validator', async ({ deployL1ContractsValues, aztecNode, dateProvider })=>{
229
+ await this.snapshotManager.snapshot('remove-initial-validator', async ({ deployL1ContractsValues, aztecNode, dateProvider })=>{
222
230
  // Send and await a tx to make sure we mine a block for the warp to correctly progress.
223
- const receipt = await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
224
- hash: await deployL1ContractsValues.walletClient.sendTransaction({
225
- to: this.baseAccount.address,
226
- value: 1n,
227
- account: this.baseAccount
228
- })
229
- });
230
- const block = await deployL1ContractsValues.publicClient.getBlock({
231
+ const { receipt } = await this._sendDummyTx(deployL1ContractsValues.l1Client);
232
+ const block = await deployL1ContractsValues.l1Client.getBlock({
231
233
  blockNumber: receipt.blockNumber
232
234
  });
233
235
  dateProvider.setTime(Number(block.timestamp) * 1000);
234
236
  await aztecNode.stop();
235
237
  });
236
238
  }
239
+ async sendDummyTx() {
240
+ return await this._sendDummyTx(this.ctx.deployL1ContractsValues.l1Client);
241
+ }
242
+ async _sendDummyTx(l1Client) {
243
+ const l1TxUtils = createL1TxUtilsFromViemWallet(l1Client);
244
+ return await l1TxUtils.sendAndMonitorTransaction({
245
+ to: l1Client.account.address,
246
+ value: 1n
247
+ });
248
+ }
237
249
  async setup() {
238
250
  this.ctx = await this.snapshotManager.setup();
239
- this.prefilledPublicData = (await getGenesisValues(this.ctx.initialFundedAccounts.map((a)=>a.address))).prefilledPublicData;
240
- this.startSyncMockSystemTimeInterval();
241
- this.gasUtils = new L1TxUtilsWithBlobs(this.ctx.deployL1ContractsValues.publicClient, this.ctx.deployL1ContractsValues.walletClient, this.logger, {
242
- gasLimitBufferPercentage: 20,
243
- maxGwei: 500n,
244
- maxAttempts: 3,
245
- checkIntervalMs: 100,
246
- stallTimeMs: 1000
247
- });
248
- this.monitor = new ChainMonitor(RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues)).start();
251
+ const sponsoredFPCAddress = await getSponsoredFPCAddress();
252
+ const initialFundedAccounts = [
253
+ ...this.ctx.initialFundedAccounts.map((a)=>a.address),
254
+ sponsoredFPCAddress
255
+ ];
256
+ const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
257
+ this.prefilledPublicData = prefilledPublicData;
258
+ const rollupContract = RollupContract.getFromL1ContractsValues(this.ctx.deployL1ContractsValues);
259
+ this.monitor = new ChainMonitor(rollupContract, this.ctx.dateProvider).start();
260
+ this.monitor.on('l1-block', ({ timestamp })=>this.ctx.dateProvider.setTime(Number(timestamp) * 1000));
249
261
  }
250
262
  async stopNodes(nodes) {
251
263
  this.logger.info('Stopping nodes');
@@ -257,11 +269,28 @@ export class P2PNetworkTest {
257
269
  this.logger.info('Nodes stopped');
258
270
  }
259
271
  async teardown() {
260
- this.monitor.stop();
261
- await this.bootstrapNode?.stop();
272
+ await this.monitor.stop();
273
+ await tryStop(this.bootstrapNode, this.logger);
262
274
  await this.snapshotManager.teardown();
263
- if (this.cleanupInterval) {
264
- clearInterval(this.cleanupInterval);
275
+ }
276
+ async getContracts() {
277
+ if (!this.ctx.deployL1ContractsValues) {
278
+ throw new Error('DeployL1ContractsValues not set');
265
279
  }
280
+ const rollup = new RollupContract(this.ctx.deployL1ContractsValues.l1Client, this.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress);
281
+ const slasherContract = getContract({
282
+ address: getAddress(await rollup.getSlasherAddress()),
283
+ abi: SlasherAbi,
284
+ client: this.ctx.deployL1ContractsValues.l1Client
285
+ });
286
+ // Get the actual slashing proposer from rollup (which handles both empire and tally)
287
+ const slashingProposer = await rollup.getSlashingProposer();
288
+ const slashFactory = new SlashFactoryContract(this.ctx.deployL1ContractsValues.l1Client, getAddress(this.ctx.deployL1ContractsValues.l1ContractAddresses.slashFactoryAddress.toString()));
289
+ return {
290
+ rollup,
291
+ slasherContract,
292
+ slashingProposer,
293
+ slashFactory
294
+ };
266
295
  }
267
296
  }
@@ -1,10 +1,48 @@
1
1
  import type { InitialAccountData } from '@aztec/accounts/testing';
2
2
  import type { AztecNodeService } from '@aztec/aztec-node';
3
- import { type Logger, type SentTx } from '@aztec/aztec.js';
4
- import type { SpamContract } from '@aztec/noir-contracts.js/Spam';
3
+ import { AztecAddress, type Logger, ProvenTx, type SentTx } from '@aztec/aztec.js';
4
+ import type { RollupCheatCodes } from '@aztec/aztec/testing';
5
+ import type { EmpireSlashingProposerContract, RollupContract, TallySlashingProposerContract } from '@aztec/ethereum';
6
+ import type { TestDateProvider } from '@aztec/foundation/timer';
7
+ import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
8
+ import { PXEService } from '@aztec/pxe/server';
9
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
10
+ import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
5
11
  import type { NodeContext } from '../fixtures/setup_p2p_test.js';
6
- export declare const submitComplexTxsTo: (logger: Logger, spamContract: SpamContract, numTxs: number, opts?: {
12
+ export declare const submitComplexTxsTo: (logger: Logger, from: AztecAddress, spamContract: SpamContract, numTxs: number, opts?: {
7
13
  callPublic?: boolean;
8
14
  }) => Promise<SentTx[]>;
9
15
  export declare const createPXEServiceAndSubmitTransactions: (logger: Logger, node: AztecNodeService, numTxs: number, fundedAccount: InitialAccountData) => Promise<NodeContext>;
16
+ export declare function createPXEServiceAndPrepareTransactions(logger: Logger, node: AztecNodeService, numTxs: number, fundedAccount: InitialAccountData): Promise<{
17
+ pxeService: PXEService;
18
+ txs: ProvenTx[];
19
+ node: AztecNodeService;
20
+ }>;
21
+ export declare function awaitProposalExecution(slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract, timeoutSeconds: number, logger: Logger): Promise<bigint>;
22
+ export declare function awaitCommitteeExists({ rollup, logger, }: {
23
+ rollup: RollupContract;
24
+ logger: Logger;
25
+ }): Promise<readonly `0x${string}`[]>;
26
+ export declare function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount, }: {
27
+ nodeAdmin: AztecNodeAdmin;
28
+ logger: Logger;
29
+ slashingRoundSize: number;
30
+ epochDuration: number;
31
+ waitUntilOffenseCount?: number;
32
+ }): Promise<import("@aztec/slasher").Offense[]>;
33
+ /**
34
+ * Await the committee to be slashed out of the validator set.
35
+ * Currently assumes that the committee is the same size as the validator set.
36
+ */
37
+ export declare function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, logger, dateProvider, }: {
38
+ rollup: RollupContract;
39
+ cheatCodes: RollupCheatCodes;
40
+ committee: readonly `0x${string}`[];
41
+ slashFactory: SlashFactoryContract;
42
+ slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
43
+ slashingRoundSize: number;
44
+ aztecSlotDuration: number;
45
+ dateProvider: TestDateProvider;
46
+ logger: Logger;
47
+ }): Promise<void>;
10
48
  //# sourceMappingURL=shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAY,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAIjE,eAAO,MAAM,kBAAkB,WACrB,MAAM,gBACA,YAAY,UAClB,MAAM,SACR;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,sBAwB/B,CAAC;AAGF,eAAO,MAAM,qCAAqC,WACxC,MAAM,QACR,gBAAgB,UACd,MAAM,iBACC,kBAAkB,KAChC,QAAQ,WAAW,CAmBrB,CAAC"}
1
+ {"version":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