Skip to content
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

#[feeless_if(..)] breaks when used in a #[pallet_section] #5981

Closed
2 tasks done
sam0x17 opened this issue Oct 8, 2024 · 1 comment · Fixed by #6032
Closed
2 tasks done

#[feeless_if(..)] breaks when used in a #[pallet_section] #5981

sam0x17 opened this issue Oct 8, 2024 · 1 comment · Fixed by #6032
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@sam0x17
Copy link
Contributor

sam0x17 commented Oct 8, 2024

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

Right now one of the bugs with #[pallet_section] is if the external pallet section has a #[feeless_if(..)] anywhere in it, for some reason this causes a string of compile errors. A recent example is here but it is quite easy to reproduce: https://github.com/opentensor/subtensor/actions/runs/11215301673/job/31172208884#step:6:1609

I imagine this has something to do with how feeless_if is implemented interfering in some way with the macro_magic import_tokens_attr call. In theory this sort of thing should never happen so my guess is there is something weird going on in the parsing/expansion code for feeless_if, but I have not had a chance to look at it in depth.

debugging steps I would take would be:

  • check out the parsing/expansion code for #[feeless_if(..)], see if you can print something to the terminal from there and use bisection to figure out where the compile error is originating from

Steps to reproduce

  • make a new pallet, dev mode is fine
  • define an external #[pallet_section]
  • import that section using #[import_section]
  • in this pallet section, use #[feeless_if(..)]
  • you will get a compile error saying "expected a value" with a span pointing to the #[pallet::pallet] macro invocation site.
@sam0x17 sam0x17 added I10-unconfirmed Issue might be valid, but it's not yet known. I2-bug The node fails to follow expected behavior. labels Oct 8, 2024
@eagr
Copy link
Contributor

eagr commented Oct 13, 2024

https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/support/procedural/src/pallet/expand/call.rs#L260

looks like the origin in the expansion resolves to the wrong thing. similar to #5320, but for the opposite reason

github-merge-queue bot pushed a commit that referenced this issue Oct 14, 2024
fixes #5981 

Could confirm the issue with the added tests:

```
test tests/split_ui/pass/split_call.rs [should pass] ... error
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
error[E0423]: expected value, found attribute macro `origin`
  --> tests/split_ui/pass/split_call.rs:23:1
   |
23 | #[frame_support::pallet(dev_mode)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a value
   |
   = note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
```

# Description

`origin` unexpectedly resolved to a macro, which is available at the
span of invocation. The solution here is to use the expansion as a
function instead of a call and pass in the desired values to avoid
ambiguities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants