-
Notifications
You must be signed in to change notification settings - Fork 85
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
migration: Add LP Gateway migration for outbound messages #1946
Conversation
for (nonce, entry) in OutboundMessageQueue::<T>::iter() { | ||
log::warn!("{LOG_PREFIX}: Found outbound message:\nnonce:{nonce}\nentry:{entry:?}"); | ||
weight = weight.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(1)); | ||
} | ||
|
||
for (nonce, entry) in FailedOutboundMessages::<T>::iter() { | ||
log::warn!( | ||
"{LOG_PREFIX}: Found failed outbound message:\nnonce:{nonce}\nentry:{entry:?}" | ||
); | ||
weight = weight.saturating_add(<T as frame_system::Config>::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.
I'm pretty sure if they're empty, we do not need to remove them.
cc @wischli
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.
Yea, this is more like an extra check to ensure that they're empty. Not doing any specific removals here apart from the nonce storage.
Testing this locally using:
However, it errors out:
|
That's normal. you have a |
c635584
to
33f81d6
Compare
|
||
#[cfg(feature = "try-runtime")] | ||
fn post_upgrade(_: Vec<u8>) -> Result<(), TryRuntimeError> { | ||
assert_eq!( |
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.
@lemunozm this is the assert that fails when running try-runtime
.
Not sure where that panic comes from tho, that's a different story.
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.
What's the error it tells you? "OutboundMessageNonceStore should be 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.
Yes, with the latest version that's what I get in the post
check. But, I guess that makes sense since the on_runtime_upgrade
doesn't really get triggered or am I missing something?
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.
Looking into this now
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.
Mmm.. I think the assert should pass IIUC this 🤔
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.
The previous message was failing correctly because "there is" entry if you read. But if you check the value it should be the default one, 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.
Wrong prefix constructor for clearing. Apart from that I would like to add a storage value to the pallet and bump it by one because this is a breaking storage change.
Luckily, you don't need to extend the code much because you can wrap your migration into a VersionedMigration
exposed from the Polkadot SDK: https://paritytech.github.io/polkadot-sdk/master/frame_support/migrations/struct.VersionedMigration.html
Unfortunately, the try-runtime
will still fail because of two unsynchronized pallets:
[2024-08-06T09:58:25Z ERROR runtime::frame-support] ForeignInvestments: On chain storage version StorageVersion(1) doesn't match current storage version StorageVersion(2).
[2024-08-06T09:58:25Z ERROR runtime::frame-support] DmpQueue: On chain storage version StorageVersion(0) doesn't match current storage version StorageVersion(2).
For FI, we just need to bump and the DMP Queue can actually be removed because it is deprecated but we needed to keep it in the migration to Polkadot v1.7.2 because that included a migration to the new pallet MessageQueue
/ pallet_message_queue
.
I am happy to open a PR with all the fixes including wrapping the gateway migration into a versioned one. WDYT @cdamian ?
{ | ||
fn on_runtime_upgrade() -> Weight { | ||
let mut weight = Self::clear_storage( | ||
OutboundMessageNonceStore::<T>::storage_prefix(), |
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.
This only represents the b"OutboundMessageNonceStore"
but is missing the pallet prefix. The solution is to always use the final storage key for clearing.
OutboundMessageNonceStore::<T>::storage_prefix(), | |
OutboundMessageNonceStore::<T>::storage_value_final_key(), |
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.
Oh, I thought the storage_alias
takes care of that.
let mut weight = Self::clear_storage( | ||
OutboundMessageNonceStore::<T>::storage_prefix(), | ||
"OutboundMessageNonceStore", | ||
); |
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.
An alternative, and my preference, would be just utilizing OutboundMessageNonceStore::<T>::kill()
here as it is a simple storage value.
* chore: remove deprecated DMP Queue * chore: remove deprecated custom migrations * fix: gateway migration * fix: rm FI v1 storage entries * ci: fix try-runtime cli by adding install
The |
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.
Approving our mutual work. Great job 😅
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.
Thanks!
Description
Add a migration that removes the LP gateway storages related to outbound messages.
Checklist: