From 1b98d7cf818922ad1dc4dd85aca9a29fe1ffe2f8 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Fri, 13 Dec 2024 16:06:30 -0500 Subject: [PATCH] geyser: add gRPC server options to config (#493) --- CHANGELOG.md | 1 + deny.toml | 4 ++++ yellowstone-grpc-geyser/config.json | 5 +++++ yellowstone-grpc-geyser/src/config.rs | 10 ++++++++++ yellowstone-grpc-geyser/src/grpc.rs | 17 ++++++++++++++++- 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f005815..dee78913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ The minor version will be incremented upon a breaking change and the patch versi - proto: add `from_slot` ([#477](https://github.com/rpcpool/yellowstone-grpc/pull/477)) - proto: add field `created_at` to update message ([#479](https://github.com/rpcpool/yellowstone-grpc/pull/479)) - nodejs: add parse err function ([#483](https://github.com/rpcpool/yellowstone-grpc/pull/483)) +- geyser: add gRPC server options to config ([#493](https://github.com/rpcpool/yellowstone-grpc/pull/493)) ## 2024-12-01 diff --git a/deny.toml b/deny.toml index 0ec726b7..bbee2ee6 100644 --- a/deny.toml +++ b/deny.toml @@ -22,4 +22,8 @@ ignore = [ # derivative 2.2.0 # Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0388 "RUSTSEC-2024-0388", + + # curve25519-dalek 3.2.1 + # Advisory: https://rustsec.org/advisories/RUSTSEC-2024-0344 + "RUSTSEC-2024-0344", ] diff --git a/yellowstone-grpc-geyser/config.json b/yellowstone-grpc-geyser/config.json index 7c7373c2..71cfa6fc 100644 --- a/yellowstone-grpc-geyser/config.json +++ b/yellowstone-grpc-geyser/config.json @@ -17,6 +17,11 @@ "accept": ["gzip", "zstd"], "send": ["gzip", "zstd"] }, + "server_http2_adaptive_window": null, + "server_http2_keepalive_interval": null, + "server_http2_keepalive_timeout": null, + "server_initial_connection_window_size": null, + "server_initial_stream_window_size": null, "max_decoding_message_size": "4_194_304", "snapshot_plugin_channel_capacity": null, "snapshot_client_channel_capacity": "50_000_000", diff --git a/yellowstone-grpc-geyser/src/config.rs b/yellowstone-grpc-geyser/src/config.rs index 0c42f7e3..c2faf724 100644 --- a/yellowstone-grpc-geyser/src/config.rs +++ b/yellowstone-grpc-geyser/src/config.rs @@ -192,6 +192,16 @@ pub struct ConfigGrpc { /// Number of slots stored for re-broadcast (replay) #[serde(default = "ConfigGrpc::default_replay_stored_slots")] pub replay_stored_slots: u64, + #[serde(default)] + pub server_http2_adaptive_window: Option, + #[serde(with = "humantime_serde")] + pub server_http2_keepalive_interval: Option, + #[serde(with = "humantime_serde")] + pub server_http2_keepalive_timeout: Option, + #[serde(default)] + pub server_initial_connection_window_size: Option, + #[serde(default)] + pub server_initial_stream_window_size: Option, } impl ConfigGrpc { diff --git a/yellowstone-grpc-geyser/src/grpc.rs b/yellowstone-grpc-geyser/src/grpc.rs index e8e8938d..fde7d139 100644 --- a/yellowstone-grpc-geyser/src/grpc.rs +++ b/yellowstone-grpc-geyser/src/grpc.rs @@ -392,6 +392,22 @@ impl GrpcService { .tls_config(ServerTlsConfig::new().identity(Identity::from_pem(cert, key))) .context("failed to apply tls_config")?; } + if let Some(enabled) = config.server_http2_adaptive_window { + server_builder = server_builder.http2_adaptive_window(Some(enabled)); + } + if let Some(http2_keepalive_interval) = config.server_http2_keepalive_interval { + server_builder = + server_builder.http2_keepalive_interval(Some(http2_keepalive_interval)); + } + if let Some(http2_keepalive_timeout) = config.server_http2_keepalive_timeout { + server_builder = server_builder.http2_keepalive_timeout(Some(http2_keepalive_timeout)); + } + if let Some(sz) = config.server_initial_connection_window_size { + server_builder = server_builder.initial_connection_window_size(sz); + } + if let Some(sz) = config.server_initial_stream_window_size { + server_builder = server_builder.initial_stream_window_size(sz); + } let filter_names = Arc::new(Mutex::new(FilterNames::new( config.filter_name_size_limit, @@ -456,7 +472,6 @@ impl GrpcService { health_reporter.set_serving::>().await; server_builder - .http2_keepalive_interval(Some(Duration::from_secs(5))) .layer(interceptor(move |request: Request<()>| { if let Some(x_token) = &config.x_token { match request.metadata().get("x-token") {