Skip to content

Commit a4abea5

Browse files
committed
fix: align benchmark with slashing proposer
1 parent 69de949 commit a4abea5

File tree

1 file changed

+7
-73
lines changed

1 file changed

+7
-73
lines changed

l1-contracts/test/benchmark/happy.t.sol

Lines changed: 7 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,8 @@ import {Timestamp, Slot, Epoch, TimeLib} from "@aztec/core/libraries/TimeLib.sol
6161
import {MultiAdder, CheatDepositArgs} from "@aztec/mock/MultiAdder.sol";
6262
import {RollupBuilder} from "../builder/RollupBuilder.sol";
6363
import {ProposedHeader} from "@aztec/core/libraries/rollup/ProposedHeaderLib.sol";
64-
import {EmpireSlashingProposer} from "@aztec/core/slashing/EmpireSlashingProposer.sol";
65-
import {SlashFactory} from "@aztec/periphery/SlashFactory.sol";
66-
import {IValidatorSelection} from "@aztec/core/interfaces/IValidatorSelection.sol";
6764
import {Slasher} from "@aztec/core/slashing/Slasher.sol";
68-
import {SlasherFlavor} from "@aztec/core/interfaces/ISlasher.sol";
69-
import {TallySlashingProposer} from "@aztec/core/slashing/TallySlashingProposer.sol";
70-
import {IPayload} from "@aztec/governance/interfaces/IPayload.sol";
65+
import {SlashingProposer} from "@aztec/core/slashing/SlashingProposer.sol";
7166
import {StakingQueueConfig} from "@aztec/core/libraries/compressed-data/StakingQueueConfig.sol";
7267
import {BN254Lib, G1Point, G2Point} from "@aztec/shared/libraries/BN254Lib.sol";
7368
import {SlashRound} from "@aztec/core/libraries/SlashRoundLib.sol";
@@ -122,7 +117,6 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
122117

123118
enum TestSlash {
124119
NONE,
125-
EMPIRE,
126120
TALLY
127121
}
128122

@@ -151,7 +145,6 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
151145
Multicall3 internal multicall = new Multicall3();
152146

153147
address internal slashingProposer;
154-
IPayload internal slashPayload;
155148

156149
modifier prepare(uint256 _validatorCount, bool _noValidators, TestSlash _slashing) {
157150
// We deploy a the rollup and sets the time and all to
@@ -179,14 +172,13 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
179172
RollupBuilder builder = new RollupBuilder(address(this)).setProvingCostPerMana(provingCost)
180173
.setManaTarget(MANA_TARGET).setSlotDuration(SLOT_DURATION).setEpochDuration(EPOCH_DURATION).setMintFeeAmount(1e30)
181174
.setValidators(initialValidators).setTargetCommitteeSize(_noValidators ? 0 : TARGET_COMMITTEE_SIZE)
182-
.setStakingQueueConfig(stakingQueueConfig).setSlashingQuorum(VOTING_ROUND_SIZE)
183-
.setSlashingRoundSize(VOTING_ROUND_SIZE);
175+
.setStakingQueueConfig(stakingQueueConfig);
184176

185177
if (_slashing == TestSlash.TALLY) {
186178
// For tally slashing, we need a round size that's a multiple of epoch duration
187179
uint256 tallyRoundSize = EPOCH_DURATION * 2; // 64; // 2 * EPOCH_DURATION (32) = 64
188180
uint256 tallyQuorum = tallyRoundSize / 2 + 1; // Must be > ROUND_SIZE / 2
189-
builder.setSlasherFlavor(SlasherFlavor.TALLY).setSlashingQuorum(tallyQuorum).setSlashingRoundSize(tallyRoundSize)
181+
builder.setSlasherEnabled(true).setSlashingQuorum(tallyQuorum).setSlashingRoundSize(tallyRoundSize)
190182
.setSlashingLifetimeInRounds(5).setSlashingExecutionDelayInRounds(1).setSlashAmountSmall(1e18)
191183
.setSlashAmountMedium(2e18).setSlashAmountLarge(3e18);
192184
}
@@ -198,12 +190,6 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
198190
slasher = Slasher(rollup.getSlasher());
199191
slashingProposer = address(slasher) == address(0) ? address(0) : slasher.PROPOSER();
200192

201-
SlashFactory slashFactory = new SlashFactory(IValidatorSelection(address(rollup)));
202-
address[] memory toSlash = new address[](0);
203-
uint96[] memory amounts = new uint96[](0);
204-
uint128[][] memory offenses = new uint128[][](0);
205-
slashPayload = slashFactory.createSlashPayload(toSlash, amounts, offenses);
206-
207193
vm.label(coinbase, "coinbase");
208194
vm.label(address(rollup), "ROLLUP");
209195
vm.label(address(asset), "ASSET");
@@ -363,26 +349,6 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
363349
return CommitteeAttestation({addr: _signer, signature: emptySignature});
364350
}
365351

366-
/**
367-
* @notice Creates an EIP-712 signature for signalWithSig
368-
* @param _signer The address that should sign (must match a proposer)
369-
* @param _payload The payload to signal
370-
* @return The EIP-712 signature
371-
*/
372-
function createEmpireSignalSignature(address _signer, IPayload _payload, Slot _slot)
373-
internal
374-
view
375-
returns (Signature memory)
376-
{
377-
uint256 privateKey = attesterPrivateKeys[_signer];
378-
require(privateKey != 0, "Private key not found for signer");
379-
bytes32 digest = EmpireSlashingProposer(slashingProposer).getSignalSignatureDigest(_payload, _slot);
380-
381-
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
382-
383-
return Signature({v: v, r: r, s: s});
384-
}
385-
386352
/**
387353
* @notice Creates vote data for tally slashing
388354
* @param _size - The number of validators
@@ -420,7 +386,7 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
420386
{
421387
uint256 privateKey = attesterPrivateKeys[_signer];
422388
require(privateKey != 0, "Private key not found for signer");
423-
bytes32 digest = TallySlashingProposer(slashingProposer).getVoteSignatureDigest(votes, slot);
389+
bytes32 digest = SlashingProposer(slashingProposer).getVoteSignatureDigest(votes, slot);
424390

425391
(uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest);
426392

@@ -446,7 +412,7 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
446412
});
447413
calls[1] = Multicall3.Call3({
448414
target: address(slashingProposer),
449-
callData: abi.encodeCall(TallySlashingProposer(slashingProposer).vote, (voteData, sig)),
415+
callData: abi.encodeCall(SlashingProposer(slashingProposer).vote, (voteData, sig)),
450416
allowFailure: false
451417
});
452418
multicall.aggregate3(calls);
@@ -456,8 +422,6 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
456422
// Do nothing for the first epoch
457423
Slot nextSlot = Slot.wrap(EPOCH_DURATION * 3 + 1);
458424
Epoch nextEpoch = Epoch.wrap(4);
459-
bool warmedUp = false;
460-
461425
uint256 stopAtCheckpoint = 150;
462426

463427
// Loop through all of the L1 metadata
@@ -468,13 +432,6 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
468432

469433
_loadL1Metadata(i);
470434

471-
if (_slashing == TestSlash.EMPIRE && !warmedUp && rollup.getCurrentSlot() == Slot.wrap(EPOCH_DURATION * 2)) {
472-
address proposer = rollup.getCurrentProposer();
473-
Signature memory sig = createEmpireSignalSignature(proposer, slashPayload, rollup.getCurrentSlot());
474-
EmpireSlashingProposer(slashingProposer).signalWithSig(slashPayload, sig);
475-
warmedUp = true;
476-
}
477-
478435
// For every "new" slot we encounter, we construct a checkpoint using current L1 data and
479436
// the decoded checkpoint fixture. The checkpoint cannot be proven, but it will be accepted
480437
// as a proposal so it is useful for testing a long range of checkpoints.
@@ -490,31 +447,8 @@ contract BenchmarkRollupTest is FeeModelTestPoints, DecoderBase {
490447
uint256 currentCheckpointNumber = rollup.getPendingCheckpointNumber() + 1;
491448
checkpointAttestations[currentCheckpointNumber] = AttestationLibHelper.packAttestations(b.attestations);
492449

493-
if (_slashing == TestSlash.EMPIRE) {
494-
Signature memory sig = createEmpireSignalSignature(proposer, slashPayload, rollup.getCurrentSlot());
495-
Multicall3.Call3[] memory calls = new Multicall3.Call3[](2);
496-
calls[0] = Multicall3.Call3({
497-
target: address(rollup),
498-
callData: abi.encodeCall(
499-
rollup.propose,
500-
(
501-
b.proposeArgs,
502-
AttestationLibHelper.packAttestations(b.attestations),
503-
b.signers,
504-
b.attestationsAndSignersSignature,
505-
b.blobInputs
506-
)
507-
),
508-
allowFailure: false
509-
});
510-
calls[1] = Multicall3.Call3({
511-
target: address(slashingProposer),
512-
callData: abi.encodeCall(EmpireSlashingProposer(slashingProposer).signalWithSig, (slashPayload, sig)),
513-
allowFailure: false
514-
});
515-
multicall.aggregate3(calls);
516-
} else if (_slashing == TestSlash.TALLY) {
517-
SlashRound slashRound = TallySlashingProposer(slashingProposer).getCurrentRound();
450+
if (_slashing == TestSlash.TALLY) {
451+
SlashRound slashRound = SlashingProposer(slashingProposer).getCurrentRound();
518452
// We are offset + 1, because the first round after the offset is used entirely on warming the storage up, so
519453
// we don't get a off-balance update
520454
if (SlashRound.unwrap(slashRound) >= 3) {

0 commit comments

Comments
 (0)