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

refactor: pay_outstanding_debt extrinsic of pallet-payment-streams #264

Merged
merged 6 commits into from
Nov 25, 2024

Conversation

TDemeco
Copy link
Contributor

@TDemeco TDemeco commented Nov 19, 2024

This PR:

  • Adds a runtime API get_providers_with_payment_streams_with_user, which receives a user and returns the list of Providers that have at least one payment stream with it. This is useful for users that were deemed insolvent and want to recoup as much of their paid deposits as possible calling the pay_outstanding_debt extrinsic of the payment streams pallet.
  • Refactors the pay_outstanding_debt extrinsic to, instead of receiving the number of payment streams to pay, it receives a list of Providers. This way, it checks if that Provider has payment streams with the user and pays it the remaining debt, without having unbounded iterations. Weight is then proportional to the amount of Providers that the user wants to repay.

pub fn pay_outstanding_debt(
origin: OriginFor<T>,
amount_of_streams_to_pay: u32,
providers: Vec<ProviderIdFor<T>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

unbounded 😱😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's bounded by the weight of the extrinsic! Basically the caller of this will pay for its execution proportional to the amount of Providers, so it shouldn't be an issue. I thought about making it a bounded vec and bounding it with a constant of the Config of the pallet, maybe that's better? @ffarall cc'ing you just in case

Copy link
Contributor

Choose a reason for hiding this comment

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

Worst case scenario, the user sends a transaction that can take up A LOT of weight, but we know that in advance and will charge him for it. Whether or not this could result in another issue... unclear to me.

@TDemeco TDemeco merged commit eddc0c3 into main Nov 25, 2024
24 checks passed
@TDemeco TDemeco deleted the fix/refactor-pay-outstanding-debt branch November 25, 2024 23:18
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.

3 participants