From bd9288bb6746a5bb27371412fa4d1a2f29bdd91d Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:01:24 +0100 Subject: [PATCH 1/3] chore: improve debugging --- abci/tests/kvstore.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/abci/tests/kvstore.rs b/abci/tests/kvstore.rs index 92f04bc..8ae845d 100644 --- a/abci/tests/kvstore.rs +++ b/abci/tests/kvstore.rs @@ -65,8 +65,10 @@ fn test_kvstore() { let socket_uri = bind_address.to_string(); let _td = common::docker::TenderdashDocker::new("tenderdash", None, &socket_uri); + let next_client = server.next_client(); + tracing::debug!(?next_client, "next client"); assert!(matches!( - server.next_client(), + next_client, Err(tenderdash_abci::Error::Cancelled()) )); drop(server); From 697e86f77d4da86fd8a02319c2acb18211cea2b7 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:40:41 +0100 Subject: [PATCH 2/3] chore: trying to fix the test --- abci/tests/kvstore.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/abci/tests/kvstore.rs b/abci/tests/kvstore.rs index 8ae845d..e3cc394 100644 --- a/abci/tests/kvstore.rs +++ b/abci/tests/kvstore.rs @@ -63,7 +63,7 @@ fn test_kvstore() { fs::set_permissions(SOCKET, perms).expect("set perms"); let socket_uri = bind_address.to_string(); - let _td = common::docker::TenderdashDocker::new("tenderdash", None, &socket_uri); + let td = common::docker::TenderdashDocker::new("tenderdash", None, &socket_uri); let next_client = server.next_client(); tracing::debug!(?next_client, "next client"); @@ -76,6 +76,8 @@ fn test_kvstore() { let kvstore_app = kvstore.into_inner().expect("kvstore lock is poisoned"); assert_eq!(kvstore_app.persisted_state, state_reference); assert_eq!(kvstore_app.last_block_height, 1); + + drop(td); } /// An example storage. From b178ca83aa733bb6deb2eec340cf70656d8b1999 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:12:27 +0100 Subject: [PATCH 3/3] fix(abci): invalid error returned when Codec terminates --- abci/src/server/codec.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/abci/src/server/codec.rs b/abci/src/server/codec.rs index 8996d71..dd38dc4 100644 --- a/abci/src/server/codec.rs +++ b/abci/src/server/codec.rs @@ -97,6 +97,18 @@ impl<'a> Codec { Self::process_worker_queues(codec, request_tx, response_rx, cancel).await; } + + /// Worker that moves messages between codec and requests and responses + /// queues. + /// + /// Reads messages from ABCI Client from `codec`, sends them to Tenderdash + /// via `request_tx`, receives Tenderdash responses from `response_rx` + /// and forwards to + /// + /// ## Error handling + /// + /// On error, it cancels the `cancel` [CancellationToken] and exits. + /// It causes `response_rx` to be closed. async fn process_worker_queues( mut codec: Framed, request_tx: Sender, @@ -149,9 +161,10 @@ impl<'a> Codec { } pub fn send(&self, value: Response) -> Result<(), Error> { - self.response_tx - .blocking_send(value) - .map_err(|e| Error::Async(e.to_string())) + self.response_tx.blocking_send(value).map_err(|_| { + // channel closed, `process_worker_queues` either errored or cancelled + Error::Cancelled() + }) } }