mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-18 22:49:34 +00:00
Add flag to enable/disable BP in HTTP API
This commit is contained in:
@@ -126,6 +126,7 @@ pub struct Config {
|
||||
pub allow_sync_stalled: bool,
|
||||
pub spec_fork_name: Option<ForkName>,
|
||||
pub data_dir: PathBuf,
|
||||
pub enable_beacon_processor: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -139,6 +140,7 @@ impl Default for Config {
|
||||
allow_sync_stalled: false,
|
||||
spec_fork_name: None,
|
||||
data_dir: PathBuf::from(DEFAULT_ROOT_DIR),
|
||||
enable_beacon_processor: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,7 +490,10 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let app_start_filter = warp::any().map(move || app_start);
|
||||
|
||||
// Create a `warp` filter that provides access the `TaskSpawner`.
|
||||
let beacon_processor_send = ctx.beacon_processor_send.clone();
|
||||
let beacon_processor_send = ctx
|
||||
.beacon_processor_send
|
||||
.clone()
|
||||
.filter(|_| config.enable_beacon_processor);
|
||||
let task_spawner_filter =
|
||||
warp::any().map(move || TaskSpawner::new(beacon_processor_send.clone()));
|
||||
|
||||
|
||||
@@ -220,6 +220,7 @@ pub async fn create_api_server_on_port<T: BeaconChainTypes>(
|
||||
allow_sync_stalled: false,
|
||||
data_dir: std::path::PathBuf::from(DEFAULT_ROOT_DIR),
|
||||
spec_fork_name: None,
|
||||
enable_beacon_processor: true,
|
||||
},
|
||||
chain: Some(chain),
|
||||
network_senders: Some(network_senders),
|
||||
|
||||
@@ -382,6 +382,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
stalled. This is useful for very small testnets. TESTING ONLY. DO NOT USE ON \
|
||||
MAINNET.")
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("http-enable-beacon-processor")
|
||||
.long("http-enable-beacon-processor")
|
||||
.help("The beacon processor is a scheduler which provides quality-of-service and \
|
||||
DoS protection. When set to \"true\", HTTP API requests will queued and scheduled \
|
||||
alongside other tasks. When set to \"false\", HTTP API responses will be executed \
|
||||
immediately.")
|
||||
.takes_value(true)
|
||||
.default_value("true")
|
||||
)
|
||||
/* Prometheus metrics HTTP server related arguments */
|
||||
.arg(
|
||||
Arg::with_name("metrics")
|
||||
|
||||
@@ -4,6 +4,7 @@ use beacon_chain::chain_config::{
|
||||
};
|
||||
use clap::ArgMatches;
|
||||
use clap_utils::flags::DISABLE_MALLOC_TUNING_FLAG;
|
||||
use clap_utils::parse_required;
|
||||
use client::{ClientConfig, ClientGenesis};
|
||||
use directory::{DEFAULT_BEACON_NODE_DIR, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR};
|
||||
use environment::RuntimeContext;
|
||||
@@ -148,6 +149,9 @@ pub fn get_config<E: EthSpec>(
|
||||
client_config.http_api.allow_sync_stalled = true;
|
||||
}
|
||||
|
||||
client_config.http_api.enable_beacon_processor =
|
||||
parse_required(cli_args, "http-enable-beacon-processor")?;
|
||||
|
||||
if let Some(cache_size) = clap_utils::parse_optional(cli_args, "shuffling-cache-size")? {
|
||||
client_config.chain.shuffling_cache_size = cache_size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user