Skip to content

Conversation

@PastaPastaPasta
Copy link
Member

@PastaPastaPasta PastaPastaPasta commented Aug 29, 2025

Summary by CodeRabbit

  • New Features

    • You can now pass raw transactions as plain strings in RPC helpers.
  • Refactor

    • Simplified lifetimes and iteration for better performance and clarity.
    • Streamlined RPC argument construction and return handling.
    • API ergonomics improved by accepting slices instead of owned vectors in some calls.
  • Tests

    • Integration tests streamlined (fewer allocations, clearer logging, simpler iterators).
    • Minor control-flow and expectation adjustments for stability.

- Remove always-true assertion in test_get_quorum_info()
- Fixes absurd_extreme_comparisons clippy error
- Integration test now passes clippy with warnings only
- Remove redundant field names in struct initialization
- Remove unused imports (Script, RawTx, BsFields)
- Elide unnecessary explicit lifetimes in trait implementations
- Remove needless borrowing in function calls
- Remove redundant Ok(?) patterns in Result handling
- Fix .into_iter() vs .iter() usage on references
- Replace .nth(0) with .next() for better readability
- Use std::slice::from_ref instead of cloning for single elements
- Remove unnecessary reference taking in comparisons
- Remove unnecessary let bindings for unit values
- Remove identity mapping in iterators
- Use !is_empty() instead of != "" for clarity
- Remove unnecessary return statements at end of functions

This reduces total clippy warnings from ~600+ to ~584 across all crates
- Convert single-binding match to let statement in test_get_protx_info
- Remove unnecessary .to_string() calls in format! and trace! macros
- Replace .to_vec().into_iter().map() with .iter().cloned().map() for better performance

All safe clippy warning fixes have been completed across non-strict crates
- Remove redundant closure in get_transaction_are_locked
- Fix useless type conversion (remove .into() on string literal)
- Change &Vec to &[T] for better performance in function signature
- Remove unnecessary reference taking in pattern matching
- Fix remaining needless borrows in node management functions
- Verified remaining "redundant imports" are actually used (false positives)

Further reduces clippy warnings across the codebase
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 29, 2025

Walkthrough

This PR removes lifetimes from RawTx impls, adds RawTx for String, updates RpcApi methods to call self.call directly and adjust iter/slice usage, changes a method signature to take a slice, refactors tests for references/slices and logging, and tweaks a serialization match binding.

Changes

Cohort / File(s) Summary
RPC client API and RawTx impls
rpc-client/src/client.rs
Dropped explicit lifetimes in RawTx impls for &Transaction, &[u8], &Vec<u8], &str; added impl RawTx for String; updated RpcApi methods to return self.call(...) directly; replaced into_iter with iter; changed get_transaction_are_locked param from &Vec<Txid> to &[Txid]; minor test URL literal tweak.
Integration tests refactor
rpc-integration-test/src/main.rs
Removed Script and BsFields imports; used &'static str constants in URL formatting; replaced nth(0) with next(); passed values instead of refs where applicable; used slice::from_ref for single-item slices; minor logging, collection, and assertion adjustments; removed a no-op early return.
JSON serialization tweak
rpc-json/src/lib.rs
Simplified match binding in Serialize for ImportMultiRequestScriptPubkey<'a> Address variant (Address(addr)), no behavior change.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as RpcApi impl
  participant Transport as HTTP/JSON-RPC
  participant Node as RPC Server

  rect rgb(230,245,255)
    note over Client: Updated pattern: direct return of self.call(...)
    Client->>Transport: call(method, params)
    Transport->>Node: JSON-RPC request
    Node-->>Transport: JSON-RPC response
    Transport-->>Client: Result<T>
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • QuantumExplorer
  • ogabrielides

Poem

Bunny taps keys with gentle flair,
Lifetimes hop away—less air to spare.
Strings now sprint in RawTx’s ring,
Tests line up in a tidy spring.
JSON smiles at cleaner match,
Calls flow swift—dispatch, dispatch!
Carrot-commit: merge and catch. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/clippy-warnings-resolution

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rpc-client/src/client.rs (1)

527-532: Use numeric serialization for asset unlock indices.

RPC expects numeric integers for the indices parameter; replace the manual string mapping with into_json(indices)? to emit JSON numbers:

-        let indices_json = indices
-            .iter()
-            .map(|index| into_json(index.to_string()))
-            .collect::<Result<Vec<Value>>>()?;
-        let args = [indices_json.into(), opt_into_json(height)?];
+        let args = [into_json(indices)?, opt_into_json(height)?];
🧹 Nitpick comments (2)
rpc-client/src/client.rs (2)

513-518: Simplify JSON args construction.

You can let serde build the array directly and avoid the map/collect.

Apply:

-        let transaction_ids_json = tx_ids.iter().map(into_json).collect::<Result<Vec<Value>>>()?;
-        let args = [transaction_ids_json.into()];
+        let args = [into_json(tx_ids)?];

1112-1112: Make fee-estimate error check resilient.

Exact-string match is brittle across Core versions.

Apply:

-        if errors == ["Insufficient data or no feerate found"] {
+        if errors.iter().any(|e| e.contains("Insufficient data") || e.contains("no feerate")) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c61a8b8 and afd525b.

📒 Files selected for processing (3)
  • rpc-client/src/client.rs (16 hunks)
  • rpc-integration-test/src/main.rs (26 hunks)
  • rpc-json/src/lib.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Use proper error types with thiserror and propagate errors appropriately
Use the tokio runtime for async operations in Rust
Use conditional compilation feature flags for optional features (#[cfg(feature = ...)])
Format Rust code with cargo fmt (and enforce via cargo fmt --check)
Run clippy with -D warnings and fix all lints
Adhere to MSRV Rust 1.89 (avoid features requiring newer compiler)

Files:

  • rpc-json/src/lib.rs
  • rpc-integration-test/src/main.rs
  • rpc-client/src/client.rs
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/**/*.rs : All code must be clippy-clean: run `cargo clippy --all-targets --all-features -- -D warnings`
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Keep test vectors in sync with Dash Core releases

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:00:14.140Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T04:00:14.140Z
Learning: Applies to {dash-spv,rpc-integration-test}/tests/**/*.rs : Provide integration tests for network operations

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/src/{bip32.rs,dip9.rs} : Keep Dash-specific derivation paths up to date (e.g., DIP-9) in bip32.rs and dip9.rs

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-25T17:15:59.361Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-08-25T17:15:59.361Z
Learning: Applies to dash-spv/src/error.rs : Define and maintain domain-specific error types in `src/error.rs` (NetworkError, StorageError, SyncError, ValidationError, SpvError) and update them when adding new failure modes

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Include integration tests that cover full wallet workflows

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/derivation_tests.rs : Place path derivation tests in tests/derivation_tests.rs

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/address_tests.rs : Place address generation and validation tests in tests/address_tests.rs

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/mnemonic_tests.rs : Place mnemonic generation and validation tests in tests/mnemonic_tests.rs

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/bip32_tests.rs : Organize unit tests so key-derivation correctness lives in tests/bip32_tests.rs

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/src/{managed_account,transaction_checking}/**/*.rs : Update wallet state atomically: add transaction, update UTXOs, recalculate balance, and mark addresses used in a single operation

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/psbt.rs : Place PSBT serialization/deserialization tests in tests/psbt.rs

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Use property-based tests for complex invariants where suitable

Applied to files:

  • rpc-integration-test/src/main.rs
📚 Learning: 2025-08-29T04:01:18.082Z
Learnt from: CR
PR: dashpay/rust-dashcore#0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-08-29T04:01:18.082Z
Learning: Applies to key-wallet/tests/**/*.rs : Use deterministic testing with known vectors (fixed seeds) in Rust tests

Applied to files:

  • rpc-integration-test/src/main.rs
🧬 Code graph analysis (1)
rpc-client/src/client.rs (1)
rpc-client/src/queryable.rs (4)
  • query (22-22)
  • query (28-33)
  • query (39-44)
  • query (50-52)
⏰ 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). (19)
  • GitHub Check: RPC Tests (stable, true)
  • GitHub Check: Strict Warnings and Clippy Checks
  • GitHub Check: Core Components Tests
  • GitHub Check: SPV Components Tests
  • GitHub Check: fuzz (hashes_sha512)
  • GitHub Check: fuzz (hashes_sha1)
  • GitHub Check: fuzz (hashes_json)
  • GitHub Check: fuzz (dash_deserialize_amount)
  • GitHub Check: fuzz (hashes_sha512_256)
  • GitHub Check: fuzz (dash_outpoint_string)
  • GitHub Check: fuzz (dash_deserialize_address)
  • GitHub Check: fuzz (dash_deserialize_witness)
  • GitHub Check: fuzz (hashes_ripemd160)
  • GitHub Check: fuzz (dash_deserialize_script)
  • GitHub Check: fuzz (dash_deserialize_block)
  • GitHub Check: fuzz (hashes_cbor)
  • GitHub Check: fuzz (hashes_sha256)
  • GitHub Check: fuzz (dash_deser_net_msg)
  • GitHub Check: fuzz (dash_script_bytes_to_asm_fmt)
🔇 Additional comments (29)
rpc-json/src/lib.rs (1)

1057-1068: Match binding cleanup is correct.

Binding Address(addr) removes an unnecessary ref without changing semantics. LGTM.

rpc-client/src/client.rs (24)

117-145: Lifetime on return slice makes intent explicit.

Signature and logic read cleanly. LGTM.


161-183: RawTx impls without explicit lifetimes look good.

Covers &Transaction, &[u8], &Vec<u8], &str. Encodings are correct. LGTM.


