Skip to content

Commit

Permalink
Merge pull request #21 from LN-Zap/updates
Browse files Browse the repository at this point in the history
Update nodes and improve startup sequence
  • Loading branch information
mrfelton authored Jun 7, 2024
2 parents bc582b1 + 04b166a commit 363bf69
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 29 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ docker compose up

This script sets up a network of nodes and channels for the Lightning Network. The nodes are instances of different Lightning Network implementations, including LND, c-lightning (CLN), and Eclair.

***NOTE: the init script must be run no later than 60 seconds after starting the nodes, otherwise nodes may crash due to an uninitialised blockchain***

### Nodes

The script sets up eight nodes:
Expand Down
56 changes: 31 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "./conf/bitcoind/bitcoin.conf:/data/.bitcoin/bitcoin.conf"

lnd1:
build: ./docker/lnd
image: lightninglabs/lnd:v0.18.0-beta.1
restart: unless-stopped
depends_on:
- bitcoind
Expand All @@ -32,43 +32,45 @@ services:
environment:
- RUST_BACKTRACE=1
volumes:
- "lnd1:/root/.lnd"
- "lndk1:/root/.lndk"
- "lnd1:/root/.lnd:ro"
networks:
testing_net:
ipv4_address: 172.30.1.3

cln1:
image: elementsproject/lightningd:v24.02
image: elementsproject/lightningd:v24.05
restart: unless-stopped
depends_on:
- bitcoind
networks:
testing_net:
ipv4_address: 172.30.1.30
command: --network=regtest --addr=0.0.0.0:9735 --announce-addr=172.30.1.30:9735 --developer --dev-fast-gossip --dev-bitcoind-poll=2 --alias=cln1 --rgb=FF0000
entrypoint: ["/wait-for-bitcoind.sh"]
command: --network=regtest --addr=0.0.0.0:9735 --announce-addr=172.30.1.30:9735 --bitcoin-retry-timeout=180 --developer --dev-fast-gossip --dev-bitcoind-poll=2 --alias=cln1 --rgb=FF0000
volumes:
- "cln1:/root/.lightning"
- "bitcoind:/root/.lightning/bitcoin"
- "bitcoind:/root/.lightning/bitcoin:ro"
- "./conf/cln/config:/root/.lightning/config"
- "./docker/cln/wait-for-bitcoind.sh:/wait-for-bitcoind.sh"

eclair1:
build: ./docker/eclair
image: lnzap/eclair:0.10.0.strike.2
restart: unless-stopped
depends_on:
- bitcoind
networks:
testing_net:
ipv4_address: 172.30.1.31
environment:
- JAVA_OPTS=-Declair.printToConsole -Dakka.loglevel=DEBUG -Dlogback.configurationFile=/data/logback-custom.xml
- JAVA_OPTS=-Declair.printToConsole -Dakka.loglevel=DEBUG -Dlogback.configurationFile=/eclair/logback-custom.xml
volumes:
- "eclair1:/data"
- "./conf/eclair/eclair1.conf:/data/eclair.conf"
- "./conf/eclair/logback-custom.xml:/data/logback-custom.xml"
- "./conf/eclair/eclair1.conf:/eclair/eclair.conf"
- "./conf/eclair/logback-custom.xml:/eclair/logback-custom.xml"

lnd2:
build: ./docker/lnd
image: lightninglabs/lnd:v0.18.0-beta.1
restart: unless-stopped
depends_on:
- bitcoind
Expand All @@ -89,69 +91,73 @@ services:
environment:
- RUST_BACKTRACE=1
volumes:
- "lnd2:/root/.lnd"
- "lndk2:/root/.lndk"
- "lnd2:/root/.lnd:ro"
networks:
testing_net:
ipv4_address: 172.30.2.2

cln2:
image: elementsproject/lightningd:v24.02
image: elementsproject/lightningd:v24.05
restart: unless-stopped
depends_on:
- bitcoind
networks:
testing_net:
ipv4_address: 172.30.2.30
command: --network=regtest --addr=0.0.0.0:9735 --announce-addr=172.30.2.30:9735 --developer --dev-fast-gossip --dev-bitcoind-poll=2 --alias=cln2 --rgb=FF0000
entrypoint: ["/wait-for-bitcoind.sh"]
command: --network=regtest --addr=0.0.0.0:9735 --announce-addr=172.30.2.30:9735 --bitcoin-retry-timeout=180 --developer --dev-fast-gossip --dev-bitcoind-poll=2 --alias=cln2 --rgb=FF0000
volumes:
- "cln2:/root/.lightning"
- "bitcoind:/root/.lightning/bitcoin"
- "bitcoind:/root/.lightning/bitcoin:ro"
- "./conf/cln/config:/root/.lightning/config"
- "./docker/cln/wait-for-bitcoind.sh:/wait-for-bitcoind.sh"

eclair2:
build: ./docker/eclair
image: lnzap/eclair:0.10.0.strike.2
restart: unless-stopped
depends_on:
- bitcoind
networks:
testing_net:
ipv4_address: 172.30.2.31
environment:
- JAVA_OPTS=-Declair.printToConsole -Dakka.loglevel=DEBUG -Dlogback.configurationFile=/data/logback-custom.xml
- JAVA_OPTS=-Declair.printToConsole -Dakka.loglevel=DEBUG -Dlogback.configurationFile=/eclair/logback-custom.xml
volumes:
- "eclair2:/data"
- "./conf/eclair/eclair2.conf:/data/eclair.conf"
- "./conf/eclair/logback-custom.xml:/data/logback-custom.xml"
- "./conf/eclair/eclair2.conf:/eclair/eclair.conf"
- "./conf/eclair/logback-custom.xml:/eclair/logback-custom.xml"

cln3:
image: elementsproject/lightningd:v24.02
image: elementsproject/lightningd:v24.05
restart: unless-stopped
depends_on:
- bitcoind
networks:
testing_net:
ipv4_address: 172.30.3.30
command: --network=regtest --addr=0.0.0.0:9735 --announce-addr=172.30.3.30:9735 --developer --dev-fast-gossip --dev-bitcoind-poll=2 --alias=cln3 --rgb=FF0000
entrypoint: ["/wait-for-bitcoind.sh"]
command: --network=regtest --addr=0.0.0.0:9735 --announce-addr=172.30.3.30:9735 --bitcoin-retry-timeout=180 --developer --dev-fast-gossip --dev-bitcoind-poll=2 --alias=cln3 --rgb=FF0000
volumes:
- "cln3:/root/.lightning"
- "bitcoind:/root/.lightning/bitcoin"
- "bitcoind:/root/.lightning/bitcoin:ro"
- "./conf/cln/config:/root/.lightning/config"
- "./docker/cln/wait-for-bitcoind.sh:/wait-for-bitcoind.sh"

eclair3:
build: ./docker/eclair
image: lnzap/eclair:0.10.0.strike.2
restart: unless-stopped
depends_on:
- bitcoind
networks:
testing_net:
ipv4_address: 172.30.3.31
environment:
- JAVA_OPTS=-Declair.printToConsole -Dakka.loglevel=DEBUG -Dlogback.configurationFile=/data/logback-custom.xml
- JAVA_OPTS=-Declair.printToConsole -Dakka.loglevel=DEBUG -Dlogback.configurationFile=/eclair/logback-custom.xml
volumes:
- "eclair3:/data"
- "./conf/eclair/eclair3.conf:/data/eclair.conf"
- "./conf/eclair/logback-custom.xml:/data/logback-custom.xml"
- "./conf/eclair/eclair3.conf:/eclair/eclair.conf"
- "./conf/eclair/logback-custom.xml:/eclair/logback-custom.xml"

blockgen:
build: ./docker/blockgen
Expand Down
16 changes: 16 additions & 0 deletions docker/cln/wait-for-bitcoind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Function to check if bitcoind is ready
is_bitcoind_ready() {
bitcoin-cli -rpcconnect=bitcoind -rpcport=43782 -rpcuser=user -rpcpassword=pass -conf=/root/.lightning/bitcoin/bitcoin.conf getblockchaininfo &> /dev/null
return $?
}

# Wait for bitcoind to be ready
until is_bitcoind_ready; do
echo "Waiting for bitcoind to be ready..."
sleep 5
done

# Start cln
exec lightningd "$@"
16 changes: 12 additions & 4 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ initBitcoinChain() {
mineBlocks $BITCOIN_ADDRESS 103
}

generateAddresses() {
generateBitcoinAddress() {
BITCOIN_ADDRESS=$(bitcoind getnewaddress)
echo BITCOIN_ADDRESS: $BITCOIN_ADDRESS
}

generateNodeAddresses() {
LND1_ADDRESS=$(lnd1 newaddress p2wkh | jq -r .address)
echo LND1_ADDRESS: $LND1_ADDRESS

Expand Down Expand Up @@ -239,9 +241,13 @@ openChannel() {
mineBlocks $BITCOIN_ADDRESS 10
}

waitForNodes() {

waitBitcoind() {
waitFor bitcoind getnetworkinfo
}


waitForNodes() {
waitFor lnd1 getinfo
waitFor cln1 getinfo
waitFor eclair1 getinfo
Expand All @@ -255,11 +261,13 @@ waitForNodes() {
}

main() {
waitBitcoind
createBitcoindWallet
generateBitcoinAddress
initBitcoinChain
waitForNodes
generateAddresses
generateNodeAddresses
getNodeInfo
initBitcoinChain
fundNodes
openChannel
}
Expand Down

0 comments on commit 363bf69

Please sign in to comment.