From 02f0f8d482b6b3072bea2127bd7c914140ae640b Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Mon, 12 Feb 2024 10:45:49 +0100 Subject: [PATCH] consensus: change `CertificateInfo` to use `RatificationResult` --- consensus/src/commons.rs | 4 ++-- consensus/src/execution_ctx.rs | 2 +- consensus/src/quorum/task.rs | 4 ++-- consensus/src/quorum/verifiers.rs | 4 ++-- consensus/src/ratification/handler.rs | 2 +- consensus/src/step_votes_reg.rs | 12 ++++++------ 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/consensus/src/commons.rs b/consensus/src/commons.rs index 11b6fab50b..574932df4e 100644 --- a/consensus/src/commons.rs +++ b/consensus/src/commons.rs @@ -148,11 +148,11 @@ impl QuorumMsgSender { Payload::Quorum(q) if !q.validation.is_empty() && !q.ratification.is_empty() - && q.vote != Vote::NoCandidate => + && q.vote() != &Vote::NoCandidate => { tracing::debug!( event = "send quorum_msg", - vote = %q.vote, + vote = %q.vote(), round = msg.header.round, iteration = msg.header.iteration, validation = ?q.validation, diff --git a/consensus/src/execution_ctx.rs b/consensus/src/execution_ctx.rs index 64108d4342..0d4c40d3f3 100644 --- a/consensus/src/execution_ctx.rs +++ b/consensus/src/execution_ctx.rs @@ -241,7 +241,7 @@ impl<'a, DB: Database, T: Operations + 'static> ExecutionCtx<'a, DB, T> { event = "quorum", src = "prev_step", msg_step = m.get_step(), - vote = %q.vote, + vote = %q.vote(), ); self.quorum_sender.send_quorum(m).await; diff --git a/consensus/src/quorum/task.rs b/consensus/src/quorum/task.rs index bd5e19e56c..f634d97004 100644 --- a/consensus/src/quorum/task.rs +++ b/consensus/src/quorum/task.rs @@ -161,11 +161,11 @@ impl<'p, D: Database> Executor<'p, D> { // Publish the quorum self.publish(msg.clone()).await; - if let Vote::Valid(hash) = quorum.vote { + if let Vote::Valid(hash) = quorum.vote() { // Create winning block debug!("generate block from quorum msg"); let cert = quorum.generate_certificate(); - return self.create_winning_block(&hash, &cert).await; + return self.create_winning_block(hash, &cert).await; } } diff --git a/consensus/src/quorum/verifiers.rs b/consensus/src/quorum/verifiers.rs index 87d3fb0036..2ec87078ca 100644 --- a/consensus/src/quorum/verifiers.rs +++ b/consensus/src/quorum/verifiers.rs @@ -28,7 +28,7 @@ pub async fn verify_quorum( // Verify validation verify_step_votes( &quorum.header, - &quorum.vote, + quorum.vote(), &quorum.validation, committees_set, seed, @@ -47,7 +47,7 @@ pub async fn verify_quorum( // Verify ratification verify_step_votes( &quorum.header, - &quorum.vote, + quorum.vote(), &quorum.ratification, committees_set, seed, diff --git a/consensus/src/ratification/handler.rs b/consensus/src/ratification/handler.rs index 976eddf412..87ec0b54de 100644 --- a/consensus/src/ratification/handler.rs +++ b/consensus/src/ratification/handler.rs @@ -191,7 +191,7 @@ impl RatificationHandler { let quorum = payload::Quorum { header, - vote, + result: vote.into(), validation, ratification, }; diff --git a/consensus/src/step_votes_reg.rs b/consensus/src/step_votes_reg.rs index 18090e97c3..6019aca993 100644 --- a/consensus/src/step_votes_reg.rs +++ b/consensus/src/step_votes_reg.rs @@ -7,7 +7,7 @@ use crate::commons::RoundUpdate; use node_data::bls::PublicKeyBytes; use node_data::ledger::{Certificate, IterationInfo, StepVotes}; -use node_data::message::payload::Vote; +use node_data::message::payload::{RatificationResult, Vote}; use node_data::message::{payload, Message}; use node_data::StepName; use std::collections::HashMap; @@ -18,7 +18,7 @@ use tracing::{debug, warn}; #[derive(Clone)] struct CertificateInfo { - vote: Vote, + result: RatificationResult, cert: Certificate, quorum_reached_validation: bool, @@ -29,8 +29,8 @@ impl fmt::Display for CertificateInfo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, - "cert_info: {}, validation: ({:?},{:?}), ratification: ({:?},{:?}) ", - self.vote, + "cert_info: {:?}, validation: ({:?},{:?}), ratification: ({:?},{:?}) ", + self.result, self.cert.validation, self.quorum_reached_validation, self.cert.ratification, @@ -42,7 +42,7 @@ impl fmt::Display for CertificateInfo { impl CertificateInfo { pub(crate) fn new(vote: Vote) -> Self { CertificateInfo { - vote, + result: vote.into(), cert: Certificate::default(), quorum_reached_validation: false, quorum_reached_ratification: false, @@ -185,7 +185,7 @@ impl CertInfoRegistry { let payload = payload::Quorum { header, - vote: result.vote.clone(), + result: result.result.clone(), validation: result.cert.validation, ratification: result.cert.ratification, };