Skip to content

Commit 2ebca95

Browse files
committed
chore: Validate L1 config in ts-land
Validates L1 config _before_ trying to deploy L1 contracts, so we can get an early warning if the deployment would fail. Also, changes the slashRoundSize setting to slashRoundSizeInEpochs, to force it to be a multiple of epochs, as required by the slash proposer. It also makes the quorum settings optional, defaulting them to half the round size plus one. This should make configuration easier.
1 parent c5fa2d3 commit 2ebca95

21 files changed

+255
-55
lines changed

l1-contracts/src/core/libraries/Errors.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ library Errors {
198198
error TallySlashingProposer__SlashOffsetMustBeGreaterThanZero(uint256 slashOffset);
199199
error TallySlashingProposer__InvalidEpochIndex(uint256 epochIndex, uint256 roundSizeInEpochs);
200200
error TallySlashingProposer__VoteSizeTooBig(uint256 voteSize, uint256 maxSize);
201+
error TallySlashingProposer__VotesMustBeMultipleOf4(uint256 votes);
201202

202203
// SlashPayloadLib
203204
error SlashPayload_ArraySizeMismatch(uint256 expected, uint256 actual);

l1-contracts/src/core/slashing/TallySlashingProposer.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ contract TallySlashingProposer is EIP712 {
355355
// We have allocated 4 bytes32 slots = 128 bytes maximum
356356
uint256 voteSize = COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS / 4;
357357
require(voteSize <= 128, Errors.TallySlashingProposer__VoteSizeTooBig(voteSize, 128));
358+
359+
require(
360+
COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS % 4 == 0,
361+
Errors.TallySlashingProposer__VotesMustBeMultipleOf4(COMMITTEE_SIZE * ROUND_SIZE_IN_EPOCHS)
362+
);
358363
}
359364

360365
/**

yarn-project/aztec/src/cli/chain_l2_config.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ export const alphaTestnetL2ChainConfig: L2ChainConfig = {
123123
/** The minimum stake for a validator. */
124124
ejectionThreshold: DefaultL1ContractsConfig.ejectionThreshold,
125125
/** The slashing round size */
126-
slashingRoundSize: 32 * 6, // 6 epochs
127-
/** The slashing quorum */
128-
slashingQuorum: (32 * 6) / 2 + 1, // 6 epochs, majority of validators
129-
/** Governance proposing quorum */
130-
governanceProposerQuorum: 151,
126+
slashingRoundSizeInEpochs: 6, // 6 epochs
131127
/** Governance proposing round size */
132128
governanceProposerRoundSize: 300,
133129
/** The mana target for the rollup */
@@ -219,9 +215,9 @@ export async function getL2ChainConfig(
219215
return undefined;
220216
}
221217

222-
function enrichVar(envVar: EnvVar, value: string) {
218+
function enrichVar(envVar: EnvVar, value: string | undefined) {
223219
// Don't override
224-
if (process.env[envVar]) {
220+
if (process.env[envVar] || value === undefined) {
225221
return;
226222
}
227223
process.env[envVar] = value;
@@ -306,9 +302,9 @@ export async function enrichEnvironmentWithChainConfig(networkName: NetworkNames
306302
enrichVar('AZTEC_PROOF_SUBMISSION_EPOCHS', config.aztecProofSubmissionEpochs.toString());
307303
enrichVar('AZTEC_ACTIVATION_THRESHOLD', config.activationThreshold.toString());
308304
enrichVar('AZTEC_EJECTION_THRESHOLD', config.ejectionThreshold.toString());
309-
enrichVar('AZTEC_SLASHING_QUORUM', config.slashingQuorum.toString());
310-
enrichVar('AZTEC_SLASHING_ROUND_SIZE', config.slashingRoundSize.toString());
311-
enrichVar('AZTEC_GOVERNANCE_PROPOSER_QUORUM', config.governanceProposerQuorum.toString());
305+
enrichVar('AZTEC_SLASHING_QUORUM', config.slashingQuorum?.toString());
306+
enrichVar('AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS', config.slashingRoundSizeInEpochs.toString());
307+
enrichVar('AZTEC_GOVERNANCE_PROPOSER_QUORUM', config.governanceProposerQuorum?.toString());
312308
enrichVar('AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE', config.governanceProposerRoundSize.toString());
313309
enrichVar('AZTEC_MANA_TARGET', config.manaTarget.toString());
314310
enrichVar('AZTEC_PROVING_COST_PER_MANA', config.provingCostPerMana.toString());

yarn-project/end-to-end/src/e2e_p2p/add_rollup.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ describe('e2e_p2p_add_rollup', () => {
7575
initialConfig: {
7676
...SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES,
7777
listenAddress: '127.0.0.1',
78-
governanceProposerQuorum: 6,
7978
governanceProposerRoundSize: 10,
8079
},
8180
});
@@ -158,7 +157,7 @@ describe('e2e_p2p_add_rollup', () => {
158157
aztecTargetCommitteeSize: t.ctx.aztecNodeConfig.aztecTargetCommitteeSize,
159158
aztecProofSubmissionEpochs: t.ctx.aztecNodeConfig.aztecProofSubmissionEpochs,
160159
slashingQuorum: t.ctx.aztecNodeConfig.slashingQuorum,
161-
slashingRoundSize: t.ctx.aztecNodeConfig.slashingRoundSize,
160+
slashingRoundSizeInEpochs: t.ctx.aztecNodeConfig.slashingRoundSizeInEpochs,
162161
slashingLifetimeInRounds: t.ctx.aztecNodeConfig.slashingLifetimeInRounds,
163162
slashingExecutionDelayInRounds: t.ctx.aztecNodeConfig.slashingExecutionDelayInRounds,
164163
slashingVetoer: t.ctx.aztecNodeConfig.slashingVetoer,

yarn-project/end-to-end/src/e2e_p2p/data_withholding_slash.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('e2e_p2p_data_withholding_slash', () => {
5858
aztecSlotDuration,
5959
aztecProofSubmissionEpochs: 0, // effectively forces instant reorgs
6060
slashingQuorum,
61-
slashingRoundSize,
61+
slashingRoundSizeInEpochs: slashingRoundSize / 2,
6262
slashAmountSmall: slashingUnit,
6363
slashAmountMedium: slashingUnit * 2n,
6464
slashAmountLarge: slashingUnit * 3n,

yarn-project/end-to-end/src/e2e_p2p/gossip_network.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('e2e_p2p_network', () => {
5959
initialConfig: {
6060
...SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES,
6161
aztecEpochDuration: 4,
62-
slashingRoundSize: 8,
62+
slashingRoundSizeInEpochs: 2,
6363
slashingQuorum: 5,
6464
listenAddress: '127.0.0.1',
6565
},

yarn-project/end-to-end/src/e2e_p2p/inactivity_slash.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('e2e_p2p_inactivity_slash', () => {
5151
validatorReexecute: false,
5252
sentinelEnabled: true,
5353
slashingQuorum: SLASHING_QUORUM,
54-
slashingRoundSize: SLASHING_ROUND_SIZE,
54+
slashingRoundSizeInEpochs: SLASHING_ROUND_SIZE / EPOCH_DURATION,
5555
slashInactivityTargetPercentage: 0.5,
5656
slashAmountSmall: SLASHING_UNIT,
5757
slashAmountMedium: SLASHING_UNIT * 2n,

yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export class P2PNetworkTest {
116116
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
117117
aztecProofSubmissionEpochs:
118118
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
119-
slashingRoundSize: initialValidatorConfig.slashingRoundSize ?? l1ContractsConfig.slashingRoundSize,
119+
slashingRoundSizeInEpochs:
120+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
120121
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
121122
aztecTargetCommitteeSize: numberOfValidators,
122123
salt: 420,
@@ -127,7 +128,8 @@ export class P2PNetworkTest {
127128
{
128129
...initialValidatorConfig,
129130
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
130-
slashingRoundSize: initialValidatorConfig.slashingRoundSize ?? l1ContractsConfig.slashingRoundSize,
131+
slashingRoundSizeInEpochs:
132+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
131133
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
132134

133135
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,

yarn-project/end-to-end/src/e2e_p2p/reqresp.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ describe('e2e_p2p_reqresp_tx', () => {
3636
...SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES,
3737
listenAddress: '127.0.0.1',
3838
aztecEpochDuration: 64, // stable committee
39-
slashingRoundSize: 128,
40-
slashingQuorum: 65,
39+
slashingRoundSizeInEpochs: 2,
4140
},
4241
});
4342
await t.applyBaseSnapshots();

yarn-project/end-to-end/src/e2e_p2p/reqresp_no_handshake.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ describe('e2e_p2p_reqresp_tx_no_handshake', () => {
4141
p2pDisableStatusHandshake: true, // DIFFERENCE FROM reqresp.test.ts
4242
listenAddress: '127.0.0.1',
4343
aztecEpochDuration: 64, // stable committee
44-
slashingRoundSize: 128,
45-
slashingQuorum: 65,
44+
slashingRoundSizeInEpochs: 2,
4645
},
4746
});
4847
await t.applyBaseSnapshots();

0 commit comments

Comments
 (0)