Skip to content

Commit

Permalink
Merge pull request #656 from EspressoSystems/hotshot/rc-0.5.60
Browse files Browse the repository at this point in the history
Hotshot/rc 0.5.60
  • Loading branch information
jparr721 committed Jul 1, 2024
2 parents a44ad35 + 4206e5c commit 5e59fb6
Show file tree
Hide file tree
Showing 14 changed files with 374 additions and 538 deletions.
606 changes: 206 additions & 400 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "rc-0.5.59" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.59" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.59" }
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.60" }
hotshot-testing = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.60" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.60" }
itertools = "0.12.1"
jf-merkle-tree = { version = "0.1.0", git = "https://github.com/EspressoSystems/jellyfish", tag = "0.4.5", features = [
"std",
Expand All @@ -100,6 +100,7 @@ trait-variant = "0.1"
typenum = "1"
vbs = "0.1"
vec1 = "1.12"
url = "2"

# Dependencies enabled by feature "file-system-data-source".
atomic_store = { git = "https://github.com/EspressoSystems/atomicstore.git", tag = "0.1.4", optional = true }
Expand All @@ -118,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 = "rc-0.5.59", optional = true }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.60", optional = true }
portpicker = { version = "0.1", optional = true }
rand = { version = "0.8", optional = true }
spin_sleep = { version = "1.2", optional = true }
Expand All @@ -139,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 = "rc-0.5.59" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.60" }
portpicker = "0.1"
rand = "0.8"
reqwest = "0.12.3"
Expand Down
48 changes: 29 additions & 19 deletions examples/simple-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,30 @@ use futures::future::{join_all, try_join_all};
use hotshot::{
traits::implementations::{MasterMap, MemoryNetwork},
types::{SignatureKey, SystemContextHandle},
HotShotInitializer, Memberships, Networks, SystemContext,
HotShotInitializer, Memberships, SystemContext,
};
use hotshot_example_types::{
auction_results_provider_types::TestAuctionResultsProvider, state_types::TestInstanceState,
storage_types::TestStorage,
};
use hotshot_example_types::{state_types::TestInstanceState, storage_types::TestStorage};
use hotshot_query_service::{
data_source,
fetching::provider::NoFetching,
run_standalone_service,
status::UpdateStatusData,
testing::{
consensus::DataSourceLifeCycle,
mocks::{MockMembership, MockNodeImpl, MockTypes},
mocks::{MockBase, MockMembership, MockNodeImpl, MockTypes},
},
Error,
};
use hotshot_testing::block_builder::{
SimpleBuilderConfig, SimpleBuilderImplementation, TestBuilderImplementation,
};
use hotshot_testing::block_builder::{SimpleBuilderImplementation, TestBuilderImplementation};
use hotshot_types::{
consensus::ConsensusMetricsValue, light_client::StateKeyPair, signature_key::BLSPubKey,
traits::election::Membership, ExecutionType, HotShotConfig, PeerConfig, ValidatorConfig,
};
use std::{num::NonZeroUsize, time::Duration};
use url::Url;
use vbs::version::StaticVersionType;

const NUM_NODES: usize = 2;
Expand Down Expand Up @@ -115,7 +117,7 @@ async fn main() -> Result<(), Error> {
let nodes = init_consensus(&data_sources).await;

// Use version 0.1, for no particular reason
let bind_version: hotshot_types::constants::Base = hotshot_types::constants::Base::instance();
let bind_version = MockBase::instance();

// Start the servers.
try_join_all(
Expand Down Expand Up @@ -170,13 +172,21 @@ async fn init_consensus(
view_sync_membership: membership.clone(),
};

// Pick a random, unused port for the builder server
let builder_port = portpicker::pick_unused_port().expect("No ports available");

let builder_url =
Url::parse(&format!("http://0.0.0.0:{builder_port}")).expect("Failed to parse URL");

// Start the builder server
let (builder_task, builder_url) = <SimpleBuilderImplementation as TestBuilderImplementation<
MockTypes,
>>::start(
1, SimpleBuilderConfig::default(), Default::default()
)
.await;
let builder_task =
<SimpleBuilderImplementation as TestBuilderImplementation<MockTypes>>::start(
1,
builder_url.clone(),
(),
Default::default(),
)
.await;

// Create the configuration
let config = HotShotConfig {
Expand Down Expand Up @@ -207,6 +217,10 @@ async fn init_consensus(
stop_proposing_view: 0,
start_voting_view: 0,
stop_voting_view: 0,
start_proposing_time: 0,
stop_proposing_time: 0,
start_voting_time: 0,
stop_voting_time: 0,
};

let nodes = join_all(priv_keys.into_iter().zip(data_sources).enumerate().map(
Expand Down Expand Up @@ -235,11 +249,6 @@ async fn init_consensus(
&master_map.clone(),
None,
));
let networks = Networks {
quorum_network: network.clone(),
da_network: network,
_pd: Default::default(),
};

let storage: TestStorage<MockTypes> = TestStorage::default();

Expand All @@ -249,12 +258,13 @@ async fn init_consensus(
node_id as u64,
config,
memberships,
networks,
network,
HotShotInitializer::from_genesis(TestInstanceState {})
.await
.unwrap(),
ConsensusMetricsValue::new(&*data_source.populate_metrics()),
storage,
TestAuctionResultsProvider::default(),
)
.await
.unwrap()
Expand Down
21 changes: 10 additions & 11 deletions src/availability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ mod test {
task::BackgroundTask,
testing::{
consensus::{MockDataSource, MockNetwork, TestableDataSource},
mocks::{mock_transaction, MockHeader, MockPayload, MockTypes},
mocks::{mock_transaction, MockBase, MockHeader, MockPayload, MockTypes},
setup_test,
},
types::HeightIndexed,
Expand All @@ -463,7 +463,6 @@ mod test {
use committable::Committable;
use futures::future::FutureExt;
use hotshot_example_types::state_types::{TestInstanceState, TestValidatedState};
use hotshot_types::constants::Base;
use hotshot_types::data::Leaf;
use portpicker::pick_unused_port;
use std::time::Duration;
Expand All @@ -474,7 +473,7 @@ mod test {

/// Get the current ledger height and a list of non-empty leaf/block pairs.
async fn get_non_empty_blocks(
client: &Client<Error, Base>,
client: &Client<Error, MockBase>,
) -> (
u64,
Vec<(LeafQueryData<MockTypes>, BlockQueryData<MockTypes>)>,
Expand Down Expand Up @@ -507,7 +506,7 @@ mod test {
unreachable!()
}

async fn validate(client: &Client<Error, Base>, height: u64) {
async fn validate(client: &Client<Error, MockBase>, height: u64) {
// Check the consistency of every block/leaf pair.
for i in 0..height {
// Limit the number of blocks we validate in order to
Expand Down Expand Up @@ -767,18 +766,18 @@ mod test {
fetch_timeout,
..Default::default()
},
Base::instance(),
MockBase::instance(),
)
.unwrap(),
)
.unwrap();
network.spawn(
"server",
app.serve(format!("0.0.0.0:{}", port), Base::instance()),
app.serve(format!("0.0.0.0:{}", port), MockBase::instance()),
);

// Start a client.
let client = Client::<Error, Base>::new(
let client = Client::<Error, MockBase>::new(
format!("http://localhost:{}/availability", port)
.parse()
.unwrap(),
Expand Down Expand Up @@ -891,12 +890,12 @@ mod test {
};

let mut api =
define_api::<RwLock<ExtensibleDataSource<MockDataSource, u64>>, MockTypes, Base>(
define_api::<RwLock<ExtensibleDataSource<MockDataSource, u64>>, MockTypes, MockBase>(
&Options {
extensions: vec![extensions.into()],
..Default::default()
},
Base::instance(),
MockBase::instance(),
)
.unwrap();
api.get("get_ext", |_, state| {
Expand All @@ -918,10 +917,10 @@ mod test {
let port = pick_unused_port().unwrap();
let _server = BackgroundTask::spawn(
"server",
app.serve(format!("0.0.0.0:{}", port), Base::instance()),
app.serve(format!("0.0.0.0:{}", port), MockBase::instance()),
);

let client = Client::<Error, Base>::new(
let client = Client::<Error, MockBase>::new(
format!("http://localhost:{}/availability", port)
.parse()
.unwrap(),
Expand Down
1 change: 1 addition & 0 deletions src/data_source/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use async_trait::async_trait;
/// let hotshot = SystemContext::<AppTypes, AppNodeImpl>::init(
/// # panic!(), panic!(), panic!(), panic!(), panic!(), panic!(), panic!(),
/// ConsensusMetricsValue::new(&*data_source.populate_metrics()), panic!(),
/// panic!(),
/// // Other fields omitted
/// ).await.map_err(Error::internal)?.0;
/// # Ok(())
Expand Down
11 changes: 5 additions & 6 deletions src/data_source/storage/no_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,12 @@ pub mod testing {
status::StatusDataSource,
testing::{
consensus::{DataSourceLifeCycle, MockNetwork},
mocks::MockTypes,
mocks::{MockBase, MockTypes},
},
Error,
};
use futures::stream::{BoxStream, StreamExt};
use hotshot::types::Event;
use hotshot_types::constants::Base;
use portpicker::pick_unused_port;
use std::{fmt::Display, time::Duration};
use tide_disco::App;
Expand All @@ -232,7 +231,7 @@ pub mod testing {

pub enum DataSource {
Sql(SqlDataSource<MockTypes, NoFetching>),
NoStorage(FetchingDataSource<MockTypes, NoStorage, QueryServiceProvider<Base>>),
NoStorage(FetchingDataSource<MockTypes, NoStorage, QueryServiceProvider<MockBase>>),
}

#[async_trait]
Expand Down Expand Up @@ -268,7 +267,7 @@ pub mod testing {
format!("http://localhost:{fetch_from_port}")
.parse()
.unwrap(),
Base::instance(),
MockBase::instance(),
);
Self::NoStorage(
FetchingDataSource::builder(NoStorage, provider)
Expand Down Expand Up @@ -317,12 +316,12 @@ pub mod testing {
let mut app = App::<_, Error>::with_state(api_data_source);
app.register_module(
"availability",
define_api(&Default::default(), Base::instance()).unwrap(),
define_api(&Default::default(), MockBase::instance()).unwrap(),
)
.unwrap();
network.spawn(
"server",
app.serve(format!("0.0.0.0:{fetch_from_port}"), Base::instance()),
app.serve(format!("0.0.0.0:{fetch_from_port}"), MockBase::instance()),
);
}

Expand Down
15 changes: 7 additions & 8 deletions src/explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,18 @@ mod test {
availability,
testing::{
consensus::{MockNetwork, MockSqlDataSource},
mocks::{mock_transaction, MockTypes},
mocks::{mock_transaction, MockBase, MockTypes},
setup_test,
},
Error,
};
use futures::StreamExt;
use hotshot_types::constants::Base;
use portpicker::pick_unused_port;
use std::{cmp::min, time::Duration};
use surf_disco::Client;
use tide_disco::App;

async fn validate(client: &Client<Error, Base>) {
async fn validate(client: &Client<Error, MockBase>) {
let explorer_summary_response: ExplorerSummaryResponse<MockTypes> =
client.get("explorer-summary").send().await.unwrap();

Expand Down Expand Up @@ -869,7 +868,7 @@ mod test {
// Start the web server.
let port = pick_unused_port().unwrap();
let mut app = App::<_, Error>::with_state(network.data_source());
app.register_module("explorer", define_api(Base::instance()).unwrap())
app.register_module("explorer", define_api(MockBase::instance()).unwrap())
.unwrap();
app.register_module(
"availability",
Expand All @@ -878,24 +877,24 @@ mod test {
fetch_timeout: Duration::from_secs(5),
..Default::default()
},
Base::instance(),
MockBase::instance(),
)
.unwrap(),
)
.unwrap();

network.spawn(
"server",
app.serve(format!("0.0.0.0:{}", port), Base::instance()),
app.serve(format!("0.0.0.0:{}", port), MockBase::instance()),
);

// Start a client.
let availability_client = Client::<Error, Base>::new(
let availability_client = Client::<Error, MockBase>::new(
format!("http://localhost:{}/availability", port)
.parse()
.unwrap(),
);
let explorer_client = Client::<Error, Base>::new(
let explorer_client = Client::<Error, MockBase>::new(
format!("http://localhost:{}/explorer", port)
.parse()
.unwrap(),
Expand Down
Loading

0 comments on commit 5e59fb6

Please sign in to comment.