Split Indices module from Balances (#1404)

* Indices module

* Remove indices stuff from balances

* Rejob node, move Lookup into system.

* Fix up some modules.

* Fix democracy tests

* Fix staking tests

* Fix more tests

* Final test fixes

* Bump runtime versions

* Assets uses compact dispatchers

* Contracts module uses indexed addressing

* Democracy has more compact encoding

* Example now demonstrates compact eencoding

* Sudo uses indexed address

* Upgrade key also uses indexed lookups

* Assets more compact types.

* Fix test

* Rebuild runtime, whitespace

* Remove TOODs

* Remove TODOs

* Add a couple of tests back to balances.

* Update lib.rs

* Update lib.rs
This commit is contained in:
Gav Wood
2019-01-16 15:57:19 +01:00
committed by GitHub
parent 04175ddc83
commit c9f047fe84
44 changed files with 907 additions and 619 deletions
+28 -18
View File
@@ -37,6 +37,7 @@ extern crate node_runtime;
#[cfg(test)] extern crate srml_treasury as treasury;
#[cfg(test)] extern crate srml_contract as contract;
#[cfg(test)] extern crate srml_grandpa as grandpa;
#[cfg(test)] extern crate srml_indices as indices;
#[cfg(test)] extern crate node_primitives;
#[cfg(test)] extern crate parity_codec as codec;
#[cfg(test)] extern crate sr_io as runtime_io;
@@ -62,12 +63,12 @@ mod tests {
use node_primitives::{Hash, BlockNumber, AccountId};
use runtime_primitives::traits::{Header as HeaderT, Digest as DigestT};
use runtime_primitives::{generic, generic::Era, ApplyOutcome, ApplyError, ApplyResult, Perbill};
use {balances, staking, session, system, consensus, timestamp, treasury, contract};
use {balances, indices, staking, session, system, consensus, timestamp, treasury, contract};
use contract::ContractAddressFor;
use system::{EventRecord, Phase};
use node_runtime::{Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances,
BuildStorage, GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, System,
SystemConfig, GrandpaConfig, Event, Log};
SystemConfig, GrandpaConfig, IndicesConfig, Event, Log};
use wabt;
const BLOATY_CODE: &[u8] = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.wasm");
@@ -94,7 +95,7 @@ mod tests {
let pair = Pair::from(Keyring::from_public(Public::from_raw(signed.clone().into())).unwrap());
let signature = pair.sign(&payload.encode()).into();
UncheckedExtrinsic {
signature: Some((balances::address::Address::Id(signed), signature, payload.0, era)),
signature: Some((indices::address::Address::Id(signed), signature, payload.0, era)),
function: payload.1,
}
}
@@ -130,7 +131,7 @@ mod tests {
twox_128(<balances::ExistentialDeposit<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::CreationFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::TransferFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<indices::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(&<system::BlockHash<Runtime>>::key_for(0)).to_vec() => vec![0u8; 32]
]);
@@ -151,7 +152,7 @@ mod tests {
twox_128(<balances::ExistentialDeposit<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::CreationFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::TransferFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<indices::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(&<system::BlockHash<Runtime>>::key_for(0)).to_vec() => vec![0u8; 32]
]);
@@ -172,7 +173,7 @@ mod tests {
twox_128(<balances::ExistentialDeposit<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::CreationFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::TransferFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<indices::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(&<system::BlockHash<Runtime>>::key_for(0)).to_vec() => vec![0u8; 32]
]);
@@ -197,7 +198,7 @@ mod tests {
twox_128(<balances::ExistentialDeposit<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::CreationFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::TransferFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<indices::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(&<system::BlockHash<Runtime>>::key_for(0)).to_vec() => vec![0u8; 32]
]);
@@ -224,6 +225,9 @@ mod tests {
}) } else { None },
..Default::default()
}),
indices: Some(IndicesConfig {
ids: vec![alice(), charlie()],
}),
balances: Some(BalancesConfig {
balances: vec![
(alice(), 111),
@@ -234,7 +238,6 @@ mod tests {
existential_deposit: 0,
transfer_fee: 0,
creation_fee: 0,
reclaim_rebate: 0,
}),
session: Some(SessionConfig {
session_length: 2,
@@ -312,13 +315,13 @@ mod tests {
1,
GENESIS_HASH.into(),
if support_changes_trie {
hex!("22e7fc466d555b9dce285425081d89751b2063243684979df3840b3ac7e8ecdc").into()
hex!("e2dc1ed62a3878e084c49baef3eed4bc462caaa1ee9db0763eaa8d39d1affc7e").into()
} else {
hex!("7395363e53e682984f817fb1d5a862c5ce8b817375c06270d7a39be7097ad953").into()
hex!("7dad66de05ab6391ece9db092288cb39ba723f7f5d0b69b507b753fc92c98b8e").into()
},
if support_changes_trie {
vec![changes_trie_log(
hex!("cda28e5c630db8eb0e4309b58ce504597c6cbb59bda43fd65e96bb2be73a4586").into(),
hex!("f254b62df0bfef049e010a7a0d6f176d73cc5d9710fa945b4e48f519c8d3a291").into(),
)]
} else {
vec![]
@@ -340,7 +343,7 @@ mod tests {
construct_block(
2,
block1(false).1,
hex!("66b9625c9c824de867815215528fe43014d50af7fb95c8da120910c220a46f6b").into(),
hex!("f085a4077d071d3334f7553bcc3f10d97fd612e25c6df5c8f94151bbe557e24a").into(),
vec![ // session changes here, so we add a grandpa change signal log.
Log::from(::grandpa::RawLog::AuthoritiesChangeSignal(0, vec![
(Keyring::One.to_raw_public().into(), 1),
@@ -369,7 +372,7 @@ mod tests {
construct_block(
1,
GENESIS_HASH.into(),
hex!("66dfdf3a0ef93ec49ec36c0a65fe328d085a865c2382397b2cd6468e391f2f51").into(),
hex!("1d47422645f5fa3d79cff9ab5cd69ee62919c909860f063bdaf18eda834baa05").into(),
vec![],
vec![
CheckedExtrinsic {
@@ -400,7 +403,14 @@ mod tests {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::balances(balances::RawEvent::NewAccount(bob(), 2, balances::NewAccountOutcome::NoHint))
event: Event::indices(indices::RawEvent::NewAccountIndex(bob(), 2))
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::balances(balances::RawEvent::NewAccount(
hex!["d7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9"].into(),
69
))
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
@@ -659,7 +669,7 @@ mod tests {
let b = construct_block(
1,
GENESIS_HASH.into(),
hex!("8197608e90fff1f7d92b35381169242d081779b1718c910689f2589a8ac09b44").into(),
hex!("c442a475a16805d20c326f1134fe5a9656511ed7e1a7f0c7dae2dfc8612e418b").into(),
vec![],
vec![
CheckedExtrinsic {
@@ -675,7 +685,7 @@ mod tests {
CheckedExtrinsic {
signed: Some((charlie(), 1)),
function: Call::Contract(
contract::Call::call::<Runtime>(addr, 10.into(), 10_000.into(), vec![0x00, 0x01, 0x02, 0x03])
contract::Call::call::<Runtime>(indices::address::Address::Id(addr), 10.into(), 10_000.into(), vec![0x00, 0x01, 0x02, 0x03])
),
},
]
@@ -741,7 +751,7 @@ mod tests {
twox_128(<balances::ExistentialDeposit<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::CreationFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::TransferFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<indices::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(&<system::BlockHash<Runtime>>::key_for(0)).to_vec() => vec![0u8; 32]
]);
@@ -763,7 +773,7 @@ mod tests {
twox_128(<balances::ExistentialDeposit<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::CreationFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::TransferFee<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<balances::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(<indices::NextEnumSet<Runtime>>::key()).to_vec() => vec![0u8; 16],
twox_128(&<system::BlockHash<Runtime>>::key_for(0)).to_vec() => vec![0u8; 32]
]);