diff --git a/Code/common/src/validator_set.rs b/Code/common/src/validator_set.rs index b0288c033..317085c44 100644 --- a/Code/common/src/validator_set.rs +++ b/Code/common/src/validator_set.rs @@ -3,8 +3,6 @@ use core::fmt::{Debug, Display}; use crate::{Context, PublicKey}; /// Voting power held by a validator. -/// -/// TODO: Do we need to abstract over this as well? pub type VotingPower = u64; /// Defines the requirements for an address. diff --git a/Code/driver/src/driver.rs b/Code/driver/src/driver.rs index c6c960fff..8802b101f 100644 --- a/Code/driver/src/driver.rs +++ b/Code/driver/src/driver.rs @@ -45,11 +45,9 @@ where proposer_selector: impl ProposerSelector + 'static, validator_set: Ctx::ValidatorSet, address: Ctx::Address, + threshold_params: ThresholdParams, ) -> Self { - let votes = VoteKeeper::new( - validator_set.total_voting_power(), - ThresholdParams::default(), // TODO: Make this configurable - ); + let votes = VoteKeeper::new(validator_set.total_voting_power(), threshold_params); Self { ctx, diff --git a/Code/test/src/utils.rs b/Code/test/src/utils.rs index a77367496..ad8eb6805 100644 --- a/Code/test/src/utils.rs +++ b/Code/test/src/utils.rs @@ -192,11 +192,6 @@ pub fn propose_state_with_proposal_and_valid( valid_round: Round, proposal: Proposal, ) -> State { - // TODO - set_valid doesn't work because the valid round is set to state round - // we need to set it to something different. - // propose_state(round) - // .set_proposal(proposal.clone()) - // .set_valid(proposal.value) State { height: Height::new(1), round: state_round, diff --git a/Code/test/src/validator_set.rs b/Code/test/src/validator_set.rs index 35b8462f5..122ca78b4 100644 --- a/Code/test/src/validator_set.rs +++ b/Code/test/src/validator_set.rs @@ -87,7 +87,6 @@ impl ValidatorSet { /// The total voting power of the validator set pub fn total_voting_power(&self) -> VotingPower { - // TODO: Cache this? self.validators.iter().map(|v| v.voting_power).sum() } @@ -115,7 +114,7 @@ impl ValidatorSet { pub fn remove(&mut self, address: &Address) { self.validators.retain(|v| &v.address != address); - Self::sort_validators(&mut self.validators); // TODO: Not needed + Self::sort_validators(&mut self.validators); } /// Get a validator by its address diff --git a/Code/test/tests/driver.rs b/Code/test/tests/driver.rs index 69cf3cb7e..2d5e017df 100644 --- a/Code/test/tests/driver.rs +++ b/Code/test/tests/driver.rs @@ -37,7 +37,7 @@ fn driver_steps_proposer() { let sel = FixedProposer::new(my_addr); let vs = ValidatorSet::new(vec![v1, v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let proposal = Proposal::new(Height::new(1), Round::new(0), value, Round::new(-1)); @@ -218,7 +218,7 @@ fn driver_steps_proposer_timeout_get_value() { let sel = FixedProposer::new(my_addr); let vs = ValidatorSet::new(vec![v1, v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -270,7 +270,7 @@ fn driver_steps_not_proposer_valid() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let proposal = Proposal::new(Height::new(1), Round::new(0), value, Round::new(-1)); @@ -439,7 +439,7 @@ fn driver_steps_not_proposer_invalid() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let proposal = Proposal::new(Height::new(1), Round::new(0), value, Round::new(-1)); @@ -548,7 +548,7 @@ fn driver_steps_not_proposer_other_height() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); // Proposal is for another height let proposal = Proposal::new(Height::new(2), Round::new(0), value, Round::new(-1)); @@ -598,7 +598,7 @@ fn driver_steps_not_proposer_other_round() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); // Proposal is for another round let proposal = Proposal::new(Height::new(1), Round::new(1), value, Round::new(-1)); @@ -648,7 +648,7 @@ fn driver_steps_not_proposer_timeout_multiple_rounds() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ // Start round 0, we, v3, are not the proposer @@ -820,7 +820,7 @@ fn driver_steps_no_value_to_propose() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let mut outputs = block_on(driver.process(Input::NewRound(Height::new(1), Round::new(0)))) .expect("execute succeeded"); @@ -848,7 +848,7 @@ fn driver_steps_proposer_not_found() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let output = block_on(driver.process(Input::NewRound(Height::new(1), Round::new(0)))); assert_eq!(output, Err(Error::ProposerNotFound(v1.address))); @@ -868,7 +868,7 @@ fn driver_steps_validator_not_found() { // We omit v2 from the validator set let vs = ValidatorSet::new(vec![v1.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); // Start new height block_on(driver.process(Input::NewRound(Height::new(1), Round::new(0)))) @@ -894,7 +894,7 @@ fn driver_steps_invalid_signature() { let sel = FixedProposer::new(v1.address); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); // Start new round block_on(driver.process(Input::NewRound(Height::new(1), Round::new(0)))) @@ -924,7 +924,7 @@ fn driver_steps_skip_round_skip_threshold() { let height = Height::new(1); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ // Start round 0, we, v3, are not the proposer @@ -1023,7 +1023,7 @@ fn driver_steps_skip_round_quorum_threshold() { let height = Height::new(1); let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ // Start round 0, we, v3, are not the proposer diff --git a/Code/test/tests/driver_extra.rs b/Code/test/tests/driver_extra.rs index afcfe841f..d49840909 100644 --- a/Code/test/tests/driver_extra.rs +++ b/Code/test/tests/driver_extra.rs @@ -35,7 +35,6 @@ use malachite_test::utils::*; // - L34 with previously received polkaAny and entering prevote (due to received poposal) // `driver_steps_polka_any_then_proposal_other()` -// TODO - move all below to utils? struct TestStep { desc: &'static str, input: Input, @@ -79,7 +78,7 @@ fn driver_steps_decide_current_with_no_locked_no_valid() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -151,7 +150,7 @@ fn driver_steps_decide_previous_with_no_locked_no_valid() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -251,7 +250,7 @@ fn driver_steps_decide_previous_with_locked_and_valid() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -371,7 +370,7 @@ fn driver_steps_polka_previous_with_locked() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -478,7 +477,7 @@ fn driver_steps_polka_previous_invalid_proposal() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -576,7 +575,7 @@ fn driver_steps_polka_previous_with_no_locked() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -684,7 +683,7 @@ fn driver_steps_polka_nil_and_timout_propose() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -744,7 +743,7 @@ fn driver_steps_polka_value_then_proposal() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep { @@ -807,7 +806,7 @@ fn driver_steps_polka_any_then_proposal_other() { let sel = RotateProposer; let vs = ValidatorSet::new(vec![v1.clone(), v2.clone(), v3.clone()]); - let mut driver = Driver::new(ctx, sel, vs, my_addr); + let mut driver = Driver::new(ctx, sel, vs, my_addr, Default::default()); let steps = vec![ TestStep {