Introduce Runtime Events (#607)

* Squashed commit.

New slashing mechanism (#554)  …
* Slashing improvements

- unstake when balance too low
- unstake after N slashes according to val prefs
- don't early-terminate session/era unless unstaked
- offline grace period before punishment
* Fix warning
* Cleanups and ensure slash_count decays
* Bump authoring version and introduce needed authoring stub
* Rename
* Fix offline tracker
* Fix offline tracker
* Renames
* Add test
* Tests
* Tests.
Remove accidental merge files.
Merge remote-tracking branch 'origin/master' into gav-new-pos
Version bump, fixes (#572)  …
* Bump version, don't propose invalid blocks
* Fix build.
* Fixes.
* More fixes.
* Fix tests.
* Fix more tests
* More tests fixed
Fix merge
Fix accidental merge bug
Fixes.
Staking failsafes  …
- Don't slash/unstake/change session when too few staking participants
- Introduce set_balance PrivCall
Make minimum validator count dynamic.
test fixes
Fix tests.
Fix tests
Fix tests, update readme.
Merge remote-tracking branch 'origin/master' into gav-new-pos
Test with release.
Use safe math when dealing with total stake
Fix test again.
Introduce events into runtime.
Fix tests
Add events for account new/reap
Integration-style tests for events.

* Remove old code
This commit is contained in:
Gav Wood
2018-08-28 12:11:40 +01:00
committed by GitHub
parent f5c684dca6
commit 278a054b81
26 changed files with 518 additions and 86 deletions
+17 -2
View File
@@ -34,6 +34,11 @@ extern crate serde_derive;
#[cfg(feature = "std")]
extern crate serde;
extern crate substrate_codec as codec;
#[macro_use]
extern crate substrate_codec_derive;
extern crate substrate_runtime_std as rstd;
extern crate substrate_runtime_consensus as consensus;
extern crate substrate_runtime_council as council;
@@ -90,6 +95,7 @@ impl system::Trait for Concrete {
type Digest = generic::Digest<Vec<u8>>;
type AccountId = AccountId;
type Header = generic::Header<BlockNumber, BlakeTwo256, Vec<u8>>;
type Event = Event;
}
/// System module for this concrete runtime.
@@ -121,18 +127,20 @@ impl Convert<AccountId, SessionKey> for SessionKeyConversion {
}
impl session::Trait for Concrete {
const NOTE_MISSED_PROPOSAL_POSITION: u32 = 1;
type ConvertAccountIdToSessionKey = SessionKeyConversion;
type OnSessionChange = Staking;
type Event = Event;
}
/// Session module for this concrete runtime.
pub type Session = session::Module<Concrete>;
impl staking::Trait for Concrete {
const NOTE_MISSED_PROPOSAL_POSITION: u32 = 1;
type Balance = Balance;
type AccountIndex = AccountIndex;
type OnAccountKill = ();
type OnFreeBalanceZero = ();
type Event = Event;
}
/// Staking module for this concrete runtime.
@@ -152,6 +160,12 @@ pub type Council = council::Module<Concrete>;
/// Council voting module for this concrete runtime.
pub type CouncilVoting = council::voting::Module<Concrete>;
impl_outer_event! {
pub enum Event for Concrete {
session, staking
}
}
impl_outer_dispatch! {
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
@@ -211,6 +225,7 @@ pub mod api {
impl_stubs!(
version => |()| super::Version::version(),
authorities => |()| super::Consensus::authorities(),
events => |()| super::System::events(),
initialise_block => |header| super::Executive::initialise_block(&header),
apply_extrinsic => |extrinsic| super::Executive::apply_extrinsic(extrinsic),
execute_block => |block| super::Executive::execute_block(block),