message: [safety-rules] log output errors for serialized safety-rules
  Closes:
  Approved by: mgorven
diff: @@ -7,6 +7,7 @@ use consensus_types::{
  vote_proposal::VoteProposal,
  };
  use libra_crypto::ed25519::Ed25519Signature;
  +use libra_logger::warn;
  use libra_types::epoch_change::EpochChangeProof;
  use serde::{Deserialize, Serialize};
  use std::sync::{Arc, RwLock};
  @@ -34,17 +35,22 @@ impl SerializerService {
  let input = lcs::from_bytes(&input_message)?;
  let output = match input {
  - SafetyRulesInput::ConsensusState => lcs::to_bytes(&self.internal.consensus_state()),
  - SafetyRulesInput::Initialize(li) => lcs::to_bytes(&self.internal.initialize(&li)),
  - SafetyRulesInput::Update(qc) => lcs::to_bytes(&self.internal.update(&qc)),
  - SafetyRulesInput::ConstructAndSignVote(vote_proposal) => {
  - lcs::to_bytes(&self.internal.construct_and_sign_vote(&vote_proposal))
  + SafetyRulesInput::ConsensusState => {
  + log_and_serialize(self.internal.consensus_state(), "ConsensusState")
  }
  + SafetyRulesInput::Initialize(li) => {
  + log_and_serialize(self.internal.initialize(&li), "Initialize")
  + }
  + SafetyRulesInput::Update(qc) => log_and_serialize(self.internal.update(&qc), "Update"),
  + SafetyRulesInput::ConstructAndSignVote(vote_proposal) => log_and_serialize(
  + self.internal.construct_and_sign_vote(&vote_proposal),
  + "ConstructAndSignVote",
  + ),
  SafetyRulesInput::SignProposal(block_data) => {
  - lcs::to_bytes(&self.internal.sign_proposal(*block_data))
  + log_and_serialize(self.internal.sign_proposal(*block_data), "SignProposal")
  }
  SafetyRulesInput::SignTimeout(timeout) => {
  - lcs::to_bytes(&self.internal.sign_timeout(&timeout))
  + log_and_serialize(self.internal.sign_timeout(&timeout), "SignTimeout")
  }
  };
  @@ -52,6 +58,16 @@ impl SerializerService {
  }
  }
  +fn log_and_serialize<T: Serialize>(
  + response: Result<T, Error>,
  + from: &'static str,
  +) -> Result<Vec<u8>, lcs::Error> {
  + if let Err(e) = &response {
  + warn!("[SafetyRules] {} failed: {}", from, e);
  + }
  + lcs::to_bytes(&response)
  +}
  +
  pub struct SerializerClient {
  service: Box<dyn TSerializerClient>,
  }
  