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

Confusing error message on duplicate dispatchable function #6379

Closed
apopiak opened this issue Jun 17, 2020 · 3 comments
Closed

Confusing error message on duplicate dispatchable function #6379

apopiak opened this issue Jun 17, 2020 · 3 comments

Comments

@apopiak
Copy link
Contributor

apopiak commented Jun 17, 2020

When adding a duplicate dispatchable in a pallet's decl_module the resulting error message is confusing:

error: Implicit conversion to privileged function has been removed. First parameter of dispatch should be marked `origin`. For root-matching dispatch, also add `ensure_root(origin)?`.
   --> pallets/template/src/lib.rs:63:1
    |
63  | / decl_module! {
64  | |     /// The module declaration.
65  | |     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
66  | |         // Initializing errors
...   |
116 | |     }
117 | | }
    | |_^
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Observed behavior: Error message complaining about implicit conversion to privileged function.

Expected behavior: Error message indicating that duplicate defintion of the same dispatchable is not allowed.

See reproduction here: #6378

@apopiak
Copy link
Contributor Author

apopiak commented Jun 17, 2020

Quoting/Paraphrasing Shawn from the reproduction PR thread:

In the case of on_initialize this is a macro matching issue.

The first on_initialize() function is captured using our macro and is expected. The next one goes through our normal dispatch function logic, which does not allow any dispatchable that does not contain origin as the first parameter.

After the first instance, the function is treated like any arbitrary function, so the name is not considered for the parsing. At this point we only consider the function parameters, and we see that this dispatchable function is missing origin, so we complain.

I would guess this problem only occurs with "reserved functions" like on_initialize, on_finalize, on_runtime_upgrade, etc...

@apopiak
Copy link
Contributor Author

apopiak commented Jun 17, 2020

Verified that this is not reproducible via duplicating a "regular dispatchable", so it's an issue with the "reserved functions".

@bkchr
Copy link
Member

bkchr commented Jul 3, 2020

Should be closed by #6384

@bkchr bkchr closed this as completed Jul 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants