Skip to content

Commit

Permalink
spec: Renaming and cleanup (#94)
Browse files Browse the repository at this point in the history
* Remove ITF trace

* Rename executor to driver

* Rename output of votekeeper to `VoteKeeperOutput`

* Rename `Event` to `ConsensusInput`

* Rename `ProposeMsg_t` to `Proposal_t` and `VoteMsg_t` to `Vote_t`

* Cleanup

* Rename `PendingEvent` to `PendingInput`

* Fix last remaining instances of `result and `event`

* Fix ITF structs

* Cleanup in Rust code
  • Loading branch information
romac authored Nov 30, 2023
1 parent 4c5a1a7 commit d4090cb
Show file tree
Hide file tree
Showing 12 changed files with 418 additions and 421 deletions.
6 changes: 3 additions & 3 deletions Code/itf/src/votekeeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct RoundVotes {
pub round: Round,
pub prevotes: VoteCount,
pub precommits: VoteCount,
pub emitted_events: HashSet<ExecutorEvent>,
pub emitted_outputs: HashSet<VoteKeeperOutput>,
#[serde(with = "As::<HashMap<Same, Integer>>")]
pub votes_addresses_weights: HashMap<Address, Weight>,
}
Expand All @@ -57,7 +57,7 @@ pub struct VoteCount {
}

#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Hash)]
pub struct ExecutorEvent {
pub struct VoteKeeperOutput {
#[serde(with = "As::<Integer>")]
pub round: Round,
pub name: String,
Expand All @@ -69,7 +69,7 @@ pub struct State {
#[serde(rename = "voteBookkeeperTest::voteBookkeeperSM::bookkeeper")]
pub bookkeeper: Bookkeeper,
#[serde(rename = "voteBookkeeperTest::voteBookkeeperSM::lastEmitted")]
pub last_emitted: ExecutorEvent,
pub last_emitted: VoteKeeperOutput,
#[serde(rename = "voteBookkeeperTest::voteBookkeeperSM::weightedVote")]
#[serde(with = "As::<(Same, Integer, Integer)>")]
pub weighted_vote: (Vote, Weight, Round),
Expand Down
12 changes: 6 additions & 6 deletions Code/itf/tests/votekeeper/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,23 @@ impl ItfRunner for VoteKeeperRunner {

let actual_round = actual_state.per_round().get(&Round::new(round)).unwrap();

let expected_events = &expected_round.emitted_events;
let actual_events = actual_round.emitted_msgs();
let expected_outputs = &expected_round.emitted_outputs;
let actual_outputs = actual_round.emitted_outputs();

assert_eq!(
actual_events.len(),
expected_events.len(),
actual_outputs.len(),
expected_outputs.len(),
"number of emitted events"
);

let mut event_count = HashMap::new();

for event in expected_events {
for event in expected_outputs {
let count = event_count.entry(event.name.clone()).or_insert(0);
*count += 1;
}

for event in actual_events {
for event in actual_outputs {
let event_name = match event {
Output::PolkaValue(_) => "PolkaValue".into(),
Output::PrecommitValue(_) => "PrecommitValue".into(),
Expand Down
18 changes: 9 additions & 9 deletions Code/vote/src/keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ where
{
votes: RoundVotes<Ctx::Address, ValueId<Ctx>>,
addresses_weights: RoundWeights<Ctx::Address>,
emitted_msgs: BTreeSet<Output<ValueId<Ctx>>>,
emitted_outputs: BTreeSet<Output<ValueId<Ctx>>>,
}

impl<Ctx> PerRound<Ctx>
Expand All @@ -36,7 +36,7 @@ where
Self {
votes: RoundVotes::new(),
addresses_weights: RoundWeights::new(),
emitted_msgs: BTreeSet::new(),
emitted_outputs: BTreeSet::new(),
}
}

Expand All @@ -48,8 +48,8 @@ where
&self.addresses_weights
}

pub fn emitted_msgs(&self) -> &BTreeSet<Output<ValueId<Ctx>>> {
&self.emitted_msgs
pub fn emitted_outputs(&self) -> &BTreeSet<Output<ValueId<Ctx>>> {
&self.emitted_outputs
}
}

Expand All @@ -62,7 +62,7 @@ where
Self {
votes: self.votes.clone(),
addresses_weights: self.addresses_weights.clone(),
emitted_msgs: self.emitted_msgs.clone(),
emitted_outputs: self.emitted_outputs.clone(),
}
}
}
Expand All @@ -76,7 +76,7 @@ where
f.debug_struct("PerRound")
.field("votes", &self.votes)
.field("addresses_weights", &self.addresses_weights)
.field("emitted_msgs", &self.emitted_msgs)
.field("emitted_outputs", &self.emitted_outputs)
.finish()
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ where

if skip_round {
let msg = Output::SkipRound(vote.round());
round.emitted_msgs.insert(msg.clone());
round.emitted_outputs.insert(msg.clone());
return Some(msg);
}
}
Expand All @@ -160,8 +160,8 @@ where
let msg = threshold_to_output(vote.vote_type(), vote.round(), threshold);

match msg {
Some(msg) if !round.emitted_msgs.contains(&msg) => {
round.emitted_msgs.insert(msg.clone());
Some(msg) if !round.emitted_outputs.contains(&msg) => {
round.emitted_outputs.insert(msg.clone());
Some(msg)
}
_ => None,
Expand Down
1 change: 0 additions & 1 deletion Specs/Quint/0DecideNonProposerTest.itf.json

This file was deleted.

2 changes: 1 addition & 1 deletion Specs/Quint/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parse:
npx @informalsystems/quint parse asyncModelsTest.qnt
npx @informalsystems/quint parse consensusTest.qnt
npx @informalsystems/quint parse executor.qnt
npx @informalsystems/quint parse driver.qnt
npx @informalsystems/quint parse statemachineTest.qnt
npx @informalsystems/quint parse voteBookkeeperTest.qnt
.PHONY: parse
Expand Down
Loading

0 comments on commit d4090cb

Please sign in to comment.