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

feat: add freeze & unfreeze extrinsics #1947

Merged
merged 20 commits into from
Aug 9, 2024
Merged

Conversation

wischli
Copy link
Contributor

@wischli wischli commented Aug 6, 2024

Description

  • Adds freeze & unfreeze extrinsics
  • Adds new Poolrole variant FrozenTrancheInvestor
    • Alternative: Extend existing TrancheInvestor permission with downside of having to migrate all existing storage entries
  • Slightly improves docs of pallet-liquidity-pools
  • Simplifies and normalizes pallet-liqudiity-pools defensive weights

Checklist:

  • I have added Rust doc comments to structs, enums, traits and functions
  • I have made corresponding changes to the documentation
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works

@wischli wischli added I5-documentation Documentation needs fixing or improving. I8-enhancement An additional feature. labels Aug 6, 2024
@wischli wischli self-assigned this Aug 6, 2024
@wischli wischli requested review from lemunozm and cdamian August 6, 2024 07:14
})
}

/// NOTE: Collecting redemptions does not check pre-conditions
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TestExternalitiesBuilder::build().execute_with(|| {
assert_noop!(
Investments::collect_investments(RuntimeOrigin::signed(NOT_INVESTOR), INVESTMENT_0_0),
DispatchError::Other("PreCondition mock fails on u64::MAX account on purpose")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - move this error to a const and use it in the mock and tests.

false,
)?;

T::Permission::add(
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason this is not implemented in the same way as update_member: the permission is set separately using the permsisions.add_permission extrinsic, and then in the liquidity pools method it is just checked that the permission is already set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point. I will refactor it to be in sync with the update_member flow!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 46.88797% with 128 lines in your changes missing coverage. Please review.

Project coverage is 48.31%. Comparing base (4bfeabe) to head (09c4b4c).

Files Patch % Lines
runtime/common/src/permissions.rs 0.00% 40 Missing ⚠️
pallets/liquidity-pools/src/lib.rs 53.57% 39 Missing ⚠️
pallets/liquidity-pools/src/defensive_weights.rs 0.00% 27 Missing ⚠️
libs/types/src/permissions.rs 0.00% 15 Missing ⚠️
pallets/liquidity-pools/src/tests.rs 95.58% 3 Missing ⚠️
pallets/investments/src/lib.rs 50.00% 2 Missing ⚠️
pallets/liquidity-pools/src/inbound.rs 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1947      +/-   ##
==========================================
+ Coverage   47.83%   48.31%   +0.48%     
==========================================
  Files         183      184       +1     
  Lines       12904    12999      +95     
==========================================
+ Hits         6172     6281     +109     
+ Misses       6732     6718      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

lemunozm
lemunozm previously approved these changes Aug 6, 2024
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Thanks William for you fully complete and well organized PR. Super easy to review 🙌🏻.

Some minor comments below, not found any major

libs/types/src/permissions.rs Show resolved Hide resolved
pallets/investments/src/mock.rs Outdated Show resolved Hide resolved
pallets/liquidity-pools/src/mock.rs Show resolved Hide resolved
pallets/liquidity-pools/src/tests.rs Show resolved Hide resolved
runtime/altair/src/lib.rs Outdated Show resolved Hide resolved
pallets/liquidity-pools/src/tests/inbound.rs Outdated Show resolved Hide resolved
pallets/liquidity-pools/src/tests/inbound.rs Outdated Show resolved Hide resolved
pallets/liquidity-pools/src/tests/inbound.rs Show resolved Hide resolved
@wischli wischli requested review from cdamian and lemunozm August 8, 2024 14:00
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Everything looks super good!

Just my concern regarding that is_frozen increases the size of the type. So the code will try to deserialize more bytes than the existing ones.

@wischli wischli marked this pull request as draft August 8, 2024 16:05
@wischli wischli marked this pull request as ready for review August 9, 2024 10:17
@wischli wischli added the D8-migration Pull request touches storage and needs migration code. label Aug 9, 2024
@wischli wischli requested a review from lemunozm August 9, 2024 10:18
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Thanks for the migration! It seemed not easy

runtime/altair/src/migrations.rs Outdated Show resolved Hide resolved
runtime/development/src/migrations.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

LSGTM!

@wischli wischli enabled auto-merge (squash) August 9, 2024 13:47
@wischli wischli merged commit 1e318e2 into main Aug 9, 2024
9 checks passed
@lemunozm lemunozm deleted the lp-v2/freeze-extrinsics branch August 9, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D8-migration Pull request touches storage and needs migration code. I5-documentation Documentation needs fixing or improving. I8-enhancement An additional feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants