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

feat: connext #429

Merged
43 commits merged into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
eae0679
Add Connext support
Apr 14, 2020
a56145f
merge connext config
reliveyy Apr 22, 2020
b372382
Use connext branch for xud
Apr 22, 2020
5ccdb30
dynamic webhookport
Apr 22, 2020
9c35f14
test: shorten simnet channel waiting timeout
reliveyy Apr 23, 2020
7ac7def
fix long-time stopping issue (resolves #430)
reliveyy Apr 23, 2020
9f5af74
fix connext status
reliveyy Apr 23, 2020
b9969ca
test: extend channel waiting timeout to 1000 seconds
reliveyy Apr 23, 2020
323af7e
test: remove raiden assertions
reliveyy Apr 23, 2020
0460288
add defaultchanconfs
reliveyy Apr 24, 2020
a2c3d78
update lnd uris
reliveyy Apr 24, 2020
37e249f
use master branch of xud for xud:latest
Apr 24, 2020
304ff43
fix 7|''
reliveyy Apr 24, 2020
c758542
adjust connext status error text
reliveyy Apr 24, 2020
aca2c21
fix: xud simnet reconnection issue
michael1011 Apr 24, 2020
9f38db4
avoid lnd connecting to itself
reliveyy Apr 24, 2020
80207b0
fix typo: staring -> starting
kilrau Apr 27, 2020
5e8df87
skip simnet test
reliveyy Apr 27, 2020
a7ffbbf
fix: lndbtc port typo 29375 -> 29735, lndltc port typo 30375 -> 30735
kilrau Apr 27, 2020
4067814
fix: more port fixes
kilrau Apr 27, 2020
fe0d4d0
shorten connext and xud status to "starting..."
reliveyy Apr 28, 2020
73eeeae
add newline
reliveyy Apr 28, 2020
43ff289
break loop when "already connected to peer"
reliveyy Apr 28, 2020
4b7eca7
fix: xud1 tor -> clearnet
kilrau Apr 28, 2020
e8717f8
apply create/restore flow for simnet (#441)
kilrau Apr 30, 2020
e245aa6
test: reduce trickledelay (graph update share interval) to 1 second
kilrau Apr 30, 2020
b1cd826
chore: trigger build
kilrau May 2, 2020
42fdf4e
fix: set lndbtc/lndltc chanconfs to 6 since it takes 6 confs to recei…
kilrau May 2, 2020
2593548
Upgrade lndbtc to 0.10.0 (#444)
kilrau May 4, 2020
e58cbb9
temp: use fix/connext-v2 branch for xud:latest
May 7, 2020
3184633
lock connext container down to specific hash
May 7, 2020
fbef775
change connext node and ethprovider ip
May 7, 2020
ad6627b
Revert "temp: use fix/connext-v2 branch for xud:latest"
May 7, 2020
91f5bfa
add python3 to arm64 build for connext
reliveyy May 8, 2020
5bcdf1d
add make g++
reliveyy May 8, 2020
e08c0de
add python
reliveyy May 8, 2020
c749472
add python3 make g++ and python for amd64 connext builder stage
reliveyy May 8, 2020
dda0676
tag connext as 6.3.8
reliveyy May 8, 2020
c08b142
Change Container Running to Waiting for connext
raladev May 11, 2020
90e6cf8
change ConnextProject/ to connext/
reliveyy May 13, 2020
c05c5cb
use connext:latest instead of 6.3.8
May 14, 2020
cac067c
temp: use fix/connext-minor-fixes branch for xud:latest
May 14, 2020
c87f866
Revert "temp: use fix/connext-minor-fixes branch for xud:latest"
May 14, 2020
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
24 changes: 24 additions & 0 deletions images/connext/latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=connext/rest-api-client
ARG BRANCH=master
# Use pure JS implemented secp256k1 bindings
RUN apk add --no-cache git bash python3 make g++ python
# This is a "hack" to automatically invalidate the cache in case there are new commits
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO /connext
# lock connext container down to specific commit hash
WORKDIR /connext
RUN git checkout 0d9bb0f7c0aa76423e65bac27a937a612ad3eabb
RUN npm install
RUN npm run build

FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor curl
RUN mkdir /root/.connext
VOLUME [ "/root/.connext" ]
COPY --from=builder /connext /app
COPY entrypoint.sh /app
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 5040
24 changes: 24 additions & 0 deletions images/connext/latest/Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=connext/rest-api-client
ARG BRANCH=master
# Use pure JS implemented secp256k1 bindings
RUN apk add --no-cache git bash python3 make g++ python
# This is a "hack" to automatically invalidate the cache in case there are new commits
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO /connext
# lock connext container down to specific commit hash
WORKDIR /connext
RUN git checkout 0d9bb0f7c0aa76423e65bac27a937a612ad3eabb
RUN npm install
RUN npm run build

FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor curl
RUN mkdir /root/.connext
VOLUME [ "/root/.connext" ]
COPY --from=builder /connext /app
COPY entrypoint.sh /app
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 5040
3 changes: 3 additions & 0 deletions images/connext/latest/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -m
npm run start
11 changes: 11 additions & 0 deletions images/connext/latest/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[supervisord]
nodaemon=true
logfile=/app/supervisord.log
childlogdir=/app
user=root

[program:connext]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
command=/app/entrypoint.sh
stopsignal=SIGINT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.13-alpine3.10 as builder
RUN apk add --no-cache bash git make gcc musl-dev
ARG VERSION=v0.9.2-beta
ARG VERSION=v0.10.0-beta
RUN wget https://github.com/lightningnetwork/lnd/releases/download/$VERSION/lnd-source-$VERSION.tar.gz
RUN wget https://github.com/lightningnetwork/lnd/releases/download/$VERSION/vendor.tar.gz
RUN mkdir -p $GOPATH/src/github.com/lightningnetwork/lnd
Expand All @@ -26,4 +26,4 @@ COPY --from=builder /go/bin/lnd /go/bin/lncli /usr/local/bin/
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
VOLUME ["/root/.lnd"]
EXPOSE 10009 8080 29375
EXPOSE 10009 10010 8080 29735
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -o errexit # -e
set -o nounset # -u
set -o pipefail
set -o monitor # -m

if [[ $CHAIN != "bitcoin" ]]; then
echo "[entrypoint] Invalid chain: $CHAIN"
Expand All @@ -15,7 +14,7 @@ TOR_DIR=$LND_DIR/tor
TOR_LOG=$LND_DIR/tor.log
TOR_DATA_DIR=$LND_DIR/tor-data
LND_HOSTNAME="$TOR_DIR/hostname"
P2P_PORT=29375
P2P_PORT=29735

[[ -e /etc/tor/torrc ]] || cat <<EOF >/etc/tor/torrc
DataDirectory $TOR_DATA_DIR
Expand All @@ -36,32 +35,42 @@ LND_ADDRESS=$(cat "$LND_HOSTNAME")
echo "[entrypoint] Onion address for lndbtc is $LND_ADDRESS"

function connect() {
local key="02db09dd366d7ba6d061502b5b6db1bbb47c0daacd36fc399ab617fd6406cf822a"
local uri="[email protected]:10012"
local key="0331c98ab6ec199164130cca2b2118a17e7d5e8b53d4e46ddfd4b656a30c636b70"
local uri="[email protected]:29735"
local result
while true; do
echo "[entrypoint] Connecting to $uri"
if lncli -n simnet -c bitcoin connect $uri >/dev/null 2>&1; then
if result=$(lncli -n simnet -c bitcoin connect $uri 2>&1); then
if lncli -n simnet -c bitcoin listpeers | grep -q $key; then
echo "[entrypoint] Connected to $uri"
break
fi
else
if echo "$result" | grep -q "cannot make connection to self"; then
break
fi
if echo "$result" | grep -q "already connected to peer"; then
break
fi
fi
sleep 5
done
}

connect &
#connect &


while ! nc -z 127.0.0.1 9050; do
echo "[entrypoint] Waiting for Tor port 9050 to be open"
sleep 1
done

lnd --externalip=$LND_ADDRESS:$P2P_PORT \
# use exec to properly respond to SIGINT
exec lnd --externalip=$LND_ADDRESS:$P2P_PORT \
--listen=0.0.0.0:$P2P_PORT \
--rpclisten=0.0.0.0:10009 \
--restlisten=0.0.0.0:8080 \
--trickledelay=1 \
--tor.active \
--tor.socks=9050 \
--tor.streamisolation \
Expand Down
4 changes: 2 additions & 2 deletions images/lnd/0.9.0-beta-ltc-patched/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN patch lnd.go /patches/lnd.patch
RUN patch vendor/github.com/ltcsuite/neutrino/blockmanager.go /patches/neutrino.patch
RUN sed -i.bak "s/\!w.isDevEnv/w.isDevEnv/" vendor/github.com/ltcsuite/ltcwallet/wallet/wallet.go
# build
RUN go install -v -mod=vendor -tags="invoicesrpc" -ldflags "-X github.com/lightningnetwork/lnd/build.Commit=$VERSION-patched" ./cmd/lnd ./cmd/lncli
RUN go install -v -mod=vendor -tags="invoicesrpc" -ldflags "-X github.com/ltcsuite/lnd/build.Commit=$VERSION-ltc-patched" ./cmd/lnd ./cmd/lncli
RUN strip /go/bin/lnd /go/bin/lncli


Expand All @@ -27,4 +27,4 @@ COPY --from=builder /go/bin/lnd /go/bin/lncli /usr/local/bin/
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
VOLUME ["/root/.lnd"]
EXPOSE 10009 8080 30375
EXPOSE 10009 10010 8080 30735
24 changes: 16 additions & 8 deletions images/lnd/0.9.0-beta-ltc-patched/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
set -o errexit # -e
set -o nounset # -u
set -o pipefail
set -o monitor # -m

if [[ $CHAIN != "litecoin" ]]; then
echo "[entrypoint] Invalid chain: $CHAIN"
Expand All @@ -15,7 +14,7 @@ TOR_DIR=$LND_DIR/tor
TOR_LOG=$LND_DIR/tor.log
TOR_DATA_DIR=$LND_DIR/tor-data
LND_HOSTNAME="$TOR_DIR/hostname"
P2P_PORT=30375
P2P_PORT=30735

[[ -e /etc/tor/torrc ]] || cat <<EOF >/etc/tor/torrc
DataDirectory $TOR_DATA_DIR
Expand All @@ -35,34 +34,43 @@ done
LND_ADDRESS=$(cat "$LND_HOSTNAME")
echo "[entrypoint] Onion address for lndbtc is $LND_ADDRESS"


function connect() {
local key="023f670b916d8b89e362f4832f8eeca4f2d578a737c97f6fd4845bb7b584647667"
local uri="[email protected]:10011"
local key="03af9876d7a367cd92d192c745194e91173830c9e4f0d51cfe19beb687189a99e5"
local uri="[email protected]:30735"
local result
while true; do
echo "[entrypoint] Connecting to $uri"
if lncli -n simnet -c litecoin connect $uri >/dev/null 2>&1; then
if result=$(lncli -n simnet -c litecoin connect $uri 2>&1); then
if lncli -n simnet -c litecoin listpeers | grep -q $key; then
echo "[entrypoint] Connected to $uri"
break
fi
else
if echo "$result" | grep -q "cannot make connection to self"; then
break
fi
if echo "$result" | grep -q "already connected to peer"; then
break
fi
fi
sleep 5
done
}

connect &
#connect &


while ! nc -z 127.0.0.1 9050; do
echo "[entrypoint] Waiting for Tor port 9050 to be open"
sleep 1
done

lnd --externalip=$LND_ADDRESS:$P2P_PORT \
# use exec to properly respond to SIGINT
exec lnd --externalip=$LND_ADDRESS:$P2P_PORT \
--listen=0.0.0.0:$P2P_PORT \
--rpclisten=0.0.0.0:10009 \
--restlisten=0.0.0.0:8080 \
--trickledelay=1 \
--tor.active \
--tor.socks=9050 \
--tor.streamisolation \
Expand Down
2 changes: 1 addition & 1 deletion images/lnd/0.9.0-beta-ltc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ COPY torrc /etc/tor/
VOLUME [ "/root/.lnd" ]
RUN mkdir -p /root/.lnd/tor
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 10009 9735 19735 10735 20735
EXPOSE 10009 10010 10735 20735
2 changes: 1 addition & 1 deletion images/lnd/0.9.2-beta/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ COPY torrc /etc/tor/
VOLUME [ "/root/.lnd" ]
RUN mkdir -p /root/.lnd/tor
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 10009 9735 19735 10735 20735
EXPOSE 10009 10010 9735 19735
12 changes: 10 additions & 2 deletions images/utils/launcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import toml
from shutil import copyfile
import traceback
import time

from .config import Config, ConfigLoader, ArgumentError, InvalidHomeDir, InvalidNetworkDir
from .shell import Shell
Expand All @@ -12,6 +13,7 @@

from .check_wallets import Action as CheckWalletsAction, BackupDirNotAvailable
from .close_other_utils import Action as CloseOtherUtilsAction
from .auto_unlock import Action as AutoUnlockAction



Expand Down Expand Up @@ -103,14 +105,20 @@ def wait_for_channels(self):
# TODO wait for channels
pass

def auto_unlock(self):
AutoUnlockAction(self.node_manager).execute()

def close_other_utils(self):
CloseOtherUtilsAction(self.config.network, self.shell).execute()

def pre_start(self):
if self.config.network in ["testnet", "mainnet"]:
if self.config.network in ["simnet", "testnet", "mainnet"]:
print("\n🏃 Warming up...\n")
time.sleep(5) # cool down 5 seconds in case lnd unlock stuck
self.check_wallets()
elif self.config.network == "simnet":
if self.config.network == "simnet":
self.wait_for_channels()
self.auto_unlock()
self.close_other_utils()

def start(self):
Expand Down
35 changes: 35 additions & 0 deletions images/utils/launcher/auto_unlock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from .node import XudApiError

class Action:
def __init__(self, node_manager):
self.node_manager = node_manager

@property
def shell(self):
return self.node_manager.shell

def xud_is_locked(self, xud):
try:
info = xud.api.getinfo()
return False
except XudApiError as e:
if "xud is locked" in str(e):
return True
return False

def xucli_unlock_wrapper(self, xud):
while True:
try:
print()
xud.cli("unlock", self.shell)
break
except KeyboardInterrupt:
break
except:
pass

def execute(self):
xud = self.node_manager.get_node("xud")
if not self.xud_is_locked(xud):
return
self.xucli_unlock_wrapper(xud)
Loading