-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New slashing logic #570
New slashing logic #570
Changes from 1 commit
b06b022
8d85ecb
f46c603
5d12d61
fd04ad7
15315de
bd579f1
42c5856
dc6de6c
b85cb38
7192001
5a19b7b
bc9f55b
b6069c7
97ed7b9
03631c6
94bebf6
5d8bc21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,7 @@ impl<T> OnSessionChange<T> for () { | |
| } | ||
|
|
||
| pub trait Trait: timestamp::Trait { | ||
| // the position of the required timestamp-set extrinsic. | ||
| // the position of the required note_missed_proposal extrinsic. | ||
| const NOTE_MISSED_PROPOSAL_POSITION: u32; | ||
|
|
||
| type ConvertAccountIdToSessionKey: Convert<Self::AccountId, Self::SessionKey>; | ||
|
|
@@ -152,7 +152,7 @@ impl<T: Trait> Module<T> { | |
| assert!(aux.is_empty()); | ||
| assert!( | ||
| <system::Module<T>>::extrinsic_index() == T::NOTE_MISSED_PROPOSAL_POSITION, | ||
| "note_offline extrinsic must be at position {} in the block", | ||
| "note_missed_proposal extrinsic must be at position {} in the block", | ||
| T::NOTE_MISSED_PROPOSAL_POSITION | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you update error message? |
||
| ); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,9 @@ extern crate substrate_runtime_support as runtime_support; | |
| #[cfg_attr(feature = "std", macro_use)] | ||
| extern crate substrate_runtime_std as rstd; | ||
|
|
||
| #[macro_use] | ||
| extern crate substrate_codec_derive; | ||
|
|
||
| extern crate substrate_codec as codec; | ||
| extern crate substrate_primitives; | ||
| extern crate substrate_runtime_io as runtime_io; | ||
|
|
@@ -102,26 +105,12 @@ impl<AccountId> OnAccountKill<AccountId> for () { | |
|
|
||
| /// Preference of what happens on a slash event. | ||
| #[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] | ||
| #[derive(Eq, PartialEq, Clone, Copy)] | ||
| #[derive(Encode, Decode, Eq, PartialEq, Clone, Copy)] | ||
| pub struct SlashPreference { | ||
| /// Validator should ensure this many more slashes than is necessary before being unstaked. | ||
| pub unstake_threshold: u32, | ||
| } | ||
|
|
||
| impl Decode for SlashPreference { | ||
| fn decode<I: Input>(input: &mut I) -> Option<Self> { | ||
| Some(SlashPreference { | ||
| unstake_threshold: Decode::decode(input)? | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl Encode for SlashPreference { | ||
| fn encode_to<T: Output>(&self, dest: &mut T) { | ||
| self.unstake_threshold.encode_to(dest) | ||
| } | ||
| } | ||
|
|
||
| impl Default for SlashPreference { | ||
| fn default() -> Self { | ||
| SlashPreference { | ||
|
|
@@ -549,8 +538,8 @@ impl<T: Trait> Module<T> { | |
| Ok(()) | ||
| } | ||
|
|
||
| /// Force there to be a new era. This also forces a new session immediately after by | ||
| /// setting `normal_rotation` to be false. Validators will get slashed. | ||
| /// Force there to be a new era. This also forces a new session immediately after. | ||
| /// `apply_rewards` should be true for validators to get the session reward. | ||
| fn force_new_era(apply_rewards: bool) -> Result { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you update the comment? |
||
| <ForcingNewEra<T>>::put(()); | ||
| <session::Module<T>>::force_new_session(apply_rewards) | ||
|
|
@@ -853,7 +842,8 @@ impl<T: Trait> Module<T> { | |
| .map(|v| (Self::slashable_balance(&v), v)) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| // Avoid making new era if it would leave us with fewer than the minimum needed validators | ||
| // Avoid reevaluate validator set if it would leave us with fewer than the minimum | ||
| // needed validators | ||
| if intentions.len() < Self::minimum_validator_count() { | ||
| return | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But isn't it too late for this? We've already changed current era index and applied some pending changes.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment out of date - just mean "reevaluate validator set" |
||
|
|
||
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.
Could you update a comment above?