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

open source #9

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 14 additions & 14 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ url = [email protected]:babylonlabs-io/babylon-contract.git
[submodule "covenant-emulator"]
path = covenant-emulator
url = [email protected]:babylonlabs-io/covenant-emulator.git
[submodule "babylon-private"]
path = babylon-private
url = [email protected]:babylonlabs-io/babylon-private.git
[submodule "babylon"]
path = babylon
url = [email protected]:babylonlabs-io/babylon.git
branch = base/consumer-chain-support
[submodule "vigilante"]
path = vigilante
url = [email protected]:babylonlabs-io/vigilante.git
[submodule "finality-provider-phase-3"]
path = finality-provider-phase-3
url = [email protected]:babylonlabs-io/finality-provider.git
[submodule "finality-provider"]
path = finality-provider
url = [email protected]:babylonlabs-io/finality-provider.git
branch = base/consumer-chain-support
[submodule "btc-staker-phase-3"]
path = btc-staker-phase-3
url = [email protected]:babylonlabs-io/btc-staker.git
[submodule "btc-staker"]
path = btc-staker
url = [email protected]:babylonlabs-io/btc-staker.git
branch = base/consumer-chain-support
[submodule "optimism"]
path = optimism
url = [email protected]:babylonlabs-io/optimism.git
branch = feat/babylon-rfc
path = optimism
url = [email protected]:babylonlabs-io/optimism.git
branch = feat/babylon-rfc
[submodule "finality-gadget"]
path = finality-gadget
url = [email protected]:babylonlabs-io/finality-gadget.git
path = finality-gadget
url = [email protected]:babylonlabs-io/finality-gadget.git
1 change: 1 addition & 0 deletions babylon
Submodule babylon added at a6f728
1 change: 0 additions & 1 deletion babylon-private
Submodule babylon-private deleted from 74a24c
1 change: 1 addition & 0 deletions btc-staker
Submodule btc-staker added at 9bbf30
1 change: 0 additions & 1 deletion btc-staker-phase-3
Submodule btc-staker-phase-3 deleted from 7dd864
35 changes: 0 additions & 35 deletions contrib/images/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +0,0 @@
ifeq ($(BITCOIN_CORE_VERSION),)
BITCOINDSIM_TAG := latest
else
BITCOINDSIM_BUILD_ARG := --build-arg BITCOIN_CORE_VERSION=$(BITCOIN_CORE_VERSION)
BITCOINDSIM_TAG := $(BITCOIN_CORE_VERSION)
endif

all: bitcoinsim

bitcoindsim:
docker build --platform "linux/amd64" --tag babylonlabs-io/bitcoindsim:$(BITCOINDSIM_TAG) -f bitcoindsim/Dockerfile \
$(shell git rev-parse --show-toplevel)/contrib/images/bitcoindsim $(BITCOINDSIM_BUILD_ARG)

ibcsim-gaia:
docker build --tag babylonlabs-io/ibcsim-gaia -f ibcsim-gaia/Dockerfile \
$(shell git rev-parse --show-toplevel)/contrib/images/ibcsim-gaia

ibcsim-bcd:
docker build --secret id=sshKey,src=${BBN_PRIV_DEPLOY_KEY} \
--tag babylonlabs-io/ibcsim-bcd -f ibcsim-bcd/Dockerfile \
$(shell git rev-parse --show-toplevel)/contrib/images/ibcsim-bcd

btcdsim-rmi:
docker rmi babylonlabs-io/btcdsim 2>/dev/null; true

bitcoindsim-rmi:
docker rmi babylonlabs-io/bitcoindsim 2>/dev/null; true

ibcsim-gaia-rmi:
docker rmi babylonlabs-io/ibcsim-gaia 2>/dev/null; true

ibcsim-bcd-rmi:
docker rmi babylonlabs-io/ibcsim-bcd 2>/dev/null; true

.PHONY: all btcdsim btcdsim-rmi bitcoindsim bitcoindsim-rmi ibcsim-gaia ibcsim-gaia-rmi ibcsim-bcd ibcsim-bcd-rmi
12 changes: 6 additions & 6 deletions deployments/btc-staking-integration-bitcoind/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ build-ibcsim-bcd:
$(MAKE) BBN_PRIV_DEPLOY_KEY=${BBN_PRIV_DEPLOY_KEY} -C $(GIT_TOPLEVEL)/contrib/images ibcsim-bcd

build-babylond:
$(MAKE) -C $(GIT_TOPLEVEL)/babylon-private/contrib/images babylond
$(MAKE) -C $(GIT_TOPLEVEL)/babylon/contrib/images babylond

build-vigilante:
$(MAKE) -C $(GIT_TOPLEVEL)/vigilante build-docker

build-btc-staker-phase-3:
$(MAKE) -C $(GIT_TOPLEVEL)/btc-staker-phase-3 build-docker
build-btc-staker:
$(MAKE) -C $(GIT_TOPLEVEL)/btc-staker build-docker

build-finality-provider-phase-3:
$(MAKE) -C $(GIT_TOPLEVEL)/finality-provider-phase-3 build-docker
build-finality-provider:
$(MAKE) -C $(GIT_TOPLEVEL)/finality-provider build-docker

build-covenant-emulator:
$(MAKE) -C $(GIT_TOPLEVEL)/covenant-emulator build-docker

build-deployment-btc-staking-integration-bitcoind: build-babylond build-bitcoindsim build-vigilante build-btc-staker-phase-3 build-finality-provider-phase-3 build-covenant-emulator build-ibcsim-bcd
build-deployment-btc-staking-integration-bitcoind: build-babylond build-bitcoindsim build-vigilante build-btc-staker build-finality-provider build-covenant-emulator build-ibcsim-bcd

start-deployment-btc-staking-integration-bitcoind: stop-deployment-btc-staking-integration-bitcoind build-deployment-btc-staking-integration-bitcoind
./pre-deployment.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ RpcListener = 127.0.0.1:12581
; The maximum number of finality-provider instances running concurrently within the daemon
MaxNumFinalityProviders = 10

; The interval between each attempt to update the finality-provider status
SyncFpStatusInterval = 10s

[chainpollerconfig]
; The maximum number of Babylon blocks that can be stored in the buffer
BufferSize = 1000
Expand All @@ -69,7 +72,7 @@ Host = 127.0.0.1
Port = 2112

; The interval of Prometheus metrics updated
UpdateInterval = 1m0s
UpdateInterval = 1m

[dbconfig]
; The directory path in which the database file should be stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ RpcListener = 127.0.0.1:12581
; The maximum number of finality-provider instances running concurrently within the daemon
MaxNumFinalityProviders = 10

; The interval between each attempt to update the finality-provider status
SyncFpStatusInterval = 10s

[chainpollerconfig]
; The maximum number of Babylon blocks that can be stored in the buffer
BufferSize = 1000
Expand All @@ -69,7 +72,7 @@ Host = 127.0.0.1
Port = 2112

; The interval of Prometheus metrics updated
UpdateInterval = 1m0s
UpdateInterval = 1m

[dbconfig]
; The directory path in which the database file should be stored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ common:
log-format: "auto"
log-level: "debug"
btc:
no-client-tls: true # use true for bitcoind as it does not support tls
no-client-tls: true # use true for bitcoind as it does not support tls
ca-file: ~
endpoint: bitcoindsim:18443 # use port 18443 for bitcoind regtest
endpoint: bitcoindsim:18443 # use port 18443 for bitcoind regtest
estimate-mode: CONSERVATIVE # only needed by bitcoind
tx-fee-max: 10000 # maximum tx fee, 10,000sat/kvb
tx-fee-min: 1000 # minimum tx fee, 1,000sat/kvb
Expand Down Expand Up @@ -58,6 +58,13 @@ submitter:
polling-interval-seconds: 60
resend-interval-seconds: 1800
resubmit-fee-multiplier: 2
database-config:
dbpath: /home/vigilante/db
dbfilename: vigilante.db
nofreelistsync: false
autocompact: true
autocompactminage: 1000
dbtimeout: 10s
reporter:
netparams: regtest
btc_cache_size: 1000
Expand All @@ -72,10 +79,18 @@ monitor:
enable-liveness-checker: true
enable-slasher: true
btcnetparams: regtest
database-config:
dbpath: /home/vigilante/db
dbfilename: vigilante.db
nofreelistsync: false
autocompact: true
autocompactminage: 1000
dbtimeout: 10s
btcstaking-tracker:
check-delegations-interval: 1m
delegations-batch-size: 100
check-if-delegation-active-interval: 5m
retry-submit-unbonding-interval: 1m
max-jitter-interval: 30s
btcnetparams: regtest
max-slashing-concurrency: 10
10 changes: 10 additions & 0 deletions deployments/btc-staking-integration-bitcoind/post-deployment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash

echo "Installing dependencies"

docker exec babylondnode0 /bin/sh -c '
apt-get install -y make git bash gcc curl jq
'

docker exec ibcsim-bcd /bin/sh -c '
apt-get install -y make git bash gcc curl jq
'

echo "Creating keyrings and sending funds to Babylon Node Consumers"

[[ "$(uname)" == "Linux" ]] && chown -R 1138:1138 .testnets/eotsmanager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ docker run --rm -v $(pwd)/.testnets:/data babylonlabs-io/babylond \
--minimum-gas-prices 0.000006ubbn \
--btc-base-header 0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000 \
--btc-network regtest --additional-sender-account \
--slashing-address "mfcGAzvis9JQAb6avB6WBGiGrgWzLxuGaC" \
--slashing-pk-script "76a914010101010101010101010101010101010101010188ab" \
--slashing-rate 0.1 \
--min-commission-rate 0.05 \
--covenant-quorum 1 \
Expand Down
14 changes: 7 additions & 7 deletions deployments/finality-gadget-integration-op-l2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ build-bitcoindsim:
@$(MAKE) -C $(GIT_TOPLEVEL)/contrib/images bitcoindsim

build-babylond:
@$(MAKE) -C $(GIT_TOPLEVEL)/babylon-private/contrib/images babylond
@$(MAKE) -C $(GIT_TOPLEVEL)/babylon/contrib/images babylond

build-vigilante:
@$(MAKE) -C $(GIT_TOPLEVEL)/vigilante build-docker

build-btc-staker-phase-3:
@$(MAKE) -C $(GIT_TOPLEVEL)/btc-staker-phase-3 build-docker
build-btc-staker:
@$(MAKE) -C $(GIT_TOPLEVEL)/btc-staker build-docker

build-finality-provider-phase-3:
@$(MAKE) -C $(GIT_TOPLEVEL)/finality-provider-phase-3 build-docker
build-finality-provider:
@$(MAKE) -C $(GIT_TOPLEVEL)/finality-provider build-docker

build-covenant-emulator:
@$(MAKE) -C $(GIT_TOPLEVEL)/covenant-emulator build-docker
Expand All @@ -35,8 +35,8 @@ build-cw-contract:
build: build-babylond \
build-bitcoindsim \
build-vigilante \
build-btc-staker-phase-3 \
build-finality-provider-phase-3 \
build-btc-staker \
build-finality-provider \
build-finality-gadget \
build-covenant-emulator \
build-cw-contract
Expand Down
61 changes: 30 additions & 31 deletions deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,41 @@ set -euo pipefail
mkdir -p .testnets && chmod -R 777 .testnets

if [[ -z "$BITCOIN_NETWORK" || "$BITCOIN_NETWORK" == "regtest" ]]; then
FINALIZATION_TIMEOUT=2
CONFIRMATION_DEPTH=1
BASE_HEADER=0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000
BASE_HEADER_HEIGHT=0
FINALIZATION_TIMEOUT=2
CONFIRMATION_DEPTH=1
BASE_HEADER=0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000
BASE_HEADER_HEIGHT=0
elif [[ "$BITCOIN_NETWORK" == "signet" ]]; then
FINALIZATION_TIMEOUT=20
CONFIRMATION_DEPTH=1
# Get the next target difficulty adjustment height
NEXT_RETARGET_HEIGHT=$(curl -sSL "https://mempool.space/signet/api/v1/difficulty-adjustment" | jq -r '.nextRetargetHeight')
echo "Next retarget height: $NEXT_RETARGET_HEIGHT"

# Calculate the previous difficulty adjustment height
# Each 2016-block interval is known as a difficulty epoch
BASE_HEADER_HEIGHT=$((NEXT_RETARGET_HEIGHT - 2016))
echo "Base header height: $BASE_HEADER_HEIGHT"

# Get the base header hash and header
BASE_HEIGHT_HASH=$(curl -sSL "https://mempool.space/signet/api/block-height/$BASE_HEADER_HEIGHT")
BASE_HEADER=$(curl -sSL "https://mempool.space/signet/api/block/$BASE_HEIGHT_HASH/header")
if [ -z "$BASE_HEADER" ]; then
echo "Error: Failed to retrieve base header"
exit 1
fi
echo "Base header: $BASE_HEADER"
FINALIZATION_TIMEOUT=20
CONFIRMATION_DEPTH=1
# Get the next target difficulty adjustment height
NEXT_RETARGET_HEIGHT=$(curl -sSL "https://mempool.space/signet/api/v1/difficulty-adjustment" | jq -r '.nextRetargetHeight')
echo "Next retarget height: $NEXT_RETARGET_HEIGHT"

# Calculate the previous difficulty adjustment height
# Each 2016-block interval is known as a difficulty epoch
BASE_HEADER_HEIGHT=$((NEXT_RETARGET_HEIGHT - 2016))
echo "Base header height: $BASE_HEADER_HEIGHT"

# Get the base header hash and header
BASE_HEIGHT_HASH=$(curl -sSL "https://mempool.space/signet/api/block-height/$BASE_HEADER_HEIGHT")
BASE_HEADER=$(curl -sSL "https://mempool.space/signet/api/block/$BASE_HEIGHT_HASH/header")

if [ -z "$BASE_HEADER" ]; then
echo "Error: Failed to retrieve base header"
exit 1
fi

echo "Base header: $BASE_HEADER"
else
echo "Unsupported bitcoin network: $BITCOIN_NETWORK"
exit 1
echo "Unsupported bitcoin network: $BITCOIN_NETWORK"
exit 1
fi
echo

# Set slashing address if not set
if [[ -z "$SLASHING_ADDRESS" ]]; then
SLASHING_ADDRESS="mfcGAzvis9JQAb6avB6WBGiGrgWzLxuGaC"
SLASHING_ADDRESS="mfcGAzvis9JQAb6avB6WBGiGrgWzLxuGaC"
fi

# Initialize files for a babylon testnet
Expand All @@ -56,7 +56,7 @@ docker run --rm -v $(pwd)/.testnets:/data babylonlabs-io/babylond \
--btc-base-header-height $BASE_HEADER_HEIGHT \
--btc-network $BITCOIN_NETWORK \
--additional-sender-account \
--slashing-address $SLASHING_ADDRESS \
--slashing-pk-script "76a914010101010101010101010101010101010101010188ab" \
--slashing-rate 0.1 \
--min-commission-rate 0.05 \
--covenant-quorum 1 \
Expand Down Expand Up @@ -103,7 +103,6 @@ else
sed -i "s|\${WALLET_PASS}|$WALLET_PASS|g" .testnets/vigilante/vigilante.yml
fi


cp artifacts/eotsd.conf .testnets/eotsmanager/eotsd.conf
cp artifacts/fpd.conf .testnets/finality-provider/fpd.conf
if [[ "$(uname)" == "Darwin" ]]; then
Expand Down Expand Up @@ -148,4 +147,4 @@ echo "Successfully copied configuration files for each component"

chmod -R 777 .testnets
chmod -R 777 .bitcoin
echo
echo
1 change: 1 addition & 0 deletions finality-provider
Submodule finality-provider added at a7fb48
1 change: 0 additions & 1 deletion finality-provider-phase-3
Submodule finality-provider-phase-3 deleted from 464946
2 changes: 1 addition & 1 deletion vigilante
Submodule vigilante updated 98 files
+2 −0 .github/workflows/ci.yml
+11 −10 .github/workflows/publish.yaml
+5 −0 CONTRIBUTING.md
+1 −1 Dockerfile
+8 −4 Makefile
+41 −72 README.md
+5 −0 RELEASE_PROCESS.md
+3 −20 btcclient/client.go
+0 −139 btcclient/client_block_subscriber.go
+83 −44 btcclient/client_wallet.go
+6 −4 btcclient/interface.go
+61 −144 btcclient/notifier.go
+54 −21 btcclient/query.go
+0 −25 btcclient/testutils.go
+2 −1 btcstaking-tracker/atomicslasher/atomic_slasher.go
+5 −0 btcstaking-tracker/atomicslasher/babylon_adapter.go
+17 −4 btcstaking-tracker/btcslasher/bootstrapping_test.go
+44 −26 btcstaking-tracker/btcslasher/slasher.go
+19 −6 btcstaking-tracker/btcslasher/slasher_test.go
+7 −0 btcstaking-tracker/btcslasher/slasher_utils.go
+3 −0 btcstaking-tracker/tracker.go
+4 −14 cmd/vigilante/cmd/btcstaking_tracker.go
+24 −10 cmd/vigilante/cmd/monitor.go
+8 −2 cmd/vigilante/cmd/reporter.go
+8 −1 cmd/vigilante/cmd/submitter.go
+27 −77 config/bitcoin.go
+14 −4 config/btcstaking_tracker.go
+4 −0 config/common.go
+9 −21 config/config.go
+82 −0 config/dbconfig.go
+2 −0 config/monitor.go
+2 −1 config/submitter.go
+11 −14 e2etest/atomicslasher_e2e_test.go
+0 −211 e2etest/babylon_node_handler.go
+21 −10 e2etest/bitcoind_node_setup.go
+8 −3 e2etest/container/config.go
+83 −19 e2etest/container/container.go
+149 −0 e2etest/monitor_e2e_test.go
+32 −4 e2etest/reporter_e2e_test.go
+13 −16 e2etest/slasher_e2e_test.go
+11 −2 e2etest/submitter_e2e_test.go
+89 −27 e2etest/test_manager.go
+273 −33 e2etest/test_manager_btcstaking.go
+3 −4 e2etest/unbondingwatcher_e2e_test.go
+97 −96 go.mod
+187 −208 go.sum
+58 −64 monitor/btcscanner/block_handler.go
+99 −45 monitor/btcscanner/btc_scanner.go
+13 −16 monitor/btcscanner/btc_scanner_test.go
+0 −15 monitor/btcscanner/interface.go
+7 −6 monitor/liveness_checker_test.go
+75 −23 monitor/monitor.go
+45 −27 monitor/query.go
+2 −0 monitor/query_test.go
+130 −0 monitor/store/store.go
+76 −0 monitor/store/store_test.go
+7 −0 proto/.clang-format
+36 −0 proto/Dockerfile
+163 −0 proto/checkpoint.pb.go
+12 −0 proto/checkpoint.proto
+24 −0 proto/gen_protos_docker.sh
+41 −0 proto/protocgen.sh
+43 −117 reporter/block_handler.go
+8 −15 reporter/bootstrapping.go
+0 −76 reporter/reorg_list.go
+24 −7 reporter/reporter.go
+13 −24 reporter/utils.go
+4 −0 reporter/utils_test.go
+62 −0 retrywrap/retry.go
+64 −0 retrywrap/retry_test.go
+0 −1 sample-vigilante.yml
+1 −0 submitter/poller/poller_test.go
+3 −1 submitter/relayer/change_address_test.go
+21 −47 submitter/relayer/estimator.go
+360 −187 submitter/relayer/relayer.go
+116 −0 submitter/relayer/relayer_test.go
+4 −88 submitter/relayer/utils.go
+183 −0 submitter/store/store.go
+40 −0 submitter/store/store_test.go
+22 −7 submitter/submitter.go
+60 −38 testutil/mocks/btcclient.go
+61 −0 testutil/port.go
+26 −0 testutil/store.go
+0 −224 tools/go.mod
+0 −1,785 tools/go.sum
+0 −8 tools/tools.go
+1 −0 types/btccache_test.go
+1 −0 types/ckpt_cache_test.go
+0 −1 types/ckpt_info.go
+1 −0 types/ckpt_segment_test.go
+2 −4 types/epoch_info.go
+4 −0 types/genesis_info.go
+1 −0 types/indexed_block_test.go
+33 −0 types/safeprivatekey.go
+1 −18 types/utils.go
+27 −0 utils/serialize.go
+0 −129 zmq/client.go
+0 −182 zmq/subscribe.go