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: use xud default ports like 8886, 18886, 28886 #395

Merged
merged 5 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion images/raiden/0.100.5a1.dev162-2217bcb/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ADDRESS=$(get_addr)
OPTS=(
"--rpc"
"--accept-disclaimer"
"--resolver-endpoint http://xud:8887/resolveraiden"
"--eth-rpc-endpoint $RPC_ENDPOINT"
"--password-file $RAIDEN_DIR/passphrase.txt"
"--datadir $RAIDEN_DIR"
Expand All @@ -70,6 +69,7 @@ testnet)
"--user-deposit-contract-address 0x3A17B96809258523c4DED8e7F3f9364D13eBc2C5"
"--monitoring-service-contract-address 0x9F50cEA29307d7D91c5176Af42f3aB74f0190dD3"
"--one-to-n-contract-address 0xA102879b6AE21B93432160532DeB8f0EA1C50b30"
"--resolver-endpoint http://xud:18887/resolveraiden"
)
;;
mainnet)
Expand All @@ -85,6 +85,7 @@ mainnet)
"--user-deposit-contract-address 0x4F26957E8fd331D53DD60feE77533FBE7564F5Fe"
"--monitoring-service-contract-address 0x37cC37D7703554183aE544391945e7D0588b7693"
"--one-to-n-contract-address 0x3dda5BE50Af796618d9f48c021Cf0C9FD64FFeb1"
"--resolver-endpoint http://xud:8887/resolveraiden"
)
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion images/utils/launcher/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def __eq__(self, other):
},
"xud": {
"name": "xud",
"image": "exchangeunion/xud:1.0.0-beta.2",
"image": "exchangeunion/xud:latest",
"volumes": [
{
"host": "$data_dir/xud",
Expand Down
8 changes: 2 additions & 6 deletions images/xud/1.0.0-beta.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=ExchangeUnion/xud
ARG BRANCH=v1.0.0-beta.2
# Use pure JS implemented secp256k1 bindings
RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# 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
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO
WORKDIR /xud
RUN git show HEAD > git_head.txt
RUN npm install
RUN npm run compile
RUN npm run compile:seedutil
Expand All @@ -18,7 +16,6 @@ RUN rm -rf seedutil/go
FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY xud.conf /tmp/
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
Expand All @@ -27,5 +24,4 @@ RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
VOLUME [ "/root/.xud" ]
EXPOSE 8885 18885 8887
EXPOSE 8887 18887 28887
7 changes: 2 additions & 5 deletions images/xud/1.0.0-beta.2/Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# python: not found
RUN apk add --no-cache 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
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO
WORKDIR /xud
RUN git show HEAD > git_head.txt
RUN cp package.json /tmp/package.json
RUN sed -Ei 's/"grpc-tools": "1.8.0",//g' package.json
RUN npm install
Expand All @@ -24,7 +23,6 @@ RUN rm -rf seedutil/go
FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY xud.conf /tmp/
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
Expand All @@ -33,5 +31,4 @@ RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
VOLUME [ "/root/.xud" ]
EXPOSE 8885 18885 8887
EXPOSE 8887 18887 28887
86 changes: 54 additions & 32 deletions images/xud/1.0.0-beta.2/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
#!/bin/bash

XUD_DIR=$HOME/.xud
XUD_CONF=$XUD_DIR/xud.conf
KEYSTORE_DIR=$HOME/.raiden/keystore

[[ -e $KEYSTORE_DIR ]] || mkdir -p "$KEYSTORE_DIR"

case $NETWORK in
mainnet)
P2P_PORT=8885
RPC_PORT=8886
HTTP_PORT=8887
;;
testnet)
P2P_PORT=18885
RPC_PORT=18886
HTTP_PORT=18887
;;
simnet)
P2P_PORT=28885
RPC_PORT=28886
HTTP_PORT=28887
;;
*)
echo >&2 "Error: Unsupported network: $NETWORK"
exit 1
esac

wait_file() {
local file="$1"; shift
local wait_seconds="${1:-10}"; shift # after 10 seconds we give up
Expand All @@ -10,40 +37,35 @@ wait_file() {
}

write_config() {
echo "xud.conf not found - creating a new one..."
cp /tmp/xud.conf ~/.xud

hn="$(hostname)"
n="${hn:3}"

if [[ -z $n ]]; then
insid="0"
else
insid="$n"
fi

case $NETWORK in
mainnet)
DELTA=0
;;
testnet)
DELTA=10000
;;
esac

sed -i "s/<instance_id>/$insid/g" ~/.xud/xud.conf
sed -i "s/<network>/$NETWORK/g" ~/.xud/xud.conf
sed -i "s/<p2p_port>/$((8885 + DELTA))/g" ~/.xud/xud.conf

XUD_HOSTNAME="/root/.xud/tor/hostname"
wait_file "$XUD_HOSTNAME" && {
XUD_ONION_ADDRESS=$(cat $XUD_HOSTNAME)
echo "Onion address for xud is $XUD_ONION_ADDRESS"
sed -i "s/<onion_address>/$XUD_ONION_ADDRESS/g" ~/.xud/xud.conf
}
echo "xud.conf not found - creating a new one..."
cp /app/sample-xud.conf $XUD_CONF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why??? You shouldn't create any xud.conf file because this would overwrite defaults in future when we change them on xud side! We always want to use xud defaults so you can't hardcode them.

