Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): Increase max response size #336

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ mod native {
use std::result::Result;

use async_trait::async_trait;
use celestia_types::consts::appconsts::SHARE_SIZE;
use celestia_types::consts::data_availability_header::MAX_EXTENDED_SQUARE_WIDTH;
use http::{header, HeaderValue};
use jsonrpsee::core::client::{BatchResponse, ClientT, Subscription, SubscriptionClientT};
use jsonrpsee::core::params::BatchRequestBuilder;
Expand All @@ -27,6 +29,13 @@ mod native {

use crate::Error;

const MAX_EDS_SIZE_BYTES: usize =
MAX_EXTENDED_SQUARE_WIDTH * MAX_EXTENDED_SQUARE_WIDTH * SHARE_SIZE;

// The biggest response we might get is for requesting an EDS.
// Also, we allow 1 MB extra for any metadata they come with it.
const MAX_RESPONSE_SIZE: usize = MAX_EDS_SIZE_BYTES + 1024 * 1024;

/// Json RPC client.
pub enum Client {
/// A client using 'http\[s\]' protocol.
Expand Down Expand Up @@ -56,11 +65,13 @@ mod native {
let client = match protocol {
Some("http") | Some("https") => Client::Http(
HttpClientBuilder::default()
.max_response_size(MAX_RESPONSE_SIZE as u32)
.set_headers(headers)
.build(conn_str)?,
),
Some("ws") | Some("wss") => Client::Ws(
WsClientBuilder::default()
.max_response_size(MAX_RESPONSE_SIZE as u32)
.set_headers(headers)
.build(conn_str)
.await?,
Expand Down
Loading