Skip to content

Conversation

@tnull
Copy link
Contributor

@tnull tnull commented Dec 17, 2025

We recently stumbled across some harder to debug issues that highlighted that the absence of logging in vss-client-ng can be a pain. Therefore, we here introduce logging for requests and the retry logic based on the log facade, which not only allows the logging to easily integrate with the Rust ecosystem, but is also a non-API breaking change allowing us to ship this in a patch release.

@tnull tnull requested a review from tankyleo December 17, 2025 10:14

bitcoin_hashes = "0.14.0"
chacha20-poly1305 = "0.1.2"
log = { version = "0.4.29", default-features = false, features = ["std"]}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine for now given its already in the transitive dep set, but post-#52 it presumably won't be and we'll have to revert this. What's the plan after that?

Copy link
Contributor Author

@tnull tnull Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the log facade is the default for logging across most Rust crates. So we might actually want to consider adding (optional) log-based logging support to bitreq as otherwise we will lose a lot of insight when making the switch.

FWIW, before we integrated it in LDK Node, we had multiple users entirely confused why LDK Node logs were absent from their logs, until their realized we did something custom that didn't have the expected compatibility what ~every other project does. While I agree that we should be cautious with additional dependencies, sharing a usable and expected interface is important. So taking a dependency on log seems entirely worth for me, especially, if we, as we now did in lightningdevkit/ldk-server#76, don't take additional dependencies for the actual default consumer.

IMO, across projects we could also eventually consider taking a similar path w.r.t tracing: we could just take a dependency on tracing_core and (re-)implement the rest ourselves.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, across projects we could also eventually consider taking a similar path w.r.t tracing: we could just take a dependency on tracing_core and (re-)implement the rest ourselves.

I think you just undercut your argument around log being the way that we have to do logging here :). Many things use log, but not everything, with tokio pushing tracing instead its certainly not universal. Having optional dependencies on log/tracing, of course, is perfectly reasonable, but ultimately when we support both we'll need some kind of unified underlying logging interface again...

@tnull tnull moved this to Goal: Merge in Weekly Goals Dec 18, 2025
@tnull tnull self-assigned this Dec 18, 2025
) -> Result<GetObjectResponse, VssError> {
retry(
let request_id: u64 = rand::random();
trace!("Sending GetObjectRequest {} for key {}.", request_id, request.key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the happy case do we want a confirmation that the operation was successful ? I would expect to see one myself, but I may get used to "silence" == success.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah, it think it might be a bit spammy to also always log for the success case.

error: &err,
}) {
trace!(
"Operation failed on attempt {}, retrying in {}ms: {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May not be necessary because once we've exhausted all attempts, we do log the request_id with the final failure message, but wondering if we want it here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't have access to the request_id here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure maybe we could have added a parameter to retry, but it's overkill for now

Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to log the version too ? I know we don't use it now, but we are planning to use it by the next ldk-node release

@tnull
Copy link
Contributor Author

tnull commented Jan 5, 2026

Do we want to log the version too ? I know we don't use it now, but we are planning to use it by the next ldk-node release

Hmm, which ones though? The global_version or the per-item version field? While I'm not super opposed, it might make sense to include it when we actually going to use it, as we'll have more context then, and if we just log everything log lines will become very hard hard to read if they get too cluttered.

@tnull tnull requested a review from tankyleo January 5, 2026 10:09
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 5, 2026

👋 Thanks for assigning @tankyleo as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

src/client.rs Outdated
trace!(
"Sending DeleteObjectRequest {} for key {:?}",
request_id,
request.key_value.iter().map(|t| &t.key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's replace this with request.key_value.as_ref().map(|t| &t.key) ?

At the moment this line looks like this:

Sending DeleteObjectRequest 14665000019760149953 for key Map { iter: Iter { inner: Item { opt: Some(KeyValue { key: "hello", version: -1, value: [] }) } } }

with the replacement we get:

Sending DeleteObjectRequest 11048689160446419397 for key Some("hello")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch! Now force-pushed with the following changes:

> git diff-tree -U2 9c0ce05 bfa91e6
diff --git a/src/client.rs b/src/client.rs
index 3aed0eb..9f6b04a 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -143,5 +143,5 @@ impl<R: RetryPolicy<E = VssError>> VssClient<R> {
                        "Sending DeleteObjectRequest {} for key {:?}",
                        request_id,
-                       request.key_value.iter().map(|t| &t.key)
+                       request.key_value.as_ref().map(|t| &t.key)
                );
                let res = retry(

We recently stumbled across some harder to debug issues that highlighted
that the absence of logging in `vss-client-ng` can be a pain. Therefore,
we here introduce logging for requests and the retry logic based on the
`log` facade, which not only allows the logging to easily integrate with
the Rust ecosystem, but is also a non-API breaking change allowing us to
ship this in a patch release.
@tnull tnull force-pushed the 2025-12-add-logging branch from 9c0ce05 to bfa91e6 Compare January 8, 2026 08:37
@tnull tnull requested a review from tankyleo January 8, 2026 08:46
@tankyleo
Copy link
Contributor

tankyleo commented Jan 8, 2026

Thank you for the PR !

@tankyleo tankyleo merged commit bfa91e6 into lightningdevkit:main Jan 8, 2026
4 checks passed
@github-project-automation github-project-automation bot moved this from Goal: Merge to Done in Weekly Goals Jan 8, 2026
@tnull tnull mentioned this pull request Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants