Add --rpc-max-multiple-accounts to override the getMultipleAccounts JSON RPC maximum

This commit is contained in:
Michael Vines 2020-12-07 09:22:35 -08:00
parent 1dc71fb5aa
commit 6e9dbb4f6e
2 changed files with 24 additions and 3 deletions

View File

@ -108,6 +108,7 @@ pub struct JsonRpcConfig {
pub health_check_slot_distance: u64, pub health_check_slot_distance: u64,
pub enable_bigtable_ledger_storage: bool, pub enable_bigtable_ledger_storage: bool,
pub enable_bigtable_ledger_upload: bool, pub enable_bigtable_ledger_upload: bool,
pub max_multiple_accounts: Option<usize>,
} }
#[derive(Clone)] #[derive(Clone)]
@ -1923,10 +1924,15 @@ impl RpcSol for RpcSolImpl {
"get_multiple_accounts rpc request received: {:?}", "get_multiple_accounts rpc request received: {:?}",
pubkey_strs.len() 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!( return Err(Error::invalid_params(format!(
"Too many inputs provided; max {}", "Too many inputs provided; max {}",
MAX_MULTIPLE_ACCOUNTS max_multiple_accounts
))); )));
} }
let mut pubkeys: Vec<Pubkey> = vec![]; let mut pubkeys: Vec<Pubkey> = vec![];

View File

@ -11,7 +11,7 @@ use solana_clap_utils::{
}, },
keypair::SKIP_SEED_PHRASE_VALIDATION_ARG, 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::{ use solana_core::ledger_cleanup_service::{
DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS, DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS,
}; };
@ -862,6 +862,7 @@ pub fn main() {
let default_dynamic_port_range = let default_dynamic_port_range =
&format!("{}-{}", VALIDATOR_PORT_RANGE.0, VALIDATOR_PORT_RANGE.1); &format!("{}-{}", VALIDATOR_PORT_RANGE.0, VALIDATOR_PORT_RANGE.1);
let default_genesis_archive_unpacked_size = &MAX_GENESIS_ARCHIVE_UNPACKED_SIZE.to_string(); 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_connections = PubSubConfig::default().max_connections.to_string();
let default_rpc_pubsub_max_fragment_size = let default_rpc_pubsub_max_fragment_size =
PubSubConfig::default().max_fragment_size.to_string(); PubSubConfig::default().max_fragment_size.to_string();
@ -1039,6 +1040,15 @@ pub fn main() {
.takes_value(false) .takes_value(false)
.help("Upload new confirmed blocks into a BigTable instance"), .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(
Arg::with_name("health_check_slot_distance") Arg::with_name("health_check_slot_distance")
.long("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| { faucet_addr: matches.value_of("rpc_faucet_addr").map(|address| {
solana_net_utils::parse_host_port(address).expect("failed to parse faucet 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!( health_check_slot_distance: value_t_or_exit!(
matches, matches,
"health_check_slot_distance", "health_check_slot_distance",