From 6e9dbb4f6e35d93d15148776e974d9b298a5bf05 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 7 Dec 2020 09:22:35 -0800 Subject: [PATCH] Add --rpc-max-multiple-accounts to override the getMultipleAccounts JSON RPC maximum --- core/src/rpc.rs | 10 ++++++++-- validator/src/main.rs | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/src/rpc.rs b/core/src/rpc.rs index d4ee71d309..f46e4ff08d 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -108,6 +108,7 @@ pub struct JsonRpcConfig { pub health_check_slot_distance: u64, pub enable_bigtable_ledger_storage: bool, pub enable_bigtable_ledger_upload: bool, + pub max_multiple_accounts: Option, } #[derive(Clone)] @@ -1923,10 +1924,15 @@ impl RpcSol for RpcSolImpl { "get_multiple_accounts rpc request received: {:?}", pubkey_strs.len() ); - if pubkey_strs.len() > MAX_MULTIPLE_ACCOUNTS { + + let max_multiple_accounts = meta + .config + .max_multiple_accounts + .unwrap_or(MAX_MULTIPLE_ACCOUNTS); + if pubkey_strs.len() > max_multiple_accounts { return Err(Error::invalid_params(format!( "Too many inputs provided; max {}", - MAX_MULTIPLE_ACCOUNTS + max_multiple_accounts ))); } let mut pubkeys: Vec = vec![]; diff --git a/validator/src/main.rs b/validator/src/main.rs index de4b9136a6..bb733b5dea 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -11,7 +11,7 @@ use solana_clap_utils::{ }, keypair::SKIP_SEED_PHRASE_VALIDATION_ARG, }; -use solana_client::rpc_client::RpcClient; +use solana_client::{rpc_client::RpcClient, rpc_request::MAX_MULTIPLE_ACCOUNTS}; use solana_core::ledger_cleanup_service::{ DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS, }; @@ -862,6 +862,7 @@ pub fn main() { let default_dynamic_port_range = &format!("{}-{}", VALIDATOR_PORT_RANGE.0, VALIDATOR_PORT_RANGE.1); let default_genesis_archive_unpacked_size = &MAX_GENESIS_ARCHIVE_UNPACKED_SIZE.to_string(); + let default_rpc_max_multiple_accounts = &MAX_MULTIPLE_ACCOUNTS.to_string(); let default_rpc_pubsub_max_connections = PubSubConfig::default().max_connections.to_string(); let default_rpc_pubsub_max_fragment_size = PubSubConfig::default().max_fragment_size.to_string(); @@ -1039,6 +1040,15 @@ pub fn main() { .takes_value(false) .help("Upload new confirmed blocks into a BigTable instance"), ) + .arg( + Arg::with_name("rpc_max_multiple_accounts") + .long("rpc-max-multiple-accounts") + .value_name("MAX ACCOUNTS") + .takes_value(true) + .default_value(default_rpc_max_multiple_accounts) + .help("Override the default maximum accounts accepted by \ + the getMultipleAccounts JSON RPC method") + ) .arg( Arg::with_name("health_check_slot_distance") .long("health-check-slot-distance") @@ -1507,6 +1517,11 @@ pub fn main() { faucet_addr: matches.value_of("rpc_faucet_addr").map(|address| { solana_net_utils::parse_host_port(address).expect("failed to parse faucet address") }), + max_multiple_accounts: Some(value_t_or_exit!( + matches, + "rpc_max_multiple_accounts", + usize + )), health_check_slot_distance: value_t_or_exit!( matches, "health_check_slot_distance",