229-229: Remove needless Ok-wrapping — good.

Directly returning T::query(self, id) is cleaner. LGTM.


327-327: Return self.call result directly.

Concise and correct. LGTM.


369-372: Field-init shorthand in get_block_template is fine.

No behavior change. LGTM.


501-502: Direct call in get_balances.

Simpler, same behavior. LGTM.


780-782: Vectorizing RawTx hexes — good.

iter().cloned() ensures raw_hex() ownership. LGTM.


894-905: addnode subcommands via second arg — good.

Clearer than distinct RPCs. LGTM.


908-909: disconnectnode arg handling — good.

Matches RPC signature. LGTM.


931-931: getnodeaddresses defaulting — good.

unwrap_or(1) matches Core default. LGTM.


1695-1695: Use as_deref() when building request.

Neat and idiomatic. LGTM.


1741-1741: Use string literal in test URL.

Removes needless allocation. LGTM.


703-703: Use of returned blocks — fine.

Keeps the test deterministic. LGTM.


733-733: Conditional get_block_filter — fine.

Version gate is correct. LGTM.


829-829: Prefer next() over nth(0).

Idiomatic and clearer. LGTM.


838-840: Use std::slice::from_ref for single-item slices.

Eliminates temp vecs. LGTM.


891-893: Same from_ref improvement.

LGTM.


933-933: Same from_ref improvement.

LGTM.


972-978: Consistent from_ref usage — good.


1001-1006: Consistent from_ref usage — good.


1028-1034: Consistent from_ref usage — good.


1125-1125: Check return value, don’t discard.

Direct unwrap() is fine in tests. LGTM.


1194-1194: Use HashSet for wallet existence — good.

Efficient membership checks. LGTM.


1245-1248: Assertions filter out test/faucet wallets — good.

Minimizes false positives. LGTM.

rpc-integration-test/src/main.rs (4)

19-19: Import json directly.

Reduces verbosity in tests. LGTM.


204-207: URL formatting with &'static str names — good.

Avoids allocations and keeps constants in one place. LGTM.


228-238: Log messages switched to constants — good.

Cleaner formatting; avoids .to_string(). LGTM.

Also applies to: 262-262


409-410: Add asset-unlock-statuses test call — good.

Exercising the new client method is valuable. LGTM.

Comment on lines +678 to 680
let outputs: Vec<_> =
outputs.iter().map(|o| serde_json::to_value(JsonOutPoint::from(*o)).unwrap()).collect();
self.call("lockunspent", &[false.into(), outputs.into()])
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

Avoid unwrap in JSON conversion.

serde_json::to_value can fail; propagate errors instead of panicking.

Apply to both functions:

-        let outputs: Vec<_> =
-            outputs.iter().map(|o| serde_json::to_value(JsonOutPoint::from(*o)).unwrap()).collect();
+        let outputs: Vec<Value> = outputs
+            .iter()
+            .map(|o| into_json(JsonOutPoint::from(*o)))
+            .collect::<Result<_>>()?;

Also applies to: 684-686

🤖 Prompt for AI Agents
In rpc-client/src/client.rs around lines 678-680 and 684-686, the code uses
serde_json::to_value(...).unwrap() which can panic; change these functions to
propagate serialization errors instead of unwrapping: replace unwrap with the ?
operator (or map_err to convert serde_json::Error into the function's
Error/Result type) so the function returns a Result and any to_value failures
are returned to the caller; ensure the call to self.call still returns the
appropriate Result by constructing/returning an Err when serialization fails.

@QuantumExplorer QuantumExplorer merged commit 46f94cc into v0.40-dev Aug 30, 2025
22 of 26 checks passed
@QuantumExplorer QuantumExplorer deleted the feat/clippy-warnings-resolution branch August 30, 2025 06:18
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.

3 participants