diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 64652d30ed..814cfbbe2a 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -3209,6 +3209,7 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api 2.0.0", "pallet-treasury 2.0.0", "pallet-utility 2.0.0", + "pallet-vesting 2.0.0", "parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/substrate/bin/node/cli/src/chain_spec.rs b/substrate/bin/node/cli/src/chain_spec.rs index 4ce0c8f49b..868b991480 100644 --- a/substrate/bin/node/cli/src/chain_spec.rs +++ b/substrate/bin/node/cli/src/chain_spec.rs @@ -298,7 +298,8 @@ pub fn testnet_genesis( members: endowed_accounts[0..3].to_vec(), pot: 0, max_members: 999, - }) + }), + pallet_vesting: Some(Default::default()), } } diff --git a/substrate/bin/node/runtime/Cargo.toml b/substrate/bin/node/runtime/Cargo.toml index 7bc105b55e..3f8e8b6731 100644 --- a/substrate/bin/node/runtime/Cargo.toml +++ b/substrate/bin/node/runtime/Cargo.toml @@ -65,6 +65,7 @@ pallet-treasury = { version = "2.0.0", default-features = false, path = "../../. pallet-utility = { version = "2.0.0", default-features = false, path = "../../../frame/utility" } pallet-transaction-payment = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment" } pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" } +pallet-vesting = { version = "2.0.0", default-features = false, path = "../../../frame/vesting" } [build-dependencies] wasm-builder-runner = { version = "1.0.4", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } @@ -125,4 +126,5 @@ std = [ "sp-version/std", "pallet-society/std", "pallet-recovery/std", + "pallet-vesting/std", ] diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 0e6a337a8b..f2c374cedd 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -35,8 +35,7 @@ use sp_runtime::{ use sp_runtime::curve::PiecewiseLinear; use sp_runtime::transaction_validity::TransactionValidity; use sp_runtime::traits::{ - self, BlakeTwo256, Block as BlockT, StaticLookup, SaturatedConversion, - OpaqueKeys, + self, BlakeTwo256, Block as BlockT, StaticLookup, SaturatedConversion, ConvertInto, OpaqueKeys, }; use sp_version::RuntimeVersion; #[cfg(any(feature = "std", test))] @@ -80,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 211, + spec_version: 212, impl_version: 0, apis: RUNTIME_API_VERSIONS, }; @@ -586,6 +585,12 @@ impl pallet_society::Trait for Runtime { type ChallengePeriod = ChallengePeriod; } +impl pallet_vesting::Trait for Runtime { + type Event = Event; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; +} + construct_runtime!( pub enum Runtime where Block = Block, @@ -619,6 +624,7 @@ construct_runtime!( Identity: pallet_identity::{Module, Call, Storage, Event}, Society: pallet_society::{Module, Call, Storage, Event, Config}, Recovery: pallet_recovery::{Module, Call, Storage, Event}, + Vesting: pallet_vesting::{Module, Call, Storage, Event, Config}, } ); diff --git a/substrate/bin/node/testing/src/genesis.rs b/substrate/bin/node/testing/src/genesis.rs index 5949781275..8c5514defa 100644 --- a/substrate/bin/node/testing/src/genesis.rs +++ b/substrate/bin/node/testing/src/genesis.rs @@ -100,5 +100,6 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig pot: 0, max_members: 999, }), + pallet_vesting: Some(Default::default()), } } diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 3395ef0f1a..4b3e88eb9f 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -386,7 +386,9 @@ decl_storage! { pub Locks get(fn locks): map hasher(blake2_256) T::AccountId => Vec>; /// True if network has been upgraded to this version. - IsUpgraded: bool = true; + /// + /// True for new networks. + IsUpgraded build(|_: &GenesisConfig| true): bool; } add_extra_genesis { config(balances): Vec<(T::AccountId, T::Balance)>; @@ -561,6 +563,7 @@ impl, I: Instance> Module { // Upgrade from the pre-#4649 balances/vesting into the new balances. pub fn do_upgrade() { + sp_runtime::print("Upgrading account balances..."); // First, migrate from old FreeBalance to new Account. // We also move all locks across since only accounts with FreeBalance values have locks. // FreeBalance: map T::AccountId => T::Balance