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: add new parachain template and remove outdated one from parity #297

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ toml_edit = { version = "0.22", features = ["serde"] }
symlink = "0.1"
serde_json = { version = "1.0", features = ["preserve_order"] }
serde = { version = "1.0", features = ["derive"] }
zombienet-sdk = "0.2.7"
zombienet-support = "0.2.7"
zombienet-sdk = "0.2.10"
git2_credentials = "0.13.0"

# pop-cli
Expand Down
21 changes: 14 additions & 7 deletions crates/pop-cli/src/commands/new/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ async fn guide_user_to_generate_parachain(verify: bool) -> Result<NewParachainCo
provider,
provider.name(),
format!(
"{} {} available option(s) {}",
"{} {} available option(s)",
provider.description(),
provider.templates().len(),
if provider.name() == "Parity" { "[deprecated]" } else { "" }
provider.templates().len()
),
);
}
Expand Down Expand Up @@ -216,7 +215,7 @@ async fn generate_parachain_from_template(
// add next steps
let mut next_steps = vec![
format!("cd into \"{name_template}\" and enjoy hacking! 🚀"),
"Use `pop build` to build your parachain.".into(),
"Use `pop build --release` to build your parachain.".into(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would keep it pop build. Adding --release takes way too long for development, and could degrade the UX for parachain development. --release should be suggested when prepping the chain for onboarding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made this change because it's common in the Zombienet configuration file to reference /target/release/. See https://github.com/OpenZeppelin/polkadot-runtime-templates/blob/main/generic-template/zombienet-config/devnet.toml#L21 or https://github.com/r0gue-io/pop-cli/blob/main/tests/networks/template.toml#L16.
Without running pop build --release, the path needs to be manually updated in the Zombienet file for things to work correctly.

];
if let Some(network_config) = template.network_config() {
next_steps.push(format!(
Expand Down Expand Up @@ -253,7 +252,15 @@ fn display_select_options(provider: &Provider) -> Result<&Parachain> {
if i == 0 {
prompt = prompt.initial_value(template);
}
prompt = prompt.item(template, template.name(), template.description());
prompt = prompt.item(
template,
template.name(),
format!(
"{} {}",
template.description(),
if matches!(template, Parachain::ParityContracts) { "[deprecated]" } else { "" }
),
);
}
Ok(prompt.interact()?)
}
Expand Down Expand Up @@ -467,11 +474,11 @@ mod tests {
fn test_is_template_supported() -> Result<()> {
is_template_supported(&Provider::Pop, &Parachain::Standard)?;
assert!(is_template_supported(&Provider::Pop, &Parachain::ParityContracts).is_err());
assert!(is_template_supported(&Provider::Pop, &Parachain::ParityFPT).is_err());
assert!(is_template_supported(&Provider::Pop, &Parachain::ParityGeneric).is_err());

assert!(is_template_supported(&Provider::Parity, &Parachain::Standard).is_err());
is_template_supported(&Provider::Parity, &Parachain::ParityContracts)?;
is_template_supported(&Provider::Parity, &Parachain::ParityFPT)
is_template_supported(&Provider::Parity, &Parachain::ParityGeneric)
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/pop-parachains/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ toml_edit.workspace = true
walkdir.workspace = true
# Zombienet
zombienet-sdk.workspace = true
zombienet-support.workspace = true

# Pop
pop-common = { path = "../pop-common", version = "0.3.0" }
Expand Down
59 changes: 32 additions & 27 deletions crates/pop-parachains/src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Type<Parachain> for Provider {
match &self {
Provider::Pop => Some(Parachain::Standard),
Provider::OpenZeppelin => Some(Parachain::OpenZeppelinGeneric),
Provider::Parity => Some(Parachain::ParityContracts),
Provider::Parity => Some(Parachain::ParityGeneric),
}
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ pub enum Parachain {
EVM,
// OpenZeppelin
#[strum(
serialize = "polkadot-generic-runtime-template",
serialize = "openzeppelin/polkadot-generic-runtime-template",
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
message = "Generic Runtime Template",
detailed_message = "A generic template for Substrate Runtime",
props(
Expand All @@ -136,33 +136,32 @@ pub enum Parachain {
)
)]
OpenZeppelinGeneric,
/// Minimal Substrate node configured for smart contracts via pallet-contracts.
/// The Parachain-Ready Template From Polkadot SDK.
#[strum(
serialize = "cpt",
message = "Contracts",
detailed_message = "Minimal Substrate node configured for smart contracts via pallet-contracts.",
serialize = "parity/polkadot-sdk-parachain-template",
message = "Polkadot SDK's Parachain Template",
detailed_message = "The Parachain-Ready Template From Polkadot SDK.",
props(
Provider = "Parity",
Repository = "https://github.com/paritytech/substrate-contracts-node",
Repository = "https://github.com/paritytech/polkadot-sdk-parachain-template",
Network = "./zombienet.toml",
License = "Unlicense"
)
)]
ParityContracts,
/// Template node for a Frontier (EVM) based parachain.
ParityGeneric,
/// Minimal Substrate node configured for smart contracts via pallet-contracts.
#[strum(
serialize = "fpt",
message = "EVM",
detailed_message = "Template node for a Frontier (EVM) based parachain.",
serialize = "parity/contracts",
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
message = "Contracts",
detailed_message = "Minimal Substrate node configured for smart contracts via pallet-contracts.",
props(
Provider = "Parity",
Repository = "https://github.com/paritytech/frontier-parachain-template",
Network = "./zombienet-config.toml",
Repository = "https://github.com/paritytech/substrate-contracts-node",
Network = "./zombienet.toml",
License = "Unlicense"
)
)]
ParityFPT,

ParityContracts,
// templates for unit tests below
#[cfg(test)]
#[strum(
Expand Down Expand Up @@ -232,9 +231,9 @@ mod tests {
("contracts".to_string(), Contracts),
("evm".to_string(), EVM),
// openzeppelin
("polkadot-generic-runtime-template".to_string(), OpenZeppelinGeneric),
("cpt".to_string(), ParityContracts),
("fpt".to_string(), ParityFPT),
("openzeppelin/polkadot-generic-runtime-template".to_string(), OpenZeppelinGeneric),
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
("parity/polkadot-sdk-parachain-template".to_string(), ParityGeneric),
("parity/contracts".to_string(), ParityContracts),
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
("test_01".to_string(), TestTemplate01),
("test_02".to_string(), TestTemplate02),
])
Expand All @@ -248,11 +247,17 @@ mod tests {
("evm".to_string(), "https://github.com/r0gue-io/evm-parachain"),
// openzeppelin
(
"polkadot-generic-runtime-template".to_string(),
"openzeppelin/polkadot-generic-runtime-template".to_string(),
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
"https://github.com/OpenZeppelin/polkadot-runtime-templates",
),
("cpt".to_string(), "https://github.com/paritytech/substrate-contracts-node"),
("fpt".to_string(), "https://github.com/paritytech/frontier-parachain-template"),
(
"parity/polkadot-sdk-parachain-template".to_string(),
"https://github.com/paritytech/polkadot-sdk-parachain-template",
),
(
"parity/contracts".to_string(),
"https://github.com/paritytech/substrate-contracts-node",
),
("test_01".to_string(), ""),
("test_02".to_string(), ""),
])
Expand All @@ -265,8 +270,8 @@ mod tests {
(Contracts, Some("./network.toml")),
(EVM, Some("./network.toml")),
(OpenZeppelinGeneric, Some("./zombienet-config/devnet.toml")),
(ParityGeneric, Some("./zombienet.toml")),
(ParityContracts, Some("./zombienet.toml")),
(ParityFPT, Some("./zombienet-config.toml")),
(TestTemplate01, Some("")),
(TestTemplate02, Some("")),
]
Expand All @@ -280,8 +285,8 @@ mod tests {
(Contracts, Some("Unlicense")),
(EVM, Some("Unlicense")),
(OpenZeppelinGeneric, Some("GPL-3.0")),
(ParityGeneric, Some("Unlicense")),
(ParityContracts, Some("Unlicense")),
(ParityFPT, Some("Unlicense")),
(TestTemplate01, Some("Unlicense")),
(TestTemplate02, Some("GPL-3.0")),
]
Expand All @@ -295,7 +300,7 @@ mod tests {
assert_eq!(Provider::Pop.provides(&template), true);
assert_eq!(Provider::Parity.provides(&template), false);
}
if matches!(template, ParityContracts | ParityFPT) {
if matches!(template, ParityContracts | ParityGeneric) {
assert_eq!(Provider::Pop.provides(&template), false);
assert_eq!(Provider::Parity.provides(&template), true)
}
Expand Down Expand Up @@ -348,15 +353,15 @@ mod tests {
let mut provider = Provider::Pop;
assert_eq!(provider.default_template(), Some(Standard));
provider = Provider::Parity;
assert_eq!(provider.default_template(), Some(ParityContracts));
assert_eq!(provider.default_template(), Some(ParityGeneric));
}

#[test]
fn test_templates_of_provider() {
let mut provider = Provider::Pop;
assert_eq!(provider.templates(), [&Standard, &Assets, &Contracts, &EVM]);
provider = Provider::Parity;
assert_eq!(provider.templates(), [&ParityContracts, &ParityFPT]);
assert_eq!(provider.templates(), [&ParityGeneric, &ParityContracts]);
}

#[test]
Expand Down
Loading
Loading