Skip to content

Commit 16f3cf1

Browse files
spalladinomralj
authored andcommitted
fix: Fix integration-l1-publisher e2e
Fixes the `integration_l1_publisher.test.ts` - Removes hardcoded empire slasher and defaults to no slashing - Refactors tally slasher validations to make it clearer when they are run - Renames test to include e2e so it is run in CI - Fixes sorting of actions in sequencer-publisher so invalidate is before publish
1 parent 9be0675 commit 16f3cf1

File tree

4 files changed

+91
-84
lines changed

4 files changed

+91
-84
lines changed

yarn-project/end-to-end/src/integration_l1_publisher/integration_l1_publisher.test.ts renamed to yarn-project/end-to-end/src/e2e_l1_publisher/e2e_l1_publisher.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { GENESIS_ARCHIVE_ROOT, MAX_NULLIFIERS_PER_TX, NUMBER_OF_L1_L2_MESSAGES_P
77
import { EpochCache } from '@aztec/epoch-cache';
88
import {
99
type DeployL1ContractsArgs,
10-
EmpireSlashingProposerContract,
1110
type ExtendedViemWalletClient,
1211
GovernanceProposerContract,
1312
type L1ContractAddresses,
@@ -139,6 +138,7 @@ describe('L1Publisher integration', () => {
139138
deployerAccount = privateKeyToAccount(deployerPK);
140139
({ l1ContractAddresses, l1Client } = await setupL1Contracts(config.l1RpcUrls, deployerAccount, logger, {
141140
aztecTargetCommitteeSize: 0,
141+
slasherFlavor: 'none',
142142
...deployL1ContractsArgs,
143143
}));
144144

@@ -205,11 +205,7 @@ describe('L1Publisher integration', () => {
205205
const sequencerL1Client = createExtendedL1Client(config.l1RpcUrls, sequencerPK, foundry);
206206
const l1TxUtils = createL1TxUtilsWithBlobsFromViemWallet(sequencerL1Client, logger, dateProvider, config);
207207
const rollupContract = new RollupContract(sequencerL1Client, l1ContractAddresses.rollupAddress.toString());
208-
const slashingProposerAddress = await rollupContract.getSlashingProposerAddress();
209-
const slashingProposerContract = new EmpireSlashingProposerContract(
210-
sequencerL1Client,
211-
slashingProposerAddress.toString(),
212-
);
208+
const slashingProposerContract = await rollupContract.getSlashingProposer();
213209
governanceProposerContract = new GovernanceProposerContract(
214210
sequencerL1Client,
215211
l1ContractAddresses.governanceProposerAddress.toString(),
@@ -475,7 +471,7 @@ describe('L1Publisher integration', () => {
475471
{
476472
target: rollupAddress,
477473
callData: expectedRollupData,
478-
allowFailure: false,
474+
allowFailure: true,
479475
},
480476
],
481477
],
@@ -636,8 +632,10 @@ describe('L1Publisher integration', () => {
636632
const block = await buildSingleBlock();
637633

638634
await publisher.enqueueProposeL2Block(block);
639-
await publisher.enqueueSlashingActions(
640-
[{ type: 'vote-empire-payload', payload: EthAddress.random() }],
635+
636+
// Should fail due to random signature
637+
await publisher.enqueueGovernanceCastSignal(
638+
EthAddress.random(),
641639
block.slot,
642640
block.timestamp,
643641
EthAddress.random(),
@@ -647,7 +645,7 @@ describe('L1Publisher integration', () => {
647645
const result = await publisher.sendRequests();
648646

649647
expect(result!.successfulActions).toEqual(['propose']);
650-
expect(result!.failedActions).toEqual(['slashing-signal']);
648+
expect(result!.failedActions).toEqual(['governance-signal']);
651649
});
652650

653651
it(`shows propose custom errors if tx simulation fails`, async () => {

yarn-project/end-to-end/src/integration_l1_publisher/write_json.ts renamed to yarn-project/end-to-end/src/e2e_l1_publisher/write_json.ts

File renamed without changes.

yarn-project/ethereum/src/config.ts

Lines changed: 81 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -423,78 +423,7 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
423423

424424
// TallySlashingProposer constructor validations
425425
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);
498427
}
499428

500429
// Epoch and slot duration validations
@@ -541,3 +470,83 @@ export function validateConfig(config: Omit<L1ContractsConfig, keyof L1TxUtilsCo
541470
);
542471
}
543472
}
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+
}

yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ export enum SignalType {
6868
}
6969

7070
export const Actions = [
71+
'invalidate-by-invalid-attestation',
72+
'invalidate-by-insufficient-attestations',
7173
'propose',
7274
'governance-signal',
7375
'empire-slashing-signal',
7476
'create-empire-payload',
7577
'execute-empire-payload',
7678
'vote-offenses',
7779
'execute-slash',
78-
'invalidate-by-invalid-attestation',
79-
'invalidate-by-insufficient-attestations',
8080
] as const;
8181
export type Action = (typeof Actions)[number];
8282

0 commit comments

Comments
 (0)