Author

Topic: Set up a stratum mining server for Capstone (Read 1845 times)

newbie
Activity: 10
Merit: 0
August 08, 2018, 06:25:34 PM
#6
Hi,


I think this post help you to setup your zcash pool server:

https://bitcointalksearch.org/topic/guide-setup-your-own-zec-stratum-pool-1697727
newbie
Activity: 14
Merit: 0
Hi

@Lpape

I was hoping you could help me with some advise, it has been some time since your post on how to set it up so im sure much has changed, well capstone no longer exists on the link you sent.

is there any better way to setup the mining pool and stratum server for zcash and decred.

please advise.

thanks
bitreo
newbie
Activity: 10
Merit: 0
hi everybody


i have just setup my new stratum mining server for caspstone : cst.stratumserver.net
member
Activity: 84
Merit: 10
part 3


cd /var/www/html/

sudo git clone git://github.com/MPOS/php-mpos.git MPOS

cd MPOS

sudo git checkout master

sudo mysql -p -e "create datebase Capstone"

sudo mysql -p Capstone < sql/000_base_structure.sql

sudo chown -R www-data templates/compile templates/cache logs

sudo cap include/config/global.inc.dist.php include/config/global.inc.php

sudo nano include/config/global.inc.php


It should look like this

?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;

/**
 * Do not edit this unless you have confirmed that your config has been updated!
 * Also the URL to check for the most recent upstream versions available
 *  https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-config-version
 **/
$config['version'] = '1.0.1';
$config['version_url'] = 'https://raw.githubusercontent.com/MPOS/php-mpos/maste$

/**
 * Unless you disable this, we'll do a quick check on your config first.
 *  https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-config-check
 */
$config['skip_config_tests'] = false;

/**
 * Unless you disable this, we'll do a check for a valid coin address on regist$
*/
$config['check_valid_coinaddress'] = true;

/**
 * Defines
 *  Debug setting and salts for hashing passwords
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-defines--salts
 */
$config['DEBUG'] = 0;
$config['SALT'] = 'PLEASEMAKEMESOMETHINGRANDOM';
$config['SALTY'] = 'THISSHOULDALSOBERRAANNDDOOM';

/**
  * Coin Algorithm
  *  Algorithm used by this coin, sha256d or scrypt
  *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-algorithm
  **/
$config['algorithm'] = 'sha256d';
 * Getbalance API Calls
  *  System used for getting actual Balance from Wallet
  *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#getbalance-api-calls
  **/
$config['getbalancewithunconfirmed'] = true;

/**
 * Database configuration
 *  MySQL database configuration
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-database-configura$
 **/
$config['db']['host'] = 'localhost';
$config['db']['user'] = 'root';
$config['db']['pass'] = 'password';
$config['db']['port'] = 3306;
$config['db']['name'] = 'Capstone';
// Disabled by default and set in bootstrap if unset, but left in here so
// people know it exists
// $config['db']['shared']['accounts'] = $config['db']['name'];
// $config['db']['shared']['workers'] = $config['db']['name'];
// $config['db']['shared']['news'] = $config['db']['name'];

/**
 * Local wallet RPC
 *  RPC configuration for your daemon/wallet
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-local-wallet-rpc
 **/
$config['wallet']['type'] = 'http';
$config['wallet']['host'] = 'localhost:9332';
$config['wallet']['username'] = 'username';
$config['wallet']['password'] = 'password';

/**
 * Swiftmailer configuration
 *  Configure your way to send mails
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-swiftmailer
 **/
$config['swiftmailer']['type'] = 'sendmail';
$config['swiftmailer']['sendmail']['path'] = '/usr/sbin/sendmail';
$config['wallet']['password'] = 'password';

/**
 * Swiftmailer configuration
 *  Configure your way to send mails
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-swiftmailer
 **/
$config['swiftmailer']['type'] = 'sendmail';
$config['swiftmailer']['sendmail']['path'] = '/usr/sbin/sendmail';
$config['swiftmailer']['sendmail']['options'] = '-bs';
$config['swiftmailer']['smtp']['host'] = 'your.mail-relay.com';
$config['swiftmailer']['smtp']['port'] = '587';
$config['swiftmailer']['smtp']['encryption'] = 'tls';
$config['swiftmailer']['smtp']['username'] = '';
$config['swiftmailer']['smtp']['password'] = '';
$config['swiftmailer']['smtp']['throttle'] = 100;

