Skip to content

Commit

Permalink
feat: 6-node topology with three miners and three stacker/signer foll…
Browse files Browse the repository at this point in the history
…owers (one signer per stacker)
  • Loading branch information
jcnelson committed Aug 20, 2024
1 parent 845139f commit 2494104
Show file tree
Hide file tree
Showing 18 changed files with 303 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source "config.sh"

_CONF_BITCOIN_P2P_PORT=18332
_CONF_BITCOIN_RPC_PORT=18333
_CONF_BITCOIN_DATA_DIR="$_CONF_BASEDIR/bitcoin/bitcoin-0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source "config.sh"

_CONF_BITCOIN_P2P_PORT=19332
_CONF_BITCOIN_RPC_PORT=19333
_CONF_BITCOIN_DATA_DIR="$_CONF_BASEDIR/bitcoin/bitcoin-1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source "config.sh"

_CONF_BITCOIN_P2P_PORT=20332
_CONF_BITCOIN_RPC_PORT=20333
_CONF_BITCOIN_DATA_DIR="$_CONF_BASEDIR/bitcoin/bitcoin-2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source "config.sh"

_CONF_BITCOIN_P2P_PORT=21332
_CONF_BITCOIN_RPC_PORT=21333
_CONF_BITCOIN_DATA_DIR="$_CONF_BASEDIR/bitcoin/bitcoin-3"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source "config.sh"

_CONF_BITCOIN_P2P_PORT=22332
_CONF_BITCOIN_RPC_PORT=22333
_CONF_BITCOIN_DATA_DIR="$_CONF_BASEDIR/bitcoin/bitcoin-4"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source "config.sh"

_CONF_BITCOIN_P2P_PORT=23332
_CONF_BITCOIN_RPC_PORT=23333
_CONF_BITCOIN_DATA_DIR="$_CONF_BASEDIR/bitcoin/bitcoin-5"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

source "./config.sh"
source "./config-bitcoind-3.sh"

_CONF_STACKS_HOST=127.0.0.1
_CONF_STACKS_P2P_PORT=21444
_CONF_STACKS_RPC_PORT=21443
_CONF_STACKS_MINER="false"
_CONF_STACKS_PEER_KEY="57df5414f7da91f3a00c3c2bf97e5608ad5cfcfcf8bec5ed1e038eb98dd99cf5"
_CONF_STACKS_MINER_KEY="3fdb6212eeb39b64e25766f55002a83549582896297aff683c3e4edfb1bd4304"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

source "./config.sh"
source "./config-bitcoind-4.sh"

_CONF_STACKS_HOST=127.0.0.1
_CONF_STACKS_P2P_PORT=31444
_CONF_STACKS_RPC_PORT=31443
_CONF_STACKS_MINER="false"
_CONF_STACKS_PEER_KEY="1f0e168191aa40c7c21f964ed23361d68808591c3fe0fc2c2e04fae6da48967a"
_CONF_STACKS_MINER_KEY="2fcbaaaeea475e5fab52cd55c9f534c9f061fe9c07633dc24c0b8278240f28d5"

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

source "./config.sh"
source "./config-bitcoind-5.sh"

_CONF_STACKS_HOST=127.0.0.1
_CONF_STACKS_P2P_PORT=41444
_CONF_STACKS_RPC_PORT=41443
_CONF_STACKS_MINER="false"
_CONF_STACKS_PEER_KEY="d58d5144f8800c545f4a9531f1b24812ad2cfef5e655d3a280db628cfffd766e"
_CONF_STACKS_MINER_KEY="b6f6a6e4c4d96ecc2592775366c130735bb612f273becfc4e7eba434e0ca6708"

11 changes: 11 additions & 0 deletions playbooks/three-miners-three-signing-followers/config-miner-0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

source "./config.sh"
source "./config-bitcoind-0.sh"

