Overview
Filter limits allow you to control and restrict what clients can subscribe to via the gRPC interface. This is essential for protecting your validator from resource exhaustion and preventing abuse by limiting the scope of subscriptions.Configuration Structure
Filter limits are configured undergrpc.filter_limits in your configuration file. Each subscription type (accounts, transactions, slots, etc.) has its own set of limits.
Account Filter Limits
Maximum number of account filters allowed per subscription request.When set to
1, clients can only have one account filter active at a time. This is useful for enforcing strict resource limits.Allow subscribing to all accounts without any filters.When set to
false, clients must specify at least one filter criterion (account pubkey, owner, or data filter). This prevents subscriptions to the entire account state.Maximum number of account pubkeys that can be specified in a single filter’s
account array.Example: With account_max: 10, a client can filter up to 10 specific account addresses.Array of account pubkeys that are explicitly forbidden in filters.Useful for blocking subscriptions to high-traffic accounts like the Token Program:
Maximum number of owner pubkeys that can be specified in a single filter’s
owner array.Example: With owner_max: 10, a client can filter accounts by up to 10 different program owners.Array of owner pubkeys that are explicitly forbidden in filters.Useful for blocking subscriptions to all accounts owned by system programs:This prevents clients from subscribing to all System Program accounts.
Maximum number of data slices that can be requested in the
accounts_data_slice array.Data slices allow clients to receive only specific portions of account data, reducing bandwidth usage.Slot Filter Limits
Maximum number of slot filters allowed per subscription request.Slots are generally low-overhead, so this is often set to
1 to allow slot subscriptions while keeping them simple.Transaction Filter Limits
Maximum number of transaction filters allowed per subscription request.
Allow subscribing to all transactions without any filters.When set to
false, clients must specify at least one filter criterion. Highly recommended for production.Maximum number of accounts in the
account_include filter array.The account_include filter matches transactions that use any account from the list (logical OR).Array of account pubkeys forbidden in
account_include filters.Prevents subscriptions to transactions involving specific high-traffic accounts:Maximum number of accounts in the
account_exclude filter array.The account_exclude filter matches transactions that do not use any account from the list.Maximum number of accounts in the
account_required filter array.The account_required filter matches transactions that use all accounts from the list (logical AND).Transaction Status Filter Limits
Transaction status filters use the same structure as transaction filters:Block Filter Limits
Maximum number of block filters allowed per subscription request.
Maximum number of accounts in the
account_include filter array for blocks.This filters both transactions and account updates within blocks that involve any of the specified accounts.Allow subscribing to all blocks without account filtering.When set to
false, clients must specify at least one account in the account_include filter.Array of account pubkeys forbidden in block
account_include filters.Control whether clients can request transaction data in block subscriptions.Setting to
false forces clients to receive blocks without transaction details, reducing data volume.Control whether clients can request account update data in block subscriptions.Setting to
false prevents clients from receiving account updates within blocks.Control whether clients can request entry data in block subscriptions.Setting to
false prevents clients from receiving entries within blocks.Block Meta Filter Limits
Maximum number of block metadata filters allowed per subscription request.Block meta subscriptions provide block information without transactions, accounts, or entries.
Entry Filter Limits
Maximum number of entry filters allowed per subscription request.Entries are typically low-overhead, so this is often set to
1:Complete Example
Here’s a production-ready filter limits configuration:Best Practices
Protection Against Abuse
- Always set
any: falsefor accounts, transactions, and blocks to prevent clients from subscribing to all data - Use reject lists to block high-traffic accounts like the Token Program (
TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA) - Set reasonable max values (typically 1-10) to prevent filter explosion
Resource Management
Testing Configuration
- Start with very restrictive limits
- Monitor metrics on the Prometheus endpoint
- Gradually adjust limits based on actual usage patterns
- Use the
debug_clients_httpendpoint to inspect active subscriptions
When Limits Are Exceeded
When a client attempts to create a subscription that exceeds configured limits, they will receive an error response:Max amount of filters/data_slices reached, only {max} allowedSubscribe on full stream with 'any' is not allowed, at least one filter requiredMax amount of Pubkeys reached, only {max} allowedPubkey {pubkey} in filters is not allowed
Related
- Configuration Schema - Complete configuration reference
- Subscribe Method - Learn about subscription filters