Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

runtime/disputes: slashing #5535

Merged
merged 95 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
d6a2eb2
disputes: runtime part of slashing
ordian May 6, 2022
fd2194a
disputes: reward winners
ordian May 9, 2022
9f8daef
disputes/slashing: validate_unsigned impl
ordian May 11, 2022
ee46d14
fmt
ordian May 11, 2022
7b158f6
disputes/slashing: report_dispute_lost_unsigned
ordian May 11, 2022
60a82a4
disputes/slashing: separate winners from losers and report winners
ordian May 13, 2022
b303ee4
disputes/slashing: refactoring
ordian May 13, 2022
6f1d724
impl HandleReports
ordian May 16, 2022
4a55be9
enable on Wenstend
ordian May 16, 2022
1941543
fmt
ordian May 16, 2022
04ad120
add slashing pallet to the mock and test runtimes
ordian May 16, 2022
3784591
fix a bug in report_dispute_lost_unsigned
ordian May 16, 2022
f49b55f
fmt
ordian May 16, 2022
cbcf176
disputes: remove new_participants from summary
ordian May 17, 2022
7b82f0d
disputes: remove punish_inconclusive
ordian May 17, 2022
f863baf
impl SlashingHandler for Pallet for type-safety
ordian May 17, 2022
b4fa682
do not impl slashing::Config on mainnets yet
ordian May 17, 2022
2739900
teach spellcheck deduplication
ordian May 17, 2022
62ff14f
simplify interfaces and resolve some TODOs
ordian May 17, 2022
4db3ab8
resolve some more TODOs
ordian May 17, 2022
02c069d
minor typos
ordian May 17, 2022
6fc8f5f
move slashing into a folder
ordian May 18, 2022
7f3ae20
remove unnecessary clone
ordian May 18, 2022
13c7c84
fix validator_set_count calculation
ordian May 18, 2022
5c98289
introduce ValidatorSetCount
ordian May 18, 2022
8263d16
store ValidatorSetCount
ordian May 18, 2022
c073e08
fmt
ordian May 18, 2022
dc3b6de
add the benchmark
ordian Jun 14, 2022
75f256d
fmt
ordian Jun 14, 2022
65851ad
unflatten slashing
ordian Jun 14, 2022
2210bad
post-rebase fixes
ordian Jun 14, 2022
6ab6b48
remove winners eagerly
ordian Jun 14, 2022
6a0ddfc
use real slashing weights for westend
ordian Jun 14, 2022
29376b1
remove bench test suite
ordian Jun 17, 2022
f76a697
Merge branch 'master' into ao-disputes-offences-runtime
ordian Jun 17, 2022
4800be1
zombinet: modify disputes test to check for an offence report
ordian Jun 17, 2022
4c0f83e
zombinet: add a timeout
ordian Jun 17, 2022
3086e26
add slashing pallet to Rococo
ordian Jun 20, 2022
677a262
zombienet: revert back to rococo-local
ordian Jun 20, 2022
e1ff282
Merge branch 'master' into ao-disputes-offences-runtime
ordian Jun 20, 2022
fe7495e
fmt
ordian Jun 20, 2022
461f37f
remove TODOs
ordian Jun 20, 2022
bae9912
revert some accidental changes
ordian Jun 20, 2022
15fcf48
slashing is submodule of disputes
ordian Jun 21, 2022
097d6c1
Merge branch 'master' into ao-disputes-offences-runtime
ordian Jun 21, 2022
65146ca
Merge branch 'master' into ao-disputes-offences-runtime
ordian Jun 28, 2022
650eb19
Merge branch 'master' into ao-disputes-offences-runtime
ordian Jul 5, 2022
95cd87d
Merge branch 'master' into ao-disputes-offences-runtime
ordian Jul 28, 2022
760bdc7
Change the log target
ordian Jul 30, 2022
d3405cc
Merge branch 'master' into ao-disputes-offences-runtime
ordian Aug 1, 2022
d5b3324
Merge branch 'ao-disputes-offences-runtime' of github.com:paritytech/…
ordian Aug 1, 2022
f50aa7d
wrap comments with rustfmt, more docs, constants
ordian Aug 1, 2022
248baa5
use Defensive trait
ordian Aug 3, 2022
b02bcef
cargo update -p sp-io
ordian Aug 3, 2022
e1c87c4
merge offence types, remove rewards for now
ordian Aug 3, 2022
37f9cd7
Merge branch 'master' into ao-disputes-offences-runtime
ordian Aug 3, 2022
b531490
cargo update -p sp-io
ordian Aug 3, 2022
454874f
benchmark fixes
ordian Aug 3, 2022
c0db743
fmt
ordian Aug 3, 2022
9fb1e38
unused var
ordian Aug 3, 2022
9c84b22
fix block_author impl
ordian Aug 3, 2022
19b7c6b
ressurect RewardValidators trait
ordian Aug 3, 2022
784e65e
remove outdated comment
ordian Aug 3, 2022
0c2559c
Merge branch 'master' into ao-disputes-offences-runtime
ordian Aug 4, 2022
3a2858d
Merge branch 'master' into ao-disputes-offences-runtime
ordian Aug 4, 2022
c22a943
more module docs
ordian Aug 5, 2022
884d9d8
introduce BenchmarkingConfig
ordian Aug 5, 2022
df81683
Merge branch 'master' into ao-disputes-offences-runtime
ordian Aug 5, 2022
7101379
typo fix
ordian Aug 5, 2022
ce879df
teach spellcheck unapplied
ordian Aug 5, 2022
b070f34
Merge branch 'master' into ao-disputes-offences-runtime
ordian Aug 31, 2022
563995b
Merge branch 'master' into ao-disputes-offences-runtime
ordian Aug 31, 2022
7d5171c
use Weight::new()
ordian Aug 31, 2022
b436249
fix mocking rewards
ordian Aug 31, 2022
397046e
use RefTimeWeight
ordian Aug 31, 2022
18965e3
".git/.scripts/bench-bot.sh" runtime westend-dev runtime_parachains::…
Aug 31, 2022
7269e18
refactor maybe_identify_validators
ordian Aug 31, 2022
399e0e6
no more ticket in disguise
ordian Aug 31, 2022
89fb5ed
remove outdated comments
ordian Aug 31, 2022
4f34bd7
lower against valid to 0.1%
ordian Sep 1, 2022
0d99787
bump zombienet version for debug
pepoviola Sep 1, 2022
9223d71
use from_perthousand
ordian Sep 1, 2022
c48aa45
Merge branch 'master' into ao-disputes-offences-runtime
ordian Sep 1, 2022
655fe98
post-merge fixes
ordian Sep 1, 2022
81578ff
Merge branch 'master' into ao-disputes-offences-runtime
ordian Sep 2, 2022
c5472c9
another day, another Weight changes
ordian Sep 2, 2022
6e5f372
Revert "bump zombienet version for debug"
ordian Sep 2, 2022
7bf295a
do not reward block authors
ordian Sep 5, 2022
8309493
Merge branch 'master' into ao-disputes-offences-runtime
ordian Sep 5, 2022
cd9aeb8
fix outdated comment
ordian Sep 6, 2022
3fe81e9
merge master once again
ordian Sep 6, 2022
e87cc9c
merge master once again II
ordian Sep 8, 2022
918b4ca
Merge branch 'master' into ao-disputes-offences-runtime
ordian Sep 19, 2022
b453b1a
use Pays from frame_support::dispatch::Pays
pepoviola Sep 19, 2022
65da473
add timeout to is up
pepoviola Sep 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix mocking rewards
  • Loading branch information
ordian committed Aug 31, 2022
commit b436249a0fdd91d1ad399102e75b65948ad93970
18 changes: 17 additions & 1 deletion runtime/parachains/src/disputes/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
disputes::DisputesHandler,
mock::{
new_test_ext, AccountId, AllPalletsWithSystem, Initializer, MockGenesisConfig, System,
Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR,
Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, REWARD_VALIDATORS,
},
};
use assert_matches::assert_matches;
Expand Down Expand Up @@ -1266,6 +1266,22 @@ fn test_provide_multi_dispute_success_and_other() {
Pallet::<Test>::note_included(4, candidate_hash.clone(), 4);
assert_eq!(SpamSlots::<Test>::get(4), Some(vec![0, 0, 0, 0, 0, 0, 0]));

// Ensure the `reward_validator` function was correctly called
assert_eq!(
REWARD_VALIDATORS.with(|r| r.borrow().clone()),
vec![
(3, vec![ValidatorIndex(0), ValidatorIndex(2)]),
(4, vec![ValidatorIndex(2), ValidatorIndex(3)]),
(3, vec![ValidatorIndex(3)]),
(3, vec![ValidatorIndex(5)]),
(5, vec![ValidatorIndex(2), ValidatorIndex(5)]),
(3, vec![ValidatorIndex(6)]),
(5, vec![ValidatorIndex(6)]),
(5, vec![ValidatorIndex(0), ValidatorIndex(1), ValidatorIndex(4)]),
(3, vec![ValidatorIndex(1), ValidatorIndex(4)]),
],
);

// Ensure punishment against is called
assert_eq!(
PUNISH_VALIDATORS_AGAINST.with(|r| r.borrow().clone()),
Expand Down
14 changes: 12 additions & 2 deletions runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,26 @@ impl crate::hrmp::Config for Test {

impl crate::disputes::Config for Test {
type Event = Event;
type RewardValidators = ();
type RewardValidators = Self;
type SlashingHandler = Self;
type WeightInfo = crate::disputes::TestWeightInfo;
}

thread_local! {
pub static REWARD_VALIDATORS: RefCell<Vec<(SessionIndex, Vec<ValidatorIndex>)>> = RefCell::new(Vec::new());
pub static PUNISH_VALIDATORS_FOR: RefCell<Vec<(SessionIndex, Vec<ValidatorIndex>)>> = RefCell::new(Vec::new());
pub static PUNISH_VALIDATORS_AGAINST: RefCell<Vec<(SessionIndex, Vec<ValidatorIndex>)>> = RefCell::new(Vec::new());
}

impl crate::disputes::RewardValidators for Test {
fn reward_dispute_statement(
session: SessionIndex,
validators: impl IntoIterator<Item = ValidatorIndex>,
) {
REWARD_VALIDATORS.with(|r| r.borrow_mut().push((session, validators.into_iter().collect())))
}
}

impl crate::disputes::SlashingHandler<BlockNumber> for Test {
fn punish_for_invalid(
session: SessionIndex,
Expand All @@ -271,7 +281,7 @@ impl crate::disputes::SlashingHandler<BlockNumber> for Test {
}

fn initializer_initialize(_now: BlockNumber) -> Weight {
0
Weight::new()
}

fn initializer_finalize() {}
Expand Down