_CONF_STACKS_HOST=127.0.0.1
_CONF_STACKS_P2P_PORT=20444
_CONF_STACKS_RPC_PORT=20443
_CONF_STACKS_MINER="true"
_CONF_STACKS_PEER_KEY="6c6620b925a9fe5162a007e86e5d8be66fda66442ed27c89419fa620faf0bb00"
_CONF_STACKS_MINER_KEY="7933b1e99bab1067d7c6c5c243bdc5a60857bb9e8800ff119ca4695f6e50e8c0"
12 changes: 12 additions & 0 deletions playbooks/three-miners-three-signing-followers/config-miner-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

source "./config.sh"
source "./config-bitcoind-1.sh"

_CONF_STACKS_HOST=127.0.0.1
_CONF_STACKS_P2P_PORT=30444
_CONF_STACKS_RPC_PORT=30443
_CONF_STACKS_MINER="true"
_CONF_STACKS_PEER_KEY="d069b6fd98b8954e64580cb4de8514e757b94a9b38ef6443a6aace483bc60ee9"
_CONF_STACKS_MINER_KEY="f0a9735da1eae5e57c540844173ca91ef3125c5c6e1605a6de6a65dbcce9cf3e01"

12 changes: 12 additions & 0 deletions playbooks/three-miners-three-signing-followers/config-miner-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

source "./config.sh"
source "./config-bitcoind-2.sh"

_CONF_STACKS_HOST=127.0.0.1
_CONF_STACKS_P2P_PORT=40444
_CONF_STACKS_RPC_PORT=40443
_CONF_STACKS_MINER="true"
_CONF_STACKS_PEER_KEY="af9acdcda1b76ba4ed313ef91dc0f19724770893060ebc73486e7c131a80ab00"
_CONF_STACKS_MINER_KEY="cc9a3341c77d3e1c5d4ffbc85c181a032981fd80f0de19f3f43eff62507a394a"

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

source "./config.sh"

# overrides
_CONF_STACKS_RPC_PORT=21443
_CONF_STACKS_SIGNER_KEY="7036b29cb5e235e5fd9b09ae3e8eec4404e44906814d5d01cbca968a60ed4bfb01"
_CONF_STACKS_SIGNER_PORT="30000"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

source "./config.sh"

# overrides
_CONF_STACKS_RPC_PORT=31443
_CONF_STACKS_SIGNER_KEY="b463f0df6c05d2f156393eee73f8016c5372caa0e9e29a901bb7171d90dc4f1401"
_CONF_STACKS_SIGNER_PORT="30001"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

source "./config.sh"

# overrides
_CONF_STACKS_RPC_PORT=41443
_CONF_STACKS_SIGNER_KEY="6a1a754ba863d7bab14adbbc3f8ebb090af9e871ace621d3e5ab634e1422885e01"
_CONF_STACKS_SIGNER_PORT="30002"
9 changes: 9 additions & 0 deletions playbooks/three-miners-three-signing-followers/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

source "../../config.sh"

# overrides
conf_set_basedir "/tmp/three-miners-three-signing-followers"

_CONF_BITCOIN_HOST="127.0.0.1"
_CONF_SEED_NODE_HOST="127.0.0.1"
19 changes: 19 additions & 0 deletions playbooks/three-miners-three-signing-followers/shutdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

naka3="../../naka3.sh"

"$naka3" -c "./config-miner-0.sh" node 0 stop
"$naka3" -c "./config-miner-1.sh" node 1 stop
"$naka3" -c "./config-miner-2.sh" node 2 stop
"$naka3" -c "./config-follower-0.sh" node 3 stop
"$naka3" -c "./config-follower-1.sh" node 4 stop
"$naka3" -c "./config-follower-2.sh" node 5 stop
"$naka3" -c "./config-signer-0.sh" signer 0 stop
"$naka3" -c "./config-signer-1.sh" signer 1 stop
"$naka3" -c "./config-signer-2.sh" signer 2 stop
"$naka3" -c "./config-bitcoind-0.sh" bitcoind stop
"$naka3" -c "./config-bitcoind-1.sh" bitcoind stop
"$naka3" -c "./config-bitcoind-2.sh" bitcoind stop
"$naka3" -c "./config-bitcoind-3.sh" bitcoind stop
"$naka3" -c "./config-bitcoind-4.sh" bitcoind stop
"$naka3" -c "./config-bitcoind-5.sh" bitcoind stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#!/bin/bash

