-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse traces for the vote keeper spec
- Loading branch information
Showing
7 changed files
with
2,950 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
use itf::ItfMap; | ||
use serde::Deserialize; | ||
|
||
use crate::deserializers as de; | ||
|
||
pub type Address = String; | ||
pub type Value = String; | ||
pub type Step = String; | ||
pub type Round = i64; | ||
pub type Height = i64; | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub enum Timeout { | ||
#[serde(rename = "timeoutPrevote")] | ||
Prevote, | ||
|
||
#[serde(rename = "timeoutPrecommit")] | ||
Precommit, | ||
|
||
#[serde(rename = "timeoutPropose")] | ||
Propose, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub struct State { | ||
pub system: System, | ||
|
||
#[serde(rename = "_Event")] | ||
pub event: Event, | ||
|
||
#[serde(rename = "_Result")] | ||
pub result: Result, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub struct System(ItfMap<Address, ConsensusState>); | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(tag = "name")] | ||
pub enum Event { | ||
Initial, | ||
NewRound { | ||
height: Height, | ||
round: Round, | ||
}, | ||
Proposal { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
ProposalAndPolkaAndValid { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
ProposalAndCommitAndValid { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
NewHeight { | ||
height: Height, | ||
round: Round, | ||
}, | ||
NewRoundProposer { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
PolkaNil { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
PolkaAny { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
PrecommitAny { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
TimeoutPrevote { | ||
height: Height, | ||
round: Round, | ||
}, | ||
TimeoutPrecommit { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
TimeoutPropose { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
ProposalInvalid { | ||
height: Height, | ||
round: Round, | ||
}, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Result { | ||
pub name: String, | ||
#[serde(deserialize_with = "de::proposal_or_none")] | ||
pub proposal: Option<Proposal>, | ||
#[serde(deserialize_with = "de::vote_message_or_none")] | ||
pub vote_message: Option<VoteMessage>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub timeout: Option<Timeout>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub decided: Option<Value>, | ||
#[serde(deserialize_with = "de::minus_one_as_none")] | ||
pub skip_round: Option<Round>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Proposal { | ||
pub src: Address, | ||
pub height: Height, | ||
pub round: Round, | ||
pub proposal: Value, | ||
pub valid_round: Round, | ||
} | ||
|
||
impl Proposal { | ||
pub fn is_empty(&self) -> bool { | ||
self.src.is_empty() | ||
&& self.proposal.is_empty() | ||
&& self.height == -1 | ||
&& self.round == -1 | ||
&& self.valid_round == -1 | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct VoteMessage { | ||
pub src: Address, | ||
pub height: Height, | ||
pub round: Round, | ||
pub step: Step, | ||
pub id: Value, | ||
} | ||
|
||
impl VoteMessage { | ||
pub fn is_empty(&self) -> bool { | ||
self.src.is_empty() | ||
&& self.id.is_empty() | ||
&& self.height == -1 | ||
&& self.round == -1 | ||
&& self.step.is_empty() | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ConsensusState { | ||
pub p: Address, | ||
pub height: Height, | ||
pub round: Round, | ||
pub step: Step, | ||
|
||
#[serde(deserialize_with = "de::minus_one_as_none")] | ||
pub locked_round: Option<Round>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub locked_value: Option<Value>, | ||
#[serde(deserialize_with = "de::minus_one_as_none")] | ||
pub valid_round: Option<Round>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub valid_value: Option<Value>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,178 +1,4 @@ | ||
use itf::ItfMap; | ||
use serde::Deserialize; | ||
pub mod consensus; | ||
pub mod votekeeper; | ||
|
||
mod deserializers; | ||
use deserializers as de; | ||
|
||
pub type Address = String; | ||
pub type Value = String; | ||
pub type Step = String; | ||
pub type Round = i64; | ||
pub type Height = i64; | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub enum Timeout { | ||
#[serde(rename = "timeoutPrevote")] | ||
Prevote, | ||
|
||
#[serde(rename = "timeoutPrecommit")] | ||
Precommit, | ||
|
||
#[serde(rename = "timeoutPropose")] | ||
Propose, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub struct ItfState { | ||
pub system: System, | ||
|
||
#[serde(rename = "_Event")] | ||
pub event: Event, | ||
|
||
#[serde(rename = "_Result")] | ||
pub result: Result, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub struct System(ItfMap<Address, ConsensusState>); | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(tag = "name")] | ||
pub enum Event { | ||
Initial, | ||
NewRound { | ||
height: Height, | ||
round: Round, | ||
}, | ||
Proposal { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
ProposalAndPolkaAndValid { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
ProposalAndCommitAndValid { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
NewHeight { | ||
height: Height, | ||
round: Round, | ||
}, | ||
NewRoundProposer { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
PolkaNil { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
PolkaAny { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
PrecommitAny { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
TimeoutPrevote { | ||
height: Height, | ||
round: Round, | ||
}, | ||
TimeoutPrecommit { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
TimeoutPropose { | ||
height: Height, | ||
round: Round, | ||
value: Value, | ||
}, | ||
ProposalInvalid { | ||
height: Height, | ||
round: Round, | ||
}, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Result { | ||
pub name: String, | ||
#[serde(deserialize_with = "de::proposal_or_none")] | ||
pub proposal: Option<Proposal>, | ||
#[serde(deserialize_with = "de::vote_message_or_none")] | ||
pub vote_message: Option<VoteMessage>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub timeout: Option<Timeout>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub decided: Option<Value>, | ||
#[serde(deserialize_with = "de::minus_one_as_none")] | ||
pub skip_round: Option<Round>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Proposal { | ||
pub src: Address, | ||
pub height: Height, | ||
pub round: Round, | ||
pub proposal: Value, | ||
pub valid_round: Round, | ||
} | ||
|
||
impl Proposal { | ||
pub fn is_empty(&self) -> bool { | ||
self.src.is_empty() | ||
&& self.proposal.is_empty() | ||
&& self.height == -1 | ||
&& self.round == -1 | ||
&& self.valid_round == -1 | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct VoteMessage { | ||
pub src: Address, | ||
pub height: Height, | ||
pub round: Round, | ||
pub step: Step, | ||
pub id: Value, | ||
} | ||
|
||
impl VoteMessage { | ||
pub fn is_empty(&self) -> bool { | ||
self.src.is_empty() | ||
&& self.id.is_empty() | ||
&& self.height == -1 | ||
&& self.round == -1 | ||
&& self.step.is_empty() | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct ConsensusState { | ||
pub p: Address, | ||
pub height: Height, | ||
pub round: Round, | ||
pub step: Step, | ||
|
||
#[serde(deserialize_with = "de::minus_one_as_none")] | ||
pub locked_round: Option<Round>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub locked_value: Option<Value>, | ||
#[serde(deserialize_with = "de::minus_one_as_none")] | ||
pub valid_round: Option<Round>, | ||
#[serde(deserialize_with = "de::empty_string_as_none")] | ||
pub valid_value: Option<Value>, | ||
} |
Oops, something went wrong.