From 9467c4f5958ff9f5daf308337d479bd42127bd42 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 8 Feb 2023 14:53:45 +0300 Subject: [PATCH 1/8] feat: Make a async-std optional --- crates/libp2p/Cargo.toml | 6 ++++-- crates/libp2p/src/lib.rs | 2 ++ crates/server-config/Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/libp2p/Cargo.toml b/crates/libp2p/Cargo.toml index 0fb8d0fcb8..c5b75f7da3 100644 --- a/crates/libp2p/Cargo.toml +++ b/crates/libp2p/Cargo.toml @@ -4,14 +4,16 @@ version = "0.2.0" authors = ["Fluence Labs"] edition = "2021" +[features] +async-std = ["dep:async-std"] + [dependencies] libp2p = { workspace = true } libp2p-noise = { workspace = true } multihash = { version = "0.16.3", features = ["serde-codec"] } futures = { workspace = true } futures-util = "0.3.26" -async-std = { workspace = true } - +async-std = { workspace = true, optional = true } serde = { version = "1.0.152", features = ["derive"] } serde_json = { workspace = true } bs58 = { workspace = true } diff --git a/crates/libp2p/src/lib.rs b/crates/libp2p/src/lib.rs index 853753d43c..8194751da1 100644 --- a/crates/libp2p/src/lib.rs +++ b/crates/libp2p/src/lib.rs @@ -31,6 +31,7 @@ mod macros; pub mod random_multiaddr; mod random_peer_id; mod serde; +#[cfg(feature = "async-std")] mod transport; pub mod types; @@ -38,6 +39,7 @@ pub use self::serde::*; pub use connected_point::*; pub use macros::*; pub use random_peer_id::RandomPeerId; +#[cfg(feature = "async-std")] pub use transport::{build_memory_transport, build_transport, Transport}; // libp2p reexports diff --git a/crates/server-config/Cargo.toml b/crates/server-config/Cargo.toml index ee153225c2..4b09b3e01a 100644 --- a/crates/server-config/Cargo.toml +++ b/crates/server-config/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" config-utils = { workspace = true } fs-utils = { workspace = true } particle-protocol = { workspace = true } -fluence-libp2p = { workspace = true } +fluence-libp2p = { workspace = true, features=["async-std"] } air-interpreter-fs = { workspace = true } peer-metrics = { workspace = true } From 11df3a0504750b844ee1081d8bc98ad8a8b0137b Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 10 Feb 2023 15:33:59 +0300 Subject: [PATCH 2/8] build: debug info --- .github/workflows/snapshot.yml | 6 +++--- Cargo.toml | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index eb09e424ff..91d736046b 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -59,11 +59,11 @@ jobs: publish: false - name: Run cargo build - run: cargo build --release -p particle-node + run: cargo build --profile release-with-debug -p particle-node - name: Calculate SHA256 id: sha - working-directory: ./target/release + working-directory: ./target/release-with-debug run: | # Calculate sha256 du -hs particle-node @@ -75,7 +75,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: rust-peer - path: target/release/particle-node + path: target/release-with-debug/particle-node container: needs: build diff --git a/Cargo.toml b/Cargo.toml index b1efd7f205..e5a9027c89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,3 +134,9 @@ debug-assertions = false strip = true lto = false codegen-units = 1 # Reduce number of codegen units to increase optimizations + +[profile.release-with-debug] +inherits = "release" +debug = true +strip = false +lto = false From a09f386641abae0d0c2df6274d2648735c4d64ad Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Feb 2023 12:58:34 +0300 Subject: [PATCH 3/8] Profile selection based on label --- .github/workflows/snapshot.yml | 18 +++++++++++++++--- Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 91d736046b..4c1b91b4c7 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -41,6 +41,16 @@ jobs: - name: Setup Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Set current profile + run: | + echo "PROFILE=release" >> $GITHUB_ENV + if: !contains( github.event.pull_request.labels.*.name, 'profiling') + + - name: Set current profile + run: | + echo "PROFILE=profiling" >> $GITHUB_ENV + if: contains( github.event.pull_request.labels.*.name, 'profiling') + - name: Set dependencies if: inputs.cargo-dependencies != '' uses: fluencelabs/github-actions/cargo-set-dependency@main @@ -59,11 +69,11 @@ jobs: publish: false - name: Run cargo build - run: cargo build --profile release-with-debug -p particle-node + run: cargo build --profile ${{ profile }} -p particle-node - name: Calculate SHA256 id: sha - working-directory: ./target/release-with-debug + working-directory: ./target/${{ profile }} run: | # Calculate sha256 du -hs particle-node @@ -71,11 +81,13 @@ jobs: sha=($(sha256sum particle-node)) echo "sha256=${sha}" >> $GITHUB_OUTPUT + - name: Upload rust-peer binary uses: actions/upload-artifact@v3 with: name: rust-peer - path: target/release-with-debug/particle-node + path: target/${{ profile }}/particle-node + container: needs: build diff --git a/Cargo.toml b/Cargo.toml index e5a9027c89..58c1ba4ede 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,7 +135,7 @@ strip = true lto = false codegen-units = 1 # Reduce number of codegen units to increase optimizations -[profile.release-with-debug] +[profile.profiling] inherits = "release" debug = true strip = false From 5c0534132c14b477ba5a54ab4bf0b7fe4201a1c3 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Feb 2023 13:00:53 +0300 Subject: [PATCH 4/8] Profile selection based on label --- .github/workflows/snapshot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 4c1b91b4c7..7047524cad 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -44,12 +44,12 @@ jobs: - name: Set current profile run: | echo "PROFILE=release" >> $GITHUB_ENV - if: !contains( github.event.pull_request.labels.*.name, 'profiling') + if: {{ !contains( github.event.pull_request.labels.*.name, 'profiling') }} - name: Set current profile run: | echo "PROFILE=profiling" >> $GITHUB_ENV - if: contains( github.event.pull_request.labels.*.name, 'profiling') + if: {{ contains( github.event.pull_request.labels.*.name, 'profiling') }} - name: Set dependencies if: inputs.cargo-dependencies != '' From 772df48a3c7b96e78e2cb48b1f38945f78742a54 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 13 Feb 2023 12:17:40 +0200 Subject: [PATCH 5/8] Use actions to get pr labels --- .github/workflows/snapshot.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 7047524cad..ea9f20adb2 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -38,18 +38,21 @@ jobs: repository: fluencelabs/rust-peer ref: ${{ inputs.ref }} + - name: Get PR labels + id: labels + uses: joerick/pr-labels-action@v1 + - name: Setup Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Set current profile - run: | - echo "PROFILE=release" >> $GITHUB_ENV - if: {{ !contains( github.event.pull_request.labels.*.name, 'profiling') }} - - - name: Set current profile + - name: Set profile run: | - echo "PROFILE=profiling" >> $GITHUB_ENV - if: {{ contains( github.event.pull_request.labels.*.name, 'profiling') }} + bin/run_normal_tests + if [[ -n "$GITHUB_PR_LABEL_PROFILING" ]]; then + echo "profile=profiling" >> $GITHUB_OUTPUTS + else + echo "profile=release" >> $GITHUB_OUTPUTS + fi - name: Set dependencies if: inputs.cargo-dependencies != '' @@ -69,11 +72,11 @@ jobs: publish: false - name: Run cargo build - run: cargo build --profile ${{ profile }} -p particle-node + run: cargo build --profile ${{ steps.labels.outputs.profile }} -p particle-node - name: Calculate SHA256 id: sha - working-directory: ./target/${{ profile }} + working-directory: ./target/${{ steps.labels.outputs.profile }} run: | # Calculate sha256 du -hs particle-node @@ -81,13 +84,11 @@ jobs: sha=($(sha256sum particle-node)) echo "sha256=${sha}" >> $GITHUB_OUTPUT - - name: Upload rust-peer binary uses: actions/upload-artifact@v3 with: name: rust-peer - path: target/${{ profile }}/particle-node - + path: target/${{ steps.labels.outputs.profile }}/particle-node container: needs: build From a77e1677943118a367301a4e54034f966492df4a Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 13 Feb 2023 12:19:11 +0200 Subject: [PATCH 6/8] Fix labels action version --- .github/workflows/snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index ea9f20adb2..d2a215c2f3 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -40,7 +40,7 @@ jobs: - name: Get PR labels id: labels - uses: joerick/pr-labels-action@v1 + uses: joerick/pr-labels-action@v1.0.7 - name: Setup Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 From 1605d729f435018220839bbb53b25b41b1605ff1 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 13 Feb 2023 12:22:10 +0200 Subject: [PATCH 7/8] Fix --- .github/workflows/snapshot.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index d2a215c2f3..f5eee8727e 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -46,8 +46,8 @@ jobs: uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Set profile + id: profile run: | - bin/run_normal_tests if [[ -n "$GITHUB_PR_LABEL_PROFILING" ]]; then echo "profile=profiling" >> $GITHUB_OUTPUTS else @@ -72,11 +72,11 @@ jobs: publish: false - name: Run cargo build - run: cargo build --profile ${{ steps.labels.outputs.profile }} -p particle-node + run: cargo build --profile ${{ steps.profile.outputs.profile }} -p particle-node - name: Calculate SHA256 id: sha - working-directory: ./target/${{ steps.labels.outputs.profile }} + working-directory: ./target/${{ steps.profile.outputs.profile }} run: | # Calculate sha256 du -hs particle-node @@ -88,7 +88,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: rust-peer - path: target/${{ steps.labels.outputs.profile }}/particle-node + path: target/${{ steps.profile.outputs.profile }}/particle-node container: needs: build From 94a63d5eaa404ad02403a313828d4b98f5858ab3 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 13 Feb 2023 12:26:24 +0200 Subject: [PATCH 8/8] Fix --- .github/workflows/snapshot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index f5eee8727e..6541d74e08 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -49,9 +49,9 @@ jobs: id: profile run: | if [[ -n "$GITHUB_PR_LABEL_PROFILING" ]]; then - echo "profile=profiling" >> $GITHUB_OUTPUTS + echo "profile=profiling" >> $GITHUB_OUTPUT else - echo "profile=release" >> $GITHUB_OUTPUTS + echo "profile=release" >> $GITHUB_OUTPUT fi - name: Set dependencies