Skip to content

chore: upgrade axum and related deps - #1586

Merged
sdbondi merged 1 commit into
tari-project:developmentfrom
sdbondi:upgrade-deps
Sep 25, 2025
Merged

chore: upgrade axum and related deps#1586
sdbondi merged 1 commit into
tari-project:developmentfrom
sdbondi:upgrade-deps

Conversation

@sdbondi

@sdbondi sdbondi commented Sep 25, 2025

Copy link
Copy Markdown
Member

Description

chore: upgrade axum and related deps

Motivation and Context

axum was fairly old

How Has This Been Tested?

Swarm

What process can a PR reviewer use to test or verify this change?

Breaking Changes

  • None
  • Requires data directory to be deleted
  • Other - Please specify

Summary by CodeRabbit

  • New Features

    • Automatic port fallback: servers now bind to an available ephemeral port if the preferred port is in use.
    • Consistent Base64 encoding for CLI outputs.
  • Refactor

    • JSON-RPC servers and listeners made asynchronous and unified on a listener-based startup.
    • Standardized JSON-RPC IDs and safer error handling semantics.
    • Consolidated Bearer auth using typed headers; removed custom token middleware.
  • Chores

    • Broad dependency upgrades and feature-flag adjustments; removed unused HTTP client deps.

@coderabbitai

coderabbitai Bot commented Sep 25, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This PR updates workspace dependencies, adds a reusable TCP bind-with-fallback utility, migrates many servers to axum::serve with TcpListener, changes JSON‑RPC IDs to axum_jrpc::Id (with cloning), replaces axum header types with axum-extra TypedHeader/Bearer, updates base64 to Engine API, removes some reqwest uses, and makes several spawn functions async.

Changes

