From f88e39e7976f5981fb4120e500b14ba86de3caf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Tue, 22 Oct 2024 16:32:27 +0100 Subject: [PATCH] Storage crate fixed. Updated ReplicaState. Tests pass. --- node/libs/storage/src/proto/mod.proto | 2 ++ node/libs/storage/src/replica_store.rs | 13 +++++++++---- node/libs/storage/src/testonly/mod.rs | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/node/libs/storage/src/proto/mod.proto b/node/libs/storage/src/proto/mod.proto index e06e84da..50744fd3 100644 --- a/node/libs/storage/src/proto/mod.proto +++ b/node/libs/storage/src/proto/mod.proto @@ -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 } diff --git a/node/libs/storage/src/replica_store.rs b/node/libs/storage/src/replica_store.rs index 465d26d6..da7698ff 100644 --- a/node/libs/storage/src/replica_store.rs +++ b/node/libs/storage/src/replica_store.rs @@ -41,7 +41,9 @@ pub struct ReplicaState { /// The highest block proposal that the replica has committed to. pub high_vote: Option, /// The highest commit quorum certificate known to the replica. - pub high_qc: Option, + pub high_commit_qc: Option, + /// The highest timeout quorum certificate known to the replica. + pub high_timeout_qc: Option, /// A cache of the received block proposals. pub proposals: Vec, } @@ -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![], } } @@ -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() @@ -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(), } } diff --git a/node/libs/storage/src/testonly/mod.rs b/node/libs/storage/src/testonly/mod.rs index c36d3b74..e52293ea 100644 --- a/node/libs/storage/src/testonly/mod.rs +++ b/node/libs/storage/src/testonly/mod.rs @@ -26,7 +26,8 @@ impl Distribution 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(), } }