Skip to content

Conversation

@girazoki
Copy link
Collaborator

What does it do?

Changes the way to calculate fee based on weight to match what usually chains do, i.e., round up if the decimal part of the floating point number is above half. We were not doing this before, and therefore our integer mult/division resulted always in rounding down.

What important points reviewers should know?

Is there something left for follow-up PRs?

What alternative implementations were considered?

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

What value does it bring to the blockchain users?

@girazoki girazoki changed the title Use perbill floating point mult when calculating weight Use perbill floating point mult when calculating fee May 16, 2022
@girazoki girazoki added A0-pleasereview Pull request needs code review. D3-trivial PR contains trivial changes in a runtime directory that do not require an audit B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes labels May 16, 2022
@girazoki girazoki requested a review from crystalin May 16, 2022 09:51
@crystalin crystalin requested a review from librelois May 16, 2022 12:13
let weight_fee =
fee_per_second.saturating_mul(weight as u128) / (WEIGHT_PER_SECOND as u128);
return weight_fee;
// We use perbill to be more precise over floating point mults
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// We use perbill to be more precise over floating point mults
// We use perbill to be more precise over fixed point mults

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe more generally "decimal" mults

@girazoki girazoki requested a review from notlesh May 19, 2022 09:38
@girazoki girazoki changed the title Use perbill floating point mult when calculating fee Use rounded up computation when calculating fee May 19, 2022
@girazoki girazoki merged commit ab475d2 into master May 20, 2022
@girazoki girazoki deleted the xcm-transactor-change-fee-calculation-to-floating branch May 20, 2022 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants