Skip to content

fix: add logging batching client#2128

Merged
baktun14 merged 1 commit intomainfrom
fix/add-logging
Oct 29, 2025
Merged

fix: add logging batching client#2128
baktun14 merged 1 commit intomainfrom
fix/add-logging

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Oct 29, 2025

Summary by CodeRabbit

  • Chores
    • Added comprehensive logging and monitoring capabilities throughout the batch signing and transaction broadcast workflow. Enhanced error handling with improved message typing and diagnostics. Implemented logging across execution initialization, account processing, sequence management, cache operations, transaction signing, and broadcast phases to improve operational visibility and troubleshooting.

@baktun14 baktun14 requested a review from a team as a code owner October 29, 2025 01:37
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

Walkthrough

This PR adds comprehensive runtime logging throughout the batch signing client service, capturing execution requests, client initialization, account info retrieval, sequence management, cache operations, and transaction broadcast stages. No public API changes or method signature modifications.

Changes

Cohort / File(s) Change Summary
Batch Signing Service Logging
apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts
Added extensive runtime logging across the entire batch signing flow: execution request, client initialization, account info fetch, sequence increment, cache clearing, batch start, per-TX signing, signing errors, TX broadcast attempts (sync and final), TX already in cache, TX broadcast errors, and batch completion. Introduced local hash variables for sync broadcast logging and explicit TX_BROADCAST_SYNC, TX_BROADCAST_FINAL, and TX_BROADCAST_ERROR log emissions. Enhanced error handling with explicit errorMessage typing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Verify that logging additions do not introduce performance overhead in the broadcast loop
  • Confirm log level selection (debug vs. warn vs. error) is appropriate for each emission point
  • Ensure consistency of log message formatting and context information across all new log statements

Possibly related PRs

Poem

🐰 A rabbit hops through logs so bright,
Each hop records the signing night—
From cache to broadcast, all is seen,
The cleanest batch flow ever been! 🪵✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: add logging batching client" directly corresponds to the main change in the pull request, which adds extensive runtime logging across the batch signing flow in the batch-signing-client.service.ts file. The title clearly communicates that logging functionality is being added to the batching client, which is the primary objective of the changeset. While the phrasing could be slightly more polished grammatically (e.g., "add logging to batch signing client"), the title is specific and sufficiently clear for a teammate scanning the repository history to understand the core change without ambiguity.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/add-logging

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.09%. Comparing base (10b4d28) to head (82f87a6).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tch-signing-client/batch-signing-client.service.ts 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2128      +/-   ##
==========================================
- Coverage   46.42%   46.09%   -0.34%     
==========================================
  Files        1016     1006      -10     
  Lines       28692    28361     -331     
  Branches     7447     7417      -30     
==========================================
- Hits        13321    13073     -248     
+ Misses      14180    14106      -74     
+ Partials     1191     1182       -9     
Flag Coverage Δ *Carryforward flag
api 81.96% <90.00%> (+0.01%) ⬆️
deploy-web 24.63% <ø> (-0.01%) ⬇️
log-collector ?
notifications 88.11% <ø> (ø)
provider-console 81.48% <ø> (ø) Carriedforward from 10b4d28
provider-proxy 84.61% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...tch-signing-client/batch-signing-client.service.ts 90.19% <90.00%> (-0.18%) ⬇️

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@baktun14 baktun14 merged commit 8bca2c8 into main Oct 29, 2025
58 of 59 checks passed
@baktun14 baktun14 deleted the fix/add-logging branch October 29, 2025 01:40
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10b4d28 and 82f87a6.

⛔ Files ignored due to path filters (1)
  • packages/net/src/generated/netConfigData.ts is excluded by !**/generated/**
📒 Files selected for processing (1)
  • apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts (7 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts
🧬 Code graph analysis (1)
apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts (1)
packages/logging/src/services/logger/logger.service.ts (1)
  • error (107-109)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: Validate local packages
🔇 Additional comments (11)
apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts (11)

78-83: LGTM!

The execution request logging captures essential operational data without exposing sensitive information.


98-98: LGTM!

Chain ID logging aids in debugging multi-chain scenarios.


180-187: Good sequence tracking for debugging.

Capturing both old and new sequence values will help diagnose account sequence mismatch errors.


192-196: LGTM!

Cache clearing events are valuable for debugging sequence-related issues.


234-241: LGTM!

Comprehensive batch metadata improves observability of the signing pipeline.


250-257: LGTM!

Per-transaction signing logs will help diagnose signing failures within batches.


267-272: LGTM!

Error context with transaction index and sequence will aid in debugging batch signing failures.


289-296: LGTM!

Extracting the hash to a local variable improves readability while adding useful broadcast logging.


300-305: LGTM!

Distinguishing final vs. sync broadcasts improves traceability of the two-phase broadcast strategy.


330-334: LGTM!

Batch completion logging with transaction hashes provides excellent audit trail for the signing pipeline.


159-165: Verify compliance requirements for logging blockchain addresses—this concern is valid.

Blockchain addresses are treated as personal data under GDPR when reasonably linkable to individuals, and CCPA expressly covers online identifiers capable of being associated with consumers. Current guidance warns that hashing or encryption alone is not a safe harbor if the original can be reconstructed or linked.

Your logging statements at lines 161, 184, 194, 237, and 253 all expose plaintext addresses. Verify with your compliance team:

  • Whether you have documented legal basis for logging these addresses
  • Whether pseudonymization (salted hash/HMAC) is required for this service's data classification
  • What retention period is appropriate for address logs
  • Whether encryption at rest and role-based access controls should be applied

Best practices recommend treating addresses as regulated personal data, minimizing collection, and using privacy-enhancing techniques when feasible.

Comment on lines +308 to +322
const errorMessage = error instanceof Error ? error.message : String(error);
if (errorMessage.toLowerCase().includes("tx already exists in cache")) {
const txHash = toHex(sha256(txBytes));
hashes.push(txHash);
this.logger.warn({
event: "TX_ALREADY_IN_CACHE",
txIndex,
hash: txHash
});
} else {
this.logger.error({
event: "TX_BROADCAST_ERROR",
txIndex,
error: errorMessage
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Improved error handling with a minor fragility concern.

The enhanced error handling and logging is well-structured. However, the string-based error detection on line 309 (errorMessage.toLowerCase().includes("tx already exists in cache")) is fragile. If the upstream error message format changes, this logic will break.

While this pattern is common in blockchain integrations where standardized error codes aren't available, consider:

  • Documenting the expected error message format
  • Adding a fallback or additional checks if possible
  • Monitoring for unexpected error formats
🤖 Prompt for AI Agents
In apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts
around lines 308 to 322, the current logic relies on a fragile exact string
check errorMessage.toLowerCase().includes("tx already exists in cache"); replace
that with a more robust detection: extract the error parsing into a small helper
that checks for multiple known variants via a case-insensitive regex or a list
of normalized substrings, also attempt to detect structured error fields (e.g.,
error.code, error.reason, error.type) before falling back to string matching,
and add a clear fallback path that treats unknown formats as generic broadcast
errors; update the log to include the raw error object when falling back and add
a short comment documenting the expected upstream message patterns so future
changes are easier to maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments