Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
added arg --rpc-max-request-payload-size to validator (#26377)
Browse files Browse the repository at this point in the history
* added ability to pass --rpc-max-request-payload-size to validator

* fixed lint errors

* more lint fix

* patch

Co-authored-by: ultd <ultd>
Co-authored-by: Justin Starry <justin@solana.com>
  • Loading branch information
ultd and jstarry authored Aug 8, 2022
1 parent d9f0bdf commit ad0acaa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ use {

type RpcCustomResult<T> = std::result::Result<T, RpcCustomError>;

pub const MAX_REQUEST_PAYLOAD_SIZE: usize = 50 * (1 << 10); // 50kB
pub const MAX_REQUEST_BODY_SIZE: usize = 50 * (1 << 10); // 50kB
pub const PERFORMANCE_SAMPLES_LIMIT: usize = 720;

// Limit the length of the `epoch_credits` array for each validator in a `get_vote_accounts`
Expand Down Expand Up @@ -160,6 +160,7 @@ pub struct JsonRpcConfig {
pub full_api: bool,
pub obsolete_v1_7_api: bool,
pub rpc_scan_and_fix_roots: bool,
pub max_request_body_size: Option<usize>,
}

impl JsonRpcConfig {
Expand Down
5 changes: 4 additions & 1 deletion rpc/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ impl JsonRpcService {

let full_api = config.full_api;
let obsolete_v1_7_api = config.obsolete_v1_7_api;
let max_request_body_size = config
.max_request_body_size
.unwrap_or(MAX_REQUEST_BODY_SIZE);
let (request_processor, receiver) = JsonRpcRequestProcessor::new(
config,
snapshot_config.clone(),
Expand Down Expand Up @@ -515,7 +518,7 @@ impl JsonRpcService {
]))
.cors_max_age(86400)
.request_middleware(request_middleware)
.max_request_body_size(MAX_REQUEST_PAYLOAD_SIZE)
.max_request_body_size(max_request_body_size)
.start_http(&rpc_addr);

if let Err(e) = server {
Expand Down
17 changes: 16 additions & 1 deletion validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use {
solana_perf::recycler::enable_recycler_warming,
solana_poh::poh_service,
solana_rpc::{
rpc::{JsonRpcConfig, RpcBigtableConfig},
rpc::{JsonRpcConfig, RpcBigtableConfig, MAX_REQUEST_BODY_SIZE},
rpc_pubsub_service::PubSubConfig,
},
solana_runtime::{
Expand Down Expand Up @@ -469,6 +469,7 @@ pub fn main() {
let default_rocksdb_fifo_shred_storage_size =
&DEFAULT_ROCKS_FIFO_SHRED_STORAGE_SIZE_BYTES.to_string();
let default_tpu_connection_pool_size = &DEFAULT_TPU_CONNECTION_POOL_SIZE.to_string();
let default_rpc_max_request_body_size = &MAX_REQUEST_BODY_SIZE.to_string();

let matches = App::new(crate_name!()).about(crate_description!())
.version(solana_version::version!())
Expand Down Expand Up @@ -1467,6 +1468,15 @@ pub fn main() {
.requires("enable_rpc_transaction_history")
.help("Verifies blockstore roots on boot and fixes any gaps"),
)
.arg(
Arg::with_name("rpc_max_request_body_size")
.long("rpc-max-request-body-size")
.value_name("BYTES")
.takes_value(true)
.validator(is_parsable::<usize>)
.default_value(default_rpc_max_request_body_size)
.help("The maximum request body size accepted by rpc service"),
)
.arg(
Arg::with_name("enable_accountsdb_repl")
.long("enable-accountsdb-repl")
Expand Down Expand Up @@ -2573,6 +2583,11 @@ pub fn main() {
rpc_niceness_adj: value_t_or_exit!(matches, "rpc_niceness_adj", i8),
account_indexes: account_indexes.clone(),
rpc_scan_and_fix_roots: matches.is_present("rpc_scan_and_fix_roots"),
max_request_body_size: Some(value_t_or_exit!(
matches,
"rpc_max_request_body_size",
usize
)),
},
geyser_plugin_config_files,
rpc_addrs: value_t!(matches, "rpc_port", u16).ok().map(|rpc_port| {
Expand Down

0 comments on commit ad0acaa

Please sign in to comment.