-
Notifications
You must be signed in to change notification settings - Fork 41
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
Migrate neo-swaps pools to bounded storage #1253
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1253 +/- ##
==========================================
+ Coverage 91.82% 91.89% +0.07%
==========================================
Files 190 191 +1
Lines 34682 34793 +111
==========================================
+ Hits 31847 31974 +127
+ Misses 2835 2819 -16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
log::info!( | ||
"MigratePoolReservesToBoundedBTreeMap: Post-upgrade pool count is {}!", | ||
new_pool_count | ||
); |
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.
How many pools were shown on battery station and main-net? Just want to verify without running it myself.
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.
51 and 74
This pull request is now in conflicts. Could you fix it @maltekliemann? 🙏 |
// Copyright 2023-2024 Forecasting Technologies LTD. | ||
// | ||
// This file is part of Zeitgeist. | ||
// | ||
// Zeitgeist 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. | ||
// | ||
// Zeitgeist 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. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Zeitgeist. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use crate::consts::MAX_ASSETS; | ||
use sp_runtime::traits::Get; | ||
|
||
pub(crate) struct MaxAssets; | ||
|
||
impl Get<u32> for MaxAssets { | ||
fn get() -> u32 { | ||
MAX_ASSETS | ||
} | ||
} |
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.
Why is that necessary? Why don't we use a Config
type for that?
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 was worried about a misconfiguration. The thing is that there's a (hard-coded!) minimum spot price required when creating a pool, so there should be a maximum number of assets allowed, because if there are too many assets, it becomes impossible to keep all spot prices above the minimum spot price. I'll add a comment to the code.
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.
Seems a bit overkill to me to create a whole new file for that. I was thinking along the lines of putting the following line next to the constant:
pub type MaxAssets = frame_support::pallet_prelude::ConstU32<MAX_ASSETS>;
…stpm/zeitgeist into mkl-neo-swaps-bounded-b-tree-map
let asset_count_u16: u16 = | ||
spot_prices.len().try_into().map_err(|_| Error::<T>::NarrowingConversion)?; | ||
let asset_count_u32: u32 = asset_count_u16.into(); | ||
ensure!(asset_count_u16 == market.outcomes(), Error::<T>::IncorrectVecLen); | ||
ensure!(asset_count_u32 <= MaxAssets::get(), Error::<T>::AssetCountAboveMax); |
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 can use shadowing here if you like. I mean this:
let asset_count: u16 =
spot_prices.len().try_into().map_err(|_| Error::<T>::NarrowingConversion)?;
ensure!(asset_count == market.outcomes(), Error::<T>::IncorrectVecLen);
let asset_count: u32 = asset_count.into();
ensure!(asset_count <= MaxAssets::get(), Error::<T>::AssetCountAboveMax);
Let me know if this doesn't work.
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.
Ah, you use it below... mhhh... then it's fine I guess.
What does it do?
Migrates neo-swaps pools from
BTreeMap
toBoundedBTreeMap
to avoid potentially faulty manualMaxEncodedLen
implementations. Fixes #1214.What important points should reviewers know?
Is there something left for follow-up PRs?
What alternative implementations were considered?
Are there relevant PRs or issues?
References