Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
aed1467
very ugly draft
niklasad1 Jul 10, 2019
89f127c
progress
niklasad1 Jul 10, 2019
0f153e5
progress
niklasad1 Jul 10, 2019
81169b9
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 11, 2019
76173fe
progress
niklasad1 Jul 11, 2019
0288d17
add `srml-rolling-window`
niklasad1 Jul 11, 2019
47fdfa1
nits
niklasad1 Jul 11, 2019
60c3ff1
polish
niklasad1 Jul 12, 2019
658d785
rolling_window: don't count unregistered kinds
niklasad1 Jul 12, 2019
b3ae519
fix: add all static misbehaviours
niklasad1 Jul 12, 2019
148848f
nits
niklasad1 Jul 12, 2019
bf86c9d
feat: add implementation `DoSlash` for Staking
niklasad1 Jul 12, 2019
20e763f
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 13, 2019
9919efc
pass `window_len` instead of static lookup table
niklasad1 Jul 15, 2019
0d187a0
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 15, 2019
32fc271
simplify code
niklasad1 Jul 15, 2019
166bc5c
nits
niklasad1 Jul 15, 2019
032c7ce
cleanup
niklasad1 Jul 15, 2019
eaeb6c8
impl `window_length` for Misbehavior type
niklasad1 Jul 15, 2019
1ccf201
clarify
niklasad1 Jul 15, 2019
b089258
make ready
niklasad1 Jul 15, 2019
f50f5fc
nits
niklasad1 Jul 15, 2019
b383c4b
feat: `impl_kind` and `impl_base_severity` macros
niklasad1 Jul 16, 2019
f21f619
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 16, 2019
2e5519f
clean
niklasad1 Jul 17, 2019
3a8f024
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 17, 2019
b41e7d8
clean
niklasad1 Jul 17, 2019
66c0a80
bump runtime version
niklasad1 Jul 17, 2019
750e051
fix grumble: include rewarder in `DoSlash`
niklasad1 Jul 17, 2019
5eb7bcf
grumbles: impl `OnSessionEnding` + BondingGuard
niklasad1 Jul 17, 2019
6b90932
fix grumbles + a couple of questions
niklasad1 Jul 17, 2019
159ccb0
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 17, 2019
503e512
fix: better name + Result in slashing traits
niklasad1 Jul 18, 2019
5b3debe
add a couple of tests
niklasad1 Jul 18, 2019
2a2841a
fix: `BondingGuard` will be unbounded
niklasad1 Jul 18, 2019
358b14f
nits
niklasad1 Jul 18, 2019
f037ca3
feat: era_idx and era_dur for BondingUniqueness
niklasad1 Jul 18, 2019
cfd66c7
nits
niklasad1 Jul 18, 2019
bb921c1
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 18, 2019
de83094
fix: EraIndex > BondingDuration instead of `>=`
niklasad1 Jul 19, 2019
adc54fb
grumble: make `BondingUniqueness` insert_only
niklasad1 Jul 19, 2019
ac0b2d2
style nits
niklasad1 Jul 19, 2019
c4c7132
remove srml_staking dependency
niklasad1 Jul 19, 2019
487b4f2
fix broken build
niklasad1 Jul 19, 2019
764611e
broken build
niklasad1 Jul 19, 2019
818171b
broken build
niklasad1 Jul 19, 2019
b9d0051
fix: slash don't return misconduct level
niklasad1 Jul 19, 2019
af8dba8
fix grumbles
niklasad1 Jul 19, 2019
2d23e6b
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 21, 2019
f9407c9
bump runtime
niklasad1 Jul 21, 2019
2ad7bb2
make tests compile again
niklasad1 Jul 21, 2019
63b4374
clarify comment
niklasad1 Jul 22, 2019
154a97c
grumbles: nits in the docs and naming
niklasad1 Jul 22, 2019
9d7df97
Update srml/rolling-window/src/lib.rs
niklasad1 Jul 22, 2019
7f3b879
address grumbles
niklasad1 Jul 22, 2019
2f1f6d0
add issue number for StakingSlasher::do_slash
niklasad1 Jul 22, 2019
14fbbe2
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 22, 2019
10a1359
fix bad merge
niklasad1 Jul 22, 2019
4072658
simplify mock
niklasad1 Jul 23, 2019
d514f45
mock: remove needless ExtBuilder
niklasad1 Jul 24, 2019
a2a54b8
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 24, 2019
e40e829
grumbles: use `assert_ok` and `assert_noop`
niklasad1 Jul 24, 2019
5016b6a
replace `OnSessionEnding` with `OneSessionHandler`
niklasad1 Jul 25, 2019
69ad966
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 25, 2019
9f326fb
Kind -> MisbehaviorKind
niklasad1 Jul 25, 2019
1f3c340
move `Misbehavior` to `runtime/impls`
niklasad1 Jul 25, 2019
1e29317
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 25, 2019
c7569a1
fix bad merge
niklasad1 Jul 25, 2019
fe33a5e
introduce `SlashHistory` in srml_staking
niklasad1 Jul 29, 2019
faef3df
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 30, 2019
5d2d756
improve `after_slash` impl
niklasad1 Jul 30, 2019
b22cc27
restructure: slash mod in staking for now
niklasad1 Jul 31, 2019
255ada9
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Jul 31, 2019
fa2f9c1
fix nits
niklasad1 Jul 31, 2019
332626a
feat: split rewarding and slashing
niklasad1 Aug 1, 2019
b95f075
fix nits
niklasad1 Aug 1, 2019
28311fa
add reward tests
niklasad1 Aug 1, 2019
e1541bf
feat: slash multiple misconducts 100%
niklasad1 Aug 2, 2019
8e3b804
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Aug 2, 2019
18ddb1b
remove enum `Misbehavior`
niklasad1 Aug 4, 2019
a50bbb6
add `trait` SlashingOffence, rm `WindowLength`
niklasad1 Aug 4, 2019
ada88ea
rewrite me
niklasad1 Aug 4, 2019
3029e53
Merge remote-tracking branch 'origin/master' into na-robs-suggest-slash
niklasad1 Aug 4, 2019
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
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ members = [
"srml/staking",
"srml/sudo",
"srml/system",
"srml/rolling-window",
"srml/timestamp",
"srml/treasury",
"node/cli",
Expand Down
44 changes: 41 additions & 3 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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};
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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),
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe define type WindowLength = u32.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see that you have a trait.

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,
}
}
}
35 changes: 35 additions & 0 deletions srml/rolling-window/Cargo.toml
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",
]
Loading