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

Fix/workaround metadata bug for pallet config #5064

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

martin-chainflip
Copy link
Contributor

@martin-chainflip martin-chainflip commented Jul 19, 2024

Pull Request

Closes: PRO-1518

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have updated documentation where appropriate.

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.

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 71%. Comparing base (fe8b41b) to head (9548a59).

Files Patch % Lines
state-chain/pallets/cf-ingress-egress/src/lib.rs 96% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@martin-chainflip martin-chainflip marked this pull request as ready for review July 19, 2024 12:41
@martin-chainflip martin-chainflip added the non-breaking Merging this PR will create a cherry-pick onto release label Jul 19, 2024
Copy link
Contributor

@kylezs kylezs left a 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.

@martin-chainflip martin-chainflip added this pull request to the merge queue Jul 22, 2024
Merged via the queue into main with commit e55ea5b Jul 22, 2024
47 checks passed
@martin-chainflip martin-chainflip deleted the fix/workaround_metadata_bug_for_pallet_config branch July 22, 2024 13:55
chainflip-bot pushed a commit that referenced this pull request Jul 22, 2024
* explicitly construct type-info for PalletConfigUpdate in ingress-egress pallet

* simplify via macro

(cherry picked from commit e55ea5b)
martin-chainflip added a commit that referenced this pull request Jul 24, 2024
* explicitly construct type-info for PalletConfigUpdate in ingress-egress pallet

* simplify via macro

(cherry picked from commit e55ea5b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-breaking Merging this PR will create a cherry-pick onto release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants