From 9977bae7b43df91695f9e3df459edfe32e4233b2 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sat, 11 Feb 2017 11:47:36 -0800 Subject: [PATCH 1/4] Updates to fix a .sql bug. Adding a script to migrate configuration values in the future. --- sample_config.sql | 2 +- sql_sync/config_entries.json | 514 +++++++++++++++++++++++++++++++++++ sql_sync/sql_sync.js | 29 ++ 3 files changed, 544 insertions(+), 1 deletion(-) create mode 100644 sql_sync/config_entries.json create mode 100644 sql_sync/sql_sync.js diff --git a/sample_config.sql b/sample_config.sql index 0c58d49..0f96829 100644 --- a/sample_config.sql +++ b/sample_config.sql @@ -1,5 +1,5 @@ UPDATE pool.config SET item_value = '' WHERE module = 'pool' and item = 'address'; -UPDATE pool.config SET item_value = '' WHERE module = 'pool' and item = 'feeAddress'; +UPDATE pool.config SET item_value = '' WHERE module = 'payout' and item = 'feeAddress'; UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'mailgunKey'; UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'mailgunURL'; UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'emailFrom'; diff --git a/sql_sync/config_entries.json b/sql_sync/config_entries.json new file mode 100644 index 0000000..2db2aa4 --- /dev/null +++ b/sql_sync/config_entries.json @@ -0,0 +1,514 @@ +[ + { + "id": 1, + "module": "pool", + "item": "address", + "item_value": "44GWfqCiW7PH3njtPPfAY5Q38x8QfQCeGjKFp4WejNoTAWq7apSrR2jRLERFmpbh4V9knMZz4GrG2bgQMfmc3w888p7x4sd", + "item_type": "string", + "Item_desc": "Address to mine to, this should be the wallet-rpc address." + }, + { + "id": 2, + "module": "pool", + "item": "minerTimeout", + "item_value": "900", + "item_type": "int", + "Item_desc": "Length of time before a miner is flagged inactive." + }, + { + "id": 3, + "module": "pool", + "item": "banEnabled", + "item_value": "true", + "item_type": "bool", + "Item_desc": "Enables/disabled banning of \"bad\" miners." + }, + { + "id": 4, + "module": "pool", + "item": "banLength", + "item_value": "-15m", + "item_type": "string", + "Item_desc": "Ban duration except perma-bans" + }, + { + "id": 5, + "module": "pool", + "item": "targetTime", + "item_value": "30", + "item_type": "int", + "Item_desc": "Time in seconds between share finds" + }, + { + "id": 6, + "module": "pool", + "item": "trustThreshold", + "item_value": "30", + "item_type": "int", + "Item_desc": "Number of shares before miner trust can kick in." + }, + { + "id": 8, + "module": "pool", + "item": "banPercent", + "item_value": "25", + "item_type": "int", + "Item_desc": "Percentage of shares that need to be invalid to be banned." + }, + { + "id": 9, + "module": "pool", + "item": "banThreshold", + "item_value": "30", + "item_type": "int", + "Item_desc": "Number of shares before bans can begin" + }, + { + "id": 10, + "module": "pool", + "item": "trustedMiners", + "item_value": "true", + "item_type": "bool", + "Item_desc": "Enable the miner trust system" + }, + { + "id": 11, + "module": "pool", + "item": "trustChange", + "item_value": "1", + "item_type": "int", + "Item_desc": "Change in the miner trust in percent" + }, + { + "id": 12, + "module": "pool", + "item": "trustMin", + "item_value": "20", + "item_type": "int", + "Item_desc": "Minimum level of miner trust" + }, + { + "id": 13, + "module": "pool", + "item": "trustPenalty", + "item_value": "30", + "item_type": "int", + "Item_desc": "Number of shares that must be successful to be trusted, reset to this value if trust share is broken" + }, + { + "id": 14, + "module": "pool", + "item": "retargetTime", + "item_value": "60", + "item_type": "int", + "Item_desc": "Time between difficulty retargets" + }, + { + "id": 15, + "module": "daemon", + "item": "address", + "item_value": "127.0.0.1", + "item_type": "string", + "Item_desc": "Monero Daemon RPC IP" + }, + { + "id": 16, + "module": "daemon", + "item": "port", + "item_value": "18081", + "item_type": "int", + "Item_desc": "Monero Daemon RPC Port" + }, + { + "id": 17, + "module": "wallet", + "item": "address", + "item_value": "127.0.0.1", + "item_type": "string", + "Item_desc": "Monero Daemon RPC Wallet IP" + }, + { + "id": 18, + "module": "wallet", + "item": "port", + "item_value": "37458", + "item_type": "int", + "Item_desc": "Monero Daemon RPC Wallet Port" + }, + { + "id": 21, + "module": "rpc", + "item": "https", + "item_value": "false", + "item_type": "bool", + "Item_desc": "Enable RPC over SSL" + }, + { + "id": 22, + "module": "pool", + "item": "maxDifficulty", + "item_value": "500000", + "item_type": "int", + "Item_desc": "Maximum difficulty for VarDiff" + }, + { + "id": 23, + "module": "pool", + "item": "minDifficulty", + "item_value": "100", + "item_type": "int", + "Item_desc": "Minimum difficulty for VarDiff" + }, + { + "id": 24, + "module": "pool", + "item": "varDiffVariance", + "item_value": "20", + "item_type": "int", + "Item_desc": "Percentage out of the target time that difficulty changes" + }, + { + "id": 25, + "module": "pool", + "item": "varDiffMaxChange", + "item_value": "30", + "item_type": "int", + "Item_desc": "Percentage amount that the difficulty may change" + }, + { + "id": 27, + "module": "payout", + "item": "btcFee", + "item_value": "1.5", + "item_type": "float", + "Item_desc": "Fee charged for auto withdrawl via BTC" + }, + { + "id": 28, + "module": "payout", + "item": "ppsFee", + "item_value": "6.5", + "item_type": "float", + "Item_desc": "Fee charged for usage of the PPS pool" + }, + { + "id": 29, + "module": "payout", + "item": "pplnsFee", + "item_value": ".6", + "item_type": "float", + "Item_desc": "Fee charged for the usage of the PPLNS pool" + }, + { + "id": 30, + "module": "payout", + "item": "propFee", + "item_value": ".7", + "item_type": "float", + "Item_desc": "Fee charged for the usage of the proportial pool" + }, + { + "id": 31, + "module": "payout", + "item": "soloFee", + "item_value": ".4", + "item_type": "float", + "Item_desc": "Fee charged for usage of the solo mining pool" + }, + { + "id": 32, + "module": "payout", + "item": "exchangeMin", + "item_value": "5", + "item_type": "float", + "Item_desc": "Minimum XMR balance for payout to exchange/payment ID" + }, + { + "id": 33, + "module": "payout", + "item": "walletMin", + "item_value": ".3", + "item_type": "float", + "Item_desc": "Minimum XMR balance for payout to personal wallet" + }, + { + "id": 34, + "module": "payout", + "item": "devDonation", + "item_value": "5", + "item_type": "float", + "Item_desc": "Donation to XMR core development" + }, + { + "id": 35, + "module": "payout", + "item": "poolDevDonation", + "item_value": "0", + "item_type": "float", + "Item_desc": "Donation to pool developer" + }, + { + "id": 36, + "module": "payout", + "item": "denom", + "item_value": ".000001", + "item_type": "float", + "Item_desc": "Minimum balance that will be paid out to." + }, + { + "id": 37, + "module": "payout", + "item": "blocksRequired", + "item_value": "60", + "item_type": "int", + "Item_desc": "Blocks required to validate a payout before it's performed." + }, + { + "id": 38, + "module": "general", + "item": "sigDivisor", + "item_value": "1000000000000", + "item_type": "int", + "Item_desc": "Divisor for turning coin into human readable amounts " + }, + { + "id": 39, + "module": "payout", + "item": "feeAddress", + "item_value": "48WnWpKMuLrfgy4YpjPjoYSDyqgVx5fCSgrSydVPy7Jmii4y2TwEi8DcH5TM9aRm56jGQnXmurXBeTWe3xjCKbjuAX1qYZt", + "item_type": "string", + "Item_desc": "Address that pool fees are sent to." + }, + { + "id": 40, + "module": "payout", + "item": "feesForTXN", + "item_value": "10", + "item_type": "int", + "Item_desc": "Amount of XMR that is left from the fees to pay miner fees." + }, + { + "id": 41, + "module": "payout", + "item": "maxTxnValue", + "item_value": "250", + "item_type": "int", + "Item_desc": "Maximum amount of XMR to send in a single transaction" + }, + { + "id": 42, + "module": "payout", + "item": "shapeshiftPair", + "item_value": "xmr_btc", + "item_type": "string", + "Item_desc": "Pair to use in all shapeshift lookups for auto BTC payout" + }, + { + "id": 43, + "module": "general", + "item": "coinCode", + "item_value": "XMR", + "item_type": "string", + "Item_desc": "Coincode to be loaded up w/ the shapeshift getcoins argument." + }, + { + "id": 44, + "module": "general", + "item": "allowBitcoin", + "item_value": "true", + "item_type": "bool", + "Item_desc": "Allow the pool to auto-payout to BTC via ShapeShift" + }, + { + "id": 45, + "module": "payout", + "item": "exchangeRate", + "item_value": "1217200", + "item_type": "float", + "Item_desc": "Current exchange rate" + }, + { + "id": 46, + "module": "payout", + "item": "bestExchange", + "item_value": "xmrto", + "item_type": "string", + "Item_desc": "Current best exchange" + }, + { + "id": 47, + "module": "payout", + "item": "mixIn", + "item_value": "4", + "item_type": "int", + "Item_desc": "Mixin count for coins that support such things." + }, + { + "id": 48, + "module": "pool", + "item": "geoDNS", + "item_value": "mine.xmrpool.net", + "item_type": "string", + "Item_desc": "geoDNS enabled address for the pool." + }, + { + "id": 49, + "module": "general", + "item": "statsBufferLength", + "item_value": "120", + "item_type": "int", + "Item_desc": "Number of items to be cached in the stats buffers." + }, + { + "id": 50, + "module": "api", + "item": "authKey", + "item_value": "", + "item_type": "string", + "Item_desc": "Auth key sent with all Websocket frames for validation" + }, + { + "id": 51, + "module": "general", + "item": "mailgunKey", + "item_value": "", + "item_type": "string", + "Item_desc": "MailGun API Key for notification" + }, + { + "id": 52, + "module": "general", + "item": "mailgunURL", + "item_value": "", + "item_type": "string", + "Item_desc": "MailGun URL for notifications" + }, + { + "id": 53, + "module": "general", + "item": "emailFrom", + "item_value": "", + "item_type": "string", + "Item_desc": "From address for the notification emails" + }, + { + "id": 54, + "module": "pps", + "item": "enable", + "item_value": "false", + "item_type": "bool", + "Item_desc": "Enable PPS or not" + }, + { + "id": 55, + "module": "pplns", + "item": "shareMulti", + "item_value": "2", + "item_type": "int", + "Item_desc": "Multiply this times difficulty to set the N in PPLNS" + }, + { + "id": 56, + "module": "pplns", + "item": "shareMultiLog", + "item_value": "3", + "item_type": "int", + "Item_desc": "How many times the difficulty of the current block do we keep in shares before clearing them out" + }, + { + "id": 57, + "module": "general", + "item": "blockCleaner", + "item_value": "true", + "item_type": "bool", + "Item_desc": "Enable the deletion of blocks or not." + }, + { + "id": 58, + "module": "api", + "item": "secKey", + "item_value": "", + "item_type": "string", + "Item_desc": "HMAC key for Passwords. JWT Secret Key" + }, + { + "id": 59, + "module": "payout", + "item": "feeSlewAmount", + "item_value": ".011", + "item_type": "float", + "Item_desc": "Amount to charge for the txn fee" + }, + { + "id": 60, + "module": "payout", + "item": "feeSlewEnd", + "item_value": "4", + "item_type": "float", + "Item_desc": "Value at which txn fee amount drops to 0" + }, + { + "id": 61, + "module": "general", + "item": "testnet", + "item_value": "false", + "item_type": "bool", + "Item_desc": "Does this pool use testnet?" + }, + { + "id": 62, + "module": "pplns", + "item": "enable", + "item_value": "true", + "item_type": "bool", + "Item_desc": "Enable PPLNS on the pool." + }, + { + "id": 63, + "module": "solo", + "item": "enable", + "item_value": "true", + "item_type": "bool", + "Item_desc": "Enable SOLO mining on the pool" + }, + { + "id": 64, + "module": "general", + "item": "adminEmail", + "item_value": "", + "item_type": "string", + "Item_desc": "Admin e-mail to send e-mails to when something isn't working right." + }, + { + "id": 65, + "module": "payout", + "item": "rpcPasswordEnabled", + "item_value": "false", + "item_type": "bool", + "Item_desc": "Does the wallet use a RPC password?" + }, + { + "id": 66, + "module": "payout", + "item": "rpcPasswordPath", + "item_value": "", + "item_type": "string", + "Item_desc": "Path and file for the RPC password file location" + }, + { + "id": 67, + "module": "payout", + "item": "maxPaymentTxns", + "item_value": "5", + "item_type": "int", + "Item_desc": "Maximum number of transactions in a single payment" + }, + { + "id": 68, + "module": "general", + "item": "shareHost", + "item_value": "", + "item_type": "string", + "Item_desc": "Host that receives share information" + } +] \ No newline at end of file diff --git a/sql_sync/sql_sync.js b/sql_sync/sql_sync.js new file mode 100644 index 0000000..fe1f73a --- /dev/null +++ b/sql_sync/sql_sync.js @@ -0,0 +1,29 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let config = fs.readFileSync("../config.json"); +let sql_schema = fs.readFileSync("config_entries.json"); + +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.schema = JSON.parse(sql_schema); + +// Config Table Layout +// . + +let loopCount = 0; +let updatedCount = 0; +global.schema.forEach(function(entry){ + loopCount += 1; + global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){ + if (rows.length > 0){ + return; + } + updatedCount += 1; + global.mysql.query("INSERT INTO config (module, item, item_value, item_type, Item_desc) VALUES (?, ?, ?, ?, ?)", [entry.module, entry.item, entry.item_value, entry.item_type, entry.Item_desc]); + if(loopCount === global.schema.length){ + console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!"); + process.exit(); + } + }); +}); \ No newline at end of file From 4af3a383555a39f6ab65e6c849f9b6cdeb10ca87 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sat, 11 Feb 2017 11:52:30 -0800 Subject: [PATCH 2/4] Moving loop counter to inside of the sql select, and adding an extra abort stage. --- sql_sync/sql_sync.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql_sync/sql_sync.js b/sql_sync/sql_sync.js index fe1f73a..e7e39a4 100644 --- a/sql_sync/sql_sync.js +++ b/sql_sync/sql_sync.js @@ -14,9 +14,13 @@ global.schema = JSON.parse(sql_schema); let loopCount = 0; let updatedCount = 0; global.schema.forEach(function(entry){ - loopCount += 1; global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){ + loopCount += 1; if (rows.length > 0){ + if(loopCount === global.schema.length){ + console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!"); + process.exit(); + } return; } updatedCount += 1; From f8be94b4f26a325e735431eb0a827b2b0fe509d3 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sat, 11 Feb 2017 11:57:32 -0800 Subject: [PATCH 3/4] Couple of configuration updates, and removing a couple of defaults that should be blank and sane. --- README.md | 8 ++++++++ sql_sync/config_entries.json | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0c5d1bf..2d0d068 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,14 @@ UPDATE pool.users SET email='your new password here' WHERE username='Administrat ``` The email field is used as the default password field until the password is changed, at which point, it's hashed and dumped into the password field instead, and using the email field as a password is disabled. +Pool Update Procedures +====================== +If upgrading the pool, please do a git pull to get the latest code within the pool's directory. + +Once complete, please cd into sql_sync, then run node sql_sync.js + +This will update your pool with the latest config options with any defaults that the pools may set. + Pool Troubleshooting ==================== diff --git a/sql_sync/config_entries.json b/sql_sync/config_entries.json index 2db2aa4..ee84eb3 100644 --- a/sql_sync/config_entries.json +++ b/sql_sync/config_entries.json @@ -3,7 +3,7 @@ "id": 1, "module": "pool", "item": "address", - "item_value": "44GWfqCiW7PH3njtPPfAY5Q38x8QfQCeGjKFp4WejNoTAWq7apSrR2jRLERFmpbh4V9knMZz4GrG2bgQMfmc3w888p7x4sd", + "item_value": "", "item_type": "string", "Item_desc": "Address to mine to, this should be the wallet-rpc address." }, @@ -275,7 +275,7 @@ "id": 39, "module": "payout", "item": "feeAddress", - "item_value": "48WnWpKMuLrfgy4YpjPjoYSDyqgVx5fCSgrSydVPy7Jmii4y2TwEi8DcH5TM9aRm56jGQnXmurXBeTWe3xjCKbjuAX1qYZt", + "item_value": "", "item_type": "string", "Item_desc": "Address that pool fees are sent to." }, @@ -347,7 +347,7 @@ "id": 48, "module": "pool", "item": "geoDNS", - "item_value": "mine.xmrpool.net", + "item_value": "", "item_type": "string", "Item_desc": "geoDNS enabled address for the pool." }, From 8a3d9dcf246a4f603a1baef04e28dd7a0f8aab6e Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sat, 11 Feb 2017 12:01:51 -0800 Subject: [PATCH 4/4] Adding timestamps to PM2 startup stuff. --- README.md | 12 ++++++------ deployment/deploy.bash | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ef21b3e..e2aba92 100644 --- a/README.md +++ b/README.md @@ -58,12 +58,12 @@ Deployment via Installer 8. Once you're happy with the settings, go ahead and start all the pool daemons, commands follow. ```bash -pm2 start init.js --name=blockManager -- --module=blockManager -pm2 start init.js --name=worker -- --module=worker -pm2 start init.js --name=payments -- --module=payments -pm2 start init.js --name=remoteShare -- --module=remoteShare -pm2 start init.js --name=longRunner -- --module=longRunner -pm2 start init.js --name=pool -- --module=pool +pm2 start init.js --name=blockManager --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=blockManager +pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=worker +pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=payments +pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=remoteShare +pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=longRunner +pm2 start init.js --name=pool --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=pool pm2 restart api ``` diff --git a/deployment/deploy.bash b/deployment/deploy.bash index a68c78b..990b8da 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -87,5 +87,5 @@ pm2 install pm2-logrotate mysql -u root --password=$ROOT_SQL_PASS < deployment/base.sql mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')" mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" -pm2 start init.js --name=api -- --module=api +pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" \ No newline at end of file