@aztec/ethereum 2.0.0-nightly.20250902 → 3.0.0-canary.a9708bd

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 (41) hide show
  1. package/dest/config.d.ts.map +1 -1
  2. package/dest/config.js +61 -54
  3. package/dest/contracts/fee_asset_handler.d.ts +3 -2
  4. package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
  5. package/dest/contracts/fee_asset_handler.js +14 -0
  6. package/dest/contracts/fee_juice.d.ts +2 -1
  7. package/dest/contracts/fee_juice.d.ts.map +1 -1
  8. package/dest/contracts/fee_juice.js +6 -0
  9. package/dest/contracts/governance.d.ts +1 -1
  10. package/dest/contracts/governance.d.ts.map +1 -1
  11. package/dest/contracts/governance.js +3 -0
  12. package/dest/contracts/governance_proposer.d.ts +1 -1
  13. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  14. package/dest/contracts/governance_proposer.js +3 -0
  15. package/dest/contracts/gse.d.ts +2 -0
  16. package/dest/contracts/gse.d.ts.map +1 -1
  17. package/dest/contracts/gse.js +6 -0
  18. package/dest/deploy_l1_contracts.d.ts +18 -4
  19. package/dest/deploy_l1_contracts.d.ts.map +1 -1
  20. package/dest/deploy_l1_contracts.js +383 -61
  21. package/dest/l1_artifacts.d.ts +39210 -39196
  22. package/dest/l1_artifacts.d.ts.map +1 -1
  23. package/dest/test/eth_cheat_codes.d.ts +3 -2
  24. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  25. package/dest/test/eth_cheat_codes.js +11 -0
  26. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  27. package/dest/test/rollup_cheat_codes.js +2 -1
  28. package/dest/test/tx_delayer.d.ts +2 -2
  29. package/dest/test/tx_delayer.d.ts.map +1 -1
  30. package/dest/test/tx_delayer.js +4 -4
  31. package/package.json +5 -4
  32. package/src/config.ts +81 -72
  33. package/src/contracts/fee_asset_handler.ts +17 -2
  34. package/src/contracts/fee_juice.ts +8 -1
  35. package/src/contracts/governance.ts +4 -1
  36. package/src/contracts/governance_proposer.ts +4 -1
  37. package/src/contracts/gse.ts +8 -0
  38. package/src/deploy_l1_contracts.ts +357 -52
  39. package/src/test/eth_cheat_codes.ts +12 -2
  40. package/src/test/rollup_cheat_codes.ts +5 -1
  41. package/src/test/tx_delayer.ts +14 -4
package/src/config.ts CHANGED
@@ -423,78 +423,7 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
423
423
 
424
424
  // TallySlashingProposer constructor validations
425
425
  if (config.slasherFlavor === 'tally') {
426
- // From: require(SLASH_OFFSET_IN_ROUNDS > 0, Errors.TallySlashingProposer__SlashOffsetMustBeGreaterThanZero(...));
427
- if (config.slashingOffsetInRounds <= 0) {
428
- errors.push(`slashingOffsetInRounds (${config.slashingOffsetInRounds}) must be greater than 0`);
429
- }
430
-
431
- // From: require(ROUND_SIZE_IN_EPOCHS * _epochDuration == ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeMustBeMultipleOfEpochDuration(...));
432
- const roundSizeInSlots = config.slashingRoundSizeInEpochs * config.aztecEpochDuration;
433
-
434
- // From: require(QUORUM > 0, Errors.TallySlashingProposer__QuorumMustBeGreaterThanZero());
435
- if (slashingQuorum !== undefined && slashingQuorum <= 0) {
436
- errors.push(`slashingQuorum (${slashingQuorum}) must be greater than 0`);
437
- }
438
-
439
- // From: require(ROUND_SIZE > 1, Errors.TallySlashingProposer__InvalidQuorumAndRoundSize(QUORUM, ROUND_SIZE));
440
- if (roundSizeInSlots <= 1) {
441
- errors.push(`slashing round size in slots (${roundSizeInSlots}) must be greater than 1`);
442
- }
443
-
444
- // From: require(_slashAmounts[0] <= _slashAmounts[1], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
445
- if (config.slashAmountSmall > config.slashAmountMedium) {
446
- errors.push(
447
- `slashAmountSmall (${config.slashAmountSmall}) must be less than or equal to slashAmountMedium (${config.slashAmountMedium})`,
448
- );
449
- }
450
-
451
- // From: require(_slashAmounts[1] <= _slashAmounts[2], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
452
- if (config.slashAmountMedium > config.slashAmountLarge) {
453
- errors.push(
454
- `slashAmountMedium (${config.slashAmountMedium}) must be less than or equal to slashAmountLarge (${config.slashAmountLarge})`,
455
- );
456
- }
457
-
458
- // From: require(LIFETIME_IN_ROUNDS < ROUNDABOUT_SIZE, Errors.TallySlashingProposer__LifetimeMustBeLessThanRoundabout(...));
459
- const ROUNDABOUT_SIZE = 128; // Constant from TallySlashingProposer
460
- if (config.slashingLifetimeInRounds >= ROUNDABOUT_SIZE) {
461
- errors.push(`slashingLifetimeInRounds (${config.slashingLifetimeInRounds}) must be less than ${ROUNDABOUT_SIZE}`);
462
- }
463
-
464
- // From: require(ROUND_SIZE_IN_EPOCHS > 0, Errors.TallySlashingProposer__RoundSizeInEpochsMustBeGreaterThanZero(...));
465
- if (config.slashingRoundSizeInEpochs <= 0) {
466
- errors.push(`slashingRoundSizeInEpochs (${config.slashingRoundSizeInEpochs}) must be greater than 0`);
467
- }
468
-
469
- // From: require(ROUND_SIZE < MAX_ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeTooLarge(ROUND_SIZE, MAX_ROUND_SIZE));
470
- const MAX_ROUND_SIZE = 1024; // Constant from TallySlashingProposer
471
- if (roundSizeInSlots >= MAX_ROUND_SIZE) {
472
- errors.push(`slashing round size in slots (${roundSizeInSlots}) must be less than ${MAX_ROUND_SIZE}`);
473
- }
474
-
475
- // From: require(COMMITTEE_SIZE > 0, Errors.TallySlashingProposer__CommitteeSizeMustBeGreaterThanZero(COMMITTEE_SIZE));
476
- if (config.aztecTargetCommitteeSize <= 0) {
477
- errors.push(`aztecTargetCommitteeSize (${config.aztecTargetCommitteeSize}) must be greater than 0`);
478
- }
479
-
480
- // From: require(voteSize <= 128, Errors.TallySlashingProposer__VoteSizeTooBig(voteSize, 128));
481
- // voteSize = COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS / 4
482
- const voteSize = (config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs) / 4;
483
- if (voteSize > 128) {
484
- errors.push(`vote size (${voteSize}) must be <= 128 (committee size * round size in epochs / 4)`);
485
- }
486
-
487
- // From: require(COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS % 4 == 0, Errors.TallySlashingProposer__InvalidCommitteeAndRoundSize(...));
488
- if ((config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs) % 4 !== 0) {
489
- errors.push(
490
- `aztecTargetCommitteeSize * slashingRoundSizeInEpochs (${config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs}) must be divisible by 4`,
491
- );
492
- }
493
-
494
- // Slashing offset validation: should be positive to allow proper slashing timing
495
- if (config.slashingOffsetInRounds < 0) {
496
- errors.push('slashingOffsetInRounds cannot be negative');
497
- }
426
+ validateTallySlasherConfig(config, errors);
498
427
  }
499
428
 
500
429
  // Epoch and slot duration validations
@@ -541,3 +470,83 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
541
470
  );
542
471
  }
543
472
  }
