Skip to content
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

Drop PricingAdmin role #1399

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions libs/types/src/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use sp_std::{
pub enum PoolRole<TrancheId = [u8; 16], Moment = u64> {
PoolAdmin,
Borrower,
PricingAdmin,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not so easy 😖, removing that enum variant will give other internal memory representations for the next variants, so I think we need several migrations in different pallets to get this to work fine.

If this is not viable, maybe marking it as deprecated can be enough, to get a warning if somebody uses it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the insight! I will undo this whole PR and just deprecate that variant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we can also remove it but add #[codec(index = x)] marks on each variant to ensure they remain with the same encoding representation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We store the permissions as bit fields though (see the block of code just after this enum). So I don't think we're ever using the enum variant index in storage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the case and we never store the enum directly, then we are safe 🙌🏻

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not, #[codec(index = x)] is a good idea I think 👍🏻

LiquidityAdmin,
InvestorAdmin,
LoanAdmin,
Expand Down Expand Up @@ -91,7 +90,6 @@ bitflags::bitflags! {
pub struct PoolAdminRoles: u32 {
const POOL_ADMIN = 0b00000001;
const BORROWER = 0b00000010;
const PRICING_ADMIN = 0b00000100;
const LIQUIDITY_ADMIN = 0b00001000;
const INVESTOR_ADMIN = 0b00010000;
const RISK_ADMIN = 0b00100000;
Expand Down Expand Up @@ -218,7 +216,6 @@ where
self.pool_admin.contains(PoolAdminRoles::LIQUIDITY_ADMIN)
}
PoolRole::PoolAdmin => self.pool_admin.contains(PoolAdminRoles::POOL_ADMIN),
PoolRole::PricingAdmin => self.pool_admin.contains(PoolAdminRoles::PRICING_ADMIN),
PoolRole::InvestorAdmin => self.pool_admin.contains(PoolAdminRoles::INVESTOR_ADMIN),
PoolRole::LoanAdmin => self.pool_admin.contains(PoolAdminRoles::RISK_ADMIN),
PoolRole::TrancheInvestor(id, _) => self.tranche_investor.contains(id),
Expand Down Expand Up @@ -257,7 +254,6 @@ where
Ok(self.pool_admin.remove(PoolAdminRoles::LIQUIDITY_ADMIN))
}
PoolRole::PoolAdmin => Ok(self.pool_admin.remove(PoolAdminRoles::POOL_ADMIN)),
PoolRole::PricingAdmin => Ok(self.pool_admin.remove(PoolAdminRoles::PRICING_ADMIN)),
PoolRole::InvestorAdmin => {
Ok(self.pool_admin.remove(PoolAdminRoles::INVESTOR_ADMIN))
}
Expand Down Expand Up @@ -291,7 +287,6 @@ where
Ok(self.pool_admin.insert(PoolAdminRoles::LIQUIDITY_ADMIN))
}
PoolRole::PoolAdmin => Ok(self.pool_admin.insert(PoolAdminRoles::POOL_ADMIN)),
PoolRole::PricingAdmin => Ok(self.pool_admin.insert(PoolAdminRoles::PRICING_ADMIN)),
PoolRole::InvestorAdmin => {
Ok(self.pool_admin.insert(PoolAdminRoles::INVESTOR_ADMIN))
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/utils/loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn issue_default_loan(
/// Should always be used instead of manually issuing a loan as this keeps the
/// `NftManager` in sync.
///
/// * owner should also be `PricingAdmin`
/// * owner should also be `Borrower`
/// * owner should be owner of `CollateralClass`
///
/// Does create the following calls:
Expand Down
7 changes: 0 additions & 7 deletions runtime/integration-tests/src/utils/pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,6 @@ pub fn whitelist_admin(admin: AccountId, pool_id: PoolId) -> Vec<RuntimeCall> {
pool_id,
PoolRole::InvestorAdmin,
));
calls.push(permission_call(
PoolRole::PoolAdmin,
admin.clone(),
pool_id,
PoolRole::PricingAdmin,
));

calls
}
Expand Down Expand Up @@ -476,7 +470,6 @@ mod with_ext {
///
/// **Needs: Mut Externalities to persist**
pub fn permit_admin(id: PoolId) {
permission_for(Keyring::Admin.into(), id, PoolRole::PricingAdmin);
permission_for(Keyring::Admin.into(), id, PoolRole::LiquidityAdmin);
permission_for(Keyring::Admin.into(), id, PoolRole::LoanAdmin);
permission_for(Keyring::Admin.into(), id, PoolRole::InvestorAdmin);
Expand Down