diff --git a/contrib/seeds/check-seeds.sh b/contrib/seeds/check-seeds.sh --- a/contrib/seeds/check-seeds.sh +++ b/contrib/seeds/check-seeds.sh @@ -7,10 +7,14 @@ MAINNET="main" TESTNET="test" +NETWORK_ABC="abc" +NETWORK_BCHN="bchn" + help_message() { set +x echo "Test that at least some threshold of seed nodes can be connected to." - echo "Usage: $0 " + echo "Usage: $0 " + echo " Where is either '${NETWORK_ABC}' or '${NETWORK_BCHN}'" echo " Where is either '${MAINNET}' or '${TESTNET}'" echo " Where is an integer (0 - 100) representing the percentage of seeds that you expect to be online." set -x @@ -22,7 +26,7 @@ help_message exit 0 ;; - "${MAINNET}"|"${TESTNET}") + "${NETWORK_ABC}"|"${NETWORK_BCHN}") # Fallthrough to get caught by the following appropriate check for the # number of arguments, as this argument appears well formed. ;; @@ -33,8 +37,8 @@ esac fi -if [ "$#" -ne 2 ]; then - echo "Error: Expecting 2 arguments, got $#" +if [ "$#" -ne 3 ]; then + echo "Error: Expecting 3 arguments, got $#" help_message exit 2 fi @@ -42,8 +46,9 @@ TOPLEVEL=$(git rev-parse --show-toplevel) SEEDS_DIR="${TOPLEVEL}"/contrib/seeds -CHAIN="$1" -PERCENT_THRESHOLD="$2" +NETWORK="$1" +CHAIN="$2" +PERCENT_THRESHOLD="$3" if [ "${CHAIN}" = "${MAINNET}" ]; then TEST_SEEDS_ARGS="" elif [ "${CHAIN}" = "${TESTNET}" ]; then @@ -53,12 +58,12 @@ exit 1 fi -SEED_NODES="${SEEDS_DIR}/nodes_${CHAIN}.txt" +SEED_NODES="${SEEDS_DIR}/${NETWORK}/nodes_${CHAIN}.txt" TOTAL=$(wc -l < "${SEED_NODES}") NUM=$("${SEEDS_DIR}"/test-seeds.sh ${TEST_SEEDS_ARGS} < "${SEED_NODES}" | wc -l) PERCENT_NODES_UP=$((NUM * 100 / TOTAL)) -echo "${PERCENT_NODES_UP}% of ${CHAIN}net seeds appear to be online." +echo "${PERCENT_NODES_UP}% of ${NETWORK} ${CHAIN}net seeds appear to be online." if [ "${PERCENT_NODES_UP}" -lt "${PERCENT_THRESHOLD}" ]; then - echo "Error: The number of online ${CHAIN}net seed nodes is below the expected threshold of ${PERCENT_THRESHOLD}%" + echo "Error: The number of online ${NETWORK} ${CHAIN}net seed nodes is below the expected threshold of ${PERCENT_THRESHOLD}%" exit 10 fi diff --git a/contrib/source-control-tools/patch-recipes/update-seeds.sh b/contrib/source-control-tools/patch-recipes/update-seeds.sh --- a/contrib/source-control-tools/patch-recipes/update-seeds.sh +++ b/contrib/source-control-tools/patch-recipes/update-seeds.sh @@ -4,27 +4,53 @@ set -euxo pipefail -: "${SEEDS_MAIN:=seeds_main.txt}" -: "${SEEDS_TEST:=seeds_test.txt}" +# Assumes seeder instances are already running on mainnet and testnet +: "${ABC_SEEDS_MAIN:=seeds_main.txt}" +: "${ABC_SEEDS_TEST:=seeds_test.txt}" +: "${BCHN_SEEDS_MAIN:=seeds_main.txt}" +: "${BCHN_SEEDS_TEST:=seeds_test.txt}" + +# Args should be the network(s) to update. Defaults to all supported networks. +NETWORKS=("$@") +if [ "$#" == 0 ]; then + NETWORKS=("abc" "bchn") +fi + TOPLEVEL=$(git rev-parse --show-toplevel) SEEDS_DIR="${TOPLEVEL}"/contrib/seeds -# Assumes seeder instances are already running on mainnet and testnet -pushd "${SEEDS_DIR}" -./makeseeds.py < "${SEEDS_MAIN}" > nodes_main.txt -git add nodes_main.txt +generate_seeds() { + NETWORK="$1" + SEEDS_MAIN="$2" + SEEDS_TEST="$3" -./makeseeds.py < "${SEEDS_TEST}" > nodes_test.txt -git add nodes_test.txt + ./makeseeds.py < "${SEEDS_MAIN}" > "${NETWORK}"/nodes_main.txt + git add "${NETWORK}"/nodes_main.txt -SEEDS_HEADER="${TOPLEVEL}"/src/chainparamsseeds.h -./generate-seeds.py . > "${SEEDS_HEADER}" -git add "${SEEDS_HEADER}" + ./makeseeds.py < "${SEEDS_TEST}" > "${NETWORK}"/nodes_test.txt + git add "${NETWORK}"/nodes_test.txt + + SEEDS_HEADER="${TOPLEVEL}"/src/networks/"${NETWORK}"/chainparamsseeds.cpp + ./generate-seeds.py "${NETWORK}" > "${SEEDS_HEADER}" + git add "${SEEDS_HEADER}" +} + +pushd "${SEEDS_DIR}" +if [[ " ${NETWORKS[*]} " =~ " abc " ]]; then + generate_seeds abc "${ABC_SEEDS_MAIN}" "${ABC_SEEDS_TEST}" +fi +if [[ " ${NETWORKS[*]} " =~ " bchn " ]]; then + generate_seeds bchn "${BCHN_SEEDS_MAIN}" "${BCHN_SEEDS_TEST}" +fi popd # Check that seeds have good connectivity -"${TOPLEVEL}"/contrib/devtools/build_cmake.sh -RPC_PORT=18832 "${SEEDS_DIR}"/check-seeds.sh main 80 -RPC_PORT=18833 "${SEEDS_DIR}"/check-seeds.sh test 70 +"${TOPLEVEL}"/contrib/devtools/build_cmake.sh bitcoind bitcoin-cli +RPC_PORT=18832 "${SEEDS_DIR}"/check-seeds.sh abc main 80 +RPC_PORT=18833 "${SEEDS_DIR}"/check-seeds.sh abc test 70 + +CMAKE_FLAGS="-DNETWORK_COMPATIBILITY=BCHN" "${TOPLEVEL}"/contrib/devtools/build_cmake.sh bitcoind bitcoin-cli +RPC_PORT=18832 "${SEEDS_DIR}"/check-seeds.sh bchn main 80 +RPC_PORT=18833 "${SEEDS_DIR}"/check-seeds.sh bchn test 70 git commit -m "[Automated] Update seeds" diff --git a/contrib/teamcity/build-configurations.yml b/contrib/teamcity/build-configurations.yml --- a/contrib/teamcity/build-configurations.yml +++ b/contrib/teamcity/build-configurations.yml @@ -415,8 +415,8 @@ # Run on different ports to avoid a race where the rpc port used in the first run # may not be closed in time for the second to start. SEEDS_DIR="${TOPLEVEL}"/contrib/seeds - RPC_PORT=18832 "${SEEDS_DIR}"/check-seeds.sh main 80 - RPC_PORT=18833 "${SEEDS_DIR}"/check-seeds.sh test 70 + RPC_PORT=18832 "${SEEDS_DIR}"/check-seeds.sh abc main 80 + RPC_PORT=18833 "${SEEDS_DIR}"/check-seeds.sh abc test 70 timeout: 600 check-source-control-tools: