diff --git a/Cargo.lock b/Cargo.lock index 4f9942e..32e9edd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,9 +608,9 @@ dependencies = [ [[package]] name = "async-compatibility-layer" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c928880329566b45c159fca61fbc2a1d301a7e5fd2a0e94c17476bb1a3ea526" +checksum = "32dd1dfd4a05a197583e51036d9615f04a4d851089dc119ee965d440d0bcaa39" dependencies = [ "async-lock 3.4.0", "async-std", @@ -1286,13 +1286,13 @@ checksum = "066fce287b1d4eafef758e89e09d724a24808a9196fe9756b8ca90e86d0719a2" [[package]] name = "cdn-broker" version = "0.4.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.2#09389360284c51dd44a3dae1f1c3b395125abe82" +source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.4#398b77fb2f461218a611294e1484b7e0bd571d64" dependencies = [ "async-std", "cdn-proto", "clap", "console-subscriber 0.3.0", - "dashmap 5.5.3", + "dashmap", "derivative", "jf-signature", "lazy_static", @@ -1310,7 +1310,7 @@ dependencies = [ [[package]] name = "cdn-client" version = "0.4.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.2#09389360284c51dd44a3dae1f1c3b395125abe82" +source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.4#398b77fb2f461218a611294e1484b7e0bd571d64" dependencies = [ "async-std", "cdn-proto", @@ -1325,7 +1325,7 @@ dependencies = [ [[package]] name = "cdn-marshal" version = "0.4.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.2#09389360284c51dd44a3dae1f1c3b395125abe82" +source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.4#398b77fb2f461218a611294e1484b7e0bd571d64" dependencies = [ "async-std", "cdn-proto", @@ -1339,7 +1339,7 @@ dependencies = [ [[package]] name = "cdn-proto" version = "0.4.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.2#09389360284c51dd44a3dae1f1c3b395125abe82" +source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.4.4#398b77fb2f461218a611294e1484b7e0bd571d64" dependencies = [ "anyhow", "ark-serialize", @@ -1996,19 +1996,6 @@ dependencies = [ "syn 2.0.69", ] -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "dashmap" version = "6.0.1" @@ -3071,8 +3058,8 @@ dependencies = [ [[package]] name = "hotshot" -version = "0.5.60" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +version = "0.5.63" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "anyhow", "async-broadcast", @@ -3089,7 +3076,7 @@ dependencies = [ "chrono", "committable", "custom_debug", - "dashmap 6.0.1", + "dashmap", "derive_more", "either", "ethereum-types", @@ -3118,7 +3105,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "async-trait", "clap", @@ -3166,8 +3153,8 @@ dependencies = [ [[package]] name = "hotshot-events-service" -version = "0.1.27" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=rc-0.1.32#1cab5bc0cb738a89b97c32e786a4fc469869b031" +version = "0.1.33" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=rc-0.1.33#ea7ee48d5909b0c014489d2b7760c2a40879c344" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -3180,6 +3167,7 @@ dependencies = [ "either", "futures", "hotshot-types", + "rand 0.8.5", "serde", "snafu", "tagged-base64", @@ -3191,8 +3179,8 @@ dependencies = [ [[package]] name = "hotshot-example-types" -version = "0.5.60" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +version = "0.5.63" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "anyhow", "async-broadcast", @@ -3210,6 +3198,7 @@ dependencies = [ "hotshot-task-impls", "hotshot-types", "rand 0.8.5", + "reqwest", "serde", "sha2 0.10.8", "sha3", @@ -3223,8 +3212,8 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" -version = "0.5.60" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +version = "0.5.63" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "anyhow", "async-compatibility-layer", @@ -3253,8 +3242,8 @@ dependencies = [ [[package]] name = "hotshot-task" -version = "0.5.60" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +version = "0.5.63" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "anyhow", "async-broadcast", @@ -3268,8 +3257,8 @@ dependencies = [ [[package]] name = "hotshot-task-impls" -version = "0.5.60" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +version = "0.5.63" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "anyhow", "async-broadcast", @@ -3305,7 +3294,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "anyhow", "ark-bls12-381", @@ -3584,7 +3573,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.52.0", + "windows-core", ] [[package]] @@ -4428,8 +4417,8 @@ dependencies = [ [[package]] name = "libp2p-networking" -version = "0.5.60" -source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.61#b7f5fa34f22df7af6fcfde92caa1b2153102d1df" +version = "0.5.63" +source = "git+https://github.com/EspressoSystems/HotShot.git?tag=rc-0.5.63#86aac47dcdc39e826bedda83e222895c04d87889" dependencies = [ "anyhow", "async-compatibility-layer", @@ -8756,7 +8745,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core 0.51.1", + "windows-core", "windows-targets 0.48.5", ] @@ -8769,15 +8758,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 15c1c7f..a12287d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,10 @@ clap = { version = "4.4", features = ["derive", "env"] } committable = "0.2" derivative = "2.2" futures = "0.3" -hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.61" } -hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.61" } -hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "rc-0.1.32" } -hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.61" } +hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.63" } +hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.63" } +hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "rc-0.1.33" } +hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.63" } serde = { version = "1.0", features = ["derive"] } sha2 = "0.10" snafu = "0.8" @@ -32,4 +32,4 @@ tracing = "0.1" vbs = "0.1" [dev-dependencies] -hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.61" } +hotshot-example-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.63" } diff --git a/src/lib.rs b/src/lib.rs index cc9c0ed..f4db6c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ pub mod service; pub mod testing; use async_compatibility_layer::channel::UnboundedReceiver; -use hotshot_builder_api::builder::BuildError; +use hotshot_builder_api::v0_2::builder::BuildError; #[derive(Debug)] pub enum WaitAndKeep { Keep(T), diff --git a/src/service.rs b/src/service.rs index 281d804..0045aa0 100644 --- a/src/service.rs +++ b/src/service.rs @@ -1,8 +1,8 @@ use hotshot::{ traits::{election::static_committee::GeneralStaticCommittee, NodeImplementation}, - types::SystemContextHandle, + types::{Event, SystemContextHandle}, }; -use hotshot_builder_api::{ +use hotshot_builder_api::v0_2::{ block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo}, builder::BuildError, data_source::{AcceptsTxnSubmits, BuilderDataSource}, @@ -41,10 +41,7 @@ use committable::{Commitment, Committable}; use derivative::Derivative; use futures::future::BoxFuture; use futures::stream::StreamExt; -use hotshot_events_service::{ - events::Error as EventStreamError, - events_source::{BuilderEvent, BuilderEventType}, -}; +use hotshot_events_service::{events::Error as EventStreamError, events_source::StartupInfo}; use sha2::{Digest, Sha256}; use std::collections::HashMap; use std::num::NonZeroUsize; @@ -772,7 +769,7 @@ async fn connect_to_events_service( hotshot_events_api_url: Url, ) -> Option<( surf_disco::socket::Connection< - BuilderEvent, + Event, surf_disco::socket::Unsupported, EventStreamError, Types::Base, @@ -790,40 +787,35 @@ async fn connect_to_events_service( tracing::info!("Builder client connected to the hotshot events api"); // client subscrive to hotshot events - let mut subscribed_events = client + let subscribed_events = client .socket("hotshot-events/events") - .subscribe::>() + .subscribe::>() .await .ok()?; // handle the startup event at the start - let membership = if let Some(Ok(event)) = subscribed_events.next().await { - match event.event { - BuilderEventType::StartupInfo { - known_node_with_stake, - non_staked_node_count, - } => { - let membership: GeneralStaticCommittee::SignatureKey> = GeneralStaticCommittee::< - Types, - ::SignatureKey, - >::create_election( - known_node_with_stake.clone(), - known_node_with_stake.clone(), - 0 - ); + let membership = if let Ok(response) = client + .get::>("hotshot-events/startup_info") + .send() + .await + { + let StartupInfo { + known_node_with_stake, + non_staked_node_count, + } = response; + let membership: GeneralStaticCommittee::SignatureKey> = + GeneralStaticCommittee::::SignatureKey>::create_election( + known_node_with_stake.clone(), + known_node_with_stake.clone(), + 0, + ); - tracing::info!( - "Startup info: Known nodes with stake: {:?}, Non-staked node count: {:?}", - known_node_with_stake, - non_staked_node_count - ); - Some(membership) - } - _ => { - tracing::error!("Startup info event not received as first event"); - None - } - } + tracing::info!( + "Startup info: Known nodes with stake: {:?}, Non-staked node count: {:?}", + known_node_with_stake, + non_staked_node_count + ); + Some(membership) } else { None }; @@ -864,15 +856,11 @@ pub async fn run_non_permissioned_standalone_builder_service( match event { Some(Ok(event)) => { match event.event { - BuilderEventType::HotshotError { error } => { + EventType::Error { error } => { tracing::error!("Error event in HotShot: {:?}", error); } - // startup event - BuilderEventType::StartupInfo { .. } => { - tracing::warn!("Startup info event received again"); - } // tx event - BuilderEventType::HotshotTransactions { transactions } => { + EventType::Transactions { transactions } => { if let Err(e) = handle_received_txns( &tx_sender, transactions, @@ -884,14 +872,16 @@ pub async fn run_non_permissioned_standalone_builder_service( } } // decide event - BuilderEventType::HotshotDecide { - latest_decide_view_num, + EventType::Decide { block_size: _, + leaf_chain, + qc: _, } => { + let latest_decide_view_num = leaf_chain[0].leaf.view_number(); handle_decide_event(&decide_sender, latest_decide_view_num).await; } // DA proposal event - BuilderEventType::HotshotDaProposal { proposal, sender } => { + EventType::DaProposal { proposal, sender } => { // get the leader for current view let leader = membership.leader(proposal.data.view_number); // get the committee mstatked node count @@ -907,7 +897,7 @@ pub async fn run_non_permissioned_standalone_builder_service( .await; } // QC proposal event - BuilderEventType::HotshotQuorumProposal { proposal, sender } => { + EventType::QuorumProposal { proposal, sender } => { // get the leader for current view let leader = membership.leader(proposal.data.view_number); handle_qc_event(&qc_sender, Arc::new(proposal), sender, leader).await;