Dev:Build a Nexus Mining Pool

From Nexus Wiki
Revision as of 02:58, 16 October 2024 by Nexus wiki (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Pool for Nexus Hash and Prime channels: https://github.com/Nexusoft/Mining-Pool

Set Up NexusWebUI

Instructions for Ubuntu 24.04

NexusWebUI

Replace requirments.txt with the following (Python 3.12):

apply_defaults==0.1.6
asgiref==3.8.1
attrs==24.2.0
bson==0.5.10
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.3.2
click==8.1.7
cryptography==43.0.1
Django==5.1.1
django-tables2==2.7.0
Faker==30.1.0
greenlet==3.1.1
grpcio==1.66.2
gunicorn==23.0.0
idna==3.10
importlib_metadata==8.5.0
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
numpy==2.1.2
packaging==24.1
pandas==2.2.3
protobuf==5.28.2
pybson==0.5.9
pycparser==2.22
pyrsistent==0.20.0
python-dateutil==2.9.0.post0
python-decouple==3.8
pytz==2024.2
PyYAML==6.0.2
referencing==0.35.1
requests==2.32.3
rpds-py==0.20.0
setuptools==75.1.0
six==1.16.0
SQLAlchemy==2.0.35
sqlparse==0.5.1
text-unidecode==1.3
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
zipp==3.20.2

Run the following commands for basic UI setup:

sudo apt install -y cmake make python3.12-venv
git clone https://github.com/Nexusoft/Mining-Pool.git
cd Mining-Pool/NexusWebUI
python3 -m venv ./venv
source venv/bin/activate
pip install -r requirements.txt
# edit .env_example and copy to .env
SECRET_KEY=88888888888888888888888888888888
ALLOWED_HOSTS=localhost,127.0.0.1,hashpool.nexus-wiki.org
POOL_IP=172.0.0.0
POOL_PORT=80
POOL_HOST=hashpool.nexus-wiki.org
POOL_USER=<user>
POOL_PWD=<pass>
mkdir logs
python3 manage.py migrate
python3 manage.py runserver 0.0.0.0:80

gunicorn test:

source venv/bin/activate
gunicorn --bind 0.0.0.0:80 NexusWebUI.wsgi

gunicorn setup:

sudo nano /etc/systemd/system/gunicorn.socket
[Unit]
Description=Gunicorn socket for Django project
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
sudo nano /etc/systemd/system/gunicorn.service
[Unit]
Description=Gunicorn service for Django project
Requires=gunicorn.socket
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/root/Projects/GitHub/Mining-Pool/NexusWebUI
ExecStart=/root/Projects/GitHub/Mining-Pool/NexusWebUI/venv/bin/gunicorn \
--access-logfile - \
--error-logfile - \
--bind unix:/run/gunicorn.sock \
NexusWebUI.wsgi:application
[Install]
WantedBy=multi-user.target
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
sudo systemctl status gunicorn.socket
sudo nano /etc/nginx/sites-available/NexusWebUI
server {
    listen 80;
    server_name hashpool.nexus-wiki.org;

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}
sudo ln -s /etc/nginx/sites-available/NexusWebUI /etc/nginx/sites-enabled
nginx -t
sudo systemctl restart nginx

Mining-Pool Setup

sudo apt-get install -y libssl-dev libsqlite3-dev sqlite3
cmake CMakeLists.txt
make

pool.conf

{
    "wallet_ip" : "127.0.0.1",
    "wallet_port" : 8080,
    "local_ip" : "127.0.0.1",
    "local_port" : 0,
    "public_ip" : "172.236.125.79",
    "miner_listen_port" : 0,
    "mining_mode" : "HASH",
    "connection_retry_interval" : 5,
    "get_height_interval" : 2,
    "session_expiry_time" : 30,
    "legacy_mode" : false,
    "pool" :
    {
        "account" : "default",
        "pin" : "<pin>",
        "fee" : 1,
        "difficulty_divider" : 4,
        "round_duration_hours" : 24,
        "nxs_api_user" : "<user>,
        "nxs_api_pw" : "<pass>"
    },
    "enable_ddos" : true,
    "ddos" :
    {
        "ddos_rscore" : 20,
        "ddos_cscore" : 2
    },
    "logfile" : "pool.log",
    "log_level" : 2,
    "persistance" :
    {
        "type" : "sqlite",
        "file" : "nexuspool.db"
    },
    "update_block_hashes_interval" : 600,
    "get_hashrate_interval" : 300,
    "miner_notifications" : true
}