Skip to content

Commit

Permalink
geyser: limit length of filter name (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Nov 2, 2024
1 parent 5ac20df commit 17faff5
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 91 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- geyser: use Arc wrapped messages in block message ([#446](https://github.com/rpcpool/yellowstone-grpc/pull/446))
- node: remove generated grpc files ([#447](https://github.com/rpcpool/yellowstone-grpc/pull/447))
- proto: add txn_signature filter ([#445](https://github.com/rpcpool/yellowstone-grpc/pull/445))
- geyser: limit length of filter name ([#448](https://github.com/rpcpool/yellowstone-grpc/pull/448))

### Breaking

Expand Down
16 changes: 14 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ hex = "0.4.3"
hostname = "0.4.0"
http = "1.1.0"
http-body-util = "0.1.2"
humantime-serde = "1.1.1"
hyper = "1.4.1"
hyper-util = "0.1.7"
lazy_static = "1.4.0"
Expand Down
2 changes: 2 additions & 0 deletions yellowstone-grpc-geyser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ futures = { workspace = true }
hostname = { workspace = true }
http = { workspace = true }
http-body-util = { workspace = true }
humantime-serde = { workspace = true }
hyper = { workspace = true }
hyper-util = { workspace = true }
lazy_static = { workspace = true }
Expand All @@ -39,6 +40,7 @@ solana-logger = { workspace = true }
solana-sdk = { workspace = true }
solana-transaction-status = { workspace = true }
spl-token-2022 = { workspace = true, features = ["no-entrypoint"] }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "fs"] }
tokio-stream = { workspace = true }
tonic = { workspace = true, features = ["gzip", "zstd", "tls", "tls-roots"] }
Expand Down
3 changes: 3 additions & 0 deletions yellowstone-grpc-geyser/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"unary_concurrency_limit": 100,
"unary_disabled": false,
"x_token": null,
"filter_name_size_limit": 32,
"filter_names_size_limit": 1024,
"filter_names_cleanup_interval": "1s",
"filters": {
"accounts": {
"max": 1,
Expand Down
26 changes: 25 additions & 1 deletion yellowstone-grpc-geyser/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
},
serde::{de, Deserialize, Deserializer},
solana_sdk::pubkey::Pubkey,
std::{collections::HashSet, fs::read_to_string, net::SocketAddr, path::Path},
std::{collections::HashSet, fs::read_to_string, net::SocketAddr, path::Path, time::Duration},
tokio::sync::Semaphore,
tonic::codec::CompressionEncoding,
};
Expand Down Expand Up @@ -110,6 +110,18 @@ pub struct ConfigGrpc {
pub filters: ConfigGrpcFilters,
/// x_token to enforce on connections
pub x_token: Option<String>,
/// Filter name size limit
#[serde(default = "ConfigGrpc::default_filter_name_size_limit")]
pub filter_name_size_limit: usize,
/// Number of cached filter names before doing cleanup
#[serde(default = "ConfigGrpc::default_filter_names_size_limit")]
pub filter_names_size_limit: usize,
/// Cleanup interval once filter names reached `filter_names_size_limit`
#[serde(
default = "ConfigGrpc::default_filter_names_cleanup_interval",
with = "humantime_serde"
)]
pub filter_names_cleanup_interval: Duration,
}

impl ConfigGrpc {
Expand All @@ -132,6 +144,18 @@ impl ConfigGrpc {
const fn unary_concurrency_limit_default() -> usize {
Semaphore::MAX_PERMITS
}

const fn default_filter_name_size_limit() -> usize {
32
}

const fn default_filter_names_size_limit() -> usize {
1_024
}

const fn default_filter_names_cleanup_interval() -> Duration {
Duration::from_secs(1)
}
}

#[derive(Debug, Clone, Deserialize)]
Expand Down
Loading

0 comments on commit 17faff5

Please sign in to comment.