added arg --rpc-max-request-payload-size to validator (#26377)

* 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>
This commit is contained in:
Ahmad 2022-08-08 07:50:05 -05:00 committed by GitHub
parent d9f0bdf392
commit ad0acaa6fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -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`
@ -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 {

View File

@ -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(),
@ -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 {

View File

@ -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::{
@ -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!())
@ -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")
@ -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| {