From 010e9d91c81e6cce240923ab67fa5d0c073e70fe Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 10:07:44 -0400 Subject: [PATCH 01/11] nit --- deployments/finality-gadget-integration-op-l2/.env.example | 2 +- .../finality-gadget-integration-op-l2/init-babylon-accounts.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/deployments/finality-gadget-integration-op-l2/.env.example b/deployments/finality-gadget-integration-op-l2/.env.example index 27d3dda6..5e0199b0 100755 --- a/deployments/finality-gadget-integration-op-l2/.env.example +++ b/deployments/finality-gadget-integration-op-l2/.env.example @@ -8,7 +8,7 @@ SLASHING_PK_SCRIPT=76a914010101010101010101010101010101010101010188ab ### Babylon BABYLON_HOME_DIR=/babylondhome -TEST_SPENDING_KEY_NAME=test-spending-key +TEST_SPENDING_KEY_NAME=test-spending-key # this is hardcoded in the babylon repo BABYLON_CHAIN_ID=chain-test ### CW contract diff --git a/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh b/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh index da623fd1..dbeae80f 100755 --- a/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh +++ b/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh @@ -77,6 +77,7 @@ function init_babylon_account() { # If account not yet funded, fund it if [ "$account_balance" = "null" ] || [ -z "$account_balance" ]; then echo "account not yet funded, funding it" + # TODO: we cannot do this when running against Euphrates. local fund_tx_hash=$(docker exec babylondnode0 /bin/sh -c " /bin/babylond tx bank send \ $TEST_SPENDING_KEY_NAME \ From df2a55cd33f5946ab87d2c45042ecc7305dbeed0 Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 10:17:47 -0400 Subject: [PATCH 02/11] nit --- .../finality-gadget-integration-op-l2/artifacts/vigilante.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/finality-gadget-integration-op-l2/artifacts/vigilante.yml b/deployments/finality-gadget-integration-op-l2/artifacts/vigilante.yml index 4c553ecf..01ccab10 100644 --- a/deployments/finality-gadget-integration-op-l2/artifacts/vigilante.yml +++ b/deployments/finality-gadget-integration-op-l2/artifacts/vigilante.yml @@ -73,7 +73,7 @@ monitor: checkpoint-buffer-size: 1000 btc-block-buffer-size: 1000 btc-cache-size: 2018 - btc-confirmation-depth: 6 + btc-confirmation-depth: 6 # it cannot be less than 6 liveness-check-interval-seconds: 100 max-live-btc-heights: 200 enable-liveness-checker: true From dc1e4ce6aadf5afc9d1364a8b0d7d47e67ab59e1 Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 10:20:36 -0400 Subject: [PATCH 03/11] nit --- deployments/finality-gadget-integration-op-l2/README.md | 1 + .../finality-gadget-integration-op-l2/init-testnets-dir.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/deployments/finality-gadget-integration-op-l2/README.md b/deployments/finality-gadget-integration-op-l2/README.md index 71e95b72..f9443066 100644 --- a/deployments/finality-gadget-integration-op-l2/README.md +++ b/deployments/finality-gadget-integration-op-l2/README.md @@ -158,6 +158,7 @@ make stop-deployment-finality-gadget-integration-op-l2 1. `BASE_HEADER_HEIGHT`, initialization for the babylon network, it should use the latest Bitcoin difficulty adjustment height 2. `btc-cache-size`, in the Vigilante reporter, it should not be less than the Bitcoin difficulty epoch 2016 3. `btc-confirmation-depth`, in the Vigilante moniter, it should not be less than 6 +4. `min-staking-amount-sat`, in the init-babylon-accounts.sh, it should not be less than 10000 (same as Euphrates v0.5.0) diff --git a/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh b/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh index a5e4ef0a..3e3d584f 100755 --- a/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh +++ b/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh @@ -63,6 +63,7 @@ if [ ! -d ".testnets" ]; then # Initialize files for a babylon testnet # `covenant-pks` should be updated if `covenant-keyring` dir is changed` + # TODO: --min-staking-amount-sat and --max-staking-time-blocks can be a ENV variable docker run --rm -v $(pwd)/.testnets:/data babylonlabs/babylond:a98269d178879f22b136760701950d8929cc2093 \ babylond testnet init-files --v 2 -o /data \ --starting-ip-address 192.168.10.2 \ From c6d9250ca8a02d8b9e77ca5c98c81f186ab6dc91 Mon Sep 17 00:00:00 2001 From: lesterli Date: Sat, 19 Oct 2024 03:01:12 +0800 Subject: [PATCH 04/11] feat: check if the FP and consumer already exists (#20) --- .../finality-gadget-integration-op-l2/Makefile | 4 ++-- .../init-babylon-accounts.sh | 1 + .../register-babylon-fp.sh | 14 ++++++++++++++ .../register-op-consumer-fp.sh | 14 ++++++++++++++ .../register-op-consumer.sh | 15 +++++++++++++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/deployments/finality-gadget-integration-op-l2/Makefile b/deployments/finality-gadget-integration-op-l2/Makefile index 8f68a4e0..e8a2de51 100644 --- a/deployments/finality-gadget-integration-op-l2/Makefile +++ b/deployments/finality-gadget-integration-op-l2/Makefile @@ -187,7 +187,7 @@ start-babylon: else \ echo "Unsupported bitcoin network: $(BITCOIN_NETWORK)"; \ fi -.PHONY: start +.PHONY: start-babylon stop-babylon: @$(DOCKER) compose -f artifacts/docker-compose.yml down -v @@ -204,7 +204,7 @@ stop-babylon: else \ echo "Unsupported bitcoin network: $(BITCOIN_NETWORK)"; \ fi -.PHONY: stop +.PHONY: stop-babylon # Run independent steps # TODO: remove these after testing diff --git a/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh b/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh index dbeae80f..cd0cff81 100755 --- a/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh +++ b/deployments/finality-gadget-integration-op-l2/init-babylon-accounts.sh @@ -77,6 +77,7 @@ function init_babylon_account() { # If account not yet funded, fund it if [ "$account_balance" = "null" ] || [ -z "$account_balance" ]; then echo "account not yet funded, funding it" + # TODO: 1000000000ubbn should be configurable # TODO: we cannot do this when running against Euphrates. local fund_tx_hash=$(docker exec babylondnode0 /bin/sh -c " /bin/babylond tx bank send \ diff --git a/deployments/finality-gadget-integration-op-l2/register-babylon-fp.sh b/deployments/finality-gadget-integration-op-l2/register-babylon-fp.sh index c824083d..bec4d531 100755 --- a/deployments/finality-gadget-integration-op-l2/register-babylon-fp.sh +++ b/deployments/finality-gadget-integration-op-l2/register-babylon-fp.sh @@ -1,6 +1,20 @@ #!/bin/bash set -euo pipefail +# check if the Babylon FP already exists +EXISTING_BBN_FP_MONIKER=$(docker exec finality-provider /bin/sh \ + -c "/bin/fpd list-finality-providers" \ + | jq '.finality_providers[0].description.moniker') +EXISTING_BBN_FP_EOTS_PK_HEX=$(docker exec finality-provider /bin/sh \ + -c "/bin/fpd list-finality-providers" \ + | jq -r '.finality_providers[0].btc_pk_hex') +if [ "$EXISTING_BBN_FP_MONIKER" == "$BBN_FP_MONIKER" ]; then + echo "Babylon finality provider already exists with \ +moniker: $EXISTING_BBN_FP_MONIKER and \ +EOTS PK: $EXISTING_BBN_FP_EOTS_PK_HEX" + exit 0 +fi + # create FP for Babylon echo "Creating Babylon finality provider..." BBN_FP_EOTS_PK_HEX=$(docker exec finality-provider /bin/sh -c " diff --git a/deployments/finality-gadget-integration-op-l2/register-op-consumer-fp.sh b/deployments/finality-gadget-integration-op-l2/register-op-consumer-fp.sh index 7b3a15e7..3def93eb 100755 --- a/deployments/finality-gadget-integration-op-l2/register-op-consumer-fp.sh +++ b/deployments/finality-gadget-integration-op-l2/register-op-consumer-fp.sh @@ -1,6 +1,20 @@ #!/bin/bash set -euo pipefail +# check if the OP consumer FP already exists +EXISTING_OP_FP_MONIKER=$(docker exec consumer-finality-provider /bin/sh \ + -c "/bin/fpd list-finality-providers" \ + | jq '.finality_providers[0].description.moniker') +EXISTING_OP_FP_EOTS_PK_HEX=$(docker exec consumer-finality-provider /bin/sh \ + -c "/bin/fpd list-finality-providers" \ + | jq -r '.finality_providers[0].btc_pk_hex') +if [ "$EXISTING_OP_FP_MONIKER" == "$OP_FP_MONIKER" ]; then + echo "OP consumer finality provider already exists with \ +moniker: $EXISTING_OP_FP_MONIKER and \ +EOTS PK: $EXISTING_OP_FP_EOTS_PK_HEX" + exit 0 +fi + # create FP for the consumer chain echo "Creating OP consumer finality provider..." OP_FP_EOTS_PK_HEX=$(docker exec consumer-finality-provider /bin/sh -c " diff --git a/deployments/finality-gadget-integration-op-l2/register-op-consumer.sh b/deployments/finality-gadget-integration-op-l2/register-op-consumer.sh index 84cecae7..55d1b90e 100755 --- a/deployments/finality-gadget-integration-op-l2/register-op-consumer.sh +++ b/deployments/finality-gadget-integration-op-l2/register-op-consumer.sh @@ -1,6 +1,21 @@ #!/bin/bash set -euo pipefail +# Get all registered consumer IDs and store them in an array +# TODO: this adds another coupling between our system and the Babylon chain. +# we should use RPC calls +CONSUMER_IDS=($(docker exec babylondnode0 /bin/sh -c " + /bin/babylond query btcstkconsumer registered-consumers \ + --home $BABYLON_HOME_DIR \ + --chain-id $BABYLON_CHAIN_ID \ + -o json" | jq -r '.consumer_ids[]')) + +# Check if the OP consumer chain is already registered +if [[ "${CONSUMER_IDS[@]}" =~ "${CONSUMER_ID}" ]]; then + echo "OP consumer chain already registered with ID: $CONSUMER_ID" + exit 0 +fi + # Register op consumer chain echo "Registering OP consumer chain..." REGISTER_TX_HASH=$(docker exec babylondnode0 /bin/sh -c " From 790d4d17a2efb54f6c8cfa71bd20a58cd3af2265 Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 15:42:58 -0400 Subject: [PATCH 05/11] replace `bc` with `awk` - to avoid the need to install `bc` - also get rid of `eq` by using the `(( ))` construct --- .../verify-bitcoin-sync-balance.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh index b5fdec75..2cdb7813 100755 --- a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh +++ b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh @@ -83,9 +83,9 @@ BALANCE_BTC=$(docker exec bitcoindsim /bin/sh -c " -rpcpassword=rpcpass \ -rpcwallet=btcstaker \ listunspent" | jq -r '[.[] | .amount] | add') -if [ $(echo "$BALANCE_BTC < 0.01" | bc -l) -eq 1 ]; then +if (( $(awk 'BEGIN {print ($BALANCE_BTC < 0.01)}') )); then echo "Warning: BTCStaker balance is less than 0.01 BTC. You may need to fund this address for ${BITCOIN_NETWORK}." else echo "BTCStaker balance is sufficient: ${BALANCE_BTC} BTC" fi -echo \ No newline at end of file +echo From 7041171a5a559d59b05cb45f5dcca661e4000a2e Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 15:48:34 -0400 Subject: [PATCH 06/11] more bc -> awk --- .../verify-bitcoin-sync-balance.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh index 2cdb7813..9852010e 100755 --- a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh +++ b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh @@ -21,7 +21,7 @@ SYNCED=$(docker exec bitcoindsim /bin/sh -c " -rpcuser=rpcuser \ -rpcpassword=rpcpass \ getblockchaininfo" | jq -r '.verificationprogress') -if [ $(echo "$SYNCED < 0.999" | bc -l) -eq 1 ]; then +if (( $(awk 'BEGIN {print ($SYNCED < 0.999)}') )); then echo "Error: Bitcoin node is not fully synced. Expected at least 99.9%, got ${SYNCED}" exit 1 fi From 4c28ce5a8191f103cf7f8b885092098a9e59c89e Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 17:42:06 -0400 Subject: [PATCH 07/11] default btc network should be signet --- deployments/finality-gadget-integration-op-l2/.env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/finality-gadget-integration-op-l2/.env.example b/deployments/finality-gadget-integration-op-l2/.env.example index 5e0199b0..adab3e0e 100755 --- a/deployments/finality-gadget-integration-op-l2/.env.example +++ b/deployments/finality-gadget-integration-op-l2/.env.example @@ -1,5 +1,5 @@ ### Bitcoin -BITCOIN_NETWORK=testnet +BITCOIN_NETWORK=signet BITCOIN_RPC_PORT=18332 WALLET_PASS=walletpass # btcstaker private key in WIF format From 3f7397bfeb1111d0e02fe562665513ec8bd75f1d Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 20:25:58 -0400 Subject: [PATCH 08/11] fix loading .env The current method can cause issues if there are comments or empty lines in the .env file. --- .../verify-bitcoin-sync-balance.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh index 9852010e..afd6bb4f 100755 --- a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh +++ b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh @@ -1,11 +1,10 @@ #!/bin/bash set -euo pipefail -# Load environment variables from .env file -echo "Load environment variables from .env file..." -if [ -f .env ]; then - export $(cat .env | grep -v '^#' | xargs) -fi +# Load environment variables from the .env file +set -a +source $(pwd)/.env +set +a if [ -z "$(echo ${WALLET_PASS})" ] || [ -z "$(echo ${BTCSTAKER_PRIVKEY})" ]; then echo "Error: WALLET_PASS or BTCSTAKER_PRIVKEY environment variable is not set" From 6f6ba4f325cd88fba6abaf2b70fa5550679f795f Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 20:27:04 -0400 Subject: [PATCH 09/11] fix awk usage - The issue was that awk was performing the comparison with limited precision, which could lead to incorrect results with very small differences. - This modification passes the $SYNCED value to awk as a variable, which avoids potential issues with shell variable expansion inside the awk command. It should correctly handle the floating-point comparison. --- .../verify-bitcoin-sync-balance.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh index afd6bb4f..6eb5accf 100755 --- a/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh +++ b/deployments/finality-gadget-integration-op-l2/verify-bitcoin-sync-balance.sh @@ -20,7 +20,7 @@ SYNCED=$(docker exec bitcoindsim /bin/sh -c " -rpcuser=rpcuser \ -rpcpassword=rpcpass \ getblockchaininfo" | jq -r '.verificationprogress') -if (( $(awk 'BEGIN {print ($SYNCED < 0.999)}') )); then +if (( $(awk -v synced="$SYNCED" 'BEGIN {print (synced < 0.999)}') )); then echo "Error: Bitcoin node is not fully synced. Expected at least 99.9%, got ${SYNCED}" exit 1 fi @@ -82,7 +82,7 @@ BALANCE_BTC=$(docker exec bitcoindsim /bin/sh -c " -rpcpassword=rpcpass \ -rpcwallet=btcstaker \ listunspent" | jq -r '[.[] | .amount] | add') -if (( $(awk 'BEGIN {print ($BALANCE_BTC < 0.01)}') )); then +if (( $(awk -v balance="$BALANCE_BTC" 'BEGIN {print (balance < 0.01)}') )); then echo "Warning: BTCStaker balance is less than 0.01 BTC. You may need to fund this address for ${BITCOIN_NETWORK}." else echo "BTCStaker balance is sufficient: ${BALANCE_BTC} BTC" From 9875ff37c4072e3c5ae85052cf7d381cd50a6968 Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 18 Oct 2024 20:34:00 -0400 Subject: [PATCH 10/11] fix: load .env properly --- .../create-btc-delegations.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/deployments/finality-gadget-integration-op-l2/create-btc-delegations.sh b/deployments/finality-gadget-integration-op-l2/create-btc-delegations.sh index 384cdb1d..d5d0d9d8 100755 --- a/deployments/finality-gadget-integration-op-l2/create-btc-delegations.sh +++ b/deployments/finality-gadget-integration-op-l2/create-btc-delegations.sh @@ -2,10 +2,9 @@ set -euo pipefail # For signet, load environment variables from .env file -echo "Load environment variables from .env file..." -if [ -f .env ]; then - export $(cat .env | grep -v '^#' | xargs) -fi +set -a +source $(pwd)/.env +set +a if [ -z "$(echo ${CONSUMER_ID})" ]; then echo "Error: CONSUMER_ID environment variable is not set" From da9679374a8aabf7bec21be5a76e5210f75d6b4d Mon Sep 17 00:00:00 2001 From: bap2pecs <111917526+bap2pecs@users.noreply.github.com> Date: Fri, 18 Oct 2024 21:30:22 -0400 Subject: [PATCH 11/11] improve and fix the init-testnets-dir.sh script (#21) --- .../init-testnets-dir.sh | 102 +++++------------- 1 file changed, 24 insertions(+), 78 deletions(-) diff --git a/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh b/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh index 3e3d584f..77b34ffd 100755 --- a/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh +++ b/deployments/finality-gadget-integration-op-l2/init-testnets-dir.sh @@ -6,7 +6,7 @@ if [ ! -d ".testnets" ]; then # Create new directory that will hold node and services' configuration mkdir -p .testnets && chmod -R 777 .testnets - if [[ -z "$BITCOIN_NETWORK" || "$BITCOIN_NETWORK" == "regtest" ]]; then + if [[ "$BITCOIN_NETWORK" == "regtest" ]]; then FINALIZATION_TIMEOUT=2 CONFIRMATION_DEPTH=1 BASE_HEADER=0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000 @@ -32,28 +32,6 @@ if [ ! -d ".testnets" ]; then exit 1 fi - echo "Base header: $BASE_HEADER" - elif [[ "$BITCOIN_NETWORK" == "testnet" ]]; then - FINALIZATION_TIMEOUT=20 - CONFIRMATION_DEPTH=1 - # Get the next target difficulty adjustment height - NEXT_RETARGET_HEIGHT=$(curl -sSL "https://mempool.space/testnet/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/testnet/api/block-height/$BASE_HEADER_HEIGHT") - BASE_HEADER=$(curl -sSL "https://mempool.space/testnet/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" @@ -68,7 +46,7 @@ if [ ! -d ".testnets" ]; then babylond testnet init-files --v 2 -o /data \ --starting-ip-address 192.168.10.2 \ --keyring-backend=test \ - --chain-id chain-test \ + --chain-id $BABYLON_CHAIN_ID \ --epoch-interval 10 \ --btc-finalization-timeout $FINALIZATION_TIMEOUT \ --btc-confirmation-depth $CONFIRMATION_DEPTH \ @@ -88,6 +66,10 @@ if [ ! -d ".testnets" ]; then sudo chown -R $(whoami):$(whoami) .testnets sudo chmod -R 777 .testnets + # TODO: we need to decouple the babylon system and our finality system. + # only put the configs that are needed for the babylon system in the .testnets dir + # and for the finality gadget system in a separate dir. + # it might also make sense to split this script into two. # Create separate subpaths for each component and copy relevant configuration mkdir -p .testnets/vigilante/bbnconfig mkdir -p .testnets/btc-staker @@ -102,73 +84,36 @@ if [ ! -d ".testnets" ]; then # for btc-staker, replace placeholders with env variables cp artifacts/stakerd.conf .testnets/btc-staker/stakerd.conf - if [[ "$(uname)" == "Darwin" ]]; then - # macOS version - sed -i '' "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/btc-staker/stakerd.conf - sed -i '' "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/btc-staker/stakerd.conf - sed -i '' "s|\${WALLET_PASS}|$WALLET_PASS|g" .testnets/btc-staker/stakerd.conf - sed -i '' "s|\${BABYLON_CHAIN_ID}|$BABYLON_CHAIN_ID|g" .testnets/btc-staker/stakerd.conf - else - # Linux version - sed -i "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/btc-staker/stakerd.conf - sed -i "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/btc-staker/stakerd.conf - sed -i "s|\${WALLET_PASS}|$WALLET_PASS|g" .testnets/btc-staker/stakerd.conf - sed -i "s|\${BABYLON_CHAIN_ID}|$BABYLON_CHAIN_ID|g" .testnets/btc-staker/stakerd.conf - fi + sed -i.bak "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/btc-staker/stakerd.conf + sed -i.bak "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/btc-staker/stakerd.conf + sed -i.bak "s|\${WALLET_PASS}|$WALLET_PASS|g" .testnets/btc-staker/stakerd.conf + sed -i.bak "s|\${BABYLON_CHAIN_ID}|$BABYLON_CHAIN_ID|g" .testnets/btc-staker/stakerd.conf + rm .testnets/btc-staker/stakerd.conf.bak # for vigilante, replace placeholders with env variables cp artifacts/vigilante.yml .testnets/vigilante/vigilante.yml - if [[ "$(uname)" == "Darwin" ]]; then - # macOS version - sed -i '' "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/vigilante/vigilante.yml - sed -i '' "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/vigilante/vigilante.yml - sed -i '' "s|\${WALLET_PASS}|$WALLET_PASS|g" .testnets/vigilante/vigilante.yml - else - # Linux version - sed -i "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/vigilante/vigilante.yml - sed -i "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/vigilante/vigilante.yml - sed -i "s|\${WALLET_PASS}|$WALLET_PASS|g" .testnets/vigilante/vigilante.yml - fi - # copy genesis file to vigilante config directory - cp .testnets/node0/babylond/config/genesis.json .testnets/vigilante/bbnconfig/genesis.json + sed -i.bak "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/vigilante/vigilante.yml + sed -i.bak "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/vigilante/vigilante.yml + sed -i.bak "s|\${WALLET_PASS}|$WALLET_PASS|g" .testnets/vigilante/vigilante.yml + rm .testnets/vigilante/vigilante.yml.bak cp artifacts/eotsd.conf .testnets/eotsmanager/eotsd.conf cp artifacts/fpd.conf .testnets/finality-provider/fpd.conf - if [[ "$(uname)" == "Darwin" ]]; then - # macOS version - sed -i '' "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/finality-provider/fpd.conf - else - # Linux version - sed -i "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/finality-provider/fpd.conf - fi + sed -i.bak "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/finality-provider/fpd.conf + rm .testnets/finality-provider/fpd.conf.bak cp artifacts/opfgd.toml .testnets/finality-gadget/opfgd.toml - if [[ "$(uname)" == "Darwin" ]]; then - # macOS version - sed -i '' "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/finality-gadget/opfgd.toml - else - # Linux version - sed -i "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/finality-gadget/opfgd.toml - fi + sed -i.bak "s|\${BITCOIN_RPC_PORT}|$BITCOIN_RPC_PORT|g" .testnets/finality-gadget/opfgd.toml + rm .testnets/finality-gadget/opfgd.toml.bak cp artifacts/consumer-eotsd.conf .testnets/consumer-eotsmanager/eotsd.conf cp artifacts/consumer-fpd.conf .testnets/consumer-finality-provider/fpd.conf - if [[ "$(uname)" == "Darwin" ]]; then - # macOS version - sed -i '' "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/consumer-finality-provider/fpd.conf - else - # Linux version - sed -i "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/consumer-finality-provider/fpd.conf - fi + sed -i.bak "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/consumer-finality-provider/fpd.conf + rm .testnets/consumer-finality-provider/fpd.conf.bak cp artifacts/covd.conf .testnets/covenant-emulator/covd.conf - if [[ "$(uname)" == "Darwin" ]]; then - # macOS version - sed -i '' "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/covenant-emulator/covd.conf - else - # Linux version - sed -i "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/covenant-emulator/covd.conf - fi + sed -i.bak "s|\${BITCOIN_NETWORK}|$BITCOIN_NETWORK|g" .testnets/covenant-emulator/covd.conf + rm .testnets/covenant-emulator/covd.conf.bak cp -R artifacts/covenant-keyring .testnets/covenant-emulator/keyring-test cp .testnets/covenant-emulator/keyring-test/* .testnets/node0/babylond/covenant-emulator/keyring-test/ @@ -178,6 +123,7 @@ if [ ! -d ".testnets" ]; then echo fi +# Only run if .bitcoin directory does not exist if [ ! -d ".bitcoin" ]; then echo "Creating .bitcoin directory..." mkdir -p .bitcoin && chmod -R 777 .bitcoin