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

Conviction pallet uses fungible trait #1821

Closed
wants to merge 35 commits into from

Conversation

PieWol
Copy link
Contributor

@PieWol PieWol commented Oct 8, 2023

Trying to help out with Issue #226

  • Using MutateFreeze and InspectFreeze as fungible traits for the Currency type in the lib.rs
  • should there be renaming from locks to freezes?

@PieWol PieWol marked this pull request as ready for review October 9, 2023 19:57
@PieWol PieWol requested review from a team October 9, 2023 19:57
Copy link
Contributor

@liamaharon liamaharon left a comment

Choose a reason for hiding this comment

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

Looking good, thanks!

Some notes

  • Need to use freezes instead of holds here. Freezes replace locks, while holds replace reserves
  • I think you could use the new Consideration tickets for reserving funds here, but a benefit of using freezes directly is the minimal code changes that need to take place, so easier review, and the priority is primarily migrating away from Currency so I'm fine with this approach of not using Consideration if you prefer that
  • Needs a migration to migrate existing locks to freezes

Comment on lines 137 to 138
/// The overarching hold reason.
type RuntimeHoldReason: From<HoldReason>;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe put this up the top with RuntimeEvent?

#[pallet::weight(T::WeightInfo::unlock())]
pub fn unlock(
#[pallet::weight(T::WeightInfo::release())]
pub fn release(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's avoid breaking the API for the pallet and just leave this method called 'unlock'.

You can explain the naming in a doc comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

type Currency: ReservableCurrency<Self::AccountId>
+ LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>>
+ fungible::Inspect<Self::AccountId>;
type Currency: MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>
Copy link
Contributor

Choose a reason for hiding this comment

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

and the comment above need to be updated

Suggested change
type Currency: MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>
type Fungible: MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>

Copy link
Contributor

Choose a reason for hiding this comment

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

I would keep Currency here, this has already been kept in other migrations like
https://github.com/paritytech/substrate/pull/14020/files#diff-70e9723e9db62816e35f6f885b6770a8449c75a6c2733e9fa7a245fe52c4656cR210-R213

There was a support from @shawntabrizi and @liamaharon towards renaming in here paritytech/substrate#14020 (comment), but it didn't end happening.

My reasoning behind not renaming is that, at the end of the day, the type is still representing a currency, even though it does not implement a currency trait directly but rather a summary of other traits that put together do represent a currency in this context

Copy link
Contributor

@liamaharon liamaharon Oct 27, 2023

Choose a reason for hiding this comment

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

I would keep Currency here, this has already been kept in other migrations

We shouldn't keep doing bad patterns just because they've been done in the past. I think if people forgot to rename 'Currency' in prior PRs, we should open a new PR to fix them instead of continuing the confusing naming.

the type is still representing a currency

The type also still represents a fungible. Fungible in this context I think is much more clear and less prone to being misinterpreted.

substrate/frame/conviction-voting/src/tests.rs Outdated Show resolved Hide resolved
@PieWol PieWol marked this pull request as draft November 8, 2023 18:54
@PieWol PieWol marked this pull request as ready for review November 22, 2023 16:02
@paritytech-review-bot paritytech-review-bot bot requested review from a team November 22, 2023 16:03
@PieWol
Copy link
Contributor Author

PieWol commented Jan 4, 2024

I've fixed the westend and rococo runtimes so they compile with the pallet now using freezes. Took me quite some time to realize the From impl of the RuntimeFreezeReason for the pallet specific FreezeReason comes from construct_runtime! 😆

I've used no renaming of imports so I hope this conforms with the latest standardization effort as mentioned in the tracking issue #226
Looking forward to some feedback before I start writing a migration :)

@PieWol
Copy link
Contributor Author

PieWol commented Feb 26, 2024

Hey @ggwpez ,
would you mind giving me a hint why the benchmarks are failing? With my latest changes I was able to make the benchmarks work locally with cargo t -p pallet-conviction-voting -F runtime-benchmarks.
Your help is much appreciated :)

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 1/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5347784

serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Mar 26, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Mar 27, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
bkchr pushed a commit that referenced this pull request Apr 10, 2024
@PieWol PieWol closed this Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants