-
Notifications
You must be signed in to change notification settings - Fork 746
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
Move some inherent logic outside of construct_runtime
#164
Comments
I would like to volunteer to implement this. Is it still available? (Asking this because of z6-mentor label.) |
I think this is a rather difficult issue. |
I started implementing but then tried to think about the FRAME inherent API as a whole: Currently inherent API in FRAME and Primitives as one issue:
As a result I questioned myself:
Some other questions:
But this issue is more narrow than FRAME inherent API. /// A trait implemented by a substrate runtime to provide and check inherents calls.
pub trait RuntimeProvideInherent {
/// The call type of the runtime.
type Call;
/// Create all inherents out of the given `InherentData`.
fn create_inherents(data: &InherentData) -> Vec<Self::Call>;
/// Return whether the call is the call of an inherent.
///
/// NOTE: Signed extrinsics are not inherents, but a signed extrinsic with the given call
/// variant can be dispatched. Only unsigned extrinsics with an inherent call are considered
/// inherent extrinsics by the runtime.
fn is_inherent(call: &Self::Call) -> bool;
/// Check whether the given inherent is valid.
fn check_inherent(call: &Self::Call, data: &InherentData) -> CheckInherentsResult;
// Here I couldn't really think of a function that aggregaed the requirements like this
// ```
// fn inherent_existence_requirements(data: &InherentData) -> RequirementsToBeChecked??;
// ```
// So instead I think we can do a method like this:
/// Check existence requirements of inherents.
fn check_inherent_existence_requirements(
data: &InherentData,
inherents: &[&Self::Call],
) -> CheckInherentsResult;
} Then all method actually used to implement the runtime APIs should be moved to executive. So I started a branch https://github.com/thiolliere/substrate/tree/gui-inherent-refactor EDIT: about mentoring you can ping me on the PR when opened, I am not very active but I can give feedback |
I will start working on it this week. Will open a draft PR as soon as I have something and we can go from there. |
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Request
related #232
Currently the code generated by
construct_runtime
for inherent is quite consequential.https://github.com/paritytech/substrate/blob/51b2f0ed6af8dd4facb18f1a489e192fd0673f7b/frame/support/procedural/src/construct_runtime/expand/inherent.rs#L59-L221
The logic should be defined in another place like executive or support.
Instead
construct_runtime
should implementis_inherent
andcheck_inherent
as an aggregation of pallets implementations (and keep current implementation ofcreate_extrinsic
)other functions
check_extrinsics
(of a block) andensure_inherent_are_first
should be implemented in a normal module, not generated by the macro.Are you willing to help with this request?
Yes! I plan to implement it
The text was updated successfully, but these errors were encountered: