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

fix: update params breaking changes #85

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 4 additions & 0 deletions internal/clients/bbnclient/bbnclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
6 changes: 4 additions & 2 deletions internal/clients/bbnclient/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/services/watch_btc_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading