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

feat: reuse existing chain spec #351

Merged
merged 14 commits into from
Nov 29, 2024

Conversation

Daanvdplas
Copy link
Collaborator

@Daanvdplas Daanvdplas commented Nov 26, 2024

Allow to provide an existing chain spec file for the chain flag. I aimed for flexibility and a clear flow in the code so that it is easily adaptable for future requirements.

Added an additional BuildSpec struct to separate the flow between getting the users input and secondary input (prompts), and generating the files with the provided options. This also allowed to not have to worry about the Option fields in the BuildSpecCmd which complicated the code.

If the user provides a chain spec file and it does not want to make changes to it (user is prompted whether it wants this), and e.g. the para id is not present in the file, a default value is used. No warning has been added as the chance of this happening is very small. Either due to a user mistake by manually removing it or a chain spec file is provided that is created without the pop cli which could cause to have no para id present. There will always be a para id in a chain spec file if it is created with the pop cli. This example counts for all the other Option fields in the BuildSpecCmd.

No tests have been written yet due to time and can be done if required

The build profile will be added as a separate PR after this is merged.

Copy link
Collaborator

@AlexD10S AlexD10S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! This definitely improves the DevEx.

The integration test is currently failing, see my comment for a way to test it without waiting for the full test to finish. Additionally, cargo test --doc needs to be fixed too after your changes.

The rest are minor comments to address and a few suggestions for improvement.

crates/pop-cli/src/commands/build/spec.rs Outdated Show resolved Hide resolved
crates/pop-parachains/src/build.rs Show resolved Hide resolved
crates/pop-parachains/src/build.rs Outdated Show resolved Hide resolved
crates/pop-parachains/src/build.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/build/spec.rs Show resolved Hide resolved
crates/pop-cli/src/commands/build/spec.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/build/spec.rs Show resolved Hide resolved
Copy link
Contributor

@al3mart al3mart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the flow, and it's great having the possibility of creating and modifying existing specs!

There's a few nits that need revisiting, but it's looking great!

crates/pop-cli/src/commands/build/spec.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/build/spec.rs Outdated Show resolved Hide resolved
@al3mart
Copy link
Contributor

al3mart commented Nov 28, 2024

@Daanvdplas thanks for the addressing the feedback! This is great!

I yet have a comment on fix: prepare_output_path.

I believe we are deviating on how we treat the input provided in --output
Given that we are telling the users:

  -o, --output <OUTPUT_FILE>       File name for the resulting spec. If a path is given, the necessary directories will be created

Whatever the user inputs should be the name of the file, I don't think we only need to consider the input as a file if it has the .json extension.
We already take the opinion of appending .json and -raw.json to the specs. But I guess we should respect the naming users provide

@Daanvdplas
Copy link
Collaborator Author

Imo it is a simple rule to follow, end your preferred name with .json, it makes the code easy as well. @AlexD10S wdyt?

@Daanvdplas Daanvdplas requested a review from al3mart November 28, 2024 18:56
Copy link
Contributor

@al3mart al3mart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Collaborator

@AlexD10S AlexD10S left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see the unit tests in thepop-clicrate.

Just one little point before merge it. If I run cargo +nightly clippy I see a couple of warnings that can be fixed, or the CI will complain when point to main.

@Daanvdplas Daanvdplas merged commit d84487c into fix/build-spec Nov 29, 2024
@Daanvdplas Daanvdplas deleted the daan/feat-use_chain_spec_file branch November 29, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants