Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Missing Error declaration in some pallets #8501

Closed
h4x3rotab opened this issue Mar 31, 2021 · 7 comments · Fixed by #8523
Closed

Missing Error declaration in some pallets #8501

h4x3rotab opened this issue Mar 31, 2021 · 7 comments · Fixed by #8523
Labels
Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.

Comments

@h4x3rotab
Copy link
Contributor

Now if we check rpc.state.getMetadata, there are a lot of pallets without error declarations populated in metadata it returns. We have checked Phala PoC3 and Polkadot (at the latest block, and block 1000). All of them have this problem.

For example, if you search "Indices" pallet, and find the errors field in its entry, it shows:

          errors: [],
          index: 4

This will cause errors in polkadotjs and subxt whenever they decode a block with the errors from these bad pallets.

However, not all the pallets have this problem. We checked around the definition of the bad pallets and good pallets, and found all the bad pallets forgot to declare the error inside decl_module!. So we suspect this is the root cause. Now we cannot dedicate some time for further testing. So I just created this issue and leave it as a record.

Good example:

decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
type Error = Error<T>;

Bad example:

decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin, system = frame_system {
/// The deposit needed for reserving an index.
const Deposit: BalanceOf<T> = T::Deposit::get();
fn deposit_event() = default;

A full list of the good pallets (by grep type Error = Error<T> in the frame directory):

substrate/frame/assets/src/lib.rs:
substrate/frame/atomic-swap/src/lib.rs:
substrate/frame/authorship/src/lib.rs:
substrate/frame/balances/src/lib.rs:
substrate/frame/collective/src/lib.rs:
substrate/frame/contracts/src/lib.rs:
substrate/frame/democracy/src/lib.rs:
substrate/frame/elections/src/lib.rs:
substrate/frame/elections-phragmen/src/lib.rs:
substrate/frame/evm/src/lib.rs:
substrate/frame/grandpa/src/lib.rs:
substrate/frame/identity/src/lib.rs:
substrate/frame/im-online/src/lib.rs:
substrate/frame/multisig/src/lib.rs:
substrate/frame/nicks/src/lib.rs:
substrate/frame/node-authorization/src/lib.rs:
substrate/frame/proxy/src/lib.rs:
substrate/frame/recovery/src/lib.rs:
substrate/frame/scheduler/src/lib.rs:
substrate/frame/scored-pool/src/lib.rs:
substrate/frame/session/src/lib.rs:
substrate/frame/society/src/lib.rs:
substrate/frame/staking/src/lib.rs:
substrate/frame/sudo/src/lib.rs:
substrate/frame/support/src/metadata.rs:
substrate/frame/system/src/lib.rs:
substrate/frame/treasury/src/lib.rs:
substrate/frame/vesting/src/lib.rs:
@xlc
Copy link
Contributor

xlc commented Mar 31, 2021

Related #6418

@shawntabrizi shawntabrizi added Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be. labels Mar 31, 2021
@shawntabrizi
Copy link
Member

This would be a good first issue for any people who want to hunt down all the missing errors.

@h4x3rotab
Copy link
Contributor Author

Would appreciate if we can get a quick fix because all the miners on our network were halted :(

@shawntabrizi
Copy link
Member

@h4x3rotab can you elaborate on how this has broke your miners?

You should be able to handle no error metadata, as it is clearly not required, and basically you should not expect it from all Substrate teams.

@jasl
Copy link
Contributor

jasl commented Apr 2, 2021

@h4x3rotab can you elaborate on how this has broke your miners?

You should be able to handle no error metadata, as it is clearly not required, and basically you should not expect it from all Substrate teams.

It breaks SubXT, I attached a PR for them to workaround this

@KiChjang
Copy link
Contributor

KiChjang commented Apr 3, 2021

It seems like that there's quite a lot of pallets nowadays that don't use the decl_module macro to implement dispatch logic anymore, and instead uses the #[pallet] macro. Pallets using the new attribute macro don't seem to need the type Error = Error<T> line anymore; instead, #[pallet::error] looks to be enough. Am I missing anything here?

@shawntabrizi
Copy link
Member

shawntabrizi commented Apr 3, 2021

@KiChjang yes, that is accurate. Thew new macros solve this issue. But old pallets could be patched up in the meantime.

Or you can spend your time to migrate the old pallets into the new macro.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants