Skip to content

Commit

Permalink
update babylond version
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Sep 10, 2024
1 parent 3d6f6b6 commit cb9b079
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 32 deletions.
6 changes: 3 additions & 3 deletions btcstaking-tracker/btcslasher/bootstrapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func FuzzSlasher_Bootstrapping(f *testing.F) {
require.NoError(t, err)

// slashing address
slashingAddr, err := datagen.GenRandomBTCAddress(r, net)
slashingPkScript, err := datagen.GenRandomPubKeyHashScript(r, net)
require.NoError(t, err)

// mock BTC staking parameters
Expand Down Expand Up @@ -116,7 +116,7 @@ func FuzzSlasher_Bootstrapping(f *testing.F) {
covenantSks,
covPks,
bsParams.Params.CovenantQuorum,
slashingAddr.String(),
slashingPkScript,
100,
1100,
delAmount,
Expand Down Expand Up @@ -146,7 +146,7 @@ func FuzzSlasher_Bootstrapping(f *testing.F) {
covenantSks,
covPks,
bsParams.Params.CovenantQuorum,
slashingAddr.String(),
slashingPkScript,
100,
1100,
delAmount,
Expand Down
10 changes: 5 additions & 5 deletions btcstaking-tracker/btcslasher/slasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func FuzzSlasher(f *testing.F) {
require.NoError(t, err)

// slashing and change address
slashingAddr, err := datagen.GenRandomBTCAddress(r, net)
slashingPkScript, err := datagen.GenRandomPubKeyHashScript(r, net)
require.NoError(t, err)

// generate BTC key pair for slashed finality provider
Expand All @@ -111,7 +111,7 @@ func FuzzSlasher(f *testing.F) {
covenantSks,
covenantBtcPks,
bsParams.Params.CovenantQuorum,
slashingAddr.String(),
slashingPkScript,
100,
1099,
delAmount,
Expand All @@ -138,7 +138,7 @@ func FuzzSlasher(f *testing.F) {
covenantSks,
covenantBtcPks,
bsParams.Params.CovenantQuorum,
slashingAddr.String(),
slashingPkScript,
100,
1100,
delAmount,
Expand All @@ -165,7 +165,7 @@ func FuzzSlasher(f *testing.F) {
covenantSks,
covenantBtcPks,
bsParams.Params.CovenantQuorum,
slashingAddr.String(),
slashingPkScript,
100,
1100,
delAmount,
Expand Down Expand Up @@ -202,7 +202,7 @@ func FuzzSlasher(f *testing.F) {
outPoint,
1000,
9000,
slashingAddr.String(),
slashingPkScript,
bsParams.Params.SlashingRate,
unbondingTime,
)
Expand Down
11 changes: 5 additions & 6 deletions e2etest/atomicslasher_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ func TestAtomicSlasher(t *testing.T) {
// Insert all existing BTC headers to babylon node
tm.CatchUpBTCLightClient(t)

emptyHintCache := btcclient.EmptyHintCache{}

backend, err := btcclient.NewNodeBackend(
btcclient.ToBitcoindConfig(tm.Config.BTC),
&chaincfg.RegressionNetParams,
&emptyHintCache,
&btcclient.EmptyHintCache{},
)
require.NoError(t, err)

Expand All @@ -49,7 +47,6 @@ func TestAtomicSlasher(t *testing.T) {
commonCfg := config.DefaultCommonConfig()
bstCfg := config.DefaultBTCStakingTrackerConfig()
bstCfg.CheckDelegationsInterval = 1 * time.Second
metrics := metrics.NewBTCStakingTrackerMetrics()

bsTracker := bst.NewBTCSTakingTracker(
tm.BTCClient,
Expand All @@ -58,7 +55,7 @@ func TestAtomicSlasher(t *testing.T) {
&bstCfg,
&commonCfg,
zap.NewNop(),
metrics,
metrics.NewBTCStakingTrackerMetrics(),
)
go bsTracker.Start()
defer bsTracker.Stop()
Expand Down Expand Up @@ -124,7 +121,9 @@ func TestAtomicSlasher(t *testing.T) {

require.Eventually(t, func() bool {
_, err := tm.BTCClient.GetRawTransaction(slashingTxHash2)
t.Logf("err of getting slashingTxHash of the BTC delegation affected by atomic slashing: %v", err)
if err != nil {
t.Logf("err of getting slashingTxHash of the BTC delegation affected by atomic slashing: %v", err)
}
return err == nil
}, eventuallyWaitTimeOut, eventuallyPollTime)

Expand Down
6 changes: 4 additions & 2 deletions e2etest/babylon_node_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type BabylonNodeHandler struct {
babylonNode *babylonNode
}

func NewBabylonNodeHandler(baseHeaderHex string, slashingAddress string, epochInterval uint) (*BabylonNodeHandler, error) {
func NewBabylonNodeHandler(baseHeaderHex string, slashingPkScript string, epochInterval uint) (*BabylonNodeHandler, error) {
testDir, err := baseDirBabylondir()
if err != nil {
return nil, err
Expand All @@ -141,8 +141,10 @@ func NewBabylonNodeHandler(baseHeaderHex string, slashingAddress string, epochIn
"--btc-confirmation-depth=2",
"--additional-sender-account",
"--btc-network=regtest",
"--min-staking-time-blocks=200",
"--min-staking-amount-sat=10000",
fmt.Sprintf("--epoch-interval=%d", epochInterval),
fmt.Sprintf("--slashing-address=%s", slashingAddress),
fmt.Sprintf("--slashing-pk-script=%s", slashingPkScript),
fmt.Sprintf("--btc-base-header=%s", baseHeaderHex),
"--covenant-quorum=1",
fmt.Sprintf("--covenant-pks=%s", bbn.NewBIP340PubKeyFromBTCPK(juryPK).MarshalHex()),
Expand Down
6 changes: 5 additions & 1 deletion e2etest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/btcsuite/btcd/txscript"
"go.uber.org/zap"
"testing"
"time"
Expand Down Expand Up @@ -116,8 +117,11 @@ func StartManager(t *testing.T, numMatureOutputsInWallet uint32, epochInterval u
minerAddressDecoded, err := btcutil.DecodeAddress(blocksResponse.Address, regtestParams)
require.NoError(t, err)

pkScript, err := txscript.PayToAddrScript(minerAddressDecoded)
require.NoError(t, err)

// start Babylon node
bh, err := NewBabylonNodeHandler(baseHeaderHex, minerAddressDecoded.EncodeAddress(), epochInterval)
bh, err := NewBabylonNodeHandler(baseHeaderHex, hex.EncodeToString(pkScript), epochInterval)
require.NoError(t, err)
err = bh.Start()
require.NoError(t, err)
Expand Down
13 changes: 6 additions & 7 deletions e2etest/test_manager_btcstaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"math"
"math/rand"
"testing"
"time"
Expand Down Expand Up @@ -44,7 +43,7 @@ func (tm *TestManager) getBTCUnbondingTime(t *testing.T) uint64 {
btccParams, err := tm.BabylonClient.BTCCheckpointParams()
require.NoError(t, err)

return bstypes.MinimumUnbondingTime(bsParams.Params, btccParams.Params) + 1
return bstypes.MinimumUnbondingTime(&bsParams.Params, &btccParams.Params) + 1
}

func (tm *TestManager) CreateFinalityProvider(t *testing.T) (*bstypes.FinalityProvider, *btcec.PrivateKey) {
Expand Down Expand Up @@ -91,7 +90,7 @@ func (tm *TestManager) CreateBTCDelegation(
require.NoError(t, err)
covenantBtcPks, err := bbnPksToBtcPks(bsParams.Params.CovenantPks)
require.NoError(t, err)
stakingTimeBlocks := uint16(math.MaxUint16)
stakingTimeBlocks := bsParams.Params.MaxStakingTimeBlocks
// get top UTXO
topUnspentResult, _, err := tm.BTCClient.GetHighUTXOAndSum()
require.NoError(t, err)
Expand All @@ -110,9 +109,9 @@ func (tm *TestManager) CreateBTCDelegation(
[]*btcec.PublicKey{fpPK},
covenantBtcPks,
bsParams.Params.CovenantQuorum,
stakingTimeBlocks,
uint16(stakingTimeBlocks),
stakingValue,
bsParams.Params.SlashingAddress,
bsParams.Params.SlashingPkScript,
bsParams.Params.SlashingRate,
uint16(tm.getBTCUnbondingTime(t)),
)
Expand Down Expand Up @@ -193,9 +192,9 @@ func (tm *TestManager) CreateBTCDelegation(
covenantBtcPks,
bsParams.Params.CovenantQuorum,
wire.NewOutPoint(stakingMsgTxHash, stakingOutIdx),
stakingTimeBlocks,
uint16(stakingTimeBlocks),
unbondingValue,
bsParams.Params.SlashingAddress,
bsParams.Params.SlashingPkScript,
bsParams.Params.SlashingRate,
uint16(tm.getBTCUnbondingTime(t)),
)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ require (
cosmossdk.io/log v1.3.1
cosmossdk.io/math v1.3.0
github.com/avast/retry-go/v4 v4.6.0
github.com/babylonlabs-io/babylon v0.9.1
github.com/babylonlabs-io/babylon v0.9.3-0.20240904123958-b1e255a85e76
github.com/boljen/go-bitmap v0.0.0-20151001105940-23cd2fb0ce7d
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/btcsuite/btcwallet v0.16.10-0.20230621165747-9c21f464ce13
github.com/btcsuite/btcwallet/walletdb v1.4.0
github.com/cometbft/cometbft v0.38.7
github.com/cosmos/cosmos-sdk v0.50.6
github.com/cosmos/relayer/v2 v2.5.1
Expand All @@ -25,6 +26,7 @@ require (
github.com/jinzhu/copier v0.3.5
github.com/jsternberg/zap-logfmt v1.3.0
github.com/lightningnetwork/lnd v0.16.4-beta.rc1
github.com/lightningnetwork/lnd/kvdb v1.4.1
github.com/ory/dockertest/v3 v3.9.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.0
Expand Down Expand Up @@ -80,7 +82,6 @@ require (
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2 // indirect
github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 // indirect
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.3 // indirect
github.com/btcsuite/btcwallet/walletdb v1.4.0 // indirect
github.com/btcsuite/btcwallet/wtxmgr v1.5.0 // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
Expand Down Expand Up @@ -217,7 +218,6 @@ require (
github.com/lightningnetwork/lightning-onion v1.2.1-0.20221202012345-ca23184850a1 // indirect
github.com/lightningnetwork/lnd/clock v1.1.0 // indirect
github.com/lightningnetwork/lnd/healthcheck v1.2.2 // indirect
github.com/lightningnetwork/lnd/kvdb v1.4.1 // indirect
github.com/lightningnetwork/lnd/queue v1.1.0 // indirect
github.com/lightningnetwork/lnd/ticker v1.1.0 // indirect
github.com/lightningnetwork/lnd/tlv v1.1.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,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.9.1 h1:V7PtWgUAQa0kxFOwOuGvh0rKXyqiY6JheTZdfyeEkBk=
github.com/babylonlabs-io/babylon v0.9.1/go.mod h1:t7B4e+ooD2oYvAxkegtNKDL9bXe+vU29a8xnCQh+UKo=
github.com/babylonlabs-io/babylon v0.9.3-0.20240904123958-b1e255a85e76 h1:JOdd2H+bOYPyKYNyCcjT2lW7H76A4Pbfstk7n/Vo2Vc=
github.com/babylonlabs-io/babylon v0.9.3-0.20240904123958-b1e255a85e76/go.mod h1:9VUUAwVaalXiDdPZT65SPoawKWpp6ple6tBr8Vw0NI8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down
2 changes: 1 addition & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/babylonlabs-io/vigilante/tools

go 1.23

require github.com/babylonlabs-io/babylon v0.9.1
require github.com/babylonlabs-io/babylon v0.9.3-0.20240904123958-b1e255a85e76

require (
cloud.google.com/go v0.112.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,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.9.1 h1:V7PtWgUAQa0kxFOwOuGvh0rKXyqiY6JheTZdfyeEkBk=
github.com/babylonlabs-io/babylon v0.9.1/go.mod h1:t7B4e+ooD2oYvAxkegtNKDL9bXe+vU29a8xnCQh+UKo=
github.com/babylonlabs-io/babylon v0.9.3-0.20240904123958-b1e255a85e76 h1:JOdd2H+bOYPyKYNyCcjT2lW7H76A4Pbfstk7n/Vo2Vc=
github.com/babylonlabs-io/babylon v0.9.3-0.20240904123958-b1e255a85e76/go.mod h1:9VUUAwVaalXiDdPZT65SPoawKWpp6ple6tBr8Vw0NI8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down

0 comments on commit cb9b079

Please sign in to comment.