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 all 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
20 changes: 20 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
2 changes: 2 additions & 0 deletions node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ executive = { package = "srml-executive", path = "../../srml/executive", default
finality-tracker = { package = "srml-finality-tracker", path = "../../srml/finality-tracker", default-features = false }
grandpa = { package = "srml-grandpa", path = "../../srml/grandpa", default-features = false }
indices = { package = "srml-indices", path = "../../srml/indices", default-features = false }
rolling-window = { package = "srml-rolling-window", path = "../../srml/rolling-window", default-features = false }
session = { package = "srml-session", path = "../../srml/session", default-features = false, features = ["historical"] }
staking = { package = "srml-staking", path = "../../srml/staking", default-features = false }
system = { package = "srml-system", path = "../../srml/system", default-features = false }
Expand Down Expand Up @@ -80,6 +81,7 @@ std = [
"safe-mix/std",
"client/std",
"rustc-hex",
"rolling-window/std",
"substrate-keyring",
"offchain-primitives/std",
"im-online/std",
Expand Down
11 changes: 10 additions & 1 deletion node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl authorship::Trait for Runtime {
type EventHandler = Staking;
}

type SessionHandlers = (Grandpa, Babe, ImOnline);
type SessionHandlers = (Grandpa, Babe, ImOnline, RollingWindow);

impl_opaque_keys! {
pub struct SessionKeys {
Expand Down Expand Up @@ -238,6 +238,10 @@ impl staking::Trait for Runtime {
type SessionInterface = Self;
}

impl staking::slash::Trait for Runtime {
type Currency = Balances;
}

parameter_types! {
pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
Expand Down Expand Up @@ -377,6 +381,10 @@ impl im_online::Trait for Runtime {
type IsValidAuthorityId = Babe;
}

impl rolling_window::Trait for Runtime {
type SessionKey = primitives::sr25519::Public;
}

impl grandpa::Trait for Runtime {
type Event = Event;
}
Expand Down Expand Up @@ -416,6 +424,7 @@ construct_runtime!(
Contracts: contracts,
Sudo: sudo,
ImOnline: im_online::{default, ValidateUnsigned},
RollingWindow: rolling_window::{Module, Storage},
}
);

Expand Down
3 changes: 2 additions & 1 deletion srml/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use inherents::{InherentDataProviders, ProvideInherentData};
use substrate_consensus_aura_primitives::{AURA_ENGINE_ID, ConsensusLog};
#[cfg(feature = "std")]
use parity_codec::Decode;
use session::SessionIndex;

mod mock;
mod tests;
Expand Down Expand Up @@ -188,7 +189,7 @@ impl<T: Trait> Module<T> {
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = T::AuthorityId;

fn on_new_session<'a, I: 'a>(changed: bool, validators: I, _queued_validators: I)
fn on_new_session<'a, I: 'a>(_: (SessionIndex, SessionIndex), changed: bool, validators: I, _queued_validators: I)
where I: Iterator<Item=(&'a T::AccountId, T::AuthorityId)>
{
// instant changes
Expand Down
11 changes: 9 additions & 2 deletions srml/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent
use inherents::{InherentDataProviders, ProvideInherentData};
use babe_primitives::{BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest};
pub use babe_primitives::{AuthorityId, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH};
use session::SessionIndex;

/// The BABE inherent identifier.
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babeslot";
Expand Down Expand Up @@ -273,8 +274,14 @@ impl<T: Trait> OnTimestampSet<T::Moment> for Module<T> {

impl<T: Trait + staking::Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = AuthorityId;
fn on_new_session<'a, I: 'a>(_changed: bool, validators: I, queued_validators: I)
where I: Iterator<Item=(&'a T::AccountId, AuthorityId)>

fn on_new_session<'a, I: 'a>(
_: (SessionIndex, SessionIndex),
_changed: bool,
validators: I,
queued_validators: I,
) where
I: Iterator<Item=(&'a T::AccountId, AuthorityId)>
{
use staking::BalanceOf;
let to_votes = |b: BalanceOf<T>| {
Expand Down
3 changes: 2 additions & 1 deletion srml/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use sr_primitives::{
use fg_primitives::{ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID};
pub use fg_primitives::{AuthorityId, AuthorityWeight};
use system::{ensure_signed, DigestOf};
use session::SessionIndex;

mod mock;
mod tests;
Expand Down Expand Up @@ -346,7 +347,7 @@ impl<T: Trait> Module<T> {
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = AuthorityId;

fn on_new_session<'a, I: 'a>(changed: bool, validators: I, _queued_validators: I)
fn on_new_session<'a, I: 'a>(_: (SessionIndex, SessionIndex), changed: bool, validators: I, _queued_validators: I)
where I: Iterator<Item=(&'a T::AccountId, AuthorityId)>
{
// instant changes
Expand Down
2 changes: 1 addition & 1 deletion srml/im-online/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl<T: Trait> Module<T> {
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = <T as Trait>::AuthorityId;

fn on_new_session<'a, I: 'a>(_changed: bool, _validators: I, _next_validators: I) {
fn on_new_session<'a, I: 'a>(_: (SessionIndex, SessionIndex), _changed: bool, _validators: I, _next_validators: I) {
Self::new_session();
}

Expand Down
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