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

chore: use babylon params instead of global parameters #151

Merged
merged 19 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
06c494c
chore: initial data to load all params
RafilxTenfen Mar 9, 2025
82d7e4d
chore: set tx inclusion height as optional at createPhase1UnbondingTr…
RafilxTenfen Mar 10, 2025
b8481d3
chore: add JSON RPC func to btc staker service to get parameters from…
RafilxTenfen Mar 10, 2025
de4bc1d
chore: removed global parameters from command stake-from-phase1
RafilxTenfen Mar 10, 2025
dbc7701
chore: add #151 to cl
RafilxTenfen Mar 10, 2025
2891545
fix: image config from v1rc7
RafilxTenfen Mar 10, 2025
5b4d1fa
chore: usa v1.99 dockerhub version
RafilxTenfen Mar 10, 2025
5c5b3bc
chore: set ValidateTxAgainstParams to public
RafilxTenfen Mar 10, 2025
6829bbd
chore: set correct version in config container
RafilxTenfen Mar 10, 2025
a3704f6
chore: removed required flag from inclusion height of btc staking tx …
RafilxTenfen Mar 10, 2025
1092b99
chore: remove unwanted file
RafilxTenfen Mar 10, 2025
e52a3ae
fix: lint comment on func
RafilxTenfen Mar 10, 2025
52582ab
chore: add test for sorting by btc activation height
RafilxTenfen Mar 10, 2025
ace0957
fix: lint add parallel call
RafilxTenfen Mar 10, 2025
6eae7f4
chore: refactory to use babylon query that returns the staking paramt…
RafilxTenfen Mar 11, 2025
a3007ff
chore: removed BtcActivationHeight and fixed comment in godoc func
RafilxTenfen Mar 11, 2025
dd5a04b
chore: removed unnecessary tag check in parse v0 staking tx
RafilxTenfen Mar 12, 2025
ae3dc29
chore: update to use babylon latest release tag on main branch v1.99.…
RafilxTenfen Mar 12, 2025
f750a26
chore: removed test-go
RafilxTenfen Mar 12, 2025
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Improvements

