Skip to content

Blobs Fees Adjustments #149

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

Merged
merged 2 commits into from
Dec 27, 2023
Merged

Blobs Fees Adjustments #149

merged 2 commits into from
Dec 27, 2023

Conversation

gabriele-0201
Copy link
Contributor

@gabriele-0201 gabriele-0201 commented Dec 21, 2023

This PR contains an implementation of the following formula for fees:

inclusion_fee = base_fee + [targeted_length_fee_adjustment * length_fee] + [targeted_weight_fee_adjustment * weight_fee];

This is accomplished by using LengthToFee dynamically along with FeeMultiplierUpdate.

Decoupling length_fee and weight_fee could be the perfect solution to handle both blockchain usage congestion and blocks usage.

In #16, I explain how difficult it is to find a relationship between those two. The main difference is that each submit_blob extrinsic has a weight even with a blob of zero size.

Having two adjustment factors can handle every scenario. Some extreme ones are:

  • Very low general usage, few transactions with small blobs => both targeted_length_fee_adjustment and targeted_weight_fee_adjustment will decrease
  • A few transactions, each with very large blobs => only targeted_length_fee_adjustment will increase while targeted_weight_fee_adjustment won't, because the blob size has a minimal impact on the submit_blob weight
  • (the one that I couldn't handle with Blobs Fee Adjustment #143) A lot of transactions with very small blobs => in this case, decoupling is the key. The block size will remain small, so targeted_length_fee_adjustment won't increase. However, with many transactions, weight has a huge impact, making targeted_weight_fee_adjustment the key to handling chain congestion.

TODOs

  • Refactor, move adjustment fees logic into a separate module
    • possibly PR into substrate to avoid dealing with weird side effects
  • Unit testing
  • Define AdjustmentVariables (at most 30% per hour in total)
  • Integration testing, make sure everything works with lots of transactions and can easily recover from low usage

Copy link
Contributor Author

gabriele-0201 commented Dec 21, 2023

@@ -5,6 +5,9 @@ use sp_runtime::{
MultiSignature,
};

// TODO: probably this could be moved into runtimes/kusama-runtime/src/constants.rs
pub const MAXIMUM_BLOCK_LENGTH: u32 = 5 * 1024 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs docs (btw, this is 5* 1024 * 1024 because it's the maximum allowed PoV size).

Copy link
Contributor Author

@gabriele-0201 gabriele-0201 Dec 22, 2023

Choose a reason for hiding this comment

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

Previously, RuntimeBlockLength was defined like this:

pub const RuntimeBlockLength: BlockLength = BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);

I decided to make the value a constant because I needed it inside the BlobsLengthToFee logic. I will add docs to describe what the constant represents.

I'm not sure why 5 * 1024 * 1024 was used as the maximum block size. I have an idea, but I'm not entirely sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

What size is used in Substrate as the default maximum block size? I am 80% sure it's 4 MiB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both in substrate node template and cumulus node template is used 5 * 1024 * 1024 as BlockLength

Copy link

vercel bot commented Dec 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2023 6:18pm

@rphmeier rphmeier merged commit 2af1ecb into main Dec 27, 2023
@rphmeier rphmeier deleted the gab_blobs_fees branch December 27, 2023 19:32
@gabriele-0201 gabriele-0201 mentioned this pull request Dec 28, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants