Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
chore: adding feature flag for message signer
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Paitrault <[email protected]>
  • Loading branch information
Freyskeyd committed Apr 17, 2024
1 parent 1d652f1 commit f9b0ba7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions crates/topos-tce-broadcast/src/double_echo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ use topos_tce_storage::types::CertificateDeliveredWithPositions;
use topos_tce_storage::validator::ValidatorStore;
use tracing::{debug, error, info, warn};

lazy_static::lazy_static! {
pub static ref TOPOS_CHECK_MESSAGE_SIGNATURE: bool =
std::env::var("TOPOS_CHECK_MESSAGE_SIGNATURE")
.map(|v| v.to_lowercase() == "true")
.ok()
.unwrap_or(true);
}

pub mod broadcast_state;

pub struct DoubleEcho {
Expand Down Expand Up @@ -154,9 +162,11 @@ impl DoubleEcho {
payload.extend_from_slice(certificate_id.as_array());
payload.extend_from_slice(validator_id.as_bytes());

if let Err(e) = self.message_signer.verify_signature(signature, &payload, validator_id.address()) {
debug!("ECHO message signature cannot be verified from: {}", e);
continue;
if *TOPOS_CHECK_MESSAGE_SIGNATURE {
if let Err(e) = self.message_signer.verify_signature(signature, &payload, validator_id.address()) {
debug!("ECHO message signature cannot be verified from: {}", e);
continue;
}
}

self.handle_echo(certificate_id, validator_id, signature).await
Expand All @@ -172,9 +182,11 @@ impl DoubleEcho {
payload.extend_from_slice(certificate_id.as_array());
payload.extend_from_slice(validator_id.as_bytes());

if let Err(e) = self.message_signer.verify_signature(signature, &payload, validator_id.address()) {
debug!("READY message signature cannot be verified from: {}", e);
continue;
if *TOPOS_CHECK_MESSAGE_SIGNATURE {
if let Err(e) = self.message_signer.verify_signature(signature, &payload, validator_id.address()) {
debug!("READY message signature cannot be verified from: {}", e);
continue;
}
}

self.handle_ready(certificate_id, validator_id, signature).await
Expand Down

0 comments on commit f9b0ba7

Please sign in to comment.