diff --git a/babylonclient/babyloncontroller.go b/babylonclient/babyloncontroller.go index 347f660..f634c8c 100644 --- a/babylonclient/babyloncontroller.go +++ b/babylonclient/babyloncontroller.go @@ -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 @@ -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, @@ -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 @@ -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), diff --git a/babylonclient/interface.go b/babylonclient/interface.go index 79f0beb..705e3ff 100644 --- a/babylonclient/interface.go +++ b/babylonclient/interface.go @@ -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 diff --git a/go.mod b/go.mod index aaddc01..e9ee1f2 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -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 diff --git a/go.sum b/go.sum index e78a14b..d363731 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/itest/containers/containers.go b/itest/containers/containers.go index 31d498d..6140d28 100644 --- a/itest/containers/containers.go +++ b/itest/containers/containers.go @@ -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 && "+ diff --git a/staker/babylontypes.go b/staker/babylontypes.go index 17758e7..c208705 100644 --- a/staker/babylontypes.go +++ b/staker/babylontypes.go @@ -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, diff --git a/staker/types.go b/staker/types.go index 5da833b..9f83e27 100644 --- a/staker/types.go +++ b/staker/types.go @@ -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, @@ -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