Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add config params for dkg-rerun bitcoin block height and target rounds #1204

Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 16 additions & 0 deletions docker/mainnet/sbtc-signer/signer-config.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -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_RERUN_BITCOIN_HEIGHT
dkg_rerun_bitcoin_height = 880088
matteojug marked this conversation as resolved.
Show resolved Hide resolved

# 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_ROUNDS_TARGET
dkg_rounds_target = 2
matteojug marked this conversation as resolved.
Show resolved Hide resolved

# !! ==============================================================================
# !! Stacks Event Observer Configuration
# !!
Expand Down
8 changes: 8 additions & 0 deletions docker/sbtc/signer/signer-config.toml
matteojug marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ 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_RERUN_BITCOIN_HEIGHT
# dkg_rerun_bitcoin_height = 1234

# !! ==============================================================================
# !! Stacks Event Observer Configuration
# !!
Expand Down
16 changes: 16 additions & 0 deletions signer/src/config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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_RERUN_BITCOIN_HEIGHT
# dkg_rerun_bitcoin_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_ROUNDS_TARGET
# dkg_rounds_target = 1

# !! ==============================================================================
# !! Stacks Event Observer Configuration
# !!
Expand Down
52 changes: 52 additions & 0 deletions signer/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -253,6 +255,18 @@ 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 at most once. If DKG has never been run, this
/// configuration has no effect.
pub dkg_rerun_bitcoin_height: Option<NonZeroU64>,
matteojug marked this conversation as resolved.
Show resolved Hide resolved

/// 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_rerun_bitcoin_height` are also met.
pub dkg_rounds_target: Option<NonZeroU32>,
}

impl Validatable for SignerConfig {
Expand Down Expand Up @@ -391,6 +405,7 @@ impl Settings {
"signer.max_deposits_per_bitcoin_tx",
DEFAULT_MAX_DEPOSITS_PER_BITCOIN_TX,
)?;
cfg_builder = cfg_builder.set_default("signer.dkg_rounds_target", 1)?;

if let Some(path) = config_path {
cfg_builder = cfg_builder.add_source(File::from(path.as_ref()));
Expand Down Expand Up @@ -521,6 +536,10 @@ mod tests {
Duration::from_secs(30)
);
assert_eq!(settings.signer.dkg_max_duration, Duration::from_secs(120));
assert_eq!(
settings.signer.dkg_rounds_target,
Some(NonZeroU32::new(1).unwrap())
);
matteojug marked this conversation as resolved.
Show resolved Hide resolved
}

#[test]
Expand Down Expand Up @@ -646,6 +665,39 @@ mod tests {
assert!(Settings::new_from_default_config().is_err());
}

#[test]
fn default_config_toml_loads_dkg_rerun_bitcoin_height() {
clear_env();

let settings = Settings::new_from_default_config().unwrap();
assert_eq!(settings.signer.dkg_rerun_bitcoin_height, None);

std::env::set_var("SIGNER_SIGNER__DKG_RERUN_BITCOIN_HEIGHT", "42");
let settings = Settings::new_from_default_config().unwrap();
assert_eq!(
settings.signer.dkg_rerun_bitcoin_height,
Some(NonZeroU64::new(42).unwrap())
);
}

#[test]
fn default_config_toml_loads_dkg_rounds_target() {
clear_env();

let settings = Settings::new_from_default_config().unwrap();
assert_eq!(
settings.signer.dkg_rounds_target,
Some(NonZeroU32::new(1).unwrap())
);

std::env::set_var("SIGNER_SIGNER__DKG_ROUNDS_TARGET", "42");
let settings = Settings::new_from_default_config().unwrap();
assert_eq!(
settings.signer.dkg_rounds_target,
Some(NonZeroU32::new(42).unwrap())
);
}

#[test]
fn default_config_toml_loads_signer_network_with_environment() {
clear_env();
Expand Down
Loading