Log block submit successes and failures (#6069)

This commit is contained in:
teor 2023-02-02 13:27:06 +10:00 committed by GitHub
parent d575e5b40c
commit dc43dca06f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 5 deletions

View File

@ -643,9 +643,18 @@ where
async move { async move {
let block: Block = match block_bytes.zcash_deserialize_into() { let block: Block = match block_bytes.zcash_deserialize_into() {
Ok(block_bytes) => block_bytes, Ok(block_bytes) => block_bytes,
Err(_) => return Ok(submit_block::ErrorResponse::Rejected.into()), Err(error) => {
tracing::info!(?error, "submit block failed");
return Ok(submit_block::ErrorResponse::Rejected.into());
}
}; };
let block_height = block
.coinbase_height()
.map(|height| height.0.to_string())
.unwrap_or_else(|| "invalid coinbase height".to_string());
let chain_verifier_response = chain_verifier let chain_verifier_response = chain_verifier
.ready() .ready()
.await .await
@ -664,13 +673,23 @@ where
// TODO (#5487): // TODO (#5487):
// - Inconclusive: check if the block is on a side-chain // - Inconclusive: check if the block is on a side-chain
// The difference is important to miners, because they want to mine on the best chain. // The difference is important to miners, because they want to mine on the best chain.
Ok(_block_hash) => return Ok(submit_block::Response::Accepted), Ok(block_hash) => {
tracing::info!(?block_hash, ?block_height, "submit block accepted");
return Ok(submit_block::Response::Accepted);
}
// Turns BoxError into Result<VerifyChainError, BoxError>, // Turns BoxError into Result<VerifyChainError, BoxError>,
// by downcasting from Any to VerifyChainError. // by downcasting from Any to VerifyChainError.
Err(box_error) => box_error Err(box_error) => {
.downcast::<VerifyChainError>() let error = box_error
.map(|boxed_chain_error| *boxed_chain_error), .downcast::<VerifyChainError>()
.map(|boxed_chain_error| *boxed_chain_error);
// TODO: add block hash to error?
tracing::info!(?error, ?block_height, "submit block failed");
error
}
}; };
let response = match chain_error { let response = match chain_error {