-
Couldn't load subscription status.
- Fork 36
feat: new command pop add pallet
#524
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for addressing some of the feedback and putting in the effort to split the functionality in a smaller PR. I left some comments in the code.
Some comments from a DevEx perspective, if I run pop add pallet, I get:
error: the following required arguments were not provided:
--pallets <PALLETS>...
It would be helpful if the UI could show users which pallets are currently supported and allow them to select one.
Also, the <pallet>=<version> format isn't very intuitive. I saw your comment in the PR description mentioning that it would be nice to allow adding 2, 3, 4, etc. pallets in one command, but since it’s unclear when that might happen, wouldn’t it be cleaner to have a flag to specify the version instead?
Finally, we should review the list of supported pallets, it might make sense to add a few more. For example, pallet_revive could be valuable, as it's something users might want to include in their runtimes soon.
|
Hey @AlexD10S ! Thanks for the feedback!
As I described in the PR description, I didn't include the UI cause selecting a few pallets from the UI and then specifying versions for each didn't look like the best possible UI. The same applies for the However, if we opt out for allowing just a pallet per execution, showing a UI with the pallets and using a
Totally agree, but as I said in the PR description, maybe that's not in the scope of this one at all. This PR should be the scaffolding for the functionality, so you'd be able to add as many pallets as possible in subsequents PR, but given that there's a lot of code to review here, I wouldn't grow the pallets file in this PR. IMO the pallets available in this PR aren't the most important thing |
Co-authored-by: Alex Bean <[email protected]>
Co-authored-by: Alex Bean <[email protected]>
Co-authored-by: Alex Bean <[email protected]>
Co-authored-by: Alex Bean <[email protected]>
Co-authored-by: Alex Bean <[email protected]>
|
Thanks for addressing most of my comments! I've created a PR: tsenovilla#4, which adds a list of suggested pallets that might be more helpful than the current default list. Feel free to review it and add anything you think is missing. While working on that, I’ve also done some additional testing and noticed a problem with how the functionality behaves when different versions are involved. It works well in an ideal setup, but issues arise when version mismatches occur. How to reproduce:
I know we've talked about the versioning issue already, and we're still not sure what the best solution is, but it definitely complicates the DevEx. If you take a look when you have some time of the scenario above, I'd really love to hear your thoughts from a DevEx perspective. One possible idea could be to ask users to specify the version of their chain (e.g., Next stepsIf you rebase with the latest changes from main, I can go ahead and create another PR to implement this logic under the [experimental] feature flag (https://github.com/r0gue-io/pop-cli/blob/main/crates/pop-cli/Cargo.toml#L66C18-L66C25). That way, we sould merge it even if it's not perfect yet, and let users start experimenting with it. |
chore: add new pallets
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #524 +/- ##
==========================================
- Coverage 79.34% 79.31% -0.03%
==========================================
Files 106 109 +3
Lines 25828 26957 +1129
Branches 25828 26957 +1129
==========================================
+ Hits 20494 21382 +888
- Misses 3047 3258 +211
- Partials 2287 2317 +30
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
@AlexD10S I've merged your PR so now the list of offered pallets is more interesting as you mentioned. I've also added the experimental feature flag for this functionality. Regarding the DevEx, as you mentioned the user would need to know the concrete version working for their template, which could be challenging. Your proposal of using a Polkadot-SDK release instead looks nicer tbh, however pulling the versions from the Plan isn't necessary if I'm not wrong, we can just add the new pallet pointing to a branch of the polkadot SDK instead of picking a concrete version, eg: pallet-contracts = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412", default-features = false }I've updated the PR accordingly, so now the command ask for a release tag instead of a version, which is definitely a better DevEx (think we can assume that the user knows which sdk version is using, so this should be a working version IMO). However I've noticed there's a problem after running: This isn't compiling due to a dependency conflict! After looking at the involved dependencies, I realized I'll open an issue as this is something you might want to check out. |
The PR
became a monster without realizing it, as I was working on it in my spare time for a very long period of time. This PR aims to bring a first piece of its functionality (the most important one IMO) to Pop-Cli, the new command
pop addwith its first subcommandpallet. While it's still a big PR, the review should be way easier.Further PRs will come in the future in order to complete the whole functionality of the previous PR if they're needed.
Disclaimer: I tried to take into account all the great feedback you gave me in the previous PR related to this command, but some parts have been reorganized and maybe I missed something, so I apologize in advance.
So..
What's new?!
This PR introduces the command
pop add pallet, which serves to expand an existing runtime by adding a new pallet and setting everything up for that pallet. The help message for this command looks like this:As you may see, there's only two available pallets:
balancesandcontracts. The PR objective isn't to bring many pallets in the first place but to create a good scaffolding allowing Pop-Cli to unlock this functionality, so more pallets may be added in subsequent PRs easily (the filecrates/pop-cli/src/commands/add/pallet/common_pallets.rscontains the supported pallets, modifying it is straightforward).Additionally, the command needs versions to be passed as arguments for each pallet. As discussed with @AlexD10S in the context of the previous PR, we've to find a better way to deal with versions as this command may be used in different templates and its a bit difficult to find out which versions need each template. But for this first version, specifying the version in the command should be good enough. I opted out for discarding an interactive UI for this first version of the command, as it feels a bit tedious to select the pallets and then being prompted to specify a version for each one.
The command in action
Let's quickly check how the command works. Imagine that we have a parachain template generated with
pop new parachainand that we wanna expand it with the contracts pallet. If we runpop add pallet -p contracts=39.0.0, our parachain undergoes these changes:Cargo.toml-> Pallet added to workspace manifestruntime/Cargo.toml-> Pallet added to runtime manifestruntime/Cargo.toml->stdfeature updatedruntime/Cargo.toml->runtime-benchmarks&try-runtimefeatures updatedruntime/src/lib.rs-> Pallet added to runtime declarationruntime/src/configs/mod.rs-> added new module forcontractsconfigruntime/src/configs/contracts.rspop add palletThis is just one example but there's much more:
#[runtime]andconstruct_runtime!macros.configs.rsas the root for theconfigsmodule instead ofconfigs/mod.rs.runtime/src/lib.rs).Other design considerations
--pallet-impl-pathisn't used, the impl block will always be created underconfigs/<pallet>.rs. Even if aconfigsmodule isn't used by the template yet, it'll be created.Future work
This is just the first version of the command, and there's so much room for improvement. Other pallets should be added in further PRs, so a Pop-Cli user would be able to add 2,3,4,... pallets to their template with a single command. As discussed with @AlexD10S offline, the optimal would be to provide support for all the existing pallets in the Polkadot SDK. This may be achieved adding all them to
crates/pop-cli/src/commands/runtime_pallet/common_pallets.rs, but maybe there's a nice way to query them on the fly.There's also the versions stuff that I talked about above, I'm sure there's a better way to deal with them.