-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Renaming and documentation for ApplyResult, ApplyOutcome and et al #4134
Conversation
I left the enumeration though since other elements might be used some day.
(This breaks the block authoring of Kusama) |
Can you shed some light on why is that? |
We can not decode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general looking good.
/// supplies the result of the extrinsic dispatch. | ||
/// | ||
/// Examples of reasons preventing inclusion in a block: | ||
/// - More block weight is required to process the extrinsic than is left in the block being built. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't name weight here and just say block resources. Weight is Palette specific while I suppose these error types are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, that's a good point. I am mistakingly assumed that we are in the pallete context.
/// included in the next block if it has enough spare weight available. | ||
/// - The sender doesn't have enough funds to pay the transaction inclusion fee. Including such | ||
/// a transaction in the block doesn't make sense. | ||
/// - The extrinsic supplied a bad signature. This transaction won't become valid ever. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make it very clear that a dispatch has two phases 1- pre-dispatch stuff and 2- the dispatch itself.
A signature check, and any other code that we might put in Executive::apply_extrinsic_xxx
is in the first group (.check
). For instance a signature check gives you Err(InclusionError)
A weight check, nonce and other things that happen either in signedExtensions or dispatch code itself are in the second group. I think a wrong nonce gives you Ok(DispatchError)
(while an all okay dispatch gives Ok(())
).
So I would make this distinction very clear in the docs.
(take the above with a grain of slat and double check, I didn't look super deep into the code.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this, without any explanation, I find it confusing that signature check and weight check are enumerated next to each other, as it seems that they are natively different types of checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would redirect the reader from this documentation to how apply/dispatch + SignedExtensions
work in general to get more details into the lifecycle of extrinsic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they are different checks in practice, but we are dealing with the non-pallete context, from the block builder API perspective, from that PoV they are essentially the same, isn't it This also relates to referencing the user to the documentation of SignedExtensions
and co.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly better than what we have now, but still a lot of room for improvement imho. But I'm happy to merge asap, cause otherwise we may end up with never ending story of doc improvements through the entire codebase.
client/block-builder/src/lib.rs
Outdated
@@ -43,7 +43,7 @@ use sr_api::{Core, ApiExt, ApiErrorFor}; | |||
pub use runtime_api::BlockBuilder as BlockBuilderApi; | |||
|
|||
/// Error when the runtime failed to apply an extrinsic. | |||
pub struct ApplyExtrinsicFailed(pub sr_primitives::ApplyError); | |||
pub struct ApplyExtrinsicFailed(pub sr_primitives::InclusionError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be renamed as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My logic was that I'd leave this as is to denote that apply_extrinsic
failed because of the following reason which is represented by InclusionError
.
I thought maybe it would be better to name apply_extrinsic
as include_extrinsic
, but that is getting out of hand...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, I am not strong on it. Give me a sign (thumbs up will do) and I will make the change
/// included in the next block if it has enough spare weight available. | ||
/// - The sender doesn't have enough funds to pay the transaction inclusion fee. Including such | ||
/// a transaction in the block doesn't make sense. | ||
/// - The extrinsic supplied a bad signature. This transaction won't become valid ever. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would redirect the reader from this documentation to how apply/dispatch + SignedExtensions
work in general to get more details into the lifecycle of extrinsic.
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
So I guess if we are more or less happy with this refactoring, as the next step I'd like to get some directions on how to cleanly integrate this PR into polkadot/kusama. Apart from updating the accompanying PR with updating the authoring version there, what else should we do here? Can you guide me on this one, @bkchr ? |
a54ced2
to
c53659b
Compare
@pepyakin re: compatibility with kusama, it's more about just ensuring that UI people are given appropriate warning. conflicts need sorting, but otherwise should be good. |
# Conflicts: # bin/node/executor/src/lib.rs # palette/executive/src/lib.rs # palette/system/src/lib.rs # primitives/sr-primitives/src/testing.rs # primitives/sr-primitives/src/traits.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the whitespaces, it looks good.
This PR features:
ApplyError
, preserving the enumeration (not sure about that, should we just useTransactionValidity
directly?),ApplyResult
andApplyOutcome
to (hopefully) less confusing ones.This change doesn't require version bump, although it changes the external API. Therefore here is the accompanying Polkadot PR.