@aztec/end-to-end 1.0.0-nightly.20250610 → 1.0.0-nightly.20250611

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.
@@ -1,12 +1,14 @@
1
1
  import type { InitialAccountData } from '@aztec/accounts/testing';
2
2
  import type { AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
3
3
  import { type AccountWalletWithSecretKey } from '@aztec/aztec.js';
4
- import { type Operator } from '@aztec/ethereum';
4
+ import { type Operator, RollupContract, type ViemClient } from '@aztec/ethereum';
5
5
  import { ChainMonitor } from '@aztec/ethereum/test';
6
6
  import { type Logger } from '@aztec/foundation/log';
7
+ import { SlashFactoryAbi, SlasherAbi, SlashingProposerAbi } from '@aztec/l1-artifacts';
7
8
  import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
8
9
  import type { BootstrapNode } from '@aztec/p2p/bootstrap';
9
10
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
11
+ import { type GetContractReturnType } from 'viem';
10
12
  import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
11
13
  export declare const WAIT_FOR_TX_TIMEOUT: number;
12
14
  export declare const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES: {
@@ -78,5 +80,11 @@ export declare class P2PNetworkTest {
78
80
  setup(): Promise<void>;
79
81
  stopNodes(nodes: AztecNodeService[]): Promise<void>;
80
82
  teardown(): Promise<void>;
83
+ getContracts(): Promise<{
84
+ rollup: RollupContract;
85
+ slasherContract: GetContractReturnType<typeof SlasherAbi, ViemClient>;
86
+ slashingProposer: GetContractReturnType<typeof SlashingProposerAbi, ViemClient>;
87
+ slashFactory: GetContractReturnType<typeof SlashFactoryAbi, ViemClient>;
88
+ }>;
81
89
  }
82
90
  //# sourceMappingURL=p2p_network.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"p2p_network.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/p2p_network.ts"],"names":[],"mappings":"AACA,O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YAAY,EAAE,qBAAqB,CAAC,OAAO,eAAe,EAAE,UAAU,CAAC,CAAC;KACzE,CAAC;CA8BH"}
@@ -3,13 +3,13 @@ import { EthAddress } from '@aztec/aztec.js';
3
3
  import { L1TxUtils, RollupContract, deployL1Contract, getL1ContractsConfigEnvVars, l1Artifacts } from '@aztec/ethereum';
4
4
  import { ChainMonitor } from '@aztec/ethereum/test';
5
5
  import { createLogger } from '@aztec/foundation/log';
6
- import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
6
+ import { RollupAbi, SlashFactoryAbi, SlasherAbi, SlashingProposerAbi, TestERC20Abi } from '@aztec/l1-artifacts';
7
7
  import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
8
8
  import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
9
9
  import { tryStop } from '@aztec/stdlib/interfaces/server';
10
10
  import { getGenesisValues } from '@aztec/world-state/testing';
11
11
  import getPort from 'get-port';
12
- import { getContract } from 'viem';
12
+ import { getAddress, getContract } from 'viem';
13
13
  import { privateKeyToAccount } from 'viem/accounts';
14
14
  import { ATTESTER_PRIVATE_KEYS_START_INDEX, createValidatorConfig, generatePrivateKeys } from '../fixtures/setup_p2p_test.js';
15
15
  import { createSnapshotManager, deployAccounts } from '../fixtures/snapshot_manager.js';
@@ -80,7 +80,9 @@ export class P2PNetworkTest {
80
80
  aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
81
81
  aztecProofSubmissionWindow: initialValidatorConfig.aztecProofSubmissionWindow ?? l1ContractsConfig.aztecProofSubmissionWindow,
82
82
  initialValidators: [],
83
- mockZkPassportVerifier
83
+ zkPassportArgs: {
84
+ mockZkPassportVerifier
85
+ }
84
86
  });
85
87
  }
