From 39c87a0ee2597a3345da368e293c2787bde90d70 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:48:41 +0200 Subject: [PATCH 1/9] feat(proto): DeriveFrom for ABCI Request Value --- proto-compiler/src/constants.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/proto-compiler/src/constants.rs b/proto-compiler/src/constants.rs index e7e6a649..a328e4a2 100644 --- a/proto-compiler/src/constants.rs +++ b/proto-compiler/src/constants.rs @@ -90,6 +90,7 @@ pub static CUSTOM_TYPE_ATTRIBUTES: &[(&str, &str)] = &[ (".tendermint.types.TxProof", SERIALIZED), (".tendermint.crypto.Proof", SERIALIZED), (".tendermint.abci.Response.value", DERIVE_FROM), + (".tendermint.abci.Request.value", DERIVE_FROM), ]; /// Custom field attributes applied on top of protobuf fields in (a) struct(s) From b9a6c538b3a3e1fd5477749e832542a34307381f Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:36:21 +0200 Subject: [PATCH 2/9] feat(abci): add tracing spans --- abci/Cargo.toml | 3 +- abci/src/application.rs | 85 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/abci/Cargo.toml b/abci/Cargo.toml index b6f5390a..a8f7a34f 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -11,7 +11,7 @@ description = """tenderdash-abci provides a simple framework with which to build low-level applications on top of Tenderdash.""" [features] -default = ["server", "docker-tests", "crypto", "tcp", "unix"] +default = ["server", "docker-tests", "crypto", "tcp", "unix", "tracing-span"] # docker-tests includes integration tests that require docker to be available docker-tests = ["server"] server = [ @@ -23,6 +23,7 @@ server = [ crypto = ["dep:lhash"] tcp = ["server"] unix = ["server"] +tracing-span = [] [[example]] name = "echo_socket" diff --git a/abci/src/application.rs b/abci/src/application.rs index c16935f1..80d01877 100644 --- a/abci/src/application.rs +++ b/abci/src/application.rs @@ -1,6 +1,8 @@ //! ABCI application interface. -use tracing::debug; +use hex::ToHex; +use tenderdash_proto::abci::request::Value; +use tracing::{debug, Level}; use crate::proto::{ abci, @@ -150,6 +152,8 @@ pub trait RequestDispatcher { // Implement `RequestDispatcher` for all `Application`s. impl RequestDispatcher for A { fn handle(&self, request: abci::Request) -> Option { + #[cfg(feature = "tracing-span")] + let _span = enter_span(request.clone().value?); tracing::trace!(?request, "received request"); let response: Result = match request.value? { @@ -188,6 +192,85 @@ impl RequestDispatcher for A { }) } } +#[cfg(feature = "tracing-span")] +fn enter_span(request: T) -> tracing::span::EnteredSpan +where + T: Into, +{ + let value = request.into(); + const SPAN_NAME: &str = "abci"; + const LEVEL: Level = Level::ERROR; + let endpoint = abci_method_name(&value); + + let span = match value { + Value::Info(r) => tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + tenderdash_version = r.version, + block_version = r.block_version, + p2p_version = r.p2p_version, + ), + Value::InitChain(r) => { + tracing::span!(LEVEL, SPAN_NAME, endpoint, chain_id = r.chain_id) + }, + Value::PrepareProposal(r) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + height = r.height, + round = r.round, + quorum_hash = r.quorum_hash.encode_hex::(), + core_locked_height = r.core_chain_locked_height, + ) + }, + Value::ProcessProposal(r) => tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + r.height, + r.round, + quorum_hash = r.quorum_hash.encode_hex::(), + r.core_chain_locked_height, + ), + Value::ExtendVote(r) => tracing::span!(LEVEL, SPAN_NAME, endpoint, r.height, r.round), + Value::VerifyVoteExtension(r) => { + tracing::span!(LEVEL, SPAN_NAME, endpoint, r.height, r.round) + }, + Value::FinalizeBlock(r) => tracing::span!(LEVEL, SPAN_NAME, endpoint, r.height, r.round), + Value::CheckTx(r) => { + tracing::span!(LEVEL, SPAN_NAME, endpoint, tx = r.tx.encode_hex::()) + }, + Value::Query(r) => { + tracing::span!(LEVEL, SPAN_NAME, endpoint, path = r.path) + }, + _ => tracing::span!(LEVEL, SPAN_NAME, endpoint), + }; + + span.entered() +} +#[cfg(feature = "tracing-span")] +fn abci_method_name(request: &Value) -> String { + match request { + Value::ApplySnapshotChunk(_) => "ApplySnapshotChunk", + Value::CheckTx(_) => "CheckTx", + Value::Echo(_) => "Echo", + Value::ExtendVote(_) => "ExtendVote", + Value::FinalizeBlock(_) => "FinalizeBlock", + Value::Flush(_) => "Flush", + Value::Info(_) => "Info", + Value::InitChain(_) => "InitChain", + Value::ListSnapshots(_) => "ListSnapshots", + Value::LoadSnapshotChunk(_) => "LoadSnapshotChunk", + Value::OfferSnapshot(_) => "OfferSnapshot", + Value::PrepareProposal(_) => "PrepareProposal", + Value::ProcessProposal(_) => "ProcessProposal", + Value::Query(_) => "Query", + Value::VerifyVoteExtension(_) => "VerifyVoteExtension", + } + .to_string() +} /// Check if ABCI version sent by Tenderdash matches version of linked protobuf /// data objects. From a2fee50c7f01a6c5e0eda00f3b9a2ce8a52b140d Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 14:17:58 +0200 Subject: [PATCH 3/9] feat: add request id to tracing span --- abci/Cargo.toml | 3 +- abci/src/application.rs | 85 +-------------------------- abci/src/lib.rs | 2 + abci/src/tracing_span.rs | 121 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 84 deletions(-) create mode 100644 abci/src/tracing_span.rs diff --git a/abci/Cargo.toml b/abci/Cargo.toml index a8f7a34f..281d9080 100644 --- a/abci/Cargo.toml +++ b/abci/Cargo.toml @@ -23,13 +23,14 @@ server = [ crypto = ["dep:lhash"] tcp = ["server"] unix = ["server"] -tracing-span = [] +tracing-span = ["dep:uuid"] [[example]] name = "echo_socket" required-features = ["server"] [dependencies] +uuid = { version = "1.4.1", features = ["v4", "fast-rng"], optional = true } tenderdash-proto = { version = "0.13.0-dev.2", path = "../proto" } bytes = { version = "1.0" } prost = { version = "0.11" } diff --git a/abci/src/application.rs b/abci/src/application.rs index 80d01877..e4fbf9ad 100644 --- a/abci/src/application.rs +++ b/abci/src/application.rs @@ -1,8 +1,6 @@ //! ABCI application interface. -use hex::ToHex; -use tenderdash_proto::abci::request::Value; -use tracing::{debug, Level}; +use tracing::debug; use crate::proto::{ abci, @@ -153,7 +151,7 @@ pub trait RequestDispatcher { impl RequestDispatcher for A { fn handle(&self, request: abci::Request) -> Option { #[cfg(feature = "tracing-span")] - let _span = enter_span(request.clone().value?); + let _span = super::tracing_span::span(request.clone().value?); tracing::trace!(?request, "received request"); let response: Result = match request.value? { @@ -192,85 +190,6 @@ impl RequestDispatcher for A { }) } } -#[cfg(feature = "tracing-span")] -fn enter_span(request: T) -> tracing::span::EnteredSpan -where - T: Into, -{ - let value = request.into(); - const SPAN_NAME: &str = "abci"; - const LEVEL: Level = Level::ERROR; - let endpoint = abci_method_name(&value); - - let span = match value { - Value::Info(r) => tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - tenderdash_version = r.version, - block_version = r.block_version, - p2p_version = r.p2p_version, - ), - Value::InitChain(r) => { - tracing::span!(LEVEL, SPAN_NAME, endpoint, chain_id = r.chain_id) - }, - Value::PrepareProposal(r) => { - tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - height = r.height, - round = r.round, - quorum_hash = r.quorum_hash.encode_hex::(), - core_locked_height = r.core_chain_locked_height, - ) - }, - Value::ProcessProposal(r) => tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - r.height, - r.round, - quorum_hash = r.quorum_hash.encode_hex::(), - r.core_chain_locked_height, - ), - Value::ExtendVote(r) => tracing::span!(LEVEL, SPAN_NAME, endpoint, r.height, r.round), - Value::VerifyVoteExtension(r) => { - tracing::span!(LEVEL, SPAN_NAME, endpoint, r.height, r.round) - }, - Value::FinalizeBlock(r) => tracing::span!(LEVEL, SPAN_NAME, endpoint, r.height, r.round), - Value::CheckTx(r) => { - tracing::span!(LEVEL, SPAN_NAME, endpoint, tx = r.tx.encode_hex::()) - }, - Value::Query(r) => { - tracing::span!(LEVEL, SPAN_NAME, endpoint, path = r.path) - }, - _ => tracing::span!(LEVEL, SPAN_NAME, endpoint), - }; - - span.entered() -} -#[cfg(feature = "tracing-span")] -fn abci_method_name(request: &Value) -> String { - match request { - Value::ApplySnapshotChunk(_) => "ApplySnapshotChunk", - Value::CheckTx(_) => "CheckTx", - Value::Echo(_) => "Echo", - Value::ExtendVote(_) => "ExtendVote", - Value::FinalizeBlock(_) => "FinalizeBlock", - Value::Flush(_) => "Flush", - Value::Info(_) => "Info", - Value::InitChain(_) => "InitChain", - Value::ListSnapshots(_) => "ListSnapshots", - Value::LoadSnapshotChunk(_) => "LoadSnapshotChunk", - Value::OfferSnapshot(_) => "OfferSnapshot", - Value::PrepareProposal(_) => "PrepareProposal", - Value::ProcessProposal(_) => "ProcessProposal", - Value::Query(_) => "Query", - Value::VerifyVoteExtension(_) => "VerifyVoteExtension", - } - .to_string() -} /// Check if ABCI version sent by Tenderdash matches version of linked protobuf /// data objects. diff --git a/abci/src/lib.rs b/abci/src/lib.rs index 6c46857b..3e457fc3 100644 --- a/abci/src/lib.rs +++ b/abci/src/lib.rs @@ -26,6 +26,8 @@ pub use tenderdash_proto as proto; #[cfg(feature = "crypto")] pub mod signatures; +#[cfg(feature = "tracing-span")] +mod tracing_span; /// Errors that may happen during protobuf communication #[derive(Debug, thiserror::Error)] diff --git a/abci/src/tracing_span.rs b/abci/src/tracing_span.rs new file mode 100644 index 00000000..e804bc82 --- /dev/null +++ b/abci/src/tracing_span.rs @@ -0,0 +1,121 @@ +use hex::ToHex; +use tenderdash_proto::abci::request::Value; +use tracing::Level; +pub(super) fn span(request: T) -> tracing::span::EnteredSpan +where + T: Into, +{ + let value = request.into(); + const SPAN_NAME: &str = "abci"; + const LEVEL: Level = Level::ERROR; + let endpoint = abci_method_name(&value); + let request_id = uuid::Uuid::new_v4().to_string(); + + let span = match value { + Value::Info(r) => tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + tenderdash_version = r.version, + block_version = r.block_version, + p2p_version = r.p2p_version, + ), + Value::InitChain(r) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + chain_id = r.chain_id + ) + }, + Value::PrepareProposal(r) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + height = r.height, + round = r.round, + quorum_hash = r.quorum_hash.encode_hex::(), + core_locked_height = r.core_chain_locked_height, + ) + }, + Value::ProcessProposal(r) => tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + height = r.height, + round = r.round, + quorum_hash = r.quorum_hash.encode_hex::(), + core_locked_height = r.core_chain_locked_height, + ), + Value::ExtendVote(r) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + height = r.height, + round = r.round + ) + }, + Value::VerifyVoteExtension(r) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + height = r.height, + round = r.round + ) + }, + Value::FinalizeBlock(r) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + height = r.height, + round = r.round + ) + }, + Value::CheckTx(r) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint, + request_id, + tx = r.tx.encode_hex::() + ) + }, + Value::Query(r) => { + tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id, path = r.path) + }, + _ => tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id), + }; + + span.entered() +} +fn abci_method_name(request: &Value) -> String { + match request { + Value::ApplySnapshotChunk(_) => "ApplySnapshotChunk", + Value::CheckTx(_) => "CheckTx", + Value::Echo(_) => "Echo", + Value::ExtendVote(_) => "ExtendVote", + Value::FinalizeBlock(_) => "FinalizeBlock", + Value::Flush(_) => "Flush", + Value::Info(_) => "Info", + Value::InitChain(_) => "InitChain", + Value::ListSnapshots(_) => "ListSnapshots", + Value::LoadSnapshotChunk(_) => "LoadSnapshotChunk", + Value::OfferSnapshot(_) => "OfferSnapshot", + Value::PrepareProposal(_) => "PrepareProposal", + Value::ProcessProposal(_) => "ProcessProposal", + Value::Query(_) => "Query", + Value::VerifyVoteExtension(_) => "VerifyVoteExtension", + } + .to_string() +} From bdbe283da23632559de7bd3278f8b83c551dc06a Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:05:04 +0200 Subject: [PATCH 4/9] chore: log exception responses on error! level and simplify span --- abci/src/application.rs | 17 +++++++++-------- abci/src/tracing_span.rs | 38 +++++++------------------------------- 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/abci/src/application.rs b/abci/src/application.rs index e4fbf9ad..68784119 100644 --- a/abci/src/application.rs +++ b/abci/src/application.rs @@ -152,9 +152,9 @@ impl RequestDispatcher for A { fn handle(&self, request: abci::Request) -> Option { #[cfg(feature = "tracing-span")] let _span = super::tracing_span::span(request.clone().value?); - tracing::trace!(?request, "received request"); + tracing::trace!(?request, "received ABCI request"); - let response: Result = match request.value? { + let response: response::Value = match request.value? { request::Value::Echo(req) => self.echo(req).map(|v| v.into()), request::Value::Flush(req) => self.flush(req).map(|v| v.into()), request::Value::Info(req) => self.info(req).map(|v| v.into()), @@ -176,15 +176,16 @@ impl RequestDispatcher for A { request::Value::VerifyVoteExtension(req) => { self.verify_vote_extension(req).map(|v| v.into()) }, - }; + } + .unwrap_or_else(|e| e.into()); - let response = match response { - Ok(v) => v, - Err(e) => response::Value::from(e), + // TODO: errors as err + if let response::Value::Exception(ref exception) = response { + tracing::error!(response=?exception, "sending ABCI exception"); + } else { + tracing::trace!(?response, "sending ABCI response"); }; - tracing::trace!(?response, "sending response"); - Some(abci::Response { value: Some(response), }) diff --git a/abci/src/tracing_span.rs b/abci/src/tracing_span.rs index e804bc82..641ffed7 100644 --- a/abci/src/tracing_span.rs +++ b/abci/src/tracing_span.rs @@ -1,7 +1,7 @@ -use hex::ToHex; use tenderdash_proto::abci::request::Value; use tracing::Level; -pub(super) fn span(request: T) -> tracing::span::EnteredSpan + +pub fn span(request: T) -> tracing::span::EnteredSpan where T: Into, { @@ -12,23 +12,9 @@ where let request_id = uuid::Uuid::new_v4().to_string(); let span = match value { - Value::Info(r) => tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - tenderdash_version = r.version, - block_version = r.block_version, - p2p_version = r.p2p_version, - ), - Value::InitChain(r) => { - tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - chain_id = r.chain_id - ) + Value::Info(_r) => tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id), + Value::InitChain(_r) => { + tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id) }, Value::PrepareProposal(r) => { tracing::span!( @@ -38,8 +24,6 @@ where request_id, height = r.height, round = r.round, - quorum_hash = r.quorum_hash.encode_hex::(), - core_locked_height = r.core_chain_locked_height, ) }, Value::ProcessProposal(r) => tracing::span!( @@ -49,8 +33,6 @@ where request_id, height = r.height, round = r.round, - quorum_hash = r.quorum_hash.encode_hex::(), - core_locked_height = r.core_chain_locked_height, ), Value::ExtendVote(r) => { tracing::span!( @@ -82,14 +64,8 @@ where round = r.round ) }, - Value::CheckTx(r) => { - tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - tx = r.tx.encode_hex::() - ) + Value::CheckTx(_r) => { + tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id) }, Value::Query(r) => { tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id, path = r.path) From 8de550d9dd44fdf1404132570170f39979e8b2be Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:20:22 +0200 Subject: [PATCH 5/9] chore: minor improvements and docs --- abci/src/application.rs | 1 - abci/src/lib.rs | 3 +- abci/src/tracing_span.rs | 97 +++++++++++++++++++--------------------- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/abci/src/application.rs b/abci/src/application.rs index 68784119..5b4730e6 100644 --- a/abci/src/application.rs +++ b/abci/src/application.rs @@ -179,7 +179,6 @@ impl RequestDispatcher for A { } .unwrap_or_else(|e| e.into()); - // TODO: errors as err if let response::Value::Exception(ref exception) = response { tracing::error!(response=?exception, "sending ABCI exception"); } else { diff --git a/abci/src/lib.rs b/abci/src/lib.rs index 3e457fc3..9f65419a 100644 --- a/abci/src/lib.rs +++ b/abci/src/lib.rs @@ -27,7 +27,8 @@ pub use tenderdash_proto as proto; #[cfg(feature = "crypto")] pub mod signatures; #[cfg(feature = "tracing-span")] -mod tracing_span; +/// Create tracing::Span for better logging +pub mod tracing_span; /// Errors that may happen during protobuf communication #[derive(Debug, thiserror::Error)] diff --git a/abci/src/tracing_span.rs b/abci/src/tracing_span.rs index 641ffed7..f3d2c45a 100644 --- a/abci/src/tracing_span.rs +++ b/abci/src/tracing_span.rs @@ -1,13 +1,52 @@ use tenderdash_proto::abci::request::Value; use tracing::Level; +const SPAN_NAME: &str = "abci"; +const LEVEL: Level = Level::ERROR; + +macro_rules! block_span { + ($request: expr, $endpoint:expr, $request_id:expr) => { + tracing::span!( + LEVEL, + SPAN_NAME, + endpoint = $endpoint, + request_id = $request_id, + height = $request.height, + round = $request.round + ) + }; +} +/// Creates a new span for tracing. +/// +/// This function creates a new `tracing::span::EnteredSpan` based on the +/// provided request. It uses the request to determine the endpoint and includes +/// a unique request ID in the span. +/// +/// The level of the span is set to ERROR, so it will be included on all log +/// levels. +/// +/// # Arguments +/// +/// * `request` - A value that can be converted into a `Value`. Depending on the +/// specific variant of `Value`, additional information like height, round, or +/// path might be included in the span. +/// +/// # Returns +/// +/// An entered span which represents an active or entered span state. +/// +/// # Examples +/// +/// ``` +/// let request = Value::Info(RequestInfo::new()); +/// let span = span(request); +/// ``` pub fn span(request: T) -> tracing::span::EnteredSpan where T: Into, { let value = request.into(); - const SPAN_NAME: &str = "abci"; - const LEVEL: Level = Level::ERROR; + let endpoint = abci_method_name(&value); let request_id = uuid::Uuid::new_v4().to_string(); @@ -16,54 +55,11 @@ where Value::InitChain(_r) => { tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id) }, - Value::PrepareProposal(r) => { - tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - height = r.height, - round = r.round, - ) - }, - Value::ProcessProposal(r) => tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - height = r.height, - round = r.round, - ), - Value::ExtendVote(r) => { - tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - height = r.height, - round = r.round - ) - }, - Value::VerifyVoteExtension(r) => { - tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - height = r.height, - round = r.round - ) - }, - Value::FinalizeBlock(r) => { - tracing::span!( - LEVEL, - SPAN_NAME, - endpoint, - request_id, - height = r.height, - round = r.round - ) - }, + Value::PrepareProposal(r) => block_span!(r, endpoint, request_id), + Value::ProcessProposal(r) => block_span!(r, endpoint, request_id), + Value::ExtendVote(r) => block_span!(r, endpoint, request_id), + Value::VerifyVoteExtension(r) => block_span!(r, endpoint, request_id), + Value::FinalizeBlock(r) => block_span!(r, endpoint, request_id), Value::CheckTx(_r) => { tracing::span!(LEVEL, SPAN_NAME, endpoint, request_id) }, @@ -75,6 +71,7 @@ where span.entered() } + fn abci_method_name(request: &Value) -> String { match request { Value::ApplySnapshotChunk(_) => "ApplySnapshotChunk", From 7b71e4979b41ca78b60da4d5669b3aa68c416aa2 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:59:34 +0200 Subject: [PATCH 6/9] chore: traced exception format same as response --- abci/src/application.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/abci/src/application.rs b/abci/src/application.rs index 5b4730e6..8fbc2fcd 100644 --- a/abci/src/application.rs +++ b/abci/src/application.rs @@ -179,8 +179,8 @@ impl RequestDispatcher for A { } .unwrap_or_else(|e| e.into()); - if let response::Value::Exception(ref exception) = response { - tracing::error!(response=?exception, "sending ABCI exception"); + if let response::Value::Exception(_) = response { + tracing::error!(response=?response, "sending ABCI exception"); } else { tracing::trace!(?response, "sending ABCI response"); }; From 0ee91ef9a748fab6fe730279ada5966d868e24dd Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:00:15 +0200 Subject: [PATCH 7/9] chore: minor fix --- abci/src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abci/src/application.rs b/abci/src/application.rs index 8fbc2fcd..914373d5 100644 --- a/abci/src/application.rs +++ b/abci/src/application.rs @@ -180,7 +180,7 @@ impl RequestDispatcher for A { .unwrap_or_else(|e| e.into()); if let response::Value::Exception(_) = response { - tracing::error!(response=?response, "sending ABCI exception"); + tracing::error!(?response, "sending ABCI exception"); } else { tracing::trace!(?response, "sending ABCI response"); }; From a4732cc9e626fdfae2f8d011d30a3872d1b44eaf Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:14:10 +0200 Subject: [PATCH 8/9] chore: cargo fmt --- abci/src/server/generic.rs | 18 +++++++++--------- abci/tests/kvstore.rs | 12 +++++++++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/abci/src/server/generic.rs b/abci/src/server/generic.rs index 921486c7..2e57496d 100644 --- a/abci/src/server/generic.rs +++ b/abci/src/server/generic.rs @@ -106,15 +106,15 @@ where let mut codec = Codec::new(listener, cancel_token.clone(), &self.runtime); while !cancel_token.is_cancelled() { let Some(request) = codec.next() else { - tracing::error!("client terminated stream"); - return Ok(()) - }; - - let Some(response) = self.app.handle(request.clone()) else { - // `RequestDispatcher` decided to stop receiving new requests: - info!("ABCI Application is shutting down"); - return Ok(()); - }; + tracing::error!("client terminated stream"); + return Ok(()); + }; + + let Some(response) = self.app.handle(request.clone()) else { + // `RequestDispatcher` decided to stop receiving new requests: + info!("ABCI Application is shutting down"); + return Ok(()); + }; if let Some(crate::proto::abci::response::Value::Exception(ex)) = response.value.clone() { diff --git a/abci/tests/kvstore.rs b/abci/tests/kvstore.rs index febc96cf..aec9fa89 100644 --- a/abci/tests/kvstore.rs +++ b/abci/tests/kvstore.rs @@ -227,7 +227,9 @@ impl Application for KVStoreABCI<'_> { .collect::>>() else { error!("Cannot decode transactions"); - return Err(abci::ResponseException {error:"cannot decode transactions".to_string()}); + return Err(abci::ResponseException { + error: "cannot decode transactions".to_string(), + }); }; // Mark transactions that should be added to the proposed transactions @@ -253,7 +255,9 @@ impl Application for KVStoreABCI<'_> { let Some(tx_records) = tx_records_encoded else { error!("cannot encode transactions"); - return Err(ResponseException{error:"cannot encode transactions".to_string()}); + return Err(ResponseException { + error: "cannot encode transactions".to_string(), + }); }; // Put both local and proposed transactions into staging area @@ -286,7 +290,9 @@ impl Application for KVStoreABCI<'_> { .map(decode_transaction) .collect::>>() else { - return Err(ResponseException{error:"cannot decode transactions".to_string()}); + return Err(ResponseException { + error: "cannot decode transactions".to_string(), + }); }; let tx_results = tx_results_accept(td_proposed_transactions.len()); From 1092076712e29d8b69ed38ad027a6376a5fd3b3c Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:26:32 +0200 Subject: [PATCH 9/9] fix: doctest --- abci/src/tracing_span.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/abci/src/tracing_span.rs b/abci/src/tracing_span.rs index f3d2c45a..96d58fad 100644 --- a/abci/src/tracing_span.rs +++ b/abci/src/tracing_span.rs @@ -38,7 +38,10 @@ macro_rules! block_span { /// # Examples /// /// ``` -/// let request = Value::Info(RequestInfo::new()); +/// # use tenderdash_proto::abci::{RequestInfo, request}; +/// # use tenderdash_abci::tracing_span::span; +/// +/// let request = request::Value::Info(RequestInfo::default()); /// let span = span(request); /// ``` pub fn span(request: T) -> tracing::span::EnteredSpan