Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Fix grumbles.
  • Loading branch information
gavofyork committed Aug 27, 2018
commit 5d8bc21e668272bfc38c321fdede1ba235863dd2
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions substrate/runtime/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

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?


type ConvertAccountIdToSessionKey: Convert<Self::AccountId, Self::SessionKey>;
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you update error message?

);

Expand Down
2 changes: 2 additions & 0 deletions substrate/runtime/staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ serde_derive = { version = "1.0", optional = true }
safe-mix = { version = "1.0", default_features = false}
substrate-keyring = { path = "../../keyring", optional = true }
substrate-codec = { path = "../../codec", default_features = false }
substrate-codec-derive = { path = "../../codec/derive", default_features = false }
substrate-primitives = { path = "../../primitives", default_features = false }
substrate-runtime-std = { path = "../../runtime-std", default_features = false }
substrate-runtime-io = { path = "../../runtime-io", default_features = false }
Expand All @@ -32,6 +33,7 @@ std = [
"safe-mix/std",
"substrate-keyring",
"substrate-codec/std",
"substrate-codec-derive/std",
"substrate-primitives/std",
"substrate-runtime-std/std",
"substrate-runtime-io/std",
Expand Down
26 changes: 8 additions & 18 deletions substrate/runtime/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Expand Down Expand Up @@ -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
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

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

comment out of date - just mean "reevaluate validator set"

Expand Down