Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions crates/rproxy/src/server/proxy/config/authrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,28 @@ pub(crate) struct ConfigAuthrpc {
)]
pub(crate) log_sanitise: bool,

/// max size of authrpc requests
#[arg(
default_value = "16",
env = "RPROXY_AUTHRPC_MAX_REQUEST_SIZE_MB",
help_heading = "authrpc",
long("authrpc-max-request-size-mb"),
name("authrpc_max_request_size_mb"),
value_name = "megabytes"
)]
pub(crate) max_request_size_mb: usize,

/// max size of authrpc responses
#[arg(
default_value = "256",
env = "RPROXY_AUTHRPC_MAX_RESPONSE_SIZE_MB",
help_heading = "authrpc",
long("authrpc-max-response-size-mb"),
name("authrpc_max_response_size_mb"),
value_name = "megabytes"
)]
pub(crate) max_response_size_mb: usize,

/// list of authrpc peers urls to mirror the requests to
#[arg(
env="RPROXY_AUTHRPC_MIRRORING_PEERS",
Expand All @@ -153,6 +175,28 @@ pub(crate) struct ConfigAuthrpc {
#[clap(value_enum)]
pub(crate) mirroring_strategy: ConfigProxyHttpMirroringStrategy,

/// size of preallocated authrpc request buffers
#[arg(
default_value = "1",
env = "RPROXY_AUTHRPC_PREALLOCATED_RESPONSE_BUFFER_SIZE_KB",
help_heading = "authrpc",
long("authrpc-preallocated-request-buffer-size-kb"),
name("authrpc_preallocated_request_buffer_size_kb"),
value_name = "kilobytes"
)]
pub(crate) prealloacated_request_buffer_size_kb: usize,

/// size of preallocated authrpc response buffers
#[arg(
default_value = "1",
env = "RPROXY_AUTHRPC_PREALLOCATED_RESPONSE_BUFFER_SIZE_KB",
help_heading = "authrpc",
long("authrpc-preallocated-response-buffer-size-kb"),
name("authrpc_preallocated_response_buffer_size_kb"),
value_name = "kilobytes"
)]
pub(crate) prealloacated_response_buffer_size_kb: usize,

/// remove authrpc backend from mirroring peers
#[arg(
env = "RPROXY_AUTHRPC_REMOVE_BACKEND_FROM_MIRRORING_PEERS",
Expand Down Expand Up @@ -329,6 +373,16 @@ impl ConfigProxyHttp for ConfigAuthrpc {
self.log_sanitise
}

#[inline]
fn max_request_size(&self) -> usize {
1024 * 1024 * self.max_request_size_mb
}

#[inline]
fn max_response_size(&self) -> usize {
1024 * 1024 * self.max_response_size_mb
}

#[inline]
fn mirroring_peer_urls(&self) -> Vec<Url> {
self.mirroring_peer_urls
Expand All @@ -341,6 +395,16 @@ impl ConfigProxyHttp for ConfigAuthrpc {
fn mirroring_strategy(&self) -> &ConfigProxyHttpMirroringStrategy {
&self.mirroring_strategy
}

#[inline]
fn prealloacated_request_buffer_size(&self) -> usize {
1024 * self.prealloacated_request_buffer_size_kb
}

#[inline]
fn prealloacated_response_buffer_size(&self) -> usize {
1024 * self.prealloacated_response_buffer_size_kb
}
}

// ConfigAuthrpcError --------------------------------------------------
Expand Down
8 changes: 0 additions & 8 deletions crates/rproxy/src/server/proxy/config/flashblocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ pub(crate) struct ConfigFlashblocks {
)]
pub(crate) log_backend_messages: bool,

/// whether to log flashblocks backend messages
#[arg(
env = "RPROXY_FLASHBLOCKS_LOG_BACKEND_MESSAGES",
help_heading = "flashblocks",
long("flashblocks-log-backend-messages"),
name("flashblocks_log_backend_messages")
)]

/// whether to log flashblocks client messages
#[arg(
env = "RPROXY_FLASHBLOCKS_LOG_CLIENT_MESSAGES",
Expand Down
64 changes: 64 additions & 0 deletions crates/rproxy/src/server/proxy/config/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,28 @@ pub(crate) struct ConfigRpc {
)]
pub(crate) log_sanitise: bool,

/// max size of rpc requests
#[arg(
default_value = "16",
env = "RPROXY_RPC_MAX_REQUEST_SIZE_MB",
help_heading = "rpc",
long("rpc-max-request-size-mb"),
name("rpc_max_request_size_mb"),
value_name = "megabytes"
)]
pub(crate) max_request_size_mb: usize,

/// max size of rpc responses
#[arg(
default_value = "256",
env = "RPROXY_RPC_MAX_RESPONSE_SIZE_MB",
help_heading = "rpc",
long("rpc-max-response-size-mb"),
name("rpc_max_response_size_mb"),
value_name = "megabytes"
)]
pub(crate) max_response_size_mb: usize,

/// whether the requests that returned an error from rpc backend should
/// be mirrored to peers
#[arg(
Expand Down Expand Up @@ -162,6 +184,28 @@ pub(crate) struct ConfigRpc {
#[clap(value_enum)]
pub(crate) mirroring_strategy: ConfigProxyHttpMirroringStrategy,

/// size of preallocated rpc request buffers
#[arg(
default_value = "1",
env = "RPROXY_RPC_PREALLOCATED_RESPONSE_BUFFER_SIZE_KB",
help_heading = "rpc",
long("rpc-preallocated-request-buffer-size-kb"),
name("rpc_preallocated_request_buffer_size_kb"),
value_name = "kilobytes"
)]
pub(crate) prealloacated_request_buffer_size_kb: usize,

/// size of preallocated rpc response buffers
#[arg(
default_value = "256",
env = "RPROXY_RPC_PREALLOCATED_RESPONSE_BUFFER_SIZE_KB",
help_heading = "rpc",
long("rpc-preallocated-response-buffer-size-kb"),
name("rpc_preallocated_response_buffer_size_kb"),
value_name = "kilobytes"
)]
pub(crate) prealloacated_response_buffer_size_kb: usize,

/// remove rpc backend from peers
#[arg(
env = "RPROXY_RPC_REMOVE_BACKEND_FROM_MIRRORING_PEERS",
Expand Down Expand Up @@ -335,6 +379,16 @@ impl ConfigProxyHttp for ConfigRpc {
self.log_sanitise
}

#[inline]
fn max_request_size(&self) -> usize {
1024 * 1024 * self.max_request_size_mb
}

#[inline]
fn max_response_size(&self) -> usize {
1024 * 1024 * self.max_response_size_mb
}

#[inline]
fn mirroring_peer_urls(&self) -> Vec<Url> {
self.mirroring_peer_urls
Expand All @@ -347,6 +401,16 @@ impl ConfigProxyHttp for ConfigRpc {
fn mirroring_strategy(&self) -> &ConfigProxyHttpMirroringStrategy {
&self.mirroring_strategy
}

#[inline]
fn prealloacated_request_buffer_size(&self) -> usize {
1024 * self.prealloacated_request_buffer_size_kb
}

#[inline]
fn prealloacated_response_buffer_size(&self) -> usize {
1024 * self.prealloacated_response_buffer_size_kb
}
}

// ConfigRpcError ------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions crates/rproxy/src/server/proxy/http/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ pub(crate) trait ConfigProxyHttp: Clone + Send + Unpin + 'static {
fn log_proxied_requests(&self) -> bool;
fn log_proxied_responses(&self) -> bool;
fn log_sanitise(&self) -> bool;
fn max_request_size(&self) -> usize;
fn max_response_size(&self) -> usize;
fn mirroring_peer_urls(&self) -> Vec<Url>;
fn mirroring_strategy(&self) -> &ConfigProxyHttpMirroringStrategy;
fn prealloacated_request_buffer_size(&self) -> usize;
fn prealloacated_response_buffer_size(&self) -> usize;
}

// ConfigProxyHttpMirroringStrategy ------------------------------------
Expand Down
Loading