From 30460f05f4cffa18907984ebccb90c810e63c7de Mon Sep 17 00:00:00 2001 From: KewbitXMR Date: Thu, 19 Jun 2025 11:22:18 +0700 Subject: [PATCH] serialization network ID set via env var and docker improvements --- .../main/java/haveno/common/app/Version.java | 2 +- docker/Dockerfile.core | 2 +- docker/daemon/.env | 3 + docker/daemon/docker-compose.yml | 28 +++++ docker/seednode/.env | 2 + docker/seednode/docker-compose.yml | 79 +++++++++++++ docker/torrc | 109 ++++++++++++++++++ 7 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 docker/daemon/.env create mode 100644 docker/daemon/docker-compose.yml create mode 100644 docker/seednode/.env create mode 100644 docker/seednode/docker-compose.yml create mode 100644 docker/torrc diff --git a/common/src/main/java/haveno/common/app/Version.java b/common/src/main/java/haveno/common/app/Version.java index d64410a9..64fa799c 100644 --- a/common/src/main/java/haveno/common/app/Version.java +++ b/common/src/main/java/haveno/common/app/Version.java @@ -99,7 +99,7 @@ public class Version { // The version no. for the objects sent over the network. A change will break the serialization of old objects. // If objects are used for both network and database the network version is applied. - public static final String P2P_NETWORK_VERSION = "X"; + public static final String P2P_NETWORK_VERSION = System.getenv().getOrDefault("P2P_NETWORK_VERSION", "X"); // The version no. of the serialized data stored to disc. A change will break the serialization of old objects. // VERSION = 0.5.0 -> LOCAL_DB_VERSION = 1 diff --git a/docker/Dockerfile.core b/docker/Dockerfile.core index 982c614a..0d6f971f 100644 --- a/docker/Dockerfile.core +++ b/docker/Dockerfile.core @@ -15,7 +15,7 @@ USER haveno WORKDIR /home/haveno -RUN set -ex && git clone https://git.haveno.com/haveno/haveno.git +RUN set -ex && git clone https://foss.haveno.com/haveno-network/haveno-core.git WORKDIR /home/haveno/haveno diff --git a/docker/daemon/.env b/docker/daemon/.env new file mode 100644 index 00000000..a319ed88 --- /dev/null +++ b/docker/daemon/.env @@ -0,0 +1,3 @@ +NETWORK_VERSION_TAG=1.1.2 +BASE_NETWORK=MAINNET +P2P_NETWORK_VERSION="X" \ No newline at end of file diff --git a/docker/daemon/docker-compose.yml b/docker/daemon/docker-compose.yml new file mode 100644 index 00000000..72a17d33 --- /dev/null +++ b/docker/daemon/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3' + +services: + haveno-daemon: + image: haveno-core + build: + context: ../ + ports: + - "127.0.0.1:3201:3201" + environment: + - P2P_NETWORK_VERSION=X + - NETWORK_VERSION_TAG=${NETWORK_VERSION_TAG} + - BASE_CURRENCY_NETWORK=XMR_${BASE_NETWORK} + - USE_LOCALHOST_FOR_P2P=false + - USE_DEV_PRIVILEGE_KEYS=false + - NODE_PORT=9999 + - APP_NAME=haveno-XMR_${BASE_NETWORK}_DAEMON + - EXPORT_SHADOW=yes + - EXPORT_SHADOW_PATH=daemon/build/libs/daemon-all.sh # Leave this blank in most cases + entrypoint: ["./haveno-daemon"] + command: + - "--baseCurrencyNetwork=XMR_${BASE_NETWORK}" + - "--useLocalhostForP2P=false" + - "--useDevPrivilegeKeys=false" + - "--nodePort=9999" + - "--appName=XMR_${BASE_NETWORK}_DAEMON" + - "--seedNodes=5i6blbmuflq4s4im6zby26a7g22oef6kyp7vbwyru6oq5e36akzo3ayd.onion:2001,dx4ktxyiemjc354imehuaswbhqlidhy62b4ifzigk5p2rb37lxqbveqd.onion:2002,ajbqx4clnjlr7lmzoftuvpvmqafdiilidsgocvokx6bqj3okk56ccfqd.onion:2003" + restart: unless-stopped diff --git a/docker/seednode/.env b/docker/seednode/.env new file mode 100644 index 00000000..d0c97381 --- /dev/null +++ b/docker/seednode/.env @@ -0,0 +1,2 @@ +BASE_NETWORK=MAINNET +P2P_NETWORK_VERSION="X" diff --git a/docker/seednode/docker-compose.yml b/docker/seednode/docker-compose.yml new file mode 100644 index 00000000..0da5abb7 --- /dev/null +++ b/docker/seednode/docker-compose.yml @@ -0,0 +1,79 @@ +version: '3.8' + +services: + haveno-core: + image: haveno-core + build: + context: ../ + dockerfile: Dockerfile.core + # No ports, this one just builds the image + entrypoint: ["true"] # No need to run + + haveno-seednode_2001: + image: haveno-core + depends_on: + - haveno-core + ports: + - "127.0.0.1:2001:2001" + environment: + - BASE_CURRENCY_NETWORK=XMR_${BASE_NETWORK} + - USE_LOCALHOST_FOR_P2P=false + - USE_DEV_PRIVILEGE_KEYS=false + - NODE_PORT=2001 + - APP_NAME=haveno-XMR_${BASE_NETWORK}_Seed_2001 + entrypoint: ["./haveno-seednode"] + command: + - "--baseCurrencyNetwork=XMR_${BASE_NETWORK}" + - "--useLocalhostForP2P=false" + - "--useDevPrivilegeKeys=false" + - "--nodePort=2001" + - "--appName=haveno-XMR_${BASE_NETWORK}_Seed_2001" + - "--hiddenServiceAddress=5i6blbmuflq4s4im6zby26a7g22oef6kyp7vbwyru6oq5e36akzo3ayd.onion" + - "--seedNodes=5i6blbmuflq4s4im6zby26a7g22oef6kyp7vbwyru6oq5e36akzo3ayd.onion:2001,dx4ktxyiemjc354imehuaswbhqlidhy62b4ifzigk5p2rb37lxqbveqd.onion:2002,ajbqx4clnjlr7lmzoftuvpvmqafdiilidsgocvokx6bqj3okk56ccfqd.onion:2003" + restart: unless-stopped + + haveno-seednode_2002: + image: haveno-core + depends_on: + - haveno-core + ports: + - "127.0.0.1:2002:2002" + environment: + - BASE_CURRENCY_NETWORK=XMR_${BASE_NETWORK} + - USE_LOCALHOST_FOR_P2P=false + - USE_DEV_PRIVILEGE_KEYS=false + - NODE_PORT=2002 + - APP_NAME=haveno-XMR_${BASE_NETWORK}_Seed_2002 + entrypoint: ["./haveno-seednode"] + command: + - "--baseCurrencyNetwork=XMR_${BASE_NETWORK}" + - "--useLocalhostForP2P=false" + - "--useDevPrivilegeKeys=false" + - "--nodePort=2002" + - "--appName=haveno-XMR_${BASE_NETWORK}_Seed_2002" + - "--hiddenServiceAddress=dx4ktxyiemjc354imehuaswbhqlidhy62b4ifzigk5p2rb37lxqbveqd.onion" + - "--seedNodes=5i6blbmuflq4s4im6zby26a7g22oef6kyp7vbwyru6oq5e36akzo3ayd.onion:2001,dx4ktxyiemjc354imehuaswbhqlidhy62b4ifzigk5p2rb37lxqbveqd.onion:2002,ajbqx4clnjlr7lmzoftuvpvmqafdiilidsgocvokx6bqj3okk56ccfqd.onion:2003" + restart: unless-stopped + + haveno-seednode_2003: + image: haveno-core + depends_on: + - haveno-core + ports: + - "127.0.0.1:2003:2003" + environment: + - BASE_CURRENCY_NETWORK=XMR_${BASE_NETWORK} + - USE_LOCALHOST_FOR_P2P=false + - USE_DEV_PRIVILEGE_KEYS=false + - NODE_PORT=2003 + - APP_NAME=haveno-XMR_${BASE_NETWORK}_Seed_2003 + entrypoint: ["./haveno-seednode"] + command: + - "--baseCurrencyNetwork=XMR_${BASE_NETWORK}" + - "--useLocalhostForP2P=false" + - "--useDevPrivilegeKeys=false" + - "--nodePort=2003" + - "--appName=haveno-XMR_${BASE_NETWORK}_Seed_2003" + - "--hiddenServiceAddress=ajbqx4clnjlr7lmzoftuvpvmqafdiilidsgocvokx6bqj3okk56ccfqd.onion" + - "--seedNodes=5i6blbmuflq4s4im6zby26a7g22oef6kyp7vbwyru6oq5e36akzo3ayd.onion:2001,dx4ktxyiemjc354imehuaswbhqlidhy62b4ifzigk5p2rb37lxqbveqd.onion:2002,ajbqx4clnjlr7lmzoftuvpvmqafdiilidsgocvokx6bqj3okk56ccfqd.onion:2003" + restart: unless-stopped \ No newline at end of file diff --git a/docker/torrc b/docker/torrc new file mode 100644 index 00000000..8ddaf97e --- /dev/null +++ b/docker/torrc @@ -0,0 +1,109 @@ +## Configuration file for Haveno Seednode +## +## Tor opens a socks proxy on port 9050 by default -- even if you don't +## configure one below. Set "SocksPort 0" if you plan to run Tor only +## as a relay, and not make any local application connections yourself. +#SocksPort 9050 # Default: Bind to localhost:9050 for local connections. +# ### SocksPort flag: OnionTrafficOnly ### +## Tell the tor client to only connect to .onion addresses in response to SOCKS5 requests on this connection. +## This is equivalent to NoDNSRequest, NoIPv4Traffic, NoIPv6Traffic. +# ### SocksPort flag: ExtendedErrors ### +## Return extended error code in the SOCKS reply. So far, the possible errors are: +# X'F0' Onion Service Descriptor Can Not be Found +# X'F1' Onion Service Descriptor Is Invalid +# X'F2' Onion Service Introduction Failed +# X'F3' Onion Service Rendezvous Failed +# X'F4' Onion Service Missing Client Authorization +# X'F5' Onion Service Wrong Client Authorization +# X'F6' Onion Service Invalid Address +# X'F7' Onion Service Introduction Timed Out +SocksPort 9050 OnionTrafficOnly ExtendedErrors + +## Entry policies to allow/deny SOCKS requests based on IP address. +## First entry that matches wins. If no SocksPolicy is set, we accept +## all (and only) requests that reach a SocksPort. Untrusted users who +## can access your SocksPort may be able to learn about the connections +## you make. +SocksPolicy accept 127.0.0.1 +SocksPolicy accept6 [::1] +SocksPolicy reject * + +## Tor will reject application connections that use unsafe variants of the socks protocol +## — ones that only provide an IP address, meaning the application is doing a DNS resolve first. +## Specifically, these are socks4 and socks5 when not doing remote DNS. (Default: 0) +#SafeSocks 1 + +## Tor will make a notice-level log entry for each connection to the Socks port indicating +## whether the request used a safe socks protocol or an unsafe one (see above entry on SafeSocks). +## This helps to determine whether an application using Tor is possibly leaking DNS requests. (Default: 0) +TestSocks 1 + +## Logs go to stdout at level "notice" unless redirected by something +## else, like one of the below lines. You can have as many Log lines as +## you want. +## +## We advise using "notice" in most cases, since anything more verbose +## may provide sensitive information to an attacker who obtains the logs. +## +## Send all messages of level 'notice' or higher to /var/log/tor/notices.log +#Log notice file /var/log/tor/notices.log +## Send every possible message to /var/log/tor/debug.log +#Log debug file /var/log/tor/debug.log +## Use the system log instead of Tor's logfiles (This is default) +#Log notice syslog +## To send all messages to stderr: +#Log debug stderr + +# Try to write to disk less frequently than we would otherwise. This is useful when running on flash memory. +AvoidDiskWrites 1 + +HiddenServiceStatistics 0 + +## Compute the hash of a password with "tor --hash-password password". +HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C +#CookieAuthentication 0 # (Default: 1) + +## MetricsPort provides an interface to the underlying Tor relay metrics. +## Exposing publicly is dangerous, set a very strict access policy. +## Retrieve the metrics with: curl http://127.0.0.1:9035/metrics +MetricsPort 127.0.0.1:9035 +MetricsPortPolicy accept 127.0.0.1 +MetricsPortPolicy accept [::1] + +HiddenServiceDir /var/lib/tor/haveno_seednode_2001 +HiddenServicePort 2001 127.0.0.1:2001 +HiddenServicePort 2001 [::1]:2001 +HiddenServiceEnableIntroDoSDefense 1 +HiddenServicePoWDefensesEnabled 1 +HiddenServicePoWQueueRate 50 # (Default: 250) +HiddenServicePoWQueueBurst 250 # (Default: 2500) +HiddenServiceMaxStreams 25 + + +HiddenServiceDir /var/lib/tor/haveno_seednode_2002 +HiddenServicePort 2002 127.0.0.1:2002 +HiddenServicePort 2002 [::1]:2002 +HiddenServiceEnableIntroDoSDefense 1 +#HiddenServiceEnableIntroDoSRatePerSec 25 # (Default: 25) +#HiddenServiceEnableIntroDoSBurstPerSec 200 # (Default: 200) +HiddenServicePoWDefensesEnabled 1 +HiddenServicePoWQueueRate 50 # (Default: 250) +HiddenServicePoWQueueBurst 250 # (Default: 2500) +HiddenServiceMaxStreams 25 +#HiddenServiceMaxStreamsCloseCircuit 1 + + +HiddenServiceDir /var/lib/tor/haveno_seednode_2003 +HiddenServicePort 2003 127.0.0.1:2003 +HiddenServicePort 2003 [::1]:2003 +HiddenServiceEnableIntroDoSDefense 1 +#HiddenServiceEnableIntroDoSRatePerSec 25 # (Default: 25) +#HiddenServiceEnableIntroDoSBurstPerSec 200 # (Default: 200) +#HiddenServiceNumIntroductionPoints 3 # (Default: 3) +HiddenServicePoWDefensesEnabled 1 +HiddenServicePoWQueueRate 50 # (Default: 250) +HiddenServicePoWQueueBurst 250 # (Default: 2500) +HiddenServiceMaxStreams 25 +#HiddenServiceMaxStreamsCloseCircuit 1 + +LongLivedPorts 2001,2002,2003 \ No newline at end of file