473
+
474
+ function validateTallySlasherConfig(config: L1ContractsConfig, errors: string[]) {
475
+ if (config.slasherFlavor !== 'tally') {
476
+ return;
477
+ }
478
+
479
+ // From: require(SLASH_OFFSET_IN_ROUNDS > 0, Errors.TallySlashingProposer__SlashOffsetMustBeGreaterThanZero(...));
480
+ if (config.slashingOffsetInRounds <= 0) {
481
+ errors.push(`slashingOffsetInRounds (${config.slashingOffsetInRounds}) must be greater than 0`);
482
+ }
483
+
484
+ // From: require(ROUND_SIZE_IN_EPOCHS * _epochDuration == ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeMustBeMultipleOfEpochDuration(...));
485
+ const roundSizeInSlots = config.slashingRoundSizeInEpochs * config.aztecEpochDuration;
486
+
487
+ // From: require(QUORUM > 0, Errors.TallySlashingProposer__QuorumMustBeGreaterThanZero());
488
+ const { slashingQuorum } = config;
489
+ if (slashingQuorum !== undefined && slashingQuorum <= 0) {
490
+ errors.push(`slashingQuorum (${slashingQuorum}) must be greater than 0`);
491
+ }
492
+
493
+ // From: require(ROUND_SIZE > 1, Errors.TallySlashingProposer__InvalidQuorumAndRoundSize(QUORUM, ROUND_SIZE));
494
+ if (roundSizeInSlots <= 1) {
495
+ errors.push(`slashing round size in slots (${roundSizeInSlots}) must be greater than 1`);
496
+ }
497
+
498
+ // From: require(_slashAmounts[0] <= _slashAmounts[1], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
499
+ if (config.slashAmountSmall > config.slashAmountMedium) {
500
+ errors.push(
501
+ `slashAmountSmall (${config.slashAmountSmall}) must be less than or equal to slashAmountMedium (${config.slashAmountMedium})`,
502
+ );
503
+ }
504
+
505
+ // From: require(_slashAmounts[1] <= _slashAmounts[2], Errors.TallySlashingProposer__InvalidSlashAmounts(_slashAmounts));
506
+ if (config.slashAmountMedium > config.slashAmountLarge) {
507
+ errors.push(
508
+ `slashAmountMedium (${config.slashAmountMedium}) must be less than or equal to slashAmountLarge (${config.slashAmountLarge})`,
509
+ );
510
+ }
511
+
512
+ // From: require(LIFETIME_IN_ROUNDS < ROUNDABOUT_SIZE, Errors.TallySlashingProposer__LifetimeMustBeLessThanRoundabout(...));
513
+ const ROUNDABOUT_SIZE = 128; // Constant from TallySlashingProposer
514
+ if (config.slashingLifetimeInRounds >= ROUNDABOUT_SIZE) {
515
+ errors.push(`slashingLifetimeInRounds (${config.slashingLifetimeInRounds}) must be less than ${ROUNDABOUT_SIZE}`);
516
+ }
517
+
518
+ // From: require(ROUND_SIZE_IN_EPOCHS > 0, Errors.TallySlashingProposer__RoundSizeInEpochsMustBeGreaterThanZero(...));
519
+ if (config.slashingRoundSizeInEpochs <= 0) {
520
+ errors.push(`slashingRoundSizeInEpochs (${config.slashingRoundSizeInEpochs}) must be greater than 0`);
521
+ }
522
+
523
+ // From: require(ROUND_SIZE < MAX_ROUND_SIZE, Errors.TallySlashingProposer__RoundSizeTooLarge(ROUND_SIZE, MAX_ROUND_SIZE));
524
+ const MAX_ROUND_SIZE = 1024; // Constant from TallySlashingProposer
525
+ if (roundSizeInSlots >= MAX_ROUND_SIZE) {
526
+ errors.push(`slashing round size in slots (${roundSizeInSlots}) must be less than ${MAX_ROUND_SIZE}`);
527
+ }
528
+
529
+ // From: require(COMMITTEE_SIZE > 0, Errors.TallySlashingProposer__CommitteeSizeMustBeGreaterThanZero(COMMITTEE_SIZE));
530
+ if (config.aztecTargetCommitteeSize <= 0) {
531
+ errors.push(`aztecTargetCommitteeSize (${config.aztecTargetCommitteeSize}) must be greater than 0`);
532
+ }
533
+
534
+ // From: require(voteSize <= 128, Errors.TallySlashingProposer__VoteSizeTooBig(voteSize, 128));
535
+ // voteSize = COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS / 4
536
+ const voteSize = (config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs) / 4;
537
+ if (voteSize > 128) {
538
+ errors.push(`vote size (${voteSize}) must be <= 128 (committee size * round size in epochs / 4)`);
539
+ }
540
+
541
+ // From: require(COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS % 4 == 0, Errors.TallySlashingProposer__InvalidCommitteeAndRoundSize(...));
542
+ if ((config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs) % 4 !== 0) {
543
+ errors.push(
544
+ `aztecTargetCommitteeSize * slashingRoundSizeInEpochs (${config.aztecTargetCommitteeSize * config.slashingRoundSizeInEpochs}) must be divisible by 4`,
545
+ );
546
+ }
547
+
548
+ // Slashing offset validation: should be positive to allow proper slashing timing
549
+ if (config.slashingOffsetInRounds < 0) {
550
+ errors.push('slashingOffsetInRounds cannot be negative');
551
+ }
552
+ }
@@ -9,12 +9,24 @@ export class FeeAssetHandlerContract {
9
9
  public address: EthAddress;
10
10
 
11
11
  constructor(
12
- address: Hex,
12
+ address: Hex | EthAddress,
13
13
  public readonly txUtils: L1TxUtils,
14
14
  ) {
15
+ if (address instanceof EthAddress) {
16
+ address = address.toString();
17
+ }
15
18
  this.address = EthAddress.fromString(address);
16
19
  }
17
20
 
21
+ public async getOwner(): Promise<EthAddress> {
22
+ const contract = getContract({
23
+ abi: FeeAssetHandlerAbi,
24
+ address: this.address.toString(),
25
+ client: this.txUtils.client,
26
+ });
27
+ return EthAddress.fromString(await contract.read.owner());
28
+ }
29
+
18
30
  public getMintAmount() {
19
31
  const contract = getContract({
20
32
  abi: FeeAssetHandlerAbi,
@@ -24,7 +36,10 @@ export class FeeAssetHandlerContract {
24
36
  return contract.read.mintAmount();
25
37
  }
26
38
 
27
- public mint(recipient: Hex) {
39
+ public mint(recipient: Hex | EthAddress) {
40
+ if (recipient instanceof EthAddress) {
41
+ recipient = recipient.toString();
42
+ }
28
43
  return this.txUtils.sendAndMonitorTransaction({
29
44
  to: this.address.toString(),
30
45
  data: encodeFunctionData({
@@ -9,9 +9,12 @@ export class FeeJuiceContract {
9
9
  private readonly feeJuiceContract: GetContractReturnType<typeof FeeJuiceAbi, ViemClient>;
10
10
 
11
11
  constructor(
12
- address: Hex,
12
+ address: Hex | EthAddress,
13
13
  public readonly client: ViemClient,
14
14
  ) {
15
+ if (address instanceof EthAddress) {
16
+ address = address.toString();
17
+ }
15
18
  this.feeJuiceContract = getContract({ address, abi: FeeJuiceAbi, client });
16
19
  }
17
20
 
@@ -19,6 +22,10 @@ export class FeeJuiceContract {
19
22
  return EthAddress.fromString(this.feeJuiceContract.address);
20
23
  }
21
24
 
25
+ public async getOwner(): Promise<EthAddress> {
26
+ return EthAddress.fromString(await this.feeJuiceContract.read.owner());
27
+ }
28
+
22
29
  private assertWalletFeeJuice(): GetContractReturnType<typeof FeeJuiceAbi, ExtendedViemWalletClient> {
23
30
  if (!isExtendedClient(this.client)) {
24
31
  throw new Error('Wallet client is required for this operation');
@@ -136,9 +136,12 @@ export class GovernanceContract extends ReadOnlyGovernanceContract {
136
136
  protected override readonly governanceContract: GetContractReturnType<typeof GovernanceAbi, ExtendedViemWalletClient>;
137
137
 
138
138
  constructor(
139
- address: Hex,
139
+ address: Hex | EthAddress,
140
140
  public override readonly client: ExtendedViemWalletClient,
141
141
  ) {
142
+ if (address instanceof EthAddress) {
143
+ address = address.toString();
144
+ }
142
145
  super(address, client);
143
146
  if (!isExtendedClient(client)) {
144
147
  throw new Error('GovernanceContract has to be instantiated with a wallet client.');
@@ -21,8 +21,11 @@ export class GovernanceProposerContract implements IEmpireBase {
21
21
 
22
22
  constructor(
23
23
  public readonly client: ViemClient,
24
- address: Hex,
24
+ address: Hex | EthAddress,
25
25
  ) {
26
+ if (address instanceof EthAddress) {
27
+ address = address.toString();
28
+ }
26
29
  this.proposer = getContract({ address, abi: GovernanceProposerAbi, client });
27
30
  }
28
31
 
@@ -39,6 +39,14 @@ export class GSEContract {
39
39
  this.gse = getContract({ address, abi: GSEAbi, client });
40
40
  }
41
41
 
42
+ public async getOwner(): Promise<EthAddress> {
43
+ return EthAddress.fromString(await this.gse.read.owner());
44
+ }
45
+
46
+ public async getGovernance(): Promise<EthAddress> {
47
+ return EthAddress.fromString(await this.gse.read.getGovernance());
48
+ }
49
+
42
50
  getAttestersFromIndicesAtTime(instance: Hex | EthAddress, ts: bigint, indices: bigint[]) {
43
51
  if (instance instanceof EthAddress) {
44
52
  instance = instance.toString();