Browse Source

runtime: Remove migration and indices module.

Shamil Gadelshin 4 years ago
parent
commit
fb9845beb7

+ 0 - 18
Cargo.lock

@@ -2039,7 +2039,6 @@ dependencies = [
  "pallet-grandpa",
  "pallet-hiring",
  "pallet-im-online",
- "pallet-indices",
  "pallet-membership",
  "pallet-memo",
  "pallet-offences",
@@ -3465,23 +3464,6 @@ dependencies = [
  "sp-std",
 ]
 
-[[package]]
-name = "pallet-indices"
-version = "2.0.0-rc4"
-source = "git+https://github.com/paritytech/substrate.git?rev=00768a1f21a579c478fe5d4f51e1fa71f7db9fd4#00768a1f21a579c478fe5d4f51e1fa71f7db9fd4"
-dependencies = [
- "frame-benchmarking",
- "frame-support",
- "frame-system",
- "parity-scale-codec",
- "serde",
- "sp-core",
- "sp-io",
- "sp-keyring",
- "sp-runtime",
- "sp-std",
-]
-
 [[package]]
 name = "pallet-membership"
 version = "3.0.0"

+ 3 - 6
node/src/chain_spec.rs

@@ -33,10 +33,9 @@ use node_runtime::{
     versioned_store::InputValidationLengthConstraint as VsInputValidation,
     AuthorityDiscoveryConfig, BabeConfig, Balance, BalancesConfig, ContentWorkingGroupConfig,
     ContractsConfig, CouncilConfig, CouncilElectionConfig, DataObjectStorageRegistryConfig,
-    DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, IndicesConfig,
-    MembersConfig, MigrationConfig, ProposalsCodexConfig, SessionConfig, SessionKeys, Signature,
-    StakerStatus, StakingConfig, StorageWorkingGroupConfig, SudoConfig, SystemConfig,
-    VersionedStoreConfig, DAYS, WASM_BINARY,
+    DataObjectTypeRegistryConfig, ElectionParameters, GrandpaConfig, ImOnlineConfig, MembersConfig,
+    ProposalsCodexConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig,
+    StorageWorkingGroupConfig, SudoConfig, SystemConfig, VersionedStoreConfig, DAYS, WASM_BINARY,
 };
 
 type AccountPublic = <Signature as Verify>::Signer;
@@ -244,7 +243,6 @@ pub fn testnet_genesis(
         pallet_grandpa: Some(GrandpaConfig {
             authorities: vec![],
         }),
-        pallet_indices: Some(IndicesConfig { indices: vec![] }),
         pallet_session: Some(SessionConfig {
             keys: initial_authorities
                 .iter()
@@ -334,7 +332,6 @@ pub fn testnet_genesis(
             channel_banner_constraint: InputValidationLengthConstraint::new(5, 1024),
             channel_title_constraint: InputValidationLengthConstraint::new(5, 1024),
         }),
-        migration: Some(MigrationConfig {}),
         proposals_codex: Some(ProposalsCodexConfig {
             set_validator_count_proposal_voting_period: cpcp
                 .set_validator_count_proposal_voting_period,

+ 4 - 4
node/src/service.rs

@@ -423,8 +423,8 @@ mod tests {
     use codec::{Decode, Encode};
     use node_runtime::RuntimeApi;
     use node_runtime::{currency::CENTS, SLOT_DURATION};
-    use node_runtime::{opaque::Block, DigestItem, Signature};
-    use node_runtime::{Address, BalancesCall, Call, UncheckedExtrinsic};
+    use node_runtime::{opaque::Block, AccountId, DigestItem, Signature};
+    use node_runtime::{BalancesCall, Call, UncheckedExtrinsic};
     use sc_consensus_babe::{BabeIntermediate, CompatibleDigestItem, INTERMEDIATE_KEY};
     use sc_consensus_epochs::descendent_query;
     use sc_finality_grandpa::{self as grandpa};
@@ -590,8 +590,8 @@ mod tests {
             },
             |service, _| {
                 let amount = 5 * CENTS;
-                let to: Address = AccountPublic::from(bob.public()).into_account().into();
-                let from: Address = AccountPublic::from(charlie.public()).into_account().into();
+                let to: AccountId = AccountPublic::from(bob.public()).into_account().into();
+                let from: AccountId = AccountPublic::from(charlie.public()).into_account().into();
                 let genesis_hash = service.client().block_hash(0).unwrap().unwrap();
                 let best_block_id = BlockId::number(service.client().chain_info().best_number);
                 let (spec_version, transaction_version) = {

+ 0 - 23
runtime-modules/proposals/codex/src/tests/mock.rs

@@ -230,29 +230,6 @@ where
 
 pub type Extrinsic = TestXt<Call, ()>;
 
-/*
-    type Currency = Balances;
-    type UnixTime = Timestamp;
-    type CurrencyToVote = CurrencyToVoteHandler;
-    type RewardRemainder = RewardRemainderMock;
-    type Event = MetaEvent;
-    type Slash = ();
-    type Reward = ();
-    type SessionsPerEra = SessionsPerEra;
-    type SlashDeferDuration = SlashDeferDuration;
-    type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
-    type BondingDuration = BondingDuration;
-    type SessionInterface = Self;
-    type RewardCurve = RewardCurve;
-    type NextNewSession = Session;
-    type ElectionLookahead = ElectionLookahead;
-    type Call = Call;
-    type MaxIterations = MaxIterations;
-    type MinSolutionScoreBump = MinSolutionScoreBump;
-    type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
-    type UnsignedPriority = UnsignedPriority;
-*/
-
 impl staking::SessionInterface<u64> for Test {
     fn disable_validator(_: &u64) -> Result<bool, ()> {
         unimplemented!()

+ 2 - 1
runtime-modules/working-group/src/lib.rs

@@ -1475,7 +1475,8 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
         Ok(())
     }
 
-    fn initialize_working_group(
+    // Initialize working group constraints and mint.
+    pub(crate) fn initialize_working_group(
         opening_human_readable_text_constraint: InputValidationLengthConstraint,
         worker_application_human_readable_text_constraint: InputValidationLengthConstraint,
         worker_exit_rationale_text_constraint: InputValidationLengthConstraint,

+ 0 - 3
runtime/Cargo.toml

@@ -37,7 +37,6 @@ system = { package = 'frame-system', default-features = false, git = 'https://gi
 pallet-grandpa = { package = 'pallet-grandpa', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 pallet-babe = { package = 'pallet-babe', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
-pallet-indices = { package = 'pallet-indices', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 pallet-transaction-payment = { package = 'pallet-transaction-payment', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 pallet-transaction-payment-rpc-runtime-api = { package = 'pallet-transaction-payment-rpc-runtime-api', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
 pallet-authorship = { package = 'pallet-authorship', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
@@ -133,7 +132,6 @@ std = [
     'pallet-staking/std',
 #    'pallet-staking-reward-curve/std', // don't have 'std' features
     'pallet-sudo/std',
-    'pallet-indices/std',
     'pallet-im-online/std',
     'pallet-collective/std',
     'pallet-offences/std',
@@ -168,7 +166,6 @@ runtime-benchmarks = [
 	"pallet-balances/runtime-benchmarks",
 	"pallet-collective/runtime-benchmarks",
 	"pallet-im-online/runtime-benchmarks",
-	"pallet-indices/runtime-benchmarks",
 	"pallet-staking/runtime-benchmarks",
 	"pallet-timestamp/runtime-benchmarks",
     "frame-benchmarking",

+ 2 - 4
runtime/src/integration/transactions.rs

@@ -3,11 +3,10 @@ use frame_support::debug;
 use frame_support::weights::{WeightToFeeCoefficients, WeightToFeePolynomial};
 use sp_runtime::generic;
 use sp_runtime::generic::SignedPayload;
-use sp_runtime::traits::StaticLookup;
 use sp_runtime::SaturatedConversion;
 
 use crate::{AccountId, Balance, BlockHashCount, Index, SignedExtra, UncheckedExtrinsic};
-use crate::{Call, Indices, Runtime, System};
+use crate::{Call, Runtime, System};
 
 /// Stub for zero transaction weights.
 pub struct NoWeights;
@@ -65,7 +64,6 @@ pub(crate) fn create_transaction<
         })
         .ok()?;
     let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
-    let address = Indices::unlookup(account);
     let (call, extra, _) = raw_payload.deconstruct();
-    Some((call, (address, signature, extra)))
+    Some((call, (account, signature, extra)))
 }

+ 3 - 26
runtime/src/lib.rs

@@ -15,7 +15,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
 
 mod constants;
 mod integration;
-mod migration;
 mod primitives;
 mod runtime_api;
 #[cfg(test)]
@@ -30,14 +29,11 @@ use frame_support::{construct_runtime, parameter_types};
 use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
 use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
 use pallet_session::historical as pallet_session_historical;
-use pallet_transaction_payment::Multiplier;
 use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
 use sp_core::crypto::KeyTypeId;
 use sp_runtime::curve::PiecewiseLinear;
-use sp_runtime::traits::{BlakeTwo256, Block as BlockT, OpaqueKeys, Saturating};
-use sp_runtime::{
-    create_runtime_str, generic, impl_opaque_keys, FixedPointNumber, Perbill, Perquintill,
-};
+use sp_runtime::traits::{BlakeTwo256, Block as BlockT, IdentityLookup, OpaqueKeys, Saturating};
+use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, Perbill};
 use sp_std::boxed::Box;
 use sp_std::vec::Vec;
 #[cfg(feature = "std")]
@@ -110,7 +106,7 @@ impl system::Trait for Runtime {
     type Hash = Hash;
     type Hashing = BlakeTwo256;
     type AccountId = AccountId;
-    type Lookup = Indices;
+    type Lookup = IdentityLookup<AccountId>;
     type Header = generic::Header<BlockNumber, BlakeTwo256>;
     type Event = Event;
     type BlockHashCount = BlockHashCount;
@@ -190,17 +186,6 @@ where
     type OverarchingCall = Call;
 }
 
-parameter_types! {
-    pub const IndexDeposit: Balance = 0; // no minimum deposit
-}
-
-impl pallet_indices::Trait for Runtime {
-    type AccountIndex = AccountIndex;
-    type Currency = Balances;
-    type Deposit = IndexDeposit;
-    type Event = Event;
-}
-
 parameter_types! {
     pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
 }
@@ -228,9 +213,6 @@ impl pallet_balances::Trait for Runtime {
 
 parameter_types! {
     pub const TransactionByteFee: Balance = 0; // TODO: adjust fee
-    pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
-    pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(1, 100_000);
-    pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000_000u128);
 }
 
 impl pallet_transaction_payment::Trait for Runtime {
@@ -487,9 +469,6 @@ impl forum::Trait for Runtime {
     type PostId = PostId;
 }
 
-impl migration::Trait for Runtime {
-    type Event = Event;
-}
 // The storage working group instance alias.
 pub type StorageWorkingGroupInstance = working_group::Instance2;
 
@@ -618,7 +597,6 @@ construct_runtime!(
         Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
         Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
         Authorship: pallet_authorship::{Module, Call, Storage, Inherent},
-        Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
         Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
         TransactionPayment: pallet_transaction_payment::{Module, Storage},
         Staking: pallet_staking::{Module, Call, Config<T>, Storage, Event<T>, ValidateUnsigned},
@@ -633,7 +611,6 @@ construct_runtime!(
         Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
         Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},
         // Joystream
-        Migration: migration::{Module, Call, Storage, Event<T>, Config},
         CouncilElection: election::{Module, Call, Storage, Event<T>, Config<T>},
         Council: council::{Module, Call, Storage, Event<T>, Config<T>},
         Memo: memo::{Module, Call, Storage, Event<T>},

+ 0 - 75
runtime/src/migration.rs

@@ -1,75 +0,0 @@
-// Clippy linter warning
-#![allow(clippy::redundant_closure_call)] // disable it because of the substrate lib design
-
-use crate::VERSION;
-use frame_support::weights::Weight;
-use frame_support::{debug, decl_event, decl_module, decl_storage};
-
-impl<T: Trait> Module<T> {
-    /// This method is called from on_initialize() when a runtime upgrade is detected. This
-    /// happens when the runtime spec version is found to be higher than the stored value.
-    /// Important to note this method should be carefully maintained, because it runs on every runtime
-    /// upgrade.
-    fn runtime_upgraded() {
-        debug::print!("Running runtime upgraded handler");
-
-        // Add initialization of modules introduced in new runtime release. Typically this
-        // would be any new storage values that need an initial value which would not
-        // have been initialized with config() or build() chainspec construction mechanism.
-        // Other tasks like resetting values, migrating values etc.
-    }
-}
-
-pub trait Trait:
-    system::Trait
-    + minting::Trait
-    + proposals_codex::Trait
-    + working_group::Trait<working_group::Instance2>
-    + storage::data_directory::Trait
-    + storage::data_object_storage_registry::Trait
-{
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
-}
-
-decl_storage! {
-    trait Store for Module<T: Trait> as Migration {
-        /// Records at what runtime spec version the store was initialized. At genesis this will be
-        /// initialized to Some(VERSION.spec_version). It is an Option because the first time the module
-        /// was introduced was as a runtime upgrade and type was never changed.
-        /// When the runtime is upgraded the spec version be updated.
-        pub SpecVersion get(fn spec_version) build(|_config: &GenesisConfig| {
-            Some(VERSION.spec_version)
-        }) : Option<u32>;
-    }
-}
-
-decl_event! {
-    pub enum Event<T> where <T as system::Trait>::BlockNumber {
-        Migrated(BlockNumber, u32),
-    }
-}
-
-decl_module! {
-    pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn deposit_event() = default;
-
-        fn on_initialize(_now: T::BlockNumber) -> Weight {
-            if Self::spec_version().map_or(true, |spec_version| VERSION.spec_version > spec_version) {
-                // Mark store version with current version of the runtime
-                SpecVersion::put(VERSION.spec_version);
-
-                // Run migrations and store initializers
-                Self::runtime_upgraded();
-
-                Self::deposit_event(RawEvent::Migrated(
-                    <system::Module<T>>::block_number(),
-                    VERSION.spec_version,
-                ));
-            }
-
-            10_000_000 // TODO adjust weight
-        }
-    }
-}
-
-impl<T: Trait> Module<T> {}

+ 4 - 6
runtime/src/runtime_api.rs

@@ -7,7 +7,7 @@ use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
 use sp_api::impl_runtime_apis;
 use sp_core::crypto::KeyTypeId;
 use sp_core::OpaqueMetadata;
-use sp_runtime::traits::{BlakeTwo256, Block as BlockT, NumberFor, StaticLookup};
+use sp_runtime::traits::{BlakeTwo256, Block as BlockT, NumberFor};
 use sp_runtime::{generic, ApplyExtrinsicResult};
 use sp_std::vec::Vec;
 
@@ -17,12 +17,10 @@ use crate::{
     GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION,
 };
 use crate::{
-    AllModules, AuthorityDiscovery, Babe, Call, Contracts, Grandpa, Historical, Indices,
-    InherentDataExt, RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment,
+    AllModules, AuthorityDiscovery, Babe, Call, Contracts, Grandpa, Historical, InherentDataExt,
+    RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment,
 };
 
-/// The address format for describing accounts.
-pub type Address = <Indices as StaticLookup>::Source;
 /// The SignedExtension to the basic transaction logic.
 pub type SignedExtra = (
     system::CheckSpecVersion<Runtime>,
@@ -51,7 +49,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
 pub type BlockId = generic::BlockId<Block>;
 
 /// Unchecked extrinsic type as expected by this runtime.
-pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
+pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, Call, Signature, SignedExtra>;
 
 /// Executive: handles dispatch to the various modules.
 pub type Executive =