Skip to content

Commit

Permalink
feat(libp2p): Optional async std libp2p & debug profile (#1454)
Browse files Browse the repository at this point in the history
* feat: Make an async-std optional

* build: Profile selection based on label

---------

Co-authored-by: Anatoly Laskaris <github_me@nahsi.dev>
  • Loading branch information
gurinderu and nahsi committed Feb 13, 2023
1 parent 6bdad82 commit 1aab9f7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,22 @@ jobs:
repository: fluencelabs/rust-peer
ref: ${{ inputs.ref }}

- name: Get PR labels
id: labels
uses: joerick/pr-labels-action@v1.0.7

- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set profile
id: profile
run: |
if [[ -n "$GITHUB_PR_LABEL_PROFILING" ]]; then
echo "profile=profiling" >> $GITHUB_OUTPUT
else
echo "profile=release" >> $GITHUB_OUTPUT
fi
- name: Set dependencies
if: inputs.cargo-dependencies != ''
uses: fluencelabs/github-actions/cargo-set-dependency@main
Expand All @@ -59,11 +72,11 @@ jobs:
publish: false

- name: Run cargo build
run: cargo build --release -p particle-node
run: cargo build --profile ${{ steps.profile.outputs.profile }} -p particle-node

- name: Calculate SHA256
id: sha
working-directory: ./target/release
working-directory: ./target/${{ steps.profile.outputs.profile }}
run: |
# Calculate sha256
du -hs particle-node
Expand All @@ -75,7 +88,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: rust-peer
path: target/release/particle-node
path: target/${{ steps.profile.outputs.profile }}/particle-node

container:
needs: build
Expand Down
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,9 @@ debug-assertions = false
strip = true
lto = false
codegen-units = 1 # Reduce number of codegen units to increase optimizations

[profile.profiling]
inherits = "release"
debug = true
strip = false
lto = false
6 changes: 4 additions & 2 deletions crates/libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 2 additions & 0 deletions crates/libp2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ mod macros;
pub mod random_multiaddr;
mod random_peer_id;
mod serde;
#[cfg(feature = "async-std")]
mod transport;
pub mod types;

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
Expand Down
2 changes: 1 addition & 1 deletion crates/server-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit 1aab9f7

Please sign in to comment.