- [#151](https://github.com/babylonlabs-io/btc-staker/pull/151) Load parameters from
babylon node instead of global parameters input file in `stake-from-phase1`.
- [#142](https://github.com/babylonlabs-io/btc-staker/pull/142) Set config default
keyring backend to "file" type
- [#138](https://github.com/babylonlabs-io/btc-staker/pull/138) Adds prometheus metrics
Expand Down
32 changes: 4 additions & 28 deletions babylonclient/babyloncontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,8 @@ func (bc *BabylonController) Params() (*StakingParams, error) {
}

return &StakingParams{
ConfirmationTimeBlocks: bccParams.ConfirmationTimeBlocks,
FinalizationTimeoutBlocks: bccParams.FinalizationTimeoutBlocks,
SlashingPkScript: stakingTrackerParams.SlashingPkScript,
CovenantPks: stakingTrackerParams.CovenantPks,
MinSlashingTxFeeSat: stakingTrackerParams.MinSlashingFee,
SlashingRate: stakingTrackerParams.SlashingRate,
CovenantQuruomThreshold: stakingTrackerParams.CovenantQuruomThreshold,
UnbondingTime: stakingTrackerParams.UnbondingTime,
UnbondingFee: stakingTrackerParams.UnbondingFee,
MinStakingTime: stakingTrackerParams.MinStakingTime,
MaxStakingTime: stakingTrackerParams.MaxStakingTime,
MinStakingValue: stakingTrackerParams.MinStakingValue,
MaxStakingValue: stakingTrackerParams.MaxStakingValue,
AllowListExpirationHeight: stakingTrackerParams.AllowListExpirationHeight,
BTCCheckpointParams: *bccParams,
BtcStakingParams: BtcStakingParamsFromStakingTracker(stakingTrackerParams),
}, nil
}

Expand Down Expand Up @@ -267,20 +255,8 @@ func (bc *BabylonController) ParamsByBtcHeight(btcHeight uint32) (*StakingParams
}

return &StakingParams{
ConfirmationTimeBlocks: bccParams.ConfirmationTimeBlocks,
FinalizationTimeoutBlocks: bccParams.FinalizationTimeoutBlocks,
SlashingPkScript: stakingTrackerParams.SlashingPkScript,
CovenantPks: stakingTrackerParams.CovenantPks,
MinSlashingTxFeeSat: stakingTrackerParams.MinSlashingFee,
SlashingRate: stakingTrackerParams.SlashingRate,
CovenantQuruomThreshold: stakingTrackerParams.CovenantQuruomThreshold,
UnbondingTime: stakingTrackerParams.UnbondingTime,
UnbondingFee: stakingTrackerParams.UnbondingFee,
MinStakingTime: stakingTrackerParams.MinStakingTime,
MaxStakingTime: stakingTrackerParams.MaxStakingTime,
MinStakingValue: stakingTrackerParams.MinStakingValue,
MaxStakingValue: stakingTrackerParams.MaxStakingValue,
AllowListExpirationHeight: stakingTrackerParams.AllowListExpirationHeight,
BTCCheckpointParams: *bccParams,
BtcStakingParams: BtcStakingParamsFromStakingTracker(stakingTrackerParams),
}, nil
}

Expand Down
41 changes: 31 additions & 10 deletions babylonclient/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ type BTCCheckpointParams struct {

// StakingParams defines the parameters for staking
type StakingParams struct {
// K-deep
ConfirmationTimeBlocks uint32
// W-deep
FinalizationTimeoutBlocks uint32
BTCCheckpointParams
BtcStakingParams
}

type BtcStakingParams struct {
// Minimum amount of satoshis required for slashing transaction
MinSlashingTxFeeSat btcutil.Amount

Expand Down Expand Up @@ -92,6 +92,23 @@ type BabylonClient interface {
QueryBtcLightClientTipHeight() (uint32, error)
}

func BtcStakingParamsFromStakingTracker(stakingTrackerParams *StakingTrackerResponse) BtcStakingParams {
return BtcStakingParams{
SlashingPkScript: stakingTrackerParams.SlashingPkScript,
CovenantPks: stakingTrackerParams.CovenantPks,
MinSlashingTxFeeSat: stakingTrackerParams.MinSlashingFee,
SlashingRate: stakingTrackerParams.SlashingRate,
CovenantQuruomThreshold: stakingTrackerParams.CovenantQuruomThreshold,
UnbondingTime: stakingTrackerParams.UnbondingTime,
UnbondingFee: stakingTrackerParams.UnbondingFee,
MinStakingTime: stakingTrackerParams.MinStakingTime,
MaxStakingTime: stakingTrackerParams.MaxStakingTime,
MinStakingValue: stakingTrackerParams.MinStakingValue,
MaxStakingValue: stakingTrackerParams.MaxStakingValue,
AllowListExpirationHeight: stakingTrackerParams.AllowListExpirationHeight,
}
}

type MockBabylonClient struct {
ClientParams *StakingParams
babylonKey *secp256k1.PrivKey
Expand Down Expand Up @@ -224,12 +241,16 @@ func GetMockClient() *MockBabylonClient {

return &MockBabylonClient{
ClientParams: &StakingParams{
ConfirmationTimeBlocks: 2,
FinalizationTimeoutBlocks: 5,
MinSlashingTxFeeSat: btcutil.Amount(1000),
CovenantPks: []*btcec.PublicKey{covenantPk.PubKey()},
SlashingPkScript: slashingPkScript,
SlashingRate: sdkmath.LegacyNewDecWithPrec(1, 1), // 1 * 10^{-1} = 0.1
BTCCheckpointParams: BTCCheckpointParams{
ConfirmationTimeBlocks: 2,
FinalizationTimeoutBlocks: 5,
},
BtcStakingParams: BtcStakingParams{
MinSlashingTxFeeSat: btcutil.Amount(1000),
CovenantPks: []*btcec.PublicKey{covenantPk.PubKey()},
SlashingPkScript: slashingPkScript,
SlashingRate: sdkmath.LegacyNewDecWithPrec(1, 1), // 1 * 10^{-1} = 0.1
},
},
babylonKey: priv,
SentMessages: make(chan *btcstypes.MsgCreateBTCDelegation),
Expand Down
Loading
Loading