diff --git a/docker/mainnet/sbtc-signer/signer-config.toml.in b/docker/mainnet/sbtc-signer/signer-config.toml.in index 3de4c8e5c..6bf347fdc 100644 --- a/docker/mainnet/sbtc-signer/signer-config.toml.in +++ b/docker/mainnet/sbtc-signer/signer-config.toml.in @@ -149,6 +149,22 @@ bitcoin_block_horizon = 3000 # Environment: SIGNER_SIGNER__PROMETHEUS_EXPORTER_ENDPOINT prometheus_exporter_endpoint = "0.0.0.0:9184" +# When defined, the signer will attempt to re-run DKG after the specified +# Bitcoin block height. Please only use this parameter when instructed to by +# the sBTC team. +# +# Required: false +# Environment: SIGNER_SIGNER__DKG_MIN_BITCOIN_BLOCK_HEIGHT +dkg_min_bitcoin_block_height = 880088 + +# When defined, the signer will attempt/allow multiple rounds of DKG until the +# specified number of rounds have been completed. Please only use this parameter +# when instructed to by the sBTC team. +# +# Required: false +# Environment: SIGNER_SIGNER__DKG_TARGET_ROUNDS +dkg_target_rounds = 2 + # !! ============================================================================== # !! Stacks Event Observer Configuration # !! diff --git a/docker/sbtc/signer/signer-config.toml b/docker/sbtc/signer/signer-config.toml index 630034e60..a8aa6bc69 100644 --- a/docker/sbtc/signer/signer-config.toml +++ b/docker/sbtc/signer/signer-config.toml @@ -197,6 +197,22 @@ bootstrap_signing_set = [ # Required: true bootstrap_signatures_required = 2 +# When defined, the signer will attempt to re-run DKG after the specified +# Bitcoin block height. Please only use this parameter when instructed to by +# the sBTC team. +# +# Required: false +# Environment: SIGNER_SIGNER__DKG_MIN_BITCOIN_BLOCK_HEIGHT +# dkg_min_bitcoin_block_height = 1234 + +# When defined, the signer will attempt/allow multiple rounds of DKG until the +# specified number of rounds have been completed. Please only use this parameter +# when instructed to by the sBTC team. +# +# Required: false +# Environment: SIGNER_SIGNER__DKG_TARGET_ROUNDS +# dkg_target_rounds = 1 + # !! ============================================================================== # !! Stacks Event Observer Configuration # !! diff --git a/signer/src/config/default.toml b/signer/src/config/default.toml index bf71802a9..1807925f1 100644 --- a/signer/src/config/default.toml +++ b/signer/src/config/default.toml @@ -205,6 +205,22 @@ sbtc_bitcoin_start_height = 101 # Environment: SIGNER_SIGNER__PROMETHEUS_EXPORTER_ENDPOINT # prometheus_exporter_endpoint = "[::]:9184" +# When defined, the signer will attempt to re-run DKG after the specified +# Bitcoin block height. Please only use this parameter when instructed to by +# the sBTC team. +# +# Required: false +# Environment: SIGNER_SIGNER__DKG_MIN_BITCOIN_BLOCK_HEIGHT +# dkg_min_bitcoin_block_height = 1234 + +# When defined, the signer will attempt/allow multiple rounds of DKG until the +# specified number of rounds have been completed. Please only use this parameter +# when instructed to by the sBTC team. +# +# Required: false +# Environment: SIGNER_SIGNER__DKG_TARGET_ROUNDS +# dkg_target_rounds = 1 + # !! ============================================================================== # !! Stacks Event Observer Configuration # !! diff --git a/signer/src/config/mod.rs b/signer/src/config/mod.rs index 9a90285e2..f2527fcc3 100644 --- a/signer/src/config/mod.rs +++ b/signer/src/config/mod.rs @@ -8,6 +8,8 @@ use serde::Deserialize; use stacks_common::types::chainstate::StacksAddress; use std::collections::BTreeSet; use std::num::NonZeroU16; +use std::num::NonZeroU32; +use std::num::NonZeroU64; use std::path::Path; use url::Url; @@ -253,6 +255,17 @@ pub struct SignerConfig { /// arrives. The default here is controlled by the /// [`MAX_DEPOSITS_PER_BITCOIN_TX`] constant pub max_deposits_per_bitcoin_tx: NonZeroU16, + /// Configures a DKG re-run Bitcoin block height. If this is set and DKG has + /// already been run, the coordinator will attempt to re-run DKG after this + /// block height is met if `dkg_target_rounds` has not been reached. If DKG + /// has never been run, this configuration has no effect. + pub dkg_min_bitcoin_block_height: Option, + /// Configures a target number of DKG rounds to run/accept. If this is set + /// and the number of DKG shares is less than this number, the coordinator + /// will continue to run DKG rounds until this number of rounds is reached, + /// assuming the conditions for `dkg_min_bitcoin_block_height` are also met. + /// If DKG has never been run, this configuration has no effect. + pub dkg_target_rounds: NonZeroU32, } impl Validatable for SignerConfig { @@ -391,6 +404,7 @@ impl Settings { "signer.max_deposits_per_bitcoin_tx", DEFAULT_MAX_DEPOSITS_PER_BITCOIN_TX, )?; + cfg_builder = cfg_builder.set_default("signer.dkg_target_rounds", 1)?; if let Some(path) = config_path { cfg_builder = cfg_builder.add_source(File::from(path.as_ref())); @@ -521,6 +535,11 @@ mod tests { Duration::from_secs(30) ); assert_eq!(settings.signer.dkg_max_duration, Duration::from_secs(120)); + assert_eq!( + settings.signer.dkg_target_rounds, + NonZeroU32::new(1).unwrap() + ); + assert_eq!(settings.signer.dkg_min_bitcoin_block_height, None); } #[test] @@ -646,6 +665,39 @@ mod tests { assert!(Settings::new_from_default_config().is_err()); } + #[test] + fn default_config_toml_loads_dkg_min_bitcoin_block_height() { + clear_env(); + + let settings = Settings::new_from_default_config().unwrap(); + assert_eq!(settings.signer.dkg_min_bitcoin_block_height, None); + + std::env::set_var("SIGNER_SIGNER__DKG_MIN_BITCOIN_BLOCK_HEIGHT", "42"); + let settings = Settings::new_from_default_config().unwrap(); + assert_eq!( + settings.signer.dkg_min_bitcoin_block_height, + Some(NonZeroU64::new(42).unwrap()) + ); + } + + #[test] + fn default_config_toml_loads_dkg_target_rounds() { + clear_env(); + + let settings = Settings::new_from_default_config().unwrap(); + assert_eq!( + settings.signer.dkg_target_rounds, + NonZeroU32::new(1).unwrap() + ); + + std::env::set_var("SIGNER_SIGNER__DKG_TARGET_ROUNDS", "42"); + let settings = Settings::new_from_default_config().unwrap(); + assert_eq!( + settings.signer.dkg_target_rounds, + NonZeroU32::new(42).unwrap() + ); + } + #[test] fn default_config_toml_loads_signer_network_with_environment() { clear_env();