-
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
fix: gateway migration et al. #1950
Merged
wischli
merged 5 commits into
feat/lp-v2-gateway-queue-migration
from
lp-v2/migration-fix
Aug 8, 2024
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef0d0e2
chore: remove deprecated DMP Queue
wischli c8a1324
chore: remove deprecated custom migrations
wischli 61aeae7
fix: gateway migration
wischli 41b3830
fix: rm FI v1 storage entries
wischli 9dc9c03
ci: fix try-runtime cli by adding install
wischli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2024 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::{Get, OnRuntimeUpgrade}; | ||
use pallet_order_book::weights::Weight; | ||
use sp_io::{storage::clear_prefix, KillStorageResult}; | ||
use sp_std::vec::Vec; | ||
|
||
pub struct Migration<T>(sp_std::marker::PhantomData<T>); | ||
|
||
const REMOVAL_LIMIT: u32 = 10u32; | ||
const LOG_PREFIX: &str = "LiquidityPoolsGatewayV1"; | ||
|
||
impl<T> OnRuntimeUpgrade for Migration<T> | ||
where | ||
T: frame_system::Config, | ||
{ | ||
fn on_runtime_upgrade() -> Weight { | ||
let mut weight = Weight::zero(); | ||
|
||
match clear_prefix(&get_storage_prefix(), Some(REMOVAL_LIMIT)) { | ||
KillStorageResult::AllRemoved(n) => { | ||
log::info!("{LOG_PREFIX}: Removed {n} ForeignInvestmentInfo V1 keys"); | ||
weight.saturating_accrue(T::DbWeight::get().writes(n.into())); | ||
} | ||
KillStorageResult::SomeRemaining(n) => { | ||
log::warn!("{LOG_PREFIX}: There are {n} remaining ForeignInvestmentInfo V1 keys!"); | ||
weight.saturating_accrue(T::DbWeight::get().writes(REMOVAL_LIMIT.into())); | ||
} | ||
} | ||
|
||
log::info!("{LOG_PREFIX}: Migration done!"); | ||
|
||
weight | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> { | ||
log::info!("{LOG_PREFIX}: Pre checks done!"); | ||
|
||
Ok(Vec::new()) | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
fn post_upgrade(_: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> { | ||
assert!( | ||
!sp_io::storage::exists(&get_storage_prefix()), | ||
"{LOG_PREFIX}: ForeignInvestmentV0 keys remaining!" | ||
); | ||
|
||
log::info!("{LOG_PREFIX}: Post checks done!"); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
/// Returns final storage key prefix of `ForeignInvestmentInfo` in v0 | ||
fn get_storage_prefix() -> Vec<u8> { | ||
hex_literal::hex!("464aed913919bab92f79f3c7b79d28f7efbac15e93f37811895e260605cdc487").to_vec() | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 know this is not the way we should do it and instead I should set up the old storage entry with the deprecated tranche currency type but I hope we can make an exception here because of the limited time until the audit. This prefix does not exist anymore in v2.
On Centrifuge Chain, there are 3 FI entries with a total of 0.000006 USDC. I discussed with Jay that we can discard it. Swapping with Orderbook is not possible because the amounts are too low.
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.
Agree! Thanks for the explanation