-
Notifications
You must be signed in to change notification settings - Fork 81
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
Altair loans sustitution #1266
Altair loans sustitution #1266
Conversation
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.
We definietly need to check needed migrations. For this we need to
a) query the current state of Altair
b) we decide to nuke the old loans storage
@offerijns what is your thinking here?
For option b) we also need a migration logic that nukes the old storage.
This is fine, on Altair. There's only 1 pool with 1 closed loan. |
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.
Some explanations below:
pallets/loans-ref/src/migrations.rs
Outdated
} | ||
|
||
fn on_runtime_upgrade() -> Weight { | ||
if v0::NextLoanId::<T>::iter_values().count() == 1 { |
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.
Ideally, I would have wanted to check here if the on_chain_storage_version()
was 0, and bump the version to 1, but I could not do it because if I initialize the pallet with STORAGE_VERSION = 1
, then it never enters here, because it will be already 1.
I think the issue was not setting the version to 0 in the past.
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 the issue was not setting the version to 0 in the past.
This makes me think that maybe we should add this version for all pallets, in this way, if in the future we have a new migration, we can easily fetch the correct version number 0 for them.
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.
Yes, I have been meaning to open an issue for that. Here it is 🌚
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.
Great! ❤️
@@ -93,8 +94,11 @@ pub mod pallet { | |||
<T as Config>::CurrencyId, | |||
>>::PoolId; | |||
|
|||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); |
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.
We initialize the version to 0, for futures migrations
pallets/loans-ref/src/migrations.rs
Outdated
return T::DbWeight::get().writes(result.unique.into()) | ||
+ T::DbWeight::get().reads(result.loops.into()); |
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.
It is expected 8 read and 8 writes
This PR is ready for review |
3a24836
to
186c627
Compare
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.
LGTM! Me gusta the check via the deprecated Storage entry 🥳
pallets/loans-ref/src/migrations.rs
Outdated
} | ||
|
||
fn on_runtime_upgrade() -> Weight { | ||
if v0::NextLoanId::<T>::iter_values().count() == 1 { |
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.
Yes, I have been meaning to open an issue for that. Here it is 🌚
pallets/loans-ref/src/migrations.rs
Outdated
} else { | ||
log::warn!("Loans: storage was already clear. This migration can be removed."); | ||
|
||
Weight::zero() |
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.
AFAIK we still perform a read
Weight::zero() | |
T::DbWeight::get().reads(1) |
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.
You're right!
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.
Following your hint, I've made a minor change for the sake of purism
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.
Re-approve
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.
Just want to ensure we are getting the right prefix. I might hardcode it, but I think the given approach is fine to.
/// If this storage is not found, the nuking process is aborted. | ||
#[storage_alias] | ||
pub(crate) type NextLoanId<T: Config> = | ||
StorageMap<Pallet<T>, Blake2_128Concat, PoolIdOf<T>, u128, ValueQuery>; |
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.
Do we get the right prefix as pallet-loans-ref
and pallet-laons
are both using the same prefix (i.e. Loans
)?
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.
They use the same prefix, yes!
Fixes #1265 #1281
Tasks:
pallet-loans
bypallet-loans-ref
inaltair
.pallet-loans-ref
that nukes the previouspallet-loans
storage only in case it is the old one.pallet-loans
dependency and others associated with it inpallet-connectors
pallet-loans
is now safe to be removed fromcentrifuge-chain
if this PR is merged (do not need to wait for the migration).