Skip to content

fix: increase http server limit#7314

Merged
SWvheerden merged 1 commit intotari-project:developmentfrom
SWvheerden:sw_feat_size_limit
Jul 14, 2025
Merged

fix: increase http server limit#7314
SWvheerden merged 1 commit intotari-project:developmentfrom
SWvheerden:sw_feat_size_limit

Conversation

@SWvheerden
Copy link
Copy Markdown
Collaborator

@SWvheerden SWvheerden commented Jul 14, 2025

Description

fixes http limits

Summary by CodeRabbit

  • New Features
    • Introduced a maximum request body size limit of 4096 bytes for the POST /json_rpc endpoint to enhance request handling.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 14, 2025

Walkthrough

A maximum request body size of 4096 bytes is now enforced on the POST /json_rpc route in the HTTP server. This is achieved by applying the DefaultBodyLimit layer from the Axum framework. The relevant import was added to support this change.

Changes

File Change Summary
applications/minotari_node/src/http/server.rs Enforced 4096-byte body limit on /json_rpc POST route; added DefaultBodyLimit import

Poem

A hop and a skip, the server’s now wise,
No giant requests in a sneaky disguise!
Four thousand and ninety-six bytes is the gate,
For JSON RPC, that’s the new weight.
With limits in place, we’re nimble and spry—
A rabbit-proof fence as the packets hop by!

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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
Copy Markdown
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 081969a and a6a822a.

📒 Files selected for processing (1)
  • applications/minotari_node/src/http/server.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ksrichard
PR: tari-project/tari#7129
File: applications/minotari_node/src/http/handler/sync_utxos_by_block.rs:21-29
Timestamp: 2025-05-29T20:59:32.020Z
Learning: In the Tari codebase, request validation for RPC services is handled at the service layer using the `serde_valid` crate rather than at the HTTP handler level. For example, `SyncUtxosByBlockRequest` validates that limit is between 1-5 and page is minimum 0. HTTP handlers should delegate validation to the service layer rather than implementing their own validation.
applications/minotari_node/src/http/server.rs (1)
Learnt from: ksrichard
PR: tari-project/tari#7129
File: applications/minotari_node/src/http/handler/sync_utxos_by_block.rs:21-29
Timestamp: 2025-05-29T20:59:32.020Z
Learning: In the Tari codebase, request validation for RPC services is handled at the service layer using the `serde_valid` crate rather than at the HTTP handler level. For example, `SyncUtxosByBlockRequest` validates that limit is between 1-5 and page is minimum 0. HTTP handlers should delegate validation to the service layer rather than implementing their own validation.
⏰ 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). (8)
  • GitHub Check: ci
  • GitHub Check: file licenses
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: cargo check with stable
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: Cucumber tests / FFI
🔇 Additional comments (1)
applications/minotari_node/src/http/server.rs (1)

7-7: LGTM: Import addition is correct.

The import of DefaultBodyLimit from axum::extract is properly added to support the body limit layer.

Comment on lines +78 to +81
.route(
"/json_rpc",
post(handler::json_rpc::handle::<B>).layer(DefaultBodyLimit::max(4096)),
)
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.

💡 Verification agent

🧩 Analysis chain

Verify the 4096 byte limit is appropriate for JSON-RPC requests.

The technical implementation is correct, but the 4096 byte limit might be too restrictive for complex JSON-RPC requests. Consider the following concerns:

  1. Potential restriction: JSON-RPC requests with large parameters or batch requests may exceed 4096 bytes
  2. Hardcoded limit: The limit should be configurable rather than hardcoded
  3. PR title discrepancy: The PR title mentions "increase" but this sets a specific limit

Please verify that 4096 bytes is sufficient for expected JSON-RPC requests and consider making this configurable:


🏁 Script executed:

#!/bin/bash
# Description: Check for existing JSON-RPC request examples and configurations
# Expected: Find JSON-RPC handlers and sample requests to assess typical size

# Search for JSON-RPC handlers and related code
rg -A 10 -B 5 "json_rpc" --type rust

# Look for any existing size limits or configurations
rg -A 5 -B 5 "body.*limit|limit.*body|request.*size|size.*request" --type rust

# Check for any configuration files that might define limits
fd -e toml -e yaml -e json | head -10 | xargs grep -l "limit\|size\|json" || echo "No config files found with limit/size settings"

Length of output: 57711


Make JSON-RPC body limit configurable and verify size

The .layer(DefaultBodyLimit::max(4096)) correctly applies a 4 KiB limit, but:

  • There’s no existing configuration key for HTTP body limits in any TOML/YAML/JSON.
  • JSON-RPC payloads (especially large transactions or batch calls) can easily exceed 4 KiB.
  • The PR title suggests “increase,” yet we’re hard-coding a new fixed limit without context.

Please update applications/minotari_node/src/http/server.rs (around lines 78–81) to:

  • Replace the hardcoded 4096 with a value loaded from configuration (e.g. http.json_rpc_max_body_size_bytes), with a sensible default.
  • Add the new config key to the application’s TOML (and document it).
  • Verify (or provide benchmarks/examples) that the chosen default comfortably covers expected JSON-RPC request sizes.
🤖 Prompt for AI Agents
In applications/minotari_node/src/http/server.rs around lines 78 to 81, replace
the hardcoded 4096 byte limit in DefaultBodyLimit::max with a value loaded from
a new configuration key, such as http.json_rpc_max_body_size_bytes, providing a
sensible default if the config is missing. Add this new configuration key to the
application's TOML file with documentation explaining its purpose and
recommended default size, ensuring the default is large enough to handle typical
JSON-RPC payloads including large transactions or batch calls.

@github-actions
Copy link
Copy Markdown

Test Results (CI)

    3 files    135 suites   36m 34s ⏱️
1 358 tests 1 358 ✅ 0 💤 0 ❌
4 072 runs  4 072 ✅ 0 💤 0 ❌

Results for commit a6a822a.

Copy link
Copy Markdown
Contributor

@MCozhusheck MCozhusheck left a comment

Choose a reason for hiding this comment

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

Could this limit be not enough in cases of paginated transaction list from gRPC method get_all_completed_transactions?
Also is this limit for whole message or just one chunk if response is a stream?

Copy link
Copy Markdown
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

utACK

I would up more size limits form the default, and increase it from 4MiB.

use std::sync::Arc;

use axum::{
extract::DefaultBodyLimit,
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.

We can also add the same increased size limit to these routes:

  • "/get_utxos_mined_info",
  • "/get_utxos_deleted_info"
  • "/sync_utxos_by_block"
  • "/get_utxos_by_block"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I dont think thats needed, and thats set on the client, not server

@github-actions
Copy link
Copy Markdown

Test Results (Integration tests)

1 tests   1 ✅  0s ⏱️
1 suites  0 💤
2 files    0 ❌
1 errors

For more details on these parsing errors, see this check.

Results for commit a6a822a.

@SWvheerden
Copy link
Copy Markdown
Collaborator Author

So this only applies to the post of the transaction to the base node, higher is not needed, this needs to fit into a block still

@SWvheerden SWvheerden merged commit 433942a into tari-project:development Jul 14, 2025
15 of 16 checks passed
@SWvheerden SWvheerden deleted the sw_feat_size_limit branch July 14, 2025 16:52
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