diff --git a/client/src/rpc_request.rs b/client/src/rpc_request.rs index 61de0ff504..68bb3123c8 100644 --- a/client/src/rpc_request.rs +++ b/client/src/rpc_request.rs @@ -127,6 +127,7 @@ pub const MAX_GET_CONFIRMED_BLOCKS_RANGE: u64 = 500_000; pub const MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT: usize = 1_000; pub const MAX_MULTIPLE_ACCOUNTS: usize = 100; pub const NUM_LARGEST_ACCOUNTS: usize = 20; +pub const MAX_GET_PROGRAM_ACCOUNT_FILTERS: usize = 4; // Validators that are this number of slots behind are considered delinquent pub const DELINQUENT_VALIDATOR_SLOT_DISTANCE: u64 = 128; diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 47f3f78f17..684ad6b8b2 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -28,7 +28,7 @@ use solana_client::{ rpc_request::{ TokenAccountsFilter, DELINQUENT_VALIDATOR_SLOT_DISTANCE, MAX_GET_CONFIRMED_BLOCKS_RANGE, MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT, - MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE, + MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE, MAX_GET_PROGRAM_ACCOUNT_FILTERS, MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, MAX_MULTIPLE_ACCOUNTS, NUM_LARGEST_ACCOUNTS, }, rpc_response::Response as RpcResponse, @@ -2223,6 +2223,12 @@ impl RpcSol for RpcSolImpl { } else { (None, vec![]) }; + if filters.len() > MAX_GET_PROGRAM_ACCOUNT_FILTERS { + return Err(Error::invalid_params(format!( + "Too many filters provided; max {}", + MAX_GET_PROGRAM_ACCOUNT_FILTERS + ))); + } for filter in &filters { verify_filter(filter)?; } diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index 1fe1744816..e82d36893f 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -1649,7 +1649,7 @@ Returns the account information for a list of Pubkeys - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd", or "jsonParsed". - "base58" is limited to Account data of less than 128 bytes. + "base58" is limited to Account data of less than 129 bytes. "base64" will return base64 encoded data for Account data of any size. "base64+zstd" compresses the Account data using [Zstandard](https://facebook.github.io/zstd/) and base64-encodes the result. "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to "base64" encoding, detectable when the `data` field is type ``. @@ -1796,7 +1796,7 @@ Returns all accounts owned by the provided program Pubkey - `` - (optional) Configuration object containing the following optional fields: - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment) - `encoding: ` - encoding for Account data, either "base58" (*slow*), "base64", "base64+zstd", or "jsonParsed". - "base58" is limited to Account data of less than 128 bytes. + "base58" is limited to Account data of less than 129 bytes. "base64" will return base64 encoded data for Account data of any size. "base64+zstd" compresses the Account data using [Zstandard](https://facebook.github.io/zstd/) and base64-encodes the result. "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to "base64" encoding, detectable when the `data` field is type ``.