Skip to content

Commit

Permalink
fix lingering da_leader things
Browse files Browse the repository at this point in the history
  • Loading branch information
pls148 committed Dec 2, 2024
1 parent 957fcbb commit 00e6acd
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 44 deletions.
3 changes: 0 additions & 3 deletions crates/hotshot/src/tasks/task_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState
cur_view: handle.cur_view().await,
cur_epoch: handle.cur_epoch().await,
quorum_membership: (*handle.hotshot.memberships).clone().into(),
network: Arc::clone(&handle.hotshot.network),
vote_collectors: BTreeMap::default(),
public_key: handle.public_key().clone(),
private_key: handle.private_key().clone(),
Expand Down Expand Up @@ -163,7 +162,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState
cur_view,
next_view: cur_view,
cur_epoch: handle.cur_epoch().await,
network: Arc::clone(&handle.hotshot.network),
membership: (*handle.hotshot.memberships).clone().into(),
public_key: handle.public_key().clone(),
private_key: handle.private_key().clone(),
Expand Down Expand Up @@ -191,7 +189,6 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> CreateTaskState
consensus: OuterConsensus::new(handle.hotshot.consensus()),
cur_view: handle.cur_view().await,
cur_epoch: handle.cur_epoch().await,
network: Arc::clone(&handle.hotshot.network),
membership: (*handle.hotshot.memberships).clone().into(),
public_key: handle.public_key().clone(),
private_key: handle.private_key().clone(),
Expand Down
26 changes: 0 additions & 26 deletions crates/hotshot/src/traits/election/randomized_committee_members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,32 +317,6 @@ impl<TYPES: NodeType, CONFIG: QuorumFilterConfig> Membership<TYPES>
Ok(TYPES::SignatureKey::public_key(&res))
}

/// Index the vector of public keys with the current view number
fn lookup_da_leader(
&self,
view_number: TYPES::View,
epoch: <TYPES as NodeType>::Epoch,
) -> Result<TYPES::SignatureKey> {
let filter = self.make_da_quorum_filter(epoch);
let leader_vec: Vec<_> = self
.da_stake_table
.iter()
.enumerate()
.filter(|(idx, _)| filter.contains(idx))
.map(|(_, v)| v.clone())
.collect();

let mut rng: StdRng = rand::SeedableRng::seed_from_u64(*view_number);

let randomized_view_number: u64 = rng.gen_range(0..=u64::MAX);
#[allow(clippy::cast_possible_truncation)]
let index = randomized_view_number as usize % leader_vec.len();

let res = leader_vec[index].clone();

Ok(TYPES::SignatureKey::public_key(&res))
}

/// Get the total number of nodes in the committee
fn total_nodes(&self, epoch: <TYPES as NodeType>::Epoch) -> usize {
self.make_quorum_filter(epoch).len()
Expand Down
15 changes: 0 additions & 15 deletions crates/types/src/traits/election.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,6 @@ pub trait Membership<TYPES: NodeType>: Clone + Debug + Send + Sync {
))
}

/// The DA leader of the committee for view `view_number` in `epoch`.
///
/// Note: this function uses a HotShot-internal error type.
/// You should implement `lookup_leader`, rather than implementing this function directly.
///
/// # Errors
/// Returns an error if the leader cannot be calculated.
fn da_leader(&self, view: TYPES::View, epoch: TYPES::Epoch) -> Result<TYPES::SignatureKey> {
use utils::anytrace::*;

self.lookup_da_leader(view, epoch).wrap().context(info!(
"Failed to get leader for view {view} in epoch {epoch}"
))
}

/// The leader of the committee for view `view_number` in `epoch`.
///
/// Note: There is no such thing as a DA leader, so any consumer
Expand Down

0 comments on commit 00e6acd

Please sign in to comment.