Skip to content

Account for extrinsic base weight#730

Closed
notlesh wants to merge 7 commits intomasterfrom
notlesh-enforce-extrinsic-base-weight
Closed

Account for extrinsic base weight#730
notlesh wants to merge 7 commits intomasterfrom
notlesh-enforce-extrinsic-base-weight

Conversation

@notlesh
Copy link
Contributor

@notlesh notlesh commented Aug 24, 2021

What does it do?

This PR uses a custom BlockWeights implementation to enforce a base weight for extrinsics. Although the mechanics of ExtrinsicBaseWeight has changed (it is now a private constant in Substrate), the Substrate docs still have this to say about it:

"...an ExtrinsicBaseWeight that is declared in the runtime and applies to all extrinsics. The base weight covers inclusion overhead like signature verification."

source: https://substrate.dev/docs/en/knowledgebase/runtime/fees

What important points reviewers should know?

The goal is to account for the fact that our signature verification is relatively expensive.

I'm not quite clear yet how this will impact Ethereum transactions (which have their own way of accounting for this); this needs to NOT impact them.

Is there something left for follow-up PRs?

What alternative implementations were considered?

Providing our own weights through benchmarking. When I ran the frame_system benchmarks in our own codebase, the weights weren't consistently higher or lower. In particular, they did not seem to reflect the idea that our signature verification is more expensive (I don't believe this overhead is included when using the benchmarking system).

Are there relevant PRs or issues in other repositories (Substrate, Polkadot, Frontier, Cumulus)?

It looks like Substrate used to allow a runtime to specify its own ExtrinsicBaseWeight up until this PR:

paritytech/substrate#6629

What value does it bring to the blockchain users?

Security

TODO

  • Ensure this doesn't affect Ethereum transactions
  • Derive a good value for the EXTRINSIC_BASE_WEIGHT value
  • Tests
  • Clean up and add to all runtimes

@notlesh notlesh added A0-pleasereview Pull request needs code review. A3-inprogress Pull request is in progress. No review needed at this stage. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes labels Aug 24, 2021
::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
.for_class(DispatchClass::Normal, |weights| {
weights.base_extrinsic = EXTRINSIC_BASE_WEIGHT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is all about setting this value here.

/// These values are dictated by Polkadot for the parachain.
pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()
Copy link
Contributor Author

@notlesh notlesh Aug 24, 2021

Choose a reason for hiding this comment

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

This impl is based on the previously used with_sensible_defaults() fn copied out of Substrate.

@kianenigma
Copy link

seems like I was mentioned here, but I don't see anything? 👀

@notlesh
Copy link
Contributor Author

notlesh commented Aug 29, 2021

seems like I was mentioned here, but I don't see anything?

Sorry, I should have left my original message. I was asking about base_extrinsic and how it could be used, but I was able to trace it through pallet_transaction_payment to understand how to use it.

Thanks for taking a look, though!

@notlesh
Copy link
Contributor Author

notlesh commented Jan 24, 2022

Superceded by #1218

@notlesh notlesh closed this Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-pleasereview Pull request needs code review. A3-inprogress Pull request is in progress. No review needed at this stage. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants