Skip to content

Commit

Permalink
bump babylon and adjust params
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradStaniec committed Dec 5, 2024
1 parent 35c690a commit 0eead4d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
12 changes: 6 additions & 6 deletions babylonclient/babyloncontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type StakingTrackerResponse struct {
CovenantPks []*btcec.PublicKey
CovenantQuruomThreshold uint32
MinSlashingFee btcutil.Amount
MinUnbondingTime uint16
UnbondingTime uint16
UnbondingFee btcutil.Amount
MinStakingTime uint16
MaxStakingTime uint16
Expand Down Expand Up @@ -179,7 +179,7 @@ func (bc *BabylonController) Params() (*StakingParams, error) {
MinSlashingTxFeeSat: stakingTrackerParams.MinSlashingFee,
SlashingRate: stakingTrackerParams.SlashingRate,
CovenantQuruomThreshold: stakingTrackerParams.CovenantQuruomThreshold,
MinUnbondingTime: stakingTrackerParams.MinUnbondingTime,
UnbondingTime: stakingTrackerParams.UnbondingTime,
UnbondingFee: stakingTrackerParams.UnbondingFee,
MinStakingTime: stakingTrackerParams.MinStakingTime,
MaxStakingTime: stakingTrackerParams.MaxStakingTime,
Expand Down Expand Up @@ -478,9 +478,9 @@ func (bc *BabylonController) QueryStakingTracker() (*StakingTrackerResponse, err
covenantPks = append(covenantPks, covenantBtcPk)
}

minUnbondingTimeBlocksU32 := response.Params.MinUnbondingTimeBlocks
if minUnbondingTimeBlocksU32 > math.MaxUint16 {
return nil, fmt.Errorf("min unbonding time is bigger than uint16: %w", ErrInvalidValueReceivedFromBabylonNode)
unbondingTime := response.Params.UnbondingTimeBlocks
if unbondingTime > math.MaxUint16 {
return nil, fmt.Errorf("unbonding time is bigger than uint16: %w", ErrInvalidValueReceivedFromBabylonNode)
}

minStakingTimeBlocksU32 := response.Params.MinStakingTimeBlocks
Expand Down Expand Up @@ -512,7 +512,7 @@ func (bc *BabylonController) QueryStakingTracker() (*StakingTrackerResponse, err
CovenantPks: covenantPks,
MinSlashingFee: btcutil.Amount(response.Params.MinSlashingTxFeeSat),
CovenantQuruomThreshold: response.Params.CovenantQuorum,
MinUnbondingTime: uint16(minUnbondingTimeBlocksU32),
UnbondingTime: uint16(unbondingTime),
UnbondingFee: btcutil.Amount(response.Params.UnbondingFeeSat),
MinStakingTime: uint16(minStakingTimeBlocksU32),
MaxStakingTime: uint16(maxStakingTimeBlocksU32),
Expand Down
2 changes: 1 addition & 1 deletion babylonclient/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type StakingParams struct {
CovenantQuruomThreshold uint32

// Minimum unbonding time required by babylon
MinUnbondingTime uint16
UnbondingTime uint16

// Fee required by unbonding transaction
UnbondingFee btcutil.Amount
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.4.0
github.com/avast/retry-go/v4 v4.5.1
github.com/babylonlabs-io/babylon v0.17.1
github.com/babylonlabs-io/babylon v0.18.0
github.com/babylonlabs-io/networks/parameters v0.2.2
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.2
Expand All @@ -22,6 +22,7 @@ require (
github.com/cosmos/cosmos-sdk v0.50.9
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/relayer/v2 v2.5.2
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/jessevdk/go-flags v1.5.0
github.com/jsternberg/zap-logfmt v1.3.0
github.com/lightningnetwork/lnd v0.16.4-beta.rc1
Expand Down Expand Up @@ -113,7 +114,6 @@ require (
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/decred/dcrd/lru v1.0.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v4 v4.3.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1432,8 +1432,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.1 h1:lyWGdR7B49qDw5pllLyTW/HAM5uQWXXPZefjFzy/Xy0=
github.com/babylonlabs-io/babylon v0.17.1/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/networks/parameters v0.2.2 h1:TCu39fZvjX5f6ZZrjhYe54M6wWxglNewuKu56yE+zrc=
github.com/babylonlabs-io/networks/parameters v0.2.2/go.mod h1:iEJVOzaLsE33vpP7J4u+CRGfkSIfErUAwRmgCFCBpyI=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down
2 changes: 1 addition & 1 deletion itest/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (m *Manager) RunBabylondResource(
"sh", "-c", fmt.Sprintf(
"babylond testnet --v=1 --output-dir=/home --starting-ip-address=192.168.10.2 "+
"--keyring-backend=test --chain-id=chain-test --btc-finalization-timeout=4 "+
"--btc-confirmation-depth=2 --min-unbonding-time=5 --additional-sender-account --btc-network=regtest "+
"--btc-confirmation-depth=2 --unbonding-time=5 --additional-sender-account --btc-network=regtest "+
"--min-staking-time-blocks=200 --min-staking-amount-sat=10000 "+
"--slashing-pk-script=%s --btc-base-header=%s --covenant-quorum=%d "+
"--covenant-pks=%s && chmod -R 777 /home && "+
Expand Down
3 changes: 1 addition & 2 deletions staker/babylontypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ func (app *App) buildOwnedDelegation(
externalData.babylonParams.CovenantQuruomThreshold,
externalData.babylonParams.SlashingPkScript,
externalData.babylonParams.UnbondingFee,
// TODO: Possiblity to customize finalization time
externalData.babylonParams.MinUnbondingTime,
externalData.babylonParams.UnbondingTime,
app.getSlashingFee(externalData.babylonParams.MinSlashingTxFeeSat),
externalData.babylonParams.SlashingRate,
app.network,
Expand Down
6 changes: 3 additions & 3 deletions staker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func slashingTxForStakingTx(
net *chaincfg.Params,
) (*wire.MsgTx, *staking.SpendInfo, error) {
stakerPubKey := delegationData.stakerPublicKey
lockSlashTxLockTime := delegationData.babylonParams.MinUnbondingTime
lockSlashTxLockTime := delegationData.babylonParams.UnbondingTime

slashingTx, err := staking.BuildSlashingTxFromStakingTxStrict(
storedTx.StakingTx,
Expand Down Expand Up @@ -509,8 +509,8 @@ func parseWatchStakingRequest(
return nil, fmt.Errorf("failed to watch staking tx due to tx not matching current data: %w", err)
}

if unbondingTime < currentParams.MinUnbondingTime {
return nil, fmt.Errorf("failed to watch staking tx. Unbonding time must be greater or equal min unbonding time. Unbonding time: %d, min unbonding time: %d", unbondingTime, currentParams.MinUnbondingTime)
if unbondingTime != currentParams.UnbondingTime {
return nil, fmt.Errorf("failed to watch staking tx. Unbonding time must be equal to unbonding time in babylon. Unbonding time: %d, unbonding time in babylon: %d", unbondingTime, currentParams.UnbondingTime)
}

// 2. Check whether slashing tx match staking tx
Expand Down

0 comments on commit 0eead4d

Please sign in to comment.