Skip to content

Commit 4b23bd1

Browse files
authored
grandpa: report equivocations with unsigned extrinsics (#6656)
* grandpa: use unsigned extrinsics for equivocation reporting * grandpa: allow signed reports as well * grandpa: change runtime api for submitting unsigned extrinsics * grandpa: fix tests * grandpa: add test for unsigned validation * grandpa: add benchmark for equivocation proof checking * offences: fix grandpa benchmark * grandpa: add proper weight for equivocation reporting extrinsic * grandpa: fix weight unit
1 parent 999722d commit 4b23bd1

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

benchmarking/src/lib.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,16 @@ benchmarks! {
282282
}
283283

284284
report_offence_grandpa {
285-
let r in 1 .. MAX_REPORTERS;
286285
let n in 0 .. MAX_NOMINATORS.min(MAX_NOMINATIONS as u32);
287-
let o = 1;
288286

289-
// Make r reporters
290-
let mut reporters = vec![];
291-
for i in 0 .. r {
292-
let reporter = account("reporter", i, SEED);
293-
reporters.push(reporter);
294-
}
287+
// for grandpa equivocation reports the number of reporters
288+
// and offenders is always 1
289+
let reporters = vec![account("reporter", 1, SEED)];
295290

296291
// make sure reporters actually get rewarded
297292
Staking::<T>::set_slash_reward_fraction(Perbill::one());
298293

299-
let (mut offenders, raw_offenders) = make_offenders::<T>(o, n)?;
294+
let (mut offenders, raw_offenders) = make_offenders::<T>(1, n)?;
300295
let keys = ImOnline::<T>::keys();
301296

302297
let offence = GrandpaEquivocationOffence {
@@ -316,9 +311,9 @@ benchmarks! {
316311
assert_eq!(
317312
System::<T>::event_count(), 0
318313
+ 1 // offence
319-
+ 2 * r // reporter (reward + endowment)
320-
+ o // offenders slashed
321-
+ o * n // nominators slashed
314+
+ 2 // reporter (reward + endowment)
315+
+ 1 // offenders slashed
316+
+ n // nominators slashed
322317
);
323318
}
324319

0 commit comments

Comments
 (0)