From d9cdd367a23aff4d28e2e2fe274394971f2f7c0a Mon Sep 17 00:00:00 2001 From: Lazar Date: Thu, 31 Oct 2024 10:47:20 +0400 Subject: [PATCH] remove vigilante from gomod --- Makefile | 2 +- config/bitcoin.go | 57 ++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 1 - harness/manager.go | 22 ++++++++++++++---- 4 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 config/bitcoin.go diff --git a/Makefile b/Makefile index 86dc7a8..253a689 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ ldflags := $(LDFLAGS) -X github.com/babylonlabs-io/babylon-benchmark/lib/version BUILD_TARGETS := build install -BUILD_FLAGS := --tags "$(build_tags)" --ldflags '$(ldflags)' +BUILD_FLAGS := --tags "$(build_tags)" --ldflags '$(ldflags)' -race build-babylond: $(MAKE) -C $(GIT_TOPLEVEL)/submodules/babylon/contrib/images babylond diff --git a/config/bitcoin.go b/config/bitcoin.go new file mode 100644 index 0000000..604f450 --- /dev/null +++ b/config/bitcoin.go @@ -0,0 +1,57 @@ +package config + +import ( + "github.com/babylonlabs-io/babylon/types" + "github.com/lightningnetwork/lnd/lnwallet/chainfee" +) + +// BTCConfig defines configuration for the Bitcoin client +type BTCConfig struct { + Endpoint string `mapstructure:"endpoint"` + WalletPassword string `mapstructure:"wallet-password"` + WalletName string `mapstructure:"wallet-name"` + WalletLockTime int64 `mapstructure:"wallet-lock-time"` // time duration in which the wallet remains unlocked, in seconds + TxFeeMin chainfee.SatPerKVByte `mapstructure:"tx-fee-min"` // minimum tx fee, sat/kvb + TxFeeMax chainfee.SatPerKVByte `mapstructure:"tx-fee-max"` // maximum tx fee, sat/kvb + DefaultFee chainfee.SatPerKVByte `mapstructure:"default-fee"` // default BTC tx fee in case estimation fails, sat/kvb + EstimateMode string `mapstructure:"estimate-mode"` // the BTC tx fee estimate mode, which is only used by bitcoind, must be either ECONOMICAL or CONSERVATIVE + TargetBlockNum int64 `mapstructure:"target-block-num"` // this implies how soon the tx is estimated to be included in a block, e.g., 1 means the tx is estimated to be included in the next block + NetParams string `mapstructure:"net-params"` + Username string `mapstructure:"username"` + Password string `mapstructure:"password"` + ReconnectAttempts int `mapstructure:"reconnect-attempts"` + ZmqSeqEndpoint string `mapstructure:"zmq-seq-endpoint"` + ZmqBlockEndpoint string `mapstructure:"zmq-block-endpoint"` + ZmqTxEndpoint string `mapstructure:"zmq-tx-endpoint"` +} + +const ( + DefaultRpcBtcNodeHost = "127.0.01:18556" + DefaultBtcNodeRpcUser = "rpcuser" + DefaultBtcNodeRpcPass = "rpcpass" + DefaultBtcNodeEstimateMode = "CONSERVATIVE" + DefaultZmqSeqEndpoint = "tcp://127.0.0.1:28333" + DefaultZmqBlockEndpoint = "tcp://127.0.0.1:29001" + DefaultZmqTxEndpoint = "tcp://127.0.0.1:29002" +) + +func DefaultBTCConfig() BTCConfig { + return BTCConfig{ + Endpoint: DefaultRpcBtcNodeHost, + WalletPassword: "walletpass", + WalletName: "default", + WalletLockTime: 10, + TxFeeMax: chainfee.SatPerKVByte(20 * 1000), // 20,000sat/kvb = 20sat/vbyte + TxFeeMin: chainfee.SatPerKVByte(1 * 1000), // 1,000sat/kvb = 1sat/vbyte + DefaultFee: chainfee.SatPerKVByte(1 * 1000), // 1,000sat/kvb = 1sat/vbyte + EstimateMode: DefaultBtcNodeEstimateMode, + TargetBlockNum: 1, + NetParams: string(types.BtcSimnet), + Username: DefaultBtcNodeRpcUser, + Password: DefaultBtcNodeRpcPass, + ReconnectAttempts: 3, + ZmqSeqEndpoint: DefaultZmqSeqEndpoint, + ZmqBlockEndpoint: DefaultZmqBlockEndpoint, + ZmqTxEndpoint: DefaultZmqTxEndpoint, + } +} diff --git a/go.mod b/go.mod index 9c3492e..cfe3020 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/avast/retry-go/v4 v4.6.0 github.com/babylonlabs-io/babylon v0.14.0 github.com/babylonlabs-io/finality-provider v0.9.1 - github.com/babylonlabs-io/vigilante v0.14.0 github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd/btcec/v2 v2.3.4 github.com/btcsuite/btcd/btcutil v1.1.6 diff --git a/harness/manager.go b/harness/manager.go index 0defccb..cedc15f 100644 --- a/harness/manager.go +++ b/harness/manager.go @@ -11,8 +11,8 @@ import ( "github.com/babylonlabs-io/babylon-benchmark/container" "github.com/babylonlabs-io/babylon-benchmark/lib" bbnclient "github.com/babylonlabs-io/babylon/client/client" + bbncfg "github.com/babylonlabs-io/babylon/client/config" finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" - "github.com/babylonlabs-io/vigilante/config" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcd/btcutil" @@ -40,14 +40,26 @@ const ( chainId = "chain-test" ) -func defaultConfig() *config.Config { - cfg := config.DefaultConfig() +type Config struct { + BTC benchcfg.BTCConfig `mapstructure:"btc"` + Babylon bbncfg.BabylonConfig `mapstructure:"babylon"` +} + +func DefaultConfig() *Config { + return &Config{ + BTC: benchcfg.DefaultBTCConfig(), + Babylon: bbncfg.DefaultBabylonConfig(), + } +} + +func defaultConfig() *Config { + cfg := DefaultConfig() cfg.BTC.NetParams = regtestParams.Name cfg.BTC.Endpoint = "127.0.0.1:18443" cfg.BTC.WalletPassword = "pass" cfg.BTC.Username = "user" cfg.BTC.Password = "pass" - cfg.BTC.ZmqSeqEndpoint = config.DefaultZmqSeqEndpoint + cfg.BTC.ZmqSeqEndpoint = benchcfg.DefaultZmqSeqEndpoint return cfg } @@ -56,7 +68,7 @@ type TestManager struct { TestRpcClient *rpcclient.Client BitcoindHandler *BitcoindTestHandler BabylonClient *bbnclient.Client - Config *config.Config + Config *Config WalletPrivKey *btcec.PrivateKey manger *container.Manager babylonDir string