Composite accounts (#4820)

* Basic account composition.

* Add try_mutate_exists

* De-duplicate

* Refactor away the UpdateBalanceOutcome

* Expunge final UpdateBalanceOutcome refs

* Refactor transfer

* Refactor reservable currency stuff.

* Test with the alternative setup.

* Fixes

* Test with both setups.

* Fixes

* Fix

* Fix macros

* Make indices opt-in

* Remove CreationFee, and make indices opt-in.

* Fix construct_runtime

* Fix last few bits

* Fix tests

* Update trait impls

* Don't hardcode the system event

* Make tests build and fix some stuff.

* Pointlessly bump runtime version

* Fix benchmark

* Another fix

* Whitespace

* Make indices module economically safe

* Migrations for indices.

* Fix

* Whilespace

* Trim defunct migrations

* Remove unused storage item

* More contains_key fixes

* Docs.

* Bump runtime

* Remove unneeded code

* Fix test

* Fix test

* Update frame/balances/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Fix ED logic

* Repatriate reserved logic

* Typo

* Fix typo

* Update frame/system/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/system/src/lib.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Last few fixes

* Another fix

* Build fix

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Jaco Greeff <jacogr@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Gavin Wood
2020-02-14 00:47:51 +00:00
committed by GitHub
parent d3fa8c91af
commit 5b7512e2e4
79 changed files with 2459 additions and 2100 deletions
-58
View File
@@ -18,7 +18,6 @@
use super::*;
use mock::*;
use codec::Encode;
use sp_runtime::{assert_eq_error_rate, traits::{OnInitialize, BadOrigin}};
use sp_staking::offence::OffenceDetails;
use frame_support::{
@@ -2671,13 +2670,6 @@ fn remove_multi_deferred() {
})
}
#[test]
fn version_initialized() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(<Staking as Store>::StorageVersion::get(), crate::migration::CURRENT_VERSION);
});
}
#[test]
fn slash_kicks_validators_not_nominators() {
ExtBuilder::default().build().execute_with(|| {
@@ -2717,56 +2709,6 @@ fn slash_kicks_validators_not_nominators() {
});
}
#[test]
fn migration_v2() {
ExtBuilder::default().build().execute_with(|| {
use crate::{EraIndex, slashing::SpanIndex};
#[derive(Encode)]
struct V1SlashingSpans {
span_index: SpanIndex,
last_start: EraIndex,
prior: Vec<EraIndex>,
}
// inject old-style values directly into storage.
let set = |stash, spans: V1SlashingSpans| {
let key = <Staking as Store>::SlashingSpans::hashed_key_for(stash);
sp_io::storage::set(&key, &spans.encode());
};
let spans_11 = V1SlashingSpans {
span_index: 10,
last_start: 1,
prior: vec![0],
};
let spans_21 = V1SlashingSpans {
span_index: 1,
last_start: 5,
prior: vec![],
};
set(11, spans_11);
set(21, spans_21);
<Staking as Store>::StorageVersion::put(1);
// perform migration.
crate::migration::inner::to_v2::<Test>(&mut 1);
assert_eq!(
<Staking as Store>::SlashingSpans::get(&11).unwrap().last_nonzero_slash(),
1,
);
assert_eq!(
<Staking as Store>::SlashingSpans::get(&21).unwrap().last_nonzero_slash(),
5,
);
});
}
#[test]
fn zero_slash_keeps_nominators() {
ExtBuilder::default().build().execute_with(|| {