srml: system: prune block hash mapping (#3062)

* srml: system: prune block number to hash mapping

* srml: system: add test for block hash mapping pruning

* node: bump runtime version

* srml: system: wrap long line

* srml: system: use parameter type for block hash count

* srml: system: prune block hash mapping before storage root calculation

* srml: system: keep the genesis hash in block number map
This commit is contained in:
André Silva
2019-07-09 16:07:38 +01:00
committed by Gavin Wood
parent 459eb94c38
commit ed630e5eda
21 changed files with 149 additions and 15 deletions
@@ -111,6 +111,10 @@ pub fn native_version() -> NativeVersion {
}
}
parameter_types! {
pub const BlockHashCount: BlockNumber = 250;
}
impl system::Trait for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
@@ -130,6 +134,8 @@ impl system::Trait for Runtime {
type Event = Event;
/// The ubiquitous origin type.
type Origin = Origin;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
type BlockHashCount = BlockHashCount;
}
impl aura::Trait for Runtime {
@@ -71,7 +71,7 @@ mod tests {
use runtime_io::with_externalities;
use primitives::{H256, Blake2Hasher};
use support::{impl_outer_origin, assert_ok};
use support::{impl_outer_origin, assert_ok, parameter_types};
use runtime_primitives::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
impl_outer_origin! {
@@ -83,6 +83,9 @@ mod tests {
// configuration traits of modules we want to use.
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl system::Trait for Test {
type Origin = Origin;
type Index = u64;
@@ -93,6 +96,7 @@ mod tests {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = ();
type BlockHashCount = BlockHashCount;
}
impl Trait for Test {
type Event = ();