From c350a6c6a98fb30f04046ee1d2666e2eae68d7dc Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Mon, 15 Jul 2024 18:34:26 +0300 Subject: [PATCH 1/2] fix(rpc): Increase max response size --- rpc/src/client.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rpc/src/client.rs b/rpc/src/client.rs index c120e9ef..eaf12a27 100644 --- a/rpc/src/client.rs +++ b/rpc/src/client.rs @@ -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; @@ -27,6 +29,13 @@ mod native { use crate::Error; + const MAX_SHARES_SIZE_IN_EDS: 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_SHARES_SIZE_IN_EDS + 1024 * 1024; + /// Json RPC client. pub enum Client { /// A client using 'http\[s\]' protocol. @@ -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?, From 7c5fe9a3ec3b6aeca8dd65d2c5979d116e4c54af Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Mon, 15 Jul 2024 22:15:55 +0300 Subject: [PATCH 2/2] rename constant --- rpc/src/client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/src/client.rs b/rpc/src/client.rs index eaf12a27..6132270f 100644 --- a/rpc/src/client.rs +++ b/rpc/src/client.rs @@ -29,12 +29,12 @@ mod native { use crate::Error; - const MAX_SHARES_SIZE_IN_EDS: usize = + 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_SHARES_SIZE_IN_EDS + 1024 * 1024; + const MAX_RESPONSE_SIZE: usize = MAX_EDS_SIZE_BYTES + 1024 * 1024; /// Json RPC client. pub enum Client {