Skip to content

Commit 960c48f

Browse files
committed
add Slasher / SlashingProposers
1 parent 787c584 commit 960c48f

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

l1-contracts/scripts/verify-from-json.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ resolve_fqn() {
127127
echo "src/core/messagebridge/Inbox.sol:Inbox" ;;
128128
Outbox)
129129
echo "src/core/messagebridge/Outbox.sol:Outbox" ;;
130+
Slasher)
131+
echo "src/core/slashing/Slasher.sol:Slasher" ;;
132+
EmpireSlashingProposer)
133+
echo "src/core/slashing/EmpireSlashingProposer.sol:EmpireSlashingProposer" ;;
134+
TallySlashingProposer)
135+
echo "src/core/slashing/TallySlashingProposer.sol:TallySlashingProposer" ;;
130136
*)
131137
echo "" ;;
132138
esac

yarn-project/ethereum/src/deploy_l1_contracts.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,109 @@ export const deployL1Contracts = async (
10411041
{ name: 'Inbox', address: inboxAddr, constructorArgsHex: inboxCtor, libraries: [] },
10421042
{ name: 'Outbox', address: outboxAddr, constructorArgsHex: outboxCtor, libraries: [] },
10431043
);
1044+
1045+
// Include Slasher and SlashingProposer (if deployed) in verification data
1046+
try {
1047+
const slasherAddrHex = await rollup.getSlasher();
1048+
const slasherAddr = EthAddress.fromString(slasherAddrHex);
1049+
if (!slasherAddr.isZero()) {
1050+
// Slasher constructor: (address _vetoer, address _governance)
1051+
const slasherCtor = encodeAbiParameters(
1052+
[{ type: 'address' }, { type: 'address' }],
1053+
[args.slashingVetoer.toString(), l1Client.account.address],
1054+
);
1055+
deployer.verificationRecords.push({
1056+
name: 'Slasher',
1057+
address: slasherAddr.toString(),
1058+
constructorArgsHex: slasherCtor,
1059+
libraries: [],
1060+
});
1061+
1062+
// Proposer address is stored in Slasher.PROPOSER()
1063+
const proposerAddr = (await rollup.getSlashingProposerAddress()).toString();
1064+
1065+
// Compute constructor args matching deployment path in RollupCore
1066+
const computedRoundSize = BigInt(args.slashingRoundSizeInEpochs * args.aztecEpochDuration);
1067+
const computedQuorum = BigInt(
1068+
args.slashingQuorum ?? (args.slashingRoundSizeInEpochs * args.aztecEpochDuration) / 2 + 1,
1069+
);
1070+
const lifetimeInRounds = BigInt(args.slashingLifetimeInRounds);
1071+
const executionDelayInRounds = BigInt(args.slashingExecutionDelayInRounds);
1072+
1073+
if (args.slasherFlavor === 'tally') {
1074+
const slashAmounts: readonly [bigint, bigint, bigint] = [
1075+
args.slashAmountSmall,
1076+
args.slashAmountMedium,
1077+
args.slashAmountLarge,
1078+
];
1079+
const committeeSize = BigInt(args.aztecTargetCommitteeSize);
1080+
const epochDuration = BigInt(args.aztecEpochDuration);
1081+
const slashOffsetInRounds = BigInt(args.slashingOffsetInRounds);
1082+
1083+
const proposerCtor = encodeAbiParameters(
1084+
[
1085+
{ type: 'address' },
1086+
{ type: 'address' },
1087+
{ type: 'uint256' },
1088+
{ type: 'uint256' },
1089+
{ type: 'uint256' },
1090+
{ type: 'uint256' },
1091+
{ type: 'uint256[3]' },
1092+
{ type: 'uint256' },
1093+
{ type: 'uint256' },
1094+
{ type: 'uint256' },
1095+
],
1096+
[
1097+
rollup.address,
1098+
slasherAddr.toString(),
1099+
computedQuorum,
1100+
computedRoundSize,
1101+
lifetimeInRounds,
1102+
executionDelayInRounds,
1103+
slashAmounts,
1104+
committeeSize,
1105+
epochDuration,
1106+
slashOffsetInRounds,
1107+
],
1108+
);
1109+
1110+
deployer.verificationRecords.push({
1111+
name: 'TallySlashingProposer',
1112+
address: proposerAddr,
1113+
constructorArgsHex: proposerCtor,
1114+
libraries: [],
1115+
});
1116+
} else if (args.slasherFlavor === 'empire') {
1117+
const proposerCtor = encodeAbiParameters(
1118+
[
1119+
{ type: 'address' },
1120+
{ type: 'address' },
1121+
{ type: 'uint256' },
1122+
{ type: 'uint256' },
1123+
{ type: 'uint256' },
1124+
{ type: 'uint256' },
1125+
],
1126+
[
1127+
rollup.address,
1128+
slasherAddr.toString(),
1129+
computedQuorum,
1130+
computedRoundSize,
1131+
lifetimeInRounds,
1132+
executionDelayInRounds,
1133+
],
1134+
);
1135+
1136+
deployer.verificationRecords.push({
1137+
name: 'EmpireSlashingProposer',
1138+
address: proposerAddr,
1139+
constructorArgsHex: proposerCtor,
1140+
libraries: [],
1141+
});
1142+
}
1143+
}
1144+
} catch (e) {
1145+
logger.warn(`Failed to add Slasher/Proposer verification records: ${String(e)}`);
1146+
}
10441147
const date = new Date();
10451148
const formattedDate = date.toISOString().slice(2, 19).replace(/[-T:]/g, '');
10461149
// Ensure the verification output directory exists

0 commit comments

Comments
 (0)