diff --git a/node/src/components/consensus.rs b/node/src/components/consensus.rs index 1d1a2b85ff..c0d0355d3b 100644 --- a/node/src/components/consensus.rs +++ b/node/src/components/consensus.rs @@ -2,12 +2,9 @@ mod consensus_protocol; mod era_supervisor; -mod traits; -// TODO: remove when we actually construct a Highway era -mod protocols; -// TODO: remove when we actually construct a Highway era -#[allow(unused)] mod highway_core; +mod protocols; +mod traits; #[cfg(test)] #[allow(unused)] diff --git a/node/src/components/consensus/highway_core/evidence.rs b/node/src/components/consensus/highway_core/evidence.rs index 581ff1d35c..6568f14fea 100644 --- a/node/src/components/consensus/highway_core/evidence.rs +++ b/node/src/components/consensus/highway_core/evidence.rs @@ -1,6 +1,5 @@ -use super::{validators::ValidatorIndex, vertex::WireVote}; -use crate::components::consensus::highway_core::vertex::SignedWireVote; -use crate::components::consensus::traits::Context; +use super::validators::ValidatorIndex; +use crate::components::consensus::{highway_core::vertex::SignedWireVote, traits::Context}; use serde::{Deserialize, Serialize}; /// Evidence that a validator is faulty. diff --git a/node/src/components/consensus/highway_core/finality_detector.rs b/node/src/components/consensus/highway_core/finality_detector.rs index 2340b71796..a4f8c5d66e 100644 --- a/node/src/components/consensus/highway_core/finality_detector.rs +++ b/node/src/components/consensus/highway_core/finality_detector.rs @@ -1,3 +1,4 @@ +#![allow(unused)] // TODO: Use the finality detector! use std::{collections::BTreeMap, iter}; use super::{ diff --git a/node/src/components/consensus/highway_core/highway.rs b/node/src/components/consensus/highway_core/highway.rs index a12d813f95..c24a5c3c3b 100644 --- a/node/src/components/consensus/highway_core/highway.rs +++ b/node/src/components/consensus/highway_core/highway.rs @@ -1,9 +1,8 @@ use super::{ active_validator::{ActiveValidator, Effect}, - evidence::Evidence, - state::{State, VoteError, Weight}, + state::{State, VoteError}, validators::Validators, - vertex::{Dependency, Vertex, WireVote}, + vertex::{Dependency, Vertex}, }; use thiserror::Error; use tracing::warn; @@ -71,12 +70,6 @@ impl From> for Vertex { #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct ValidVertex(Vertex); -impl ValidVertex { - pub(crate) fn vertex(&self) -> &Vertex { - &self.0 - } -} - #[derive(Debug)] pub(crate) struct HighwayParams { /// The protocol instance ID. This needs to be unique, to prevent replay attacks. @@ -231,10 +224,6 @@ impl Highway { } } - pub(crate) fn state(&self) -> &State { - &self.state - } - fn on_new_vote(&self, vhash: &C::Hash, timestamp: Timestamp) -> Vec> { self.active_validator .as_ref() @@ -266,7 +255,7 @@ impl Highway { fn do_validate_vertex(&self, vertex: &Vertex) -> Result<(), VertexError> { match vertex { Vertex::Vote(vote) => Ok(self.state.validate_vote(vote)?), - Vertex::Evidence(evidence) => Ok(()), + Vertex::Evidence(_evidence) => Ok(()), } } @@ -297,10 +286,9 @@ pub(crate) mod tests { highway_core::{ highway::{Highway, HighwayParams, VertexError, VoteError}, state::tests::{ - AddVoteError, TestContext, ALICE, ALICE_SEC, BOB, BOB_SEC, CAROL, CAROL_SEC, - WEIGHTS, + TestContext, ALICE, ALICE_SEC, BOB, BOB_SEC, CAROL, CAROL_SEC, WEIGHTS, }, - state::{State, Weight}, + state::State, validators::Validators, vertex::{SignedWireVote, Vertex, WireVote}, vote::Panorama, diff --git a/node/src/components/consensus/highway_core/state.rs b/node/src/components/consensus/highway_core/state.rs index c1c4c46f51..03c8d03ac3 100644 --- a/node/src/components/consensus/highway_core/state.rs +++ b/node/src/components/consensus/highway_core/state.rs @@ -2,7 +2,6 @@ use std::{ cmp::Ordering, collections::HashMap, convert::identity, - fmt::{self, Display, Formatter}, iter, ops::{Div, Mul}, }; diff --git a/node/src/components/consensus/highway_core/tallies.rs b/node/src/components/consensus/highway_core/tallies.rs index 6c0bda8333..ee1083cd3c 100644 --- a/node/src/components/consensus/highway_core/tallies.rs +++ b/node/src/components/consensus/highway_core/tallies.rs @@ -176,11 +176,6 @@ impl<'a, C: Context> Tallies<'a, C> { .or_insert_with(|| Tally::new(bhash, weight)); } - /// Returns the number tallies. - pub(crate) fn len(&self) -> usize { - self.0.len() - } - /// Returns `true` if there are no tallies in this map. pub(crate) fn is_empty(&self) -> bool { self.0.is_empty() @@ -194,6 +189,13 @@ mod tests { *, }; + impl<'a> Tallies<'a, TestContext> { + /// Returns the number of tallies. + pub(crate) fn len(&self) -> usize { + self.0.len() + } + } + #[test] fn tallies() -> Result<(), AddVoteError> { let mut state = State::new(WEIGHTS, 0); diff --git a/node/src/components/consensus/highway_core/validators.rs b/node/src/components/consensus/highway_core/validators.rs index 186854073e..e4256c99ed 100644 --- a/node/src/components/consensus/highway_core/validators.rs +++ b/node/src/components/consensus/highway_core/validators.rs @@ -56,10 +56,6 @@ impl Validators { self.validators.iter().map(|v| v.weight()).sum() } - pub(crate) fn len(&self) -> usize { - self.validators.len() - } - pub(crate) fn get_index(&self, id: &VID) -> ValidatorIndex { *self.index_by_id.get(id).unwrap() } diff --git a/node/src/components/consensus/highway_core/vertex.rs b/node/src/components/consensus/highway_core/vertex.rs index 219bb5b6d8..defa9df329 100644 --- a/node/src/components/consensus/highway_core/vertex.rs +++ b/node/src/components/consensus/highway_core/vertex.rs @@ -1,5 +1,3 @@ -use std::iter; - use serde::{Deserialize, Serialize}; use super::{evidence::Evidence, validators::ValidatorIndex, vote::Panorama}; diff --git a/node/src/components/consensus/highway_core/vote.rs b/node/src/components/consensus/highway_core/vote.rs index 6a234806e3..debf695bf2 100644 --- a/node/src/components/consensus/highway_core/vote.rs +++ b/node/src/components/consensus/highway_core/vote.rs @@ -1,11 +1,8 @@ use serde::{Deserialize, Serialize}; -use super::{state::State, validators::ValidatorIndex, vertex::WireVote}; +use super::{state::State, validators::ValidatorIndex}; use crate::{ - components::consensus::{ - highway_core::vertex::SignedWireVote, - traits::{Context, ValidatorSecret}, - }, + components::consensus::{highway_core::vertex::SignedWireVote, traits::Context}, types::Timestamp, };