diff --git a/go.mod b/go.mod index 5ff2c47..0e54686 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.1 require ( github.com/avast/retry-go/v4 v4.5.1 - github.com/babylonlabs-io/babylon v0.17.2 + github.com/babylonlabs-io/babylon v0.18.0 github.com/babylonlabs-io/staking-queue-client v0.4.7-0.20241203052145-e50972fc19c9 github.com/btcsuite/btcd v0.24.3-0.20241011125836-24eb815168f4 github.com/btcsuite/btcd/btcec/v2 v2.3.4 diff --git a/go.sum b/go.sum index 112c5f4..82725d4 100644 --- a/go.sum +++ b/go.sum @@ -280,8 +280,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/babylonlabs-io/babylon v0.17.2 h1:CzBXYFOZLg3+ijfqIsisETAzRVp5AGKNO2FG63w0HUo= -github.com/babylonlabs-io/babylon v0.17.2/go.mod h1:sT+KG2U+M0tDMNZZ2L5CwlXX0OpagGEs56BiWXqaZFw= +github.com/babylonlabs-io/babylon v0.18.0 h1:phMY/GiR9N5MpD3XCmvyPpZkc1I3kTM9yX+Cf0h3OnU= +github.com/babylonlabs-io/babylon v0.18.0/go.mod h1:sT+KG2U+M0tDMNZZ2L5CwlXX0OpagGEs56BiWXqaZFw= github.com/babylonlabs-io/staking-queue-client v0.4.7-0.20241203052145-e50972fc19c9 h1:4UGpRPm5oxj3P8QNrGrkiQtlQYTAgsWzXJFi8oD7zpY= github.com/babylonlabs-io/staking-queue-client v0.4.7-0.20241203052145-e50972fc19c9/go.mod h1:n3fr3c+9LNiJlyETmcrVk94Zn76rAADhGZKxX+rVf+Q= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/internal/clients/bbnclient/bbnclient.go b/internal/clients/bbnclient/bbnclient.go index d089485..998660b 100644 --- a/internal/clients/bbnclient/bbnclient.go +++ b/internal/clients/bbnclient/bbnclient.go @@ -94,6 +94,10 @@ func (c *BBNClient) GetAllStakingParams(ctx context.Context) (map[uint32]*Stakin if err := params.Params.Validate(); err != nil { return nil, fmt.Errorf("failed to validate staking params for version %d: %w", version, err) } + // BBN is missing the btcActivationHeight validation in the staking params + if params.Params.BtcActivationHeight == 0 { + return nil, fmt.Errorf("btc activation height is not set") + } allParams[version] = FromBbnStakingParams(params.Params) version++ diff --git a/internal/clients/bbnclient/types.go b/internal/clients/bbnclient/types.go index 052d891..68087e1 100644 --- a/internal/clients/bbnclient/types.go +++ b/internal/clients/bbnclient/types.go @@ -19,11 +19,12 @@ type StakingParams struct { SlashingPkScript string `bson:"slashing_pk_script"` MinSlashingTxFeeSat int64 `bson:"min_slashing_tx_fee_sat"` SlashingRate string `bson:"slashing_rate"` - MinUnbondingTimeBlocks uint32 `bson:"min_unbonding_time_blocks"` + UnbondingTimeBlocks uint32 `bson:"unbonding_time_blocks"` UnbondingFeeSat int64 `bson:"unbonding_fee_sat"` MinCommissionRate string `bson:"min_commission_rate"` DelegationCreationBaseGasFee uint64 `bson:"delegation_creation_base_gas_fee"` AllowListExpirationHeight uint64 `bson:"allow_list_expiration_height"` + BtcActivationHeight uint32 `bson:"btc_activation_height"` } type CheckpointParams struct { @@ -43,11 +44,12 @@ func FromBbnStakingParams(params stakingtypes.Params) *StakingParams { SlashingPkScript: hex.EncodeToString(params.SlashingPkScript), MinSlashingTxFeeSat: params.MinSlashingTxFeeSat, SlashingRate: params.SlashingRate.String(), - MinUnbondingTimeBlocks: params.MinUnbondingTimeBlocks, + UnbondingTimeBlocks: params.UnbondingTimeBlocks, UnbondingFeeSat: params.UnbondingFeeSat, MinCommissionRate: params.MinCommissionRate.String(), DelegationCreationBaseGasFee: params.DelegationCreationBaseGasFee, AllowListExpirationHeight: params.AllowListExpirationHeight, + BtcActivationHeight: params.BtcActivationHeight, } } diff --git a/internal/services/watch_btc_events.go b/internal/services/watch_btc_events.go index 49654e9..010a194 100644 --- a/internal/services/watch_btc_events.go +++ b/internal/services/watch_btc_events.go @@ -348,7 +348,7 @@ func (s *Service) startWatchingSlashingChange( if err != nil { return fmt.Errorf("failed to get staking params: %w", err) } - slashingChangeTimelockExpireHeight := spendingHeight + stakingParams.MinUnbondingTimeBlocks + slashingChangeTimelockExpireHeight := spendingHeight + stakingParams.UnbondingTimeBlocks // Save timelock expire to mark it as Withdrawn (sub state - timelock_slashing/early_unbonding_slashing) if err := s.db.SaveNewTimeLockExpire(