Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Update hotshot #237

Merged
merged 4 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ clap = { version = "4.5", features = ["derive", "env"] }
committable = "0.2"
derivative = "2.2"
futures = "0.3"
hotshot = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.69" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.69" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.40" }
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-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.41" }
hotshot-types = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70" }
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10"
snafu = "0.8"
Expand All @@ -34,7 +34,7 @@ lru = "0.12.3"
hex = "0.4.3"

[dev-dependencies]
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" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(async_executor_impl, values("async-std", "tokio"))'] }
18 changes: 10 additions & 8 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use hotshot_types::{
consensus_api::ConsensusApi,
election::Membership,
network::Topic,
node_implementation::{ConsensusTime, NodeType},
node_implementation::{ConsensusTime, NodeType, Versions},
signature_key::{BuilderSignatureKey, SignatureKey},
},
utils::BuilderCommitment,
Expand Down Expand Up @@ -715,18 +715,18 @@ impl<Types: NodeType> ReadState for ProxyGlobalState<Types> {
}
}

async fn connect_to_events_service<Types: NodeType>(
async fn connect_to_events_service<Types: NodeType, V: Versions>(
hotshot_events_api_url: Url,
) -> Option<(
surf_disco::socket::Connection<
Event<Types>,
surf_disco::socket::Unsupported,
EventStreamError,
Types::Base,
V::Base,
>,
GeneralStaticCommittee<Types, <Types as NodeType>::SignatureKey>,
)> {
let client = surf_disco::Client::<hotshot_events_service::events::Error, Types::Base>::new(
let client = surf_disco::Client::<hotshot_events_service::events::Error, V::Base>::new(
hotshot_events_api_url.clone(),
);

Expand Down Expand Up @@ -775,7 +775,7 @@ async fn connect_to_events_service<Types: NodeType>(
/*
Running Non-Permissioned Builder Service
*/
pub async fn run_non_permissioned_standalone_builder_service<Types: NodeType>(
pub async fn run_non_permissioned_standalone_builder_service<Types: NodeType, V: Versions>(
// sending a DA proposal from the hotshot to the builder states
da_sender: BroadcastSender<MessageType<Types>>,

Expand All @@ -792,7 +792,7 @@ pub async fn run_non_permissioned_standalone_builder_service<Types: NodeType>(
hotshot_events_api_url: Url,
) -> Result<(), anyhow::Error> {
// connection to the events stream
let connected = connect_to_events_service(hotshot_events_api_url.clone()).await;
let connected = connect_to_events_service::<Types, V>(hotshot_events_api_url.clone()).await;
if connected.is_none() {
return Err(anyhow!(
"failed to connect to API at {hotshot_events_api_url}"
Expand Down Expand Up @@ -856,7 +856,8 @@ pub async fn run_non_permissioned_standalone_builder_service<Types: NodeType>(
}
None => {
tracing::error!("Event stream ended");
let connected = connect_to_events_service(hotshot_events_api_url.clone()).await;
let connected =
connect_to_events_service::<Types, V>(hotshot_events_api_url.clone()).await;
if connected.is_none() {
return Err(anyhow!(
"failed to reconnect to API at {hotshot_events_api_url}"
Expand All @@ -875,6 +876,7 @@ Running Permissioned Builder Service
pub async fn run_permissioned_standalone_builder_service<
Types: NodeType,
I: NodeImplementation<Types>,
V: Versions,
>(
// sending received transactions
tx_sender: BroadcastSender<Arc<ReceivedTransaction<Types>>>,
Expand All @@ -889,7 +891,7 @@ pub async fn run_permissioned_standalone_builder_service<
decide_sender: BroadcastSender<MessageType<Types>>,

// hotshot context handle
hotshot_handle: Arc<SystemContextHandle<Types, I>>,
hotshot_handle: Arc<SystemContextHandle<Types, I, V>>,
) {
let mut event_stream = hotshot_handle.event_stream();
loop {
Expand Down
29 changes: 18 additions & 11 deletions src/testing/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ mod tests {
use sha2::{Digest, Sha256};
use std::sync::Arc;
use std::time::Duration;
use vbs::version::StaticVersion;

use serde::{Deserialize, Serialize};
/// This test simulates multiple builder states receiving messages from the channels and processing them
Expand Down Expand Up @@ -82,12 +81,6 @@ mod tests {
type InstanceState = TestInstanceState;
type Membership = GeneralStaticCommittee<TestTypes, Self::SignatureKey>;
type BuilderSignatureKey = BuilderKey;
type Base = StaticVersion<0, 1>;
type Upgrade = StaticVersion<0, 2>;
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,
];
type AuctionResult = TestAuctionResult;
}
// no of test messages to send
Expand Down Expand Up @@ -175,7 +168,9 @@ mod tests {
<TestBlockPayload as BlockPayload<TestTypes>>::from_transactions(
vec![tx.clone()],
&TestValidatedState::default(),
&TestInstanceState {},
&TestInstanceState {
..Default::default()
},
)
.await
.unwrap();
Expand Down Expand Up @@ -210,7 +205,9 @@ mod tests {
0 => {
QuorumCertificate::<TestTypes>::genesis(
&TestValidatedState::default(),
&TestInstanceState {},
&TestInstanceState {
..Default::default()
},
)
.await
}
Expand Down Expand Up @@ -283,7 +280,15 @@ mod tests {
// Prepare the decide message
// let qc = QuorumCertificate::<TestTypes>::genesis();
let leaf = match i {
0 => Leaf::genesis(&TestValidatedState::default(), &TestInstanceState {}).await,
0 => {
Leaf::genesis(
&TestValidatedState::default(),
&TestInstanceState {
..Default::default()
},
)
.await
}
_ => {
let block_payload = BlockPayload::<TestTypes>::from_bytes(
&encoded_transactions,
Expand Down Expand Up @@ -369,7 +374,9 @@ mod tests {
NonZeroUsize::new(TEST_NUM_NODES_IN_VID_COMPUTATION).unwrap(),
Duration::from_millis(10), // max time to wait for non-zero txn block
0, // base fee
Arc::new(TestInstanceState {}),
Arc::new(TestInstanceState {
..Default::default()
}),
Duration::from_secs(3600), // duration for txn garbage collection
Arc::new(TestValidatedState::default()),
);
Expand Down
Loading