Skip to content

Commit

Permalink
slashing addr
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Aug 28, 2024
1 parent 7413dd6 commit 3335ab7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion contracts/btc-staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub(crate) mod tests {

/// Build an active BTC delegation from a BTC delegation
pub(crate) fn get_active_btc_delegation() -> ActiveBtcDelegation {
let (del, _) = get_btc_delegation_and_params();
let (del, params) = get_btc_delegation_and_params();
let btc_undelegation = del.btc_undelegation.unwrap();

ActiveBtcDelegation {
Expand Down
12 changes: 2 additions & 10 deletions contracts/btc-staking/src/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn handle_btc_staking(

// Process active delegations
for del in active_delegations {
handle_active_delegation(deps.storage, deps.querier, env.block.height, del)?;
handle_active_delegation(deps.storage, env.block.height, del)?;
// TODO: Add event
}

Expand Down Expand Up @@ -100,19 +100,11 @@ pub fn handle_new_fp(
///
pub fn handle_active_delegation(
storage: &mut dyn Storage,
querier: QuerierWrapper,
height: u64,
active_delegation: &ActiveBtcDelegation,
) -> Result<(), ContractError> {
let config = CONFIG.load(storage)?;
let params = PARAMS.load(storage)?;

// Query Babylon contract's config
let babylon_config: babylon_contract::state::config::Config = querier.query_wasm_smart(
config.babylon.clone(),
&babylon_contract::msg::contract::QueryMsg::Config {},
)?;

// Basic stateless checks
active_delegation.validate()?;

Expand Down Expand Up @@ -200,7 +192,7 @@ pub fn handle_active_delegation(
&slashing_address,
&staker_btc_pk,
active_delegation.unbonding_time as u16,
get_bitcoin_network(babylon_config.network),
get_bitcoin_network(params.btc_network),
)?;

// Verify staker signature against slashing path of the staking tx script
Expand Down
5 changes: 4 additions & 1 deletion contracts/btc-staking/src/state/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use babylon_bitcoin::chain_params::Network;
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Addr;
use cosmwasm_std::Decimal;
Expand Down Expand Up @@ -29,6 +30,8 @@ pub struct Config {
#[derive(Derivative)]
#[derivative(Default)]
pub struct Params {
#[derivative(Default(value = "Network::Regtest"))]
pub btc_network: Network,
// `min_commission_rate` is the chain-wide minimum commission rate that a finality provider
// can charge their delegators
// pub min_commission_rate: Decimal,
Expand All @@ -42,7 +45,7 @@ pub struct Params {
pub min_pub_rand: u64,
/// `slashing_address` is the address that the slashed BTC goes to.
/// The address is in string format on Bitcoin.
#[derivative(Default(value = "String::from(\"SMPJunctnV4LunQRk37CuFeWeU9iBDoZwx\")"))]
#[derivative(Default(value = "String::from(\"n4cV57jePmAAue2WTTBQzH3k3R2rgWBQwY\")"))]
pub slashing_address: String,
/// `min_slashing_tx_fee_sat` is the minimum amount of tx fee (quantified in Satoshi) needed for
/// the pre-signed slashing tx
Expand Down

0 comments on commit 3335ab7

Please sign in to comment.