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: logic for parachain registration #410

Open
wants to merge 13 commits into
base: feat/deploy-parachain
Choose a base branch
from

Conversation

AlexD10S
Copy link
Collaborator

@AlexD10S AlexD10S commented Feb 12, 2025

This is the first step in a larger PR: PR #404. It consolidates the existing logic for deploying a parachain into a relay chain when a user executes pop up in a parachain project.

Changes included:

  • Added generate_genesis_artifacts function in specs to build and return paths for the genesis and WASM files.
  • Updated submit_extrinsic_with_wallet to return events.
  • Parsed the Reserved event in the Registrar pallet to retrieve the parachain ID after reservation.
  • Integrated the entire process: reserving the paraID, generating specifications, and registering the parachain in the pop up command.

How to test it
Start the Paseo parachain locally by running:

pop up parachain -f ./tests/networks/paseo.toml

Run pop up in your parachain folder or specify the folder with the path flag

pop up --path ../test-chain --relay-url ws://127.0.0.1:49155

Note: The account used for signing must have sufficient funds to cover both the reservation and signing process.

Notes:

  • I tried to have a more generic event parsing approach but couldn't find a viable solution. Instead, I followed the approach used in cargo-contracts: Reference. If we need to parse more events in the future, we can manually add them.
  • To sign this logic is using the wallet signing approach (--use-wallet). If useful, I can add options for --suri and specifying a private key via the command line, but not sure if makes sense.

[sc-2756]

@AlexD10S AlexD10S force-pushed the feat/pop-up-for-parachain branch from 6c5a488 to ba6e253 Compare February 14, 2025 11:51
@AlexD10S AlexD10S force-pushed the feat/deploy-parachain branch from 511e547 to 945a8ac Compare February 14, 2025 12:22
@AlexD10S AlexD10S mentioned this pull request Feb 15, 2025
4 tasks
@AlexD10S AlexD10S force-pushed the feat/deploy-parachain branch 2 times, most recently from df55096 to 0a64db8 Compare February 17, 2025 16:34
@AlexD10S AlexD10S force-pushed the feat/pop-up-for-parachain branch from ba6e253 to b55ddaa Compare February 17, 2025 17:30
@AlexD10S AlexD10S force-pushed the feat/pop-up-for-parachain branch from b55ddaa to d360dba Compare February 17, 2025 17:33

// Generate chain spec.
generate_plain_chain_spec(&binary_path, output_file, default_bootnode, chain)?;
Copy link
Collaborator Author

@AlexD10S AlexD10S Feb 17, 2025

Choose a reason for hiding this comment

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

Refactored the logic for generating the chain spec and raw chain spec into the generate_chain_spec function.

// Sign and submit an extrinsic using wallet integration.
async fn submit_extrinsic_with_wallet(
// Sign and submit an extrinsic using wallet integration, then returns the resulting events.
pub(crate) async fn submit_extrinsic_with_wallet(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function is now reused in pop up, so it might make sense to move it to a common file. But I wasn’t sure about making additional changes.

@AlexD10S AlexD10S marked this pull request as ready for review February 17, 2025 22:24
Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 53.05466% with 146 lines in your changes missing coverage. Please review.

Project coverage is 75.05%. Comparing base (89d4c23) to head (e413871).

Files with missing lines Patch % Lines
crates/pop-cli/src/commands/up/parachain.rs 66.23% 39 Missing and 40 partials ⚠️
crates/pop-cli/src/commands/build/spec.rs 2.38% 41 Missing ⚠️
crates/pop-cli/src/commands/call/chain.rs 0.00% 11 Missing ⚠️
crates/pop-parachains/src/call/metadata/events.rs 0.00% 9 Missing ⚠️
crates/pop-cli/src/commands/up/mod.rs 75.00% 0 Missing and 3 partials ⚠️
crates/pop-parachains/src/call/mod.rs 0.00% 3 Missing ⚠️
@@                    Coverage Diff                    @@
##           feat/deploy-parachain     #410      +/-   ##
=========================================================
- Coverage                  75.35%   75.05%   -0.31%     
=========================================================
  Files                         64       66       +2     
  Lines                      13998    14269     +271     
  Branches                   13998    14269     +271     
=========================================================
+ Hits                       10548    10709     +161     
- Misses                      2098     2167      +69     
- Partials                    1352     1393      +41     
Files with missing lines Coverage Δ
crates/pop-parachains/src/call/metadata/mod.rs 93.15% <ø> (ø)
crates/pop-cli/src/commands/up/mod.rs 78.21% <75.00%> (+0.55%) ⬆️
crates/pop-parachains/src/call/mod.rs 58.68% <0.00%> (+0.34%) ⬆️
crates/pop-parachains/src/call/metadata/events.rs 0.00% <0.00%> (ø)
crates/pop-cli/src/commands/call/chain.rs 74.20% <0.00%> (-0.44%) ⬇️
crates/pop-cli/src/commands/build/spec.rs 71.67% <2.38%> (-2.15%) ⬇️
crates/pop-cli/src/commands/up/parachain.rs 66.23% <66.23%> (ø)

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.

2 participants