From 61b0e1c5f9afc7713e0bb9310d076e99b0760e3a Mon Sep 17 00:00:00 2001 From: Rob Date: Tue, 26 Mar 2024 16:17:44 -0400 Subject: [PATCH] fix hotshot-testing flag --- .github/workflows/build-and-test.yml | 4 ++-- crates/examples/Cargo.toml | 4 ++-- crates/examples/infra/mod.rs | 1 + .../src/traits/networking/libp2p_network.rs | 6 ++++-- .../src/traits/networking/push_cdn_network.rs | 20 +++++++++++-------- justfile | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a85d82d567..da8848c48b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -51,7 +51,7 @@ jobs: RUST_BACKTRACE: full - name: Build examples in release mode - run: just ${{ matrix.just_variants }} build_release --examples --package hotshot-examples --no-default-features --features="docs,doc-images" + run: just ${{ matrix.just_variants }} build_release --examples --package hotshot-examples --no-default-features - name: Upload Binaries uses: actions/upload-artifact@v4 @@ -89,7 +89,7 @@ jobs: prefix-key: arm-${{ matrix.just_variants }} - name: Build examples in release mode - run: just ${{ matrix.just_variants }} build_release --examples --package hotshot-examples --no-default-features --features="docs,doc-images" + run: just ${{ matrix.just_variants }} build_release --examples --package hotshot-examples --no-default-features - name: Upload Binaries uses: actions/upload-artifact@v4 diff --git a/crates/examples/Cargo.toml b/crates/examples/Cargo.toml index 0e5d5e48b1..e4c8b1749a 100644 --- a/crates/examples/Cargo.toml +++ b/crates/examples/Cargo.toml @@ -8,7 +8,7 @@ version = { workspace = true } rust-version = "1.65.0" [features] -default = ["docs", "doc-images"] +default = ["docs", "doc-images", "hotshot-testing"] gpu-vid = ["hotshot-task-impls/gpu-vid"] # Features required for binaries @@ -17,7 +17,7 @@ bin-orchestrator = ["clap"] # Build the extended documentation docs = [] doc-images = [] -hotshot-testing = [] +hotshot-testing = ["hotshot/hotshot-testing"] randomized-leader-election = [] # libp2p diff --git a/crates/examples/infra/mod.rs b/crates/examples/infra/mod.rs index 405fe9642b..2af3c172f3 100644 --- a/crates/examples/infra/mod.rs +++ b/crates/examples/infra/mod.rs @@ -444,6 +444,7 @@ async fn libp2p_network_from_config( // NOTE: this introduces an invariant that the keys are assigned using this indexed // function all_keys, + #[cfg(feature = "hotshot-testing")] None, da_keys.clone(), da_keys.contains(&pub_key), diff --git a/crates/hotshot/src/traits/networking/libp2p_network.rs b/crates/hotshot/src/traits/networking/libp2p_network.rs index 5358d3a30e..b20244840c 100644 --- a/crates/hotshot/src/traits/networking/libp2p_network.rs +++ b/crates/hotshot/src/traits/networking/libp2p_network.rs @@ -16,6 +16,8 @@ use futures::{ future::{join_all, Either}, FutureExt, StreamExt, }; +#[cfg(feature = "hotshot-testing")] +use hotshot_types::traits::network::NetworkReliability; use hotshot_types::{ boxed_sync, constants::{Version01, LOOK_AHEAD, STATIC_VER_0_1, VERSION_0_1}, @@ -33,7 +35,7 @@ use hotshot_types::{ #[cfg(feature = "hotshot-testing")] use hotshot_types::{ message::{Message, MessageKind}, - traits::network::{NetworkReliability, TestableNetworkingImplementation, ViewMessage}, + traits::network::{TestableNetworkingImplementation, ViewMessage}, }; use libp2p_identity::PeerId; #[cfg(feature = "hotshot-testing")] @@ -332,7 +334,7 @@ impl Libp2pNetwork { id: usize, // HACK committee_pks: BTreeSet, - reliability_config: Option>, + #[cfg(feature = "hotshot-testing")] reliability_config: Option>, da_pks: BTreeSet, is_da: bool, ) -> Result, NetworkError> { diff --git a/crates/hotshot/src/traits/networking/push_cdn_network.rs b/crates/hotshot/src/traits/networking/push_cdn_network.rs index fcc254e511..5aa729fa82 100644 --- a/crates/hotshot/src/traits/networking/push_cdn_network.rs +++ b/crates/hotshot/src/traits/networking/push_cdn_network.rs @@ -1,13 +1,14 @@ use super::NetworkError; +#[cfg(feature = "hotshot-testing")] use async_compatibility_layer::art::{async_block_on, async_spawn}; use async_compatibility_layer::channel::UnboundedSendError; use async_trait::async_trait; use bincode::config::Options; +use cdn_broker::reexports::connection::protocols::Tcp; use cdn_broker::reexports::def::RunDef; use cdn_broker::reexports::discovery::{Embedded, Redis}; -use cdn_broker::{ - reexports::connection::protocols::Tcp, Broker, Config, ConfigBuilder as BrokerConfigBuilder, -}; +#[cfg(feature = "hotshot-testing")] +use cdn_broker::{Broker, Config, ConfigBuilder as BrokerConfigBuilder}; use cdn_client::{ reexports::{ connection::protocols::Quic, @@ -16,28 +17,31 @@ use cdn_client::{ }, Client, ConfigBuilder as ClientConfigBuilder, }; +#[cfg(feature = "hotshot-testing")] use cdn_marshal::{ConfigBuilder as MarshalConfigBuilder, Marshal}; #[cfg(feature = "hotshot-testing")] -use hotshot_types::traits::network::TestableNetworkingImplementation; +use hotshot_types::traits::network::{NetworkReliability, TestableNetworkingImplementation}; use hotshot_types::{ boxed_sync, constants::{Version01, VERSION_0_1}, data::ViewNumber, message::Message, traits::{ - network::{ - ConnectedNetwork, ConsensusIntentEvent, NetworkReliability, PushCdnNetworkError, - }, + network::{ConnectedNetwork, ConsensusIntentEvent, PushCdnNetworkError}, node_implementation::NodeType, signature_key::SignatureKey, }, utils::bincode_opts, BoxSyncFuture, }; +#[cfg(feature = "hotshot-testing")] use rand::rngs::StdRng; +#[cfg(feature = "hotshot-testing")] use rand::{RngCore, SeedableRng}; +use std::collections::BTreeSet; use std::marker::PhantomData; -use std::{collections::BTreeSet, path::Path, sync::Arc, time::Duration}; +#[cfg(feature = "hotshot-testing")] +use std::{path::Path, sync::Arc, time::Duration}; use tracing::{error, warn}; use versioned_binary_serialization::{ version::{StaticVersionType, Version}, diff --git a/justfile b/justfile index f1c9f665c4..02f3ffcee5 100644 --- a/justfile +++ b/justfile @@ -39,7 +39,7 @@ build_release *ARGS: cargo build --profile=release {{ARGS}} example *ARGS: - cargo run --profile=release-lto --example {{ARGS}} + cargo run --profile=release-lto --package hotshot-examples --no-default-features --example {{ARGS}} test *ARGS: echo Testing {{ARGS}}