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

Implement bundle limit runtime api to limit bundle weight and size #2568

Merged
merged 10 commits into from
Mar 11, 2024

Conversation

ParthDesai
Copy link
Contributor

@ParthDesai ParthDesai commented Feb 28, 2024

Description

This PR implements formula described in #2413 to limit the probability of exceeding the TargetDomainBlockWeight. Refactoring MaxDomainBlockWeight to TargetDomainBlockWeight will be done in separate PR.

This PR takes different approach than #2563 by introducing runtime api and both consensus runtime as well as the client use the underlying logic. The calculation is also now using checked_* api to prevent overflow or division by zero.

Fixes: #2413

Code contributor checklist:

@ParthDesai ParthDesai force-pushed the add-runtime-api-for-bundle-weight branch from c09b6f3 to 722a195 Compare February 28, 2024 14:58
Copy link
Member

@NingLin-P NingLin-P left a comment

Choose a reason for hiding this comment

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

Make sense! just a few nits.

crates/pallet-domains/src/lib.rs Outdated Show resolved Hide resolved
crates/pallet-domains/src/lib.rs Outdated Show resolved Hide resolved
@NingLin-P NingLin-P requested a review from dariolina March 1, 2024 15:46
@nazar-pc
Copy link
Member

nazar-pc commented Mar 1, 2024

GitHub has issues today, see https://status.github.com/

@NingLin-P
Copy link
Member

This PR is ready to review, PTAL when you get a chance @vedhavyas @dariolina thanks!

@dariolina
Copy link
Member

The test is quite hard to follow but the calculations are correct.

@vedhavyas
Copy link
Member

Will look at this today @NingLin-P

Copy link
Member

@vedhavyas vedhavyas left a comment

Choose a reason for hiding this comment

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

Make sense to me.
Left some questions and nits

// This represents: Ceil[2*Sqrt[bundle_slot_probability/SLOT_PROBABILITY]])
let std_of_expected_bundles_per_block = expected_bundles_per_block
.integer_sqrt()
.checked_mul(2)?
Copy link
Member

@vedhavyas vedhavyas Mar 7, 2024

Choose a reason for hiding this comment

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

@dariolina wouldn't it be ideal to make this constant specific to each domain rather than all domains as is?
Some domain executions might not need to more restrictive secifically substrate based one where we would know to a good level what will the execution time while EVM based domains might not be the case and would need to be mor restrictive to avoid longer execution times

Copy link
Member

Choose a reason for hiding this comment

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

Sorry just saw it now. I think it makes sense to let each domain decide via something like "target block time confidence" with levels like 1-3 or smth. I also think we should first address #2365 refactor though.

Copy link
Member

Choose a reason for hiding this comment

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

@NingLin-P not a blocker for this PR but can you create an issue so that we can track this change please?

crates/subspace-runtime/src/lib.rs Outdated Show resolved Hide resolved
crates/pallet-domains/src/domain_registry.rs Outdated Show resolved Hide resolved
vedhavyas
vedhavyas previously approved these changes Mar 11, 2024
@NingLin-P NingLin-P added this pull request to the merge queue Mar 11, 2024
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.

Limit bundle weight based on target domain block weight
5 participants