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

Document the existence of inherinted weights in #[pallet::call] #4766

Open
kianenigma opened this issue Jun 12, 2024 · 4 comments
Open

Document the existence of inherinted weights in #[pallet::call] #4766

kianenigma opened this issue Jun 12, 2024 · 4 comments
Assignees
Labels
C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. T1-FRAME This PR/Issue is related to core FRAME, the framework. T11-documentation This PR/Issue is related to documentation.

Comments

@kianenigma
Copy link
Contributor

kianenigma commented Jun 12, 2024

This code path is not well known and not well documented. It should be explained with a simple example or similar in the documentation of pallet::call and pallet::weight.

cc @shawntabrizi @gupnik

@kianenigma kianenigma added T1-FRAME This PR/Issue is related to core FRAME, the framework. T11-documentation This PR/Issue is related to documentation. labels Jun 12, 2024
@kianenigma kianenigma added the C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. label Oct 2, 2024
@Cjumelin
Copy link

Cjumelin commented Dec 1, 2024

Hi 👋

I have came with a short description of the behavior of Inherit. Yet I am not sure where to put it

CallWeightDef::Inherited

CallWeightDef::Inherited represents a call weight definition that is inherited. This variant is used when the weight of a dispatchable function is not explicitly defined but is instead determined by its parent context, if it exist. It is particularly useful in scenarios where the weight of a dispatchable is dependent on dynamic, higher-level calculations or nested dispatchable calls.

The CallWeightDef::Inherited variant is automatically applied implicitly in the following cases:

  • No Explicit Weight Attribute (does not define a #[pallet::weight($expr)])

  • Developer Mode dev_mode

Code Reference:

In CallDef of substrate/frame/support/procedural/src/pallet/expand/call.rs:

match weight_attrs.len() {
    0 if inherited_call_weight.is_some() => CallWeightDef::Inherited,
}

cc @ndkazu @Krayt78

@kianenigma
Copy link
Contributor Author

Ho Cjumelin, thanks for taking this on!

To finish the task, please do the following:

  1. The objective is to document how this feature is present for developers building on top of FRAME, rather than the internals of the macro
  2. Therefore, what we need to only update the documentation of pallet::call and #pallet::weight
  3. Within these update, only focus on specifying what feature is available to end-users, not how it is implemented.

Please open a PR for this if clear, and we will continue there!

@Cjumelin
Copy link

Cjumelin commented Dec 3, 2024

Can I be assigned to it then?

@shawntabrizi
Copy link
Member

@Cjumelin done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. T1-FRAME This PR/Issue is related to core FRAME, the framework. T11-documentation This PR/Issue is related to documentation.
Projects
None yet
Development

No branches or pull requests

4 participants