# Topology:
#
#
# `bitcoind 0` <-----> `bitcoind 1` <-----> `bitcoind 2` <-----> `bitcoind 3` <-----> `bitcoind 4` <-----> `bitcoind 5`
# | | | | | |
# | | | | | |
# V V V V V V
# `stacks 0` <-----> `stacks 1` <-----> `stacks 2` <-----> `stacks 3` <-----> `stacks 4` <-----> `stacks 5`
# `(miner) ` `(miner) ` `(miner) ` `(follower)` `(follower)` `(follower)`
# ^ ^ ^
# | | |
# | | |
# `signer 0` `signer 1` `signer 2`


set -ueo pipefail

naka3="../../naka3.sh"

rm -rf "/tmp/three-miners-three-signing-followers"

"$naka3" -c "./config-signer-0.sh" signer 0 config
"$naka3" -c "./config-signer-1.sh" signer 1 config
"$naka3" -c "./config-signer-2.sh" signer 2 config

"$naka3" -c "./config-miner-0.sh" node 0 config-miner "none"
"$naka3" -c "./config-miner-1.sh" node 1 config-miner "none"
"$naka3" -c "./config-miner-2.sh" node 2 config-miner "none"
"$naka3" -c "./config-follower-0.sh" node 3 config-follower-stacker 0
"$naka3" -c "./config-follower-1.sh" node 4 config-follower-stacker 1
"$naka3" -c "./config-follower-2.sh" node 5 config-follower-stacker 2

btcaddr_0="$("$naka3" -c "./config-miner-0.sh" node 0 miner-addr | jq -r '.BTC')"
btcaddr_1="$("$naka3" -c "./config-miner-1.sh" node 1 miner-addr | jq -r '.BTC')"
btcaddr_2="$("$naka3" -c "./config-miner-2.sh" node 2 miner-addr | jq -r '.BTC')"

echo "Miner address is $btcaddr_0"
echo "Miner address is $btcaddr_1"
echo "Miner address is $btcaddr_2"

"$naka3" -c "./config-bitcoind-0.sh" bitcoind start
"$naka3" -c "./config-bitcoind-1.sh" bitcoind start
"$naka3" -c "./config-bitcoind-2.sh" bitcoind start
"$naka3" -c "./config-bitcoind-3.sh" bitcoind start
"$naka3" -c "./config-bitcoind-4.sh" bitcoind start
"$naka3" -c "./config-bitcoind-5.sh" bitcoind start

"$naka3" -c "./config-bitcoind-0.sh" bitcoind peer "127.0.0.1" "19332"
"$naka3" -c "./config-bitcoind-0.sh" bitcoind peer "127.0.0.1" "20332"
"$naka3" -c "./config-bitcoind-0.sh" bitcoind peer "127.0.0.1" "21332"
"$naka3" -c "./config-bitcoind-0.sh" bitcoind peer "127.0.0.1" "22332"
"$naka3" -c "./config-bitcoind-0.sh" bitcoind peer "127.0.0.1" "23332"

"$naka3" -c "./config-bitcoind-1.sh" bitcoind peer "127.0.0.1" "18332"
"$naka3" -c "./config-bitcoind-1.sh" bitcoind peer "127.0.0.1" "20332"
"$naka3" -c "./config-bitcoind-1.sh" bitcoind peer "127.0.0.1" "21332"
"$naka3" -c "./config-bitcoind-1.sh" bitcoind peer "127.0.0.1" "22332"
"$naka3" -c "./config-bitcoind-1.sh" bitcoind peer "127.0.0.1" "23332"

"$naka3" -c "./config-bitcoind-2.sh" bitcoind peer "127.0.0.1" "18332"
"$naka3" -c "./config-bitcoind-2.sh" bitcoind peer "127.0.0.1" "19332"
"$naka3" -c "./config-bitcoind-2.sh" bitcoind peer "127.0.0.1" "21332"
"$naka3" -c "./config-bitcoind-2.sh" bitcoind peer "127.0.0.1" "22332"
"$naka3" -c "./config-bitcoind-2.sh" bitcoind peer "127.0.0.1" "23332"

