-
Notifications
You must be signed in to change notification settings - Fork 2.7k
slashing aggregator v2 #3137
slashing aggregator v2 #3137
Conversation
All misconduct kinds need to be registered at startup and only these kinds are possible to use in the rolling window. Added a simple test for it too.
|
It looks like @niklasad1 signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
1 similar comment
|
It looks like @niklasad1 signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
28dd5be to
fa2f9c1
Compare
|
I see that you added quite a few more things. Is it ready for another round of reviews? something missing? |
This commit splits the `DoSlash` trait in two traits: `DoReward` and `DoSlash` The reasons for it, is that we want reward based on the `total slashed amount` but the entire amount doesn't necessarily be rewarded. Some part of the total slashed amount might need to transmitted to some other part such as `treasory`. Thus, instead we return the total slash and `ReportSlashing` has to determine what to do with the total slashed amount. In other words, the concrete misconduct type determines what to do.
|
@marcio-diaz it is close, will probably be reviewable tomorrow |
pepyakin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: docs ranting
srml/support/src/traits.rs
Outdated
| /// Trait for representing window length | ||
| pub trait WindowLength<T> { | ||
| /// Fetch window length | ||
| fn window_length(&self) -> &T; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn(&self) -> &T implies that T should live inside of self, but the usage of trait looks like it should be returned by value.
srml/support/src/traits.rs
Outdated
| } | ||
|
|
||
| /// A generic trait for paying out rewards | ||
| pub trait DoReward<Reporters, Reward> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could mention that it is related to slashing. Otherwise it looks like generic rewarding trait. Alternatively, we could rename it to something like "do reward reporters".
22bb264 to
8e3b804
Compare
node/runtime/src/impls.rs
Outdated
| /// 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type shouldn't exist.
|
it's looking better, however there's still a structural issue with that fat |
|
Thanks Gav However, I'm not sure that Thus, Well, I can try to implement it and see it how goes... |
Hey,
This PR is the next attempt to introduce the slashing aggregator "partly"
What does this
It enables the functionality of what to do each severity level instead of specifying strictly based on misbehavior.
It introducing the following:
By introducing the traits ReportSlash and DoSlash for a generic interface to slash misbehavior(s) with support of a
RollingWindowwhich will keep the lastnsessions of misbehaviors. The number of sessions is determined by the misconduct type.Additionally, the
basic Misconducts kindsare pre-defined in the runtime with a window length as input which needs to be initialized by the concrete misconduct such asBabeEquivocation. So, for example,GrandpaEquivocationmay need a different window thanBabeEquivocationand so on.However, it is assumed that the
window_lengthandbase_severityis static for the concrete misconduct. I have two different macros for them but they are basically the same with different function names because I think it will be easier to use and you might not need both,See the example use-case below which is probably easier to understand
What is missing
ReportSlash(currently very boilerplate-isch)Example use-case
See test implementation in
substrate/srml/staking/src/slash.rs