Cohort / File(s) Summary
Workspace deps & tooling
Cargo.toml (root), applications/*/Cargo.toml, networking/rpc_framework/Cargo.toml, utilities/db_inspector/Cargo.toml
Bump and align many deps (axum 0.8, tower, prost 0.14, indexmap, base64 0.22, serde_with, rocksdb, toml, cargo_toml); add axum-extra, axum-jrpc, async-trait; remove reqwest in spots; adjust features.
TCP bind helper
applications/tari_app_utilities/src/lib.rs, applications/tari_app_utilities/src/tcp.rs, applications/tari_app_utilities/Cargo.toml
Add public module tcp with pub async fn try_bind_with_fallback(SocketAddr) -> io::Result<TcpListener> and enable additional dependency features.
Server binding refactor (axum::serve + listener)
applications/tari_indexer/src/graphql/server.rs, .../http_ui/server.rs, applications/tari_indexer/src/json_rpc/server.rs, applications/tari_validator_node/src/http_ui/server.rs, applications/tari_validator_node/src/json_rpc/server.rs, applications/tari_walletd/*/server.rs, utilities/db_inspector/src/webserver/server.rs, applications/tari_swarm_daemon/src/webserver/server.rs, applications/tari_walletd/src/jrpc_server.rs, applications/tari_walletd/src/http_ui/server.rs
Replace manual try_bind fallback flows with try_bind_with_fallback(...).await, construct servers via axum::serve(listener, router), derive bound address from server.local_addr(), adjust server spawn / futures accordingly.
JSON‑RPC ID type & callsite changes
applications/tari_indexer/src/json_rpc/error.rs, .../handlers.rs, applications/tari_validator_node/src/json_rpc/jrpc_errors.rs, .../handlers.rs, applications/tari_walletd/src/jrpc_server.rs, applications/tari_walletd/src/webrtc.rs, applications/tari_swarm_daemon/src/webserver/server.rs
Migrate answer_id types from i64 to axum_jrpc::Id, update helper signatures, and insert .clone() at call sites where ownership required; adjust some closures (internal_error -> FnOnce).
Auth header handling → axum-extra TypedHeader
applications/tari_signaling_server/Cargo.toml, applications/tari_signaling_server/src/data.rs, .../jrpc_server.rs, applications/tari_walletd/src/handlers/*, applications/tari_walletd/Cargo.toml, applications/tari_swarm_daemon/Cargo.toml
Replace axum header imports with axum_extra::headers::authorization::Bearer and TypedHeader; move token extraction into handlers (optional TypedHeader) for signaling server; update check_jwt signature to accept Bearer.
Async spawn / listener APIs
applications/tari_indexer/src/json_rpc/server.rs, applications/tari_validator_node/src/json_rpc/server.rs, applications/tari_walletd/src/jrpc_server.rs, applications/tari_walletd/src/lib.rs, applications/tari_indexer/src/lib.rs
Convert several spawn/listener functions to async and update callsites to .await, returning same logical results but as futures.
Base64 Engine API
applications/tari_wallet_cli/src/command/proof.rs, .../transaction.rs, .../from_base64.rs
Switch encoding/decoding to base64::prelude::BASE64_STANDARD / Engine API and add a private base64_decode helper.
IndexMap import & serde_with feature
applications/tari_indexer/Cargo.toml, applications/tari_indexer/src/network_state_sync/sync_progress.rs
Add indexmap dep (workspace), change serde_with feature to indexmap_2, and import indexmap::IndexMap in sync code.
Prost codec trait bound
networking/libp2p-messaging/src/codec/prost.rs
Add fmt::Debug bound to TMsg for ProstCodec Codec impl.
DB Inspector handler signature simplification
utilities/db_inspector/src/webserver/handlers/tables.rs
Remove generic B and associated HttpBody bound from list handler signature and Handler return type.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor App
  participant Server as Server module
  participant TCP as tcp::try_bind_with_fallback
  participant OS as OS Socket

  App->>Server: start_server(preferred_addr)
  Server->>TCP: try_bind_with_fallback(preferred_addr)
  TCP->>OS: bind(preferred_addr)
  alt bind ok
    OS-->>TCP: TcpListener
  else bind fails
    TCP-->>Server: warn(preferred bind failed)
    TCP->>OS: bind(addr with port=0)
    OS-->>TCP: TcpListener
  end
  TCP-->>Server: TcpListener
  Server->>Server: axum::serve(listener, router)
  Server-->>App: local_addr()
  App-->>Server: await run
Loading
sequenceDiagram
  autonumber
  actor Client
  participant HTTP as HTTP Endpoint (JRPC)
  participant Auth as TypedHeader<Authorization<Bearer>>
  participant Handlers as JSON-RPC Handlers

  Client->>HTTP: POST /jsonrpc (optional Authorization: Bearer)
  HTTP->>Auth: extract header (Option)
  alt method != auth.login and no valid token
    HTTP-->>Client: 401 Unauthorized (JsonRpcResponse::error)
  else valid or login
    HTTP->>Handlers: handle(request, answer_id: axum_jrpc::Id)
    Handlers-->>HTTP: JsonRpcResponse (may clone Id)
    HTTP-->>Client: 200 OK with response
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

I twitched my ears at ports that wouldn’t stay,
So I bound, then bounced to zero—hip hooray!
Headers hopped in, IDs learned to clone,
Base64 hums with Engine tones alone.
Axum listens, futures sprint — carrot cheers! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.88% 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
Title Check ✅ Passed The title succinctly conveys that the PR is focused on upgrading axum and related dependencies, which matches the extensive dependency updates and code adjustments in this changeset. It avoids listing individual files or extraneous details and provides clear context for reviewers.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e644d67 and d05a773.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (55)
  • Cargo.toml (5 hunks)
  • applications/tari_app_utilities/Cargo.toml (2 hunks)
  • applications/tari_app_utilities/src/lib.rs (1 hunks)
  • applications/tari_app_utilities/src/tcp.rs (1 hunks)
  • applications/tari_indexer/Cargo.toml (2 hunks)
  • applications/tari_indexer/src/graphql/server.rs (2 hunks)
  • applications/tari_indexer/src/http_ui/server.rs (2 hunks)
  • applications/tari_indexer/src/json_rpc/error.rs (2 hunks)
  • applications/tari_indexer/src/json_rpc/handlers.rs (29 hunks)
  • applications/tari_indexer/src/json_rpc/server.rs (1 hunks)
  • applications/tari_indexer/src/lib.rs (1 hunks)
  • applications/tari_indexer/src/network_state_sync/sync_progress.rs (1 hunks)
  • applications/tari_signaling_server/Cargo.toml (1 hunks)
  • applications/tari_signaling_server/src/data.rs (2 hunks)
  • applications/tari_signaling_server/src/jrpc_server.rs (5 hunks)
  • applications/tari_swarm_daemon/Cargo.toml (1 hunks)
  • applications/tari_swarm_daemon/src/webserver/handler.rs (1 hunks)
  • applications/tari_swarm_daemon/src/webserver/server.rs (6 hunks)
  • applications/tari_validator_node/Cargo.toml (1 hunks)
  • applications/tari_validator_node/src/cli.rs (1 hunks)
  • applications/tari_validator_node/src/http_ui/server.rs (2 hunks)
  • applications/tari_validator_node/src/json_rpc/handlers.rs (29 hunks)
  • applications/tari_validator_node/src/json_rpc/jrpc_errors.rs (5 hunks)
  • applications/tari_validator_node/src/json_rpc/server.rs (2 hunks)
  • applications/tari_validator_node/src/lib.rs (1 hunks)
  • applications/tari_wallet_cli/src/command/proof.rs (2 hunks)
  • applications/tari_wallet_cli/src/command/transaction.rs (3 hunks)
  • applications/tari_wallet_cli/src/from_base64.rs (2 hunks)
  • applications/tari_walletd/Cargo.toml (1 hunks)
  • applications/tari_walletd/src/handlers/accounts.rs (1 hunks)
  • applications/tari_walletd/src/handlers/auth/jwt.rs (1 hunks)
  • applications/tari_walletd/src/handlers/confidential.rs (1 hunks)
  • applications/tari_walletd/src/handlers/context.rs (1 hunks)
  • applications/tari_walletd/src/handlers/keys.rs (1 hunks)
  • applications/tari_walletd/src/handlers/mod.rs (1 hunks)
  • applications/tari_walletd/src/handlers/nfts.rs (1 hunks)
  • applications/tari_walletd/src/handlers/rpc.rs (1 hunks)
  • applications/tari_walletd/src/handlers/settings.rs (1 hunks)
  • applications/tari_walletd/src/handlers/stealth_utxos.rs (1 hunks)
  • applications/tari_walletd/src/handlers/substates.rs (1 hunks)
  • applications/tari_walletd/src/handlers/templates.rs (1 hunks)
  • applications/tari_walletd/src/handlers/transaction.rs (1 hunks)
  • applications/tari_walletd/src/handlers/validator.rs (1 hunks)
  • applications/tari_walletd/src/handlers/wallet.rs (1 hunks)
  • applications/tari_walletd/src/handlers/webauthn.rs (1 hunks)
  • applications/tari_walletd/src/handlers/webrtc.rs (5 hunks)
  • applications/tari_walletd/src/http_ui/server.rs (2 hunks)
  • applications/tari_walletd/src/jrpc_server.rs (6 hunks)
  • applications/tari_walletd/src/lib.rs (1 hunks)
  • applications/tari_walletd/src/webrtc.rs (1 hunks)
  • networking/libp2p-messaging/src/codec/prost.rs (1 hunks)
  • networking/rpc_framework/Cargo.toml (1 hunks)
  • utilities/db_inspector/Cargo.toml (0 hunks)
  • utilities/db_inspector/src/webserver/handlers/tables.rs (1 hunks)
  • utilities/db_inspector/src/webserver/server.rs (2 hunks)

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

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

⚠️ Outside diff range comments (3)
applications/tari_signaling_server/src/jrpc_server.rs (1)

176-185: Bug: token extraction passes Bearer struct to check_jwt

Extract the token string from the header; pass &str (or String) to check_jwt.

-    let token = authorization_header.map(|auth| auth.0 .0);
+    let token = authorization_header
+        .as_ref()
+        .map(|TypedHeader(headers::Authorization(bearer))| bearer.token().to_string());
...
-    if let Some(token) = token {
-        let id = match data.check_jwt(token) {
+    if let Some(token) = token {
+        let id = match data.check_jwt(&token) {
applications/tari_indexer/src/json_rpc/handlers.rs (2)

367-371: Overflow-safe formatting: prefer saturating_add(1).

request.version.unwrap_or(0) + 1 can overflow at u64::MAX. Use saturating_add(1) for robustness in error messages.

-                                    request.version.unwrap_or(0) + 1,
+                                    request.version.unwrap_or(0).saturating_add(1),

486-498: Fix off-by-one in shard_state_versions entry limit
The length check uses NumPreshards::MAX_SHARD.as_u32() (256) but valid entries run 0–256 (257 total). Change the guard to > NumPreshards::MAX_SHARD.as_u32() as usize + 1 or use the shared MAX_SHARDS/ShardStateVersions::MAX_LEN constant so 257 entries are permitted.

🧹 Nitpick comments (19)
applications/tari_app_utilities/Cargo.toml (1)

37-41: Feature set expansion looks correct; consider trimming defaults if not needed

serde(rc) and tokio(net) make sense given new TCP helpers. If default-heavy features aren’t required, consider narrowing for smaller builds.

applications/tari_validator_node/src/http_ui/server.rs (2)

43-48: Startup log may be misleading after fallback bind

The first log prints the preferred address before binding; fallback may change the port. Either remove it or clarify intent.

Apply:

-    info!(target: LOG_TARGET, "🕸️ Web UI started at http://{}", address);
+    info!(target: LOG_TARGET, "🕸️ Attempting to bind Web UI at http://{}", address);
@@
-    info!(target: LOG_TARGET, "🕸️ Web UI listening on {}", server.local_addr()?);
+    info!(target: LOG_TARGET, "🕸️ Web UI listening on {}", server.local_addr()?);

76-76: Avoid println! in server path

Use logging for consistency.

Apply:

-    println!("Not found {:?}", path);
+    warn!(target: LOG_TARGET, "Not found {:?}", path);
applications/tari_swarm_daemon/src/webserver/server.rs (1)

180-201: Don’t leak internal error details in production responses

Mirror the pattern used elsewhere to reduce error detail in release builds.

Apply:

-fn resolve_any_error(answer_id: axum_jrpc::Id, e: &anyhow::Error) -> JsonRpcResponse {
-    warn!(target: LOG_TARGET, "🌐 JSON-RPC error: {}", e);
-    if let Some(handler_err) = e.downcast_ref::<HandlerError>() {
-        return resolve_handler_error(answer_id, handler_err);
-    }
-
-    JsonRpcResponse::error(
-        answer_id,
-        JsonRpcError::new(JsonRpcErrorReason::ApplicationError(500), e.to_string(), json!({})),
-    )
-}
+fn resolve_any_error(answer_id: axum_jrpc::Id, e: &anyhow::Error) -> JsonRpcResponse {
+    warn!(target: LOG_TARGET, "🌐 JSON-RPC error: {}", e);
+    if let Some(handler_err) = e.downcast_ref::<HandlerError>() {
+        return resolve_handler_error(answer_id, handler_err);
+    }
+    let msg = if cfg!(debug_assertions) || option_env!("CI").is_some() {
+        e.to_string()
+    } else {
+        "Something went wrong".to_string()
+    };
+    JsonRpcResponse::error(
+        answer_id,
+        JsonRpcError::new(JsonRpcErrorReason::ApplicationError(500), msg, json!({})),
+    )
+}
applications/tari_validator_node/src/lib.rs (1)

143-145: Log the actual bound JSON-RPC address after awaiting spawn.

Current info! logs the preferred address before binding (can be wrong if fallback to ephemeral happens). Log after awaiting to show the actual bound address.

-        )
-        .await?;
+        ).await?;
+        info!(target: LOG_TARGET, "🌐 JSON-RPC listening on {}", jrpc_address);

For a cleaner result, also remove the earlier pre-bind info! on Line 136 so only the actual address is logged.

applications/tari_signaling_server/src/data.rs (1)

72-79: Consider taking &Bearer instead of Bearer to avoid unnecessary moves and reduce coupling.

Accepting a reference avoids ownership transfers and keeps this utility flexible.

-    pub fn check_jwt(&self, token: Bearer) -> anyhow::Result<u64> {
+    pub fn check_jwt(&self, token: &Bearer) -> anyhow::Result<u64> {
         let token: TokenData<Claims> = decode(
-            token.token(),
+            token.token(),
             &DecodingKey::from_secret(self.secret_key.reveal()),
             &Validation::default(),
         )?;
         Ok(token.claims.id)
     }
applications/tari_indexer/src/http_ui/server.rs (1)

53-57: Avoid pre-bind “started” log; only log after binding to the actual address.

The first info! can be misleading if fallback occurs. Rely on server.local_addr() for accuracy.

-    info!(target: LOG_TARGET, "🕸️ Web UI started at http://{}", address);
     let listener = try_bind_with_fallback(address).await?;
     let server = axum::serve(listener, router);
     info!(target: LOG_TARGET, "🕸️ Web UI listening on {}", server.local_addr()?);
applications/tari_app_utilities/src/tcp.rs (1)

11-23: Tighten fallback conditions and improve diagnostics.

Fallback on AddrInUse (and optionally AddrNotAvailable) only; otherwise propagate errors. Also log the preferred address for traceability.

 pub async fn try_bind_with_fallback(mut preferred_address: SocketAddr) -> io::Result<TcpListener> {
-    match TcpListener::bind(preferred_address).await {
-        Ok(l) => Ok(l),
-        Err(e) => {
-            warn!(
-                target: LOG_TARGET,
-                "🕸️ Failed to bind on preferred address ({e}). Trying OS-assigned",
-            );
-            preferred_address.set_port(0);
-            TcpListener::bind(preferred_address).await
-        },
-    }
+    match TcpListener::bind(preferred_address).await {
+        Ok(l) => Ok(l),
+        Err(e) if matches!(e.kind(), io::ErrorKind::AddrInUse | io::ErrorKind::AddrNotAvailable) => {
+            warn!(
+                target: LOG_TARGET,
+                "🕸️ Failed to bind on preferred address {preferred_address} ({e}). Trying OS-assigned"
+            );
+            preferred_address.set_port(0);
+            TcpListener::bind(preferred_address).await
+        },
+        Err(e) => Err(e),
+    }
 }
applications/tari_indexer/src/lib.rs (1)

158-159: Log the actual bound JSON-RPC address after awaiting spawn.

The info! on Line 149 logs the preferred address; prefer logging the actual one returned by spawn_json_rpc.

-        let jrpc_address = spawn_json_rpc(jrpc_address, handlers).await?;
-        debug!(target: LOG_TARGET, "JSON-RPC address {}", jrpc_address);
+        let jrpc_address = spawn_json_rpc(jrpc_address, handlers).await?;
+        info!(target: LOG_TARGET, "🌐 JSON-RPC listening on {}", jrpc_address);

Optionally remove the earlier pre-bind info! on Line 149 to avoid duplicate/misleading logs.

applications/tari_indexer/src/json_rpc/error.rs (1)

13-26: Prefer FnOnce and avoid unnecessary Id clone

This closure is only called once; returning FnOnce lets you drop the extra clone and align with the validator-node implementation.

-pub fn internal_error<T: Display>(answer_id: axum_jrpc::Id) -> impl Fn(T) -> JsonRpcResponse {
+pub fn internal_error<T: Display>(answer_id: axum_jrpc::Id) -> impl FnOnce(T) -> JsonRpcResponse {
     move |err| {
         let msg = if cfg!(debug_assertions) || option_env!("CI").is_some() {
             err.to_string()
         } else {
             log::error!(target: LOG_TARGET, "🚨 Internal error: {}", err);
             "Something went wrong".to_string()
         };
         JsonRpcResponse::error(
-            answer_id.clone(),
+            answer_id,
             JsonRpcError::new(JsonRpcErrorReason::InternalError, msg, serde_json::Value::Null),
         )
     }
 }
applications/tari_validator_node/src/json_rpc/server.rs (1)

52-57: Minor: you can spawn Serve directly without IntoFuture

Serve implements Future; you can drop IntoFuture and spawn the server directly.

-use std::{future::IntoFuture, net::SocketAddr, sync::Arc};
+use std::{net::SocketAddr, sync::Arc};
...
-    tokio::spawn(server.into_future());
+    tokio::spawn(server);
applications/tari_walletd/src/http_ui/server.rs (1)

44-48: Avoid potentially misleading pre-bind log

If fallback occurs (e.g., port in use), the initial “started at http://{address}” can be wrong. Log “attempting to bind” or remove the pre-bind log.

-    info!(target: LOG_TARGET, "🕸️ Web UI started at http://{}", address);
+    debug!(target: LOG_TARGET, "🕸️ Attempting to bind Web UI at http://{}", address);
     let listener = try_bind_with_fallback(address).await?;
     let server = axum::serve(listener, router);
     info!(target: LOG_TARGET, "🕸️ Web UI listening on {}", server.local_addr()?);
applications/tari_signaling_server/src/jrpc_server.rs (3)

43-46: Adopt the common bind-with-fallback helper for consistency and resilience

Other servers use try_bind_with_fallback to gracefully fall back to an OS-assigned port. Mirror that here.

+use tari_ootle_app_utilities::tcp::try_bind_with_fallback;
...
-    let listener = tokio::net::TcpListener::bind(preferred_address).await?;
-    let server = axum::serve(listener, router);
-    info!(target: LOG_TARGET, "🌐 JSON-RPC listening on {}", server.local_addr()?);
+    let listener = try_bind_with_fallback(preferred_address).await?;
+    let server = axum::serve(listener, router);
+    info!(target: LOG_TARGET, "🌐 JSON-RPC listening on {}", server.local_addr()?);

199-201: Use answer_id in get_answer errors (avoid hardcoded 0) — pass JsonRpcExtractor

Today get_answer uses a fixed id=0 in its error; pass value to get_answer so it can use value.get_answer_id().

-            "get.answer" => get_answer(id, data)?,
+            "get.answer" => get_answer(id, value, data)?,

117-123: Fix JSON-RPC error id in get_answer

Return errors with the real answer_id instead of 0.

-fn get_answer(id: u64, data: MutexGuard<Data>) -> Result<json::Value, JsonRpcResponse> {
+fn get_answer(id: u64, value: JsonRpcExtractor, data: MutexGuard<Data>) -> Result<json::Value, JsonRpcResponse> {
     info!(target: LOG_TARGET, "Getting answer for id {id}");
     data.get_answer(id).cloned().map_err(|e| {
         JsonRpcResponse::error(
-            0,
+            value.get_answer_id(),
             JsonRpcError::new(
                 JsonRpcErrorReason::ApplicationError(404),
                 "Answer not found".to_string(),
                 json!({
                     "id": id,
                     "error": e.to_string(),
                 }),
             ),
         )
     })
 }
applications/tari_indexer/src/json_rpc/server.rs (1)

52-53: Consider exposing shutdown/JoinHandle for lifecycle control.

The detached spawn drops the JoinHandle, so panics/early exits aren’t observable and there’s no graceful shutdown. Consider returning the JoinHandle or adding a shutdown signal (like walletd’s with_graceful_shutdown) in a follow‑up.

applications/tari_indexer/src/json_rpc/handlers.rs (2)

852-855: Rename Self::internal_error to avoid collision with imported internal_error().

Having both an imported internal_error(answer_id) -> impl Fn and a Self::internal_error(answer_id, err) increases cognitive load and invites misuse. Consider renaming the inherent method to internal_error_resp (or similar).


58-60: Avoid logging full request payloads.

Debug logging the entire JsonRpcExtractor can leak sensitive params in dev/log aggregation. Consider logging method and id only (or redact known sensitive fields).

applications/tari_walletd/src/jrpc_server.rs (1)

61-69: Minor: “Stopping JSON-RPC” log fires immediately.

That log runs right after spawning the server, not on shutdown. Consider moving it into the spawned task after server.await returns to reflect actual shutdown.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3099ac2 and e644d67.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (55)
  • Cargo.toml (5 hunks)
  • applications/tari_app_utilities/Cargo.toml (2 hunks)
  • applications/tari_app_utilities/src/lib.rs (1 hunks)
  • applications/tari_app_utilities/src/tcp.rs (1 hunks)
  • applications/tari_indexer/Cargo.toml (2 hunks)
  • applications/tari_indexer/src/graphql/server.rs (2 hunks)
  • applications/tari_indexer/src/http_ui/server.rs (2 hunks)
  • applications/tari_indexer/src/json_rpc/error.rs (2 hunks)
  • applications/tari_indexer/src/json_rpc/handlers.rs (29 hunks)
  • applications/tari_indexer/src/json_rpc/server.rs (1 hunks)
  • applications/tari_indexer/src/lib.rs (1 hunks)
  • applications/tari_indexer/src/network_state_sync/sync_progress.rs (1 hunks)
  • applications/tari_signaling_server/Cargo.toml (1 hunks)
  • applications/tari_signaling_server/src/data.rs (2 hunks)
  • applications/tari_signaling_server/src/jrpc_server.rs (5 hunks)
  • applications/tari_swarm_daemon/Cargo.toml (1 hunks)
  • applications/tari_swarm_daemon/src/webserver/handler.rs (1 hunks)
  • applications/tari_swarm_daemon/src/webserver/server.rs (6 hunks)
  • applications/tari_validator_node/Cargo.toml (1 hunks)
  • applications/tari_validator_node/src/cli.rs (1 hunks)
  • applications/tari_validator_node/src/http_ui/server.rs (2 hunks)
  • applications/tari_validator_node/src/json_rpc/handlers.rs (29 hunks)
  • applications/tari_validator_node/src/json_rpc/jrpc_errors.rs (5 hunks)
  • applications/tari_validator_node/src/json_rpc/server.rs (2 hunks)
  • applications/tari_validator_node/src/lib.rs (1 hunks)
  • applications/tari_wallet_cli/src/command/proof.rs (2 hunks)
  • applications/tari_wallet_cli/src/command/transaction.rs (3 hunks)
  • applications/tari_wallet_cli/src/from_base64.rs (2 hunks)
  • applications/tari_walletd/Cargo.toml (1 hunks)
  • applications/tari_walletd/src/handlers/accounts.rs (1 hunks)
  • applications/tari_walletd/src/handlers/auth/jwt.rs (1 hunks)
  • applications/tari_walletd/src/handlers/confidential.rs (1 hunks)
  • applications/tari_walletd/src/handlers/context.rs (1 hunks)
  • applications/tari_walletd/src/handlers/keys.rs (1 hunks)
  • applications/tari_walletd/src/handlers/mod.rs (1 hunks)
  • applications/tari_walletd/src/handlers/nfts.rs (1 hunks)
  • applications/tari_walletd/src/handlers/rpc.rs (1 hunks)
  • applications/tari_walletd/src/handlers/settings.rs (1 hunks)
  • applications/tari_walletd/src/handlers/stealth_utxos.rs (1 hunks)
  • applications/tari_walletd/src/handlers/substates.rs (1 hunks)
  • applications/tari_walletd/src/handlers/templates.rs (1 hunks)
  • applications/tari_walletd/src/handlers/transaction.rs (1 hunks)
  • applications/tari_walletd/src/handlers/validator.rs (1 hunks)
  • applications/tari_walletd/src/handlers/wallet.rs (1 hunks)
  • applications/tari_walletd/src/handlers/webauthn.rs (1 hunks)
  • applications/tari_walletd/src/handlers/webrtc.rs (5 hunks)
  • applications/tari_walletd/src/http_ui/server.rs (2 hunks)
  • applications/tari_walletd/src/jrpc_server.rs (6 hunks)
  • applications/tari_walletd/src/lib.rs (1 hunks)
  • applications/tari_walletd/src/webrtc.rs (1 hunks)
  • networking/libp2p-messaging/src/codec/prost.rs (1 hunks)
  • networking/rpc_framework/Cargo.toml (1 hunks)
  • utilities/db_inspector/Cargo.toml (0 hunks)
  • utilities/db_inspector/src/webserver/handlers/tables.rs (1 hunks)
  • utilities/db_inspector/src/webserver/server.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • utilities/db_inspector/Cargo.toml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-19T10:49:02.115Z
Learnt from: sdbondi
PR: tari-project/tari-ootle#1543
File: crates/common_types/src/shard_state_versions.rs:59-74
Timestamp: 2025-08-19T10:49:02.115Z
Learning: In crates/common_types/src/shard_state_versions.rs, MAX_SHARDS represents the maximum shard number + 1 (257) used for bounds checking, not the maximum capacity. The current code correctly validates that shard group end numbers don't exceed the maximum possible shard number (256).

Applied to files:

  • applications/tari_indexer/src/json_rpc/handlers.rs
🧬 Code graph analysis (16)
applications/tari_indexer/src/http_ui/server.rs (1)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_validator_node/src/json_rpc/handlers.rs (1)
applications/tari_validator_node/src/json_rpc/jrpc_errors.rs (2)
  • internal_error (47-60)
  • not_found (62-71)
applications/tari_indexer/src/json_rpc/server.rs (2)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_validator_node/src/json_rpc/server.rs (2)
  • spawn_json_rpc (35-59)
  • handler (61-117)
applications/tari_validator_node/src/json_rpc/server.rs (2)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_indexer/src/json_rpc/server.rs (1)
  • spawn_json_rpc (39-55)
applications/tari_validator_node/src/json_rpc/jrpc_errors.rs (2)
applications/tari_indexer/src/json_rpc/error.rs (1)
  • internal_error (13-26)
applications/tari_indexer/src/json_rpc/handlers.rs (2)
  • internal_error (852-855)
  • not_found (844-846)
applications/tari_walletd/src/lib.rs (1)
applications/tari_walletd/src/jrpc_server.rs (1)
  • spawn_listener (44-73)
applications/tari_walletd/src/jrpc_server.rs (2)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_swarm_daemon/src/webserver/server.rs (3)
  • e (192-192)
  • resolve_handler_error (180-188)
  • resolve_any_error (190-200)
applications/tari_validator_node/src/http_ui/server.rs (1)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_walletd/src/http_ui/server.rs (1)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_swarm_daemon/src/webserver/server.rs (2)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_walletd/src/jrpc_server.rs (5)
  • e (244-244)
  • e (248-248)
  • e (255-255)
  • resolve_handler_error (228-240)
  • resolve_any_error (242-274)
applications/tari_indexer/src/json_rpc/handlers.rs (2)
applications/tari_indexer/src/json_rpc/error.rs (1)
  • internal_error (13-26)
applications/tari_validator_node/src/json_rpc/jrpc_errors.rs (2)
  • internal_error (47-60)
  • not_found (62-71)
applications/tari_indexer/src/json_rpc/error.rs (2)
applications/tari_indexer/src/json_rpc/handlers.rs (1)
  • internal_error (852-855)
applications/tari_validator_node/src/json_rpc/jrpc_errors.rs (1)
  • internal_error (47-60)
applications/tari_walletd/src/handlers/accounts.rs (1)
crates/engine/src/runtime/working_state.rs (1)
  • authorization (947-949)
applications/tari_indexer/src/graphql/server.rs (1)
applications/tari_app_utilities/src/tcp.rs (1)
  • try_bind_with_fallback (11-23)
applications/tari_indexer/src/lib.rs (1)
applications/tari_indexer/src/json_rpc/server.rs (1)
  • spawn_json_rpc (39-55)
applications/tari_wallet_cli/src/command/transaction.rs (1)
crates/tari_bor/src/lib.rs (1)
  • decode_exact (123-132)
⏰ 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). (6)
  • GitHub Check: test
  • GitHub Check: machete
  • GitHub Check: clippy
  • GitHub Check: check stable
  • GitHub Check: fmt
  • GitHub Check: check nightly
🔇 Additional comments (55)
utilities/db_inspector/src/webserver/handlers/tables.rs (1)

25-31: Signature update aligns with axum 0.8 Handler changes.

Removing the extraneous B generic and returning impl Handler<(), S> matches the updated trait in axum 0.8. No further adjustments needed here.

applications/tari_wallet_cli/src/command/proof.rs (1)

25-81: BASE64 engine alignment looks good.

Switching to BASE64_STANDARD.encode (Line 81) keeps this command on the supported API after the base64 upgrade.

applications/tari_wallet_cli/src/from_base64.rs (1)

25-45: Consistent decode path confirmed.

Using BASE64_STANDARD.decode (Line 44) here matches the rest of the CLI changes and avoids the deprecated free function.

applications/tari_wallet_cli/src/command/transaction.rs (3)

756-757: Helper reuse keeps decoding uniform.

Routing the blob load through base64_decode (Line 757) makes the CLI share the same engine-based decode everywhere.


937-942: Globals decode path updated correctly.

The switch to base64_decode (Lines 938-942) ensures file/data URLs use the new engine-backed API consistently.


956-959: New helper matches the base64 0.22 API expectations.

The wrapper cleanly centralizes BASE64_STANDARD.decode (Lines 956-959) and keeps the trait import scoped.

utilities/db_inspector/src/webserver/server.rs (1)

120-132: Fallback bind flow and logging look great

We bind eagerly, warn on failure, fall back to an ephemeral loopback listener, and surface the actual address via Serve::local_addr. Solid upgrade for the Axum 0.8 flow.

applications/tari_app_utilities/Cargo.toml (1)

12-12: tari_crypto serde feature enabled — LGTM

This aligns with broader serde usage across the workspace.

applications/tari_walletd/src/lib.rs (1)

122-124: Async spawn_listener await and handle — LGTM

Pattern matches the new listener-based axum 0.8 startup. Select! awaits the join handle cleanly.

applications/tari_validator_node/src/json_rpc/handlers.rs (1)

166-167: axum_jrpc::Id migration and error mapping closure usage — LGTM

Consistent Id cloning and map_err(FnOnce) usage across handlers.

Also applies to: 195-198, 205-216, 274-278, 303-305, 306-310, 314-322, 325-327, 344-345, 361-367, 383-391, 407-407, 431-433, 444-445, 465-466, 478-479, 500-501, 506-507, 539-540, 568-575, 584-585, 602-609, 621-628, 653-654, 707-711, 723-724, 739-740, 775-776, 812-813, 817-818, 872-873, 879-880, 884-885, 918-919

applications/tari_swarm_daemon/src/webserver/server.rs (4)

69-72: Binding via try_bind_with_fallback + axum::serve — LGTM

Correctly logs the actual bound address via server.local_addr().


112-112: Switched to warn! for 404s — LGTM

Consistent with server logging.


180-188: No missing match arms; enum only has Anyhow variant The HandlerError enum currently defines only the Anyhow variant, so the match in resolve_handler_error is exhaustive—remove the commented-out NotFound code if it’s no longer needed.

Likely an incorrect or invalid review comment.


84-93: Remove unnecessary MSRV compatibility suggestion Option::is_none_or was stabilized in Rust 1.82 and our MSRV is 1.88, so no change is required.

Likely an incorrect or invalid review comment.

applications/tari_validator_node/src/json_rpc/jrpc_errors.rs (2)

47-60: internal_error(Id) as FnOnce — LGTM

Matches usage via map_err(internal_error(answer_id.clone())).


62-71: Error helpers now accept axum_jrpc::Id — LGTM

Signatures align with handler call sites; consistent error shaping.

Also applies to: 74-83, 85-94

applications/tari_validator_node/Cargo.toml (1)

74-74: No reqwest references detected in applications/tari_validator_node

Cargo.toml (1)

161-165: Workspace Axum/Tower versions consistent
All Cargo.toml files reference axum = "0.8" and tower = "0.5"; no mixed major versions detected.

applications/tari_walletd/src/handlers/accounts.rs (1)

6-6: Bearer import migration looks correct.

The swap to axum_extra’s Bearer aligns with axum 0.8’s typed-header reorganization. No further action needed.

applications/tari_walletd/src/handlers/validator.rs (1)

7-7: Bearer header path updated appropriately.

Matches the framework upgrade requirements; nothing else to fix here.

applications/tari_walletd/src/handlers/webauthn.rs (1)

4-4: Bearer import switch looks good.

Consistent with the rest of the handlers and axum-extra usage.

applications/tari_walletd/src/handlers/templates.rs (1)

4-4: Bearer import migration confirmed.

Keeps the handler current with the dependency upgrades.

applications/tari_walletd/src/handlers/keys.rs (1)

4-4: Bearer import update LGTM.

No functional changes beyond the dependency shift—looks solid.

applications/tari_walletd/src/handlers/substates.rs (1)

4-4: Bearer import sourced correctly.

Matches the axum-extra migration; all good.

applications/tari_walletd/src/handlers/confidential.rs (1)

7-7: Bearer header move verified.

The handler compiles against the new axum-extra location—no issues spotted.

applications/tari_walletd/src/handlers/nfts.rs (1)

7-7: Bearer import change checks out.

Consistent with the project-wide transition; ready to go.

applications/tari_walletd/src/handlers/stealth_utxos.rs (1)

4-4: Align Bearer import with axum 0.8

Switching to axum_extra::headers::authorization::Bearer matches the new location in the upgraded axum stack; the handler signature remains valid.

applications/tari_walletd/src/handlers/auth/jwt.rs (1)

6-6: Bearer extractor import is up to date

The move to axum_extra::headers::authorization::Bearer aligns this module with the axum 0.8 migration while keeping token handling intact.

applications/tari_walletd/src/handlers/context.rs (1)

4-4: Context now references the new Bearer location

Importing Bearer from axum_extra keeps HandlerContext::check_auth compatible with the framework upgrade.

applications/tari_walletd/src/handlers/wallet.rs (1)

4-4: Bearer import follows the framework migration

The handler continues to accept optional bearer tokens while pointing at the updated type path.

applications/tari_walletd/src/handlers/settings.rs (1)

4-4: Updated Bearer path is correct

Authorization for the settings endpoints now references the axum-extra header as expected for axum 0.8.

applications/tari_walletd/src/handlers/transaction.rs (1)

6-6: Bearer extractor import matches new dependency layout

This swap keeps all transaction handlers compatible with the axum upgrade without altering behavior.

applications/tari_walletd/src/handlers/rpc.rs (1)

4-4: Bearer import relocation acknowledged

Using axum_extra here keeps the RPC auth flow aligned with the updated dependency graph.

applications/tari_app_utilities/src/lib.rs (1)

31-31: Exporting the tcp module looks good

Exposing pub mod tcp; cleanly surfaces the new binding helper for downstream crates.

applications/tari_signaling_server/src/data.rs (1)

6-6: LGTM: Migrating to axum-extra’s Bearer is consistent with the axum 0.8 upgrade.

applications/tari_walletd/src/handlers/webrtc.rs (2)

6-6: LGTM: axum-extra Bearer import path.


33-73: LGTM: Cloning answer_id in error branches avoids moved-value issues.

This aligns with axum_jrpc::Id ownership requirements.

applications/tari_indexer/Cargo.toml (2)

52-52: LGTM: Adding indexmap aligns with serde_with indexmap_2 feature.


68-68: Ensure workspace serde_with version ≥ 3.2.0 to enable the indexmap_2 feature
Verify that the serde_with dependency in the root/workspace Cargo.toml is set to v3.2.0 or higher.

applications/tari_walletd/src/handlers/mod.rs (1)

26-27: LGTM: axum_extra::headers::authorization::Bearer and async_trait imports are correct. axum-extra is already enabled with the typed-header feature in the workspace.

applications/tari_validator_node/src/json_rpc/server.rs (1)

52-55: LGTM: listener + axum::serve migration

Using try_bind_with_fallback and deriving the bound address via server.local_addr() looks correct.

applications/tari_indexer/src/graphql/server.rs (1)

68-72: LGTM: migrated to TcpListener + axum::serve

Binding via try_bind_with_fallback and logging the actual bound address is sound. Awaiting the server in-place maintains previous behavior.

applications/tari_signaling_server/src/jrpc_server.rs (1)

203-208: Confirm JrpcResult semantics for error returns

You return Ok(JsonRpcResponse::error(...)) for some errors and Err(...) for others. Ensure this is intentional (e.g., to influence HTTP status mapping) and consistent with axum_jrpc’s expected handler contract.

Also applies to: 229-238

applications/tari_indexer/src/json_rpc/server.rs (2)

39-55: Axum 0.8 serve + TcpListener migration looks good.

Clean switch to try_bind_with_fallback + axum::serve(listener, router) with local_addr() and spawning via into_future(). Matches axum 0.8 patterns.


32-32: No change needed: crate path is correct. The crate at applications/tari_app_utilities/Cargo.toml is named tari_ootle_app_utilities, matching the import; no duplicate utilities exist.

applications/tari_indexer/src/json_rpc/handlers.rs (1)

151-176: Consistent switch to axum_jrpc::Id and error helpers is solid.

Id cloning at call sites and helper signatures align with axum_jrpc::Id. Error mapping via closure internal_error(answer_id.clone()) vs. Self::* helpers is coherent.

Also applies to: 188-195, 200-207, 218-222, 234-240, 398-401, 409-416, 419-430, 445-461, 501-517, 526-533, 541-548, 586-595, 610-611, 632-652, 668-670, 681-688, 711-721, 724-727, 731-733, 757-758, 780-782, 820-821, 832-833, 837-855

applications/tari_walletd/src/jrpc_server.rs (2)

44-49: Serve + listener + fallback bind and updated Bearer header import look good.

  • Binding via try_bind_with_fallback + axum::serve with local_addr() is correct.
  • axum_extra::headers::authorization::Bearer import matches newer axum‑extra.

Also applies to: 61-64, 11-12, 22-22


44-49: All spawn_listener calls are awaited – the invocation in applications/tari_walletd/src/lib.rs:123 already uses .await.

networking/rpc_framework/Cargo.toml (1)

24-24: Dependency feature trim LGTM

Line [24]: Dropping tower’s default feature set while keeping the explicit make/util pair lines up nicely with the workspace upgrade. 👍

applications/tari_swarm_daemon/Cargo.toml (1)

30-31: Handshake with axum-extra looks solid

Lines [30-31]: Swapping out headers for axum-extra’s typed-header support pairs cleanly with the axum 0.8 migration—no concerns here.

applications/tari_walletd/Cargo.toml (1)

33-36: Walletd dependency bump is consistent

Lines [33-36]: Adding the shared async-trait crate and moving TypedHeader support to axum-extra matches the rest of the stack. Looks good.

applications/tari_swarm_daemon/src/webserver/handler.rs (1)

6-6: Async-trait import aligned

Line [6]: Switching to async_trait::async_trait keeps the attribute usable post-axum upgrade. All good.

applications/tari_validator_node/src/cli.rs (1)

30-30: Url alias cleanup accepted

Line [30]: Using url::Url directly removes the reqwest alias dependency without altering behavior. 👍

applications/tari_indexer/src/network_state_sync/sync_progress.rs (1)

4-4: IndexMap import looks right

Line [4]: Moving to the workspace indexmap ties in perfectly with the Cargo feature updates—happy path.

applications/tari_signaling_server/Cargo.toml (1)

18-19: Signaling server deps in sync

Lines [18-19]: Axum + axum-extra split matches the new auth header flow. No issues spotted.

Comment thread applications/tari_validator_node/src/json_rpc/server.rs
Comment thread applications/tari_walletd/src/jrpc_server.rs
Comment thread applications/tari_walletd/src/webrtc.rs
Comment thread networking/libp2p-messaging/src/codec/prost.rs
@sdbondi
sdbondi merged commit e6a2f8a into tari-project:development Sep 25, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants