This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
slashing aggregator v2 #3137
Closed
Closed
slashing aggregator v2 #3137
Changes from 61 commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
aed1467
very ugly draft
niklasad1 89f127c
progress
niklasad1 0f153e5
progress
niklasad1 81169b9
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 76173fe
progress
niklasad1 0288d17
add `srml-rolling-window`
niklasad1 47fdfa1
nits
niklasad1 60c3ff1
polish
niklasad1 658d785
rolling_window: don't count unregistered kinds
niklasad1 b3ae519
fix: add all static misbehaviours
niklasad1 148848f
nits
niklasad1 bf86c9d
feat: add implementation `DoSlash` for Staking
niklasad1 20e763f
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 9919efc
pass `window_len` instead of static lookup table
niklasad1 0d187a0
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 32fc271
simplify code
niklasad1 166bc5c
nits
niklasad1 032c7ce
cleanup
niklasad1 eaeb6c8
impl `window_length` for Misbehavior type
niklasad1 1ccf201
clarify
niklasad1 b089258
make ready
niklasad1 f50f5fc
nits
niklasad1 b383c4b
feat: `impl_kind` and `impl_base_severity` macros
niklasad1 f21f619
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 2e5519f
clean
niklasad1 3a8f024
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 b41e7d8
clean
niklasad1 66c0a80
bump runtime version
niklasad1 750e051
fix grumble: include rewarder in `DoSlash`
niklasad1 5eb7bcf
grumbles: impl `OnSessionEnding` + BondingGuard
niklasad1 6b90932
fix grumbles + a couple of questions
niklasad1 159ccb0
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 503e512
fix: better name + Result in slashing traits
niklasad1 5b3debe
add a couple of tests
niklasad1 2a2841a
fix: `BondingGuard` will be unbounded
niklasad1 358b14f
nits
niklasad1 f037ca3
feat: era_idx and era_dur for BondingUniqueness
niklasad1 cfd66c7
nits
niklasad1 bb921c1
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 de83094
fix: EraIndex > BondingDuration instead of `>=`
niklasad1 adc54fb
grumble: make `BondingUniqueness` insert_only
niklasad1 ac0b2d2
style nits
niklasad1 c4c7132
remove srml_staking dependency
niklasad1 487b4f2
fix broken build
niklasad1 764611e
broken build
niklasad1 818171b
broken build
niklasad1 b9d0051
fix: slash don't return misconduct level
niklasad1 af8dba8
fix grumbles
niklasad1 2d23e6b
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 f9407c9
bump runtime
niklasad1 2ad7bb2
make tests compile again
niklasad1 63b4374
clarify comment
niklasad1 154a97c
grumbles: nits in the docs and naming
niklasad1 9d7df97
Update srml/rolling-window/src/lib.rs
niklasad1 7f3b879
address grumbles
niklasad1 2f1f6d0
add issue number for StakingSlasher::do_slash
niklasad1 14fbbe2
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 10a1359
fix bad merge
niklasad1 4072658
simplify mock
niklasad1 d514f45
mock: remove needless ExtBuilder
niklasad1 a2a54b8
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 e40e829
grumbles: use `assert_ok` and `assert_noop`
niklasad1 5016b6a
replace `OnSessionEnding` with `OneSessionHandler`
niklasad1 69ad966
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 9f326fb
Kind -> MisbehaviorKind
niklasad1 1f3c340
move `Misbehavior` to `runtime/impls`
niklasad1 1e29317
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 c7569a1
fix bad merge
niklasad1 fe33a5e
introduce `SlashHistory` in srml_staking
niklasad1 faef3df
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 5d2d756
improve `after_slash` impl
niklasad1 b22cc27
restructure: slash mod in staking for now
niklasad1 255ada9
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 fa2f9c1
fix nits
niklasad1 332626a
feat: split rewarding and slashing
niklasad1 b95f075
fix nits
niklasad1 28311fa
add reward tests
niklasad1 e1541bf
feat: slash multiple misconducts 100%
niklasad1 8e3b804
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 18ddb1b
remove enum `Misbehavior`
niklasad1 a50bbb6
add `trait` SlashingOffence, rm `WindowLength`
niklasad1 ada88ea
rewrite me
niklasad1 3029e53
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
|
|
||
| use rstd::prelude::*; | ||
| use support::{ | ||
| construct_runtime, parameter_types, traits::{SplitTwoWays, Currency, OnUnbalanced} | ||
| construct_runtime, parameter_types, traits::{SplitTwoWays, Currency, OnUnbalanced, WindowLength} | ||
| }; | ||
| use substrate_primitives::u32_trait::{_1, _2, _3, _4}; | ||
| use node_primitives::{ | ||
|
|
@@ -44,6 +44,9 @@ use version::RuntimeVersion; | |
| use elections::VoteIndex; | ||
| #[cfg(any(feature = "std", test))] | ||
| use version::NativeVersion; | ||
| #[cfg(any(feature = "std", test))] | ||
| use serde::{Serialize, Deserialize}; | ||
| use parity_codec::{Encode, Decode}; | ||
| use substrate_primitives::OpaqueMetadata; | ||
| use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; | ||
| use finality_tracker::{DEFAULT_REPORT_LATENCY, DEFAULT_WINDOW_SIZE}; | ||
|
|
@@ -75,8 +78,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { | |
| // and set impl_version to equal spec_version. If only runtime | ||
| // implementation changes and behavior does not, then leave spec_version as | ||
| // is and increment impl_version. | ||
| spec_version: 117, | ||
| impl_version: 117, | ||
| spec_version: 118, | ||
| impl_version: 118, | ||
| apis: RUNTIME_API_VERSIONS, | ||
| }; | ||
|
|
||
|
|
@@ -533,3 +536,38 @@ impl_runtime_apis! { | |
| } | ||
| } | ||
| } | ||
|
|
||
| /// Misbehavior type which takes window length as input | ||
| /// Each variant and its data is a seperate kind | ||
| #[derive(Copy, Clone, Eq, Hash, PartialEq, Encode, Decode)] | ||
| #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))] | ||
| pub enum Misbehavior { | ||
| /// Validator is not online | ||
| Unresponsiveness(u32), | ||
| /// Unjustified vote | ||
| UnjustifiedVote(u32), | ||
| /// Rejecting set of votes | ||
| RejectSetVotes(u32), | ||
| /// Equivocation | ||
| Equivocation(u32), | ||
| /// Invalid Vote | ||
| InvalidVote(u32), | ||
| /// Invalid block | ||
| InvalidBlock(u32), | ||
| /// Parachain Invalid validity statement | ||
| ParachainInvalidity(u32), | ||
| } | ||
|
|
||
|
||
| impl WindowLength<u32> for Misbehavior { | ||
| fn window_length(&self) -> &u32 { | ||
| match self { | ||
| Misbehavior::Unresponsiveness(len) => len, | ||
| Misbehavior::UnjustifiedVote(len) => len, | ||
| Misbehavior::RejectSetVotes(len) => len, | ||
| Misbehavior::Equivocation(len) => len, | ||
| Misbehavior::InvalidVote(len) => len, | ||
| Misbehavior::InvalidBlock(len) => len, | ||
| Misbehavior::ParachainInvalidity(len) => len, | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| [package] | ||
| name = "srml-rolling-window" | ||
| version = "2.0.0" | ||
| authors = ["Parity Technologies <[email protected]>"] | ||
| edition = "2018" | ||
|
|
||
| [dependencies] | ||
| balances = { package = "srml-balances", path = "../balances", default-features = false } | ||
| parity-codec = { version = "4.1.1", default-features = false } | ||
| rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } | ||
| serde = { version = "1.0", optional = true } | ||
| sr-primitives = { path = "../../core/sr-primitives", default-features = false } | ||
| srml-support = { path = "../support", default-features = false } | ||
| srml-session = { path = "../session", default-features = false } | ||
| system = { package = "srml-system", path = "../system", default-features = false } | ||
|
|
||
| [dev-dependencies] | ||
| balances = { package = "srml-balances", path = "../balances" } | ||
| runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } | ||
| substrate-primitives = { path = "../../core/primitives" } | ||
| timestamp = { package = "srml-timestamp", path = "../timestamp" } | ||
| srml-staking = { path = "../staking" } | ||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = [ | ||
| "balances/std", | ||
| "parity-codec/std", | ||
| "rstd/std", | ||
| "serde", | ||
| "sr-primitives/std", | ||
| "srml-session/std", | ||
| "srml-support/std", | ||
| "system/std", | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.