86
88
  static async create({ testName, numberOfNodes, basePort, metricsPort, initialConfig, startProverNode, mockZkPassportVerifier }) {
@@ -141,7 +143,7 @@ export class P2PNetworkTest {
141
143
  abi: l1Artifacts.multiAdder.contractAbi,
142
144
  client: deployL1ContractsValues.l1Client
143
145
  });
144
- const stakeNeeded = l1ContractsConfig.minimumStake * BigInt(this.numberOfNodes);
146
+ const stakeNeeded = l1ContractsConfig.depositAmount * BigInt(this.numberOfNodes);
145
147
  await Promise.all([
146
148
  await stakingAsset.write.mint([
147
149
  multiAdder.address,
@@ -238,4 +240,31 @@ export class P2PNetworkTest {
238
240
  await tryStop(this.bootstrapNode, this.logger);
239
241
  await this.snapshotManager.teardown();
240
242
  }
243
+ async getContracts() {
244
+ if (!this.ctx.deployL1ContractsValues) {
245
+ throw new Error('DeployL1ContractsValues not set');
246
+ }
247
+ const rollup = new RollupContract(this.ctx.deployL1ContractsValues.l1Client, this.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress);
248
+ const slasherContract = getContract({
249
+ address: getAddress(await rollup.getSlasher()),
250
+ abi: SlasherAbi,
251
+ client: this.ctx.deployL1ContractsValues.l1Client
252
+ });
253
+ const slashingProposer = getContract({
254
+ address: getAddress(await slasherContract.read.PROPOSER()),
255
+ abi: SlashingProposerAbi,
256
+ client: this.ctx.deployL1ContractsValues.l1Client
257
+ });
258
+ const slashFactory = getContract({
259
+ address: getAddress(this.ctx.deployL1ContractsValues.l1ContractAddresses.slashFactoryAddress.toString()),
260
+ abi: SlashFactoryAbi,
261
+ client: this.ctx.deployL1ContractsValues.l1Client
262
+ });
263
+ return {
264
+ rollup,
265
+ slasherContract,
266
+ slashingProposer,
267
+ slashFactory
268
+ };
269
+ }
241
270
  }
@@ -1,8 +1,14 @@
1
1
  import type { InitialAccountData } from '@aztec/accounts/testing';
2
2
  import type { AztecNodeService } from '@aztec/aztec-node';
3
3
  import { type Logger, ProvenTx, type SentTx } from '@aztec/aztec.js';
4
+ import type { RollupCheatCodes } from '@aztec/aztec.js/testing';
5
+ import type { RollupContract, ViemClient } from '@aztec/ethereum';
6
+ import type { SlashFactoryAbi } from '@aztec/l1-artifacts/SlashFactoryAbi';
7
+ import type { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
4
8
  import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
5
9
  import { PXEService } from '@aztec/pxe/server';
10
+ import { Offense } from '@aztec/slasher';
11
+ import type { GetContractReturnType } from 'viem';
6
12
  import type { NodeContext } from '../fixtures/setup_p2p_test.js';
7
13
  export declare const submitComplexTxsTo: (logger: Logger, spamContract: SpamContract, numTxs: number, opts?: {
8
14
  callPublic?: boolean;
@@ -13,4 +19,22 @@ export declare function createPXEServiceAndPrepareTransactions(logger: Logger, n
13
19
  txs: ProvenTx[];
14
20
  node: AztecNodeService;
15
21
  }>;
22
+ export declare function awaitProposalExecution(slashingProposer: GetContractReturnType<typeof SlashingProposerAbi, ViemClient>, timeoutSeconds: number): Promise<void>;
23
+ export declare function awaitCommitteeExists({ rollup, logger }: {
24
+ rollup: RollupContract;
25
+ logger: Logger;
26
+ }): Promise<readonly `0x${string}`[]>;
27
+ export declare function awaitCommitteeKicked({ offense, rollup, cheatCodes, committee, slashingAmount, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, logger, sendDummyTx, }: {
28
+ offense: Offense;
29
+ rollup: RollupContract;
30
+ cheatCodes: RollupCheatCodes;
31
+ committee: readonly `0x${string}`[];
32
+ slashingAmount: bigint;
33
+ slashFactory: GetContractReturnType<typeof SlashFactoryAbi, ViemClient>;
34
+ slashingProposer: GetContractReturnType<typeof SlashingProposerAbi, ViemClient>;
35
+ slashingRoundSize: number;
36
+ aztecSlotDuration: number;
37
+ logger: Logger;
38
+ sendDummyTx: () => Promise<void>;
39
+ }): Promise<void>;
16
40
  //# 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,CA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,CAAC,EACzC,OAAO,EACP,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,EACN,WAAW,GACZ,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,SAAS,EAAE,SAAS,KAAK,MAAM,EAAE,EAAE,CAAC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,qBAAqB,CAAC,OAAO,eAAe,EAAE,UAAU,CAAC,CAAC;IACxE,gBAAgB,EAAE,qBAAqB,CAAC,OAAO,mBAAmB,EAAE,UAAU,CAAC,CAAC;IAChF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,iBA2DA"}
@@ -1,8 +1,9 @@
1
1
  import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
- import { Fr, TxStatus, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
2
+ import { Fr, TxStatus, getContractInstanceFromDeployParams, retryUntil } from '@aztec/aztec.js';
3
3
  import { timesAsync } from '@aztec/foundation/collection';
4
4
  import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
5
5
  import { createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe/server';
6
+ import { OffenseToBigInt } from '@aztec/slasher';
6
7
  import { submitTxsTo } from '../shared/submit-transactions.js';
7
8
  // submits a set of transactions to the provided Private eXecution Environment (PXE)
8
9
  export const submitComplexTxsTo = async (logger, spamContract, numTxs, opts = {})=>{
@@ -67,3 +68,73 @@ export async function createPXEServiceAndPrepareTransactions(logger, node, numTx
67
68
  node
68
69
  };
69
70
  }
71
+ export async function awaitProposalExecution(slashingProposer, timeoutSeconds) {
72
+ await retryUntil(async ()=>{
73
+ const events = await slashingProposer.getEvents.ProposalExecuted();
74
+ if (events.length === 0) {
75
+ return false;
76
+ }
77
+ const event = events[0];
78
+ const roundNumber = event.args.round;
79
+ const proposal = event.args.proposal;
80
+ return roundNumber && proposal;
81
+ }, 'proposal executed', timeoutSeconds, 1);
82
+ }
83
+ export async function awaitCommitteeExists({ rollup, logger }) {
84
+ logger.info(`Waiting for committee to be set`);
85
+ let committee = [];
86
+ await retryUntil(async ()=>{
87
+ committee = await rollup.getCurrentEpochCommittee();
88
+ return committee.length > 0;
89
+ }, 'non-empty committee', 60);
90
+ return committee;
91
+ }
92
+ export async function awaitCommitteeKicked({ offense, rollup, cheatCodes, committee, slashingAmount, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, logger, sendDummyTx }) {
93
+ logger.info(`Waiting for slash payload to be deployed`);
94
+ const expectedSlashes = Array.from({
95
+ length: committee.length
96
+ }, ()=>slashingAmount);
97
+ const sortedCommittee = [
98
+ ...committee
99
+ ].sort((a, b)=>a.localeCompare(b));
100
+ await retryUntil(async ()=>{
101
+ const [address, _, isDeployed] = await slashFactory.read.getAddressAndIsDeployed([
102
+ sortedCommittee,
103
+ expectedSlashes
104
+ ]);
105
+ return address && isDeployed;
106
+ }, 'slash payload deployed', 60, 1);
107
+ const slashPayloadEvents = await slashFactory.getEvents.SlashPayloadCreated();
108
+ expect(slashPayloadEvents.length).toBe(1);
109
+ expect(slashPayloadEvents[0].args.offenses).toEqual(Array.from({
110
+ length: committee.length
111
+ }, ()=>OffenseToBigInt[offense]));
112
+ const attestersPre = await rollup.getAttesters();
113
+ expect(attestersPre.length).toBe(committee.length);
114
+ for (const attester of attestersPre){
115
+ const attesterInfo = await rollup.getAttesterView(attester);
116
+ // Check that status isValidating
117
+ expect(attesterInfo.status).toEqual(1);
118
+ }
119
+ logger.info(`Waiting for slash proposal to be executed`);
120
+ await awaitProposalExecution(slashingProposer, slashingRoundSize * 2 * aztecSlotDuration);
121
+ // The attesters should still form the committee
122
+ // but they should be reduced to the "living" status
123
+ await cheatCodes.debugRollup();
124
+ const committeePostSlashing = await rollup.getCurrentEpochCommittee();
125
+ expect(committeePostSlashing.length).toBe(attestersPre.length);
126
+ const attestersPostSlashing = await rollup.getAttesters();
127
+ expect(attestersPostSlashing.length).toBe(0);
128
+ for (const attester of attestersPre){
129
+ const attesterInfo = await rollup.getAttesterView(attester);
130
+ // Check that status is Living
131
+ expect(attesterInfo.status).toEqual(2);
132
+ }
133
+ await cheatCodes.advanceToNextEpoch();
134
+ await sendDummyTx();
135
+ await cheatCodes.debugRollup();
136
+ const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
137
+ expect(committeeNextEpoch.length).toBe(0);
138
+ const attestersNextEpoch = await rollup.getAttesters();
139
+ expect(attestersNextEpoch.length).toBe(0);
140
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"setup_p2p_test.d.ts","sourceRoot":"","sources":["../../src/fixtures/setup_p2p_test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM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D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,EAAE,CAO7F;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,EAC1C,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAmC7B;AAGD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,YAAY,EAAE,MAAM,EACpB,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,EAC1C,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,6BAQ5C;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,eAAe,EACvB,gBAAgB,CAAC,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,GAAE,MAAU,EACxB,aAAa,CAAC,EAAE,MAAM,4BAuBvB"}
@@ -31,6 +31,11 @@ export async function createNodes(config, dateProvider, bootstrapNodeEnr, numNod
31
31
  nodePromises.push(nodePromise);
32
32
  }
33
33
  const nodes = await Promise.all(nodePromises);
34
+ // Sanity check that we have a sequencer
35
+ const seqClient = nodes[0].getSequencer();
36
+ if (!seqClient) {
37
+ throw new Error('Sequencer not found');
38
+ }
34
39
  removeLogNameHandler(logNameHandler);
35
40
  return nodes;
36
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/end-to-end",
3
- "version": "1.0.0-nightly.20250610",
3
+ "version": "1.0.0-nightly.20250611",
4
4
  "type": "module",
5
5
  "exports": "./dest/index.js",
6
6
  "inherits": [
@@ -25,40 +25,40 @@
25
25
  "formatting": "run -T prettier --check ./src && run -T eslint ./src"
26
26
  },
27
27
  "dependencies": {
28
- "@aztec/accounts": "1.0.0-nightly.20250610",
29
- "@aztec/archiver": "1.0.0-nightly.20250610",
30
- "@aztec/aztec": "1.0.0-nightly.20250610",
31
- "@aztec/aztec-node": "1.0.0-nightly.20250610",
32
- "@aztec/aztec.js": "1.0.0-nightly.20250610",
33
- "@aztec/bb-prover": "1.0.0-nightly.20250610",
34
- "@aztec/blob-lib": "1.0.0-nightly.20250610",
35
- "@aztec/blob-sink": "1.0.0-nightly.20250610",
36
- "@aztec/bot": "1.0.0-nightly.20250610",
37
- "@aztec/cli": "1.0.0-nightly.20250610",
38
- "@aztec/constants": "1.0.0-nightly.20250610",
39
- "@aztec/entrypoints": "1.0.0-nightly.20250610",
40
- "@aztec/epoch-cache": "1.0.0-nightly.20250610",
41
- "@aztec/ethereum": "1.0.0-nightly.20250610",
42
- "@aztec/foundation": "1.0.0-nightly.20250610",
43
- "@aztec/kv-store": "1.0.0-nightly.20250610",
44
- "@aztec/l1-artifacts": "1.0.0-nightly.20250610",
45
- "@aztec/merkle-tree": "1.0.0-nightly.20250610",
46
- "@aztec/noir-contracts.js": "1.0.0-nightly.20250610",
47
- "@aztec/noir-noirc_abi": "1.0.0-nightly.20250610",
48
- "@aztec/noir-protocol-circuits-types": "1.0.0-nightly.20250610",
49
- "@aztec/noir-test-contracts.js": "1.0.0-nightly.20250610",
50
- "@aztec/p2p": "1.0.0-nightly.20250610",
51
- "@aztec/protocol-contracts": "1.0.0-nightly.20250610",
52
- "@aztec/prover-client": "1.0.0-nightly.20250610",
53
- "@aztec/prover-node": "1.0.0-nightly.20250610",
54
- "@aztec/pxe": "1.0.0-nightly.20250610",
55
- "@aztec/sequencer-client": "1.0.0-nightly.20250610",
56
- "@aztec/simulator": "1.0.0-nightly.20250610",
57
- "@aztec/slasher": "1.0.0-nightly.20250610",
58
- "@aztec/stdlib": "1.0.0-nightly.20250610",
59
- "@aztec/telemetry-client": "1.0.0-nightly.20250610",
60
- "@aztec/validator-client": "1.0.0-nightly.20250610",
61
- "@aztec/world-state": "1.0.0-nightly.20250610",
28
+ "@aztec/accounts": "1.0.0-nightly.20250611",
29
+ "@aztec/archiver": "1.0.0-nightly.20250611",
30
+ "@aztec/aztec": "1.0.0-nightly.20250611",
31
+ "@aztec/aztec-node": "1.0.0-nightly.20250611",
32
+ "@aztec/aztec.js": "1.0.0-nightly.20250611",
33
+ "@aztec/bb-prover": "1.0.0-nightly.20250611",
34
+ "@aztec/blob-lib": "1.0.0-nightly.20250611",
35
+ "@aztec/blob-sink": "1.0.0-nightly.20250611",
36
+ "@aztec/bot": "1.0.0-nightly.20250611",
37
+ "@aztec/cli": "1.0.0-nightly.20250611",
38
+ "@aztec/constants": "1.0.0-nightly.20250611",
39
+ "@aztec/entrypoints": "1.0.0-nightly.20250611",
40
+ "@aztec/epoch-cache": "1.0.0-nightly.20250611",
41
+ "@aztec/ethereum": "1.0.0-nightly.20250611",
42
+ "@aztec/foundation": "1.0.0-nightly.20250611",
43
+ "@aztec/kv-store": "1.0.0-nightly.20250611",
44
+ "@aztec/l1-artifacts": "1.0.0-nightly.20250611",
45
+ "@aztec/merkle-tree": "1.0.0-nightly.20250611",
46
+ "@aztec/noir-contracts.js": "1.0.0-nightly.20250611",
47
+ "@aztec/noir-noirc_abi": "1.0.0-nightly.20250611",
48
+ "@aztec/noir-protocol-circuits-types": "1.0.0-nightly.20250611",
49
+ "@aztec/noir-test-contracts.js": "1.0.0-nightly.20250611",
50
+ "@aztec/p2p": "1.0.0-nightly.20250611",
51
+ "@aztec/protocol-contracts": "1.0.0-nightly.20250611",
52
+ "@aztec/prover-client": "1.0.0-nightly.20250611",
53
+ "@aztec/prover-node": "1.0.0-nightly.20250611",
54
+ "@aztec/pxe": "1.0.0-nightly.20250611",
55
+ "@aztec/sequencer-client": "1.0.0-nightly.20250611",
56
+ "@aztec/simulator": "1.0.0-nightly.20250611",
57
+ "@aztec/slasher": "1.0.0-nightly.20250611",
58
+ "@aztec/stdlib": "1.0.0-nightly.20250611",
59
+ "@aztec/telemetry-client": "1.0.0-nightly.20250611",
60
+ "@aztec/validator-client": "1.0.0-nightly.20250611",
61
+ "@aztec/world-state": "1.0.0-nightly.20250611",
62
62
  "@iarna/toml": "^2.2.5",
63
63
  "@jest/globals": "^29.5.0",
64
64
  "@noble/curves": "^1.0.0",
@@ -155,6 +155,7 @@
155
155
  "testTimeout": 120000,
156
156
  "setupFiles": [
157
157
  "../../foundation/src/jest/setup.mjs"
158
- ]
158
+ ],
159
+ "testEnvironment": "../../foundation/src/jest/env.mjs"
159
160
  }
160
161
  }
@@ -7,13 +7,14 @@ import {
7
7
  L1TxUtils,
8
8
  type Operator,
9
9
  RollupContract,
10
+ type ViemClient,
10
11
  deployL1Contract,
11
12
  getL1ContractsConfigEnvVars,
12
13
  l1Artifacts,
13
14
  } from '@aztec/ethereum';
14
15
  import { ChainMonitor } from '@aztec/ethereum/test';
15
16
  import { type Logger, createLogger } from '@aztec/foundation/log';
16
- import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
17
+ import { RollupAbi, SlashFactoryAbi, SlasherAbi, SlashingProposerAbi, TestERC20Abi } from '@aztec/l1-artifacts';
17
18
  import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
18
19
  import type { BootstrapNode } from '@aztec/p2p/bootstrap';
19
20
  import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
@@ -22,7 +23,7 @@ import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
22
23
  import { getGenesisValues } from '@aztec/world-state/testing';
23
24
 
24
25
  import getPort from 'get-port';
25
- import { getContract } from 'viem';
26
+ import { type GetContractReturnType, getAddress, getContract } from 'viem';
26
27
  import { privateKeyToAccount } from 'viem/accounts';
27
28
 
28
29
  import {
@@ -114,7 +115,9 @@ export class P2PNetworkTest {
114
115
  aztecProofSubmissionWindow:
115
116
  initialValidatorConfig.aztecProofSubmissionWindow ?? l1ContractsConfig.aztecProofSubmissionWindow,
116
117
  initialValidators: [],
117
- mockZkPassportVerifier,
118
+ zkPassportArgs: {
119
+ mockZkPassportVerifier,
120
+ },
118
121
  },
119
122
  );
120
123
  }
@@ -227,7 +230,7 @@ export class P2PNetworkTest {
227
230
  client: deployL1ContractsValues.l1Client,
228
231
  });
229
232
 
230
- const stakeNeeded = l1ContractsConfig.minimumStake * BigInt(this.numberOfNodes);
233
+ const stakeNeeded = l1ContractsConfig.depositAmount * BigInt(this.numberOfNodes);
231
234
  await Promise.all(
232
235
  [await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
233
236
  deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
@@ -352,4 +355,40 @@ export class P2PNetworkTest {
352
355
  await tryStop(this.bootstrapNode, this.logger);
353
356
  await this.snapshotManager.teardown();
354
357
  }
358
+
359
+ async getContracts(): Promise<{
360
+ rollup: RollupContract;
361
+ slasherContract: GetContractReturnType<typeof SlasherAbi, ViemClient>;
362
+ slashingProposer: GetContractReturnType<typeof SlashingProposerAbi, ViemClient>;
363
+ slashFactory: GetContractReturnType<typeof SlashFactoryAbi, ViemClient>;
364
+ }> {
365
+ if (!this.ctx.deployL1ContractsValues) {
366
+ throw new Error('DeployL1ContractsValues not set');
367
+ }
368
+
369
+ const rollup = new RollupContract(
370
+ this.ctx.deployL1ContractsValues!.l1Client,
371
+ this.ctx.deployL1ContractsValues!.l1ContractAddresses.rollupAddress,
372
+ );
373
+
374
+ const slasherContract = getContract({
375
+ address: getAddress(await rollup.getSlasher()),
376
+ abi: SlasherAbi,
377
+ client: this.ctx.deployL1ContractsValues.l1Client,
378
+ });
379
+
380
+ const slashingProposer = getContract({
381
+ address: getAddress(await slasherContract.read.PROPOSER()),
382
+ abi: SlashingProposerAbi,
383
+ client: this.ctx.deployL1ContractsValues.l1Client,
384
+ });
385
+
386
+ const slashFactory = getContract({
387
+ address: getAddress(this.ctx.deployL1ContractsValues.l1ContractAddresses.slashFactoryAddress!.toString()),
388
+ abi: SlashFactoryAbi,
389
+ client: this.ctx.deployL1ContractsValues.l1Client,
390
+ });
391
+
392
+ return { rollup, slasherContract, slashingProposer, slashFactory };
393
+ }
355
394
  }
@@ -1,11 +1,26 @@
1
1
  import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
2
  import type { InitialAccountData } from '@aztec/accounts/testing';
3
3
  import type { AztecNodeService } from '@aztec/aztec-node';
4
- import { Fr, type Logger, ProvenTx, type SentTx, TxStatus, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
4
+ import {
5
+ Fr,
6
+ type Logger,
7
+ ProvenTx,
8
+ type SentTx,
9
+ TxStatus,
10
+ getContractInstanceFromDeployParams,
11
+ retryUntil,
12
+ } from '@aztec/aztec.js';
13
+ import type { RollupCheatCodes } from '@aztec/aztec.js/testing';
14
+ import type { RollupContract, ViemClient } from '@aztec/ethereum';
5
15
  import { timesAsync } from '@aztec/foundation/collection';
16
+ import type { SlashFactoryAbi } from '@aztec/l1-artifacts/SlashFactoryAbi';
17
+ import type { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
6
18
  import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
7
19
  import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
8
20
  import { PXEService, createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe/server';
21
+ import { Offense, OffenseToBigInt } from '@aztec/slasher';
22
+
23
+ import type { GetContractReturnType } from 'viem';
9
24
 
10
25
  import type { NodeContext } from '../fixtures/setup_p2p_test.js';
11
26
  import { submitTxsTo } from '../shared/submit-transactions.js';
@@ -90,3 +105,123 @@ export async function createPXEServiceAndPrepareTransactions(
90
105
 
91
106
  return { txs, pxeService: pxe, node };
92
107
  }
108
+
109
+ export async function awaitProposalExecution(
110
+ slashingProposer: GetContractReturnType<typeof SlashingProposerAbi, ViemClient>,
111
+ timeoutSeconds: number,
112
+ ) {
113
+ await retryUntil(
114
+ async () => {
115
+ const events = await slashingProposer.getEvents.ProposalExecuted();
116
+ if (events.length === 0) {
117
+ return false;
118
+ }
119
+ const event = events[0];
120
+ const roundNumber = event.args.round;
121
+ const proposal = event.args.proposal;
122
+ return roundNumber && proposal;
123
+ },
124
+ 'proposal executed',
125
+ timeoutSeconds,
126
+ 1,
127
+ );
128
+ }
129
+
130
+ export async function awaitCommitteeExists({ rollup, logger }: { rollup: RollupContract; logger: Logger }) {
131
+ logger.info(`Waiting for committee to be set`);
132
+ let committee: readonly `0x${string}`[] = [];
133
+ await retryUntil(
134
+ async () => {
135
+ committee = await rollup.getCurrentEpochCommittee();
136
+ return committee.length > 0;
137
+ },
138
+ 'non-empty committee',
139
+ 60,
140
+ );
141
+ return committee;
142
+ }
143
+
144
+ export async function awaitCommitteeKicked({
145
+ offense,
146
+ rollup,
147
+ cheatCodes,
148
+ committee,
149
+ slashingAmount,
150
+ slashFactory,
151
+ slashingProposer,
152
+ slashingRoundSize,
153
+ aztecSlotDuration,
154
+ logger,
155
+ sendDummyTx,
156
+ }: {
157
+ offense: Offense;
158
+ rollup: RollupContract;
159
+ cheatCodes: RollupCheatCodes;
160
+ committee: readonly `0x${string}`[];
161
+ slashingAmount: bigint;
162
+ slashFactory: GetContractReturnType<typeof SlashFactoryAbi, ViemClient>;
163
+ slashingProposer: GetContractReturnType<typeof SlashingProposerAbi, ViemClient>;
164
+ slashingRoundSize: number;
165
+ aztecSlotDuration: number;
166
+ logger: Logger;
167
+ sendDummyTx: () => Promise<void>;
168
+ }) {
169
+ logger.info(`Waiting for slash payload to be deployed`);
170
+ const expectedSlashes = Array.from({ length: committee.length }, () => slashingAmount);
171
+ const sortedCommittee = [...committee].sort((a, b) => a.localeCompare(b));
172
+ await retryUntil(
173
+ async () => {
174
+ const [address, _, isDeployed] = await slashFactory.read.getAddressAndIsDeployed([
175
+ sortedCommittee,
176
+ expectedSlashes,
177
+ ]);
178
+ return address && isDeployed;
179
+ },
180
+ 'slash payload deployed',
181
+ 60,
182
+ 1,
183
+ );
184
+
185
+ const slashPayloadEvents = await slashFactory.getEvents.SlashPayloadCreated();
186
+ expect(slashPayloadEvents.length).toBe(1);
187
+ expect(slashPayloadEvents[0].args.offenses).toEqual(
188
+ Array.from({ length: committee.length }, () => OffenseToBigInt[offense]),
189
+ );
190
+
191
+ const attestersPre = await rollup.getAttesters();
192
+ expect(attestersPre.length).toBe(committee.length);
193
+
194
+ for (const attester of attestersPre) {
195
+ const attesterInfo = await rollup.getAttesterView(attester);
196
+ // Check that status isValidating
197
+ expect(attesterInfo.status).toEqual(1);
198
+ }
199
+
200
+ logger.info(`Waiting for slash proposal to be executed`);
201
+ await awaitProposalExecution(slashingProposer, slashingRoundSize * 2 * aztecSlotDuration);
202
+
203
+ // The attesters should still form the committee
204
+ // but they should be reduced to the "living" status
205
+ await cheatCodes.debugRollup();
206
+ const committeePostSlashing = await rollup.getCurrentEpochCommittee();
207
+ expect(committeePostSlashing.length).toBe(attestersPre.length);
208
+
209
+ const attestersPostSlashing = await rollup.getAttesters();
210
+ expect(attestersPostSlashing.length).toBe(0);
211
+
212
+ for (const attester of attestersPre) {
213
+ const attesterInfo = await rollup.getAttesterView(attester);
214
+ // Check that status is Living
215
+ expect(attesterInfo.status).toEqual(2);
216
+ }
217
+
218
+ await cheatCodes.advanceToNextEpoch();
219
+ await sendDummyTx();
220
+ await cheatCodes.debugRollup();
221
+
222
+ const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
223
+ expect(committeeNextEpoch.length).toBe(0);
224
+
225
+ const attestersNextEpoch = await rollup.getAttesters();
226
+ expect(attestersNextEpoch.length).toBe(0);
227
+ }
@@ -69,6 +69,13 @@ export async function createNodes(
69
69
  nodePromises.push(nodePromise);
70
70
  }
71
71
  const nodes = await Promise.all(nodePromises);
72
+
73
+ // Sanity check that we have a sequencer
74
+ const seqClient = nodes[0].getSequencer();
75
+ if (!seqClient) {
76
+ throw new Error('Sequencer not found');
77
+ }
78
+
72
79
  removeLogNameHandler(logNameHandler);
73
80
  return nodes;
74
81
  }