From 51ea201d30eccd54d4d08edf61851c4bad1031bb Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 23 Feb 2020 23:08:23 +0100 Subject: [PATCH 1/4] Remove indices from node-template --- bin/node-template/node/src/chain_spec.rs | 11 ++++------- bin/node-template/runtime/src/lib.rs | 24 +++--------------------- frame/indices/src/lib.rs | 2 +- frame/system/src/lib.rs | 13 +++++++++++++ 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/bin/node-template/node/src/chain_spec.rs b/bin/node-template/node/src/chain_spec.rs index 9bdfea3b7820d..64b84005072fd 100644 --- a/bin/node-template/node/src/chain_spec.rs +++ b/bin/node-template/node/src/chain_spec.rs @@ -1,7 +1,7 @@ use sp_core::{Pair, Public, sr25519}; use node_template_runtime::{ AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, - IndicesConfig, SudoConfig, SystemConfig, WASM_BINARY, Signature + SudoConfig, SystemConfig, WASM_BINARY, Signature }; use sp_consensus_aura::sr25519::{AuthorityId as AuraId}; use grandpa_primitives::{AuthorityId as GrandpaId}; @@ -127,21 +127,18 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>, code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), }), - indices: Some(IndicesConfig { - indices: vec![], - }), balances: Some(BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(), }), - sudo: Some(SudoConfig { - key: root_key, - }), aura: Some(AuraConfig { authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), }), grandpa: Some(GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), }), + sudo: Some(SudoConfig { + key: root_key, + }), } } diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index a1bcd157ad63a..44057a4538f35 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -132,7 +132,7 @@ impl system::Trait for Runtime { /// The aggregated dispatch type that is available for extrinsics. type Call = Call; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = Indices; + type Lookup = System; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. @@ -177,23 +177,6 @@ impl grandpa::Trait for Runtime { type Event = Event; } -parameter_types! { - /// How much an index costs. - pub const IndexDeposit: u128 = 100; -} - -impl indices::Trait for Runtime { - /// The type for recording indexing into the account enumeration. If this ever overflows, there - /// will be problems! - type AccountIndex = AccountIndex; - /// The ubiquitous event type. - type Event = Event; - /// The currency type. - type Currency = Balances; - /// How much an index costs. - type Deposit = IndexDeposit; -} - parameter_types! { pub const MinimumPeriod: u64 = SLOT_DURATION / 2; } @@ -250,21 +233,20 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, Timestamp: timestamp::{Module, Call, Storage, Inherent}, Aura: aura::{Module, Config, Inherent(Timestamp)}, Grandpa: grandpa::{Module, Call, Storage, Config, Event}, - Indices: indices::{Module, Call, Storage, Event, Config}, Balances: balances::{Module, Call, Storage, Config, Event}, TransactionPayment: transaction_payment::{Module, Storage}, Sudo: sudo::{Module, Call, Config, Storage, Event}, // Used for the module template in `./template.rs` TemplateModule: template::{Module, Call, Storage, Event}, - RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, } ); /// The address format for describing accounts. -pub type Address = ::Source; +pub type Address = ::Source; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index d59a50179372d..95ac6cf752838 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -264,7 +264,7 @@ impl StaticLookup for Module { type Source = address::Address; type Target = T::AccountId; - fn lookup(a: Self::Source) -> Result { + fn lookup(a: Self::Source) -> Result { Self::lookup_address(a).ok_or(LookupError) } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index ec35fe3b60321..163138fb30f47 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1408,6 +1408,19 @@ impl Lookup for ChainContext { } } +impl StaticLookup for Module { + type Source = T::AccountId; + type Target = T::AccountId; + + fn lookup(a: Self::Source) -> Result { + Ok(a) + } + + fn unlookup(a: Self::Target) -> Self::Source { + a + } +} + #[cfg(test)] mod tests { use super::*; From faafb421a84abd70362c134e579b9deea53bf4fe Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 23 Feb 2020 23:26:10 +0100 Subject: [PATCH 2/4] Use identity lookup instead --- bin/node-template/runtime/src/lib.rs | 6 +++--- frame/system/src/lib.rs | 13 ------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 44057a4538f35..373103e7002d2 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -15,7 +15,7 @@ use sp_runtime::{ impl_opaque_keys, MultiSignature, }; use sp_runtime::traits::{ - BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount + BlakeTwo256, Block as BlockT, IdentityLookup, Verify, ConvertInto, IdentifyAccount }; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -132,7 +132,7 @@ impl system::Trait for Runtime { /// The aggregated dispatch type that is available for extrinsics. type Call = Call; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = System; + type Lookup = IdentityLookup; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. @@ -246,7 +246,7 @@ construct_runtime!( ); /// The address format for describing accounts. -pub type Address = ::Source; +pub type Address = AccountId; /// Block header type as expected by this runtime. pub type Header = generic::Header; /// Block type as expected by this runtime. diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 163138fb30f47..ec35fe3b60321 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1408,19 +1408,6 @@ impl Lookup for ChainContext { } } -impl StaticLookup for Module { - type Source = T::AccountId; - type Target = T::AccountId; - - fn lookup(a: Self::Source) -> Result { - Ok(a) - } - - fn unlookup(a: Self::Target) -> Self::Source { - a - } -} - #[cfg(test)] mod tests { use super::*; From b6f907a326fa5da7105911aba54d95a8f66c0692 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 24 Feb 2020 00:03:20 +0100 Subject: [PATCH 3/4] Bump impl --- bin/node/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index b6be9335ca94c..be9833893baea 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -82,7 +82,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. spec_version: 224, - impl_version: 2, + impl_version: 3, apis: RUNTIME_API_VERSIONS, }; From aac2779b0a54080dc364c19a2e299243190dc00f Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 24 Feb 2020 11:28:37 +0100 Subject: [PATCH 4/4] clean cargo.toml --- Cargo.lock | 1 - bin/node-template/runtime/Cargo.toml | 2 -- 2 files changed, 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48b14599b1ca9..3fe9079addd8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3629,7 +3629,6 @@ dependencies = [ "pallet-aura", "pallet-balances", "pallet-grandpa", - "pallet-indices", "pallet-randomness-collective-flip", "pallet-sudo", "pallet-template", diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index b5a89febce08a..671123016e449 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -14,7 +14,6 @@ aura = { version = "2.0.0-dev", default-features = false, package = "pallet-aura balances = { version = "2.0.0-dev", default-features = false, package = "pallet-balances", path = "../../../frame/balances" } frame-support = { version = "2.0.0-dev", default-features = false, path = "../../../frame/support" } grandpa = { version = "2.0.0-dev", default-features = false, package = "pallet-grandpa", path = "../../../frame/grandpa" } -indices = { version = "2.0.0-dev", default-features = false, package = "pallet-indices", path = "../../../frame/indices" } randomness-collective-flip = { version = "2.0.0-dev", default-features = false, package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip" } sudo = { version = "2.0.0-dev", default-features = false, package = "pallet-sudo", path = "../../../frame/sudo" } system = { version = "2.0.0-dev", default-features = false, package = "frame-system", path = "../../../frame/system" } @@ -49,7 +48,6 @@ std = [ "frame-executive/std", "frame-support/std", "grandpa/std", - "indices/std", "randomness-collective-flip/std", "serde", "sp-api/std",