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

Node crate to folder #1632

Merged
merged 18 commits into from
Dec 15, 2023
Merged

Node crate to folder #1632

merged 18 commits into from
Dec 15, 2023

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Nov 29, 2023

Description

Move the node and its dependencies to a node folder

Fixes #1278

Changes and Descriptions

  • res src build.rs to node folder
  • Node using workspace dependencies
  • Some feature compilation fixes
  • Update scripts to now compile the node with cargo build -p centrifuge-chain
  • Modify scripts/tests.sh into scripts/cargo_split.sh to filter by feature and reuse compilation artifacts, improving the speed. It takes around 20 min to compile all crates for one feature in my M1.
  • Add subalfred target to ci/run-check.sh for a feature CI job checking this

Current issue (when moving the node) SOLVED

When you compile the workspace, the same crate dependency built is used for different crates of the workspace. If different crates use the same dependency with different features, the first version in the compiling process is used for both. This leads to feature problems, such as the compiler complaining about missing features when the feature is actually correctly set in the crate.

When compiling the node along the workspace crate, all crates use dependencies that at least contain the features they need (probably because its dependencies are compiled first). Nevertheless, when moving the node out, the compiling order changes and causes some crates to use some dependencies with some features missing.

A simple cargo check -F runtime-benchmarks fails because some crate uses a previous artifact that was built without runtime-benchmarks even when in its Cargo.toml, the feature is correctly set.

@lemunozm lemunozm added I3-annoyance The code behaves as expected, but "expected" is an issue. dependencies Pull requests that update a dependency file. I11-cleaning No mandatory issue that leave the repo more readable/organized labels Nov 29, 2023
@lemunozm lemunozm self-assigned this Nov 29, 2023
Copy link
Contributor Author

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

Relevant points

ci/run-check.sh Outdated Show resolved Hide resolved
ci/run-check.sh Outdated Show resolved Hide resolved
Comment on lines +20 to +23
[package.metadata.wasm-pack.profile.release]
# `wasm-opt` has some problems on linux, see
# https:/rustwasm/wasm-pack/issues/781 etc.
wasm-opt = false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does anyone know what was exactly the issue to check if it now works removing this? From the linked issue, it seems fixed, but I am not sure how to check it or evaluate it

@@ -1,30 +0,0 @@
[package]
Copy link
Contributor Author

@lemunozm lemunozm Nov 29, 2023

Choose a reason for hiding this comment

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

AFAIK, this module is deprecated and can be removed