"$naka3" -c "./config-bitcoind-3.sh" bitcoind peer "127.0.0.1" "18332"
"$naka3" -c "./config-bitcoind-3.sh" bitcoind peer "127.0.0.1" "19332"
"$naka3" -c "./config-bitcoind-3.sh" bitcoind peer "127.0.0.1" "20332"
"$naka3" -c "./config-bitcoind-3.sh" bitcoind peer "127.0.0.1" "22332"
"$naka3" -c "./config-bitcoind-3.sh" bitcoind peer "127.0.0.1" "23332"

"$naka3" -c "./config-bitcoind-4.sh" bitcoind peer "127.0.0.1" "18332"
"$naka3" -c "./config-bitcoind-4.sh" bitcoind peer "127.0.0.1" "19332"
"$naka3" -c "./config-bitcoind-4.sh" bitcoind peer "127.0.0.1" "20332"
"$naka3" -c "./config-bitcoind-4.sh" bitcoind peer "127.0.0.1" "21332"
"$naka3" -c "./config-bitcoind-4.sh" bitcoind peer "127.0.0.1" "23332"

"$naka3" -c "./config-bitcoind-5.sh" bitcoind peer "127.0.0.1" "18332"
"$naka3" -c "./config-bitcoind-5.sh" bitcoind peer "127.0.0.1" "19332"
"$naka3" -c "./config-bitcoind-5.sh" bitcoind peer "127.0.0.1" "20332"
"$naka3" -c "./config-bitcoind-5.sh" bitcoind peer "127.0.0.1" "21332"
"$naka3" -c "./config-bitcoind-5.sh" bitcoind peer "127.0.0.1" "22332"

for i in $(seq 0 34); do
"$naka3" -c "./config-bitcoind-0.sh" bitcoind mine 1 "$btcaddr_0"
sleep 0.5s
"$naka3" -c "./config-bitcoind-1.sh" bitcoind mine 1 "$btcaddr_1"
sleep 0.5s
"$naka3" -c "./config-bitcoind-2.sh" bitcoind mine 1 "$btcaddr_2"
sleep 0.5s
done

# at 105 bitcoin blocks

# boot signers
"$naka3" -c "./config-signer-0.sh" signer 0 start
"$naka3" -c "./config-signer-1.sh" signer 1 start
"$naka3" -c "./config-signer-2.sh" signer 2 start

# boot miner nodes
"$naka3" -c "./config-miner-0.sh" node 0 start-miner "none"
"$naka3" -c "./config-miner-1.sh" node 1 start-miner "none"
"$naka3" -c "./config-miner-2.sh" node 2 start-miner "none"

# boot follower nodes
"$naka3" -c "./config-follower-0.sh" node 3 start-follower-stacker 0
"$naka3" -c "./config-follower-1.sh" node 4 start-follower-stacker 1
"$naka3" -c "./config-follower-2.sh" node 5 start-follower-stacker 2

# advance to epoch 2.5 (starts at 108)
for i in $(seq 0 5); do
sleep 10
"$naka3" -c "./config-bitcoind-0.sh" bitcoind mine 1 "$btcaddr_0"
done

echo "stack stackity stack-stack-stack"
for i in $(seq 0 2); do
tx="$("$naka3" -c "./config-signer-$i.sh" signer "$i" stack-tx 5 9000000000000000 0 1)"
"$naka3" -c "./config-miner-0.sh" node 0 send-tx "$tx"
done

# mine through Nakamoto activation
for i in $(seq 0 20); do
"$naka3" -c "./config-bitcoind-0.sh" bitcoind mine 1 "$btcaddr_0"
sleep 15s
done

while true; do
"$naka3" -c "./config-bitcoind-0.sh" bitcoind mine 1 "$btcaddr_0"
sleep 30s

"$naka3" -c "./config-bitcoind-0.sh" bitcoind mine 1 "$btcaddr_0"
sleep 30s

"$naka3" -c "./config-bitcoind-0.sh" bitcoind mine 1 "$btcaddr_0"
sleep 30s
done

0 comments on commit 2494104

Please sign in to comment.