Skip to content
Closed
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
5 changes: 3 additions & 2 deletions crates/hotshot/hotshot/src/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ use hotshot_task::task::Task;
#[cfg(feature = "rewind")]
use hotshot_task_impls::rewind::RewindTaskState;
use hotshot_task_impls::{
block_builder::BlockBuilderTaskState,
da::DaTaskState,
events::HotShotEvent,
network::{NetworkEventTaskState, NetworkMessageTaskState},
request::NetworkRequestState,
response::{run_response_task, NetworkResponseState},
stats::StatsTaskState,
transactions::TransactionTaskState,
upgrade::UpgradeTaskState,
vid::VidTaskState,
view_sync::ViewSyncTaskState,
Expand Down Expand Up @@ -232,7 +232,8 @@ pub async fn add_consensus_tasks<TYPES: NodeType, I: NodeImplementation<TYPES>,
handle.add_task(ViewSyncTaskState::<TYPES, V>::create_from(handle).await);
handle.add_task(VidTaskState::<TYPES, I, V>::create_from(handle).await);
handle.add_task(DaTaskState::<TYPES, I, V>::create_from(handle).await);
handle.add_task(TransactionTaskState::<TYPES, V>::create_from(handle).await);
// handle.add_task(TransactionTaskState::<TYPES, V>::create_from(handle).await);
handle.add_task(BlockBuilderTaskState::<TYPES, V>::create_from(handle).await);

{
let mut upgrade_certificate_lock = handle
Expand Down
41 changes: 35 additions & 6 deletions crates/hotshot/hotshot/src/tasks/task_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@
// along with the HotShot repository. If not, see <https://mit-license.org/>.

use std::{
collections::BTreeMap,
collections::{BTreeMap, HashSet},
num::NonZero,
sync::{atomic::AtomicBool, Arc},
time::Instant,
};

use async_trait::async_trait;
use chrono::Utc;
use hotshot_task_impls::{
builder::BuilderClient, consensus::ConsensusTaskState, da::DaTaskState,
quorum_proposal::QuorumProposalTaskState, quorum_proposal_recv::QuorumProposalRecvTaskState,
quorum_vote::QuorumVoteTaskState, request::NetworkRequestState, rewind::RewindTaskState,
stats::StatsTaskState, transactions::TransactionTaskState, upgrade::UpgradeTaskState,
vid::VidTaskState, view_sync::ViewSyncTaskState,
block_builder::BlockBuilderTaskState, builder::BuilderClient, consensus::ConsensusTaskState,
da::DaTaskState, quorum_proposal::QuorumProposalTaskState,
quorum_proposal_recv::QuorumProposalRecvTaskState, quorum_vote::QuorumVoteTaskState,
request::NetworkRequestState, rewind::RewindTaskState, stats::StatsTaskState,
transactions::TransactionTaskState, upgrade::UpgradeTaskState, vid::VidTaskState,
view_sync::ViewSyncTaskState,
};
use hotshot_types::{
consensus::OuterConsensus,
traits::{
consensus_api::ConsensusApi,
node_implementation::{ConsensusTime, NodeImplementation, NodeType},
signature_key::BuilderSignatureKey,
},
};
use lru::LruCache;
use tokio::spawn;

use crate::{types::SystemContextHandle, Versions};
Expand Down Expand Up @@ -219,6 +223,31 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState
}
}

#[async_trait]
impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState<TYPES, I, V>
for BlockBuilderTaskState<TYPES, V>
{
async fn create_from(handle: &SystemContextHandle<TYPES, I, V>) -> Self {
let (builder_key, builder_private_key) =
TYPES::BuilderSignatureKey::generated_from_seed_indexed([0; 32], handle.hotshot.id);
Self {
cur_view: handle.cur_view().await,
cur_epoch: handle.cur_epoch().await,
membership_coordinator: handle.hotshot.membership_coordinator.clone(),
upgrade_lock: handle.hotshot.upgrade_lock.clone(),
epoch_height: handle.epoch_height,
consensus: OuterConsensus::new(handle.hotshot.consensus()),
transactions: LruCache::new(NonZero::new(10000).unwrap()),
instance_state: handle.hotshot.instance_state(),
base_fee: 1,
public_key: handle.public_key().clone(),
builder_public_key: builder_key,
builder_private_key,
decided_not_seen_txns: HashSet::new(),
}
}
}

#[async_trait]
impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState<TYPES, I, V>
for QuorumVoteTaskState<TYPES, I, V>
Expand Down
Loading
Loading