This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow pallet error enum variants to contain fields #10242
Merged
paritytech-processbot
merged 83 commits into
master
from
kckyeung/nested-pallet-error-enum
Mar 24, 2022
Merged
Allow pallet error enum variants to contain fields #10242
paritytech-processbot
merged 83 commits into
master
from
kckyeung/nested-pallet-error-enum
Mar 24, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KiChjang
added
A0-please_review
Pull request needs code review.
B3-apinoteworthy
C1-low
PR touches the given topic and has a low impact on builders.
D3-trivial 🧸
PR contains trivial changes in a runtime directory that do not require an audit
labels
Nov 11, 2021
Maybe I'm oversimplifying this, but do we actually need a new trait and implement it on the error enum? |
bkchr
reviewed
Nov 12, 2021
…s to implement them
Okay, the basic implementation for restricting the Error enum to only contain types that have an encoded size of 1 byte is done. What I'm not 100% certain right now is whether the |
gui1117
reviewed
Nov 22, 2021
ordian
pushed a commit
to paritytech/polkadot
that referenced
this pull request
Mar 24, 2022
* Rename to BagError * update lockfile for {"substrate"} Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: parity-processbot <>
ordian
added a commit
to paritytech/polkadot
that referenced
this pull request
Mar 24, 2022
* master: Try to fix out of view statements (#5177) Companion for Substrate#11107 (#5197) paras: `include_pvf_check_statement` rt bench (#4938) [ci] Run short benchmarks only in PR pipelines (#5200) Companion for paritytech/substrate#10242 (#4862) [ci] Add short benchmarks to the pipeline (#5188) upgrade coarsetime to 0.1.22 to fix a potential panic (#5193) Update docs and enable DOT-over-XCM (#4809) enable disputes on all chains (#5182) companion for validator self-vote in bags (#5088) Extract MAX_FINALITY_LAG constant from relay_chain_selection (#5159)
grishasobol
pushed a commit
to gear-tech/substrate
that referenced
this pull request
Mar 28, 2022
* Allow pallet errors to contain at most one field * Update docs on pallet::error * Reword documentation * cargo fmt * Introduce CompactPalletError trait and require #[pallet::error] fields to implement them * cargo fmt * Do not assume tuple variants * Add CompactPalletError derive macro * Check for error type compactness in construct_runtime * cargo fmt * Derive CompactPalletError instead of implementing it directly during macro expansion * Implement CompactPalletError on OptionBool instead of Option<bool> * Check for type idents instead of variant ident * Add doc comments for ErrorCompactnessTest * Add an trait implementation of ErrorCompactnessTest for () * Convert the error field of DispatchError to a 4-element byte array * Add static check for pallet error size * Rename to MAX_PALLET_ERROR_ENCODED_SIZE * Remove ErrorCompactnessTest trait * Remove check_compactness * Return only the most significant byte when constructing a custom InvalidTransaction * Rename CompactPalletError to PalletError * Use counter to generate unique idents for assert macros * Make declarative pallet macros compile with pallet error size checks * Remove unused doc comment * Try and fix build errors * Fix build errors * Add macro_use for some test modules * Test fix * Fix compilation errors * Remove unneeded #[macro_use] * Resolve import ambiguity * Make path to pallet Error enum more specific * Fix test expectation * Disambiguate imports * Fix test expectations * Revert appending pallet module name to path * Rename bags_list::list::Error to BagError * Fixes * Fixes * Fixes * Fix test expectations * Fix test expectation * Add more implementations for PalletError * Lift the 1-field requirement for nested pallet errors * Fix UI test expectation * Remove PalletError impl for OptionBool * Use saturating operations * cargo fmt * Delete obsolete test * Fix test expectation * Try and use assert macro in const context * Pull out the pallet error size check macro * Fix UI test for const assertion * cargo fmt * Apply clippy suggestion * Fix doc comment * Docs for create_tt_return_macro * Ensure TryInto is imported in earlier Rust editions * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix up comments and names * Implement PalletError for Never * cargo fmt * Don't compile example code * Bump API version for block builder * Factor in codec attributes while derving PalletError * Rename module and fix unit test * Add missing attribute * Check API version and convert ApplyExtrinsicResult accordingly * Rename BagError to ListError Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Use codec crate re-exported from frame support * Add links to types mentioned in doc comments Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * cargo fmt * cargo fmt * Re-add attribute for hidden docs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
grishasobol
pushed a commit
to gear-tech/substrate
that referenced
this pull request
Mar 28, 2022
* Allow pallet errors to contain at most one field * Update docs on pallet::error * Reword documentation * cargo fmt * Introduce CompactPalletError trait and require #[pallet::error] fields to implement them * cargo fmt * Do not assume tuple variants * Add CompactPalletError derive macro * Check for error type compactness in construct_runtime * cargo fmt * Derive CompactPalletError instead of implementing it directly during macro expansion * Implement CompactPalletError on OptionBool instead of Option<bool> * Check for type idents instead of variant ident * Add doc comments for ErrorCompactnessTest * Add an trait implementation of ErrorCompactnessTest for () * Convert the error field of DispatchError to a 4-element byte array * Add static check for pallet error size * Rename to MAX_PALLET_ERROR_ENCODED_SIZE * Remove ErrorCompactnessTest trait * Remove check_compactness * Return only the most significant byte when constructing a custom InvalidTransaction * Rename CompactPalletError to PalletError * Use counter to generate unique idents for assert macros * Make declarative pallet macros compile with pallet error size checks * Remove unused doc comment * Try and fix build errors * Fix build errors * Add macro_use for some test modules * Test fix * Fix compilation errors * Remove unneeded #[macro_use] * Resolve import ambiguity * Make path to pallet Error enum more specific * Fix test expectation * Disambiguate imports * Fix test expectations * Revert appending pallet module name to path * Rename bags_list::list::Error to BagError * Fixes * Fixes * Fixes * Fix test expectations * Fix test expectation * Add more implementations for PalletError * Lift the 1-field requirement for nested pallet errors * Fix UI test expectation * Remove PalletError impl for OptionBool * Use saturating operations * cargo fmt * Delete obsolete test * Fix test expectation * Try and use assert macro in const context * Pull out the pallet error size check macro * Fix UI test for const assertion * cargo fmt * Apply clippy suggestion * Fix doc comment * Docs for create_tt_return_macro * Ensure TryInto is imported in earlier Rust editions * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix up comments and names * Implement PalletError for Never * cargo fmt * Don't compile example code * Bump API version for block builder * Factor in codec attributes while derving PalletError * Rename module and fix unit test * Add missing attribute * Check API version and convert ApplyExtrinsicResult accordingly * Rename BagError to ListError Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Use codec crate re-exported from frame support * Add links to types mentioned in doc comments Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * cargo fmt * cargo fmt * Re-add attribute for hidden docs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
grishasobol
pushed a commit
to gear-tech/substrate
that referenced
this pull request
Mar 28, 2022
* Allow pallet errors to contain at most one field * Update docs on pallet::error * Reword documentation * cargo fmt * Introduce CompactPalletError trait and require #[pallet::error] fields to implement them * cargo fmt * Do not assume tuple variants * Add CompactPalletError derive macro * Check for error type compactness in construct_runtime * cargo fmt * Derive CompactPalletError instead of implementing it directly during macro expansion * Implement CompactPalletError on OptionBool instead of Option<bool> * Check for type idents instead of variant ident * Add doc comments for ErrorCompactnessTest * Add an trait implementation of ErrorCompactnessTest for () * Convert the error field of DispatchError to a 4-element byte array * Add static check for pallet error size * Rename to MAX_PALLET_ERROR_ENCODED_SIZE * Remove ErrorCompactnessTest trait * Remove check_compactness * Return only the most significant byte when constructing a custom InvalidTransaction * Rename CompactPalletError to PalletError * Use counter to generate unique idents for assert macros * Make declarative pallet macros compile with pallet error size checks * Remove unused doc comment * Try and fix build errors * Fix build errors * Add macro_use for some test modules * Test fix * Fix compilation errors * Remove unneeded #[macro_use] * Resolve import ambiguity * Make path to pallet Error enum more specific * Fix test expectation * Disambiguate imports * Fix test expectations * Revert appending pallet module name to path * Rename bags_list::list::Error to BagError * Fixes * Fixes * Fixes * Fix test expectations * Fix test expectation * Add more implementations for PalletError * Lift the 1-field requirement for nested pallet errors * Fix UI test expectation * Remove PalletError impl for OptionBool * Use saturating operations * cargo fmt * Delete obsolete test * Fix test expectation * Try and use assert macro in const context * Pull out the pallet error size check macro * Fix UI test for const assertion * cargo fmt * Apply clippy suggestion * Fix doc comment * Docs for create_tt_return_macro * Ensure TryInto is imported in earlier Rust editions * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix up comments and names * Implement PalletError for Never * cargo fmt * Don't compile example code * Bump API version for block builder * Factor in codec attributes while derving PalletError * Rename module and fix unit test * Add missing attribute * Check API version and convert ApplyExtrinsicResult accordingly * Rename BagError to ListError Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Use codec crate re-exported from frame support * Add links to types mentioned in doc comments Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * cargo fmt * cargo fmt * Re-add attribute for hidden docs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
12 tasks
notlesh
referenced
this pull request
in moonbeam-foundation/moonbeam
May 9, 2022
jiguantong
added a commit
to darwinia-network/darwinia-messages-substrate
that referenced
this pull request
Jun 9, 2022
Merged
fewensa
added a commit
to darwinia-network/darwinia-messages-substrate
that referenced
this pull request
Jun 29, 2022
hackfisher
pushed a commit
to darwinia-network/darwinia-messages-substrate
that referenced
this pull request
Jul 1, 2022
* Add client-darwinia/client-crab/client-crab-parachain * Update CI * rever substrate commit * fix compile * remove transactional * Fix * Bump finality-grandpa to v0.16.0 * fix wrong import * make change follow paritytech/substrate#11415 * Add runtime-common to workspace and try fix test * Make changes follow paritytech/substrate#10242 * Code clean * More ci check * Remove integrity Co-authored-by: bear <boundless.forest@outlook.com>
10 tasks
3 tasks
DaviRain-Su
pushed a commit
to octopus-network/substrate
that referenced
this pull request
Aug 23, 2022
* Allow pallet errors to contain at most one field * Update docs on pallet::error * Reword documentation * cargo fmt * Introduce CompactPalletError trait and require #[pallet::error] fields to implement them * cargo fmt * Do not assume tuple variants * Add CompactPalletError derive macro * Check for error type compactness in construct_runtime * cargo fmt * Derive CompactPalletError instead of implementing it directly during macro expansion * Implement CompactPalletError on OptionBool instead of Option<bool> * Check for type idents instead of variant ident * Add doc comments for ErrorCompactnessTest * Add an trait implementation of ErrorCompactnessTest for () * Convert the error field of DispatchError to a 4-element byte array * Add static check for pallet error size * Rename to MAX_PALLET_ERROR_ENCODED_SIZE * Remove ErrorCompactnessTest trait * Remove check_compactness * Return only the most significant byte when constructing a custom InvalidTransaction * Rename CompactPalletError to PalletError * Use counter to generate unique idents for assert macros * Make declarative pallet macros compile with pallet error size checks * Remove unused doc comment * Try and fix build errors * Fix build errors * Add macro_use for some test modules * Test fix * Fix compilation errors * Remove unneeded #[macro_use] * Resolve import ambiguity * Make path to pallet Error enum more specific * Fix test expectation * Disambiguate imports * Fix test expectations * Revert appending pallet module name to path * Rename bags_list::list::Error to BagError * Fixes * Fixes * Fixes * Fix test expectations * Fix test expectation * Add more implementations for PalletError * Lift the 1-field requirement for nested pallet errors * Fix UI test expectation * Remove PalletError impl for OptionBool * Use saturating operations * cargo fmt * Delete obsolete test * Fix test expectation * Try and use assert macro in const context * Pull out the pallet error size check macro * Fix UI test for const assertion * cargo fmt * Apply clippy suggestion * Fix doc comment * Docs for create_tt_return_macro * Ensure TryInto is imported in earlier Rust editions * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix up comments and names * Implement PalletError for Never * cargo fmt * Don't compile example code * Bump API version for block builder * Factor in codec attributes while derving PalletError * Rename module and fix unit test * Add missing attribute * Check API version and convert ApplyExtrinsicResult accordingly * Rename BagError to ListError Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Use codec crate re-exported from frame support * Add links to types mentioned in doc comments Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * cargo fmt * cargo fmt * Re-add attribute for hidden docs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
jiguantong
pushed a commit
to darwinia-network/darwinia-messages-substrate
that referenced
this pull request
Sep 29, 2022
* Add client-darwinia/client-crab/client-crab-parachain * Update CI * rever substrate commit * fix compile * remove transactional * Fix * Bump finality-grandpa to v0.16.0 * fix wrong import * make change follow paritytech/substrate#11415 * Add runtime-common to workspace and try fix test * Make changes follow paritytech/substrate#10242 * Code clean * More ci check * Remove integrity Co-authored-by: bear <boundless.forest@outlook.com>
wuminzhe
pushed a commit
to darwinia-network/darwinia-messages-substrate
that referenced
this pull request
Sep 30, 2022
* Update market after order is created or comfirmed (#94) * Update order capacity * FIX CI * Update comment * Redesign fee market payment (#169) * Add basic solution * Refactor Slash Report * Refactor Slash Report 2 * Add other changes * Add tests * Self review * Rename to `message_and_confirm_reward` * Rename to `previous_relayers` * Rename to AssignedRelayer * Add more comments * Add more comments * Add new reward implementation * Rename and clean the code, needs more test * Add more docs here * Prepare for tests * Fix broken tests * Refactor * Rename * Remove RewardBook * Self review * Save one storage * Try fix ci * Handle Zero `CollateralPerOrder` (#176) * Companion 189 for darwinia-parachain (#194) * Update fee-market terminology (#192) (#199) * Support pangolin <> pangolin parachain alpha bridge (#190) * Cherry-pick #201 to `darwinia-parachain` (#203) * Del useless related to fee calculation (#201) * Delete estimate_delivery_transaction * Delete transaction_payment * Delete MessageTransaction * Code clean * Fix compile * Anchor polkadot-v0.9.27 * remove unused import * Fix test problem (#172) * fix ci * Add necessary reward event (#89) * Refactor the total reward cal * Code Clean * Fix test * Add OrderCreated event * Self review * Update comment * Update OrderCreate event to include relayers * Fix review * Enhance dispatch module (#121) * rm shift session manager pallet and clean useless imports (#128) * `Pre-dispatch` validate for main branch (#130) * Adjust the traits * Try fix compile * Fix tests * Code clean * Avoid duplicate evm transact fees (#136) * cherry pick #137 (#140) * cherry pick #137 * pick #141 Co-authored-by: bear <boundless.forest@outlook.com> * Drop error in `pre_dispatch` (#152) (#153) * Migrate to new s2s bridge (#149) * Add client-darwinia/client-crab/client-crab-parachain * Update CI * rever substrate commit * fix compile * remove transactional * Fix * Bump finality-grandpa to v0.16.0 * fix wrong import * make change follow paritytech/substrate#11415 * Add runtime-common to workspace and try fix test * Make changes follow paritytech/substrate#10242 * Code clean * More ci check * Remove integrity Co-authored-by: bear <boundless.forest@outlook.com> * Companion for #155 (#157) * Update market after order is created or comfirmed (#94) * Update order capacity * FIX CI * Update comment * Redesign fee market payment (#169) * Add basic solution * Refactor Slash Report * Refactor Slash Report 2 * Add other changes * Add tests * Self review * Rename to `message_and_confirm_reward` * Rename to `previous_relayers` * Rename to AssignedRelayer * Add more comments * Add more comments * Add new reward implementation * Rename and clean the code, needs more test * Add more docs here * Prepare for tests * Fix broken tests * Refactor * Rename * Remove RewardBook * Self review * Save one storage * Try fix ci * Handle Zero `CollateralPerOrder` (#176) * Update Fee market docs (#178) * Update doc * Update example * Move to `dev-dependencies` (#182) * Sync part.1 (#184) * Remove fee relates (#186) * Sync missing changes from different branches (#191) * Support pangolin <> pangolin parachain alpha bridge (#190) * Integrate `fee-market` to `FromThisChainMessageVerifier` (#189) * Run ignored crate * Fix tests * Add features * Fix compile * Update fee-market terminology (#192) * Del useless related to fee calculation (#201) * Delete estimate_delivery_transaction * Delete transaction_payment * Delete MessageTransaction * Code clean * master > polkadot-v0.9.27 * roll back bp-parachain Co-authored-by: bear <boundless.forest@outlook.com> Co-authored-by: Xavier Lau <xavier@inv.cafe> Co-authored-by: Aki Wu <aki.wu@itering.com> Co-authored-by: HackFisher <denny.wang@itering.io> Co-authored-by: HackFisher <hackfisher@gmail.com> Co-authored-by: fewensa <37804932+fewensa@users.noreply.github.com>
ark0f
pushed a commit
to gear-tech/substrate
that referenced
this pull request
Feb 27, 2023
* Allow pallet errors to contain at most one field * Update docs on pallet::error * Reword documentation * cargo fmt * Introduce CompactPalletError trait and require #[pallet::error] fields to implement them * cargo fmt * Do not assume tuple variants * Add CompactPalletError derive macro * Check for error type compactness in construct_runtime * cargo fmt * Derive CompactPalletError instead of implementing it directly during macro expansion * Implement CompactPalletError on OptionBool instead of Option<bool> * Check for type idents instead of variant ident * Add doc comments for ErrorCompactnessTest * Add an trait implementation of ErrorCompactnessTest for () * Convert the error field of DispatchError to a 4-element byte array * Add static check for pallet error size * Rename to MAX_PALLET_ERROR_ENCODED_SIZE * Remove ErrorCompactnessTest trait * Remove check_compactness * Return only the most significant byte when constructing a custom InvalidTransaction * Rename CompactPalletError to PalletError * Use counter to generate unique idents for assert macros * Make declarative pallet macros compile with pallet error size checks * Remove unused doc comment * Try and fix build errors * Fix build errors * Add macro_use for some test modules * Test fix * Fix compilation errors * Remove unneeded #[macro_use] * Resolve import ambiguity * Make path to pallet Error enum more specific * Fix test expectation * Disambiguate imports * Fix test expectations * Revert appending pallet module name to path * Rename bags_list::list::Error to BagError * Fixes * Fixes * Fixes * Fix test expectations * Fix test expectation * Add more implementations for PalletError * Lift the 1-field requirement for nested pallet errors * Fix UI test expectation * Remove PalletError impl for OptionBool * Use saturating operations * cargo fmt * Delete obsolete test * Fix test expectation * Try and use assert macro in const context * Pull out the pallet error size check macro * Fix UI test for const assertion * cargo fmt * Apply clippy suggestion * Fix doc comment * Docs for create_tt_return_macro * Ensure TryInto is imported in earlier Rust editions * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix up comments and names * Implement PalletError for Never * cargo fmt * Don't compile example code * Bump API version for block builder * Factor in codec attributes while derving PalletError * Rename module and fix unit test * Add missing attribute * Check API version and convert ApplyExtrinsicResult accordingly * Rename BagError to ListError Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Use codec crate re-exported from frame support * Add links to types mentioned in doc comments Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * cargo fmt * cargo fmt * Re-add attribute for hidden docs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
ggwpez
pushed a commit
to ggwpez/runtimes
that referenced
this pull request
Mar 10, 2023
* Rename to BagError * update lockfile for {"substrate"} Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: parity-processbot <>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
A0-please_review
Pull request needs code review.
C1-low
PR touches the given topic and has a low impact on builders.
D3-trivial 🧸
PR contains trivial changes in a runtime directory that do not require an audit
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #8081.
This PR allows FRAME developers to construct a pallet error enum with variants containing fields, provided that the field types implements
scale_info::TypeInfo
and a new trait calledPalletError
, which can easily be derived viaframe_support::PalletError
. Note that this trait is automatically implemented for types that are statically known to have a maximum encoded size. Other types not listed will have to derive or implement the trait manually.PalletError
statically checks to see whether the maximum encoded size of the pallet error enum is greater thanMAX_PALLET_ERROR_ENCODED_SIZE
, and is currently set at 4 bytes.polkadot companion: paritytech/polkadot#4862