Skip to content
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
7 changes: 2 additions & 5 deletions node/src/components/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
5 changes: 2 additions & 3 deletions node/src/components/consensus/highway_core/evidence.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unused)] // TODO: Use the finality detector!
use std::{collections::BTreeMap, iter};

use super::{
Expand Down
22 changes: 5 additions & 17 deletions node/src/components/consensus/highway_core/highway.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -71,12 +70,6 @@ impl<C: Context> From<PreValidatedVertex<C>> for Vertex<C> {
#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct ValidVertex<C: Context>(Vertex<C>);

impl<C: Context> ValidVertex<C> {
pub(crate) fn vertex(&self) -> &Vertex<C> {
&self.0
}
}

#[derive(Debug)]
pub(crate) struct HighwayParams<C: Context> {
/// The protocol instance ID. This needs to be unique, to prevent replay attacks.
Expand Down Expand Up @@ -231,10 +224,6 @@ impl<C: Context> Highway<C> {
}
}

pub(crate) fn state(&self) -> &State<C> {
&self.state
}

fn on_new_vote(&self, vhash: &C::Hash, timestamp: Timestamp) -> Vec<Effect<C>> {
self.active_validator
.as_ref()
Expand Down Expand Up @@ -266,7 +255,7 @@ impl<C: Context> Highway<C> {
fn do_validate_vertex(&self, vertex: &Vertex<C>) -> Result<(), VertexError> {
match vertex {
Vertex::Vote(vote) => Ok(self.state.validate_vote(vote)?),
Vertex::Evidence(evidence) => Ok(()),
Vertex::Evidence(_evidence) => Ok(()),
}
}

Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion node/src/components/consensus/highway_core/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{
cmp::Ordering,
collections::HashMap,
convert::identity,
fmt::{self, Display, Formatter},
iter,
ops::{Div, Mul},
};
Expand Down
12 changes: 7 additions & 5 deletions node/src/components/consensus/highway_core/tallies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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<TestContext>> {
let mut state = State::new(WEIGHTS, 0);
Expand Down
4 changes: 0 additions & 4 deletions node/src/components/consensus/highway_core/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ impl<VID: Eq + Hash> Validators<VID> {
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()
}
Expand Down
2 changes: 0 additions & 2 deletions node/src/components/consensus/highway_core/vertex.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::iter;

use serde::{Deserialize, Serialize};

use super::{evidence::Evidence, validators::ValidatorIndex, vote::Panorama};
Expand Down
7 changes: 2 additions & 5 deletions node/src/components/consensus/highway_core/vote.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down