-
Notifications
You must be signed in to change notification settings - Fork 710
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
templates: make node compilation optional #5954
templates: make node compilation optional #5954
Conversation
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
This increases CI time but for a good reason. We want to ensure parachains pick up the finalized block info from the relay chain. Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
…ake-node-compilation-optional
Signed-off-by: Iulian Barbu <[email protected]>
This reverts commit dae9b73.
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
@@ -21,15 +21,28 @@ path = "bin/main.rs" | |||
name = "chain-spec-builder" | |||
|
|||
[lib] | |||
crate-type = ["rlib"] | |||
# Docs tests are not needed since the code samples that would be executed |
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.
I am not sure why this is needed; anything in docify::embed
already has a ignore
(for the opposite, you have docify::embed_run!
).
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.
It is about compiling test snippet not running it.
docify::embed
still compiles the snippet, and since we use the trick with bash!
macro (which is inaccessible in doc context), compilation would fail.
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.
Adding on top of what @michalkucharczyk said, docify::embed in context of markdown will use rust
lang instead of ignore
, which will make the sample a doc test. It might insert ignore
accordingly for general public/crate-level docs from .rs
files (which I haven't tested), so this can be considered a bug. Also, embedding in markdown files can not use embed_run
. I tried that previously and generating the readme fails with an error at compile time.
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.
Also, adding something like below in the README (to disable the doc test), will disable the embedding:
\`\`\`ignore
<!-- docify::embed(file_path, name_of_the_export) -->
\`\`\`
@@ -28,6 +31,53 @@ const DUMMY_PATH: &str = "fake-runtime-path"; | |||
|
|||
const OUTPUT_FILE: &str = "/tmp/chain_spec_builder.test_output_file.json"; | |||
|
|||
const RUNTIME_PATH: &str = unwrap_option_str(substrate_test_runtime::WASM_BINARY_PATH); |
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.
Follow-up:
there is some code in multiple places in polkadot-sdk that reads the cargo metadata, finds the target dir, and from there, tries to find the wasm path.
If we have this new const exported by substrate-wasm-builder
, it can likely simplify that code.
Example from my code:
cc @pepoviola and @pgherveou I think I have seen this in your recent PRs.
#[docify::export] | ||
fn cmd_display_preset() -> String { | ||
bash!( | ||
chain-spec-builder display-preset -r $RUNTIME_PATH -p "staging" |
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.
How does $RUNTIME_PATH
get resolved here?
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.
templates/parachain/README.md
Outdated
|
||
```sh | ||
cargo build --release | ||
cargo build -p parachain-template-runtime --release |
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.
cargo build -p parachain-template-runtime --release | |
cargo build --release |
Right? it should be the same.
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.
just nit picking in the overall direction that cargo build
should just build the runtime.
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.
Done 51c1814.
templates/parachain/README.md
Outdated
|
||
```sh | ||
cargo install --path node | ||
polkadot-omni-node --chain <path/to/chain_spec.json> |
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.
The OmniNode setup here should not demonstrate a broken command, instead it should:
- explain that a parachain cannot progress without relay chain, which we can only setup with ZN
- use
--dev-block-time --tmp
here.
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.
Done: 51c1814
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] |
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.
@pepoviola PTAL 🙏
templates/parachain/README.md
Outdated
|
||
```sh | ||
docker build . -t polkadot-sdk-parachain-template | ||
chain-spec-builder create --relay-chain "rococo-local" --para-id 1000 --runtime \ | ||
<target/release/wbuild/path/to/minimal-template-runtime.wasm> named-preset development |
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.
<target/release/wbuild/path/to/minimal-template-runtime.wasm> named-preset development | |
./target/release/wbuild/parachain-template-runtime/parachain_template_runtime.wasm named-preset development |
This path can be corrected to what will be its true value, as it is predictable
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.
Done: 51c1814
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
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.
LGTM post addressing open comments and getting the CI to be green.
This is a great work, thanks @iulianbarbu
I think there has been a lot of learning here: how to properly do good READMEs that are correct, let's learn the recipe, and then apply them to all the rest of OmniTools!
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
All in all the PR is pending on two outstanding CI issues (observed at least):
|
Signed-off-by: Iulian Barbu <[email protected]>
Signed-off-by: Iulian Barbu <[email protected]>
2a84917
Description
Closes #5940
Integration
Node devs that rely on templates' nodes binaries for minimal or parachain would need to follow the updated templates' README.mds again to find how to build the nodes' binaries.
Review Notes
Conditional compilation of virtual workspaces would compile the
members
list as if we passed--workspace
flag tocargo build
, except when adding adefault-members
list which will be used for any cargo command executed in the virtual workspace root. To build the full members list needs passing--workspace
flag.Other options investigated:
node
crate by defining a feature in thenode
crate, but it feels too complex since all code needs to be feature guarded. I haven't tried it but technically speaking it might work. I think though it looks awkward and my opinion is that the alternative is better.node
crate and then not passing the feature to cargo build results in ignoring thenode
crate)--package minimal-template-node
flag to thecargo build
command. This has the disadvantage of not allowing IDEs based on rust analyzer to index/compile the node crate.My conclusion is that any option would require two commands to build the template, one with the node and one without, and both must be included in the README or templates usage documentation. If it comes which ones to pick I am in favor of the
default-members
option, which requires minimal intervention and expresses how cargo commands are executed on top of the workspace members, and what's left out from regular usage.Testing
Testing was conducted as described bellow:
minimal-template-node
,parachain-template-node
andpolkadot-omni-node
. Things work as expected.paritytech-stg
org to test the end result of theCargo.toml
changes.