-
Notifications
You must be signed in to change notification settings - Fork 317
Handle dust in order_swap.rs and leasing.rs to sync TI #2754
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
base: devnet-ready
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| use super::*; | ||
| use frame_support::{ | ||
| dispatch::RawOrigin, | ||
| traits::{Defensive, fungible::*, tokens::Preservation}, | ||
| traits::{Defensive, fungible::*}, | ||
| }; | ||
| use frame_system::pallet_prelude::OriginFor; | ||
| use frame_system::pallet_prelude::*; | ||
|
|
@@ -92,12 +92,7 @@ impl<T: Config> Pallet<T> { | |
| frame_system::Pallet::<T>::inc_providers(&lease_coldkey); | ||
| frame_system::Pallet::<T>::inc_providers(&lease_hotkey); | ||
|
|
||
| <T as Config>::Currency::transfer( | ||
| &crowdloan.funds_account, | ||
| &lease_coldkey, | ||
| crowdloan.raised, | ||
| Preservation::Expendable, | ||
| )?; | ||
| Self::transfer_tao(&crowdloan.funds_account, &lease_coldkey, crowdloan.raised)?; | ||
|
|
||
| Self::do_register_network( | ||
| RawOrigin::Signed(lease_coldkey.clone()).into(), | ||
|
|
@@ -151,23 +146,13 @@ impl<T: Config> Pallet<T> { | |
| .saturating_mul(U64F64::from(u64::from(leftover_cap))) | ||
| .floor() | ||
| .saturating_to_num::<u64>(); | ||
| <T as Config>::Currency::transfer( | ||
| &lease_coldkey, | ||
| &contributor, | ||
| contributor_refund.into(), | ||
| Preservation::Expendable, | ||
| )?; | ||
| Self::transfer_tao(&lease_coldkey, &contributor, contributor_refund.into())?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] Update leasing weight for contributor refund issuance accounting This still routes each contributor refund through |
||
| refunded_cap = refunded_cap.saturating_add(contributor_refund); | ||
| } | ||
|
|
||
| // Refund what's left after refunding the contributors to the beneficiary | ||
| let beneficiary_refund = leftover_cap.saturating_sub(refunded_cap.into()); | ||
| <T as Config>::Currency::transfer( | ||
| &lease_coldkey, | ||
| &who, | ||
| beneficiary_refund, | ||
| Preservation::Expendable, | ||
| )?; | ||
| Self::transfer_tao(&lease_coldkey, &who, beneficiary_refund)?; | ||
|
|
||
| Self::deposit_event(Event::SubnetLeaseCreated { | ||
| beneficiary: who, | ||
|
|
||
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.
[HIGH] Update leasing weight for per-contributor issuance accounting
This refund loop now calls
Self::transfer_tao, which does more storage work than the previous directCurrency::transfer: it checks the source balance, reads Balances total issuance before and after, and can mutate SubtensorTotalIssuancewhen dust is burned. Because this runs once per contributor,register_leased_network(k)gained O(k) additional reads and possible writes, butSubnetLeasingWeightInfo::do_register_leased_networkand the generated benchmark weight were not updated. Re-benchmark/update the weight or manually add the extra DB reads/writes so the extrinsic is not underweighted at highMaxContributors.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.
Bad review. Direct Currency::transfer does not update subtensor pallet TotalIssuance if it burns dust.