Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
Log signing message type during attempted double sign events
Browse files Browse the repository at this point in the history
It seems possible the KMS might be rejecting some potentially valid
`<nil>` PreCommits, however it's difficult to ascertain right now as
this information isn't presently logged as part of the double signing
error message.

This adds additional logging (and also extracts the double signing
handler into its own function)
  • Loading branch information
tony-iqlusion committed Aug 8, 2019
1 parent a77998c commit 85dac58
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,10 @@ impl Session {
if let Err(e) = chain_state.update_consensus_state(request_state.clone()) {
// Report double signing error back to the validator
if e.kind() == StateErrorKind::DoubleSign {
let height = request.height().unwrap();

error!(
"[{}:{}] attempted double sign at h/r/s: {} ({} != {})",
&self.config.chain_id,
&self.config.addr,
request_state,
chain_state.consensus_state().block_id_prefix(),
request_state.block_id_prefix()
return self.handle_double_signing(
request,
&chain_state.consensus_state().block_id_prefix(),
);

let remote_err = RemoteError::double_sign(height);
return Ok(request.build_response(Some(remote_err)));
} else {
return Err(e.into());
}
Expand Down Expand Up @@ -214,4 +205,31 @@ impl Session {
started_at.elapsed().as_millis(),
);
}

/// Handle attempted double signing
fn handle_double_signing<T: TendermintRequest + Debug>(
&self,
request: T,
original_block_id: &str,
) -> Result<Response, Error> {
let msg_type = request
.msg_type()
.map(|t| format!("{:?}", t))
.unwrap_or_else(|| "Unknown".to_owned());

let request_state = request.consensus_state().unwrap();

error!(
"[{}:{}] attempted double sign for {} at h/r/s: {} ({} != {})",
&self.config.chain_id,
&self.config.addr,
msg_type,
request_state,
original_block_id,
request_state.block_id_prefix()
);

let remote_err = RemoteError::double_sign(request.height().unwrap());
return Ok(request.build_response(Some(remote_err)));
}
}

0 comments on commit 85dac58

Please sign in to comment.