Don't attempt to upgrade balances module on chain start (#4802)

* Introduce vesting to node, debug message for upgrades and fix them

* Bump spec version
This commit is contained in:
Gavin Wood
2020-02-01 18:08:39 +00:00
committed by GitHub
parent 98255bd37e
commit 1c9418d748
6 changed files with 19 additions and 5 deletions
+1
View File
@@ -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)",
+2 -1
View File
@@ -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()),
}
}
+2
View File
@@ -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",
]
+9 -3
View File
@@ -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<T>},
Society: pallet_society::{Module, Call, Storage, Event<T>, Config<T>},
Recovery: pallet_recovery::{Module, Call, Storage, Event<T>},
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>},
}
);
@@ -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()),
}
}
+4 -1
View File
@@ -386,7 +386,9 @@ decl_storage! {
pub Locks get(fn locks): map hasher(blake2_256) T::AccountId => Vec<BalanceLock<T::Balance>>;
/// True if network has been upgraded to this version.
IsUpgraded: bool = true;
///
/// True for new networks.
IsUpgraded build(|_: &GenesisConfig<T, I>| true): bool;
}
add_extra_genesis {
config(balances): Vec<(T::AccountId, T::Balance)>;
@@ -561,6 +563,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
// 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