-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release centrifuge 1024 client 1035 #1607
Changes from 1 commit
dbd5934
09bf25e
6a5f505
0654dac
4d7e8c5
44e5e7d
71a1fc5
0e52d38
6ef6cc5
f8d871e
08ff938
c4c754e
e8fbe8a
b80639b
e84e22c
cb2e474
2dd0a6b
205024a
5299da0
ab0a221
2451724
0da6e58
9d4922e
84bf880
27baf14
a0ea8cb
597f674
bf0885e
52ee34a
f01b929
372606f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2021 Centrifuge Foundation (centrifuge.io). | ||
// | ||
// This file is part of the Centrifuge chain project. | ||
// Centrifuge is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version (see http://www.gnu.org/licenses). | ||
// Centrifuge is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
use frame_support::{traits::OnRuntimeUpgrade, weights::Weight}; | ||
use sp_runtime::DispatchError; | ||
|
||
/// All balance information for an account. | ||
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, RuntimeDebug, MaxEncodedLen, TypeInfo)] | ||
Check failure on line 17 in runtime/common/src/migrations/balances.rs GitHub Actions / docs
Check failure on line 17 in runtime/common/src/migrations/balances.rs GitHub Actions / docs
Check failure on line 17 in runtime/common/src/migrations/balances.rs GitHub Actions / docs
Check failure on line 17 in runtime/common/src/migrations/balances.rs GitHub Actions / docs
|
||
pub struct OldAccountData<Balance> { | ||
/// Non-reserved part of the balance. There may still be restrictions on | ||
/// this, but it is the total pool what may in principle be transferred, | ||
/// reserved and used for tipping. | ||
/// | ||
/// This is the only balance that matters in terms of most operations on | ||
/// tokens. It alone is used to determine the balance when in the contract | ||
/// execution environment. | ||
pub free: Balance, | ||
/// Balance which is reserved and may not be used at all. | ||
/// | ||
/// This can still get slashed, but gets slashed last of all. | ||
/// | ||
/// This balance is a 'reserve' balance that other subsystems use in order | ||
/// to set aside tokens that are still 'owned' by the account holder, but | ||
/// which are suspendable. This includes named reserve and unnamed reserve. | ||
pub reserved: Balance, | ||
/// The amount that `free` may not drop below when withdrawing for *anything | ||
/// except transaction fee payment*. | ||
pub misc_frozen: Balance, | ||
/// The amount that `free` may not drop below when withdrawing specifically | ||
/// for transaction fee payment. | ||
pub fee_frozen: Balance, | ||
} | ||
|
||
pub struct Migration<T: pallet_balances::Config>(sp_std::marker::PhantomData<T>); | ||
|
||
impl<T> OnRuntimeUpgrade for Migration<T> | ||
where | ||
T: pallet_balances::Config, | ||
{ | ||
#[cfg(feature = "try-runtime")] | ||
fn pre_upgrade() -> Result<Vec<u8>, DispatchError> { | ||
// CHECKING DECODING OLD DATASTRUCTURE WITH NEW LAYOUT WORKS: | ||
// * Fetch storage from chain with NEW data structure | ||
// * Check if fetched accounts matches on-chain storage entries | ||
|
||
// TODO: | ||
// * Research whether orml-pallets datastructure also changed | ||
// * Research whether we need to migrate locks in orml (maybe first check if | ||
// there exist any. ^^ | ||
|
||
let accounts = frame_system::Account::<T>::full_storage_key; | ||
|
||
Ok(Vec::new()) | ||
} | ||
|
||
fn on_runtime_upgrade() -> Weight { | ||
// WE CAN NOT MIGRATE. THIS CODE IS JUST FOR CHECKING IF WE NEED ANYTHING | ||
// BESIDES THE LAZY MIGRATION FROM PARITY | ||
// See: https://kflabs.slack.com/archives/C05TBFRBL15/p1699956615421249 | ||
Weight::from_parts(0, 0) | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
fn post_upgrade(_: Vec<u8>) -> Result<(), DispatchError> { | ||
Ok(()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orml-tokens
has not updated theirAccountData
yet:https://github.com/open-web3-stack/open-runtime-module-library/blob/8f59b50ab45d15572d18cee0425966e43567a954/tokens/src/lib.rs#L142-L160
I would assume, they won't do that to not force consumers into synchronous migrations. In Substrate, the
misc_frozen
field ofAccountData
was replaced withflags
. However, both fields have the same size which removes the requirement of a sync migration: https://github.com/paritytech/substrate/pull/12951/files#r1140113642There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, just thought that it might be a good idea to have similar checks like we do for the normal accounts. No actual migrations taking place, just us having some checks before the upgrade itself. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is a good idea!