Introduce exponential length fee for substrate-based fees#1496
Merged
Introduce exponential length fee for substrate-based fees#1496
Conversation
notlesh
commented
May 12, 2022
Comment on lines
+2336
to
+2348
| // left: cost of length fee, right: size in bytes | ||
| // /------------- proportional component: O(N * 1B) | ||
| // | /- exponential component: O(N ** 3) | ||
| // | | | ||
| assert_eq!( 1_000_000_001, calc_fee(1)); | ||
| assert_eq!( 10_000_001_000, calc_fee(10)); | ||
| assert_eq!( 100_001_000_000, calc_fee(100)); | ||
| assert_eq!( 1_001_000_000_000, calc_fee(1_000)); | ||
| assert_eq!( 11_000_000_000_000, calc_fee(10_000)); // inflection point | ||
| assert_eq!( 1_100_000_000_000_000, calc_fee(100_000)); | ||
| assert_eq!( 1_001_000_000_000_000_000, calc_fee(1_000_000)); // one UNIT, ~ 1MB | ||
| assert_eq!( 1_000_010_000_000_000_000_000, calc_fee(10_000_000)); | ||
| assert_eq!(1_000_000_100_000_000_000_000_000, calc_fee(100_000_000)); |
Contributor
Author
There was a problem hiding this comment.
These are the initial results
girazoki
reviewed
May 23, 2022
tests/tests/test-author-mapping.ts
Outdated
| expect( | ||
| ((await context.polkadotApi.query.system.account(BALTATHAR)) as any).data.free.toBigInt() | ||
| ).to.eq(1208925818354628766561176n); | ||
| ).to.eq(1208925819614502764560800n); |
Collaborator
There was a problem hiding this comment.
These should have dissapeared if you bring master
Collaborator
|
I dont fully understand the concern with runtime upgrades. By looking at https://github.com/paritytech/cumulus/blob/f9bc77c3c801973b4b6943cb6f236fb3934eb993/pallets/parachain-system/src/lib.rs#L406 it seems to me as if this extrinsic does not lead to fee payment. Therefore the LengthToFee implementation should not affect, am I right? |
girazoki
approved these changes
May 23, 2022
crystalin
approved these changes
May 23, 2022
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does it do?
Introduces a non-linear
LengthToFeetransaction length fee (only for Substrate-based transactions -- does not impact Ethereum-based ones). This replaces #1353, and like it will need to be reconciled with #1218.This currently has two components to the length fee:
1byte = 1X)1byte = 1X**3)The result is that the proportional fee dominates from [1byte .. 1000bytes] after which the cubic portion grows very rapidly. The goal is to cause fees to become untenable quickly into the 1MB+ range.
See the rust test assertions for a table-ish of results.
I haven't done much research into what range of txn sizes we typically see in the real world. Ideally, these would be nearly unaffected by the exponential byte fee portion. Furthermore, we need to make some assumptions about runtime upgrades, as these are the only (?) legitimate large transactions. It is acceptable that these be expensive, but (1) they can't be "too" expensive and (2) their exception should not prevent a serious determent to much larger txns.
Another note: Ethereum transactions have a maximum size (implied from the max block size divided by their own per-byte fee). The Ethereum per-byte fee is adjusted by gas price while the
LengthToFeefrompallet-transaction-paymentis unadjusted.Related: paritytech/substrate#10785