diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 8cc814a84ab..ea81c1bf9ec 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -281,5 +281,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { ) .value_name("DIR") .takes_value(true) + .requires("slasher") + ) + .arg( + Arg::with_name("slasher-update-period") + .long("slasher-update-period") + .help( + "Configure how often the slasher runs batch processing." + ) + .value_name("SECONDS") + .requires("slasher") + .takes_value(true) ) } diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 5c7925e34c8..581efb99fa6 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -267,7 +267,15 @@ pub fn get_config( } else { client_config.data_dir.join("slasher_db") }; - client_config.slasher = Some(slasher::Config::new(slasher_dir)); + + let mut slasher_config = slasher::Config::new(slasher_dir); + + if let Some(update_period) = clap_utils::parse_optional(cli_args, "slasher-update-period")? + { + slasher_config.update_period = update_period; + } + + client_config.slasher = Some(slasher_config); } Ok(client_config) diff --git a/slasher/src/config.rs b/slasher/src/config.rs index d41c78c60b9..5f59dd46f3b 100644 --- a/slasher/src/config.rs +++ b/slasher/src/config.rs @@ -6,6 +6,7 @@ use types::{Epoch, EthSpec, IndexedAttestation}; pub const DEFAULT_CHUNK_SIZE: usize = 16; pub const DEFAULT_VALIDATOR_CHUNK_SIZE: usize = 256; pub const DEFAULT_HISTORY_LENGTH: usize = 54_000; +pub const DEFAULT_UPDATE_PERIOD: u64 = 12; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Config { @@ -14,6 +15,8 @@ pub struct Config { pub validator_chunk_size: usize, /// Number of epochs of history to keep. pub history_length: usize, + /// Update frequency in seconds. + pub update_period: u64, } impl Config { @@ -23,6 +26,7 @@ impl Config { chunk_size: DEFAULT_CHUNK_SIZE, validator_chunk_size: DEFAULT_VALIDATOR_CHUNK_SIZE, history_length: DEFAULT_HISTORY_LENGTH, + update_period: DEFAULT_UPDATE_PERIOD, } } diff --git a/slasher/src/slasher_server.rs b/slasher/src/slasher_server.rs index 1f10b70ed54..33dc02e742b 100644 --- a/slasher/src/slasher_server.rs +++ b/slasher/src/slasher_server.rs @@ -23,12 +23,13 @@ impl SlasherServer { // don't need to burden them with more work (we can wait). let (sender, receiver) = sync_channel(1); let log = slasher.log.clone(); + let update_period = slasher.config().update_period; executor.spawn( async move { // FIXME(sproul): read slot time from config, align to some fraction of each slot let slot_clock = Arc::new(slot_clock); - let mut interval = interval_at(Instant::now(), Duration::from_secs(12)); + let mut interval = interval_at(Instant::now(), Duration::from_secs(update_period)); while interval.next().await.is_some() { if let Some(current_slot) = slot_clock.clone().now() { let current_epoch = current_slot.epoch(E::slots_per_epoch());