Skip to content

Commit

Permalink
geyser: add gRPC server options to config (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Dec 13, 2024
1 parent ad5dd94 commit 1b98d7c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
5 changes: 5 additions & 0 deletions yellowstone-grpc-geyser/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions yellowstone-grpc-geyser/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>,
#[serde(with = "humantime_serde")]
pub server_http2_keepalive_interval: Option<Duration>,
#[serde(with = "humantime_serde")]
pub server_http2_keepalive_timeout: Option<Duration>,
#[serde(default)]
pub server_initial_connection_window_size: Option<u32>,
#[serde(default)]
pub server_initial_stream_window_size: Option<u32>,
}

impl ConfigGrpc {
Expand Down
17 changes: 16 additions & 1 deletion yellowstone-grpc-geyser/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -456,7 +472,6 @@ impl GrpcService {
health_reporter.set_serving::<GeyserServer<Self>>().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") {
Expand Down

0 comments on commit 1b98d7c

Please sign in to comment.