@@ -66,6 +41,7 @@ members = [
"pallets/rewards",
"runtime/altair",
"runtime/centrifuge",
"runtime/development",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can not tell why, but you can compile development even if it is not on the list. Anyways, adding it here for correctness

@lemunozm lemunozm added the Q5-hard Can be done by an experienced coder with a good knowledge of the codebase. label Dec 11, 2023
@lemunozm lemunozm marked this pull request as ready for review December 11, 2023 12:28
node/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

Overall LGTM but I think the root Cargo.toml was emptied too much 😅

node/Cargo.toml Outdated Show resolved Hide resolved
node/Cargo.toml Show resolved Hide resolved
node/Cargo.toml Outdated Show resolved Hide resolved
pallets/liquidity-pools/Cargo.toml Show resolved Hide resolved
Comment on lines +1 to +5
#!/usr/bin/env bash

# Usage
# ./scripts/tests.sh check|test "-F=feature1,feature2,..." <--no-run>

Copy link
Contributor

@wischli wischli Dec 12, 2023

Choose a reason for hiding this comment

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

The comment is off, should refer to cargo_split.sh instead of tests.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was named previously so, but now you can execute any cargo <command>. That's why I changed the name to another more generic.

Thinking now that maybe even already exists such cargo tool 🤔

Cargo.toml Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
@lemunozm
Copy link
Contributor Author

Seems the docker build command is failing. Could it be related to the last addition of #1646 ?

Tested and "it works on my machine"

@lemunozm
Copy link
Contributor Author

lemunozm commented Dec 13, 2023

As a test, I've reverted the already merged #1646, and now it works again.

I'm quite lost, any suggestion @gpmayorga @wischli

The CI job error is: https:/centrifuge/centrifuge-chain/actions/runs/7188961287/job/19579621674

Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

There are a few outdated code paths which want to pull chain specs from the root /res not the moved /node/res:

  • ./docker/docker-compose-local-chain.yml
  • ./docker/docker-compose-local-relay.yml
  • ./scripts/run_collator.sh

@@ -20,8 +20,7 @@ FROM --platform=linux/amd64 docker.io/paritytech/ci-linux:production as builder
WORKDIR /centrifuge-chain
ARG FEATURES=""
RUN FEATURES=$(echo ${FEATURES} | tr -d '"') \
cargo build --locked --release --features=${FEATURES}

cargo build -p centrifuge-chain --locked --release --features=${FEATURES}
Copy link
Contributor

Choose a reason for hiding this comment

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

@lemunozm Can you try reverting the revert and removing the -p centrifuge-chain here? I have no clue how the pipeline change affects this PR, so this attempt is out of desperation.

Suggested change
cargo build -p centrifuge-chain --locked --release --features=${FEATURES}
cargo build --locked --release --features=${FEATURES}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try!

BTW, Thanks for notifying the above files 🙌🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just playing around with the above command, I'll try a cargo update. Maybe the --locked param is what is hitting us here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested everything and everything failed 🥲. Suuuper weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested locally and also fails.

This seems to be the issue: https://stackoverflow.com/questions/74643818/docker-buildx-gives-exit-code-137-with-cargo

Copy link
Contributor

@wischli wischli Dec 14, 2023

Choose a reason for hiding this comment

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

Tested locally and also fails.

This seems to be the issue: https://stackoverflow.com/questions/74643818/docker-buildx-gives-exit-code-137-with-cargo

IMO, the CI issue and Apple M1 docker build failures are unrelated. AFAIK, we cannot build our docker image locally on M1.

@lemunozm I deleted all cache related to this PR and re-ran the docker build manually in the actions and it succeeded 🎉 https:/centrifuge/centrifuge-chain/actions/runs/7206286656 Now re-scheduling the failed CI jobs here and hoping for deterministic behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uooo! Cool!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then, I'm going to revert the cargo update done and adding again -p centrifuge-chain

Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

Super happy CI is finally bending the knee. Let's get this merged ASAP!

@lemunozm
Copy link
Contributor Author

Thanks so much for all your help on this last issue @wischli 🙏🏻

@lemunozm lemunozm enabled auto-merge (squash) December 14, 2023 15:58
@lemunozm
Copy link
Contributor Author

@mustermeiszer @NunoAlexandre I think we need an approval from any of you 🙏🏻

Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

I disagree with moving the specs into the node folder. But no blocker.

@lemunozm
Copy link
Contributor Author

Why not? Do they not belong to the node? Actually, those files are only referenced from the node crate.

@lemunozm lemunozm merged commit 1d1bdb7 into main Dec 15, 2023
11 checks passed
@lemunozm lemunozm deleted the node-to-crate branch December 15, 2023 10:17
@mustermeiszer
Copy link
Collaborator

Why not? Do they not belong to the node? Actually, those files are only referenced from the node crate.

The spec is general for our chain. It should be usable by any node in theory or by any project without forcing them to depend in the node itself.

@lemunozm
Copy link
Contributor Author

Ok, that makes sense!

@wischli
Copy link
Contributor

wischli commented Dec 15, 2023

I disagree with moving the specs into the node folder. But no blocker.

I was thinking about this as well. I know at least two projects, which also moved the specs into the node directory and didn't raise this concern for that reason. But I definitely agree with out point that specs and the client are independent.

@lemunozm
Copy link
Contributor Author

Thanks for sharing the research!

@lemunozm
Copy link
Contributor Author

Maybe for now, we can keep it until we find the need to move this out (?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file. I3-annoyance The code behaves as expected, but "expected" is an issue. I11-cleaning No mandatory issue that leave the repo more readable/organized Q5-hard Can be done by an experienced coder with a good knowledge of the codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

node crate under its own folder
5 participants