You can pull the current xud defaults from the sample config files here: https://github.com/ExchangeUnion/xud-docker/tree/master/images/utils/launcher/config, I am maintaining them there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We create xud.conf to config xud for a long history. And this config file is updated when xud image updated. And I do modify sample-xud.conf from xud source. I'm not sure about your concerning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just don't create it, it will cause troubles overwriting things. We had that in multiple places before. xud has default values without any config and we assume these.

Copy link
Collaborator Author

@reliveyy reliveyy Apr 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to use command line options to customize xud configuration at the very beginning like other nodes. But later we changed to xud.conf file. So we are going to change it back? I remember we use this xud.conf becuase it's easy to change xud configuration by just editing host data/xud/xud.conf file and restarting xud container. And in case of xud container upgrading with old xud.conf file, we do override this file everytime. But if you specify --xud.preserve-config you could remain the old config file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a full list of what we changed from sample-xud.conf:

  • network
  • http.host
  • http.port
  • lnd.BTC.host
  • lnd.BTC.certpath
  • lnd.LTC.host
  • lnd.LTC.port
  • lnd.LTC.certpath
  • p2p.addresses
  • p2p.port
  • p2p.tor
  • p2p.torport
  • raiden.host
  • raiden.keystorepath
  • rpc.host
  • rpc.port

I think we can leave http.port, p2p.port and rpc.port out becuase there is no change to their default value now.

Copy link
Collaborator Author

@reliveyy reliveyy Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these 3 options are in sample-xud.conf. And their values are for simnet. If we want to use default values, we need to delete these 3 options from xud.conf. So I'll leave it as it was.


XUD_HOSTNAME="/root/.xud/tor/hostname"
wait_file "$XUD_HOSTNAME" && {
XUD_ONION_ADDRESS=$(cat $XUD_HOSTNAME)
echo "Onion address for xud is $XUD_ONION_ADDRESS"
}

sed -i "s/network.*/network = \"$NETWORK\"/" $XUD_CONF
sed -i 's/noencrypt.*/noencrypt = false/' $XUD_CONF
sed -i '/\[http/,/^$/s/host.*/host = "0.0.0.0"/' $XUD_CONF
sed -i "/\[http/,/^$/s/port.*/port = $HTTP_PORT/" $XUD_CONF
sed -i '/\[lnd\.BTC/,/^$/s/host.*/host = "lndbtc"/' $XUD_CONF
sed -i "/\[lnd\.BTC/,/^$/s|^$|certpath = \"/root/.lndbtc/tls.cert\"\nmacaroonpath = \"/root/.lndbtc/data/chain/bitcoin/$NETWORK/admin.macaroon\"\n|" $XUD_CONF
sed -i '/\[lnd\.LTC/,/^$/s/host.*/host = "lndltc"/' $XUD_CONF
sed -i '/\[lnd\.LTC/,/^$/s/port.*/port = 10009/' $XUD_CONF
sed -i "/\[lnd\.LTC/,/^$/s|^$|certpath = \"/root/.lndltc/tls.cert\"\nmacaroonpath = \"/root/.lndltc/data/chain/litecoin/$NETWORK/admin.macaroon\"\n|" $XUD_CONF
sed -i "/\[p2p/,/^$/s/addresses.*/addresses = \[\"$XUD_ONION_ADDRESS\"]/" $XUD_CONF
sed -i "/\[p2p/,/^$/s/port.*/port = $P2P_PORT/" $XUD_CONF
sed -i '/\[p2p/,/^$/s/tor = .*/tor = true/' $XUD_CONF
sed -i '/\[p2p/,/^$/s/torport.*/torport = 9050/' $XUD_CONF
sed -i '/\[raiden/,/^$/s/host.*/host = "raiden"/' $XUD_CONF
sed -i "/\[raiden/,/^$/s|^$|keystorepath = \"$KEYSTORE_DIR\"\n|" $XUD_CONF
sed -i '/\[rpc/,/^$/s/host.*/host = "0.0.0.0"/' $XUD_CONF
sed -i "/\[rpc/,/^$/s/port.*/port = $RPC_PORT/" $XUD_CONF
}

if [[ $XUD_REWRITE_CONFIG || ! -e ~/.xud/xud.conf ]]; then
if [[ $XUD_REWRITE_CONFIG || ! -e $XUD_CONF ]]; then
write_config
fi

Expand Down
86 changes: 0 additions & 86 deletions images/xud/1.0.0-beta.2/xud.conf

This file was deleted.

27 changes: 27 additions & 0 deletions images/xud/latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=ExchangeUnion/xud
ARG BRANCH=master
RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# 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
WORKDIR /xud
RUN npm install
RUN npm run compile
RUN npm run compile:seedutil
RUN npm prune --production
RUN rm -rf seedutil/go


FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY torrc /etc/tor/torrc
RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 8887 18887 28887
34 changes: 34 additions & 0 deletions images/xud/latest/Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=ExchangeUnion/xud
ARG BRANCH=v1.0.0-beta.2
# Use pure JS implemented secp256k1 bindings
RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# Pre-built binaries not found for sqlite3@4.1.0 and node@12.16.1 (node-v72 ABI, musl) (falling back to source compile with node-gyp)
# python: not found
RUN apk add --no-cache 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
WORKDIR /xud
RUN cp package.json /tmp/package.json
RUN sed -Ei 's/"grpc-tools": "1.8.0",//g' package.json
RUN npm install
RUN cp /tmp/package.json package.json
RUN npm run compile
RUN npm run compile:seedutil
RUN npm prune --production
RUN rm -rf seedutil/go


FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY torrc /etc/tor/torrc
RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 8887 18887 28887
Loading