/**
 * Getting Started Config
 *  Shown to users in the 'Getting Started' section
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-getting-started
 **/
$config['gettingstarted']['coinname'] = 'Litecoin';
$config['gettingstarted']['coinurl'] = 'http://www.litecoin.org';
$config['gettingstarted']['stratumurl'] = 'your IP';
$config['gettingstarted']['stratumport'] = '3333';

/**
 * Ticker API
 *  Fetch exchange rates via an API
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-ticker-api
 **/
$config['price']['enabled'] = false;
$config['price']['url'] = 'https://btc-e.com';
$config['price']['target'] = '/api/2/ltc_usd/ticker';
$config['price']['currency'] = '';

/**
 * Automatic Payout Thresholds
*   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-automatic-payout-t$
 **/
$config['ap_threshold']['min'] = 1;
$config['ap_threshold']['max'] = 250;

/**
 * Minimum manual Payout Threshold
 *  Minimum manual payout amount
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-manual-payout-thre$
 **/
$config['mp_threshold'] = 1;

/**
 * Donation thresholds
 *  Minimum donation amount in percent
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-donation-thresholds
 **/
$config['donate_threshold']['min'] = 1;
*/
$config['currency'] = 'CST';

/**
 * Coin Target
 *  Target time for coins to be generated
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-coin-target
 **/
$config['cointarget'] = '150';

/**
 * Coin Diff Change
 *  Amount of blocks between difficulty changes
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-coin-diff-change
 **/
$config['coindiffchangetarget'] = 1;

/**
 * TX Fees
 *  Fees applied to transactions
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-tx-fees
 **/
$config['txfee_auto'] = 0.1;
$config['txfee_manual'] = 0.1;

/**
 * Block & Pool Bonus
 *  Bonus coins for blockfinder or a pool bonus for everyone
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-block-bonus
*/
$config['block_bonus'] = 0;
$config['pool_bonus'] = 0;
$config['pool_bonus_type'] = 'payout';

/**
 * Payout System
 *  Payout system chosen
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-payout-system
 **/
$config['payout_system'] = 'prop';

/**
 * Sendmany Support
 *  Enable/Disable Sendmany RPC method
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-sendmany-support
 **/
$config['sendmany']['enabled'] = false;
/**
 * Transaction Limits
 *  Number of transactions per payout run
 **/
$config['payout']['txlimit_manual'] = 500;
$config['payout']['txlimit_auto'] = 500;

/**
 * Round Purging
 *  Round share purging configuration

 **/
$config['purge']['sleep'] = 1;
$config['purge']['shares'] = 25000;

/**
 * Share Archiving
 *  Share archiving configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-archiving
 **/
$config['archive']['maxrounds'] = 10;
$config['archive']['maxage'] = 60 * 24;


/**
 * Pool Fees
 *  Fees applied to users
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pool-fees
 */
$config['fees'] = 0;
/**
 * PPLNS
 *  Pay Per Last N Shares
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pplns-settings
 */
$config['pplns']['shares']['default'] = 4000000;
$config['pplns']['shares']['type'] = 'blockavg';
$config['pplns']['blockavg']['blockcount'] = 10;
$config['pplns']['reverse_payout'] = true;
$config['pplns']['dynamic']['percent'] = 30;

/**
 * Difficulty
 *  Difficulty setting for stratum/pushpool
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pool-target-diffic$
 */
$config['difficulty'] = 1;

/**
 *  Block reward configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-reward-settings
 **/
$config['reward_type'] = 'block';
$config['reward'] = 33;

/**
 * Confirmations
 *  Credit and Network confirmation settings
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-confirmations
 */
$config['confirmations'] = 120;
$config['network_confirmations'] = 120;

/**
 * PPS
 *  Pay Per Share configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pps-settings
 **/
$config['pps']['reward']['default'] = 50;
$config['pps']['reward']['type'] = 'blockavg';
$config['pps']['blockavg']['blockcount'] = 10;

/**
 * Memcache
 *  Memcache configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-memcache
 **/
$config['memcache']['enabled'] = true;

$config['memcache']['port'] = 11211;
$config['memcache']['keyprefix'] = 'mpos_';
$config['memcache']['expiration'] = 90;
$config['memcache']['splay'] = 15;
$config['memcache']['force']['contrib_shares'] = false;
$config['memcache']['sasl'] = false;
$config['memcache']['sasl']['username'] = '';
$config['memcache']['sasl']['password'] = '';

/**
 * Cookies
 *  Cookie configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-cookies
 **/
$config['cookie']['duration'] = '1440';
$config['cookie']['domain'] = '';
$config['cookie']['path'] = '/';
$config['cookie']['httponly'] = true;
$config['cookie']['secure'] = false;

/**
 * Smarty Cache
 *  Enable smarty cache and cache length
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-smarty-cache
 **/
$config['smarty']['cache'] = 0;
$config['smarty']['cache_lifetime'] = 30;

/**


sudo nano /usr/local/lib/python2.7/dist-packages/stratum-0.2.13-py2.7.egg/stratum/websocket_transport.py

It should look like this
from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory
from protocol import Protocol
from event_handler import GenericEventHandler

class WebsocketServerProtocol(WebSocketServerProtocol, Protocol):
    def connectionMade(self):
        WebSocketServerProtocol.connectionMade(self)
        Protocol.connectionMade(self)

    def connectionLost(self, reason):
        WebSocketServerProtocol.connectionLost(self, reason)
        Protocol.connectionLost(self, reason)

    def onMessage(self, msg, is_binary):
        Protocol.dataReceived(self, msg)

    def transport_write(self, data):
        self.sendMessage(data, False)

class WebsocketTransportFactory(WebSocketServerFactory):
    def __init__(self, port, is_secure=False, debug=False, signing_key=None, signing_id=None,
                 event_handler=GenericEventHandler):
        self.debug = debug
        self.signing_key = signing_key
        self.signing_id = signing_id
        self.protocol = WebsocketServerProtocol
        self.event_handler = event_handler

        if is_secure:
            uri = "wss://0.0.0.0:%d" % port
        else:
            uri = "ws://0.0.0.0:%d" % port

        WebSocketServerFactory.__init__(self, uri)

# P.S. There's not Websocket client implementation yet
# P.P.S. And it probably won't be for long time...'


in your web explore type your ip/MPOS/public to see your built server.

last thing

cd
cd stratum-mining
twisted -y -launcher.tac










member
Activity: 84
Merit: 10
Part 2

The commands needed to install the stratum server are:

git clone https://github.com/Tydus/litecoin_scrypt
git clone https://github.com/ahmedbodi/stratum-mining
git clone https://github.com/ahmedbodi/stratum

cd stratum-mining
git submodule init
git submodule update

cd externals/litecoin_scrypt
sudo python setup.py install

cd ~
cd stratum-mining/externals/stratum
sudo python setup.py install

cd~
cp stratum-mining/conf/config_sample.py stratum-mining/conf/config.py
sudo nano stratum-mining/conf/config.py




This is how it should look

'''
This is example configuration for Stratum server.
Please rename it to config.py and fill correct values.

This is already setup with sane values for solomining.
You NEED to set the parameters in BASIC SETTINGS
'''

# ******************** BASIC SETTINGS ***************
# These are the MUST BE SET parameters!

CENTRAL_WALLET = 'CdQQns45eJcPr3bhgyARbpd3xakGt9dFbZ'                # Local coin address where money goes

COINDAEMON_TRUSTED_HOST = 'localhost'
COINDAEMON_TRUSTED_PORT = 9332
COINDAEMON_TRUSTED_USER = 'username'
COINDAEMON_TRUSTED_PASSWORD = 'password'

# Coin algorithm is the option used to determine the algorithm used by stratum
# This currently works with POW and POS coins
# The available options are:
# scrypt, sha256d, scrypt-jane, skeinhash, quark and riecoin
# If the option does not meet either of these criteria stratum defaults to scrypt
# For Coins which support TX Messages please enter yes in the TX selection
COINDAEMON_ALGO = 'sha256d'
COINDAEMON_TX = 'no'

# ******************** BASIC SETTINGS ***************
# Backup Coin Daemon address's (consider having at least 1 backup)
# You can have up to 99

#COINDAEMON_TRUSTED_HOST_1 = 'localhost'
#COINDAEMON_TRUSTED_PORT_1 = 28332
#COINDAEMON_TRUSTED_USER_1 = 'user'
#COINDAEMON_TRUSTED_PASSWORD_1 = 'somepassword'
# ******************** GENERAL SETTINGS ***************
# Set process name of twistd, much more comfortable if you run multiple processes on one machine
STRATUM_MINING_PROCESS_NAME= 'twistd-stratum-mining-Capstone'


# Enable some verbose debug (logging requests and responses).
DEBUG = False

# Destination for application logs, files rotated once per day.
LOGDIR = 'log/'

# Main application log file.
LOGFILE = None      # eg. 'stratum.log'
LOGLEVEL = 'DEBUG'
# Logging Rotation can be enabled with the following settings
# It if not enabled here, you can set up logrotate to rotate the files.
# For built in log rotation set LOG_ROTATION = True and configure the variables
LOG_ROTATION = True
LOG_SIZE = 10485760 # Rotate every 10M
LOG_RETENTION = 10 # Keep 10 Logs

# How many threads use for synchronous methods (services).
# 30 is enough for small installation, for real usage
# it should be slightly more, say 100-300.
THREAD_POOL_SIZE = 300

# ******************** TRANSPORTS *********************
# Hostname or external IP to expose
HOSTNAME = 'localhost'

# Disable the example service
ENABLE_EXAMPLE_SERVICE = False

# Port used for Socket transport. Use 'None' for disabling the transport.
LISTEN_SOCKET_TRANSPORT = 3333
# Port used for HTTP Poll transport. Use 'None' for disabling the transport
LISTEN_HTTP_TRANSPORT = None
# Port used for HTTPS Poll transport
LISTEN_HTTPS_TRANSPORT = None
# Port used for WebSocket transport, 'None' for disabling WS
LISTEN_WS_TRANSPORT = None
# Port used for secure WebSocket, 'None' for disabling WSS
LISTEN_WSS_TRANSPORT = None

# Salt used for Block Notify Password
PASSWORD_SALT = 'some_crazy_string'

# ******************** Database  *********************
DATABASE_DRIVER = 'mysql'       # Options: none, sqlite, postgresql or mysql
DATABASE_EXTEND = False         # SQLite and PGSQL Only!

# SQLite
DB_SQLITE_FILE = 'pooldb.sqlite'
# Postgresql
DB_PGSQL_HOST = 'localhost'
DB_PGSQL_DBNAME = 'pooldb'
DB_PGSQL_USER = 'pooldb'
DB_PGSQL_PASS = '**empty**'
DB_PGSQL_SCHEMA = 'public'
# MySQL
DB_MYSQL_HOST = 'localhost'
DB_MYSQL_DBNAME = 'Capstone'
DB_MYSQL_USER = 'root'
DB_MYSQL_PASS = 'password'
DB_MYSQL_PORT = 3306            # Default port for MySQL

# ******************** Adv. DB Settings *********************
#  Don't change these unless you know what you are doing

DB_LOADER_CHECKTIME = 15        # How often we check to see if we should run the loader
DB_LOADER_REC_MIN = 10          # Min Records before the bulk loader fires
DB_LOADER_REC_MAX = 50          # Max Records the bulk loader will commit at a time
DB_LOADER_FORCE_TIME = 300      # How often the cache should be flushed into the DB regardless of size.
DB_STATS_AVG_TIME = 300         # When using the DATABASE_EXTEND option, average speed over X sec
                                # Note: this is also how often it updates
DB_USERCACHE_TIME = 600         # How long the usercache is good for before we refresh

# ******************** Pool Settings *********************

# User Auth Options
USERS_AUTOADD = False           # Automatically add users to database when they connect.
                                # This basically disables User Auth for the pool.
USERS_CHECK_PASSWORD = False    # Check the workers password? (Many pools don't)

# Transaction Settings
COINBASE_EXTRAS = '/stratumPool/'           # Extra Descriptive String to incorporate in solved blocks
ALLOW_NONLOCAL_WALLET = False               # Allow valid, but NON-Local wallet's

# Coin Daemon communication polling settings (In Seconds)
PREVHASH_REFRESH_INTERVAL = 5   # How often to check for new Blocks

MERKLE_REFRESH_INTERVAL = 60    # How often check memorypool
                                #   This effectively resets the template and incorporates new transactions.
                                #   This should be "slow"

INSTANCE_ID = 31                # Used for extranonce and needs to be 0-31

# ******************** Pool Difficulty Settings *********************
VDIFF_X2_TYPE = True            # Powers of 2 e.g. 2,4,8,16,32,64,128,256,512,1024
VDIFF_FLOAT = False             # Use float difficulty

# Pool Target (Base Difficulty)
POOL_TARGET = 1                 # Pool-wide difficulty target int >= 1

# Variable Difficulty Enable
VARIABLE_DIFF = True            # Master variable difficulty enable

# Variable diff tuning variables
#VARDIFF will start at the POOL_TARGET. It can go as low as the VDIFF_MIN and as high as min(VDIFF_MAX or coindaemons difficulty)
USE_COINDAEMON_DIFF = False     # Set the maximum difficulty to the coindaemon difficulty.
DIFF_UPDATE_FREQUENCY = 86400   # Update the coindaemon difficulty once a day for the VARDIFF maximum
VDIFF_MIN_TARGET = 16           # Minimum target difficulty
VDIFF_MAX_TARGET = 1024         # Maximum target difficulty
VDIFF_TARGET_TIME = 15          # Target time per share (i.e. try to get 1 share per this many seconds)
VDIFF_RETARGET_TIME = 120       # Check to see if we should retarget this often
VDIFF_VARIANCE_PERCENT = 30     # Allow average time to very this % from target without retarget

# Allow external setting of worker difficulty, checks pool_worker table datarow[6] position for target difficulty
# if present or else defaults to pool target, over rides all other difficulty settings, no checks are made
# for min or max limits this should be done by your front end software
ALLOW_EXTERNAL_DIFFICULTY = False

#### Advanced Option #####
# For backwards compatibility, we send the scrypt hash to the solutions column in the shares table
# For block confirmation, we have an option to send the block hash in
# Please make sure your front end is compatible with the block hash in the solutions table.
# For People using the MPOS frontend enabling this is recommended. It allows the frontend to compare the block hash to the coin daemon reducin$

BLOCK_CHECK_SCRYPT_HASH = False

# ******************** Worker Ban Options *********************
ENABLE_WORKER_BANNING = True    # Enable/disable temporary worker banning
WORKER_CACHE_TIME = 600         # How long the worker stats cache is good before we check and refresh
WORKER_BAN_TIME = 300           # How long we temporarily ban worker
INVALID_SHARES_PERCENT = 50     # Allow average invalid shares vary this % before we ban

# ******************** E-Mail Notification Settings *********************
NOTIFY_EMAIL_TO = ''                                            # Where to send Start/Found block notifications
NOTIFY_EMAIL_TO_DEADMINER = ''                                  # Where to send dead miner notifications
NOTIFY_EMAIL_FROM = 'root@localhost'                            # Sender address
NOTIFY_EMAIL_SERVER = 'localhost'                               # E-Mail sender
NOTIFY_EMAIL_USERNAME = ''                                      # E-Mail server SMTP logon
NOTIFY_EMAIL_PASSWORD = ''
NOTIFY_EMAIL_USETLS = True

# ******************** Memcache Settings *********************
# Memcahce is a requirement. Enter the settings below
MEMCACHE_HOST = "localhost"     # Hostname or IP that runs memcached
MEMCACHE_PORT = 11211           # Port
MEMCACHE_TIMEOUT = 900          # Key timeout
MEMCACHE_PREFIX = "stratum_"    # Prefix for keys


member
Activity: 84
Merit: 10
Start with linux ubuntu 14.04 do not update until after you finish the 3 sets.


Part 1: Building and compiling the wallet
Part 2: Building and configuring the stratum server
Part 3: Building and configuring the Web Front End and final testing

Part 1: Building and compiling the wallet

Dependencies you will need (run these commands in this order before you start to make sure everything will work as expected):

sudo apt-get install git screen watch

sudo apt-get install build-essential libboost-all-dev libcurl4-openssl-dev libdb5.1-dev libdb5.1++-dev mysql-server

This example I am using password for my sql password

sudo apt-get install python-twisted python-mysqldb python-dev python-setuptools python-memcache python-simplejson python-pylibmc

sudo easy_install -U distribute

sudo apt-get install memcached php5-memcached php5-mysqlnd php5-curl php5-json libapache2-mod-php5

sudo apache2ctl -k stop; sleep 2; sudo apache2ctl -k start


Download open source coding

git clone https://github.com/CapstoneDigitalMining/Capstone-src

permissions

cd  Capstone-src/src/leveldb

chmod a+x build_detect_platform

cd ..

make -f makefile.unix USE_UPNP=-


Make config file

cd .Capstone

cd Capstone.conf


It should look like this

rpcuser=username
rpcpassword=password
rpcallowip=127.0.0.1
rpcport=9332
daemon=1
server=1
gen=0
listen=1
addnode=104.131.163.132


Start server

cd  Capstone-src/src/
./Capstoned


Jump to: