Skip to content

Commit

Permalink
Storage crate fixed. Updated ReplicaState. Tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoffranca committed Oct 22, 2024
1 parent 015b364 commit f88e39e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions node/libs/storage/src/proto/mod.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ message ReplicaState {
optional uint64 view = 1; // required; ViewNumber
optional roles.validator.Phase phase = 2; // required
optional roles.validator.ReplicaCommit high_vote = 3; // optional
// TODO: name should be high_commit_qc
optional roles.validator.CommitQC high_qc = 4; // optional
repeated Proposal proposals = 5;
optional roles.validator.TimeoutQC high_timeout_qc = 6; // optional
}
13 changes: 9 additions & 4 deletions node/libs/storage/src/replica_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pub struct ReplicaState {
/// The highest block proposal that the replica has committed to.
pub high_vote: Option<validator::ReplicaCommit>,
/// The highest commit quorum certificate known to the replica.
pub high_qc: Option<validator::CommitQC>,
pub high_commit_qc: Option<validator::CommitQC>,
/// The highest timeout quorum certificate known to the replica.
pub high_timeout_qc: Option<validator::TimeoutQC>,
/// A cache of the received block proposals.
pub proposals: Vec<Proposal>,
}
Expand All @@ -52,7 +54,8 @@ impl Default for ReplicaState {
view: validator::ViewNumber(0),
phase: validator::Phase::Prepare,
high_vote: None,
high_qc: None,
high_commit_qc: None,
high_timeout_qc: None,
proposals: vec![],
}
}
Expand Down Expand Up @@ -84,7 +87,8 @@ impl ProtoFmt for ReplicaState {
view: validator::ViewNumber(r.view.context("view_number")?),
phase: read_required(&r.phase).context("phase")?,
high_vote: read_optional(&r.high_vote).context("high_vote")?,
high_qc: read_optional(&r.high_qc).context("high_qc")?,
high_commit_qc: read_optional(&r.high_qc).context("high_commit_qc")?,
high_timeout_qc: read_optional(&r.high_timeout_qc).context("high_timeout_qc")?,
proposals: r
.proposals
.iter()
Expand All @@ -99,7 +103,8 @@ impl ProtoFmt for ReplicaState {
view: Some(self.view.0),
phase: Some(self.phase.build()),
high_vote: self.high_vote.as_ref().map(|x| x.build()),
high_qc: self.high_qc.as_ref().map(|x| x.build()),
high_qc: self.high_commit_qc.as_ref().map(|x| x.build()),
high_timeout_qc: self.high_timeout_qc.as_ref().map(|x| x.build()),
proposals: self.proposals.iter().map(|p| p.build()).collect(),
}
}
Expand Down
3 changes: 2 additions & 1 deletion node/libs/storage/src/testonly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ impl Distribution<ReplicaState> for Standard {
view: rng.gen(),
phase: rng.gen(),
high_vote: rng.gen(),
high_qc: rng.gen(),
high_commit_qc: rng.gen(),
high_timeout_qc: rng.gen(),
proposals: (0..rng.gen_range(1..11)).map(|_| rng.gen()).collect(),
}
}
Expand Down

0 comments on commit f88e39e

Please sign in to comment.