Skip to content

Carthage/mainnet runtime parameters#4341

Merged
Lezek123 merged 8 commits intoJoystream:carthagefrom
Lezek123:carthage-mainnet-params
Oct 10, 2022
Merged

Carthage/mainnet runtime parameters#4341
Lezek123 merged 8 commits intoJoystream:carthagefrom
Lezek123:carthage-mainnet-params

Conversation

@Lezek123
Copy link
Copy Markdown
Contributor

@Lezek123 Lezek123 commented Oct 5, 2022

Implements runtime parameters according to #4300 (proposal + discussion).

Monthly budget estimation for council: $660,000

Notable changes

  • Reward curve's max_piece_count parameter was set to 40 instead of 100, as the value of 100 was causing one of the tests to fail with Generated reward curve approximation is invalid: has more points than specified.
  • RuntimeUpgradeWasmProposalMaxLength was set to 3 MB instead of 3.5 MB, as mega_bytes macro doesn't support float values

Missing parameter values

Those parameter values were not included in the original proposal:

content

    pub const MaxNumberOfAssetsPerChannel: MaxNumber = 10;
    pub const MaxNumberOfAssetsPerVideo: MaxNumber = 20;
    pub const MaxNumberOfCollaboratorsPerChannel: MaxNumber = 10;

storage

 pub const MaxNumberOfOperatorsPerDistributionBucket: u32 = 20;

forum

Note that the proposal assumes #4275 has been addressed, but it's not the case yet, so I left some of the values untouched, ie.:

    pub const MaxSubcategories: u64 = 40;
    pub const MaxThreadsInCategory: u64 = 20;
    pub const MaxPostsInThread: u64 = 20;

There is also one new value that was introduced recently:

pub const MaxStickiedThreads: u32 = 20;

Current fees (examples)

Disclaimer: I was using the current weights, obviously the fees will be impacted once we re-generate weights using a proper setup.

addForumPost

addForumPost

addVideoComment

addVideoComment

buyMembership

buyMembership

createChannel

createChannel

createForumThread

createForumThread

createVideo

createVideo

deleteChannel

deleteChannel

deleteForumPost

deleteForumPost

deleteForumThread

deleteForumThread

deleteVideo

deleteVideo

┆Issue is synchronized with this Asana task by Unito

@Lezek123 Lezek123 marked this pull request as draft October 5, 2022 15:03
@Lezek123 Lezek123 marked this pull request as ready for review October 5, 2022 15:04
@Lezek123 Lezek123 changed the base branch from carthage to carthage-weights-gen October 5, 2022 15:17
@Lezek123 Lezek123 changed the base branch from carthage-weights-gen to carthage October 5, 2022 15:17
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 5, 2022

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

1 Ignored Deployment
Name Status Preview Updated
pioneer-testnet ⬜️ Ignored (Inspect) Oct 8, 2022 at 6:26PM (UTC)

@Lezek123 Lezek123 requested review from bedeho and mnaamani October 5, 2022 15:26
Copy link
Copy Markdown
Member

@bedeho bedeho left a comment

Choose a reason for hiding this comment

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

Fantastic job!

  • Fees are a tad high, but it looks acceptable, thanks again for making this tool, it really makes a tremendous end-of-the-day sanity check.
  • The automated fees were just fantastic. I'm slightly nervous about them not being const but I think it's worth it, I also secretly don't quite believe this actually breaks anything despite Parity saying so :D.
  • I think it would be great if we could try to isolate a few of these literal values, in particular tests, into named constants, so there is some separate space for comments and just more maintainable.

use sp_std::mem::size_of;

/// Compute total fee for executing a call
pub fn compute_fee(call: Call) -> Balance {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This implementation looks right, but how did you arrive at this? did you extract the core logic of some other routines?

Copy link
Copy Markdown
Contributor Author

@Lezek123 Lezek123 Oct 7, 2022

Choose a reason for hiding this comment

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

So initially I was thinking about using TransactionPayment::compute_fee approach as described in #4300, but it had a few major drawbacks:

  • The main issue was that it was reading a storage value (fee multiplier) which meant the result would change depending on it. This was very risky, because the runtime constants shouldn't change.
  • It didn't work for genesis config values, only for the pallet's Config trait parameters

So I implemented the logic of TransactionPayment::compute_fee in this function while disregarding the fee multiplier (so assuming it's 1). The formula for inclusion fee is quite simple as it's just:

inclusion_fee = base_fee + length_fee + [targeted_fee_adjustment * weight_fee];

Source: https://docs.rs/pallet-transaction-payment/3.0.0/pallet_transaction_payment/

So if we disregard targeted_fee_adjustment (fee multiplier), it's:

inclusion_fee = base_fee + length_fee + weight_fee;

pub const MaxThreadsInCategory: u64 = 20;
pub const MaxPostsInThread: u64 = 20;
pub const MaxModeratorsForCategory: u64 = 20;
pub const MaxSubcategories: u64 = 40; // TODO: adjust
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are there TODOs here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's explained in the PR description. It's because #4275 is not yet implemented, but the #4300 proposal assumes it is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

4275 is now implemented by Ignazio in #4352

@Lezek123
Copy link
Copy Markdown
Contributor Author

Lezek123 commented Oct 7, 2022

Fees are a tad high, but it looks acceptable

The considerable part of the cost of channel/video creation is a result of StorageDepositCleanupProfit being set to 1 cent, which means all bloat bonds (including data object bloat bond) are 1 cent higher than they really need to be.
For example, when creating a video with 3 assets (thumbnail + media + subtitles), the additional 4 cents are a result of StorageDepositCleanupProfit alone (video_bloat_bond + 3 * data_object_bloat_bond).

When it comes to inclusion fees, most of the cost is weight-driven. Notice in case of channels and videos we're using a worst case scenario number of storage/distribution buckets, the actual numbers may be much lower.

I'm slightly nervous about them not being const

I think this is not a problem as long as the function that computes them doesn't depend on anything that may change over time. Currently the only way to make those functions (like compute_fee / compute_single_bloat_bond etc.) return different results would be to modify the runtime code. So they are constant in a sense, they are just not defined as constant functions.

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