-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-4231: Extract chain bootstrap to a separate crate (#1699)
# Description This final PR achieves the goal of removing the `aleph-runtime` dependency from `aleph-node`. A new crate `chain-bootstraper` is made from the current chain bootstrap logic in `aleph-node`. The dependencies in `aleph-node` should be clearer now: * `aleph-node` does not compile native runtime anymore via default features build. * `chain-bootstrapper` does compile both native and wasm runtime during build. The amount of packages that node compiles is about 150 less than it was before. Depending on the machine, It's up to 40% compilation speedup for a`aleph-node` binary. Here's local build, clean repo, on my laptop: After change - `aleph-node` and `chain-bootstrapper` builds in the similar time. ``` time ./scripts/run_nodes.sh -v 6 2024-04-22 13:37:54:233 Starting ./scripts/run_nodes.sh 2024-04-22 13:37:54:234 Creating base path ./run-nodes-local if it does not exist 2024-04-22 13:37:54:236 Stopping all current node processes 2024-04-22 13:37:54:241 No aleph-node processes found. 2024-04-22 13:37:54:242 Building testing aleph-node binary (short session) and chainspec-generator binary. Compiling proc-macro2 v1.0.81 [...] Finished release [optimized] target(s) in 9m 02s [...] Finished release [optimized] target(s) in 9m 31s [...] ________________________________________________________ Executed in 18.59 mins fish external usr time 119.30 mins 874.00 micros 119.30 mins sys time 5.67 mins 0.00 micros 5.67 mins ``` Before change - note though the overall time is faster than before: ``` marcin@marcin-Latitude-3520 ~/g/aleph-node-3 (main)> time ./scripts/run_nodes.sh -v 6 (base) [...] Finished release [optimized] target(s) in 16m 44s [...] Executed in 16.77 mins fish external usr time 107.24 mins 0.00 micros 107.24 mins sys time 5.32 mins 791.00 micros 5.32 mins ``` This is because of `polkadot-sdk` crates architecture - we still need to compile most of the crates in both node and bootstrapper. There's small optimization in this PR to not build three polkadot-sdk crates with default features, ie to disable `rocks-db` build when `chain-bootstrapper` is built. In Ci though, compilation should be faster as we can parallelize `aleph-node` and `chain-bootstrapper` build, which this PR achieves so. Most of the changes are workflows anyway. ## Type of change Please delete options that are not relevant. - Breaking change (fix or feature that would cause existing functionality to not work as expected) # Checklist: * Deploy to devnet: - will be tested after merge to `main`. * Nightly feature-gated builds: https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/8828449304 * Nightly pipeline e2e tests on featurenet: - FEs engine require small change, and will be tested after merge to `main`. * Nightly pipeline integration tests: https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/8828450804 * Nightly pipeline logic e2e tests: https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/8828452203 * Nightly pipeline normal session e2e tests: https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/8828453925 * On main push workflow (edited so it's no-op): https://github.com/Cardinal-Cryptography/aleph-node/actions/runs/8828493822
- Loading branch information
1 parent
1236343
commit ee6414a
Showing
40 changed files
with
512 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
**/target | ||
target | ||
!target/release/aleph-node | ||
!target/release/chain-bootstrapper | ||
!target/production/chain-bootstrapper | ||
!target/production/aleph-node | ||
!bin/cliain/target/release/cliain | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
# This workflow builds chain-bootstrapper binary, dedicated fer generating chainspecs for | ||
# test and dev chains | ||
name: Build chain-bootstrapper | ||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: 'git ref: hash, branch, tag to build chain-bootstrapper binary from' | ||
type: string | ||
required: true | ||
production: | ||
description: 'set to true to use production profile' | ||
type: boolean | ||
required: true | ||
|
||
jobs: | ||
main: | ||
name: Build chain-bootstrapper | ||
runs-on: [self-hosted, Linux, X64, large] | ||
env: | ||
RUST_BACKTRACE: full | ||
RUSTC_WRAPPER: sccache | ||
CARGO_FOLDER: ${{ inputs.production == true && 'production' || 'release' }} | ||
ARTIFACT_NAME_SUFFIX: ${{ inputs.production == true && 'release' || 'test' }} | ||
steps: | ||
- name: Checkout aleph-node source code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Call action get-ref-properties | ||
id: get-ref-properties | ||
uses: Cardinal-Cryptography/github-actions/get-ref-properties@v6 | ||
|
||
- name: Install Rust toolchain | ||
uses: Cardinal-Cryptography/github-actions/install-rust-toolchain@v6 | ||
with: | ||
targets: wasm32-unknown-unknown | ||
|
||
- name: Build without production profile | ||
if: ${{ inputs.production != true }} | ||
run: | | ||
cargo build --release -p chain-bootstrapper \ | ||
--features "short_session enable_treasury_proposals" | ||
- name: Build with production profile | ||
if: ${{ inputs.production == true }} | ||
run: | | ||
cargo build --profile production -p chain-bootstrapper | ||
- name: Upload binary to GH Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: chain-bootstrapper-${{ env.ARTIFACT_NAME_SUFFIX }} | ||
path: target/${{ env.CARGO_FOLDER }}/chain-bootstrapper | ||
if-no-files-found: error | ||
retention-days: 7 | ||
|
||
- name: Build docker | ||
id: build-image | ||
run: | | ||
chmod +x target/${{ env.CARGO_FOLDER }}/chain-bootstrapper | ||
if [[ ${{ inputs.production }} == true ]]; then | ||
mkdir -p target/release | ||
mv target/production/chain-bootstrapper target/release/ | ||
fi | ||
docker build --tag chain-bootstrapper:latest -f ./bin/chain-bootstrapper/Dockerfile . | ||
docker save -o chain-bootstrapper.tar chain-bootstrapper:latest | ||
- name: Upload docker image to GH Artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: chain-bootstrapper-image-${{ env.ARTIFACT_NAME_SUFFIX }} | ||
path: chain-bootstrapper.tar | ||
if-no-files-found: error | ||
retention-days: 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.