Skip to content

FeeTracker deduplications #8477

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

serban300
Copy link
Contributor

Closes #8462

@serban300 serban300 self-assigned this May 9, 2025
@paritytech-review-bot paritytech-review-bot bot requested a review from a team May 9, 2025 12:27
@serban300 serban300 added T6-XCM This PR/Issue is related to XCM. T15-bridges This PR/Issue is related to bridges. labels May 9, 2025
// if we can't decrease the delivery fee factor anymore, we don't change anything
if bridge.delivery_fee_factor == MINIMAL_DELIVERY_FEE_FACTOR {
if !Self::do_decrease_fee_factor(&mut bridge.delivery_fee_factor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, actually, I didn't want to touch pallet-xcm-bridge-hub-router, because we will deprecate and remove it as soon as we get merged pallet-xcm-bridge-router here #6231

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I modified pallet-xcm-bridge-hub-router as well because this PR is small and I would like to merge it before #6231 . After that, these changes will need to be merged in #6231 . I can do that if you want. It might be a bit of throwaway work, but it's almost insignificant.

Copy link
Contributor

Choose a reason for hiding this comment

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

I modified pallet-xcm-bridge-hub-router as well because this PR is small and I would like to merge it before #6231 . After that, these changes will need to be merged in #6231 . I can do that if you want. It might be a bit of throwaway work, but it's almost insignificant.

Yes, but we will loose possibility to backport wherever we need to, because this is major change, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yes, I think it's major. But being a small change, I think we can merge this one before the 2506 cutoff. Do you plan to backport #6231 also to older releases ?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we want to use it on fellowship runtimes depending on 2503 so we will "backport" to 2503

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I see. But even so, the changes to the FeeTracker are major. So we won't be able to use this in #6231 . We will need to create a separate PR (which will not be backported) on top of #6231 which will use the new FeeTracker in pallet-xcm-bridge-router. But we can still leave the changes to pallet-xcm-bridge-router in the current PR right ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see. But even so, the changes to the FeeTracker are major. So we won't be able to use this in #6231 . We will need to create a separate PR (which will not be backported) on top of #6231 which will use the new FeeTracker in pallet-xcm-bridge-router. But we can still leave the changes to pallet-xcm-bridge-router in the current PR right ?

But we can still leave the changes to pallet-xcm-bridge-router in the current PR right ?

Did you mean pallet-xcm-bridge-hub-router (the old one)? :)
If so, then yes, I think we can even go ahead and merge this PR, since it should be orthogonal to #6231. Once we merge/backport #6231 where needed, then we can also merge the FeeTracker for pallet-xcm-bridge-router (the new one) from #6231.

Comment on lines +436 to +453
impl<T: Config<I>, I: 'static> FeeTracker for Pallet<T, I> {
type Id = ();

fn get_min_fee_factor() -> FixedU128 {
MINIMAL_DELIVERY_FEE_FACTOR
}

fn get_fee_factor(_id: Self::Id) -> FixedU128 {
Self::bridge().delivery_fee_factor
}

fn set_fee_factor(_id: Self::Id, val: FixedU128) {
let mut bridge = Self::bridge();
bridge.delivery_fee_factor = val;
Bridge::<T, I>::put(bridge);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 nice, I like this new setup - id/min/get/set :)

@paritytech-review-bot paritytech-review-bot bot requested a review from a team May 9, 2025 13:12
@serban300
Copy link
Contributor Author

/cmd prdoc --audience runtime_dev --bump patch

@@ -997,9 +997,9 @@ fn verify_fee_factor_increase_and_decrease() {
// We take 5 100 byte pages
XcmpQueue::take_outbound_messages(1);
}
assert!(DeliveryFeeFactor::<Test>::get(sibling_para_id) < FixedU128::from_float(1.72));
assert!(DeliveryFeeFactor::<Test>::get(sibling_para_id) < FixedU128::from_float(1.80));
Copy link
Contributor

Choose a reason for hiding this comment

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

@serban300 why is this changed? Did you change anything else besides refactoring FeeTracker?

Copy link
Contributor

@bkontur bkontur left a comment

Choose a reason for hiding this comment

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

lgtm modulo question for xcmp-queue test here

Comment on lines +288 to 290
fn get_min_fee_factor() -> FixedU128 {
unimplemented!()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be defensive and use something that will crash only on debug like debug_assert? Just in case this reaches prod and we get a panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T6-XCM This PR/Issue is related to XCM. T15-bridges This PR/Issue is related to bridges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor pallet-xcm-bridge-router to use FeeTracker/PriceForDelivery mechanism
4 participants