-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix/workaround metadata bug for pallet config #5064
Fix/workaround metadata bug for pallet config #5064
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5064 +/- ##
======================================
- Coverage 71% 71% -0%
======================================
Files 441 441
Lines 76362 76239 -123
Branches 76362 76239 -123
======================================
- Hits 54567 54386 -181
- Misses 18915 18967 +52
- Partials 2880 2886 +6 ☔ View full report in Codecov by Sentry. |
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.
Is this fixed in a more recent version of substrate? or is there an open issue to fix it? Would be good to at least link the issue somewhere here to explain why this is required.
* explicitly construct type-info for PalletConfigUpdate in ingress-egress pallet * simplify via macro (cherry picked from commit e55ea5b)
* explicitly construct type-info for PalletConfigUpdate in ingress-egress pallet * simplify via macro (cherry picked from commit e55ea5b)
Pull Request
Closes: PRO-1518
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
Defining typeInfos for different enums with the same name causes PolkadotJS some confusion. For example, we have multiple Ingress-Egress pallets, one for each chain. Each of these pallets has an enum defined called "PalletConfigUpdate". Even though their type path and type ID are different, PolkadotJS seems to only look at the enum name when parsing the metadata. This leads to the situation where when trying to set a value for PalletConfigUpdate on Ethereum, the PolkadotJS interface uses the type for Solana (or whatever pallet was constructed last).
The solution is to not derive the typeInfo, but to explicitly construct it and assign different type names for each instance.
The main problem was that the name needs to be a string literal, but we can't construct it via concat!, because that will only work with string literals. Alastair suggested constcat::concat! instead, but that also doesn't work, because Rust doesn't allow to access static elements via generic types (wow).
In the end I just bruteforce write out all the chains. It sucks, but it is better than what we had before.
There is an open issue to fix this in polkadot-js that dan raised:
polkadot-js/apps#10432
Non-Breaking changes
If this PR includes non-breaking changes, select the
non-breaking
label. On merge, CI will automatically cherry-pick the commit to a PR against the release branch.