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

XCM native fee reduction #1092

Merged
merged 2 commits into from
Nov 30, 2023
Merged

XCM native fee reduction #1092

merged 2 commits into from
Nov 30, 2023

Conversation

Dinonard
Copy link
Member

@Dinonard Dinonard commented Nov 27, 2023

Pull Request Summary

Solution suggestion to reduce XCM fees when paid in native.

Overview
With the introduction of fee alignment, native fees have been slightly increased according to the
proposed Tokenomics 2.0 model (here).

A thing that was missed is the impact of this on XCM fees.
The way XCM fees are calculated, in general, is static. We, as the Substrate/Polkadot ecosystem, don't yet have a good mechanism for the fetching of dynamic prices.

To minimize the impact, this PR suggests to reuse the existing WeightToFee struct which as the name says, converts Weight component into numeric fee (e.g. how much ASTR needs to be paid), but multiplies that fee with the minimum possible allowed value of the adjustment factor (the adjustment factor is used when calculating fees for the native transactions).

Fee Overview

At the moment, all our runtimes have hardcoded XCM instruction ref time weight to 1_000_000_000 (picoseconds).
Base fee per gas is set to 98_974_000 for all runtimes as well.
Using that information we can express price per instruction:

--- Astar Shiden Shibuya
Price Per Base Weight 0.0030855 0.000030855 0.0030855
Price Per Instruction 0.03177 0.0003177 0.03177

Taking into account an average sequence with fixed weights, the price for execution on Astar will be around 0.2 ASTR per sequence.

NOTE: This was calculated outside of runtime scope so real numbers might differ on-chain.

@Dinonard Dinonard changed the title Solution suggestion XCM native fee reduction Nov 27, 2023
@Dinonard Dinonard added the runtime This PR/Issue is related to the topic “runtime”. label Nov 27, 2023
Copy link
Member

@shaunxw shaunxw left a comment

Choose a reason for hiding this comment

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

The direction looks good to me. IMO we need checks on local fork to see how much XCM fees needed for common cross-chain transfers with this solution.

Copy link
Member

@PierreOssun PierreOssun left a comment

Choose a reason for hiding this comment

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

LGTM

@Dinonard Dinonard marked this pull request as ready for review November 29, 2023 17:15
Copy link

Code Coverage

Package Line Rate Branch Rate Health
precompiles/utils/src 55% 0%
chain-extensions/types/xvm/src 0% 0%
pallets/xvm/src 40% 0%
chain-extensions/pallet-assets/src 0% 0%
chain-extensions/types/dapps-staking/src 0% 0%
pallets/dapps-staking/src 81% 0%
precompiles/assets-erc20/src 77% 0%
chain-extensions/dapps-staking/src 0% 0%
primitives/src/xcm 66% 0%
precompiles/xcm/src 75% 0%
pallets/collator-selection/src 69% 0%
chain-extensions/types/unified-accounts/src 0% 0%
pallets/block-rewards-hybrid/src 87% 0%
pallets/dapps-staking/src/pallet 85% 0%
precompiles/dapps-staking/src 93% 0%
pallets/xc-asset-config/src 53% 0%
precompiles/utils/macro/src 0% 0%
pallets/block-reward/src 85% 0%
chain-extensions/xvm/src 0% 0%
chain-extensions/unified-accounts/src 0% 0%
precompiles/utils/src/testing 38% 0%
precompiles/xvm/src 75% 0%
pallets/contracts-migration/src 0% 0%
pallets/ethereum-checked/src 48% 0%
precompiles/substrate-ecdsa/src 78% 0%
precompiles/sr25519/src 79% 0%
chain-extensions/types/assets/src 0% 0%
pallets/unified-accounts/src 83% 0%
pallets/dynamic-evm-base-fee/src 81% 0%
primitives/src 65% 0%
Summary 57% (2275 / 4014) 0% (0 / 0)

Minimum allowed line rate is 50%

Copy link
Member

@PierreOssun PierreOssun left a comment

Choose a reason for hiding this comment

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

LGTM

@Dinonard Dinonard merged commit 5a51359 into master Nov 30, 2023
10 checks passed
@Dinonard Dinonard deleted the feat/xcm-fee-reduction branch November 30, 2023 18:01
@PierreOssun PierreOssun mentioned this pull request Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
runtime This PR/Issue is related to the topic “runtime”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants