diff --git a/Cargo.lock b/Cargo.lock index 55c82680c..9edcfedc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3049,7 +3049,7 @@ dependencies = [ [[package]] name = "hotshot" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-broadcast", @@ -3096,7 +3096,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "async-trait", "clap", @@ -3115,7 +3115,7 @@ dependencies = [ [[package]] name = "hotshot-example-types" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-broadcast", @@ -3148,7 +3148,7 @@ dependencies = [ [[package]] name = "hotshot-fakeapi" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-lock 2.8.0", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "hotshot-macros" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "derive_builder", "proc-macro2", @@ -3178,7 +3178,7 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-compatibility-layer", @@ -3267,7 +3267,7 @@ dependencies = [ [[package]] name = "hotshot-task" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-broadcast", @@ -3282,7 +3282,7 @@ dependencies = [ [[package]] name = "hotshot-task-impls" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-broadcast", @@ -3319,7 +3319,7 @@ dependencies = [ [[package]] name = "hotshot-testing" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-broadcast", @@ -3365,7 +3365,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "ark-bn254", @@ -4537,7 +4537,7 @@ dependencies = [ [[package]] name = "libp2p-networking" version = "0.5.69" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.69#b3796d6abea494780f6220845d729cb186a11f6a" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" dependencies = [ "anyhow", "async-compatibility-layer", diff --git a/Cargo.toml b/Cargo.toml index a1918326c..8fc4166fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,9 +75,9 @@ derivative = "2.2" derive_more = "0.99" either = "1.12" futures = "0.3" -hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.69" } -hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.69" } -hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.69" } +hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70" } +hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70" } +hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70" } itertools = "0.12.1" jf-merkle-tree = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [ "std", @@ -119,7 +119,7 @@ tokio-postgres = { version = "0.7", optional = true, default-features = false, f # Dependencies enabled by feature "testing". espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0", optional = true } -hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.69", optional = true } +hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70", optional = true } portpicker = { version = "0.1", optional = true } rand = { version = "0.8", optional = true } spin_sleep = { version = "1.2", optional = true } @@ -140,7 +140,7 @@ backtrace-on-stack-overflow = { version = "0.3", optional = true } clap = { version = "4.5", features = ["derive", "env"] } espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0" } generic-array = "0.14" -hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.69" } +hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70" } portpicker = "0.1" rand = "0.8" reqwest = "0.12.3" diff --git a/examples/simple-server.rs b/examples/simple-server.rs index fb82878fe..164ab054c 100644 --- a/examples/simple-server.rs +++ b/examples/simple-server.rs @@ -26,8 +26,8 @@ use hotshot::{ HotShotInitializer, MarketplaceConfig, Memberships, SystemContext, }; use hotshot_example_types::{ - auction_results_provider_types::TestAuctionResultsProvider, state_types::TestInstanceState, - storage_types::TestStorage, + auction_results_provider_types::TestAuctionResultsProvider, node_types::TestVersions, + state_types::TestInstanceState, storage_types::TestStorage, }; use hotshot_query_service::{ data_source, @@ -143,7 +143,7 @@ async fn main() -> Result<(), Error> { async fn init_consensus( data_sources: &[DataSource], -) -> Vec> { +) -> Vec> { let (pub_keys, priv_keys): (Vec<_>, Vec<_>) = (0..data_sources.len()) .map(|i| BLSPubKey::generated_from_seed_indexed([0; 32], i as u64)) .unzip(); @@ -270,9 +270,11 @@ async fn init_consensus( config, memberships, network, - HotShotInitializer::from_genesis(TestInstanceState {}) - .await - .unwrap(), + HotShotInitializer::from_genesis(TestInstanceState { + delay_config: Default::default(), + }) + .await + .unwrap(), ConsensusMetricsValue::new(&*data_source.populate_metrics()), storage, MarketplaceConfig { diff --git a/src/availability.rs b/src/availability.rs index 0b6e883dc..e4d58f3c6 100644 --- a/src/availability.rs +++ b/src/availability.rs @@ -861,8 +861,13 @@ mod test { ); // mock up some consensus data. - let leaf = - Leaf::::genesis(&TestValidatedState::default(), &TestInstanceState {}).await; + let leaf = Leaf::::genesis( + &TestValidatedState::default(), + &TestInstanceState { + delay_config: Default::default(), + }, + ) + .await; let block = BlockQueryData::new(leaf.block_header().clone(), MockPayload::genesis()); diff --git a/src/data_source.rs b/src/data_source.rs index 46051b27e..ac698266b 100644 --- a/src/data_source.rs +++ b/src/data_source.rs @@ -465,11 +465,18 @@ pub mod persistence_tests { // Mock up some consensus data. let mut qc = QuorumCertificate::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, + ) + .await; + let mut leaf = Leaf::::genesis( + &TestValidatedState::default(), + &TestInstanceState { + delay_config: Default::default(), + }, ) .await; - let mut leaf = - Leaf::::genesis(&TestValidatedState::default(), &TestInstanceState {}).await; // Increment the block number, to distinguish this block from the genesis block, which // already exists. leaf.block_header_mut().block_number += 1; @@ -513,11 +520,18 @@ pub mod persistence_tests { // Mock up some consensus data. let mut qc = QuorumCertificate::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, + ) + .await; + let mut leaf = Leaf::::genesis( + &TestValidatedState::default(), + &TestInstanceState { + delay_config: Default::default(), + }, ) .await; - let mut leaf = - Leaf::::genesis(&TestValidatedState::default(), &TestInstanceState {}).await; // Increment the block number, to distinguish this block from the genesis block, which // already exists. leaf.block_header_mut().block_number += 1; @@ -600,14 +614,18 @@ pub mod node_tests { let mut leaves = vec![ LeafQueryData::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await, ]; let mut blocks = vec![ BlockQueryData::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await, ]; @@ -746,7 +764,9 @@ pub mod node_tests { >::from_transactions( [mock_transaction(vec![i as u8 % 2])], &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await .unwrap(); @@ -764,7 +784,9 @@ pub mod node_tests { let mut leaf = LeafQueryData::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await; *leaf.leaf.block_header_mut() = header.clone(); @@ -820,7 +842,9 @@ pub mod node_tests { // Insert test data with VID common and a share. let leaf = LeafQueryData::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await; let common = VidCommonQueryData::new(leaf.header().clone(), disperse.common); diff --git a/src/data_source/fs.rs b/src/data_source/fs.rs index 907e88fc2..6d1ef2c09 100644 --- a/src/data_source/fs.rs +++ b/src/data_source/fs.rs @@ -99,6 +99,7 @@ use std::path::Path; /// # use hotshot_query_service::testing::mocks::{ /// # MockNodeImpl as AppNodeImpl, MockTypes as AppTypes, /// # }; +/// # use hotshot_example_types::node_types::TestVersions; /// # use std::path::Path; /// # use tide_disco::App; /// # use vbs::version::StaticVersionType; @@ -111,7 +112,7 @@ use std::path::Path; /// /// async fn init_server( /// storage_path: &Path, -/// hotshot: SystemContextHandle, +/// hotshot: SystemContextHandle, /// ) -> Result>, Error>, Error> { /// let mut loader = AtomicStoreLoader::create(storage_path, "my_app") // or `open` /// .map_err(Error::internal)?; diff --git a/src/data_source/metrics.rs b/src/data_source/metrics.rs index c29a6d0fe..1a91a7838 100644 --- a/src/data_source/metrics.rs +++ b/src/data_source/metrics.rs @@ -39,9 +39,10 @@ use async_trait::async_trait; /// # Error, /// # }; /// # use hotshot_types::consensus::ConsensusMetricsValue; +/// # use hotshot_example_types::node_types::TestVersions; /// # async fn doc() -> Result<(), hotshot_query_service::Error> { /// let data_source = MetricsDataSource::default(); -/// let hotshot = SystemContext::::init( +/// let hotshot = SystemContext::::init( /// # panic!(), panic!(), panic!(), panic!(), panic!(), panic!(), panic!(), /// ConsensusMetricsValue::new(&*data_source.populate_metrics()), panic!(), /// panic!(), diff --git a/src/data_source/sql.rs b/src/data_source/sql.rs index 335cde066..d25b97243 100644 --- a/src/data_source/sql.rs +++ b/src/data_source/sql.rs @@ -263,6 +263,7 @@ impl Config { /// # use hotshot_query_service::testing::mocks::{ /// # MockNodeImpl as AppNodeImpl, MockTypes as AppTypes, /// # }; +/// # use hotshot_example_types::node_types::TestVersions; /// # use tide_disco::App; /// # use vbs::version::StaticVersionType; /// struct AppState { @@ -272,7 +273,7 @@ impl Config { /// /// async fn init_server( /// config: Config, -/// hotshot: SystemContextHandle, +/// hotshot: SystemContextHandle, /// ) -> Result>, Error>, Error> { /// let mut hotshot_qs = config.connect(NoFetching).await.map_err(Error::internal)?; /// // Initialize storage for other modules, using `hotshot_qs` to access the database. @@ -444,7 +445,9 @@ mod test { // Insert test data with VID common but no share. let leaf = LeafQueryData::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await; let common = VidCommonQueryData::new(leaf.header().clone(), disperse.common); diff --git a/src/data_source/storage/sql.rs b/src/data_source/storage/sql.rs index 057cf90f4..5e741f56b 100644 --- a/src/data_source/storage/sql.rs +++ b/src/data_source/storage/sql.rs @@ -3341,7 +3341,9 @@ mod test { let mut storage = SqlStorage::connect(cfg).await.unwrap(); let mut leaf = LeafQueryData::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await; // insert some mock data @@ -3424,7 +3426,9 @@ mod test { let mut storage = SqlStorage::connect(db.config()).await.unwrap(); let mut leaf = LeafQueryData::::genesis( &TestValidatedState::default(), - &TestInstanceState {}, + &TestInstanceState { + delay_config: Default::default(), + }, ) .await; // insert some mock data diff --git a/src/lib.rs b/src/lib.rs index 1fb65e003..1b3491bc7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,7 @@ //! # use hotshot_query_service::testing::mocks::{ //! # MockNodeImpl as AppNodeImpl, MockTypes as AppTypes, //! # }; +//! # use hotshot_example_types::node_types::TestVersions; //! # use hotshot_types::consensus::ConsensusMetricsValue; //! # use std::path::Path; //! # async fn doc(storage_path: &std::path::Path) -> Result<(), hotshot_query_service::Error> { @@ -49,7 +50,7 @@ //! .map_err(Error::internal)?; //! //! // Create hotshot, giving it a handle to the status metrics. -//! let hotshot = SystemContext::::init( +//! let hotshot = SystemContext::::init( //! # panic!(), panic!(), panic!(), panic!(), panic!(), panic!(), panic!(), //! ConsensusMetricsValue::new(&*data_source.populate_metrics()), panic!(), //! panic!() @@ -102,8 +103,9 @@ //! # use hotshot_query_service::{data_source::FileSystemDataSource, Error, Options}; //! # use hotshot_query_service::fetching::provider::NoFetching; //! # use hotshot_query_service::testing::mocks::{MockBase, MockNodeImpl, MockTypes}; +//! # use hotshot_example_types::node_types::TestVersions; //! # use std::path::Path; -//! # async fn doc(storage_path: &Path, options: Options, hotshot: SystemContextHandle) -> Result<(), Error> { +//! # async fn doc(storage_path: &Path, options: Options, hotshot: SystemContextHandle) -> Result<(), Error> { //! use hotshot_query_service::run_standalone_service; //! //! let data_source = FileSystemDataSource::create(storage_path, NoFetching).await.map_err(Error::internal)?; @@ -431,7 +433,7 @@ use async_std::sync::{Arc, RwLock}; use futures::StreamExt; use hotshot::types::SystemContextHandle; use hotshot_types::traits::{ - node_implementation::{NodeImplementation, NodeType}, + node_implementation::{NodeImplementation, NodeType, Versions}, BlockPayload, }; use serde::{Deserialize, Serialize}; @@ -487,10 +489,16 @@ pub struct Options { } /// Run an instance of the HotShot Query service with no customization. -pub async fn run_standalone_service, D, Ver>( +pub async fn run_standalone_service< + Types: NodeType, + I: NodeImplementation, + D, + Ver, + V: Versions, +>( options: Options, data_source: D, - hotshot: SystemContextHandle, + hotshot: SystemContextHandle, bind_version: Ver, ) -> Result<(), Error> where @@ -714,8 +722,13 @@ mod test { .unwrap(); // Mock up some data and add a block to the store. - let leaf = - Leaf::::genesis(&TestValidatedState::default(), &TestInstanceState {}).await; + let leaf = Leaf::::genesis( + &TestValidatedState::default(), + &TestInstanceState { + delay_config: Default::default(), + }, + ) + .await; let block = BlockQueryData::new(leaf.block_header().clone(), MockPayload::genesis()); hotshot_qs.insert_block(block.clone()).await.unwrap(); diff --git a/src/testing/consensus.rs b/src/testing/consensus.rs index 76b0bf8e4..4c8f06228 100644 --- a/src/testing/consensus.rs +++ b/src/testing/consensus.rs @@ -32,8 +32,8 @@ use hotshot::{ HotShotInitializer, MarketplaceConfig, Memberships, SystemContext, }; use hotshot_example_types::{ - auction_results_provider_types::TestAuctionResultsProvider, state_types::TestInstanceState, - storage_types::TestStorage, + auction_results_provider_types::TestAuctionResultsProvider, node_types::TestVersions, + state_types::TestInstanceState, storage_types::TestStorage, }; use hotshot_testing::block_builder::{SimpleBuilderImplementation, TestBuilderImplementation}; use hotshot_types::{ @@ -50,7 +50,7 @@ use tracing::{info_span, Instrument}; use url::Url; struct MockNode { - hotshot: SystemContextHandle, + hotshot: SystemContextHandle, data_source: Arc>, storage: D::Storage, } @@ -202,9 +202,11 @@ impl MockNetwork { config, memberships, network, - HotShotInitializer::from_genesis(TestInstanceState {}) - .await - .unwrap(), + HotShotInitializer::from_genesis(TestInstanceState { + delay_config: Default::default(), + }) + .await + .unwrap(), ConsensusMetricsValue::new(&*data_source.populate_metrics()), hs_storage, MarketplaceConfig { @@ -244,7 +246,7 @@ impl MockNetwork { } impl MockNetwork { - pub fn handle(&self) -> &SystemContextHandle { + pub fn handle(&self) -> &SystemContextHandle { &self.nodes[0].hotshot } diff --git a/src/testing/mocks.rs b/src/testing/mocks.rs index 897cfd300..979ea38ca 100644 --- a/src/testing/mocks.rs +++ b/src/testing/mocks.rs @@ -20,12 +20,14 @@ use hotshot::traits::{ election::static_committee::GeneralStaticCommittee, implementations::MemoryNetwork, NodeImplementation, }; +use hotshot_example_types::node_types::TestVersions; use hotshot_example_types::{ auction_results_provider_types::{TestAuctionResult, TestAuctionResultsProvider}, block_types::{TestBlockHeader, TestBlockPayload, TestTransaction}, state_types::{TestInstanceState, TestValidatedState}, storage_types::TestStorage, }; +use hotshot_types::traits::node_implementation::Versions; use hotshot_types::{ data::{QuorumProposal, ViewNumber}, signature_key::BLSPubKey, @@ -39,7 +41,6 @@ use jf_merkle_tree::{ }; use serde::{Deserialize, Serialize}; use std::ops::Range; -use vbs::version::StaticVersion; pub type MockHeader = TestBlockHeader; pub type MockPayload = TestBlockPayload; @@ -134,17 +135,11 @@ impl NodeType for MockTypes { type ValidatedState = TestValidatedState; type Membership = GeneralStaticCommittee; type BuilderSignatureKey = BLSPubKey; - type Base = StaticVersion<0, 1>; - type Upgrade = StaticVersion<0, 2>; type AuctionResult = TestAuctionResult; - const UPGRADE_HASH: [u8; 32] = [ - 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, - ]; } /// A type alias for the mock base version -pub type MockBase = ::Base; +pub type MockBase = ::Base; pub type MockMembership = GeneralStaticCommittee::SignatureKey>; pub type MockQuorumProposal = QuorumProposal;