From db94117366d1e7f8c8f6f57192df9e7a3f98a601 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Aug 2018 03:20:12 +0200 Subject: [PATCH 0001/1496] Merge branch 'master' of https://github.com/MoneroOcean/nodejs-pool From e661c2f8151e5920a048c147bb6ca4b9d180285c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Aug 2018 09:33:13 +0200 Subject: [PATCH 0002/1496] Do not switch from current algo if it is less than 5 percent profitable --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3e4161891..34215a7b0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -704,12 +704,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } let best_algo = ""; let best_algo_perf = this.algos_perf[""]; + if (this.curr_algo === "") best_algo_perf *= 1.05; let miner = this; ALGOS.forEach(function(algo) { if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; - const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; + let algoHashFactor = global.config.daemon["algoHashFactor" + algo]; + if (this.curr_algo === algo) algoHashFactor *= 1.05; if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { debug(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); best_algo = algo; From 3f45f353a661b27afd4f925b4cddbf40e5aa0053 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Aug 2018 09:36:32 +0200 Subject: [PATCH 0003/1496] Fixed typo --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 34215a7b0..26b154271 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -711,7 +711,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const port = activeBlockTemplate[algo].port; if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; let algoHashFactor = global.config.daemon["algoHashFactor" + algo]; - if (this.curr_algo === algo) algoHashFactor *= 1.05; + if (miner.curr_algo === algo) algoHashFactor *= 1.05; if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { debug(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); best_algo = algo; From 01c4754551ec0af31b6250972332061036fd8595 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Aug 2018 17:14:24 +0200 Subject: [PATCH 0004/1496] Moved cn specific stuf to xmr.js --- lib/coins/xmr.js | 6 ++++++ lib/pool.js | 15 +++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f5de82184..cd052e408 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -213,6 +213,12 @@ function Coin(data){ }; }; + // returns true if algo array reported by miner is OK or error string otherwise + this.algoCheck = function(algos) { + return algos.includes("cn/1") || algos.includes("cryptonight/1") ? + true : "algo array should include cn/1 or cryptonight/1"; + } + this.cryptoNight = function(convertedBlob, port) { switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon diff --git a/lib/pool.js b/lib/pool.js index 26b154271..5be290dc8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -568,11 +568,16 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.setAlgos = function(algos, algos_perf) { - if (algos && (algos instanceof Array) && (algos.includes("cn/1") || algos.includes("cryptonight/1"))) { - this.algos = {}; - for (let i in algos) this.algos[algos[i]] = 1; + if (algos && algos instanceof Array) { + const check = global.coinFuncs.algoCheck(algos); + if (check === true) { + this.algos = {}; + for (let i in algos) this.algos[algos[i]] = 1; + } else { + return check; + } } else { - return "algo array should include cn/1 or cryptonight/1"; + return "algo should be array"; } if (algos_perf && (algos_perf instanceof Object)) { this.algos_perf = {}; @@ -591,8 +596,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (algos) { if (!algos_perf) algos_perf = { "cn/1": 1 }; - //console.error(JSON.stringify(algos)); - //console.error(JSON.stringify(algos_perf)); const status = this.setAlgos(algos, algos_perf); if (status != "") { this.error = status; From 250d8bff6a395d37274c989e52cc99dd69182bc9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 12 Aug 2018 20:27:56 +0200 Subject: [PATCH 0005/1496] Fixed msr algo_perf detection --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5be290dc8..9015ff544 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -584,7 +584,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer for (let algo in algos_perf) { if (algo.includes("heavy")) this.algos_perf["Heavy"] = algos_perf[algo]; else if (algo.includes("lite")) this.algos_perf["Light"] = algos_perf[algo]; - else if (algo.includes("fast")) this.algos_perf["Fast"] = algos_perf[algo]; + else if (algo.includes("fast") || algo.includes("msr")) this.algos_perf["Fast"] = algos_perf[algo]; else this.algos_perf[""] = this.algos_perf["XTL"] = algos_perf[algo]; } if (!this.algos_perf[""]) return "algo_perf set should include non heavy/lite/fast hashrate"; From 35d9cadcbfa620e4d3e7dd6950ec9be2165ca42b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 13 Aug 2018 10:34:06 +0200 Subject: [PATCH 0006/1496] Added LOKI support --- deployment/base.sql | 1 + lib/coins/xmr.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 11d8cd237..a3228e7d1 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -242,6 +242,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_17750', '', 'string', 'Address to mine to for 17750 (Haven) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_24182', '', 'string', 'Address to mine to for 24182 (BitTube) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Stellite) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_22023', '', 'string', 'Address to mine to for 22023 (Loki) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunURL', '', 'string', 'MailGun URL for notifications'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index cd052e408..1c31851c8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -225,6 +225,7 @@ function Coin(data){ case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite + case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR default: return multiHashing.cryptonight(convertedBlob, 1); @@ -244,6 +245,7 @@ function Coin(data){ case 12211: return "cryptonight-heavy/0"; // RYO case 17750: return "cryptonight-heavy/xhv"; // Haven case 20189: return "cryptonight/xtl"; // Stellite + case 22023: return "cryptonight-heavy/0"; // LOKI case 24182: return "cryptonight-heavy/tube"; // BitTube case 38081: return "cryptonight/msr"; // MSR default: return "cryptonight/1"; @@ -256,6 +258,7 @@ function Coin(data){ case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 20189: return "cn/xtl"; // Stellite + case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 38081: return "cn/msr"; // MSR default: return "cn/1"; @@ -267,6 +270,7 @@ function Coin(data){ case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven case 20189: return "xtl"; // Stellite + case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube case 38081: return "msr"; // MSR default: return "1"; From d38cd785327ac5cfc8ef5b56de253840879f40d1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 13 Aug 2018 17:23:08 +0200 Subject: [PATCH 0007/1496] Fixed block reward for dev fee coins --- lib/coins/xmr.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1c31851c8..105df6d03 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -77,8 +77,20 @@ function Coin(data){ }; this.getPortBlockHeaderByHash = function(port, blockHash, callback){ - global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ + global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { + if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { + const blockJson = JSON.parse(body.result.json); + body.result.block_header.reward = 0; + + const minerTx = blockJson.miner_tx; + if (minerTx.vout.length != 2) console.error('Coinbase transaction vout size is not 2'); + + for (var i=0; i body.result.block_header.reward) { + body.result.block_header.reward = minerTx.vout[i].amount; + } + } + return callback(null, body.result.block_header); } else { console.error(JSON.stringify(body)); From e36e01d59c824c6e1c80680a781ffcffdee67633 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 13 Aug 2018 17:26:13 +0200 Subject: [PATCH 0008/1496] Fixed block reward for dev fee coins --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 105df6d03..be435e38e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -83,7 +83,7 @@ function Coin(data){ body.result.block_header.reward = 0; const minerTx = blockJson.miner_tx; - if (minerTx.vout.length != 2) console.error('Coinbase transaction vout size is not 2'); + //if (minerTx.vout.length != 2) console.error('Coinbase transaction vout size is not 2'); for (var i=0; i body.result.block_header.reward) { From b8738b570605c4ccd7c7f1500b88cecf2701136c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 14 Aug 2018 12:22:19 +0200 Subject: [PATCH 0009/1496] Made algo check less strict --- lib/pool.js | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9015ff544..23d1318f1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -568,34 +568,26 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.setAlgos = function(algos, algos_perf) { - if (algos && algos instanceof Array) { - const check = global.coinFuncs.algoCheck(algos); - if (check === true) { - this.algos = {}; - for (let i in algos) this.algos[algos[i]] = 1; - } else { - return check; - } + const check = global.coinFuncs.algoCheck(algos); + if (check === true) { + this.algos = {}; + for (let i in algos) this.algos[algos[i]] = 1; } else { - return "algo should be array"; + return check; } - if (algos_perf && (algos_perf instanceof Object)) { - this.algos_perf = {}; - for (let algo in algos_perf) { - if (algo.includes("heavy")) this.algos_perf["Heavy"] = algos_perf[algo]; - else if (algo.includes("lite")) this.algos_perf["Light"] = algos_perf[algo]; - else if (algo.includes("fast") || algo.includes("msr")) this.algos_perf["Fast"] = algos_perf[algo]; - else this.algos_perf[""] = this.algos_perf["XTL"] = algos_perf[algo]; - } - if (!this.algos_perf[""]) return "algo_perf set should include non heavy/lite/fast hashrate"; - } else { - return "algo_perf set should be present"; + this.algos_perf = {}; + for (let algo in algos_perf) { + if (algo.includes("heavy")) this.algos_perf["Heavy"] = algos_perf[algo]; + else if (algo.includes("lite")) this.algos_perf["Light"] = algos_perf[algo]; + else if (algo.includes("fast") || algo.includes("msr")) this.algos_perf["Fast"] = algos_perf[algo]; + else this.algos_perf[""] = this.algos_perf["XTL"] = algos_perf[algo]; } + if (!this.algos_perf[""]) return "algo_perf set should include non heavy/lite/fast hashrate"; return ""; }; - if (algos) { - if (!algos_perf) algos_perf = { "cn/1": 1 }; + if (algos && algos instanceof Array) { + if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn/1": 1 }; const status = this.setAlgos(algos, algos_perf); if (status != "") { this.error = status; @@ -1377,7 +1369,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } miner.heartbeat(); - if (miner.algos && params.algo && params["algo-perf"]) { + if (miner.algos && params.algo && params.algo instanceof Array && params["algo-perf"] && params["algo-perf"] instanceof Object) { const status = miner.setAlgos(params.algo, params["algo-perf"]); if (status != "") { sendReply(status); From a26d83960c42aac1737ed6c0a2919b91eb75c62e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 14 Aug 2018 18:40:45 +0200 Subject: [PATCH 0010/1496] Fixed reward detection for XTL --- lib/coins/xmr.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index be435e38e..937d37341 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,18 +79,18 @@ function Coin(data){ this.getPortBlockHeaderByHash = function(port, blockHash, callback){ global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { - const blockJson = JSON.parse(body.result.json); - body.result.block_header.reward = 0; + if (port != 20189) { // Stellite was strange miner_tx + const blockJson = JSON.parse(body.result.json); + body.result.block_header.reward = 0; - const minerTx = blockJson.miner_tx; - //if (minerTx.vout.length != 2) console.error('Coinbase transaction vout size is not 2'); + const minerTx = blockJson.miner_tx; - for (var i=0; i body.result.block_header.reward) { - body.result.block_header.reward = minerTx.vout[i].amount; + for (var i=0; i body.result.block_header.reward) { + body.result.block_header.reward = minerTx.vout[i].amount; + } } } - return callback(null, body.result.block_header); } else { console.error(JSON.stringify(body)); From 0c4d32f7181043c467ce4d244c2853db100b3964 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 14 Aug 2018 18:51:50 +0200 Subject: [PATCH 0011/1496] Fixed reward detection for ITNS --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 937d37341..ef48c25dc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,7 +79,7 @@ function Coin(data){ this.getPortBlockHeaderByHash = function(port, blockHash, callback){ global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { - if (port != 20189) { // Stellite was strange miner_tx + if (port != 20189 && port != 48782) { // Stellite and Intense has Bytecoin based miner_tx const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; From abb5625b186889a262dbce71b12e76107ee96301 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 14 Aug 2018 19:04:38 +0200 Subject: [PATCH 0012/1496] Fixed reward detection for Aeon --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ef48c25dc..b2b877e29 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,7 +79,7 @@ function Coin(data){ this.getPortBlockHeaderByHash = function(port, blockHash, callback){ global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { - if (port != 20189 && port != 48782) { // Stellite and Intense has Bytecoin based miner_tx + if (port != 20189 && port != 48782 && port != 11181) { // Stellite/Intense/Aeon have composite based miner_tx const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; From 843221279ed14fc4036e4d1a6bc01b3f8ea0cff0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 15 Aug 2018 21:17:33 +0200 Subject: [PATCH 0013/1496] cn/1 algo now has 5% more profit estimation to switch to other algos only if they are at least 5 percent better --- lib/pool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 23d1318f1..adf812fbb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -698,8 +698,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return this.curr_algo; } let best_algo = ""; - let best_algo_perf = this.algos_perf[""]; - if (this.curr_algo === "") best_algo_perf *= 1.05; + let best_algo_perf = this.algos_perf[""] * 1.05; let miner = this; ALGOS.forEach(function(algo) { if (!(algo in activeBlockTemplate)) return; From 8b0f6981829b1dd8499afec1dc4186cdbf069e85 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 18 Aug 2018 09:24:55 +0200 Subject: [PATCH 0014/1496] Fixed RYO support --- README.md | 1 + lib/coins/xmr.js | 7 ++++--- package.json | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0a35a3f30..668175aa7 100644 --- a/README.md +++ b/README.md @@ -269,6 +269,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XTL - ```Se3Qr5s83AxjCtYrkkqg6QXJagCVi8dELbHb5Cnemw4rMk3xZzEX3kQfWrbTZPpdAJSP3enA6ri3DcvdkERkGKE518vyPQTyi``` * XHV - ```hvxyEmtbqs5TEk9U2tCxyfGx2dyGD1g8EBspdr3GivhPchkvnMHtpCR2fGLc5oEY42UGHVBMBANPge5QJ7BDXSMu1Ga2KFspQR``` * TUBE - ```bxcpZTr4C41NshmJM9Db7FBE5crarjaDXVUApRbsCxHHBf8Jkqjwjzz1zmWHhm9trWNhrY1m4RpcS7tmdG4ykdHG2kTgDcbKJ``` +* LOKI - ```L6XqN6JDedz5Ub8KxpMYRCUoQCuyEA8EegEmeQsdP5FCNuXJavcrxPvLhpqY6emphGTYVrmAUVECsE9drafvY2hXUTJz6rW``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b2b877e29..bfde96db5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -246,6 +246,7 @@ function Coin(data){ this.blobTypeStr = function(port) { switch (port) { + case 12211: return "cryptonote_ryo"; // MSR case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } @@ -308,7 +309,7 @@ function Coin(data){ let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 2) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.3+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + return "Please update your xmr-node-proxy (" + agent + ") to version v0.2.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]) * 100; @@ -333,8 +334,8 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 103) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.3+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 201) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.2.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } return false; diff --git a/package.json b/package.json index 94d10fb30..79ffa9724 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v1.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v2.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v2.2.0" } } From 8f407cb695212d598494e003fac3765c0d9c67cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 18 Aug 2018 09:34:21 +0200 Subject: [PATCH 0015/1496] Updated debug module --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79ffa9724..63e02deb7 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto": "0.0.3", - "debug": "2.5.1", + "debug": "2.6.9", "express": "4.14.0", "apicache": "1.2.1", "jsonwebtoken": "^7.2.1", From 7702119dab5ace1a65b612313ce8b2d65d73de37 Mon Sep 17 00:00:00 2001 From: Learner Date: Sun, 19 Aug 2018 11:21:08 +0700 Subject: [PATCH 0016/1496] Only let one cleanshare instance if cleanshare is stuck or long, it won't cause multiple instances. --- lib/local_comms.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index d7ea169eb..4fd85cc8c 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -2,6 +2,7 @@ let range = require('range'); let debug = require('debug')('db'); let async = require('async'); +let cleanShareInProgress = false; function poolTypeStr(poolType) { switch (poolType) { @@ -712,6 +713,11 @@ function Database(){ where there's unlocked blocks. A find on the current block will have enough depth as long as the saves are correct. This will cause the system to clean up shares massively when there are no unlocked blocks. */ + if (cleanShareInProgress) { + console.error("CleanShareDB already running"); + return ; // already running + } + cleanShareInProgress = true; let oldestLockedBlockHeight = this.getOldestLockedBlockHeight(); async.waterfall([ function(callback){ @@ -826,8 +832,10 @@ function Database(){ } global.database.env.sync(function(){ }); + cleanShareInProgress = false; } else { console.log("Block cleaning disabled. Would have removed: " + JSON.stringify(data)); + cleanShareInProgress = false; } console.log("Done cleaning up the share DB"); }); From 0d05f769b201512c5a0b45a34007d83efbe06f68 Mon Sep 17 00:00:00 2001 From: Learner Date: Mon, 20 Aug 2018 10:16:01 +0700 Subject: [PATCH 0017/1496] Email notification Sending email if more than 5 times consecutive stucks. --- lib/local_comms.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 4fd85cc8c..da1e969bb 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -3,6 +3,7 @@ let range = require('range'); let debug = require('debug')('db'); let async = require('async'); let cleanShareInProgress = false; +let cleanShareStuckCount = 0; function poolTypeStr(poolType) { switch (poolType) { @@ -715,6 +716,8 @@ function Database(){ */ if (cleanShareInProgress) { console.error("CleanShareDB already running"); + ++cleanShareStuckCount; + if (cleanShareStuckCount > 5) global.support.sendEmail(global.config.general.adminEmail,"LongRunner stuck",cleanShareStuckCount); return ; // already running } cleanShareInProgress = true; @@ -832,10 +835,10 @@ function Database(){ } global.database.env.sync(function(){ }); - cleanShareInProgress = false; + cleanShareInProgress = false; cleanShareStuckCount = 0; } else { console.log("Block cleaning disabled. Would have removed: " + JSON.stringify(data)); - cleanShareInProgress = false; + cleanShareInProgress = false; cleanShareStuckCount = 0; } console.log("Done cleaning up the share DB"); }); From 783d9452118e7cdfa4d9532a16b383f87128975a Mon Sep 17 00:00:00 2001 From: Learner Date: Mon, 20 Aug 2018 10:47:38 +0700 Subject: [PATCH 0018/1496] Add sendEmail to Admin for simpler code With this function, we can make code shorter by avoiding repeating global.config.general.adminEmail parameter. --- lib/support.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/support.js b/lib/support.js index f21cc108f..2c1ddf380 100644 --- a/lib/support.js +++ b/lib/support.js @@ -109,6 +109,14 @@ function sendEmail(toAddress, subject, body, wallet){ } } +function sendEmailAdmin(subject, body){ + if (subject.indexOf("FYI") === -1) { + sendEmailReal(global.config.general.adminEmail, subject, body); + } else { + sendEmail(global.config.general.adminEmail, subject, body); + } +} + function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { let uri; if (global.config.rpc.https) { @@ -339,6 +347,7 @@ module.exports = function () { formatDateFromSQL: formatDateFromSQL, blockCompare: blockCompare, sendEmail: sendEmail, + sendEmailAdmin: sendEmailAdmin, tsCompare: tsCompare, getAlgoHashFactor: getAlgoHashFactor, getActivePort: getActivePort, From 3b82b1eab021f4d76a598e4ab07600068a6ce41f Mon Sep 17 00:00:00 2001 From: Learner Date: Mon, 20 Aug 2018 10:55:16 +0700 Subject: [PATCH 0019/1496] Replace indexOf by includes shorter code --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 2c1ddf380..82d3b33c9 100644 --- a/lib/support.js +++ b/lib/support.js @@ -110,7 +110,7 @@ function sendEmail(toAddress, subject, body, wallet){ } function sendEmailAdmin(subject, body){ - if (subject.indexOf("FYI") === -1) { + if (subject.includes("FYI")) { sendEmailReal(global.config.general.adminEmail, subject, body); } else { sendEmail(global.config.general.adminEmail, subject, body); From 316c985a274dd30ff2d0906c013471dda0e7dfa8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Aug 2018 09:49:22 +0200 Subject: [PATCH 0020/1496] Added legacy heavy algo naming support and enable smart miners only under new option --- deployment/base.sql | 1 + lib/coins/xmr.js | 12 +++++++++++- lib/pool.js | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index a3228e7d1..ab8feb05a 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -197,6 +197,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'algoHashFactorLight', '0', 'float', 'Light algo hash price factor relative to algoHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'algoHashFactorFast', '0', 'float', 'Fast algo hash price factor relative to algoHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'algoHashFactorXTL', '0', 'float', 'XTL algo hash price factor relative to algoHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('rpc', 'https', 'false', 'bool', 'Enable RPC over SSL'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index bfde96db5..da6a8621f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -246,7 +246,7 @@ function Coin(data){ this.blobTypeStr = function(port) { switch (port) { - case 12211: return "cryptonote_ryo"; // MSR + case 12211: return "cryptonote_ryo"; // RYO case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } @@ -290,6 +290,16 @@ function Coin(data){ } } + this.isMinerSupportPortAlgo = function(port, algos) { + if (this.algoTypeStr(port) in algos || this.algoShortTypeStr(port) in algos) return true; + switch (port) { + case 12211: // RYO + case 22023: // LOKI + return "cryptonight-heavy" in algos || "cn-heavy" in algos; + default: return false; + } + } + this.get_miner_agent_notification = function(agent) { let m; if (m = reXMRig.exec(agent)) { diff --git a/lib/pool.js b/lib/pool.js index adf812fbb..2a91c0758 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -586,7 +586,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return ""; }; - if (algos && algos instanceof Array) { + if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn/1": 1 }; const status = this.setAlgos(algos, algos_perf); if (status != "") { @@ -703,7 +703,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer ALGOS.forEach(function(algo) { if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; - if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; + if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos)) return; let algoHashFactor = global.config.daemon["algoHashFactor" + algo]; if (miner.curr_algo === algo) algoHashFactor *= 1.05; if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { From d878fac3d3d10426ca10593e741150aee66487fa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Aug 2018 15:10:56 +0200 Subject: [PATCH 0021/1496] Fixed RYO blob_type --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index da6a8621f..31013b481 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -151,6 +151,7 @@ function Coin(data){ this.portBlobType = function(port) { switch (port) { + case 12211: return 4; // RYO case 38081: return 3; // MSR default: return 0; } From eadbfc7ac63335d878869a8b22502e7c5f64dec3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Aug 2018 15:36:38 +0200 Subject: [PATCH 0022/1496] Some code rearangement --- lib/local_comms.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index da1e969bb..7c49b4bad 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -715,10 +715,10 @@ function Database(){ correct. This will cause the system to clean up shares massively when there are no unlocked blocks. */ if (cleanShareInProgress) { - console.error("CleanShareDB already running"); - ++cleanShareStuckCount; - if (cleanShareStuckCount > 5) global.support.sendEmail(global.config.general.adminEmail,"LongRunner stuck",cleanShareStuckCount); - return ; // already running + console.error("CleanShareDB already running"); + ++cleanShareStuckCount; + if (cleanShareStuckCount > 5) global.support.sendEmail(global.config.general.adminEmail,"LongRunner stuck",cleanShareStuckCount); + return; // already running } cleanShareInProgress = true; let oldestLockedBlockHeight = this.getOldestLockedBlockHeight(); @@ -835,11 +835,11 @@ function Database(){ } global.database.env.sync(function(){ }); - cleanShareInProgress = false; cleanShareStuckCount = 0; } else { console.log("Block cleaning disabled. Would have removed: " + JSON.stringify(data)); - cleanShareInProgress = false; cleanShareStuckCount = 0; } + cleanShareInProgress = false; + cleanShareStuckCount = 0; console.log("Done cleaning up the share DB"); }); }; From ad2ad56ac1af1333cb778a62ed524bc2d478508a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Aug 2018 15:43:28 +0200 Subject: [PATCH 0023/1496] Fixed sendEmailAdmin --- lib/support.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/support.js b/lib/support.js index 82d3b33c9..31c3c9ef1 100644 --- a/lib/support.js +++ b/lib/support.js @@ -80,7 +80,7 @@ function sendEmailReal(toAddress, subject, email_body, retry) { } function sendEmail(toAddress, subject, body, wallet){ - if (toAddress === global.config.general.adminEmail && subject.indexOf("FYI") === -1) { + if (toAddress === global.config.general.adminEmail && !subject.includes("FYI")) { sendEmailReal(toAddress, subject, body); } else { let reEmail = /^([a-zA-Z0-9_\.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; @@ -110,11 +110,7 @@ function sendEmail(toAddress, subject, body, wallet){ } function sendEmailAdmin(subject, body){ - if (subject.includes("FYI")) { - sendEmailReal(global.config.general.adminEmail, subject, body); - } else { - sendEmail(global.config.general.adminEmail, subject, body); - } + sendEmail(global.config.general.adminEmail, subject, body); } function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { From d4bd48e3eb4c0ffa8b9a6e1a611e8ac00fd74d4f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Aug 2018 16:41:11 +0200 Subject: [PATCH 0024/1496] Added port miner count --- lib/worker.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 9a013c2b7..2038b185f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -40,6 +40,7 @@ function updateShareStats() { let identifiers = {}; let minerSet = {}; + let minerPortSet = {}; let minerCount = 0; let localMinerCount = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 }; let localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; @@ -106,7 +107,7 @@ function updateShareStats() { if (port in localPortHashes) localPortHashes[port] += share.shares; else localPortHashes[port] = share.shares; - if (minerID in minerSet) { + if (minerID in minerPortSet) { localStats.miners[minerID] += share.shares; localStats.miners2[minerID] += share.shares2 ? share.shares2 : share.shares; if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; @@ -117,6 +118,7 @@ function updateShareStats() { localStats.miners2[minerID] = share.shares2 ? share.shares2 : share.shares; localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; + minerPortSet[minerID] = port; } if (minerIDWithIdentifier in minerSet) { localStats.miners[minerIDWithIdentifier] += share.shares; @@ -258,6 +260,12 @@ function updateShareStats() { Object.keys(identifiers).forEach(function (key) { cache_updates['identifiers:' + key] = identifiers[key]; }); + let portMinerCount = {}; + Object.values(minerPortSet).forEach(function (port) { + if (port in portMinerCount) ++ portMinerCount[port]; + else portMinerCount[port] = 1; + }); + cache_updates.portMinerCount = portMinerCount; cache_updates.minerSet = minerSet; global.database.bulkSetCache(cache_updates); @@ -572,6 +580,10 @@ function updatePoolStats2(poolType) { //debug(threadName + "Checking Influx for last 5min avg for pool stats (hashRate) per port"); return callback(null, port_hash || {}); }, + function (callback) { + //debug(threadName + "Checking LMDB cache for portMinerCount"); + return callback(null, global.database.getCache('portMinerCount') || {}); + }, ], function (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; @@ -601,6 +613,7 @@ function updatePoolStats2(poolType) { pplnsPortShares: result[20] || {}, pplnsWindowTime: result[21] || 0, portHash: result[22] || {}, + portMinerCount: result[23] || {}, }); }); } From 618002f505351bc9a3077a8e22d47e07e3dcaace Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Aug 2018 16:47:12 +0200 Subject: [PATCH 0025/1496] Fixed Ojbect.values missing --- lib/worker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 2038b185f..f5c6537aa 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -261,10 +261,11 @@ function updateShareStats() { cache_updates['identifiers:' + key] = identifiers[key]; }); let portMinerCount = {}; - Object.values(minerPortSet).forEach(function (port) { + for (let miner in minerPortSet) { + const port = minerPortSet[miner]; if (port in portMinerCount) ++ portMinerCount[port]; else portMinerCount[port] = 1; - }); + } cache_updates.portMinerCount = portMinerCount; cache_updates.minerSet = minerSet; global.database.bulkSetCache(cache_updates); From e0036cd560e9517aeacff0257bbe1de5e25616a0 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Tue, 21 Aug 2018 17:38:26 +0300 Subject: [PATCH 0026/1496] fix for other coins --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 1bbdb1fc9..47d93eec6 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -7,7 +7,7 @@ function cleanCacheDB() { let cursor = new global.database.lmdb.Cursor(txn, global.database.cacheDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentString(function(key, data){ // jshint ignore:line - if (key.length < 95) return; // min XMR address length + if (key.length < global.config.pool.address.length) return; // min XMR address length if (key.includes("identifiers:")) { // remove frozen worker names after 24h let parts = key.split(/:(.+)/); From 4bb32f0c34accbc980dd36ee8085bee43ff383c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 21 Aug 2018 22:39:08 +0200 Subject: [PATCH 0027/1496] Disable algo switched stuff if it is not enabled --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2a91c0758..01296c39a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1641,7 +1641,7 @@ if (cluster.isMaster) { global.config.daemon.activePort = global.config.daemon.port; } else { setInterval(updateActivePort, 3*1000, ""); - ALGOS.forEach(function(algo) { + if (global.config.daemon.enableAlgoSwitching) ALGOS.forEach(function(algo) { if ("activePort" + algo in global.config.daemon) { setInterval(updateActivePort, 5*1000, algo); templateUpdate(algo); @@ -1657,9 +1657,9 @@ if (cluster.isMaster) { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); } else { templateUpdate(""); - if (global.config.daemon.activePortHeavy && global.config.daemon.activePortLight) { - ALGOS.forEach(function(algo) { templateUpdate(algo); }); - } + if (global.config.daemon.enableAlgoSwitching) ALGOS.forEach(function(algo) { + if ("activePort" + algo in global.config.daemon) templateUpdate(algo); + }); anchorBlockUpdate(); setInterval(anchorBlockUpdate, 3*1000); setInterval(checkAliveMiners, 60*1000); From 635ce5213f71fe250ab680164f3240209fdc12c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 21 Aug 2018 22:40:24 +0200 Subject: [PATCH 0028/1496] Enable msr mining for plain xmrig --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 01296c39a..928c21197 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -587,7 +587,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { - if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn/1": 1 }; + if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn": 1, "cn-fast": 2 }; const status = this.setAlgos(algos, algos_perf); if (status != "") { this.error = status; From 1d192b91b968644c24dc332d40b5a7047bd48067 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 22 Aug 2018 11:35:19 +0200 Subject: [PATCH 0029/1496] Added algo_min_time functionality support --- lib/pool.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 928c21197..7317c5e52 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -480,7 +480,7 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf) { +function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. // Default function is to use the password so they can login. Identifiers can be unique, payment ID is last. @@ -567,7 +567,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return; } - this.setAlgos = function(algos, algos_perf) { + this.setAlgos = function(algos, algos_perf, algo_min_time) { const check = global.coinFuncs.algoCheck(algos); if (check === true) { this.algos = {}; @@ -583,12 +583,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer else this.algos_perf[""] = this.algos_perf["XTL"] = algos_perf[algo]; } if (!this.algos_perf[""]) return "algo_perf set should include non heavy/lite/fast hashrate"; + this.algo_min_time = algo_min_time; return ""; }; if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn": 1, "cn-fast": 2 }; - const status = this.setAlgos(algos, algos_perf); + if (!algo_min_time) algo_min_time = 0; + const status = this.setAlgos(algos, algos_perf, algo_min_time); if (status != "") { this.error = status; this.valid_miner = false; @@ -694,7 +696,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestAlgo = function() { if (!this.algos) return ""; - if (typeof(this.curr_algo) !== 'undefined' && this.curr_algo_time && this.algos_perf[this.curr_algo] && Date.now() - this.curr_algo_time < 5*60*1000) { + if (typeof(this.curr_algo) !== 'undefined' && this.curr_algo_time && this.algos_perf[this.curr_algo] && + Date.now() - this.curr_algo_time < this.algo_min_time*1000 + ) { return this.curr_algo; } let best_algo = ""; @@ -1291,7 +1295,10 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"]); + miner = new Miner( + minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, + params.algo, params["algo-perf"], params["algo-min-time"] + ); let time_now = Date.now(); if (!miner.valid_miner) { if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { @@ -1369,7 +1376,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } miner.heartbeat(); if (miner.algos && params.algo && params.algo instanceof Array && params["algo-perf"] && params["algo-perf"] instanceof Object) { - const status = miner.setAlgos(params.algo, params["algo-perf"]); + const status = miner.setAlgos(params.algo, params["algo-perf"], params["algo-min-time"]); if (status != "") { sendReply(status); return; From 9fd5267976e6818290ee8b6e396a4d7f124f4396 Mon Sep 17 00:00:00 2001 From: Learner Date: Thu, 23 Aug 2018 00:55:41 +0700 Subject: [PATCH 0030/1496] "Drown in waterfall" bug, finally gotcha Finally, I can trace back the database explosion (turtlecoin unstability, graft under attack, electroneum under attack) issue because of longRunner stuck that I didn't notice. The probability to occur is very slim with normal network (only if you restart daemon par hazard at the same time longRunner starts). Steps to reproduce longRunner stuck : Step 1 : Stop coin daemon Step 2 : Start longRunner Step 3 : Start coin daemon Expected : cleanShareDB exits when daemon request fails. Observation : cleanShareDB got stuck in waterfall and never exits even when coin daemon come back to normal. --- lib/local_comms.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 7c49b4bad..d4bd20bf3 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -730,7 +730,7 @@ function Database(){ global.coinFuncs.getBlockHeaderByID(oldestLockedBlockHeight, (err, result) => { if (err !== null) { console.error("Can't get block with " + oldestLockedBlockHeight + " height"); - return; + return callback(true); } callback(null, oldestLockedBlockHeight, result.difficulty); }); @@ -740,7 +740,7 @@ function Database(){ global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { console.error("Last block header request failed!"); - return; + return callback(true); } if (oldestLockedBlockHeight === null){ /* @@ -812,6 +812,10 @@ function Database(){ callback(null, Array.from(Object.keys(blockSet))); } ], function(err, data){ + if (err !== null) { + console.error("ERROR with cleaning up because of daemon stuck"); + return; + } if (global.config.general.blockCleaner === true){ if(data.length > 0){ global.database.refreshEnv(); From 49b044aec6dbec2218e2225747dcf58999b0cd7e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 22 Aug 2018 21:00:03 +0200 Subject: [PATCH 0031/1496] Added share check during algo switch --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 7317c5e52..1258eb118 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -719,6 +719,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (typeof(this.curr_algo) === 'undefined' || this.curr_algo != best_algo) { this.curr_algo = best_algo; this.curr_algo_time = Date.now(); + if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_algo].height; } return best_algo; } From 9ea8c41f2587e537877a6f10da97798e998a1ece Mon Sep 17 00:00:00 2001 From: Learner Date: Thu, 23 Aug 2018 12:47:20 +0700 Subject: [PATCH 0032/1496] Forgot to turn off inProgress ;) --- lib/local_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index d4bd20bf3..e362d0873 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -814,6 +814,7 @@ function Database(){ ], function(err, data){ if (err !== null) { console.error("ERROR with cleaning up because of daemon stuck"); + cleanShareInProgress = false; return; } if (global.config.general.blockCleaner === true){ From 33f076b99187ea7f14cedcc59b0ebfd45330fae0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Aug 2018 11:13:06 +0200 Subject: [PATCH 0033/1496] Increased threshold to switch to other algos --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1258eb118..d8dcca0a5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -702,7 +702,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return this.curr_algo; } let best_algo = ""; - let best_algo_perf = this.algos_perf[""] * 1.05; + let best_algo_perf = this.algos_perf[""] * 1.1; let miner = this; ALGOS.forEach(function(algo) { if (!(algo in activeBlockTemplate)) return; From 931ba5e4d6cb3577558a7234f22c32cc4f1d8a50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Aug 2018 14:02:20 +0200 Subject: [PATCH 0034/1496] Switched MSR hashrate factor to 1.9 --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d8dcca0a5..5c54652c2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -588,7 +588,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { - if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn": 1, "cn-fast": 2 }; + if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn": 1, "cn-fast": 1.9 }; if (!algo_min_time) algo_min_time = 0; const status = this.setAlgos(algos, algos_perf, algo_min_time); if (status != "") { From 425e6789b6b9c6c0d591927ee49ebfa830ada8ad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 27 Aug 2018 18:07:03 +0200 Subject: [PATCH 0035/1496] Do not emit outdated blocks for blocks that were not replaced by a new one --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5c54652c2..f157ffb30 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1447,7 +1447,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return t.idHash === job.blockHash; })[0]; let is_outdated = false; - if (blockTemplate) { + if (blockTemplate && blockTemplate.timeOutdate) { let late_time = Date.now() - blockTemplate.timeOutdate; if (late_time > 0) { let max_late_time = global.config.pool.targetTime*1000; From 460e2f5e8299a3e4b05e96fd9cc9af52f06dcd44 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 28 Aug 2018 18:48:26 +0200 Subject: [PATCH 0036/1496] More considtent algo_perf parsing --- lib/pool.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f157ffb30..048f6fac6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -576,13 +576,27 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return check; } this.algos_perf = {}; - for (let algo in algos_perf) { - if (algo.includes("heavy")) this.algos_perf["Heavy"] = algos_perf[algo]; - else if (algo.includes("lite")) this.algos_perf["Light"] = algos_perf[algo]; - else if (algo.includes("fast") || algo.includes("msr")) this.algos_perf["Fast"] = algos_perf[algo]; - else this.algos_perf[""] = this.algos_perf["XTL"] = algos_perf[algo]; - } - if (!this.algos_perf[""]) return "algo_perf set should include non heavy/lite/fast hashrate"; + + if ("cn" in algos_perf) this.algos_perf[""] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) this.algos_perf[""] = algos_perf["cn/1"]; + else if ("cryptonight" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight"]; + else if ("cryptonight/1" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/1"]; + else return "algo_perf set should include cn or cn/1 hashrate"; + + if ("cn/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cn/xtl"]; + else if ("cryptonight/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cryptonight/xtl"]; + else this.algos_perf["XTL"] = this.algos_perf[""]; + + if ("cn-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy"]; + else if ("cn-heavy/0" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy/0"]; + else if ("cryptonight-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cryptonight-heavy"]; + else if ("cryptonight-heavy/0" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cryptonight-heavy/0"]; + + if ("cn-lite" in algos_perf) this.algos_perf["Light"] = algos_perf["cn-lite"]; + else if ("cn-lite/1" in algos_perf) this.algos_perf["Light"] = algos_perf["cn-lite/1"]; + else if ("cryptonight-lite" in algos_perf) this.algos_perf["Light"] = algos_perf["cryptonight-lite"]; + else if ("cryptonight-lite/1" in algos_perf) this.algos_perf["Light"] = algos_perf["cryptonight-lite/1"]; + this.algo_min_time = algo_min_time; return ""; }; From d07ba6ca911def3556956af3ade8980fba49a645 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 28 Aug 2018 18:51:28 +0200 Subject: [PATCH 0037/1496] More considtent algo_perf parsing --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 048f6fac6..60c02d263 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -577,11 +577,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.algos_perf = {}; - if ("cn" in algos_perf) this.algos_perf[""] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) this.algos_perf[""] = algos_perf["cn/1"]; - else if ("cryptonight" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight"]; - else if ("cryptonight/1" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/1"]; - else return "algo_perf set should include cn or cn/1 hashrate"; + if ("cn" in algos_perf) this.algos_perf[""] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) this.algos_perf[""] = algos_perf["cn/1"]; + else if ("cryptonight" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight"]; + else if ("cryptonight/1" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/1"]; + else return "algo_perf set should include cn or cn/1 hashrate"; if ("cn/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cn/xtl"]; else if ("cryptonight/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cryptonight/xtl"]; From 498df664156fc9bd3706614dec71f3ebd2223c54 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 28 Aug 2018 19:05:24 +0200 Subject: [PATCH 0038/1496] Fixed fast case --- lib/pool.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 60c02d263..adcad3f35 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -587,6 +587,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer else if ("cryptonight/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cryptonight/xtl"]; else this.algos_perf["XTL"] = this.algos_perf[""]; + if ("cn-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn-fast"]; + else if ("cn/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn/msr"]; + else if ("cryptonight-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight-fast"]; + else if ("cryptonight/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight/msr"]; + else this.algos_perf["Fast"] = this.algos_perf[""]; + if ("cn-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy/0"]; else if ("cryptonight-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cryptonight-heavy"]; From 170f2a1ff3149c0431b20b7b1bba4e5539701b09 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 28 Aug 2018 19:06:22 +0200 Subject: [PATCH 0039/1496] Fixed fast case --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index adcad3f35..87cb3f862 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -591,7 +591,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer else if ("cn/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn/msr"]; else if ("cryptonight-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight-fast"]; else if ("cryptonight/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight/msr"]; - else this.algos_perf["Fast"] = this.algos_perf[""]; if ("cn-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy/0"]; From 56ec4d3725220a7888d9e953a82dd513888944dc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 28 Aug 2018 19:07:52 +0200 Subject: [PATCH 0040/1496] Fixed fast case --- lib/pool.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 87cb3f862..8761660c2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -577,20 +577,20 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.algos_perf = {}; - if ("cn" in algos_perf) this.algos_perf[""] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) this.algos_perf[""] = algos_perf["cn/1"]; - else if ("cryptonight" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight"]; - else if ("cryptonight/1" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/1"]; + if ("cn" in algos_perf) this.algos_perf[""] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) this.algos_perf[""] = algos_perf["cn/1"]; + else if ("cryptonight" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight"]; + else if ("cryptonight/1" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/1"]; else return "algo_perf set should include cn or cn/1 hashrate"; - if ("cn/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cn/xtl"]; - else if ("cryptonight/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cryptonight/xtl"]; - else this.algos_perf["XTL"] = this.algos_perf[""]; + if ("cn/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cn/xtl"]; + else if ("cryptonight/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cryptonight/xtl"]; + else this.algos_perf["XTL"] = this.algos_perf[""]; - if ("cn-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn-fast"]; - else if ("cn/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn/msr"]; - else if ("cryptonight-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight-fast"]; - else if ("cryptonight/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight/msr"]; + if ("cn-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn-fast"]; + else if ("cn/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn/msr"]; + else if ("cryptonight-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight-fast"]; + else if ("cryptonight/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight/msr"]; if ("cn-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy/0"]; From d49c55ec349513b5baeda9a299ae546e16e7ff4e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 8 Sep 2018 16:32:34 +0200 Subject: [PATCH 0041/1496] Fixed proxy mienr name removal and reduced their diff memory --- lib/pool.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8761660c2..3936712fa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -207,7 +207,11 @@ function retargetMiners() { let proxyMiners = {}; function addProxyMiner(miner) { - let proxyMinerName = miner.payout + ":" + miner.identifier; + if (miner.proxyMinerName) return; + + const proxyMinerName = miner.payout + ":" + miner.identifier; + miner.proxyMinerName = proxyMinerName; + if (!(proxyMinerName in proxyMiners)) { proxyMiners[proxyMinerName] = {}; proxyMiners[proxyMinerName].connectTime = Date.now(); @@ -221,8 +225,8 @@ function addProxyMiner(miner) { function removeMiner(miner) { process.send({type: 'removeMiner', data: miner.port}); - let proxyMinerName = miner.payout + ":" + miner.identifier; - if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; + const proxyMinerName = miner.proxyMinerName; + if (proxyMinerName && proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; if (miner.algos) { delete activeSmartMiners[miner.id]; @@ -748,21 +752,25 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let miner; let target; let min_diff; + let history_time; if (proxyMinerName in proxyMiners) { miner = proxyMiners[proxyMinerName]; target = 5; min_diff = 10*global.config.pool.minDifficulty; + history_time = 5; } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { miner = minerWallets[this.payout]; target = 5; min_diff = 10*global.config.pool.minDifficulty; + history_time = 5; } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; min_diff = this.proxy ? 10*global.config.pool.minDifficulty : global.config.pool.minDifficulty; + history_time = 60; } if (miner.connectTimeShift) { - if (Date.now() - miner.connectTimeShift > 60*60*1000) { + if (Date.now() - miner.connectTimeShift > history_time*60*1000) { miner.connectTime = miner.connectTimeShift; miner.hashes -= miner.hashesShift; miner.connectTimeShift = Date.now(); From 4e2e573e10618ffdea6d6d59e65a42c4a5a92e75 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 10 Sep 2018 21:44:38 +0200 Subject: [PATCH 0042/1496] Fixed blockManager freeze --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e6c36ab81..cf0458512 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -20,7 +20,7 @@ let blockQueue = async.queue(function (task, callback) { global.coinFuncs.getBlockHeaderByID(task.blockID, (err, body) => { if (err !== null) { console.error("Can't get block with " + task.blockID + " height"); - return; + return callback(); } if (body.hash in blockHexCache) { return callback(); From e2d7dfa6f1a5aad9bcfd07ef016ac0b2b570750b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 14 Sep 2018 11:33:35 +0200 Subject: [PATCH 0043/1496] Improved efficiency of miner handling --- lib/pool.js | 68 ++++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3936712fa..a0bd829c5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -17,8 +17,8 @@ let bannedAddresses = {}; let notifyAddresses = {}; let baseDiff = global.coinFuncs.baseDiff(); -let activeMiners = {}; -let activeSmartMiners = {}; // miners with algos/algos-perf +let activeMiners = new Map(); +let activeSmartMiners = new Map(); // miners with algos/algos-perf let lastBlockHash = {}; // algo key let lastAlgoHashFactor = {}; // algo key @@ -186,16 +186,12 @@ function retargetMiners() { let miner_count = 0; const time_before = Date.now(); - for (let minerId in activeSmartMiners) { - if (activeSmartMiners.hasOwnProperty(minerId)) { - retargetMiner(activeSmartMiners[minerId]); - } + for (var [minerId, miner] of activeSmartMiners) { + retargetMiner(miner); ++ miner_count; } - for (let minerId in activeMiners) { - if (activeMiners.hasOwnProperty(minerId)) { - retargetMiner(activeMiners[minerId]); - } + for (var [minerId, miner] of activeMiners) { + retargetMiner(miner); ++ miner_count; } const elapsed = Date.now() - time_before; @@ -229,9 +225,9 @@ function removeMiner(miner) { if (proxyMinerName && proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; if (miner.algos) { - delete activeSmartMiners[miner.id]; + activeSmartMiners.delete(miner.id); } else { - delete activeMiners[miner.id]; + activeMiners.delete(miner.id); } } @@ -240,18 +236,12 @@ function checkAliveMiners() { const time_before = Date.now(); const deadline = time_before - global.config.pool.minerTimeout * 1000; let miner_count = 0; - for (let minerId in activeSmartMiners) { - if (activeSmartMiners.hasOwnProperty(minerId)) { - let miner = activeSmartMiners[minerId]; - if (miner.lastContact < deadline) removeMiner(miner); - } + for (var [minerId, miner] of activeSmartMiners) { + if (miner.lastContact < deadline) removeMiner(miner); ++ miner_count; } - for (let minerId in activeMiners) { - if (activeMiners.hasOwnProperty(minerId)) { - let miner = activeMiners[minerId]; - if (miner.lastContact < deadline) removeMiner(miner); - } + for (var [minerId, miner] of activeMiners) { + if (miner.lastContact < deadline) removeMiner(miner); ++ miner_count; } const elapsed = Date.now() - time_before; @@ -415,12 +405,9 @@ function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { if (algo !== "") global.config.daemon["algoHashFactor" + algo] = algoHashFactor; // used in miner.selectBestAlgo - for (let minerId in activeSmartMiners) { - if (activeSmartMiners.hasOwnProperty(minerId)) { - let miner = activeSmartMiners[minerId]; - if (check_height) miner.trust.check_height = check_height; - miner.sendNewJob(); - } + for (var [minerId, miner] of activeSmartMiners) { + if (check_height) miner.trust.check_height = check_height; + miner.sendNewJob(); ++ miner_count; } @@ -459,12 +446,9 @@ function setNewBlockTemplate(template) { let miner_count = 0; const time_before = Date.now(); - if (algo === "") for (let minerId in activeMiners) { - if (activeMiners.hasOwnProperty(minerId)) { - let miner = activeMiners[minerId]; - if (isExtraCheck) miner.trust.check_height = height; - miner.sendNewJob(); - } + if (algo === "") for (var [minerId, miner] of activeMiners) { + if (isExtraCheck) miner.trust.check_height = height; + miner.sendNewJob(); ++ miner_count; } @@ -1368,9 +1352,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } process.send({type: 'newMiner', data: miner.port}); if (miner.algos) { - activeSmartMiners[minerId] = miner; + activeSmartMiners.set(minerId) = miner; } else { - activeMiners[minerId] = miner; + activeMiners.set(minerId) = miner; } if (!miner.proxy) { let proxyMinerName = miner.payout + ":" + miner.identifier; @@ -1396,8 +1380,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { }); break; case 'getjob': - miner = activeSmartMiners[params.id]; - if (!miner) miner = activeMiners[params.id]; + miner = activeSmartMiners.get(params.id); + if (!miner) miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1413,8 +1397,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.sendNewJob(); break; case 'submit': - miner = activeSmartMiners[params.id]; - if (!miner) miner = activeMiners[params.id]; + miner = activeSmartMiners.get(params.id); + if (!miner) miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1548,8 +1532,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(null, {status: 'OK'}); break; case 'keepalived': - miner = activeSmartMiners[params.id]; - if (!miner) miner = activeMiners[params.id]; + miner = activeSmartMiners.get(params.id); + if (!miner) miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; From 2ec815aeaae079a68d0d194fd6e1eab42376bf12 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 14 Sep 2018 11:40:54 +0200 Subject: [PATCH 0044/1496] Fixed map set --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a0bd829c5..173e8f574 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1352,9 +1352,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } process.send({type: 'newMiner', data: miner.port}); if (miner.algos) { - activeSmartMiners.set(minerId) = miner; + activeSmartMiners.set(minerId, miner); } else { - activeMiners.set(minerId) = miner; + activeMiners.set(minerId, miner); } if (!miner.proxy) { let proxyMinerName = miner.payout + ":" + miner.identifier; From 99230c6006b3beb19b565c6c96407eef45bc6c1f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 14 Sep 2018 12:01:40 +0200 Subject: [PATCH 0045/1496] Simplified code by removing counters --- lib/pool.js | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 173e8f574..01b6f9e47 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -183,19 +183,11 @@ function retargetMiners() { } } - let miner_count = 0; const time_before = Date.now(); - - for (var [minerId, miner] of activeSmartMiners) { - retargetMiner(miner); - ++ miner_count; - } - for (var [minerId, miner] of activeMiners) { - retargetMiner(miner); - ++ miner_count; - } + for (var [minerId, miner] of activeSmartMiners) retargetMiner(miner); + for (var [minerId, miner] of activeMiners) retargetMiner(miner); const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms for " + miner_count + " miners"); + if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms for " + (activeSmartMiners.size + activeMiners.size) + " miners"); } // wallet " " proxy miner name -> { connectTime, count (miner), hashes } @@ -235,17 +227,10 @@ function checkAliveMiners() { debug(threadName + "Verifying if miners are still alive"); const time_before = Date.now(); const deadline = time_before - global.config.pool.minerTimeout * 1000; - let miner_count = 0; - for (var [minerId, miner] of activeSmartMiners) { - if (miner.lastContact < deadline) removeMiner(miner); - ++ miner_count; - } - for (var [minerId, miner] of activeMiners) { - if (miner.lastContact < deadline) removeMiner(miner); - ++ miner_count; - } + for (var [minerId, miner] of activeSmartMiners) if (miner.lastContact < deadline) removeMiner(miner); + for (var [minerId, miner] of activeMiners) if (miner.lastContact < deadline) removeMiner(miner); const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms for " + miner_count + " miners"); + if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms for " + (activeSmartMiners.size + activeMiners.size) + " miners"); } // global.config.daemon["activePort" + algo] is only updated in master thread @@ -400,7 +385,6 @@ function anchorBlockUpdate() { } function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { - let miner_count = 0; const time_before = Date.now(); if (algo !== "") global.config.daemon["algoHashFactor" + algo] = algoHashFactor; // used in miner.selectBestAlgo @@ -408,11 +392,10 @@ function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { for (var [minerId, miner] of activeSmartMiners) { if (check_height) miner.trust.check_height = check_height; miner.sendNewJob(); - ++ miner_count; } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("setNewAlgoHashFactor() consumed " + elapsed + " ms for " + miner_count + " miners"); + if (elapsed > 500) console.error("setNewAlgoHashFactor() consumed " + elapsed + " ms for " + activeSmartMiners.size + " miners"); } function setNewBlockTemplate(template) { @@ -443,17 +426,15 @@ function setNewBlockTemplate(template) { setNewAlgoHashFactor(algo, template.algoHashFactor, isExtraCheck ? height : 0); - let miner_count = 0; const time_before = Date.now(); - if (algo === "") for (var [minerId, miner] of activeMiners) { + if (algo === "") for (var [minerId, miner] of activeMiners) { if (isExtraCheck) miner.trust.check_height = height; miner.sendNewJob(); - ++ miner_count; } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("setNewBlockTemplate() consumed " + elapsed + " ms for " + miner_count + " miners"); + if (elapsed > 500) console.error("setNewBlockTemplate() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } // here we keep verified share number of a specific wallet (miner.payout) @@ -909,7 +890,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.sendNewJob = function() { - let job = this.getJob(); + const job = this.getJob(); if (job === null) return; return this.messageSender('job', job); }; From dd7f26ec4bee5a900c9853132a99580545492dad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 15 Sep 2018 16:54:44 +0200 Subject: [PATCH 0046/1496] Added cn/2 support and Loki new utils support --- lib/coins/xmr.js | 33 +++++++++++++++++++-------------- lib/pool.js | 12 ++++++------ package.json | 4 ++-- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 31013b481..91a5fadf1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -228,8 +228,8 @@ function Coin(data){ // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - return algos.includes("cn/1") || algos.includes("cryptonight/1") ? - true : "algo array should include cn/1 or cryptonight/1"; + return algos.includes("cn/1") || algos.includes("cn/2") || algos.includes("cryptonight/1") || algos.includes("cryptonight/2") ? + true : "algo array should include cn/1, cn/2, cryptonight/1 or cryptonight/2"; } this.cryptoNight = function(convertedBlob, port) { @@ -237,6 +237,7 @@ function Coin(data){ case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven + case 18081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 8 ? 8 : 1); // XMR case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube @@ -245,19 +246,21 @@ function Coin(data){ } } - this.blobTypeStr = function(port) { + this.blobTypeStr = function(port, version) { switch (port) { - case 12211: return "cryptonote_ryo"; // RYO - case 38081: return "cryptonote2"; // MSR + case 12211: return "cryptonote_ryo"; // RYO + case 22023: return version >= 9 ? "cryptonote_loki" : "cryptonote"; // LOKI + case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } } - this.algoTypeStr = function(port) { + this.algoTypeStr = function(port, version) { switch (port) { case 11181: return "cryptonight-lite/1"; // Aeon case 12211: return "cryptonight-heavy/0"; // RYO case 17750: return "cryptonight-heavy/xhv"; // Haven + case 18081: return version >= 8 ? "cryptonight/2" : "cryptonight/1"; // XMR case 20189: return "cryptonight/xtl"; // Stellite case 22023: return "cryptonight-heavy/0"; // LOKI case 24182: return "cryptonight-heavy/tube"; // BitTube @@ -266,11 +269,12 @@ function Coin(data){ } } - this.algoShortTypeStr = function(port) { + this.algoShortTypeStr = function(port, version) { switch (port) { case 11181: return "cn-lite/1"; // Aeon case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven + case 18081: return version >= 8 ? "cn/2" : "cn/1"; // XMR case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube @@ -279,10 +283,11 @@ function Coin(data){ } } - this.variantValue = function(port) { + this.variantValue = function(port, version) { switch (port) { case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven + case 18081: return version >= 8 ? "2" : "1"; // XMR case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube @@ -291,8 +296,8 @@ function Coin(data){ } } - this.isMinerSupportPortAlgo = function(port, algos) { - if (this.algoTypeStr(port) in algos || this.algoShortTypeStr(port) in algos) return true; + this.isMinerSupportPortAlgo = function(port, algos, version) { + if (this.algoShortTypeStr(port, version) in algos || this.algoTypeStr(port, version) in algos) return true; switch (port) { case 12211: // RYO case 22023: // LOKI @@ -319,8 +324,8 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 2) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.2.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 300) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.0+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]) * 100; @@ -345,8 +350,8 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 201) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.2.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 300) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } return false; diff --git a/lib/pool.js b/lib/pool.js index 01b6f9e47..1bc5462b1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -695,7 +695,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer ALGOS.forEach(function(algo) { if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; - if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos)) return; + if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, activeBlockTemplate[algo].blob[0])) return; let algoHashFactor = global.config.daemon["algoHashFactor" + algo]; if (miner.curr_algo === algo) algoHashFactor *= 1.05; if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { @@ -848,8 +848,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); this.cachedJob = { blob: blob, - algo: global.coinFuncs.algoShortTypeStr(bt.port), - variant: global.coinFuncs.variantValue(bt.port), + algo: global.coinFuncs.algoShortTypeStr(bt.port, blob[0]), + variant: global.coinFuncs.variantValue(bt.port, blob[0]), job_id: newJob.id, target: target, id: this.id @@ -872,9 +872,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); this.cachedJob = { blocktemplate_blob: blob, - blob_type: global.coinFuncs.blobTypeStr(bt.port), - algo: global.coinFuncs.algoShortTypeStr(bt.port), - variant: global.coinFuncs.variantValue(bt.port), + blob_type: global.coinFuncs.blobTypeStr(bt.port, blob[0]), + algo: global.coinFuncs.algoShortTypeStr(bt.port, blob[0]), + variant: global.coinFuncs.variantValue(bt.port, blob[0]), difficulty: bt.difficulty, height: bt.height, reserved_offset: bt.reserveOffset, diff --git a/package.json b/package.json index 63e02deb7..c6231b6d2 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v2.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v2.2.0" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.0" } } From 5b28c9fc9cd3e03975cb09a8ede4809b2f5ccebb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 15 Sep 2018 22:38:53 +0200 Subject: [PATCH 0047/1496] Fixed xnp requirement --- lib/coins/xmr.js | 2 +- lib/pool.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 91a5fadf1..5da345ae0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -324,7 +324,7 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 300) { + if (majorv + minorv + minorv2 < 2) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.0+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { diff --git a/lib/pool.js b/lib/pool.js index 1bc5462b1..d7560bd63 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -548,9 +548,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if ("cn" in algos_perf) this.algos_perf[""] = algos_perf["cn"]; else if ("cn/1" in algos_perf) this.algos_perf[""] = algos_perf["cn/1"]; + else if ("cn/2" in algos_perf) this.algos_perf[""] = algos_perf["cn/2"]; else if ("cryptonight" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight"]; else if ("cryptonight/1" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/1"]; - else return "algo_perf set should include cn or cn/1 hashrate"; + else if ("cryptonight/2" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/2"]; + else return "algo_perf set should include cn, cn/1 or cn/2 hashrate"; if ("cn/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cn/xtl"]; else if ("cryptonight/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cryptonight/xtl"]; From a7bf21fbebe3bb39e71ee62a61815d3b3800ce1d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 17 Sep 2018 22:52:19 +0200 Subject: [PATCH 0048/1496] Fixed block version usage --- lib/coins/xmr.js | 9 +++++---- lib/pool.js | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5da345ae0..ff4e0bad0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -149,24 +149,25 @@ function Coin(data){ return cnUtil.address_decode_integrated(address) === this.intPrefix; }; - this.portBlobType = function(port) { + this.portBlobType = function(port, version) { switch (port) { case 12211: return 4; // RYO + case 22023: return version >= 9 ? 5 : 0; // LOKI case 38081: return 3; // MSR default: return 0; } } this.convertBlob = function(blobBuffer, port){ - return cnUtil.convert_blob(blobBuffer, this.portBlobType(port)); + return cnUtil.convert_blob(blobBuffer, this.portBlobType(port, blobBuffer[0])); }; this.constructNewBlob = function(blockTemplate, NonceBuffer, port){ - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port)); + return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0])); }; this.getBlockID = function(blockBuffer, port){ - return cnUtil.get_block_id(blockBuffer, this.portBlobType(port)); + return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blockBuffer[0])); }; this.BlockTemplate = function(template) { diff --git a/lib/pool.js b/lib/pool.js index d7560bd63..496ca671d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -697,7 +697,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer ALGOS.forEach(function(algo) { if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; - if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, activeBlockTemplate[algo].blob[0])) return; + if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, activeBlockTemplate[algo].buffer[0])) return; let algoHashFactor = global.config.daemon["algoHashFactor" + algo]; if (miner.curr_algo === algo) algoHashFactor *= 1.05; if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { @@ -850,8 +850,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); this.cachedJob = { blob: blob, - algo: global.coinFuncs.algoShortTypeStr(bt.port, blob[0]), - variant: global.coinFuncs.variantValue(bt.port, blob[0]), + algo: global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]), + variant: global.coinFuncs.variantValue(bt.port, bt.buffer[0]), job_id: newJob.id, target: target, id: this.id @@ -874,9 +874,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); this.cachedJob = { blocktemplate_blob: blob, - blob_type: global.coinFuncs.blobTypeStr(bt.port, blob[0]), - algo: global.coinFuncs.algoShortTypeStr(bt.port, blob[0]), - variant: global.coinFuncs.variantValue(bt.port, blob[0]), + blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), + algo: global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]), + variant: global.coinFuncs.variantValue(bt.port, bt.buffer[0]), difficulty: bt.difficulty, height: bt.height, reserved_offset: bt.reserveOffset, From 8b8686842b41e2bb17a2c9e9dbc2d1583ca01ef2 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Tue, 18 Sep 2018 23:56:10 +0300 Subject: [PATCH 0049/1496] Fix Loki reward with upcoming fork --- lib/coins/xmr.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ff4e0bad0..b0e766778 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,7 +79,7 @@ function Coin(data){ this.getPortBlockHeaderByHash = function(port, blockHash, callback){ global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { - if (port != 20189 && port != 48782 && port != 11181) { // Stellite/Intense/Aeon have composite based miner_tx + if (port != 20189 && port != 48782 && port != 11181 && port != 22023) { // Stellite/Intense/Aeon/loki have composite based miner_tx const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; @@ -91,6 +91,14 @@ function Coin(data){ } } } + else if (port == 22023) { // Stellite/Intense/Aeon have composite based miner_tx + const blockJson = JSON.parse(body.result.json); + body.result.block_header.reward = 0; + + const minerTx = blockJson.miner_tx; + + body.result.block_header.reward = minerTx.vout[0].amount; + } return callback(null, body.result.block_header); } else { console.error(JSON.stringify(body)); From 190659990b8391c774960b68e94348942637d89c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 27 Sep 2018 17:30:11 +0200 Subject: [PATCH 0050/1496] Switched to sequantial altblock processing --- lib/blockManager.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index cf0458512..2f6303c1e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -567,24 +567,25 @@ function altblockUnlocker() { } debug("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); - blockList.forEach(function (block) { + async.eachSeries(blockList, function(block, next) { global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { if (err !== null) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); - return; + return next(); } if (body.hash !== block.hash) { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); + return next(); } else { if (block.pay_value !== 0) { - altblockPayments(block); + altblockPayments(block, function() { next(); } ); } else { console.log("Waiting for altblock with " + block.port + " port and " + block.height + " height pay value"); + return next(); } } }); - }); } @@ -620,13 +621,12 @@ function blockPayments(block) { }); break; default: - console.log("Unknown payment type. FREAKOUT"); - global.database.unlockBlock(block.hash); + console.error("Unknown payment type. FREAKOUT"); break; } } -function altblockPayments(block) { +function altblockPayments(block, cb) { switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { @@ -635,26 +635,28 @@ function altblockPayments(block) { if (anchor_err === null){ if (paymentInProgress) { debug("Skipping payment as there's a payment in progress"); - return; + return cb(); } paymentInProgress = true; calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty, function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); }); + return cb(); } else { console.error("Can't get correct block header by height " + block.anchor_height.toString()); + return cb(); } }); } else { console.error("Can't get correct altblock header of " + block.port.toString() + " port by hash " + block.hash.toString('hex')); + return cb(); } }); break; default: - console.log("Unknown payment type. FREAKOUT"); - global.database.unlockAltBlock(block.hash); - break; + console.error("Unknown payment type. FREAKOUT"); + return cb(); } } From 25f8b3905c5782d30ede0cfef16acb8027b6547f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 27 Sep 2018 17:44:34 +0200 Subject: [PATCH 0051/1496] Changed setInterval to setTimeout for alt block processing to avoif overlaps --- lib/blockManager.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 2f6303c1e..d7b08c536 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -555,14 +555,17 @@ function blockUnlocker() { function altblockUnlocker() { if (is_full_stop) { debug("Dropping all altblock unlocks"); + setTimeout(altblockUnlocker, 2*60*1000); return; } if (scanInProgress) { debug("Skipping altblock unlocker run as there's a scan in progress"); + setTimeout(altblockUnlocker, 2*60*1000); return; } if (paymentInProgress) { debug("Skipping altblock unlocker run as there's a payment in progress"); + setTimeout(altblockUnlocker, 2*60*1000); return; } debug("Running altblock unlocker"); @@ -586,6 +589,8 @@ function altblockUnlocker() { } } }); + }, function() { + setTimeout(altblockUnlocker, 2*60*1000); }); } @@ -715,7 +720,6 @@ function initial_sync() { // Scan every 120 seconds for invalidated blocks setInterval(blockUnlocker, 2*60*1000); blockUnlocker(); - setInterval(altblockUnlocker, 2*60*1000); altblockUnlocker(); debug("Blocks loaded from SQL: " + blockIDCache.length); console.log("Boot-sync from SQL complete: pending completion of queued jobs to get back to work."); From 724b25c32f6e2e857fd2a13344b6820368ba6093 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 27 Sep 2018 17:52:09 +0200 Subject: [PATCH 0052/1496] Reduced number of messages --- lib/blockManager.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index d7b08c536..14081407d 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -570,6 +570,7 @@ function altblockUnlocker() { } debug("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); + let blockHeightWait = {}; async.eachSeries(blockList, function(block, next) { global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { if (err !== null) { @@ -584,12 +585,18 @@ function altblockUnlocker() { if (block.pay_value !== 0) { altblockPayments(block, function() { next(); } ); } else { - console.log("Waiting for altblock with " + block.port + " port and " + block.height + " height pay value"); + if (!(block.port in blockHeightWait)) { + blockHeightWait[block.port] = (); + } + blockHeightWait[block.port].push(block.height); return next(); } } }); }, function() { + for (let port in blockHeightWait) { + console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); + } setTimeout(altblockUnlocker, 2*60*1000); }); } From ee724b55e94a447ff2ea0933b2edc2b04c5e42b6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 27 Sep 2018 17:53:49 +0200 Subject: [PATCH 0053/1496] Reduced number of messages --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 14081407d..e9029f374 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -586,7 +586,7 @@ function altblockUnlocker() { altblockPayments(block, function() { next(); } ); } else { if (!(block.port in blockHeightWait)) { - blockHeightWait[block.port] = (); + blockHeightWait[block.port] = []; } blockHeightWait[block.port].push(block.height); return next(); From 0ed9cf15a0a2e3082977f770960d43c4ddac05d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 28 Sep 2018 05:58:57 +0200 Subject: [PATCH 0054/1496] Removed extra damon check when payment is in process --- lib/blockManager.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e9029f374..7d4b0cbab 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -585,9 +585,7 @@ function altblockUnlocker() { if (block.pay_value !== 0) { altblockPayments(block, function() { next(); } ); } else { - if (!(block.port in blockHeightWait)) { - blockHeightWait[block.port] = []; - } + if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; blockHeightWait[block.port].push(block.height); return next(); } @@ -639,6 +637,10 @@ function blockPayments(block) { } function altblockPayments(block, cb) { + if (paymentInProgress) { + debug("Skipping payment as there's a payment in progress"); + return cb(); + } switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { From 53244164d4e89d8e8e6776fefbe3b2716ff78118 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 Sep 2018 14:15:21 +0200 Subject: [PATCH 0055/1496] Replaced accumulation based worker counts to more reliable counters that will work in case of worker process restarts --- lib/pool.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 496ca671d..4e9cda072 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -125,11 +125,8 @@ function messageHandler(message) { debug(threadName + "Received new algo hash factor"); setNewAlgoHashFactor(message.data.algo, message.data.algoHashFactor); break; - case 'removeMiner': - if (cluster.isMaster) -- minerCount[message.data]; - break; - case 'newMiner': - if (cluster.isMaster) ++ minerCount[message.data]; + case 'minerPortCount': + if (cluster.isMaster) minerCount[message.data.worker_id] = message.data.ports; break; case 'sendRemote': if (cluster.isMaster) { @@ -183,11 +180,13 @@ function retargetMiners() { } } + global.config.ports.forEach(function (portData) { minerCount[portData.port] = 0; }); const time_before = Date.now(); - for (var [minerId, miner] of activeSmartMiners) retargetMiner(miner); - for (var [minerId, miner] of activeMiners) retargetMiner(miner); + for (var [minerId, miner] of activeSmartMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } + for (var [minerId, miner] of activeMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } const elapsed = Date.now() - time_before; if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms for " + (activeSmartMiners.size + activeMiners.size) + " miners"); + process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id, ports: minerCount } }); } // wallet " " proxy miner name -> { connectTime, count (miner), hashes } @@ -212,7 +211,6 @@ function addProxyMiner(miner) { } function removeMiner(miner) { - process.send({type: 'removeMiner', data: miner.port}); const proxyMinerName = miner.proxyMinerName; if (proxyMinerName && proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; @@ -1333,7 +1331,6 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner_agent_notification); return; } - process.send({type: 'newMiner', data: miner.port}); if (miner.algos) { activeSmartMiners.set(minerId, miner); } else { @@ -1535,10 +1532,13 @@ if (global.config.general.allowStuckPoolKill && fs.existsSync("block_template_is } if (cluster.isMaster) { - let numWorkers = require('os').cpus().length; - global.config.ports.forEach(function (portData) { - minerCount[portData.port] = 0; - }); + const numWorkers = require('os').cpus().length; + for (let i = 0; i != numWorkers; ++ i) { + minerCount[i] = []; + global.config.ports.forEach(function (portData) { + minerCount[i][portData.port] = 0; + }); + } registerPool(); setInterval(function () { @@ -1548,9 +1548,11 @@ if (cluster.isMaster) { global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]); } global.config.ports.forEach(function (portData) { - global.mysql.query("UPDATE ports SET lastSeen = now(), miners = ? WHERE pool_id = ? AND network_port = ?", [minerCount[portData.port], global.config.pool_id, portData.port]); + let miner_count = 0; + for (let i = 0; i != numWorkers; ++ i) miner_count += minerCount[i][portData.port]; + global.mysql.query("UPDATE ports SET lastSeen = now(), miners = ? WHERE pool_id = ? AND network_port = ?", [miner_count, global.config.pool_id, portData.port]); }); - }, 10*1000); + }, 30*1000); setInterval(function () { From 139088295ebab8fda26135fe97ef3e47ccf96501 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 Sep 2018 14:49:56 +0200 Subject: [PATCH 0056/1496] Fixed worker numbering --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4e9cda072..a5e9255cc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1533,7 +1533,7 @@ if (global.config.general.allowStuckPoolKill && fs.existsSync("block_template_is if (cluster.isMaster) { const numWorkers = require('os').cpus().length; - for (let i = 0; i != numWorkers; ++ i) { + for (let i = 1; i <= numWorkers; ++ i) { minerCount[i] = []; global.config.ports.forEach(function (portData) { minerCount[i][portData.port] = 0; @@ -1549,7 +1549,7 @@ if (cluster.isMaster) { } global.config.ports.forEach(function (portData) { let miner_count = 0; - for (let i = 0; i != numWorkers; ++ i) miner_count += minerCount[i][portData.port]; + for (let i = 1; i <= numWorkers; ++ i) miner_count += minerCount[i][portData.port]; global.mysql.query("UPDATE ports SET lastSeen = now(), miners = ? WHERE pool_id = ? AND network_port = ?", [miner_count, global.config.pool_id, portData.port]); }); }, 30*1000); From 1cdcd86493ab58ea1bea18acb0fa17b47be9a76c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 Sep 2018 20:43:21 +0200 Subject: [PATCH 0057/1496] Moved from algo to coin based switching implementation --- deployment/base.sql | 24 ++-- lib/coins/xmr.js | 56 +++++++- lib/pool.js | 344 +++++++++++++++++++------------------------- lib/support.js | 28 ++-- lib/worker.js | 14 +- 5 files changed, 239 insertions(+), 227 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index ab8feb05a..bf72a4785 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -188,15 +188,21 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'retargetTime', '60', 'int', 'Time between difficulty retargets'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'port', '18081', 'int', 'Monero Daemon RPC Port'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePort', '0', 'int', 'Currently active daemon RPC port'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortHeavy', '0', 'int', 'Currently active heavy algo daemon RPC port'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLight', '0', 'int', 'Currently active light algo daemon RPC port'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortFast', '0', 'int', 'Currently active fast algo daemon RPC port'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTL', '0', 'int', 'Currently active XTL algo daemon RPC port'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'algoHashFactorHeavy', '0', 'float', 'Heavy algo hash price factor relative to algoHashFactor'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'algoHashFactorLight', '0', 'float', 'Light algo hash price factor relative to algoHashFactor'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'algoHashFactorFast', '0', 'float', 'Fast algo hash price factor relative to algoHashFactor'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'algoHashFactorXTL', '0', 'float', 'XTL algo hash price factor relative to algoHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePort', '18081', 'int', 'Main coin active daemon RPC port'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortRYO', '0', 'int', 'Ryo coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLOKI', '0', 'int', 'Loki coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTUBE', '0', 'int', 'BitTube coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXHV', '0', 'int', 'Haven coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortAEON', '0', 'int', 'Aeon coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortMSR', '0', 'int', 'Masari coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTL', '0', 'int', 'Stellite coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTUBE', '0', 'float', 'BitTube algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXHV', '0', 'float', 'Haven algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorAEON', '0', 'float', 'Aeon algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorMSR', '0', 'float', 'Masari algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTL', '0', 'float', 'Stellite algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b0e766778..2330417eb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -160,7 +160,7 @@ function Coin(data){ this.portBlobType = function(port, version) { switch (port) { case 12211: return 4; // RYO - case 22023: return version >= 9 ? 5 : 0; // LOKI + case 22023: return 5; // LOKI case 38081: return 3; // MSR default: return 0; } @@ -235,6 +235,58 @@ function Coin(data){ }; }; + this.getCOINS = function() { + return [ "GRFT", "LTHN", "RYO", "LOKI", "TUBE", "XHV", "AEON", "MSR", "XTL" ]; + } + + this.getDefaultAlgos = function() { + return [ "cn/1" ]; + } + + this.getDefaultAlgosPerf = function() { + return { "cn": 1, "cn-fast": 1.9 }; + } + + this.convertAlgosToCoinPerf(algos_perf) { + let coin_perf = {}; + + if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; + else if ("cryptonight" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cryptonight"]; + else if ("cryptonight/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cryptonight/1"]; + else return "algo_perf set should include cn or cn/1 hashrate"; + + if ("cn/2" in algos_perf) coin_perf[""] = algos_perf["cn/2"]; + else if ("cryptonight/2" in algos_perf) coin_perf[""] = algos_perf["cryptonight/2"]; + + if ("cn/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtl"]; + else if ("cryptonight/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cryptonight/xtl"]; + else coin_perf["XTL"] = coin_perf["GRFT"]; + + if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; + else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; + else if ("cryptonight-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cryptonight-fast"]; + else if ("cryptonight/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cryptonight/msr"]; + + if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; + else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; + else if ("cryptonight-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cryptonight-heavy"]; + else if ("cryptonight-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cryptonight-heavy/0"]; + + if ("cn-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cn-heavy/tube"]; + else if ("cryptonight-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cryptonight-heavy/tube"]; + + if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; + else if ("cryptonight-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cryptonight-heavy/xhv"]; + + if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; + else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; + else if ("cryptonight-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cryptonight-lite"]; + else if ("cryptonight-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cryptonight-lite/1"]; + + return coin_perf; + } + // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { return algos.includes("cn/1") || algos.includes("cn/2") || algos.includes("cryptonight/1") || algos.includes("cryptonight/2") ? @@ -258,7 +310,7 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { case 12211: return "cryptonote_ryo"; // RYO - case 22023: return version >= 9 ? "cryptonote_loki" : "cryptonote"; // LOKI + case 22023: return "cryptonote_loki"; // LOKI case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } diff --git a/lib/pool.js b/lib/pool.js index a5e9255cc..e7cb31d45 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -18,15 +18,14 @@ let notifyAddresses = {}; let baseDiff = global.coinFuncs.baseDiff(); let activeMiners = new Map(); -let activeSmartMiners = new Map(); // miners with algos/algos-perf -let lastBlockHash = {}; // algo key -let lastAlgoHashFactor = {}; // algo key -let activeBlockTemplate = {}; // algo key +let lastBlockHash = {}; // coin key +let lastCoinHashFactor = {}; // coin key +let activeBlockTemplate = {}; // coin key let pastBlockTemplates = global.support.circularBuffer(10); -let lastPortErrorTime = {}; // main algo port +let lastPortErrorTime = {}; // main coin port const fix_daemon_sh = "./fix_daemon.sh"; let lastBlockFixTime = {}; // time when blocks were checked to be in line with other nodes or when fix_daemon_sh was attempted @@ -78,8 +77,7 @@ if (cluster.isMaster) { global.database.thread_id = threadName; -// algo can be "", "Heavy", "Light", "Fast" -const ALGOS = [ "Heavy", "Light", "Fast", "XTL" ]; +const COINS = global.coinFuncs.getCOINS(); function registerPool() { global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { @@ -121,9 +119,9 @@ function messageHandler(message) { debug(threadName + "Received new block template"); setNewBlockTemplate(message.data); break; - case 'newAlgoHashFactor': - debug(threadName + "Received new algo hash factor"); - setNewAlgoHashFactor(message.data.algo, message.data.algoHashFactor); + case 'newCoinHashFactor': + debug(threadName + "Received new coin hash factor"); + setNewCoinHashFactor(message.data.coin, message.data.coinHashFactor); break; case 'minerPortCount': if (cluster.isMaster) minerCount[message.data.worker_id] = message.data.ports; @@ -182,10 +180,9 @@ function retargetMiners() { global.config.ports.forEach(function (portData) { minerCount[portData.port] = 0; }); const time_before = Date.now(); - for (var [minerId, miner] of activeSmartMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } - for (var [minerId, miner] of activeMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } + for (var [minerId, miner] of activeMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms for " + (activeSmartMiners.size + activeMiners.size) + " miners"); + if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id, ports: minerCount } }); } @@ -214,56 +211,51 @@ function removeMiner(miner) { const proxyMinerName = miner.proxyMinerName; if (proxyMinerName && proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; - if (miner.algos) { - activeSmartMiners.delete(miner.id); - } else { - activeMiners.delete(miner.id); - } + activeMiners.delete(miner.id); } function checkAliveMiners() { debug(threadName + "Verifying if miners are still alive"); const time_before = Date.now(); const deadline = time_before - global.config.pool.minerTimeout * 1000; - for (var [minerId, miner] of activeSmartMiners) if (miner.lastContact < deadline) removeMiner(miner); - for (var [minerId, miner] of activeMiners) if (miner.lastContact < deadline) removeMiner(miner); + for (var [minerId, miner] of activeMiners) if (miner.lastContact < deadline) removeMiner(miner); const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms for " + (activeSmartMiners.size + activeMiners.size) + " miners"); + if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } -// global.config.daemon["activePort" + algo] is only updated in master thread -function updateActivePort(algo) { - global.support.getActivePort(algo, function (newActivePort) { - const oldActivePort = global.config.daemon["activePort" + algo]; +// global.config.daemon["activePort" + coin] is only updated in master thread +function updateActivePort(coin) { + global.support.getActivePort(coin, function (newActivePort) { + const oldActivePort = global.config.daemon["activePort" + coin]; if (newActivePort === null) { - if (algo === "" && oldActivePort != global.config.daemon.port) { + if (coin === "" && oldActivePort != global.config.daemon.port) { console.error("Error getting activePort, so rolling back to main port"); global.config.daemon.activePort = global.config.daemon.port; } else { - console.error("Error getting " + "activePort" + algo); - global.config.daemon["algoHashFactor" + algo] = 0.0; + console.error("Error getting " + "activePort" + coin); + global.config.daemon["coinHashFactor" + coin] = 0.0; } } else { - if (algo !== "") { - global.support.getAlgoHashFactor(algo, function (newAlgoHashFactor) { - if (newAlgoHashFactor === null) { - console.error("Error getting " + "algoHashFactor" + algo); - global.config.daemon["algoHashFactor" + algo] = 0.0; + if (coin !== "") { + global.support.getCoinHashFactor(coin, function (newCoinHashFactor) { + if (newCoinHashFactor === null) { + console.error("Error getting " + "coinHashFactor" + coin); + global.config.daemon["coinHashFactor" + coin] = 0.0; } else { - if (newAlgoHashFactor == 0) debug("Got zero " + "algoHashFactor" + algo); - global.config.daemon["algoHashFactor" + algo] = newAlgoHashFactor; + if (newCoinHashFactor == 0) debug("Got zero " + "coinHashFactor" + coin); + global.config.daemon["coinHashFactor" + coin] = newCoinHashFactor; if (oldActivePort !== newActivePort) { - console.log("Changing " + "activePort" + algo + " from " + oldActivePort + " to " + newActivePort); - global.config.daemon["activePort" + algo] = newActivePort; + console.log("Changing " + "activePort" + coin + " from " + oldActivePort + " to " + newActivePort); + global.config.daemon["activePort" + coin] = newActivePort; } } }); } else if (oldActivePort !== newActivePort) { if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*60*1000) { - console.log("Changing " + "activePort" + algo + " from " + oldActivePort + " to " + newActivePort); - global.config.daemon["activePort" + algo] = newActivePort; + console.log("Changing " + "activePort" + coin + " from " + oldActivePort + " to " + newActivePort); + global.config.daemon["activePort" + coin] = newActivePort; } else if ((Date.now() - lastPortErrorTime[newActivePort]) % 60*1000 < 6*1000) { // print every 10th message - console.warn("Avoiding changing recently problem " + "activePort" + algo + " from " + oldActivePort + " to " + newActivePort); + console.warn("Avoiding changing recently problem " + "activePort" + coin + " from " + oldActivePort + " to " + newActivePort); } } } @@ -283,17 +275,17 @@ function setProblemPort(port) { } // templateUpdateReal is only called in master thread (except the beginning of a worker thread) -function templateUpdateReal(algo, activePort, algoHashFactor) { +function templateUpdateReal(coin, activePort, coinHashFactor) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { - if (activePort !== global.config.daemon["activePort" + algo]) { - console.log("Aborting " + activePort + " last block template request because " + "activePort" + algo + " was already changed to " + global.config.daemon["activePort" + algo] + " port"); + if (activePort !== global.config.daemon["activePort" + coin]) { + console.log("Aborting " + activePort + " last block template request because " + "activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; - rpcResponse.algo = algo; + rpcResponse.coin = coin; rpcResponse.port = activePort; - rpcResponse.algoHashFactor = algoHashFactor; + rpcResponse.coinHashFactor = coinHashFactor; debug(threadName + "New block template found at " + rpcResponse.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); @@ -303,60 +295,60 @@ function templateUpdateReal(algo, activePort, algoHashFactor) { } } else { console.error("Block template request failed for " + activePort + " port."); - if (algo === "") { + if (coin === "") { if (activePort != global.config.daemon.port) setProblemPort(activePort); } else { - algoHashFactorUpdate(algo, 0); + coinHashFactorUpdate(coin, 0); } - setTimeout(templateUpdateReal, 3000, algo, activePort); + setTimeout(templateUpdateReal, 3000, coin, activePort); } }); } -function algoHashFactorUpdate(algo, algoHashFactor) { - if (algo === "") return; +function coinHashFactorUpdate(coin, coinHashFactor) { + if (coin === "") return; if (cluster.isMaster) { - let data = { algo: algo, algoHashFactor: algoHashFactor }; - sendToWorkers({type: 'newAlgoHashFactor', data: data}); - setNewAlgoHashFactor(algo, algoHashFactor); - console.log('[*] New ' + algo + ' algo hash factor is set to ' + algoHashFactor); + let data = { coin: coin, coinHashFactor: coinHashFactor }; + sendToWorkers({type: 'newCoinHashFactor', data: data}); + setNewCoinHashFactor(coin, coinHashFactor); + console.log('[*] New ' + coin + ' coin hash factor is set to ' + coinHashFactor); } else { - setNewAlgoHashFactor(algo, algoHashFactor); + setNewCoinHashFactor(coin, coinHashFactor); } } // templateUpdate is only called in master thread (except the beginning of a worker thread) -function templateUpdate(algo, repeating) { - let activePort = global.config.daemon["activePort" + algo]; +function templateUpdate(coin, repeating) { + let activePort = global.config.daemon["activePort" + coin]; if (activePort) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { - if (activePort !== global.config.daemon["activePort" + algo]) { - console.log("Aborting " + activePort + " last block header request because " + "activePort" + algo + " was already changed to " + global.config.daemon["activePort" + algo] + " port"); - if (repeating === true) setTimeout(templateUpdate, 50, algo, repeating); + if (activePort !== global.config.daemon["activePort" + coin]) { + console.log("Aborting " + activePort + " last block header request because " + "activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); + if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); return; } if (err === null) { - const algoHashFactor = algo === "" ? 1.0 : global.config.daemon["algoHashFactor" + algo]; - if (!(algo in lastBlockHash) || body.hash !== lastBlockHash[algo]) { - lastBlockHash[algo] = body.hash; - lastAlgoHashFactor[algo] = algoHashFactor; - templateUpdateReal(algo, activePort, algoHashFactor); - } else if ( !(algo in lastAlgoHashFactor) || (algoHashFactor == 0 && lastAlgoHashFactor[algo] != 0) || - (algoHashFactor != 0 && Math.abs(lastAlgoHashFactor[algo] - algoHashFactor) / algoHashFactor > 0.05) + const coinHashFactor = coin === "" ? 1.0 : global.config.daemon["coinHashFactor" + coin]; + if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { + lastBlockHash[coin] = body.hash; + lastCoinHashFactor[coin] = coinHashFactor; + templateUpdateReal(coin, activePort, coinHashFactor); + } else if ( !(coin in lastCoinHashFactor) || (coinHashFactor == 0 && lastCoinHashFactor[coin] != 0) || + (coinHashFactor != 0 && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05) ) { - lastAlgoHashFactor[algo] = algoHashFactor; - algoHashFactorUpdate(algo, algoHashFactor); + lastCoinHashFactor[coin] = coinHashFactor; + coinHashFactorUpdate(coin, coinHashFactor); } - if (repeating === true) setTimeout(templateUpdate, 50, algo, repeating); + if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { - console.error("Last block header request for " + global.config.daemon["activePort" + algo] + " port failed!"); - if (algo === "") { + console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); + if (coin === "") { if (activePort != global.config.daemon.port) setProblemPort(activePort); } else { - algoHashFactorUpdate(algo, 0); + coinHashFactorUpdate(coin, 0); } - setTimeout(templateUpdate, 1000, algo, repeating); + setTimeout(templateUpdate, 1000, coin, repeating); } - }); else setTimeout(templateUpdate, 1000, algo, repeating); + }); else setTimeout(templateUpdate, 1000, coin, repeating); } @@ -382,57 +374,47 @@ function anchorBlockUpdate() { }); } -function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { +function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const time_before = Date.now(); - if (algo !== "") global.config.daemon["algoHashFactor" + algo] = algoHashFactor; // used in miner.selectBestAlgo + if (coin !== "") global.config.daemon["coinHashFactor" + coin] = coinHashFactor; // used in miner.selectBestCoin - for (var [minerId, miner] of activeSmartMiners) { + for (var [minerId, miner] of activeMiners) { if (check_height) miner.trust.check_height = check_height; miner.sendNewJob(); } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("setNewAlgoHashFactor() consumed " + elapsed + " ms for " + activeSmartMiners.size + " miners"); + if (elapsed > 500) console.error("setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { - const algo = template.algo; + const coin = template.coin; let isExtraCheck = false; - if (algo in activeBlockTemplate) { - if (activeBlockTemplate[algo].previous_hash.toString('hex') === template.prev_hash) { + if (coin in activeBlockTemplate) { + if (activeBlockTemplate[coin].previous_hash.toString('hex') === template.prev_hash) { console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } - activeBlockTemplate[algo].timeOutdate = Date.now() + 4*1000; - pastBlockTemplates.enq(activeBlockTemplate[algo]); - if (activeBlockTemplate[algo].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; + activeBlockTemplate[coin].timeOutdate = Date.now() + 4*1000; + pastBlockTemplates.enq(activeBlockTemplate[coin]); + if (activeBlockTemplate[coin].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { - const algo_str = algo === "" ? "" : algo + " "; - console.log('[*] New ' + algo_str + 'block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port (with algo hash factor ' + template.algoHashFactor + ")"); + const coin_str = coin === "" ? "" : coin + " "; + console.log('[*] New ' + coin_str + 'block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port (with coin hash factor ' + template.coinHashFactor + ")"); } else { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } - activeBlockTemplate[algo] = new BlockTemplate(template); - const height = activeBlockTemplate[algo].height; + activeBlockTemplate[coin] = new BlockTemplate(template); + const height = activeBlockTemplate[coin].height; - if (algo === "" && global.config.daemon.port == activeBlockTemplate[""].port) { + if (coin === "" && global.config.daemon.port == activeBlockTemplate[""].port) { anchorBlockHeight = height; } - setNewAlgoHashFactor(algo, template.algoHashFactor, isExtraCheck ? height : 0); - - const time_before = Date.now(); - - if (algo === "") for (var [minerId, miner] of activeMiners) { - if (isExtraCheck) miner.trust.check_height = height; - miner.sendNewJob(); - } - - const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("setNewBlockTemplate() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + setNewCoinHashFactor(coin, template.coinHashFactor, isExtraCheck ? height : 0); } // here we keep verified share number of a specific wallet (miner.payout) @@ -542,50 +524,32 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } else { return check; } - this.algos_perf = {}; - - if ("cn" in algos_perf) this.algos_perf[""] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) this.algos_perf[""] = algos_perf["cn/1"]; - else if ("cn/2" in algos_perf) this.algos_perf[""] = algos_perf["cn/2"]; - else if ("cryptonight" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight"]; - else if ("cryptonight/1" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/1"]; - else if ("cryptonight/2" in algos_perf) this.algos_perf[""] = algos_perf["cryptonight/2"]; - else return "algo_perf set should include cn, cn/1 or cn/2 hashrate"; - - if ("cn/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cn/xtl"]; - else if ("cryptonight/xtl" in algos_perf) this.algos_perf["XTL"] = algos_perf["cryptonight/xtl"]; - else this.algos_perf["XTL"] = this.algos_perf[""]; - - if ("cn-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn-fast"]; - else if ("cn/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cn/msr"]; - else if ("cryptonight-fast" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight-fast"]; - else if ("cryptonight/msr" in algos_perf) this.algos_perf["Fast"] = algos_perf["cryptonight/msr"]; - - if ("cn-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy"]; - else if ("cn-heavy/0" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cn-heavy/0"]; - else if ("cryptonight-heavy" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cryptonight-heavy"]; - else if ("cryptonight-heavy/0" in algos_perf) this.algos_perf["Heavy"] = algos_perf["cryptonight-heavy/0"]; - - if ("cn-lite" in algos_perf) this.algos_perf["Light"] = algos_perf["cn-lite"]; - else if ("cn-lite/1" in algos_perf) this.algos_perf["Light"] = algos_perf["cn-lite/1"]; - else if ("cryptonight-lite" in algos_perf) this.algos_perf["Light"] = algos_perf["cryptonight-lite"]; - else if ("cryptonight-lite/1" in algos_perf) this.algos_perf["Light"] = algos_perf["cryptonight-lite/1"]; - + const coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); + if (algos instanceof Object) { + this.coin_perf = coin_perf; + } else { + return coin_perf; + } this.algo_min_time = algo_min_time; return ""; }; if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { - if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = { "cn": 1, "cn-fast": 1.9 }; + if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = global.coinFuncs.getDefaultAlgosPerf(); if (!algo_min_time) algo_min_time = 0; - const status = this.setAlgos(algos, algos_perf, algo_min_time); - if (status != "") { - this.error = status; - this.valid_miner = false; - return; - } + } else { + algos = global.coinFuncs.getDefaultAlgos(); + algos_perf = global.coinFuncs.getDefaultAlgosPerf(); + algo_min_time = 0; + } + const status = this.setAlgos(algos, algos_perf, algo_min_time); + if (status != "") { + this.error = status; + this.valid_miner = false; + return; } + // 3) setup valid miner stuff // 3a) misc stuff @@ -682,34 +646,33 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer identifier: this.identifier }); - this.selectBestAlgo = function() { - if (!this.algos) return ""; - if (typeof(this.curr_algo) !== 'undefined' && this.curr_algo_time && this.algos_perf[this.curr_algo] && - Date.now() - this.curr_algo_time < this.algo_min_time*1000 + this.selectBestCoin = function() { + if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && this.coin_perf[this.curr_coin] && + Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { - return this.curr_algo; + return this.curr_coin; } - let best_algo = ""; - let best_algo_perf = this.algos_perf[""] * 1.1; + let best_coin = ""; + let best_coin_perf = this.coin_perf[""] * 1.1; let miner = this; - ALGOS.forEach(function(algo) { - if (!(algo in activeBlockTemplate)) return; - const port = activeBlockTemplate[algo].port; - if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, activeBlockTemplate[algo].buffer[0])) return; - let algoHashFactor = global.config.daemon["algoHashFactor" + algo]; - if (miner.curr_algo === algo) algoHashFactor *= 1.05; - if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { - debug(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); - best_algo = algo; - best_algo_perf = miner.algos_perf[algo] * algoHashFactor; + COINS.forEach(function(coin) { + if (!(coin in activeBlockTemplate)) return; + const port = activeBlockTemplate[coin].port; + if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, activeBlockTemplate[coin].buffer[0])) return; + let coinHashFactor = global.config.daemon["coinHashFactor" + coin]; + if (miner.curr_coin === coin) coinHashFactor *= 1.05; + if (coin in miner.coin_perf && miner.coin_perf[coin] * coinHashFactor > best_coin_perf) { + debug(miner.logString + ": " + coin + ": " + miner.coin_perf[coin] * coinHashFactor); + best_coin = coin; + best_coin_perf = miner.coin_perf[coin] * coinHashFactor; } }); - if (typeof(this.curr_algo) === 'undefined' || this.curr_algo != best_algo) { - this.curr_algo = best_algo; - this.curr_algo_time = Date.now(); - if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_algo].height; + if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { + this.curr_coin = best_coin; + this.curr_coin_time = Date.now(); + if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_coin].height; } - return best_algo; + return best_coin; } this.calcNewDiff = function () { @@ -822,27 +785,27 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return buffReversed.toString('hex'); }; this.getJob = function () { - const algo = this.selectBestAlgo(); - let bt = activeBlockTemplate[algo]; + const coin = this.selectBestCoin(); + let bt = activeBlockTemplate[coin]; if (this.jobLastBlockHash === bt.idHash && !this.newDiff && this.cachedJob !== null) return null; this.jobLastBlockHash = bt.idHash; if (this.newDiff) { this.difficulty = this.newDiff; this.newDiff = null; } - const algoHashFactor = algo === "" ? 1.0 : global.config.daemon["algoHashFactor" + algo]; + const coinHashFactor = coin === "" ? 1.0 : global.config.daemon["coinHashFactor" + coin]; if (!this.proxy) { let blob = bt.nextBlob(); let target = this.getTargetHex(); let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), - algo_type: algo, + coin: coin, blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, difficulty: this.difficulty, diffHex: this.diffHex, - algoHashFactor: algoHashFactor, + coinHashFactor: coinHashFactor, submissions: {} }; this.validJobs.enq(newJob); @@ -858,7 +821,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let blob = bt.nextBlobWithChildNonce(); let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), - algo_type: algo, + coin: coin, blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, @@ -866,7 +829,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer diffHex: this.diffHex, clientPoolLocation: bt.clientPoolLocation, clientNonceLocation: bt.clientNonceLocation, - algoHashFactor: algoHashFactor, + coinHashFactor: coinHashFactor, submissions: {} }; this.validJobs.enq(newJob); @@ -1088,7 +1051,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy process.send({type: 'normalShare'}); debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); } - if (activeBlockTemplate[blockTemplate.algo].idHash !== job.blockHash) { + if (activeBlockTemplate[blockTemplate.coin].idHash !== job.blockHash) { process.send({type: 'outdatedShare'}); } @@ -1195,7 +1158,7 @@ function processShare(miner, job, blockTemplate, params) { hash = global.coinFuncs.cryptoNight(convertedBlob); if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } - console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate[blockTemplate.algo].height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); + console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate[blockTemplate.coin].height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time global.coinFuncs.getPortLastBlockHeader(blockTemplate.port, function(err, body){ if (err !== null) { @@ -1290,7 +1253,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let minerId = uuidV4(); miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, - params.algo, params["algo-perf"], params["algo-min-time"] + params.coin, params["coin-perf"], params["coin-min-time"] ); let time_now = Date.now(); if (!miner.valid_miner) { @@ -1331,11 +1294,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner_agent_notification); return; } - if (miner.algos) { - activeSmartMiners.set(minerId, miner); - } else { - activeMiners.set(minerId, miner); - } + + activeMiners.set(minerId, miner); + if (!miner.proxy) { let proxyMinerName = miner.payout + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { @@ -1360,15 +1321,14 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { }); break; case 'getjob': - miner = activeSmartMiners.get(params.id); - if (!miner) miner = activeMiners.get(params.id); + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; } miner.heartbeat(); - if (miner.algos && params.algo && params.algo instanceof Array && params["algo-perf"] && params["algo-perf"] instanceof Object) { - const status = miner.setAlgos(params.algo, params["algo-perf"], params["algo-min-time"]); + if (params.coin && params.coin instanceof Array && params["coin-perf"] && params["coin-perf"] instanceof Object) { + const status = miner.setAlgos(params.coin, params["coin-perf"], params["coin-min-time"]); if (status != "") { sendReply(status); return; @@ -1377,8 +1337,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.sendNewJob(); break; case 'submit': - miner = activeSmartMiners.get(params.id); - if (!miner) miner = activeMiners.get(params.id); + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1433,7 +1392,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let blockTemplate; job.rewarded_difficulty = job.difficulty; - if (activeBlockTemplate[job.algo_type].idHash !== job.blockHash) { + if (activeBlockTemplate[job.coin].idHash !== job.blockHash) { blockTemplate = pastBlockTemplates.toarray().filter(function (t) { return t.idHash === job.blockHash; })[0]; @@ -1464,10 +1423,10 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } } else { - blockTemplate = activeBlockTemplate[job.algo_type]; + blockTemplate = activeBlockTemplate[job.coin]; } - job.rewarded_difficulty2 = job.rewarded_difficulty * job.algoHashFactor; + job.rewarded_difficulty2 = job.rewarded_difficulty * job.coinHashFactor; let shareAccepted = processShare(miner, job, blockTemplate, params); if (shareAccepted === null) { @@ -1512,8 +1471,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(null, {status: 'OK'}); break; case 'keepalived': - miner = activeSmartMiners.get(params.id); - if (!miner) miner = activeMiners.get(params.id); + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1645,13 +1603,13 @@ if (cluster.isMaster) { global.config.daemon.activePort = global.config.daemon.port; } else { setInterval(updateActivePort, 3*1000, ""); - if (global.config.daemon.enableAlgoSwitching) ALGOS.forEach(function(algo) { - if ("activePort" + algo in global.config.daemon) { - setInterval(updateActivePort, 5*1000, algo); - templateUpdate(algo); - setTimeout(templateUpdate, 50, algo, true); + if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { + if ("activePort" + coin in global.config.daemon) { + setInterval(updateActivePort, 5*1000, coin); + templateUpdate(coin); + setTimeout(templateUpdate, 50, coin, true); } else { - console.warn("global.config.daemon." + "activePort" + algo + " is not defined, so ignoring its algo changes"); + console.warn("global.config.daemon." + "activePort" + coin + " is not defined, so ignoring its coin changes"); } }); } @@ -1661,8 +1619,8 @@ if (cluster.isMaster) { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); } else { templateUpdate(""); - if (global.config.daemon.enableAlgoSwitching) ALGOS.forEach(function(algo) { - if ("activePort" + algo in global.config.daemon) templateUpdate(algo); + if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { + if ("activePort" + coin in global.config.daemon) templateUpdate(coin); }); anchorBlockUpdate(); setInterval(anchorBlockUpdate, 3*1000); diff --git a/lib/support.js b/lib/support.js index 31c3c9ef1..14f77cd20 100644 --- a/lib/support.js +++ b/lib/support.js @@ -241,34 +241,34 @@ function https_get(url, callback) { req.end(); } -function getAlgoHashFactor(algo, callback) { - global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'algoHashFactor" + algo + "'").then(function (rows) { +function getCoinHashFactor(coin, callback) { + global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'coinHashFactor" + coin + "'").then(function (rows) { if (rows.length != 1) { - console.error("Can't get config.daemon.algoHashFactor" + algo + " value"); + console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } callback(parseFloat(rows[0].item_value)); }); } -function getActivePort(algo, callback) { - global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'activePort" + algo + "'").then(function (rows) { +function getActivePort(coin, callback) { + global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'activePort" + coin + "'").then(function (rows) { if (rows.length != 1) { - console.error("Can't get config.daemon.activePort" + algo + " value"); + console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } callback(parseInt(rows[0].item_value)); }); } -function setAlgoHashFactor(algo, algoHashFactor) { - global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'algoHashFactor" + algo + "'", [algoHashFactor]); - global.config.daemon["algoHashFactor" + algo] = algoHashFactor; +function setCoinHashFactor(coin, coinHashFactor) { + global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'coinHashFactor" + coin + "'", [coinHashFactor]); + global.config.daemon["coinHashFactor" + coin] = coinHashFactor; } -function setActivePort(algo, activePort) { - global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort" + algo + "'", [activePort]); - global.config.daemon["activePort" + algo] = activePort; +function setActivePort(coin, activePort) { + global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort" + coin + "'", [activePort]); + global.config.daemon["activePort" + coin] = activePort; } function formatDate(date) { @@ -345,9 +345,9 @@ module.exports = function () { sendEmail: sendEmail, sendEmailAdmin: sendEmailAdmin, tsCompare: tsCompare, - getAlgoHashFactor: getAlgoHashFactor, + getCoinHashFactor: getCoinHashFactor, getActivePort: getActivePort, - setAlgoHashFactor: setAlgoHashFactor, + setCoinHashFactor: setCoinHashFactor, setActivePort: setActivePort, https_get: https_get, }; diff --git a/lib/worker.js b/lib/worker.js index f5c6537aa..97945de58 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -373,14 +373,10 @@ function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { } function updatePoolStats(poolType) { - if (global.config.daemon.activePort) { - global.support.getActivePort("", function (newActivePort) { - if (newActivePort) global.config.daemon.activePort = newActivePort; - updatePoolStats2(poolType); - }); - } else { + global.support.getActivePort("", function (newActivePort) { + if (newActivePort) global.config.daemon.activePort = newActivePort; updatePoolStats2(poolType); - } + }); } let price_btc = 0; @@ -390,7 +386,7 @@ let min_block_rewards = {}; function updatePoolStats2(poolType) { let cache; - let port_suffix = global.config.daemon.activePort && global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; + let port_suffix = global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; if (typeof(poolType) !== 'undefined') { cache = global.database.getCache(poolType + "_stats"); if (port_suffix === "") { @@ -507,7 +503,7 @@ function updatePoolStats2(poolType) { }, function (callback) { //debug(threadName + "Checking MySQL for activePort value"); - return callback(null, global.config.daemon.activePort ? global.config.daemon.activePort : global.config.daemon.port); + return callback(null, global.config.daemon.activePort); }, function (callback) { //debug(threadName + "Checking LMDB cache for active_ports value"); From 713c6df54b1549733d5f31a75cbbddf5c767e072 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 Sep 2018 20:45:15 +0200 Subject: [PATCH 0058/1496] Syntax fix --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2330417eb..7d4505f53 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -247,7 +247,7 @@ function Coin(data){ return { "cn": 1, "cn-fast": 1.9 }; } - this.convertAlgosToCoinPerf(algos_perf) { + this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; From f037f49ae31ade156e39d5745f9c9f9daef6f0e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 Sep 2018 20:55:24 +0200 Subject: [PATCH 0059/1496] Fixed algo name --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7d4505f53..aeedd86e1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -216,8 +216,8 @@ function Coin(data){ this.clientNonceLocation = this.reserveOffset + 12; // The clientPoolLocation is for multi-thread/multi-server pools to handle the nonce for each of their tiers. this.clientPoolLocation = this.reserveOffset + 8; - // this is current algo type - this.algo = template.algo; + // this is current coin + this.coin = template.coin; // this is current daemon port this.port = template.port; this.nextBlob = function () { From f2362f06d7d4a2ba4e895a8313d787ffba7902d1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 Sep 2018 21:27:59 +0200 Subject: [PATCH 0060/1496] Fixed small diff adjustments --- lib/pool.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e7cb31d45..8f4f739be 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -729,16 +729,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.setNewDiff = function (difficulty) { if (this.fixed_diff) return false; - this.newDiff = Math.round(difficulty); - if (this.newDiff > global.config.pool.maxDifficulty && !this.proxy) { - this.newDiff = global.config.pool.maxDifficulty; + let newDiff = Math.round(difficulty); + if (newDiff > global.config.pool.maxDifficulty && !this.proxy) { + newDiff = global.config.pool.maxDifficulty; } - if (this.newDiff < global.config.pool.minDifficulty) { - this.newDiff = global.config.pool.minDifficulty; + if (newDiff < global.config.pool.minDifficulty) { + newDiff = global.config.pool.minDifficulty; } - const ratio = Math.abs(this.newDiff - this.difficulty) / this.difficulty; + const ratio = Math.abs(newDiff - this.difficulty) / this.difficulty; if (ratio < 0.05) return false; + this.newDiff = newDiff; debug(threadName + "Difficulty change to: " + this.newDiff + " For: " + this.logString); if (this.hashes > 0) { From c36d7fae6feb6e8d4df6825f26c2527a70729de5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 Sep 2018 22:09:11 +0200 Subject: [PATCH 0061/1496] Fixed wrong replace --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8f4f739be..c57e50fd3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1254,7 +1254,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let minerId = uuidV4(); miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, - params.coin, params["coin-perf"], params["coin-min-time"] + params.algo, params["algo-perf"], params["algo-min-time"] ); let time_now = Date.now(); if (!miner.valid_miner) { @@ -1328,8 +1328,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } miner.heartbeat(); - if (params.coin && params.coin instanceof Array && params["coin-perf"] && params["coin-perf"] instanceof Object) { - const status = miner.setAlgos(params.coin, params["coin-perf"], params["coin-min-time"]); + if (params.algo && params.algo instanceof Array && params["algo-perf"] && params["algo-perf"] instanceof Object) { + const status = miner.setAlgos(params.algo, params["algo-perf"], params["algo-min-time"]); if (status != "") { sendReply(status); return; From ace71768237e04a3484532a8e626bafcbd240522 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Oct 2018 20:34:18 +0200 Subject: [PATCH 0062/1496] Added cn/2 tweak support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6231b6d2..ef7943e18 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.1" } } From e746f7217efea3fb26b758853b64c3589dcde151 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Oct 2018 22:36:55 +0200 Subject: [PATCH 0063/1496] Added fixed cn/2 support --- lib/coins/xmr.js | 18 ++++++++++++------ package.json | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index aeedd86e1..6c088f2fb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -8,7 +8,7 @@ const process = require('process'); let hexChars = new RegExp("[0-9a-f]+"); -var reXMRig = /XMRig\/(\d+)\.(\d+)\./; +var reXMRig = /XMRig(?:-[A-Za-z]+)?\/(\d+)\.(\d+)\./; var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; var reXMRSTAK2 = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)\.(\d+)/; var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; @@ -373,7 +373,7 @@ function Coin(data){ let majorv = parseInt(m[1]) * 100; let minorv = parseInt(m[2]); if (majorv + minorv < 205) { - return "Please update your XMRig miner (" + agent + ") to v2.6.1+"; + return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; } } else if (m = reXMRSTAK.exec(agent)) { let majorv = parseInt(m[1]) * 100; @@ -386,7 +386,7 @@ function Coin(data){ let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 2) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.0+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]) * 100; @@ -400,7 +400,13 @@ function Coin(data){ this.get_miner_agent_warning_notification = function(agent) { let m; - if (m = reXMRSTAK2.exec(agent)) { + if (m = reXMRig.exec(agent)) { + let majorv = parseInt(m[1]) * 100; + let minorv = parseInt(m[2]); + if (majorv + minorv < 208) { + return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; + } + } else if (m = reXMRSTAK2.exec(agent)) { let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); @@ -411,8 +417,8 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 300) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 301) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } return false; diff --git a/package.json b/package.json index ef7943e18..117bb4fa6 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.2" } } From 348ad2ae10f345a372c4bde69b82950d47271596 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Oct 2018 22:54:44 +0200 Subject: [PATCH 0064/1496] Updated hashing utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 117bb4fa6..3101b1dfb 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.2" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.3" } } From b80298095b47cb67196594f8904ddb338f2ac4a5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Oct 2018 17:27:50 +0200 Subject: [PATCH 0065/1496] Block processing optimization --- lib/pool.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c57e50fd3..1bde34ef0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -375,13 +375,24 @@ function anchorBlockUpdate() { } function setNewCoinHashFactor(coin, coinHashFactor, check_height) { - const time_before = Date.now(); - if (coin !== "") global.config.daemon["coinHashFactor" + coin] = coinHashFactor; // used in miner.selectBestCoin + if (!(coin in activeBlockTemplate)) return; + const port = activeBlockTemplate[coin].port; + const block_version = activeBlockTemplate[coin].buffer[0]; - for (var [minerId, miner] of activeMiners) { - if (check_height) miner.trust.check_height = check_height; - miner.sendNewJob(); + const time_before = Date.now(); + + if (check_height) { + for (var [minerId, miner] of activeMiners) { + if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, block_version)) continue; + miner.trust.check_height = check_height; + miner.sendNewJob(); + } + } else { + for (var [minerId, miner] of activeMiners) { + if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, block_version)) continue; + miner.sendNewJob(); + } } const elapsed = Date.now() - time_before; From f8bc4e56860fa85914164cbc0c9c733d4c5cea7f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Oct 2018 17:47:59 +0200 Subject: [PATCH 0066/1496] Updated cn hash utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3101b1dfb..d0968adab 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.3" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.5" } } From 2a762c5788d53384b53b21188ba8b4682113cb1d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Oct 2018 18:40:01 +0200 Subject: [PATCH 0067/1496] More miner processing optimizations --- lib/coins/xmr.js | 18 +++++++----------- lib/pool.js | 11 +++++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6c088f2fb..3b93a160f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -8,7 +8,7 @@ const process = require('process'); let hexChars = new RegExp("[0-9a-f]+"); -var reXMRig = /XMRig(?:-[A-Za-z]+)?\/(\d+)\.(\d+)\./; +var reXMRig = /XMRig(?:-AMD)?\/(\d+)\.(\d+)\./; var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; var reXMRSTAK2 = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)\.(\d+)/; var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; @@ -357,14 +357,10 @@ function Coin(data){ } } - this.isMinerSupportPortAlgo = function(port, algos, version) { - if (this.algoShortTypeStr(port, version) in algos || this.algoTypeStr(port, version) in algos) return true; - switch (port) { - case 12211: // RYO - case 22023: // LOKI - return "cryptonight-heavy" in algos || "cn-heavy" in algos; - default: return false; - } + this.isMinerSupportAlgo = function(algo, algos) { + if (algo in algos) return true; + if (algo === "cn-heavy/0" && "cn-heavy" in algos) return true; + return false; } this.get_miner_agent_notification = function(agent) { @@ -379,7 +375,7 @@ function Coin(data){ let majorv = parseInt(m[1]) * 100; let minorv = parseInt(m[2]); if (majorv + minorv < 203) { - return "Please update your xmr-stak miner (" + agent + ") to v2.4.3+ (and use cryptonight_v7 in config)"; + return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]) * 10000; @@ -411,7 +407,7 @@ function Coin(data){ let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 20403) { - return "Please update your xmr-stak miner (" + agent + ") to v2.4.3+ (and use cryptonight_v7 in config)"; + return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]) * 10000; diff --git a/lib/pool.js b/lib/pool.js index 1bde34ef0..bcad1cf4a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -379,18 +379,19 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { if (!(coin in activeBlockTemplate)) return; const port = activeBlockTemplate[coin].port; const block_version = activeBlockTemplate[coin].buffer[0]; + const algo = global.coinFuncs.algoShortTypeStr(port, block_version); const time_before = Date.now(); if (check_height) { for (var [minerId, miner] of activeMiners) { - if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, block_version)) continue; + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; miner.trust.check_height = check_height; miner.sendNewJob(); } } else { for (var [minerId, miner] of activeMiners) { - if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, block_version)) continue; + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; miner.sendNewJob(); } } @@ -668,8 +669,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let miner = this; COINS.forEach(function(coin) { if (!(coin in activeBlockTemplate)) return; - const port = activeBlockTemplate[coin].port; - if (!global.coinFuncs.isMinerSupportPortAlgo(port, miner.algos, activeBlockTemplate[coin].buffer[0])) return; + const port = activeBlockTemplate[coin].port; + const block_version = activeBlockTemplate[coin].buffer[0]; + const algo = global.coinFuncs.algoShortTypeStr(port, block_version); + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) return; let coinHashFactor = global.config.daemon["coinHashFactor" + coin]; if (miner.curr_coin === coin) coinHashFactor *= 1.05; if (coin in miner.coin_perf && miner.coin_perf[coin] * coinHashFactor > best_coin_perf) { From dbe3cab9dacc730e56996868fbcaf2f7e471ad2b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Oct 2018 18:49:59 +0200 Subject: [PATCH 0068/1496] Reduced difficulty jumping --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bcad1cf4a..340a189d9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -752,7 +752,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } const ratio = Math.abs(newDiff - this.difficulty) / this.difficulty; - if (ratio < 0.05) return false; + if (ratio < 0.2) return false; this.newDiff = newDiff; debug(threadName + "Difficulty change to: " + this.newDiff + " For: " + this.logString); From 19bfe0959baa221446ffe4c863e61200f11386cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Oct 2018 19:57:17 +0200 Subject: [PATCH 0069/1496] Fixed XNP 0.3.1 issue --- lib/coins/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3b93a160f..e5ea3d32a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -359,6 +359,7 @@ function Coin(data){ this.isMinerSupportAlgo = function(algo, algos) { if (algo in algos) return true; + if (algo === "cn/1" && "cryptonight/1" in algos) return true; // for temp compat with XNP 0.3.1 if (algo === "cn-heavy/0" && "cn-heavy" in algos) return true; return false; } @@ -413,8 +414,8 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 301) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 302) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.2+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } return false; From 175ff7873d77443f0811c6beb53ba1cc28c9228e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Oct 2018 14:14:48 +0200 Subject: [PATCH 0070/1496] Precise diff setting during new block job --- lib/pool.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 340a189d9..e787e8431 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -751,15 +751,16 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer newDiff = global.config.pool.minDifficulty; } + this.newDiffRecommendation = newDiff; const ratio = Math.abs(newDiff - this.difficulty) / this.difficulty; if (ratio < 0.2) return false; - this.newDiff = newDiff; + this.newDiffToSet = newDiff; - debug(threadName + "Difficulty change to: " + this.newDiff + " For: " + this.logString); + debug(threadName + "Difficulty change to: " + this.newDiffToSet + " For: " + this.logString); if (this.hashes > 0) { debug(threadName + "Hashes: " + this.hashes + " in: " + Math.floor((Date.now() - this.connectTime) / 1000) + " seconds gives: " + Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) + " hashes/second or: " + - Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime + " difficulty versus: " + this.newDiff); + Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime + " difficulty versus: " + this.newDiffToSet); } return true; }; @@ -802,11 +803,15 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.getJob = function () { const coin = this.selectBestCoin(); let bt = activeBlockTemplate[coin]; - if (this.jobLastBlockHash === bt.idHash && !this.newDiff && this.cachedJob !== null) return null; + if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; this.jobLastBlockHash = bt.idHash; - if (this.newDiff) { - this.difficulty = this.newDiff; - this.newDiff = null; + if (this.newDiffToSet) { + this.difficulty = this.newDiffToSet; + this.newDiffToSet = null; + this.newDiffRecommendation = null; + } else if (this.newDiffRecommendation) { + this.difficulty = this.newDiffRecommendation; + this.newDiffRecommendation = null; } const coinHashFactor = coin === "" ? 1.0 : global.config.daemon["coinHashFactor" + coin]; if (!this.proxy) { From 3210935a26653d01e7bb7273a465e3306ffda619 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Oct 2018 16:14:33 +0200 Subject: [PATCH 0071/1496] Fixed semantic error --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e787e8431..859f12415 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -537,7 +537,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return check; } const coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); - if (algos instanceof Object) { + if (coin_perf instanceof Object) { this.coin_perf = coin_perf; } else { return coin_perf; From 4d813346c44b60794210b1efa61e3f1d4f11651a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Oct 2018 08:56:33 +0200 Subject: [PATCH 0072/1496] Pool closed bad miner sockets now --- lib/pool.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 859f12415..538438e14 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1254,18 +1254,18 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { +function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { // Check for ban here, so preconnected attackers can't continue to screw you if (ip in bannedIPs) { // Handle IP ban off clip. - sendReply("IP Address currently banned"); + sendFinalReply("IP Address currently banned"); return; } let miner; switch (method) { case 'login': if (!params.login) { - sendReply("No login specified"); + sendFinalReply("No login specified"); return; } if (!params.pass) params.pass = "x"; @@ -1281,14 +1281,14 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); lastMinerLogTime[miner.payout] = time_now; } - sendReply(miner.error); + sendFinalReply(miner.error); return; } let miner_id = miner.payout + ":" + miner.identifier + ":" + miner.ipAddress; if (miner_id in badMinerLastShareTime) { let ban_time_left = 3*60*1000 - (time_now - badMinerLastShareTime[miner_id]); if (ban_time_left > 0) { - sendReply("You miner " + miner.identifier + " is currently banned for submitting wrong result for " + (ban_time_left / 1000) + " seconds"); + sendFinalReply("You miner " + miner.identifier + " is currently banned for submitting wrong result for " + (ban_time_left / 1000) + " seconds"); return; } else { debug(threadName + "Removed miner " + miner.logString + " from ban"); @@ -1302,7 +1302,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_notification); - sendReply(miner_notification + " (miner will connect after several attempts)"); + sendFinalReply(miner_notification + " (miner will connect after several attempts)"); return; } } @@ -1311,7 +1311,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); } - sendReply(miner_agent_notification); + sendFinalReply(miner_agent_notification); return; } @@ -1343,7 +1343,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { case 'getjob': miner = activeMiners.get(params.id); if (!miner) { - sendReply('Unauthenticated'); + sendFinalReply('Unauthenticated'); return; } miner.heartbeat(); @@ -1359,7 +1359,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { case 'submit': miner = activeMiners.get(params.id); if (!miner) { - sendReply('Unauthenticated'); + sendFinalReply('Unauthenticated'); return; } miner.heartbeat(); @@ -1369,7 +1369,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { })[0]; if (!job) { - sendReply('Invalid job id'); + sendFinalReply('Invalid job id'); return; } @@ -1493,7 +1493,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { case 'keepalived': miner = activeMiners.get(params.id); if (!miner) { - sendReply('Unauthenticated'); + sendFinalReply('Unauthenticated'); return; } miner.heartbeat(); @@ -1742,7 +1742,16 @@ if (cluster.isMaster) { }) + "\n"; socket.write(sendData); }; - handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, pushMessage); + let sendFinalReply = function (error) { + let sendData = JSON.stringify({ + id: jsonData.id, + jsonrpc: "2.0", + error: {code: -1, message: error}, + result: null + }) + "\n"; + socket.end(sendData); + }; + handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); }; function socketConn(socket) { From 4a5244f09452ea2d832eafec8400e38ea15d093e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Oct 2018 21:22:56 +0200 Subject: [PATCH 0073/1496] Store miner agents into file --- lib/pool.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 538438e14..986a3198e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -437,6 +437,9 @@ let walletTrust = {}; // wallet last seen time (all wallets that are not detected for more than 1 day are removed) let walletLastSeeTime = {}; +// miner agent strings (for cluster.worker.id == 1) +let minerAgents = {}; + var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; @@ -1275,6 +1278,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); + if (params.agent && cluster.worker.id == 1) minerAgents[params.agent] = 1; let time_now = Date.now(); if (!miner.valid_miner) { if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { @@ -1694,7 +1698,7 @@ if (cluster.isMaster) { }); } - // dump wallet trust to file + // dump wallet trust and miner agents to file setInterval(function () { let str = ""; for (let wallet in walletTrust) { @@ -1706,8 +1710,16 @@ if (cluster.isMaster) { delete walletLastSeeTime[wallet]; } } - let fn = "wallet_trust_" + cluster.worker.id.toString(); + const fn = "wallet_trust_" + cluster.worker.id.toString(); fs.writeFile(fn, str, function(err) { if (err) console.error("Error saving " + fn + " file"); }); + + if (cluster.worker.id == 1) { + let str2 = ""; + for (let agent in minerAgents) { str2 += agent + "\n"; } + const fn2 = "miner_agents"; + fs.writeFile(fn2, str2, function(err) { if (err) console.error("Error saving " + fn2 + " file"); }); + } + }, 10*60*1000); let lastGarbageFromIpTime = {}; From 2ce55f4bbaa511c915f62067dbba9c4064a7cd84 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Oct 2018 21:26:17 +0200 Subject: [PATCH 0074/1496] Moved wallet trust messages to debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 986a3198e..377146d60 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1691,7 +1691,7 @@ if (cluster.isMaster) { let trust = parseInt(parts[1], 10); let time = parseInt(parts[2], 10); if (Date.now() - time < 24*60*60*1000 && (!(wallet in walletTrust) || trust < walletTrust[wallet])) { - console.log("Adding " + trust.toString() + " trust for " + wallet + " wallet"); + debug("Adding " + trust.toString() + " trust for " + wallet + " wallet"); walletTrust[wallet] = trust; walletLastSeeTime[wallet] = time; } From c0ab9f3ead73b9dbf00396dd2e150e5be9930658 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Oct 2018 22:18:40 +0200 Subject: [PATCH 0075/1496] Updated miner agent checks --- lib/coins/xmr.js | 52 +++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e5ea3d32a..da504e366 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -8,11 +8,13 @@ const process = require('process'); let hexChars = new RegExp("[0-9a-f]+"); -var reXMRig = /XMRig(?:-AMD)?\/(\d+)\.(\d+)\./; -var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; -var reXMRSTAK2 = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)\.(\d+)/; -var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; -var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; +const reXMRig = /XMRig(?:-AMD)?\/(\d+)\.(\d+)\./; // 2.8.0 +const reXMRSTAK = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)/; // 2.5.0 +const reXMRSTAK2 = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 +const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 +const reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; // ? +const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 +const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 function Coin(data){ this.bestExchange = global.config.payout.bestExchange; @@ -367,15 +369,15 @@ function Coin(data){ this.get_miner_agent_notification = function(agent) { let m; if (m = reXMRig.exec(agent)) { - let majorv = parseInt(m[1]) * 100; - let minorv = parseInt(m[2]); - if (majorv + minorv < 205) { + let majorv = parseInt(m[1]) * 10000; + let minorv = parseInt(m[2]) * 100; + if (majorv + minorv < 20500) { return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; } } else if (m = reXMRSTAK.exec(agent)) { - let majorv = parseInt(m[1]) * 100; - let minorv = parseInt(m[2]); - if (majorv + minorv < 203) { + let majorv = parseInt(m[1]) * 10000; + let minorv = parseInt(m[2]) * 100; + if (majorv + minorv < 20300) { return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; } } else if (m = reXNP.exec(agent)) { @@ -383,12 +385,12 @@ function Coin(data){ let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 2) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.2+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { - let majorv = parseInt(m[1]) * 100; - let minorv = parseInt(m[2]); - if (majorv + minorv < 300) { + let majorv = parseInt(m[1]) * 10000; + let minorv = parseInt(m[2]) * 100; + if (majorv + minorv < 30000) { return "Please update ccminer-cryptonight miner to v3.02+"; } } @@ -398,9 +400,9 @@ function Coin(data){ this.get_miner_agent_warning_notification = function(agent) { let m; if (m = reXMRig.exec(agent)) { - let majorv = parseInt(m[1]) * 100; - let minorv = parseInt(m[2]); - if (majorv + minorv < 208) { + let majorv = parseInt(m[1]) * 10000; + let minorv = parseInt(m[2]) * 100; + if (majorv + minorv < 20800) { return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; } } else if (m = reXMRSTAK2.exec(agent)) { @@ -417,6 +419,20 @@ function Coin(data){ if (majorv + minorv + minorv2 < 302) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.2+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } + } else if (m = reCAST.exec(agent)) { + let majorv = parseInt(m[1]) * 10000; + let minorv = parseInt(m[2]) * 100; + let minorv2 = parseInt(m[3]); + if (majorv + minorv + minorv2 < 10500) { + return "Please update your cast-xmr miner (" + agent + ") to version v1.5.0+"; + } + } else if (m = reSRB.exec(agent)) { + let majorv = parseInt(m[1]) * 10000; + let minorv = parseInt(m[2]) * 100; + let minorv2 = parseInt(m[3]); + if (majorv + minorv + minorv2 < 10608) { + return "Please update your SRBminer (" + agent + ") to version v1.6.8+"; + } } return false; }; From 64a3dd60daa1e4d2147113731e5e3057a2580942 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Tue, 9 Oct 2018 17:36:52 +0300 Subject: [PATCH 0076/1496] trim spaces --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 377146d60..2b489515d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -636,7 +636,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // 3e) password setup stuff - let email = this.email; + let email = this.email.trim(); if (email != "") { // Need to do an initial registration call here. Might as well do it right... let payoutAddress = this.payout; From 2543122746ffcb83ba3daf67240e9d7c90d2b25d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Oct 2018 22:25:25 +0200 Subject: [PATCH 0077/1496] Updated for new monero release --- deployment/deploy.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index c26427bc0..e4d9ff5c0 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,7 +26,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.12.2.0 +sudo git checkout v0.13.0.2 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo git submodule init sudo git submodule update diff --git a/deployment/leaf.bash b/deployment/leaf.bash index be2402739..5a053a038 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -22,7 +22,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.12.2.0 +sudo git checkout v0.13.0.2 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo git submodule init sudo git submodule update diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 73e60f408..7e13b772e 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,10 +6,10 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.12.2.0 &&\ -curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v &&\ +sudo git checkout v0.13.0.2 &&\ +#curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ sudo nice make &&\ -echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" +echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" From 69899343a7b4a1cbf8a6f902ce5f4f57aa54d084 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Oct 2018 22:30:35 +0200 Subject: [PATCH 0078/1496] Install libsodium required for new monero release --- deployment/deploy.bash | 2 +- deployment/leaf.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index e4d9ff5c0..c02203a54 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -14,7 +14,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. cd /usr/src/gtest diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 5a053a038..308752c2a 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -10,7 +10,7 @@ CURUSER=$(whoami) sudo timedatectl set-timezone Etc/UTC sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libzmq3-dev +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libzmq3-dev libsodium-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. cd /usr/src/gtest From 9a82bb703f934035ad6ce55b8d2acfe291f08143 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Oct 2018 23:15:58 +0200 Subject: [PATCH 0079/1496] Added old bin dir support --- deployment/deploy.bash | 2 ++ deployment/leaf.bash | 2 ++ deployment/upgrade_monero.bash | 2 ++ 3 files changed, 6 insertions(+) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index c02203a54..2113095ab 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -31,6 +31,8 @@ curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment sudo git submodule init sudo git submodule update sudo make -j$(nproc) +sudo mkdir -p /usr/local/src/monero/build/release/bin +sudo cp -r /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 308752c2a..aa29acf98 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -27,6 +27,8 @@ curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment sudo git submodule init sudo git submodule update sudo make -j$(nproc) +sudo mkdir -p /usr/local/src/monero/build/release/bin +sudo cp -r /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 7e13b772e..29dcf6a69 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -12,4 +12,6 @@ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ sudo nice make &&\ +sudo mkdir -p /usr/local/src/monero/build/release/bin &&\ +sudo cp -r /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/* /usr/local/src/monero/build/release/bin &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" From 16541ac4fd6d1d5ee0e299983688aeb99e08c4cc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 12 Oct 2018 00:25:18 +0200 Subject: [PATCH 0080/1496] Fixed dir copy --- deployment/upgrade_monero.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 29dcf6a69..9cbcbaccd 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -13,5 +13,5 @@ sudo git submodule update &&\ sudo rm -rf build &&\ sudo nice make &&\ sudo mkdir -p /usr/local/src/monero/build/release/bin &&\ -sudo cp -r /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/* /usr/local/src/monero/build/release/bin &&\ +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/bin/* /usr/local/src/monero/build/release/bin &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" From ce2617547fa302a687dbc8c611d17e8777a30752 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 12 Oct 2018 00:25:55 +0200 Subject: [PATCH 0081/1496] Fixed dir copy --- deployment/deploy.bash | 2 +- deployment/leaf.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 2113095ab..b2db260bc 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -32,7 +32,7 @@ sudo git submodule init sudo git submodule update sudo make -j$(nproc) sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp -r /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/* /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index aa29acf98..9e666e1f4 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -28,7 +28,7 @@ sudo git submodule init sudo git submodule update sudo make -j$(nproc) sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp -r /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/* /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) From 37ff4b8c1709a317929c43834d9e90d6a69b7516 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 12 Oct 2018 06:47:20 +0200 Subject: [PATCH 0082/1496] Updated miner versions --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index da504e366..a3a5bc45c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -8,7 +8,7 @@ const process = require('process'); let hexChars = new RegExp("[0-9a-f]+"); -const reXMRig = /XMRig(?:-AMD)?\/(\d+)\.(\d+)\./; // 2.8.0 +const reXMRig = /XMRig(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\./; // 2.8.0 const reXMRSTAK = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)/; // 2.5.0 const reXMRSTAK2 = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 @@ -378,7 +378,7 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; if (majorv + minorv < 20300) { - return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; + return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use monero in config)"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]) * 10000; @@ -409,8 +409,8 @@ function Coin(data){ let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 20403) { - return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; + if (majorv + minorv + minorv2 < 20500) { + return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use monero in config)"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]) * 10000; From 1314113430fc92709fbf20c7ade56fc6a0eed7db Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 12 Oct 2018 08:39:04 +0200 Subject: [PATCH 0083/1496] Added cn/2 to default miner algo list to allow smooth transition --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a3a5bc45c..ad65a3a9e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -242,7 +242,7 @@ function Coin(data){ } this.getDefaultAlgos = function() { - return [ "cn/1" ]; + return [ "cn/1", "cn/2" ]; } this.getDefaultAlgosPerf = function() { From a1b279977567a94a3f298248f841dc5f1e9d7a52 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 13 Oct 2018 12:29:43 +0200 Subject: [PATCH 0084/1496] Drop connection for banned miner --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 377146d60..3d1c74423 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1474,7 +1474,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply badMinerLastShareTime[miner.payout + ":" + miner.identifier + ":" + miner.ipAddress] = Date.now(); debug(threadName + "Banned miner for some time " + miner.logString); removeMiner(miner); - sendReply('Low difficulty share'); + sendFinalReply('Low difficulty share'); return; } debug(threadName + "Share trust broken by " + miner.logString); From 6254dca62c2c8f4ea3ba0f5ab25defaaf386e880 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 13 Oct 2018 14:46:34 +0200 Subject: [PATCH 0085/1496] Updated donate address --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 668175aa7..64f201883 100644 --- a/README.md +++ b/README.md @@ -256,7 +256,7 @@ For assistance, please contact MoneroOcean at support@moneroocean.stream. Developer Donations =================== If you'd like to make a one time donation, the addresses are as follows: -* XMR - ```499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE``` +* XMR - ```44qJYxdbuqSKarYnDSXB6KLbsH4yR65vpJe3ELLDii9i4ZgKpgQXZYR4AMJxBJbfbKZGWUxZU42QyZSsP4AyZZMbJBCrWr1``` * AEON - ```WmsEg3RuUKCcEvFBtXcqRnGYfiqGJLP1FGBYiNMgrcdUjZ8iMcUn2tdcz59T89inWr9Vae4APBNf7Bg2DReFP5jr23SQqaDMT``` * ETN - ```etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1``` * SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` From 331796387b7ad24f5869252fd818f1b6420a8e76 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 14 Oct 2018 16:06:14 +0200 Subject: [PATCH 0086/1496] REturned to more conservative socket handling --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3d1c74423..4313ed6b0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1347,7 +1347,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply case 'getjob': miner = activeMiners.get(params.id); if (!miner) { - sendFinalReply('Unauthenticated'); + sendReply('Unauthenticated'); return; } miner.heartbeat(); @@ -1363,7 +1363,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply case 'submit': miner = activeMiners.get(params.id); if (!miner) { - sendFinalReply('Unauthenticated'); + sendReply('Unauthenticated'); return; } miner.heartbeat(); @@ -1373,7 +1373,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply })[0]; if (!job) { - sendFinalReply('Invalid job id'); + sendReply('Invalid job id'); return; } @@ -1474,7 +1474,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply badMinerLastShareTime[miner.payout + ":" + miner.identifier + ":" + miner.ipAddress] = Date.now(); debug(threadName + "Banned miner for some time " + miner.logString); removeMiner(miner); - sendFinalReply('Low difficulty share'); + sendReply('Low difficulty share'); return; } debug(threadName + "Share trust broken by " + miner.logString); @@ -1497,7 +1497,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply case 'keepalived': miner = activeMiners.get(params.id); if (!miner) { - sendFinalReply('Unauthenticated'); + sendReply('Unauthenticated'); return; } miner.heartbeat(); From f5b96d7f37481ef2c907619f3b304571e57882cd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 14 Oct 2018 18:24:51 +0200 Subject: [PATCH 0087/1496] Simplified build procedure --- deployment/deploy.bash | 4 +--- deployment/leaf.bash | 4 +--- deployment/upgrade_monero.bash | 4 +--- lib/coins/xmr.js | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index b2db260bc..8e5871bc5 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -30,9 +30,7 @@ sudo git checkout v0.13.0.2 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo git submodule init sudo git submodule update -sudo make -j$(nproc) -sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/bin/* /usr/local/src/monero/build/release/bin +USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 9e666e1f4..456cb362e 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -26,9 +26,7 @@ sudo git checkout v0.13.0.2 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo git submodule init sudo git submodule update -sudo make -j$(nproc) -sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/bin/* /usr/local/src/monero/build/release/bin +USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 9cbcbaccd..c1fe833bb 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -11,7 +11,5 @@ sudo git checkout v0.13.0.2 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ -sudo nice make &&\ -sudo mkdir -p /usr/local/src/monero/build/release/bin &&\ -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.2_/release/bin/* /usr/local/src/monero/build/release/bin &&\ +USE_SINGLE_BUILDDIR=1 sudo nice make &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ad65a3a9e..2fe7f5deb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -44,7 +44,7 @@ function Coin(data){ "43c2ykU9i2KZHjV8dWff9HKurYYRkckLueYK96Qh4p1EDoEvdo8mpgNJJpPuods53PM6wNzmj4K2D1V11wvXsy9LMiaYc86", // Changelly.com "45rTtwU6mHqSEMduDm5EvUEmFNx2Z6gQhGBJGqXAPHGyFm9qRfZFDNgDm3drL6wLTVHfVhbfHpCtwKVvDLbQDMH88jx2N6w", // ? "4ALcw9nTAStZSshoWVUJakZ6tLwTDhixhQUQNJkCn4t3fG3MMK19WZM44HnQRvjqmz4LkkA8t565v7iBwQXx2r34HNroSAZ", // Cryptopia.co.nz - "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm", // ? + "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm", // Bitfinex "41xeYWWKwtSiHju5AdyF8y5xeptuRY3j5X1XYHuB1g6ke4eRexA1iygjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3gJqjM9", // HitBTC "44rouyxW44oMc1yTGXBUsL6qo9AWWeHETFiimWC3TMQEizSqqZZPnw1UXCaJrCtUC9QT25L5MZvkoGKRxZttvbkmFXA3TMG" // BTC-Alpha ]; // These are addresses that MUST have a paymentID to perform logins with. From bffbbc12c5f2caddfc49c46adbfc3baf567755e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 16 Oct 2018 09:38:58 +0200 Subject: [PATCH 0088/1496] Updated Monero version --- deployment/deploy.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 8e5871bc5..91a49bf94 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,7 +26,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.13.0.2 +sudo git checkout v0.13.0.3 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo git submodule init sudo git submodule update diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 456cb362e..8bb9d8b7a 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -22,7 +22,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.13.0.2 +sudo git checkout v0.13.0.3 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo git submodule init sudo git submodule update diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index c1fe833bb..0b59e0885 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.13.0.2 &&\ +sudo git checkout v0.13.0.3 &&\ #curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v &&\ sudo git submodule init &&\ sudo git submodule update &&\ From 9d01f8b7f42ee325a8846face4d48883f5cd5338 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 16 Oct 2018 12:36:11 +0200 Subject: [PATCH 0089/1496] Returned build dir copy --- deployment/deploy.bash | 6 +++--- deployment/leaf.bash | 2 ++ deployment/upgrade_monero.bash | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 91a49bf94..9bf29c74e 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -27,10 +27,10 @@ cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero sudo git checkout v0.13.0.3 -curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v -sudo git submodule init -sudo git submodule update +#curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) +sudo mkdir -p /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 8bb9d8b7a..3393eb5f9 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -27,6 +27,8 @@ curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment sudo git submodule init sudo git submodule update USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) +sudo mkdir -p /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 0b59e0885..483bda81b 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -12,4 +12,6 @@ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ USE_SINGLE_BUILDDIR=1 sudo nice make &&\ +sudo mkdir -p /usr/local/src/monero/build/release/bin &&\ +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" From 29e5abca199df9b740b249d4437056f294dc889c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 16 Oct 2018 12:57:15 +0200 Subject: [PATCH 0090/1496] Removed not needed stuff --- deployment/deploy.bash | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 9bf29c74e..584c84971 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -17,10 +17,10 @@ echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. -cd /usr/src/gtest -sudo cmake . -sudo make -sudo mv libg* /usr/lib/ +#cd /usr/src/gtest +#sudo cmake . +#sudo make +#sudo mv libg* /usr/lib/ cd ~ sudo systemctl enable ntp cd /usr/local/src @@ -33,10 +33,10 @@ sudo mkdir -p /usr/local/src/monero/build/release/bin sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon -BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) -sudo -u monerodaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw https://downloads.getmonero.org/blockchain.raw -sudo -u monerodaemon /usr/local/src/monero/build/release/bin/monero-blockchain-import --input-file $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw --batch-size 20000 --database lmdb#fastest --data-dir /home/monerodaemon/.bitmonero -sudo -u monerodaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR +#BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) +#sudo -u monerodaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw https://downloads.getmonero.org/blockchain.raw +#sudo -u monerodaemon /usr/local/src/monero/build/release/bin/monero-blockchain-import --input-file $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw --batch-size 20000 --database lmdb#fastest --data-dir /home/monerodaemon/.bitmonero +#sudo -u monerodaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR sudo systemctl daemon-reload sudo systemctl enable monero sudo systemctl start monero From d8b694e68e33dbf6f29f0ade9a190145edde3d00 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 16 Oct 2018 12:58:04 +0200 Subject: [PATCH 0091/1496] Removed not needed stuff --- deployment/leaf.bash | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 3393eb5f9..6768662b1 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -13,28 +13,26 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libzmq3-dev libsodium-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. -cd /usr/src/gtest -sudo cmake . -sudo make -sudo mv libg* /usr/lib/ +#cd /usr/src/gtest +#sudo cmake . +#sudo make +#sudo mv libg* /usr/lib/ cd ~ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero sudo git checkout v0.13.0.3 -curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v -sudo git submodule init -sudo git submodule update +#curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) sudo mkdir -p /usr/local/src/monero/build/release/bin sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon -BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) -sudo -u monerodaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw https://downloads.getmonero.org/blockchain.raw -sudo -u monerodaemon /usr/local/src/monero/build/release/bin/monero-blockchain-import --input-file $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw --batch-size 20000 --database lmdb#fastest --data-dir /home/monerodaemon/.bitmonero -sudo -u monerodaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR +#BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) +#sudo -u monerodaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw https://downloads.getmonero.org/blockchain.raw +#sudo -u monerodaemon /usr/local/src/monero/build/release/bin/monero-blockchain-import --input-file $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw --batch-size 20000 --database lmdb#fastest --data-dir /home/monerodaemon/.bitmonero +#sudo -u monerodaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR sudo systemctl daemon-reload sudo systemctl enable monero sudo systemctl start monero From 6129669eaf36c111e8a360169f01053017a95b70 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 16 Oct 2018 13:11:05 +0200 Subject: [PATCH 0092/1496] Added libcap2-bin install --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 584c84971..089ca6a81 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -14,7 +14,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libcap2-bin git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. #cd /usr/src/gtest From bf652741b077c7a71a3404c29eb5c43d87f552f2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Oct 2018 11:50:36 +0200 Subject: [PATCH 0093/1496] After cn/2 fork changes --- lib/coins/xmr.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2fe7f5deb..2171a2c06 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -12,7 +12,6 @@ const reXMRig = /XMRig(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\./; // 2.8.0 const reXMRSTAK = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)/; // 2.5.0 const reXMRSTAK2 = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 -const reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; // ? const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 @@ -371,27 +370,35 @@ function Coin(data){ if (m = reXMRig.exec(agent)) { let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 20500) { + if (majorv + minorv < 20800) { return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; } } else if (m = reXMRSTAK.exec(agent)) { let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 20300) { - return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use monero in config)"; + if (majorv + minorv < 20500) { + return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 2) { + if (majorv + minorv + minorv2 < 3) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.2+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } - } else if (m = reCCMINER.exec(agent)) { + } else if (m = reCAST.exec(agent)) { + let majorv = parseInt(m[1]) * 10000; + let minorv = parseInt(m[2]) * 100; + let minorv2 = parseInt(m[3]); + if (majorv + minorv + minorv2 < 10500) { + return "Please update your cast-xmr miner (" + agent + ") to version v1.5.0+"; + } + } else if (m = reSRB.exec(agent)) { let majorv = parseInt(m[1]) * 10000; let minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 30000) { - return "Please update ccminer-cryptonight miner to v3.02+"; + let minorv2 = parseInt(m[3]); + if (majorv + minorv + minorv2 < 10608) { + return "Please update your SRBminer (" + agent + ") to version v1.6.8+"; } } return false; @@ -410,7 +417,7 @@ function Coin(data){ let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 20500) { - return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use monero in config)"; + return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]) * 10000; From bd413b9368f358cd706b3d3e531edbf18f4fc6e1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Oct 2018 12:16:09 +0200 Subject: [PATCH 0094/1496] Additional post fork adjustements --- lib/coins/xmr.js | 96 +++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2171a2c06..7aed3d56f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -241,7 +241,7 @@ function Coin(data){ } this.getDefaultAlgos = function() { - return [ "cn/1", "cn/2" ]; + return [ "cn/2" ]; } this.getDefaultAlgosPerf = function() { @@ -290,8 +290,8 @@ function Coin(data){ // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - return algos.includes("cn/1") || algos.includes("cn/2") || algos.includes("cryptonight/1") || algos.includes("cryptonight/2") ? - true : "algo array should include cn/1, cn/2, cryptonight/1 or cryptonight/2"; + return algos.includes("cn/2") || algos.includes("cryptonight/2") ? + true : "algo array should include cn/2 or cryptonight/2"; } this.cryptoNight = function(convertedBlob, port) { @@ -299,7 +299,7 @@ function Coin(data){ case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 8 ? 8 : 1); // XMR + case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube @@ -322,7 +322,7 @@ function Coin(data){ case 11181: return "cryptonight-lite/1"; // Aeon case 12211: return "cryptonight-heavy/0"; // RYO case 17750: return "cryptonight-heavy/xhv"; // Haven - case 18081: return version >= 8 ? "cryptonight/2" : "cryptonight/1"; // XMR + case 18081: return "cryptonight/2"; // XMR case 20189: return "cryptonight/xtl"; // Stellite case 22023: return "cryptonight-heavy/0"; // LOKI case 24182: return "cryptonight-heavy/tube"; // BitTube @@ -336,7 +336,7 @@ function Coin(data){ case 11181: return "cn-lite/1"; // Aeon case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven - case 18081: return version >= 8 ? "cn/2" : "cn/1"; // XMR + case 18081: return "cn/2"; // XMR case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube @@ -349,7 +349,7 @@ function Coin(data){ switch (port) { case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven - case 18081: return version >= 8 ? "2" : "1"; // XMR + case 18081: return "2"; // XMR case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube @@ -360,7 +360,6 @@ function Coin(data){ this.isMinerSupportAlgo = function(algo, algos) { if (algo in algos) return true; - if (algo === "cn/1" && "cryptonight/1" in algos) return true; // for temp compat with XNP 0.3.1 if (algo === "cn-heavy/0" && "cn-heavy" in algos) return true; return false; } @@ -368,37 +367,41 @@ function Coin(data){ this.get_miner_agent_notification = function(agent) { let m; if (m = reXMRig.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; if (majorv + minorv < 20800) { - return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; + return "You must update your XMRig miner (" + agent + ") to v2.8.0+"; } } else if (m = reXMRSTAK.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; if (majorv + minorv < 20500) { - return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; + return "You must update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; } } else if (m = reXNP.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 3) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.2+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + const minorv2 = parseInt(m[3]); + const version = majorv + minorv + minorv2; + if (version < 3) { + return "You must update your xmr-node-proxy (" + agent + ") to version v0.3.2+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + } + if (version >= 100 && version < 302) { + return "You must update your xmr-node-proxy (" + agent + ") to version v0.3.2+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCAST.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 10500) { - return "Please update your cast-xmr miner (" + agent + ") to version v1.5.0+"; + return "You must update your cast-xmr miner (" + agent + ") to version v1.5.0+"; } } else if (m = reSRB.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 10608) { - return "Please update your SRBminer (" + agent + ") to version v1.6.8+"; + return "You must update your SRBminer (" + agent + ") to version v1.6.8+"; } } return false; @@ -406,41 +409,42 @@ function Coin(data){ this.get_miner_agent_warning_notification = function(agent) { let m; - if (m = reXMRig.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; + /*if (m = reXMRig.exec(agent)) { + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; if (majorv + minorv < 20800) { return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; } } else if (m = reXMRSTAK2.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 20500) { return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; } - } else if (m = reXNP.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 302) { + } else */if (m = reXNP.exec(agent)) { + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + const minorv2 = parseInt(m[3]); + const version = majorv + minorv + minorv2; + if (version < 302) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.2+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } - } else if (m = reCAST.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); + } /*else if (m = reCAST.exec(agent)) { + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 10500) { return "Please update your cast-xmr miner (" + agent + ") to version v1.5.0+"; } } else if (m = reSRB.exec(agent)) { - let majorv = parseInt(m[1]) * 10000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 10608) { return "Please update your SRBminer (" + agent + ") to version v1.6.8+"; } - } + }*/ return false; }; } From 22c71dc5ca913bb066a4f3c867664b374ee5d3a7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Oct 2018 20:49:43 +0200 Subject: [PATCH 0095/1496] Removed algo long name support --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7aed3d56f..d756c4eb9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -290,8 +290,7 @@ function Coin(data){ // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - return algos.includes("cn/2") || algos.includes("cryptonight/2") ? - true : "algo array should include cn/2 or cryptonight/2"; + return algos.includes("cn/2") ? true : "algo array should include cn/2"; } this.cryptoNight = function(convertedBlob, port) { From e5cb223753336097809ae54fdd6cd2ca68422400 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Oct 2018 23:55:08 +0200 Subject: [PATCH 0096/1496] Serialized threshold retrieval --- lib/payment_systems/xmr.js | 93 ++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 3373095a4..1c56b4062 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -699,15 +699,13 @@ function makePayments() { console.log("Loaded all payees into the system for processing"); let paymentDestinations = []; let totalAmount = 0; - let roundCount = 0; let payeeList = []; let payeeObjects = {}; - rows.forEach(function (row) { + async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); payeeObjects[row.payment_address] = payee; global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { - ++ roundCount; let threshold = global.support.decimalToCoin(0.3); let custom_threshold = false; if (userRow.length !== 0 && userRow[0].payout_threshold != 0) { @@ -747,56 +745,55 @@ function makePayments() { payee.makeBitcoinPayment(); } } - //debug("Went: " + roundCount + " With: " + paymentDestinations.length + " Possible destinations and: " + rows.length + " Rows"); - if (roundCount === rows.length && paymentDestinations.length > 0) { - while (paymentDestinations.length > 0) { - let paymentDetails = { - destinations: paymentDestinations.splice(0, global.config.payout.maxPaymentTxns), - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn - }; - console.log("Adding payment for " + paymentDetails.destinations.length + " miners"); - paymentQueue.unshift(paymentDetails, function (body) { //jshint ignore:line - // This is the only section that could potentially contain multiple txns. Lets do this safely eh? - if (body.fee && body.fee > 10) { - let totalAmount = 0; - let totalFee = 0; + return next(); + }); + }, function() { + while (paymentDestinations.length > 0) { + let paymentDetails = { + destinations: paymentDestinations.splice(0, global.config.payout.maxPaymentTxns), + priority: global.config.payout.priority, + mixin: global.config.payout.mixIn + }; + console.log("Adding payment for " + paymentDetails.destinations.length + " miners"); + paymentQueue.unshift(paymentDetails, function (body) { //jshint ignore:line + // This is the only section that could potentially contain multiple txns. Lets do this safely eh? + if (body.fee && body.fee > 10) { + let totalAmount = 0; + let totalFee = 0; + paymentDetails.destinations.forEach(function (payeeItem) { + totalAmount += payeeObjects[payeeItem.address].amount; + totalFee += payeeObjects[payeeItem.address].fee; + console.log("[**] Successful payment to " + payeeItem.address + " for " + global.support.coinToDecimal(payeeObjects[payeeItem.address].amount) + " XMR (fee " + global.support.coinToDecimal(payeeObjects[payeeItem.address].fee) + ")"); + }); + console.log("[*] Successful payment to multiple miners of " + global.support.coinToDecimal(totalAmount) + " XMR (fee " + global.support.coinToDecimal(totalFee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(totalFee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " and tx_key " + body.tx_key); + global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + [0, null, null, totalAmount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, paymentDetails.destinations.length]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, null, null, " + + totalAmount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", " + paymentDetails.destinations.length + ")" + ); paymentDetails.destinations.forEach(function (payeeItem) { - totalAmount += payeeObjects[payeeItem.address].amount; - totalFee += payeeObjects[payeeItem.address].fee; - console.log("[**] Successful payment to " + payeeItem.address + " for " + global.support.coinToDecimal(payeeObjects[payeeItem.address].amount) + " XMR (fee " + global.support.coinToDecimal(payeeObjects[payeeItem.address].fee) + ")"); + payee = payeeObjects[payeeItem.address]; + payee.transactionID = 0; + payee.manualPaymentShow(); }); - console.log("[*] Successful payment to multiple miners of " + global.support.coinToDecimal(totalAmount) + " XMR (fee " + global.support.coinToDecimal(totalFee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(totalFee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " and tx_key " + body.tx_key); - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [0, null, null, totalAmount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, paymentDetails.destinations.length]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, null, null, " - + totalAmount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", " + paymentDetails.destinations.length + ")" - ); - paymentDetails.destinations.forEach(function (payeeItem) { - payee = payeeObjects[payeeItem.address]; - payee.transactionID = 0; - payee.manualPaymentShow(); - }); - full_stop(result); - return; - } - paymentDetails.destinations.forEach(function (payeeItem) { - payee = payeeObjects[payeeItem.address]; - payee.transactionID = result.insertId; - payee.tx_hash = body.tx_hash.match(hexChars)[0]; - payee.tx_key = body.tx_key; - payee.trackPayment(); - }); - }); - } else { - console.error("Unknown error from the wallet: " + JSON.stringify(body)); + full_stop(result); + return; } + paymentDetails.destinations.forEach(function (payeeItem) { + payee = payeeObjects[payeeItem.address]; + payee.transactionID = result.insertId; + payee.tx_hash = body.tx_hash.match(hexChars)[0]; + payee.tx_key = body.tx_key; + payee.trackPayment(); + }); }); + } else { + console.error("Unknown error from the wallet: " + JSON.stringify(body)); } - } - if (roundCount === rows.length) debug("Finished processing payments for now"); - }); + }); + } + debug("Finished processing payments for now"); }); }); debug("Finished makePayments"); From a82098a119fd00f8a8a951713d005e31a30cba86 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Oct 2018 00:00:36 +0200 Subject: [PATCH 0097/1496] Fixed let --- lib/payment_systems/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 1c56b4062..b92ca600b 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -773,7 +773,7 @@ function makePayments() { + totalAmount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", " + paymentDetails.destinations.length + ")" ); paymentDetails.destinations.forEach(function (payeeItem) { - payee = payeeObjects[payeeItem.address]; + let payee = payeeObjects[payeeItem.address]; payee.transactionID = 0; payee.manualPaymentShow(); }); @@ -781,7 +781,7 @@ function makePayments() { return; } paymentDetails.destinations.forEach(function (payeeItem) { - payee = payeeObjects[payeeItem.address]; + let payee = payeeObjects[payeeItem.address]; payee.transactionID = result.insertId; payee.tx_hash = body.tx_hash.match(hexChars)[0]; payee.tx_key = body.tx_key; From 0a8efd17ac506689e4c99984c4e5c590cbe1a0d9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Oct 2018 09:45:38 +0200 Subject: [PATCH 0098/1496] Fixed algo detection --- lib/coins/xmr.js | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d756c4eb9..07bfc5970 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -251,46 +251,34 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; - else if ("cryptonight" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cryptonight"]; - else if ("cryptonight/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cryptonight/1"]; - else return "algo_perf set should include cn or cn/1 hashrate"; + if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; + if ("cn/2" in algos_perf) coin_perf[""] = algos_perf["cn/2"]; - if ("cn/2" in algos_perf) coin_perf[""] = algos_perf["cn/2"]; - else if ("cryptonight/2" in algos_perf) coin_perf[""] = algos_perf["cryptonight/2"]; + if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1 or cn/2 hashrate"; - if ("cn/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtl"]; - else if ("cryptonight/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cryptonight/xtl"]; - else coin_perf["XTL"] = coin_perf["GRFT"]; + if ("cn/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtl"]; + else coin_perf["XTL"] = "GRFT" in coin_perf ? coin_perf["GRFT"] : coin_perf[""]; - if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; - else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; - else if ("cryptonight-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cryptonight-fast"]; - else if ("cryptonight/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cryptonight/msr"]; + if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; + else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; - if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; - else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; - else if ("cryptonight-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cryptonight-heavy"]; - else if ("cryptonight-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cryptonight-heavy/0"]; + if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; + else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; - if ("cn-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cn-heavy/tube"]; - else if ("cryptonight-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cryptonight-heavy/tube"]; + if ("cn-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cn-heavy/tube"]; - if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; - else if ("cryptonight-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cryptonight-heavy/xhv"]; + if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; - if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; - else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; - else if ("cryptonight-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cryptonight-lite"]; - else if ("cryptonight-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cryptonight-lite/1"]; + if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; + else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; return coin_perf; } // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - return algos.includes("cn/2") ? true : "algo array should include cn/2"; + return algos.includes("cn/2") ? true : "algo array must include cn/2"; } this.cryptoNight = function(convertedBlob, port) { From bd2e4858c547a7c4d4f792b13b5db2bfea065af0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 10:01:34 +0200 Subject: [PATCH 0099/1496] Coin support --- deployment/base.sql | 7 +++++++ lib/coins/xmr.js | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index bf72a4785..b2be577e5 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -196,6 +196,9 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortAEON', '0', 'int', 'Aeon coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortMSR', '0', 'int', 'Masari coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTL', '0', 'int', 'Stellite coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLTHN', '0', 'int', 'Lethean coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortGRFT', '0', 'int', 'Graft coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTUBE', '0', 'float', 'BitTube algo hash price factor relative to coinHashFactor'); @@ -203,6 +206,9 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorAEON', '0', 'float', 'Aeon algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorMSR', '0', 'float', 'Masari algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTL', '0', 'float', 'Stellite algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLTHN', '0', 'float', 'Lethean algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorGRFT', '0', 'float', 'Graft algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTRTL', '0', 'float', 'Turtle algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -250,6 +256,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_24182', '', 'string', 'Address to mine to for 24182 (BitTube) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Stellite) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_22023', '', 'string', 'Address to mine to for 22023 (Loki) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11898', '', 'string', 'Address to mine to for 11898 (Turtle) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunURL', '', 'string', 'MailGun URL for notifications'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 07bfc5970..ec4813c5a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -92,7 +92,7 @@ function Coin(data){ } } } - else if (port == 22023) { // Stellite/Intense/Aeon have composite based miner_tx + else if (port == 22023) { // Loki has reward as zero transaction const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; @@ -245,7 +245,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "cn": 1, "cn-fast": 1.9 }; + return { "cn": 1, "cn/msr": 1.9 }; } this.convertAlgosToCoinPerf = function(algos_perf) { From c4be14e62b0744b683e6c6551d9614631eb6822f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 10:04:22 +0200 Subject: [PATCH 0100/1496] Added TRTL donate address --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 64f201883..d27566e5d 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XHV - ```hvxyEmtbqs5TEk9U2tCxyfGx2dyGD1g8EBspdr3GivhPchkvnMHtpCR2fGLc5oEY42UGHVBMBANPge5QJ7BDXSMu1Ga2KFspQR``` * TUBE - ```bxcpZTr4C41NshmJM9Db7FBE5crarjaDXVUApRbsCxHHBf8Jkqjwjzz1zmWHhm9trWNhrY1m4RpcS7tmdG4ykdHG2kTgDcbKJ``` * LOKI - ```L6XqN6JDedz5Ub8KxpMYRCUoQCuyEA8EegEmeQsdP5FCNuXJavcrxPvLhpqY6emphGTYVrmAUVECsE9drafvY2hXUTJz6rW``` +* TRTL - ```TRTLv2x2bac17cngo1r2wt3CaxN8ckoWHe2TX7dc8zW8Fc9dpmxAvhVX4u4zPjpv9WeALm2koBLF36REVvsLmeufZZ1Yx6uWkYG``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` From d6c2f897574676d0e6dcc37d830c692c87a7aa15 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 10:21:43 +0200 Subject: [PATCH 0101/1496] Added TRTL support --- lib/coins/xmr.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ec4813c5a..2c0fde89e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -160,6 +160,7 @@ function Coin(data){ this.portBlobType = function(port, version) { switch (port) { + case 11898: return 2: // TRTL case 12211: return 4; // RYO case 22023: return 5; // LOKI case 38081: return 3; // MSR @@ -237,7 +238,7 @@ function Coin(data){ }; this.getCOINS = function() { - return [ "GRFT", "LTHN", "RYO", "LOKI", "TUBE", "XHV", "AEON", "MSR", "XTL" ]; + return [ "GRFT", "LTHN", "RYO", "LOKI", "TUBE", "XHV", "AEON", "MSR", "XTL", "TRTL" ]; } this.getDefaultAlgos = function() { @@ -284,19 +285,23 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, port) { switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon + case 11898: return multiHashing.cryptonight_light(convertedBlob, 1): // TRTL case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR + case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR + case 18981: return multiHashing.cryptonight(convertedBlob, 1); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR - default: return multiHashing.cryptonight(convertedBlob, 1); + case 48782: return multiHashing.cryptonight(convertedBlob, 1); // Lethean + default: return multiHashing.cryptonight(convertedBlob, 8); } } this.blobTypeStr = function(port, version) { switch (port) { + case 11898: return "forknote2"; // TRTL case 12211: return "cryptonote_ryo"; // RYO case 22023: return "cryptonote_loki"; // LOKI case 38081: return "cryptonote2"; // MSR @@ -307,41 +312,51 @@ function Coin(data){ this.algoTypeStr = function(port, version) { switch (port) { case 11181: return "cryptonight-lite/1"; // Aeon + case 11898: return "cryptonight-lite/1"; // TRTL case 12211: return "cryptonight-heavy/0"; // RYO case 17750: return "cryptonight-heavy/xhv"; // Haven case 18081: return "cryptonight/2"; // XMR + case 18981: return "cryptonight/1"; // Graft case 20189: return "cryptonight/xtl"; // Stellite case 22023: return "cryptonight-heavy/0"; // LOKI case 24182: return "cryptonight-heavy/tube"; // BitTube case 38081: return "cryptonight/msr"; // MSR - default: return "cryptonight/1"; + case 48782: return "cryptonight/1"; // Lethean + default: return "cryptonight/2"; } } this.algoShortTypeStr = function(port, version) { switch (port) { case 11181: return "cn-lite/1"; // Aeon + case 11898: return "cn-lite/1"; // TRTL case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR + case 18981: return "cn/1"; // Graft case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 38081: return "cn/msr"; // MSR - default: return "cn/1"; + case 48782: return "cn/1"; // Lethean + default: return "cn/2"; } } this.variantValue = function(port, version) { switch (port) { + case 11181: return "1"; // Aeon + case 11898: return "1"; // TRTL case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR + case 18981: return "1"; // Graft case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube case 38081: return "msr"; // MSR - default: return "1"; + case 48782: return "1"; // Lethean + default: return "2"; } } From 91f0d39240fe4457673fec22bd933158ab000226 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 10:25:22 +0200 Subject: [PATCH 0102/1496] Added TRTL support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2c0fde89e..df01e661f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -160,7 +160,7 @@ function Coin(data){ this.portBlobType = function(port, version) { switch (port) { - case 11898: return 2: // TRTL + case 11898: return 2; // TRTL case 12211: return 4; // RYO case 22023: return 5; // LOKI case 38081: return 3; // MSR From 7b9d499983afe44cb58a9bf65d20743f1ff83713 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 10:26:10 +0200 Subject: [PATCH 0103/1496] Added TRTL support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index df01e661f..ff5623b4f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -285,7 +285,7 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, port) { switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon - case 11898: return multiHashing.cryptonight_light(convertedBlob, 1): // TRTL + case 11898: return multiHashing.cryptonight_light(convertedBlob, 1); // TRTL case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR From 819e85c3d38f084b4bde9411ab3e3e337eb36ba6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 10:43:57 +0200 Subject: [PATCH 0104/1496] Added TRTL perf --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ff5623b4f..7d85faa03 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -271,8 +271,8 @@ function Coin(data){ if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; - if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; - else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; + if ("cn-lite" in algos_perf) coin_perf["AEON"] = coin_perf["TRTL"] = algos_perf["cn-lite"]; + else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = coin_perf["TRTL"] = algos_perf["cn-lite/1"]; return coin_perf; } From e907ff18af88b6ba3074a3ab4fda93858ed8ab54 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 11:08:30 +0200 Subject: [PATCH 0105/1496] Fixed getblockheader for TRTL --- lib/coins/xmr.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7d85faa03..85cb9d609 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -78,9 +78,10 @@ function Coin(data){ }; this.getPortBlockHeaderByHash = function(port, blockHash, callback){ - global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { + global.support.rpcPortDaemon(port, port == 11898 ? 'getblockheaderbyhash' : 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { - if (port != 20189 && port != 48782 && port != 11181 && port != 22023) { // Stellite/Intense/Aeon/loki have composite based miner_tx + + if (port != 11898 && port != 20189 && port != 48782 && port != 11181 && port != 22023) { // Stellite/Intense/Aeon/loki have composite based miner_tx const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; @@ -91,8 +92,8 @@ function Coin(data){ body.result.block_header.reward = minerTx.vout[i].amount; } } - } - else if (port == 22023) { // Loki has reward as zero transaction + + } else if (port == 22023) { // Loki has reward as zero transaction const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; @@ -100,6 +101,7 @@ function Coin(data){ body.result.block_header.reward = minerTx.vout[0].amount; } + return callback(null, body.result.block_header); } else { console.error(JSON.stringify(body)); From ad77ff6f7f172b533aed0b83864f75063502f408 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 11:13:44 +0200 Subject: [PATCH 0106/1496] Added case for TRTL --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index e362d0873..8d7b83153 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -419,7 +419,7 @@ function Database(){ let blockDataDecoded = global.protos.AltBlock.decode(blockData); global.coinFuncs.getPortBlockHeaderByHash(blockDataDecoded.port, blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan - if (err && header && header.error && typeof(header.error.message) === 'string' && header.error.message.indexOf("can't get block by hash") > -1) { + if (err && header && header.error && typeof(header.error.message) === 'string' && (header.error.message.indexOf("can't get block by hash") > -1 || header.error.message.indexOf("Requested hash wasn't found in main blockchain") > -1)) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { if (time_now - orphanBlocks[blockDataDecoded.hash] > 5*60*1000) { From 51ee147f04b2508bd066b302726128b7caf332e9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 15:51:00 +0200 Subject: [PATCH 0107/1496] Fixed case when disabled coin is still mined --- lib/pool.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8e2139f72..d1cd09d73 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -245,14 +245,14 @@ function updateActivePort(coin) { if (newCoinHashFactor == 0) debug("Got zero " + "coinHashFactor" + coin); global.config.daemon["coinHashFactor" + coin] = newCoinHashFactor; if (oldActivePort !== newActivePort) { - console.log("Changing " + "activePort" + coin + " from " + oldActivePort + " to " + newActivePort); + console.log("Changing activePort" + coin + " from " + oldActivePort + " to " + newActivePort); global.config.daemon["activePort" + coin] = newActivePort; } } }); } else if (oldActivePort !== newActivePort) { if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*60*1000) { - console.log("Changing " + "activePort" + coin + " from " + oldActivePort + " to " + newActivePort); + console.log("Changing activePort" + coin + " from " + oldActivePort + " to " + newActivePort); global.config.daemon["activePort" + coin] = newActivePort; } else if ((Date.now() - lastPortErrorTime[newActivePort]) % 60*1000 < 6*1000) { // print every 10th message console.warn("Avoiding changing recently problem " + "activePort" + coin + " from " + oldActivePort + " to " + newActivePort); @@ -348,8 +348,10 @@ function templateUpdate(coin, repeating) { } setTimeout(templateUpdate, 1000, coin, repeating); } - }); else setTimeout(templateUpdate, 1000, coin, repeating); - + }); else { + coinHashFactorUpdate(coin, 0); + setTimeout(templateUpdate, 1000, coin, repeating); + } } // main chain anchor block height for alt chain block @@ -662,7 +664,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); this.selectBestCoin = function() { - if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && this.coin_perf[this.curr_coin] && + if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && + global.config.daemon["coinHashFactor" + this.curr_coin] && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { return this.curr_coin; @@ -671,12 +674,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_coin_perf = this.coin_perf[""] * 1.1; let miner = this; COINS.forEach(function(coin) { + let coinHashFactor = global.config.daemon["coinHashFactor" + coin]; + if (!coinHashFactor) return; if (!(coin in activeBlockTemplate)) return; const port = activeBlockTemplate[coin].port; const block_version = activeBlockTemplate[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) return; - let coinHashFactor = global.config.daemon["coinHashFactor" + coin]; if (miner.curr_coin === coin) coinHashFactor *= 1.05; if (coin in miner.coin_perf && miner.coin_perf[coin] * coinHashFactor > best_coin_perf) { debug(miner.logString + ": " + coin + ": " + miner.coin_perf[coin] * coinHashFactor); From 4dcd28eacbcfd3e0a0d3106f9e9036e84064f397 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 15:55:56 +0200 Subject: [PATCH 0108/1496] Reduced 0 factor spam --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d1cd09d73..8f3d0dd84 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -349,7 +349,7 @@ function templateUpdate(coin, repeating) { setTimeout(templateUpdate, 1000, coin, repeating); } }); else { - coinHashFactorUpdate(coin, 0); + if (coin !== "" && global.config.daemon["coinHashFactor" + coin]) coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } } From 256914dc41570cfa8049f50f2e48b2a096e7a194 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 16:23:11 +0200 Subject: [PATCH 0109/1496] Add special case for main coin --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8f3d0dd84..8fd1e186d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -665,7 +665,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestCoin = function() { if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && - global.config.daemon["coinHashFactor" + this.curr_coin] && + (this.curr_coin === "" || global.config.daemon["coinHashFactor" + this.curr_coin]) && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { return this.curr_coin; From 81e2b865f3ff3f462a7b2d3a9345bad58e34c573 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Oct 2018 16:29:46 +0200 Subject: [PATCH 0110/1496] Some code reorg --- lib/pool.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8fd1e186d..97c7a3e27 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -223,6 +223,10 @@ function checkAliveMiners() { if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } +function get_hash_factor(coin) { + return coin === "" ? 1.0 : global.config.daemon["coinHashFactor" + coin]; +} + // global.config.daemon["activePort" + coin] is only updated in master thread function updateActivePort(coin) { global.support.getActivePort(coin, function (newActivePort) { @@ -327,7 +331,7 @@ function templateUpdate(coin, repeating) { return; } if (err === null) { - const coinHashFactor = coin === "" ? 1.0 : global.config.daemon["coinHashFactor" + coin]; + const coinHashFactor = get_hash_factor(coin); if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; lastCoinHashFactor[coin] = coinHashFactor; @@ -664,8 +668,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); this.selectBestCoin = function() { - if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && - (this.curr_coin === "" || global.config.daemon["coinHashFactor" + this.curr_coin]) && + if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && get_hash_factor(this.curr_coin) && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { return this.curr_coin; @@ -820,7 +823,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.difficulty = this.newDiffRecommendation; this.newDiffRecommendation = null; } - const coinHashFactor = coin === "" ? 1.0 : global.config.daemon["coinHashFactor" + coin]; + const coinHashFactor = get_hash_factor(coin); if (!this.proxy) { let blob = bt.nextBlob(); let target = this.getTargetHex(); From 0714321f4f6e4a252d7ceaca6fb284d4eca9fe5e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 10:03:53 +0200 Subject: [PATCH 0111/1496] Cleaned up best coin sellection code with some debug output --- lib/pool.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 97c7a3e27..16a322550 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -677,18 +677,21 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_coin_perf = this.coin_perf[""] * 1.1; let miner = this; COINS.forEach(function(coin) { - let coinHashFactor = global.config.daemon["coinHashFactor" + coin]; - if (!coinHashFactor) return; + if (!(coin in miner.coin_perf)) return; if (!(coin in activeBlockTemplate)) return; - const port = activeBlockTemplate[coin].port; - const block_version = activeBlockTemplate[coin].buffer[0]; + const coinHashFactor = global.config.daemon["coinHashFactor" + coin]; + if (!coinHashFactor) return; + const bt = activeBlockTemplate[coin]; + const port = bt.port; + const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) return; - if (miner.curr_coin === coin) coinHashFactor *= 1.05; - if (coin in miner.coin_perf && miner.coin_perf[coin] * coinHashFactor > best_coin_perf) { - debug(miner.logString + ": " + coin + ": " + miner.coin_perf[coin] * coinHashFactor); - best_coin = coin; - best_coin_perf = miner.coin_perf[coin] * coinHashFactor; + let coin_perf = miner.coin_perf[coin] * coinHashFactor; + if (miner.curr_coin === coin) coin_perf *= 1.05; + if (coin_perf > best_coin_perf) { + console.log(miner.logString + ": " + coin + ": " + coin_perf); + best_coin = coin; + best_coin_perf = coin_perf; } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { From 94d37627a51522fe409aa6c3a72da6af45f434c5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 10:26:23 +0200 Subject: [PATCH 0112/1496] More algo switch testing --- lib/coins/xmr.js | 1 + lib/pool.js | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 85cb9d609..6cb17861c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -22,6 +22,7 @@ function Coin(data){ let instanceId = new Buffer(4); instanceId.writeUInt32LE( ((global.config.pool_id % (1<<16)) << 16) + (process.pid % (1<<16)) ); console.log("Generated instanceId: " + instanceId.toString('hex')); + this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address this.poolDevAddress = "499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE"; // MoneroOcean Address diff --git a/lib/pool.js b/lib/pool.js index 16a322550..afc9a273f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -551,13 +551,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } else { return coin_perf; } - this.algo_min_time = algo_min_time; + this.algo_min_time = algo_min_time ? algo_min_time : 0; return ""; }; if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = global.coinFuncs.getDefaultAlgosPerf(); - if (!algo_min_time) algo_min_time = 0; } else { algos = global.coinFuncs.getDefaultAlgos(); algos_perf = global.coinFuncs.getDefaultAlgosPerf(); @@ -689,7 +688,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; if (coin_perf > best_coin_perf) { - console.log(miner.logString + ": " + coin + ": " + coin_perf); + if (miner.payout == global.coinFuncs.testDevAddress) console.log(miner.logString + ": " + coin + ": " + coin_perf); best_coin = coin; best_coin_perf = coin_perf; } From 2e188611f81398c0fc26796176ddf146b85f77a2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 11:34:50 +0200 Subject: [PATCH 0113/1496] Disable bad coin more reliably --- lib/pool.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index afc9a273f..869514b8b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -237,17 +237,17 @@ function updateActivePort(coin) { global.config.daemon.activePort = global.config.daemon.port; } else { console.error("Error getting " + "activePort" + coin); - global.config.daemon["coinHashFactor" + coin] = 0.0; + coinHashFactorUpdate(coin, 0); } } else { if (coin !== "") { global.support.getCoinHashFactor(coin, function (newCoinHashFactor) { if (newCoinHashFactor === null) { console.error("Error getting " + "coinHashFactor" + coin); - global.config.daemon["coinHashFactor" + coin] = 0.0; + coinHashFactorUpdate(coin, 0); } else { - if (newCoinHashFactor == 0) debug("Got zero " + "coinHashFactor" + coin); - global.config.daemon["coinHashFactor" + coin] = newCoinHashFactor; + if (newActivePort == 0 || newCoinHashFactor == 0) coinHashFactorUpdate(coin, 0); + else global.config.daemon["coinHashFactor" + coin] = newCoinHashFactor; if (oldActivePort !== newActivePort) { console.log("Changing activePort" + coin + " from " + oldActivePort + " to " + newActivePort); global.config.daemon["activePort" + coin] = newActivePort; @@ -311,6 +311,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor) { function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; + if (global.config.daemon["coinHashFactor" + coin] == 0 && coinHashFactor == 0) return; if (cluster.isMaster) { let data = { coin: coin, coinHashFactor: coinHashFactor }; sendToWorkers({type: 'newCoinHashFactor', data: data}); @@ -353,7 +354,7 @@ function templateUpdate(coin, repeating) { setTimeout(templateUpdate, 1000, coin, repeating); } }); else { - if (coin !== "" && global.config.daemon["coinHashFactor" + coin]) coinHashFactorUpdate(coin, 0); + coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } } From 01f9431eab3d737593ecdb06b2f5f377997144d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 11:55:38 +0200 Subject: [PATCH 0114/1496] Better debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 869514b8b..3566fab4f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -688,8 +688,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) return; let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; + if (miner.payout == global.coinFuncs.testDevAddress) console.log(miner.logString + ": " + coin + ": " + coin_perf); if (coin_perf > best_coin_perf) { - if (miner.payout == global.coinFuncs.testDevAddress) console.log(miner.logString + ": " + coin + ": " + coin_perf); best_coin = coin; best_coin_perf = coin_perf; } From 710dbc5c83ba719b5e79ab23b887c3f8de3a8b7b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 12:09:42 +0200 Subject: [PATCH 0115/1496] Accelerated debug miner handling --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3566fab4f..6e1db2b61 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -487,6 +487,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } } + this.debugMiner = miner.payout == global.coinFuncs.testDevAddress; + this.email = pass_split.length === 2 ? pass_split[1] : ""; this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + ipAddress + ")"; @@ -688,7 +690,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) return; let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; - if (miner.payout == global.coinFuncs.testDevAddress) console.log(miner.logString + ": " + coin + ": " + coin_perf); + if (miner.debugMiner) console.log(miner.logString + ": " + coin + ": " + coin_perf); if (coin_perf > best_coin_perf) { best_coin = coin; best_coin_perf = coin_perf; From 7a6ff514611fa29bdd6bf39f7b16191e5d6671b5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 13:44:32 +0200 Subject: [PATCH 0116/1496] Coin selection speed optimization --- lib/pool.js | 55 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6e1db2b61..fb42f80a8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -388,18 +388,44 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const block_version = activeBlockTemplate[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); + const isHashFactorChange = !(coin in lastCoinHashFactor) || !(coin in activeBlockTemplate) || coinHashFactor == 0 || + (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); + const time_before = Date.now(); - if (check_height) { - for (var [minerId, miner] of activeMiners) { - if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; - miner.trust.check_height = check_height; - miner.sendNewJob(); + if (isHashFactorChange) { + lastCoinHashFactor[coin] = coinHashFactor; + + if (check_height) { + for (var [minerId, miner] of activeMiners) { + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; + miner.trust.check_height = check_height; + miner.sendNewJob(); + } + } else { + for (var [minerId, miner] of activeMiners) { + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; + miner.sendNewJob(); + } } } else { - for (var [minerId, miner] of activeMiners) { - if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; - miner.sendNewJob(); + if (check_height) { + for (var [minerId, miner] of activeMiners) { + if (miner.curr_coin !== coin) continue; + if (typeof(this.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); + if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); + miner.trust.check_height = check_height; + miner.sendNewCoinJob(coin); + } + } else { + for (var [minerId, miner] of activeMiners) { + if (miner.curr_coin !== coin) continue; + if (typeof(this.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); + if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); + miner.sendNewCoinJob(coin); + } } } @@ -815,8 +841,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.target = buffReversed.readUInt32BE(0); return buffReversed.toString('hex'); }; - this.getJob = function () { - const coin = this.selectBestCoin(); + this.getCoinJob = function (coin) { let bt = activeBlockTemplate[coin]; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; this.jobLastBlockHash = bt.idHash; @@ -886,12 +911,18 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } return this.cachedJob; }; + this.getJob = function () { + return this.getCoinJob(this.selectBestCoin()); + }; - this.sendNewJob = function() { - const job = this.getJob(); + this.sendNewCoinJob = function(coin) { + const job = this.getCoinJob(coin); if (job === null) return; return this.messageSender('job', job); }; + this.sendNewJob = function() { + return this.sendNewCoinJob(this.selectBestCoin()); + }; } } From b7abfd22cbaa52cf2a91efc5244277f35c573e7a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 13:45:44 +0200 Subject: [PATCH 0117/1496] Error fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index fb42f80a8..0afd25273 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -513,7 +513,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } } - this.debugMiner = miner.payout == global.coinFuncs.testDevAddress; + this.debugMiner = this.payout == global.coinFuncs.testDevAddress; this.email = pass_split.length === 2 ? pass_split[1] : ""; this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + ipAddress + ")"; From 43a61ad0e67f5c7501e914b0310a78ef9f3fc4b9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 13:49:28 +0200 Subject: [PATCH 0118/1496] Disabled new code --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0afd25273..804cfeb85 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -388,8 +388,8 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const block_version = activeBlockTemplate[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - const isHashFactorChange = !(coin in lastCoinHashFactor) || !(coin in activeBlockTemplate) || coinHashFactor == 0 || - (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); + const isHashFactorChange = true;/*!(coin in lastCoinHashFactor) || !(coin in activeBlockTemplate) || coinHashFactor == 0 || + (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05);*/ const time_before = Date.now(); From e8a5c23c8cd2e940f417b12fd448ab3fe7aecef4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 13:53:55 +0200 Subject: [PATCH 0119/1496] Error fix --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 804cfeb85..7e198bfa7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -388,8 +388,8 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const block_version = activeBlockTemplate[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - const isHashFactorChange = true;/*!(coin in lastCoinHashFactor) || !(coin in activeBlockTemplate) || coinHashFactor == 0 || - (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05);*/ + const isHashFactorChange = !(coin in lastCoinHashFactor) || !(coin in activeBlockTemplate) || coinHashFactor == 0 || + (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); const time_before = Date.now(); @@ -411,8 +411,8 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } else { if (check_height) { for (var [minerId, miner] of activeMiners) { + if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); if (miner.curr_coin !== coin) continue; - if (typeof(this.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); miner.trust.check_height = check_height; @@ -420,8 +420,8 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } } else { for (var [minerId, miner] of activeMiners) { + if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); if (miner.curr_coin !== coin) continue; - if (typeof(this.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); miner.sendNewCoinJob(coin); From 1590a60e29997f3dcc86d2ae9da180b2a0423143 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 14:03:08 +0200 Subject: [PATCH 0120/1496] More logs --- lib/pool.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7e198bfa7..d0faaaf50 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -394,6 +394,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const time_before = Date.now(); if (isHashFactorChange) { + console.log("Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); lastCoinHashFactor[coin] = coinHashFactor; if (check_height) { @@ -409,21 +410,22 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } } } else { + console.log("Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); if (check_height) { for (var [minerId, miner] of activeMiners) { - if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); + //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); if (miner.curr_coin !== coin) continue; - if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); - if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); + //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); + //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); miner.trust.check_height = check_height; miner.sendNewCoinJob(coin); } } else { for (var [minerId, miner] of activeMiners) { - if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); + //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); if (miner.curr_coin !== coin) continue; - if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); - if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); + //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); + //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); miner.sendNewCoinJob(coin); } } From 5a5ff8b7b90840322718383e90542fe03590d471 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 14:09:29 +0200 Subject: [PATCH 0121/1496] More debug --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d0faaaf50..5bce76180 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -394,7 +394,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const time_before = Date.now(); if (isHashFactorChange) { - console.log("Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); + console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); lastCoinHashFactor[coin] = coinHashFactor; if (check_height) { @@ -410,7 +410,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } } } else { - console.log("Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); + console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); @@ -718,7 +718,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) return; let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; - if (miner.debugMiner) console.log(miner.logString + ": " + coin + ": " + coin_perf); + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": " + coin_perf); if (coin_perf > best_coin_perf) { best_coin = coin; best_coin_perf = coin_perf; From fdb4681d4404ad005aac2fdc6ef8d78f75b9ed41 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 14:12:08 +0200 Subject: [PATCH 0122/1496] More debug --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5bce76180..593f2f082 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -182,7 +182,7 @@ function retargetMiners() { const time_before = Date.now(); for (var [minerId, miner] of activeMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 500) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id, ports: minerCount } }); } @@ -220,7 +220,7 @@ function checkAliveMiners() { const deadline = time_before - global.config.pool.minerTimeout * 1000; for (var [minerId, miner] of activeMiners) if (miner.lastContact < deadline) removeMiner(miner); const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 500) console.error(threadName + "checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function get_hash_factor(coin) { @@ -432,7 +432,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 500) console.error(threadName + "setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { From fced1dd743aed19718e98ec9bf92d5fa7cadd609 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 14:19:47 +0200 Subject: [PATCH 0123/1496] Switched messages to debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 593f2f082..db72f2e28 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -394,7 +394,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const time_before = Date.now(); if (isHashFactorChange) { - console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); + debug(threadName + "Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); lastCoinHashFactor[coin] = coinHashFactor; if (check_height) { @@ -410,7 +410,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } } } else { - console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); + debug(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); From c9a1e92e43025f70b03d97a4d0beb77c93f1aa7f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 15:32:56 +0200 Subject: [PATCH 0124/1496] Updated LTHN stuff --- lib/coins/xmr.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6cb17861c..70032ad78 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -257,7 +257,7 @@ function Coin(data){ if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; - if ("cn/2" in algos_perf) coin_perf[""] = algos_perf["cn/2"]; + if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn/2"]; if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1 or cn/2 hashrate"; @@ -297,7 +297,7 @@ function Coin(data){ case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, 1); // Lethean + case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); } } @@ -324,7 +324,7 @@ function Coin(data){ case 22023: return "cryptonight-heavy/0"; // LOKI case 24182: return "cryptonight-heavy/tube"; // BitTube case 38081: return "cryptonight/msr"; // MSR - case 48782: return "cryptonight/1"; // Lethean + case 48782: return "cryptonight/2"; // Lethean default: return "cryptonight/2"; } } @@ -341,7 +341,7 @@ function Coin(data){ case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 38081: return "cn/msr"; // MSR - case 48782: return "cn/1"; // Lethean + case 48782: return "cn/2"; // Lethean default: return "cn/2"; } } @@ -358,7 +358,7 @@ function Coin(data){ case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube case 38081: return "msr"; // MSR - case 48782: return "1"; // Lethean + case 48782: return "2"; // Lethean default: return "2"; } } From d3e4eba516f92e3dc2e3b0b2b449afa17009bda0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Oct 2018 22:17:59 +0200 Subject: [PATCH 0125/1496] Added Graft fork support --- lib/coins/xmr.js | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 70032ad78..7741c76c4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -264,8 +264,8 @@ function Coin(data){ if ("cn/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtl"]; else coin_perf["XTL"] = "GRFT" in coin_perf ? coin_perf["GRFT"] : coin_perf[""]; - if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; - else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; + if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; + else if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; @@ -292,7 +292,7 @@ function Coin(data){ case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR - case 18981: return multiHashing.cryptonight(convertedBlob, 1); // Graft + case 18981: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 11 ? 8 : 1); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube @@ -312,23 +312,6 @@ function Coin(data){ } } - this.algoTypeStr = function(port, version) { - switch (port) { - case 11181: return "cryptonight-lite/1"; // Aeon - case 11898: return "cryptonight-lite/1"; // TRTL - case 12211: return "cryptonight-heavy/0"; // RYO - case 17750: return "cryptonight-heavy/xhv"; // Haven - case 18081: return "cryptonight/2"; // XMR - case 18981: return "cryptonight/1"; // Graft - case 20189: return "cryptonight/xtl"; // Stellite - case 22023: return "cryptonight-heavy/0"; // LOKI - case 24182: return "cryptonight-heavy/tube"; // BitTube - case 38081: return "cryptonight/msr"; // MSR - case 48782: return "cryptonight/2"; // Lethean - default: return "cryptonight/2"; - } - } - this.algoShortTypeStr = function(port, version) { switch (port) { case 11181: return "cn-lite/1"; // Aeon @@ -336,7 +319,7 @@ function Coin(data){ case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR - case 18981: return "cn/1"; // Graft + case 18981: return version >= 11 ? "cn/2" : "cn/1"; // Graft case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube @@ -353,7 +336,7 @@ function Coin(data){ case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR - case 18981: return "1"; // Graft + case 18981: return version >= 11 ? "2" : "1"; // Graft case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube From 09011cacc7ea1049658552d6d7028a6002ecb952 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Oct 2018 16:14:20 +0200 Subject: [PATCH 0126/1496] Switch to normalize hashrate for global pool numbers --- lib/worker.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 97945de58..da8028302 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -82,22 +82,23 @@ function updateShareStats() { if (share.timestamp <= locTime) return; let minerIDWithIdentifier = minerID + "_" + identifier; - localStats.global += share.shares; + const shares2 = share.shares2 ? share.shares2 : share.shares; + localStats.global += shares2; if (localTimes.global < share.timestamp) localTimes.global = share.timestamp; let minerType; switch (share.poolType) { case global.protos.POOLTYPE.PPLNS: minerType = 'pplns'; - localStats.pplns += share.shares; + localStats.pplns += shares2; if (localTimes.pplns < share.timestamp) localTimes.pplns = share.timestamp; break; case global.protos.POOLTYPE.PPS: - localStats.pps += share.shares; + localStats.pps += shares2; minerType = 'pps'; if (localTimes.pps < share.timestamp) localTimes.pps = share.timestamp; break; case global.protos.POOLTYPE.SOLO: - localStats.solo += share.shares; + localStats.solo += shares2; minerType = 'solo'; if (localTimes.solo < share.timestamp) localTimes.solo = share.timestamp; break; @@ -147,13 +148,16 @@ function updateShareStats() { let cache_updates = {}; // pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { + const hash = Math.floor(localStats[key] / (hashrate_avg_min*60)) + 1; + const lastHash = localTimes[key]; + const minerCount = localMinerCount[key]; let cachedData = global.database.getCache(key + "_stats"); if (cachedData !== false) { - cachedData.hash = Math.floor(localStats[key] / (hashrate_avg_min*60)) + 1; - cachedData.lastHash = localTimes[key]; - cachedData.minerCount = localMinerCount[key]; + cachedData.hash = hash; + cachedData.lastHash = lastHash; + cachedData.minerCount = minerCount; if (!cachedData.hasOwnProperty("hashHistory")) { - cachedData.hashHistory = []; + cachedData.hashHistory = []; cachedData.minerHistory = []; } if (cycleCount === 0) { @@ -172,12 +176,12 @@ function updateShareStats() { } } else { cachedData = { - hash: Math.floor(localStats[key] / (hashrate_avg_min*60)) + 1, + hash: hash, totalHashes: 0, - lastHash: localTimes[key], - minerCount: localMinerCount[key], - hashHistory: [{ts: currentTime, hs: cachedData.hash}], - minerHistory: [{ts: currentTime, cn: cachedData.hash}] + lastHash: lastHash, + minerCount: minerCount, + hashHistory: [{ts: currentTime, hs: hash}], + minerHistory: [{ts: currentTime, cn: minerCount}] }; } cache_updates[key + "_stats"] = cachedData; From 47eded0971bd4dbe6e7dc9103b86c8d259764b7c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Oct 2018 09:50:15 +0200 Subject: [PATCH 0127/1496] Added option to get getPortLastBlockHeader siliently --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7741c76c4..562e1fdb9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -115,12 +115,12 @@ function Coin(data){ return this.getPortBlockHeaderByHash(global.config.daemon.port, blockHash, callback); }; - this.getPortLastBlockHeader = function(port, callback){ + this.getPortLastBlockHeader = function(port, callback, no_error_report){ global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ return callback(null, body.result.block_header); } else { - console.error(JSON.stringify(body)); + if (!no_error_report) console.error(JSON.stringify(body)); return callback(true, body); } }); From 19d2ca33d91efb61fe98f115e6c10aaaac566214 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Oct 2018 10:00:05 +0200 Subject: [PATCH 0128/1496] Make getPortLastBlockHeader silent and report error in one line --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index da8028302..5571c6143 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -714,7 +714,7 @@ function updateBlockHeader() { for (let port in min_block_rewards) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err !== null) { - console.error("Last block header request failed for " + port + " port!"); + console.error("Last block header request failed for " + port + " port!" + (body instanceof Object ? JSON.stringify(body) : body)); body.difficulty = prev_network_info[port].difficulty; body.hash = prev_network_info[port].hash; body.height = prev_network_info[port].height; @@ -739,7 +739,7 @@ function updateBlockHeader() { info.main_height = prev_network_info[global.config.daemon.port].height; global.database.setCache('networkBlockInfo', info); } - }); + }, true); } } From d9afcf76b7e723e491d17aa654694ac7f239f5bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Oct 2018 10:18:29 +0200 Subject: [PATCH 0129/1496] Make getPortLastBlockHeader silent and report error in one line --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 5571c6143..fb8adfb23 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -714,7 +714,7 @@ function updateBlockHeader() { for (let port in min_block_rewards) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err !== null) { - console.error("Last block header request failed for " + port + " port!" + (body instanceof Object ? JSON.stringify(body) : body)); + console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); body.difficulty = prev_network_info[port].difficulty; body.hash = prev_network_info[port].hash; body.height = prev_network_info[port].height; From 4b52c3cffb851014dd473cc4039b83c959d1dc71 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Oct 2018 16:02:00 +0200 Subject: [PATCH 0130/1496] Added info about cast option --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 562e1fdb9..f37e56a77 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -382,7 +382,7 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 10500) { - return "You must update your cast-xmr miner (" + agent + ") to version v1.5.0+"; + return "You must update your cast-xmr miner (" + agent + ") to version v1.5.0+ (and use --algo=10 command line switch)"; } } else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; From d275a91cd5af70b1dc704d5da6ff0965da27a80b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 07:36:53 +0200 Subject: [PATCH 0131/1496] More algo switch debug --- lib/pool.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index db72f2e28..1f9995457 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -707,15 +707,27 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_coin_perf = this.coin_perf[""] * 1.1; let miner = this; COINS.forEach(function(coin) { - if (!(coin in miner.coin_perf)) return; - if (!(coin in activeBlockTemplate)) return; + if (!(coin in miner.coin_perf)) { + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coin_perf"); + return; + } + if (!(coin in activeBlockTemplate)) { + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplate"); + return; + } const coinHashFactor = global.config.daemon["coinHashFactor" + coin]; - if (!coinHashFactor) return; + if (!coinHashFactor) { + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); + return; + } const bt = activeBlockTemplate[coin]; const port = bt.port; const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) return; + if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no algo support"); + return; + } let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": " + coin_perf); From ee9d72c96031783decf318a1d2610dc2f30fbe2c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 09:00:59 +0200 Subject: [PATCH 0132/1496] More algo switch debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 1f9995457..a26fc99d1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -698,6 +698,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); this.selectBestCoin = function() { + if (miner.debugMiner) console.log(threadName + miner.logString + ": current coin is " + this.curr_coin); if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && get_hash_factor(this.curr_coin) && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { From d134251b17acdfa1fbe8b5442ec785280811c467 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 09:16:45 +0200 Subject: [PATCH 0133/1496] Removed old code --- lib/pool.js | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a26fc99d1..006232c7e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -236,14 +236,14 @@ function updateActivePort(coin) { console.error("Error getting activePort, so rolling back to main port"); global.config.daemon.activePort = global.config.daemon.port; } else { - console.error("Error getting " + "activePort" + coin); + console.error("Error getting activePort" + coin); coinHashFactorUpdate(coin, 0); } } else { if (coin !== "") { global.support.getCoinHashFactor(coin, function (newCoinHashFactor) { if (newCoinHashFactor === null) { - console.error("Error getting " + "coinHashFactor" + coin); + console.error("Error getting coinHashFactor" + coin); coinHashFactorUpdate(coin, 0); } else { if (newActivePort == 0 || newCoinHashFactor == 0) coinHashFactorUpdate(coin, 0); @@ -266,18 +266,6 @@ function updateActivePort(coin) { }); } - -function setProblemPort(port) { - console.warn("Returning to " + global.config.daemon.port + " port."); - lastPortErrorTime[port] = Date.now(); - global.config.daemon.activePort = global.config.daemon.port; - global.support.sendEmail(global.config.general.adminEmail, - "FYI: Block template request failed for " + port + " port.", - "On pool server " + global.config.hostname + " block template request failed for " + port + " port.\n" + - "Returning to " + global.config.daemon.port + " port." - ); -} - // templateUpdateReal is only called in master thread (except the beginning of a worker thread) function templateUpdateReal(coin, activePort, coinHashFactor) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { @@ -299,11 +287,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor) { } } else { console.error("Block template request failed for " + activePort + " port."); - if (coin === "") { - if (activePort != global.config.daemon.port) setProblemPort(activePort); - } else { - coinHashFactorUpdate(coin, 0); - } + coinHashFactorUpdate(coin, 0); setTimeout(templateUpdateReal, 3000, coin, activePort); } }); @@ -346,11 +330,7 @@ function templateUpdate(coin, repeating) { if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); - if (coin === "") { - if (activePort != global.config.daemon.port) setProblemPort(activePort); - } else { - coinHashFactorUpdate(coin, 0); - } + coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } }); else { From 26df81cc38835cd36f54e3c1cfabffabc1b261dd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 09:43:02 +0200 Subject: [PATCH 0134/1496] Fixed some minor stuff --- lib/pool.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 006232c7e..3392414e4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -295,7 +295,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor) { function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; - if (global.config.daemon["coinHashFactor" + coin] == 0 && coinHashFactor == 0) return; + if (global.config.daemon["coinHashFactor" + coin] === 0 && coinHashFactor === 0) return; if (cluster.isMaster) { let data = { coin: coin, coinHashFactor: coinHashFactor }; sendToWorkers({type: 'newCoinHashFactor', data: data}); @@ -362,18 +362,17 @@ function anchorBlockUpdate() { } function setNewCoinHashFactor(coin, coinHashFactor, check_height) { - if (coin !== "") global.config.daemon["coinHashFactor" + coin] = coinHashFactor; // used in miner.selectBestCoin if (!(coin in activeBlockTemplate)) return; - const port = activeBlockTemplate[coin].port; - const block_version = activeBlockTemplate[coin].buffer[0]; - const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - - const isHashFactorChange = !(coin in lastCoinHashFactor) || !(coin in activeBlockTemplate) || coinHashFactor == 0 || - (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); + if (coin !== "") global.config.daemon["coinHashFactor" + coin] = coinHashFactor; // used in miner.selectBestCoin const time_before = Date.now(); + const isHashFactorChange = !(coin in lastCoinHashFactor) || !coinHashFactor || (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); if (isHashFactorChange) { + const port = activeBlockTemplate[coin].port; + const block_version = activeBlockTemplate[coin].buffer[0]; + const algo = global.coinFuncs.algoShortTypeStr(port, block_version); + debug(threadName + "Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); lastCoinHashFactor[coin] = coinHashFactor; @@ -678,7 +677,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); this.selectBestCoin = function() { - if (miner.debugMiner) console.log(threadName + miner.logString + ": current coin is " + this.curr_coin); + if (this.debugMiner) console.log(threadName + this.logString + ": current coin is " + this.curr_coin); if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && get_hash_factor(this.curr_coin) && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { From 8fd94998cf1fb693cd73e6cd36d75037639c1cf3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 11:47:23 +0200 Subject: [PATCH 0135/1496] More debug --- lib/pool.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3392414e4..1941eea43 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -21,6 +21,7 @@ let activeMiners = new Map(); let lastBlockHash = {}; // coin key let lastCoinHashFactor = {}; // coin key +let currCoinHashFactor = {}; // coin key let activeBlockTemplate = {}; // coin key let pastBlockTemplates = global.support.circularBuffer(10); @@ -223,8 +224,8 @@ function checkAliveMiners() { if (elapsed > 500) console.error(threadName + "checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } -function get_hash_factor(coin) { - return coin === "" ? 1.0 : global.config.daemon["coinHashFactor" + coin]; +function set_hash_factor(coin, hash_factor) { + currCoinHashFactor[coin] = hash_factor; } // global.config.daemon["activePort" + coin] is only updated in master thread @@ -246,8 +247,8 @@ function updateActivePort(coin) { console.error("Error getting coinHashFactor" + coin); coinHashFactorUpdate(coin, 0); } else { - if (newActivePort == 0 || newCoinHashFactor == 0) coinHashFactorUpdate(coin, 0); - else global.config.daemon["coinHashFactor" + coin] = newCoinHashFactor; + if (!newActivePort || !newCoinHashFactor) coinHashFactorUpdate(coin, 0); + else set_hash_factor(coin, newCoinHashFactor); if (oldActivePort !== newActivePort) { console.log("Changing activePort" + coin + " from " + oldActivePort + " to " + newActivePort); global.config.daemon["activePort" + coin] = newActivePort; @@ -295,7 +296,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor) { function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; - if (global.config.daemon["coinHashFactor" + coin] === 0 && coinHashFactor === 0) return; + if (currCoinHashFactor[coin] === 0 && coinHashFactor === 0) return; if (cluster.isMaster) { let data = { coin: coin, coinHashFactor: coinHashFactor }; sendToWorkers({type: 'newCoinHashFactor', data: data}); @@ -316,13 +317,13 @@ function templateUpdate(coin, repeating) { return; } if (err === null) { - const coinHashFactor = get_hash_factor(coin); + const coinHashFactor = currCoinHashFactor[coin]; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; lastCoinHashFactor[coin] = coinHashFactor; templateUpdateReal(coin, activePort, coinHashFactor); - } else if ( !(coin in lastCoinHashFactor) || (coinHashFactor == 0 && lastCoinHashFactor[coin] != 0) || - (coinHashFactor != 0 && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05) + } else if ( !(coin in lastCoinHashFactor) || (!coinHashFactor && lastCoinHashFactor[coin]) || + (coinHashFactor && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05) ) { lastCoinHashFactor[coin] = coinHashFactor; coinHashFactorUpdate(coin, coinHashFactor); @@ -363,7 +364,7 @@ function anchorBlockUpdate() { function setNewCoinHashFactor(coin, coinHashFactor, check_height) { if (!(coin in activeBlockTemplate)) return; - if (coin !== "") global.config.daemon["coinHashFactor" + coin] = coinHashFactor; // used in miner.selectBestCoin + if (coin !== "") set_hash_factor(coin, coinHashFactor); // used in miner.selectBestCoin const time_before = Date.now(); const isHashFactorChange = !(coin in lastCoinHashFactor) || !coinHashFactor || (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); @@ -373,7 +374,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { const block_version = activeBlockTemplate[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - debug(threadName + "Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); + if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); lastCoinHashFactor[coin] = coinHashFactor; if (check_height) { @@ -389,7 +390,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } } } else { - debug(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); + if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); @@ -678,7 +679,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestCoin = function() { if (this.debugMiner) console.log(threadName + this.logString + ": current coin is " + this.curr_coin); - if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && get_hash_factor(this.curr_coin) && + if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && currCoinHashFactor[this.curr_coin] && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { return this.curr_coin; @@ -695,7 +696,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplate"); return; } - const coinHashFactor = global.config.daemon["coinHashFactor" + coin]; + const coinHashFactor = currCoinHashFactor[coin]; if (!coinHashFactor) { if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); return; @@ -835,6 +836,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.target = buffReversed.readUInt32BE(0); return buffReversed.toString('hex'); }; + this.getCoinJob = function (coin) { let bt = activeBlockTemplate[coin]; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; @@ -847,7 +849,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.difficulty = this.newDiffRecommendation; this.newDiffRecommendation = null; } - const coinHashFactor = get_hash_factor(coin); + const coinHashFactor = currCoinHashFactor[coin]; if (!this.proxy) { let blob = bt.nextBlob(); let target = this.getTargetHex(); @@ -1663,8 +1665,10 @@ if (cluster.isMaster) { console.warn("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); global.config.daemon.activePort = global.config.daemon.port; } else { + currCoinHashFactor[""] = 1; setInterval(updateActivePort, 3*1000, ""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { + currCoinHashFactor[coin] = 0; if ("activePort" + coin in global.config.daemon) { setInterval(updateActivePort, 5*1000, coin); templateUpdate(coin); @@ -1679,8 +1683,10 @@ if (cluster.isMaster) { setTimeout(templateUpdate, 50, "", true); global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); } else { + currCoinHashFactor[""] = 1; templateUpdate(""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { + currCoinHashFactor[coin] = 0; if ("activePort" + coin in global.config.daemon) templateUpdate(coin); }); anchorBlockUpdate(); From 8e2a6f4d8d7b569394bdb69a4572499a7dbe9483 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 12:14:06 +0200 Subject: [PATCH 0136/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1941eea43..50c9a2243 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -390,7 +390,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } } } else { - if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); + if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor (" + lastCoinHashFactor[coin] + " base)"); if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); From 4d3cfaa11c75f5c9936c8e55b62131d363ad5191 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 12:55:34 +0200 Subject: [PATCH 0137/1496] Fixed changed hashfactor processing --- lib/pool.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 50c9a2243..b92f42875 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -122,7 +122,7 @@ function messageHandler(message) { break; case 'newCoinHashFactor': debug(threadName + "Received new coin hash factor"); - setNewCoinHashFactor(message.data.coin, message.data.coinHashFactor); + setNewCoinHashFactor(true, message.data.coin, message.data.coinHashFactor); break; case 'minerPortCount': if (cluster.isMaster) minerCount[message.data.worker_id] = message.data.ports; @@ -268,7 +268,7 @@ function updateActivePort(coin) { } // templateUpdateReal is only called in master thread (except the beginning of a worker thread) -function templateUpdateReal(coin, activePort, coinHashFactor) { +function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { if (activePort !== global.config.daemon["activePort" + coin]) { console.log("Aborting " + activePort + " last block template request because " + "activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); @@ -279,6 +279,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor) { rpcResponse.coin = coin; rpcResponse.port = activePort; rpcResponse.coinHashFactor = coinHashFactor; + rpcResponse.isHashFactorChange = isHashFactorChange; debug(threadName + "New block template found at " + rpcResponse.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); @@ -300,10 +301,10 @@ function coinHashFactorUpdate(coin, coinHashFactor) { if (cluster.isMaster) { let data = { coin: coin, coinHashFactor: coinHashFactor }; sendToWorkers({type: 'newCoinHashFactor', data: data}); - setNewCoinHashFactor(coin, coinHashFactor); + setNewCoinHashFactor(true, coin, coinHashFactor); console.log('[*] New ' + coin + ' coin hash factor is set to ' + coinHashFactor); } else { - setNewCoinHashFactor(coin, coinHashFactor); + setNewCoinHashFactor(true, coin, coinHashFactor); } } @@ -318,14 +319,13 @@ function templateUpdate(coin, repeating) { } if (err === null) { const coinHashFactor = currCoinHashFactor[coin]; + const isHashFactorChange = !(coin in lastCoinHashFactor) || (!coinHashFactor && lastCoinHashFactor[coin]) || + (coinHashFactor && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); + lastCoinHashFactor[coin] = coinHashFactor; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; - lastCoinHashFactor[coin] = coinHashFactor; - templateUpdateReal(coin, activePort, coinHashFactor); - } else if ( !(coin in lastCoinHashFactor) || (!coinHashFactor && lastCoinHashFactor[coin]) || - (coinHashFactor && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05) - ) { - lastCoinHashFactor[coin] = coinHashFactor; + templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); + } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); @@ -362,20 +362,18 @@ function anchorBlockUpdate() { }); } -function setNewCoinHashFactor(coin, coinHashFactor, check_height) { +function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { if (!(coin in activeBlockTemplate)) return; if (coin !== "") set_hash_factor(coin, coinHashFactor); // used in miner.selectBestCoin const time_before = Date.now(); - const isHashFactorChange = !(coin in lastCoinHashFactor) || !coinHashFactor || (Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); if (isHashFactorChange) { const port = activeBlockTemplate[coin].port; const block_version = activeBlockTemplate[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed from " + lastCoinHashFactor[coin] + " to " + coinHashFactor); - lastCoinHashFactor[coin] = coinHashFactor; + if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed to " + coinHashFactor); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -390,7 +388,7 @@ function setNewCoinHashFactor(coin, coinHashFactor, check_height) { } } } else { - if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor (" + lastCoinHashFactor[coin] + " base)"); + if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); @@ -441,7 +439,7 @@ function setNewBlockTemplate(template) { anchorBlockHeight = height; } - setNewCoinHashFactor(coin, template.coinHashFactor, isExtraCheck ? height : 0); + setNewCoinHashFactor(template.isHashFactorChange, coin, template.coinHashFactor, isExtraCheck ? height : 0); } // here we keep verified share number of a specific wallet (miner.payout) From 78376c2040c3d0ffb408514aaf069b98ef2cbb1f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 13:04:28 +0200 Subject: [PATCH 0138/1496] Fixed changed hashfactor processing --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b92f42875..82b3d742b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -321,7 +321,7 @@ function templateUpdate(coin, repeating) { const coinHashFactor = currCoinHashFactor[coin]; const isHashFactorChange = !(coin in lastCoinHashFactor) || (!coinHashFactor && lastCoinHashFactor[coin]) || (coinHashFactor && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); - lastCoinHashFactor[coin] = coinHashFactor; + if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); From a01f597cf3659cb29e4ec1e08901ac7d491bfbe5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 13:20:57 +0200 Subject: [PATCH 0139/1496] Corrently handle 0 hash factors --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 82b3d742b..005c9a86c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -321,7 +321,6 @@ function templateUpdate(coin, repeating) { const coinHashFactor = currCoinHashFactor[coin]; const isHashFactorChange = !(coin in lastCoinHashFactor) || (!coinHashFactor && lastCoinHashFactor[coin]) || (coinHashFactor && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); - if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); @@ -364,6 +363,7 @@ function anchorBlockUpdate() { function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { if (!(coin in activeBlockTemplate)) return; + if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; if (coin !== "") set_hash_factor(coin, coinHashFactor); // used in miner.selectBestCoin const time_before = Date.now(); From 7417e6487f8298b54b477fa653581e87cd545586 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 13:37:56 +0200 Subject: [PATCH 0140/1496] Better debugging --- lib/pool.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 005c9a86c..d12de4521 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -299,13 +299,11 @@ function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; if (currCoinHashFactor[coin] === 0 && coinHashFactor === 0) return; if (cluster.isMaster) { + console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor); let data = { coin: coin, coinHashFactor: coinHashFactor }; sendToWorkers({type: 'newCoinHashFactor', data: data}); - setNewCoinHashFactor(true, coin, coinHashFactor); - console.log('[*] New ' + coin + ' coin hash factor is set to ' + coinHashFactor); - } else { - setNewCoinHashFactor(true, coin, coinHashFactor); } + setNewCoinHashFactor(true, coin, coinHashFactor); } // templateUpdate is only called in master thread (except the beginning of a worker thread) From fd91dd59972dc3875ec9585712a9602388784aec Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 13:57:17 +0200 Subject: [PATCH 0141/1496] Update hashfactor from 0 only in case of new block --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d12de4521..c04367d41 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -322,7 +322,7 @@ function templateUpdate(coin, repeating) { if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); - } else if (isHashFactorChange) { + } else if (isHashFactorChange && lastCoinHashFactor[coin]) { coinHashFactorUpdate(coin, coinHashFactor); } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); From 28296187b167f3d725320cf63f8470bc74c95041 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 14:16:39 +0200 Subject: [PATCH 0142/1496] Double zero hash factor possible fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c04367d41..dc7f36b52 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -297,7 +297,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; - if (currCoinHashFactor[coin] === 0 && coinHashFactor === 0) return; + if (currCoinHashFactor[coin] == 0 && coinHashFactor == 0) return; if (cluster.isMaster) { console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor); let data = { coin: coin, coinHashFactor: coinHashFactor }; From 3975325ee45ddb310429b394207305729dbd089f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 14:23:29 +0200 Subject: [PATCH 0143/1496] Double zero hash factor possible fix --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index dc7f36b52..f146f46e4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -297,7 +297,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; - if (currCoinHashFactor[coin] == 0 && coinHashFactor == 0) return; + if (currCoinHashFactor[coin] === 0 && coinHashFactor === 0) return; if (cluster.isMaster) { console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor); let data = { coin: coin, coinHashFactor: coinHashFactor }; @@ -319,7 +319,7 @@ function templateUpdate(coin, repeating) { const coinHashFactor = currCoinHashFactor[coin]; const isHashFactorChange = !(coin in lastCoinHashFactor) || (!coinHashFactor && lastCoinHashFactor[coin]) || (coinHashFactor && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); - if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { + if ((!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) && coinHashFactor) { lastBlockHash[coin] = body.hash; templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); } else if (isHashFactorChange && lastCoinHashFactor[coin]) { From f1783a4bf425c73998e4a1783024975454adc5d4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 15:46:00 +0200 Subject: [PATCH 0144/1496] Solution for possible race condition --- lib/pool.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f146f46e4..d4449cc4d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -317,13 +317,14 @@ function templateUpdate(coin, repeating) { } if (err === null) { const coinHashFactor = currCoinHashFactor[coin]; - const isHashFactorChange = !(coin in lastCoinHashFactor) || (!coinHashFactor && lastCoinHashFactor[coin]) || - (coinHashFactor && Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05); - if ((!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) && coinHashFactor) { - lastBlockHash[coin] = body.hash; - templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); - } else if (isHashFactorChange && lastCoinHashFactor[coin]) { - coinHashFactorUpdate(coin, coinHashFactor); + if (coinHashFactor) { + const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; + if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { + lastBlockHash[coin] = body.hash; + templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); + } else if (isHashFactorChange && lastCoinHashFactor[coin]) { + coinHashFactorUpdate(coin, coinHashFactor); + } } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { From a1ca5f28311395843a43aca6b536cb70f78acde1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 16:04:26 +0200 Subject: [PATCH 0145/1496] Optimized code in case of 0 hash factor --- lib/pool.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d4449cc4d..a050a9a09 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -308,23 +308,21 @@ function coinHashFactorUpdate(coin, coinHashFactor) { // templateUpdate is only called in master thread (except the beginning of a worker thread) function templateUpdate(coin, repeating) { - let activePort = global.config.daemon["activePort" + coin]; - if (activePort) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + const activePort = global.config.daemon["activePort" + coin]; + const coinHashFactor = currCoinHashFactor[coin]; + if (activePort && coinHashFactor) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (activePort !== global.config.daemon["activePort" + coin]) { console.log("Aborting " + activePort + " last block header request because " + "activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); return; } if (err === null) { - const coinHashFactor = currCoinHashFactor[coin]; - if (coinHashFactor) { - const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; - if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { - lastBlockHash[coin] = body.hash; - templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); - } else if (isHashFactorChange && lastCoinHashFactor[coin]) { - coinHashFactorUpdate(coin, coinHashFactor); - } + const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; + if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { + lastBlockHash[coin] = body.hash; + templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); + } else if (isHashFactorChange && lastCoinHashFactor[coin]) { + coinHashFactorUpdate(coin, coinHashFactor); } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { From a71104a2ccb7b468b42a48523de347c62a0826c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 17:24:46 +0200 Subject: [PATCH 0146/1496] Added var dump --- lib/pool.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a050a9a09..ae37e422e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -19,9 +19,9 @@ let baseDiff = global.coinFuncs.baseDiff(); let activeMiners = new Map(); -let lastBlockHash = {}; // coin key -let lastCoinHashFactor = {}; // coin key -let currCoinHashFactor = {}; // coin key +let lastBlockHash = {}; // coin key +let lastCoinHashFactor = {}; // coin key +let currCoinHashFactor = {}; // coin key let activeBlockTemplate = {}; // coin key let pastBlockTemplates = global.support.circularBuffer(10); @@ -1547,6 +1547,16 @@ if (global.config.general.allowStuckPoolKill && fs.existsSync("block_template_is process.exit(); } +setInterval(function dump_vars() { + const fn = "dump" + (cluster.isMaster ? "" : "_" + cluster.worker.id.toString()); + fs.access(fn, fs.F_OK, function(err) { + if (!err) return; + let s = fs.createWriteStream(fn, {'flags': 'a'}); + for (var [minerId, miner] of activeMiners) s.write(minerId + ": " + JSON.strinfigy(miner)); + s.end(); + }); +}, 60*1000); + if (cluster.isMaster) { const numWorkers = require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { @@ -1677,6 +1687,7 @@ if (cluster.isMaster) { templateUpdate(""); setTimeout(templateUpdate, 50, "", true); global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); + } else { currCoinHashFactor[""] = 1; templateUpdate(""); From 53318ab045fee084b0ef17a04434eae49c1b84e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 17:26:56 +0200 Subject: [PATCH 0147/1496] Added var dump --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ae37e422e..f1e039af9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1551,8 +1551,9 @@ setInterval(function dump_vars() { const fn = "dump" + (cluster.isMaster ? "" : "_" + cluster.worker.id.toString()); fs.access(fn, fs.F_OK, function(err) { if (!err) return; + console.log("DUMPING VARS TO " + fn + " FILE"); let s = fs.createWriteStream(fn, {'flags': 'a'}); - for (var [minerId, miner] of activeMiners) s.write(minerId + ": " + JSON.strinfigy(miner)); + for (var [minerId, miner] of activeMiners) s.write(minerId + ": " + JSON.stringify(miner)); s.end(); }); }, 60*1000); From 85755ed7cffb5a496b5ab28dc77fed30d3c6b03d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 17:39:10 +0200 Subject: [PATCH 0148/1496] Extended dump --- lib/pool.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f1e039af9..70d42a958 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1553,7 +1553,46 @@ setInterval(function dump_vars() { if (!err) return; console.log("DUMPING VARS TO " + fn + " FILE"); let s = fs.createWriteStream(fn, {'flags': 'a'}); - for (var [minerId, miner] of activeMiners) s.write(minerId + ": " + JSON.stringify(miner)); + + s.write("activeMiners:\n"); + for (var [minerId, miner] of activeMiners) s.write(minerId + ": " + JSON.stringify(miner, null, '\t') + "\n"); + + s.write("\n\n\npastBlockTemplates:\n"); + pastBlockTemplates.toarray().forEach(function(v) { s.write(JSON.stringify(v, null, '\t') + "\n"); }); + + s.write("\n\n\nlastBlockHash:\n"); + s.write(JSON.stringify(lastBlockHash, null, '\t') + "\n"); + + s.write("\n\n\nlastCoinHashFactor:\n"); + s.write(JSON.stringify(lastCoinHashFactor, null, '\t') + "\n"); + + s.write("\n\n\ncurrCoinHashFactor:\n"); + s.write(JSON.stringify(currCoinHashFactor, null, '\t') + "\n"); + + s.write("\n\n\nactiveBlockTemplate:\n"); + s.write(JSON.stringify(activeBlockTemplate, null, '\t') + "\n"); + + s.write("\n\n\nproxyMiners:\n"); + s.write(JSON.stringify(proxyMiners, null, '\t') + "\n"); + + s.write("\n\n\nanchorBlockHeight: " + anchorBlockHeight + "\n"); + s.write("\n\n\nanchorBlockPrevHeight: " + anchorBlockPrevHeight + "\n"); + + s.write("\n\n\nwalletTrust:\n"); + s.write(JSON.stringify(walletTrust, null, '\t') + "\n"); + + s.write("\n\n\nwalletLastSeeTime:\n"); + s.write(JSON.stringify(walletLastSeeTime, null, '\t') + "\n"); + + s.write("\n\n\nwalletAcc:\n"); + s.write(JSON.stringify(walletAcc, null, '\t') + "\n"); + + s.write("\n\n\nwalletWorkerCount:\n"); + s.write(JSON.stringify(walletWorkerCount, null, '\t') + "\n"); + + s.write("\n\n\nis_walletAccFinalizer:\n"); + s.write(JSON.stringify(is_walletAccFinalizer, null, '\t') + "\n"); + s.end(); }); }, 60*1000); From cac0670ec882d549ffff2d04d699925919d74119 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 20:49:28 +0200 Subject: [PATCH 0149/1496] Moved altblockManager to separate dir --- init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.js b/init.js index d4dc05d10..11e34c0ea 100644 --- a/init.js +++ b/init.js @@ -81,7 +81,7 @@ global.mysql.query("SELECT * FROM config").then(function (rows) { require('./lib/blockManager.js'); break; case 'altblockManager': - require('./lib/altblockManager.js'); + require('./lib2/altblockManager.js'); break; case 'payments': require('./lib/payments.js'); From 89954b0662fada1376eff2e1d37837e276b989a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 21:11:31 +0200 Subject: [PATCH 0150/1496] altblockManager config file example --- ex_keys.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ex_keys.json diff --git a/ex_keys.json b/ex_keys.json new file mode 100644 index 000000000..12e71b284 --- /dev/null +++ b/ex_keys.json @@ -0,0 +1,10 @@ +{ + "CRYPTOPIA": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "CRYPTOPIA_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=", + "TRADEOGRE": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "TRADEOGRE_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "QRYPTOS": "NNNNNN", + "QRYPTOS_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==", + "LIVECOIN": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "LIVECOIN_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" +} \ No newline at end of file From 45b5d3a39313cd37e744a2dfc7fa6ba54a4ae5bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Oct 2018 22:04:00 +0200 Subject: [PATCH 0151/1496] Updated to 13.0.4 --- deployment/deploy.bash | 4 ++-- deployment/leaf.bash | 4 ++-- deployment/upgrade_monero.bash | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 089ca6a81..2297ede28 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,11 +26,11 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.13.0.3 +sudo git checkout v0.13.0.4 #curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.4_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon #BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 6768662b1..6c2854dd1 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -22,11 +22,11 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.13.0.3 +sudo git checkout v0.13.0.4 #curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.4_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon #BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 483bda81b..fcdd9db74 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,12 +6,12 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.13.0.3 &&\ +sudo git checkout v0.13.0.4 &&\ #curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ USE_SINGLE_BUILDDIR=1 sudo nice make &&\ sudo mkdir -p /usr/local/src/monero/build/release/bin &&\ -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.3_/release/bin/* /usr/local/src/monero/build/release/bin &&\ +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.4_/release/bin/* /usr/local/src/monero/build/release/bin &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" From e29332a57a4365f6989e81566d0eba59a651f9b2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Oct 2018 19:55:41 +0100 Subject: [PATCH 0152/1496] Added WOW, XRN coins --- deployment/base.sql | 3 +++ lib/coins/xmr.js | 27 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index b2be577e5..c4fdeb132 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -201,6 +201,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXRN', '0', 'float', 'Saronite algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorWOW', '0', 'float', 'Wownero algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTUBE', '0', 'float', 'BitTube algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXHV', '0', 'float', 'Haven algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorAEON', '0', 'float', 'Aeon algo hash price factor relative to coinHashFactor'); @@ -256,6 +258,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_24182', '', 'string', 'Address to mine to for 24182 (BitTube) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Stellite) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_22023', '', 'string', 'Address to mine to for 22023 (Loki) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_31014', '', 'string', 'Address to mine to for 31014 (Saronite) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11898', '', 'string', 'Address to mine to for 11898 (Turtle) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f37e56a77..01c71e0aa 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -82,7 +82,8 @@ function Coin(data){ global.support.rpcPortDaemon(port, port == 11898 ? 'getblockheaderbyhash' : 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { - if (port != 11898 && port != 20189 && port != 48782 && port != 11181 && port != 22023) { // Stellite/Intense/Aeon/loki have composite based miner_tx + // Stellite / Lethean / Aeon / Loki / Saronite have composite based miner_tx + if (port != 11898 && port != 20189 && port != 48782 && port != 11181 && port != 22023 && port != 31014) { const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; @@ -94,7 +95,7 @@ function Coin(data){ } } - } else if (port == 22023) { // Loki has reward as zero transaction + } else if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction const blockJson = JSON.parse(body.result.json); body.result.block_header.reward = 0; @@ -166,6 +167,7 @@ function Coin(data){ case 11898: return 2; // TRTL case 12211: return 4; // RYO case 22023: return 5; // LOKI + case 31014: return 5; // XRN case 38081: return 3; // MSR default: return 0; } @@ -241,7 +243,7 @@ function Coin(data){ }; this.getCOINS = function() { - return [ "GRFT", "LTHN", "RYO", "LOKI", "TUBE", "XHV", "AEON", "MSR", "XTL", "TRTL" ]; + return [ "GRFT", "LTHN", "RYO", "LOKI", "TUBE", "XHV", "AEON", "MSR", "XTL", "TRTL", "XRN", "WOW" ]; } this.getDefaultAlgos = function() { @@ -255,20 +257,20 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; - if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn/2"]; + if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["WOW"] = coin_perf["LTHN"] = algos_perf["cn/2"]; + else if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["WOW"] = coin_perf["LTHN"] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["WOW"] = coin_perf["LTHN"] = algos_perf["cn/1"]; if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1 or cn/2 hashrate"; if ("cn/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtl"]; - else coin_perf["XTL"] = "GRFT" in coin_perf ? coin_perf["GRFT"] : coin_perf[""]; + else coin_perf["XTL"] = "cn" in algos_perf ? algos_perf["cn"] : coin_perf[""]; if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; else if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; - if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; - else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; + if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; + else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; if ("cn-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cn-heavy/tube"]; @@ -296,6 +298,8 @@ function Coin(data){ case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube + case 31014: return multiHashing.cryptonight_heavy(convertedBlob, 0); // Saronite + case 34568: return multiHashing.cryptonight(convertedBlob, 8); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); @@ -307,6 +311,7 @@ function Coin(data){ case 11898: return "forknote2"; // TRTL case 12211: return "cryptonote_ryo"; // RYO case 22023: return "cryptonote_loki"; // LOKI + case 31014: return "cryptonote_loki"; // Saronite case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } @@ -323,6 +328,8 @@ function Coin(data){ case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube + case 31014: return "cn-heavy/0"; // Saronite + case 34568: return "cn/2"; // Wownero case 38081: return "cn/msr"; // MSR case 48782: return "cn/2"; // Lethean default: return "cn/2"; @@ -340,6 +347,8 @@ function Coin(data){ case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube + case 31014: return "0"; // Saronite + case 34568: return "2"; // Wownero case 38081: return "msr"; // MSR case 48782: return "2"; // Lethean default: return "2"; From b08fded0e974c9fb82db45365e576b8fb8ae4f71 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Oct 2018 19:58:03 +0100 Subject: [PATCH 0153/1496] Moved ex_keys.json to ex_keys.example.json --- ex_keys.json => ex_keys.example.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ex_keys.json => ex_keys.example.json (100%) diff --git a/ex_keys.json b/ex_keys.example.json similarity index 100% rename from ex_keys.json rename to ex_keys.example.json From 71a21ac8649b2062f4cf2fd9ce40b2623cda2303 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Oct 2018 21:27:36 +0100 Subject: [PATCH 0154/1496] Fixed start case without BT --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 70d42a958..ae0c5f536 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -359,9 +359,9 @@ function anchorBlockUpdate() { } function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { - if (!(coin in activeBlockTemplate)) return; if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; if (coin !== "") set_hash_factor(coin, coinHashFactor); // used in miner.selectBestCoin + if (!(coin in activeBlockTemplate)) return; const time_before = Date.now(); From ebf09e15a40e5b2993825ccb3489056c85236521 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Oct 2018 14:25:40 +0100 Subject: [PATCH 0155/1496] Optimized some params and new coins support --- deployment/base.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index c4fdeb132..93cdcfd59 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -191,6 +191,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePort', '18081', 'int', 'Main coin active daemon RPC port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortRYO', '0', 'int', 'Ryo coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLOKI', '0', 'int', 'Loki coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXRN', '0', 'int', 'Saronite coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortWOW', '0', 'int', 'Wownero coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTUBE', '0', 'int', 'BitTube coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXHV', '0', 'int', 'Haven coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortAEON', '0', 'int', 'Aeon coin daemon RPC port or 0'); @@ -224,12 +226,12 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'pplnsFee', '.6', 'float', 'Fee charged for the usage of the PPLNS pool'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'propFee', '.7', 'float', 'Fee charged for the usage of the proportial pool'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'soloFee', '.4', 'float', 'Fee charged for usage of the solo mining pool'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'exchangeMin', '5', 'float', 'Minimum XMR balance for payout to exchange/payment ID'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'exchangeMin', '1', 'float', 'Minimum XMR balance for payout to exchange/payment ID'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'walletMin', '.3', 'float', 'Minimum XMR balance for payout to personal wallet'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'devDonation', '3', 'float', 'Donation to XMR core development'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'poolDevDonation', '3', 'float', 'Donation to pool developer'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'denom', '.000001', 'float', 'Minimum balance that will be paid out to.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'blocksRequired', '60', 'int', 'Blocks required to validate a payout before it''s performed.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'blocksRequired', '30', 'int', 'Blocks required to validate a payout before it''s performed.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'sigDivisor', '1000000000000', 'int', 'Divisor for turning coin into human readable amounts '); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feesForTXN', '10', 'int', 'Amount of XMR that is left from the fees to pay miner fees.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'maxTxnValue', '250', 'int', 'Maximum amount of XMR to send in a single transaction'); @@ -238,7 +240,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'allowBitcoin', 'false', 'bool', 'Allow the pool to auto-payout to BTC via ShapeShift'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'exchangeRate', '0', 'float', 'Current exchange rate'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'bestExchange', 'xmrto', 'string', 'Current best exchange'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'mixIn', '6', 'int', 'Mixin count for coins that support such things.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'mixIn', '10', 'int', 'Mixin count for coins that support such things.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferLength', '480', 'int', 'Number of items to be cached in the stats buffers.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pps', 'enable', 'false', 'bool', 'Enable PPS or not'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'shareMulti', '2', 'int', 'Multiply this times difficulty to set the N in PPLNS'); @@ -272,7 +274,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewEnd', '4', 'float', 'Value at which txn fee amount drops to 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'rpcPasswordEnabled', 'false', 'bool', 'Does the wallet use a RPC password?'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'rpcPasswordPath', '', 'string', 'Path and file for the RPC password file location'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'maxPaymentTxns', '5', 'int', 'Maximum number of transactions in a single payment'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'maxPaymentTxns', '15', 'int', 'Maximum number of transactions in a single payment'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'shareHost', '', 'string', 'Host that receives share information'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingBody', 'Your worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n', 'string', 'Email sent to the miner when their worker stops hashing'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingSubject', 'Status of your worker(s)', 'string', 'Subject of email sent to miner when worker stops hashing'); From ec81cff6f2c41825531953555d63e8e6fa5efbe8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Oct 2018 19:33:37 +0100 Subject: [PATCH 0156/1496] Possible fix for stuck coins --- lib/coins/xmr.js | 6 +++--- lib/pool.js | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 01c71e0aa..195f72dfb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -294,7 +294,7 @@ function Coin(data){ case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR - case 18981: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 11 ? 8 : 1); // Graft + case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube @@ -324,7 +324,7 @@ function Coin(data){ case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR - case 18981: return version >= 11 ? "cn/2" : "cn/1"; // Graft + case 18981: return "cn/2"; // Graft case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube @@ -343,7 +343,7 @@ function Coin(data){ case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR - case 18981: return version >= 11 ? "2" : "1"; // Graft + case 18981: return "2"; // Graft case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube diff --git a/lib/pool.js b/lib/pool.js index ae0c5f536..8727c8730 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -260,7 +260,7 @@ function updateActivePort(coin) { console.log("Changing activePort" + coin + " from " + oldActivePort + " to " + newActivePort); global.config.daemon["activePort" + coin] = newActivePort; } else if ((Date.now() - lastPortErrorTime[newActivePort]) % 60*1000 < 6*1000) { // print every 10th message - console.warn("Avoiding changing recently problem " + "activePort" + coin + " from " + oldActivePort + " to " + newActivePort); + console.warn("Avoiding changing recently problem activePort" + coin + " from " + oldActivePort + " to " + newActivePort); } } } @@ -290,7 +290,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange } else { console.error("Block template request failed for " + activePort + " port."); coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdateReal, 3000, coin, activePort); + setTimeout(templateUpdateReal, 3000, coin, activePort, coinHashFactor, isHashFactorChange); } }); } @@ -310,13 +310,11 @@ function coinHashFactorUpdate(coin, coinHashFactor) { function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; const coinHashFactor = currCoinHashFactor[coin]; - if (activePort && coinHashFactor) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + if ((activePort && coinHashFactor) || !cluster.isMaster) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (activePort !== global.config.daemon["activePort" + coin]) { - console.log("Aborting " + activePort + " last block header request because " + "activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); + console.log("Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); - return; - } - if (err === null) { + } else if (err === null) { const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; From b9ec763f32ac835724e65acf0129c1342d0cd864 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Nov 2018 16:30:42 +0100 Subject: [PATCH 0157/1496] Fixed payment bug --- lib/payment_systems/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index b92ca600b..e51c0d538 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -704,7 +704,6 @@ function makePayments() { async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); - payeeObjects[row.payment_address] = payee; global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(0.3); let custom_threshold = false; @@ -729,6 +728,7 @@ function makePayments() { payee.setFeeAmount(); if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { console.log("[++] " + payee.id + " miner to bulk payment. Amount: " + global.support.coinToDecimal(payee.amount)); + payeeObjects[payee.address] = payee; paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); totalAmount += payee.amount; payeeList.push(payee); From 67e89371e24ed7680da788e5b8bd7ace86bccdfe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Nov 2018 21:46:21 +0100 Subject: [PATCH 0158/1496] Addned new module support --- init.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.js b/init.js index 11e34c0ea..5ad2cc446 100644 --- a/init.js +++ b/init.js @@ -83,6 +83,9 @@ global.mysql.query("SELECT * FROM config").then(function (rows) { case 'altblockManager': require('./lib2/altblockManager.js'); break; + case 'altblockExchange': + require('./lib2/altblockExchange.js'); + break; case 'payments': require('./lib/payments.js'); break; From bd8ec0dee4cf97492091d57529a43909f386f57b Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sat, 3 Nov 2018 00:48:11 +0300 Subject: [PATCH 0159/1496] one payments to same address in one time --- lib/payment_systems/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index e51c0d538..9dc9dd645 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -703,6 +703,7 @@ function makePayments() { let payeeObjects = {}; async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); + if (payeeObjects[row.payment_address]) {return next();} let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(0.3); @@ -825,4 +826,4 @@ if (global.config.payout.timer > 35791) { console.error("Payout timer is too high. Please use a value under 35791 to avoid overflows."); } else { init(); -} \ No newline at end of file +} From 0d9edea05adaced4ba6d6a288600cd226453b755 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Nov 2018 23:20:53 +0100 Subject: [PATCH 0160/1496] Updated pull request --- lib/payment_systems/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 9dc9dd645..7287ce2df 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -703,7 +703,7 @@ function makePayments() { let payeeObjects = {}; async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); - if (payeeObjects[row.payment_address]) {return next();} + if (row.payment_address in payeeObjects) return next(); // avoid doing payment for different pool types at the same time let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(0.3); From e80109262c2abd13fa39bf24b71e7ef3af742d70 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 5 Nov 2018 08:57:20 +0100 Subject: [PATCH 0161/1496] Fixed issue with partial block payments for new PPLNS pools --- lib/blockManager.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 7d4b0cbab..110e5dce4 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -399,7 +399,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un } global.database.setCache('pplns_port_shares', pplns_port_shares); global.database.setCache('pplns_window_time', (firstShareTime - lastShareTime) / 1000); - let totalPayments = 0; global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { if (typeof(rows[0]) === 'undefined' || typeof(rows[0].amt) === 'undefined') { @@ -409,18 +408,25 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un prev_balance_sum = rows[0].amt; block_unlock_callback = unlock_callback; + let totalPayments = 0; Object.keys(paymentData).forEach(function (key) { - paymentData[key].amount = Math.floor((paymentData[key].amount / (blockDiff*global.config.pplns.shareMulti)) * rewardTotal); + totalPayments += paymentData[key].amount; + }); + + const default_window = blockDiff*global.config.pplns.shareMulti; + const pay_window = totalPayments < default_window ? totalPayments : default_window; + + Object.keys(paymentData).forEach(function (key) { + paymentData[key].amount = Math.floor((paymentData[key].amount / pay_window) * rewardTotal); balanceQueue.push(paymentData[key], function () {}); //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); - totalPayments += paymentData[key].amount; }); - console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / block_reward) * 100 + "% (precisely " + totalPayments + " / " + block_reward + ")"); - if (totalPayments != block_reward) { + console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")"); + if (totalPayments != default_window) { global.support.sendEmail(global.config.general.adminEmail, "Block was not payed completely!", - "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / block_reward) * 100 + "% (precisely " + totalPayments + " / " + block_reward + ")" + "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")" ); } }); From 4aa750e4c3f0b6c2353903e858b1eb4cb885a08a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 5 Nov 2018 09:11:04 +0100 Subject: [PATCH 0162/1496] Better reporting of partial blocks --- lib/blockManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 110e5dce4..402629590 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -422,11 +422,13 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); }); - console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")"); + console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); if (totalPayments != default_window) { + console.log("PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")"); global.support.sendEmail(global.config.general.adminEmail, "Block was not payed completely!", - "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")" + "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + + "PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")" ); } }); From 42c82b3498126b41750d516bd4947651708645c1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 5 Nov 2018 10:04:08 +0100 Subject: [PATCH 0163/1496] Adjusted warning message --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 402629590..0080f0549 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -424,9 +424,9 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); if (totalPayments != default_window) { - console.log("PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")"); + console.warn("PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")"); global.support.sendEmail(global.config.general.adminEmail, - "Block was not payed completely!", + "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + "PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")" ); From 400414a3b1c43a31115ac2ae7aad68fe6d04c2bf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Nov 2018 14:41:17 +0100 Subject: [PATCH 0164/1496] Fixed payment reporting --- lib/blockManager.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 0080f0549..ed6bbaa78 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -414,7 +414,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }); const default_window = blockDiff*global.config.pplns.shareMulti; - const pay_window = totalPayments < default_window ? totalPayments : default_window; + const pay_window = totalPayments != default_window ? totalPayments : default_window; Object.keys(paymentData).forEach(function (key) { paymentData[key].amount = Math.floor((paymentData[key].amount / pay_window) * rewardTotal); @@ -422,13 +422,13 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); }); - console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); + console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); if (totalPayments != default_window) { - console.warn("PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")"); + console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); global.support.sendEmail(global.config.general.adminEmail, "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", - "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + - "PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + ")" + "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + + "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" ); } }); From e462d15f9831e8491f3cdc6bceb3ed9079656dd2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Nov 2018 14:59:19 +0100 Subject: [PATCH 0165/1496] Improved float compare --- lib/blockManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index ed6bbaa78..a8cef5f4f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -414,7 +414,8 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }); const default_window = blockDiff*global.config.pplns.shareMulti; - const pay_window = totalPayments != default_window ? totalPayments : default_window; + const is_need_correction = Math.abs(totalPayments - default_window) > 1; + const pay_window = is_need_correction ? totalPayments : default_window; Object.keys(paymentData).forEach(function (key) { paymentData[key].amount = Math.floor((paymentData[key].amount / pay_window) * rewardTotal); @@ -423,7 +424,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }); console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); - if (totalPayments != default_window) { + if (is_need_correction) { console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); global.support.sendEmail(global.config.general.adminEmail, "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", From 51ba74b06a744598b3017a4c465fd84a9fbcae0a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Nov 2018 15:14:32 +0100 Subject: [PATCH 0166/1496] Fixed compare once again --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index a8cef5f4f..842097d85 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -414,7 +414,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }); const default_window = blockDiff*global.config.pplns.shareMulti; - const is_need_correction = Math.abs(totalPayments - default_window) > 1; + const is_need_correction = Math.abs(totalPayments/default_window - 1) > 0.0001; const pay_window = is_need_correction ? totalPayments : default_window; Object.keys(paymentData).forEach(function (key) { From e3f063077ac42aaa0a71099b7c5e640ce30e4b2d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 10:42:24 +0100 Subject: [PATCH 0167/1496] More reliable reward determination via actual wallet incoming tx --- lib/coins/xmr.js | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 195f72dfb..ccb9fd657 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,36 +79,55 @@ function Coin(data){ }; this.getPortBlockHeaderByHash = function(port, blockHash, callback){ - global.support.rpcPortDaemon(port, port == 11898 ? 'getblockheaderbyhash' : 'getblock', {"hash": blockHash}, function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { + if (port != 11898) global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { + if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { + console.error(JSON.stringify(body)); + return callback(true, body); + } + + global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { + if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { + console.error(JSON.stringify(body2)); + return callback(true, body2); + } + body.result.block_header.reward = body2.result.transfer.amount; // Stellite / Lethean / Aeon / Loki / Saronite have composite based miner_tx if (port != 11898 && port != 20189 && port != 48782 && port != 11181 && port != 22023 && port != 31014) { const blockJson = JSON.parse(body.result.json); - body.result.block_header.reward = 0; + body.result.block_header.reward2 = 0; const minerTx = blockJson.miner_tx; for (var i=0; i body.result.block_header.reward) { - body.result.block_header.reward = minerTx.vout[i].amount; + if (minerTx.vout[i].amount > body.result.block_header.reward2) { + body.result.block_header.reward2 = minerTx.vout[i].amount; } } } else if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction const blockJson = JSON.parse(body.result.json); - body.result.block_header.reward = 0; + body.result.block_header.reward2 = 0; const minerTx = blockJson.miner_tx; - body.result.block_header.reward = minerTx.vout[0].amount; + body.result.block_header.reward2 = minerTx.vout[0].amount; + } + + if (body.result.block_header.reward !== body.result.block_header.reward2) { + console.error("Block reward does not match wallet reward!!!"); + return callback(true, body); } return callback(null, body.result.block_header); - } else { + }); + + }); else global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { // TRTL is very special + if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); return callback(true, body); } + return callback(null, body.result.block_header); }); }; From 30e29479f159af12c17fdf8675b3b469126ebafc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 11:12:14 +0100 Subject: [PATCH 0168/1496] Reduced frequency of attempts to atore orphan block --- lib/local_comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 8d7b83153..acc1a18c4 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -386,7 +386,7 @@ function Database(){ } } if (err || typeof(header) === 'undefined' || !header){ - setTimeout(function () { return callback(false) }, 1000); + setTimeout(function () { return callback(false) }, 10*1000); return; } blockDataDecoded.value = header.reward; @@ -436,7 +436,7 @@ function Database(){ } } if (err || typeof(header) === 'undefined' || !header){ - setTimeout(function () { return callback(false) }, 1000); + setTimeout(function () { return callback(false) }, 10*1000); return; } blockDataDecoded.value = header.reward; From f8ad624cf2c5496e3f79e616ad49031576d5d292 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 11:17:59 +0100 Subject: [PATCH 0169/1496] More debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ccb9fd657..85c34890f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -87,7 +87,7 @@ function Coin(data){ global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { - console.error(JSON.stringify(body2)); + console.error(port + ": " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body2); } body.result.block_header.reward = body2.result.transfer.amount; From 01e03e817b25edd02fb0f8c24e1b0358c7280ed7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 11:22:08 +0100 Subject: [PATCH 0170/1496] Returned to prev impl --- lib/coins/xmr.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 85c34890f..70eb0b12b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -85,12 +85,12 @@ function Coin(data){ return callback(true, body); } - global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { + /*global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body2); - } - body.result.block_header.reward = body2.result.transfer.amount; + }*/ + //body.result.block_header.reward = body2.result.transfer.amount; // Stellite / Lethean / Aeon / Loki / Saronite have composite based miner_tx if (port != 11898 && port != 20189 && port != 48782 && port != 11181 && port != 22023 && port != 31014) { @@ -114,13 +114,15 @@ function Coin(data){ body.result.block_header.reward2 = minerTx.vout[0].amount; } + body.result.block_header.reward = body.result.block_header.reward2; + if (body.result.block_header.reward !== body.result.block_header.reward2) { console.error("Block reward does not match wallet reward!!!"); return callback(true, body); } return callback(null, body.result.block_header); - }); + //}); }); else global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { // TRTL is very special if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { From d0f562d140dd89fa4d0f6706b0d3bd2d8d7a5599 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 11:26:35 +0100 Subject: [PATCH 0171/1496] Returned to prev impl --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 70eb0b12b..519b531fb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -104,6 +104,7 @@ function Coin(data){ body.result.block_header.reward2 = minerTx.vout[i].amount; } } + body.result.block_header.reward = body.result.block_header.reward2; } else if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction const blockJson = JSON.parse(body.result.json); @@ -112,15 +113,14 @@ function Coin(data){ const minerTx = blockJson.miner_tx; body.result.block_header.reward2 = minerTx.vout[0].amount; + body.result.block_header.reward = body.result.block_header.reward2; } - body.result.block_header.reward = body.result.block_header.reward2; - - if (body.result.block_header.reward !== body.result.block_header.reward2) { + /*if (body.result.block_header.reward !== body.result.block_header.reward2) { console.error("Block reward does not match wallet reward!!!"); return callback(true, body); } - + */ return callback(null, body.result.block_header); //}); From 97d4322daafa31743441a322fa58528bec967722 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 11:55:56 +0100 Subject: [PATCH 0172/1496] Fixed reward calcs --- lib/coins/xmr.js | 61 ++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 519b531fb..fb58b47cd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,58 +79,47 @@ function Coin(data){ }; this.getPortBlockHeaderByHash = function(port, blockHash, callback){ - if (port != 11898) global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { + // TRTL does not get getblock and XTL / LTHN / AEON have composite tx + if (port == 11898 || port == 20189 || port == 48782 || port == 11181) global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { + if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { + console.error(JSON.stringify(body)); + return callback(true, body); + } + return callback(null, body.result.block_header); + }); else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); return callback(true, body); } - /*global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { + global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body2); - }*/ - //body.result.block_header.reward = body2.result.transfer.amount; - - // Stellite / Lethean / Aeon / Loki / Saronite have composite based miner_tx - if (port != 11898 && port != 20189 && port != 48782 && port != 11181 && port != 22023 && port != 31014) { - const blockJson = JSON.parse(body.result.json); - body.result.block_header.reward2 = 0; - - const minerTx = blockJson.miner_tx; - + } + body.result.block_header.reward = body2.result.transfer.amount; + let reward_check = 0; + const blockJson = JSON.parse(body.result.json); + const minerTx = blockJson.miner_tx; + + if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction + reward_check = minerTx.vout[0].amount; + } else { for (var i=0; i body.result.block_header.reward2) { - body.result.block_header.reward2 = minerTx.vout[i].amount; + if (minerTx.vout[i].amount > reward_check) { + reward_check = minerTx.vout[i].amount; } } - body.result.block_header.reward = body.result.block_header.reward2; - - } else if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction - const blockJson = JSON.parse(body.result.json); - body.result.block_header.reward2 = 0; - - const minerTx = blockJson.miner_tx; - - body.result.block_header.reward2 = minerTx.vout[0].amount; - body.result.block_header.reward = body.result.block_header.reward2; } - /*if (body.result.block_header.reward !== body.result.block_header.reward2) { - console.error("Block reward does not match wallet reward!!!"); + if (body.result.block_header.reward !== reward_check) { + console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); } - */ - return callback(null, body.result.block_header); - //}); - }); else global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { // TRTL is very special - if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { - console.error(JSON.stringify(body)); - return callback(true, body); - } - return callback(null, body.result.block_header); - }); + return callback(null, body.result.block_header); + }); + }); }; this.getBlockHeaderByHash = function(blockHash, callback){ From 7c41272ba1a92d4941374a676008e22fd2922a96 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 12:02:40 +0100 Subject: [PATCH 0173/1496] Some code adjustements to make it more durable --- lib/coins/xmr.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index fb58b47cd..605c0ad85 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -92,12 +92,14 @@ function Coin(data){ return callback(true, body); } + body.result.block_header.reward = 0; + global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); - return callback(true, body2); + return callback(true, body); } - body.result.block_header.reward = body2.result.transfer.amount; + const reward = body2.result.transfer.amount; let reward_check = 0; const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; @@ -112,11 +114,13 @@ function Coin(data){ } } - if (body.result.block_header.reward !== reward_check) { + if (reward !== reward_check) { console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); } + body.result.block_header.reward = reward; + return callback(null, body.result.block_header); }); }); From 3623486cce9a031ffc5af260be251f981e813cd2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 12:29:32 +0100 Subject: [PATCH 0174/1496] Added block reward compute for non out blocks --- lib/coins/xmr.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 605c0ad85..5526c268e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -78,7 +78,7 @@ function Coin(data){ return this.getPortBlockHeaderByID(global.config.daemon.port, blockId, callback); }; - this.getPortBlockHeaderByHash = function(port, blockHash, callback){ + this.getPortBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ // TRTL does not get getblock and XTL / LTHN / AEON have composite tx if (port == 11898 || port == 20189 || port == 48782 || port == 11181) global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { @@ -94,25 +94,26 @@ function Coin(data){ body.result.block_header.reward = 0; - global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { + let reward_check = 0; + const blockJson = JSON.parse(body.result.json); + const minerTx = blockJson.miner_tx; + + if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction + reward_check = minerTx.vout[0].amount; + } else { + for (var i=0; i reward_check) { + reward_check = minerTx.vout[i].amount; + } + } + } + + if (is_our_block) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); } const reward = body2.result.transfer.amount; - let reward_check = 0; - const blockJson = JSON.parse(body.result.json); - const minerTx = blockJson.miner_tx; - - if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction - reward_check = minerTx.vout[0].amount; - } else { - for (var i=0; i reward_check) { - reward_check = minerTx.vout[i].amount; - } - } - } if (reward !== reward_check) { console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); @@ -120,9 +121,12 @@ function Coin(data){ } body.result.block_header.reward = reward; + return callback(null, body.result.block_header); + }); else { + body.result.block_header.reward = reward_check; return callback(null, body.result.block_header); - }); + } }); }; From 5b9c232475e693291617a64b7c32833ed2656c1f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 12:33:16 +0100 Subject: [PATCH 0175/1496] Added block reward compute for non our blocks --- lib/coins/xmr.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5526c268e..96b14ea09 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -78,7 +78,7 @@ function Coin(data){ return this.getPortBlockHeaderByID(global.config.daemon.port, blockId, callback); }; - this.getPortBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ + this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ // TRTL does not get getblock and XTL / LTHN / AEON have composite tx if (port == 11898 || port == 20189 || port == 48782 || port == 11181) global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { @@ -130,6 +130,10 @@ function Coin(data){ }); }; + this.getPortBlockHeaderByHash = function(port, blockHash, callback){ + return this.getPortAnyBlockHeaderByHash(port, blockHash, true, callback); + }; + this.getBlockHeaderByHash = function(blockHash, callback){ return this.getPortBlockHeaderByHash(global.config.daemon.port, blockHash, callback); }; From 431c79c199619521b91ca02216d466d9b3dbb7d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 14:18:16 +0100 Subject: [PATCH 0176/1496] Recuced amount of error messages --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 96b14ea09..c0bd95afa 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -110,7 +110,7 @@ function Coin(data){ if (is_our_block) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { - console.error(port + ": " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); + console.error(port + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body); } const reward = body2.result.transfer.amount; From c3849802eac9fd790a050dbd51e7dfe536be542d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 14:45:33 +0100 Subject: [PATCH 0177/1496] Added more reliable block check --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c0bd95afa..f8ff3d882 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -87,7 +87,7 @@ function Coin(data){ } return callback(null, body.result.block_header); }); else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { - if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { + if (typeof(body) === 'undefined' || !body.hasOwnProperty('result') || !body.result.hasOwnProperty('get_transfer_by_txid')) { console.error(JSON.stringify(body)); return callback(true, body); } From 9983ce4a439160f7bfbef69c062d5c0ef4349003 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 14:46:44 +0100 Subject: [PATCH 0178/1496] Added more reliable block check --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f8ff3d882..919f48c2e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -87,7 +87,7 @@ function Coin(data){ } return callback(null, body.result.block_header); }); else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { - if (typeof(body) === 'undefined' || !body.hasOwnProperty('result') || !body.result.hasOwnProperty('get_transfer_by_txid')) { + if (typeof(body) === 'undefined' || !body.hasOwnProperty('result') || !body.result.hasOwnProperty('miner_tx_hash')) { console.error(JSON.stringify(body)); return callback(true, body); } From ac482b32f44cd413bea98d3d1d51c9836d35bba3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 14:48:37 +0100 Subject: [PATCH 0179/1496] Added more reliable block check --- lib/coins/xmr.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 919f48c2e..55562f37e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,13 +79,15 @@ function Coin(data){ }; this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ - // TRTL does not get getblock and XTL / LTHN / AEON have composite tx - if (port == 11898 || port == 20189 || port == 48782 || port == 11181) global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { - if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { - console.error(JSON.stringify(body)); - return callback(true, body); - } - return callback(null, body.result.block_header); + // TRTL does not get getblock and XTL / LTHN / AEON have composite tx, GRFT does not have miner_tx_hash + if (port == 11898 || port == 20189 || port == 48782 || port == 11181 || port == 18981) { + global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { + if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { + console.error(JSON.stringify(body)); + return callback(true, body); + } + return callback(null, body.result.block_header); + }); }); else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result') || !body.result.hasOwnProperty('miner_tx_hash')) { console.error(JSON.stringify(body)); From d4c238abe858114c3ef41d373a235a03c3a83037 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 14:49:23 +0100 Subject: [PATCH 0180/1496] Added more reliable block check --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 55562f37e..1054d3524 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -88,7 +88,7 @@ function Coin(data){ } return callback(null, body.result.block_header); }); - }); else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { + } else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result') || !body.result.hasOwnProperty('miner_tx_hash')) { console.error(JSON.stringify(body)); return callback(true, body); From a2461df11b085c9558ccdd3e61ed3b802e3ec42d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Nov 2018 14:56:35 +0100 Subject: [PATCH 0181/1496] More intellegent miner_tx_hash check --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1054d3524..3623bf253 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -79,8 +79,8 @@ function Coin(data){ }; this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ - // TRTL does not get getblock and XTL / LTHN / AEON have composite tx, GRFT does not have miner_tx_hash - if (port == 11898 || port == 20189 || port == 48782 || port == 11181 || port == 18981) { + // TRTL does not get getblock and XTL / LTHN / AEON have composite tx + if (port == 11898 || port == 20189 || port == 48782 || port == 11181) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); @@ -89,7 +89,7 @@ function Coin(data){ return callback(null, body.result.block_header); }); } else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { - if (typeof(body) === 'undefined' || !body.hasOwnProperty('result') || !body.result.hasOwnProperty('miner_tx_hash')) { + if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); return callback(true, body); } @@ -110,7 +110,7 @@ function Coin(data){ } } - if (is_our_block) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { + if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body); From 866998f266c86676bb6298e7d706f58a49e2adb0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 13 Nov 2018 15:10:00 +0100 Subject: [PATCH 0182/1496] Added XRN fork support --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3623bf253..5edf491c1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -322,7 +322,7 @@ function Coin(data){ case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - case 31014: return multiHashing.cryptonight_heavy(convertedBlob, 0); // Saronite + case 31014: return multiHashing.cryptonight_heavy(convertedBlob, convertedBlob[0] > 9 ? 1 : 0); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 8); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean @@ -352,7 +352,7 @@ function Coin(data){ case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube - case 31014: return "cn-heavy/0"; // Saronite + case 31014: return version > 9 ? "cn-heavy/xhv" : "cn-heavy/0"; // Saronite case 34568: return "cn/2"; // Wownero case 38081: return "cn/msr"; // MSR case 48782: return "cn/2"; // Lethean @@ -371,7 +371,7 @@ function Coin(data){ case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube - case 31014: return "0"; // Saronite + case 31014: return version > 9 ? "xhv" : "0"; // Saronite case 34568: return "2"; // Wownero case 38081: return "msr"; // MSR case 48782: return "2"; // Lethean From b5cfdde69de5580031299cee2aa8f52c5035a182 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Nov 2018 09:01:43 +0100 Subject: [PATCH 0183/1496] Allow dump for paymentid miners --- manage_scripts/dump_shares.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manage_scripts/dump_shares.js b/manage_scripts/dump_shares.js index 0f0cb4e50..401371d0d 100644 --- a/manage_scripts/dump_shares.js +++ b/manage_scripts/dump_shares.js @@ -9,12 +9,19 @@ if (!argv.user) { } const user = argv.user; +let paymentid; +if (argv.paymentid) paymentid = argv.paymentid; + let worker; if (argv.worker) worker = argv.worker; let depth = 10; if (argv.depth) depth = argv.depth; +console.log("Dumping shares for " + user + " user"); +if (paymentid) console.log("Dumping shares for " + paymentid + " paymentid"); +if (worker) console.log("Dumping shares for " + worker + " worker"); + require("../init_mini.js").init(function() { global.coinFuncs.getLastBlockHeader(function (err, body) { @@ -30,7 +37,7 @@ require("../init_mini.js").init(function() { for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let shareData = global.protos.Share.decode(data); - if (shareData.paymentAddress === user && (!worker || shareData.identifier === worker)) { + if (shareData.paymentAddress === user && (!paymentid || shareData.paymentID === paymentid) && (!worker || shareData.identifier === worker)) { var d = new Date(shareData.timestamp); console.log(d.toString() + ": " + JSON.stringify(shareData)) } From 7490bbe1a9f9c5509cd95d2fa17e4cbe05106780 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Nov 2018 10:00:54 +0100 Subject: [PATCH 0184/1496] Fixed case when daemon are off during pool start --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8727c8730..b8c82dc51 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -310,7 +310,7 @@ function coinHashFactorUpdate(coin, coinHashFactor) { function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; const coinHashFactor = currCoinHashFactor[coin]; - if ((activePort && coinHashFactor) || !cluster.isMaster) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + if (activePort && coinHashFactor) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (activePort !== global.config.daemon["activePort" + coin]) { console.log("Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); @@ -328,7 +328,7 @@ function templateUpdate(coin, repeating) { coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } - }); else { + }); else if (cluster.isMaster) { coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } From 43c3e43db99093f7ce9c3969beb0c682650210a3 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Mon, 26 Nov 2018 11:53:58 +0300 Subject: [PATCH 0185/1496] Little more strict test --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 842097d85..6009c4d16 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -545,7 +545,7 @@ function blockUnlocker() { console.error("Can't get block with " + block.height + " height"); return; } - if (body.hash !== block.hash) { + if (body.hash !== block.hash && topBlockHeight - block.height > 5) { global.database.invalidateBlock(block.height); global.mysql.query("UPDATE block_log SET orphan = true WHERE hex = ?", [block.hash]); blockIDCache.splice(blockIDCache.indexOf(block.height)); From 43662a028b4816e6614c5d71a40d34c7bab785b5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Nov 2018 11:01:33 +0100 Subject: [PATCH 0186/1496] Added email_disable.js script --- user_scripts/email_disable.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 user_scripts/email_disable.js diff --git a/user_scripts/email_disable.js b/user_scripts/email_disable.js new file mode 100644 index 000000000..39d7ed270 --- /dev/null +++ b/user_scripts/email_disable.js @@ -0,0 +1,35 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.user) { + console.error("Please specify user address to set"); + process.exit(1); +} + +const user = argv.user; + +require("../init_mini.js").init(function() { + async.waterfall([ + function (callback) { + global.mysql.query("SELECT * FROM users WHERE username = ?", [user]).then(function (rows) { + if (rows.length != 1) { + console.error("User password and thus email is not yet set"); + process.exit(1); + } + callback(); + }); + }, + function (callback) { + global.mysql.query("UPDATE users SET enable_email = '0' WHERE username = ?", [user]).then(function (rows) { + console.log("UPDATE users SET enable_email = '0' WHERE username = " + user); + callback(); + }); + }, + function (callback) { + console.log("Done."); + process.exit(0); + } + ]); +}); From 561602a815524a3f495d50f88f1ae2197a719a45 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 4 Dec 2018 09:43:04 +0100 Subject: [PATCH 0187/1496] Post Saronite fork and avoid spamming bad tx for orthan blocks --- lib/coins/xmr.js | 6 +++--- lib/local_comms.js | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5edf491c1..e174184ca 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -322,7 +322,7 @@ function Coin(data){ case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - case 31014: return multiHashing.cryptonight_heavy(convertedBlob, convertedBlob[0] > 9 ? 1 : 0); // Saronite + case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 8); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean @@ -352,7 +352,7 @@ function Coin(data){ case 20189: return "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube - case 31014: return version > 9 ? "cn-heavy/xhv" : "cn-heavy/0"; // Saronite + case 31014: return "cn-heavy/xhv"; // Saronite case 34568: return "cn/2"; // Wownero case 38081: return "cn/msr"; // MSR case 48782: return "cn/2"; // Lethean @@ -371,7 +371,7 @@ function Coin(data){ case 20189: return "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube - case 31014: return version > 9 ? "xhv" : "0"; // Saronite + case 31014: return "xhv"; // Saronite case 34568: return "2"; // Wownero case 38081: return "msr"; // MSR case 48782: return "2"; // Lethean diff --git a/lib/local_comms.js b/lib/local_comms.js index acc1a18c4..893f57aac 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -419,10 +419,14 @@ function Database(){ let blockDataDecoded = global.protos.AltBlock.decode(blockData); global.coinFuncs.getPortBlockHeaderByHash(blockDataDecoded.port, blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan - if (err && header && header.error && typeof(header.error.message) === 'string' && (header.error.message.indexOf("can't get block by hash") > -1 || header.error.message.indexOf("Requested hash wasn't found in main blockchain") > -1)) { + if (err && header && header.error && typeof(header.error.message) === 'string' && ( + header.error.message.indexOf("can't get block by hash") > -1 || + header.error.message.indexOf("Transaction not found") > -1 || + header.error.message.indexOf("") > -1 + )) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { - if (time_now - orphanBlocks[blockDataDecoded.hash] > 5*60*1000) { + if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); err = false; header = {}; @@ -436,7 +440,7 @@ function Database(){ } } if (err || typeof(header) === 'undefined' || !header){ - setTimeout(function () { return callback(false) }, 10*1000); + setTimeout(function () { return callback(false) }, 30*1000); return; } blockDataDecoded.value = header.reward; From b63dbd07ca934dbc47738769c077aa7c8f5831a2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 4 Dec 2018 11:52:55 +0100 Subject: [PATCH 0188/1496] Fixed orphan block handling --- lib/local_comms.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 893f57aac..59bcf7864 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -368,11 +368,14 @@ function Database(){ let blockDataDecoded = global.protos.Block.decode(blockData); global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan - if (err && header && header.error && typeof(header.error.message) === 'string' && - (header.error.message.indexOf("can't get block by hash") > -1 || header.error.message.indexOf("hash wasn't found") > -1)) { + if (err && header && header.error && typeof(header.error.message) === 'string' && ( + header.error.message.indexOf("can't get block by hash") > -1 || + header.error.message.indexOf("hash wasn't found") > -1 || + header.error.message.indexOf("Transaction not found") > -1 + )) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { - if (time_now - orphanBlocks[blockDataDecoded.hash] > 5*60*1000) { + if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); err = false; header = {}; @@ -386,7 +389,7 @@ function Database(){ } } if (err || typeof(header) === 'undefined' || !header){ - setTimeout(function () { return callback(false) }, 10*1000); + setTimeout(function () { return callback(false) }, 30*1000); return; } blockDataDecoded.value = header.reward; @@ -421,8 +424,7 @@ function Database(){ // after 5 minutes of submit attempts finally cosider this block as orphan if (err && header && header.error && typeof(header.error.message) === 'string' && ( header.error.message.indexOf("can't get block by hash") > -1 || - header.error.message.indexOf("Transaction not found") > -1 || - header.error.message.indexOf("") > -1 + header.error.message.indexOf("Requested hash wasn't found in main blockchain") > -1 )) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { From 8a471825f64c5f9d41c82416a389c537617ba9ac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 4 Dec 2018 12:42:43 +0100 Subject: [PATCH 0189/1496] Improved orphan block detection --- lib/local_comms.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 59bcf7864..ad9c9e80f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -368,11 +368,13 @@ function Database(){ let blockDataDecoded = global.protos.Block.decode(blockData); global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan - if (err && header && header.error && typeof(header.error.message) === 'string' && ( + const is_orphan1 = header && header.orphan_status && header.orphan_status === true; + const is_orphan2 = err && header && header.error && typeof(header.error.message) === 'string' && ( header.error.message.indexOf("can't get block by hash") > -1 || header.error.message.indexOf("hash wasn't found") > -1 || header.error.message.indexOf("Transaction not found") > -1 - )) { + ); + if (is_orphan1 || is_orphan2) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { From 28c01252c3ab6b6156e2daa961bbbbc84aa8e6ca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 4 Dec 2018 12:52:15 +0100 Subject: [PATCH 0190/1496] Fixed block header stuff --- lib/coins/xmr.js | 2 +- lib/local_comms.js | 40 +++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e174184ca..46bbc3cbd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -113,7 +113,7 @@ function Coin(data){ if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); - return callback(true, body); + return callback(true, body.result.block_header); } const reward = body2.result.transfer.amount; diff --git a/lib/local_comms.js b/lib/local_comms.js index ad9c9e80f..2efae6849 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -368,26 +368,28 @@ function Database(){ let blockDataDecoded = global.protos.Block.decode(blockData); global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan - const is_orphan1 = header && header.orphan_status && header.orphan_status === true; - const is_orphan2 = err && header && header.error && typeof(header.error.message) === 'string' && ( - header.error.message.indexOf("can't get block by hash") > -1 || - header.error.message.indexOf("hash wasn't found") > -1 || - header.error.message.indexOf("Transaction not found") > -1 - ); - if (is_orphan1 || is_orphan2) { - let time_now = Date.now(); - if (blockDataDecoded.hash in orphanBlocks) { - if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { - console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); - err = false; - header = {}; - header.reward = 0; - blockDataDecoded.valid = false; - blockDataDecoded.unlocked = true; + if (err && header) { + const is_orphan1 = header.orphan_status && header.orphan_status === true; + const is_orphan2 = header.error && typeof(header.error.message) === 'string' && ( + header.error.message.indexOf("can't get block by hash") > -1 || + header.error.message.indexOf("hash wasn't found") > -1 || + header.error.message.indexOf("Transaction not found") > -1 + ); + if (is_orphan1 || is_orphan2) { + let time_now = Date.now(); + if (blockDataDecoded.hash in orphanBlocks) { + if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { + console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); + err = false; + header = {}; + header.reward = 0; + blockDataDecoded.valid = false; + blockDataDecoded.unlocked = true; + } + } else { + console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); + orphanBlocks[blockDataDecoded.hash] = time_now; } - } else { - console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); - orphanBlocks[blockDataDecoded.hash] = time_now; } } if (err || typeof(header) === 'undefined' || !header){ From d1c647d2b0996782f0646361479768f24c13ab35 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 4 Dec 2018 12:58:38 +0100 Subject: [PATCH 0191/1496] Fixed block header stuff --- lib/local_comms.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 2efae6849..771e78239 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -426,23 +426,27 @@ function Database(){ let blockDataDecoded = global.protos.AltBlock.decode(blockData); global.coinFuncs.getPortBlockHeaderByHash(blockDataDecoded.port, blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan - if (err && header && header.error && typeof(header.error.message) === 'string' && ( + if (err && header) { + const is_orphan1 = header.orphan_status && header.orphan_status === true; + const is_orphan2 = header.error && typeof(header.error.message) === 'string' && ( header.error.message.indexOf("can't get block by hash") > -1 || header.error.message.indexOf("Requested hash wasn't found in main blockchain") > -1 - )) { - let time_now = Date.now(); - if (blockDataDecoded.hash in orphanBlocks) { - if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { - console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); - err = false; - header = {}; - header.reward = 0; - blockDataDecoded.valid = false; - blockDataDecoded.unlocked = true; + ); + if (is_orphan1 || is_orphan2) { + let time_now = Date.now(); + if (blockDataDecoded.hash in orphanBlocks) { + if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { + console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); + err = false; + header = {}; + header.reward = 0; + blockDataDecoded.valid = false; + blockDataDecoded.unlocked = true; + } + } else { + console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); + orphanBlocks[blockDataDecoded.hash] = time_now; } - } else { - console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); - orphanBlocks[blockDataDecoded.hash] = time_now; } } if (err || typeof(header) === 'undefined' || !header){ From 1c8ef02daac59e74f186065bbaa9a02fd2f8dde3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 10 Dec 2018 11:30:06 +0100 Subject: [PATCH 0192/1496] Fixed situation with dead daemon --- lib/worker.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index fb8adfb23..a5651370e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -715,11 +715,19 @@ function updateBlockHeader() { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err !== null) { console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); - body.difficulty = prev_network_info[port].difficulty; - body.hash = prev_network_info[port].hash; - body.height = prev_network_info[port].height; - body.reward = prev_network_info[port].value; - body.timestamp = prev_network_info[port].ts; + if (port in prev_network_info) { + body.difficulty = prev_network_info[port].difficulty; + body.hash = prev_network_info[port].hash; + body.height = prev_network_info[port].height; + body.reward = prev_network_info[port].value; + body.timestamp = prev_network_info[port].ts; + } else { + body.difficulty = 0; + body.hash = 0; + body.height = 0; + body.reward = 0; + body.timestamp = 0; + } } prev_network_info[port] = info[port] = { difficulty: body.difficulty, From c6a6b54d4f03e9d543771225ea699a88ed0a6a19 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sat, 5 Jan 2019 01:44:49 +0300 Subject: [PATCH 0193/1496] Avoid doing payment for different pool types at the same time for all wallet types --- lib/payment_systems/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 7287ce2df..d248b442c 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -703,7 +703,7 @@ function makePayments() { let payeeObjects = {}; async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); - if (row.payment_address in payeeObjects) return next(); // avoid doing payment for different pool types at the same time + if ((row.payment_address+row.payment_id) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(0.3); @@ -727,9 +727,9 @@ function makePayments() { } if (payee.amount >= threshold) { payee.setFeeAmount(); + payeeObjects[payee.address+payee.paymentID] = payee; if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { console.log("[++] " + payee.id + " miner to bulk payment. Amount: " + global.support.coinToDecimal(payee.amount)); - payeeObjects[payee.address] = payee; paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); totalAmount += payee.amount; payeeList.push(payee); From cbe1e60fcc1da0d4386b9394f2f623de71175376 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sat, 5 Jan 2019 03:01:57 +0300 Subject: [PATCH 0194/1496] fix null paymentID --- lib/payment_systems/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index d248b442c..74c8d9114 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -703,7 +703,7 @@ function makePayments() { let payeeObjects = {}; async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); - if ((row.payment_address+row.payment_id) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time + if ((row.payment_address+(row.payment_id?row.payment_id:'')) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(0.3); @@ -727,7 +727,7 @@ function makePayments() { } if (payee.amount >= threshold) { payee.setFeeAmount(); - payeeObjects[payee.address+payee.paymentID] = payee; + payeeObjects[payee.address+(payee.paymentID?payee.paymentID:'')] = payee; if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { console.log("[++] " + payee.id + " miner to bulk payment. Amount: " + global.support.coinToDecimal(payee.amount)); paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); From 81a79f88f95197bde00c7c641f1b0bb6a8f95d0d Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Mon, 7 Jan 2019 15:52:00 +0300 Subject: [PATCH 0195/1496] Get real diff instead diff of last block For better calculation current effort and show real network hash rate It doesn't work with forknote I add "rpcResult.result ? rpcResult.result.difficulty : body.difficulty" --- lib/worker.js | 71 +++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index a5651370e..e1e270af1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -712,42 +712,45 @@ function updateBlockHeader() { for (let port in min_block_rewards) ++ left; for (let port in min_block_rewards) { + console.log("start " + left) global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ - if (err !== null) { - console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); - if (port in prev_network_info) { - body.difficulty = prev_network_info[port].difficulty; - body.hash = prev_network_info[port].hash; - body.height = prev_network_info[port].height; - body.reward = prev_network_info[port].value; - body.timestamp = prev_network_info[port].ts; - } else { - body.difficulty = 0; - body.hash = 0; - body.height = 0; - body.reward = 0; - body.timestamp = 0; + global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { + if (err !== null) { + console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); + if (port in prev_network_info) { + body.difficulty = prev_network_info[port].difficulty; + body.hash = prev_network_info[port].hash; + body.height = prev_network_info[port].height; + body.reward = prev_network_info[port].value; + body.timestamp = prev_network_info[port].ts; + } else { + body.difficulty = 0; + body.hash = 0; + body.height = 0; + body.reward = 0; + body.timestamp = 0; + } } - } - prev_network_info[port] = info[port] = { - difficulty: body.difficulty, - hash: body.hash, - height: body.height, - value: body.reward, - ts: body.timestamp, - }; - if (port == global.config.daemon.activePort) { - info.difficulty = body.difficulty; - info.hash = body.hash; - info.height = body.height; - info.value = body.reward; - info.ts = body.timestamp; - } - if (-- left === 0) { - info.main_height = prev_network_info[global.config.daemon.port].height; - global.database.setCache('networkBlockInfo', info); - } - }, true); + prev_network_info[port] = info[port] = { + difficulty: body.difficulty, + hash: body.hash, + height: body.height, + value: body.reward, + ts: body.timestamp, + }; + if (port == global.config.daemon.activePort) { + info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; + info.hash = body.hash; + info.height = body.height; + info.value = body.reward; + info.ts = body.timestamp; + } + if (-- left === 0) { + info.main_height = prev_network_info[global.config.daemon.port].height; + global.database.setCache('networkBlockInfo', info); + } + }) + }, true); } } From 297c02aaef1dc569387cd1041ec1c2eacc10dbe2 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Mon, 7 Jan 2019 15:54:27 +0300 Subject: [PATCH 0196/1496] delete log --- lib/worker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index e1e270af1..c0184ad69 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -712,7 +712,6 @@ function updateBlockHeader() { for (let port in min_block_rewards) ++ left; for (let port in min_block_rewards) { - console.log("start " + left) global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { if (err !== null) { From 054f3e17a8f1296c2c3919267d20ef19e2ee8f47 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 10 Jan 2019 10:32:28 -0800 Subject: [PATCH 0197/1496] Added new HitBTC exchange address --- lib/coins/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 46bbc3cbd..d07981d69 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -45,7 +45,8 @@ function Coin(data){ "45rTtwU6mHqSEMduDm5EvUEmFNx2Z6gQhGBJGqXAPHGyFm9qRfZFDNgDm3drL6wLTVHfVhbfHpCtwKVvDLbQDMH88jx2N6w", // ? "4ALcw9nTAStZSshoWVUJakZ6tLwTDhixhQUQNJkCn4t3fG3MMK19WZM44HnQRvjqmz4LkkA8t565v7iBwQXx2r34HNroSAZ", // Cryptopia.co.nz "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm", // Bitfinex - "41xeYWWKwtSiHju5AdyF8y5xeptuRY3j5X1XYHuB1g6ke4eRexA1iygjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3gJqjM9", // HitBTC + "41xeYWWKwtSiHju5AdyF8y5xeptuRY3j5X1XYHuB1g6ke4eRexA1iygjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3gJqjM9", // HitBTC 1 + "43Kg3mcpvaDhHpv8C4UWf7Kw2DAexn2NoRMqqM5cpAtuRgkedDZWjBQjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3dx22mZ", // HitBTC 2 "44rouyxW44oMc1yTGXBUsL6qo9AWWeHETFiimWC3TMQEizSqqZZPnw1UXCaJrCtUC9QT25L5MZvkoGKRxZttvbkmFXA3TMG" // BTC-Alpha ]; // These are addresses that MUST have a paymentID to perform logins with. From fee16d555552070f9b0fb9750e6a3e76e5866447 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Thu, 10 Jan 2019 23:41:34 +0300 Subject: [PATCH 0198/1496] reorg --- lib/payment_systems/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 74c8d9114..5b3ce59b7 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -703,7 +703,7 @@ function makePayments() { let payeeObjects = {}; async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); - if ((row.payment_address+(row.payment_id?row.payment_id:'')) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time + if ((row.payment_address+(row.payment_id?'.'+row.payment_id:'')) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(0.3); @@ -727,7 +727,7 @@ function makePayments() { } if (payee.amount >= threshold) { payee.setFeeAmount(); - payeeObjects[payee.address+(payee.paymentID?payee.paymentID:'')] = payee; + payeeObjects[payee.id)] = payee; if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { console.log("[++] " + payee.id + " miner to bulk payment. Amount: " + global.support.coinToDecimal(payee.amount)); paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); From 708c96e56e05753145ee787e1909b971a947629c Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Thu, 10 Jan 2019 23:45:22 +0300 Subject: [PATCH 0199/1496] more spaces and beauty :) --- lib/payment_systems/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 5b3ce59b7..17e01902c 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -703,7 +703,7 @@ function makePayments() { let payeeObjects = {}; async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); - if ((row.payment_address+(row.payment_id?'.'+row.payment_id:'')) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time + if ((row.payment_address + (row.payment_id ? ('.' + row.payment_id) : '')) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(0.3); From 4a9ec841508361040aa6d137dd8757815036010d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 10 Jan 2019 12:47:52 -0800 Subject: [PATCH 0200/1496] Fixed typo --- lib/payment_systems/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 17e01902c..72488545e 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -727,7 +727,7 @@ function makePayments() { } if (payee.amount >= threshold) { payee.setFeeAmount(); - payeeObjects[payee.id)] = payee; + payeeObjects[payee.id] = payee; if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { console.log("[++] " + payee.id + " miner to bulk payment. Amount: " + global.support.coinToDecimal(payee.amount)); paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); From 0637abba4316ac36c739e7af81baf58c37836790 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 Jan 2019 10:19:22 -0800 Subject: [PATCH 0201/1496] Added cn-half support --- lib/coins/xmr.js | 17 +++++++++-------- package.json | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d07981d69..ae97a3b5d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -276,7 +276,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "cn": 1, "cn/msr": 1.9 }; + return { "cn": 1, "cn/half": 1.9 }; } this.convertAlgosToCoinPerf = function(algos_perf) { @@ -291,7 +291,8 @@ function Coin(data){ if ("cn/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtl"]; else coin_perf["XTL"] = "cn" in algos_perf ? algos_perf["cn"] : coin_perf[""]; - if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; + if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; + else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; else if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; @@ -320,12 +321,12 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft - case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite + case 20189: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 5 ? 9 : 3); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 8); // Wownero - case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR + case 38081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 8 ? 9 : 4); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); } @@ -350,12 +351,12 @@ function Coin(data){ case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR case 18981: return "cn/2"; // Graft - case 20189: return "cn/xtl"; // Stellite + case 20189: return version >= 5 ? "cn/half" : "cn/xtl"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 31014: return "cn-heavy/xhv"; // Saronite case 34568: return "cn/2"; // Wownero - case 38081: return "cn/msr"; // MSR + case 38081: return version >= 8 ? "cn/half" : "cn/msr"; // MSR case 48782: return "cn/2"; // Lethean default: return "cn/2"; } @@ -369,12 +370,12 @@ function Coin(data){ case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR case 18981: return "2"; // Graft - case 20189: return "xtl"; // Stellite + case 20189: return version >= 5 ? "half" : "xtl"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube case 31014: return "xhv"; // Saronite case 34568: return "2"; // Wownero - case 38081: return "msr"; // MSR + case 38081: return version >= 8 ? "half" : "msr"; // MSR case 48782: return "2"; // Lethean default: return "2"; } diff --git a/package.json b/package.json index d0968adab..26a12021c 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "nodejs-pool", "version": "0.0.1", - "description": "Fairly simple universal cryptonote pool", + "description": "IMproved version of Snipa22 nodejs-pool", "main": "init.js", "repository": { "type": "git", - "url": "https://github.com/Snipa22/node-crypto-pool.git" + "url": "https://github.com/MoneroOcean/nodejs-pool.git" }, "author": "Multiple", "license": "MIT", @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v3.0.5" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v4.0.0" } } From 642dd7b119981a256ad584f5721c7500859190da Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 Jan 2019 12:30:50 -0800 Subject: [PATCH 0202/1496] Fixed race condition --- manage_scripts/altblock_revalidate.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/manage_scripts/altblock_revalidate.js b/manage_scripts/altblock_revalidate.js index 42ec2f533..576eac5bc 100644 --- a/manage_scripts/altblock_revalidate.js +++ b/manage_scripts/altblock_revalidate.js @@ -11,10 +11,12 @@ const hash = argv.hash; require("../init_mini.js").init(function() { let txn = global.database.env.beginTxn(); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + let is_found = true; for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); if (blockData.hash === hash) { + is_found = true; global.coinFuncs.getPortBlockHeaderByHash(blockData.port, hash, (err, body) => { if (err !== null) { console.log("Altblock with " + hash + " hash still has invalid hash for " + blockData.port + " port! Exiting!"); @@ -33,8 +35,10 @@ require("../init_mini.js").init(function() { } }); } - cursor.close(); - txn.commit(); - console.log("Not found altblock with " + hash + " hash"); - process.exit(1); + if (!is_found) { + cursor.close(); + txn.commit(); + console.log("Not found altblock with " + hash + " hash"); + process.exit(1); + } }); From fe74911c153fab26284a51167ed98a38016d1981 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 Jan 2019 09:28:19 -0800 Subject: [PATCH 0203/1496] Updated hashing package with minor build fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 26a12021c..4bdaa8f57 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v4.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v4.0.1" } } From 4e4325fc9bbdffcdffebb91d125920f824cd2f43 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 16 Jan 2019 09:49:28 -0800 Subject: [PATCH 0204/1496] Fixed XTL perf --- lib/coins/xmr.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ae97a3b5d..93edbb5ec 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -288,10 +288,7 @@ function Coin(data){ if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1 or cn/2 hashrate"; - if ("cn/xtl" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtl"]; - else coin_perf["XTL"] = "cn" in algos_perf ? algos_perf["cn"] : coin_perf[""]; - - if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; + if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; else if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; @@ -321,7 +318,7 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft - case 20189: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 5 ? 9 : 3); // Stellite + case 20189: return multiHashing.cryptonight(9); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite @@ -351,7 +348,7 @@ function Coin(data){ case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR case 18981: return "cn/2"; // Graft - case 20189: return version >= 5 ? "cn/half" : "cn/xtl"; // Stellite + case 20189: return "cn/half"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 31014: return "cn-heavy/xhv"; // Saronite @@ -370,7 +367,7 @@ function Coin(data){ case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR case 18981: return "2"; // Graft - case 20189: return version >= 5 ? "half" : "xtl"; // Stellite + case 20189: return "half"; // Stellite case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube case 31014: return "xhv"; // Saronite From e8551d723790dfa9f58ce6e3674c08e39a9957d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 16 Jan 2019 10:03:29 -0800 Subject: [PATCH 0205/1496] Fixed XTL perf --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 93edbb5ec..1891ee11d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -318,7 +318,7 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft - case 20189: return multiHashing.cryptonight(9); // Stellite + case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite From ece343e1202d5b330b81ef3c44ebf2b4ab8ea8f2 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Wed, 16 Jan 2019 21:58:19 +0300 Subject: [PATCH 0206/1496] For detecting xtl-stak or trtl-stak and etc --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1891ee11d..4bfe37486 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -9,8 +9,8 @@ const process = require('process'); let hexChars = new RegExp("[0-9a-f]+"); const reXMRig = /XMRig(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\./; // 2.8.0 -const reXMRSTAK = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)/; // 2.5.0 -const reXMRSTAK2 = /xmr-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 +const reXMRSTAK = /\w+-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)/; // 2.5.0 +const reXMRSTAK2 = /\w+-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 From 00bc192a01104db2bde6b1d7846ff00006208ebd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 16 Jan 2019 11:16:33 -0800 Subject: [PATCH 0207/1496] Fixed syntax bug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b8c82dc51..56f2f8372 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1436,7 +1436,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } let nonce_test = `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; if (nonce_test in job.submissions) { - console.warn(threadName + 'Duplicate proxy share with ' + params.nonce_test.toString() + ' nonce from ' + miner.logString); + console.warn(threadName + 'Duplicate proxy share with ' + nonce_test.toString() + ' nonce from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); global.database.storeInvalidShare(miner.invalidShareProto); From 17a6ebdef717f2730ab561d2411ee51916b819bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 23 Jan 2019 18:35:42 -0800 Subject: [PATCH 0208/1496] Added cn-pico algo support --- lib/coins/xmr.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1891ee11d..371967815 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -313,7 +313,7 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, port) { switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon - case 11898: return multiHashing.cryptonight_light(convertedBlob, 1); // TRTL + case 11898: return convertedBlob[0] >= 5 ? multiHashing.cryptonight_pico(convertedBlob, 0) : multiHashing.cryptonight_light(convertedBlob, 1); // TRTL case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR @@ -343,7 +343,7 @@ function Coin(data){ this.algoShortTypeStr = function(port, version) { switch (port) { case 11181: return "cn-lite/1"; // Aeon - case 11898: return "cn-lite/1"; // TRTL + case 11898: return version >= 5 ? "cn-pico/trtl" : "cn-lite/1"; // TRTL case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR @@ -362,7 +362,7 @@ function Coin(data){ this.variantValue = function(port, version) { switch (port) { case 11181: return "1"; // Aeon - case 11898: return "1"; // TRTL + case 11898: return version >= 5 ? "trtl" : "1"; // TRTL case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR diff --git a/package.json b/package.json index 4bdaa8f57..d72d8fc06 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v4.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v5.0.0" } } From 547c1c3a108c0143675199673c70e07915611ffd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Jan 2019 07:45:47 -0800 Subject: [PATCH 0209/1496] Removed MSR fork detection --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b230d2315..d8bc19950 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -323,7 +323,7 @@ function Coin(data){ case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 8); // Wownero - case 38081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 8 ? 9 : 4); // MSR + case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); } @@ -353,7 +353,7 @@ function Coin(data){ case 24182: return "cn-heavy/tube"; // BitTube case 31014: return "cn-heavy/xhv"; // Saronite case 34568: return "cn/2"; // Wownero - case 38081: return version >= 8 ? "cn/half" : "cn/msr"; // MSR + case 38081: return "cn/half"; // MSR case 48782: return "cn/2"; // Lethean default: return "cn/2"; } @@ -372,7 +372,7 @@ function Coin(data){ case 24182: return "tube"; // BitTube case 31014: return "xhv"; // Saronite case 34568: return "2"; // Wownero - case 38081: return version >= 8 ? "half" : "msr"; // MSR + case 38081: return "half"; // MSR case 48782: return "2"; // Lethean default: return "2"; } From 41d2fff0fdd7cbef66bdefa921efc0be2c3ce1be Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Jan 2019 08:41:42 -0800 Subject: [PATCH 0210/1496] Updated utils for MSR --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d72d8fc06..e687ea748 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v3.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v5.0.0" } } From ee85ed9c3c1270826b36b6c910f9f3501294744e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Jan 2019 08:43:21 -0800 Subject: [PATCH 0211/1496] Updated MSR blob type --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d8bc19950..3464f7ab4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -193,7 +193,7 @@ function Coin(data){ case 12211: return 4; // RYO case 22023: return 5; // LOKI case 31014: return 5; // XRN - case 38081: return 3; // MSR + case 38081: return 6; // MSR default: return 0; } } @@ -335,7 +335,7 @@ function Coin(data){ case 12211: return "cryptonote_ryo"; // RYO case 22023: return "cryptonote_loki"; // LOKI case 31014: return "cryptonote_loki"; // Saronite - case 38081: return "cryptonote2"; // MSR + case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; } } From b2b3cf6235569340c2d2be58dfbdc33445bff953 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Jan 2019 09:24:58 -0800 Subject: [PATCH 0212/1496] One more Masari fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e687ea748..59b9cb983 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v5.0.0" } } From f2400ba0a2b4e2071ee260cb64eb8159f57cee0e Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sat, 26 Jan 2019 22:39:59 +0300 Subject: [PATCH 0213/1496] Catch error Too many connections --- lib/blockManager.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 6009c4d16..3a26102fb 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -114,6 +114,9 @@ let balanceQueue = async.queue(function (task, callback) { console.error("Can't do SQL balance update: UPDATE balance SET amount = amount+" + amount + " WHERE id = " + balance_id + ";") } return intCallback(null); + }).catch(function (err) { + console.error(err); + console.error("Can't do SQL balance update: UPDATE balance SET amount = amount+" + amount + " WHERE id = " + balance_id + ";") }); } ], From ee727f9e7029556cb6bc7fafe362cfcf4d51e650 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 27 Jan 2019 10:14:50 -0800 Subject: [PATCH 0214/1496] Added cn/fast2 alias --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3464f7ab4..2c299c755 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -289,6 +289,7 @@ function Coin(data){ if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1 or cn/2 hashrate"; if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; + else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; else if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; From 6525561eb08090a3fb82e535ef2131c474794bcb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 27 Jan 2019 10:49:50 -0800 Subject: [PATCH 0215/1496] Added cn/xtlv9 alias --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2c299c755..6836e8247 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -290,8 +290,7 @@ function Coin(data){ if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; - else if ("cn/msr" in algos_perf) coin_perf["MSR"] = algos_perf["cn/msr"]; - else if ("cn-fast" in algos_perf) coin_perf["MSR"] = algos_perf["cn-fast"]; + else if ("cn/xtlv9" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtlv9"]; if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; From 9dd3dc8c77294c146a39dda0af5c14587b28c510 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 1 Feb 2019 09:12:02 -0800 Subject: [PATCH 0216/1496] Removed conditional TRTL algo --- lib/coins/xmr.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6836e8247..3b3ddce96 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -299,8 +299,11 @@ function Coin(data){ if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; - if ("cn-lite" in algos_perf) coin_perf["AEON"] = coin_perf["TRTL"] = algos_perf["cn-lite"]; - else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = coin_perf["TRTL"] = algos_perf["cn-lite/1"]; + if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; + else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; + + if ("cn-pico" in algos_perf) coin_perf["TRTL"] = algos_perf["cn-pico"]; + else if ("cn-pico/trtl" in algos_perf) coin_perf["TRTL"] = algos_perf["cn-pico/trtl"]; return coin_perf; } @@ -313,7 +316,7 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, port) { switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon - case 11898: return convertedBlob[0] >= 5 ? multiHashing.cryptonight_pico(convertedBlob, 0) : multiHashing.cryptonight_light(convertedBlob, 1); // TRTL + case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR @@ -343,7 +346,7 @@ function Coin(data){ this.algoShortTypeStr = function(port, version) { switch (port) { case 11181: return "cn-lite/1"; // Aeon - case 11898: return version >= 5 ? "cn-pico/trtl" : "cn-lite/1"; // TRTL + case 11898: return "cn-pico/trtl"; // TRTL case 12211: return "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR @@ -362,7 +365,7 @@ function Coin(data){ this.variantValue = function(port, version) { switch (port) { case 11181: return "1"; // Aeon - case 11898: return version >= 5 ? "trtl" : "1"; // TRTL + case 11898: return "trtl"; // TRTL case 12211: return "0"; // RYO case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR From ea4adeeebdf8f9b626516ef8f64fef41c2099a36 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 13:49:49 -0800 Subject: [PATCH 0217/1496] Added extra cn/gpu algo support --- lib/coins/xmr.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3b3ddce96..ffd0ec63a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -317,7 +317,7 @@ function Coin(data){ switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL - case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO + case 12211: return convertedBlob[0] >= 6 ? multiHashing.cryptonight(convertedBlob, 10) : multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft @@ -347,7 +347,7 @@ function Coin(data){ switch (port) { case 11181: return "cn-lite/1"; // Aeon case 11898: return "cn-pico/trtl"; // TRTL - case 12211: return "cn-heavy/0"; // RYO + case 12211: return version >= 6 ? "cn/gpu" : "cn-heavy/0"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR case 18981: return "cn/2"; // Graft @@ -366,7 +366,7 @@ function Coin(data){ switch (port) { case 11181: return "1"; // Aeon case 11898: return "trtl"; // TRTL - case 12211: return "0"; // RYO + case 12211: return version >= 6 ? "gpu" : "0"; // RYO case 17750: return "xhv"; // Haven case 18081: return "2"; // XMR case 18981: return "2"; // Graft @@ -450,8 +450,8 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 302) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.3.2+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (version < 600) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.6.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } /*else if (m = reCAST.exec(agent)) { const majorv = parseInt(m[1]) * 10000; diff --git a/package.json b/package.json index 59b9cb983..05d9e9496 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v5.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v6.0.0" } } From 16065392d74b1fc47d08371bbd5a02ba12832776 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 13:54:45 -0800 Subject: [PATCH 0218/1496] Synced cn/gpu algo number from 10 to 11 to match xmrig enum --- lib/coins/xmr.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ffd0ec63a..65aab48ea 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -317,7 +317,7 @@ function Coin(data){ switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL - case 12211: return convertedBlob[0] >= 6 ? multiHashing.cryptonight(convertedBlob, 10) : multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO + case 12211: return convertedBlob[0] >= 6 ? multiHashing.cryptonight(convertedBlob, 11) : multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft diff --git a/package.json b/package.json index 05d9e9496..8b6f036c0 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v6.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v6.0.1" } } From 00a5d062bc7725eabaf7fc41116ea92392d54a6f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 13:57:56 -0800 Subject: [PATCH 0219/1496] Synced cn/gpu algo number from 10 to 11 to match xmrig enum --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 65aab48ea..c68c604e4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -450,8 +450,8 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 600) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.6.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (version < 601) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.6.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } /*else if (m = reCAST.exec(agent)) { const majorv = parseInt(m[1]) * 10000; From 9b2efc3df1ebf78cf3b29c933dd9f35160d90133 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 15:55:16 -0800 Subject: [PATCH 0220/1496] Adaprt diff to coin algo during switch --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 56f2f8372..7932d2d98 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -714,6 +714,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.curr_coin = best_coin; this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_coin].height; + if (this.hashes) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; } return best_coin; } From cb7782c15e33e43d511e7fe5ca878ba47ee506d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 15:58:15 -0800 Subject: [PATCH 0221/1496] Adaprt diff to coin algo during switch --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7932d2d98..b15fd7a34 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -711,10 +711,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { + if (this.hashes) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; this.curr_coin = best_coin; this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_coin].height; - if (this.hashes) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; } return best_coin; } From 6e8ef7064475ce2eaa598d54fc3d3bf93ca83e8a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 16:09:19 -0800 Subject: [PATCH 0222/1496] Adaprt diff to coin algo during switch --- lib/pool.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b15fd7a34..adf6e8268 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -711,7 +711,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - if (this.hashes) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + if (this.debugMiner) { + console.log(threadName + this.logString + ": " + coin + ": was " + this.hashes + " hashes"); + if (this.hashes && this.curr_coin) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + console.log(threadName + this.logString + ": " + coin + ": became " + this.hashes + " hashes"); + } this.curr_coin = best_coin; this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_coin].height; From 0f72a6e9382b7e548bb9a192e219684150c8d21d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 16:14:31 -0800 Subject: [PATCH 0223/1496] Adaprt diff to coin algo during switch --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index adf6e8268..38784c2af 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -712,9 +712,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { if (this.debugMiner) { - console.log(threadName + this.logString + ": " + coin + ": was " + this.hashes + " hashes"); + console.log(threadName + this.logString + ": miner has " + this.hashes + " hashes"); if (this.hashes && this.curr_coin) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; - console.log(threadName + this.logString + ": " + coin + ": became " + this.hashes + " hashes"); + console.log(threadName + this.logString + ": miner now has " + this.hashes + " hashes"); } this.curr_coin = best_coin; this.curr_coin_time = Date.now(); From ad5c342ebb41f1e103365be99b413fef0dd91870 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 16:26:52 -0800 Subject: [PATCH 0224/1496] Adaprt diff to coin algo during switch --- lib/pool.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 38784c2af..2965a8e49 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -711,11 +711,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - if (this.debugMiner) { - console.log(threadName + this.logString + ": miner has " + this.hashes + " hashes"); - if (this.hashes && this.curr_coin) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; - console.log(threadName + this.logString + ": miner now has " + this.hashes + " hashes"); - } + //if (this.debugMiner) { + // console.log(threadName + this.logString + ": miner has " + this.hashes + " hashes"); + if (this.hashes && this.curr_coin) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + this.setNewDiff(this.calcNewDiff()); + // console.log(threadName + this.logString + ": miner now has " + this.hashes + " hashes"); + //} this.curr_coin = best_coin; this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_coin].height; From c765a3c8321a6b5710496f4be4843baa71f1416a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 16:33:29 -0800 Subject: [PATCH 0225/1496] Adaprt diff to coin algo during switch --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2965a8e49..a3a97098d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -711,12 +711,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - //if (this.debugMiner) { - // console.log(threadName + this.logString + ": miner has " + this.hashes + " hashes"); + if (this.debugMiner) { + console.log(threadName + this.logString + ": miner has " + this.hashes + " hashes"); if (this.hashes && this.curr_coin) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; this.setNewDiff(this.calcNewDiff()); - // console.log(threadName + this.logString + ": miner now has " + this.hashes + " hashes"); - //} + console.log(threadName + this.logString + ": miner now has " + this.hashes + " hashes"); + } this.curr_coin = best_coin; this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_coin].height; From 7439e553a8aa863ae58105a6a16945796132fdbb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Feb 2019 16:37:59 -0800 Subject: [PATCH 0226/1496] Adaprt diff to coin algo during switch --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a3a97098d..ed9d25dbb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -713,8 +713,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { if (this.debugMiner) { console.log(threadName + this.logString + ": miner has " + this.hashes + " hashes"); - if (this.hashes && this.curr_coin) this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; - this.setNewDiff(this.calcNewDiff()); + if (this.hashes && typeof(this.curr_coin) !== 'undefined') this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + this.setNewDiff(this.calcNewDiff()); console.log(threadName + this.logString + ": miner now has " + this.hashes + " hashes"); } this.curr_coin = best_coin; From 998da066897bc53aa36fc97f05b67a8b4a312bc1 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Fri, 8 Feb 2019 18:32:15 +0300 Subject: [PATCH 0227/1496] Wait before close pool module. --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ed9d25dbb..4f92335d3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1548,7 +1548,8 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (global.config.general.allowStuckPoolKill && fs.existsSync("block_template_is_stuck")) { console.error("Stuck block template was detected on previous run. Please fix monerod and remove block_template_is_stuck file after that. Exiting..."); - process.exit(); + setTimeout(function() { process.exit(); }, 5*1000); + return; } setInterval(function dump_vars() { From ab5817e5531ee0c394cb206f5fdf2df998cecc38 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 Feb 2019 09:53:49 -0800 Subject: [PATCH 0228/1496] Bug fixes for AVX CPUs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b6f036c0..63a31095b 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v6.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v6.0.3" } } From ab6a39e0ba06c61e99960777d2acf1acff2afff6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 10 Feb 2019 01:14:22 -0800 Subject: [PATCH 0229/1496] Fixed TUBE reward --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c68c604e4..ee9c36763 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -101,7 +101,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 22023 || port == 31014) { // Loki / Saronite has reward as zero transaction + if (port == 22023 || port == 31014 || port == 24182) { // Loki / Saronite / TUBE has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Sun, 10 Feb 2019 02:05:52 -0800 Subject: [PATCH 0230/1496] Added block hash --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ee9c36763..8cdcf0480 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -113,7 +113,7 @@ function Coin(data){ if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { - console.error(port + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); + console.error(port + "block hash: " + blockHash + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); } const reward = body2.result.transfer.amount; From e2f2b688fd9eeb516b823f26eb80e49928603502 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 10 Feb 2019 02:06:27 -0800 Subject: [PATCH 0231/1496] Added block hash --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8cdcf0480..33b40ab23 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -113,7 +113,7 @@ function Coin(data){ if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { - console.error(port + "block hash: " + blockHash + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); + console.error(port + ": block hash: " + blockHash + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); } const reward = body2.result.transfer.amount; From 27852e7ba3f77d5e88f01b0375cba6e09d3192cd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 10 Feb 2019 12:07:52 -0800 Subject: [PATCH 0232/1496] Added cn/wow support --- lib/coins/xmr.js | 14 +++++++------- lib/pool.js | 5 +++-- package.json | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 33b40ab23..63a7f96c3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -313,7 +313,7 @@ function Coin(data){ return algos.includes("cn/2") ? true : "algo array must include cn/2"; } - this.cryptoNight = function(convertedBlob, port) { + this.cryptoNight = function(convertedBlob, port, height) { switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL @@ -325,7 +325,7 @@ function Coin(data){ case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite - case 34568: return multiHashing.cryptonight(convertedBlob, 8); // Wownero + case 34568: return convertedBlob[0] >= 11 ? multiHashing.cryptonight(convertedBlob, 12, height) : multiHashing.cryptonight(convertedBlob, 8); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); @@ -355,7 +355,7 @@ function Coin(data){ case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 31014: return "cn-heavy/xhv"; // Saronite - case 34568: return "cn/2"; // Wownero + case 34568: return version >= 11 ? "cn/wow" : "cn/2"; // Wownero case 38081: return "cn/half"; // MSR case 48782: return "cn/2"; // Lethean default: return "cn/2"; @@ -374,8 +374,8 @@ function Coin(data){ case 22023: return "0"; // LOKI case 24182: return "tube"; // BitTube case 31014: return "xhv"; // Saronite - case 34568: return "2"; // Wownero - case 38081: return "half"; // MSR + case 34568: return version >= 11 ? "wow" : "2"; // Wownero + case 38081: return "half"; // MSR case 48782: return "2"; // Lethean default: return "2"; } @@ -450,8 +450,8 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 601) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.6.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (version < 700) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.7.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } /*else if (m = reCAST.exec(agent)) { const majorv = parseInt(m[1]) * 10000; diff --git a/lib/pool.js b/lib/pool.js index ed9d25dbb..ace28331c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -868,6 +868,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer blob: blob, algo: global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]), variant: global.coinFuncs.variantValue(bt.port, bt.buffer[0]), + height: bt.height, job_id: newJob.id, target: target, id: this.id @@ -1182,7 +1183,7 @@ function processShare(miner, job, blockTemplate, params) { return false; } let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port); + hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); if (hash.toString('hex') !== resultHash) { let time_now = Date.now(); @@ -1216,7 +1217,7 @@ function processShare(miner, job, blockTemplate, params) { let isNotifyAdmin = true; if (shareType) { let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - hash = global.coinFuncs.cryptoNight(convertedBlob); + hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate[blockTemplate.coin].height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); diff --git a/package.json b/package.json index 63a31095b..6cfa3b228 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v6.0.3" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v7.0.0" } } From ff7d2fb82981e2f841e68470dec05f70294d7013 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Feb 2019 21:07:44 -0800 Subject: [PATCH 0233/1496] Updated version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6cfa3b228..9a4756e4c 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v7.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v7.0.1" } } From 3b37016ee98d5d35055879c3bdc40db93b449e90 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 13 Feb 2019 11:19:29 -0800 Subject: [PATCH 0234/1496] Enabled algo aware diff setting --- lib/pool.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ace28331c..f158867a7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -711,11 +711,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - if (this.debugMiner) { - console.log(threadName + this.logString + ": miner has " + this.hashes + " hashes"); - if (this.hashes && typeof(this.curr_coin) !== 'undefined') this.hashes *= this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + if (typeof(this.curr_coin) !== 'undefined') { + const factor = this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + const proxyMinerName = this.payout + ":" + this.identifier; + if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; + if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; + this.hashes *= factor; this.setNewDiff(this.calcNewDiff()); - console.log(threadName + this.logString + ": miner now has " + this.hashes + " hashes"); } this.curr_coin = best_coin; this.curr_coin_time = Date.now(); From 90fae43e59531593c1418227941595439185b458 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 13 Feb 2019 15:47:16 -0800 Subject: [PATCH 0235/1496] Disabled proxy diff change during algo changes --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f158867a7..1b7d6c774 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -713,9 +713,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { if (typeof(this.curr_coin) !== 'undefined') { const factor = this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; - const proxyMinerName = this.payout + ":" + this.identifier; - if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; - if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; + //const proxyMinerName = this.payout + ":" + this.identifier; + //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; + //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; this.hashes *= factor; this.setNewDiff(this.calcNewDiff()); } From 955afa891ebfdcefdd9138161079b347c2ba5a96 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Feb 2019 10:35:56 -0800 Subject: [PATCH 0236/1496] Updated RYO algo perf --- lib/coins/xmr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 63a7f96c3..d3cd6a407 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -292,8 +292,10 @@ function Coin(data){ else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; else if ("cn/xtlv9" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtlv9"]; - if ("cn-heavy" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; - else if ("cn-heavy/0" in algos_perf) coin_perf["RYO"] = coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; + if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; + + if ("cn-heavy" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; + else if ("cn-heavy/0" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; if ("cn-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cn-heavy/tube"]; From c83134d4dedce4ed912d3ce20782cb228bc3d2ff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Feb 2019 10:55:17 -0800 Subject: [PATCH 0237/1496] Automated variant name function --- lib/coins/xmr.js | 23 ++------------- lib/pool.js | 77 ++++++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 57 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d3cd6a407..8eca8acbf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -319,7 +319,7 @@ function Coin(data){ switch (port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL - case 12211: return convertedBlob[0] >= 6 ? multiHashing.cryptonight(convertedBlob, 11) : multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO + case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft @@ -349,7 +349,7 @@ function Coin(data){ switch (port) { case 11181: return "cn-lite/1"; // Aeon case 11898: return "cn-pico/trtl"; // TRTL - case 12211: return version >= 6 ? "cn/gpu" : "cn-heavy/0"; // RYO + case 12211: return "cn/gpu"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/2"; // XMR case 18981: return "cn/2"; // Graft @@ -364,25 +364,6 @@ function Coin(data){ } } - this.variantValue = function(port, version) { - switch (port) { - case 11181: return "1"; // Aeon - case 11898: return "trtl"; // TRTL - case 12211: return version >= 6 ? "gpu" : "0"; // RYO - case 17750: return "xhv"; // Haven - case 18081: return "2"; // XMR - case 18981: return "2"; // Graft - case 20189: return "half"; // Stellite - case 22023: return "0"; // LOKI - case 24182: return "tube"; // BitTube - case 31014: return "xhv"; // Saronite - case 34568: return version >= 11 ? "wow" : "2"; // Wownero - case 38081: return "half"; // MSR - case 48782: return "2"; // Lethean - default: return "2"; - } - } - this.isMinerSupportAlgo = function(algo, algos) { if (algo in algos) return true; if (algo === "cn-heavy/0" && "cn-heavy" in algos) return true; diff --git a/lib/pool.js b/lib/pool.js index 1b7d6c774..4df8ad5ae 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -850,61 +850,66 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.difficulty = this.newDiffRecommendation; this.newDiffRecommendation = null; } + const coinHashFactor = currCoinHashFactor[coin]; + const algo_name = global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]); + const variant_name = algo_name.split('/')[1]; + if (!this.proxy) { let blob = bt.nextBlob(); let target = this.getTargetHex(); let newJob = { - id: crypto.pseudoRandomBytes(21).toString('base64'), - coin: coin, - blockHash: bt.idHash, - extraNonce: bt.extraNonce, - height: bt.height, - difficulty: this.difficulty, - diffHex: this.diffHex, + id: crypto.pseudoRandomBytes(21).toString('base64'), + coin: coin, + blockHash: bt.idHash, + extraNonce: bt.extraNonce, + height: bt.height, + difficulty: this.difficulty, + diffHex: this.diffHex, coinHashFactor: coinHashFactor, - submissions: {} + submissions: {} }; this.validJobs.enq(newJob); this.cachedJob = { - blob: blob, - algo: global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]), - variant: global.coinFuncs.variantValue(bt.port, bt.buffer[0]), - height: bt.height, - job_id: newJob.id, - target: target, - id: this.id + blob: blob, + algo: algo_name, + variant: variant_name, + height: bt.height, + job_id: newJob.id, + target: target, + id: this.id }; } else { let blob = bt.nextBlobWithChildNonce(); let newJob = { - id: crypto.pseudoRandomBytes(21).toString('base64'), - coin: coin, - blockHash: bt.idHash, - extraNonce: bt.extraNonce, - height: bt.height, - difficulty: this.difficulty, - diffHex: this.diffHex, - clientPoolLocation: bt.clientPoolLocation, + id: crypto.pseudoRandomBytes(21).toString('base64'), + coin: coin, + blockHash: bt.idHash, + extraNonce: bt.extraNonce, + height: bt.height, + difficulty: this.difficulty, + diffHex: this.diffHex, + clientPoolLocation: bt.clientPoolLocation, clientNonceLocation: bt.clientNonceLocation, - coinHashFactor: coinHashFactor, - submissions: {} + coinHashFactor: coinHashFactor, + submissions: {} }; this.validJobs.enq(newJob); + const algo_name = global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]); this.cachedJob = { blocktemplate_blob: blob, - blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), - algo: global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]), - variant: global.coinFuncs.variantValue(bt.port, bt.buffer[0]), - difficulty: bt.difficulty, - height: bt.height, - reserved_offset: bt.reserveOffset, + blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), + algo: algo_name, + variant: variant_name, + difficulty: bt.difficulty, + height: bt.height, + reserved_offset: bt.reserveOffset, client_nonce_offset: bt.clientNonceLocation, - client_pool_offset: bt.clientPoolLocation, - target_diff: this.difficulty, - target_diff_hex: this.diffHex, - job_id: newJob.id, - id: this.id + client_pool_offset: bt.clientPoolLocation, + target_diff: this.difficulty, + target_diff_hex: this.diffHex, + job_id: newJob.id, + id: this.id }; } return this.cachedJob; From 72990c4a6dd3e928213f12e7d6e8825e9d3cdfad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 Feb 2019 07:33:10 -0800 Subject: [PATCH 0238/1496] Updated cn/wow algo perf --- lib/coins/xmr.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8eca8acbf..9f3b4736b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -282,9 +282,9 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["WOW"] = coin_perf["LTHN"] = algos_perf["cn/2"]; - else if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["WOW"] = coin_perf["LTHN"] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["WOW"] = coin_perf["LTHN"] = algos_perf["cn/1"]; + if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/2"]; + else if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1 or cn/2 hashrate"; @@ -294,6 +294,8 @@ function Coin(data){ if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; + if ("cn/wow" in algos_perf) coin_perf["WOW"] = algos_perf["cn/wow"]; + if ("cn-heavy" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; @@ -327,7 +329,7 @@ function Coin(data){ case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite - case 34568: return convertedBlob[0] >= 11 ? multiHashing.cryptonight(convertedBlob, 12, height) : multiHashing.cryptonight(convertedBlob, 8); // Wownero + case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); @@ -357,7 +359,7 @@ function Coin(data){ case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 31014: return "cn-heavy/xhv"; // Saronite - case 34568: return version >= 11 ? "cn/wow" : "cn/2"; // Wownero + case 34568: return "cn/wow"; // Wownero case 38081: return "cn/half"; // MSR case 48782: return "cn/2"; // Lethean default: return "cn/2"; From bd24b61a936e4f31b8391534c219cf452f342282 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 Feb 2019 07:46:39 -0800 Subject: [PATCH 0239/1496] Added algo diff factor change limit --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4df8ad5ae..77c1fe2d5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -712,7 +712,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { if (typeof(this.curr_coin) !== 'undefined') { - const factor = this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + let factor = this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; + if (factor > 10) factor = 10; + else (factor < 0.1) factor = 0.1; //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; From c5b8a6af7af1adf17d71ebc1622a8b814a590c56 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 Feb 2019 07:47:34 -0800 Subject: [PATCH 0240/1496] Added algo diff factor change limit --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 77c1fe2d5..b517ad2a9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -714,7 +714,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (typeof(this.curr_coin) !== 'undefined') { let factor = this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; if (factor > 10) factor = 10; - else (factor < 0.1) factor = 0.1; + else if (factor < 0.1) factor = 0.1; //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; From 7f1d77a7090db19ae741ba8ab5ebf91026f31b90 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 Feb 2019 18:58:02 -0800 Subject: [PATCH 0241/1496] Fixed wild diff jumps in case of algo switches --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index b517ad2a9..00aa12821 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -719,6 +719,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; this.hashes *= factor; + if (this.hashesShift) this.hashesShift *= factor; this.setNewDiff(this.calcNewDiff()); } this.curr_coin = best_coin; From e24cf4a9b0552b5d00b960e76972ca9b09c38b66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Feb 2019 09:53:47 -0800 Subject: [PATCH 0242/1496] Added cn/4 algo support --- lib/coins/xmr.js | 30 ++++++++++++++++-------------- package.json | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9f3b4736b..8238070b0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -272,7 +272,7 @@ function Coin(data){ } this.getDefaultAlgos = function() { - return [ "cn/2" ]; + return [ "cn/2", "cn/4" ]; } this.getDefaultAlgosPerf = function() { @@ -286,7 +286,11 @@ function Coin(data){ else if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; - if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1 or cn/2 hashrate"; + if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/wow"]; + + if ("cn/4" in algos_perf) coin_perf[""] = algos_perf["cn/4"]; + + if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1, cn/2, cn/4 or cn/wow hashrate"; if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; @@ -294,8 +298,6 @@ function Coin(data){ if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; - if ("cn/wow" in algos_perf) coin_perf["WOW"] = algos_perf["cn/wow"]; - if ("cn-heavy" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; @@ -323,7 +325,7 @@ function Coin(data){ case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, 8); // XMR + case 18081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 10 ? 13 : 8, height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI @@ -353,7 +355,7 @@ function Coin(data){ case 11898: return "cn-pico/trtl"; // TRTL case 12211: return "cn/gpu"; // RYO case 17750: return "cn-heavy/xhv"; // Haven - case 18081: return "cn/2"; // XMR + case 18081: return version >= 10 ? "cn/4" : "cn/2"; // XMR case 18981: return "cn/2"; // Graft case 20189: return "cn/half"; // Stellite case 22023: return "cn-heavy/0"; // LOKI @@ -417,26 +419,26 @@ function Coin(data){ this.get_miner_agent_warning_notification = function(agent) { let m; - /*if (m = reXMRig.exec(agent)) { + if (m = reXMRig.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 20800) { - return "Please update your XMRig miner (" + agent + ") to v2.8.0+"; + if (majorv + minorv < 21300) { + return "Please update your XMRig miner (" + agent + ") to v2.13.0+ to support new cn/4 Monero algo before March 9 Monero fork"; } - } else if (m = reXMRSTAK2.exec(agent)) { + /*} else if (m = reXMRSTAK2.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 20500) { return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; - } - } else */if (m = reXNP.exec(agent)) { + }*/ + } else if (m = reXNP.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 700) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.7.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (version < 800) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.8.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } /*else if (m = reCAST.exec(agent)) { const majorv = parseInt(m[1]) * 10000; diff --git a/package.json b/package.json index 9a4756e4c..1f9f2f715 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v7.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v8.0.0" } } From 85a5433199de1b34bcad6534618f8e6f3de6252b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Feb 2019 11:25:14 -0800 Subject: [PATCH 0243/1496] Update to new XMR version --- deployment/upgrade_monero.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index fcdd9db74..b73083597 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,12 +6,11 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.13.0.4 &&\ -#curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v &&\ +sudo git checkout v0.14.0.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ USE_SINGLE_BUILDDIR=1 sudo nice make &&\ sudo mkdir -p /usr/local/src/monero/build/release/bin &&\ -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.4_/release/bin/* /usr/local/src/monero/build/release/bin &&\ +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.14.0.0_/release/bin/* /usr/local/src/monero/build/release/bin &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" From e50e7b019f13685778c5b9af9caaf9c03732f84c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Feb 2019 11:59:56 -0800 Subject: [PATCH 0244/1496] Updated to newer monero daemon --- deployment/deploy.bash | 4 ++-- deployment/leaf.bash | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 2297ede28..bec022194 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,11 +26,11 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.13.0.4 +sudo git checkout v0.14.0.0 #curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.4_/release/bin/* /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.14.0.0_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon #BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 6c2854dd1..06a71e8a0 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -22,11 +22,11 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.13.0.4 +sudo git checkout v0.14.0.0 #curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.13.0.4_/release/bin/* /usr/local/src/monero/build/release/bin +sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.14.0.0_/release/bin/* /usr/local/src/monero/build/release/bin sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon #BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) From d69b7538bdf9342da2d05eb73ea43d33cc459ce9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Feb 2019 19:29:19 -0800 Subject: [PATCH 0245/1496] Removed cn/4 name --- lib/coins/xmr.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8238070b0..e52a2430a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -272,7 +272,7 @@ function Coin(data){ } this.getDefaultAlgos = function() { - return [ "cn/2", "cn/4" ]; + return [ "cn/2", "cn/r" ]; } this.getDefaultAlgosPerf = function() { @@ -288,9 +288,10 @@ function Coin(data){ if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/wow"]; - if ("cn/4" in algos_perf) coin_perf[""] = algos_perf["cn/4"]; + if ("cn/r" in algos_perf) coin_perf[""] = algos_perf["cn/r"]; + else if ("cn/4" in algos_perf) coin_perf[""] = algos_perf["cn/4"]; - if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1, cn/2, cn/4 or cn/wow hashrate"; + if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1, cn/2, cn/r or cn/wow hashrate"; if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; @@ -355,7 +356,7 @@ function Coin(data){ case 11898: return "cn-pico/trtl"; // TRTL case 12211: return "cn/gpu"; // RYO case 17750: return "cn-heavy/xhv"; // Haven - case 18081: return version >= 10 ? "cn/4" : "cn/2"; // XMR + case 18081: return version >= 10 ? "cn/r" : "cn/2"; // XMR case 18981: return "cn/2"; // Graft case 20189: return "cn/half"; // Stellite case 22023: return "cn-heavy/0"; // LOKI @@ -423,7 +424,7 @@ function Coin(data){ const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; if (majorv + minorv < 21300) { - return "Please update your XMRig miner (" + agent + ") to v2.13.0+ to support new cn/4 Monero algo before March 9 Monero fork"; + return "Please update your XMRig miner (" + agent + ") to v2.13.0+ to support new cn/r Monero algo before March 9 Monero fork"; } /*} else if (m = reXMRSTAK2.exec(agent)) { const majorv = parseInt(m[1]) * 10000; @@ -437,8 +438,8 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 800) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.8.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (version < 801) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.8.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } /*else if (m = reCAST.exec(agent)) { const majorv = parseInt(m[1]) * 10000; From ef95663ea96395ca2a1f576b73770c6b113a63d3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Feb 2019 20:01:19 -0800 Subject: [PATCH 0246/1496] Updated wow handling --- lib/coins/xmr.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e52a2430a..c2c2ce521 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -286,10 +286,9 @@ function Coin(data){ else if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; - if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/wow"]; - - if ("cn/r" in algos_perf) coin_perf[""] = algos_perf["cn/r"]; - else if ("cn/4" in algos_perf) coin_perf[""] = algos_perf["cn/4"]; + if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/r"]; + else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/4"]; + else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/wow"]; if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1, cn/2, cn/r or cn/wow hashrate"; From 8b68baf8c3a3151e9c201302b043c05cc95687fc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Feb 2019 09:00:29 -0800 Subject: [PATCH 0247/1496] Added script to fix wrong pay stages --- manage_scripts/altblock_change_stage.js | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 manage_scripts/altblock_change_stage.js diff --git a/manage_scripts/altblock_change_stage.js b/manage_scripts/altblock_change_stage.js new file mode 100644 index 000000000..49f4ee78e --- /dev/null +++ b/manage_scripts/altblock_change_stage.js @@ -0,0 +1,39 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.hash) { + console.error("Please specify altblock hash"); + process.exit(1); +} +const hash = argv.hash; + +if (!argv.stage) { + console.error("Please specify new stage value"); + process.exit(1); +} +const stage = argv.stage; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn(); + let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + if (blockData.hash === hash) { + console.log("Found altblock with " + blockData.hash + " hash"); + blockData.stage = stage; + console.log("Put \"" + blockData.stage + "\" stage to block"); + txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + txn.commit(); + cursor.close(); + console.log("Changed altblock"); + process.exit(0); + } + }); + } + cursor.close(); + txn.commit(); + console.log("Not found altblock with " + hash + " hash"); + process.exit(1); +}); From feeda564982053c8fe6fc3bed67480c3114390ff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Feb 2019 09:09:04 -0800 Subject: [PATCH 0248/1496] Added script to fix wrong pay stages --- manage_scripts/altblock_change_stage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manage_scripts/altblock_change_stage.js b/manage_scripts/altblock_change_stage.js index 49f4ee78e..3d7bb25f0 100644 --- a/manage_scripts/altblock_change_stage.js +++ b/manage_scripts/altblock_change_stage.js @@ -22,8 +22,8 @@ require("../init_mini.js").init(function() { let blockData = global.protos.AltBlock.decode(data); if (blockData.hash === hash) { console.log("Found altblock with " + blockData.hash + " hash"); - blockData.stage = stage; - console.log("Put \"" + blockData.stage + "\" stage to block"); + blockData.pay_stage = stage; + console.log("Put \"" + blockData.pay_stage + "\" stage to block"); txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); txn.commit(); cursor.close(); From 2edee1d8949edb6f4eb878e4b638be131192caae Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Feb 2019 10:57:16 -0800 Subject: [PATCH 0249/1496] Updated SRB miner update warning --- lib/coins/xmr.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c2c2ce521..647fe0b17 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -438,7 +438,7 @@ function Coin(data){ const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; if (version < 801) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.8.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + return "Please update your xmr-node-proxy (" + agent + ") to version v0.8.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new cn/r Monero algo before March 9 Monero fork"; } } /*else if (m = reCAST.exec(agent)) { const majorv = parseInt(m[1]) * 10000; @@ -446,15 +446,15 @@ function Coin(data){ const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 10500) { return "Please update your cast-xmr miner (" + agent + ") to version v1.5.0+"; - } + }*/ } else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 10608) { - return "Please update your SRBminer (" + agent + ") to version v1.6.8+"; + if (majorv + minorv + minorv2 < 10709) { + return "Please update your SRBminer (" + agent + ") to version v1.7.9+ to support new cn/r Monero algo before March 9 Monero fork"; } - }*/ + } return false; }; } From f7cfdd473eb8ff5053603f085aaf77f651660068 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 27 Feb 2019 13:49:25 -0800 Subject: [PATCH 0250/1496] Updated algo-perf writing --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 647fe0b17..261078e24 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -290,7 +290,7 @@ function Coin(data){ else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/4"]; else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/wow"]; - if (!("" in coin_perf)) return "algo_perf set must include cn, cn/1, cn/2, cn/r or cn/wow hashrate"; + if (!("" in coin_perf)) return "algo-perf set must include cn, cn/1, cn/2, cn/r or cn/wow hashrate"; if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; From ba3c57f9b6138cc6eaccb40c7e0c7e533a1d0e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=88=86=E4=B9=8B=E4=B8=80?= Date: Thu, 28 Feb 2019 22:44:03 +0800 Subject: [PATCH 0251/1496] fix SRB miner update warning --- lib/coins/xmr.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 261078e24..45b4dd4ac 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -447,7 +447,7 @@ function Coin(data){ if (majorv + minorv + minorv2 < 10500) { return "Please update your cast-xmr miner (" + agent + ") to version v1.5.0+"; }*/ - } else if (m = reSRB.exec(agent)) { + else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); @@ -455,8 +455,9 @@ function Coin(data){ return "Please update your SRBminer (" + agent + ") to version v1.7.9+ to support new cn/r Monero algo before March 9 Monero fork"; } } - return false; + } + return false; }; -} + module.exports = Coin; From 2202607054e1bb177cbe61e0dd02d7eaf5da14b2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 3 Mar 2019 15:49:22 -0800 Subject: [PATCH 0252/1496] Updated xmr-stak version --- lib/coins/xmr.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 261078e24..044fffb65 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -425,13 +425,13 @@ function Coin(data){ if (majorv + minorv < 21300) { return "Please update your XMRig miner (" + agent + ") to v2.13.0+ to support new cn/r Monero algo before March 9 Monero fork"; } - /*} else if (m = reXMRSTAK2.exec(agent)) { + } else if (m = reXMRSTAK2.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 20500) { - return "Please update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; - }*/ + if (majorv + minorv + minorv2 < 20900) { + return "Please update your xmr-stak miner (" + agent + ") to v2.9.0+ (and use cryptonight_r in config) to support new cn/r Monero algo before March 9 Monero fork"; + } } else if (m = reXNP.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; @@ -440,13 +440,6 @@ function Coin(data){ if (version < 801) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.8.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new cn/r Monero algo before March 9 Monero fork"; } - } /*else if (m = reCAST.exec(agent)) { - const majorv = parseInt(m[1]) * 10000; - const minorv = parseInt(m[2]) * 100; - const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 10500) { - return "Please update your cast-xmr miner (" + agent + ") to version v1.5.0+"; - }*/ } else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; From 8aaab16c40489860a47e30966e5272206be76b62 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 3 Mar 2019 17:14:59 -0800 Subject: [PATCH 0253/1496] Updated xmr-stak version --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 91d315764..bbc542ee8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -430,7 +430,7 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 20900) { - return "Please update your xmr-stak miner (" + agent + ") to v2.9.0+ (and use cryptonight_r in config) to support new cn/r Monero algo before March 9 Monero fork"; + return "Please update your xmr-stak miner (" + agent + ") to v2.9.0+ (use monero in config now and cryptonight_r after fork) to support new cn/r Monero algo before March 9 Monero fork"; } } else if (m = reXNP.exec(agent)) { const majorv = parseInt(m[1]) * 10000; From d99ba504817039a353f533a4119cd4b9949f964a Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Mon, 4 Mar 2019 22:44:26 +0300 Subject: [PATCH 0254/1496] workerList has died workers if worker died. Function sendToWorkers crash master thread because foreach of undefined. --- lib/pool.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 00aa12821..d3e916007 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -32,7 +32,6 @@ const fix_daemon_sh = "./fix_daemon.sh"; let lastBlockFixTime = {}; // time when blocks were checked to be in line with other nodes or when fix_daemon_sh was attempted let lastBlockFixCount = {}; // number of times fix_daemon_sh was run -let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; let threadName; let minerCount = []; @@ -158,8 +157,8 @@ function messageHandler(message) { process.on('message', messageHandler); function sendToWorkers(data) { - workerList.forEach(function (worker) { - worker.send(data); + Object.keys(cluster.workers).forEach(function(key) { + cluster.workers[key].send(data); }); } @@ -1705,7 +1704,6 @@ if (cluster.isMaster) { for (let i = 0; i < numWorkers; i++) { let worker = cluster.fork(); worker.on('message', messageHandler); - workerList.push(worker); } cluster.on('online', function (worker) { @@ -1717,7 +1715,6 @@ if (cluster.isMaster) { console.log('Starting a new worker'); worker = cluster.fork(); worker.on('message', messageHandler); - workerList.push(worker); }); From a17ba7c113fbd6024db0d9a34441b182a2fdca9f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Mar 2019 15:13:03 -0800 Subject: [PATCH 0255/1496] Fixed stuff --- lib/coins/xmr.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index bbc542ee8..280ae822d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -276,7 +276,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "cn": 1, "cn/half": 1.9 }; + return { "cn": 1, "cn/half": 1.9, "cn/rwz": 1.3, "cn/zls": 1.3, "cn/double": 0.5 }; } this.convertAlgosToCoinPerf = function(algos_perf) { @@ -326,7 +326,7 @@ function Coin(data){ case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 10 ? 13 : 8, height); // XMR - case 18981: return multiHashing.cryptonight(convertedBlob, 8); // Graft + case 18981: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 12 ? 14 : 8); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube @@ -356,7 +356,7 @@ function Coin(data){ case 12211: return "cn/gpu"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return version >= 10 ? "cn/r" : "cn/2"; // XMR - case 18981: return "cn/2"; // Graft + case 18981: return version >= 12 ? "cn/rwz" : "cn/2"; // Graft case 20189: return "cn/half"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube diff --git a/package.json b/package.json index 1f9f2f715..8b4f75096 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v8.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.0" } } From 9dbefceb8813c23473fadb04b4d78357e189b098 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Mar 2019 08:58:35 -0800 Subject: [PATCH 0256/1496] Updated Graft algo perf --- lib/coins/xmr.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 280ae822d..517f6d6e8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -282,9 +282,9 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/2"]; - else if ("cn" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["GRFT"] = coin_perf["LTHN"] = algos_perf["cn/1"]; + if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn/2"]; + else if ("cn" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn/1"]; if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/r"]; else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/4"]; @@ -298,6 +298,8 @@ function Coin(data){ if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; + if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; + if ("cn-heavy" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; @@ -326,7 +328,7 @@ function Coin(data){ case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 10 ? 13 : 8, height); // XMR - case 18981: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 12 ? 14 : 8); // Graft + case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube @@ -356,7 +358,7 @@ function Coin(data){ case 12211: return "cn/gpu"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return version >= 10 ? "cn/r" : "cn/2"; // XMR - case 18981: return version >= 12 ? "cn/rwz" : "cn/2"; // Graft + case 18981: return "cn/rwz"; // Graft case 20189: return "cn/half"; // Stellite case 22023: return "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube From ad8aa39a07fb5cce2eb40d080c2ed660eab90ac6 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Fri, 8 Mar 2019 21:35:53 +0300 Subject: [PATCH 0257/1496] fix typo --- lib/coins/xmr.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 517f6d6e8..5a4707c2d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -450,9 +450,10 @@ function Coin(data){ return "Please update your SRBminer (" + agent + ") to version v1.7.9+ to support new cn/r Monero algo before March 9 Monero fork"; } } - } - return false; - }; + return false; + }; +}; + module.exports = Coin; From fdd98f464043cfaf117d1a68e95e67c46294a33d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Mar 2019 14:59:09 -0800 Subject: [PATCH 0258/1496] Updated for LTHN fork --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 517f6d6e8..a3f895e31 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -335,7 +335,7 @@ function Coin(data){ case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, 8); // Lethean + case 48782: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 6 ? 13 : 8); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); } } @@ -365,7 +365,7 @@ function Coin(data){ case 31014: return "cn-heavy/xhv"; // Saronite case 34568: return "cn/wow"; // Wownero case 38081: return "cn/half"; // MSR - case 48782: return "cn/2"; // Lethean + case 48782: return version >= 6 ? "cn/r" : "cn/2"; // Lethean default: return "cn/2"; } } From e28aa8a65bc4fe42992540c308d6a8fa6cf6c3a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Mar 2019 15:23:53 -0800 Subject: [PATCH 0259/1496] Fixed possible overflow --- lib/data.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/data.proto b/lib/data.proto index f2b6fba1a..52d463271 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -26,7 +26,7 @@ message InvalidShare{ } message Share { - required int32 shares = 1; + required int64 shares = 1; required string paymentAddress = 2; required bool foundBlock = 3; optional string paymentID = 4; @@ -39,8 +39,8 @@ message Share { required int64 timestamp = 11; required string identifier = 12; optional int32 port = 13; - optional int32 shares2 = 14; - optional int32 share_num = 15; + optional int64 shares2 = 14; + optional int64 share_num = 15; } message Block { From 8a7c8536d7b364f51c45146cd1c3539374a4549c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Mar 2019 22:50:40 -0800 Subject: [PATCH 0260/1496] Post fork LTHN update --- lib/coins/xmr.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8df283488..04c9bc8e7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -282,13 +282,13 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn/2" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn/2"]; - else if ("cn" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = algos_perf["cn/1"]; + if ("cn/2" in algos_perf) coin_perf[""] = algos_perf["cn/2"]; + else if ("cn" in algos_perf) coin_perf[""] = algos_perf["cn"]; + else if ("cn/1" in algos_perf) coin_perf[""] = algos_perf["cn/1"]; - if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/r"]; - else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/4"]; - else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["WOW"] = algos_perf["cn/wow"]; + if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; + else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/4"]; + else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/wow"]; if (!("" in coin_perf)) return "algo-perf set must include cn, cn/1, cn/2, cn/r or cn/wow hashrate"; @@ -335,7 +335,7 @@ function Coin(data){ case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 6 ? 13 : 8); // Lethean + case 48782: return multiHashing.cryptonight(convertedBlob, 13); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); } } @@ -365,7 +365,7 @@ function Coin(data){ case 31014: return "cn-heavy/xhv"; // Saronite case 34568: return "cn/wow"; // Wownero case 38081: return "cn/half"; // MSR - case 48782: return version >= 6 ? "cn/r" : "cn/2"; // Lethean + case 48782: return "cn/r"; // Lethean default: return "cn/2"; } } From 8943832a461f97302f8ed17042e7f88c08ba9abb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 Mar 2019 07:07:37 -0800 Subject: [PATCH 0261/1496] Fixed LTHN bug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 04c9bc8e7..02269c91e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -335,7 +335,7 @@ function Coin(data){ case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, 13); // Lethean + case 48782: return multiHashing.cryptonight(convertedBlob, 13, height); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); } } From ec912d71e1ccb690c9b3b2f69d727a027c2ddc4c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 Mar 2019 09:27:29 -0800 Subject: [PATCH 0262/1496] Post XMR fork update --- lib/coins/xmr.js | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 02269c91e..86a9d5114 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -272,7 +272,7 @@ function Coin(data){ } this.getDefaultAlgos = function() { - return [ "cn/2", "cn/r" ]; + return [ "cn/r" ]; } this.getDefaultAlgosPerf = function() { @@ -282,15 +282,12 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn/2" in algos_perf) coin_perf[""] = algos_perf["cn/2"]; - else if ("cn" in algos_perf) coin_perf[""] = algos_perf["cn"]; - else if ("cn/1" in algos_perf) coin_perf[""] = algos_perf["cn/1"]; - - if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; + if ("cn" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn"]; + else if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/4"]; else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/wow"]; - if (!("" in coin_perf)) return "algo-perf set must include cn, cn/1, cn/2, cn/r or cn/wow hashrate"; + if (!("" in coin_perf)) return "algo-perf set must include cn or cn/r hashrate"; if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; @@ -318,7 +315,7 @@ function Coin(data){ // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - return algos.includes("cn/2") ? true : "algo array must include cn/2"; + return algos.includes("cn/r") ? true : "algo array must include cn/r"; } this.cryptoNight = function(convertedBlob, port, height) { @@ -327,7 +324,7 @@ function Coin(data){ case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 10 ? 13 : 8, height); // XMR + case 18081: return multiHashing.cryptonight(convertedBlob, 13, height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI @@ -357,7 +354,7 @@ function Coin(data){ case 11898: return "cn-pico/trtl"; // TRTL case 12211: return "cn/gpu"; // RYO case 17750: return "cn-heavy/xhv"; // Haven - case 18081: return version >= 10 ? "cn/r" : "cn/2"; // XMR + case 18081: return "cn/r"; // XMR case 18981: return "cn/rwz"; // Graft case 20189: return "cn/half"; // Stellite case 22023: return "cn-heavy/0"; // LOKI @@ -381,14 +378,14 @@ function Coin(data){ if (m = reXMRig.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 20800) { - return "You must update your XMRig miner (" + agent + ") to v2.8.0+"; + if (majorv + minorv < 21300) { + return "You must update your XMRig miner (" + agent + ") to v2.13.0+"; } } else if (m = reXMRSTAK.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 20500) { - return "You must update your xmr-stak miner (" + agent + ") to v2.5.0+ (and use cryptonight_v8 in config)"; + if (majorv + minorv < 20900) { + return "You must update your xmr-stak miner (" + agent + ") to v2.9.0+ (and use cryptonight_r in config)"; } } else if (m = reXNP.exec(agent)) { const majorv = parseInt(m[1]) * 10000; @@ -396,24 +393,24 @@ function Coin(data){ const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; if (version < 3) { - return "You must update your xmr-node-proxy (" + agent + ") to version v0.3.2+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + return "You must update your xmr-node-proxy (" + agent + ") to version v0.8.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } - if (version >= 100 && version < 302) { - return "You must update your xmr-node-proxy (" + agent + ") to version v0.3.2+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (version >= 100 && version < 801) { + return "You must update your xmr-node-proxy (" + agent + ") to version v0.8.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCAST.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 10500) { - return "You must update your cast-xmr miner (" + agent + ") to version v1.5.0+ (and use --algo=10 command line switch)"; + if (majorv + minorv + minorv2 <= 10800) { + return "Your cast-xmr miner (" + agent + ") is no longer supported (please change miner to xmrig-amd)"; } } else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 10608) { - return "You must update your SRBminer (" + agent + ") to version v1.6.8+"; + if (majorv + minorv + minorv2 < 10709) { + return "You must update your SRBminer (" + agent + ") to version v1.7.9+"; } } return false; @@ -432,7 +429,7 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); if (majorv + minorv + minorv2 < 20900) { - return "Please update your xmr-stak miner (" + agent + ") to v2.9.0+ (use monero in config now and cryptonight_r after fork) to support new cn/r Monero algo before March 9 Monero fork"; + return "Please update your xmr-stak miner (" + agent + ") to v2.9.0+ (and use cryptonight_r in config) to support new cn/r Monero algo before March 9 Monero fork"; } } else if (m = reXNP.exec(agent)) { const majorv = parseInt(m[1]) * 10000; @@ -451,7 +448,8 @@ function Coin(data){ } } return false; - }; + }; + }; From 5c4004bce5047f17ee70cc830827207c28b829f3 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sun, 10 Mar 2019 13:35:43 +0300 Subject: [PATCH 0263/1496] Daemon has wrong cumulative_difficulty Send mail if daemon has wrong "cumulative_difficulty" because "block.difficulty != header.difficulty" That daemon needs to resync. --- lib/blockManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 3a26102fb..de4f4c4a8 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -631,6 +631,8 @@ function blockPayments(block) { }); } else { console.error("Can't get correct block header by hash " + block.hash.toString('hex')); + global.support.sendEmail(global.config.general.adminEmail, "blockManager unable to make blockPayments", + "Hello,\r\nThe blockManager has hit an issue making blockPayments with block " + block.hash.toString('hex')); } }); break; From 40b13578537c1946ccfd477962635cd6d219bb20 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sun, 10 Mar 2019 13:48:25 +0300 Subject: [PATCH 0264/1496] Send mail if worker restarted. Before fix about WorkerList if a worker died master thread died too. And after restart master thread sends mail with "Pool online". Now if we have a bug or something worker will be died in circles and we don't know about it. --- lib/pool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index d3e916007..15a0c8b56 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1715,6 +1715,10 @@ if (cluster.isMaster) { console.log('Starting a new worker'); worker = cluster.fork(); worker.on('message', messageHandler); + if (worker.id > 8){ + global.support.sendEmail(global.config.general.adminEmail, "Started new worker " + worker.id, + "Hello,\r\nMaster theread starts new worker with id " + worker.id); + }; }); From d863c88b440dd1f4f4791212d97927d107019a5e Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Mon, 11 Mar 2019 16:53:35 +0300 Subject: [PATCH 0265/1496] remove condition --- lib/pool.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 15a0c8b56..c7da9823b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1715,10 +1715,8 @@ if (cluster.isMaster) { console.log('Starting a new worker'); worker = cluster.fork(); worker.on('message', messageHandler); - if (worker.id > 8){ - global.support.sendEmail(global.config.general.adminEmail, "Started new worker " + worker.id, + global.support.sendEmail(global.config.general.adminEmail, "FYI: Started new worker " + worker.id, "Hello,\r\nMaster theread starts new worker with id " + worker.id); - }; }); From 4ae1686e850bde3c903dde1252036c0dc8e26a8a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 Mar 2019 14:13:53 -0700 Subject: [PATCH 0266/1496] Added separate perf for cn/wow --- lib/coins/xmr.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 86a9d5114..42e197d39 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -295,6 +295,8 @@ function Coin(data){ if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; + if ("cn/wow" in algos_perf) coin_perf["WOW"] = algos_perf["cn/wow"]; + if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; if ("cn-heavy" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; From 2d06e4addc9f5014b7338bca8cd22ff77dbda843 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 Mar 2019 16:12:03 -0700 Subject: [PATCH 0267/1496] Moved cn/r on top of also selection list --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 42e197d39..788b61f73 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -282,8 +282,8 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn"]; - else if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; + if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; + else if ("cn" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn"]; else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/4"]; else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/wow"]; From 2f37f07d2cc98fb236e7748338fd4d2606f2174c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 15:25:44 -0700 Subject: [PATCH 0268/1496] More intellegent stats --- deployment/base.sql | 1 + lib/worker.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 93cdcfd59..8558f09e9 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -242,6 +242,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'bestExchange', 'xmrto', 'string', 'Current best exchange'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'mixIn', '10', 'int', 'Mixin count for coins that support such things.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferLength', '480', 'int', 'Number of items to be cached in the stats buffers.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferHours', '24', 'int', 'Number of hours to be cached in the stats buffers.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pps', 'enable', 'false', 'bool', 'Enable PPS or not'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'shareMulti', '2', 'int', 'Multiply this times difficulty to set the N in PPLNS'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'shareMultiLog', '3', 'int', 'How many times the difficulty of the current block do we keep in shares before clearing them out'); diff --git a/lib/worker.js b/lib/worker.js index c0184ad69..25af96da1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -215,7 +215,14 @@ function updateShareStats() { stats.hashHistory.unshift({ts: currentTime, hs: stats.hash, hs2: stats.hash2}); if (stats.hashHistory.length > global.config.general.statsBufferLength) { while (stats.hashHistory.length > global.config.general.statsBufferLength) { - stats.hashHistory.pop(); + const last_index = stats.hashHistory.size() - 1; + if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { + stats.hashHistory.pop(); + } else { + // here we remove larger indexes (that are more distant in time) with more probability + const index_to_remove = Math.floor((last_index) * (1 - Math.pow(Math.random(), 3))); + stats.hashHistory.slice(index_to_remove, 1); + } } } cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; From 96e80d28a599f88cd7a26014f2bfbb204b377c4d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 15:31:48 -0700 Subject: [PATCH 0269/1496] Fixed array delete --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 25af96da1..0f63e7850 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -220,8 +220,8 @@ function updateShareStats() { stats.hashHistory.pop(); } else { // here we remove larger indexes (that are more distant in time) with more probability - const index_to_remove = Math.floor((last_index) * (1 - Math.pow(Math.random(), 3))); - stats.hashHistory.slice(index_to_remove, 1); + const index_to_remove = Math.floor(last_index * (1 - Math.pow(Math.random(), 3))); + stats.hashHistory.splice(index_to_remove, 1); } } } From 1559668c4b1387e4c704cfccc7e2e9221e3a6192 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 15:34:26 -0700 Subject: [PATCH 0270/1496] Fixed array length --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0f63e7850..9a6bc1ce9 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -215,7 +215,7 @@ function updateShareStats() { stats.hashHistory.unshift({ts: currentTime, hs: stats.hash, hs2: stats.hash2}); if (stats.hashHistory.length > global.config.general.statsBufferLength) { while (stats.hashHistory.length > global.config.general.statsBufferLength) { - const last_index = stats.hashHistory.size() - 1; + const last_index = stats.hashHistory.length - 1; if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { stats.hashHistory.pop(); } else { From e0dbeba09eb22edfe74e085f4a9455a1899e02cd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 15:39:46 -0700 Subject: [PATCH 0271/1496] More graduate old hashrate removal --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 9a6bc1ce9..0ec2a554b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -220,7 +220,7 @@ function updateShareStats() { stats.hashHistory.pop(); } else { // here we remove larger indexes (that are more distant in time) with more probability - const index_to_remove = Math.floor(last_index * (1 - Math.pow(Math.random(), 3))); + const index_to_remove = Math.floor(last_index * (1 - Math.pow(Math.random(), 2))); stats.hashHistory.splice(index_to_remove, 1); } } From 8fb8625a2ee19a97c77c41764b79b1551c912ef8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 18:06:59 -0700 Subject: [PATCH 0272/1496] Fixed rounding --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0ec2a554b..0d40104cb 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -220,7 +220,7 @@ function updateShareStats() { stats.hashHistory.pop(); } else { // here we remove larger indexes (that are more distant in time) with more probability - const index_to_remove = Math.floor(last_index * (1 - Math.pow(Math.random(), 2))); + const index_to_remove = (last_index * (1 - Math.pow(Math.random(), 2))).toFixed(); stats.hashHistory.splice(index_to_remove, 1); } } From 4ddfc6ef55d09e71468faf101e74f7a1ebe778fd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 19:58:07 -0700 Subject: [PATCH 0273/1496] Improved history pow calc --- lib/worker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0d40104cb..277ab86f1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -15,12 +15,17 @@ let prev_pool_workers; let stats_cache = {}; + + function updateShareStats() { // This is an omni-worker to deal with all things share-stats related // Time based averages are worked out on ring buffers. // Buffer lengths? You guessed it, configured in SQL. // Stats timeouts are 30 seconds, so everything for buffers should be there. let currentTime = Date.now(); + // power to ensure we can keep up to global.config.general.statsBufferHours in global.config.general.statsBufferLength array + const history_power = Math.exp(global.config.general.statsBufferHours * Math.log(global.config.general.statsBufferLength) / 60 / global.config.general.statsBufferLength); + async.waterfall([ function (callback) { global.coinFuncs.getLastBlockHeader(function (err, body) { @@ -220,7 +225,7 @@ function updateShareStats() { stats.hashHistory.pop(); } else { // here we remove larger indexes (that are more distant in time) with more probability - const index_to_remove = (last_index * (1 - Math.pow(Math.random(), 2))).toFixed(); + const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); stats.hashHistory.splice(index_to_remove, 1); } } From 68eb4f06f02732590851f1be36b2c5c2f93c733d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 19:58:56 -0700 Subject: [PATCH 0274/1496] Improved history pow calc --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 277ab86f1..470f4043b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -25,6 +25,7 @@ function updateShareStats() { let currentTime = Date.now(); // power to ensure we can keep up to global.config.general.statsBufferHours in global.config.general.statsBufferLength array const history_power = Math.exp(global.config.general.statsBufferHours * Math.log(global.config.general.statsBufferLength) / 60 / global.config.general.statsBufferLength); + comsole.log("History power: " + history_power); async.waterfall([ function (callback) { From 9d029a55f9bc25c4b90bcf63d1b9615f27bfba91 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 19:59:23 -0700 Subject: [PATCH 0275/1496] Improved history pow calc --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 470f4043b..247ef9643 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -25,7 +25,7 @@ function updateShareStats() { let currentTime = Date.now(); // power to ensure we can keep up to global.config.general.statsBufferHours in global.config.general.statsBufferLength array const history_power = Math.exp(global.config.general.statsBufferHours * Math.log(global.config.general.statsBufferLength) / 60 / global.config.general.statsBufferLength); - comsole.log("History power: " + history_power); + console.log("History power: " + history_power); async.waterfall([ function (callback) { From eb7412ec505f9f77f04c9864469bfc147583490b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 20:01:35 -0700 Subject: [PATCH 0276/1496] Improved history pow calc --- lib/worker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 247ef9643..277ab86f1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -25,7 +25,6 @@ function updateShareStats() { let currentTime = Date.now(); // power to ensure we can keep up to global.config.general.statsBufferHours in global.config.general.statsBufferLength array const history_power = Math.exp(global.config.general.statsBufferHours * Math.log(global.config.general.statsBufferLength) / 60 / global.config.general.statsBufferLength); - console.log("History power: " + history_power); async.waterfall([ function (callback) { From bed99275105c3f9a5513619a1007410dfd4977d9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 14 Mar 2019 21:57:13 -0700 Subject: [PATCH 0277/1496] Improved history pow calc --- lib/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 277ab86f1..dde211506 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -24,7 +24,8 @@ function updateShareStats() { // Stats timeouts are 30 seconds, so everything for buffers should be there. let currentTime = Date.now(); // power to ensure we can keep up to global.config.general.statsBufferHours in global.config.general.statsBufferLength array - const history_power = Math.exp(global.config.general.statsBufferHours * Math.log(global.config.general.statsBufferLength) / 60 / global.config.general.statsBufferLength); + const history_power = Math.log(global.config.general.statsBufferLength) / Math.log(global.config.general.statsBufferHours * 60); + console.log("History power: " + history_power); async.waterfall([ function (callback) { From 1ef0aadbe332515a792422116642e50a262b38ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 15 Mar 2019 09:31:18 -0700 Subject: [PATCH 0278/1496] Added more explanations how history_power is computed --- lib/worker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index dde211506..8f21c5855 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -24,6 +24,8 @@ function updateShareStats() { // Stats timeouts are 30 seconds, so everything for buffers should be there. let currentTime = Date.now(); // power to ensure we can keep up to global.config.general.statsBufferHours in global.config.general.statsBufferLength array + // here N = log(history_power, global.config.general.statsBufferLength) is number of attemps required on average to remove top left history point (the oldest one) + // we just select history_power so that is till happen on global.config.general.statsBufferHours * 60 attemps on average const history_power = Math.log(global.config.general.statsBufferLength) / Math.log(global.config.general.statsBufferHours * 60); console.log("History power: " + history_power); From 3a7aef91f61cf2cf0034078dc9e8dcb99217abfe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 15 Mar 2019 10:17:02 -0700 Subject: [PATCH 0279/1496] Put history power to other line --- lib/worker.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 8f21c5855..841efa731 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -27,7 +27,6 @@ function updateShareStats() { // here N = log(history_power, global.config.general.statsBufferLength) is number of attemps required on average to remove top left history point (the oldest one) // we just select history_power so that is till happen on global.config.general.statsBufferHours * 60 attemps on average const history_power = Math.log(global.config.general.statsBufferLength) / Math.log(global.config.general.statsBufferHours * 60); - console.log("History power: " + history_power); async.waterfall([ function (callback) { @@ -41,7 +40,7 @@ function updateShareStats() { }, function (height, callback) { bad_header_stop(global.config.daemon.port); - console.log("Starting stats collection for " + height + " height"); + console.log("Starting stats collection for " + height + " height (history power: " + history_power + ")"); const locTime = currentTime - (hashrate_avg_min*60*1000); const identifierTime = currentTime - (2*hashrate_avg_min*60*1000); From afd09612fbc2766fda4f723511eae0f72ea08585 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 18 Mar 2019 08:51:49 -0700 Subject: [PATCH 0280/1496] Moved to updated LOKI utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b4f75096..f78f202e6 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.0.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.1.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.0" } } From 1a3dd1a90a55e50b1dafae1152775e8c6284ef99 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 18 Mar 2019 08:54:38 -0700 Subject: [PATCH 0281/1496] Updated LOKI support --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 788b61f73..731b6f3ac 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -329,7 +329,7 @@ function Coin(data){ case 18081: return multiHashing.cryptonight(convertedBlob, 13, height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite - case 22023: return multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI + case 22023: return convertedBlob[0] >= 11 ? multiHashing.cryptonight_pico(convertedBlob, 0) : multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero @@ -359,7 +359,7 @@ function Coin(data){ case 18081: return "cn/r"; // XMR case 18981: return "cn/rwz"; // Graft case 20189: return "cn/half"; // Stellite - case 22023: return "cn-heavy/0"; // LOKI + case 22023: return version >= 11 ? "cn-pico/trtl" : "cn-heavy/0"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 31014: return "cn-heavy/xhv"; // Saronite case 34568: return "cn/wow"; // Wownero From 668790be63550ceaea44f3c91a10ca2067089e04 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Mar 2019 16:15:27 -0700 Subject: [PATCH 0282/1496] Loki update --- lib/coins/xmr.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 731b6f3ac..11f4eafea 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -299,8 +299,8 @@ function Coin(data){ if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; - if ("cn-heavy" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; - else if ("cn-heavy/0" in algos_perf) coin_perf["LOKI"] = coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; + if ("cn-heavy" in algos_perf) coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; + else if ("cn-heavy/0" in algos_perf) coin_perf["XRN"] = coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; if ("cn-heavy/tube" in algos_perf) coin_perf["TUBE"] = algos_perf["cn-heavy/tube"]; @@ -309,8 +309,8 @@ function Coin(data){ if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; - if ("cn-pico" in algos_perf) coin_perf["TRTL"] = algos_perf["cn-pico"]; - else if ("cn-pico/trtl" in algos_perf) coin_perf["TRTL"] = algos_perf["cn-pico/trtl"]; + if ("cn-pico" in algos_perf) coin_perf["LOKI"] = coin_perf["TRTL"] = algos_perf["cn-pico"]; + else if ("cn-pico/trtl" in algos_perf) coin_perf["LOKI"] = coin_perf["TRTL"] = algos_perf["cn-pico/trtl"]; return coin_perf; } @@ -329,7 +329,7 @@ function Coin(data){ case 18081: return multiHashing.cryptonight(convertedBlob, 13, height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite - case 22023: return convertedBlob[0] >= 11 ? multiHashing.cryptonight_pico(convertedBlob, 0) : multiHashing.cryptonight_heavy(convertedBlob, 0); // LOKI + case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 31014: return multiHashing.cryptonight_heavy(1); // Saronite case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero @@ -359,7 +359,7 @@ function Coin(data){ case 18081: return "cn/r"; // XMR case 18981: return "cn/rwz"; // Graft case 20189: return "cn/half"; // Stellite - case 22023: return version >= 11 ? "cn-pico/trtl" : "cn-heavy/0"; // LOKI + case 22023: return "cn-pico/trtl"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 31014: return "cn-heavy/xhv"; // Saronite case 34568: return "cn/wow"; // Wownero From bb488acfdb2df48597338380b8f7e9043369fc24 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 11:03:35 -0700 Subject: [PATCH 0283/1496] Added merged mining support --- lib/coins/xmr.js | 155 +++++++++++++++--------- lib/pool.js | 307 +++++++++++++++++++++++++++-------------------- package.json | 2 +- 3 files changed, 280 insertions(+), 184 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 11f4eafea..7178ec61d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -14,6 +14,47 @@ const reXMRSTAK2 = /\w+-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 + +const port2coin = { + "11181": "AEON", + "11898": "TRTL", + "12211": "RYO", + "17750": "XHV", + "18081": "XMR", + "18981": "GRFT", + "20189": "XTL", + "22023": "LOKI", + "24182": "TUBE", + "31014": "XRN", + "34568": "WOW", + "38081": "MSR", + "48782": "LTHN" +}; +const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); +const mm_port_set = { "22023": "11898" }; + +function get_coin2port(port2coin) { + let coin2port = {}; + for (port in port2coin) coin2port[port2coin[port]] = port; + return coin2port; +} +const coin2port = get_coin2port(port2coin); +function get_coins(port2coin) { + let coins = []; + for (port in port2coin) coins.push(port2coin[port]); + return coins; +} +const coins = get_coins(port2coin); +function get_mm_child_port_set(mm_port_set) { + let mm_child_port_set = {}; + for (port in mm_port_set) { + if (!(port in mm_child_port_set[port])) mm_child_port_set[port] = {}; + mm_child_port_set[port][mm_port_set[port]] = 1; + } + return mm_child_port_set; +} +const mm_child_port_set = get_mm_child_port_set(mm_port_set); + function Coin(data){ this.bestExchange = global.config.payout.bestExchange; @@ -158,7 +199,7 @@ function Coin(data){ this.getPortBlockTemplate = function(port, callback){ global.support.rpcPortDaemon(port, 'getblocktemplate', { - reserve_size: 17, + reserve_size: port in mm_port_set ? mm_nonce_size + 16 + 1 : 16 + 1, wallet_address: global.config.pool[port == global.config.daemon.port ? "address" : "address_" + port.toString()] }, function(body){ return callback(body); @@ -210,66 +251,72 @@ function Coin(data){ return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blockBuffer[0])); }; - this.BlockTemplate = function(template) { - /* - Generating a block template is a simple thing. Ask for a boatload of information, and go from there. - Important things to consider. - The reserved space is 16 bytes long now in the following format: - Assuming that the extraNonce starts at byte 130: - |130-133|134-137|138-141|142-145| - |minerNonce/extraNonce - 4 bytes|instanceId - 4 bytes|clientPoolNonce - 4 bytes|clientNonce - 4 bytes| - This is designed to allow a single block template to be used on up to 4 billion poolSlaves (clientPoolNonce) - Each with 4 billion clients. (clientNonce) - While being unique to this particular pool thread (instanceId) - With up to 4 billion clients (minerNonce/extraNonce) - Overkill? Sure. But that's what we do here. Overkill. - */ - - // Set this.blob equal to the BT blob that we get from upstream. - this.blob = template.blocktemplate_blob; - this.idHash = crypto.createHash('md5').update(template.blocktemplate_blob).digest('hex'); - // Set this.diff equal to the known diff for this block. - this.difficulty = template.difficulty; - // Set this.height equal to the known height for this block. - this.height = template.height; + this.BlockTemplate = function(template, activeBlockTemplates) { + // Generating a block template is a simple thing. Ask for a boatload of information, and go from there. + // Important things to consider. + // The reserved space is 16 bytes long now in the following format: + // Assuming that the extraNonce starts at byte 130: + // |130-133|134-137|138-141|142-145| + // |minerNonce/extraNonce - 4 bytes|instanceId - 4 bytes|clientPoolNonce - 4 bytes|clientNonce - 4 bytes| + // This is designed to allow a single block template to be used on up to 4 billion poolSlaves (clientPoolNonce) + // Each with 4 billion clients. (clientNonce) + // While being unique to this particular pool thread (instanceId) + // With up to 4 billion clients (minerNonce/extraNonce) + // Overkill? Sure. But that's what we do here. Overkill. + + // Set these params equal to values we get from upstream. + this.blocktemplate_blob = template.blocktemplate_blob; + this.prev_hash = template.prev_hash; + this.difficulty = template.difficulty; + this.height = template.height; + this.coin = template.coin; + this.port = template.port; + + this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); + + const is_mm = port in mm_port_set; + // Set this.reserveOffset to the byte location of the reserved offset. - this.reserveOffset = template.reserved_offset; - // Set this.buffer to the binary decoded version of the BT blob. - this.buffer = new Buffer(this.blob, 'hex'); + this.reserveOffset = template.reserved_offset + (is_mm ? mm_nonce_size : 0); + // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. + this.buffer = new Buffer(this.blocktemplate_blob, 'hex'); + + const child_coin = port2coin[mm_port_set[port]]; + if (is_mm && child_coin in activeBlockTemplates) { + this.child_template = activeBlockTemplates[child_coin]; + this.buffer = cnUtil.construct_mm_parent_block_blob( + this.buffer, this.portBlobType(template.port, this.buffer[0]), this.child_template.buffer + ); + } + // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 4); - // Generate a clean, shiny new buffer. - this.previous_hash = new Buffer(32); - // Copy in bytes 7 through 39 to this.previous_hash from the current BT. - this.buffer.copy(this.previous_hash, 0, 7, 39); - // Reset the Nonce. - This is the per-miner/pool nonce + // Reset the Nonce - this is the per-miner/pool nonce this.extraNonce = 0; // The clientNonceLocation is the location at which the client pools should set the nonces for each of their clients. this.clientNonceLocation = this.reserveOffset + 12; // The clientPoolLocation is for multi-thread/multi-server pools to handle the nonce for each of their tiers. this.clientPoolLocation = this.reserveOffset + 8; - // this is current coin - this.coin = template.coin; - // this is current daemon port - this.port = template.port; + this.nextBlob = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset); - // Convert the blob into something hashable. + // Convert the blocktemplate_blob into something hashable. return global.coinFuncs.convertBlob(this.buffer, this.port).toString('hex'); }; - // Make it so you can get the raw block blob out. + // Make it so you can get the raw block blocktemplate_blob out. this.nextBlobWithChildNonce = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset); - // Don't convert the blob to something hashable. You bad. + // Don't convert the blocktemplate_blob to something hashable. You bad. return this.buffer.toString('hex'); }; }; - this.getCOINS = function() { - return [ "GRFT", "LTHN", "RYO", "LOKI", "TUBE", "XHV", "AEON", "MSR", "XTL", "TRTL", "XRN", "WOW" ]; - } + this.getCOINS = function() { return coins; } + this.getPORT2COIN = function() { return port2coin; } + this.getMM_PORTS = function() { return mm_port_set; } + this.getMM_CHILD_PORTS = function() { return get_mm_child_port_set; } this.getDefaultAlgos = function() { return [ "cn/r" ]; @@ -322,19 +369,19 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, port, height) { switch (port) { - case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon - case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL - case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO - case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, 13, height); // XMR - case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft - case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite - case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI - case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - case 31014: return multiHashing.cryptonight_heavy(1); // Saronite - case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero - case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, 13, height); // Lethean + case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon + case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL + case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO + case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven + case 18081: return multiHashing.cryptonight(convertedBlob, 13, height); // XMR + case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft + case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite + case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI + case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube + case 31014: return multiHashing.cryptonight_heavy(1); // Saronite + case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero + case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR + case 48782: return multiHashing.cryptonight(convertedBlob, 13, height); // Lethean default: return multiHashing.cryptonight(convertedBlob, 8); } } diff --git a/lib/pool.js b/lib/pool.js index e98f81630..6d50c67d4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -19,10 +19,10 @@ let baseDiff = global.coinFuncs.baseDiff(); let activeMiners = new Map(); -let lastBlockHash = {}; // coin key -let lastCoinHashFactor = {}; // coin key -let currCoinHashFactor = {}; // coin key -let activeBlockTemplate = {}; // coin key +let lastBlockHash = {}; // coin key +let lastCoinHashFactor = {}; // coin key +let currCoinHashFactor = {}; // coin key +let activeBlockTemplates = {}; // coin key let pastBlockTemplates = global.support.circularBuffer(10); @@ -274,17 +274,17 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { - rpcResponse = rpcResponse.result; - rpcResponse.coin = coin; - rpcResponse.port = activePort; - rpcResponse.coinHashFactor = coinHashFactor; - rpcResponse.isHashFactorChange = isHashFactorChange; - debug(threadName + "New block template found at " + rpcResponse.height + " height"); + let template = rpcResponse.result; + template.coin = coin; + template.port = activePort; + template.coinHashFactor = coinHashFactor; + template.isHashFactorChange = isHashFactorChange; + debug(threadName + "New block template found at " + template.height + " height"); if (cluster.isMaster) { - sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); - setNewBlockTemplate(rpcResponse); + sendToWorkers({type: 'newBlockTemplate', data: template}); + setNewBlockTemplate(template); } else { - setNewBlockTemplate(rpcResponse); + setNewBlockTemplate(template); } } else { console.error("Block template request failed for " + activePort + " port."); @@ -340,7 +340,7 @@ let anchorBlockPrevHeight; // update main chain anchor block height for alt chain block // anchorBlockUpdate is only called in worker threads function anchorBlockUpdate() { - if (("" in activeBlockTemplate) && global.config.daemon.port == activeBlockTemplate[""].port) return; + if (("" in activeBlockTemplates) && global.config.daemon.port == activeBlockTemplates[""].port) return; // only need to do that separately if we mine alt chain global.coinFuncs.getLastBlockHeader(function (err, body) { if (err === null) { @@ -358,13 +358,13 @@ function anchorBlockUpdate() { function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; if (coin !== "") set_hash_factor(coin, coinHashFactor); // used in miner.selectBestCoin - if (!(coin in activeBlockTemplate)) return; + if (!(coin in activeBlockTemplates)) return; const time_before = Date.now(); if (isHashFactorChange) { - const port = activeBlockTemplate[coin].port; - const block_version = activeBlockTemplate[coin].buffer[0]; + const port = activeBlockTemplates[coin].port; + const block_version = activeBlockTemplates[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed to " + coinHashFactor); @@ -410,14 +410,26 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he function setNewBlockTemplate(template) { const coin = template.coin; let isExtraCheck = false; - if (coin in activeBlockTemplate) { - if (activeBlockTemplate[coin].previous_hash.toString('hex') === template.prev_hash) { - console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); - return; + if (coin in activeBlockTemplates) { + if (activeBlockTemplates[coin].prev_hash.toString('hex') === template.prev_hash) { + if (template.port in global.coinFuncs.getMM_PORTS()) { + const child_coin_port = global.coinFuncs.getMM_PORTS()[template.port]; + const child_coin = global.coinFuncs.getPORT2COIN()[child_coin_port]; + if (child_coin in activeBlockTemplates && "child_template" in template) { + const child_template = activeBlockTemplates[child_coin]; + if (child_template.prev_hash.toString('hex') === template.child_template.prev_hash) { + console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); + return; + } + } + } else { + console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); + return; + } } - activeBlockTemplate[coin].timeOutdate = Date.now() + 4*1000; - pastBlockTemplates.enq(activeBlockTemplate[coin]); - if (activeBlockTemplate[coin].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; + activeBlockTemplates[coin].timeOutdate = Date.now() + 4*1000; + pastBlockTemplates.enq(activeBlockTemplates[coin]); + if (activeBlockTemplates[coin].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { const coin_str = coin === "" ? "" : coin + " "; @@ -426,10 +438,22 @@ function setNewBlockTemplate(template) { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } - activeBlockTemplate[coin] = new BlockTemplate(template); - const height = activeBlockTemplate[coin].height; + activeBlockTemplates[coin] = new BlockTemplate(template, activeBlockTemplates); - if (coin === "" && global.config.daemon.port == activeBlockTemplate[""].port) { + // update parent coins if current coin was updated now + if (template.port in global.coinFuncs.getMM_CHILD_PORTS()) { + const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[template.port]; + for (parent_port in parent_ports) { + const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; + if (parent_coin in activeBlockTemplates) { + process.send ({type: 'newBlockTemplate', data: activeBlockTemplates[parent_coin]}); + sendToWorkers({type: 'newBlockTemplate', data: activeBlockTemplates[parent_coin]}); + } + } + } + const height = activeBlockTemplates[coin].height; + + if (coin === "" && global.config.daemon.port == activeBlockTemplates[""].port) { anchorBlockHeight = height; } @@ -534,7 +558,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return; } - if (!("" in activeBlockTemplate)) { + if (!("" in activeBlockTemplates)) { this.error = "No active block template"; this.valid_miner = false; return; @@ -684,8 +708,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coin_perf"); return; } - if (!(coin in activeBlockTemplate)) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplate"); + if (!(coin in activeBlockTemplates)) { + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplates"); return; } const coinHashFactor = currCoinHashFactor[coin]; @@ -693,7 +717,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); return; } - const bt = activeBlockTemplate[coin]; + const bt = activeBlockTemplates[coin]; const port = bt.port; const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); @@ -723,7 +747,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.curr_coin = best_coin; this.curr_coin_time = Date.now(); - if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplate[best_coin].height; + if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplates[best_coin].height; } return best_coin; } @@ -841,7 +865,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.getCoinJob = function (coin) { - let bt = activeBlockTemplate[coin]; + let bt = activeBlockTemplates[coin]; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; this.jobLastBlockHash = bt.idHash; if (this.newDiffToSet) { @@ -899,7 +923,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); const algo_name = global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]); this.cachedJob = { - blocktemplate_blob: blob, + blocktemplate_blob: blob, blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), algo: algo_name, variant: variant_name, @@ -1122,7 +1146,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy process.send({type: 'normalShare'}); debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); } - if (activeBlockTemplate[blockTemplate.coin].idHash !== job.blockHash) { + if (activeBlockTemplates[blockTemplate.coin].idHash !== job.blockHash) { process.send({type: 'outdatedShare'}); } @@ -1145,15 +1169,81 @@ function getShareBuffer(miner, job, blockTemplate, params) { let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex'), blockTemplate.port); return shareBuffer; } catch (e) { - console.error("Can't constructNewBlob with " + nonce + " nonce from " + miner.logString + ": " + e); - global.support.sendEmail(global.config.general.adminEmail, - "FYI: Can't constructNewBlob", - "Can't constructNewBlob with " + nonce + " nonce from " + miner.logString + ": " + e - ); + const err_str = "Can't constructNewBlob with " + nonce + " nonce from " + miner.logString + ": " + e; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't constructNewBlob", err_str); return null; } } + +function invalid_share(miner) { + process.send({type: 'invalidShare'}); + miner.sendNewJob(); + walletTrust[miner.payout] = 0; + return false; +} + +function submit_block(miner, job, blockTemplate, shareBuffer, retry) { + global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { + if (rpcResult.error) { + // Did not manage to submit a block. Log and continue on. + recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); + let isNotifyAdmin = true; + if (shareType) { + let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); + hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); + if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; + } + + console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); + + if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time + global.coinFuncs.getPortLastBlockHeader(blockTemplate.port, function(err, body) { + if (err !== null) { + console.error("Last block header request failed for " + blockTemplate.port + " port!"); + return; + } + if (blockTemplate.height == body.height + 1) global.support.sendEmail(global.config.general.adminEmail, + "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", + "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + + "Input: " + shareBuffer.toString('hex') + "\n" + + threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + ); + }); + }, 2*1000); + + if (global.config.pool.trustedMiners) { + debug(threadName + "Share trust broken by " + miner.logString); + miner.trust.probability = 256; + miner.trust.penalty = global.config.pool.trustPenalty; + miner.trust.threshold = global.config.pool.trustThreshold; + walletTrust[miner.payout] = 0; + } + } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { + // Success! Submitted a block without an issue. + const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); + console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + blockTemplate.height + " by " + miner.logString + + ", share type: " + shareType + " - submit result: " + JSON.stringify(rpcResult.result) + ); + recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, shareType, blockTemplate); + } else { + if (retry) { + setTimeout(submit_block, 500, false); + } else { + // RPC bombed out massively. + console.error(threadName + "RPC Error. Please check logs for details"); + global.support.sendEmail(global.config.general.adminEmail, + "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", + "Input: " + shareBuffer.toString('hex') + "\n" + + "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + + "RPC Error. Please check logs for details" + ); + } + } + }); +} + function processShare(miner, job, blockTemplate, params) { let hash; let shareType; @@ -1168,10 +1258,7 @@ function processShare(miner, job, blockTemplate, params) { try { hash = new Buffer(resultHash, 'hex'); } catch (err) { - process.send({type: 'invalidShare'}); - miner.sendNewJob(); - walletTrust[miner.payout] = 0; - return false; + return invalid_share(miner); } shareType = true; } else { // verify share @@ -1185,12 +1272,7 @@ function processShare(miner, job, blockTemplate, params) { return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer === null) { - process.send({type: 'invalidShare'}); - miner.sendNewJob(); - walletTrust[miner.payout] = 0; - return false; - } + if (shareBuffer === null) return invalid_share(miner); let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); @@ -1200,10 +1282,7 @@ function processShare(miner, job, blockTemplate, params) { console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (miner.trust.probability == 256 ? " [banned]" : "")); lastMinerLogTime[miner.payout] = time_now; } - process.send({type: 'invalidShare'}); - miner.sendNewJob(); - walletTrust[miner.payout] = 0; - return false; + return invalid_share(miner); } ++ walletTrust[miner.payout]; @@ -1211,70 +1290,41 @@ function processShare(miner, job, blockTemplate, params) { } let hashArray = hash.toByteArray().reverse(); - let hashNum = bignum.fromBuffer(new Buffer(hashArray)); - let hashDiff = baseDiff.div(hashNum); - - if (hashDiff.ge(blockTemplate.difficulty)) { - // Submit block to the RPC Daemon. - // Todo: Implement within the coins/.js file. - if (!shareBuffer) shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - function submit_block(retry) { - global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { - if (rpcResult.error) { - // Did not manage to submit a block. Log and continue on. - recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); - let isNotifyAdmin = true; - if (shareType) { - let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); - if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; - } - console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate[blockTemplate.coin].height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); - if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time - global.coinFuncs.getPortLastBlockHeader(blockTemplate.port, function(err, body){ - if (err !== null) { - console.error("Last block header request failed for " + blockTemplate.port + " port!"); - return; - } - if (job.height == body.height + 1) global.support.sendEmail(global.config.general.adminEmail, - "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", - "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + - "Input: " + shareBuffer.toString('hex') + "\n" + - threadName + "Error submitting block at " + job.height + " height from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) - ); - }); - }, 2*1000); - if (global.config.pool.trustedMiners) { - debug(threadName + "Share trust broken by " + miner.logString); - miner.trust.probability = 256; - miner.trust.penalty = global.config.pool.trustPenalty; - miner.trust.threshold = global.config.pool.trustThreshold; - walletTrust[miner.payout] = 0; - } - } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { - //Success! Submitted a block without an issue. - let blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); - console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + job.height + " by " + miner.logString + - ", share type: " + shareType + " - submit result: " + JSON.stringify(rpcResult.result) - ); - recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, shareType, blockTemplate); - } else { - if (retry) { - setTimeout(submit_block, 500, false); - } else { - // RPC bombed out massively. - console.error(threadName + "RPC Error. Please check logs for details"); - global.support.sendEmail(global.config.general.adminEmail, - "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", - "Input: " + shareBuffer.toString('hex') + "\n" + - "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + - "RPC Error. Please check logs for details" - ); - } - } - }); + let hashNum = bignum.fromBuffer(new Buffer(hashArray)); + let hashDiff = baseDiff.div(hashNum); + + let is_block_diff_matched = false; + + if (hashDiff.ge(blockTemplate.difficulty)) { // Submit block to the RPC Daemon. + if (!shareBuffer) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (!shareBuffer) return invalid_share(miner); + } + submit_block(miner, job, blockTemplate, shareBuffer, true); + is_block_diff_matched = true; + } + + if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. + if (!shareBuffer) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (!shareBuffer) return invalid_share(miner); + } + let shareBuffer2; + try { + shareBuffer2 = cnUtil.construct_mm_child_block_blob( + shareBuffer, this.portBlobType(blockTemplate.port, blockTemplate.buffer[0]), blockTemplate.child_template.buffer + ); + } catch (e) { + const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template.buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't construct_mm_child_block_blob", err_str); + return invalid_share(miner); } - if (shareBuffer) submit_block(true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, true); + is_block_diff_matched = true; + } + + if (is_block_diff_matched) { // Do nothing here } else if (hashDiff.lt(job.difficulty)) { let time_now = Date.now(); @@ -1282,8 +1332,7 @@ function processShare(miner, job, blockTemplate, params) { console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString + (miner.trust.probability == 256 ? " [banned]" : "")); lastMinerLogTime[miner.payout] = time_now; } - process.send({type: 'invalidShare'}); - return false; + return invalid_share(miner); } else { recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); @@ -1464,7 +1513,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply let blockTemplate; job.rewarded_difficulty = job.difficulty; - if (activeBlockTemplate[job.coin].idHash !== job.blockHash) { + if (activeBlockTemplates[job.coin].idHash !== job.blockHash) { blockTemplate = pastBlockTemplates.toarray().filter(function (t) { return t.idHash === job.blockHash; })[0]; @@ -1495,7 +1544,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } } else { - blockTemplate = activeBlockTemplate[job.coin]; + blockTemplate = activeBlockTemplates[job.coin]; } job.rewarded_difficulty2 = job.rewarded_difficulty * job.coinHashFactor; @@ -1528,8 +1577,8 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply debug(threadName + "Share trust broken by " + miner.logString); global.database.storeInvalidShare(miner.invalidShareProto); miner.trust.probability = 256; - miner.trust.penalty = global.config.pool.trustPenalty; - miner.trust.threshold = global.config.pool.trustThreshold; + miner.trust.penalty = global.config.pool.trustPenalty; + miner.trust.threshold = global.config.pool.trustThreshold; } } @@ -1585,7 +1634,7 @@ setInterval(function dump_vars() { s.write(JSON.stringify(currCoinHashFactor, null, '\t') + "\n"); s.write("\n\n\nactiveBlockTemplate:\n"); - s.write(JSON.stringify(activeBlockTemplate, null, '\t') + "\n"); + s.write(JSON.stringify(activeBlockTemplates, null, '\t') + "\n"); s.write("\n\n\nproxyMiners:\n"); s.write(JSON.stringify(proxyMiners, null, '\t') + "\n"); @@ -1623,8 +1672,8 @@ if (cluster.isMaster) { registerPool(); setInterval(function () { - if ("" in activeBlockTemplate) { - global.mysql.query("UPDATE pools SET last_checkin = ?, active = ?, blockIDTime = now(), blockID = ?, port = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, activeBlockTemplate[""].height, activeBlockTemplate[""].port, global.config.pool_id]); + if ("" in activeBlockTemplates) { + global.mysql.query("UPDATE pools SET last_checkin = ?, active = ?, blockIDTime = now(), blockID = ?, port = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, activeBlockTemplates[""].height, activeBlockTemplates[""].port, global.config.pool_id]); } else { global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]); } @@ -1637,12 +1686,12 @@ if (cluster.isMaster) { setInterval(function () { - if (!("" in activeBlockTemplate)) return; + if (!("" in activeBlockTemplates)) return; global.mysql.query("SELECT blockID, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { let top_height = 0; - const port = activeBlockTemplate[""].port; - const height = activeBlockTemplate[""].height; + const port = activeBlockTemplates[""].port; + const height = activeBlockTemplates[""].height; rows.forEach(function (row) { if (row.port != port) return; if (row.blockID > top_height) top_height = row.blockID; diff --git a/package.json b/package.json index f78f202e6..d3067c8bf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v4.1.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.0" } } From 591d7f275f63fa6025d8cdd351ae7b12611b5058 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 11:54:42 -0700 Subject: [PATCH 0284/1496] Fixed for loops --- lib/coins/xmr.js | 6 +++--- lib/pool.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7178ec61d..15cbaf655 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -35,19 +35,19 @@ const mm_port_set = { "22023": "11898" }; function get_coin2port(port2coin) { let coin2port = {}; - for (port in port2coin) coin2port[port2coin[port]] = port; + for (let port in port2coin) coin2port[port2coin[port]] = port; return coin2port; } const coin2port = get_coin2port(port2coin); function get_coins(port2coin) { let coins = []; - for (port in port2coin) coins.push(port2coin[port]); + for (let port in port2coin) coins.push(port2coin[port]); return coins; } const coins = get_coins(port2coin); function get_mm_child_port_set(mm_port_set) { let mm_child_port_set = {}; - for (port in mm_port_set) { + for (let port in mm_port_set) { if (!(port in mm_child_port_set[port])) mm_child_port_set[port] = {}; mm_child_port_set[port][mm_port_set[port]] = 1; } diff --git a/lib/pool.js b/lib/pool.js index 6d50c67d4..e1ef40533 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -443,7 +443,7 @@ function setNewBlockTemplate(template) { // update parent coins if current coin was updated now if (template.port in global.coinFuncs.getMM_CHILD_PORTS()) { const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[template.port]; - for (parent_port in parent_ports) { + for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; if (parent_coin in activeBlockTemplates) { process.send ({type: 'newBlockTemplate', data: activeBlockTemplates[parent_coin]}); From a10692d5de297030ceb75786c6e7f509eb209198 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 11:55:48 -0700 Subject: [PATCH 0285/1496] Fixed set usage --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 15cbaf655..27f40bd6a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -48,7 +48,7 @@ const coins = get_coins(port2coin); function get_mm_child_port_set(mm_port_set) { let mm_child_port_set = {}; for (let port in mm_port_set) { - if (!(port in mm_child_port_set[port])) mm_child_port_set[port] = {}; + if (!(port in mm_child_port_set)) mm_child_port_set[port] = {}; mm_child_port_set[port][mm_port_set[port]] = 1; } return mm_child_port_set; From 5db24273321485f48bd431b64db2e6be5c6690b3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 11:57:19 -0700 Subject: [PATCH 0286/1496] Fixed this.port usage --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 27f40bd6a..9a7179e7f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -274,18 +274,18 @@ function Coin(data){ this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); - const is_mm = port in mm_port_set; + const is_mm = this.port in mm_port_set; // Set this.reserveOffset to the byte location of the reserved offset. this.reserveOffset = template.reserved_offset + (is_mm ? mm_nonce_size : 0); // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. this.buffer = new Buffer(this.blocktemplate_blob, 'hex'); - const child_coin = port2coin[mm_port_set[port]]; + const child_coin = port2coin[mm_port_set[this.port]]; if (is_mm && child_coin in activeBlockTemplates) { this.child_template = activeBlockTemplates[child_coin]; this.buffer = cnUtil.construct_mm_parent_block_blob( - this.buffer, this.portBlobType(template.port, this.buffer[0]), this.child_template.buffer + this.buffer, this.portBlobType(this.port, this.buffer[0]), this.child_template.buffer ); } From 0be759865976c478209e1d833c3e1adf7332ec7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 12:47:34 -0700 Subject: [PATCH 0287/1496] Fixed this.portBlobType usage --- lib/coins/xmr.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9a7179e7f..4c61c82e5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -30,6 +30,21 @@ const port2coin = { "38081": "MSR", "48782": "LTHN" }; +const port2blob_num = { + "11181": 0, // AEON + "11898": 2, // TRTL + "12211": 4, // RYO + "17750": 0, // XHV + "18081": 0, // XMR + "18981": 0, // GRFT + "20189": 0, // XTL + "22023": 5, // LOKI + "24182": 0, // TUBE + "31014": 5, // XRN + "34568": 0, // WOW + "38081": 6, // MSR + "48782": 0, // LTHN +}; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); const mm_port_set = { "22023": "11898" }; @@ -54,7 +69,6 @@ function get_mm_child_port_set(mm_port_set) { return mm_child_port_set; } const mm_child_port_set = get_mm_child_port_set(mm_port_set); - function Coin(data){ this.bestExchange = global.config.payout.bestExchange; @@ -228,16 +242,7 @@ function Coin(data){ return cnUtil.address_decode_integrated(address) === this.intPrefix; }; - this.portBlobType = function(port, version) { - switch (port) { - case 11898: return 2; // TRTL - case 12211: return 4; // RYO - case 22023: return 5; // LOKI - case 31014: return 5; // XRN - case 38081: return 6; // MSR - default: return 0; - } - } + this.portBlobType = function(port, version) { return port2blob_num[port]; } this.convertBlob = function(blobBuffer, port){ return cnUtil.convert_blob(blobBuffer, this.portBlobType(port, blobBuffer[0])); @@ -285,7 +290,7 @@ function Coin(data){ if (is_mm && child_coin in activeBlockTemplates) { this.child_template = activeBlockTemplates[child_coin]; this.buffer = cnUtil.construct_mm_parent_block_blob( - this.buffer, this.portBlobType(this.port, this.buffer[0]), this.child_template.buffer + this.buffer, global.coinFuncs.portBlobType(this.port, this.buffer[0]), this.child_template.buffer ); } From ae14c0deb6afe58a5071979adc61686fea4aa1c6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 12:54:05 -0700 Subject: [PATCH 0288/1496] Added prev_hash check --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4c61c82e5..6b72e3b13 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -271,6 +271,7 @@ function Coin(data){ // Set these params equal to values we get from upstream. this.blocktemplate_blob = template.blocktemplate_blob; + if (!("prev_hash" in template)) console.err("NOT DEFINED PREV_HASH FOR " + template.port); this.prev_hash = template.prev_hash; this.difficulty = template.difficulty; this.height = template.height; From 683e68b9b1251827fc0621a7fa90ec31cf61b09d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 12:54:58 -0700 Subject: [PATCH 0289/1496] Added prev_hash check --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6b72e3b13..59a92833d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -271,7 +271,7 @@ function Coin(data){ // Set these params equal to values we get from upstream. this.blocktemplate_blob = template.blocktemplate_blob; - if (!("prev_hash" in template)) console.err("NOT DEFINED PREV_HASH FOR " + template.port); + if (!("prev_hash" in template)) console.error("NOT DEFINED PREV_HASH FOR " + template.port); this.prev_hash = template.prev_hash; this.difficulty = template.difficulty; this.height = template.height; From 117271cba98e4080482ef104c87eb2d274be2eb2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 12:58:42 -0700 Subject: [PATCH 0290/1496] Fixed missed prev_hash for TRTL block --- lib/coins/xmr.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 59a92833d..2126cb0a2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -271,8 +271,6 @@ function Coin(data){ // Set these params equal to values we get from upstream. this.blocktemplate_blob = template.blocktemplate_blob; - if (!("prev_hash" in template)) console.error("NOT DEFINED PREV_HASH FOR " + template.port); - this.prev_hash = template.prev_hash; this.difficulty = template.difficulty; this.height = template.height; this.coin = template.coin; @@ -287,6 +285,14 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. this.buffer = new Buffer(this.blocktemplate_blob, 'hex'); + if (!("prev_hash" in template)) { // Get prev_hash from blob + let prev_hash = new Buffer(32); + this.buffer.copy(prev_hash, 0, 7, 39); + this.prev_hash = prev_hash.toString('hex'); + } else { + this.prev_hash = template.prev_hash; + } + const child_coin = port2coin[mm_port_set[this.port]]; if (is_mm && child_coin in activeBlockTemplates) { this.child_template = activeBlockTemplates[child_coin]; From 09600f8b783eb23f7449f2ef194f549479b882be Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 12:59:13 -0700 Subject: [PATCH 0291/1496] Fixed missed prev_hash for TRTL block --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e1ef40533..445f3774f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -411,13 +411,13 @@ function setNewBlockTemplate(template) { const coin = template.coin; let isExtraCheck = false; if (coin in activeBlockTemplates) { - if (activeBlockTemplates[coin].prev_hash.toString('hex') === template.prev_hash) { + if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { if (template.port in global.coinFuncs.getMM_PORTS()) { const child_coin_port = global.coinFuncs.getMM_PORTS()[template.port]; const child_coin = global.coinFuncs.getPORT2COIN()[child_coin_port]; if (child_coin in activeBlockTemplates && "child_template" in template) { const child_template = activeBlockTemplates[child_coin]; - if (child_template.prev_hash.toString('hex') === template.child_template.prev_hash) { + if (child_template.prev_hash === template.child_template.prev_hash) { console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From 96add999aedbc74b5ae16359bfdd856ba92d1a0c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 13:04:01 -0700 Subject: [PATCH 0292/1496] Added logs --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 445f3774f..82fc21520 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1311,6 +1311,7 @@ function processShare(miner, job, blockTemplate, params) { } let shareBuffer2; try { + console.log("MERGED MINING: cnUtil.construct_mm_child_block_blob"); shareBuffer2 = cnUtil.construct_mm_child_block_blob( shareBuffer, this.portBlobType(blockTemplate.port, blockTemplate.buffer[0]), blockTemplate.child_template.buffer ); From 5159f44e3ebb06544d27c92644eb391be0586849 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 13:04:04 -0700 Subject: [PATCH 0293/1496] Added logs --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2126cb0a2..0c5acdf41 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -295,6 +295,7 @@ function Coin(data){ const child_coin = port2coin[mm_port_set[this.port]]; if (is_mm && child_coin in activeBlockTemplates) { + console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); this.child_template = activeBlockTemplates[child_coin]; this.buffer = cnUtil.construct_mm_parent_block_blob( this.buffer, global.coinFuncs.portBlobType(this.port, this.buffer[0]), this.child_template.buffer From 2d783a8a9e116ec8a25fdade30636dbeead993d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 13:14:49 -0700 Subject: [PATCH 0294/1496] Fixed parent block creation --- lib/coins/xmr.js | 17 ++++++++++------- lib/pool.js | 5 +++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0c5acdf41..0b65d4c43 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,13 +293,16 @@ function Coin(data){ this.prev_hash = template.prev_hash; } - const child_coin = port2coin[mm_port_set[this.port]]; - if (is_mm && child_coin in activeBlockTemplates) { - console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); - this.child_template = activeBlockTemplates[child_coin]; - this.buffer = cnUtil.construct_mm_parent_block_blob( - this.buffer, global.coinFuncs.portBlobType(this.port, this.buffer[0]), this.child_template.buffer - ); + if (is_mm) { + const child_coin = port2coin[mm_port_set[this.port]]; + if (child_coin in activeBlockTemplates) { + console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); + this.child_template = activeBlockTemplates[child_coin]; + this.child_template_buffer = this.child_template.buffer; + this.buffer = cnUtil.construct_mm_parent_block_blob( + this.buffer, global.coinFuncs.portBlobType(this.port, this.buffer[0]), this.child_template_buffer + ); + } } // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. diff --git a/lib/pool.js b/lib/pool.js index 82fc21520..d7182f7df 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1309,11 +1309,11 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } - let shareBuffer2; + let shareBuffer2 = null; try { console.log("MERGED MINING: cnUtil.construct_mm_child_block_blob"); shareBuffer2 = cnUtil.construct_mm_child_block_blob( - shareBuffer, this.portBlobType(blockTemplate.port, blockTemplate.buffer[0]), blockTemplate.child_template.buffer + shareBuffer, this.portBlobType(blockTemplate.port, blockTemplate.buffer[0]), blockTemplate.child_template_buffer ); } catch (e) { const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template.buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; @@ -1321,6 +1321,7 @@ function processShare(miner, job, blockTemplate, params) { global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't construct_mm_child_block_blob", err_str); return invalid_share(miner); } + if (shareBuffer2 === null) return invalid_share(miner); submit_block(miner, job, blockTemplate.child_template, shareBuffer2, true); is_block_diff_matched = true; } From 9e7f1ea8349a5f4fc52b6d3cefac5503914d7d6e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:20:37 -0700 Subject: [PATCH 0295/1496] Moved parent block creation to master --- lib/coins/xmr.js | 34 ++++++++++++++-------------------- lib/pool.js | 40 +++++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0b65d4c43..0a812dcf2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -20,7 +20,7 @@ const port2coin = { "11898": "TRTL", "12211": "RYO", "17750": "XHV", - "18081": "XMR", + "18081": "", "18981": "GRFT", "20189": "XTL", "22023": "LOKI", @@ -256,7 +256,7 @@ function Coin(data){ return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blockBuffer[0])); }; - this.BlockTemplate = function(template, activeBlockTemplates) { + this.BlockTemplate = function(template) { // Generating a block template is a simple thing. Ask for a boatload of information, and go from there. // Important things to consider. // The reserved space is 16 bytes long now in the following format: @@ -276,14 +276,20 @@ function Coin(data){ this.coin = template.coin; this.port = template.port; - this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); - const is_mm = this.port in mm_port_set; + if (is_mm) { + this.child_template = template.child_template; + this.child_template_buffer = template.child_template_buffer; + } + const blob = is_mm ? template.parent_blocktemplate_blob : this.blocktemplate_blob; + + this.idHash = crypto.createHash('md5').update(blob).digest('hex'); + // Set this.reserveOffset to the byte location of the reserved offset. this.reserveOffset = template.reserved_offset + (is_mm ? mm_nonce_size : 0); // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. - this.buffer = new Buffer(this.blocktemplate_blob, 'hex'); + this.buffer = new Buffer(blob, 'hex'); if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); @@ -293,18 +299,6 @@ function Coin(data){ this.prev_hash = template.prev_hash; } - if (is_mm) { - const child_coin = port2coin[mm_port_set[this.port]]; - if (child_coin in activeBlockTemplates) { - console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); - this.child_template = activeBlockTemplates[child_coin]; - this.child_template_buffer = this.child_template.buffer; - this.buffer = cnUtil.construct_mm_parent_block_blob( - this.buffer, global.coinFuncs.portBlobType(this.port, this.buffer[0]), this.child_template_buffer - ); - } - } - // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 4); // Reset the Nonce - this is the per-miner/pool nonce @@ -317,14 +311,14 @@ function Coin(data){ this.nextBlob = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset); - // Convert the blocktemplate_blob into something hashable. + // Convert the buffer into something hashable. return global.coinFuncs.convertBlob(this.buffer, this.port).toString('hex'); }; - // Make it so you can get the raw block blocktemplate_blob out. + // Make it so you can get the raw block buffer out. this.nextBlobWithChildNonce = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset); - // Don't convert the blocktemplate_blob to something hashable. You bad. + // Don't convert the buffer to something hashable. You bad. return this.buffer.toString('hex'); }; }; diff --git a/lib/pool.js b/lib/pool.js index d7182f7df..baae9c779 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -266,6 +266,29 @@ function updateActivePort(coin) { }); } +function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange) { + let template = rpc_template; + + template.coin = coin; + template.port = activePort; + template.coinHashFactor = coinHashFactor; + template.isHashFactorChange = isHashFactorChange; + + if (port in global.coinFuncs.getMM_PORTS()) { + const child_coin = global.coinFuncs.getPORT2COIN[global.coinFuncs.getMM_PORTS()[port]]; + if (child_coin in activeBlockTemplates) { + console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); + template.child_template = activeBlockTemplates[child_coin]; + template.child_template_buffer = template.child_template.buffer; + template.parent_blocktemplate_blob = cnUtil.construct_mm_parent_block_blob( + new Buffer(rpc_template.blocktemplate_blob, 'hex'), global.coinFuncs.portBlobType(this.port, this.buffer[0]), template.child_template_buffer + ).toString('hex'); + } + } + + return template; +} + // templateUpdateReal is only called in master thread (except the beginning of a worker thread) function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { @@ -274,12 +297,9 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { - let template = rpcResponse.result; - template.coin = coin; - template.port = activePort; - template.coinHashFactor = coinHashFactor; - template.isHashFactorChange = isHashFactorChange; - debug(threadName + "New block template found at " + template.height + " height"); + const rpc_template = rpcResponse.result; + const template = process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange); + debug(threadName + "New block template found at " + rpc_template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); setNewBlockTemplate(template); @@ -438,7 +458,7 @@ function setNewBlockTemplate(template) { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } - activeBlockTemplates[coin] = new BlockTemplate(template, activeBlockTemplates); + activeBlockTemplates[coin] = new BlockTemplate(template); // update parent coins if current coin was updated now if (template.port in global.coinFuncs.getMM_CHILD_PORTS()) { @@ -446,8 +466,10 @@ function setNewBlockTemplate(template) { for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; if (parent_coin in activeBlockTemplates) { - process.send ({type: 'newBlockTemplate', data: activeBlockTemplates[parent_coin]}); - sendToWorkers({type: 'newBlockTemplate', data: activeBlockTemplates[parent_coin]}); + const coinHashFactor = coin in currCoinHashFactor ? currCoinHashFactor[coin] : 0; + const template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, coinHashFactor, false); + process.send ({type: 'newBlockTemplate', data: template}); + sendToWorkers({type: 'newBlockTemplate', data: template}); } } } From ff7bd2a8cb4abf23734d161a4d2c4390a70149cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:22:09 -0700 Subject: [PATCH 0296/1496] Fixedp port usage --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index baae9c779..aa50875f2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -298,7 +298,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { const rpc_template = rpcResponse.result; - const template = process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange); + const template = process_rpc_template(rpc_template, coin, activePort, coinHashFactor, isHashFactorChange); debug(threadName + "New block template found at " + rpc_template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); From cde85651f45ba211b22db1383b517b167c918502 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:23:07 -0700 Subject: [PATCH 0297/1496] Fixedp port usage --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index aa50875f2..ab747b00d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -270,7 +270,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa let template = rpc_template; template.coin = coin; - template.port = activePort; + template.port = port; template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; From 0705b138cd21ed04a4fa1a2591ed2051b9d64b8f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:26:06 -0700 Subject: [PATCH 0298/1496] Fixed mm detection --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0a812dcf2..636e61323 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -262,7 +262,7 @@ function Coin(data){ // The reserved space is 16 bytes long now in the following format: // Assuming that the extraNonce starts at byte 130: // |130-133|134-137|138-141|142-145| - // |minerNonce/extraNonce - 4 bytes|instanceId - 4 bytes|clientPoolNonce - 4 bytes|clientNonce - 4 bytes| + // |minerNonce/extraNonce - 4 bytes|instanceId - Z4 bytes|clientPoolNonce - 4 bytes|clientNonce - 4 bytes| // This is designed to allow a single block template to be used on up to 4 billion poolSlaves (clientPoolNonce) // Each with 4 billion clients. (clientNonce) // While being unique to this particular pool thread (instanceId) @@ -276,7 +276,7 @@ function Coin(data){ this.coin = template.coin; this.port = template.port; - const is_mm = this.port in mm_port_set; + const is_mm = "child_template" in template; if (is_mm) { this.child_template = template.child_template; From 7081899fb1ad7edbf3d9e90410d46373ccf5a648 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:35:34 -0700 Subject: [PATCH 0299/1496] Fixed function call --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 636e61323..1e8228f13 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -326,7 +326,7 @@ function Coin(data){ this.getCOINS = function() { return coins; } this.getPORT2COIN = function() { return port2coin; } this.getMM_PORTS = function() { return mm_port_set; } - this.getMM_CHILD_PORTS = function() { return get_mm_child_port_set; } + this.getMM_CHILD_PORTS = function() { return mm_child_port_set; } this.getDefaultAlgos = function() { return [ "cn/r" ]; @@ -422,7 +422,7 @@ function Coin(data){ case 34568: return "cn/wow"; // Wownero case 38081: return "cn/half"; // MSR case 48782: return "cn/r"; // Lethean - default: return "cn/2"; + default: return "cn/r"; } } From e8f47a2a7238c06408b8d071a6a4b681f071fbbe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:36:10 -0700 Subject: [PATCH 0300/1496] Added log --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index ab747b00d..d67735e19 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -276,6 +276,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.getPORT2COIN[global.coinFuncs.getMM_PORTS()[port]]; + console.log("!!!!! " + child_coin); if (child_coin in activeBlockTemplates) { console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); template.child_template = activeBlockTemplates[child_coin]; From cae887bd7ecbe6ac632422ffafbda29740f78099 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:38:28 -0700 Subject: [PATCH 0301/1496] Fixed func usage --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d67735e19..7546e570f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -275,7 +275,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.isHashFactorChange = isHashFactorChange; if (port in global.coinFuncs.getMM_PORTS()) { - const child_coin = global.coinFuncs.getPORT2COIN[global.coinFuncs.getMM_PORTS()[port]]; + const child_coin = global.coinFuncs.getPORT2COIN()[global.coinFuncs.getMM_PORTS()[port]]; console.log("!!!!! " + child_coin); if (child_coin in activeBlockTemplates) { console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); From 8feb522a98889e4c36cfda83854600eb7537ac65 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:49:23 -0700 Subject: [PATCH 0302/1496] Several fixes --- lib/coins/xmr.js | 8 ++++++++ lib/pool.js | 11 ++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1e8228f13..f033f457b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -252,6 +252,14 @@ function Coin(data){ return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0])); }; + this.constructMMParentBlockBlob = function(parentTemplateBuffer, port, childTemplateBuffer){ + return cnUtil.construct_mm_parent_block_blob(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); + }; + + this.constructMMChildBlockBlob = function(shareBuffer, port, childTemplateBuffer){ + return cnUtil.construct_mm_child_block_blob(shareBuffer, this.portBlobType(port, shareBuffer[0]), childTemplateBuffer); + }; + this.getBlockID = function(blockBuffer, port){ return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blockBuffer[0])); }; diff --git a/lib/pool.js b/lib/pool.js index 7546e570f..c615edb6a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -276,13 +276,12 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.getPORT2COIN()[global.coinFuncs.getMM_PORTS()[port]]; - console.log("!!!!! " + child_coin); if (child_coin in activeBlockTemplates) { console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); template.child_template = activeBlockTemplates[child_coin]; template.child_template_buffer = template.child_template.buffer; - template.parent_blocktemplate_blob = cnUtil.construct_mm_parent_block_blob( - new Buffer(rpc_template.blocktemplate_blob, 'hex'), global.coinFuncs.portBlobType(this.port, this.buffer[0]), template.child_template_buffer + template.parent_blocktemplate_blob = global.coinFuncs.constructMMChildBlockBlob( + new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } } @@ -1334,10 +1333,8 @@ function processShare(miner, job, blockTemplate, params) { } let shareBuffer2 = null; try { - console.log("MERGED MINING: cnUtil.construct_mm_child_block_blob"); - shareBuffer2 = cnUtil.construct_mm_child_block_blob( - shareBuffer, this.portBlobType(blockTemplate.port, blockTemplate.buffer[0]), blockTemplate.child_template_buffer - ); + console.log("MERGED MINING: constructMMChildBlockBlob"); + shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, blockTemplate.port, blockTemplate.child_template_buffer); } catch (e) { const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template.buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; console.error(err_str); From 1c1c263ade877329d983e6fb910dc0958aad1f59 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:53:28 -0700 Subject: [PATCH 0303/1496] Added logs --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index c615edb6a..984ef724c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -463,6 +463,7 @@ function setNewBlockTemplate(template) { // update parent coins if current coin was updated now if (template.port in global.coinFuncs.getMM_CHILD_PORTS()) { const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[template.port]; + console.log("!!!!!!!!!!! " + JSON.stringify(parent_ports)); for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; if (parent_coin in activeBlockTemplates) { From 96c4f5a27d2bee42a2c277e11eec898dde7ade3c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:57:32 -0700 Subject: [PATCH 0304/1496] Fixed child port set --- lib/coins/xmr.js | 5 +++-- lib/pool.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f033f457b..3f9103712 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -63,8 +63,9 @@ const coins = get_coins(port2coin); function get_mm_child_port_set(mm_port_set) { let mm_child_port_set = {}; for (let port in mm_port_set) { - if (!(port in mm_child_port_set)) mm_child_port_set[port] = {}; - mm_child_port_set[port][mm_port_set[port]] = 1; + const child_port = mm_port_set[port]; + if (!(child_port in mm_child_port_set)) mm_child_port_set[child_port] = {}; + mm_child_port_set[child_port][port] = 1; } return mm_child_port_set; } diff --git a/lib/pool.js b/lib/pool.js index 984ef724c..9caf2fa3e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,7 +280,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); template.child_template = activeBlockTemplates[child_coin]; template.child_template_buffer = template.child_template.buffer; - template.parent_blocktemplate_blob = global.coinFuncs.constructMMChildBlockBlob( + template.parent_blocktemplate_blob = global.coinFuncs.constructMMParentBlockBlob( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } From fb270769b47c4a90c36ee53cd83370a4da63b04e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 14:59:24 -0700 Subject: [PATCH 0305/1496] Fixed parent_template --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9caf2fa3e..a8df137ed 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -468,9 +468,9 @@ function setNewBlockTemplate(template) { const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; if (parent_coin in activeBlockTemplates) { const coinHashFactor = coin in currCoinHashFactor ? currCoinHashFactor[coin] : 0; - const template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, coinHashFactor, false); - process.send ({type: 'newBlockTemplate', data: template}); - sendToWorkers({type: 'newBlockTemplate', data: template}); + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, coinHashFactor, false); + process.send ({type: 'newBlockTemplate', data: parent_template}); + sendToWorkers({type: 'newBlockTemplate', data: parent_template}); } } } From ac9aefdef136a23e62cadecd11c4ffa686014836 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:05:47 -0700 Subject: [PATCH 0306/1496] Added template.reserved_offset store --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3f9103712..3f3cd6593 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -280,6 +280,7 @@ function Coin(data){ // Set these params equal to values we get from upstream. this.blocktemplate_blob = template.blocktemplate_blob; + this.reserved_offset = template.reserved_offset; this.difficulty = template.difficulty; this.height = template.height; this.coin = template.coin; From 2e1f28949089d63d8124faa680e76ef4cd6cd7da Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:09:11 -0700 Subject: [PATCH 0307/1496] More debug --- lib/coins/xmr.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3f3cd6593..52d07df82 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -292,7 +292,7 @@ function Coin(data){ this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; } - const blob = is_mm ? template.parent_blocktemplate_blob : this.blocktemplate_blob; + const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; this.idHash = crypto.createHash('md5').update(blob).digest('hex'); @@ -301,6 +301,14 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. this.buffer = new Buffer(blob, 'hex'); + if (is_mm) { + console.log("!!!!!!!!!!!"); + console.log(template.blocktemplate_blob.length()); + console.log(template.parent_blocktemplate_blob.length()); + console.log(template.reserved_offset); + console.log(this.reserveOffset); + } + if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); this.buffer.copy(prev_hash, 0, 7, 39); From 4127ace7efbd6e5311cf9125c77bd4b185641cd8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:14:38 -0700 Subject: [PATCH 0308/1496] More debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 52d07df82..98d80f848 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -302,7 +302,7 @@ function Coin(data){ this.buffer = new Buffer(blob, 'hex'); if (is_mm) { - console.log("!!!!!!!!!!!"); + console.log("xxxxxxxxxxxxxxxxx " + template.blocktemplate_blob.length()); console.log(template.blocktemplate_blob.length()); console.log(template.parent_blocktemplate_blob.length()); console.log(template.reserved_offset); From 23e6a70c513838fd0fef5e1f61f812511647ad80 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:19:17 -0700 Subject: [PATCH 0309/1496] Move parent coin block update to master thread --- lib/pool.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a8df137ed..d27ed02b3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -303,6 +303,20 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); setNewBlockTemplate(template); + // update parent coins if current coin was updated now + if (activePort in global.coinFuncs.getMM_CHILD_PORTS()) { + const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[activePort]; + console.log("!!!!!!!!!!! " + JSON.stringify(parent_ports)); + for (let parent_port in parent_ports) { + const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; + if (parent_coin in activeBlockTemplates) { + const coinHashFactor = coin in currCoinHashFactor ? currCoinHashFactor[coin] : 0; + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, coinHashFactor, false); + sendToWorkers({type: 'newBlockTemplate', data: parent_template}); + setNewBlockTemplate(parent_template); + } + } + } } else { setNewBlockTemplate(template); } @@ -460,20 +474,6 @@ function setNewBlockTemplate(template) { activeBlockTemplates[coin] = new BlockTemplate(template); - // update parent coins if current coin was updated now - if (template.port in global.coinFuncs.getMM_CHILD_PORTS()) { - const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[template.port]; - console.log("!!!!!!!!!!! " + JSON.stringify(parent_ports)); - for (let parent_port in parent_ports) { - const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; - if (parent_coin in activeBlockTemplates) { - const coinHashFactor = coin in currCoinHashFactor ? currCoinHashFactor[coin] : 0; - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, coinHashFactor, false); - process.send ({type: 'newBlockTemplate', data: parent_template}); - sendToWorkers({type: 'newBlockTemplate', data: parent_template}); - } - } - } const height = activeBlockTemplates[coin].height; if (coin === "" && global.config.daemon.port == activeBlockTemplates[""].port) { From 721f3a94b4987df3a648b73a4855bd6b5da2af41 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:23:44 -0700 Subject: [PATCH 0310/1496] More debug --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 98d80f848..2807c549e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -302,9 +302,9 @@ function Coin(data){ this.buffer = new Buffer(blob, 'hex'); if (is_mm) { - console.log("xxxxxxxxxxxxxxxxx " + template.blocktemplate_blob.length()); - console.log(template.blocktemplate_blob.length()); - console.log(template.parent_blocktemplate_blob.length()); + console.log("xxxxxxxxxxxxxxxxx " + template.blocktemplate_blob.length); + console.log(template.blocktemplate_blob.length); + console.log(template.parent_blocktemplate_blob.length); console.log(template.reserved_offset); console.log(this.reserveOffset); } From ce1af3e221b707dbd3289356c8e227cb1c24c62f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:27:27 -0700 Subject: [PATCH 0311/1496] Less debug --- lib/coins/xmr.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2807c549e..99a6398c2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -301,14 +301,6 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. this.buffer = new Buffer(blob, 'hex'); - if (is_mm) { - console.log("xxxxxxxxxxxxxxxxx " + template.blocktemplate_blob.length); - console.log(template.blocktemplate_blob.length); - console.log(template.parent_blocktemplate_blob.length); - console.log(template.reserved_offset); - console.log(this.reserveOffset); - } - if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); this.buffer.copy(prev_hash, 0, 7, 39); From 05299e7a4de4f1a4a3044c5dc9014163e9168f18 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:34:04 -0700 Subject: [PATCH 0312/1496] Less debug --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d27ed02b3..3ff77f160 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -306,7 +306,6 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange // update parent coins if current coin was updated now if (activePort in global.coinFuncs.getMM_CHILD_PORTS()) { const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[activePort]; - console.log("!!!!!!!!!!! " + JSON.stringify(parent_ports)); for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; if (parent_coin in activeBlockTemplates) { From 6a6a3e1101c7fecac8c392b8dc27895eaea38155 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:40:35 -0700 Subject: [PATCH 0313/1496] Fixed child block prev hash check --- lib/pool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3ff77f160..a228a862e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -449,8 +449,7 @@ function setNewBlockTemplate(template) { const child_coin_port = global.coinFuncs.getMM_PORTS()[template.port]; const child_coin = global.coinFuncs.getPORT2COIN()[child_coin_port]; if (child_coin in activeBlockTemplates && "child_template" in template) { - const child_template = activeBlockTemplates[child_coin]; - if (child_template.prev_hash === template.child_template.prev_hash) { + if (activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From c2ba13d13b17e92a88002a1da9c3d58e9d025565 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:45:40 -0700 Subject: [PATCH 0314/1496] Fixed child block prev hash check --- lib/pool.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a228a862e..86efa4163 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -445,14 +445,10 @@ function setNewBlockTemplate(template) { let isExtraCheck = false; if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { - if (template.port in global.coinFuncs.getMM_PORTS()) { - const child_coin_port = global.coinFuncs.getMM_PORTS()[template.port]; - const child_coin = global.coinFuncs.getPORT2COIN()[child_coin_port]; - if (child_coin in activeBlockTemplates && "child_template" in template) { - if (activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { - console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); - return; - } + if ("child_template" in template) { + if (activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { + console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); + return; } } else { console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); From d7c4d60551a23ae38640fac8ab948e885aab323f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 15:46:57 -0700 Subject: [PATCH 0315/1496] Fixed child block prev hash check --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 86efa4163..ea43e6739 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -445,7 +445,7 @@ function setNewBlockTemplate(template) { let isExtraCheck = false; if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { - if ("child_template" in template) { + if ("child_template" in template && "child_template" in activeBlockTemplates[coin]) { if (activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; From 5e27a8d9a9ed4163b614122883e5c719ce2e2826 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:39:11 -0700 Subject: [PATCH 0316/1496] Added hash factor calc based on mm --- lib/coins/xmr.js | 3 ++- lib/pool.js | 50 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 99a6398c2..f807ab689 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -334,7 +334,8 @@ function Coin(data){ }; this.getCOINS = function() { return coins; } - this.getPORT2COIN = function() { return port2coin; } + this.PORT2COIN = function(port) { return port2coin[port]; } + this.COIN2PORT = function(coin) { return coin2port[coin]; } this.getMM_PORTS = function() { return mm_port_set; } this.getMM_CHILD_PORTS = function() { return mm_child_port_set; } diff --git a/lib/pool.js b/lib/pool.js index ea43e6739..0ba514fba 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -20,8 +20,9 @@ let baseDiff = global.coinFuncs.baseDiff(); let activeMiners = new Map(); let lastBlockHash = {}; // coin key -let lastCoinHashFactor = {}; // coin key -let currCoinHashFactor = {}; // coin key +let lastCoinHashFactor = {}; // coin key, last set individual coin hash factor +let currCoinHashFactor = {}; // coin key, current individual coin hash factor +let currCoinHashFactorMM = {}; // coin key, current individual coin hash factor that includes merged mining factor let activeBlockTemplates = {}; // coin key let pastBlockTemplates = global.support.circularBuffer(10); @@ -275,7 +276,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.isHashFactorChange = isHashFactorChange; if (port in global.coinFuncs.getMM_PORTS()) { - const child_coin = global.coinFuncs.getPORT2COIN()[global.coinFuncs.getMM_PORTS()[port]]; + const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); template.child_template = activeBlockTemplates[child_coin]; @@ -307,10 +308,9 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange if (activePort in global.coinFuncs.getMM_CHILD_PORTS()) { const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[activePort]; for (let parent_port in parent_ports) { - const parent_coin = global.coinFuncs.getPORT2COIN()[parent_port]; + const parent_coin = global.coinFuncs.PORT2COIN(parent_port); if (parent_coin in activeBlockTemplates) { - const coinHashFactor = coin in currCoinHashFactor ? currCoinHashFactor[coin] : 0; - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, coinHashFactor, false); + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, currCoinHashFactor[coin], false); sendToWorkers({type: 'newBlockTemplate', data: parent_template}); setNewBlockTemplate(parent_template); } @@ -390,9 +390,28 @@ function anchorBlockUpdate() { function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; - if (coin !== "") set_hash_factor(coin, coinHashFactor); // used in miner.selectBestCoin if (!(coin in activeBlockTemplates)) return; + // used in miner.selectBestCoin + //if (coin !== "") set_hash_factor(coin, coinHashFactor); + currCoinHashFactorMM[coin] = coinHashFactor; + const port = global.coinFuncs.COIN2PORT(coin); + if (port in global.coinFuncs.getMM_PORTS()) { + const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); + if (child_coin in lastCoinHashFactor) currCoinHashFactorMM[coin] += lastCoinHashFactor[child_coin]; + } + + // update parent coins if current coin was updated now + if (port in global.coinFuncs.getMM_CHILD_PORTS()) { + const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[port]; + for (let parent_port in parent_ports) { + const parent_coin = global.coinFuncs.PORT2COIN(parent_port); + if (parent_coin in lastCoinHashFactor) { + setNewCoinHashFactor(isHashFactorChange, parent_coin, lastCoinHashFactor[parent_coin], 0); + } + } + } + const time_before = Date.now(); if (isHashFactorChange) { @@ -712,7 +731,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestCoin = function() { if (this.debugMiner) console.log(threadName + this.logString + ": current coin is " + this.curr_coin); - if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && currCoinHashFactor[this.curr_coin] && + if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && currCoinHashFactorMM[this.curr_coin] && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { return this.curr_coin; @@ -729,7 +748,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplates"); return; } - const coinHashFactor = currCoinHashFactor[coin]; + const coinHashFactor = currCoinHashFactorMM[coin]; if (!coinHashFactor) { if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); return; @@ -894,7 +913,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.newDiffRecommendation = null; } - const coinHashFactor = currCoinHashFactor[coin]; + const coinHashFactor = currCoinHashFactorMM[coin]; const algo_name = global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]); const variant_name = algo_name.split('/')[1]; @@ -1650,6 +1669,9 @@ setInterval(function dump_vars() { s.write("\n\n\ncurrCoinHashFactor:\n"); s.write(JSON.stringify(currCoinHashFactor, null, '\t') + "\n"); + s.write("\n\n\ncurrCoinHashFactorMM:\n"); + s.write(JSON.stringify(currCoinHashFactorMM, null, '\t') + "\n"); + s.write("\n\n\nactiveBlockTemplate:\n"); s.write(JSON.stringify(activeBlockTemplates, null, '\t') + "\n"); @@ -1791,10 +1813,10 @@ if (cluster.isMaster) { console.warn("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); global.config.daemon.activePort = global.config.daemon.port; } else { - currCoinHashFactor[""] = 1; + currCoinHashFactor[""] = currCoinHashFactorMM[""] = 1; setInterval(updateActivePort, 3*1000, ""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { - currCoinHashFactor[coin] = 0; + currCoinHashFactor[coin] = currCoinHashFactorMM[coin] = 0; if ("activePort" + coin in global.config.daemon) { setInterval(updateActivePort, 5*1000, coin); templateUpdate(coin); @@ -1810,10 +1832,10 @@ if (cluster.isMaster) { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); } else { - currCoinHashFactor[""] = 1; + currCoinHashFactor[""] = currCoinHashFactorMM[""] = 1; templateUpdate(""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { - currCoinHashFactor[coin] = 0; + currCoinHashFactor[coin] = currCoinHashFactorMM[coin] = 0; if ("activePort" + coin in global.config.daemon) templateUpdate(coin); }); anchorBlockUpdate(); From 0b708675baf134a7b5d1909c144456ed196060f1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:42:35 -0700 Subject: [PATCH 0317/1496] Added hash factor calc based on mm --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 0ba514fba..4cccb0d37 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -393,7 +393,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he if (!(coin in activeBlockTemplates)) return; // used in miner.selectBestCoin - //if (coin !== "") set_hash_factor(coin, coinHashFactor); + if (coin !== "") set_hash_factor(coin, coinHashFactor); currCoinHashFactorMM[coin] = coinHashFactor; const port = global.coinFuncs.COIN2PORT(coin); if (port in global.coinFuncs.getMM_PORTS()) { From f2bd5fa26ec95a753c4e912737351f15c57b168c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:46:59 -0700 Subject: [PATCH 0318/1496] Do not do fast parent block updates for fast child update --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4cccb0d37..2fcf4187b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -402,12 +402,12 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } // update parent coins if current coin was updated now - if (port in global.coinFuncs.getMM_CHILD_PORTS()) { + if (isHashFactorChange) if (port in global.coinFuncs.getMM_CHILD_PORTS()) { const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[port]; for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.PORT2COIN(parent_port); if (parent_coin in lastCoinHashFactor) { - setNewCoinHashFactor(isHashFactorChange, parent_coin, lastCoinHashFactor[parent_coin], 0); + setNewCoinHashFactor(true, parent_coin, lastCoinHashFactor[parent_coin], 0); } } } From b53f891115dd7534cd4acd9bc0e1d798465895c6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:51:09 -0700 Subject: [PATCH 0319/1496] More debug --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f807ab689..05c884b07 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -291,6 +291,7 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; + console.log("XXXXXXXXXXXXX " + template.parent_blocktemplate_blob.length); } const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; From 5707538416b66af969ddd14d51af81162514fcb6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:53:06 -0700 Subject: [PATCH 0320/1496] More debug --- lib/coins/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 05c884b07..508a77c92 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -291,7 +291,8 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; - console.log("XXXXXXXXXXXXX " + template.parent_blocktemplate_blob.length); + console.log("XXXXXXXXXXXXX1 " + template.parent_blocktemplate_blob.length); + console.log("XXXXXXXXXXXXX2 " + template.reserved_offset + (is_mm ? mm_nonce_size : 0)); } const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; From 84b15e3f2bed88820d2d618c45522cbf609eb209 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:55:39 -0700 Subject: [PATCH 0321/1496] More debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 508a77c92..9d59f3cfa 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -292,7 +292,7 @@ function Coin(data){ this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; console.log("XXXXXXXXXXXXX1 " + template.parent_blocktemplate_blob.length); - console.log("XXXXXXXXXXXXX2 " + template.reserved_offset + (is_mm ? mm_nonce_size : 0)); + console.log("XXXXXXXXXXXXX2 " + (template.reserved_offset + (is_mm ? mm_nonce_size : 0))); } const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; From 62f586067cad60d30031d6c95a5a739e7d14de21 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:55:59 -0700 Subject: [PATCH 0322/1496] Fixed same child block check --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2fcf4187b..748612339 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -464,8 +464,8 @@ function setNewBlockTemplate(template) { let isExtraCheck = false; if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { - if ("child_template" in template && "child_template" in activeBlockTemplates[coin]) { - if (activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { + if ("child_template" in template) { + if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From 8de54e7a27194c330cb059adfc77f0a5ec9ac6b5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 16:56:54 -0700 Subject: [PATCH 0323/1496] More debug --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9d59f3cfa..4e9693529 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -291,6 +291,7 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; + console.log("XXXXXXXXXXXXX0 " + template.blocktemplate_blob.length); console.log("XXXXXXXXXXXXX1 " + template.parent_blocktemplate_blob.length); console.log("XXXXXXXXXXXXX2 " + (template.reserved_offset + (is_mm ? mm_nonce_size : 0))); } From eb4b61859a3b6dde2a86d34cc77928629f2ae7f3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 17:18:04 -0700 Subject: [PATCH 0324/1496] Update for updated coin utils --- lib/coins/xmr.js | 17 ++++++++--------- lib/pool.js | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4e9693529..c146b8ce9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -253,8 +253,8 @@ function Coin(data){ return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0])); }; - this.constructMMParentBlockBlob = function(parentTemplateBuffer, port, childTemplateBuffer){ - return cnUtil.construct_mm_parent_block_blob(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); + this.constructMMParentBlockExtraNonce = function(parentTemplateBuffer, port, childTemplateBuffer){ + return cnUtil.construct_mm_parent_block_extra_nonce(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); }; this.constructMMChildBlockBlob = function(shareBuffer, port, childTemplateBuffer){ @@ -291,20 +291,19 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; - console.log("XXXXXXXXXXXXX0 " + template.blocktemplate_blob.length); - console.log("XXXXXXXXXXXXX1 " + template.parent_blocktemplate_blob.length); - console.log("XXXXXXXXXXXXX2 " + (template.reserved_offset + (is_mm ? mm_nonce_size : 0))); + this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + + template.parent_extra_nonce_hex + + this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); } - const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; - this.idHash = crypto.createHash('md5').update(blob).digest('hex'); + this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); // Set this.reserveOffset to the byte location of the reserved offset. this.reserveOffset = template.reserved_offset + (is_mm ? mm_nonce_size : 0); // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. - this.buffer = new Buffer(blob, 'hex'); + this.buffer = new Buffer(this.blocktemplate_blob, 'hex'); - if (!("prev_hash" in template)) { // Get prev_hash from blob + if (!("prev_hash" in template)) { // Get prev_hash from this.blocktemplate_blob let prev_hash = new Buffer(32); this.buffer.copy(prev_hash, 0, 7, 39); this.prev_hash = prev_hash.toString('hex'); diff --git a/lib/pool.js b/lib/pool.js index 748612339..3420f3cb3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -281,7 +281,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); template.child_template = activeBlockTemplates[child_coin]; template.child_template_buffer = template.child_template.buffer; - template.parent_blocktemplate_blob = global.coinFuncs.constructMMParentBlockBlob( + template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } From 9a32a6d954e5691d6799115e5213258752c69bcb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 17:26:16 -0700 Subject: [PATCH 0325/1496] More info about MM hash factors --- lib/pool.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3420f3cb3..dd8cb67b1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -331,7 +331,7 @@ function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; if (currCoinHashFactor[coin] === 0 && coinHashFactor === 0) return; if (cluster.isMaster) { - console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor); + //console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor); let data = { coin: coin, coinHashFactor: coinHashFactor }; sendToWorkers({type: 'newCoinHashFactor', data: data}); } @@ -393,14 +393,19 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he if (!(coin in activeBlockTemplates)) return; // used in miner.selectBestCoin - if (coin !== "") set_hash_factor(coin, coinHashFactor); currCoinHashFactorMM[coin] = coinHashFactor; const port = global.coinFuncs.COIN2PORT(coin); - if (port in global.coinFuncs.getMM_PORTS()) { + const is_mm = port in global.coinFuncs.getMM_PORTS(); + if (is_mm) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in lastCoinHashFactor) currCoinHashFactorMM[coin] += lastCoinHashFactor[child_coin]; } + if (cluster.isMaster) { + console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor + (is_mm ? ' (MM: ' + currCoinHashFactorMM[coin] + ')' : "")); + } + if (coin !== "") set_hash_factor(coin, coinHashFactor); + // update parent coins if current coin was updated now if (isHashFactorChange) if (port in global.coinFuncs.getMM_CHILD_PORTS()) { const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[port]; From fa9f3ec024517bee3c3e96945325296e7f40b548 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 17:27:39 -0700 Subject: [PATCH 0326/1496] More info about MM hash factors --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index dd8cb67b1..086074df9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -424,7 +424,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he const block_version = activeBlockTemplates[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed to " + coinHashFactor); + if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed to " + currCoinHashFactorMM[coin]); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -439,7 +439,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } } } else { - if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + coinHashFactor + " hash factor"); + if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); From ecfe0dba50865d7fb6e74392cf2728ae522bd7cd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 17:31:04 -0700 Subject: [PATCH 0327/1496] Moved debug messages --- lib/coins/xmr.js | 6 ++++-- lib/pool.js | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c146b8ce9..8f33e2ae4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -253,11 +253,13 @@ function Coin(data){ return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0])); }; - this.constructMMParentBlockExtraNonce = function(parentTemplateBuffer, port, childTemplateBuffer){ + this.constructMMParentBlockExtraNonce = function(parentTemplateBuffer, port, childTemplateBuffer) { + console.log("MERGED MINING: constructMMChildBlockExtraNonce"); return cnUtil.construct_mm_parent_block_extra_nonce(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); }; - this.constructMMChildBlockBlob = function(shareBuffer, port, childTemplateBuffer){ + this.constructMMChildBlockBlob = function(shareBuffer, port, childTemplateBuffer) { + console.log("MERGED MINING: constructMMChildBlockBlob"); return cnUtil.construct_mm_child_block_blob(shareBuffer, this.portBlobType(port, shareBuffer[0]), childTemplateBuffer); }; diff --git a/lib/pool.js b/lib/pool.js index 086074df9..d6a2ef09c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -278,10 +278,9 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { - console.log("MERGED MINING: cnUtil.construct_mm_parent_block_blob"); - template.child_template = activeBlockTemplates[child_coin]; - template.child_template_buffer = template.child_template.buffer; - template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( + template.child_template = activeBlockTemplates[child_coin]; + template.child_template_buffer = template.child_template.buffer; + template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } @@ -1352,7 +1351,6 @@ function processShare(miner, job, blockTemplate, params) { } let shareBuffer2 = null; try { - console.log("MERGED MINING: constructMMChildBlockBlob"); shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, blockTemplate.port, blockTemplate.child_template_buffer); } catch (e) { const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template.buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; From 65bc5f4384c9360878de6a977b1031029a0ca403 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 17:36:27 -0700 Subject: [PATCH 0328/1496] Remove XMR empty string from COINS --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8f33e2ae4..b2b552bff 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -57,6 +57,7 @@ const coin2port = get_coin2port(port2coin); function get_coins(port2coin) { let coins = []; for (let port in port2coin) coins.push(port2coin[port]); + delete coins[""]; return coins; } const coins = get_coins(port2coin); From 0c354037aff4ae095159c0a83f64b88e9ee15358 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:00:27 -0700 Subject: [PATCH 0329/1496] Extra debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index d6a2ef09c..d7c15ed84 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -279,6 +279,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { template.child_template = activeBlockTemplates[child_coin]; + console.log("SSSSSSSSSSSSSSS " + template.child_template.prev_hash); template.child_template_buffer = template.child_template.buffer; template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer @@ -470,6 +471,7 @@ function setNewBlockTemplate(template) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { if ("child_template" in template) { if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { + console.log("XXXXXXX " + activeBlockTemplates[coin].child_template.prev_hash); console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From e1ec2beb07150fa8754a0a9224a1d72e878dc061 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:13:25 -0700 Subject: [PATCH 0330/1496] Extra debug --- lib/pool.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d7c15ed84..ab6a2057e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -278,10 +278,11 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { - template.child_template = activeBlockTemplates[child_coin]; - console.log("SSSSSSSSSSSSSSS " + template.child_template.prev_hash); - template.child_template_buffer = template.child_template.buffer; - template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( + template.child_template = activeBlockTemplates[child_coin]; + template.child_template_prev_hash = template.child_template.prev_hash; + console.log("SSSSSSSSSSSSSSS " + template.child_template_prev_hash); + template.child_template_buffer = template.child_template.buffer; + template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } @@ -470,8 +471,10 @@ function setNewBlockTemplate(template) { if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { if ("child_template" in template) { - if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { - console.log("XXXXXXX " + activeBlockTemplates[coin].child_template.prev_hash); + console.log("XXXXXXX0 " + activeBlockTemplates[coin].child_template.prev_hash); + console.log("XXXXXXX1 " + activeBlockTemplates[coin].child_template_prev_hash); + if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template_prev_hash === template.child_template_prev_hash) { + console.log("XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From f8d958320c36fa5e640264df9ca811c461b3ef81 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:13:35 -0700 Subject: [PATCH 0331/1496] Extra debug --- lib/coins/xmr.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b2b552bff..e2bc8abde 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -292,11 +292,12 @@ function Coin(data){ const is_mm = "child_template" in template; if (is_mm) { - this.child_template = template.child_template; - this.child_template_buffer = template.child_template_buffer; - this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + - template.parent_extra_nonce_hex + - this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); + this.child_template = template.child_template; + this.child_template_prev_hash = template.child_template_prev_hash; + this.child_template_buffer = template.child_template_buffer; + this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + + template.parent_extra_nonce_hex + + this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); } this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); From 40049ad63ddfa3a1f9cc2704ec5989a922d14c31 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:15:05 -0700 Subject: [PATCH 0332/1496] Extra debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ab6a2057e..545166fae 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -471,8 +471,8 @@ function setNewBlockTemplate(template) { if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { if ("child_template" in template) { - console.log("XXXXXXX0 " + activeBlockTemplates[coin].child_template.prev_hash); - console.log("XXXXXXX1 " + activeBlockTemplates[coin].child_template_prev_hash); + console.log("XXXXXXX0 " + template.child_template.prev_hash); + console.log("XXXXXXX1 " + template.child_template_prev_hash); if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template_prev_hash === template.child_template_prev_hash) { console.log("XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); From 78cfa6cb819258de3c9351ef594a9d61d2e133e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:16:33 -0700 Subject: [PATCH 0333/1496] Extra debug --- lib/pool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 545166fae..033805627 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -473,6 +473,10 @@ function setNewBlockTemplate(template) { if ("child_template" in template) { console.log("XXXXXXX0 " + template.child_template.prev_hash); console.log("XXXXXXX1 " + template.child_template_prev_hash); + if ("child_template" in activeBlockTemplates[coin]) { + console.log("XXXXXXX0 " + activeBlockTemplates[coin].template.child_template.prev_hash); + console.log("XXXXXXX1 " + activeBlockTemplates[coin].template.child_template_prev_hash); + } if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template_prev_hash === template.child_template_prev_hash) { console.log("XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); From 710d097b4fea593281f131ff5fc7a01dc0a514f3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:17:09 -0700 Subject: [PATCH 0334/1496] Extra debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 033805627..c41cb4e77 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -474,8 +474,8 @@ function setNewBlockTemplate(template) { console.log("XXXXXXX0 " + template.child_template.prev_hash); console.log("XXXXXXX1 " + template.child_template_prev_hash); if ("child_template" in activeBlockTemplates[coin]) { - console.log("XXXXXXX0 " + activeBlockTemplates[coin].template.child_template.prev_hash); - console.log("XXXXXXX1 " + activeBlockTemplates[coin].template.child_template_prev_hash); + console.log("XXXXXXX0 " + activeBlockTemplates[coin].child_template.prev_hash); + console.log("XXXXXXX1 " + activeBlockTemplates[coin].child_template_prev_hash); } if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template_prev_hash === template.child_template_prev_hash) { console.log("XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); From f920dedecb321d492243744b3c70b8d455261515 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:18:47 -0700 Subject: [PATCH 0335/1496] Extra debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c41cb4e77..c83ca1fd1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -474,8 +474,8 @@ function setNewBlockTemplate(template) { console.log("XXXXXXX0 " + template.child_template.prev_hash); console.log("XXXXXXX1 " + template.child_template_prev_hash); if ("child_template" in activeBlockTemplates[coin]) { - console.log("XXXXXXX0 " + activeBlockTemplates[coin].child_template.prev_hash); - console.log("XXXXXXX1 " + activeBlockTemplates[coin].child_template_prev_hash); + console.log("XXXXXXX2 " + activeBlockTemplates[coin].child_template.prev_hash); + console.log("XXXXXXX3 " + activeBlockTemplates[coin].child_template_prev_hash); } if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template_prev_hash === template.child_template_prev_hash) { console.log("XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); From 27283c2254824ee0d4a7e62b9de197208b8bc3f0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:21:11 -0700 Subject: [PATCH 0336/1496] Extra debug --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c83ca1fd1..95346b051 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -471,14 +471,14 @@ function setNewBlockTemplate(template) { if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { if ("child_template" in template) { - console.log("XXXXXXX0 " + template.child_template.prev_hash); - console.log("XXXXXXX1 " + template.child_template_prev_hash); + console.log(threadName + "XXXXXXX0 " + template.child_template.prev_hash); + console.log(threadName + "XXXXXXX1 " + template.child_template_prev_hash); if ("child_template" in activeBlockTemplates[coin]) { - console.log("XXXXXXX2 " + activeBlockTemplates[coin].child_template.prev_hash); - console.log("XXXXXXX3 " + activeBlockTemplates[coin].child_template_prev_hash); + console.log(threadName + "XXXXXXX2 " + activeBlockTemplates[coin].child_template.prev_hash); + console.log(threadName + "XXXXXXX3 " + activeBlockTemplates[coin].child_template_prev_hash); } if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template_prev_hash === template.child_template_prev_hash) { - console.log("XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); + console.log(threadName + "XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From f336d37946c9d0c5d59a0c4d0e100464f0565ea8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:25:05 -0700 Subject: [PATCH 0337/1496] Extra debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 95346b051..dcdf3e31b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -344,6 +344,7 @@ function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; const coinHashFactor = currCoinHashFactor[coin]; if (activePort && coinHashFactor) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + if (coin == "") console.log("!!!!"); if (activePort !== global.config.daemon["activePort" + coin]) { console.log("Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); From cb06b161d4b5036743c0aed01851780a0f22a918 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:28:56 -0700 Subject: [PATCH 0338/1496] Fixed main bloc ktemplate update --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index dcdf3e31b..0181bbd37 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -392,7 +392,6 @@ function anchorBlockUpdate() { function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; - if (!(coin in activeBlockTemplates)) return; // used in miner.selectBestCoin currCoinHashFactorMM[coin] = coinHashFactor; @@ -407,6 +406,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor + (is_mm ? ' (MM: ' + currCoinHashFactorMM[coin] + ')' : "")); } if (coin !== "") set_hash_factor(coin, coinHashFactor); + if (!(coin in activeBlockTemplates)) return; // update parent coins if current coin was updated now if (isHashFactorChange) if (port in global.coinFuncs.getMM_CHILD_PORTS()) { From 544b8672c796417199ebbfc53edfee7ef2c691d3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:32:22 -0700 Subject: [PATCH 0339/1496] Fixed main bloc ktemplate update --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 0181bbd37..3c8dbbbd4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -343,6 +343,7 @@ function coinHashFactorUpdate(coin, coinHashFactor) { function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; const coinHashFactor = currCoinHashFactor[coin]; + console.log("!!!!1 " + activePort + " " + coinHashFactor); if (activePort && coinHashFactor) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (coin == "") console.log("!!!!"); if (activePort !== global.config.daemon["activePort" + coin]) { From 8e985b8717958754547136b28228433932fd0382 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:37:14 -0700 Subject: [PATCH 0340/1496] Fixed main bloc ktemplate update --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3c8dbbbd4..9e684519f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1827,7 +1827,8 @@ if (cluster.isMaster) { console.warn("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); global.config.daemon.activePort = global.config.daemon.port; } else { - currCoinHashFactor[""] = currCoinHashFactorMM[""] = 1; + currCoinHashFactor[""] = 1; + currCoinHashFactorMM[""] = 1; setInterval(updateActivePort, 3*1000, ""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { currCoinHashFactor[coin] = currCoinHashFactorMM[coin] = 0; From 94992eb6be89dc834e1e84656cfe651eb1ae9be8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:40:12 -0700 Subject: [PATCH 0341/1496] Less debug --- lib/pool.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9e684519f..61f259183 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -343,9 +343,7 @@ function coinHashFactorUpdate(coin, coinHashFactor) { function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; const coinHashFactor = currCoinHashFactor[coin]; - console.log("!!!!1 " + activePort + " " + coinHashFactor); if (activePort && coinHashFactor) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { - if (coin == "") console.log("!!!!"); if (activePort !== global.config.daemon["activePort" + coin]) { console.log("Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); @@ -1827,8 +1825,7 @@ if (cluster.isMaster) { console.warn("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); global.config.daemon.activePort = global.config.daemon.port; } else { - currCoinHashFactor[""] = 1; - currCoinHashFactorMM[""] = 1; + currCoinHashFactor[""] = currCoinHashFactorMM[""] = 1; setInterval(updateActivePort, 3*1000, ""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { currCoinHashFactor[coin] = currCoinHashFactorMM[coin] = 0; From 6984ea431686fd37b667aff784dadc883deb3d8a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:43:13 -0700 Subject: [PATCH 0342/1496] More debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 61f259183..cbed09747 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -470,10 +470,10 @@ function setNewBlockTemplate(template) { let isExtraCheck = false; if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { - if ("child_template" in template) { + if ("child_template" in template && cluster.isMaster) { console.log(threadName + "XXXXXXX0 " + template.child_template.prev_hash); console.log(threadName + "XXXXXXX1 " + template.child_template_prev_hash); - if ("child_template" in activeBlockTemplates[coin]) { + if ("child_template" in activeBlockTemplates[coin] && cluster.isMaster) { console.log(threadName + "XXXXXXX2 " + activeBlockTemplates[coin].child_template.prev_hash); console.log(threadName + "XXXXXXX3 " + activeBlockTemplates[coin].child_template_prev_hash); } From 3adad3700b2f552848e436a58108a44d817da65c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:46:03 -0700 Subject: [PATCH 0343/1496] More debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cbed09747..1da6ef9b8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,7 +280,8 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (child_coin in activeBlockTemplates) { template.child_template = activeBlockTemplates[child_coin]; template.child_template_prev_hash = template.child_template.prev_hash; - console.log("SSSSSSSSSSSSSSS " + template.child_template_prev_hash); + console.log("SSSSSSSSSSSSSSS1 " + activeBlockTemplates[coin].child_template_prev_hash); + console.log("SSSSSSSSSSSSSSS2 " + template.child_template_prev_hash); template.child_template_buffer = template.child_template.buffer; template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer From b5274c95d0e6923cdb387fcabb2de4a54abf997d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:48:52 -0700 Subject: [PATCH 0344/1496] More debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1da6ef9b8..0ec905a24 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,8 +280,8 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (child_coin in activeBlockTemplates) { template.child_template = activeBlockTemplates[child_coin]; template.child_template_prev_hash = template.child_template.prev_hash; - console.log("SSSSSSSSSSSSSSS1 " + activeBlockTemplates[coin].child_template_prev_hash); - console.log("SSSSSSSSSSSSSSS2 " + template.child_template_prev_hash); + console.log("SSSSSSSSSSSSSSS1 " + coin + " " + activeBlockTemplates[coin].child_template_prev_hash); + console.log("SSSSSSSSSSSSSSS2 " + child_coin + " " + template.child_template_prev_hash); template.child_template_buffer = template.child_template.buffer; template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer From 7e102564a0810e345c12b8980ec833ae22a91450 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:52:55 -0700 Subject: [PATCH 0345/1496] More debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 0ec905a24..43c07372b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -275,6 +275,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; + console.log("CCCCCCCCCCCCCC " + coin); if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { From 83e7ec6825c171f9bd1d0948cc36cbe9f90bd445 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:54:43 -0700 Subject: [PATCH 0346/1496] Fixed main bloc ktemplate update --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e2bc8abde..830fbfe5c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -56,8 +56,7 @@ function get_coin2port(port2coin) { const coin2port = get_coin2port(port2coin); function get_coins(port2coin) { let coins = []; - for (let port in port2coin) coins.push(port2coin[port]); - delete coins[""]; + for (let port in port2coin) if (port2coin[port] != "") coins.push(port2coin[port]); return coins; } const coins = get_coins(port2coin); From f267a466be867713c907a72f454ceca84caa68be Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 18:58:23 -0700 Subject: [PATCH 0347/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 43c07372b..b6a9cb552 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,8 +280,8 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { template.child_template = activeBlockTemplates[child_coin]; - template.child_template_prev_hash = template.child_template.prev_hash; console.log("SSSSSSSSSSSSSSS1 " + coin + " " + activeBlockTemplates[coin].child_template_prev_hash); + template.child_template_prev_hash = template.child_template.prev_hash; console.log("SSSSSSSSSSSSSSS2 " + child_coin + " " + template.child_template_prev_hash); template.child_template_buffer = template.child_template.buffer; template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( From df260071e4337db11ba52682b9124b2bc26176c4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 19:01:34 -0700 Subject: [PATCH 0348/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b6a9cb552..1ee775768 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -268,7 +268,7 @@ function updateActivePort(coin) { } function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange) { - let template = rpc_template; + let template = Object.assign({}, rpc_template); template.coin = coin; template.port = port; From b5004ce0a29eda4da517333b34bdd4a36b23b4f4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 19:05:52 -0700 Subject: [PATCH 0349/1496] Removed extra debug --- lib/coins/xmr.js | 11 +++++------ lib/pool.js | 21 +++++---------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 830fbfe5c..705c6fd77 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -291,12 +291,11 @@ function Coin(data){ const is_mm = "child_template" in template; if (is_mm) { - this.child_template = template.child_template; - this.child_template_prev_hash = template.child_template_prev_hash; - this.child_template_buffer = template.child_template_buffer; - this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + - template.parent_extra_nonce_hex + - this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); + this.child_template = template.child_template; + this.child_template_buffer = template.child_template_buffer; + this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + + template.parent_extra_nonce_hex + + this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); } this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); diff --git a/lib/pool.js b/lib/pool.js index 1ee775768..68068ee07 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -275,16 +275,12 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; - console.log("CCCCCCCCCCCCCC " + coin); if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { - template.child_template = activeBlockTemplates[child_coin]; - console.log("SSSSSSSSSSSSSSS1 " + coin + " " + activeBlockTemplates[coin].child_template_prev_hash); - template.child_template_prev_hash = template.child_template.prev_hash; - console.log("SSSSSSSSSSSSSSS2 " + child_coin + " " + template.child_template_prev_hash); - template.child_template_buffer = template.child_template.buffer; - template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( + template.child_template = activeBlockTemplates[child_coin]; + template.child_template_buffer = template.child_template.buffer; + template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } @@ -472,15 +468,8 @@ function setNewBlockTemplate(template) { let isExtraCheck = false; if (coin in activeBlockTemplates) { if (activeBlockTemplates[coin].prev_hash === template.prev_hash) { - if ("child_template" in template && cluster.isMaster) { - console.log(threadName + "XXXXXXX0 " + template.child_template.prev_hash); - console.log(threadName + "XXXXXXX1 " + template.child_template_prev_hash); - if ("child_template" in activeBlockTemplates[coin] && cluster.isMaster) { - console.log(threadName + "XXXXXXX2 " + activeBlockTemplates[coin].child_template.prev_hash); - console.log(threadName + "XXXXXXX3 " + activeBlockTemplates[coin].child_template_prev_hash); - } - if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template_prev_hash === template.child_template_prev_hash) { - console.log(threadName + "XXXXXXX " + activeBlockTemplates[coin].child_template_prev_hash); + if ("child_template" in template) { + if ("child_template" in activeBlockTemplates[coin] && activeBlockTemplates[coin].child_template.prev_hash === template.child_template.prev_hash) { console.log(threadName + 'Ignoring duplicate parent block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From b0b5e638b05987e35eebb4ff0901ce1bdfa2f58f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 19:27:51 -0700 Subject: [PATCH 0350/1496] Fixed parent hash factor --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 68068ee07..0d1910ff4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -309,7 +309,7 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.PORT2COIN(parent_port); if (parent_coin in activeBlockTemplates) { - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, currCoinHashFactor[coin], false); + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, currCoinHashFactor[parent_coin], false); sendToWorkers({type: 'newBlockTemplate', data: parent_template}); setNewBlockTemplate(parent_template); } From 081e45edee3c064494a475783922280b538c41bb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Apr 2019 19:44:04 -0700 Subject: [PATCH 0351/1496] Fixed name --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 705c6fd77..ce1c13b49 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -254,7 +254,7 @@ function Coin(data){ }; this.constructMMParentBlockExtraNonce = function(parentTemplateBuffer, port, childTemplateBuffer) { - console.log("MERGED MINING: constructMMChildBlockExtraNonce"); + console.log("MERGED MINING: constructMMParentBlockExtraNonce"); return cnUtil.construct_mm_parent_block_extra_nonce(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); }; From 48da77afe82c8c1a8abd49023e833cfb3baa73dd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 00:26:50 -0700 Subject: [PATCH 0352/1496] Fixed port type --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ce1c13b49..0cce4458c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -50,7 +50,7 @@ const mm_port_set = { "22023": "11898" }; function get_coin2port(port2coin) { let coin2port = {}; - for (let port in port2coin) coin2port[port2coin[port]] = port; + for (let port in port2coin) coin2port[port2coin[port]] = parseInt(port); return coin2port; } const coin2port = get_coin2port(port2coin); From bf70dcf8bd4466a6c63df9764ce2189626d33bff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 00:37:47 -0700 Subject: [PATCH 0353/1496] Added debug --- lib/coins/xmr.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0cce4458c..7895b7203 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -46,7 +46,7 @@ const port2blob_num = { "48782": 0, // LTHN }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); -const mm_port_set = { "22023": "11898" }; +const mm_port_set = { "22023": 11898 }; function get_coin2port(port2coin) { let coin2port = {}; @@ -407,7 +407,9 @@ function Coin(data){ case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, height); // Lethean - default: return multiHashing.cryptonight(convertedBlob, 8); + default: + console.error("Unknown port for PoW type " + port + " on " + height + " height"); + return multiHashing.cryptonight(convertedBlob, 8); } } @@ -437,7 +439,9 @@ function Coin(data){ case 34568: return "cn/wow"; // Wownero case 38081: return "cn/half"; // MSR case 48782: return "cn/r"; // Lethean - default: return "cn/r"; + default: + console.error("Unknown port for PoW type " + port + " on " + version + " version"); + return "cn/r"; } } From 4e6e7fb20343b853b9dd37e14900f0912f90087c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 00:40:49 -0700 Subject: [PATCH 0354/1496] Fixed port type --- lib/coins/xmr.js | 4 ++-- lib/pool.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7895b7203..8eef889c9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -408,7 +408,7 @@ function Coin(data){ case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, height); // Lethean default: - console.error("Unknown port for PoW type " + port + " on " + height + " height"); + console.error("Unknown " + port + " port for PoW type on " + height + " height"); return multiHashing.cryptonight(convertedBlob, 8); } } @@ -440,7 +440,7 @@ function Coin(data){ case 38081: return "cn/half"; // MSR case 48782: return "cn/r"; // Lethean default: - console.error("Unknown port for PoW type " + port + " on " + version + " version"); + console.error("Unknown " + port + " port for PoW type on " + version + " version"); return "cn/r"; } } diff --git a/lib/pool.js b/lib/pool.js index 0d1910ff4..9299f88c5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -271,7 +271,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa let template = Object.assign({}, rpc_template); template.coin = coin; - template.port = port; + template.port = parseInt(port); template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; From ec4744fa0d1ad949c805cc4d14a1e1b4fcbf54bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 07:05:04 -0700 Subject: [PATCH 0355/1496] More debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9299f88c5..03bab51e3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1351,9 +1351,10 @@ function processShare(miner, job, blockTemplate, params) { } let shareBuffer2 = null; try { + console.log(JSON.stringify(blockTemplate.child_template_buffer)); shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, blockTemplate.port, blockTemplate.child_template_buffer); } catch (e) { - const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template.buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; + const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't construct_mm_child_block_blob", err_str); return invalid_share(miner); From 64da98634fe0ff0828f6b1b04b3788a9de352b59 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:11:53 -0700 Subject: [PATCH 0356/1496] More debug --- lib/pool.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 03bab51e3..04efc902c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,9 +280,17 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (child_coin in activeBlockTemplates) { template.child_template = activeBlockTemplates[child_coin]; template.child_template_buffer = template.child_template.buffer; +console.log("DEBUG: BT1"); +console.log(template.child_template_buffer); +console.log(template.child_template_buffer.toString('hex')); +console.log(JSON.stringify(template.child_template_buffer)); template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); +console.log("DEBUG: BT2"); +console.log(template.child_template_buffer); +console.log(template.child_template_buffer.toString('hex')); +console.log(JSON.stringify(template.child_template_buffer)); } } @@ -1351,7 +1359,10 @@ function processShare(miner, job, blockTemplate, params) { } let shareBuffer2 = null; try { - console.log(JSON.stringify(blockTemplate.child_template_buffer)); +console.log("DEBUG: BT"); +console.log(blockTemplate.child_template_buffer); +console.log(blockTemplate.child_template_buffer.toString('hex')); +console.log(JSON.stringify(blockTemplate.child_template_buffer)); shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, blockTemplate.port, blockTemplate.child_template_buffer); } catch (e) { const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; @@ -1569,7 +1580,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } else { is_outdated = true; } - } + } } if (!blockTemplate || is_outdated) { let err_str = is_outdated ? "Block outdated" : "Block expired"; From adf2cc8da4d7882e0686985a998f498d8ea4dc43 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:13:14 -0700 Subject: [PATCH 0357/1496] More debug --- lib/pool.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 04efc902c..da7fb083d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1352,6 +1352,13 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } +if ("child_template" in blockTemplate) { +console.log("DEBUG: BTX"); +console.log(blockTemplate.child_template_buffer); +console.log(blockTemplate.child_template_buffer.toString('hex')); +console.log(JSON.stringify(blockTemplate.child_template_buffer)); +} + if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); From 7b594f5e0d847d61787f7db72f384e6d3f95a268 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:18:07 -0700 Subject: [PATCH 0358/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index da7fb083d..465615b34 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -268,7 +268,7 @@ function updateActivePort(coin) { } function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange) { - let template = Object.assign({}, rpc_template); + let template = rpc_template; //Object.assign({}, rpc_template); template.coin = coin; template.port = parseInt(port); From 0ceb1e5e05d8251a5372cc179ba8038965d537e2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:20:04 -0700 Subject: [PATCH 0359/1496] More debug --- lib/pool.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 465615b34..3b76ca76e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -268,7 +268,7 @@ function updateActivePort(coin) { } function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange) { - let template = rpc_template; //Object.assign({}, rpc_template); + let template = Object.assign({}, rpc_template); template.coin = coin; template.port = parseInt(port); @@ -499,6 +499,11 @@ function setNewBlockTemplate(template) { activeBlockTemplates[coin] = new BlockTemplate(template); +console.log("DEBUG: BT2"); +console.log(activeBlockTemplates[coin].child_template_buffer); +console.log(activeBlockTemplates[coin].child_template_buffer.toString('hex')); +console.log(JSON.stringify(activeBlockTemplates[coin].child_template_buffer)); + const height = activeBlockTemplates[coin].height; if (coin === "" && global.config.daemon.port == activeBlockTemplates[""].port) { @@ -1352,12 +1357,12 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } -if ("child_template" in blockTemplate) { +/*if ("child_template" in blockTemplate) { console.log("DEBUG: BTX"); console.log(blockTemplate.child_template_buffer); console.log(blockTemplate.child_template_buffer.toString('hex')); console.log(JSON.stringify(blockTemplate.child_template_buffer)); -} +} */ if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { From a54d0cb247c22fcaf89b2627dc8f5b304a616c99 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:20:52 -0700 Subject: [PATCH 0360/1496] More debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 3b76ca76e..58e22f7f3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -500,9 +500,11 @@ function setNewBlockTemplate(template) { activeBlockTemplates[coin] = new BlockTemplate(template); console.log("DEBUG: BT2"); +if ("child_template" in activeBlockTemplates[coin]) { console.log(activeBlockTemplates[coin].child_template_buffer); console.log(activeBlockTemplates[coin].child_template_buffer.toString('hex')); console.log(JSON.stringify(activeBlockTemplates[coin].child_template_buffer)); +} const height = activeBlockTemplates[coin].height; From 00d628b1c42702748b3442b60d54d1b122869d10 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:24:09 -0700 Subject: [PATCH 0361/1496] Added debug --- lib/coins/xmr.js | 10 ++++++++++ lib/pool.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8eef889c9..e9c4a1ed9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,6 +293,16 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; +if (cluster.isMaster) { +console.log("DEBUG: BT3"); +console.log(template.child_template_buffer); +console.log(template.child_template_buffer.toString('hex')); +console.log(JSON.stringify(template.child_template_buffer)); +console.log("DEBUG: BT4"); +console.log(this.child_template_buffer); +console.log(this.child_template_buffer.toString('hex')); +console.log(JSON.stringify(this.child_template_buffer)); +} this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + template.parent_extra_nonce_hex + this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); diff --git a/lib/pool.js b/lib/pool.js index 58e22f7f3..015e3aa49 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -499,8 +499,8 @@ function setNewBlockTemplate(template) { activeBlockTemplates[coin] = new BlockTemplate(template); +if ("child_template" in activeBlockTemplates[coin] && cluster.isMaster) { console.log("DEBUG: BT2"); -if ("child_template" in activeBlockTemplates[coin]) { console.log(activeBlockTemplates[coin].child_template_buffer); console.log(activeBlockTemplates[coin].child_template_buffer.toString('hex')); console.log(JSON.stringify(activeBlockTemplates[coin].child_template_buffer)); From 534f3df2b171504543f27ae3d88863be4cceb161 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:24:38 -0700 Subject: [PATCH 0362/1496] Added debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 015e3aa49..1e643dfb3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -500,7 +500,7 @@ function setNewBlockTemplate(template) { activeBlockTemplates[coin] = new BlockTemplate(template); if ("child_template" in activeBlockTemplates[coin] && cluster.isMaster) { -console.log("DEBUG: BT2"); +console.log("DEBUG: BT5"); console.log(activeBlockTemplates[coin].child_template_buffer); console.log(activeBlockTemplates[coin].child_template_buffer.toString('hex')); console.log(JSON.stringify(activeBlockTemplates[coin].child_template_buffer)); From a1aead3bd9a1c196f3446a3f8a8a6cdb364d632e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:25:38 -0700 Subject: [PATCH 0363/1496] Added debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e9c4a1ed9..1fdeb2c2d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,7 +293,7 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; -if (cluster.isMaster) { +if (true) { console.log("DEBUG: BT3"); console.log(template.child_template_buffer); console.log(template.child_template_buffer.toString('hex')); From 8e67e46e8e5d2effef2816a6c683d19a4a11d2f5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:34:49 -0700 Subject: [PATCH 0364/1496] Fixed issue with wrong buffer stringify --- lib/coins/xmr.js | 10 ---------- lib/pool.js | 28 ++-------------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1fdeb2c2d..8eef889c9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,16 +293,6 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; -if (true) { -console.log("DEBUG: BT3"); -console.log(template.child_template_buffer); -console.log(template.child_template_buffer.toString('hex')); -console.log(JSON.stringify(template.child_template_buffer)); -console.log("DEBUG: BT4"); -console.log(this.child_template_buffer); -console.log(this.child_template_buffer.toString('hex')); -console.log(JSON.stringify(this.child_template_buffer)); -} this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + template.parent_extra_nonce_hex + this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); diff --git a/lib/pool.js b/lib/pool.js index 1e643dfb3..ea858940a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,17 +280,9 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (child_coin in activeBlockTemplates) { template.child_template = activeBlockTemplates[child_coin]; template.child_template_buffer = template.child_template.buffer; -console.log("DEBUG: BT1"); -console.log(template.child_template_buffer); -console.log(template.child_template_buffer.toString('hex')); -console.log(JSON.stringify(template.child_template_buffer)); template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); -console.log("DEBUG: BT2"); -console.log(template.child_template_buffer); -console.log(template.child_template_buffer.toString('hex')); -console.log(JSON.stringify(template.child_template_buffer)); } } @@ -499,13 +491,6 @@ function setNewBlockTemplate(template) { activeBlockTemplates[coin] = new BlockTemplate(template); -if ("child_template" in activeBlockTemplates[coin] && cluster.isMaster) { -console.log("DEBUG: BT5"); -console.log(activeBlockTemplates[coin].child_template_buffer); -console.log(activeBlockTemplates[coin].child_template_buffer.toString('hex')); -console.log(JSON.stringify(activeBlockTemplates[coin].child_template_buffer)); -} - const height = activeBlockTemplates[coin].height; if (coin === "" && global.config.daemon.port == activeBlockTemplates[""].port) { @@ -1359,24 +1344,15 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } -/*if ("child_template" in blockTemplate) { -console.log("DEBUG: BTX"); -console.log(blockTemplate.child_template_buffer); -console.log(blockTemplate.child_template_buffer.toString('hex')); -console.log(JSON.stringify(blockTemplate.child_template_buffer)); -} */ - if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } + // need to properly restore child template buffer here since it went via message string and was restored not correctly + blockTemplate.child_template_buffer = Buffer.from(JSON.stringify(blockTemplate.child_template_buffer)); let shareBuffer2 = null; try { -console.log("DEBUG: BT"); -console.log(blockTemplate.child_template_buffer); -console.log(blockTemplate.child_template_buffer.toString('hex')); -console.log(JSON.stringify(blockTemplate.child_template_buffer)); shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, blockTemplate.port, blockTemplate.child_template_buffer); } catch (e) { const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; From d05fdd93bab3ab8f0a69fd0cc013f0de09b66a9c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:51:35 -0700 Subject: [PATCH 0365/1496] More debug --- lib/pool.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ea858940a..150d51c4f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1344,6 +1344,11 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } + if ("child_template" in blockTemplate) { + console.log("XXX1 " + blockTemplate.difficulty); + console.log("XXX2 " + blockTemplate.child_template.difficulty); + } + if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1560,9 +1565,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply })[0]; let is_outdated = false; if (blockTemplate && blockTemplate.timeOutdate) { - let late_time = Date.now() - blockTemplate.timeOutdate; + const late_time = Date.now() - blockTemplate.timeOutdate; if (late_time > 0) { - let max_late_time = global.config.pool.targetTime*1000; + const max_late_time = global.config.pool.targetTime*1000; if (late_time < max_late_time) { let factor = (max_late_time - late_time) / max_late_time; job.rewarded_difficulty = Math.floor(job.difficulty * Math.pow(factor, 6)); From 83203194352a2f5161ec6bc90a0e69b54bfff6b8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 09:53:38 -0700 Subject: [PATCH 0366/1496] Less debug --- lib/pool.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 150d51c4f..730add9bc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1344,11 +1344,6 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } - if ("child_template" in blockTemplate) { - console.log("XXX1 " + blockTemplate.difficulty); - console.log("XXX2 " + blockTemplate.child_template.difficulty); - } - if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); From c35a6507d8c390b4f6bd6f2f1f6304275cae0d72 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 10:02:55 -0700 Subject: [PATCH 0367/1496] Improved past BT storing --- lib/pool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 730add9bc..281df0fdb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -24,8 +24,7 @@ let lastCoinHashFactor = {}; // coin key, last set individual coin hash factor let currCoinHashFactor = {}; // coin key, current individual coin hash factor let currCoinHashFactorMM = {}; // coin key, current individual coin hash factor that includes merged mining factor let activeBlockTemplates = {}; // coin key - -let pastBlockTemplates = global.support.circularBuffer(10); +let pastBlockTemplates = {}; // coin key -> global.support.circularBuffer -> activeBlockTemplates let lastPortErrorTime = {}; // main coin port @@ -479,7 +478,8 @@ function setNewBlockTemplate(template) { } } activeBlockTemplates[coin].timeOutdate = Date.now() + 4*1000; - pastBlockTemplates.enq(activeBlockTemplates[coin]); + if (!(coin in pastBlockTemplates)) pastBlockTemplates[coin] = global.support.circularBuffer(10); + pastBlockTemplates[coin].enq(activeBlockTemplates[coin]); if (activeBlockTemplates[coin].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { @@ -1555,7 +1555,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply job.rewarded_difficulty = job.difficulty; if (activeBlockTemplates[job.coin].idHash !== job.blockHash) { - blockTemplate = pastBlockTemplates.toarray().filter(function (t) { + blockTemplate = pastBlockTemplates[job.coin].toarray().filter(function (t) { return t.idHash === job.blockHash; })[0]; let is_outdated = false; @@ -1663,7 +1663,7 @@ setInterval(function dump_vars() { for (var [minerId, miner] of activeMiners) s.write(minerId + ": " + JSON.stringify(miner, null, '\t') + "\n"); s.write("\n\n\npastBlockTemplates:\n"); - pastBlockTemplates.toarray().forEach(function(v) { s.write(JSON.stringify(v, null, '\t') + "\n"); }); + s.write(JSON.stringify(pastBlockTemplates, null, '\t') + "\n"); s.write("\n\n\nlastBlockHash:\n"); s.write(JSON.stringify(lastBlockHash, null, '\t') + "\n"); @@ -1677,7 +1677,7 @@ setInterval(function dump_vars() { s.write("\n\n\ncurrCoinHashFactorMM:\n"); s.write(JSON.stringify(currCoinHashFactorMM, null, '\t') + "\n"); - s.write("\n\n\nactiveBlockTemplate:\n"); + s.write("\n\n\nactiveBlockTemplates:\n"); s.write(JSON.stringify(activeBlockTemplates, null, '\t') + "\n"); s.write("\n\n\nproxyMiners:\n"); From b5dad72fee6ef4a56ffce151983ace5a9a033d69 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 11:20:46 -0700 Subject: [PATCH 0368/1496] More debug --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 281df0fdb..7fe60be97 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1344,6 +1344,11 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } + if ("child_template" in blockTemplate) { + console.log("XXX1 " + JSON.stringify(blockTemplate.child_template_buffer)); + console.log("XXX1 " + JSON.stringify(Buffer.from(JSON.stringify(blockTemplate.child_template_buffer)))); + } + if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); From 0c9afbe02cdc9e6f7ce8d5f8d404c7ad6aad954f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 11:22:24 -0700 Subject: [PATCH 0369/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7fe60be97..54c7439f7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1346,7 +1346,7 @@ function processShare(miner, job, blockTemplate, params) { if ("child_template" in blockTemplate) { console.log("XXX1 " + JSON.stringify(blockTemplate.child_template_buffer)); - console.log("XXX1 " + JSON.stringify(Buffer.from(JSON.stringify(blockTemplate.child_template_buffer)))); + console.log("XXX2 " + JSON.stringify(Buffer.from(blockTemplate.child_template_buffer))); } if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. From aebddde927bb2d6f1e58ca661d4acea2f25103c1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 11:23:15 -0700 Subject: [PATCH 0370/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 54c7439f7..8fca62490 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1346,7 +1346,7 @@ function processShare(miner, job, blockTemplate, params) { if ("child_template" in blockTemplate) { console.log("XXX1 " + JSON.stringify(blockTemplate.child_template_buffer)); - console.log("XXX2 " + JSON.stringify(Buffer.from(blockTemplate.child_template_buffer))); + console.log("XXX2 " + Buffer.from(blockTemplate.child_template_buffer)); } if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. From 85128918939241d04bab654f584a7fc0f256d9a3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 11:23:51 -0700 Subject: [PATCH 0371/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8fca62490..3755675a5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1346,7 +1346,7 @@ function processShare(miner, job, blockTemplate, params) { if ("child_template" in blockTemplate) { console.log("XXX1 " + JSON.stringify(blockTemplate.child_template_buffer)); - console.log("XXX2 " + Buffer.from(blockTemplate.child_template_buffer)); + console.log("XXX2 " + Buffer.from(blockTemplate.child_template_buffer).toString('hex')); } if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. From 698c0101fd504c5d4bd53df0c6dd53219fc5a67b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 11:25:00 -0700 Subject: [PATCH 0372/1496] Fixed child buffer creation --- lib/pool.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3755675a5..34218b991 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1344,18 +1344,13 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } - if ("child_template" in blockTemplate) { - console.log("XXX1 " + JSON.stringify(blockTemplate.child_template_buffer)); - console.log("XXX2 " + Buffer.from(blockTemplate.child_template_buffer).toString('hex')); - } - if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } // need to properly restore child template buffer here since it went via message string and was restored not correctly - blockTemplate.child_template_buffer = Buffer.from(JSON.stringify(blockTemplate.child_template_buffer)); + blockTemplate.child_template_buffer = Buffer.from(blockTemplate.child_template_buffer); let shareBuffer2 = null; try { shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, blockTemplate.port, blockTemplate.child_template_buffer); From 6ff26740a4488c35f3b72feea7d2ba477d15ee63 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 11:37:52 -0700 Subject: [PATCH 0373/1496] Record mm share data --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 34218b991..6f207b185 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1344,7 +1344,8 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } - if ("child_template" in blockTemplate && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. + const is_mm = "child_template" in blockTemplate; + if (is_mm && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); @@ -1377,6 +1378,7 @@ function processShare(miner, job, blockTemplate, params) { } else { recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); + if (is_mm) recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate.child_template); } return true; From 20a1a884cdeadf5e93d579e5a9f009c8ff0208c4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 12:02:10 -0700 Subject: [PATCH 0374/1496] Removed master coin hashfactor change --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6f207b185..3402f234b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -398,10 +398,10 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he if (child_coin in lastCoinHashFactor) currCoinHashFactorMM[coin] += lastCoinHashFactor[child_coin]; } - if (cluster.isMaster) { - console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor + (is_mm ? ' (MM: ' + currCoinHashFactorMM[coin] + ')' : "")); + if (coin !== "") { + if (cluster.isMaster) console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor + (is_mm ? ' (MM: ' + currCoinHashFactorMM[coin] + ')' : "")); + set_hash_factor(coin, coinHashFactor); } - if (coin !== "") set_hash_factor(coin, coinHashFactor); if (!(coin in activeBlockTemplates)) return; // update parent coins if current coin was updated now From 1c3fef2bbbac1c00ad3b8179053ef5c780340e25 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 19:17:31 -0700 Subject: [PATCH 0375/1496] Fixed MM stuff --- lib/coins/xmr.js | 13 ++++++------- lib/pool.js | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8eef889c9..1bd30aca7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -253,9 +253,9 @@ function Coin(data){ return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0])); }; - this.constructMMParentBlockExtraNonce = function(parentTemplateBuffer, port, childTemplateBuffer) { - console.log("MERGED MINING: constructMMParentBlockExtraNonce"); - return cnUtil.construct_mm_parent_block_extra_nonce(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); + this.constructMMParentBlockBlob = function(parentTemplateBuffer, port, childTemplateBuffer) { + console.log("MERGED MINING: constructMMParentBlockBlob"); + return cnUtil.construct_mm_parent_block_blob(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); }; this.constructMMChildBlockBlob = function(shareBuffer, port, childTemplateBuffer) { @@ -281,7 +281,6 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream. - this.blocktemplate_blob = template.blocktemplate_blob; this.reserved_offset = template.reserved_offset; this.difficulty = template.difficulty; this.height = template.height; @@ -293,9 +292,9 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; - this.blocktemplate_blob = this.blocktemplate_blob.substring(0, this.reserved_offset * 2) + - template.parent_extra_nonce_hex + - this.blocktemplate_blob.substring(this.reserved_offset * 2 + template.parent_extra_nonce_hex.length); + this.blocktemplate_blob = template.parent_blocktemplate_blob; + } else { + this.blocktemplate_blob = template.blocktemplate_blob; } this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); diff --git a/lib/pool.js b/lib/pool.js index 3402f234b..ee366e010 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -277,9 +277,9 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); if (child_coin in activeBlockTemplates) { - template.child_template = activeBlockTemplates[child_coin]; - template.child_template_buffer = template.child_template.buffer; - template.parent_extra_nonce_hex = global.coinFuncs.constructMMParentBlockExtraNonce( + template.child_template = activeBlockTemplates[child_coin]; + template.child_template_buffer = template.child_template.buffer; + template.parent_blocktemplate_blob = global.coinFuncs.constructMMParentBlockBlob( new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } From b84163ca5e18a389afc49e6700540ac9ccdcbdbf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 19:20:35 -0700 Subject: [PATCH 0376/1496] Fixed MM stuff --- lib/coins/xmr.js | 12 +++++------- lib/pool.js | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1bd30aca7..6d4231a1f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -299,8 +299,6 @@ function Coin(data){ this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); - // Set this.reserveOffset to the byte location of the reserved offset. - this.reserveOffset = template.reserved_offset + (is_mm ? mm_nonce_size : 0); // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. this.buffer = new Buffer(this.blocktemplate_blob, 'hex'); @@ -313,24 +311,24 @@ function Coin(data){ } // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. - instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 4); + instanceId.copy(this.buffer, this.reserved_offset + 4, 0, 4); // Reset the Nonce - this is the per-miner/pool nonce this.extraNonce = 0; // The clientNonceLocation is the location at which the client pools should set the nonces for each of their clients. - this.clientNonceLocation = this.reserveOffset + 12; + this.clientNonceLocation = this.reserved_offset + 12; // The clientPoolLocation is for multi-thread/multi-server pools to handle the nonce for each of their tiers. - this.clientPoolLocation = this.reserveOffset + 8; + this.clientPoolLocation = this.reserved_offset + 8; this.nextBlob = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. - this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset); + this.buffer.writeUInt32BE(++this.extraNonce, this.reserved_offset); // Convert the buffer into something hashable. return global.coinFuncs.convertBlob(this.buffer, this.port).toString('hex'); }; // Make it so you can get the raw block buffer out. this.nextBlobWithChildNonce = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. - this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset); + this.buffer.writeUInt32BE(++this.extraNonce, this.reserved_offset); // Don't convert the buffer to something hashable. You bad. return this.buffer.toString('hex'); }; diff --git a/lib/pool.js b/lib/pool.js index ee366e010..77b932ca4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -969,7 +969,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer variant: variant_name, difficulty: bt.difficulty, height: bt.height, - reserved_offset: bt.reserveOffset, + reserved_offset: bt.reserved_offset, client_nonce_offset: bt.clientNonceLocation, client_pool_offset: bt.clientPoolLocation, target_diff: this.difficulty, @@ -1198,10 +1198,10 @@ function getShareBuffer(miner, job, blockTemplate, params) { let template = new Buffer(blockTemplate.buffer.length); if (!miner.proxy) { blockTemplate.buffer.copy(template); - template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset); + template.writeUInt32BE(job.extraNonce, blockTemplate.reserved_offset); } else { blockTemplate.buffer.copy(template); - template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset); + template.writeUInt32BE(job.extraNonce, blockTemplate.reserved_offset); template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); } From 0ad1240e12a7bbda724356bd4736280b050a09ad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 19:45:09 -0700 Subject: [PATCH 0377/1496] Avoid blob override by parent --- lib/coins/xmr.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6d4231a1f..6bb3e32b6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -281,6 +281,7 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream. + this.blocktemplate_blob = template.blocktemplate_blob; this.reserved_offset = template.reserved_offset; this.difficulty = template.difficulty; this.height = template.height; @@ -292,17 +293,16 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; - this.blocktemplate_blob = template.parent_blocktemplate_blob; - } else { - this.blocktemplate_blob = template.blocktemplate_blob; } - this.idHash = crypto.createHash('md5').update(this.blocktemplate_blob).digest('hex'); + const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; + + this.idHash = crypto.createHash('md5').update(blob).digest('hex'); - // Set this.buffer to the binary decoded version of the BT blocktemplate_blob. - this.buffer = new Buffer(this.blocktemplate_blob, 'hex'); + // Set this.buffer to the binary decoded version of the BT blob + this.buffer = new Buffer(blob, 'hex'); - if (!("prev_hash" in template)) { // Get prev_hash from this.blocktemplate_blob + if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); this.buffer.copy(prev_hash, 0, 7, 39); this.prev_hash = prev_hash.toString('hex'); From a2bece1928dde25a3c36e68ce771b1f25862a45f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 21:22:08 -0700 Subject: [PATCH 0378/1496] Fixed block submit --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 77b932ca4..7bf9b6f13 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1224,7 +1224,7 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, shareBuffer, retry) { +function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, retry) { global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. @@ -1269,7 +1269,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, retry) { recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, shareType, blockTemplate); } else { if (retry) { - setTimeout(submit_block, 500, false); + setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, false); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1340,7 +1340,7 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } - submit_block(miner, job, blockTemplate, shareBuffer, true); + submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, true); is_block_diff_matched = true; } @@ -1362,7 +1362,7 @@ function processShare(miner, job, blockTemplate, params) { return invalid_share(miner); } if (shareBuffer2 === null) return invalid_share(miner); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, true); is_block_diff_matched = true; } From 965a2129d48d4fa4e059e7702e44ed14e22703cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 22:45:03 -0700 Subject: [PATCH 0379/1496] Fixed shareType param --- lib/pool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7bf9b6f13..f1e4c60d1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1224,15 +1224,15 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, retry) { +function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, retry) { global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); let isNotifyAdmin = true; if (shareType) { - let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); + const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); + const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } @@ -1269,7 +1269,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, retry) { recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, shareType, blockTemplate); } else { if (retry) { - setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, false); + setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, shareType, false); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1340,7 +1340,7 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } - submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, true); + submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, true); is_block_diff_matched = true; } @@ -1362,7 +1362,7 @@ function processShare(miner, job, blockTemplate, params) { return invalid_share(miner); } if (shareBuffer2 === null) return invalid_share(miner); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, shareType, true); is_block_diff_matched = true; } From eae34cb6656d1c320f94cf7c292d3d5129d249ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 23:06:01 -0700 Subject: [PATCH 0380/1496] Fix chil block crash --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f1e4c60d1..f8eeeabef 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1224,13 +1224,13 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, retry) { +function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, isParentBlock, retry) { global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); let isNotifyAdmin = true; - if (shareType) { + if (isParentBlock && shareType) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; @@ -1269,7 +1269,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareTyp recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, shareType, blockTemplate); } else { if (retry) { - setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, shareType, false); + setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, shareType, isParentBlock, false); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1340,7 +1340,7 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } - submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, true); + submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, true, true); is_block_diff_matched = true; } @@ -1362,7 +1362,7 @@ function processShare(miner, job, blockTemplate, params) { return invalid_share(miner); } if (shareBuffer2 === null) return invalid_share(miner); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, shareType, true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, shareType, false, true); is_block_diff_matched = true; } From aed1b1f5e5296b449fb1c5f3339d055ccd6d81c4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Apr 2019 23:09:37 -0700 Subject: [PATCH 0381/1496] More clean var names --- lib/pool.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f8eeeabef..2148e78da 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -995,7 +995,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } } -// store wallet_key (address, paymentID, bitcoin, poolTypeEnum, port) -> worker_name -> shareType -> (height, difficulty, time, acc, acc2) +// store wallet_key (address, paymentID, bitcoin, poolTypeEnum, port) -> worker_name -> isTrustedShare -> (height, difficulty, time, acc, acc2) let walletAcc = {}; // number of worker_name for wallet_key (so we do not count them by iteration) let walletWorkerCount = {}; @@ -1047,7 +1047,7 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi } } -function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareType, blockTemplate) { +function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrustedShare, blockTemplate) { miner.hashes += job.difficulty; let proxyMinerName = miner.payout + ":" + miner.identifier; if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.difficulty; @@ -1071,7 +1071,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy paymentAddress: miner.address, paymentID: miner.paymentID, foundBlock: blockCandidate, - trustedShare: shareType, + trustedShare: isTrustedShare, poolType: miner.poolTypeEnum, poolID: global.config.pool_id, blockDiff: blockTemplate.difficulty, @@ -1119,7 +1119,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy paymentAddress: miner.address, paymentID: miner.paymentID, foundBlock: false, - trustedShare: shareType, + trustedShare: isTrustedShare, poolType: miner.poolTypeEnum, poolID: global.config.pool_id, blockDiff: difficulty, @@ -1179,7 +1179,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy })); } } - if (shareType) { + if (isTrustedShare) { process.send({type: 'trustedShare'}); debug(threadName + "Accepted trusted share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); } else { @@ -1224,19 +1224,19 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, isParentBlock, retry) { +function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTrustedShare, isParentBlock, isRetrySubmitBlock) { global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. - recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); + recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); let isNotifyAdmin = true; - if (isParentBlock && shareType) { + if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } - console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); + console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", share type: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time global.coinFuncs.getPortLastBlockHeader(blockTemplate.port, function(err, body) { @@ -1248,7 +1248,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareTyp "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "Input: " + shareBuffer.toString('hex') + "\n" + - threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", share type: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) ); }); }, 2*1000); @@ -1264,12 +1264,12 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareTyp // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + blockTemplate.height + " by " + miner.logString + - ", share type: " + shareType + " - submit result: " + JSON.stringify(rpcResult.result) + ", share type: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) ); - recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, shareType, blockTemplate); + recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); } else { - if (retry) { - setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, shareType, isParentBlock, false); + if (isRetrySubmitBlock) { + setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, isTrustedShare, isParentBlock, false); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1286,7 +1286,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareTyp function processShare(miner, job, blockTemplate, params) { let hash; - let shareType; + let isTrustedShare; let shareBuffer; const resultHash = params.result; @@ -1300,7 +1300,7 @@ function processShare(miner, job, blockTemplate, params) { } catch (err) { return invalid_share(miner); } - shareType = true; + isTrustedShare = true; } else { // verify share if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { @@ -1326,7 +1326,7 @@ function processShare(miner, job, blockTemplate, params) { } ++ walletTrust[miner.payout]; - shareType = false; + isTrustedShare = false; } let hashArray = hash.toByteArray().reverse(); @@ -1340,7 +1340,7 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } - submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, shareType, true, true); + submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTrustedShare, true, true); is_block_diff_matched = true; } @@ -1362,7 +1362,7 @@ function processShare(miner, job, blockTemplate, params) { return invalid_share(miner); } if (shareBuffer2 === null) return invalid_share(miner); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, shareType, false, true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, isTrustedShare, false, true); is_block_diff_matched = true; } @@ -1377,8 +1377,8 @@ function processShare(miner, job, blockTemplate, params) { return invalid_share(miner); } else { - recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); - if (is_mm) recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate.child_template); + recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); + if (is_mm) recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); } return true; From 3d14fec884b003a8065c5fe1a0422a1cfb28c801 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 12:15:11 -0700 Subject: [PATCH 0382/1496] Added check of parent bloc reserialization --- lib/coins/xmr.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6bb3e32b6..23dbf975c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,6 +293,9 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; + if (template.parent_blocktemplate_blob[this.reserved_offset - 2] != 2 || template.parent_blocktemplate_blob[this.reserved_offset - 1] != 17) { + console.error("INTERNAL ERROR: Parent block after serialization changed reserved_offset!"); + } } const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; From 6ad7224590dc3950c090f717af076e2f0561fb6b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 12:17:18 -0700 Subject: [PATCH 0383/1496] Fixed serialization check --- lib/coins/xmr.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 23dbf975c..404eeaaba 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,9 +293,6 @@ function Coin(data){ if (is_mm) { this.child_template = template.child_template; this.child_template_buffer = template.child_template_buffer; - if (template.parent_blocktemplate_blob[this.reserved_offset - 2] != 2 || template.parent_blocktemplate_blob[this.reserved_offset - 1] != 17) { - console.error("INTERNAL ERROR: Parent block after serialization changed reserved_offset!"); - } } const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; @@ -305,6 +302,12 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); + if (is_mm) { + if (this.buffer[this.reserved_offset - 2] != 2 || this.buffer[this.reserved_offset - 1] != 17) { + console.error("INTERNAL ERROR: Parent block after serialization changed reserved_offset!"); + } + } + if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); this.buffer.copy(prev_hash, 0, 7, 39); From 74c48300d7f372339efd27605df675a255506886 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 12:19:20 -0700 Subject: [PATCH 0384/1496] More debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 404eeaaba..f001f5b0e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -304,7 +304,7 @@ function Coin(data){ if (is_mm) { if (this.buffer[this.reserved_offset - 2] != 2 || this.buffer[this.reserved_offset - 1] != 17) { - console.error("INTERNAL ERROR: Parent block after serialization changed reserved_offset!"); + console.error("INTERNAL ERROR: Parent block after serialization changed reserved_offset " + this.reserved_offset + ": " + this.buffer.toString('hex')); } } From 6557cba904599a92a8721fa1a92a4cad7681283a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 12:43:44 -0700 Subject: [PATCH 0385/1496] Ipmroved reserved offsetdetection --- lib/coins/xmr.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f001f5b0e..d17ce662c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -15,6 +15,7 @@ const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 +const pool_nonce_size = 16; const port2coin = { "11181": "AEON", "11898": "TRTL", @@ -214,7 +215,7 @@ function Coin(data){ this.getPortBlockTemplate = function(port, callback){ global.support.rpcPortDaemon(port, 'getblocktemplate', { - reserve_size: port in mm_port_set ? mm_nonce_size + 16 + 1 : 16 + 1, + reserve_size: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size, wallet_address: global.config.pool[port == global.config.daemon.port ? "address" : "address_" + port.toString()] }, function(body){ return callback(body); @@ -282,7 +283,6 @@ function Coin(data){ // Set these params equal to values we get from upstream. this.blocktemplate_blob = template.blocktemplate_blob; - this.reserved_offset = template.reserved_offset; this.difficulty = template.difficulty; this.height = template.height; this.coin = template.coin; @@ -302,10 +302,22 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); - if (is_mm) { - if (this.buffer[this.reserved_offset - 2] != 2 || this.buffer[this.reserved_offset - 1] != 17) { - console.error("INTERNAL ERROR: Parent block after serialization changed reserved_offset " + this.reserved_offset + ": " + this.buffer.toString('hex')); + const extra_nonce_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); + const found_reserved_offset_template = blob.indexOf(extra_nonce_template_hex); + + if (found_reserved_offset_template !== -1) { + const found_reserved_offset = (found_reserved_offset_template >> 1) + 2; + if (is_mm) { + this.reserved_offset = found_reserved_offset; + } else { + if (found_reserved_offset != template.reserved_offset) { + console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + this.buffer.toString('hex')); + } + this.reserved_offset = found_reserved_offset; } + } else { + console.error("INTERNAL ERROR: Can not find reserved offset template '" + extra_nonce_template_hex + "' in block " + ": " + this.buffer.toString('hex')); + this.reserved_offset = found_reserved_offset; } if (!("prev_hash" in template)) { // Get prev_hash from blob From 165b0285cb4439c4db68a19a7a62892b808a38cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 12:45:27 -0700 Subject: [PATCH 0386/1496] Fixed bug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d17ce662c..04f9fbedd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -317,7 +317,7 @@ function Coin(data){ } } else { console.error("INTERNAL ERROR: Can not find reserved offset template '" + extra_nonce_template_hex + "' in block " + ": " + this.buffer.toString('hex')); - this.reserved_offset = found_reserved_offset; + this.reserved_offset = template.reserved_offset; } if (!("prev_hash" in template)) { // Get prev_hash from blob From 2b390a80711f5229a40beabc919c343c114a2a9d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 12:49:32 -0700 Subject: [PATCH 0387/1496] Fixed bug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 04f9fbedd..c9518d49b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -15,7 +15,7 @@ const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 -const pool_nonce_size = 16; +const pool_nonce_size = 16+1; // 1 extra byte for old daemon bug const port2coin = { "11181": "AEON", "11898": "TRTL", From e214a5d3ebec295a545998097df37bc69e342774 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 12:59:49 -0700 Subject: [PATCH 0388/1496] Some TRTL bug fix with reserved offests --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c9518d49b..45f3a957d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -310,7 +310,7 @@ function Coin(data){ if (is_mm) { this.reserved_offset = found_reserved_offset; } else { - if (found_reserved_offset != template.reserved_offset) { + if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + this.buffer.toString('hex')); } this.reserved_offset = found_reserved_offset; From cd495c77cb38eba1108fc135ee7f9445effe0ec4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 13:01:41 -0700 Subject: [PATCH 0389/1496] Added explanations --- lib/coins/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 45f3a957d..54b1c2ac8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -15,7 +15,7 @@ const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 -const pool_nonce_size = 16+1; // 1 extra byte for old daemon bug +const pool_nonce_size = 16+1; // 1 extra byte for old XMR and new TRTL daemon bugs const port2coin = { "11181": "AEON", "11898": "TRTL", @@ -310,10 +310,11 @@ function Coin(data){ if (is_mm) { this.reserved_offset = found_reserved_offset; } else { + // here we are OK with +1 difference because we put extra byte into pool_nonce_size if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + this.buffer.toString('hex')); } - this.reserved_offset = found_reserved_offset; + this.reserved_offset = template.reserved_offset; } } else { console.error("INTERNAL ERROR: Can not find reserved offset template '" + extra_nonce_template_hex + "' in block " + ": " + this.buffer.toString('hex')); From 3ca4160e5b0bd91301b595f10203d568c96c1fa0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 13:03:39 -0700 Subject: [PATCH 0390/1496] Optimization --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 54b1c2ac8..2b7e3514c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -16,6 +16,7 @@ const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 const pool_nonce_size = 16+1; // 1 extra byte for old XMR and new TRTL daemon bugs +const extra_nonce_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); const port2coin = { "11181": "AEON", "11898": "TRTL", @@ -302,7 +303,6 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); - const extra_nonce_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); const found_reserved_offset_template = blob.indexOf(extra_nonce_template_hex); if (found_reserved_offset_template !== -1) { From 60870e78f14e1252db292493d90ba487805f0ad5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 13:05:01 -0700 Subject: [PATCH 0391/1496] Optimization --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2b7e3514c..1408562cb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -312,12 +312,12 @@ function Coin(data){ } else { // here we are OK with +1 difference because we put extra byte into pool_nonce_size if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { - console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + this.buffer.toString('hex')); + console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + blob); } this.reserved_offset = template.reserved_offset; } } else { - console.error("INTERNAL ERROR: Can not find reserved offset template '" + extra_nonce_template_hex + "' in block " + ": " + this.buffer.toString('hex')); + console.error("INTERNAL ERROR: Can not find reserved offset template '" + extra_nonce_template_hex + "' in block " + ": " + blob); this.reserved_offset = template.reserved_offset; } From 4d4667032501ebb6af1eb2da2c5146829eb88c59 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 17:45:22 -0700 Subject: [PATCH 0392/1496] Detect extra nonce tempalte hex for original parment mm block --- lib/coins/xmr.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1408562cb..4e3dbbd5a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -16,7 +16,6 @@ const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 const pool_nonce_size = 16+1; // 1 extra byte for old XMR and new TRTL daemon bugs -const extra_nonce_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); const port2coin = { "11181": "AEON", "11898": "TRTL", @@ -50,6 +49,9 @@ const port2blob_num = { const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); const mm_port_set = { "22023": 11898 }; +const extra_nonce_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); +const extra_nonce_mm_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(mm_nonce_size + pool_nonce_size); + function get_coin2port(port2coin) { let coin2port = {}; for (let port in port2coin) coin2port[port2coin[port]] = parseInt(port); @@ -303,7 +305,8 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); - const found_reserved_offset_template = blob.indexOf(extra_nonce_template_hex); + const template_hex = (port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; + const found_reserved_offset_template = blob.indexOf(template_hex); if (found_reserved_offset_template !== -1) { const found_reserved_offset = (found_reserved_offset_template >> 1) + 2; @@ -317,7 +320,7 @@ function Coin(data){ this.reserved_offset = template.reserved_offset; } } else { - console.error("INTERNAL ERROR: Can not find reserved offset template '" + extra_nonce_template_hex + "' in block " + ": " + blob); + console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in block " + ": " + blob); this.reserved_offset = template.reserved_offset; } From a3915e39929af40854cc4e957c7af0122dcb4ca6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 17:46:45 -0700 Subject: [PATCH 0393/1496] Detect extra nonce tempalte hex for original parment mm block --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4e3dbbd5a..2b007570d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -305,7 +305,7 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); - const template_hex = (port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; + const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; const found_reserved_offset_template = blob.indexOf(template_hex); if (found_reserved_offset_template !== -1) { From 9d329430fb803ba603318afcde8d79e402b45a00 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Apr 2019 17:47:53 -0700 Subject: [PATCH 0394/1496] Detect extra nonce tempalte hex for original parment mm block --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2b007570d..af8f7bc53 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -49,8 +49,8 @@ const port2blob_num = { const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); const mm_port_set = { "22023": 11898 }; -const extra_nonce_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); -const extra_nonce_mm_template_hex = "02" + (pool_nonce_size+0x100).toString(16).substr(-2) + "00".repeat(mm_nonce_size + pool_nonce_size); +const extra_nonce_template_hex = "02" + (pool_nonce_size + 0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); +const extra_nonce_mm_template_hex = "02" + (mm_nonce_size + pool_nonce_size + 0x100).toString(16).substr(-2) + "00".repeat(mm_nonce_size + pool_nonce_size); function get_coin2port(port2coin) { let coin2port = {}; From 48c277c0f4a28abf771d22da8f5fc045f4261ab4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 03:26:20 -0700 Subject: [PATCH 0395/1496] Fixed child block recorded height --- lib/pool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2148e78da..3036b575a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1061,7 +1061,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust is_walletAccFinalizer[wallet_key] = false; } - let db_job_height = global.config.daemon.port == blockTemplate.port ? job.height : anchorBlockHeight; + let db_job_height = global.config.daemon.port == blockTemplate.port ? blockTemplate.height : anchorBlockHeight; if (job.difficulty >= 1000000 || blockCandidate) { @@ -1155,7 +1155,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust if (blockCandidate) { if (global.config.daemon.port == blockTemplate.port) { - global.database.storeBlock(job.height, global.protos.Block.encode({ + global.database.storeBlock(blockTemplate.height, global.protos.Block.encode({ hash: hashHex, difficulty: blockTemplate.difficulty, shares: 0, @@ -1174,7 +1174,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust unlocked: false, valid: true, port: blockTemplate.port, - height: job.height, + height: blockTemplate.height, anchor_height: anchorBlockHeight })); } @@ -1236,7 +1236,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } - console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", share type: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); + console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", is trusted share: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time global.coinFuncs.getPortLastBlockHeader(blockTemplate.port, function(err, body) { @@ -1248,7 +1248,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "Input: " + shareBuffer.toString('hex') + "\n" + - threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", share type: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) + threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", is trusted share: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) ); }); }, 2*1000); @@ -1264,7 +1264,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + blockTemplate.height + " by " + miner.logString + - ", share type: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", is trusted share: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) ); recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); } else { From 6360cbd4d85c26a19bebc621fa88d081fe60ad72 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 09:54:48 -0700 Subject: [PATCH 0396/1496] Added block hex for good block submits --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3036b575a..1b81591eb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1236,7 +1236,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } - console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", is trusted share: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); + console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time global.coinFuncs.getPortLastBlockHeader(blockTemplate.port, function(err, body) { @@ -1248,7 +1248,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "Input: " + shareBuffer.toString('hex') + "\n" + - threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", is trusted share: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) + threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", isTrustedShare: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) ); }); }, 2*1000); @@ -1264,7 +1264,8 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + blockTemplate.height + " by " + miner.logString + - ", is trusted share: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + + ", block hex: \n" + shareBuffer.toString('hex') ); recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); } else { From 6f1a06d3b27a6342b4d92976033919f3290d4434 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 10:07:58 -0700 Subject: [PATCH 0397/1496] Updated block found message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1b81591eb..ca9a2d3c5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1263,7 +1263,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); - console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + blockTemplate.height + " by " + miner.logString + + console.log(threadName + "New " + blockTemplate.coin + "(port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", block hex: \n" + shareBuffer.toString('hex') ); From 7077576c8fafcdf047e938444325c11a5acc2e77 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 10:27:16 -0700 Subject: [PATCH 0398/1496] Disable double child coin profit calcs --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ca9a2d3c5..56540b96a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1379,7 +1379,7 @@ function processShare(miner, job, blockTemplate, params) { } else { recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); - if (is_mm) recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); + //if (is_mm) recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); } return true; From 98323f084c7674907ef8eaf35be07b621c626048 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 10:47:10 -0700 Subject: [PATCH 0399/1496] Updated block found message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 56540b96a..d1f2d7485 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1263,7 +1263,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); - console.log(threadName + "New " + blockTemplate.coin + "(port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + + console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", block hex: \n" + shareBuffer.toString('hex') ); From 94fd7aa5ae1d09100a2e4a1c12bc18d1c3a224c8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 11:29:02 -0700 Subject: [PATCH 0400/1496] More block submit error details --- lib/pool.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d1f2d7485..cf0e3409f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1236,7 +1236,11 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } - console.error(threadName + "Error submitting block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); + console.error(threadName + "Error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + + miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error) + + ", block hex: \n" + shareBuffer.toString('hex') + ); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time global.coinFuncs.getPortLastBlockHeader(blockTemplate.port, function(err, body) { @@ -1245,10 +1249,11 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste return; } if (blockTemplate.height == body.height + 1) global.support.sendEmail(global.config.general.adminEmail, - "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", + "FYI: Can't submit " + blockTemplate.coin + " block to deamon on " + blockTemplate.port + " port", "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "Input: " + shareBuffer.toString('hex') + "\n" + - threadName + "Error submitting block at " + blockTemplate.height + " height from " + miner.logString + ", isTrustedShare: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) + threadName + "Error submitting " + blockTemplate.coin + " block at " + blockTemplate.height + " height from " + miner.logString + + ", isTrustedShare: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) ); }); }, 2*1000); From be5c37bbd6da4aad197aca259a04e23b1beddd32 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 12:01:46 -0700 Subject: [PATCH 0401/1496] Fixed child block effort calcs --- lib/blockManager.js | 2 +- lib/pool.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index de4f4c4a8..5a6a421c6 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -357,7 +357,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un if (!firstShareTime) firstShareTime = shareData.timestamp; if (totalPaid < rewardTotal) lastShareTime = shareData.timestamp; - let amountToPay = shareData.shares2 ? shareData.shares2 : shareData.shares; + let amountToPay = shareData.shares2; let feesToPay = amountToPay * (global.config.payout.pplnsFee / 100) + (shareData.bitcoin === true ? amountToPay * (global.config.payout.btcFee / 100) : 0); let devDonation = feesToPay * (global.config.payout.devDonation / 100); diff --git a/lib/pool.js b/lib/pool.js index cf0e3409f..602315c99 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1384,7 +1384,11 @@ function processShare(miner, job, blockTemplate, params) { } else { recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); - //if (is_mm) recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); + // record child proc share for rewarded_difficulty effort calcs status but with 0 rewards (all included in parent share) + if (is_mm) { + job.rewarded_difficulty2 = 0; + recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); + } } return true; From 53d6b0283b8a5537aefe689018460f600683f81b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 18:03:24 -0700 Subject: [PATCH 0402/1496] Updated to tagged coin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3067c8bf..7a48c4b41 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.0" } } From 4993e0b713f72bb6a107ac13f4cfc5f2ecaeb4fe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 18:06:12 -0700 Subject: [PATCH 0403/1496] Removed extra debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index af8f7bc53..3f8358838 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -258,7 +258,7 @@ function Coin(data){ }; this.constructMMParentBlockBlob = function(parentTemplateBuffer, port, childTemplateBuffer) { - console.log("MERGED MINING: constructMMParentBlockBlob"); + //console.log("MERGED MINING: constructMMParentBlockBlob"); return cnUtil.construct_mm_parent_block_blob(parentTemplateBuffer, this.portBlobType(port, parentTemplateBuffer[0]), childTemplateBuffer); }; From 73376abcb6e7ad91d7738bd1d0932991fcd61bc7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 18:32:36 -0700 Subject: [PATCH 0404/1496] Added UTF --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7a48c4b41..6c00bf7e4 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", + "utf8", "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.0" } From 8b3cde60dd7a847ebb24b1ba24bf0b9802d7662e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Apr 2019 18:48:11 -0700 Subject: [PATCH 0405/1496] Fixed hashres calcs --- lib/worker.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 841efa731..b1ba54a5a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -89,7 +89,7 @@ function updateShareStats() { if (share.timestamp <= locTime) return; let minerIDWithIdentifier = minerID + "_" + identifier; - const shares2 = share.shares2 ? share.shares2 : share.shares; + const shares2 = share.shares2; localStats.global += shares2; if (localTimes.global < share.timestamp) localTimes.global = share.timestamp; let minerType; @@ -117,24 +117,24 @@ function updateShareStats() { if (minerID in minerPortSet) { localStats.miners[minerID] += share.shares; - localStats.miners2[minerID] += share.shares2 ? share.shares2 : share.shares; + localStats.miners2[minerID] += share.shares2; if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; } else { ++ localMinerCount[minerType]; ++ localMinerCount.global; localStats.miners[minerID] = share.shares; - localStats.miners2[minerID] = share.shares2 ? share.shares2 : share.shares; + localStats.miners2[minerID] = share.shares2; localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; minerPortSet[minerID] = port; } if (minerIDWithIdentifier in minerSet) { localStats.miners[minerIDWithIdentifier] += share.shares; - localStats.miners2[minerIDWithIdentifier] += share.shares2 ? share.shares2 : share.shares; + localStats.miners2[minerIDWithIdentifier] += share.shares2; if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; } else { localStats.miners[minerIDWithIdentifier] = share.shares; - localStats.miners2[minerIDWithIdentifier] = share.shares2 ? share.shares2 : share.shares; + localStats.miners2[minerIDWithIdentifier] = share.shares2; localTimes.miners[minerIDWithIdentifier] = share.timestamp; minerSet[minerIDWithIdentifier] = 1; } From 3ab0bf95025fa4e17a0ad18e31d5235f2e15e51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=88=86=E4=B9=8B=E4=B8=80?= Date: Sat, 6 Apr 2019 00:40:06 +0800 Subject: [PATCH 0406/1496] fix UTF --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c00bf7e4..2c0d132bf 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "uuid": "3.0.1", "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", - "utf8", "^3.0.0", + "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.0" } From fe875f2406bf0203e91c8a09175629566df80585 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 5 Apr 2019 11:32:32 -0700 Subject: [PATCH 0407/1496] Count miners for parent merged mining coin only --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index b1ba54a5a..4c7862ce8 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -115,7 +115,7 @@ function updateShareStats() { if (port in localPortHashes) localPortHashes[port] += share.shares; else localPortHashes[port] = share.shares; - if (minerID in minerPortSet) { + if (minerID in minerSet) { localStats.miners[minerID] += share.shares; localStats.miners2[minerID] += share.shares2; if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; @@ -126,7 +126,7 @@ function updateShareStats() { localStats.miners2[minerID] = share.shares2; localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; - minerPortSet[minerID] = port; + if (share.shares2) minerPortSet[minerID] = port; // set port only for parent port share } if (minerIDWithIdentifier in minerSet) { localStats.miners[minerIDWithIdentifier] += share.shares; From 1f239dccaa6d8e0fd84742b4c67734321a861a50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 5 Apr 2019 11:42:22 -0700 Subject: [PATCH 0408/1496] Count miners for parent merged mining coin only --- lib/worker.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 4c7862ce8..10304e75f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -126,8 +126,10 @@ function updateShareStats() { localStats.miners2[minerID] = share.shares2; localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; - if (share.shares2) minerPortSet[minerID] = port; // set port only for parent port share } + + if (!(minerID in minerPortSet) && share.shares2) minerPortSet[minerID] = port; // set port only for parent port share + if (minerIDWithIdentifier in minerSet) { localStats.miners[minerIDWithIdentifier] += share.shares; localStats.miners2[minerIDWithIdentifier] += share.shares2; From 5c6b6ea822f416cf55eb1cad26e2514ec066a18a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 5 Apr 2019 14:49:51 -0700 Subject: [PATCH 0409/1496] Fixed double stats for mm --- lib/worker.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 10304e75f..5b34298ec 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -115,28 +115,29 @@ function updateShareStats() { if (port in localPortHashes) localPortHashes[port] += share.shares; else localPortHashes[port] = share.shares; - if (minerID in minerSet) { + if (!shares2) return; // use virtual shares from child block mining only for global pool stats + + if (minerID in minerPortSet) { localStats.miners[minerID] += share.shares; - localStats.miners2[minerID] += share.shares2; + localStats.miners2[minerID] += shares2; if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; } else { ++ localMinerCount[minerType]; ++ localMinerCount.global; localStats.miners[minerID] = share.shares; - localStats.miners2[minerID] = share.shares2; + localStats.miners2[minerID] = shares2; localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; + minerPortSet[minerID] = port; } - if (!(minerID in minerPortSet) && share.shares2) minerPortSet[minerID] = port; // set port only for parent port share - if (minerIDWithIdentifier in minerSet) { localStats.miners[minerIDWithIdentifier] += share.shares; - localStats.miners2[minerIDWithIdentifier] += share.shares2; + localStats.miners2[minerIDWithIdentifier] += shares2; if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; } else { localStats.miners[minerIDWithIdentifier] = share.shares; - localStats.miners2[minerIDWithIdentifier] = share.shares2; + localStats.miners2[minerIDWithIdentifier] = shares2; localTimes.miners[minerIDWithIdentifier] = share.timestamp; minerSet[minerIDWithIdentifier] = 1; } From 4cdd4d9e136f661cc9171947ac61789e552a4009 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 5 Apr 2019 19:05:01 -0700 Subject: [PATCH 0410/1496] Added some web wallet --- lib/coins/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3f8358838..4317d343b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -107,7 +107,8 @@ function Coin(data){ "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm", // Bitfinex "41xeYWWKwtSiHju5AdyF8y5xeptuRY3j5X1XYHuB1g6ke4eRexA1iygjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3gJqjM9", // HitBTC 1 "43Kg3mcpvaDhHpv8C4UWf7Kw2DAexn2NoRMqqM5cpAtuRgkedDZWjBQjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3dx22mZ", // HitBTC 2 - "44rouyxW44oMc1yTGXBUsL6qo9AWWeHETFiimWC3TMQEizSqqZZPnw1UXCaJrCtUC9QT25L5MZvkoGKRxZttvbkmFXA3TMG" // BTC-Alpha + "44rouyxW44oMc1yTGXBUsL6qo9AWWeHETFiimWC3TMQEizSqqZZPnw1UXCaJrCtUC9QT25L5MZvkoGKRxZttvbkmFXA3TMG", // BTC-Alpha + "45SLfxvu355SpjjzibLKaChA4NGoTrQAwZmSopAXQa9UXBT63BvreEoYyczTcfXow6eL8VaEG2X6NcTG67XZFTNPLgdR9iM", // some web wallet ]; // These are addresses that MUST have a paymentID to perform logins with. this.prefix = 18; From 1c285f72cc74114fceb34f3add17938a58f6232b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 5 Apr 2019 22:19:06 -0700 Subject: [PATCH 0411/1496] Fixed undefined resultHash --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 602315c99..9ba74f22b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1224,7 +1224,7 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTrustedShare, isParentBlock, isRetrySubmitBlock) { +function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, isRetrySubmitBlock) { global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. @@ -1275,7 +1275,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTruste recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); } else { if (isRetrySubmitBlock) { - setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, hashDiff, isTrustedShare, isParentBlock, false); + setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, false); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1346,7 +1346,7 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return invalid_share(miner); } - submit_block(miner, job, blockTemplate, shareBuffer, hashDiff, isTrustedShare, true, true); + submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, true, true); is_block_diff_matched = true; } @@ -1368,7 +1368,7 @@ function processShare(miner, job, blockTemplate, params) { return invalid_share(miner); } if (shareBuffer2 === null) return invalid_share(miner); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, hashDiff, isTrustedShare, false, true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, hashDiff, isTrustedShare, false, true); is_block_diff_matched = true; } From ff2f1e435d6c7e5991293ef9cef76bcb716e80bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Apr 2019 11:20:42 -0700 Subject: [PATCH 0412/1496] Change XTL name to XTC --- lib/coins/xmr.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4317d343b..206bb63cf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -23,7 +23,7 @@ const port2coin = { "17750": "XHV", "18081": "", "18981": "GRFT", - "20189": "XTL", + "20189": "XTC", "22023": "LOKI", "24182": "TUBE", "31014": "XRN", @@ -38,7 +38,7 @@ const port2blob_num = { "17750": 0, // XHV "18081": 0, // XMR "18981": 0, // GRFT - "20189": 0, // XTL + "20189": 0, // XTC "22023": 5, // LOKI "24182": 0, // TUBE "31014": 5, // XRN @@ -141,7 +141,7 @@ function Coin(data){ }; this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ - // TRTL does not get getblock and XTL / LTHN / AEON have composite tx + // TRTL does not get getblock and XTC / LTHN / AEON have composite tx if (port == 11898 || port == 20189 || port == 48782 || port == 11181) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { @@ -381,9 +381,9 @@ function Coin(data){ if (!("" in coin_perf)) return "algo-perf set must include cn or cn/r hashrate"; - if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/half"]; - else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTL"] = algos_perf["cn/fast2"]; - else if ("cn/xtlv9" in algos_perf) coin_perf["XTL"] = algos_perf["cn/xtlv9"]; + if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTC"] = algos_perf["cn/half"]; + else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTC"] = algos_perf["cn/fast2"]; + else if ("cn/xtlv9" in algos_perf) coin_perf["XTC"] = algos_perf["cn/xtlv9"]; if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; From ce661e547b93329d53b6c9dc5dceaa1c37ef7064 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Apr 2019 19:20:54 -0700 Subject: [PATCH 0413/1496] Added ability to restatore master coin daemon --- lib/coins/xmr.js | 20 ++++++++++++++++++++ lib/pool.js | 18 +----------------- lib/worker.js | 8 ++++++++ 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 206bb63cf..d05177337 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -49,6 +49,8 @@ const port2blob_num = { const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); const mm_port_set = { "22023": 11898 }; +const fix_daemon_sh = "./fix_daemon.sh"; + const extra_nonce_template_hex = "02" + (pool_nonce_size + 0x100).toString(16).substr(-2) + "00".repeat(pool_nonce_size); const extra_nonce_mm_template_hex = "02" + (mm_nonce_size + pool_nonce_size + 0x100).toString(16).substr(-2) + "00".repeat(mm_nonce_size + pool_nonce_size); @@ -548,6 +550,24 @@ function Coin(data){ return false; }; + this.fixDaemonIssue = function(height, top_height, port) { + global.support.sendEmail(global.config.general.adminEmail, + "Pool server " + global.config.hostname + " has stuck block template", + "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " with current block height " + + height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + + port + " port\nAttempting to fix..." + ); + if (fs.existsSync(fix_daemon_sh)) { + child_process.exec(fix_daemon_sh + " " + port, function callback(error, stdout, stderr) { + console.log("> " + fix_daemon_sh + " " + port); + console.log(stdout); + console.error(stderr); + if (error) console.error(fix_daemon_sh + " script returned error exit code: " + error.code); + }); + } else { + console.error("No " + fix_daemon_sh + " script was found to fix stuff"); + } + } }; diff --git a/lib/pool.js b/lib/pool.js index 9ba74f22b..096444b94 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -28,7 +28,6 @@ let pastBlockTemplates = {}; // coin key -> global.support.circularBuffer -> a let lastPortErrorTime = {}; // main coin port -const fix_daemon_sh = "./fix_daemon.sh"; let lastBlockFixTime = {}; // time when blocks were checked to be in line with other nodes or when fix_daemon_sh was attempted let lastBlockFixCount = {}; // number of times fix_daemon_sh was run @@ -1772,22 +1771,7 @@ if (cluster.isMaster) { return; } - global.support.sendEmail(global.config.general.adminEmail, - "Pool server " + global.config.hostname + " has stuck block template", - "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " with current block height " + - height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + - port + " port\nAttempting to fix..." - ); - if (fs.existsSync(fix_daemon_sh)) { - child_process.exec(fix_daemon_sh + " " + port, function callback(error, stdout, stderr) { - console.log("> " + fix_daemon_sh + " " + port); - console.log(stdout); - console.error(stderr); - if (error) console.error(fix_daemon_sh + " script returned error exit code: " + error.code); - }); - } else { - console.error("No " + fix_daemon_sh + " script was found to fix stuff"); - } + global.coinFuncs.fixDaemonIssue(height, top_height, port); lastBlockFixTime[port] = Date.now(); } } else { diff --git a/lib/worker.js b/lib/worker.js index 5b34298ec..416684254 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -848,6 +848,9 @@ function bad_header_stop(port) { function monitorNodes() { global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { + let height = 0; + let top_height = 0; + let is_master_daemon_issue = rows.length > 1 ? true : false; rows.forEach(function (row) { let port = row.port ? row.port : global.config.daemon.port; global.coinFuncs.getPortLastBlockHeader(port, function (err, block) { @@ -856,14 +859,19 @@ function monitorNodes() { return; } bad_header_stop(); + height = block.height; + if (top_height < row.blockID) top_height = row.blockID; if (Math.abs(block.height - row.blockID) > 3) { global.support.sendEmail(global.config.general.adminEmail, "Pool server behind in blocks", "The pool server: " + row.hostname + " with IP: " + row.ip + " is " + (block.height - row.blockID) + " blocks behind for " + port + " port" ); + } else { + is_master_daemon_issue = false; } }); }); + if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(height, top_height, global.config.daemon.port); }); } From bbba6476a4e0a0035c49c46e4b52b9c7377df3d9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Apr 2019 19:23:22 -0700 Subject: [PATCH 0414/1496] Added ability to restatore master coin daemon --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d05177337..6348b8f31 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -5,6 +5,7 @@ const multiHashing = require('cryptonight-hashing'); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); const process = require('process'); +const fs = require('fs'); let hexChars = new RegExp("[0-9a-f]+"); From bf73e211c77dd748d04bf823c830b236a00281f9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Apr 2019 19:24:14 -0700 Subject: [PATCH 0415/1496] Added ability to restatore master coin daemon --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6348b8f31..25bb4f3b3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -6,6 +6,7 @@ const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); const process = require('process'); const fs = require('fs'); +const child_process = require('child_process'); let hexChars = new RegExp("[0-9a-f]+"); From 3e20145f259a563b93a3cb8481e2521c00f6c483 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Apr 2019 19:26:15 -0700 Subject: [PATCH 0416/1496] Added ability to restatore master coin daemon --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 416684254..38bcd18b3 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -856,6 +856,7 @@ function monitorNodes() { global.coinFuncs.getPortLastBlockHeader(port, function (err, block) { if (err !== null){ bad_header_start(port); + is_master_daemon_issue = false; return; } bad_header_stop(); From ff7337d738bdff0f2cf11075d37950a60b64b697 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Apr 2019 19:27:48 -0700 Subject: [PATCH 0417/1496] Added ability to restatore master coin daemon --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 38bcd18b3..cea7eb345 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -872,7 +872,7 @@ function monitorNodes() { } }); }); - if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(height, top_height, global.config.daemon.port); +// if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(height, top_height, global.config.daemon.port); }); } From 8da8645217b7630979ea8cb00f41610ef055c5c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Apr 2019 19:35:54 -0700 Subject: [PATCH 0418/1496] Added ability to restatore master coin daemon --- lib/worker.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index cea7eb345..6a0d732da 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -848,31 +848,32 @@ function bad_header_stop(port) { function monitorNodes() { global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { - let height = 0; - let top_height = 0; - let is_master_daemon_issue = rows.length > 1 ? true : false; - rows.forEach(function (row) { - let port = row.port ? row.port : global.config.daemon.port; - global.coinFuncs.getPortLastBlockHeader(port, function (err, block) { - if (err !== null){ - bad_header_start(port); + global.coinFuncs.getPortLastBlockHeader(global.config.daemon.port, function (err, block) { + if (err !== null){ + bad_header_start(port); + return; + } + bad_header_stop(); + let top_height = 0; + let is_master_daemon_issue = rows.length > 1 ? true : false; + rows.forEach(function (row) { + if (row.port && row.port != global.config.daemon.port) { + console.error("INTERNAL ERROR: pool node port " + row.port + " do not match master port " + global.config.daemon.port); is_master_daemon_issue = false; return; } - bad_header_stop(); - height = block.height; if (top_height < row.blockID) top_height = row.blockID; if (Math.abs(block.height - row.blockID) > 3) { global.support.sendEmail(global.config.general.adminEmail, - "Pool server behind in blocks", + "Pool server behind in blocks", "The pool server: " + row.hostname + " with IP: " + row.ip + " is " + (block.height - row.blockID) + " blocks behind for " + port + " port" ); } else { is_master_daemon_issue = false; } }); + if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(block.height, top_height, global.config.daemon.port); }); -// if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(height, top_height, global.config.daemon.port); }); } From 6f5bc45b5011443eafe31fc36b4ac44cebbb3537 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Apr 2019 15:04:13 -0700 Subject: [PATCH 0419/1496] Correct outdate share decetion for child blocks --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 096444b94..a176db6d9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1185,7 +1185,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust process.send({type: 'normalShare'}); debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); } - if (activeBlockTemplates[blockTemplate.coin].idHash !== job.blockHash) { + if (activeBlockTemplates[blockTemplate.coin].idHash !== blockTemplate.idHash) { process.send({type: 'outdatedShare'}); } From 2d45d92cf341baf65dfa55cc7f3fbca2bff71a98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Apr 2019 16:25:21 -0700 Subject: [PATCH 0420/1496] Added some debug stuff --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index a176db6d9..0cbe72d68 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1515,6 +1515,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply sendReply('Unauthenticated'); return; } + if (miner.debugMiner) console.log("SUBMIT"); miner.heartbeat(); let job = miner.validJobs.toarray().filter(function (job) { @@ -1642,6 +1643,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply miner.lastShareTime = Date.now() / 1000 || 0; sendReply(null, {status: 'OK'}); + if (miner.debugMiner) console.log("SUBMIT OK"); break; case 'keepalived': miner = activeMiners.get(params.id); From 4787157370f21ab68a779ee9a115ed3365a46498 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Apr 2019 19:38:51 -0700 Subject: [PATCH 0421/1496] Decreased consumed messages --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0cbe72d68..bac0c1a69 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -181,7 +181,7 @@ function retargetMiners() { const time_before = Date.now(); for (var [minerId, miner] of activeMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 100) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id, ports: minerCount } }); } @@ -219,7 +219,7 @@ function checkAliveMiners() { const deadline = time_before - global.config.pool.minerTimeout * 1000; for (var [minerId, miner] of activeMiners) if (miner.lastContact < deadline) removeMiner(miner); const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error(threadName + "checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 100) console.error(threadName + "checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function set_hash_factor(coin, hash_factor) { @@ -458,7 +458,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error(threadName + "setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 100) console.error(threadName + "setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { From 3851dc25e00f9e49bc5772eb6f711c7a61af0bbc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Apr 2019 19:43:10 -0700 Subject: [PATCH 0422/1496] Decreased consumed messages --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index bac0c1a69..32378c90a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -181,7 +181,7 @@ function retargetMiners() { const time_before = Date.now(); for (var [minerId, miner] of activeMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } const elapsed = Date.now() - time_before; - if (elapsed > 100) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 50) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id, ports: minerCount } }); } @@ -219,7 +219,7 @@ function checkAliveMiners() { const deadline = time_before - global.config.pool.minerTimeout * 1000; for (var [minerId, miner] of activeMiners) if (miner.lastContact < deadline) removeMiner(miner); const elapsed = Date.now() - time_before; - if (elapsed > 100) console.error(threadName + "checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 50) console.error(threadName + "checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function set_hash_factor(coin, hash_factor) { @@ -458,7 +458,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const elapsed = Date.now() - time_before; - if (elapsed > 100) console.error(threadName + "setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 50) console.error(threadName + "setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { From c26c55dda2f8890c3fe115c090c8201eea7a6d04 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 12:21:46 -0700 Subject: [PATCH 0423/1496] Move BT selection from the fast coin update loop --- lib/pool.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 32378c90a..8c2f9d74b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -437,6 +437,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } } else { if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); + const bt = activeBlockTemplates[coin]; if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); @@ -444,7 +445,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); miner.trust.check_height = check_height; - miner.sendNewCoinJob(coin); + miner.sendNewCoinJob(coin, bt); } } else { for (var [minerId, miner] of activeMiners) { @@ -452,7 +453,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he if (miner.curr_coin !== coin) continue; //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); - miner.sendNewCoinJob(coin); + miner.sendNewCoinJob(coin, bt); } } } @@ -903,8 +904,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return buffReversed.toString('hex'); }; - this.getCoinJob = function (coin) { - let bt = activeBlockTemplates[coin]; + this.getCoinJob = function (coin, bt) { if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; this.jobLastBlockHash = bt.idHash; if (this.newDiffToSet) { @@ -980,16 +980,18 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return this.cachedJob; }; this.getJob = function () { - return this.getCoinJob(this.selectBestCoin()); + const coin = this.selectBestCoin(); + return this.getCoinJob(coin, activeBlockTemplates[coin]); }; - this.sendNewCoinJob = function(coin) { - const job = this.getCoinJob(coin); + this.sendNewCoinJob = function(coin, bt) { + const job = this.getCoinJob(coin, bt); if (job === null) return; return this.messageSender('job', job); }; this.sendNewJob = function() { - return this.sendNewCoinJob(this.selectBestCoin()); + const coin = this.selectBestCoin(); + return this.sendNewCoinJob(coin, activeBlockTemplates[coin]); }; } } From b15c9f3eafc94ac21062f271355784bdd3917cf3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 12:33:10 -0700 Subject: [PATCH 0424/1496] Move BT selection from the fast coin update loop --- lib/pool.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8c2f9d74b..73bce3335 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -385,6 +385,15 @@ function anchorBlockUpdate() { }); } +function getCoinJobParams(coin) { + let params = {}; + params.bt = activeBlockTemplates[coin]; + params.coinHashFactor = currCoinHashFactorMM[coin]; + params.algo_name = global.coinFuncs.algoShortTypeStr(params.bt.port, params.bt.buffer[0]); + params.variant_name = algo_name.split('/')[1]; + return params; +}; + function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; @@ -437,7 +446,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } } else { if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); - const bt = activeBlockTemplates[coin]; + const params = getCoinJobParams(coin); if (check_height) { for (var [minerId, miner] of activeMiners) { //if (typeof(miner.curr_coin) === 'undefined') console.error("[INTERNAL ERROR]: " + miner.logString + ": undefined curr_coin"); @@ -445,7 +454,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); miner.trust.check_height = check_height; - miner.sendNewCoinJob(coin, bt); + miner.sendNewCoinJob(coin, params); } } else { for (var [minerId, miner] of activeMiners) { @@ -453,7 +462,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he if (miner.curr_coin !== coin) continue; //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); - miner.sendNewCoinJob(coin, bt); + miner.sendNewCoinJob(coin, params); } } } @@ -904,7 +913,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return buffReversed.toString('hex'); }; - this.getCoinJob = function (coin, bt) { + this.getCoinJob = function (coin, params) { + const bt = params.bt; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; this.jobLastBlockHash = bt.idHash; if (this.newDiffToSet) { @@ -916,9 +926,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.newDiffRecommendation = null; } - const coinHashFactor = currCoinHashFactorMM[coin]; - const algo_name = global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]); - const variant_name = algo_name.split('/')[1]; + const coinHashFactor = params.coinHashFactor; + const algo_name = params.algo_name; + const variant_name = params.variant_name; if (!this.proxy) { let blob = bt.nextBlob(); @@ -981,17 +991,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.getJob = function () { const coin = this.selectBestCoin(); - return this.getCoinJob(coin, activeBlockTemplates[coin]); + return this.getCoinJob(coin, getCoinJobParams(coin)); }; - this.sendNewCoinJob = function(coin, bt) { - const job = this.getCoinJob(coin, bt); + this.sendNewCoinJob = function(coin, params) { + const job = this.getCoinJob(coin, params); if (job === null) return; return this.messageSender('job', job); }; this.sendNewJob = function() { const coin = this.selectBestCoin(); - return this.sendNewCoinJob(coin, activeBlockTemplates[coin]); + return this.sendNewCoinJob(coin, getCoinJobParams(coin)); }; } } From a057883fceff87515951349bf63599d1d000a0c4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 12:34:24 -0700 Subject: [PATCH 0425/1496] Move BT selection from the fast coin update loop --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 73bce3335..e68dc98df 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -390,7 +390,7 @@ function getCoinJobParams(coin) { params.bt = activeBlockTemplates[coin]; params.coinHashFactor = currCoinHashFactorMM[coin]; params.algo_name = global.coinFuncs.algoShortTypeStr(params.bt.port, params.bt.buffer[0]); - params.variant_name = algo_name.split('/')[1]; + params.variant_name = params.algo_name.split('/')[1]; return params; }; From 15f9cd34134294a9d54542a53c2c9882c830d50e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 12:38:29 -0700 Subject: [PATCH 0426/1496] Move BT selection from the fast coin update loop --- lib/pool.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e68dc98df..d5fa6ba9a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -926,10 +926,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.newDiffRecommendation = null; } - const coinHashFactor = params.coinHashFactor; - const algo_name = params.algo_name; - const variant_name = params.variant_name; - if (!this.proxy) { let blob = bt.nextBlob(); let target = this.getTargetHex(); @@ -941,14 +937,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer height: bt.height, difficulty: this.difficulty, diffHex: this.diffHex, - coinHashFactor: coinHashFactor, + coinHashFactor: params.coinHashFactor, submissions: {} }; this.validJobs.enq(newJob); this.cachedJob = { blob: blob, - algo: algo_name, - variant: variant_name, + algo: params.algo_name, + variant: params.variant_name, height: bt.height, job_id: newJob.id, target: target, @@ -966,16 +962,15 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer diffHex: this.diffHex, clientPoolLocation: bt.clientPoolLocation, clientNonceLocation: bt.clientNonceLocation, - coinHashFactor: coinHashFactor, + coinHashFactor: params.coinHashFactor, submissions: {} }; this.validJobs.enq(newJob); - const algo_name = global.coinFuncs.algoShortTypeStr(bt.port, bt.buffer[0]); this.cachedJob = { blocktemplate_blob: blob, blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), - algo: algo_name, - variant: variant_name, + algo: params.algo_name, + variant: params.variant_name, difficulty: bt.difficulty, height: bt.height, reserved_offset: bt.reserved_offset, From a4f0b953d575ac6bdf05e89f27a3bbaf59857331 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 12:40:15 -0700 Subject: [PATCH 0427/1496] Move BT selection from the fast coin update loop --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d5fa6ba9a..41e5f737e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -917,12 +917,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const bt = params.bt; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; this.jobLastBlockHash = bt.idHash; + if (this.newDiffToSet) { - this.difficulty = this.newDiffToSet; - this.newDiffToSet = null; + this.difficulty = this.newDiffToSet; + this.newDiffToSet = null; this.newDiffRecommendation = null; } else if (this.newDiffRecommendation) { - this.difficulty = this.newDiffRecommendation; + this.difficulty = this.newDiffRecommendation; this.newDiffRecommendation = null; } From 3c88979254cc852bf91da1926c948a2637c552eb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 12:59:27 -0700 Subject: [PATCH 0428/1496] More debug info --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 41e5f737e..c1dbac8f4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -468,7 +468,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const elapsed = Date.now() - time_before; - if (elapsed > 50) console.error(threadName + "setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 50) console.error(threadName + coin + " setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { From 7ebd5961c30d43217acc6134f0c47151fa657e66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 14:02:51 -0700 Subject: [PATCH 0429/1496] More debug --- lib/pool.js | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c1dbac8f4..1eaccf07c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -424,13 +424,15 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const time_before = Date.now(); + let strLogPrefix; if (isHashFactorChange) { const port = activeBlockTemplates[coin].port; const block_version = activeBlockTemplates[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed to " + currCoinHashFactorMM[coin]); + strLogPrefix = "Full BT update for coin " + coin; + if (cluster.isMaster) console.log(threadName + strLogPrefix + " with hash factor changed to " + currCoinHashFactorMM[coin]); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -445,7 +447,8 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } } } else { - if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); + strLogPrefix = "Fast BT update for coin " + coin; + if (cluster.isMaster) console.log(threadName + strLogPrefix + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); const params = getCoinJobParams(coin); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -468,7 +471,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const elapsed = Date.now() - time_before; - if (elapsed > 50) console.error(threadName + coin + " setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 50) console.error(threadName + strLogPrefix + " setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { @@ -524,6 +527,17 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; +function getTargetHex(difficulty) { + let padded = new Buffer(32); + padded.fill(0); + const diffBuff = baseDiff.div(difficulty).toBuffer(); + diffBuff.copy(padded, 32 - diffBuff.length); + const buff = padded.slice(0, 4); + const buffArray = buff.toByteArray().reverse(); + const buffReversed = new Buffer(buffArray); + return buffReversed.toString('hex'); +}; + function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -900,19 +914,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (protoVersion === 1) { - this.getTargetHex = function () { - let padded = new Buffer(32); - padded.fill(0); - let diffBuff = baseDiff.div(this.difficulty).toBuffer(); - diffBuff.copy(padded, 32 - diffBuff.length); - - let buff = padded.slice(0, 4); - let buffArray = buff.toByteArray().reverse(); - let buffReversed = new Buffer(buffArray); - this.target = buffReversed.readUInt32BE(0); - return buffReversed.toString('hex'); - }; - this.getCoinJob = function (coin, params) { const bt = params.bt; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; @@ -928,9 +929,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } if (!this.proxy) { - let blob = bt.nextBlob(); - let target = this.getTargetHex(); - let newJob = { + const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, blockHash: bt.idHash, @@ -943,17 +942,16 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.validJobs.enq(newJob); this.cachedJob = { - blob: blob, + blob: bt.nextBlob(), algo: params.algo_name, variant: params.variant_name, height: bt.height, job_id: newJob.id, - target: target, + target: getTargetHex(this.difficulty), id: this.id }; } else { - let blob = bt.nextBlobWithChildNonce(); - let newJob = { + const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, blockHash: bt.idHash, @@ -968,7 +966,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.validJobs.enq(newJob); this.cachedJob = { - blocktemplate_blob: blob, + blocktemplate_blob: bt.nextBlobWithChildNonce(), blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), algo: params.algo_name, variant: params.variant_name, From 8178f87bb91c7d3d86082ad8af66ccef978a0cfa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 14:11:43 -0700 Subject: [PATCH 0430/1496] Restored code --- lib/pool.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1eaccf07c..83c6d79c2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -527,17 +527,6 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -function getTargetHex(difficulty) { - let padded = new Buffer(32); - padded.fill(0); - const diffBuff = baseDiff.div(difficulty).toBuffer(); - diffBuff.copy(padded, 32 - diffBuff.length); - const buff = padded.slice(0, 4); - const buffArray = buff.toByteArray().reverse(); - const buffReversed = new Buffer(buffArray); - return buffReversed.toString('hex'); -}; - function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -914,6 +903,20 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (protoVersion === 1) { + + this.getTargetHex = function () { + let padded = new Buffer(32); + padded.fill(0); + let diffBuff = baseDiff.div(this.difficulty).toBuffer(); + diffBuff.copy(padded, 32 - diffBuff.length); + + let buff = padded.slice(0, 4); + let buffArray = buff.toByteArray().reverse(); + let buffReversed = new Buffer(buffArray); + this.target = buffReversed.readUInt32BE(0); + return buffReversed.toString('hex'); + }; + this.getCoinJob = function (coin, params) { const bt = params.bt; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; @@ -947,7 +950,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer variant: params.variant_name, height: bt.height, job_id: newJob.id, - target: getTargetHex(this.difficulty), + target: this.getTargetHex(), id: this.id }; } else { From 3dd4a89fe5c3dfab2515e16943fb69a0dc566213 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 14:15:08 -0700 Subject: [PATCH 0431/1496] Revert "Restored code" This reverts commit 8178f87bb91c7d3d86082ad8af66ccef978a0cfa. --- lib/pool.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 83c6d79c2..1eaccf07c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -527,6 +527,17 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; +function getTargetHex(difficulty) { + let padded = new Buffer(32); + padded.fill(0); + const diffBuff = baseDiff.div(difficulty).toBuffer(); + diffBuff.copy(padded, 32 - diffBuff.length); + const buff = padded.slice(0, 4); + const buffArray = buff.toByteArray().reverse(); + const buffReversed = new Buffer(buffArray); + return buffReversed.toString('hex'); +}; + function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -903,20 +914,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (protoVersion === 1) { - - this.getTargetHex = function () { - let padded = new Buffer(32); - padded.fill(0); - let diffBuff = baseDiff.div(this.difficulty).toBuffer(); - diffBuff.copy(padded, 32 - diffBuff.length); - - let buff = padded.slice(0, 4); - let buffArray = buff.toByteArray().reverse(); - let buffReversed = new Buffer(buffArray); - this.target = buffReversed.readUInt32BE(0); - return buffReversed.toString('hex'); - }; - this.getCoinJob = function (coin, params) { const bt = params.bt; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; @@ -950,7 +947,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer variant: params.variant_name, height: bt.height, job_id: newJob.id, - target: this.getTargetHex(), + target: getTargetHex(this.difficulty), id: this.id }; } else { From 46469c932c0e21e725ad60fa72cd80d41a5dcb02 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 14:15:17 -0700 Subject: [PATCH 0432/1496] Revert "More debug" This reverts commit 7ebd5961c30d43217acc6134f0c47151fa657e66. --- lib/pool.js | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1eaccf07c..c1dbac8f4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -424,15 +424,13 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const time_before = Date.now(); - let strLogPrefix; if (isHashFactorChange) { const port = activeBlockTemplates[coin].port; const block_version = activeBlockTemplates[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - strLogPrefix = "Full BT update for coin " + coin; - if (cluster.isMaster) console.log(threadName + strLogPrefix + " with hash factor changed to " + currCoinHashFactorMM[coin]); + if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed to " + currCoinHashFactorMM[coin]); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -447,8 +445,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } } } else { - strLogPrefix = "Fast BT update for coin " + coin; - if (cluster.isMaster) console.log(threadName + strLogPrefix + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); + if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); const params = getCoinJobParams(coin); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -471,7 +468,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const elapsed = Date.now() - time_before; - if (elapsed > 50) console.error(threadName + strLogPrefix + " setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 50) console.error(threadName + coin + " setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { @@ -527,17 +524,6 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -function getTargetHex(difficulty) { - let padded = new Buffer(32); - padded.fill(0); - const diffBuff = baseDiff.div(difficulty).toBuffer(); - diffBuff.copy(padded, 32 - diffBuff.length); - const buff = padded.slice(0, 4); - const buffArray = buff.toByteArray().reverse(); - const buffReversed = new Buffer(buffArray); - return buffReversed.toString('hex'); -}; - function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -914,6 +900,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (protoVersion === 1) { + this.getTargetHex = function () { + let padded = new Buffer(32); + padded.fill(0); + let diffBuff = baseDiff.div(this.difficulty).toBuffer(); + diffBuff.copy(padded, 32 - diffBuff.length); + + let buff = padded.slice(0, 4); + let buffArray = buff.toByteArray().reverse(); + let buffReversed = new Buffer(buffArray); + this.target = buffReversed.readUInt32BE(0); + return buffReversed.toString('hex'); + }; + this.getCoinJob = function (coin, params) { const bt = params.bt; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; @@ -929,7 +928,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } if (!this.proxy) { - const newJob = { + let blob = bt.nextBlob(); + let target = this.getTargetHex(); + let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, blockHash: bt.idHash, @@ -942,16 +943,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.validJobs.enq(newJob); this.cachedJob = { - blob: bt.nextBlob(), + blob: blob, algo: params.algo_name, variant: params.variant_name, height: bt.height, job_id: newJob.id, - target: getTargetHex(this.difficulty), + target: target, id: this.id }; } else { - const newJob = { + let blob = bt.nextBlobWithChildNonce(); + let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, blockHash: bt.idHash, @@ -966,7 +968,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.validJobs.enq(newJob); this.cachedJob = { - blocktemplate_blob: bt.nextBlobWithChildNonce(), + blocktemplate_blob: blob, blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), algo: params.algo_name, variant: params.variant_name, From 3cb7d0d1a04d0a5eb15ef0051f13a32d7caf4fa2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 14:20:51 -0700 Subject: [PATCH 0433/1496] Another attempt --- lib/pool.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c1dbac8f4..f6e36f6c7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -424,13 +424,15 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const time_before = Date.now(); + let strLogPrefix; if (isHashFactorChange) { const port = activeBlockTemplates[coin].port; const block_version = activeBlockTemplates[coin].buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (cluster.isMaster) console.log(threadName + "Full BT update for coin " + coin + " with hash factor changed to " + currCoinHashFactorMM[coin]); + strLogPrefix = "Full BT update for coin " + coin; + if (cluster.isMaster) console.log(threadName + strLogPrefix + " with hash factor changed to " + currCoinHashFactorMM[coin]); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -444,8 +446,12 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he miner.sendNewJob(); } } + } else { - if (cluster.isMaster) console.log(threadName + "Fast BT update for coin " + coin + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); + + strLogPrefix = "Fast BT update for coin " + coin; + if (cluster.isMaster) console.log(threadName + strLogPrefix + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); + const params = getCoinJobParams(coin); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -468,7 +474,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } const elapsed = Date.now() - time_before; - if (elapsed > 50) console.error(threadName + coin + " setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); + if (elapsed > 50) console.error(threadName + strLogPrefix + " setNewCoinHashFactor() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } function setNewBlockTemplate(template) { @@ -524,6 +530,17 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; +function getTargetHex(difficulty) { + let padded = new Buffer(32); + padded.fill(0); + const diffBuff = baseDiff.div(difficulty).toBuffer(); + diffBuff.copy(padded, 32 - diffBuff.length); + const buff = padded.slice(0, 4); + const buffArray = buff.toByteArray().reverse(); + const buffReversed = new Buffer(buffArray); + return buffReversed.toString('hex'); +}; + function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -900,19 +917,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (protoVersion === 1) { - this.getTargetHex = function () { - let padded = new Buffer(32); - padded.fill(0); - let diffBuff = baseDiff.div(this.difficulty).toBuffer(); - diffBuff.copy(padded, 32 - diffBuff.length); - - let buff = padded.slice(0, 4); - let buffArray = buff.toByteArray().reverse(); - let buffReversed = new Buffer(buffArray); - this.target = buffReversed.readUInt32BE(0); - return buffReversed.toString('hex'); - }; - this.getCoinJob = function (coin, params) { const bt = params.bt; if (this.jobLastBlockHash === bt.idHash && !this.newDiffToSet && this.cachedJob !== null) return null; @@ -929,7 +933,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!this.proxy) { let blob = bt.nextBlob(); - let target = this.getTargetHex(); + let target = getTargetHex(this.difficulty); let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, From ddc2420ce74eb71fb5886f93759cad34f2b6c66d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 14:26:24 -0700 Subject: [PATCH 0434/1496] More costs usage --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f6e36f6c7..2598e8388 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -932,9 +932,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } if (!this.proxy) { - let blob = bt.nextBlob(); - let target = getTargetHex(this.difficulty); - let newJob = { + const blob = bt.nextBlob(); + const target = getTargetHex(this.difficulty); + const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, blockHash: bt.idHash, @@ -956,8 +956,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer id: this.id }; } else { - let blob = bt.nextBlobWithChildNonce(); - let newJob = { + const blob = bt.nextBlobWithChildNonce(); + const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, blockHash: bt.idHash, From a4789563c1426c37376e996b7ce188cc6747c687 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 15:08:57 -0700 Subject: [PATCH 0435/1496] Cache diff hex --- lib/pool.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2598e8388..c439611e2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -11,11 +11,14 @@ const tls = require('tls'); const fs = require('fs'); const child_process = require('child_process'); -let nonceCheck = new RegExp("^[0-9a-f]{8}$"); +const httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; +const nonceCheck = new RegExp("^[0-9a-f]{8}$"); +const hexMatch = new RegExp("^[0-9a-f]+$"); +const baseDiff = global.coinFuncs.baseDiff(); + let bannedIPs = {}; let bannedAddresses = {}; let notifyAddresses = {}; -let baseDiff = global.coinFuncs.baseDiff(); let activeMiners = new Map(); @@ -31,11 +34,9 @@ let lastPortErrorTime = {}; // main coin port let lastBlockFixTime = {}; // time when blocks were checked to be in line with other nodes or when fix_daemon_sh was attempted let lastBlockFixCount = {}; // number of times fix_daemon_sh was run -let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; let threadName; let minerCount = []; let BlockTemplate = global.coinFuncs.BlockTemplate; -let hexMatch = new RegExp("^[0-9a-f]+$"); let totalShares = 0, trustedShares = 0, normalShares = 0, invalidShares = 0, outdatedShares = 0, throttledShares = 0; // wallet -> { connectTime, count (miner), hashes, last_ver_shares } @@ -530,7 +531,11 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; +let cacheTargetHex = {}; + function getTargetHex(difficulty) { + const result = cacheTargetHex[difficulty]; + if (result) return result; let padded = new Buffer(32); padded.fill(0); const diffBuff = baseDiff.div(difficulty).toBuffer(); @@ -538,7 +543,9 @@ function getTargetHex(difficulty) { const buff = padded.slice(0, 4); const buffArray = buff.toByteArray().reverse(); const buffReversed = new Buffer(buffArray); - return buffReversed.toString('hex'); + const new_result = buffReversed.toString('hex'); + cacheTargetHex[difficulty] = new_result; + return new_result; }; function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { @@ -1927,6 +1934,8 @@ if (cluster.isMaster) { fs.writeFile(fn2, str2, function(err) { if (err) console.error("Error saving " + fn2 + " file"); }); } + cacheTargetHex = {}; + }, 10*60*1000); let lastGarbageFromIpTime = {}; From d77349444f0e6d7eb06cab5e6fbbd254dde4bf22 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 15:32:16 -0700 Subject: [PATCH 0436/1496] Normalized coin jobs functions --- lib/pool.js | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c439611e2..a353333c4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -171,7 +171,7 @@ function retargetMiners() { if (miner.difficulty * 10 < newDiff) { console.log("Dropped low fixed diff " + miner.difficulty + " for " + miner.logString + " miner to " + newDiff + " dynamic diff"); miner.fixed_diff = false; - if (miner.setNewDiff(newDiff)) miner.sendNewJob(); + if (miner.setNewDiff(newDiff)) miner.sendSameCoinJob(); } } else { miner.updateDifficulty(); @@ -439,12 +439,12 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he for (var [minerId, miner] of activeMiners) { if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; miner.trust.check_height = check_height; - miner.sendNewJob(); + miner.sendBestCoinJob(); } } else { for (var [minerId, miner] of activeMiners) { if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) continue; - miner.sendNewJob(); + miner.sendBestCoinJob(); } } @@ -461,7 +461,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); miner.trust.check_height = check_height; - miner.sendNewCoinJob(coin, params); + miner.sendCoinJob(coin, params); } } else { for (var [minerId, miner] of activeMiners) { @@ -469,7 +469,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he if (miner.curr_coin !== coin) continue; //if (!(coin in miner.coin_perf)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported coin " + coin + " in miner " + JSON.stringify(miner.coin_perf) + " coin_perf"); //if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) console.error("[INTERNAL ERROR]: " + miner.logString + ": no longer supported algo " + algo + " in miner " + JSON.stringify(miner.algos) + " algos"); - miner.sendNewCoinJob(coin, params); + miner.sendCoinJob(coin, params); } } } @@ -531,11 +531,11 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -let cacheTargetHex = {}; +//let cacheTargetHex = {}; function getTargetHex(difficulty) { - const result = cacheTargetHex[difficulty]; - if (result) return result; + //const result = cacheTargetHex[difficulty]; + //if (result) return result; let padded = new Buffer(32); padded.fill(0); const diffBuff = baseDiff.div(difficulty).toBuffer(); @@ -544,7 +544,7 @@ function getTargetHex(difficulty) { const buffArray = buff.toByteArray().reverse(); const buffReversed = new Buffer(buffArray); const new_result = buffReversed.toString('hex'); - cacheTargetHex[difficulty] = new_result; + //cacheTargetHex[difficulty] = new_result; return new_result; }; @@ -873,7 +873,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.updateDifficulty = function () { if (this.fixed_diff) return; - if (this.setNewDiff(this.calcNewDiff())) this.sendNewJob(); + if (this.setNewDiff(this.calcNewDiff())) this.sendSameCoinJob(); }; this.setNewDiff = function (difficulty) { @@ -996,19 +996,21 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } return this.cachedJob; }; - this.getJob = function () { - const coin = this.selectBestCoin(); - return this.getCoinJob(coin, getCoinJobParams(coin)); - }; - this.sendNewCoinJob = function(coin, params) { + this.sendCoinJob = function(coin, params) { const job = this.getCoinJob(coin, params); if (job === null) return; return this.messageSender('job', job); }; - this.sendNewJob = function() { + + this.sendSameCoinJob = function () { + const coin = typeof(this.curr_coin) !== 'undefined' ? this.curr_coin : this.selectBestCoin() + return sendCoinJob(coin, getCoinJobParams(coin)); + }; + + this.sendBestCoinJob = function() { const coin = this.selectBestCoin(); - return this.sendNewCoinJob(coin, getCoinJobParams(coin)); + return this.sendCoinJob(coin, getCoinJobParams(coin)); }; } } @@ -1237,7 +1239,7 @@ function getShareBuffer(miner, job, blockTemplate, params) { function invalid_share(miner) { process.send({type: 'invalidShare'}); - miner.sendNewJob(); + miner.sendSameCoinJob(); walletTrust[miner.payout] = 0; return false; } @@ -1508,7 +1510,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } sendReply(null, { id: minerId, - job: miner.getJob(), + job: miner.getBestCoinJob(), status: 'OK' }); break; @@ -1526,7 +1528,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } } - miner.sendNewJob(); + miner.sendBestCoinJob(); break; case 'submit': miner = activeMiners.get(params.id); @@ -1610,7 +1612,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); lastMinerLogTime[miner.payout] = time_now; } - miner.sendNewJob(); + miner.sendSameCoinJob(); sendReply(err_str); global.database.storeInvalidShare(miner.invalidShareProto); return; @@ -1934,7 +1936,7 @@ if (cluster.isMaster) { fs.writeFile(fn2, str2, function(err) { if (err) console.error("Error saving " + fn2 + " file"); }); } - cacheTargetHex = {}; + //cacheTargetHex = {}; }, 10*60*1000); From ba88b07fbb0a51806fa830d5b94785fac7ae19e6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 15:33:53 -0700 Subject: [PATCH 0437/1496] Normalized coin jobs functions --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index a353333c4..e057ab40a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1008,6 +1008,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return sendCoinJob(coin, getCoinJobParams(coin)); }; + this.getBestCoinJob = function() { + const coin = this.selectBestCoin(); + return this.getCoinJob(coin, getCoinJobParams(coin)); + }; + this.sendBestCoinJob = function() { const coin = this.selectBestCoin(); return this.sendCoinJob(coin, getCoinJobParams(coin)); From adc38a3a836a50d1cf29a1b72f57b05230d7d4ec Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Apr 2019 15:34:51 -0700 Subject: [PATCH 0438/1496] Normalized coin jobs functions --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e057ab40a..c9b9e3a8d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1005,7 +1005,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.sendSameCoinJob = function () { const coin = typeof(this.curr_coin) !== 'undefined' ? this.curr_coin : this.selectBestCoin() - return sendCoinJob(coin, getCoinJobParams(coin)); + return this.sendCoinJob(coin, getCoinJobParams(coin)); }; this.getBestCoinJob = function() { From fd6bb8d2ac553c688a601c799cbfa9d90221d185 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Thu, 18 Apr 2019 14:38:18 +0300 Subject: [PATCH 0439/1496] Fix mistake If mainer has more than walletMin and less than exchangeMin and payment address is exchange_type they don't get coins. payeeList don't used var --- lib/payment_systems/xmr.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 72488545e..2fcaea123 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -699,7 +699,6 @@ function makePayments() { console.log("Loaded all payees into the system for processing"); let paymentDestinations = []; let totalAmount = 0; - let payeeList = []; let payeeObjects = {}; async.eachSeries(rows, function(row, next) { //debug("Starting round for: " + JSON.stringify(row)); @@ -727,21 +726,23 @@ function makePayments() { } if (payee.amount >= threshold) { payee.setFeeAmount(); - payeeObjects[payee.id] = payee; if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { + payeeObjects[payee.id] = payee; console.log("[++] " + payee.id + " miner to bulk payment. Amount: " + global.support.coinToDecimal(payee.amount)); paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); totalAmount += payee.amount; - payeeList.push(payee); } else if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length === 106 && (payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold))) { // Special code to handle integrated payment addresses. What a pain in the rear. // These are exchange addresses though, so they need to hit the exchange payout amount. + payeeObjects[payee.id] = payee; console.log("[+] " + payee.id + " as separate payment to integrated address. Amount: " + global.support.coinToDecimal(payee.amount)); payee.makePaymentAsIntegrated(); } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold)) && payee.bitcoin === 0) { + payeeObjects[payee.id] = payee; console.log("[+] " + payee.id + " as separate payment to payment ID address. Amount: " + global.support.coinToDecimal(payee.amount)); payee.makePaymentWithID(); } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold)) && payee.bitcoin === 1) { + payeeObjects[payee.id] = payee; console.log("[+] " + payee.id + " as separate payment to bitcoin. Amount: " + global.support.coinToDecimal(payee.amount)); payee.makeBitcoinPayment(); } From 83ec40dda907829a527f7f76e2722e9e0c1032ab Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 09:03:49 -0700 Subject: [PATCH 0440/1496] Some code optimizations --- lib/pool.js | 69 +++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c9b9e3a8d..deb01c80a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -940,7 +940,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!this.proxy) { const blob = bt.nextBlob(); - const target = getTargetHex(this.difficulty); const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, @@ -948,7 +947,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer extraNonce: bt.extraNonce, height: bt.height, difficulty: this.difficulty, - diffHex: this.diffHex, coinHashFactor: params.coinHashFactor, submissions: {} }; @@ -959,7 +957,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer variant: params.variant_name, height: bt.height, job_id: newJob.id, - target: target, + target: getTargetHex(this.difficulty), id: this.id }; } else { @@ -971,7 +969,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer extraNonce: bt.extraNonce, height: bt.height, difficulty: this.difficulty, - diffHex: this.diffHex, clientPoolLocation: bt.clientPoolLocation, clientNonceLocation: bt.clientNonceLocation, coinHashFactor: params.coinHashFactor, @@ -989,7 +986,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer client_nonce_offset: bt.clientNonceLocation, client_pool_offset: bt.clientPoolLocation, target_diff: this.difficulty, - target_diff_hex: this.diffHex, job_id: newJob.id, id: this.id }; @@ -1218,23 +1214,17 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust } function getShareBuffer(miner, job, blockTemplate, params) { - let nonce = params.nonce; - let resultHash = params.result; - let template = new Buffer(blockTemplate.buffer.length); - if (!miner.proxy) { - blockTemplate.buffer.copy(template); - template.writeUInt32BE(job.extraNonce, blockTemplate.reserved_offset); - } else { + try { + let template = new Buffer(blockTemplate.buffer.length); blockTemplate.buffer.copy(template); template.writeUInt32BE(job.extraNonce, blockTemplate.reserved_offset); - template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); - template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); - } - try { - let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex'), blockTemplate.port); - return shareBuffer; + if (miner.proxy) { + template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); + template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); + } + return global.coinFuncs.constructNewBlob(template, new Buffer(params.nonce, 'hex'), blockTemplate.port); } catch (e) { - const err_str = "Can't constructNewBlob with " + nonce + " nonce from " + miner.logString + ": " + e; + const err_str = "Can't constructNewBlob with " + params.nonce + " nonce from " + miner.logString + ": " + e; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't constructNewBlob", err_str); return null; @@ -1541,7 +1531,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply sendReply('Unauthenticated'); return; } - if (miner.debugMiner) console.log("SUBMIT"); + //if (miner.debugMiner) console.log("SUBMIT"); miner.heartbeat(); let job = miner.validJobs.toarray().filter(function (job) { @@ -1553,24 +1543,16 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } - params.nonce = (typeof params.nonce === 'string' ? params.nonce.substr(0, 8).toLowerCase() : ""); - if (!nonceCheck.test(params.nonce)) { + if ((typeof params.nonce !== 'string') || !nonceCheck.test(params.nonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); global.database.storeInvalidShare(miner.invalidShareProto); return; } - if (!miner.proxy) { - if (params.nonce in job.submissions) { - console.warn(threadName + 'Duplicate share with ' + params.nonce.toString() + ' nonce from ' + miner.logString); - miner.checkBan(false); - sendReply('Duplicate share'); - global.database.storeInvalidShare(miner.invalidShareProto); - return; - } - job.submissions[params.nonce] = 1; - } else { + + let nonce_test; + if (miner.proxy) { if (!Number.isInteger(params.poolNonce) || !Number.isInteger(params.workerNonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); @@ -1578,16 +1560,19 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply global.database.storeInvalidShare(miner.invalidShareProto); return; } - let nonce_test = `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; - if (nonce_test in job.submissions) { - console.warn(threadName + 'Duplicate proxy share with ' + nonce_test.toString() + ' nonce from ' + miner.logString); - miner.checkBan(false); - sendReply('Duplicate share'); - global.database.storeInvalidShare(miner.invalidShareProto); - return; - } - job.submissions[nonce_test] = 1; + nonce_test = `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; + } else { + nonce_test = params.nonce; + } + + if (nonce_test in job.submissions) { + console.warn(threadName + 'Duplicate miner share with ' + nonce_test + ' nonce from ' + miner.logString); + miner.checkBan(false); + sendReply('Duplicate share'); + global.database.storeInvalidShare(miner.invalidShareProto); + return; } + job.submissions[nonce_test] = 1; let blockTemplate; job.rewarded_difficulty = job.difficulty; @@ -1669,7 +1654,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply miner.lastShareTime = Date.now() / 1000 || 0; sendReply(null, {status: 'OK'}); - if (miner.debugMiner) console.log("SUBMIT OK"); + //if (miner.debugMiner) console.log("SUBMIT OK"); break; case 'keepalived': miner = activeMiners.get(params.id); From 6d3e6ecc70b816dcf864bc7cc870908668afb7ab Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 09:47:23 -0700 Subject: [PATCH 0441/1496] Added proxy diff limit based on pool limit --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index deb01c80a..2e49d4df4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -880,7 +880,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (this.fixed_diff) return false; let newDiff = Math.round(difficulty); - if (newDiff > global.config.pool.maxDifficulty && !this.proxy) { + if (newDiff > global.config.pool.maxDifficulty) { newDiff = global.config.pool.maxDifficulty; } if (newDiff < global.config.pool.minDifficulty) { From 5ccb9e3bf7f3cf9dcb8515df4b148ba814b54a59 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 10:45:03 -0700 Subject: [PATCH 0442/1496] Donot store invalid share buffer in miner object --- lib/pool.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2e49d4df4..ea8a4ed55 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -760,11 +760,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs = global.support.circularBuffer(10); this.cachedJob = null; - this.invalidShareProto = global.protos.InvalidShare.encode({ - paymentAddress: this.address, - paymentID: this.paymentID, - identifier: this.identifier - }); + this.storeInvalidShare = function() { + global.database.storeInvalidShare(global.protos.InvalidShare.encode({ + paymentAddress: this.address, + paymentID: this.paymentID, + identifier: this.identifier + })); + }; this.selectBestCoin = function() { if (this.debugMiner) console.log(threadName + this.logString + ": current coin is " + this.curr_coin); @@ -823,7 +825,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplates[best_coin].height; } return best_coin; - } + }; this.calcNewDiff = function () { const proxyMinerName = this.payout + ":" + this.identifier; @@ -1547,7 +1549,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); - global.database.storeInvalidShare(miner.invalidShareProto); + miner.storeInvalidShare(); return; } @@ -1557,7 +1559,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); - global.database.storeInvalidShare(miner.invalidShareProto); + miner.storeInvalidShare(); return; } nonce_test = `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; @@ -1569,7 +1571,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply console.warn(threadName + 'Duplicate miner share with ' + nonce_test + ' nonce from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); - global.database.storeInvalidShare(miner.invalidShareProto); + miner.storeInvalidShare(); return; } job.submissions[nonce_test] = 1; @@ -1604,7 +1606,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } miner.sendSameCoinJob(); sendReply(err_str); - global.database.storeInvalidShare(miner.invalidShareProto); + miner.storeInvalidShare(); return; } } else { @@ -1639,7 +1641,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } debug(threadName + "Share trust broken by " + miner.logString); - global.database.storeInvalidShare(miner.invalidShareProto); + miner.storeInvalidShare(); miner.trust.probability = 256; miner.trust.penalty = global.config.pool.trustPenalty; miner.trust.threshold = global.config.pool.trustThreshold; From cd3aaeaf0911f3299c011d39dd718cbb996b5f4e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 10:47:53 -0700 Subject: [PATCH 0443/1496] Code simplify --- lib/pool.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ea8a4ed55..3357c8e71 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1625,11 +1625,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (global.config.pool.trustedMiners) { if (shareAccepted) { miner.trust.probability -= global.config.pool.trustChange; - if (miner.trust.probability < (global.config.pool.trustMin)) { - miner.trust.probability = global.config.pool.trustMin; - } - miner.trust.penalty--; - miner.trust.threshold--; + if (miner.trust.probability < global.config.pool.trustMin) miner.trust.probability = global.config.pool.trustMin; + -- miner.trust.penalty; + -- miner.trust.threshold; miner.trust.check_height = 0; } else { From 70ca6fb06fcbc419dff0f17e6a7f9c0a68349f08 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 11:29:08 -0700 Subject: [PATCH 0444/1496] Added extra wallet verify --- lib/pool.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 3357c8e71..a01ad6b29 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1307,6 +1307,9 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi }); } +// wallets that need extra share verification +let extra_wallet_verify = {}; + function processShare(miner, job, blockTemplate, params) { let hash; let isTrustedShare; @@ -1320,6 +1323,18 @@ function processShare(miner, job, blockTemplate, params) { crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability && miner.trust.check_height !== job.height) { try { hash = new Buffer(resultHash, 'hex'); + if (miner.payout in extra_wallet_verify) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (shareBuffer !== null) { + let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); + const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); + if (hash2.toString('hex') !== resultHash) { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE"); + } + } else { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); + } + } } catch (err) { return invalid_share(miner); } @@ -1930,6 +1945,22 @@ if (cluster.isMaster) { }, 10*60*1000); + // get extra wallets to check + setInterval(function () { + const extra_wallet_verify_fn = "extra_wallet_verify.txt"; + extra_wallet_verify = {}; + fs.access(extra_wallet_verify_fn, fs.F_OK, function(err) { + if (err) return; + let rs = fs.createReadStream(extra_wallet_verify_fn); + rs.on('error', function() { console.error("Can't open " + extra_wallet_verify_fn + " file"); }); + let lineReader = require('readline').createInterface({ input: rs }); + lineReader.on('line', function (line) { + console.log("WILL EXTRA CHECK WALLET: '" + line + "'"); + extra_wallet_verify[line] = 1; + }); + }); + }, 60*1000); + let lastGarbageFromIpTime = {}; async.each(global.config.ports, function (portData) { From 2f8f34ea52b831ad4f532214f1718dbc35a5e945 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 12:15:34 -0700 Subject: [PATCH 0445/1496] Added extra wallet verify --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index a01ad6b29..5219b4c92 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1329,7 +1329,7 @@ function processShare(miner, job, blockTemplate, params) { let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); if (hash2.toString('hex') !== resultHash) { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE"); + console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); } } else { console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); From 07709bc245924dba81d79e40e60387d26dab186a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 12:16:22 -0700 Subject: [PATCH 0446/1496] Added extra wallet verify --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5219b4c92..f27c8bc79 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1959,7 +1959,7 @@ if (cluster.isMaster) { extra_wallet_verify[line] = 1; }); }); - }, 60*1000); + }, 5*60*1000); let lastGarbageFromIpTime = {}; From 71bc109d3c4b69813b78a56af0fc1349c2525513 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 13:00:45 -0700 Subject: [PATCH 0447/1496] Const adjustement --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f27c8bc79..8326bbf50 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1319,7 +1319,7 @@ function processShare(miner, job, blockTemplate, params) { if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); - if (global.config.pool.trustedMiners && miner.difficulty < 400000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && + if (global.config.pool.trustedMiners && miner.difficulty < 100000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability && miner.trust.check_height !== job.height) { try { hash = new Buffer(resultHash, 'hex'); From cc17c86fd6312c14867c91e0cb6940abb2a70a7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 14:21:38 -0700 Subject: [PATCH 0448/1496] Modified wallet trust --- lib/pool.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8326bbf50..e2ea7717c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -730,11 +730,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer walletTrust[this.payout] = 0; walletLastSeeTime[this.payout] = Date.now(); } - let is_trusted_wallet = this.difficulty <= 16001 && this.payout in walletTrust && walletTrust[this.payout] > global.config.pool.trustThreshold * 20; this.trust = { - threshold: is_trusted_wallet ? 1 : global.config.pool.trustThreshold, - probability: is_trusted_wallet ? global.config.pool.trustMin : 256, - penalty: 0, + threshold: global.config.pool.trustThreshold, + probability: 256, check_height: 0 }; } @@ -1278,7 +1276,6 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi if (global.config.pool.trustedMiners) { debug(threadName + "Share trust broken by " + miner.logString); miner.trust.probability = 256; - miner.trust.penalty = global.config.pool.trustPenalty; miner.trust.threshold = global.config.pool.trustThreshold; walletTrust[miner.payout] = 0; } @@ -1319,8 +1316,13 @@ function processShare(miner, job, blockTemplate, params) { if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); - if (global.config.pool.trustedMiners && miner.difficulty < 100000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && - crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability && miner.trust.check_height !== job.height) { + const reward_diff = job.rewarded_difficulty2; + const miner_wallet = miner.payout; + const is_safe_to_trust = reward_diff < 400000 && ( + (miner_wallet in walletTrust && reward_diff * 1000 < walletTrust[miner_wallet]) || + (miner.trust.threshold <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability) + ); + if (global.config.pool.trustedMiners && is_safe_to_trust && miner.trust.check_height !== job.height) { try { hash = new Buffer(resultHash, 'hex'); if (miner.payout in extra_wallet_verify) { @@ -1342,7 +1344,7 @@ function processShare(miner, job, blockTemplate, params) { } else { // verify share if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - console.error(threadName + "Throttled down miner share (diff " + job.difficulty + ") submission from " + miner.logString); + console.error(threadName + "Throttled down miner share (diff " + job.difficulty2 + ") submission from " + miner.logString); } process.send({type: 'throttledShare'}); addProxyMiner(miner); @@ -1363,7 +1365,7 @@ function processShare(miner, job, blockTemplate, params) { return invalid_share(miner); } - ++ walletTrust[miner.payout]; + walletTrust[miner.payout] += job.rewarded_difficulty2; isTrustedShare = false; } @@ -1641,7 +1643,6 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (shareAccepted) { miner.trust.probability -= global.config.pool.trustChange; if (miner.trust.probability < global.config.pool.trustMin) miner.trust.probability = global.config.pool.trustMin; - -- miner.trust.penalty; -- miner.trust.threshold; miner.trust.check_height = 0; @@ -1656,7 +1657,6 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply debug(threadName + "Share trust broken by " + miner.logString); miner.storeInvalidShare(); miner.trust.probability = 256; - miner.trust.penalty = global.config.pool.trustPenalty; miner.trust.threshold = global.config.pool.trustThreshold; } } From 9423b0c011dd8a59cbe8e89709fd2135e50e4dee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 14:43:01 -0700 Subject: [PATCH 0449/1496] Fixed total wallet trust case --- lib/pool.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e2ea7717c..3dca35ca2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1319,8 +1319,14 @@ function processShare(miner, job, blockTemplate, params) { const reward_diff = job.rewarded_difficulty2; const miner_wallet = miner.payout; const is_safe_to_trust = reward_diff < 400000 && ( - (miner_wallet in walletTrust && reward_diff * 1000 < walletTrust[miner_wallet]) || - (miner.trust.threshold <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability) + ( + miner.trust.threshold != global.config.pool.trustThreshold && + miner_wallet in walletTrust && + reward_diff * 1000 < walletTrust[miner_wallet] && + crypto.randomBytes(1).readUIntBE(0, 1) > global.config.pool.trustMin + ) || ( + miner.trust.threshold <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability + ) ); if (global.config.pool.trustedMiners && is_safe_to_trust && miner.trust.check_height !== job.height) { try { From ba68a06544fe662eb2854f24b130431bdf0a3b8c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 15:38:12 -0700 Subject: [PATCH 0450/1496] Changed miner trust system --- lib/pool.js | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3dca35ca2..719bf7109 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -731,8 +731,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer walletLastSeeTime[this.payout] = Date.now(); } this.trust = { - threshold: global.config.pool.trustThreshold, - probability: 256, + trust: 0, check_height: 0 }; } @@ -1275,8 +1274,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi if (global.config.pool.trustedMiners) { debug(threadName + "Share trust broken by " + miner.logString); - miner.trust.probability = 256; - miner.trust.threshold = global.config.pool.trustThreshold; + miner.trust.trust = 0; walletTrust[miner.payout] = 0; } } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { @@ -1307,6 +1305,18 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi // wallets that need extra share verification let extra_wallet_verify = {}; +function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { + return reward_diff < 400000 && miner_trust != 0 && ( + ( miner_wallet in walletTrust && + reward_diff * 1000 < walletTrust[miner_wallet] && + crypto.randomBytes(1).readUIntBE(0, 1) > global.config.pool.trustMin + ) || ( + reward_diff * global.config.pool.trustThreshold < miner_trust && + crypto.randomBytes(1).readUIntBE(0, 1) > Math.max(256 - miner_trust / reward_diff, global.config.pool.trustMin) + ) + ); +} + function processShare(miner, job, blockTemplate, params) { let hash; let isTrustedShare; @@ -1316,19 +1326,10 @@ function processShare(miner, job, blockTemplate, params) { if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); - const reward_diff = job.rewarded_difficulty2; - const miner_wallet = miner.payout; - const is_safe_to_trust = reward_diff < 400000 && ( - ( - miner.trust.threshold != global.config.pool.trustThreshold && - miner_wallet in walletTrust && - reward_diff * 1000 < walletTrust[miner_wallet] && - crypto.randomBytes(1).readUIntBE(0, 1) > global.config.pool.trustMin - ) || ( - miner.trust.threshold <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability - ) - ); - if (global.config.pool.trustedMiners && is_safe_to_trust && miner.trust.check_height !== job.height) { + if (global.config.pool.trustedMiners && + is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && + miner.trust.check_height !== job.height + ) { try { hash = new Buffer(resultHash, 'hex'); if (miner.payout in extra_wallet_verify) { @@ -1365,7 +1366,7 @@ function processShare(miner, job, blockTemplate, params) { if (hash.toString('hex') !== resultHash) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (miner.trust.probability == 256 ? " [banned]" : "")); + console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (miner.trust.trust == 0 ? " [banned]" : "")); lastMinerLogTime[miner.payout] = time_now; } return invalid_share(miner); @@ -1417,7 +1418,7 @@ function processShare(miner, job, blockTemplate, params) { } else if (hashDiff.lt(job.difficulty)) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString + (miner.trust.probability == 256 ? " [banned]" : "")); + console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString + (miner.trust.trust == 0 ? " [banned]" : "")); lastMinerLogTime[miner.payout] = time_now; } return invalid_share(miner); @@ -1647,13 +1648,11 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (global.config.pool.trustedMiners) { if (shareAccepted) { - miner.trust.probability -= global.config.pool.trustChange; - if (miner.trust.probability < global.config.pool.trustMin) miner.trust.probability = global.config.pool.trustMin; - -- miner.trust.threshold; + miner.trust.trust += job.rewarded_difficulty2; miner.trust.check_height = 0; } else { - if (miner.trust.probability == 256) { + if (miner.trust.trust == 0) { badMinerLastShareTime[miner.payout + ":" + miner.identifier + ":" + miner.ipAddress] = Date.now(); debug(threadName + "Banned miner for some time " + miner.logString); removeMiner(miner); @@ -1662,8 +1661,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } debug(threadName + "Share trust broken by " + miner.logString); miner.storeInvalidShare(); - miner.trust.probability = 256; - miner.trust.threshold = global.config.pool.trustThreshold; + miner.trust.trust = 0; } } From 80061b4f123d07ae912b09d0af276c6604dd053d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 15:57:39 -0700 Subject: [PATCH 0451/1496] More debug --- lib/pool.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 719bf7109..cffbf8be3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1306,12 +1306,14 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi let extra_wallet_verify = {}; function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { + const reward_diff2 = reward_diff * global.config.pool.trustThreshold; + console.log(Math.max(256 - miner_trust / reward_diff, global.config.pool.trustMin)); return reward_diff < 400000 && miner_trust != 0 && ( ( miner_wallet in walletTrust && - reward_diff * 1000 < walletTrust[miner_wallet] && + reward_diff2 * global.config.pool.trustThreshold < walletTrust[miner_wallet] && crypto.randomBytes(1).readUIntBE(0, 1) > global.config.pool.trustMin ) || ( - reward_diff * global.config.pool.trustThreshold < miner_trust && + reward_diff2 < miner_trust && crypto.randomBytes(1).readUIntBE(0, 1) > Math.max(256 - miner_trust / reward_diff, global.config.pool.trustMin) ) ); From b4b516be54a38a7340739bed133f763019bd726e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 16:00:38 -0700 Subject: [PATCH 0452/1496] Removed debug --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cffbf8be3..3e3398655 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1307,7 +1307,6 @@ let extra_wallet_verify = {}; function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { const reward_diff2 = reward_diff * global.config.pool.trustThreshold; - console.log(Math.max(256 - miner_trust / reward_diff, global.config.pool.trustMin)); return reward_diff < 400000 && miner_trust != 0 && ( ( miner_wallet in walletTrust && reward_diff2 * global.config.pool.trustThreshold < walletTrust[miner_wallet] && From bfd89bdabc04d04ca500798cb7901b3950549d4a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 18:34:45 -0700 Subject: [PATCH 0453/1496] Added XTNC support --- lib/coins/xmr.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 25bb4f3b3..1230d0a2e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -28,7 +28,7 @@ const port2coin = { "20189": "XTC", "22023": "LOKI", "24182": "TUBE", - "31014": "XRN", + "33124": "XTNC", "34568": "WOW", "38081": "MSR", "48782": "LTHN" @@ -43,13 +43,13 @@ const port2blob_num = { "20189": 0, // XTC "22023": 5, // LOKI "24182": 0, // TUBE - "31014": 5, // XRN + "33124": 5, // XTNC "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); -const mm_port_set = { "22023": 11898 }; +const mm_port_set = { "22023": 11898, "33124": 11898 }; const fix_daemon_sh = "./fix_daemon.sh"; @@ -166,7 +166,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 22023 || port == 31014 || port == 24182) { // Loki / Saronite / TUBE has reward as zero transaction + if (port == 22023 || port == 33124 || port == 24182) { // Loki / XtendCash / TUBE has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Fri, 19 Apr 2019 18:48:53 -0700 Subject: [PATCH 0454/1496] Added XTNC donate address --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d27566e5d..9f33d1bfe 100644 --- a/README.md +++ b/README.md @@ -271,6 +271,7 @@ If you'd like to make a one time donation, the addresses are as follows: * TUBE - ```bxcpZTr4C41NshmJM9Db7FBE5crarjaDXVUApRbsCxHHBf8Jkqjwjzz1zmWHhm9trWNhrY1m4RpcS7tmdG4ykdHG2kTgDcbKJ``` * LOKI - ```L6XqN6JDedz5Ub8KxpMYRCUoQCuyEA8EegEmeQsdP5FCNuXJavcrxPvLhpqY6emphGTYVrmAUVECsE9drafvY2hXUTJz6rW``` * TRTL - ```TRTLv2x2bac17cngo1r2wt3CaxN8ckoWHe2TX7dc8zW8Fc9dpmxAvhVX4u4zPjpv9WeALm2koBLF36REVvsLmeufZZ1Yx6uWkYG``` +* XTNC - ```XtazhSxz1bbJLpT2JuiD2UWFUJYSFty5SVWuF6sy2w9v8pn69smkUxkTVCQc8NKCd6CBMNDGzgdPRYBKaHdbgZ5SNptVH1yPCTQ``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` From a77483bb84c0cc224667b083b0cadf1c1939ff5d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Apr 2019 18:55:01 -0700 Subject: [PATCH 0455/1496] Added XTNC support --- deployment/base.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 8558f09e9..232d4779d 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -192,6 +192,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortRYO', '0', 'int', 'Ryo coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLOKI', '0', 'int', 'Loki coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXRN', '0', 'int', 'Saronite coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTNC', '0', 'int', 'XtencCash coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortWOW', '0', 'int', 'Wownero coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTUBE', '0', 'int', 'BitTube coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXHV', '0', 'int', 'Haven coin daemon RPC port or 0'); @@ -204,6 +205,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXRN', '0', 'float', 'Saronite algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTNC', '0', 'float', 'XtendCash algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorWOW', '0', 'float', 'Wownero algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTUBE', '0', 'float', 'BitTube algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXHV', '0', 'float', 'Haven algo hash price factor relative to coinHashFactor'); @@ -262,6 +264,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Stellite) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_22023', '', 'string', 'Address to mine to for 22023 (Loki) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_31014', '', 'string', 'Address to mine to for 31014 (Saronite) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_33124', '', 'string', 'Address to mine to for 33124 (XtendCash) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11898', '', 'string', 'Address to mine to for 11898 (Turtle) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); From 690bc2c11ab52455fa22515ca07e24add923d042 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Apr 2019 10:23:39 -0700 Subject: [PATCH 0456/1496] Adjust constant --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3e3398655..7c844bc44 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1313,7 +1313,7 @@ function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { crypto.randomBytes(1).readUIntBE(0, 1) > global.config.pool.trustMin ) || ( reward_diff2 < miner_trust && - crypto.randomBytes(1).readUIntBE(0, 1) > Math.max(256 - miner_trust / reward_diff, global.config.pool.trustMin) + crypto.randomBytes(1).readUIntBE(0, 1) > Math.max(256 - miner_trust / reward_diff / 2, global.config.pool.trustMin) ) ); } From 462d96803bca5a1c9d5f68138a6902b717fbf889 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Apr 2019 23:40:24 -0700 Subject: [PATCH 0457/1496] Payment precalc draft implementation --- deployment/base.sql | 12 ++ lib/blockManager.js | 510 +++++++++++++++++++++++++++++++------------- lib/data.proto | 2 + lib/local_comms.js | 38 ++++ 4 files changed, 412 insertions(+), 150 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 232d4779d..a9a0237cf 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -17,6 +17,18 @@ CREATE TABLE `balance` ( UNIQUE KEY `balance_payment_address_pool_type_bitcoin_payment_id_uindex` (`payment_address`,`pool_type`,`bitcoin`,`payment_id`), KEY `balance_payment_address_payment_id_index` (`payment_address`,`payment_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `block_balance` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `hex` varchar(128) NOT NULL, + `payment_address` varchar(128) DEFAULT NULL, + `payment_id` varchar(128) DEFAULT NULL, + `amount` float(53) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `block_balance_id_uindex` (`id`), + UNIQUE KEY `block_balance_hex_payment_address_payment_id_uindex` (`hex`, `payment_address`,`payment_id`), + KEY `block_balance_hex_index` (`hex`), + KEY `block_balance_payment_address_payment_id_index` (`payment_address`,`payment_id`), +) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `bans` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ip_address` varchar(40) DEFAULT NULL, diff --git a/lib/blockManager.js b/lib/blockManager.js index 5a6a421c6..e18e19ebc 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -9,46 +9,60 @@ const async = require("async"); // Maintain a check for valid blocks in the system. (Only last number of blocks required for validation of payouts) - Perform every 2 minutes. Scan on the main blocks table as well for sanity sake. // Maintain the block_log database in order to ensure payments happen smoothly. - Scan every 1 second for a change in lastblockheader, if it changes, insert into the DB. -let blockIDCache = []; +//let blockIDCache = []; let paymentInProgress = false; -let scanInProgress = false; -let blockHexCache = {}; -let lastBlock = 0; +//let scanInProgress = false; +//let blockHexCache = {}; +//let lastBlock = 0; let balanceIDCache = {}; -let blockScannerTask; -let blockQueue = async.queue(function (task, callback) { - global.coinFuncs.getBlockHeaderByID(task.blockID, (err, body) => { - if (err !== null) { - console.error("Can't get block with " + task.blockID + " height"); - return callback(); - } - if (body.hash in blockHexCache) { - return callback(); +//let blockScannerTask; +//let blockQueue = async.queue(function (task, callback) { +// global.coinFuncs.getBlockHeaderByID(task.blockID, (err, body) => { +// if (err !== null) { +// console.error("Can't get block with " + task.blockID + " height"); +// return callback(); +// } +// if (body.hash in blockHexCache) { +// return callback(); +// } +// debug("Adding block to block_log, ID: " + task.blockID); +// blockIDCache.push(task.blockID); +// blockHexCache[body.hash] = null; +// global.mysql.query("INSERT INTO block_log (id, orphan, hex, find_time, reward, difficulty, major_version, minor_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", +// [task.blockID, body.orphan_status, body.hash, global.support.formatDate(body.timestamp * 1000), body.reward, body.difficulty, body.major_version, body.minor_version]).then(function () { +// return calculatePPSPayments(body, callback); +// }).catch(function (err) { +// debug("BlockHexCache Check: " + body.hash in blockHexCache); +// debug("BlockIDCache Check: " + blockIDCache.hasOwnProperty(task.blockID)); +// debug("Hex: " + body.hash + " Height:" + task.blockID); +// console.error("Tried to reprocess a block that'd already been processed"); +// console.error(JSON.stringify(err)); +// return callback(); +// }); +// }); +//}, 16); + +//blockQueue.drain = function () { +// debug("blockQueue drained: unlocking remainder of blockManager functionality"); +// scanInProgress = false; +// if (typeof(blockScannerTask) === 'undefined'){ +// blockScannerTask = setInterval(blockScanner, 1000); +// } +//}; + +let createBlockBalanceQueue = async.queue(function (task, callback) { + global.mysql.query("REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES (?, ?, ?, ?)", [task.hex, task.payment_address, task.payment_id, task.amount]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ")"); + return callback(false); } - debug("Adding block to block_log, ID: " + task.blockID); - blockIDCache.push(task.blockID); - blockHexCache[body.hash] = null; - global.mysql.query("INSERT INTO block_log (id, orphan, hex, find_time, reward, difficulty, major_version, minor_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [task.blockID, body.orphan_status, body.hash, global.support.formatDate(body.timestamp * 1000), body.reward, body.difficulty, body.major_version, body.minor_version]).then(function () { - return calculatePPSPayments(body, callback); - }).catch(function (err) { - debug("BlockHexCache Check: " + body.hash in blockHexCache); - debug("BlockIDCache Check: " + blockIDCache.hasOwnProperty(task.blockID)); - debug("Hex: " + body.hash + " Height:" + task.blockID); - console.error("Tried to reprocess a block that'd already been processed"); - console.error(JSON.stringify(err)); - return callback(); - }); + return callback(true); + }).catch(function (err) { + console.error(err); + console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ")"); + return callback(false); }); -}, 16); - -blockQueue.drain = function () { - debug("blockQueue drained: unlocking remainder of blockManager functionality"); - scanInProgress = false; - if (typeof(blockScannerTask) === 'undefined'){ - blockScannerTask = setInterval(blockScanner, 1000); - } -}; +}, 1); let createBalanceQueue = async.queue(function (task, callback) { let pool_type = task.pool_type; @@ -93,8 +107,7 @@ let balanceQueue = async.queue(function (task, callback) { if (cacheKey in balanceIDCache) { return intCallback(null, balanceIDCache[cacheKey]); } else { - createBalanceQueue.push(task, function () { - }); + createBalanceQueue.push(task, function () {}); async.until(function () { return cacheKey in balanceIDCache; }, function (intCallback) { @@ -266,11 +279,174 @@ function calculatePPSPayments(blockHeader, callback) { return callback(); } +function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, done_callback) { + const rewardTotal = 1.0; + console.log("Performing PPLNS reward pre-calculations on block " + block_hex + " on (anchor) height " + block_height); + const blockDiff = block_difficulty; + const windowPPLNS = blockDiff * global.config.pplns.shareMulti; + + let blockCheckHeight = block_height; + let totalPaid = 0; + let totalShares = 0; + let paymentData = {}; + + paymentData[global.config.payout.feeAddress] = { + pool_type: 'fees', + payment_address: global.config.payout.feeAddress, + payment_id: null, + bitcoin: 0, + amount: 0 + }; + paymentData[global.coinFuncs.coinDevAddress] = { + pool_type: 'fees', + payment_address: global.coinFuncs.coinDevAddress, + payment_id: null, + bitcoin: 0, + amount: 0 + }; + paymentData[global.coinFuncs.poolDevAddress] = { + pool_type: 'fees', + payment_address: global.coinFuncs.poolDevAddress, + payment_id: null, + bitcoin: 0, + amount: 0 + }; + + function addPayment(keyAdd, valueAdd) { + if (valueAdd === 0) return; + if (totalPaid >= rewardTotal) return; + totalShares += valueAdd; + paymentData[keyAdd].amount += valueAdd; + let totalPaid2 = totalShares / windowPPLNS * rewardTotal; + if (totalPaid2 <= rewardTotal) { // totalPaid can not overflow rewardTotal now + totalPaid = totalPaid2; + } else { // we need recalculate totalPaid precisely now + totalPaid = 0; + Object.keys(paymentData).forEach(function (key) { + totalPaid += Math.floor(paymentData[key].amount / windowPPLNS * rewardTotal); + }); + console.log("Aproximate totalPaid " + totalPaid2 + " was reset to precise value " + totalPaid); + if (totalPaid >= rewardTotal) { + console.log("Precise value totalPaid " + totalPaid + " reached max " + rewardTotal); + let extra = (totalPaid - rewardTotal) / rewardTotal * windowPPLNS; + console.log("Rewarded " + (valueAdd - extra) + " instead of " + valueAdd + " hashes for " + keyAdd); + paymentData[keyAdd].amount -= extra; + totalPaid = rewardTotal; + } + } + }; + + let portShares = {}; + let firstShareTime; + let lastShareTime; + + async.doWhilst(function (callback) { + let txn = global.database.env.beginTxn({readOnly: true}); + let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); + for (let found = (cursor.goToRange(blockCheckHeight) === blockCheckHeight); found; found = cursor.goToNextDup()) { + cursor.getCurrentBinary(function (key, data) { // jshint ignore:line + let shareData; + try { + shareData = global.protos.Share.decode(data); + } catch (e) { + console.error(e); + return; + } + if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { + let userIdentifier = shareData.paymentAddress; + if (shareData.paymentID) { + userIdentifier = userIdentifier + "." + shareData.paymentID; + } + if (!(userIdentifier in paymentData)) { + paymentData[userIdentifier] = { + pool_type: 'pplns', + payment_address: shareData.paymentAddress, + payment_id: shareData.paymentID, + bitcoin: shareData.bitcoin, + amount: 0 + }; + } + + if (!firstShareTime) firstShareTime = shareData.timestamp; + if (totalPaid < rewardTotal) lastShareTime = shareData.timestamp; + + let amountToPay = shareData.shares2; + let feesToPay = amountToPay * (global.config.payout.pplnsFee / 100) + + (shareData.bitcoin === true ? amountToPay * (global.config.payout.btcFee / 100) : 0); + let devDonation = feesToPay * (global.config.payout.devDonation / 100); + let poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); + + addPayment(userIdentifier, amountToPay - feesToPay); + addPayment(global.config.payout.feeAddress, feesToPay - devDonation - poolDevDonation); + addPayment(global.coinFuncs.poolDevAddress, poolDevDonation); + addPayment(global.coinFuncs.coinDevAddress, devDonation); + + if (typeof(shareData.port) !== 'undefined') { + if (shareData.port in portShares) { + portShares[shareData.port] += amountToPay; + } else { + portShares[shareData.port] = amountToPay; + } + } + } + }); + } + cursor.close(); + txn.abort(); + setImmediate(callback, null, totalPaid); + }, function (totalPayment) { + blockCheckHeight = blockCheckHeight - 1; + debug("Decrementing the block chain check height to:" + blockCheckHeight); + if (totalPayment >= rewardTotal) { + debug("Loop 1: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); + return false; + } else { + debug("Loop 2: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); + return blockCheckHeight !== 0; + } + }, function (err) { + let sumAllPorts = 0; + for (let port in portShares) sumAllPorts += portShares[port]; + let pplns_port_shares = {}; + for (let port in portShares) { + const port_share = portShares[port] / sumAllPorts; + pplns_port_shares[port] = port_share; + console.log("Port " + port + ": " + (100.0 * port_share).toFixed(2) + "%"); + } + global.database.setCache('pplns_port_shares', pplns_port_shares); + global.database.setCache('pplns_window_time', (firstShareTime - lastShareTime) / 1000); + + let totalPayments = 0; + Object.keys(paymentData).forEach(function (key) { + totalPayments += paymentData[key].amount; + }); + + const default_window = blockDiff*global.config.pplns.shareMulti; + const is_need_correction = Math.abs(totalPayments/default_window - 1) > 0.0001; + const pay_window = is_need_correction ? totalPayments : default_window; + + let add_count = 0; + let is_ok = true; + Object.keys(paymentData).forEach(function (key) { + if (paymentData[key].amount) { + paymentData[key].hex = block_hex; + paymentData[key].amount = paymentData[key].amount / pay_window; + ++ add_count; + createBlockBalanceQueue.push(paymentData[key], function (status) { + if (status === false) is_ok = false; + if (--add_count == 0) done_callback(is_ok); + }); + } + }); + }); +} + function calculatePPLNSPayments(block_height, block_reward, block_difficulty, unlock_callback) { - console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward)); - let rewardTotal = block_reward; - let blockDiff = block_difficulty; - let windowPPLNS = blockDiff * global.config.pplns.shareMulti; + const rewardTotal = block_reward; + console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal)); + const blockDiff = block_difficulty; + const windowPPLNS = blockDiff * global.config.pplns.shareMulti; + let blockCheckHeight = block_height; let totalPaid = 0; let totalShares = 0; @@ -337,8 +513,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un console.error(e); return; } - let blockDiff = block_difficulty; - let rewardTotal = block_reward; if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { let userIdentifier = shareData.paymentAddress; if (shareData.paymentID) { @@ -426,18 +600,18 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); }); - console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); + console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); if (is_need_correction) { - console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); + console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); global.support.sendEmail(global.config.general.adminEmail, "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", - "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + - "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" + "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + + "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" ); } }); }); -}; +} function calculateSoloPayments(blockHeader) { console.log("Performing Solo payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); @@ -521,15 +695,17 @@ function calculateSoloPayments(blockHeader) { console.log("Solo payout cycle complete on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / blockHeader.reward) * 100 + "%"); } +let payReadyBlockHashCalc = {}; + function blockUnlocker() { if (is_full_stop) { debug("Dropping all block unlocks"); return; } - if (scanInProgress) { - debug("Skipping block unlocker run as there's a scan in progress"); - return; - } +// if (scanInProgress) { +// debug("Skipping block unlocker run as there's a scan in progress"); +// return; +// } if (paymentInProgress) { debug("Skipping block unlocker run as there's a payment in progress"); return; @@ -541,22 +717,29 @@ function blockUnlocker() { console.error("Last block header request failed!"); return; } - let topBlockHeight = body.height; + const topBlockHeight = body.height; blockList.forEach(function (block) { global.coinFuncs.getBlockHeaderByID(block.height, (err, body) => { if (err !== null) { console.error("Can't get block with " + block.height + " height"); return; } - if (body.hash !== block.hash && topBlockHeight - block.height > 5) { + if (topBlockHeight - block.height <= 5) return; + if (body.hash !== block.hash) { global.database.invalidateBlock(block.height); - global.mysql.query("UPDATE block_log SET orphan = true WHERE hex = ?", [block.hash]); - blockIDCache.splice(blockIDCache.indexOf(block.height)); + //global.mysql.query("UPDATE block_log SET orphan = true WHERE hex = ?", [block.hash]); + //blockIDCache.splice(blockIDCache.indexOf(block.height)); console.log("Invalidating block " + block.height + " due to being an orphan block"); - } else { - if (topBlockHeight - block.height > global.config.payout.blocksRequired) { - blockPayments(block); - } + } else if (block.poolType == global.protos.POOLTYPE.PPLNS && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + payReadyBlockHashCalc[block.hash] = 1; + preCalculatePPLNSPayments(block.hash, block.height, block.difficulty, function(status) { + if (status) { + console.log("Completed PPLNS reward pre-calculations on block " + block.hash + " on height " + block.height); + global.database.payReadyBlock(block.hash); + } + }); + } else if (topBlockHeight - block.height > global.config.payout.blocksRequired /*&& (block.poolType != global.protos.POOLTYPE.PPLNS || block.pay_ready === true)*/) { + blockPayments(block); } }); @@ -570,11 +753,11 @@ function altblockUnlocker() { setTimeout(altblockUnlocker, 2*60*1000); return; } - if (scanInProgress) { - debug("Skipping altblock unlocker run as there's a scan in progress"); - setTimeout(altblockUnlocker, 2*60*1000); - return; - } +// if (scanInProgress) { +// debug("Skipping altblock unlocker run as there's a scan in progress"); +// setTimeout(altblockUnlocker, 2*60*1000); +// return; +// } if (paymentInProgress) { debug("Skipping altblock unlocker run as there's a payment in progress"); setTimeout(altblockUnlocker, 2*60*1000); @@ -583,31 +766,54 @@ function altblockUnlocker() { debug("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); let blockHeightWait = {}; - async.eachSeries(blockList, function(block, next) { - global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { - if (err !== null) { - console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); - return next(); - } - if (body.hash !== block.hash) { - global.database.invalidateAltBlock(block.id); - console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); - return next(); - } else { - if (block.pay_value !== 0) { - altblockPayments(block, function() { next(); } ); - } else { - if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; - blockHeightWait[block.port].push(block.height); + global.coinFuncs.getLastBlockHeader(function(err, body){ + if (err !== null) { + console.error("Last block header request failed!"); + setTimeout(altblockUnlocker, 2*60*1000); + return; + } + const topBlockHeight = body.height; + async.eachSeries(blockList, function(block, next) { + global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { + if (err !== null) { + console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); return next(); } + if (topBlockHeight - block.anchor_height <= 5) return; + if (body.hash !== block.hash) { + global.database.invalidateAltBlock(block.id); + console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); + return next(); + } else if (block.poolType == global.protos.POOLTYPE.PPLNS && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { + if (anchor_err === null){ + payReadyBlockHashCalc[block.hash] = 1; + preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, function(status) { + if (status) { + console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); + global.database.payReadyAltBlock(block.hash); + } + }); + } else { + console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); + } + }); + } else if (true/*(block.poolType != global.protos.POOLTYPE.PPLNS || block.pay_ready === true)*/) { + if (block.pay_value !== 0) { + altblockPayments(block, function() { next(); } ); + } else { + if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; + blockHeightWait[block.port].push(block.height); + return next(); + } + } + }); + }, function() { + for (let port in blockHeightWait) { + console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); } + setTimeout(altblockUnlocker, 2*60*1000); }); - }, function() { - for (let port in blockHeightWait) { - console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); - } - setTimeout(altblockUnlocker, 2*60*1000); }); } @@ -672,7 +878,7 @@ function altblockPayments(block, cb) { }); return cb(); } else { - console.error("Can't get correct block header by height " + block.anchor_height.toString()); + console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); return cb(); } }); @@ -688,65 +894,69 @@ function altblockPayments(block, cb) { } } -function blockScanner() { - let inc_check = 0; - if (scanInProgress) { - debug("Skipping scan as there's one in progress."); - return; - } - scanInProgress = true; - global.coinFuncs.getLastBlockHeader(function (err, blockHeader) { - if (err === null){ - if (lastBlock === blockHeader.height) { - //debug("No new work to be performed, block header matches last block"); - scanInProgress = false; - return; - } - debug("Parsing data for new blocks"); - lastBlock = blockHeader.height; - range.range(0, (blockHeader.height - Math.floor(global.config.payout.blocksRequired/2))).forEach(function (blockID) { - if (!blockIDCache.hasOwnProperty(blockID)) { - ++ inc_check; - blockQueue.push({blockID: blockID}, function (err) { - debug("Completed block scan on " + blockID); - if (err) { - console.error("Error processing " + blockID); - } - }); - } - }); - if (inc_check === 0) { - debug("No new work to be performed, initial scan complete"); - scanInProgress = false; - blockScannerTask = setInterval(blockScanner, 1000); - } - } else { - console.error(`Upstream error from the block daemon. Resetting scanner due to: ${JSON.stringify(blockHeader)}`); - scanInProgress = false; - blockScannerTask = setInterval(blockScanner, 1000); - } - }); -} - -function initial_sync() { - console.log("Performing boot-sync"); - global.mysql.query("SELECT id, hex FROM block_log WHERE orphan = 0").then(function (rows) { - let intCount = 0; - rows.forEach(function (row) { - ++ intCount; - blockIDCache.push(row.id); - blockHexCache[row.hex] = null; - }); - }).then(function () { - // Enable block scanning for 1 seconds to update the block log. - blockScanner(); - // Scan every 120 seconds for invalidated blocks - setInterval(blockUnlocker, 2*60*1000); - blockUnlocker(); - altblockUnlocker(); - debug("Blocks loaded from SQL: " + blockIDCache.length); - console.log("Boot-sync from SQL complete: pending completion of queued jobs to get back to work."); - }); -} - -initial_sync(); +//function blockScanner() { +// let inc_check = 0; +// if (scanInProgress) { +// debug("Skipping scan as there's one in progress."); +// return; +// } +// scanInProgress = true; +// global.coinFuncs.getLastBlockHeader(function (err, blockHeader) { +// if (err === null){ +// if (lastBlock === blockHeader.height) { +// //debug("No new work to be performed, block header matches last block"); +// scanInProgress = false; +// return; +// } +// debug("Parsing data for new blocks"); +// lastBlock = blockHeader.height; +// range.range(0, (blockHeader.height - Math.floor(global.config.payout.blocksRequired/2))).forEach(function (blockID) { +// if (!blockIDCache.hasOwnProperty(blockID)) { +// ++ inc_check; +// blockQueue.push({blockID: blockID}, function (err) { +// debug("Completed block scan on " + blockID); +// if (err) { +// console.error("Error processing " + blockID); +// } +// }); +// } +// }); +// if (inc_check === 0) { +// debug("No new work to be performed, initial scan complete"); +// scanInProgress = false; +// blockScannerTask = setInterval(blockScanner, 1000); +// } +// } else { +// console.error(`Upstream error from the block daemon. Resetting scanner due to: ${JSON.stringify(blockHeader)}`); +// scanInProgress = false; +// blockScannerTask = setInterval(blockScanner, 1000); +// } +// }); +//} + +//function initial_sync() { +// console.log("Performing boot-sync"); +// global.mysql.query("SELECT id, hex FROM block_log WHERE orphan = 0").then(function (rows) { +// let intCount = 0; +// rows.forEach(function (row) { +// ++ intCount; +// blockIDCache.push(row.id); +// blockHexCache[row.hex] = null; +// }); +// }).then(function () { +// // Enable block scanning for 1 seconds to update the block log. +// blockScanner(); +// // Scan every 120 seconds for invalidated blocks +// setInterval(blockUnlocker, 2*60*1000); +// blockUnlocker(); +// altblockUnlocker(); +// debug("Blocks loaded from SQL: " + blockIDCache.length); +// console.log("Boot-sync from SQL complete: pending completion of queued jobs to get back to work."); +// }); +//} + +//initial_sync(); + +setInterval(blockUnlocker, 2*60*1000); +blockUnlocker(); +altblockUnlocker(); \ No newline at end of file diff --git a/lib/data.proto b/lib/data.proto index 52d463271..653703822 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -52,6 +52,7 @@ message Block { required bool unlocked = 6; required bool valid = 7; optional int64 value = 8; + optional bool pay_ready = 9; } message AltBlock { @@ -69,4 +70,5 @@ message AltBlock { optional int64 pay_value = 12; optional string pay_stage = 13; optional string pay_status = 14; + optional bool pay_ready = 15; } diff --git a/lib/local_comms.js b/lib/local_comms.js index 771e78239..a221c1dbc 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -614,6 +614,44 @@ function Database(){ txn.commit(); }; + this.payReadyBlock = function(blockHex){ + this.refreshEnv(); + let txn = this.env.beginTxn(); + let cursor = new this.lmdb.Cursor(txn, this.blockDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + let blockDB = this.blockDB; + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.Block.decode(data); + if (blockData.hash === blockHex){ + blockData.pay_ready = true; + txn.putBinary(blockDB, key, global.protos.Block.encode(blockData)); + } + }); + blockDB = null; + } + cursor.close(); + txn.commit(); + }; + + this.payReadyAltBlock = function(blockHex){ + this.refreshEnv(); + let txn = this.env.beginTxn(); + let cursor = new this.lmdb.Cursor(txn, this.altblockDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + let altblockDB = this.altblockDB; + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + if (blockData.hash === blockHex){ + blockData.pay_ready = true; + txn.putBinary(altblockDB, key, global.protos.AltBlock.encode(blockData)); + } + }); + altblockDB = null; + } + cursor.close(); + txn.commit(); + }; + this.getCache = function(cacheKey){ debug("Getting Key: "+cacheKey); try { From 25e4d0eb23e68959fe2e44dec3967ba9263b15e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 09:46:20 -0700 Subject: [PATCH 0458/1496] Fixed rounding --- lib/blockManager.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e18e19ebc..8c974fbcf 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -317,22 +317,15 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do if (totalPaid >= rewardTotal) return; totalShares += valueAdd; paymentData[keyAdd].amount += valueAdd; - let totalPaid2 = totalShares / windowPPLNS * rewardTotal; - if (totalPaid2 <= rewardTotal) { // totalPaid can not overflow rewardTotal now + const totalPaid2 = totalShares / windowPPLNS * rewardTotal; + if (totalPaid2 > rewardTotal) { // totalPaid can not overflow rewardTotal now + console.log("Value totalPaid " + totalPaid + " reached max " + rewardTotal); + let extra = (totalPaid - rewardTotal) / rewardTotal * windowPPLNS; + console.log("Rewarded " + (valueAdd - extra) + " instead of " + valueAdd + " hashes for " + keyAdd); + paymentData[keyAdd].amount -= extra; + totalPaid = rewardTotal; + } else { totalPaid = totalPaid2; - } else { // we need recalculate totalPaid precisely now - totalPaid = 0; - Object.keys(paymentData).forEach(function (key) { - totalPaid += Math.floor(paymentData[key].amount / windowPPLNS * rewardTotal); - }); - console.log("Aproximate totalPaid " + totalPaid2 + " was reset to precise value " + totalPaid); - if (totalPaid >= rewardTotal) { - console.log("Precise value totalPaid " + totalPaid + " reached max " + rewardTotal); - let extra = (totalPaid - rewardTotal) / rewardTotal * windowPPLNS; - console.log("Rewarded " + (valueAdd - extra) + " instead of " + valueAdd + " hashes for " + keyAdd); - paymentData[keyAdd].amount -= extra; - totalPaid = rewardTotal; - } } }; From 67922cc8e53007673aa0598884a430c94389db68 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 10:06:02 -0700 Subject: [PATCH 0459/1496] Fixed rounding --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 8c974fbcf..424a65992 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -281,7 +281,7 @@ function calculatePPSPayments(blockHeader, callback) { function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, done_callback) { const rewardTotal = 1.0; - console.log("Performing PPLNS reward pre-calculations on block " + block_hex + " on (anchor) height " + block_height); + console.log("Performing PPLNS reward pre-calculations of block " + block_hex + " on (anchor) height " + block_height); const blockDiff = block_difficulty; const windowPPLNS = blockDiff * global.config.pplns.shareMulti; @@ -320,7 +320,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do const totalPaid2 = totalShares / windowPPLNS * rewardTotal; if (totalPaid2 > rewardTotal) { // totalPaid can not overflow rewardTotal now console.log("Value totalPaid " + totalPaid + " reached max " + rewardTotal); - let extra = (totalPaid - rewardTotal) / rewardTotal * windowPPLNS; + const extra = (totalPaid2 - rewardTotal) / rewardTotal * windowPPLNS; console.log("Rewarded " + (valueAdd - extra) + " instead of " + valueAdd + " hashes for " + keyAdd); paymentData[keyAdd].amount -= extra; totalPaid = rewardTotal; @@ -727,7 +727,7 @@ function blockUnlocker() { payReadyBlockHashCalc[block.hash] = 1; preCalculatePPLNSPayments(block.hash, block.height, block.difficulty, function(status) { if (status) { - console.log("Completed PPLNS reward pre-calculations on block " + block.hash + " on height " + block.height); + console.log("Completed PPLNS reward pre-calculations of block " + block.hash + " on height " + block.height); global.database.payReadyBlock(block.hash); } }); From bc63c652e424c573843fdd71b1cb7dcf836a9dfb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 10:52:53 -0700 Subject: [PATCH 0460/1496] Name fix --- manage_scripts/block_add.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/block_add.js b/manage_scripts/block_add.js index 04e71c2e6..08ae68200 100644 --- a/manage_scripts/block_add.js +++ b/manage_scripts/block_add.js @@ -42,7 +42,7 @@ require("../init_mini.js").init(function() { console.error("Block body is invalid: " + JSON.stringify(body3)); process.exit(1); } - const body4 = global.protos.AltBlock.encode(body3); + const body4 = global.protos.Block.encode(body3); let txn = global.database.env.beginTxn(); txn.putBinary(global.database.blockDB, height, body4); txn.commit(); From cf3d49e144660ebddbe65b327f017b926530fd67 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 11:18:08 -0700 Subject: [PATCH 0461/1496] Fixed callbacks --- lib/blockManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 424a65992..98abac604 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -786,9 +786,11 @@ function altblockUnlocker() { console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); global.database.payReadyAltBlock(block.hash); } + return next(); }); } else { console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); + return next(); } }); } else if (true/*(block.poolType != global.protos.POOLTYPE.PPLNS || block.pay_ready === true)*/) { From 562a3aff6847df1a8358f8855e57df0ab0ba448a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 11:22:02 -0700 Subject: [PATCH 0462/1496] Fixed callbacks --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 98abac604..c0f364f10 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -756,7 +756,7 @@ function altblockUnlocker() { setTimeout(altblockUnlocker, 2*60*1000); return; } - debug("Running altblock unlocker"); + console.log("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); let blockHeightWait = {}; global.coinFuncs.getLastBlockHeader(function(err, body){ @@ -772,7 +772,7 @@ function altblockUnlocker() { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); return next(); } - if (topBlockHeight - block.anchor_height <= 5) return; + if (topBlockHeight - block.anchor_height <= 5) return next(); if (body.hash !== block.hash) { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); From c17ffb1e40f757c7a673dd022f473ec5bdc716fd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 11:37:53 -0700 Subject: [PATCH 0463/1496] More debug --- lib/blockManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index c0f364f10..6649f8f46 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -53,13 +53,14 @@ let balanceIDCache = {}; let createBlockBalanceQueue = async.queue(function (task, callback) { global.mysql.query("REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES (?, ?, ?, ?)", [task.hex, task.payment_address, task.payment_id, task.amount]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ")"); + console.error(JSON.stringify(result)); + console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); return callback(false); } return callback(true); }).catch(function (err) { console.error(err); - console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ")"); + console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); return callback(false); }); }, 1); From 5229cc1b5595974b7368ce5eb2c6127f91538701 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 11:42:51 -0700 Subject: [PATCH 0464/1496] More debug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 6649f8f46..53499c552 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -52,7 +52,7 @@ let balanceIDCache = {}; let createBlockBalanceQueue = async.queue(function (task, callback) { global.mysql.query("REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES (?, ?, ?, ?)", [task.hex, task.payment_address, task.payment_id, task.amount]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + if (!result.hasOwnProperty("affectedRows") || (result.affectedRows != 1 && result.affectedRows != 2)) { console.error(JSON.stringify(result)); console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); return callback(false); From 7eec27de45390b3b3261df86fd5e66be9aaa7ca5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 21:11:41 -0700 Subject: [PATCH 0465/1496] Added pre calc check --- lib/blockManager.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 53499c552..e05203d98 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -347,10 +347,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do return; } if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { - let userIdentifier = shareData.paymentAddress; - if (shareData.paymentID) { - userIdentifier = userIdentifier + "." + shareData.paymentID; - } + const userIdentifier = shareData.paymentID ? userIdentifier + "." + shareData.paymentID : shareData.paymentAddress; if (!(userIdentifier in paymentData)) { paymentData[userIdentifier] = { pool_type: 'pplns', @@ -435,7 +432,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do }); } -function calculatePPLNSPayments(block_height, block_reward, block_difficulty, unlock_callback) { +function calculatePPLNSPayments(block_hex, block_height, block_reward, block_difficulty, unlock_callback) { const rewardTotal = block_reward; console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal)); const blockDiff = block_difficulty; @@ -508,10 +505,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un return; } if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { - let userIdentifier = shareData.paymentAddress; - if (shareData.paymentID) { - userIdentifier = userIdentifier + "." + shareData.paymentID; - } + const userIdentifier = shareData.paymentID ? userIdentifier + "." + shareData.paymentID : shareData.paymentAddress; if (!(userIdentifier in paymentData)) { paymentData[userIdentifier] = { pool_type: 'pplns', @@ -594,6 +588,24 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); }); + global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { + if (Object.keys(paymentData).length == rows.length) { + Object.keys(rows).forEach(function (row) { + const userIdentifier = row.payment_id ? row.payment_address + "." + row.payment_id : row.payment_address; + if (userIdentifier in paymentData) { + const amount2 = row.amount * rewardTotal; + if (amount2 / paymentData[userIdentifier].amount < 0.99 || amount2 / paymentData[userIdentifier].amount > 1.01) { + console.error("Block " + block_hex + " has different payment for recipient " + userIdentifier + ": " + amount2 + " -> " + paymentData[userIdentifier].amount); + } + } else { + console.error("Block " + block_hex + " has unkown payment recipient " + userIdentifier); + } + }); + } else { + console.error("Block " + block_hex + " has different number of precomputed payments " + rows.length + " vs " + Object.keys(paymentData).length + " now"); + } + }); + console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); if (is_need_correction) { console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); @@ -827,7 +839,7 @@ function blockPayments(block) { return; } paymentInProgress = true; - calculatePPLNSPayments(block.height, block.value, block.difficulty, function() { + calculatePPLNSPayments(block.hash, block.height, block.value, block.difficulty, function() { console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockBlock(block.hash); }); @@ -868,7 +880,7 @@ function altblockPayments(block, cb) { return cb(); } paymentInProgress = true; - calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty, function() { + calculatePPLNSPayments(block.hash, block.anchor_height, block.pay_value, anchor_header.difficulty, function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); }); From 968de3108d091ecc345cc4ae1b3f4d051b4a6673 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 21:16:27 -0700 Subject: [PATCH 0466/1496] Fixed bug --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e05203d98..5d0922a41 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -347,7 +347,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do return; } if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { - const userIdentifier = shareData.paymentID ? userIdentifier + "." + shareData.paymentID : shareData.paymentAddress; + const userIdentifier = shareData.paymentID ? shareData.paymentAddress + "." + shareData.paymentID : shareData.paymentAddress; if (!(userIdentifier in paymentData)) { paymentData[userIdentifier] = { pool_type: 'pplns', @@ -505,7 +505,7 @@ function calculatePPLNSPayments(block_hex, block_height, block_reward, block_dif return; } if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { - const userIdentifier = shareData.paymentID ? userIdentifier + "." + shareData.paymentID : shareData.paymentAddress; + const userIdentifier = shareData.paymentID ? shareData.paymentAddress + "." + shareData.paymentID : shareData.paymentAddress; if (!(userIdentifier in paymentData)) { paymentData[userIdentifier] = { pool_type: 'pplns', From d5a242f18a71832ebc70ddaf0d6cc035f349ee31 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 21:21:50 -0700 Subject: [PATCH 0467/1496] Fixed bug --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 5d0922a41..209860b7a 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -601,6 +601,7 @@ function calculatePPLNSPayments(block_hex, block_height, block_reward, block_dif console.error("Block " + block_hex + " has unkown payment recipient " + userIdentifier); } }); + console.log("Block " + block_hex + " pre calc payment was valided"); } else { console.error("Block " + block_hex + " has different number of precomputed payments " + rows.length + " vs " + Object.keys(paymentData).length + " now"); } From 903aefe6c4f3ae0b5035e4ef7dd2c21277220971 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 21:29:52 -0700 Subject: [PATCH 0468/1496] Fixed bug --- lib/blockManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 209860b7a..9b46819eb 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -582,14 +582,16 @@ function calculatePPLNSPayments(block_hex, block_height, block_reward, block_dif const is_need_correction = Math.abs(totalPayments/default_window - 1) > 0.0001; const pay_window = is_need_correction ? totalPayments : default_window; + let paymentDataCount = 0; Object.keys(paymentData).forEach(function (key) { + if (paymentData[key].amount) ++ paymentDataCount; paymentData[key].amount = Math.floor((paymentData[key].amount / pay_window) * rewardTotal); balanceQueue.push(paymentData[key], function () {}); //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); }); global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { - if (Object.keys(paymentData).length == rows.length) { + if (paymentDataCount == rows.length) { Object.keys(rows).forEach(function (row) { const userIdentifier = row.payment_id ? row.payment_address + "." + row.payment_id : row.payment_address; if (userIdentifier in paymentData) { @@ -603,7 +605,7 @@ function calculatePPLNSPayments(block_hex, block_height, block_reward, block_dif }); console.log("Block " + block_hex + " pre calc payment was valided"); } else { - console.error("Block " + block_hex + " has different number of precomputed payments " + rows.length + " vs " + Object.keys(paymentData).length + " now"); + console.error("Block " + block_hex + " has different number of precomputed payments " + rows.length + " vs " + paymentDataCount + " now"); } }); From 3cd99763f2dd3031fd0fa06d0bcbfa5fb138ebb3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 21:36:48 -0700 Subject: [PATCH 0469/1496] Fixed bug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 9b46819eb..63909a608 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -592,7 +592,7 @@ function calculatePPLNSPayments(block_hex, block_height, block_reward, block_dif global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (paymentDataCount == rows.length) { - Object.keys(rows).forEach(function (row) { + rows.forEach(function (row) { const userIdentifier = row.payment_id ? row.payment_address + "." + row.payment_id : row.payment_address; if (userIdentifier in paymentData) { const amount2 = row.amount * rewardTotal; From 1ea920a9ad417fe9af5b0bc14a7408bac0cafd32 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 21:44:13 -0700 Subject: [PATCH 0470/1496] Fixed bug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 63909a608..7415fc40d 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -595,7 +595,7 @@ function calculatePPLNSPayments(block_hex, block_height, block_reward, block_dif rows.forEach(function (row) { const userIdentifier = row.payment_id ? row.payment_address + "." + row.payment_id : row.payment_address; if (userIdentifier in paymentData) { - const amount2 = row.amount * rewardTotal; + const amount2 = Math.floor(row.amount * rewardTotal); if (amount2 / paymentData[userIdentifier].amount < 0.99 || amount2 / paymentData[userIdentifier].amount > 1.01) { console.error("Block " + block_hex + " has different payment for recipient " + userIdentifier + ": " + amount2 + " -> " + paymentData[userIdentifier].amount); } From 2b41f2dd7c9d9d8fddd44936d850e5455f2ef088 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 22:23:01 -0700 Subject: [PATCH 0471/1496] Moved to precalc block rewards --- lib/blockManager.js | 247 +++++++++----------------------------------- 1 file changed, 46 insertions(+), 201 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 7415fc40d..b482db557 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -92,15 +92,13 @@ let createBalanceQueue = async.queue(function (task, callback) { }, 1); let balanceQueue = async.queue(function (task, callback) { - let pool_type = task.pool_type; - let payment_address = task.payment_address; - let payment_id = null; - if (typeof(task.payment_id) !== 'undefined' && task.payment_id !== null && task.payment_id.length > 10){ - payment_id = task.payment_id; - } + const pool_type = task.pool_type; + const bitcoin = task.bitcoin; + const amount = task.amount; + const payment_address = task.payment_address; + let payment_id = null; + if (typeof(task.payment_id) !== 'undefined' && task.payment_id !== null && task.payment_id.length > 10) payment_id = task.payment_id; task.payment_id = payment_id; - let bitcoin = task.bitcoin; - let amount = task.amount; debug("Processing balance increment task: " + JSON.stringify(task)); async.waterfall([ function (intCallback) { @@ -155,7 +153,7 @@ function full_stop(err) { } let block_unlock_callback = null; -let prev_balance_sum = null; +let prev_balance_sum = null; balanceQueue.drain = function () { if (!paymentInProgress) { @@ -320,9 +318,9 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do paymentData[keyAdd].amount += valueAdd; const totalPaid2 = totalShares / windowPPLNS * rewardTotal; if (totalPaid2 > rewardTotal) { // totalPaid can not overflow rewardTotal now - console.log("Value totalPaid " + totalPaid + " reached max " + rewardTotal); + //console.log("Value totalPaid " + totalPaid + " reached max " + rewardTotal); const extra = (totalPaid2 - rewardTotal) / rewardTotal * windowPPLNS; - console.log("Rewarded " + (valueAdd - extra) + " instead of " + valueAdd + " hashes for " + keyAdd); + //console.log("Rewarded " + (valueAdd - extra) + " instead of " + valueAdd + " hashes for " + keyAdd); paymentData[keyAdd].amount -= extra; totalPaid = rewardTotal; } else { @@ -429,194 +427,39 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do }); } }); - }); -} - -function calculatePPLNSPayments(block_hex, block_height, block_reward, block_difficulty, unlock_callback) { - const rewardTotal = block_reward; - console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal)); - const blockDiff = block_difficulty; - const windowPPLNS = blockDiff * global.config.pplns.shareMulti; - - let blockCheckHeight = block_height; - let totalPaid = 0; - let totalShares = 0; - let paymentData = {}; - paymentData[global.config.payout.feeAddress] = { - pool_type: 'fees', - payment_address: global.config.payout.feeAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - paymentData[global.coinFuncs.coinDevAddress] = { - pool_type: 'fees', - payment_address: global.coinFuncs.coinDevAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - paymentData[global.coinFuncs.poolDevAddress] = { - pool_type: 'fees', - payment_address: global.coinFuncs.poolDevAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - function addPayment(keyAdd, valueAdd) { - if (valueAdd === 0) return; - if (totalPaid >= rewardTotal) return; - totalShares += valueAdd; - paymentData[keyAdd].amount += valueAdd; - let totalPaid2 = totalShares / windowPPLNS * rewardTotal; - if (totalPaid2 + 1 < rewardTotal) { // totalPaid can not overflow rewardTotal now - totalPaid = totalPaid2; - } else { // we need recalculate totalPaid precisely now - totalPaid = 0; - Object.keys(paymentData).forEach(function (key) { - totalPaid += Math.floor(paymentData[key].amount / windowPPLNS * rewardTotal); - }); - console.log("Aproximate totalPaid " + totalPaid2 + " was reset to precise value " + totalPaid); - if (totalPaid >= rewardTotal) { - console.log("Precise value totalPaid " + totalPaid + " reached max " + rewardTotal); - let extra = (totalPaid - rewardTotal) / rewardTotal * windowPPLNS; - console.log("Rewarded " + (valueAdd - extra) + " instead of " + valueAdd + " hashes for " + keyAdd); - paymentData[keyAdd].amount -= extra; - totalPaid = rewardTotal; - } + console.log("PPLNS payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); + if (is_need_correction) { + console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); + global.support.sendEmail(global.config.general.adminEmail, + "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", + "PPLNS payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + + "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" + ); } - }; - - let portShares = {}; - let firstShareTime; - let lastShareTime; - - async.doWhilst(function (callback) { - let txn = global.database.env.beginTxn({readOnly: true}); - let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - for (let found = (cursor.goToRange(blockCheckHeight) === blockCheckHeight); found; found = cursor.goToNextDup()) { - cursor.getCurrentBinary(function (key, data) { // jshint ignore:line - let shareData; - try { - shareData = global.protos.Share.decode(data); - } catch (e) { - console.error(e); - return; - } - if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { - const userIdentifier = shareData.paymentID ? shareData.paymentAddress + "." + shareData.paymentID : shareData.paymentAddress; - if (!(userIdentifier in paymentData)) { - paymentData[userIdentifier] = { - pool_type: 'pplns', - payment_address: shareData.paymentAddress, - payment_id: shareData.paymentID, - bitcoin: shareData.bitcoin, - amount: 0 - }; - } - - if (!firstShareTime) firstShareTime = shareData.timestamp; - if (totalPaid < rewardTotal) lastShareTime = shareData.timestamp; - - let amountToPay = shareData.shares2; - let feesToPay = amountToPay * (global.config.payout.pplnsFee / 100) + - (shareData.bitcoin === true ? amountToPay * (global.config.payout.btcFee / 100) : 0); - let devDonation = feesToPay * (global.config.payout.devDonation / 100); - let poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); - - addPayment(userIdentifier, amountToPay - feesToPay); - addPayment(global.config.payout.feeAddress, feesToPay - devDonation - poolDevDonation); - addPayment(global.coinFuncs.poolDevAddress, poolDevDonation); - addPayment(global.coinFuncs.coinDevAddress, devDonation); + }); +} - if (typeof(shareData.port) !== 'undefined') { - if (shareData.port in portShares) { - portShares[shareData.port] += amountToPay; - } else { - portShares[shareData.port] = amountToPay; - } - } - } - }); - } - cursor.close(); - txn.abort(); - setImmediate(callback, null, totalPaid); - }, function (totalPayment) { - blockCheckHeight = blockCheckHeight - 1; - debug("Decrementing the block chain check height to:" + blockCheckHeight); - if (totalPayment >= rewardTotal) { - debug("Loop 1: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); - return false; - } else { - debug("Loop 2: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); - return blockCheckHeight !== 0; - } - }, function (err) { - let sumAllPorts = 0; - for (let port in portShares) sumAllPorts += portShares[port]; - let pplns_port_shares = {}; - for (let port in portShares) { - const port_share = portShares[port] / sumAllPorts; - pplns_port_shares[port] = port_share; - console.log("Port " + port + ": " + (100.0 * port_share).toFixed(2) + "%"); +function doPPLNSPayments(block_hex, block_reward, unlock_callback) { + console.log("Performing PPLNS payout of block " + block_hex + " with value " + global.support.coinToDecimal(block_reward)); + global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { + if (typeof(rows[0]) === 'undefined' || typeof(rows[0].amt) === 'undefined') { + console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); + return; } - global.database.setCache('pplns_port_shares', pplns_port_shares); - global.database.setCache('pplns_window_time', (firstShareTime - lastShareTime) / 1000); - - global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { - if (typeof(rows[0]) === 'undefined' || typeof(rows[0].amt) === 'undefined') { - console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); - return; - } - prev_balance_sum = rows[0].amt; - block_unlock_callback = unlock_callback; - - let totalPayments = 0; - Object.keys(paymentData).forEach(function (key) { - totalPayments += paymentData[key].amount; - }); - - const default_window = blockDiff*global.config.pplns.shareMulti; - const is_need_correction = Math.abs(totalPayments/default_window - 1) > 0.0001; - const pay_window = is_need_correction ? totalPayments : default_window; - - let paymentDataCount = 0; - Object.keys(paymentData).forEach(function (key) { - if (paymentData[key].amount) ++ paymentDataCount; - paymentData[key].amount = Math.floor((paymentData[key].amount / pay_window) * rewardTotal); - balanceQueue.push(paymentData[key], function () {}); - //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); - }); - - global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { - if (paymentDataCount == rows.length) { - rows.forEach(function (row) { - const userIdentifier = row.payment_id ? row.payment_address + "." + row.payment_id : row.payment_address; - if (userIdentifier in paymentData) { - const amount2 = Math.floor(row.amount * rewardTotal); - if (amount2 / paymentData[userIdentifier].amount < 0.99 || amount2 / paymentData[userIdentifier].amount > 1.01) { - console.error("Block " + block_hex + " has different payment for recipient " + userIdentifier + ": " + amount2 + " -> " + paymentData[userIdentifier].amount); - } - } else { - console.error("Block " + block_hex + " has unkown payment recipient " + userIdentifier); - } - }); - console.log("Block " + block_hex + " pre calc payment was valided"); - } else { - console.error("Block " + block_hex + " has different number of precomputed payments " + rows.length + " vs " + paymentDataCount + " now"); - } - }); - - console.log("PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); - if (is_need_correction) { - console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); - global.support.sendEmail(global.config.general.adminEmail, - "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", - "PPLNS payout cycle complete on block: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + - "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Block Value: " + global.support.coinToDecimal(rewardTotal) + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" - ); + prev_balance_sum = rows[0].amt; + + global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { + if (rows.length) { + block_unlock_callback = unlock_callback; + rows.forEach(function (row) { + row.amount = Math.floor(row.amount * block_reward); + row.pool_type = "pplns"; + row.bitcoin = 0; + balanceQueue.push(row, function () {}); + }); + } else { + console.error("Block " + block_hex + " has no payments in SQL"); } }); }); @@ -734,12 +577,13 @@ function blockUnlocker() { return; } if (topBlockHeight - block.height <= 5) return; + const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; if (body.hash !== block.hash) { global.database.invalidateBlock(block.height); //global.mysql.query("UPDATE block_log SET orphan = true WHERE hex = ?", [block.hash]); //blockIDCache.splice(blockIDCache.indexOf(block.height)); console.log("Invalidating block " + block.height + " due to being an orphan block"); - } else if (block.poolType == global.protos.POOLTYPE.PPLNS && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { payReadyBlockHashCalc[block.hash] = 1; preCalculatePPLNSPayments(block.hash, block.height, block.difficulty, function(status) { if (status) { @@ -747,7 +591,7 @@ function blockUnlocker() { global.database.payReadyBlock(block.hash); } }); - } else if (topBlockHeight - block.height > global.config.payout.blocksRequired /*&& (block.poolType != global.protos.POOLTYPE.PPLNS || block.pay_ready === true)*/) { + } else if (topBlockHeight - block.height > global.config.payout.blocksRequired && (!is_pplns_block || block.pay_ready === true)) { blockPayments(block); } }); @@ -789,11 +633,12 @@ function altblockUnlocker() { return next(); } if (topBlockHeight - block.anchor_height <= 5) return next(); + const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; if (body.hash !== block.hash) { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); return next(); - } else if (block.poolType == global.protos.POOLTYPE.PPLNS && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; @@ -809,7 +654,7 @@ function altblockUnlocker() { return next(); } }); - } else if (true/*(block.poolType != global.protos.POOLTYPE.PPLNS || block.pay_ready === true)*/) { + } else if (!is_pplns_block || block.pay_ready === true) { if (block.pay_value !== 0) { altblockPayments(block, function() { next(); } ); } else { @@ -842,7 +687,7 @@ function blockPayments(block) { return; } paymentInProgress = true; - calculatePPLNSPayments(block.hash, block.height, block.value, block.difficulty, function() { + doPPLNSPayments(block.hash, block.value, function() { console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockBlock(block.hash); }); @@ -883,7 +728,7 @@ function altblockPayments(block, cb) { return cb(); } paymentInProgress = true; - calculatePPLNSPayments(block.hash, block.anchor_height, block.pay_value, anchor_header.difficulty, function() { + doPPLNSPayments(block.hash, block.pay_value, function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); }); From d07d9e855329694f6363d0407eca8fdc50bf838d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Apr 2019 22:49:04 -0700 Subject: [PATCH 0472/1496] Fixed bug --- lib/blockManager.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index b482db557..3c98189c8 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -656,12 +656,14 @@ function altblockUnlocker() { }); } else if (!is_pplns_block || block.pay_ready === true) { if (block.pay_value !== 0) { - altblockPayments(block, function() { next(); } ); + altblockPayments(block, function() { return next(); } ); } else { if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; blockHeightWait[block.port].push(block.height); return next(); } + } else { + return next(); } }); }, function() { From 70eeac3e6aaf76758a12d8da60c1f8380647e390 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 08:59:55 -0700 Subject: [PATCH 0473/1496] Added SUMO support --- lib/coins/xmr.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1230d0a2e..2327dfd32 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -31,7 +31,8 @@ const port2coin = { "33124": "XTNC", "34568": "WOW", "38081": "MSR", - "48782": "LTHN" + "48782": "LTHN", + "19734": "SUMO" }; const port2blob_num = { "11181": 0, // AEON @@ -47,6 +48,7 @@ const port2blob_num = { "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN + "19734": 0, // SUMO }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); const mm_port_set = { "22023": 11898, "33124": 11898 }; @@ -378,10 +380,10 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; - else if ("cn" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn"]; - else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/4"]; - else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/wow"]; + if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; + else if ("cn" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn"]; + else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/4"]; + else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/wow"]; if (!("" in coin_perf)) return "algo-perf set must include cn or cn/r hashrate"; @@ -424,6 +426,7 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 13, height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft + case 19734: return multiHashing.cryptonight(convertedBlob, 13, height); // SUMO case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube @@ -456,6 +459,7 @@ function Coin(data){ case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/r"; // XMR case 18981: return "cn/rwz"; // Graft + case 19734: return "cn/r"; // SUMO case 20189: return "cn/half"; // Stellite case 22023: return "cn-pico/trtl"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube From fa754a933d47b6b091593b8ffc09026b2518c939 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 09:43:44 -0700 Subject: [PATCH 0474/1496] Do reward precalc even if coin daemon is down --- lib/blockManager.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 3c98189c8..6155cb0a3 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -627,14 +627,14 @@ function altblockUnlocker() { } const topBlockHeight = body.height; async.eachSeries(blockList, function(block, next) { + if (topBlockHeight - block.anchor_height <= 5) return next(); + const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { - if (err !== null) { + const is_valid_request = (err === null); + if (!is_valid_request) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); - return next(); } - if (topBlockHeight - block.anchor_height <= 5) return next(); - const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - if (body.hash !== block.hash) { + if (is_valid_request && body.hash !== block.hash) { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); return next(); @@ -654,7 +654,7 @@ function altblockUnlocker() { return next(); } }); - } else if (!is_pplns_block || block.pay_ready === true) { + } else if (is_valid_request && (!is_pplns_block || block.pay_ready === true)) { if (block.pay_value !== 0) { altblockPayments(block, function() { return next(); } ); } else { From 59949c796775e9907c318bd808084f685cb5a855 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 09:56:26 -0700 Subject: [PATCH 0475/1496] Added ability to clean shares form locked block but that were already has pay_ready flag set --- lib/local_comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index a221c1dbc..5eda1f805 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -708,7 +708,7 @@ function Database(){ for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); - if (blockData.unlocked === false){ + if (blockData.unlocked === false && blockData.pay_ready !== true){ if (oldestLockedBlockHeight === null || oldestLockedBlockHeight > blockData.anchor_height) { oldestLockedBlockHeight = blockData.anchor_height; } @@ -723,7 +723,7 @@ function Database(){ cursor.getCurrentBinary(function(key, data){ // jshint ignore:line if (oldestLockedBlockHeight !== null && oldestLockedBlockHeight <= key) return; let blockData = global.protos.Block.decode(data); - if (blockData.unlocked === false) { + if (blockData.unlocked === false && blockData.pay_ready !== true) { oldestLockedBlockHeight = key; } }); From 12138d7bf06bdeac469ace71bde5d52e3ec63ede Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 10:20:44 -0700 Subject: [PATCH 0476/1496] Fixed cleaning to take into account shares2 --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 5eda1f805..e3a1e98ce 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -844,7 +844,7 @@ function Database(){ try{ let shareData = global.protos.Share.decode(data); if (shareData.poolType === global.protos.POOLTYPE.PPLNS){ - shareCount += shareData.shares; + shareCount += shareData.shares2; } } catch(e){ console.error("Invalid share"); From e193c27863ede30c23c519cb4c9c2df7e15acb8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=88=86=E4=B9=8B=E4=B8=80?= Date: Tue, 23 Apr 2019 01:25:23 +0800 Subject: [PATCH 0477/1496] fix create block_balance symbol issue --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index a9a0237cf..847444866 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -27,7 +27,7 @@ CREATE TABLE `block_balance` ( UNIQUE KEY `block_balance_id_uindex` (`id`), UNIQUE KEY `block_balance_hex_payment_address_payment_id_uindex` (`hex`, `payment_address`,`payment_id`), KEY `block_balance_hex_index` (`hex`), - KEY `block_balance_payment_address_payment_id_index` (`payment_address`,`payment_id`), + KEY `block_balance_payment_address_payment_id_index` (`payment_address`,`payment_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `bans` ( `id` int(11) NOT NULL AUTO_INCREMENT, From c1328c3f8df1400700f83a33292158aa53918700 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 10:29:52 -0700 Subject: [PATCH 0478/1496] Added SUMO support --- deployment/base.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 847444866..e01520d52 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -202,6 +202,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'port', '18081', 'int', 'Monero Daemon RPC Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePort', '18081', 'int', 'Main coin active daemon RPC port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortRYO', '0', 'int', 'Ryo coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortSUMO', '0', 'int', 'SUMO coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLOKI', '0', 'int', 'Loki coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXRN', '0', 'int', 'Saronite coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTNC', '0', 'int', 'XtencCash coin daemon RPC port or 0'); @@ -215,6 +216,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortGRFT', '0', 'int', 'Graft coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXRN', '0', 'float', 'Saronite algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTNC', '0', 'float', 'XtendCash algo hash price factor relative to coinHashFactor'); From d31696e4d644f4fa21eb307682de5c9be7aa2021 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 10:37:34 -0700 Subject: [PATCH 0479/1496] Updated XTL names --- deployment/base.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index e01520d52..af99cb322 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -211,7 +211,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXHV', '0', 'int', 'Haven coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortAEON', '0', 'int', 'Aeon coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortMSR', '0', 'int', 'Masari coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTL', '0', 'int', 'Stellite coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTC', '0', 'int', 'Torque coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLTHN', '0', 'int', 'Lethean coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortGRFT', '0', 'int', 'Graft coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); @@ -225,7 +225,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXHV', '0', 'float', 'Haven algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorAEON', '0', 'float', 'Aeon algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorMSR', '0', 'float', 'Masari algo hash price factor relative to coinHashFactor'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTL', '0', 'float', 'Stellite algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTC', '0', 'float', 'Torque algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLTHN', '0', 'float', 'Lethean algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorGRFT', '0', 'float', 'Graft algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTRTL', '0', 'float', 'Turtle algo hash price factor relative to coinHashFactor'); @@ -275,7 +275,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11181', '', 'string', 'Address to mine to for 11181 (Aeon) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_17750', '', 'string', 'Address to mine to for 17750 (Haven) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_24182', '', 'string', 'Address to mine to for 24182 (BitTube) port.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Stellite) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Torque) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_22023', '', 'string', 'Address to mine to for 22023 (Loki) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_31014', '', 'string', 'Address to mine to for 31014 (Saronite) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_33124', '', 'string', 'Address to mine to for 33124 (XtendCash) port.'); From 548bb5be5f0c3618c9aad85449107264239b77a8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 15:42:52 -0700 Subject: [PATCH 0480/1496] Updated hashing utils version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c0d132bf..8053ef29c 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.2" } } From 9c2fa4e88a7122f9dd09e0c29ea6c3cacaeefbb1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Apr 2019 20:28:53 -0700 Subject: [PATCH 0481/1496] Added functionality for batch block trades --- lib/local_comms.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index e3a1e98ce..b1543775f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -511,6 +511,21 @@ function Database(){ txn.commit(); }; + this.moveAltBlockReward = function(srcBlockId, dstBlockId){ + this.refreshEnv(); + let txn = this.env.beginTxn(); + let srcBlockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, srcBlockId)); + let dstBlockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, dstBlockId)); + dstBlockData.value += srcBlockData.value; + srcBlockData.value = 0; + srcBlockData.pay_stage = "Payed by other block"; + srcBlockData.pay_status = "Will be payed by block " + dstBlockData.hash + " on " + dstBlockData.height + " height"; + srcBlockData.unlocked = true; + txn.putBinary(this.altblockDB, srcBlockId, global.protos.AltBlock.encode(srcBlockData)); + txn.putBinary(this.altblockDB, dstBlockId, global.protos.AltBlock.encode(dstBlockData)); + txn.commit(); + }; + this.changeAltBlockPayValue = function(blockId, pay_value){ this.refreshEnv(); let txn = this.env.beginTxn(); From 4ccf79c16a2a6b23a3c9b6c455c5a49d9585d10c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Apr 2019 01:34:04 -0700 Subject: [PATCH 0482/1496] Added functionality for batch block trades --- lib/local_comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index b1543775f..593646884 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -511,12 +511,12 @@ function Database(){ txn.commit(); }; - this.moveAltBlockReward = function(srcBlockId, dstBlockId){ + this.moveAltBlockReward = function(srcBlockId, dstBlockId, srcAmount){ this.refreshEnv(); let txn = this.env.beginTxn(); let srcBlockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, srcBlockId)); let dstBlockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, dstBlockId)); - dstBlockData.value += srcBlockData.value; + dstBlockData.value += srcAmount; srcBlockData.value = 0; srcBlockData.pay_stage = "Payed by other block"; srcBlockData.pay_status = "Will be payed by block " + dstBlockData.hash + " on " + dstBlockData.height + " height"; From 9041730a68db587551b14b3adc1c33deccb7e648 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Apr 2019 01:51:16 -0700 Subject: [PATCH 0483/1496] Added functionality for batch block trades --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 6155cb0a3..1d1734921 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -722,7 +722,7 @@ function altblockPayments(block, cb) { switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { - if (err === null && block.height === header.height && block.value === header.reward && block.difficulty === header.difficulty){ + if (err === null && block.height === header.height && block.value >= header.reward && block.difficulty === header.difficulty){ global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ if (paymentInProgress) { From 153d9d04a7f5f9e84a1ac3f04c8a9fb9f331eed8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Apr 2019 11:25:15 -0700 Subject: [PATCH 0484/1496] Fixed port usage --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 6a0d732da..f28b0d2fc 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -866,7 +866,7 @@ function monitorNodes() { if (Math.abs(block.height - row.blockID) > 3) { global.support.sendEmail(global.config.general.adminEmail, "Pool server behind in blocks", - "The pool server: " + row.hostname + " with IP: " + row.ip + " is " + (block.height - row.blockID) + " blocks behind for " + port + " port" + "The pool server: " + row.hostname + " with IP: " + row.ip + " is " + (block.height - row.blockID) + " blocks behind for " + row.port + " port" ); } else { is_master_daemon_issue = false; From b6ac358ec5939a1a1bb202860807507248c4b318 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 May 2019 12:55:31 -0700 Subject: [PATCH 0485/1496] Fixed late block reward calc --- lib/blockManager.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1d1734921..19ca3c2eb 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -410,6 +410,23 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do totalPayments += paymentData[key].amount; }); + if (totalPayments == 0) { + console.warn("This PPLNS payout cycle complete on block was redone for top height: " + block_height); + global.support.sendEmail(global.config.general.adminEmail, + "Warning: No shares to pay block, so it was corrected by using the top height", + "PPLNS payout cycle complete on block: " + block_height + ); + global.coinFuncs.getLastBlockHeader(function(err, body){ + if (err !== null) { + console.error("Last block header request failed!"); + return done_callback(false); + } + const topBlockHeight = body.height; + return preCalculatePPLNSPayments(block_hex, topBlockHeight, block_difficulty, done_callback); + }); + return; + } + const default_window = blockDiff*global.config.pplns.shareMulti; const is_need_correction = Math.abs(totalPayments/default_window - 1) > 0.0001; const pay_window = is_need_correction ? totalPayments : default_window; From 2ff89f0ff004bb59ebdb92e93d6ce9b5e0f0f4ff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Jun 2019 14:02:13 -0700 Subject: [PATCH 0486/1496] Resolve crash if no miner trust is used --- lib/blockManager.js | 6 +++--- lib/pool.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 19ca3c2eb..3a04482bf 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -411,10 +411,10 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do }); if (totalPayments == 0) { - console.warn("This PPLNS payout cycle complete on block was redone for top height: " + block_height); + console.warn("PPLNS payout cycle for " + block_hex + " block does not have any shares so will be redone using top height"); global.support.sendEmail(global.config.general.adminEmail, - "Warning: No shares to pay block, so it was corrected by using the top height", - "PPLNS payout cycle complete on block: " + block_height + "FYI: No shares to pay block, so it was corrected by using the top height", + "PPLNS payout cycle for " + block_hex + " block does not have any shares so will be redone using top height" ); global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { diff --git a/lib/pool.js b/lib/pool.js index 7c844bc44..b553404b3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1367,7 +1367,7 @@ function processShare(miner, job, blockTemplate, params) { if (hash.toString('hex') !== resultHash) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (miner.trust.trust == 0 ? " [banned]" : "")); + console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (global.config.pool.trustedMiners && miner.trust.trust == 0 ? " [banned]" : "")); lastMinerLogTime[miner.payout] = time_now; } return invalid_share(miner); From 93cef13643df6f1a8e122c5abb71b6f0d2dbf448 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Jun 2019 15:55:08 -0700 Subject: [PATCH 0487/1496] Correctly process MSR uncle reward --- lib/coins/xmr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2327dfd32..ceb8b6441 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -186,8 +186,10 @@ function Coin(data){ const reward = body2.result.transfer.amount; if (reward !== reward_check) { - console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); - return callback(true, body); + if (!(port == 38081 && reward < reward_check)) { // MSR can have uncle block reward here + console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); + return callback(true, body); + } } body.result.block_header.reward = reward; From c3a85125a67f6139a6ec8ca9ad9bca9c19ad0c63 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 17 Jun 2019 10:47:56 -0700 Subject: [PATCH 0488/1496] Added RandomWOW support --- lib/coins/xmr.js | 42 +++++++++++++++++++++--------------------- lib/pool.js | 6 +++--- package.json | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ceb8b6441..94f5f4dac 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -297,6 +297,7 @@ function Coin(data){ this.blocktemplate_blob = template.blocktemplate_blob; this.difficulty = template.difficulty; this.height = template.height; + this.seed_hash = template.seed_hash; this.coin = template.coin; this.port = template.port; @@ -385,7 +386,6 @@ function Coin(data){ if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; else if ("cn" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn"]; else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/4"]; - else if ("cn/wow" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/wow"]; if (!("" in coin_perf)) return "algo-perf set must include cn or cn/r hashrate"; @@ -395,7 +395,7 @@ function Coin(data){ if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; - if ("cn/wow" in algos_perf) coin_perf["WOW"] = algos_perf["cn/wow"]; + if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; @@ -420,25 +420,25 @@ function Coin(data){ return algos.includes("cn/r") ? true : "algo array must include cn/r"; } - this.cryptoNight = function(convertedBlob, port, height) { - switch (port) { - case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon - case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL - case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO - case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, 13, height); // XMR - case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft - case 19734: return multiHashing.cryptonight(convertedBlob, 13, height); // SUMO - case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite - case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI - case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash - case 34568: return multiHashing.cryptonight(convertedBlob, 12, height); // Wownero - case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, 13, height); // Lethean + this.cryptoNight = function(convertedBlob, blockTemplate) { + switch (blockTemplate.port) { + case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon + case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL + case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO + case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven + case 18081: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR + case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft + case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO + case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite + case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI + case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube + case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash + case 34568: return multiHashing.random_wow(convertedBlob, Buffer.from(blockTemplate.seed_hash)); // Wownero + case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR + case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean default: - console.error("Unknown " + port + " port for PoW type on " + height + " height"); - return multiHashing.cryptonight(convertedBlob, 8); + console.error("Unknown " + blockTemplate.port + " port for PoW type"); + return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); } } @@ -466,7 +466,7 @@ function Coin(data){ case 22023: return "cn-pico/trtl"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 33124: return "cn-pico/trtl"; // XtendCash - case 34568: return "cn/wow"; // Wownero + case 34568: return "rx/wow"; // Wownero case 38081: return "cn/half"; // MSR case 48782: return "cn/r"; // Lethean default: diff --git a/lib/pool.js b/lib/pool.js index b553404b3..0d99d4b18 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1246,7 +1246,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); + const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } @@ -1337,7 +1337,7 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (shareBuffer !== null) { let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); + const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); if (hash2.toString('hex') !== resultHash) { console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); } @@ -1362,7 +1362,7 @@ function processShare(miner, job, blockTemplate, params) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (shareBuffer === null) return invalid_share(miner); let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port, blockTemplate.height); + hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); if (hash.toString('hex') !== resultHash) { let time_now = Date.now(); diff --git a/package.json b/package.json index 8053ef29c..ea4d7c6c6 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v9.0.2" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v10.0.0" } } From e5198f610dfaa5ada8a4f720d762236b87362b83 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 17 Jun 2019 11:02:02 -0700 Subject: [PATCH 0489/1496] Added seed_hash to miner jobs --- lib/pool.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0d99d4b18..9c0646a70 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -945,19 +945,21 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, + seed_hash: bt.seed_hash, difficulty: this.difficulty, coinHashFactor: params.coinHashFactor, submissions: {} }; this.validJobs.enq(newJob); this.cachedJob = { - blob: blob, - algo: params.algo_name, - variant: params.variant_name, - height: bt.height, - job_id: newJob.id, - target: getTargetHex(this.difficulty), - id: this.id + blob: blob, + algo: params.algo_name, + variant: params.variant_name, + height: bt.height, + seed_hash: bt.seed_hash, + job_id: newJob.id, + target: getTargetHex(this.difficulty), + id: this.id }; } else { const blob = bt.nextBlobWithChildNonce(); @@ -967,6 +969,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, + seed_hash: bt.seed_hash, difficulty: this.difficulty, clientPoolLocation: bt.clientPoolLocation, clientNonceLocation: bt.clientNonceLocation, @@ -981,6 +984,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer variant: params.variant_name, difficulty: bt.difficulty, height: bt.height, + seed_hash: bt.seed_hash, reserved_offset: bt.reserved_offset, client_nonce_offset: bt.clientNonceLocation, client_pool_offset: bt.clientPoolLocation, From ea095a2bfcabf6629a9f50f0911b4f8a8d9f61d9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 17 Jun 2019 11:19:33 -0700 Subject: [PATCH 0490/1496] Moveed recommended version of XNP up --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 94f5f4dac..5d4b208bc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -544,8 +544,8 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 801) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.8.1+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new cn/r Monero algo before March 9 Monero fork"; + if (version < 1000) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.10.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/wow algo"; } } else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; From 6a5823b75359794ed8b7a902a01592aff3db720f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 17 Jun 2019 14:57:38 -0700 Subject: [PATCH 0491/1496] Removed variant --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9c0646a70..827829970 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -391,7 +391,7 @@ function getCoinJobParams(coin) { params.bt = activeBlockTemplates[coin]; params.coinHashFactor = currCoinHashFactorMM[coin]; params.algo_name = global.coinFuncs.algoShortTypeStr(params.bt.port, params.bt.buffer[0]); - params.variant_name = params.algo_name.split('/')[1]; + //params.variant_name = params.algo_name.split('/')[1]; return params; }; @@ -954,7 +954,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.cachedJob = { blob: blob, algo: params.algo_name, - variant: params.variant_name, + //variant: params.variant_name, height: bt.height, seed_hash: bt.seed_hash, job_id: newJob.id, @@ -981,7 +981,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer blocktemplate_blob: blob, blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), algo: params.algo_name, - variant: params.variant_name, + //variant: params.variant_name, difficulty: bt.difficulty, height: bt.height, seed_hash: bt.seed_hash, From 24e23d50c49b3edd8185beda38f789b43d0f5840 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 17 Jun 2019 15:02:08 -0700 Subject: [PATCH 0492/1496] Added hex format to buffer conversion --- lib/coins/xmr.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5d4b208bc..d3efc3f4e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -422,20 +422,20 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, blockTemplate) { switch (blockTemplate.port) { - case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon - case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL - case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO - case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR - case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft - case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO - case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite - case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI - case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash - case 34568: return multiHashing.random_wow(convertedBlob, Buffer.from(blockTemplate.seed_hash)); // Wownero - case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean + case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon + case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL + case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO + case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven + case 18081: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR + case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft + case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO + case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite + case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI + case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube + case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash + case 34568: return multiHashing.random_wow(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex')); // Wownero + case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR + case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean default: console.error("Unknown " + blockTemplate.port + " port for PoW type"); return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); From b858b7f5701b70fb513c3b8a87d2f38355ba6cff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 01:47:04 -0700 Subject: [PATCH 0493/1496] Fixed undefined case --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index f28b0d2fc..b3c619252 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -679,8 +679,8 @@ function updatePoolPorts(poolServers) { if (local_counts[portData.port] === Object.keys(poolServers).length) { local_cache.global.push({ host: { - blockID: local_cache[pool_type][0].host.blockID, - blockIDTime: local_cache[pool_type][0].host.blockIDTime, + blockID: typeof(local_cache[pool_type][0].host) === 'undefined' ? 0 : local_cache[pool_type][0].host.blockID, + blockIDTime: typeof(local_cache[pool_type][0].host) === 'undefined' ? 0 : local_cache[pool_type][0].host.blockIDTime, hostname: global.config.pool.geoDNS, }, port: portData.port, From 3be3c6a735566f3f28d8cdae27f52718d0a363f3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 13:21:42 -0700 Subject: [PATCH 0494/1496] Added block balance table cleaner --- lib/longRunner.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/longRunner.js b/lib/longRunner.js index 47d93eec6..d7b826c10 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -67,9 +67,38 @@ function cleanCacheDB() { console.log("Deleted cache items: " + count); } +let saw_block_hash_before = {}; + +function cleanBlockBalanceTable() { + console.log("Cleaning up the block balance table"); + + let locked_block_hashes = {}; + global.database.getValidLockedBlocks().forEach(function (block) { locked_block_hashes[block.hash] = 1; }); + global.database.getValidLockedAltBlocks().forEach(function (block) { locked_block_hashes[block.hash] = 1; }); + + let deleted_row_count = 0; + global.mysql.query("SELECT DISTINCT hex FROM block_balance").then(function (rows) { + rows.forEach(function (row) { + if (row.hash in locked_block_hashes) { + console.log("Block hash is currently locked: " + row.hash); return; + } + if (row.hash in saw_block_hash_before) { + //global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [row.hash]).then(function () {}); + delete saw_block_hash_before[row.hash]; + ++ deleted_row_count; + } else { + saw_block_hash_before[row.hash] = 1; + } + }); + }); + + console.log("Finished cleaning the block balance table. Removed " + deleted_row_count + " rows."); +} + console.log("Cleaning up the share DB"); global.database.cleanShareDB(); cleanCacheDB(); +cleanBlockBalanceTable(); setInterval(function(){ console.log("Cleaning up the share DB"); @@ -80,3 +109,8 @@ setInterval(function(){ setInterval(function(){ cleanCacheDB(); }, 24*60*60*1000); + +// clean block balance table +setInterval(function(){ + cleanBlockBalanceTable(); +}, 60*1000); From 9c98ec96f28afdfa0d461a8f09440db93ab67cfa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 13:31:27 -0700 Subject: [PATCH 0495/1496] Added block balance table cleaner --- lib/longRunner.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index d7b826c10..da4396cf3 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -79,15 +79,15 @@ function cleanBlockBalanceTable() { let deleted_row_count = 0; global.mysql.query("SELECT DISTINCT hex FROM block_balance").then(function (rows) { rows.forEach(function (row) { - if (row.hash in locked_block_hashes) { - console.log("Block hash is currently locked: " + row.hash); return; + if (row.hex in locked_block_hashes) { + console.log("Block hash is currently locked: " + row.hex); return; } - if (row.hash in saw_block_hash_before) { - //global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [row.hash]).then(function () {}); - delete saw_block_hash_before[row.hash]; + if (row.hex in saw_block_hash_before) { + //global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [row.hex]).then(function () {}); + delete saw_block_hash_before[row.hex]; ++ deleted_row_count; } else { - saw_block_hash_before[row.hash] = 1; + saw_block_hash_before[row.hex] = 1; } }); }); From e19e008007cacf5ec5367d5094ad3df9860bffc3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 13:34:33 -0700 Subject: [PATCH 0496/1496] Added block balance table cleaner --- lib/longRunner.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index da4396cf3..df916d942 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -90,9 +90,8 @@ function cleanBlockBalanceTable() { saw_block_hash_before[row.hex] = 1; } }); + console.log("Finished cleaning the block balance table. Removed " + deleted_row_count + " rows."); }); - - console.log("Finished cleaning the block balance table. Removed " + deleted_row_count + " rows."); } console.log("Cleaning up the share DB"); From c582233ffef0d5217ef813cacdb482b025b7d76f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 13:36:50 -0700 Subject: [PATCH 0497/1496] Added block balance table cleaner --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index df916d942..efb4279df 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -83,7 +83,7 @@ function cleanBlockBalanceTable() { console.log("Block hash is currently locked: " + row.hex); return; } if (row.hex in saw_block_hash_before) { - //global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [row.hex]).then(function () {}); + global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [row.hex]).then(function () {}); delete saw_block_hash_before[row.hex]; ++ deleted_row_count; } else { From 69facfde9a31de98197318a77d915fe49e1d9921 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 13:43:22 -0700 Subject: [PATCH 0498/1496] Added block balance table cleaner --- lib/longRunner.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index efb4279df..7731733ec 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -69,6 +69,10 @@ function cleanCacheDB() { let saw_block_hash_before = {}; +let cleanBlockBalanceTableQueue = async.queue(function (task, callback) { + global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [task.hex]).then(function () { return callback(true); }); +}, 10); + function cleanBlockBalanceTable() { console.log("Cleaning up the block balance table"); @@ -83,7 +87,7 @@ function cleanBlockBalanceTable() { console.log("Block hash is currently locked: " + row.hex); return; } if (row.hex in saw_block_hash_before) { - global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [row.hex]).then(function () {}); + cleanBlockBalanceTableQueue.push(row, function () {}); delete saw_block_hash_before[row.hex]; ++ deleted_row_count; } else { From 78559d8c2746a989d8a834f9acf56e268d41ad63 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 13:43:44 -0700 Subject: [PATCH 0499/1496] Added block balance table cleaner --- lib/longRunner.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/longRunner.js b/lib/longRunner.js index 7731733ec..d1fd86aef 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -1,5 +1,7 @@ "use strict"; +const async = require("async"); + function cleanCacheDB() { console.log("Cleaning up the cache DB"); let count = 0; From c4452afb2d710514549da235c15a1a7f8773c31a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 20 Jun 2019 13:48:45 -0700 Subject: [PATCH 0500/1496] Added block balance table cleaner --- lib/longRunner.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index d1fd86aef..d3630fdde 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -85,9 +85,7 @@ function cleanBlockBalanceTable() { let deleted_row_count = 0; global.mysql.query("SELECT DISTINCT hex FROM block_balance").then(function (rows) { rows.forEach(function (row) { - if (row.hex in locked_block_hashes) { - console.log("Block hash is currently locked: " + row.hex); return; - } + if (row.hex in locked_block_hashes) return; if (row.hex in saw_block_hash_before) { cleanBlockBalanceTableQueue.push(row, function () {}); delete saw_block_hash_before[row.hex]; @@ -118,4 +116,4 @@ setInterval(function(){ // clean block balance table setInterval(function(){ cleanBlockBalanceTable(); -}, 60*1000); +}, 24*60*60*1000); From 0140b6f583ce340a63dd171c22165999c0a21c91 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 10:02:33 -0700 Subject: [PATCH 0501/1496] Some general improvements --- deployment/monero_daemon.patch | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 deployment/monero_daemon.patch diff --git a/deployment/monero_daemon.patch b/deployment/monero_daemon.patch deleted file mode 100644 index e98c4b85f..000000000 --- a/deployment/monero_daemon.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp -index 5dfbc1d..1e0487a 100644 ---- a/src/cryptonote_core/tx_pool.cpp -+++ b/src/cryptonote_core/tx_pool.cpp -@@ -1093,7 +1093,7 @@ namespace cryptonote - LockedTXN lock(m_blockchain); - - auto sorted_it = m_txs_by_fee_and_receive_time.begin(); -- while (sorted_it != m_txs_by_fee_and_receive_time.end()) -+ while (sorted_it != m_txs_by_fee_and_receive_time.end() && bl.tx_hashes.size() <= 120) - { - txpool_tx_meta_t meta; - if (!m_blockchain.get_txpool_tx_meta(sorted_it->second, meta)) From 1a9473b00350391c508450ead292f37981f6554f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 10:03:10 -0700 Subject: [PATCH 0502/1496] Some general improvements --- deployment/deploy.bash | 20 ++----- deployment/deploy_test.bash | 16 ++---- deployment/leaf.bash | 22 ++------ deployment/monero.service | 2 +- deployment/monero_test.service | 2 +- deployment/upgrade_monero.bash | 6 +-- lib/pool.js | 98 ++++++++++++++-------------------- 7 files changed, 58 insertions(+), 108 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index bec022194..0caec38ce 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -16,27 +16,15 @@ sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again p echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libcap2-bin git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev cd ~ -git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. -#cd /usr/src/gtest -#sudo cmake . -#sudo make -#sudo mv libg* /usr/lib/ -cd ~ +git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.14.0.0 -#curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v -USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) -sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.14.0.0_/release/bin/* /usr/local/src/monero/build/release/bin +sudo git checkout v0.14.1.0 +sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon -#BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) -#sudo -u monerodaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw https://downloads.getmonero.org/blockchain.raw -#sudo -u monerodaemon /usr/local/src/monero/build/release/bin/monero-blockchain-import --input-file $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw --batch-size 20000 --database lmdb#fastest --data-dir /home/monerodaemon/.bitmonero -#sudo -u monerodaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR sudo systemctl daemon-reload sudo systemctl enable monero sudo systemctl start monero @@ -85,7 +73,7 @@ rm -rf $CADDY_DOWNLOAD_DIR cd ~ sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.11.3/bin `pwd`/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` cd ~/nodejs-pool -sudo chown -R $CURUSER. ~/.pm2 +sudo chown -R $CURUSER ~/.pm2 echo "Installing pm2-logrotate in the background!" pm2 install pm2-logrotate & mysql -u root --password=$ROOT_SQL_PASS < deployment/base.sql diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 9d797b0fc..826d52179 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -16,19 +16,13 @@ sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again p echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev mysql-server lmdb-utils libzmq3-dev cd ~ -git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. -cd /usr/src/gtest -sudo cmake . -sudo make -sudo mv libg* /usr/lib/ -cd ~ +git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp cd /usr/local/src -sudo git clone https://github.com/monero-project/monero.git +sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout release-v0.12 -curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v -sudo make -j$(nproc) +sudo git checkout v0.14.1.0 +sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon sudo systemctl daemon-reload @@ -79,7 +73,7 @@ rm -rf $CADDY_DOWNLOAD_DIR cd ~ sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.11.3/bin `pwd`/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` cd ~/nodejs-pool -sudo chown -R $CURUSER. ~/.pm2 +sudo chown -R $CURUSER ~/.pm2 echo "Installing pm2-logrotate in the background!" pm2 install pm2-logrotate & mysql -u root --password=$ROOT_SQL_PASS < deployment/base.sql diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 06a71e8a0..294ec678d 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -10,29 +10,17 @@ CURUSER=$(whoami) sudo timedatectl set-timezone Etc/UTC sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libzmq3-dev libsodium-dev -cd ~ -git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. -#cd /usr/src/gtest -#sudo cmake . -#sudo make -#sudo mv libg* /usr/lib/ +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install ntp build-essential cmake pkg-config libboost-all-dev libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev doxygen graphviz libpgm-dev cd ~ +git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.14.0.0 -#curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v -USE_SINGLE_BUILDDIR=1 sudo make -j$(nproc) -sudo mkdir -p /usr/local/src/monero/build/release/bin -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.14.0.0_/release/bin/* /usr/local/src/monero/build/release/bin +sudo git checkout v0.14.1.0 +sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon -#BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u monerodaemon mktemp -d) -#sudo -u monerodaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw https://downloads.getmonero.org/blockchain.raw -#sudo -u monerodaemon /usr/local/src/monero/build/release/bin/monero-blockchain-import --input-file $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.raw --batch-size 20000 --database lmdb#fastest --data-dir /home/monerodaemon/.bitmonero -#sudo -u monerodaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR sudo systemctl daemon-reload sudo systemctl enable monero sudo systemctl start monero @@ -46,7 +34,7 @@ npm install -g pm2 openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.pool" -newkey rsa:2048 -nodes -keyout cert.key -x509 -out cert.pem -days 36500 cd ~ sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.11.3/bin `pwd`/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` -sudo chown -R $CURUSER. ~/.pm2 +sudo chown -R $CURUSER ~/.pm2 echo "Installing pm2-logrotate in the background!" pm2 install pm2-logrotate echo "You're setup with a leaf node! Congrats" diff --git a/deployment/monero.service b/deployment/monero.service index a1ad70d6e..86fcb3694 100644 --- a/deployment/monero.service +++ b/deployment/monero.service @@ -5,7 +5,7 @@ After=network.target [Service] Type=forking GuessMainPID=no -ExecStart=/usr/local/src/monero/build/release/bin/monerod --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc +ExecStart=/usr/local/src/monero/build/release/bin/monerod --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc --prune-blockchain Restart=always User=monerodaemon diff --git a/deployment/monero_test.service b/deployment/monero_test.service index d6a20b1e4..e2f508f80 100644 --- a/deployment/monero_test.service +++ b/deployment/monero_test.service @@ -5,7 +5,7 @@ After=network.target [Service] Type=forking GuessMainPID=no -ExecStart=/usr/local/src/monero/build/release/bin/monerod --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc --testnet +ExecStart=/usr/local/src/monero/build/release/bin/monerod --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc --testnet --prune-blockchain Restart=always User=monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index b73083597..bf87951d1 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,11 +6,9 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.14.0.0 &&\ +sudo git checkout v0.14.1.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ -USE_SINGLE_BUILDDIR=1 sudo nice make &&\ -sudo mkdir -p /usr/local/src/monero/build/release/bin &&\ -sudo cp /usr/local/src/monero/build/Linux/_HEAD_detached_at_v0.14.0.0_/release/bin/* /usr/local/src/monero/build/release/bin &&\ +(sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make) &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" diff --git a/lib/pool.js b/lib/pool.js index 827829970..9cebebdaa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -83,7 +83,7 @@ function registerPool() { global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { rows.forEach(function (row) { if (row.ip !== global.config.bind_ip) { - console.error("Pool ID in use already for a different IP. Update MySQL or change pool ID."); + console.error("Pool ID in use already for a different IP. Update MySQL or change pool ID."); process.exit(1); } }); @@ -592,19 +592,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // 2) check stuff if (diffSplit.length > 2) { - this.error = "Too many options in the login field"; + this.error = "Too many options in the login field. Please use monero_address[.payment_id][+difficulty_number] format"; this.valid_miner = false; return; } if (pass_split.length > 2) { - this.error = "Too many options in the password field"; + this.error = "Too many options in the password field. Please use worker_name[:email] format"; this.valid_miner = false; return; } if (this.payout in bannedAddresses) { // Banned Address - this.error = "Banned payment address provided: " + bannedAddresses[this.payout]; + this.error = "Permanently banned payment address provided: " + bannedAddresses[this.payout]; this.valid_miner = false; return; } @@ -617,16 +617,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (global.coinFuncs.validateAddress(this.address)) { this.bitcoin = 0; - } else if (btcValidator.validate(this.address)) { - if (global.config.general.allowBitcoin && global.coinFuncs.supportsAutoExchange) { - this.bitcoin = 1; - } else { - this.error = "This pool does not allow payouts to bitcoin"; - this.valid_miner = false; - return; - } + } else if (global.config.general.allowBitcoin && global.coinFuncs.supportsAutoExchange && btcValidator.validate(this.address)) { + this.bitcoin = 1; } else { - this.error = "Invalid payment address provided: " + this.address; + this.error = "Invalid payment address provided: " + this.address + ". Please use monero_address[.payment_id][+difficulty_number] format"; this.valid_miner = false; return; } @@ -901,23 +895,30 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.checkBan = function (validShare) { - if (!global.config.pool.banEnabled) { - return; - } + if (!global.config.pool.banEnabled) return; // Valid stats are stored by the pool. if (validShare) { - ++ this.validShares; + ++ this.validShares; } else { - ++ this.invalidShares; + if (this.validShares === 0) { + console.error(threadName + "Suspended miner IP for submitting bad share with zero trust " + this.logString); + removeMiner(this); + process.send({type: 'banIP', data: this.ipAddress}); + return; + } + ++ this.invalidShares; } - if (this.validShares + this.invalidShares >= global.config.pool.banThreshold) { - if (this.invalidShares / this.validShares >= global.config.pool.banPercent / 100) { + + const shareCount = this.validShares + this.invalidShares; + if (shareCount >= global.config.pool.banThreshold) { + if (100 * this.invalidShares / shareCount >= global.config.pool.banPercent) { + console.error(threadName + "Suspended miner IP for submitting too many bad shares recently " + this.logString); removeMiner(this); process.send({type: 'banIP', data: this.ipAddress}); } else { this.invalidShares = 0; - this.validShares = 0; + this.validShares = 0; } } }; @@ -1371,7 +1372,7 @@ function processShare(miner, job, blockTemplate, params) { if (hash.toString('hex') !== resultHash) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (global.config.pool.trustedMiners && miner.trust.trust == 0 ? " [banned]" : "")); + console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); lastMinerLogTime[miner.payout] = time_now; } return invalid_share(miner); @@ -1423,7 +1424,7 @@ function processShare(miner, job, blockTemplate, params) { } else if (hashDiff.lt(job.difficulty)) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString + (miner.trust.trust == 0 ? " [banned]" : "")); + console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString); lastMinerLogTime[miner.payout] = time_now; } return invalid_share(miner); @@ -1445,9 +1446,6 @@ let lastMinerLogTime = {}; // Miner notification times let lastMinerNotifyTime = {}; -// Share times of miners (payout:identifier:ipAddress) that never submitted any good share -let badMinerLastShareTime = {}; - function get_miner_notification(payout) { if (payout in notifyAddresses) return notifyAddresses[payout]; return false; @@ -1457,14 +1455,14 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply // Check for ban here, so preconnected attackers can't continue to screw you if (ip in bannedIPs) { // Handle IP ban off clip. - sendFinalReply("IP Address currently banned"); + sendFinalReply("This IP address is temporarily suspended from mining", 60); return; } let miner; switch (method) { case 'login': if (!params.login) { - sendFinalReply("No login specified"); + sendFinalReply("No login specified", 10); return; } if (!params.pass) params.pass = "x"; @@ -1481,20 +1479,11 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); lastMinerLogTime[miner.payout] = time_now; } - sendFinalReply(miner.error); + sendFinalReply(miner.error, 10); return; } let miner_id = miner.payout + ":" + miner.identifier + ":" + miner.ipAddress; - if (miner_id in badMinerLastShareTime) { - let ban_time_left = 3*60*1000 - (time_now - badMinerLastShareTime[miner_id]); - if (ban_time_left > 0) { - sendFinalReply("You miner " + miner.identifier + " is currently banned for submitting wrong result for " + (ban_time_left / 1000) + " seconds"); - return; - } else { - debug(threadName + "Removed miner " + miner.logString + " from ban"); - delete badMinerLastShareTime[miner_id]; - } - } + let miner_agent_notification = params.agent ? global.coinFuncs.get_miner_agent_notification(params.agent) : false; let miner_notification = miner_agent_notification ? miner_agent_notification : global.coinFuncs.get_miner_agent_warning_notification(params.agent); miner_notification = miner_notification ? miner_notification : get_miner_notification(miner.payout); @@ -1502,7 +1491,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_notification); - sendFinalReply(miner_notification + " (miner will connect after several attempts)"); + sendFinalReply(miner_notification + " (miner will connect after several attempts)", 10); return; } } @@ -1511,7 +1500,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); } - sendFinalReply(miner_agent_notification); + sendFinalReply(miner_agent_notification, 10); return; } @@ -1655,15 +1644,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (shareAccepted) { miner.trust.trust += job.rewarded_difficulty2; miner.trust.check_height = 0; - } else { - if (miner.trust.trust == 0) { - badMinerLastShareTime[miner.payout + ":" + miner.identifier + ":" + miner.ipAddress] = Date.now(); - debug(threadName + "Banned miner for some time " + miner.logString); - removeMiner(miner); - sendReply('Low difficulty share'); - return; - } debug(threadName + "Share trust broken by " + miner.logString); miner.storeInvalidShare(); miner.trust.trust = 0; @@ -1882,7 +1863,7 @@ if (cluster.isMaster) { setInterval(retargetMiners, global.config.pool.retargetTime * 1000); setInterval(function () { bannedIPs = {}; - }, 60*1000); + }, 10*60*1000); function add_bans(is_show) { global.mysql.query("SELECT mining_address, reason FROM bans").then(function (rows) { @@ -2002,14 +1983,15 @@ if (cluster.isMaster) { }) + "\n"; socket.write(sendData); }; - let sendFinalReply = function (error) { - let sendData = JSON.stringify({ - id: jsonData.id, - jsonrpc: "2.0", - error: {code: -1, message: error}, - result: null - }) + "\n"; - socket.end(sendData); + let sendFinalReply = function (error, delay_time) { + setTimeout(function() { + socket.end(JSON.stringify({ + id: jsonData.id, + jsonrpc: "2.0", + error: {code: -1, message: error}, + result: null + }) + "\n"); + }, delay_time); }; handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); }; From e2fba15e69fa4f451d1562ac8fa8147105c12d52 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 20:50:42 -0700 Subject: [PATCH 0503/1496] Fixed delay time --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9cebebdaa..64517f4a4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1991,7 +1991,7 @@ if (cluster.isMaster) { error: {code: -1, message: error}, result: null }) + "\n"); - }, delay_time); + }, delay_time * 1000); }; handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); }; From cd0c90a4f906a5268d807aecf4efb68f8638d99f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 21:31:33 -0700 Subject: [PATCH 0504/1496] Reduced ban message timeout --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 64517f4a4..579d9bdaa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1455,7 +1455,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply // Check for ban here, so preconnected attackers can't continue to screw you if (ip in bannedIPs) { // Handle IP ban off clip. - sendFinalReply("This IP address is temporarily suspended from mining", 60); + sendFinalReply("This IP address is temporarily suspended from mining", 20); return; } let miner; From ec4bd693b19e8fe82409064400a1caf6e0cb1021 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 21:38:30 -0700 Subject: [PATCH 0505/1496] Better socker error reporting --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 579d9bdaa..df7cd58f3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2061,7 +2061,7 @@ if (cluster.isMaster) { } }).on('error', function (err) { if (err.code !== 'ECONNRESET') { - console.warn(threadName + "Socket Error from " + socket.remoteAddress + " Error: " + err); + console.warn(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); } }).on('close', function () { pushMessage = function () { From f27ecf655f4b493659e7aa47590f65367c439cef Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 21:40:27 -0700 Subject: [PATCH 0506/1496] Reduced ban message timeout --- lib/pool.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index df7cd58f3..023717f82 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1455,14 +1455,14 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply // Check for ban here, so preconnected attackers can't continue to screw you if (ip in bannedIPs) { // Handle IP ban off clip. - sendFinalReply("This IP address is temporarily suspended from mining", 20); + sendFinalReply("This IP address is temporarily suspended from mining"); return; } let miner; switch (method) { case 'login': if (!params.login) { - sendFinalReply("No login specified", 10); + sendFinalReply("No login specified"); return; } if (!params.pass) params.pass = "x"; @@ -1479,7 +1479,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); lastMinerLogTime[miner.payout] = time_now; } - sendFinalReply(miner.error, 10); + sendFinalReply(miner.error); return; } let miner_id = miner.payout + ":" + miner.identifier + ":" + miner.ipAddress; @@ -1491,7 +1491,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_notification); - sendFinalReply(miner_notification + " (miner will connect after several attempts)", 10); + sendFinalReply(miner_notification + " (miner will connect after several attempts)"); return; } } @@ -1500,7 +1500,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); } - sendFinalReply(miner_agent_notification, 10); + sendFinalReply(miner_agent_notification); return; } @@ -1983,7 +1983,7 @@ if (cluster.isMaster) { }) + "\n"; socket.write(sendData); }; - let sendFinalReply = function (error, delay_time) { + let sendFinalReply = function (error) { setTimeout(function() { socket.end(JSON.stringify({ id: jsonData.id, @@ -1991,7 +1991,7 @@ if (cluster.isMaster) { error: {code: -1, message: error}, result: null }) + "\n"); - }, delay_time * 1000); + }, 9 * 1000); }; handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); }; From f7afbb29c1c643c44432e39ac540c9da342ac233 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 21:42:53 -0700 Subject: [PATCH 0507/1496] Better socker error reporting --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 023717f82..5af1ed279 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2060,7 +2060,7 @@ if (cluster.isMaster) { dataBuffer = incomplete; } }).on('error', function (err) { - if (err.code !== 'ECONNRESET') { + if (err.code !== 'ECONNRESET' && err.code !== 'EPIPE') { console.warn(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); } }).on('close', function () { From 07ce1b8dd215d935a606c206b4695456e9871916 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 23:14:41 -0700 Subject: [PATCH 0508/1496] Better socker error reporting --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5af1ed279..7362e6bb2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2060,7 +2060,7 @@ if (cluster.isMaster) { dataBuffer = incomplete; } }).on('error', function (err) { - if (err.code !== 'ECONNRESET' && err.code !== 'EPIPE') { + if (err.code !== 'ECONNRESET' && err.code !== 'EPIPE' && err.code !== 'ETIMEDOUT') { console.warn(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); } }).on('close', function () { From 43acfe7d707cf852004f20090f8935b5d2231543 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 23 Jun 2019 23:19:07 -0700 Subject: [PATCH 0509/1496] Better socker error reporting --- lib/pool.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7362e6bb2..0b82c86de 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2060,9 +2060,7 @@ if (cluster.isMaster) { dataBuffer = incomplete; } }).on('error', function (err) { - if (err.code !== 'ECONNRESET' && err.code !== 'EPIPE' && err.code !== 'ETIMEDOUT') { - console.warn(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); - } + debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { pushMessage = function () { }; From ccfb4ed9eb093498a74de8dde8dd0d63c4259464 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Jul 2019 09:59:13 -0700 Subject: [PATCH 0510/1496] Reduce bad block email freq --- lib/worker.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index b3c619252..550014bf2 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -823,26 +823,27 @@ function updateWalletStats() { function bad_header_start(port) { console.error("Issue in getting block header for " + port + " port. Skipping node monitor"); - if (!(port in lastBlockCheckIsFailed)) { - lastBlockCheckIsFailed[port] = 1; - global.support.sendEmail( + if (port in lastBlockCheckIsFailed) { + if (++ lastBlockCheckIsFailed[port] >= 5) global.support.sendEmail( global.config.general.adminEmail, 'Failed to query daemon for ' + port + ' port for last block header', `The worker failed to return last block header for ` + port + ` port. Please verify if the daemon is running properly.` ); + } else { + lastBlockCheckIsFailed[port] = 1; } return; } function bad_header_stop(port) { if (port in lastBlockCheckIsFailed) { - delete lastBlockCheckIsFailed[port]; - global.support.sendEmail( + if (lastBlockCheckIsFailed[port] >= 5) global.support.sendEmail( global.config.general.adminEmail, 'Quering daemon for ' + port + ' port for last block header is back to normal', `An warning was sent to you indicating that the the worker failed to return the last block header for ${port} port. The issue seems to be solved now.` ); + delete lastBlockCheckIsFailed[port]; } } From 200b7fc055c58ef14d86528baece0de45e918529 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Jul 2019 12:21:02 -0700 Subject: [PATCH 0511/1496] Updated daemon version --- deployment/upgrade_monero.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index bf87951d1..cf884b875 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.14.1.0 &&\ +sudo git checkout v0.14.1.2 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From c3d64f45ad84f07ad6e5ee1158886d905d0fb129 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Jul 2019 12:32:54 -0700 Subject: [PATCH 0512/1496] Added clarification about ban length --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 0b82c86de..558f03c6d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1455,7 +1455,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply // Check for ban here, so preconnected attackers can't continue to screw you if (ip in bannedIPs) { // Handle IP ban off clip. - sendFinalReply("This IP address is temporarily suspended from mining"); + sendFinalReply("This IP address is temporarily suspended from mining (10 minutes max)"); return; } let miner; From 4f023a99d389546783bcba54a1baf92a72985d56 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Jul 2019 10:25:50 -0700 Subject: [PATCH 0513/1496] Added RX/Loki support --- lib/coins/xmr.js | 24 +++++++++++++----------- package.json | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d3efc3f4e..a091efc68 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -51,7 +51,7 @@ const port2blob_num = { "19734": 0, // SUMO }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); -const mm_port_set = { "22023": 11898, "33124": 11898 }; +const mm_port_set = { "33124": 11898 }; const fix_daemon_sh = "./fix_daemon.sh"; @@ -383,9 +383,9 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/r"]; - else if ("cn" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn"]; - else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = coin_perf["WOW"] = algos_perf["cn/4"]; + if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; + else if ("cn" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn"]; + else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/4"]; if (!("" in coin_perf)) return "algo-perf set must include cn or cn/r hashrate"; @@ -397,6 +397,8 @@ function Coin(data){ if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; + if ("rx/loki" in algos_perf) coin_perf["LOKI"] = algos_perf["rx/loki"]; + if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; if ("cn-heavy" in algos_perf) coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; @@ -409,8 +411,8 @@ function Coin(data){ if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; - if ("cn-pico" in algos_perf) coin_perf["XTNC"] = coin_perf["LOKI"] = coin_perf["TRTL"] = algos_perf["cn-pico"]; - else if ("cn-pico/trtl" in algos_perf) coin_perf["XTNC"] = coin_perf["LOKI"] = coin_perf["TRTL"] = algos_perf["cn-pico/trtl"]; + if ("cn-pico" in algos_perf) coin_perf["XTNC"] = coin_perf["TRTL"] = algos_perf["cn-pico"]; + else if ("cn-pico/trtl" in algos_perf) coin_perf["XTNC"] = coin_perf["TRTL"] = algos_perf["cn-pico/trtl"]; return coin_perf; } @@ -430,10 +432,10 @@ function Coin(data){ case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite - case 22023: return multiHashing.cryptonight_pico(convertedBlob, 0); // LOKI + case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki // LOKI case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash - case 34568: return multiHashing.random_wow(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex')); // Wownero + case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean default: @@ -463,7 +465,7 @@ function Coin(data){ case 18981: return "cn/rwz"; // Graft case 19734: return "cn/r"; // SUMO case 20189: return "cn/half"; // Stellite - case 22023: return "cn-pico/trtl"; // LOKI + case 22023: return "rx/loki"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 33124: return "cn-pico/trtl"; // XtendCash case 34568: return "rx/wow"; // Wownero @@ -544,8 +546,8 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 1000) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.10.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/wow algo"; + if (version < 1100) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.11.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/loki algo"; } } else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; diff --git a/package.json b/package.json index ea4d7c6c6..131e29c71 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v10.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v11.0.0" } } From 061b5d725cba32e10bcc836a245321f3d3fe90c1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Jul 2019 10:23:42 -0700 Subject: [PATCH 0514/1496] Do not diconnect existing miners during IP bans --- lib/pool.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 558f03c6d..43b2554bf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1452,15 +1452,13 @@ function get_miner_notification(payout) { } function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { - // Check for ban here, so preconnected attackers can't continue to screw you - if (ip in bannedIPs) { - // Handle IP ban off clip. - sendFinalReply("This IP address is temporarily suspended from mining (10 minutes max)"); - return; - } let miner; switch (method) { case 'login': + if (ip in bannedIPs) { + sendFinalReply("New connections from this IP address are temporarily suspended from mining (10 minutes max)"); + return; + } if (!params.login) { sendFinalReply("No login specified"); return; From fd1fcad537d4d35602b37d77c5eda5d3ac73b963 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Aug 2019 09:46:22 -0700 Subject: [PATCH 0515/1496] Updated block value --- manage_scripts/altblock_revalidate.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manage_scripts/altblock_revalidate.js b/manage_scripts/altblock_revalidate.js index 576eac5bc..4c6bbee57 100644 --- a/manage_scripts/altblock_revalidate.js +++ b/manage_scripts/altblock_revalidate.js @@ -26,6 +26,8 @@ require("../init_mini.js").init(function() { } blockData.valid = true; blockData.unlocked = false; + if (blockData.value != body.reward) console.log("Changing alt-block vlaue from " + blockData.value + " to " + body.reward); + blockData.value = body.reward; txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); cursor.close(); txn.commit(); From c1ec42338263a569c7adbd02ee78b74f68618f71 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sun, 4 Aug 2019 23:35:10 +0300 Subject: [PATCH 0516/1496] ReferenceError: port is not defined --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 550014bf2..52ea3cb0d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -851,7 +851,7 @@ function monitorNodes() { global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { global.coinFuncs.getPortLastBlockHeader(global.config.daemon.port, function (err, block) { if (err !== null){ - bad_header_start(port); + bad_header_start(global.config.daemon.port); return; } bad_header_stop(); From d8a833f754b9cfad9eca295d37a24596112ad45b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Aug 2019 13:49:55 -0700 Subject: [PATCH 0517/1496] Added XLA support --- lib/coins/xmr.js | 13 +++++++------ lib/pool.js | 6 ++++++ package.json | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a091efc68..c3253ccce 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -389,9 +389,10 @@ function Coin(data){ if (!("" in coin_perf)) return "algo-perf set must include cn or cn/r hashrate"; - if ("cn/half" in algos_perf) coin_perf["MSR"] = coin_perf["XTC"] = algos_perf["cn/half"]; - else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = coin_perf["XTC"] = algos_perf["cn/fast2"]; - else if ("cn/xtlv9" in algos_perf) coin_perf["XTC"] = algos_perf["cn/xtlv9"]; + if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; + else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; + + if ("defyx" in algos_perf) coin_perf["XTC"] = algos_perf["defyx"]; if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; @@ -431,8 +432,8 @@ function Coin(data){ case 18081: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO - case 20189: return multiHashing.cryptonight(convertedBlob, 9); // Stellite - case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki // LOKI + case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala + case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero @@ -464,7 +465,7 @@ function Coin(data){ case 18081: return "cn/r"; // XMR case 18981: return "cn/rwz"; // Graft case 19734: return "cn/r"; // SUMO - case 20189: return "cn/half"; // Stellite + case 20189: return "defyx"; // Scala case 22023: return "rx/loki"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube case 33124: return "cn-pico/trtl"; // XtendCash diff --git a/lib/pool.js b/lib/pool.js index 43b2554bf..6d6573a5c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1309,6 +1309,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi // wallets that need extra share verification let extra_wallet_verify = {}; +let extra_verify_wallet_hashes = []; function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { const reward_diff2 = reward_diff * global.config.pool.trustThreshold; @@ -1345,6 +1346,8 @@ function processShare(miner, job, blockTemplate, params) { const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); if (hash2.toString('hex') !== resultHash) { console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); + } else { + extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(blockTemplate.port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); } } else { console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); @@ -1946,6 +1949,9 @@ if (cluster.isMaster) { console.log("WILL EXTRA CHECK WALLET: '" + line + "'"); extra_wallet_verify[line] = 1; }); + const fn = "extra_verify_wallet_hashes_" + cluster.worker.id.toString(); + fs.writeFile(fn, extra_verify_wallet_hashes.join("\n"), function(err) { if (err) console.error("Error saving " + fn + " file"); }); + extra_verify_wallet_hashes = []; }); }, 5*60*1000); diff --git a/package.json b/package.json index 131e29c71..048d0f2f4 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v11.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v12.0.0" } } From 28f9749a90842992416b76eb91b2447d60bda373 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Aug 2019 19:11:11 -0700 Subject: [PATCH 0518/1496] Check block headers --- manage_scripts/get_block_header.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 manage_scripts/get_block_header.js diff --git a/manage_scripts/get_block_header.js b/manage_scripts/get_block_header.js new file mode 100644 index 000000000..a02732c08 --- /dev/null +++ b/manage_scripts/get_block_header.js @@ -0,0 +1,14 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.port) { + console.error("Please specify port"); + process.exit(1); +} +const port = argv.port; + +global.coinFuncs.getPortLastBlockHeader(port, function (err_header, body_header) { + console.log(JSON.stringify(err_header)); + console.log(JSON.stringify(body_header)); +}); From 6aef6dbc14533ce0090a385a711e845635b166fe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 16 Aug 2019 00:05:16 -0700 Subject: [PATCH 0519/1496] Extra scripts --- manage_scripts/get_block_header.js | 9 ++++++--- manage_scripts/get_block_height.js | 23 +++++++++++++++++++++++ manage_scripts/get_block_template.js | 17 +++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 manage_scripts/get_block_height.js create mode 100644 manage_scripts/get_block_template.js diff --git a/manage_scripts/get_block_header.js b/manage_scripts/get_block_header.js index a02732c08..4f576074f 100644 --- a/manage_scripts/get_block_header.js +++ b/manage_scripts/get_block_header.js @@ -8,7 +8,10 @@ if (!argv.port) { } const port = argv.port; -global.coinFuncs.getPortLastBlockHeader(port, function (err_header, body_header) { - console.log(JSON.stringify(err_header)); - console.log(JSON.stringify(body_header)); +require("../init_mini.js").init(function() { + global.coinFuncs.getPortLastBlockHeader(port, function (err_header, body_header) { + console.log("err:" + JSON.stringify(err_header)); + console.log("body:" + JSON.stringify(body_header)); + process.exit(0); + }); }); diff --git a/manage_scripts/get_block_height.js b/manage_scripts/get_block_height.js new file mode 100644 index 000000000..297877d2d --- /dev/null +++ b/manage_scripts/get_block_height.js @@ -0,0 +1,23 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.port) { + console.error("Please specify port"); + process.exit(1); +} +const port = argv.port; + +if (!argv.height) { + console.error("Please specify height"); + process.exit(1); +} +const height = argv.height; + +require("../init_mini.js").init(function() { + global.coinFuncs.getPortBlockHeaderByID(port, height, function (err_header, body_header) { + console.log("err:" + JSON.stringify(err_header)); + console.log("body:" + JSON.stringify(body_header)); + process.exit(0); + }); +}); diff --git a/manage_scripts/get_block_template.js b/manage_scripts/get_block_template.js new file mode 100644 index 000000000..c2fc7f8f0 --- /dev/null +++ b/manage_scripts/get_block_template.js @@ -0,0 +1,17 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.port) { + console.error("Please specify port"); + process.exit(1); +} +const port = argv.port; + +require("../init_mini.js").init(function() { + global.coinFuncs.getPortBlockTemplate(port, function (err_header, body_header) { + console.log("err:" + JSON.stringify(err_header)); + console.log("body:" + JSON.stringify(body_header)); + process.exit(0); + }); +}); From ed04d621ff43d0bd8741b439a3021f7377bf8ca9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 10:28:47 -0700 Subject: [PATCH 0520/1496] Added coin algo name in API --- lib/coins/xmr.js | 2 ++ lib/worker.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c3253ccce..5ba91cecf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -69,6 +69,7 @@ function get_coins(port2coin) { for (let port in port2coin) if (port2coin[port] != "") coins.push(port2coin[port]); return coins; } +const ports = port2coin.keys(); const coins = get_coins(port2coin); function get_mm_child_port_set(mm_port_set) { let mm_child_port_set = {}; @@ -366,6 +367,7 @@ function Coin(data){ }; }; + this.getPORTS = function() { return ports; } this.getCOINS = function() { return coins; } this.PORT2COIN = function(port) { return port2coin[port]; } this.COIN2PORT = function(coin) { return coin2port[coin]; } diff --git a/lib/worker.js b/lib/worker.js index 52ea3cb0d..7852ccb7c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -602,6 +602,11 @@ function updatePoolStats2(poolType) { //debug(threadName + "Checking LMDB cache for portMinerCount"); return callback(null, global.database.getCache('portMinerCount') || {}); }, + function (callback) { + let portCoinAlgo = {}; + for (let port in global.coinFuncs.getPORTS()) portCoinAlgo[port] = global.coinFuncs.algoShortTypeStr(port, 0); + return callback(null, portCoinAlgo); + }, ], function (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; @@ -632,6 +637,7 @@ function updatePoolStats2(poolType) { pplnsWindowTime: result[21] || 0, portHash: result[22] || {}, portMinerCount: result[23] || {}, + portCoinAlgo: result[24] || {}, }); }); } From e72408e703fcb8a42d6790c45deff384722f6bca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 11:33:51 -0700 Subject: [PATCH 0521/1496] More details about block error --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6d6573a5c..da8388abd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -354,7 +354,7 @@ function templateUpdate(coin, repeating) { } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { - console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); + console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!: " + err); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } From bdd8f8b61cfd2761cc62204e2465883cda196596 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 11:35:02 -0700 Subject: [PATCH 0522/1496] More details about block error --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5ba91cecf..c93b5e40a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -69,7 +69,7 @@ function get_coins(port2coin) { for (let port in port2coin) if (port2coin[port] != "") coins.push(port2coin[port]); return coins; } -const ports = port2coin.keys(); +const ports = []; //port2coin.keys(); const coins = get_coins(port2coin); function get_mm_child_port_set(mm_port_set) { let mm_child_port_set = {}; From d89156f57a7691017a67a2307240f391549cb94e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 12:38:12 -0700 Subject: [PATCH 0523/1496] More details about block error --- lib/pool.js | 2 +- lib/support.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index da8388abd..6d6573a5c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -354,7 +354,7 @@ function templateUpdate(coin, repeating) { } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { - console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!: " + err); + console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } diff --git a/lib/support.js b/lib/support.js index 14f77cd20..44bf6d522 100644 --- a/lib/support.js +++ b/lib/support.js @@ -151,6 +151,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { } else { client.post(path, data, function (err, res, body) { if (err) { + if (typeof(err) === "string") console.error("Error doing " + path + " request: " + err); return callback(err); } debug("JSON result: " + JSON.stringify(body)); From b4c3c00199846008ffa8055b8452e6237bf12b39 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 13:08:32 -0700 Subject: [PATCH 0524/1496] More details about block error --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 44bf6d522..42b8f4799 100644 --- a/lib/support.js +++ b/lib/support.js @@ -151,7 +151,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { } else { client.post(path, data, function (err, res, body) { if (err) { - if (typeof(err) === "string") console.error("Error doing " + path + " request: " + err); + /*if (typeof(err) === "string")*/ console.error("Error doing " + path + " request: " + err); return callback(err); } debug("JSON result: " + JSON.stringify(body)); From 0802066d691d7374887ac46ddec47b663ce75e7e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 14:25:28 -0700 Subject: [PATCH 0525/1496] Restore after bad block header request --- lib/pool.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6d6573a5c..9790fb424 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -336,11 +336,14 @@ function coinHashFactorUpdate(coin, coinHashFactor) { setNewCoinHashFactor(true, coin, coinHashFactor); } +let failedPortLastBlockHeader = {}; + // templateUpdate is only called in master thread (except the beginning of a worker thread) function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; const coinHashFactor = currCoinHashFactor[coin]; - if (activePort && coinHashFactor) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeader)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + delete failedPortLastBlockHeader[coin]; if (activePort !== global.config.daemon["activePort" + coin]) { console.log("Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); @@ -353,14 +356,15 @@ function templateUpdate(coin, repeating) { coinHashFactorUpdate(coin, coinHashFactor); } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); - } else { + } else if (cluster.isMaster) { + failedPortLastBlockHeader[coin] = 1; console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } }); else if (cluster.isMaster) { - coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdate, 1000, coin, repeating); + coinHashFactorUpdate(coin, 0); + setTimeout(templateUpdate, 1000, coin, repeating); } } From 6380d86ba82b15014fef2febc12822cf2ea6f27b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 14:38:08 -0700 Subject: [PATCH 0526/1496] Restore after bad block header request --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9790fb424..5081f3e53 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -345,7 +345,7 @@ function templateUpdate(coin, repeating) { if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeader)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { delete failedPortLastBlockHeader[coin]; if (activePort !== global.config.daemon["activePort" + coin]) { - console.log("Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); + console.log(threadName + "Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else if (err === null) { const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; @@ -356,9 +356,9 @@ function templateUpdate(coin, repeating) { coinHashFactorUpdate(coin, coinHashFactor); } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); - } else if (cluster.isMaster) { + } else { failedPortLastBlockHeader[coin] = 1; - console.error("Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); + console.error(threadName + "Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } From bfb8d3b62f2a362abdbbe030d1e0b5186e73eb33 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 14:42:43 -0700 Subject: [PATCH 0527/1496] Restore after bad block header request --- lib/coins/xmr.js | 2 +- lib/support.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c93b5e40a..3bfd37527 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -216,7 +216,7 @@ function Coin(data){ if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ return callback(null, body.result.block_header); } else { - if (!no_error_report) console.error(JSON.stringify(body)); + if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); return callback(true, body); } }); diff --git a/lib/support.js b/lib/support.js index 42b8f4799..44bf6d522 100644 --- a/lib/support.js +++ b/lib/support.js @@ -151,7 +151,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { } else { client.post(path, data, function (err, res, body) { if (err) { - /*if (typeof(err) === "string")*/ console.error("Error doing " + path + " request: " + err); + if (typeof(err) === "string") console.error("Error doing " + path + " request: " + err); return callback(err); } debug("JSON result: " + JSON.stringify(body)); From 17c10427e6e2d1c6ebca510fd4bba0bebf4b2d79 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 15:19:26 -0700 Subject: [PATCH 0528/1496] More debug --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 44bf6d522..9d36a6d31 100644 --- a/lib/support.js +++ b/lib/support.js @@ -151,7 +151,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { } else { client.post(path, data, function (err, res, body) { if (err) { - if (typeof(err) === "string") console.error("Error doing " + path + " request: " + err); + if (typeof(err) === "string") console.error("Error doing " + uri + path + " request: " + err); return callback(err); } debug("JSON result: " + JSON.stringify(body)); From c0a252f31a57f311d11464cb9a732f4f9ebfd698 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 17:24:10 -0700 Subject: [PATCH 0529/1496] Restore ccoin hash factor --- lib/pool.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5081f3e53..d08bbbc94 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -336,14 +336,17 @@ function coinHashFactorUpdate(coin, coinHashFactor) { setNewCoinHashFactor(true, coin, coinHashFactor); } -let failedPortLastBlockHeader = {}; +let failedPortLastBlockHeaderCoinHashFactor = {}; // templateUpdate is only called in master thread (except the beginning of a worker thread) function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; - const coinHashFactor = currCoinHashFactor[coin]; - if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeader)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { - delete failedPortLastBlockHeader[coin]; + let coinHashFactor = currCoinHashFactor[coin]; + if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeaderCoinHashFactor)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + if (coin in failedPortLastBlockHeaderCoinHashFactor) { + if (!coinHashFactor) coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; + delete failedPortLastBlockHeaderCoinHashFactor[coin]; + } if (activePort !== global.config.daemon["activePort" + coin]) { console.log(threadName + "Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); @@ -357,7 +360,7 @@ function templateUpdate(coin, repeating) { } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { - failedPortLastBlockHeader[coin] = 1; + failedPortLastBlockHeaderCoinHashFactor[coin] = coinHashFactor; console.error(threadName + "Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); From 981da8ae24463f0ce5d91ed46916c33c6ba1e65e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 18:02:07 -0700 Subject: [PATCH 0530/1496] Restore coin hash factor --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d08bbbc94..0238161a5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -351,6 +351,7 @@ function templateUpdate(coin, repeating) { console.log(threadName + "Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else if (err === null) { + console.error("!!! " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; @@ -361,11 +362,12 @@ function templateUpdate(coin, repeating) { if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else { failedPortLastBlockHeaderCoinHashFactor[coin] = coinHashFactor; - console.error(threadName + "Last block header request for " + global.config.daemon["activePort" + coin] + " port failed!"); + console.error(threadName + "Last block header request for " + activePort + " port failed!"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } }); else if (cluster.isMaster) { + console.error(threadName + "Last block header request for " + activePort + " port was skipped!"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } From f076a858b0799e292151465e8e7a9b7dd5fc35b3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 18:15:59 -0700 Subject: [PATCH 0531/1496] Restore coin hash factor --- lib/pool.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0238161a5..fd84357f2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -344,16 +344,19 @@ function templateUpdate(coin, repeating) { let coinHashFactor = currCoinHashFactor[coin]; if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeaderCoinHashFactor)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (coin in failedPortLastBlockHeaderCoinHashFactor) { - if (!coinHashFactor) coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; + if (!coinHashFactor) { + coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; + console.error("!!! " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); + } delete failedPortLastBlockHeaderCoinHashFactor[coin]; } if (activePort !== global.config.daemon["activePort" + coin]) { console.log(threadName + "Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else if (err === null) { - console.error("!!! " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; - if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { + if (!(coin in lastBlockHash) || body.hash !== + lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); } else if (isHashFactorChange && lastCoinHashFactor[coin]) { From 5bcce927d45aad75934ca2a9b19e243d356f1338 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 18:16:46 -0700 Subject: [PATCH 0532/1496] Restore coin hash factor --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index fd84357f2..acd1c0e6e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -344,10 +344,11 @@ function templateUpdate(coin, repeating) { let coinHashFactor = currCoinHashFactor[coin]; if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeaderCoinHashFactor)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (coin in failedPortLastBlockHeaderCoinHashFactor) { + console.error("!!!1 " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); if (!coinHashFactor) { coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; - console.error("!!! " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); } + console.error("!!!2 " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); delete failedPortLastBlockHeaderCoinHashFactor[coin]; } if (activePort !== global.config.daemon["activePort" + coin]) { From 402df1eb7ca49c080adb766a61193dc4a9b01ea5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 18:48:49 -0700 Subject: [PATCH 0533/1496] Restore coin hash factor --- lib/pool.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index acd1c0e6e..fd407baa4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -356,11 +356,10 @@ function templateUpdate(coin, repeating) { if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); } else if (err === null) { const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; - if (!(coin in lastBlockHash) || body.hash !== - lastBlockHash[coin]) { + if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); - } else if (isHashFactorChange && lastCoinHashFactor[coin]) { + } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); From 0bee6ba1242e5d97a7886097ea4b7cecd9236343 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 20:06:31 -0700 Subject: [PATCH 0534/1496] Restore coin hash factor --- lib/pool.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index fd407baa4..a10009234 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -344,11 +344,7 @@ function templateUpdate(coin, repeating) { let coinHashFactor = currCoinHashFactor[coin]; if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeaderCoinHashFactor)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (coin in failedPortLastBlockHeaderCoinHashFactor) { - console.error("!!!1 " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); - if (!coinHashFactor) { - coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; - } - console.error("!!!2 " + activePort + " port: " + currCoinHashFactor[coin] + " " + lastCoinHashFactor[coin] + " " + coinHashFactor); + if (!coinHashFactor) coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; delete failedPortLastBlockHeaderCoinHashFactor[coin]; } if (activePort !== global.config.daemon["activePort" + coin]) { @@ -370,7 +366,7 @@ function templateUpdate(coin, repeating) { setTimeout(templateUpdate, 1000, coin, repeating); } }); else if (cluster.isMaster) { - console.error(threadName + "Last block header request for " + activePort + " port was skipped!"); + //console.error(threadName + "Last block header request for " + activePort + " port was skipped!"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdate, 1000, coin, repeating); } From 88bc1e16eea083b130188b3ee3061b39743bb3f4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Aug 2019 21:40:11 -0700 Subject: [PATCH 0535/1496] Fixed keys usage --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3bfd37527..f16e45039 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -69,7 +69,7 @@ function get_coins(port2coin) { for (let port in port2coin) if (port2coin[port] != "") coins.push(port2coin[port]); return coins; } -const ports = []; //port2coin.keys(); +const ports = Object.keys(port2coin); const coins = get_coins(port2coin); function get_mm_child_port_set(mm_port_set) { let mm_child_port_set = {}; From 8a5348c1ff774058a445b593c0f8dec7619ce295 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:27:34 -0700 Subject: [PATCH 0536/1496] Added new script --- manage_scripts/get_block_hash.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 manage_scripts/get_block_hash.js diff --git a/manage_scripts/get_block_hash.js b/manage_scripts/get_block_hash.js new file mode 100644 index 000000000..b323703b2 --- /dev/null +++ b/manage_scripts/get_block_hash.js @@ -0,0 +1,23 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.port) { + console.error("Please specify port"); + process.exit(1); +} +const port = argv.port; + +if (!argv.hash) { + console.error("Please specify height"); + process.exit(1); +} +const height = argv.hash; + +require("../init_mini.js").init(function() { + global.coinFuncs.getPortAnyBlockHeaderByHash(port, hash, function (err_header, body_header) { + console.log("err:" + JSON.stringify(err_header)); + console.log("body:" + JSON.stringify(body_header)); + process.exit(0); + }); +}); From 78dfe4d0550f25ca3f86c4bd2b7b1b6d6f31c366 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:28:26 -0700 Subject: [PATCH 0537/1496] Added new script --- manage_scripts/get_block_hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/get_block_hash.js b/manage_scripts/get_block_hash.js index b323703b2..84ef2e7cf 100644 --- a/manage_scripts/get_block_hash.js +++ b/manage_scripts/get_block_hash.js @@ -12,7 +12,7 @@ if (!argv.hash) { console.error("Please specify height"); process.exit(1); } -const height = argv.hash; +const hash = argv.hash; require("../init_mini.js").init(function() { global.coinFuncs.getPortAnyBlockHeaderByHash(port, hash, function (err_header, body_header) { From 3a21f0dbe41ff257789d4074d354555946364b1e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:28:57 -0700 Subject: [PATCH 0538/1496] Added new script --- manage_scripts/get_block_hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/get_block_hash.js b/manage_scripts/get_block_hash.js index 84ef2e7cf..85f572617 100644 --- a/manage_scripts/get_block_hash.js +++ b/manage_scripts/get_block_hash.js @@ -15,7 +15,7 @@ if (!argv.hash) { const hash = argv.hash; require("../init_mini.js").init(function() { - global.coinFuncs.getPortAnyBlockHeaderByHash(port, hash, function (err_header, body_header) { + global.coinFuncs.getPortAnyBlockHeaderByHash(port, hash, true, function (err_header, body_header) { console.log("err:" + JSON.stringify(err_header)); console.log("body:" + JSON.stringify(body_header)); process.exit(0); From eea496dbc873c9d5744e2e514191ab7cf43b1c5c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:41:40 -0700 Subject: [PATCH 0539/1496] Fixed xero reward tx blocks handling --- lib/coins/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f16e45039..36ca4c579 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -186,8 +186,9 @@ function Coin(data){ } const reward = body2.result.transfer.amount; - if (reward !== reward_check) { - if (!(port == 38081 && reward < reward_check)) { // MSR can have uncle block reward here + if (reward !== reward_check || reward_check === 0) { + if (port == 38081 && reward < reward_check) { // MSR can have uncle block reward here + } else { console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); } From 9dd9d37f605250cdb373f235b2ee20f60a960b9b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:43:50 -0700 Subject: [PATCH 0540/1496] Fixed xero reward tx blocks handling --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 36ca4c579..2934325f8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -186,7 +186,7 @@ function Coin(data){ } const reward = body2.result.transfer.amount; - if (reward !== reward_check || reward_check === 0) { + if (reward !== reward_check || reward_check == 0) { if (port == 38081 && reward < reward_check) { // MSR can have uncle block reward here } else { console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); From 6eb36de250650cce8a43c14d2ddee6add7e187e3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:45:07 -0700 Subject: [PATCH 0541/1496] Fixed xero reward tx blocks handling --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2934325f8..b372336f5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -188,6 +188,7 @@ function Coin(data){ if (reward !== reward_check || reward_check == 0) { if (port == 38081 && reward < reward_check) { // MSR can have uncle block reward here + console.out("MSR OK"); } else { console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); From 4695cc2c193b54032a8cdce1a48412dc84067171 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:45:54 -0700 Subject: [PATCH 0542/1496] Fixed xero reward tx blocks handling --- lib/coins/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b372336f5..0c990b3bb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -188,7 +188,8 @@ function Coin(data){ if (reward !== reward_check || reward_check == 0) { if (port == 38081 && reward < reward_check) { // MSR can have uncle block reward here - console.out("MSR OK"); + console.log(reward); + console.log(reward_check); } else { console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); From 59d09a6ca83277bf1f0b9120768215ae1f5296f5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Aug 2019 12:46:53 -0700 Subject: [PATCH 0543/1496] Fixed xero reward tx blocks handling --- lib/coins/xmr.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0c990b3bb..5f0a70d96 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -186,10 +186,8 @@ function Coin(data){ } const reward = body2.result.transfer.amount; - if (reward !== reward_check || reward_check == 0) { - if (port == 38081 && reward < reward_check) { // MSR can have uncle block reward here - console.log(reward); - console.log(reward_check); + if (reward !== reward_check || reward == 0) { + if (port == 38081 && reward < reward_check && reward != 0) { // MSR can have uncle block reward here } else { console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); From a24f46e7fbd47e20e325df928353a5210bf94d5d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Aug 2019 12:17:44 -0700 Subject: [PATCH 0544/1496] Added TRTL after fork support --- lib/coins/xmr.js | 13 ++++++++----- lib/pool.js | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5f0a70d96..ff1038b0a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -51,7 +51,7 @@ const port2blob_num = { "19734": 0, // SUMO }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); -const mm_port_set = { "33124": 11898 }; +const mm_port_set = { }; const fix_daemon_sh = "./fix_daemon.sh"; @@ -415,8 +415,11 @@ function Coin(data){ if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; - if ("cn-pico" in algos_perf) coin_perf["XTNC"] = coin_perf["TRTL"] = algos_perf["cn-pico"]; - else if ("cn-pico/trtl" in algos_perf) coin_perf["XTNC"] = coin_perf["TRTL"] = algos_perf["cn-pico/trtl"]; + if ("cn-pico" in algos_perf) coin_perf["XTNC"] = algos_perf["cn-pico"]; + else if ("cn-pico/trtl" in algos_perf) coin_perf["XTNC"] = algos_perf["cn-pico/trtl"]; + + if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; + else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; return coin_perf; } @@ -429,7 +432,7 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, blockTemplate) { switch (blockTemplate.port) { case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon - case 11898: return multiHashing.cryptonight_pico(convertedBlob, 0); // TRTL + case 11898: return multiHashing.argon2(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR @@ -462,7 +465,7 @@ function Coin(data){ this.algoShortTypeStr = function(port, version) { switch (port) { case 11181: return "cn-lite/1"; // Aeon - case 11898: return "cn-pico/trtl"; // TRTL + case 11898: return "argon2/chukwa"; // TRTL case 12211: return "cn/gpu"; // RYO case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/r"; // XMR diff --git a/lib/pool.js b/lib/pool.js index a10009234..b3c0d29d8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -628,7 +628,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } else if (global.config.general.allowBitcoin && global.coinFuncs.supportsAutoExchange && btcValidator.validate(this.address)) { this.bitcoin = 1; } else { - this.error = "Invalid payment address provided: " + this.address + ". Please use monero_address[.payment_id][+difficulty_number] format"; + this.error = "Invalid payment address provided: " + this.address + ". Please use 95_char_long_monero_wallet_address[+difficulty_number] format"; this.valid_miner = false; return; } diff --git a/package.json b/package.json index 048d0f2f4..559fc1027 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v12.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v13.0.4" } } From 472efe12ae5e12e882042680406d2a84bd1db193 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Thu, 29 Aug 2019 19:54:12 +0300 Subject: [PATCH 0545/1496] XLA don't have composite tx --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ff1038b0a..8cde1c786 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -148,8 +148,8 @@ function Coin(data){ }; this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ - // TRTL does not get getblock and XTC / LTHN / AEON have composite tx - if (port == 11898 || port == 20189 || port == 48782 || port == 11181) { + // TRTL does not get getblock LTHN / AEON have composite tx + if (port == 11898 || port == 48782 || port == 11181) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); From 086d51d7574f7229bff8cf7a17518dfddd3ac10a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Aug 2019 18:18:26 -0700 Subject: [PATCH 0546/1496] Added ability to split hashrate --- lib/pool.js | 283 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 191 insertions(+), 92 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b3c0d29d8..ac64576d9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -563,9 +563,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // If there is no miner identifier, then the miner identifier is set to the password // If the password is x, aka, old-logins, we're not going to allow detailed review of miners. - let diffSplit = login.split("+"); - let addressSplit = diffSplit[0].split('.'); - let pass_split = pass.split(":"); + const login_diff_split = login.split("+"); + const login_div_split = login_diff_split[0].split("%"); + const login_paymentid_split = login_div_split[0].split("."); + let pass_split = pass.split(":"); // Workaround for a common mistake to put email without : before it // and also security measure to hide emails used as worker names @@ -576,43 +577,90 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // 1) set payout, identifier, email and logString - this.payout = this.address = addressSplit[0]; + this.payout = this.address = login_paymentid_split[0]; this.paymentID = null; this.identifier = agent && agent.includes('MinerGate') ? "MinerGate" : pass_split[0].substring(0, 64); - if (typeof(addressSplit[1]) !== 'undefined') { - if (addressSplit[1].length === 64 && hexMatch.test(addressSplit[1]) && global.coinFuncs.validatePlainAddress(this.address)) { - this.paymentID = addressSplit[1]; + if (typeof(login_paymentid_split[1]) !== 'undefined') { + if (login_paymentid_split[1].length === 64 && hexMatch.test(login_paymentid_split[1]) && global.coinFuncs.validatePlainAddress(this.address)) { + this.paymentID = login_paymentid_split[1]; this.payout += "." + this.paymentID; - if (typeof(addressSplit[2]) !== 'undefined' && this.identifier === 'x') { - this.identifier = addressSplit[2].substring(0, 64); + if (typeof(login_paymentid_split[2]) !== 'undefined' && this.identifier === 'x') { + this.identifier = login_paymentid_split[2].substring(0, 64); } } else if (this.identifier === 'x') { - this.identifier = addressSplit[1].substring(0, 64); + this.identifier = login_paymentid_split[1].substring(0, 64); } } this.debugMiner = this.payout == global.coinFuncs.testDevAddress; - - this.email = pass_split.length === 2 ? pass_split[1] : ""; - this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + ipAddress + ")"; + this.email = pass_split.length === 2 ? pass_split[1] : ""; + this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + ipAddress + ")"; // 2) check stuff - if (diffSplit.length > 2) { - this.error = "Too many options in the login field. Please use monero_address[.payment_id][+difficulty_number] format"; + if (login_diff_split.length > 2) { + this.error = "Please use monero_address[.payment_id][+difficulty_number] login/user format"; + this.valid_miner = false; + return; + } + + if (Math.abs(login_div_split.length % 2) == 0 || login_div_split.length > 5) { + this.error = "Please use monero_address[.payment_id][%N%95_char_long_monero_wallet_address]+[+difficulty_number] login/user format"; this.valid_miner = false; return; } + this.payout_div = {}; + + let payout_percent_left = 100; + for (let index = 1; index < login_div_split.length - 1; ++ index) { + const percent_raw = parseInt(login_div_split[index]); + const percent = isNaN(percent_raw) ? 1 : percent_Raw; + if (percent < 1) { + this.error = "Your payment divide split " + percent + " is below 1% and can't be processed"; + this.valid_miner = false; + return; + } + if (percent > 99) { + this.error = "Your payment divide split " + percent + " is above 99% and can't be processed"; + this.valid_miner = false; + return; + } + payout_percent_left -= percent; + if (payout_percent_left < 1) { + this.error = "Your summary payment divide split exceeds 99% and can't be processed"; + this.valid_miner = false; + return; + } + const address = login_div_split[index + 1]; + if (address.length != 95 || global.coinFuncs.validateAddress(address)) { + this.error = "Invalid payment address provided: " + address + ". Please use 95_char_long_monero_wallet_address format"; + this.valid_miner = false; + return; + } + if (address in bannedAddresses) { // Banned Address + this.error = "Permanently banned payment address " + address + " provided: " + bannedAddresses[address]; + this.valid_miner = false; + return; + } + this.payout_div[address] = percent; + } + + if (payout_percent_left === 100) { + this.payout_div = null; + } else { + this.payout_div[this.payout] = payout_percent_left; + } + if (pass_split.length > 2) { - this.error = "Too many options in the password field. Please use worker_name[:email] format"; + this.error = "Please use worker_name[:email] password format"; this.valid_miner = false; return; } if (this.payout in bannedAddresses) { // Banned Address - this.error = "Permanently banned payment address provided: " + bannedAddresses[this.payout]; + this.error = "Permanently banned payment address " + this.payout + " provided: " + bannedAddresses[this.payout]; this.valid_miner = false; return; } @@ -714,9 +762,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.fixed_diff = true; this.difficulty = global.coinFuncs.niceHashDiff; } - if (diffSplit.length === 2) { + if (login_diff_split.length === 2) { this.fixed_diff = true; - this.difficulty = Number(diffSplit[1]); + this.difficulty = Number(login_diff_split[1]); if (this.difficulty < global.config.pool.minDifficulty) { this.difficulty = global.config.pool.minDifficulty; } @@ -1035,7 +1083,56 @@ let walletWorkerCount = {}; // is share finalizer function for dead worker_name is active let is_walletAccFinalizer = {}; -function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bitcoin, miner_poolTypeEnum, miner_port) { +function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_name, bt_port, bt_height, bt_difficulty, isBlockCandidate, isTrustedShare) { + const time_now = Date.now(); + if (miner.payout_div === null) { + global.database.storeShare(bt_height, global.protos.Share.encode({ + paymentAddress: miner.address, + paymentID: miner.paymentID, + shares: share_reward, + shares2: share_reward2, + share_num: share_num, + identifier: worker_name, + port: bt_port, + blockHeight: bt_height, + blockDiff: bt_difficulty, + poolType: miner.poolTypeEnum, + bitcoin: miner.bitcoin, + foundBlock: isBlockCandidate, + trustedShare: isTrustedShare, + poolID: global.config.pool_id, + timestamp: time_now + })); + } else { + for (let payout in miner.payout_div) { + const payout_split = payout.split("."); + const paymentAddress = payout_split[0]; + const paymentID = payout_split.length === 2 ? payout_split[1] : null; + const payoutPercent = miner.payout_div[payout]; + const shares = share_reward * 100 / payoutPercent; + const shares2 = share_reward2 * 100 / payoutPercent; + global.database.storeShare(bt_height, global.protos.Share.encode({ + paymentAddress: paymentAddress, + paymentID: paymentID, + shares: shares, + shares2: shares2, + share_num: share_num, + identifier: worker_name, + port: bt_port, + blockHeight: bt_height, + blockDiff: bt_difficulty, + poolType: miner.poolTypeEnum, + bitcoin: miner.bitcoin, + foundBlock: isBlockCandidate, + trustedShare: isTrustedShare, + poolID: global.config.pool_id, + timestamp: time_now + })); + } + } +} + +function walletAccFinalizer(wallet_key, miner, bt_port) { debug("!!! " + wallet_key + ": scanning for old worker names"); let wallet = walletAcc[wallet_key]; let is_something_left = false; @@ -1047,23 +1144,24 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi if (acc != 0) { let height = worker.height; debug("!!! " + wallet_key + " / " + worker_name + ": storing old worker share " + height + " " + worker.difficulty + " " + time_now + " " + acc); - global.database.storeShare(height, global.protos.Share.encode({ - shares: acc, - shares2: worker.acc2, - paymentAddress: miner_address, - paymentID: miner_paymentID, - foundBlock: false, - trustedShare: true, - poolType: miner_poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: worker.difficulty, - bitcoin: miner_bitcoin, - blockHeight: height, - timestamp: time_now, - identifier: worker_name, - port: miner_port, - share_num: worker.share_num - })); + storeShareDiv(miner, acc, worker.acc2, worker.share_num, worker_name, bt_port, height, worker.difficulty, false, true); + //global.database.storeShare(height, global.protos.Share.encode({ + // shares: acc, + // shares2: worker.acc2, + // paymentAddress: miner_address, + // paymentID: miner_paymentID, + // foundBlock: false, + // trustedShare: true, + // poolType: miner_poolTypeEnum, + // poolID: global.config.pool_id, + // blockDiff: worker.difficulty, + // bitcoin: miner_bitcoin, + // blockHeight: height, + // timestamp: time_now, + // identifier: worker_name, + // port: bt_port, + // share_num: worker.share_num + //})); } debug("!!! " + wallet_key + ": removing old worker " + worker_name); if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; @@ -1074,13 +1172,13 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi } if (is_something_left) { - setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner_address, miner_paymentID, miner_bitcoin, miner_poolTypeEnum, miner_port); + setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner, bt_port); } else { is_walletAccFinalizer[wallet_key] = false; } } -function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrustedShare, blockTemplate) { +function recordShareData(miner, job, shareDiff, isBlockCandidate, hashHex, isTrustedShare, blockTemplate) { miner.hashes += job.difficulty; let proxyMinerName = miner.payout + ":" + miner.identifier; if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.difficulty; @@ -1096,25 +1194,25 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust let db_job_height = global.config.daemon.port == blockTemplate.port ? blockTemplate.height : anchorBlockHeight; - if (job.difficulty >= 1000000 || blockCandidate) { - - global.database.storeShare(db_job_height, global.protos.Share.encode({ - shares: job.rewarded_difficulty, - shares2: job.rewarded_difficulty2, - paymentAddress: miner.address, - paymentID: miner.paymentID, - foundBlock: blockCandidate, - trustedShare: isTrustedShare, - poolType: miner.poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: blockTemplate.difficulty, - bitcoin: miner.bitcoin, - blockHeight: db_job_height, - timestamp: time_now, - identifier: miner.identifier, - port: blockTemplate.port, - share_num: 1 - })); + if (job.difficulty >= 1000000 || isBlockCandidate) { + storeShareDiv(miner, job.rewarded_difficulty, job.rewarded_difficulty2, 1, miner.identifier, blockTemplate.port, db_job_height, blockTemplate.difficulty, isBlockCandidate, isTrustedShare); + //global.database.storeShare(db_job_height, global.protos.Share.encode({ + // shares: job.rewarded_difficulty, + // shares2: job.rewarded_difficulty2, + // paymentAddress: miner.address, + // paymentID: miner.paymentID, + // foundBlock: isBlockCandidate, + // trustedShare: isTrustedShare, + // poolType: miner.poolTypeEnum, + // poolID: global.config.pool_id, + // blockDiff: blockTemplate.difficulty, + // bitcoin: miner.bitcoin, + // blockHeight: db_job_height, + // timestamp: time_now, + // identifier: miner.identifier, + // port: blockTemplate.port, + // share_num: 1 + //})); } else { @@ -1146,23 +1244,24 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > 60*1000 || acc >= 1000000) { if (acc != 0) { debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); - global.database.storeShare(height, global.protos.Share.encode({ - shares: acc, - shares2: acc2, - paymentAddress: miner.address, - paymentID: miner.paymentID, - foundBlock: false, - trustedShare: isTrustedShare, - poolType: miner.poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: difficulty, - bitcoin: miner.bitcoin, - blockHeight: height, - timestamp: time_now, - identifier: worker_name, - port: blockTemplate.port, - share_num: share_num - })); + storeShareDiv(miner, acc, acc2, share_num, worker_name, blockTemplate.port, height, difficulty, false, isTrustedShare); + //global.database.storeShare(height, global.protos.Share.encode({ + // shares: acc, + // shares2: acc2, + // paymentAddress: miner.address, + // paymentID: miner.paymentID, + // foundBlock: false, + // trustedShare: isTrustedShare, + // poolType: miner.poolTypeEnum, + // poolID: global.config.pool_id, + // blockDiff: difficulty, + // bitcoin: miner.bitcoin, + // blockHeight: height, + // timestamp: time_now, + // identifier: worker_name, + // port: blockTemplate.port, + // share_num: share_num + //})); } worker.height = db_job_height; @@ -1183,31 +1282,31 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, isTrust if (is_walletAccFinalizer[wallet_key] === false) { is_walletAccFinalizer[wallet_key] = true; - setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner.address, miner.paymentID, miner.bitcoin, miner.poolTypeEnum, blockTemplate.port); + setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner, blockTemplate.port); } - if (blockCandidate) { + if (isBlockCandidate) { if (global.config.daemon.port == blockTemplate.port) { global.database.storeBlock(blockTemplate.height, global.protos.Block.encode({ - hash: hashHex, + hash: hashHex, difficulty: blockTemplate.difficulty, - shares: 0, - timestamp: time_now, - poolType: miner.poolTypeEnum, - unlocked: false, - valid: true + shares: 0, + timestamp: time_now, + poolType: miner.poolTypeEnum, + unlocked: false, + valid: true })); } else { global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ - hash: hashHex, - difficulty: blockTemplate.difficulty, - shares: 0, - timestamp: time_now, - poolType: miner.poolTypeEnum, - unlocked: false, - valid: true, - port: blockTemplate.port, - height: blockTemplate.height, + hash: hashHex, + difficulty: blockTemplate.difficulty, + shares: 0, + timestamp: time_now, + poolType: miner.poolTypeEnum, + unlocked: false, + valid: true, + port: blockTemplate.port, + height: blockTemplate.height, anchor_height: anchorBlockHeight })); } From 072b2e77e2e6558f86cbe4a19aefb651b66ef992 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Aug 2019 18:44:56 -0700 Subject: [PATCH 0547/1496] Added ability to split hashrate --- lib/pool.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ac64576d9..6eec1c3c1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -615,9 +615,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let payout_percent_left = 100; for (let index = 1; index < login_div_split.length - 1; ++ index) { - const percent_raw = parseInt(login_div_split[index]); - const percent = isNaN(percent_raw) ? 1 : percent_Raw; - if (percent < 1) { + const percent = parseInt(login_div_split[index]); + if (isNaN(percent) || percent < 1) { this.error = "Your payment divide split " + percent + " is below 1% and can't be processed"; this.valid_miner = false; return; @@ -648,9 +647,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } if (payout_percent_left === 100) { - this.payout_div = null; + this.payout_div = null; } else { - this.payout_div[this.payout] = payout_percent_left; + this.payout_div[this.payout] = payout_percent_left; } if (pass_split.length > 2) { @@ -676,7 +675,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } else if (global.config.general.allowBitcoin && global.coinFuncs.supportsAutoExchange && btcValidator.validate(this.address)) { this.bitcoin = 1; } else { - this.error = "Invalid payment address provided: " + this.address + ". Please use 95_char_long_monero_wallet_address[+difficulty_number] format"; + this.error = "Invalid payment address provided: " + this.address + ". Please use 95_char_long_monero_wallet_address format"; this.valid_miner = false; return; } From 5e45ee544f89e77dbf6d9b0349f9505448eb1c8d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Aug 2019 18:48:55 -0700 Subject: [PATCH 0548/1496] Fixed bonus address validation --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6eec1c3c1..1c0149bd9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -633,7 +633,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return; } const address = login_div_split[index + 1]; - if (address.length != 95 || global.coinFuncs.validateAddress(address)) { + if (address.length != 95 || !global.coinFuncs.validateAddress(address)) { this.error = "Invalid payment address provided: " + address + ". Please use 95_char_long_monero_wallet_address format"; this.valid_miner = false; return; From 0fb6243c7dd8017bf37840cd18c790381eaf39e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Aug 2019 18:59:56 -0700 Subject: [PATCH 0549/1496] Fixed reward split --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1c0149bd9..2880a5809 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1108,8 +1108,8 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam const paymentAddress = payout_split[0]; const paymentID = payout_split.length === 2 ? payout_split[1] : null; const payoutPercent = miner.payout_div[payout]; - const shares = share_reward * 100 / payoutPercent; - const shares2 = share_reward2 * 100 / payoutPercent; + const shares = share_reward * payoutPercent / 100; + const shares2 = share_reward2 * payoutPercent / 100; global.database.storeShare(bt_height, global.protos.Share.encode({ paymentAddress: paymentAddress, paymentID: paymentID, From d607134f2331ef6e9df1bca24d7592af8c5b9c40 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Aug 2019 19:09:50 -0700 Subject: [PATCH 0550/1496] Error on repeated split address --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 2880a5809..881c6a0da 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -643,6 +643,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.valid_miner = false; return; } + if (address in this.payout_div) { + this.error = "You can't repeat payment split address " + address; + this.valid_miner = false; + return; + } this.payout_div[address] = percent; } From 61d46f55cb77ed60120e351d73728da060e49c34 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Aug 2019 19:11:16 -0700 Subject: [PATCH 0551/1496] Fixed multiple payment split address processing --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 881c6a0da..dd3ad4e84 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -614,7 +614,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.payout_div = {}; let payout_percent_left = 100; - for (let index = 1; index < login_div_split.length - 1; ++ index) { + for (let index = 1; index < login_div_split.length - 1; index += 2) { const percent = parseInt(login_div_split[index]); if (isNaN(percent) || percent < 1) { this.error = "Your payment divide split " + percent + " is below 1% and can't be processed"; From c77004d8a4f45b67b33585c0c67e1e3efd5698d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Aug 2019 19:12:44 -0700 Subject: [PATCH 0552/1496] Fixed multiple payment split address processing --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index dd3ad4e84..2c87a5a1c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -654,6 +654,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (payout_percent_left === 100) { this.payout_div = null; } else { + if (this.payout in this.payout_div) { + this.error = "You can't repeat payment split address " + this.payout; + this.valid_miner = false; + return; + } this.payout_div[this.payout] = payout_percent_left; } From fefef3f9c4190d4eee0a88f5e2b064d2f1b4085a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Sep 2019 15:43:15 -0700 Subject: [PATCH 0553/1496] Allow non cn/r miners to mine --- lib/coins/xmr.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8cde1c786..d08f16078 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -380,7 +380,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "cn": 1, "cn/half": 1.9, "cn/rwz": 1.3, "cn/zls": 1.3, "cn/double": 0.5 }; + return { "cn/r": 1, "cn/half": 1.9, "cn/rwz": 1.3, "cn/zls": 1.3, "cn/double": 0.5 }; } this.convertAlgosToCoinPerf = function(algos_perf) { @@ -389,21 +389,22 @@ function Coin(data){ if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; else if ("cn" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn"]; else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/4"]; - - if (!("" in coin_perf)) return "algo-perf set must include cn or cn/r hashrate"; + else { + coin_perf[""] = 0.001; + } if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; - if ("defyx" in algos_perf) coin_perf["XTC"] = algos_perf["defyx"]; + if ("defyx" in algos_perf) coin_perf["XTC"] = algos_perf["defyx"]; if ("cn/gpu" in algos_perf) coin_perf["RYO"] = algos_perf["cn/gpu"]; if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; - if ("rx/loki" in algos_perf) coin_perf["LOKI"] = algos_perf["rx/loki"]; + if ("rx/loki" in algos_perf) coin_perf["LOKI"] = algos_perf["rx/loki"]; - if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; + if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; if ("cn-heavy" in algos_perf) coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy"]; else if ("cn-heavy/0" in algos_perf) coin_perf["TUBE"] = coin_perf["XHV"] = algos_perf["cn-heavy/0"]; @@ -426,7 +427,7 @@ function Coin(data){ // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - return algos.includes("cn/r") ? true : "algo array must include cn/r"; + return true; //algos.includes("cn/r") ? true : "algo array must include cn/r"; } this.cryptoNight = function(convertedBlob, blockTemplate) { From da585abf733a4ea336d12c86d2785a0a1e5bfe46 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Sep 2019 14:26:05 -0700 Subject: [PATCH 0554/1496] Added ARQ/IRD support --- deployment/base.sql | 6 ++++++ lib/coins/xmr.js | 27 +++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index af99cb322..03e2d104e 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -215,6 +215,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLTHN', '0', 'int', 'Lethean coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortGRFT', '0', 'int', 'Graft coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortIRD', '0', 'int', 'Iridium coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortARQ', '0', 'int', 'ArqMa coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -229,6 +231,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLTHN', '0', 'float', 'Lethean algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorGRFT', '0', 'float', 'Graft algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTRTL', '0', 'float', 'Turtle algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorIRD', '0', 'float', 'Iridium algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorARQ', '0', 'float', 'ArqMa algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -280,6 +284,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_31014', '', 'string', 'Address to mine to for 31014 (Saronite) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_33124', '', 'string', 'Address to mine to for 33124 (XtendCash) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11898', '', 'string', 'Address to mine to for 11898 (Turtle) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13007', '', 'string', 'Address to mine to for 13007 (Iridium) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19994', '', 'string', 'Address to mine to for 19994 (ArqMa) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunURL', '', 'string', 'MailGun URL for notifications'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d08f16078..bf764feaf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -32,7 +32,9 @@ const port2coin = { "34568": "WOW", "38081": "MSR", "48782": "LTHN", - "19734": "SUMO" + "19734": "SUMO", + "13007": "IRD", + "19994": "ARQ", }; const port2blob_num = { "11181": 0, // AEON @@ -49,9 +51,11 @@ const port2blob_num = { "38081": 6, // MSR "48782": 0, // LTHN "19734": 0, // SUMO + "13007": 2, // IRD + "19994": 0, // ARQ }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); -const mm_port_set = { }; +const mm_port_set = { "19994": 13007 }; const fix_daemon_sh = "./fix_daemon.sh"; @@ -148,8 +152,8 @@ function Coin(data){ }; this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ - // TRTL does not get getblock LTHN / AEON have composite tx - if (port == 11898 || port == 48782 || port == 11181) { + // TRTL/IRD does not get getblock LTHN / AEON have composite tx + if (port == 11898 || port == 13007 || port == 48782 || port == 11181) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); @@ -416,8 +420,10 @@ function Coin(data){ if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; - if ("cn-pico" in algos_perf) coin_perf["XTNC"] = algos_perf["cn-pico"]; - else if ("cn-pico/trtl" in algos_perf) coin_perf["XTNC"] = algos_perf["cn-pico/trtl"]; + if ("cn-pico" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico"]; + else if ("cn-pico/trtl" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico/trtl"]; + + if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; @@ -435,14 +441,16 @@ function Coin(data){ case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO + case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO + case 19994: return multiHashing.cryptonight_pico(convertedBlob, 0); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash + //case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash??? case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean @@ -455,6 +463,7 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { case 11898: return "forknote2"; // TRTL + case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO case 22023: return "cryptonote_loki"; // LOKI case 33124: return "cryptonote_loki"; // XtendCash @@ -468,14 +477,16 @@ function Coin(data){ case 11181: return "cn-lite/1"; // Aeon case 11898: return "argon2/chukwa"; // TRTL case 12211: return "cn/gpu"; // RYO + case 13007: return "cn-pico/trtl"; // IRD case 17750: return "cn-heavy/xhv"; // Haven case 18081: return "cn/r"; // XMR case 18981: return "cn/rwz"; // Graft case 19734: return "cn/r"; // SUMO + case 19994: return "cn-pico/trtl"; // ArqMa case 20189: return "defyx"; // Scala case 22023: return "rx/loki"; // LOKI case 24182: return "cn-heavy/tube"; // BitTube - case 33124: return "cn-pico/trtl"; // XtendCash + case 33124: return "c29s"; // XtendCash case 34568: return "rx/wow"; // Wownero case 38081: return "cn/half"; // MSR case 48782: return "cn/r"; // Lethean From 62828efc100bb273955ca7b23b9fdcc90e686e09 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Sep 2019 15:23:57 -0700 Subject: [PATCH 0555/1496] Added more debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2c87a5a1c..6dc0cd84b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1941,7 +1941,7 @@ if (cluster.isMaster) { worker = cluster.fork(); worker.on('message', messageHandler); global.support.sendEmail(global.config.general.adminEmail, "FYI: Started new worker " + worker.id, - "Hello,\r\nMaster theread starts new worker with id " + worker.id); + "Hello,\r\nMaster thread of " + global.config.hostname + " starts new worker with id " + worker.id); }); From b7822f6dbc13fda79522a71509f714ddfe35f580 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Sep 2019 15:51:00 -0700 Subject: [PATCH 0556/1496] Improved miner supported algo detection --- lib/coins/xmr.js | 54 ++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index bf764feaf..9c878ff22 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -54,6 +54,26 @@ const port2blob_num = { "13007": 2, // IRD "19994": 0, // ARQ }; + +const port2algo = { + "11181": "cn-lite/1", // Aeon + "11898": "argon2/chukwa", // TRTL + "12211": "cn/gpu", // RYO + "13007": "cn-pico/trtl", // IRD + "17750": "cn-heavy/xhv", // Haven + "18081": "cn/r", // XMR + "18981": "cn/rwz", // Graft + "19734": "cn/r", // SUMO + "19994": "cn-pico/trtl", // ArqMa + "20189": "defyx", // Scala + "22023": "rx/loki", // LOKI + "24182": "cn-heavy/tube", // BitTube + "33124": "c29s", // XtendCash + "34568": "rx/wow", // Wownero + "38081": "cn/half", // MSR + "48782": "cn/r", // Lethean +}; + const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); const mm_port_set = { "19994": 13007 }; @@ -84,6 +104,12 @@ function get_mm_child_port_set(mm_port_set) { } return mm_child_port_set; } +function get_algos() { + let algos = {}; + for (let port in port2algo) algos[port2algo(port)] = 1; + return algos; +} +const all_algos = get_algos(); const mm_child_port_set = get_mm_child_port_set(mm_port_set); function Coin(data){ @@ -433,7 +459,9 @@ function Coin(data){ // returns true if algo array reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - return true; //algos.includes("cn/r") ? true : "algo array must include cn/r"; + if (algos.includes("cn/r")) return true; + for (let algo in all_algos) if (algos.includes(algo)) return true; + return "algo array must include at least one supported pool algo"; } this.cryptoNight = function(convertedBlob, blockTemplate) { @@ -473,27 +501,9 @@ function Coin(data){ } this.algoShortTypeStr = function(port, version) { - switch (port) { - case 11181: return "cn-lite/1"; // Aeon - case 11898: return "argon2/chukwa"; // TRTL - case 12211: return "cn/gpu"; // RYO - case 13007: return "cn-pico/trtl"; // IRD - case 17750: return "cn-heavy/xhv"; // Haven - case 18081: return "cn/r"; // XMR - case 18981: return "cn/rwz"; // Graft - case 19734: return "cn/r"; // SUMO - case 19994: return "cn-pico/trtl"; // ArqMa - case 20189: return "defyx"; // Scala - case 22023: return "rx/loki"; // LOKI - case 24182: return "cn-heavy/tube"; // BitTube - case 33124: return "c29s"; // XtendCash - case 34568: return "rx/wow"; // Wownero - case 38081: return "cn/half"; // MSR - case 48782: return "cn/r"; // Lethean - default: - console.error("Unknown " + port + " port for PoW type on " + version + " version"); - return "cn/r"; - } + if (port in port2algo) return port2algo[port]; + console.error("Unknown " + port + " port for PoW type on " + version + " version"); + return "cn/r"; } this.isMinerSupportAlgo = function(algo, algos) { From 81149582a5f525137840b98ce04ca0772a1719d8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Sep 2019 15:51:25 -0700 Subject: [PATCH 0557/1496] Moved log into error --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6dc0cd84b..8d07bca42 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1936,7 +1936,7 @@ if (cluster.isMaster) { }); cluster.on('exit', function (worker, code, signal) { - console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal); + console.error('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal); console.log('Starting a new worker'); worker = cluster.fork(); worker.on('message', messageHandler); From 4cb8ad8dcaf5dc46ff2585774ebd27a7717810d8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Sep 2019 15:52:30 -0700 Subject: [PATCH 0558/1496] Fixed bug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9c878ff22..6f0686ec4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -106,7 +106,7 @@ function get_mm_child_port_set(mm_port_set) { } function get_algos() { let algos = {}; - for (let port in port2algo) algos[port2algo(port)] = 1; + for (let port in port2algo) algos[port2algo[port]] = 1; return algos; } const all_algos = get_algos(); From 24456cf3f910f95c0a58e120de663036885ab78d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 12 Sep 2019 14:10:34 -0700 Subject: [PATCH 0559/1496] Added cn-pico miners support --- lib/coins/xmr.js | 6 +++--- lib/pool.js | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6f0686ec4..fb21047b3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -457,10 +457,10 @@ function Coin(data){ return coin_perf; } - // returns true if algo array reported by miner is OK or error string otherwise + // returns true if algo set reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - if (algos.includes("cn/r")) return true; - for (let algo in all_algos) if (algos.includes(algo)) return true; + if ("cn/r" in algos) return true; + for (let algo in all_algos) if (algo in algos) return true; return "algo array must include at least one supported pool algo"; } diff --git a/lib/pool.js b/lib/pool.js index 8d07bca42..bd7ddfeaf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -697,13 +697,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.setAlgos = function(algos, algos_perf, algo_min_time) { - const check = global.coinFuncs.algoCheck(algos); - if (check === true) { - this.algos = {}; - for (let i in algos) this.algos[algos[i]] = 1; - } else { - return check; - } + this.algos = {}; + for (let i in algos) this.algos[algos[i]] = 1; + if (global.coinFuncs.algoCheck(this.algos) !== true) return check; + if ("cn-pico" in this.algos) this.algos["cn-pico/trtl"] = 1; const coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); if (coin_perf instanceof Object) { this.coin_perf = coin_perf; From fde246787a2bd7d62d3a8c85c13f87f78926f24c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 12 Sep 2019 14:11:53 -0700 Subject: [PATCH 0560/1496] Added cn-pico miners support --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bd7ddfeaf..2b4f9e25a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -699,7 +699,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.setAlgos = function(algos, algos_perf, algo_min_time) { this.algos = {}; for (let i in algos) this.algos[algos[i]] = 1; - if (global.coinFuncs.algoCheck(this.algos) !== true) return check; + const check = global.coinFuncs.algoCheck(this.algos); + if (check !== true) return check; if ("cn-pico" in this.algos) this.algos["cn-pico/trtl"] = 1; const coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); if (coin_perf instanceof Object) { From 982bb91ea373a4cdaaba135cc5dc1993eec4bb5f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Sep 2019 09:11:55 -0700 Subject: [PATCH 0561/1496] Disabled emails by default --- user_scripts/pass_set.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_scripts/pass_set.js b/user_scripts/pass_set.js index b0bae4f60..dbfb7403b 100644 --- a/user_scripts/pass_set.js +++ b/user_scripts/pass_set.js @@ -27,8 +27,8 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [user, pass]).then(function (rows) { - console.log("INSERT INTO users (username, email) VALUES (" + user + ", " + pass + ")"); + global.mysql.query("INSERT INTO users (username, email, enable_email) VALUES (?, ?, 0)", [user, pass]).then(function (rows) { + console.log("INSERT INTO users (username, email, enable_email) VALUES (" + user + ", " + pass + ", 0)"); callback(); }); }, From d1dce27edd6921272d448dccee2220ec6a4fbcb6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Sep 2019 12:42:01 -0700 Subject: [PATCH 0562/1496] Added ability to do float reward separation --- lib/pool.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2b4f9e25a..291e75ec9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -615,20 +615,20 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let payout_percent_left = 100; for (let index = 1; index < login_div_split.length - 1; index += 2) { - const percent = parseInt(login_div_split[index]); - if (isNaN(percent) || percent < 1) { - this.error = "Your payment divide split " + percent + " is below 1% and can't be processed"; + const percent = parseFloat(login_div_split[index]); + if (isNaN(percent) || percent < 0.1) { + this.error = "Your payment divide split " + percent + " is below 0.1% and can't be processed"; this.valid_miner = false; return; } - if (percent > 99) { - this.error = "Your payment divide split " + percent + " is above 99% and can't be processed"; + if (percent > 99.9) { + this.error = "Your payment divide split " + percent + " is above 99.9% and can't be processed"; this.valid_miner = false; return; } payout_percent_left -= percent; - if (payout_percent_left < 1) { - this.error = "Your summary payment divide split exceeds 99% and can't be processed"; + if (payout_percent_left < 0.1) { + this.error = "Your summary payment divide split exceeds 99.9% and can't be processed"; this.valid_miner = false; return; } @@ -1116,8 +1116,8 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam const paymentAddress = payout_split[0]; const paymentID = payout_split.length === 2 ? payout_split[1] : null; const payoutPercent = miner.payout_div[payout]; - const shares = share_reward * payoutPercent / 100; - const shares2 = share_reward2 * payoutPercent / 100; + const shares = Math.floor(share_reward * payoutPercent / 100); + const shares2 = Math.floor(share_reward2 * payoutPercent / 100); global.database.storeShare(bt_height, global.protos.Share.encode({ paymentAddress: paymentAddress, paymentID: paymentID, From 0f4febf5eb1228041f2a59e85cdf15c8f6bcfb77 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Oct 2019 14:16:08 -0700 Subject: [PATCH 0563/1496] Fixed array iteration --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 7852ccb7c..77e526cca 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -604,7 +604,7 @@ function updatePoolStats2(poolType) { }, function (callback) { let portCoinAlgo = {}; - for (let port in global.coinFuncs.getPORTS()) portCoinAlgo[port] = global.coinFuncs.algoShortTypeStr(port, 0); + for (let port of global.coinFuncs.getPORTS()) portCoinAlgo[port] = global.coinFuncs.algoShortTypeStr(port, 0); return callback(null, portCoinAlgo); }, ], function (err, result) { From 4f79e68822f8ce8e582b3c16e9993c62f2061c1c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 3 Oct 2019 16:49:06 -0700 Subject: [PATCH 0564/1496] Fixed block payment issues --- lib/blockManager.js | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 3a04482bf..79be08607 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -569,6 +569,7 @@ let payReadyBlockHashCalc = {}; function blockUnlocker() { if (is_full_stop) { debug("Dropping all block unlocks"); + setTimeout(blockUnlocker, 2*60*1000); return; } // if (scanInProgress) { @@ -576,7 +577,8 @@ function blockUnlocker() { // return; // } if (paymentInProgress) { - debug("Skipping block unlocker run as there's a payment in progress"); + console.error("Skipping block unlocker run as there's a payment in progress"); + setTimeout(blockUnlocker, 2*60*1000); return; } console.log("Running block unlocker"); @@ -587,19 +589,20 @@ function blockUnlocker() { return; } const topBlockHeight = body.height; - blockList.forEach(function (block) { + async.eachSeries(blockList, function(block, next) { global.coinFuncs.getBlockHeaderByID(block.height, (err, body) => { if (err !== null) { console.error("Can't get block with " + block.height + " height"); - return; + return next(); } - if (topBlockHeight - block.height <= 5) return; + if (topBlockHeight - block.height <= 5) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; if (body.hash !== block.hash) { global.database.invalidateBlock(block.height); //global.mysql.query("UPDATE block_log SET orphan = true WHERE hex = ?", [block.hash]); //blockIDCache.splice(blockIDCache.indexOf(block.height)); console.log("Invalidating block " + block.height + " due to being an orphan block"); + return next(); } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { payReadyBlockHashCalc[block.hash] = 1; preCalculatePPLNSPayments(block.hash, block.height, block.difficulty, function(status) { @@ -607,12 +610,17 @@ function blockUnlocker() { console.log("Completed PPLNS reward pre-calculations of block " + block.hash + " on height " + block.height); global.database.payReadyBlock(block.hash); } + return next(); }); } else if (topBlockHeight - block.height > global.config.payout.blocksRequired && (!is_pplns_block || block.pay_ready === true)) { - blockPayments(block); + blockPayments(block, function() { return next(); } ); + return next(); + } else { + return next(); } }); - + }, function() { + setTimeout(blockUnlocker, 2*60*1000); }); }); } @@ -629,7 +637,7 @@ function altblockUnlocker() { // return; // } if (paymentInProgress) { - debug("Skipping altblock unlocker run as there's a payment in progress"); + console.error("Skipping altblock unlocker run as there's a payment in progress"); setTimeout(altblockUnlocker, 2*60*1000); return; } @@ -692,28 +700,31 @@ function altblockUnlocker() { }); } -function blockPayments(block) { +function blockPayments(block, cb) { switch (block.poolType) { case global.protos.POOLTYPE.PPS: // PPS is paid out per share find per block, so this is handled in the main block-find loop. global.database.unlockBlock(block.hash); - break; + return cb(); + case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getBlockHeaderByHash(block.hash, function (err, header) { if (err === null && block.height === header.height && block.value === header.reward && block.difficulty === header.difficulty){ if (paymentInProgress) { - debug("Skipping payment as there's a payment in progress"); - return; + console.error("Skipping payment as there's a payment in progress"); + return cb(); } paymentInProgress = true; doPPLNSPayments(block.hash, block.value, function() { console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockBlock(block.hash); + return cb(); }); } else { console.error("Can't get correct block header by hash " + block.hash.toString('hex')); global.support.sendEmail(global.config.general.adminEmail, "blockManager unable to make blockPayments", "Hello,\r\nThe blockManager has hit an issue making blockPayments with block " + block.hash.toString('hex')); + return cb(); } }); break; @@ -723,17 +734,18 @@ function blockPayments(block) { calculateSoloPayments(header); global.database.unlockBlock(block.hash); } + return cb(); }); break; default: console.error("Unknown payment type. FREAKOUT"); - break; + return cb(); } } function altblockPayments(block, cb) { if (paymentInProgress) { - debug("Skipping payment as there's a payment in progress"); + console.error("Skipping payment as there's a payment in progress"); return cb(); } switch (block.poolType) { @@ -743,15 +755,15 @@ function altblockPayments(block, cb) { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ if (paymentInProgress) { - debug("Skipping payment as there's a payment in progress"); + console.error("Skipping payment as there's a payment in progress"); return cb(); } paymentInProgress = true; doPPLNSPayments(block.hash, block.pay_value, function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); + return cb(); }); - return cb(); } else { console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); return cb(); @@ -832,6 +844,5 @@ function altblockPayments(block, cb) { //initial_sync(); -setInterval(blockUnlocker, 2*60*1000); blockUnlocker(); altblockUnlocker(); \ No newline at end of file From 3d7b94e8c2f6950afbab8179f8183b9393290aa5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 3 Oct 2019 17:12:59 -0700 Subject: [PATCH 0565/1496] Commented extra block share output info --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 79be08607..22937d618 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -400,7 +400,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do for (let port in portShares) { const port_share = portShares[port] / sumAllPorts; pplns_port_shares[port] = port_share; - console.log("Port " + port + ": " + (100.0 * port_share).toFixed(2) + "%"); + //console.log("Port " + port + ": " + (100.0 * port_share).toFixed(2) + "%"); } global.database.setCache('pplns_port_shares', pplns_port_shares); global.database.setCache('pplns_window_time', (firstShareTime - lastShareTime) / 1000); From fd63199530be061b8eb6c1828328f871e5f83667 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 3 Oct 2019 17:14:42 -0700 Subject: [PATCH 0566/1496] Removed extra callback --- lib/blockManager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 22937d618..955a7ad60 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -614,7 +614,6 @@ function blockUnlocker() { }); } else if (topBlockHeight - block.height > global.config.payout.blocksRequired && (!is_pplns_block || block.pay_ready === true)) { blockPayments(block, function() { return next(); } ); - return next(); } else { return next(); } From 3fbe061545260e516eef2e6e3879758baf044291 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 3 Oct 2019 21:47:18 -0700 Subject: [PATCH 0567/1496] Fixed reward split finalizer --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 291e75ec9..3e441f277 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -755,6 +755,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.poolTypeEnum = global.protos.POOLTYPE.PPLNS; } + this.wallet_key = this.payout + " " + this.bitcoin + " " + this.poolTypeEnum + " " + JSON.stringify(this.payout_div) + " "; + // 3c) diff stuff this.lastShareTime = Math.floor(Date.now() / 1000); @@ -1191,7 +1193,7 @@ function recordShareData(miner, job, shareDiff, isBlockCandidate, hashHex, isTru if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.difficulty; let time_now = Date.now(); - let wallet_key = miner.address + " " + miner.paymentID + " " + miner.bitcoin + " " + miner.poolTypeEnum + " " + blockTemplate.port; + let wallet_key = miner.wallet_key + blockTemplate.port; if (!(wallet_key in walletAcc)) { walletAcc[wallet_key] = {}; From c1e118f56a70558f8af48f81714eb10cbb554899 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Oct 2019 12:45:46 -0700 Subject: [PATCH 0568/1496] Fixed for loki API change --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index fb21047b3..34eba13ea 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -209,9 +209,9 @@ function Coin(data){ } } - if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.miner_tx_hash}, function (body2) { + if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.block_header.miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { - console.error(port + ": block hash: " + blockHash + ": txid " + body.result.miner_tx_hash + ": " + JSON.stringify(body2)); + console.error(port + ": block hash: " + blockHash + ": txid " + body.result.block_header.miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); } const reward = body2.result.transfer.amount; From c51af46cae703ed7c35618ed6d958db757f4680a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Oct 2019 12:48:40 -0700 Subject: [PATCH 0569/1496] Fixed for loki API change --- lib/coins/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 34eba13ea..d1e0ca5d7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -208,10 +208,11 @@ function Coin(data){ } } } + const miner_tx_hash = body.result.miner_tx_hash == "" ? body.result.block_header.miner_tx_hash : body.result.miner_tx_hash; - if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": body.result.block_header.miner_tx_hash}, function (body2) { + if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { - console.error(port + ": block hash: " + blockHash + ": txid " + body.result.block_header.miner_tx_hash + ": " + JSON.stringify(body2)); + console.error(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); } const reward = body2.result.transfer.amount; From 1e1b31847b4c1bd5a4ea2ff014b7cee9959abcbb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Oct 2019 15:36:39 -0700 Subject: [PATCH 0570/1496] rx/0, rx/arq and k12 algo support --- lib/coins/xmr.js | 24 +++++++++++++++--------- package.json | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d1e0ca5d7..c4ec18d03 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -407,7 +407,7 @@ function Coin(data){ this.getMM_CHILD_PORTS = function() { return mm_child_port_set; } this.getDefaultAlgos = function() { - return [ "cn/r" ]; + return [ "cn/r", "rx/0" ]; } this.getDefaultAlgosPerf = function() { @@ -467,19 +467,22 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, blockTemplate) { switch (blockTemplate.port) { - case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon + case 11181: return blockTemplate.buffer[0] >= 8 ? multiHashing.k12(convertedBlob) : + multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR + case 18081: return blockTemplate.buffer[0] >= 12 ? multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0) : + multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO - case 19994: return multiHashing.cryptonight_pico(convertedBlob, 0); // ArqMa + case 19994: blockTemplate.buffer[0] >= 15 ? multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2) : + multiHashing.cryptonight_pico(convertedBlob, 0); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - //case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash??? + //case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash??? case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean @@ -561,8 +564,11 @@ function Coin(data){ if (m = reXMRig.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 21300) { - return "Please update your XMRig miner (" + agent + ") to v2.13.0+ to support new cn/r Monero algo before March 9 Monero fork"; + if (majorv + minorv < 32000) { + return "Please update your XMRig miner (" + agent + ") to v3.2.0+ to support new rx/0 Monero algo before November 30 Monero fork"; + } + if (majorv + minorv >= 40000 && majorv + minorv < 42000) { + return "Please update your XMRig miner (" + agent + ") to v4.2.0+ to support new rx/0 Monero algo before November 30 Monero fork"; } } else if (m = reXMRSTAK2.exec(agent)) { const majorv = parseInt(m[1]) * 10000; @@ -576,8 +582,8 @@ function Coin(data){ const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; - if (version < 1100) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.11.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/loki algo"; + if (version < 1400) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.14.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/0 Monero algo before November 30 Monero fork"; } } else if (m = reSRB.exec(agent)) { const majorv = parseInt(m[1]) * 10000; diff --git a/package.json b/package.json index 559fc1027..bc680b54f 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v13.0.4" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v15.0.0" } } From 2844e9d0f0477752f242cb27e91d9f7158410a01 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Oct 2019 15:41:39 -0700 Subject: [PATCH 0571/1496] bug fix --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c4ec18d03..067d3c593 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -477,8 +477,8 @@ function Coin(data){ multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO - case 19994: blockTemplate.buffer[0] >= 15 ? multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2) : - multiHashing.cryptonight_pico(convertedBlob, 0); // ArqMa + case 19994: return blockTemplate.buffer[0] >= 15 ? multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2) : + multiHashing.cryptonight_pico(convertedBlob, 0); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube From 9356a5586292ce16d384308ed7f6a5b82ce8d2a3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 16 Oct 2019 14:36:34 -0700 Subject: [PATCH 0572/1496] Added script to set min payout --- user_scripts/pay_set.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 user_scripts/pay_set.js diff --git a/user_scripts/pay_set.js b/user_scripts/pay_set.js new file mode 100644 index 000000000..d2e39624e --- /dev/null +++ b/user_scripts/pay_set.js @@ -0,0 +1,36 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.user) { + console.error("Please specify user address to set"); + process.exit(1); +} +const user = argv.user; +const pass = "pasword"; + +require("../init_mini.js").init(function() { + async.waterfall([ + function (callback) { + global.mysql.query("SELECT * FROM users WHERE username = ?", [user]).then(function (rows) { + if (rows.length == 1) { + console.error("Your password is already set, so can not set it again"); + console.log("Found rows in users table: " + rows.length); + process.exit(1); + } + callback(); + }); + }, + function (callback) { + global.mysql.query("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (?, ?, 0, 3000000000)", [user, pass]).then(function (rows) { + console.log("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (" + user + ", " + pass + ", 0, 3000000000)"); + callback(); + }); + }, + function (callback) { + console.log("Done."); + process.exit(0); + } + ]); +}); From 7dc8e5974932401e2ddc471acd2eeb84994069e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 16 Oct 2019 14:38:33 -0700 Subject: [PATCH 0573/1496] Added script to set min payout --- user_scripts/pay_set.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_scripts/pay_set.js b/user_scripts/pay_set.js index d2e39624e..9aac2136a 100644 --- a/user_scripts/pay_set.js +++ b/user_scripts/pay_set.js @@ -8,7 +8,7 @@ if (!argv.user) { process.exit(1); } const user = argv.user; -const pass = "pasword"; +const pass = "password"; require("../init_mini.js").init(function() { async.waterfall([ From 7e7960e9b620bcad8dd1d0ba3210d5385038c595 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Oct 2019 10:09:26 -0700 Subject: [PATCH 0574/1496] Allow 0 MSR blocks rewards in wallet --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 067d3c593..488931f2a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -218,9 +218,9 @@ function Coin(data){ const reward = body2.result.transfer.amount; if (reward !== reward_check || reward == 0) { - if (port == 38081 && reward < reward_check && reward != 0) { // MSR can have uncle block reward here + if (port == 38081 && reward < reward_check/* && reward != 0*/) { // MSR can have uncle block reward here } else { - console.error("Block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); + console.error("Port " + port + " block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); } } From 7acb12c1e6e375d9e6f8947f8e3278882f118090 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Oct 2019 10:11:40 -0700 Subject: [PATCH 0575/1496] Allow 0 MSR blocks rewards in wallet --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 488931f2a..ad2c27012 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -220,7 +220,7 @@ function Coin(data){ if (reward !== reward_check || reward == 0) { if (port == 38081 && reward < reward_check/* && reward != 0*/) { // MSR can have uncle block reward here } else { - console.error("Port " + port + " block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); + console.error(port + ": block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); } } From 7d6440c5ec521e90a2aaae045e3b7b86f2240649 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Oct 2019 10:40:05 -0700 Subject: [PATCH 0576/1496] Added login to remove MSR blocks that do not have incoming wallet tx --- lib/local_comms.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 593646884..4c0abfd06 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -420,12 +420,20 @@ function Database(){ } }; + let potentiallyBadBlocks = {}; // port -> block hash that has issues that will move into badBlocks after we will find good block for same port + let badBlocks = {}; // block hashes that we just start ignore (can't find incoming wallet tx) + this.storeAltBlock = function(blockId, blockData, callback){ this.refreshEnv(); try{ let blockDataDecoded = global.protos.AltBlock.decode(blockData); + if (blockDataDecoded.hash in badBlocks) { + console.error("Invalidating " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); + return callback(true); + } global.coinFuncs.getPortBlockHeaderByHash(blockDataDecoded.port, blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan + let is_orphan = false; if (err && header) { const is_orphan1 = header.orphan_status && header.orphan_status === true; const is_orphan2 = header.error && typeof(header.error.message) === 'string' && ( @@ -436,6 +444,7 @@ function Database(){ let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { + is_orphan = true; console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); err = false; header = {}; @@ -446,13 +455,26 @@ function Database(){ } else { console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); orphanBlocks[blockDataDecoded.hash] = time_now; + setTimeout(function () { return callback(false) }, 30*1000); + return; } } } - if (err || typeof(header) === 'undefined' || !header){ + if (err || typeof(header) === 'undefined' || !header) { + if (!(blockDataDecoded.port in potentiallyBadBlocks)) potentiallyBadBlocks[blockDataDecoded.port] = {}; + potentiallyBadBlocks[blockDataDecoded.port][blockDataDecoded.hash] = 1; setTimeout(function () { return callback(false) }, 30*1000); return; } + if (!is_orphan) { // now we found good block (not orphan) and we can move potentiallyBadBlocks to badBlocks + if (blockDataDecoded.port in potentiallyBadBlocks) { + for (let hash in potentiallyBadBlocks[blockDataDecoded.port]) { + console.log("Marking bad " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); + badBlocks[hash] = 1; + } + delete potentiallyBadBlocks[blockDataDecoded.port]; + } + } blockDataDecoded.value = header.reward; blockDataDecoded.pay_value = 0; //blockData = global.database.calculateShares(blockDataDecoded, blockId); From e7361aa4573670bf5240d5295907137b16aeb332 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Oct 2019 10:43:14 -0700 Subject: [PATCH 0577/1496] Added login to remove MSR blocks that do not have incoming wallet tx --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 4c0abfd06..6ad9a4a01 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -469,7 +469,7 @@ function Database(){ if (!is_orphan) { // now we found good block (not orphan) and we can move potentiallyBadBlocks to badBlocks if (blockDataDecoded.port in potentiallyBadBlocks) { for (let hash in potentiallyBadBlocks[blockDataDecoded.port]) { - console.log("Marking bad " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); + console.log("Marking bad " + blockDataDecoded.port + " port block hash " + hash); badBlocks[hash] = 1; } delete potentiallyBadBlocks[blockDataDecoded.port]; From 18895bfb2fccc04ce15bb661c58491fc59e0cf43 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Oct 2019 10:45:43 -0700 Subject: [PATCH 0578/1496] Added login to remove MSR blocks that do not have incoming wallet tx --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 6ad9a4a01..376b13fde 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -469,7 +469,7 @@ function Database(){ if (!is_orphan) { // now we found good block (not orphan) and we can move potentiallyBadBlocks to badBlocks if (blockDataDecoded.port in potentiallyBadBlocks) { for (let hash in potentiallyBadBlocks[blockDataDecoded.port]) { - console.log("Marking bad " + blockDataDecoded.port + " port block hash " + hash); + console.log("Allowing bad " + blockDataDecoded.port + " port block hash " + hash); badBlocks[hash] = 1; } delete potentiallyBadBlocks[blockDataDecoded.port]; From 6f2466f471073546e8d46030ac485868c1578ed1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Oct 2019 10:47:38 -0700 Subject: [PATCH 0579/1496] Added login to remove MSR blocks that do not have incoming wallet tx --- lib/local_comms.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 376b13fde..03eb8505a 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -427,10 +427,6 @@ function Database(){ this.refreshEnv(); try{ let blockDataDecoded = global.protos.AltBlock.decode(blockData); - if (blockDataDecoded.hash in badBlocks) { - console.error("Invalidating " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); - return callback(true); - } global.coinFuncs.getPortBlockHeaderByHash(blockDataDecoded.port, blockDataDecoded.hash, function(err, header){ // after 5 minutes of submit attempts finally cosider this block as orphan let is_orphan = false; @@ -460,7 +456,11 @@ function Database(){ } } } - if (err || typeof(header) === 'undefined' || !header) { + if (err || typeof(header) === 'undefined' || !header) { // bad blcok and not orphan + if (blockDataDecoded.hash in badBlocks) { + console.error("Invalidating " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); + return callback(true); + } if (!(blockDataDecoded.port in potentiallyBadBlocks)) potentiallyBadBlocks[blockDataDecoded.port] = {}; potentiallyBadBlocks[blockDataDecoded.port][blockDataDecoded.hash] = 1; setTimeout(function () { return callback(false) }, 30*1000); From e20a0d234b1948ca4d97b073c3f036f6861e319c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Oct 2019 11:22:58 -0700 Subject: [PATCH 0580/1496] Ignore zero MSR blocks --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ad2c27012..1577d33a1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -218,7 +218,7 @@ function Coin(data){ const reward = body2.result.transfer.amount; if (reward !== reward_check || reward == 0) { - if (port == 38081 && reward < reward_check/* && reward != 0*/) { // MSR can have uncle block reward here + if (port == 38081 && reward < reward_check && reward != 0) { // MSR can have uncle block reward here } else { console.error(port + ": block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); From 1dbacc1170ddd343dd60b651e33c201b011d2c4a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 14:19:20 -0700 Subject: [PATCH 0581/1496] Added custom algo support --- lib/pool.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3e441f277..481e15875 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -566,7 +566,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const login_diff_split = login.split("+"); const login_div_split = login_diff_split[0].split("%"); const login_paymentid_split = login_div_split[0].split("."); - let pass_split = pass.split(":"); + const pass_algo_split = pass.split("~"); + let pass_split = pass_algo_split[0].split(":"); // Workaround for a common mistake to put email without : before it // and also security measure to hide emails used as worker names @@ -712,12 +713,21 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return ""; }; - if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { - if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = global.coinFuncs.getDefaultAlgosPerf(); + if (pass_algo_split.length == 2) { + const algo_name = pass_algo_split[1]; + algos = [ algo_name ]; + algos_perf = {}; + algos_perf[algo_name] = 1; + algo_min_time = 0; + } else { - algos = global.coinFuncs.getDefaultAlgos(); - algos_perf = global.coinFuncs.getDefaultAlgosPerf(); - algo_min_time = 0; + if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { + if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = global.coinFuncs.getDefaultAlgosPerf(); + } else { + algos = global.coinFuncs.getDefaultAlgos(); + algos_perf = global.coinFuncs.getDefaultAlgosPerf(); + algo_min_time = 0; + } } const status = this.setAlgos(algos, algos_perf, algo_min_time); if (status != "") { From 3391ec461c5c3372fae0cbe604daf0fb42b88afe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 14:23:34 -0700 Subject: [PATCH 0582/1496] Switched AEON to K12 --- lib/coins/xmr.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1577d33a1..1b495d872 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -56,7 +56,7 @@ const port2blob_num = { }; const port2algo = { - "11181": "cn-lite/1", // Aeon + "11181": "k12", // Aeon "11898": "argon2/chukwa", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD @@ -444,8 +444,7 @@ function Coin(data){ if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; - if ("cn-lite" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite"]; - else if ("cn-lite/1" in algos_perf) coin_perf["AEON"] = algos_perf["cn-lite/1"]; + if ("k12" in algos_perf) coin_perf["AEON"] = algos_perf["k12"]; if ("cn-pico" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico"]; else if ("cn-pico/trtl" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico/trtl"]; @@ -467,8 +466,7 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, blockTemplate) { switch (blockTemplate.port) { - case 11181: return blockTemplate.buffer[0] >= 8 ? multiHashing.k12(convertedBlob) : - multiHashing.cryptonight_light(convertedBlob, 1); // Aeon + case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium From a6a11ad5d206e3de80fb98d3863b965aa39cca9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 14:49:27 -0700 Subject: [PATCH 0583/1496] Disable warnings for miners that do not support cn/r --- lib/pool.js | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 481e15875..c70e58f82 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1609,26 +1609,27 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply sendFinalReply(miner.error); return; } - let miner_id = miner.payout + ":" + miner.identifier + ":" + miner.ipAddress; - - let miner_agent_notification = params.agent ? global.coinFuncs.get_miner_agent_notification(params.agent) : false; - let miner_notification = miner_agent_notification ? miner_agent_notification : global.coinFuncs.get_miner_agent_warning_notification(params.agent); - miner_notification = miner_notification ? miner_notification : get_miner_notification(miner.payout); - if (miner_notification) { - if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { - lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent notification to " + miner.logString + ": " + miner_notification); - sendFinalReply(miner_notification + " (miner will connect after several attempts)"); - return; + + if ("cn/r" in miner.algos) { + let miner_agent_notification = params.agent ? global.coinFuncs.get_miner_agent_notification(params.agent) : false; + let miner_notification = miner_agent_notification ? miner_agent_notification : global.coinFuncs.get_miner_agent_warning_notification(params.agent); + miner_notification = miner_notification ? miner_notification : get_miner_notification(miner.payout); + if (miner_notification) { + if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { + lastMinerNotifyTime[miner.payout] = time_now; + console.error("Sent notification to " + miner.logString + ": " + miner_notification); + sendFinalReply(miner_notification + " (miner will connect after several attempts)"); + return; + } } - } - if (miner_agent_notification) { - if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { - lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); + if (miner_agent_notification) { + if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { + lastMinerNotifyTime[miner.payout] = time_now; + console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); + } + sendFinalReply(miner_agent_notification); + return; } - sendFinalReply(miner_agent_notification); - return; } activeMiners.set(minerId, miner); From a3530a670352b06796b927da322f180f2dd07b1d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 15:37:42 -0700 Subject: [PATCH 0584/1496] Updated aeon algo name --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1b495d872..03c6932e9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -56,7 +56,7 @@ const port2blob_num = { }; const port2algo = { - "11181": "k12", // Aeon + "11181": "kangarootwelve", // Aeon "11898": "argon2/chukwa", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD @@ -444,7 +444,7 @@ function Coin(data){ if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; - if ("k12" in algos_perf) coin_perf["AEON"] = algos_perf["k12"]; + if ("kangarootwelve" in algos_perf) coin_perf["AEON"] = algos_perf["kangarootwelve"]; if ("cn-pico" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico"]; else if ("cn-pico/trtl" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico/trtl"]; From a5e107009ca463c7f3973df15ee315d1578a8250 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 16:12:41 -0700 Subject: [PATCH 0585/1496] Reduced value of 0 cn/r perf --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 03c6932e9..8d7e88813 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -421,7 +421,7 @@ function Coin(data){ else if ("cn" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn"]; else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/4"]; else { - coin_perf[""] = 0.001; + coin_perf[""] = 1.0e-12; } if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; From ed71ee4d4d9c67e7aedc4203a076828dd3a828c6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 17:52:20 -0700 Subject: [PATCH 0586/1496] Aeon support --- lib/coins/xmr.js | 5 +++-- lib/pool.js | 7 ++++++- package.json | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8d7e88813..92f0918fc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -37,7 +37,7 @@ const port2coin = { "19994": "ARQ", }; const port2blob_num = { - "11181": 0, // AEON + "11181": 7, // AEON "11898": 2, // TRTL "12211": 4, // RYO "17750": 0, // XHV @@ -319,7 +319,7 @@ function Coin(data){ // The reserved space is 16 bytes long now in the following format: // Assuming that the extraNonce starts at byte 130: // |130-133|134-137|138-141|142-145| - // |minerNonce/extraNonce - 4 bytes|instanceId - Z4 bytes|clientPoolNonce - 4 bytes|clientNonce - 4 bytes| + // |minerNonce/extraNonce - 4 bytes|instanceId - 4 bytes|clientPoolNonce - 4 bytes|clientNonce - 4 bytes| // This is designed to allow a single block template to be used on up to 4 billion poolSlaves (clientPoolNonce) // Each with 4 billion clients. (clientNonce) // While being unique to this particular pool thread (instanceId) @@ -492,6 +492,7 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { + case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO diff --git a/lib/pool.js b/lib/pool.js index c70e58f82..b40e4b87e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -12,7 +12,8 @@ const fs = require('fs'); const child_process = require('child_process'); const httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; -const nonceCheck = new RegExp("^[0-9a-f]{8}$"); +const nonceCheck32 = new RegExp("^[0-9a-f]{8}$"); +const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); const hexMatch = new RegExp("^[0-9a-f]+$"); const baseDiff = global.coinFuncs.baseDiff(); @@ -1018,6 +1019,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, + blob_type: global.coinFuncs.portBlobType(bt.port), blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, @@ -1042,6 +1044,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, + blob_type: global.coinFuncs.portBlobType(bt.port), blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, @@ -1691,6 +1694,8 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } + const nonceCheck = job.blob_type == 7 ? nonceCheck64 : nonceCheck32; + if ((typeof params.nonce !== 'string') || !nonceCheck.test(params.nonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); diff --git a/package.json b/package.json index bc680b54f..2f6584e2d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "wallet-address-validator": "0.1.0", "zmq": "^2.15.3", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v5.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v6.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v15.0.0" } } From f5f6befb6e7da2b490ac297670885ca17669afd2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 18:05:41 -0700 Subject: [PATCH 0587/1496] Aeon support --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 92f0918fc..f50d377cf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -56,7 +56,7 @@ const port2blob_num = { }; const port2algo = { - "11181": "kangarootwelve", // Aeon + "11181": "k12", // Aeon "11898": "argon2/chukwa", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD @@ -444,7 +444,7 @@ function Coin(data){ if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; - if ("kangarootwelve" in algos_perf) coin_perf["AEON"] = algos_perf["kangarootwelve"]; + if ("k12" in algos_perf) coin_perf["AEON"] = algos_perf["k12"]; if ("cn-pico" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico"]; else if ("cn-pico/trtl" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico/trtl"]; From dab11127f44b0c62a547a50682ca9bde9085d027 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 18:22:30 -0700 Subject: [PATCH 0588/1496] Aeon support --- lib/pool.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b40e4b87e..67fe3196a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -542,14 +542,14 @@ let walletLastCheckTime = {}; //let cacheTargetHex = {}; -function getTargetHex(difficulty) { +function getTargetHex(difficulty, size) { //const result = cacheTargetHex[difficulty]; //if (result) return result; let padded = new Buffer(32); padded.fill(0); const diffBuff = baseDiff.div(difficulty).toBuffer(); diffBuff.copy(padded, 32 - diffBuff.length); - const buff = padded.slice(0, 4); + const buff = padded.slice(0, size); const buffArray = buff.toByteArray().reverse(); const buffReversed = new Buffer(buffArray); const new_result = buffReversed.toString('hex'); @@ -1014,12 +1014,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.newDiffRecommendation = null; } + const blob_type_num = global.coinFuncs.portBlobType(bt.port); + if (!this.proxy) { const blob = bt.nextBlob(); const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, - blob_type: global.coinFuncs.portBlobType(bt.port), + blob_type_num: blob_type_num, blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, @@ -1036,7 +1038,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer height: bt.height, seed_hash: bt.seed_hash, job_id: newJob.id, - target: getTargetHex(this.difficulty), + target: getTargetHex(this.difficulty, blob_type_num == 7 ? 8 : 4), id: this.id }; } else { @@ -1044,7 +1046,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), coin: coin, - blob_type: global.coinFuncs.portBlobType(bt.port), + blob_type_num: blob_type_num, blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, @@ -1694,7 +1696,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } - const nonceCheck = job.blob_type == 7 ? nonceCheck64 : nonceCheck32; + const nonceCheck = job.blob_type_num == 7 ? nonceCheck64 : nonceCheck32; if ((typeof params.nonce !== 'string') || !nonceCheck.test(params.nonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); From cde98debb8c95c19edb5688a849321474332227b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 18:41:44 -0700 Subject: [PATCH 0589/1496] Do not try to get status of 0 port --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 67fe3196a..6aafa051d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -343,7 +343,7 @@ let failedPortLastBlockHeaderCoinHashFactor = {}; function templateUpdate(coin, repeating) { const activePort = global.config.daemon["activePort" + coin]; let coinHashFactor = currCoinHashFactor[coin]; - if ((activePort && coinHashFactor) || (coin in failedPortLastBlockHeaderCoinHashFactor)) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + if (activePort && (coinHashFactor || (coin in failedPortLastBlockHeaderCoinHashFactor))) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (coin in failedPortLastBlockHeaderCoinHashFactor) { if (!coinHashFactor) coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; delete failedPortLastBlockHeaderCoinHashFactor[coin]; From 126adf58146200309a277393e50b6166fcd4700c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 18:55:12 -0700 Subject: [PATCH 0590/1496] Removed cn, cn/4 support for cn/r perf --- lib/coins/xmr.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f50d377cf..8000921f0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -418,8 +418,6 @@ function Coin(data){ let coin_perf = {}; if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; - else if ("cn" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn"]; - else if ("cn/4" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/4"]; else { coin_perf[""] = 1.0e-12; } From 4fd257d77b4a5f627bbe8d7d016578651204d61b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 19:05:59 -0700 Subject: [PATCH 0591/1496] Improved handling of non cn/r miners --- lib/coins/xmr.js | 3 --- lib/pool.js | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8000921f0..9d58c3b8d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -418,9 +418,6 @@ function Coin(data){ let coin_perf = {}; if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; - else { - coin_perf[""] = 1.0e-12; - } if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; diff --git a/lib/pool.js b/lib/pool.js index 6aafa051d..c12481773 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -704,8 +704,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const check = global.coinFuncs.algoCheck(this.algos); if (check !== true) return check; if ("cn-pico" in this.algos) this.algos["cn-pico/trtl"] = 1; - const coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); + let coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); if (coin_perf instanceof Object) { + if (!("" in coin_perf) || !("cn/r" in this.algos)) coin_perf[""] = 1.0e-12; this.coin_perf = coin_perf; } else { return coin_perf; From 66691654cf6a508d57bf4fa66ca8ca22b2f97d29 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 21:10:22 -0700 Subject: [PATCH 0592/1496] Adjust diff based on hash factors and not on miner algo_perf --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c12481773..13d5a3fba 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -706,7 +706,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if ("cn-pico" in this.algos) this.algos["cn-pico/trtl"] = 1; let coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); if (coin_perf instanceof Object) { - if (!("" in coin_perf) || !("cn/r" in this.algos)) coin_perf[""] = 1.0e-12; + if (!("" in coin_perf) || !global.coinFuncs.algoMainCheck(this.algos)) coin_perf[""] = 1.0e-12; this.coin_perf = coin_perf; } else { return coin_perf; @@ -878,9 +878,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { if (typeof(this.curr_coin) !== 'undefined') { - let factor = this.coin_perf[best_coin] / this.coin_perf[this.curr_coin]; - if (factor > 10) factor = 10; - else if (factor < 0.1) factor = 0.1; + let factor = currCoinHashFactorMM[best_coin] / currCoinHashFactorMM[this.curr_coin]; + //if (factor > 10) factor = 10; + //else if (factor < 0.1) factor = 0.1; //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; @@ -1616,7 +1616,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } - if ("cn/r" in miner.algos) { + if (global.coinFuncs.algoMainCheck(miner.algos)) { let miner_agent_notification = params.agent ? global.coinFuncs.get_miner_agent_notification(params.agent) : false; let miner_notification = miner_agent_notification ? miner_agent_notification : global.coinFuncs.get_miner_agent_warning_notification(params.agent); miner_notification = miner_notification ? miner_notification : get_miner_notification(miner.payout); From 18ca542e642d6717ba377cedd5ff99700db9fd6d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 21:11:19 -0700 Subject: [PATCH 0593/1496] Adjust diff based on hash factors and not on miner algo_perf --- lib/coins/xmr.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9d58c3b8d..91a63e076 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -452,9 +452,15 @@ function Coin(data){ return coin_perf; } + // returns true if algo set reported by miner is for main algo + this.algoMainCheck = function(algos) { + if ("cn/r" in algos) return true; + if ("rx/0" in algos) return true; + return false; + } // returns true if algo set reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - if ("cn/r" in algos) return true; + if (algoMainCheck(algos)) return true; for (let algo in all_algos) if (algo in algos) return true; return "algo array must include at least one supported pool algo"; } From 43237c37128e7136af4e6bc328d1cb15662b2b37 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 21:12:01 -0700 Subject: [PATCH 0594/1496] Adjust diff based on hash factors and not on miner algo_perf --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 91a63e076..339ad6025 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -460,7 +460,7 @@ function Coin(data){ } // returns true if algo set reported by miner is OK or error string otherwise this.algoCheck = function(algos) { - if (algoMainCheck(algos)) return true; + if (this.algoMainCheck(algos)) return true; for (let algo in all_algos) if (algo in algos) return true; return "algo array must include at least one supported pool algo"; } From 77046a7b28d31851d4ebc8ade1606a672211967b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 21:25:42 -0700 Subject: [PATCH 0595/1496] Adjust diff based on hash factors and not on miner algo_perf --- lib/pool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 13d5a3fba..993eb9b37 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -877,8 +877,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - if (typeof(this.curr_coin) !== 'undefined') { - let factor = currCoinHashFactorMM[best_coin] / currCoinHashFactorMM[this.curr_coin]; + const curr_hash_factor = typeof(this.curr_coin) === 'undefined' ? 1 : currCoinHashFactorMM[this.curr_coin]; + const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; + if (factor != 1) { //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; //const proxyMinerName = this.payout + ":" + this.identifier; From 91a61e64477b944de789f0fcae1f7d4e754fdcb3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 21:29:29 -0700 Subject: [PATCH 0596/1496] Adjust diff based on hash factors and not on miner algo_perf --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 993eb9b37..02aa3dd20 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -880,6 +880,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const curr_hash_factor = typeof(this.curr_coin) === 'undefined' ? 1 : currCoinHashFactorMM[this.curr_coin]; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; if (factor != 1) { + console.log(factor); //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; //const proxyMinerName = this.payout + ":" + this.identifier; From b42185bd72a6b70c370efe59af351dbfe08d0404 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 21:34:33 -0700 Subject: [PATCH 0597/1496] Adjust diff based on hash factors and not on miner algo_perf --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 02aa3dd20..70284b567 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -880,7 +880,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const curr_hash_factor = typeof(this.curr_coin) === 'undefined' ? 1 : currCoinHashFactorMM[this.curr_coin]; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; if (factor != 1) { - console.log(factor); + if (miner.debugMiner) console.log(factor); //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; //const proxyMinerName = this.payout + ":" + this.identifier; From 02dfc1aa68c86f48caa8ecba1abe9affe80508c0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 21:45:29 -0700 Subject: [PATCH 0598/1496] Adjust diff based on hash factors and not on miner algo_perf --- lib/pool.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 70284b567..e0c04b441 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -880,15 +880,18 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const curr_hash_factor = typeof(this.curr_coin) === 'undefined' ? 1 : currCoinHashFactorMM[this.curr_coin]; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; if (factor != 1) { - if (miner.debugMiner) console.log(factor); //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; - this.hashes *= factor; - if (this.hashesShift) this.hashesShift *= factor; - this.setNewDiff(this.calcNewDiff()); + if (this.hashes === 0) { + this.setNewDiff(this.difficulty * factor); + } else { + this.hashes *= factor; + if (this.hashesShift) this.hashesShift *= factor; + this.setNewDiff(this.calcNewDiff()); + } } this.curr_coin = best_coin; this.curr_coin_time = Date.now(); From f2bc8c62b5a4a57ee42d2ace285cb1c292ff2d6c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 22:03:56 -0700 Subject: [PATCH 0599/1496] More debug --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e0c04b441..68e5e5891 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -911,16 +911,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer target = 5; min_diff = 10*global.config.pool.minDifficulty; history_time = 5; + if (this.debugMiner) console.log(threadName + this.logString + ": calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { miner = minerWallets[this.payout]; target = 5; min_diff = 10*global.config.pool.minDifficulty; history_time = 5; + if (this.debugMiner) console.log(threadName + this.logString + ": calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; min_diff = this.proxy ? 10*global.config.pool.minDifficulty : global.config.pool.minDifficulty; history_time = 60; + if (this.debugMiner) console.log(threadName + this.logString + ": calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } if (miner.connectTimeShift) { if (Date.now() - miner.connectTimeShift > history_time*60*1000) { @@ -1497,7 +1500,7 @@ function processShare(miner, job, blockTemplate, params) { } else { // verify share if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - console.error(threadName + "Throttled down miner share (diff " + job.difficulty2 + ") submission from " + miner.logString); + console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); } process.send({type: 'throttledShare'}); addProxyMiner(miner); From 52f0e9e2c593c3eaf96cb363f46cf8fd3d66c475 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 22:18:32 -0700 Subject: [PATCH 0600/1496] More debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 68e5e5891..5a50e4843 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1498,6 +1498,7 @@ function processShare(miner, job, blockTemplate, params) { } isTrustedShare = true; } else { // verify share + if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); From 1c4b6b5d1e756295a384101d5cbc708f68de13f9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 22:27:39 -0700 Subject: [PATCH 0601/1496] More debug --- lib/pool.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5a50e4843..211b75608 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -163,21 +163,21 @@ function sendToWorkers(data) { }); } -function retargetMiners() { - debug(threadName + "Performing difficulty check on miners"); - - function retargetMiner(miner) { - if (miner.fixed_diff) { - const newDiff = miner.calcNewDiff(); - if (miner.difficulty * 10 < newDiff) { - console.log("Dropped low fixed diff " + miner.difficulty + " for " + miner.logString + " miner to " + newDiff + " dynamic diff"); - miner.fixed_diff = false; - if (miner.setNewDiff(newDiff)) miner.sendSameCoinJob(); - } - } else { - miner.updateDifficulty(); +function retargetMiner(miner) { + if (miner.fixed_diff) { + const newDiff = miner.calcNewDiff(); + if (miner.difficulty * 10 < newDiff) { + console.log("Dropped low fixed diff " + miner.difficulty + " for " + miner.logString + " miner to " + newDiff + " dynamic diff"); + miner.fixed_diff = false; + if (miner.setNewDiff(newDiff)) miner.sendSameCoinJob(); } + } else { + miner.updateDifficulty(); } +} + +function retargetMiners() { + debug(threadName + "Performing difficulty check on miners"); global.config.ports.forEach(function (portData) { minerCount[portData.port] = 0; }); const time_before = Date.now(); @@ -1505,7 +1505,8 @@ function processShare(miner, job, blockTemplate, params) { } process.send({type: 'throttledShare'}); addProxyMiner(miner); - miner.updateDifficulty(); + retargetMiner(miner); + //miner.updateDifficulty(); return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); From b9dc4549304ef3850614fd28b0bf05519325c9c9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 22:34:43 -0700 Subject: [PATCH 0602/1496] Fixing low diff share burst --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 211b75608..2789de34e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1505,6 +1505,7 @@ function processShare(miner, job, blockTemplate, params) { } process.send({type: 'throttledShare'}); addProxyMiner(miner); + proxyMiners[proxyMinerName].hashes += job.difficulty; retargetMiner(miner); //miner.updateDifficulty(); return null; From 03fac3a3bc3df705c058b7121f6be76464886b5c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 22:37:25 -0700 Subject: [PATCH 0603/1496] Fixing low diff share burst --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 2789de34e..9800ed2bf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1505,6 +1505,7 @@ function processShare(miner, job, blockTemplate, params) { } process.send({type: 'throttledShare'}); addProxyMiner(miner); + const proxyMinerName = miner.payout + ":" + miner.identifier; proxyMiners[proxyMinerName].hashes += job.difficulty; retargetMiner(miner); //miner.updateDifficulty(); From c7050ddf69d77fdd8714f6806bbfc65fc38bbd2b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 23:04:52 -0700 Subject: [PATCH 0604/1496] Fixing low diff share burst --- lib/pool.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9800ed2bf..c277f148b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -171,8 +171,8 @@ function retargetMiner(miner) { miner.fixed_diff = false; if (miner.setNewDiff(newDiff)) miner.sendSameCoinJob(); } - } else { - miner.updateDifficulty(); + } else if (miner.setNewDiff(miner.calcNewDiff())) { + miner.sendSameCoinJob(); } } @@ -949,11 +949,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return diff < min_diff ? min_diff : diff; }; - this.updateDifficulty = function () { - if (this.fixed_diff) return; - if (this.setNewDiff(this.calcNewDiff())) this.sendSameCoinJob(); - }; - this.setNewDiff = function (difficulty) { if (this.fixed_diff) return false; @@ -1508,7 +1503,6 @@ function processShare(miner, job, blockTemplate, params) { const proxyMinerName = miner.payout + ":" + miner.identifier; proxyMiners[proxyMinerName].hashes += job.difficulty; retargetMiner(miner); - //miner.updateDifficulty(); return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1656,7 +1650,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply let proxyMinerName = miner.payout + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { addProxyMiner(miner); - if (proxyMiners[proxyMinerName].hashes) miner.setNewDiff(miner.calcNewDiff()); + if (proxyMiners[proxyMinerName].hashes) retargetMiner(miner); } else { if (!(miner.payout in minerWallets)) { minerWallets[miner.payout] = {}; From 7bac0db935e5be21c77c80cf3f0b374f472ad0e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Oct 2019 23:32:26 -0700 Subject: [PATCH 0605/1496] Fixing low diff share burst --- lib/pool.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c277f148b..675e25b29 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -163,17 +163,18 @@ function sendToWorkers(data) { }); } -function retargetMiner(miner) { +function adjustMinerDiff(miner) { if (miner.fixed_diff) { const newDiff = miner.calcNewDiff(); if (miner.difficulty * 10 < newDiff) { console.log("Dropped low fixed diff " + miner.difficulty + " for " + miner.logString + " miner to " + newDiff + " dynamic diff"); miner.fixed_diff = false; - if (miner.setNewDiff(newDiff)) miner.sendSameCoinJob(); + if (miner.setNewDiff(newDiff)) return true; } } else if (miner.setNewDiff(miner.calcNewDiff())) { - miner.sendSameCoinJob(); + return true; } + return false; } function retargetMiners() { @@ -181,7 +182,10 @@ function retargetMiners() { global.config.ports.forEach(function (portData) { minerCount[portData.port] = 0; }); const time_before = Date.now(); - for (var [minerId, miner] of activeMiners) { retargetMiner(miner); ++ minerCount[miner.port]; } + for (var [minerId, miner] of activeMiners) { + if (adjustMinerDiff(miner)) miner.sendSameCoinJob(); + ++ minerCount[miner.port]; + } const elapsed = Date.now() - time_before; if (elapsed > 50) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id, ports: minerCount } }); @@ -1502,7 +1506,7 @@ function processShare(miner, job, blockTemplate, params) { addProxyMiner(miner); const proxyMinerName = miner.payout + ":" + miner.identifier; proxyMiners[proxyMinerName].hashes += job.difficulty; - retargetMiner(miner); + adjustMinerDiff(miner); return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1650,7 +1654,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply let proxyMinerName = miner.payout + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { addProxyMiner(miner); - if (proxyMiners[proxyMinerName].hashes) retargetMiner(miner); + if (proxyMiners[proxyMinerName].hashes) adjustMinerDiff(miner); } else { if (!(miner.payout in minerWallets)) { minerWallets[miner.payout] = {}; From 2a8cc2e5f7e1c3210476d7a6486d786870c0d98d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Oct 2019 01:03:27 -0700 Subject: [PATCH 0606/1496] More debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 339ad6025..f23425a06 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -462,7 +462,7 @@ function Coin(data){ this.algoCheck = function(algos) { if (this.algoMainCheck(algos)) return true; for (let algo in all_algos) if (algo in algos) return true; - return "algo array must include at least one supported pool algo"; + return "algo array must include at least one supported pool algo: [" + Object.keys(algos).join(", ") + "]"; } this.cryptoNight = function(convertedBlob, blockTemplate) { From 906403755ca34e7dced1ee891ae7c639d72eda07 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 29 Oct 2019 15:20:53 -0700 Subject: [PATCH 0607/1496] Adjusted coin location --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 675e25b29..53723429e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1350,7 +1350,7 @@ function recordShareData(miner, job, shareDiff, isBlockCandidate, hashHex, isTru process.send({type: 'normalShare'}); debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); } - if (activeBlockTemplates[blockTemplate.coin].idHash !== blockTemplate.idHash) { + if (activeBlockTemplates[job.coin].idHash !== blockTemplate.idHash) { process.send({type: 'outdatedShare'}); } From 9eb268269496d3843387873999fa537f0fe19879 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 09:58:40 -0700 Subject: [PATCH 0608/1496] Fixed xmrig detection --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f23425a06..7970a5f1d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -564,10 +564,10 @@ function Coin(data){ if (m = reXMRig.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 32000) { + if (majorv + minorv < 30200) { return "Please update your XMRig miner (" + agent + ") to v3.2.0+ to support new rx/0 Monero algo before November 30 Monero fork"; } - if (majorv + minorv >= 40000 && majorv + minorv < 42000) { + if (majorv + minorv >= 40000 && majorv + minorv < 40200) { return "Please update your XMRig miner (" + agent + ") to v4.2.0+ to support new rx/0 Monero algo before November 30 Monero fork"; } } else if (m = reXMRSTAK2.exec(agent)) { From 7f8a1851b3a23dae938a75c4629b6c29c1d96f84 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 15:53:54 -0700 Subject: [PATCH 0609/1496] Added hash factor debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 53723429e..c27fcc108 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -886,6 +886,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (factor != 1) { //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; + if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor); //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; From 7800bd204d9e0f1a7d73aa51e1e439df75b82a0e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 15:55:17 -0700 Subject: [PATCH 0610/1496] Added hash factor debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c27fcc108..f4d9248d2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -886,7 +886,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (factor != 1) { //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; - if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor); + if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; From 7925b52ea01161f07ca1b1c7e8e141bf5f454bd9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 16:07:03 -0700 Subject: [PATCH 0611/1496] Added hash factor debug --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f4d9248d2..d695f9ea2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -881,12 +881,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - const curr_hash_factor = typeof(this.curr_coin) === 'undefined' ? 1 : currCoinHashFactorMM[this.curr_coin]; - const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; + const curr_hash_factor = typeof(this.curr_coin) === 'undefined' ? 1 : lastCoinHashFactor[this.curr_coin]; + const factor = curr_hash_factor / lastCoinHashFactor[best_coin]; if (factor != 1) { //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; - if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); + if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + lastCoinHashFactor[best_coin] + ")"); //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; From 82640d6778891e194f0ebeb4b195be22dff8f729 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 16:14:09 -0700 Subject: [PATCH 0612/1496] Fixed diff jumps --- lib/pool.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d695f9ea2..1abb1748f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -881,12 +881,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - const curr_hash_factor = typeof(this.curr_coin) === 'undefined' ? 1 : lastCoinHashFactor[this.curr_coin]; + const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / lastCoinHashFactor[best_coin]; if (factor != 1) { //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; - if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + lastCoinHashFactor[best_coin] + ")"); + if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; @@ -898,8 +898,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.setNewDiff(this.calcNewDiff()); } } - this.curr_coin = best_coin; - this.curr_coin_time = Date.now(); + this.curr_coin = best_coin; + this.curr_coin_hash_factor = currCoinHashFactorMM[best_coin]; + this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplates[best_coin].height; } return best_coin; From 2cf28cf1605e482142ed3bb50a3e5701fe600ed6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 16:23:10 -0700 Subject: [PATCH 0613/1496] Fixed diff jumps --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1abb1748f..d6a6dc6aa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -882,11 +882,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }); if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; - const factor = curr_hash_factor / lastCoinHashFactor[best_coin]; + const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; if (factor != 1) { //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; - if (factor < 0.1) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); + if (factor < 0.1 || factor > 10) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; From 243c472c087bb70f82feb724e30c6a3f22c30291 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 16:29:14 -0700 Subject: [PATCH 0614/1496] Added hash factor debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index d6a6dc6aa..5bde74599 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -900,6 +900,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.curr_coin = best_coin; this.curr_coin_hash_factor = currCoinHashFactorMM[best_coin]; + if (this.curr_coin_hash_factor === 0) console.error("!!! " + best_coin + " hash factor: 0"); this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplates[best_coin].height; } From f59f0b624a7e46aa9eda8d54cdfb8b66e66462f1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 16:58:59 -0700 Subject: [PATCH 0615/1496] Added hash factor debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5bde74599..5d0a15b61 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -900,7 +900,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.curr_coin = best_coin; this.curr_coin_hash_factor = currCoinHashFactorMM[best_coin]; - if (this.curr_coin_hash_factor === 0) console.error("!!! " + best_coin + " hash factor: 0"); + if (this.curr_coin_hash_factor == 0) console.error("!!! " + best_coin + " hash factor: 0"); this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplates[best_coin].height; } From a0ddd39c8bda91677d6e13dbeaf283b9b9e84c4b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 17:22:29 -0700 Subject: [PATCH 0616/1496] Added hash factor debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5d0a15b61..a29cd5a4e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -886,7 +886,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (factor != 1) { //if (factor > 10) factor = 10; //else if (factor < 0.1) factor = 0.1; - if (factor < 0.1 || factor > 10) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); + if (factor < 0.1 || factor > 10) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " '" + this.curr_coin_hash_factor + "' (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); //const proxyMinerName = this.payout + ":" + this.identifier; //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; From e4648b046934dbda6b604f1d34ae8df7ee117ffa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Oct 2019 17:59:17 -0700 Subject: [PATCH 0617/1496] Removed debug info --- lib/pool.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a29cd5a4e..13e23a3f2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -884,12 +884,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; if (factor != 1) { - //if (factor > 10) factor = 10; - //else if (factor < 0.1) factor = 0.1; - if (factor < 0.1 || factor > 10) console.error("!!! " + this.curr_coin + " to " + best_coin + " hash factor: " + factor + " '" + this.curr_coin_hash_factor + "' (" + curr_hash_factor + " / " + currCoinHashFactorMM[best_coin] + ")"); - //const proxyMinerName = this.payout + ":" + this.identifier; - //if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes *= factor; - //if (this.payout in minerWallets) minerWallets[this.payout].hashes *= factor; if (this.hashes === 0) { this.setNewDiff(this.difficulty * factor); } else { @@ -900,7 +894,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.curr_coin = best_coin; this.curr_coin_hash_factor = currCoinHashFactorMM[best_coin]; - if (this.curr_coin_hash_factor == 0) console.error("!!! " + best_coin + " hash factor: 0"); this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplates[best_coin].height; } From 12acd285c51b482bdb437b65f7b2f7f010369458 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Nov 2019 21:34:07 -0800 Subject: [PATCH 0618/1496] ARQ post fork changes --- lib/coins/xmr.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7970a5f1d..f5527c1aa 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -64,7 +64,7 @@ const port2algo = { "18081": "cn/r", // XMR "18981": "cn/rwz", // Graft "19734": "cn/r", // SUMO - "19994": "cn-pico/trtl", // ArqMa + "19994": "rx/arq", // ArqMa "20189": "defyx", // Scala "22023": "rx/loki", // LOKI "24182": "cn-heavy/tube", // BitTube @@ -75,7 +75,7 @@ const port2algo = { }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); -const mm_port_set = { "19994": 13007 }; +const mm_port_set = { }; const fix_daemon_sh = "./fix_daemon.sh"; @@ -441,8 +441,10 @@ function Coin(data){ if ("k12" in algos_perf) coin_perf["AEON"] = algos_perf["k12"]; - if ("cn-pico" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico"]; - else if ("cn-pico/trtl" in algos_perf) coin_perf["ARQ"] = coin_perf["IRD"] = algos_perf["cn-pico/trtl"]; + if ("cn-pico" in algos_perf) coin_perf["IRD"] = algos_perf["cn-pico"]; + else if ("cn-pico/trtl" in algos_perf) coin_perf["IRD"] = algos_perf["cn-pico/trtl"]; + + if ("rx/arq" in algos_perf) coin_perf["ARQ"] = algos_perf["rx/arq"]; if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; From 12408f610b7d43e15664ef7bcabe5331a24c853b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Nov 2019 22:39:44 -0800 Subject: [PATCH 0619/1496] ARQ post fork changes --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f5527c1aa..9d7115428 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -478,8 +478,7 @@ function Coin(data){ multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO - case 19994: return blockTemplate.buffer[0] >= 15 ? multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2) : - multiHashing.cryptonight_pico(convertedBlob, 0); // ArqMa + case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube From e896afc0b52ec16a59d709c48168dff252c3ac6c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Nov 2019 16:37:06 -0800 Subject: [PATCH 0620/1496] Moved to v15 --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 0caec38ce..905709262 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.14.1.0 +sudo git checkout v0.15.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 826d52179..744695f0c 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.14.1.0 +sudo git checkout v0.15.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 294ec678d..860dae811 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.14.1.0 +sudo git checkout v0.15.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon From 7155ab0714d853e9a30cf9b31496abbfcdfb9869 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Nov 2019 16:38:21 -0800 Subject: [PATCH 0621/1496] Moved to v15 --- deployment/upgrade_monero.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index cf884b875..7bdd7514c 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.14.1.2 &&\ +sudo git checkout v0.15.0.1 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 9bc105fee8ee614142c97bb3dafeb895a656ee56 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Nov 2019 20:38:20 -0800 Subject: [PATCH 0622/1496] Disabled payment ID payments --- lib/payment_systems/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 2fcaea123..388795d79 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -737,10 +737,10 @@ function makePayments() { payeeObjects[payee.id] = payee; console.log("[+] " + payee.id + " as separate payment to integrated address. Amount: " + global.support.coinToDecimal(payee.amount)); payee.makePaymentAsIntegrated(); - } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold)) && payee.bitcoin === 0) { - payeeObjects[payee.id] = payee; - console.log("[+] " + payee.id + " as separate payment to payment ID address. Amount: " + global.support.coinToDecimal(payee.amount)); - payee.makePaymentWithID(); + //} else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold)) && payee.bitcoin === 0) { + // payeeObjects[payee.id] = payee; + // console.log("[+] " + payee.id + " as separate payment to payment ID address. Amount: " + global.support.coinToDecimal(payee.amount)); + // payee.makePaymentWithID(); } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold)) && payee.bitcoin === 1) { payeeObjects[payee.id] = payee; console.log("[+] " + payee.id + " as separate payment to bitcoin. Amount: " + global.support.coinToDecimal(payee.amount)); From 8d9647f362c59b3e487bd523eeb83286ddeb172f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 10:28:39 -0800 Subject: [PATCH 0623/1496] Post rx/0 update --- lib/coins/xmr.js | 97 +++++++++++++++--------------------------------- lib/pool.js | 26 ++++--------- 2 files changed, 38 insertions(+), 85 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9d7115428..70cdc49e7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -10,12 +10,13 @@ const child_process = require('child_process'); let hexChars = new RegExp("[0-9a-f]+"); -const reXMRig = /XMRig(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\./; // 2.8.0 -const reXMRSTAK = /\w+-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)/; // 2.5.0 -const reXMRSTAK2 = /\w+-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 -const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 -const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 -const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 +const reXMRig = /XMRig(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\./; // 2.8.0 +const reXMRSTAKRX = /\w+-stak-rx\/(\d+)\.(\d+)\.(\d+)/; // 1.0.1 +const reXMRSTAK = /\w+-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 +const reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // 0.3.2 +const reCAST = /cast_xmr\/(\d+)\.(\d+)\.(\d+)/; // 1.5.0 +const reSRB = /SRBMiner Cryptonight AMD GPU miner\/(\d+)\.(\d+)\.(\d+)/; // 1.6.8 +const reSRBMULTI = /SRBMiner-MULTI\/(\d+)\.(\d+)\.(\d+)/; // 0.1.5 const pool_nonce_size = 16+1; // 1 extra byte for old XMR and new TRTL daemon bugs const port2coin = { @@ -407,7 +408,7 @@ function Coin(data){ this.getMM_CHILD_PORTS = function() { return mm_child_port_set; } this.getDefaultAlgos = function() { - return [ "cn/r", "rx/0" ]; + return [ "rx/0" ]; } this.getDefaultAlgosPerf = function() { @@ -417,7 +418,10 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("cn/r" in algos_perf) coin_perf[""] = coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; + + if ("rx/0" in algos_perf) coin_perf[""] = algos_perf["rx/0"]; + + if ("cn/r" in algos_perf) coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; @@ -456,10 +460,14 @@ function Coin(data){ // returns true if algo set reported by miner is for main algo this.algoMainCheck = function(algos) { - if ("cn/r" in algos) return true; if ("rx/0" in algos) return true; return false; } + // returns true if algo set reported by miner is one of previous main algos + this.algoPrevMainCheck = function(algos) { + if ("cn/r" in algos) return true; + return false; + } // returns true if algo set reported by miner is OK or error string otherwise this.algoCheck = function(algos) { if (this.algoMainCheck(algos)) return true; @@ -474,8 +482,7 @@ function Coin(data){ case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return blockTemplate.buffer[0] >= 12 ? multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0) : - multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // XMR + case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa @@ -508,7 +515,7 @@ function Coin(data){ this.algoShortTypeStr = function(port, version) { if (port in port2algo) return port2algo[port]; console.error("Unknown " + port + " port for PoW type on " + version + " version"); - return "cn/r"; + return "rx/0"; } this.isMinerSupportAlgo = function(algo, algos) { @@ -517,81 +524,37 @@ function Coin(data){ return false; } - this.get_miner_agent_notification = function(agent) { - let m; - if (m = reXMRig.exec(agent)) { - const majorv = parseInt(m[1]) * 10000; - const minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 21300) { - return "You must update your XMRig miner (" + agent + ") to v2.13.0+"; - } - } else if (m = reXMRSTAK.exec(agent)) { - const majorv = parseInt(m[1]) * 10000; - const minorv = parseInt(m[2]) * 100; - if (majorv + minorv < 20900) { - return "You must update your xmr-stak miner (" + agent + ") to v2.9.0+ (and use cryptonight_r in config)"; - } - } else if (m = reXNP.exec(agent)) { - const majorv = parseInt(m[1]) * 10000; - const minorv = parseInt(m[2]) * 100; - const minorv2 = parseInt(m[3]); - const version = majorv + minorv + minorv2; - if (version < 3) { - return "You must update your xmr-node-proxy (" + agent + ") to version v0.8.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; - } - if (version >= 100 && version < 801) { - return "You must update your xmr-node-proxy (" + agent + ") to version v0.8.1+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; - } - } else if (m = reCAST.exec(agent)) { - const majorv = parseInt(m[1]) * 10000; - const minorv = parseInt(m[2]) * 100; - const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 <= 10800) { - return "Your cast-xmr miner (" + agent + ") is no longer supported (please change miner to xmrig-amd)"; - } - } else if (m = reSRB.exec(agent)) { - const majorv = parseInt(m[1]) * 10000; - const minorv = parseInt(m[2]) * 100; - const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 10709) { - return "You must update your SRBminer (" + agent + ") to version v1.7.9+"; - } - } - return false; - }; - this.get_miner_agent_warning_notification = function(agent) { let m; if (m = reXMRig.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; if (majorv + minorv < 30200) { - return "Please update your XMRig miner (" + agent + ") to v3.2.0+ to support new rx/0 Monero algo before November 30 Monero fork"; + return "Please update your XMRig miner (" + agent + ") to v3.2.0+ to support new rx/0 Monero algo"; } if (majorv + minorv >= 40000 && majorv + minorv < 40200) { - return "Please update your XMRig miner (" + agent + ") to v4.2.0+ to support new rx/0 Monero algo before November 30 Monero fork"; - } - } else if (m = reXMRSTAK2.exec(agent)) { - const majorv = parseInt(m[1]) * 10000; - const minorv = parseInt(m[2]) * 100; - const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 20900) { - return "Please update your xmr-stak miner (" + agent + ") to v2.9.0+ (and use cryptonight_r in config) to support new cn/r Monero algo before March 9 Monero fork"; + return "Please update your XMRig miner (" + agent + ") to v4.2.0+ to support new rx/0 Monero algo"; } + } else if (m = reXMRSTAKRX.exec(agent)) { + return false; + } else if (m = reXMRSTAK.exec(agent)) { + return "Please update your xmr-stak miner (" + agent + ") to xmr-stak-rx miner to support new rx/0 Monero algo"; } else if (m = reXNP.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); const version = majorv + minorv + minorv2; if (version < 1400) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.14.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/0 Monero algo before November 30 Monero fork"; + return "Please update your xmr-node-proxy (" + agent + ") to version v0.14.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/0 Monero algo"; } } else if (m = reSRB.exec(agent)) { + return "Please update your SRBminer (" + agent + ") to SRBminer-MULTI miner v0.1.5+ to support new rx/0 Monero algo"; + } else if (m = reSRBMULTI.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; const minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 10709) { - return "Please update your SRBminer (" + agent + ") to version v1.7.9+ to support new cn/r Monero algo before March 9 Monero fork"; + if (majorv + minorv + minorv2 < 105) { + return "Please update your SRBminer-MULTI (" + agent + ") to version v0.1.5+ to support new rx/0 Monero algo"; } } return false; diff --git a/lib/pool.js b/lib/pool.js index 13e23a3f2..fe687b065 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1622,24 +1622,14 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } - if (global.coinFuncs.algoMainCheck(miner.algos)) { - let miner_agent_notification = params.agent ? global.coinFuncs.get_miner_agent_notification(params.agent) : false; - let miner_notification = miner_agent_notification ? miner_agent_notification : global.coinFuncs.get_miner_agent_warning_notification(params.agent); - miner_notification = miner_notification ? miner_notification : get_miner_notification(miner.payout); - if (miner_notification) { - if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { - lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent notification to " + miner.logString + ": " + miner_notification); - sendFinalReply(miner_notification + " (miner will connect after several attempts)"); - return; - } - } - if (miner_agent_notification) { - if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { - lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); - } - sendFinalReply(miner_agent_notification); + const miner_agent_notification = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos) + ? global.coinFuncs.get_miner_agent_warning_notification(params.agent) : false; + const miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); + if (miner_notification) { + if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { + lastMinerNotifyTime[miner.payout] = time_now; + console.error("Sent notification to " + miner.logString + ": " + miner_notification); + sendFinalReply(miner_notification + " (miner will connect after several attempts)"); return; } } From 069f611799e0bdf30d8a9953038285f61a0563ab Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 11:03:57 -0800 Subject: [PATCH 0624/1496] Fixed XMR algo --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 70cdc49e7..0128e16e1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -62,7 +62,7 @@ const port2algo = { "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD "17750": "cn-heavy/xhv", // Haven - "18081": "cn/r", // XMR + "18081": "rx/0", // XMR "18981": "cn/rwz", // Graft "19734": "cn/r", // SUMO "19994": "rx/arq", // ArqMa From cee6ae06f2283d6d2f5b044a9261af50f84a3e6c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 11:21:16 -0800 Subject: [PATCH 0625/1496] Updated default perf --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0128e16e1..cd0cfe0f8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -412,7 +412,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "cn/r": 1, "cn/half": 1.9, "cn/rwz": 1.3, "cn/zls": 1.3, "cn/double": 0.5 }; + return { "rx/0": 1, "rx/loki": 1 }; } this.convertAlgosToCoinPerf = function(algos_perf) { From 9ad0da811b70da84472966d715984d8f3d5f50da Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 12:20:12 -0800 Subject: [PATCH 0626/1496] Remove old miners --- lib/coins/xmr.js | 12 ++++++++++++ lib/pool.js | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index cd0cfe0f8..c5371f683 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -560,6 +560,18 @@ function Coin(data){ return false; }; + this.get_miner_agent_not_supported_notification = function(agent) { + let m; + if (m = reXMRSTAKRX.exec(agent)) { + return false; + } else if (m = reXMRSTAK.exec(agent)) { + return "You must update your xmr-stak miner (" + agent + ") to xmr-stak-rx miner to support new rx/0 Monero algo"; + } else if (m = reSRB.exec(agent)) { + return "You must update your SRBminer (" + agent + ") to SRBminer-MULTI miner v0.1.5+ to support new rx/0 Monero algo"; + } + return false; + }; + this.fixDaemonIssue = function(height, top_height, port) { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " has stuck block template", diff --git a/lib/pool.js b/lib/pool.js index fe687b065..3a2194e31 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1622,6 +1622,13 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply return; } + const miner_agent_not_supported_notification = global.coinFuncs.get_miner_agent_not_supported_notification(params.agent); + if (miner_agent_not_supported_notification) { + console.error("Sent notification to " + miner.logString + ": " + miner_agent_not_supported_notification); + sendFinalReply(miner_agent_not_supported_notification); + return; + } + const miner_agent_notification = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos) ? global.coinFuncs.get_miner_agent_warning_notification(params.agent) : false; const miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); From 1d91b2ce6d3c9185d4a7f3cf433eac15bef7d870 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 12:24:16 -0800 Subject: [PATCH 0627/1496] Remove old miners --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3a2194e31..129684ad9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1624,7 +1624,10 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply const miner_agent_not_supported_notification = global.coinFuncs.get_miner_agent_not_supported_notification(params.agent); if (miner_agent_not_supported_notification) { - console.error("Sent notification to " + miner.logString + ": " + miner_agent_not_supported_notification); + if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { + console.error("Sent notification to " + miner.logString + ": " + miner_agent_not_supported_notification); + lastMinerLogTime[miner.payout] = time_now; + } sendFinalReply(miner_agent_not_supported_notification); return; } From c1942a21de463ab7076f2be53f23a88b2596cd21 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 15:32:57 -0800 Subject: [PATCH 0628/1496] Added agent for debug --- lib/pool.js | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 129684ad9..78b62b0f2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -602,6 +602,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.debugMiner = this.payout == global.coinFuncs.testDevAddress; this.email = pass_split.length === 2 ? pass_split[1] : ""; this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + ipAddress + ")"; + this.agent = agent; // 2) check stuff @@ -2117,19 +2118,17 @@ if (cluster.isMaster) { } let sendReply = function (error, result) { - if (!socket.writable) { - return; - } - let sendData = JSON.stringify({ - id: jsonData.id, - jsonrpc: "2.0", - error: error ? {code: -1, message: error} : null, - result: result - }) + "\n"; - socket.write(sendData); + if (!socket.writable) return; + socket.write(JSON.stringify({ + id: jsonData.id, + jsonrpc: "2.0", + error: error ? {code: -1, message: error} : null, + result: result + }) + "\n"); }; let sendFinalReply = function (error) { setTimeout(function() { + if (!socket.writable) return; socket.end(JSON.stringify({ id: jsonData.id, jsonrpc: "2.0", @@ -2148,15 +2147,12 @@ if (cluster.isMaster) { let dataBuffer = ''; let pushMessage = function (method, params) { - if (!socket.writable) { - return; - } - let sendData = JSON.stringify({ - jsonrpc: "2.0", - method: method, - params: params - }) + "\n"; - socket.write(sendData); + if (!socket.writable) return; + socket.write(JSON.stringify({ + jsonrpc: "2.0", + method: method, + params: params + }) + "\n"); }; socket.on('data', function (d) { @@ -2205,7 +2201,7 @@ if (cluster.isMaster) { dataBuffer = incomplete; } }).on('error', function (err) { - debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); + //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { pushMessage = function () { }; From 01d16673c52da0b2e7a22c3d25d77b66d67d26e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 16:10:33 -0800 Subject: [PATCH 0629/1496] Fixed default algo perf for old xmrig --- lib/coins/xmr.js | 4 ++++ lib/pool.js | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c5371f683..2442096c0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -415,6 +415,10 @@ function Coin(data){ return { "rx/0": 1, "rx/loki": 1 }; } + this.getPrevAlgosPerf = function() { + return { "cn/r": 1, "cn/half": 1.9, "cn/rwz": 1.3, "cn/zls": 1.3, "cn/double": 0.5 }; + } + this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; diff --git a/lib/pool.js b/lib/pool.js index 78b62b0f2..8987d9b3d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -709,6 +709,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const check = global.coinFuncs.algoCheck(this.algos); if (check !== true) return check; if ("cn-pico" in this.algos) this.algos["cn-pico/trtl"] = 1; + + if (!(algos_perf && algos_perf instanceof Object)) { + if (global.coinFuncs.algoMainCheck(this.algos)) algos_perf = global.coinFuncs.getDefaultAlgosPerf(); + else algos_perf = global.coinFuncs.getPrevAlgosPerf(); + } + let coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); if (coin_perf instanceof Object) { if (!("" in coin_perf) || !global.coinFuncs.algoMainCheck(this.algos)) coin_perf[""] = 1.0e-12; @@ -727,15 +733,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer algos_perf[algo_name] = 1; algo_min_time = 0; - } else { - if (algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching) { - if (!algos_perf || !(algos_perf instanceof Object)) algos_perf = global.coinFuncs.getDefaultAlgosPerf(); - } else { - algos = global.coinFuncs.getDefaultAlgos(); - algos_perf = global.coinFuncs.getDefaultAlgosPerf(); - algo_min_time = 0; - } + } else if (!(algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching)) { + algos = global.coinFuncs.getDefaultAlgos(); + algos_perf = global.coinFuncs.getDefaultAlgosPerf(); + algo_min_time = 0; } + const status = this.setAlgos(algos, algos_perf, algo_min_time); if (status != "") { this.error = status; From 57558948d1acc8f7299a9f20dad83b0638f830c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 16:27:31 -0800 Subject: [PATCH 0630/1496] Added new script --- user_scripts/unban_user.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 user_scripts/unban_user.js diff --git a/user_scripts/unban_user.js b/user_scripts/unban_user.js new file mode 100644 index 000000000..59c4fa73a --- /dev/null +++ b/user_scripts/unban_user.js @@ -0,0 +1,33 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.user) { + console.error("Please specify user address to unban"); + process.exit(1); +} +const user = argv.user; + +require("../init_mini.js").init(function() { + async.waterfall([ + function (callback) { + global.mysql.query('DELETE FROM bans WHERE mining_address = ?', [user]).then(function (rows) { + callback(); + }); + }, + function (callback) { + global.mysql.query("SELECT * FROM bans").then(function (rows) { + for (let i in rows) { + const row = rows[i]; + console.log(row.mining_address + ": " + row.reason); + } + callback(); + }); + }, + function (callback) { + console.log("Done. User was unbanned."); + process.exit(0); + } + ]); +}); From 486269436574a0fcefd28c08a207e2ea8a78f3ad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 17:12:40 -0800 Subject: [PATCH 0631/1496] Socket based miners --- lib/pool.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8987d9b3d..5ad1ef563 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1596,8 +1596,7 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { - let miner; +function handleMinerData(socket, method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { switch (method) { case 'login': if (ip in bannedIPs) { @@ -1611,7 +1610,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - miner = new Miner( + let miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); @@ -1648,6 +1647,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } } + socket.miner = miner; activeMiners.set(minerId, miner); if (!miner.proxy) { @@ -1673,8 +1673,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply status: 'OK' }); break; + case 'getjob': - miner = activeMiners.get(params.id); + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1689,8 +1690,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } miner.sendBestCoinJob(); break; + case 'submit': - miner = activeMiners.get(params.id); + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1807,8 +1809,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply sendReply(null, {status: 'OK'}); //if (miner.debugMiner) console.log("SUBMIT OK"); break; + case 'keepalived': - miner = activeMiners.get(params.id); + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -2140,7 +2143,7 @@ if (cluster.isMaster) { }) + "\n"); }, 9 * 1000); }; - handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); + handleMinerData(socket, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); }; function socketConn(socket) { @@ -2206,8 +2209,8 @@ if (cluster.isMaster) { }).on('error', function (err) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { - pushMessage = function () { - }; + pushMessage = function () {}; + if (socket.miner) activeMiners.delete(socket.miner.id); }); } From 93fd7b3f3e86f55dcba941b027cf353b7e885b9d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 17:14:37 -0800 Subject: [PATCH 0632/1496] Revert "Socket based miners" This reverts commit 486269436574a0fcefd28c08a207e2ea8a78f3ad. --- lib/pool.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5ad1ef563..8987d9b3d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1596,7 +1596,8 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(socket, method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { +function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { + let miner; switch (method) { case 'login': if (ip in bannedIPs) { @@ -1610,7 +1611,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - let miner = new Miner( + miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); @@ -1647,7 +1648,6 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi } } - socket.miner = miner; activeMiners.set(minerId, miner); if (!miner.proxy) { @@ -1673,9 +1673,8 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi status: 'OK' }); break; - case 'getjob': - let miner = socket.miner; + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1690,9 +1689,8 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi } miner.sendBestCoinJob(); break; - case 'submit': - let miner = socket.miner; + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1809,9 +1807,8 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi sendReply(null, {status: 'OK'}); //if (miner.debugMiner) console.log("SUBMIT OK"); break; - case 'keepalived': - let miner = socket.miner; + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -2143,7 +2140,7 @@ if (cluster.isMaster) { }) + "\n"); }, 9 * 1000); }; - handleMinerData(socket, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); + handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); }; function socketConn(socket) { @@ -2209,8 +2206,8 @@ if (cluster.isMaster) { }).on('error', function (err) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { - pushMessage = function () {}; - if (socket.miner) activeMiners.delete(socket.miner.id); + pushMessage = function () { + }; }); } From 809ab0becf93cf41cd62f526a2352238c66a0932 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 17:15:55 -0800 Subject: [PATCH 0633/1496] Revert "Revert "Socket based miners"" This reverts commit 93fd7b3f3e86f55dcba941b027cf353b7e885b9d. --- lib/pool.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8987d9b3d..5ad1ef563 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1596,8 +1596,7 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { - let miner; +function handleMinerData(socket, method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { switch (method) { case 'login': if (ip in bannedIPs) { @@ -1611,7 +1610,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - miner = new Miner( + let miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); @@ -1648,6 +1647,7 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } } + socket.miner = miner; activeMiners.set(minerId, miner); if (!miner.proxy) { @@ -1673,8 +1673,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply status: 'OK' }); break; + case 'getjob': - miner = activeMiners.get(params.id); + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1689,8 +1690,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply } miner.sendBestCoinJob(); break; + case 'submit': - miner = activeMiners.get(params.id); + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1807,8 +1809,9 @@ function handleMinerData(method, params, ip, portData, sendReply, sendFinalReply sendReply(null, {status: 'OK'}); //if (miner.debugMiner) console.log("SUBMIT OK"); break; + case 'keepalived': - miner = activeMiners.get(params.id); + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -2140,7 +2143,7 @@ if (cluster.isMaster) { }) + "\n"); }, 9 * 1000); }; - handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); + handleMinerData(socket, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); }; function socketConn(socket) { @@ -2206,8 +2209,8 @@ if (cluster.isMaster) { }).on('error', function (err) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { - pushMessage = function () { - }; + pushMessage = function () {}; + if (socket.miner) activeMiners.delete(socket.miner.id); }); } From 2fbf982a24b10afd853de9d84dc3d26b734173ce Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 17:19:46 -0800 Subject: [PATCH 0634/1496] Socket based miners --- lib/pool.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5ad1ef563..9439dc69f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1597,6 +1597,8 @@ function get_miner_notification(payout) { } function handleMinerData(socket, method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { + let miner; + switch (method) { case 'login': if (ip in bannedIPs) { @@ -1610,7 +1612,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - let miner = new Miner( + miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); @@ -1675,7 +1677,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'getjob': - let miner = socket.miner; + miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1692,7 +1694,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'submit': - let miner = socket.miner; + miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1811,7 +1813,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'keepalived': - let miner = socket.miner; + miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; From 37e1456093ab661b22b6b9b9c942bb312795110c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 17:23:45 -0800 Subject: [PATCH 0635/1496] Revert "Socket based miners" This reverts commit 2fbf982a24b10afd853de9d84dc3d26b734173ce. --- lib/pool.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9439dc69f..5ad1ef563 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1597,8 +1597,6 @@ function get_miner_notification(payout) { } function handleMinerData(socket, method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { - let miner; - switch (method) { case 'login': if (ip in bannedIPs) { @@ -1612,7 +1610,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - miner = new Miner( + let miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); @@ -1677,7 +1675,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'getjob': - miner = socket.miner; + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1694,7 +1692,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'submit': - miner = socket.miner; + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; @@ -1813,7 +1811,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'keepalived': - miner = socket.miner; + let miner = socket.miner; if (!miner) { sendReply('Unauthenticated'); return; From 764038545a1f857bb8a9e1b9d9f9d97e822afc0a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Nov 2019 17:38:29 -0800 Subject: [PATCH 0636/1496] Just remove activeMiners with closed socket --- lib/pool.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5ad1ef563..d9a4fb5c3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1597,6 +1597,8 @@ function get_miner_notification(payout) { } function handleMinerData(socket, method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { + let miner; + switch (method) { case 'login': if (ip in bannedIPs) { @@ -1610,7 +1612,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - let miner = new Miner( + miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); @@ -1647,7 +1649,8 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi } } - socket.miner = miner; + if (!socket.miner_ids) socket.miner_ids = []; + socket.miner_ids.push(minerId); activeMiners.set(minerId, miner); if (!miner.proxy) { @@ -1675,7 +1678,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'getjob': - let miner = socket.miner; + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1692,7 +1695,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'submit': - let miner = socket.miner; + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1811,7 +1814,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'keepalived': - let miner = socket.miner; + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -2210,7 +2213,7 @@ if (cluster.isMaster) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { pushMessage = function () {}; - if (socket.miner) activeMiners.delete(socket.miner.id); + if (socket.miner_ids) socket.miner_ids.forEach(miner_id => activeMiners.delete(miner_id)); }); } From e28c9c2fe970f08be2fde71707ab126832e563fc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 10:33:59 -0800 Subject: [PATCH 0637/1496] Balance move force --- user_scripts/balance_move_force.js | 92 ++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 user_scripts/balance_move_force.js diff --git a/user_scripts/balance_move_force.js b/user_scripts/balance_move_force.js new file mode 100644 index 000000000..4aefc2437 --- /dev/null +++ b/user_scripts/balance_move_force.js @@ -0,0 +1,92 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.old_user) { + console.error("Please specify old_user address to move balance from"); + process.exit(1); +} +const old_user = argv.old_user; + +if (!argv.new_user) { + console.error("Please specify new_user address to move balance to"); + process.exit(1); +} +const new_user = argv.new_user; + +require("../init_mini.js").init(function() { + const old_parts = old_user.split("."); + const old_address = old_parts.length === 1 ? old_user : old_parts[0]; + const old_payment_id = old_parts.length === 2 ? old_parts[1] : null; + + const new_parts = new_user.split("."); + const new_address = new_parts.length === 1 ? new_user : new_parts[0]; + const new_payment_id = new_parts.length === 2 ? new_parts[1] : null; + + console.log("Old Address: " + old_address); + console.log("Old PaymentID: " + old_payment_id); + console.log("New Address: " + new_address); + console.log("New PaymentID: " + new_payment_id); + + const old_where_str = old_payment_id === null ? "payment_address = '" + old_address + "' AND payment_id IS NULL" + : "payment_address = '" + old_address + "' AND payment_id = '" + old_payment_id + "'"; + + const new_where_str = new_payment_id === null ? "payment_address = '" + new_address + "' AND payment_id IS NULL" + : "payment_address = '" + new_address + "' AND payment_id = '" + new_payment_id + "'"; + + let old_amount; + + async.waterfall([ + function (callback) { + global.mysql.query("SELECT * FROM balance WHERE " + old_where_str).then(function (rows) { + if (rows.length != 1) { + console.error("Can't find old_user!"); + process.exit(1); + } + old_amount = rows[0].amount; + console.log("Old address amount: " + global.support.coinToDecimal(old_amount)); + console.log("Old address last update time: " + rows[0].last_edited); + callback(); + }); + }, + function (callback) { + global.mysql.query("SELECT * FROM balance WHERE " + new_where_str).then(function (rows) { + if (rows.length != 1) { + console.error("Can't find new_user!"); + process.exit(1); + } + console.log("New address amount: " + global.support.coinToDecimal(rows[0].amount)); + callback(); + }); + }, + function (callback) { + global.mysql.query("UPDATE balance SET amount = '0' WHERE " + old_where_str).then(function (rows) { + console.log("UPDATE balance SET amount = '0' WHERE " + old_where_str); + callback(); + }); + }, + function (callback) { + global.mysql.query("UPDATE balance SET amount = amount + " + old_amount + " WHERE " + new_where_str).then(function (rows) { + console.log("UPDATE balance SET amount = amount + " + old_amount + " WHERE " + new_where_str); + callback(); + }); + }, + function (callback) { + global.mysql.query("SELECT * FROM balance WHERE " + old_where_str).then(function (rows) { + console.log("New old address amount: " + global.support.coinToDecimal(rows[0].amount)); + callback(); + }); + }, + function (callback) { + global.mysql.query("SELECT * FROM balance WHERE " + new_where_str).then(function (rows) { + console.log("New new address amount: " + global.support.coinToDecimal(rows[0].amount)); + callback(); + }); + }, + function (callback) { + console.log("DONE"); + process.exit(0); + } + ]); +}); From b306017e29c5e59244dfdd5c76fd6b7f6b7b4686 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 14:41:48 -0800 Subject: [PATCH 0638/1496] Do not send not supported algo to miner --- lib/pool.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d9a4fb5c3..ce28f9d00 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -717,7 +717,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); if (coin_perf instanceof Object) { - if (!("" in coin_perf) || !global.coinFuncs.algoMainCheck(this.algos)) coin_perf[""] = 1.0e-12; + if (!("" in coin_perf && global.coinFuncs.algoMainCheck(this.algos))) coin_perf[""] = 0; this.coin_perf = coin_perf; } else { return coin_perf; @@ -884,6 +884,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer best_coin_perf = coin_perf; } }); + if (best_coin_perf == 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; @@ -1092,18 +1093,18 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.sendSameCoinJob = function () { - const coin = typeof(this.curr_coin) !== 'undefined' ? this.curr_coin : this.selectBestCoin() - return this.sendCoinJob(coin, getCoinJobParams(coin)); + const coin = typeof(this.curr_coin) !== 'undefined' ? this.curr_coin : this.selectBestCoin(); + if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); }; this.getBestCoinJob = function() { const coin = this.selectBestCoin(); - return this.getCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) this.getCoinJob(coin, getCoinJobParams(coin)); }; this.sendBestCoinJob = function() { const coin = this.selectBestCoin(); - return this.sendCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); }; } } From 17b4496e4a79469a187b79a28f742a6dc4db3528 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 14:51:03 -0800 Subject: [PATCH 0639/1496] Do not send not supported algo to miner --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ce28f9d00..e88d20131 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1094,17 +1094,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.sendSameCoinJob = function () { const coin = typeof(this.curr_coin) !== 'undefined' ? this.curr_coin : this.selectBestCoin(); - if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); + /*if (coin !== false)*/ this.sendCoinJob(coin, getCoinJobParams(coin)); }; this.getBestCoinJob = function() { const coin = this.selectBestCoin(); - if (coin !== false) this.getCoinJob(coin, getCoinJobParams(coin)); + /*if (coin !== false)*/ this.getCoinJob(coin, getCoinJobParams(coin)); }; this.sendBestCoinJob = function() { const coin = this.selectBestCoin(); - if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); + /*if (coin !== false)*/ this.sendCoinJob(coin, getCoinJobParams(coin)); }; } } From 95aea72aac60d5b984a94c729e10d642930c5229 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 15:02:07 -0800 Subject: [PATCH 0640/1496] Do not send not supported algo to miner --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e88d20131..287c0a709 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -717,7 +717,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let coin_perf = global.coinFuncs.convertAlgosToCoinPerf(algos_perf); if (coin_perf instanceof Object) { - if (!("" in coin_perf && global.coinFuncs.algoMainCheck(this.algos))) coin_perf[""] = 0; + if (!("" in coin_perf && global.coinFuncs.algoMainCheck(this.algos))) coin_perf[""] = -1; this.coin_perf = coin_perf; } else { return coin_perf; @@ -884,7 +884,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer best_coin_perf = coin_perf; } }); - if (best_coin_perf == 0) return false; + if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; @@ -1094,17 +1094,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.sendSameCoinJob = function () { const coin = typeof(this.curr_coin) !== 'undefined' ? this.curr_coin : this.selectBestCoin(); - /*if (coin !== false)*/ this.sendCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); }; this.getBestCoinJob = function() { const coin = this.selectBestCoin(); - /*if (coin !== false)*/ this.getCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) this.getCoinJob(coin, getCoinJobParams(coin)); }; this.sendBestCoinJob = function() { const coin = this.selectBestCoin(); - /*if (coin !== false)*/ this.sendCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); }; } } From c7471586131adadfb8ba5e535db3410181221b0d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 15:23:23 -0800 Subject: [PATCH 0641/1496] Do not send not supported algo to miner --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 287c0a709..1a0300a4f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -884,7 +884,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer best_coin_perf = coin_perf; } }); - if (best_coin_perf < 0) return false; + //if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; @@ -1094,17 +1094,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.sendSameCoinJob = function () { const coin = typeof(this.curr_coin) !== 'undefined' ? this.curr_coin : this.selectBestCoin(); - if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) return this.sendCoinJob(coin, getCoinJobParams(coin)); }; this.getBestCoinJob = function() { const coin = this.selectBestCoin(); - if (coin !== false) this.getCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) return this.getCoinJob(coin, getCoinJobParams(coin)); }; this.sendBestCoinJob = function() { const coin = this.selectBestCoin(); - if (coin !== false) this.sendCoinJob(coin, getCoinJobParams(coin)); + if (coin !== false) return this.sendCoinJob(coin, getCoinJobParams(coin)); }; } } From 0950450dfb1d33c834f8afa0129c0ae964794917 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 15:26:18 -0800 Subject: [PATCH 0642/1496] Do not send not supported algo to miner --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1a0300a4f..266ce92e2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -884,7 +884,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer best_coin_perf = coin_perf; } }); - //if (best_coin_perf < 0) return false; + if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; From 583100e0456560c8522444447bf047d35100db4a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 16:50:26 -0800 Subject: [PATCH 0643/1496] Added some socket based miner debug --- lib/pool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 266ce92e2..c543d28c8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1653,6 +1653,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (!socket.miner_ids) socket.miner_ids = []; socket.miner_ids.push(minerId); activeMiners.set(minerId, miner); + socket.miner = miner; if (!miner.proxy) { let proxyMinerName = miner.payout + ":" + miner.identifier; @@ -1701,6 +1702,9 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi sendReply('Unauthenticated'); return; } + if (socket.miner.id != miner.id) { + console.err(socket.miner.id + ": different miners"); + } //if (miner.debugMiner) console.log("SUBMIT"); miner.heartbeat(); From e6a3f205270104bd636a6234ff8cf85b8b45ae9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 16:55:12 -0800 Subject: [PATCH 0644/1496] Added some socket based miner debug --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c543d28c8..9d1fa3655 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1697,14 +1697,14 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'submit': - miner = activeMiners.get(params.id); + miner = socket.miner;//activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; } - if (socket.miner.id != miner.id) { - console.err(socket.miner.id + ": different miners"); - } + //if (socket.miner.id != miner.id) { + // console.error(socket.miner.id + ": different miners"); + //} //if (miner.debugMiner) console.log("SUBMIT"); miner.heartbeat(); From 97e8ec1d9aea8e5a31aa9504623aff25ef44a405 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 16:57:33 -0800 Subject: [PATCH 0645/1496] Added some socket based miner debug --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9d1fa3655..9064cb2a0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1697,14 +1697,14 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi break; case 'submit': - miner = socket.miner;//activeMiners.get(params.id); + miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; } - //if (socket.miner.id != miner.id) { - // console.error(socket.miner.id + ": different miners"); - //} + if (!socket.miner || socket.miner.id != miner.id) { + console.error(socket.miner.id + ": different miners"); + } //if (miner.debugMiner) console.log("SUBMIT"); miner.heartbeat(); From 8bdf7680728e1e9d66f551e00d10467dfde523cd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2019 17:01:37 -0800 Subject: [PATCH 0646/1496] Disabled debug code --- lib/pool.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9064cb2a0..266ce92e2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1653,7 +1653,6 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (!socket.miner_ids) socket.miner_ids = []; socket.miner_ids.push(minerId); activeMiners.set(minerId, miner); - socket.miner = miner; if (!miner.proxy) { let proxyMinerName = miner.payout + ":" + miner.identifier; @@ -1702,9 +1701,6 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi sendReply('Unauthenticated'); return; } - if (!socket.miner || socket.miner.id != miner.id) { - console.error(socket.miner.id + ": different miners"); - } //if (miner.debugMiner) console.log("SUBMIT"); miner.heartbeat(); From fd1b98ae38f525c37400142c178716599cab6c45 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 07:29:32 -0800 Subject: [PATCH 0647/1496] Fixed SRB miner support --- lib/coins/xmr.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2442096c0..ceb533259 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -570,8 +570,6 @@ function Coin(data){ return false; } else if (m = reXMRSTAK.exec(agent)) { return "You must update your xmr-stak miner (" + agent + ") to xmr-stak-rx miner to support new rx/0 Monero algo"; - } else if (m = reSRB.exec(agent)) { - return "You must update your SRBminer (" + agent + ") to SRBminer-MULTI miner v0.1.5+ to support new rx/0 Monero algo"; } return false; }; From 7a39545a0a6a6daa9cb720f06e1252f2b6a946c7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 08:52:58 -0800 Subject: [PATCH 0648/1496] Fixed SRB miner support --- lib/coins/xmr.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ceb533259..546efa427 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -551,8 +551,6 @@ function Coin(data){ if (version < 1400) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.14.0+ by doing 'cd xmr-node-proxy && ./update.sh' (or check https://github.com/MoneroOcean/xmr-node-proxy repo) to support new rx/0 Monero algo"; } - } else if (m = reSRB.exec(agent)) { - return "Please update your SRBminer (" + agent + ") to SRBminer-MULTI miner v0.1.5+ to support new rx/0 Monero algo"; } else if (m = reSRBMULTI.exec(agent)) { const majorv = parseInt(m[1]) * 10000; const minorv = parseInt(m[2]) * 100; From 4e0865520fb0868db449b02ea42fd3ab283466b8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 22:47:48 -0800 Subject: [PATCH 0649/1496] Remove CORS --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index d209aba5b..907e0c1ad 100644 --- a/lib/api.js +++ b/lib/api.js @@ -28,7 +28,7 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -app.use(cors({origin: true})); +app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 72e8033e846ea565a2816db631abe7ad3f58444c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 22:50:45 -0800 Subject: [PATCH 0650/1496] Remove CORS --- lib/api.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 907e0c1ad..a1aa22bf7 100644 --- a/lib/api.js +++ b/lib/api.js @@ -12,7 +12,6 @@ const cnUtil = require('cryptoforknote-util'); const bodyParser = require('body-parser'); const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens const crypto = require('crypto'); -const cors = require('cors'); let addressBase58Prefix = cnUtil.address_decode(new Buffer(global.config.pool.address)); let threadName = ""; @@ -28,7 +27,7 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -app.use(cors()); +app.use(); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From ec4678820b1e879ec66b64444b65d9c3942d93e1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 22:51:42 -0800 Subject: [PATCH 0651/1496] Revert "Remove CORS" This reverts commit 72e8033e846ea565a2816db631abe7ad3f58444c. --- lib/api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index a1aa22bf7..907e0c1ad 100644 --- a/lib/api.js +++ b/lib/api.js @@ -12,6 +12,7 @@ const cnUtil = require('cryptoforknote-util'); const bodyParser = require('body-parser'); const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens const crypto = require('crypto'); +const cors = require('cors'); let addressBase58Prefix = cnUtil.address_decode(new Buffer(global.config.pool.address)); let threadName = ""; @@ -27,7 +28,7 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -app.use(); +app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 3604150b2bc1041834a97c3cc60ba516f62555ea Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 22:54:36 -0800 Subject: [PATCH 0652/1496] Remove CORS --- lib/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 907e0c1ad..7a444045a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -12,7 +12,6 @@ const cnUtil = require('cryptoforknote-util'); const bodyParser = require('body-parser'); const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens const crypto = require('crypto'); -const cors = require('cors'); let addressBase58Prefix = cnUtil.address_decode(new Buffer(global.config.pool.address)); let threadName = ""; @@ -28,7 +27,6 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 528ad86f7e07353bac148d6d5e3921246705c0bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 22:54:37 -0800 Subject: [PATCH 0653/1496] Revert "Remove CORS" This reverts commit 3604150b2bc1041834a97c3cc60ba516f62555ea. --- lib/api.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/api.js b/lib/api.js index 7a444045a..907e0c1ad 100644 --- a/lib/api.js +++ b/lib/api.js @@ -12,6 +12,7 @@ const cnUtil = require('cryptoforknote-util'); const bodyParser = require('body-parser'); const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens const crypto = require('crypto'); +const cors = require('cors'); let addressBase58Prefix = cnUtil.address_decode(new Buffer(global.config.pool.address)); let threadName = ""; @@ -27,6 +28,7 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); +app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From baf08286493e38c7734548fec067ea7a7edbdb64 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 22:55:08 -0800 Subject: [PATCH 0654/1496] Remove CORS --- lib/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 907e0c1ad..7a444045a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -12,7 +12,6 @@ const cnUtil = require('cryptoforknote-util'); const bodyParser = require('body-parser'); const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens const crypto = require('crypto'); -const cors = require('cors'); let addressBase58Prefix = cnUtil.address_decode(new Buffer(global.config.pool.address)); let threadName = ""; @@ -28,7 +27,6 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From ffb6785d2cb72e25b24dde2e549b81b64d2e3e52 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:00:54 -0800 Subject: [PATCH 0655/1496] Revert "Remove CORS" This reverts commit baf08286493e38c7734548fec067ea7a7edbdb64. --- lib/api.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/api.js b/lib/api.js index 7a444045a..907e0c1ad 100644 --- a/lib/api.js +++ b/lib/api.js @@ -12,6 +12,7 @@ const cnUtil = require('cryptoforknote-util'); const bodyParser = require('body-parser'); const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens const crypto = require('crypto'); +const cors = require('cors'); let addressBase58Prefix = cnUtil.address_decode(new Buffer(global.config.pool.address)); let threadName = ""; @@ -27,6 +28,7 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); +app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 4a78d937a81e9a446fa8e3244619a0edaf08fc6a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:03:57 -0800 Subject: [PATCH 0656/1496] Added dynamic CORS --- lib/api.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 907e0c1ad..13ae8066a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -28,7 +28,18 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -app.use(cors()); +var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; +var corsOptions = { + origin: function (origin, callback) { + if (whitelist.indexOf(origin) !== -1) { + callback(null, true); + } else { + callback(new Error('Not allowed by CORS')); + } + } +} + +app.use(cors(corsOptions)); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 0916caec0c743128b53b9cbabfc3026adba17350 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:06:06 -0800 Subject: [PATCH 0657/1496] Added dynamic CORS --- lib/api.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/api.js b/lib/api.js index 13ae8066a..1476701e7 100644 --- a/lib/api.js +++ b/lib/api.js @@ -31,11 +31,7 @@ if (global.config.solo.enable === true) pool_list.push('solo'); var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; var corsOptions = { origin: function (origin, callback) { - if (whitelist.indexOf(origin) !== -1) { - callback(null, true); - } else { - callback(new Error('Not allowed by CORS')); - } + return callback(null, whitelist.indexOf(origin) !== -1); } } From d26ff840cd1362ea80cfa50073b6318d32124918 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:09:15 -0800 Subject: [PATCH 0658/1496] Added dynamic CORS --- lib/api.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/api.js b/lib/api.js index 1476701e7..5aece7226 100644 --- a/lib/api.js +++ b/lib/api.js @@ -29,13 +29,10 @@ if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; -var corsOptions = { - origin: function (origin, callback) { - return callback(null, whitelist.indexOf(origin) !== -1); - } -} -app.use(cors(corsOptions)); +app.use(cors({ + origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1); } +})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); @@ -201,7 +198,7 @@ app.get('/pool/address_type/:address', cache('10 seconds'), function (req, res) } }); -app.get('/pool/stats', cache('10 seconds'), function (req, res) { +app.get('/pool/stats', cors(), cache('10 seconds'), function (req, res) { let localCache = global.database.getCache('pool_stats_global'); delete(localCache.minerHistory); delete(localCache.hashHistory); From 645a40bd65c649fbafd1f360fbe0d30647fb5ce5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:19:20 -0800 Subject: [PATCH 0659/1496] Added dynamic CORS --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 5aece7226..7e445b514 100644 --- a/lib/api.js +++ b/lib/api.js @@ -31,7 +31,7 @@ if (global.config.solo.enable === true) pool_list.push('solo'); var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; app.use(cors({ - origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1); } + origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } })); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From fb81f69b0f9cfdad935759f50bf54a0a6c2a6a59 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:20:30 -0800 Subject: [PATCH 0660/1496] Disabled CORS --- lib/api.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/api.js b/lib/api.js index 7e445b514..61aa8bb31 100644 --- a/lib/api.js +++ b/lib/api.js @@ -28,11 +28,10 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; - -app.use(cors({ - origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } -})); +//var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; +//app.use(cors({ +// origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } +//})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 9bd5b9931ecf00a8fb44a926c0566388a384a87d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:23:26 -0800 Subject: [PATCH 0661/1496] Added dynamic CORS --- lib/api.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api.js b/lib/api.js index 61aa8bb31..609ee3452 100644 --- a/lib/api.js +++ b/lib/api.js @@ -28,10 +28,10 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -//var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; -//app.use(cors({ -// origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } -//})); +var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; +app.use(cors({ + origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } +})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 2a2ee81cc63d8154758ae02b840a93697a6295c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2019 23:30:42 -0800 Subject: [PATCH 0662/1496] Disabled CORS --- lib/api.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/api.js b/lib/api.js index 609ee3452..03e510c4b 100644 --- a/lib/api.js +++ b/lib/api.js @@ -28,10 +28,11 @@ if (global.config.pplns.enable === true) pool_list.push('pplns'); if (global.config.pps.enable === true) pool_list.push('pps'); if (global.config.solo.enable === true) pool_list.push('solo'); -var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; -app.use(cors({ - origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } -})); +//var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; +//app.use(cors({ +// origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } +//})); +app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 5624204be3b0384990e712c3000ea417ecabd1c5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Dec 2019 01:41:50 -0800 Subject: [PATCH 0663/1496] More debug --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 955a7ad60..abad5e69b 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -640,8 +640,8 @@ function altblockUnlocker() { setTimeout(altblockUnlocker, 2*60*1000); return; } - console.log("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); + console.log("Running altblock unlocker for " + blockList.length + " blocks"); let blockHeightWait = {}; global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { @@ -750,7 +750,7 @@ function altblockPayments(block, cb) { switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { - if (err === null && block.height === header.height && block.value >= header.reward && block.difficulty === header.difficulty){ + if (err === null && block.height === header.height && block.value >= header.reward /*&& block.difficulty === header.difficulty*/){ global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ if (paymentInProgress) { From 246d6d4d980a44ea03eef2baea72c2aed3fdd77a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Dec 2019 17:08:10 -0800 Subject: [PATCH 0664/1496] Restore diff check --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index abad5e69b..7467be7c5 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -750,7 +750,7 @@ function altblockPayments(block, cb) { switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { - if (err === null && block.height === header.height && block.value >= header.reward /*&& block.difficulty === header.difficulty*/){ + if (err === null && block.height === header.height && block.value >= header.reward && block.difficulty === header.difficulty){ global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ if (paymentInProgress) { From 532cbb05ffb31e8ae716e0cae9ac68e1da9b03ac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Dec 2019 17:46:23 -0800 Subject: [PATCH 0665/1496] Removed diff check --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 7467be7c5..abad5e69b 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -750,7 +750,7 @@ function altblockPayments(block, cb) { switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { - if (err === null && block.height === header.height && block.value >= header.reward && block.difficulty === header.difficulty){ + if (err === null && block.height === header.height && block.value >= header.reward /*&& block.difficulty === header.difficulty*/){ global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ if (paymentInProgress) { From cd5fb290a6f9daf7c3c0e67f4ac1a07048a36b37 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Dec 2019 10:07:06 -0800 Subject: [PATCH 0666/1496] Added debug fo convert blob --- lib/coins/xmr.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 546efa427..7888eb58c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,7 +293,14 @@ function Coin(data){ this.portBlobType = function(port, version) { return port2blob_num[port]; } this.convertBlob = function(blobBuffer, port){ - return cnUtil.convert_blob(blobBuffer, this.portBlobType(port, blobBuffer[0])); + try { + let blob = cnUtil.convert_blob(blobBuffer, this.portBlobType(port, blobBuffer[0])); + } catch (e) { + const err_str = "Can't do port " + port + " convert_blob " + blobBuffer.toString('hex') + " with blob type " + this.portBlobType(port, blobBuffer[0]) + ": " + e; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't convert_blob", err_str); + throw new Error(e); + } }; this.constructNewBlob = function(blockTemplate, NonceBuffer, port){ From 160efbc8f4f0fd8e1904284f737bd0725eb3065b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Dec 2019 10:08:27 -0800 Subject: [PATCH 0667/1496] Added debug fo convert blob --- lib/coins/xmr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7888eb58c..e5fa07d4c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -293,14 +293,16 @@ function Coin(data){ this.portBlobType = function(port, version) { return port2blob_num[port]; } this.convertBlob = function(blobBuffer, port){ + let blob; try { - let blob = cnUtil.convert_blob(blobBuffer, this.portBlobType(port, blobBuffer[0])); + blob = cnUtil.convert_blob(blobBuffer, this.portBlobType(port, blobBuffer[0])); } catch (e) { const err_str = "Can't do port " + port + " convert_blob " + blobBuffer.toString('hex') + " with blob type " + this.portBlobType(port, blobBuffer[0]) + ": " + e; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't convert_blob", err_str); throw new Error(e); } + return blob; }; this.constructNewBlob = function(blockTemplate, NonceBuffer, port){ From b6c1ea2ec3d8b20fb79205d191ac76b332dc88e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 8 Dec 2019 21:46:28 -0800 Subject: [PATCH 0668/1496] Disabled XTNC --- lib/coins/xmr.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e5fa07d4c..4996a7944 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -29,7 +29,6 @@ const port2coin = { "20189": "XTC", "22023": "LOKI", "24182": "TUBE", - "33124": "XTNC", "34568": "WOW", "38081": "MSR", "48782": "LTHN", @@ -47,7 +46,6 @@ const port2blob_num = { "20189": 0, // XTC "22023": 5, // LOKI "24182": 0, // TUBE - "33124": 5, // XTNC "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN @@ -463,7 +461,7 @@ function Coin(data){ if ("rx/arq" in algos_perf) coin_perf["ARQ"] = algos_perf["rx/arq"]; - if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; + //if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; From 4c59ace023d2add30937b1e26900e77b9f809567 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:07:35 -0800 Subject: [PATCH 0669/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 266ce92e2..7870f8acf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1644,7 +1644,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (miner_notification) { if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent notification to " + miner.logString + ": " + miner_notification); + console.error("Sent notification to " + miner.logString + ": " + miner_notification + " " + JSON.stringify(miner.algos)); sendFinalReply(miner_notification + " (miner will connect after several attempts)"); return; } From 102642ffdfb9bc158eff2d4e9d1efb9e72f57a0f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:15:13 -0800 Subject: [PATCH 0670/1496] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7870f8acf..66a91e0cc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1644,7 +1644,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (miner_notification) { if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent notification to " + miner.logString + ": " + miner_notification + " " + JSON.stringify(miner.algos)); + console.error("Sent notification to " + miner.logString + ": " + miner_notification + " <" + JSON.stringify(miner.algos) + ">"); sendFinalReply(miner_notification + " (miner will connect after several attempts)"); return; } From 9cdaac9b508d5fdbad0c9ceafd3edabc50777845 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:22:26 -0800 Subject: [PATCH 0671/1496] Fixed xmr stak suported if used for direct algo --- lib/pool.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 66a91e0cc..43f0201bf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1628,23 +1628,15 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi return; } - const miner_agent_not_supported_notification = global.coinFuncs.get_miner_agent_not_supported_notification(params.agent); - if (miner_agent_not_supported_notification) { - if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { - console.error("Sent notification to " + miner.logString + ": " + miner_agent_not_supported_notification); - lastMinerLogTime[miner.payout] = time_now; - } - sendFinalReply(miner_agent_not_supported_notification); - return; - } - - const miner_agent_notification = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos) - ? global.coinFuncs.get_miner_agent_warning_notification(params.agent) : false; - const miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); + const is_prev_main_algo_miner = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos); + const miner_agent_not_supported_notification = is_prev_main_algo_miner ? global.coinFuncs.get_miner_agent_not_supported_notification(params.agent) : false; + const miner_agent_notification = is_prev_main_algo_miner ? global.coinFuncs.get_miner_agent_warning_notification(params.agent) : false; + const miner_notification = miner_agent_not_supported_notification ? miner_agent_not_supported_notification : + (miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout)); if (miner_notification) { if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent notification to " + miner.logString + ": " + miner_notification + " <" + JSON.stringify(miner.algos) + ">"); + console.error("Sent notification to " + miner.logString + ": " + miner_notification); sendFinalReply(miner_notification + " (miner will connect after several attempts)"); return; } From 7d80e5989ee0b85a4e3ae74b348589f78132d478 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:33:43 -0800 Subject: [PATCH 0672/1496] Adjust --- lib/api.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/api.js b/lib/api.js index 03e510c4b..675b6325f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -507,6 +507,28 @@ app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { }); }); +app.get('/user/:address', function (req, res) { + global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE id = ?", [req.params.address]).then(function(row){ + return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}}); + }); +}); + +app.post('user/toggleEmail', function (req, res) { + global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE id = ?", [req.body.address]).then(function () { + return res.json({'msg': 'Email toggled'}); + }); +}); + +app.post('user/updateThreshold', function (req, res) { + let threshold = req.body.threshold; + if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); + if (threshold < global.config.payout.walletMin) threshold = global.config.payout.walletMin; + threshold = global.support.decimalToCoin(threshold); + global.mysql.query("UPDATE users SET payout_threshold = ? WHERE id = ?", [threshold, req.body.username]).then(function () { + return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); + }); +}); + // Authentication app.post('/authenticate', function (req, res) { let hmac; From bac8af222fd37b2de14bf250bc6b5dce7d491e7e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:43:12 -0800 Subject: [PATCH 0673/1496] Adjust --- lib/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api.js b/lib/api.js index 675b6325f..4c8aa9e36 100644 --- a/lib/api.js +++ b/lib/api.js @@ -520,6 +520,7 @@ app.post('user/toggleEmail', function (req, res) { }); app.post('user/updateThreshold', function (req, res) { + console.log(JSON.stringify(req)); let threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); if (threshold < global.config.payout.walletMin) threshold = global.config.payout.walletMin; From 346c1fcc67f1d1265bbdf0d48337c81293622b7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:45:12 -0800 Subject: [PATCH 0674/1496] Adjust --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 4c8aa9e36..2fd11d1e6 100644 --- a/lib/api.js +++ b/lib/api.js @@ -513,13 +513,13 @@ app.get('/user/:address', function (req, res) { }); }); -app.post('user/toggleEmail', function (req, res) { +app.post('/user/toggleEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE id = ?", [req.body.address]).then(function () { return res.json({'msg': 'Email toggled'}); }); }); -app.post('user/updateThreshold', function (req, res) { +app.post('/user/updateThreshold', function (req, res) { console.log(JSON.stringify(req)); let threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); From 224118be259dcbea673e5f501d37498a4aed665a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:46:03 -0800 Subject: [PATCH 0675/1496] Adjust --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 2fd11d1e6..1ad33779a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -520,7 +520,7 @@ app.post('/user/toggleEmail', function (req, res) { }); app.post('/user/updateThreshold', function (req, res) { - console.log(JSON.stringify(req)); + console.log(JSON.stringify(req.body)); let threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); if (threshold < global.config.payout.walletMin) threshold = global.config.payout.walletMin; From a5458f37eab16e67c9264dc608faeec11dd870ba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:48:57 -0800 Subject: [PATCH 0676/1496] Adjust --- lib/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api.js b/lib/api.js index 1ad33779a..f9d26bc4b 100644 --- a/lib/api.js +++ b/lib/api.js @@ -525,6 +525,7 @@ app.post('/user/updateThreshold', function (req, res) { if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); if (threshold < global.config.payout.walletMin) threshold = global.config.payout.walletMin; threshold = global.support.decimalToCoin(threshold); + console.log("UPDATE users SET payout_threshold = " + threshold + " WHERE id = " + req.body.username); global.mysql.query("UPDATE users SET payout_threshold = ? WHERE id = ?", [threshold, req.body.username]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); }); From 9d6b5218109209e88636f6363c26da1d4cb82c6c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:53:25 -0800 Subject: [PATCH 0677/1496] Adjust --- lib/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api.js b/lib/api.js index f9d26bc4b..4f3b9494f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -526,6 +526,7 @@ app.post('/user/updateThreshold', function (req, res) { if (threshold < global.config.payout.walletMin) threshold = global.config.payout.walletMin; threshold = global.support.decimalToCoin(threshold); console.log("UPDATE users SET payout_threshold = " + threshold + " WHERE id = " + req.body.username); + console.log(typeof req.body.username); global.mysql.query("UPDATE users SET payout_threshold = ? WHERE id = ?", [threshold, req.body.username]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); }); From 72ff63ed7570067676e945535921f198eb26cd67 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 10:58:45 -0800 Subject: [PATCH 0678/1496] Adjust --- lib/api.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/api.js b/lib/api.js index 4f3b9494f..7a084a725 100644 --- a/lib/api.js +++ b/lib/api.js @@ -508,13 +508,13 @@ app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { }); app.get('/user/:address', function (req, res) { - global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE id = ?", [req.params.address]).then(function(row){ + global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE username = ?", [req.params.address]).then(function(row){ return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}}); }); }); app.post('/user/toggleEmail', function (req, res) { - global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE id = ?", [req.body.address]).then(function () { + global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE username = ?", [req.body.address]).then(function () { return res.json({'msg': 'Email toggled'}); }); }); @@ -525,9 +525,7 @@ app.post('/user/updateThreshold', function (req, res) { if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); if (threshold < global.config.payout.walletMin) threshold = global.config.payout.walletMin; threshold = global.support.decimalToCoin(threshold); - console.log("UPDATE users SET payout_threshold = " + threshold + " WHERE id = " + req.body.username); - console.log(typeof req.body.username); - global.mysql.query("UPDATE users SET payout_threshold = ? WHERE id = ?", [threshold, req.body.username]).then(function () { + global.mysql.query("UPDATE users SET payout_threshold = ? WHERE username = ?", [threshold, req.body.username]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); }); }); From a641ad6538ec9570019bbf72d3a03788400b5c42 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 11:04:57 -0800 Subject: [PATCH 0679/1496] Adjust --- lib/api.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/api.js b/lib/api.js index 7a084a725..9e83af606 100644 --- a/lib/api.js +++ b/lib/api.js @@ -514,19 +514,19 @@ app.get('/user/:address', function (req, res) { }); app.post('/user/toggleEmail', function (req, res) { - global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE username = ?", [req.body.address]).then(function () { + const enabled = req.body.enabled; + if (!enabled) return res.status(401).send({'success': false, 'msg': "Can't set enabled to a wrong value"}); + global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, req.body.username]).then(function () { return res.json({'msg': 'Email toggled'}); }); }); app.post('/user/updateThreshold', function (req, res) { - console.log(JSON.stringify(req.body)); - let threshold = req.body.threshold; + const threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); - if (threshold < global.config.payout.walletMin) threshold = global.config.payout.walletMin; - threshold = global.support.decimalToCoin(threshold); - global.mysql.query("UPDATE users SET payout_threshold = ? WHERE username = ?", [threshold, req.body.username]).then(function () { - return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); + const threshold2 = global.support.decimalToCoin(threshold < global.config.payout.walletMin ? global.config.payout.walletMin : threshold); + global.mysql.query("UPDATE users SET payout_threshold = ? WHERE username = ?", [threshold2, req.body.username]).then(function () { + return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold2)}); }); }); From 1ce79e2b7878e449b6a4bda5a404ade9587fc6e6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 13:03:44 -0800 Subject: [PATCH 0680/1496] Adjust --- lib/api.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/api.js b/lib/api.js index 9e83af606..8e451e719 100644 --- a/lib/api.js +++ b/lib/api.js @@ -514,9 +514,11 @@ app.get('/user/:address', function (req, res) { }); app.post('/user/toggleEmail', function (req, res) { + console.log(JSON.stringify(req.body)); const enabled = req.body.enabled; if (!enabled) return res.status(401).send({'success': false, 'msg': "Can't set enabled to a wrong value"}); global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, req.body.username]).then(function () { + console.log(JSON.stringify(enabled)); return res.json({'msg': 'Email toggled'}); }); }); From e43174f77f4cabd73580bc89e263a0439605e032 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Dec 2019 13:05:53 -0800 Subject: [PATCH 0681/1496] Adjust --- lib/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 8e451e719..9e83af606 100644 --- a/lib/api.js +++ b/lib/api.js @@ -514,11 +514,9 @@ app.get('/user/:address', function (req, res) { }); app.post('/user/toggleEmail', function (req, res) { - console.log(JSON.stringify(req.body)); const enabled = req.body.enabled; if (!enabled) return res.status(401).send({'success': false, 'msg': "Can't set enabled to a wrong value"}); global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, req.body.username]).then(function () { - console.log(JSON.stringify(enabled)); return res.json({'msg': 'Email toggled'}); }); }); From d9943c2f004f674a3a0d1c90dd2185a849487ea2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 07:25:19 -0800 Subject: [PATCH 0682/1496] No not allow blocked miners --- lib/pool.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 43f0201bf..bd63896ea 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1630,9 +1630,16 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi const is_prev_main_algo_miner = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos); const miner_agent_not_supported_notification = is_prev_main_algo_miner ? global.coinFuncs.get_miner_agent_not_supported_notification(params.agent) : false; + if (miner_agent_not_supported_notification) { + if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { + lastMinerNotifyTime[miner.payout] = time_now; + console.error("Sent final notification to " + miner.logString + ": " + miner_agent_not_supported_notification); + } + sendFinalReply(miner_agent_not_supported_notification); + return; + } const miner_agent_notification = is_prev_main_algo_miner ? global.coinFuncs.get_miner_agent_warning_notification(params.agent) : false; - const miner_notification = miner_agent_not_supported_notification ? miner_agent_not_supported_notification : - (miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout)); + const miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); if (miner_notification) { if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; From 83378c61840d917060404e9e2364a075ef7bd019 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 14:51:00 -0800 Subject: [PATCH 0683/1496] Added IRD/ARQ addresses --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9f33d1bfe..39d7e32da 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,8 @@ If you'd like to make a one time donation, the addresses are as follows: * LOKI - ```L6XqN6JDedz5Ub8KxpMYRCUoQCuyEA8EegEmeQsdP5FCNuXJavcrxPvLhpqY6emphGTYVrmAUVECsE9drafvY2hXUTJz6rW``` * TRTL - ```TRTLv2x2bac17cngo1r2wt3CaxN8ckoWHe2TX7dc8zW8Fc9dpmxAvhVX4u4zPjpv9WeALm2koBLF36REVvsLmeufZZ1Yx6uWkYG``` * XTNC - ```XtazhSxz1bbJLpT2JuiD2UWFUJYSFty5SVWuF6sy2w9v8pn69smkUxkTVCQc8NKCd6CBMNDGzgdPRYBKaHdbgZ5SNptVH1yPCTQ``` +* IRD - ```ir3DHyB8Ub1aAHEewMeUxQ7b7tQdWa7VL8M5oXDPohS3Me4nhwvALXM4mym2kWg9VsceT75dm6XWiWF1K4zu8RVQ1HJD8Z3R9``` +* ARQ - ```ar4Ha6ZQCkKRhkKQLfexv7VZQM2MhUmMmU9hmzswCPK4T3o2rbPKZM1GxEoYg4AFQsh57PsEets7sbpU958FAvxo2RkkTQ1gE``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` From 31e9c4de34148f3f5da2a9523134bd5684983245 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 18:43:08 -0800 Subject: [PATCH 0684/1496] Added block share dumps --- lib/blockManager.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index abad5e69b..062e57cc0 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -331,6 +331,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do let portShares = {}; let firstShareTime; let lastShareTime; + let shares4dump = []; async.doWhilst(function (callback) { let txn = global.database.env.beginTxn({readOnly: true}); @@ -359,17 +360,22 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do if (!firstShareTime) firstShareTime = shareData.timestamp; if (totalPaid < rewardTotal) lastShareTime = shareData.timestamp; - let amountToPay = shareData.shares2; - let feesToPay = amountToPay * (global.config.payout.pplnsFee / 100) + + const amountToPay = shareData.shares2; + const feesToPay = amountToPay * (global.config.payout.pplnsFee / 100) + (shareData.bitcoin === true ? amountToPay * (global.config.payout.btcFee / 100) : 0); - let devDonation = feesToPay * (global.config.payout.devDonation / 100); - let poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); + const devDonation = feesToPay * (global.config.payout.devDonation / 100); + const poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); + const amountToPay2 = amountToPay - feesToPay; - addPayment(userIdentifier, amountToPay - feesToPay); + shares4dump.push(userIdentifier.slice(-16) + "\t" + shareData.timestamp + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + + global.coinFuncs.PORT2COIN(shareData.port) + "\t" + amountToPay + "\t" + amountToPay2); + + addPayment(userIdentifier, amountToPay2); addPayment(global.config.payout.feeAddress, feesToPay - devDonation - poolDevDonation); addPayment(global.coinFuncs.poolDevAddress, poolDevDonation); addPayment(global.coinFuncs.coinDevAddress, devDonation); + if (typeof(shareData.port) !== 'undefined') { if (shareData.port in portShares) { portShares[shareData.port] += amountToPay; @@ -394,6 +400,10 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do return blockCheckHeight !== 0; } }, function (err) { + + const fn = "block_share_dumps/" + block_hex + ".cvs"; + fs.writeFile(fn, shares4dump.join("\n"), function(err) { if (err) console.error("Error saving " + fn + " file"); }); + let sumAllPorts = 0; for (let port in portShares) sumAllPorts += portShares[port]; let pplns_port_shares = {}; From 69894bbd26f954e7ce1f16c89c1247ecd92bd40f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 18:50:35 -0800 Subject: [PATCH 0685/1496] Added block share dumps --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 062e57cc0..5a292505c 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -2,6 +2,7 @@ const range = require("range"); const debug = require("debug")("blockManager"); const async = require("async"); +const fs = require('fs'); // This file is for managing the block databases within the SQL database. // Primary Tasks: From 3974d5e2dd0515a0c9c9683add3c2ac0d1734888 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 19:02:28 -0800 Subject: [PATCH 0686/1496] Adjusted dumps --- lib/blockManager.js | 4 +++- lib/coins/xmr.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 5a292505c..bca330c07 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -334,6 +334,8 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do let lastShareTime; let shares4dump = []; + shares4dump.push("#last_16_chars_ofxmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); + async.doWhilst(function (callback) { let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); @@ -369,7 +371,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do const amountToPay2 = amountToPay - feesToPay; shares4dump.push(userIdentifier.slice(-16) + "\t" + shareData.timestamp + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + - global.coinFuncs.PORT2COIN(shareData.port) + "\t" + amountToPay + "\t" + amountToPay2); + global.coinFuncs.PORT2COIN_FULL(shareData.port) + "\t" + amountToPay + "\t" + amountToPay2); addPayment(userIdentifier, amountToPay2); addPayment(global.config.payout.feeAddress, feesToPay - devDonation - poolDevDonation); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4996a7944..4b6ec0819 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -410,6 +410,7 @@ function Coin(data){ this.getPORTS = function() { return ports; } this.getCOINS = function() { return coins; } this.PORT2COIN = function(port) { return port2coin[port]; } + this.PORT2COIN_FULL = function(port) { const coin = port2coin[port]; return coin == "" ? "XMR" : coin; } this.COIN2PORT = function(coin) { return coin2port[coin]; } this.getMM_PORTS = function() { return mm_port_set; } this.getMM_CHILD_PORTS = function() { return mm_child_port_set; } From 59be1a09d3b67f1a98d173d635203fbdf86d78a6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 19:05:08 -0800 Subject: [PATCH 0687/1496] Adjusted dumps --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index bca330c07..f36852b2f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -334,7 +334,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do let lastShareTime; let shares4dump = []; - shares4dump.push("#last_16_chars_ofxmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); + shares4dump.push("#last_8_chars_ofxmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); async.doWhilst(function (callback) { let txn = global.database.env.beginTxn({readOnly: true}); @@ -370,7 +370,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do const poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); const amountToPay2 = amountToPay - feesToPay; - shares4dump.push(userIdentifier.slice(-16) + "\t" + shareData.timestamp + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + + shares4dump.push(userIdentifier.slice(-8) + "\t" + shareData.timestamp + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + global.coinFuncs.PORT2COIN_FULL(shareData.port) + "\t" + amountToPay + "\t" + amountToPay2); addPayment(userIdentifier, amountToPay2); From 99535122a906561bf76183f97d7f1c5d18fea7d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 19:08:05 -0800 Subject: [PATCH 0688/1496] Adjusted dumps --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index f36852b2f..494c9272f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -371,7 +371,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do const amountToPay2 = amountToPay - feesToPay; shares4dump.push(userIdentifier.slice(-8) + "\t" + shareData.timestamp + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + - global.coinFuncs.PORT2COIN_FULL(shareData.port) + "\t" + amountToPay + "\t" + amountToPay2); + global.coinFuncs.PORT2COIN_FULL(shareData.port) + "\t" + amountToPay + "\t" + (amountToPay === amountToPay2 ? "" : amountToPay2)); addPayment(userIdentifier, amountToPay2); addPayment(global.config.payout.feeAddress, feesToPay - devDonation - poolDevDonation); From 20a9c4f8cf2565289f03a10e21836406733efd53 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 19:29:09 -0800 Subject: [PATCH 0689/1496] Adjusted dumps --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 494c9272f..f2dbe4032 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -334,8 +334,6 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do let lastShareTime; let shares4dump = []; - shares4dump.push("#last_8_chars_ofxmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); - async.doWhilst(function (callback) { let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); @@ -370,7 +368,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do const poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); const amountToPay2 = amountToPay - feesToPay; - shares4dump.push(userIdentifier.slice(-8) + "\t" + shareData.timestamp + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + + shares4dump.push(userIdentifier.slice(-16) + "\t" + shareData.timestamp.toString(16) + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + global.coinFuncs.PORT2COIN_FULL(shareData.port) + "\t" + amountToPay + "\t" + (amountToPay === amountToPay2 ? "" : amountToPay2)); addPayment(userIdentifier, amountToPay2); @@ -404,6 +402,8 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do } }, function (err) { + shares4dump.sort(); + shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); const fn = "block_share_dumps/" + block_hex + ".cvs"; fs.writeFile(fn, shares4dump.join("\n"), function(err) { if (err) console.error("Error saving " + fn + " file"); }); From 03ad1bda356d08a57271ff2f8b233ba58de6b5a1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 19:37:37 -0800 Subject: [PATCH 0690/1496] Pack cvs files --- lib/blockManager.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index f2dbe4032..7a52205e8 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -3,6 +3,7 @@ const range = require("range"); const debug = require("debug")("blockManager"); const async = require("async"); const fs = require('fs'); +const child_process = require('child_process'); // This file is for managing the block databases within the SQL database. // Primary Tasks: @@ -405,7 +406,12 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do shares4dump.sort(); shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); const fn = "block_share_dumps/" + block_hex + ".cvs"; - fs.writeFile(fn, shares4dump.join("\n"), function(err) { if (err) console.error("Error saving " + fn + " file"); }); + fs.writeFile(fn, shares4dump.join("\n"), function(err) { + if (err) { console.error("Error saving " + fn + " file"); return; } + child_process.exec("xz " + fn, function callback(error, stdout, stderr) { + if (error) console.error("xz " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); + }); + }); let sumAllPorts = 0; for (let port in portShares) sumAllPorts += portShares[port]; From 5ebd1fbd58c9d2ab2ce96dc37c921f9118af1dce Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 21:41:49 -0800 Subject: [PATCH 0691/1496] Added custom block share dump processing --- lib/blockManager.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 7a52205e8..d5e0e544b 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -403,15 +403,17 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do } }, function (err) { - shares4dump.sort(); - shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); - const fn = "block_share_dumps/" + block_hex + ".cvs"; - fs.writeFile(fn, shares4dump.join("\n"), function(err) { - if (err) { console.error("Error saving " + fn + " file"); return; } - child_process.exec("xz " + fn, function callback(error, stdout, stderr) { - if (error) console.error("xz " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); + if (fs.existsSync("./block_share_dumps/process.sh")) { + shares4dump.sort(); + shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); + const fn = "block_share_dumps/" + block_hex + ".cvs"; + fs.writeFile(fn, shares4dump.join("\n"), function(err) { + if (err) { console.error("Error saving " + fn + " file"); return; } + child_process.exec("./block_share_dumps/process.sh " + fn, function callback(error, stdout, stderr) { + if (error) console.error("./block_share_dumps/process.sh " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); + }); }); - }); + } let sumAllPorts = 0; for (let port in portShares) sumAllPorts += portShares[port]; From 53c9f9fb0271aae7b0fd82930e51d321b563bed8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Dec 2019 23:56:56 -0800 Subject: [PATCH 0692/1496] Tools for block share data parsing --- block_share_dumps/calc_mo_cvs.js | 79 ++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 block_share_dumps/calc_mo_cvs.js diff --git a/block_share_dumps/calc_mo_cvs.js b/block_share_dumps/calc_mo_cvs.js new file mode 100644 index 000000000..405260ed5 --- /dev/null +++ b/block_share_dumps/calc_mo_cvs.js @@ -0,0 +1,79 @@ +"use strict"; + +if (Boolean(process.stdin.isTTY) || process.argv.length !== 3) { + console.log("Usage: unxz -c .cvs.xz | node calc_mo_cvs.js "); + console.log(" wget -O - https://moneroocean-block-share-dumps.s3.us-east-2.amazonaws.com/.cvs.xz | unxz -c | node calc_mo_cvs.js "); + process.exit(1); +} + +const my_wallet = process.argv[2].slice(-16); + +let stdin = ""; + +process.stdin.on('data', function(data) { + stdin += data.toString(); +}); + +function human_hashrate(hashes) { + const power = Math.pow(10, 2 || 0); + if (hashes > 1000000000000) return String(Math.round((hashes / 1000000000000) * power) / power) + " TH/s"; + if (hashes > 1000000000) return String(Math.round((hashes / 1000000000) * power) / power) + " GH/s"; + if (hashes > 1000000) return String(Math.round((hashes / 1000000) * power) / power) + " MH/s"; + if (hashes > 1000) return String(Math.round((hashes / 1000) * power) / power) + " KH/s"; + return Math.floor( hashes || 0 ) + " H/s" +}; + +process.stdin.on('end', function() { + let pplns_window = 0; + let oldest_timestamp = 0; + let newest_timestamp = 0; + + let my_share_count = 0; + let my_xmr_diff = 0; + let my_xmr_diff_payed = 0; + let my_coin_raw_diff = {}; + let my_coin_xmr_diff = {}; + + for (let line of stdin.split("\n")) { + if (line.substring(0, 1) == "#") continue; + const items = line.split('\t'); + if (items.length < 7) { + console.error("Skipped invalid line: " + line); + continue; + } + const wallet = items[0]; + const timestamp = parseInt(items[1], 16); + const raw_diff = parseInt(items[2]); + const count = parseInt(items[3]); + const coin = items[4]; + const xmr_diff = parseInt(items[5]); + const xmr_diff_payed = items[6] == "" ? xmr_diff : parseInt(items[6]); + pplns_window += xmr_diff; + if (!oldest_timestamp || timestamp < oldest_timestamp) oldest_timestamp = timestamp; + if (newest_timestamp < timestamp) newest_timestamp = timestamp; + if (wallet === my_wallet) { + my_share_count += count; + my_xmr_diff += xmr_diff; + my_xmr_diff_payed += xmr_diff_payed; + if (!(coin in my_coin_raw_diff)) my_coin_raw_diff[coin] = 0; + my_coin_raw_diff[coin] += raw_diff; + if (!(coin in my_coin_xmr_diff)) my_coin_xmr_diff[coin] = 0; + my_coin_xmr_diff[coin] += xmr_diff; + } + } + + console.log("PPLNS window size: \t" + ((newest_timestamp - oldest_timestamp)/1000/60/60).toFixed(2) + " hours"); + console.log("PPLNS window size: \t" + pplns_window + " xmr hashes"); + console.log("Pool XMR normalized hashrate: \t" + human_hashrate(pplns_window / (newest_timestamp - oldest_timestamp) * 1000)); + console.log(""); + console.log("Your submitted shares: \t" + my_share_count); + console.log("Your payment: \t" + ((my_xmr_diff_payed / pplns_window) * 100).toFixed(6) + "% (" + my_xmr_diff_payed + " xmr hashes)"); + console.log("Your XMR normalized hashrate: \t" + human_hashrate(my_xmr_diff_payed / (newest_timestamp - oldest_timestamp) * 1000)); + console.log(""); + console.log("You mined these coins:"); + for (let coin of Object.keys(my_coin_raw_diff).sort()) { + console.log("\t" + coin + ": " + my_coin_raw_diff[coin] + " raw coin hashes (" + ((my_coin_xmr_diff[coin] / my_xmr_diff) * 100).toFixed(6) + "% of XMR normalized hashrate)"); + } + + process.exit(0); +}); \ No newline at end of file From 1c8f4df1e0c0389c992c4542ea15a8ffbcd87128 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 12 Dec 2019 07:31:35 -0800 Subject: [PATCH 0693/1496] Fixed location of block dumps --- block_share_dumps/calc_mo_cvs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block_share_dumps/calc_mo_cvs.js b/block_share_dumps/calc_mo_cvs.js index 405260ed5..7d67e6b5c 100644 --- a/block_share_dumps/calc_mo_cvs.js +++ b/block_share_dumps/calc_mo_cvs.js @@ -2,7 +2,7 @@ if (Boolean(process.stdin.isTTY) || process.argv.length !== 3) { console.log("Usage: unxz -c .cvs.xz | node calc_mo_cvs.js "); - console.log(" wget -O - https://moneroocean-block-share-dumps.s3.us-east-2.amazonaws.com/.cvs.xz | unxz -c | node calc_mo_cvs.js "); + console.log(" wget -O - https://block-share-dumps.moneroocean.stream/.cvs.xz | unxz -c | node calc_mo_cvs.js "); process.exit(1); } From f50b2b692ad6ab057a766687d8f12f33ccac4010 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 17:19:01 -0800 Subject: [PATCH 0694/1496] Added XMV support --- lib/coins/xmr.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4b6ec0819..6f6f14cc2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -35,6 +35,7 @@ const port2coin = { "19734": "SUMO", "13007": "IRD", "19994": "ARQ", + "19091": "XMV", }; const port2blob_num = { "11181": 7, // AEON @@ -52,6 +53,7 @@ const port2blob_num = { "19734": 0, // SUMO "13007": 2, // IRD "19994": 0, // ARQ + "19091": 0, // XMV }; const port2algo = { @@ -62,6 +64,7 @@ const port2algo = { "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR "18981": "cn/rwz", // Graft + "19091": "rx/v", // MoneroV "19734": "cn/r", // SUMO "19994": "rx/arq", // ArqMa "20189": "defyx", // Scala @@ -420,7 +423,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "rx/0": 1, "rx/loki": 1 }; + return { "rx/0": 1, "rx/loki": 1, "rx/v": 1 }; } this.getPrevAlgosPerf = function() { @@ -462,6 +465,8 @@ function Coin(data){ if ("rx/arq" in algos_perf) coin_perf["ARQ"] = algos_perf["rx/arq"]; + if ("rx/v" in algos_perf) coin_perf["XMV"] = algos_perf["rx/v"]; + //if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; @@ -496,6 +501,7 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft + case 19091: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 19); // MoneroV case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala From cbdf89c618afa8357b14bf5443c3759f7dfdfdba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 18:25:38 -0800 Subject: [PATCH 0695/1496] Added XMV support --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6f6f14cc2..d3a38f08e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -35,7 +35,7 @@ const port2coin = { "19734": "SUMO", "13007": "IRD", "19994": "ARQ", - "19091": "XMV", + "19281": "XMV", }; const port2blob_num = { "11181": 7, // AEON @@ -53,7 +53,7 @@ const port2blob_num = { "19734": 0, // SUMO "13007": 2, // IRD "19994": 0, // ARQ - "19091": 0, // XMV + "19281": 0, // XMV }; const port2algo = { @@ -64,7 +64,7 @@ const port2algo = { "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR "18981": "cn/rwz", // Graft - "19091": "rx/v", // MoneroV + "19281": "rx/v", // MoneroV "19734": "cn/r", // SUMO "19994": "rx/arq", // ArqMa "20189": "defyx", // Scala @@ -501,7 +501,7 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft - case 19091: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 19); // MoneroV + case 19281: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 19); // MoneroV case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala From 279870439b987a38670912559a6f64ace14b2dd7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 18:42:14 -0800 Subject: [PATCH 0696/1496] Added XMV support --- README.md | 2 +- deployment/base.sql | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 39d7e32da..c5d6412a6 100644 --- a/README.md +++ b/README.md @@ -264,7 +264,7 @@ If you'd like to make a one time donation, the addresses are as follows: * MSR - ```5hnMXUKArLDRue5tWsNpbmGLsLQibt23MEsV3VGwY6MGStYwfTqHkff4BgvziprTitbcDYYpFXw2rEgXeipsABTtEmcmnCK``` * ITNS - ```iz53aMEaKJ25zB8xku3FQK5VVvmu2v6DENnbGHRmn659jfrGWBH1beqAzEVYaKhTyMZcxLJAdaCW3Kof1DwTiTbp1DSqLae3e``` * WOW - ```Wo3yjV8UkwvbJDCB1Jy7vvXv3aaQu3K8YMG6tbY3Jo2KApfyf5RByZiBXy95bzmoR3AvPgNq6rHzm98LoHTkzjiA2dY7sqQMJ``` -* XMV - ```4BDgQohRBqg2wFZ5ezYqCrNGjgECAttARdbh1fNkuAbd3HnNkSgas11QD9VFQMzbnvDD3Mfcky1LAFihkbEYph5oGAMLurw``` +* XMV - ```XvyVfpAYp3zSuvdtoHgnDzMUf7GAeiumeUgVC7RTq6SfgtzGEzy4dUgfEEfD5adk1kN4dfVZdT3zZdgSD2xmVBs627Vwt2C3Ey``` * RYO - ```RYoLsi22qnoKYhnv1DwHBXcGe9QK6P9zmekwQnHdUAak7adFBK4i32wFTszivQ9wEPeugbXr2UD7tMd6ogf1dbHh76G5UszE7k1``` * XTL - ```Se3Qr5s83AxjCtYrkkqg6QXJagCVi8dELbHb5Cnemw4rMk3xZzEX3kQfWrbTZPpdAJSP3enA6ri3DcvdkERkGKE518vyPQTyi``` * XHV - ```hvxyEmtbqs5TEk9U2tCxyfGx2dyGD1g8EBspdr3GivhPchkvnMHtpCR2fGLc5oEY42UGHVBMBANPge5QJ7BDXSMu1Ga2KFspQR``` diff --git a/deployment/base.sql b/deployment/base.sql index 03e2d104e..952b388c3 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -217,6 +217,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortIRD', '0', 'int', 'Iridium coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortARQ', '0', 'int', 'ArqMa coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMV', '0', 'int', 'MoneroV coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -233,6 +234,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTRTL', '0', 'float', 'Turtle algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorIRD', '0', 'float', 'Iridium algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorARQ', '0', 'float', 'ArqMa algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMV', '0', 'float', 'MoneroV algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -274,7 +276,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_38081', '', 'string', 'Address to mine to for 38081 (MSR) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_48782', '', 'string', 'Address to mine to for 48782 (ITNS) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_34568', '', 'string', 'Address to mine to for 34568 (WOW) port.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19091', '', 'string', 'Address to mine to for 19091 (XMV) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19281', '', 'string', 'Address to mine to for 19281 (XMV) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_12211', '', 'string', 'Address to mine to for 12211 (RYO) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11181', '', 'string', 'Address to mine to for 11181 (Aeon) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_17750', '', 'string', 'Address to mine to for 17750 (Haven) port.'); From d3d0b5cbc200d7724736adf52eb56a5f6d90f40f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 19:12:35 -0800 Subject: [PATCH 0697/1496] More intelegent xmr stak handling --- lib/coins/xmr.js | 6 +++--- lib/pool.js | 20 ++++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d3a38f08e..88277a35e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -576,12 +576,12 @@ function Coin(data){ return false; }; - this.get_miner_agent_not_supported_notification = function(agent) { + this.get_miner_agent_not_supported_algo = function(agent) { let m; if (m = reXMRSTAKRX.exec(agent)) { - return false; + return "rx/0"; } else if (m = reXMRSTAK.exec(agent)) { - return "You must update your xmr-stak miner (" + agent + ") to xmr-stak-rx miner to support new rx/0 Monero algo"; + return "cn/r"; } return false; }; diff --git a/lib/pool.js b/lib/pool.js index bd63896ea..4bb880152 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -734,7 +734,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer algo_min_time = 0; } else if (!(algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching)) { - algos = global.coinFuncs.getDefaultAlgos(); + const agent_algo = global.coinFuncs.get_miner_agent_not_supported_algo(agent); + if (agent_algo) { + algos = [ agent_algo ]; + } else { + algos = global.coinFuncs.getDefaultAlgos(); + } algos_perf = global.coinFuncs.getDefaultAlgosPerf(); algo_min_time = 0; } @@ -1628,17 +1633,8 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi return; } - const is_prev_main_algo_miner = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos); - const miner_agent_not_supported_notification = is_prev_main_algo_miner ? global.coinFuncs.get_miner_agent_not_supported_notification(params.agent) : false; - if (miner_agent_not_supported_notification) { - if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { - lastMinerNotifyTime[miner.payout] = time_now; - console.error("Sent final notification to " + miner.logString + ": " + miner_agent_not_supported_notification); - } - sendFinalReply(miner_agent_not_supported_notification); - return; - } - const miner_agent_notification = is_prev_main_algo_miner ? global.coinFuncs.get_miner_agent_warning_notification(params.agent) : false; + const miner_agent_notification = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos) ? + global.coinFuncs.get_miner_agent_warning_notification(params.agent) : false; const miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); if (miner_notification) { if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { From d57ee378c2633a2ee528a1811e377a613aabf837 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 19:36:56 -0800 Subject: [PATCH 0698/1496] Added aut rx/v algo perf --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 88277a35e..9ae793b7b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -434,7 +434,7 @@ function Coin(data){ let coin_perf = {}; - if ("rx/0" in algos_perf) coin_perf[""] = algos_perf["rx/0"]; + if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["LOKI"] = coin_perf["XMV"] = algos_perf["rx/0"]; if ("cn/r" in algos_perf) coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; From 02d0bd5ae99dd82ad71c77fd1d7e1733759dea8d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 19:59:06 -0800 Subject: [PATCH 0699/1496] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f6584e2d..4b98cefab 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v6.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v15.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v15.1.0" } } From 77c6407db4af662b18569efe23533741afe76817 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 20:01:50 -0800 Subject: [PATCH 0700/1496] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b98cefab..55043da99 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ "zmq": "^2.15.3", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v6.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v15.1.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v15.1.1" } } From 47dfda33055730855774a6208a491388d11f695e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 21:46:43 -0800 Subject: [PATCH 0701/1496] Reduce parallel block dumps --- lib/blockManager.js | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index d5e0e544b..cce784f4e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -403,18 +403,6 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do } }, function (err) { - if (fs.existsSync("./block_share_dumps/process.sh")) { - shares4dump.sort(); - shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); - const fn = "block_share_dumps/" + block_hex + ".cvs"; - fs.writeFile(fn, shares4dump.join("\n"), function(err) { - if (err) { console.error("Error saving " + fn + " file"); return; } - child_process.exec("./block_share_dumps/process.sh " + fn, function callback(error, stdout, stderr) { - if (error) console.error("./block_share_dumps/process.sh " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); - }); - }); - } - let sumAllPorts = 0; for (let port in portShares) sumAllPorts += portShares[port]; let pplns_port_shares = {}; @@ -431,6 +419,10 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do totalPayments += paymentData[key].amount; }); + let is_dump_done = false; + let is_ok = true; + let is_pay_done = false; + if (totalPayments == 0) { console.warn("PPLNS payout cycle for " + block_hex + " block does not have any shares so will be redone using top height"); global.support.sendEmail(global.config.general.adminEmail, @@ -446,6 +438,27 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do return preCalculatePPLNSPayments(block_hex, topBlockHeight, block_difficulty, done_callback); }); return; + } else { + if (fs.existsSync("./block_share_dumps/process.sh")) { + shares4dump.sort(); + shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); + const fn = "block_share_dumps/" + block_hex + ".cvs"; + fs.writeFile(fn, shares4dump.join("\n"), function(err) { + if (err) { + console.error("Error saving " + fn + " file"); + is_dump_done = true; + if (is_pay_done) done_callback(is_ok); + return; + } + child_process.exec("./block_share_dumps/process.sh " + fn, function callback(error, stdout, stderr) { + if (error) console.error("./block_share_dumps/process.sh " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); + is_dump_done = true; + if (is_pay_done) done_callback(is_ok); + }); + }); + } else { + is_dump_done = true; + } } const default_window = blockDiff*global.config.pplns.shareMulti; @@ -453,7 +466,6 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do const pay_window = is_need_correction ? totalPayments : default_window; let add_count = 0; - let is_ok = true; Object.keys(paymentData).forEach(function (key) { if (paymentData[key].amount) { paymentData[key].hex = block_hex; @@ -461,7 +473,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do ++ add_count; createBlockBalanceQueue.push(paymentData[key], function (status) { if (status === false) is_ok = false; - if (--add_count == 0) done_callback(is_ok); + if (--add_count == 0 && is_dump_done) return done_callback(is_ok); }); } }); From 485d53fcc9068e83c0787743169cf78f23624c22 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 21:52:06 -0800 Subject: [PATCH 0702/1496] Reduce parallel block dumps --- lib/blockManager.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index cce784f4e..1ade27c27 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -447,13 +447,13 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do if (err) { console.error("Error saving " + fn + " file"); is_dump_done = true; - if (is_pay_done) done_callback(is_ok); + if (is_pay_done) return done_callback(is_ok); return; } child_process.exec("./block_share_dumps/process.sh " + fn, function callback(error, stdout, stderr) { if (error) console.error("./block_share_dumps/process.sh " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); is_dump_done = true; - if (is_pay_done) done_callback(is_ok); + if (is_pay_done) return done_callback(is_ok); }); }); } else { @@ -473,7 +473,10 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do ++ add_count; createBlockBalanceQueue.push(paymentData[key], function (status) { if (status === false) is_ok = false; - if (--add_count == 0 && is_dump_done) return done_callback(is_ok); + if (--add_count == 0) { + is_pay_done = true; + if (is_dump_done) return done_callback(is_ok); + } }); } }); From 8b22517ed0206b0aa05de161b69ec952848bb071 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Dec 2019 21:54:16 -0800 Subject: [PATCH 0703/1496] Reduce parallel block dumps --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1ade27c27..a5499e8c3 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -452,6 +452,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do } child_process.exec("./block_share_dumps/process.sh " + fn, function callback(error, stdout, stderr) { if (error) console.error("./block_share_dumps/process.sh " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); + else console.log("./block_share_dumps/process.sh " + fn + ": complete"); is_dump_done = true; if (is_pay_done) return done_callback(is_ok); }); From 93dd58397b715cc3b5e2e416c72b84ab860df690 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 09:01:13 -0800 Subject: [PATCH 0704/1496] Debug --- lib/blockManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index a5499e8c3..1822d2da5 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -690,7 +690,9 @@ function altblockUnlocker() { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 5) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; + console.log("Start " + block.port + " " + block.height); global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { + console.log("Finish " + block.port + " " + block.height); const is_valid_request = (err === null); if (!is_valid_request) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); From d04c1ea3527426c886f5740316961c33ce2c5f91 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 09:05:47 -0800 Subject: [PATCH 0705/1496] Debug --- lib/blockManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1822d2da5..4d93545cf 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -702,6 +702,7 @@ function altblockUnlocker() { console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); return next(); } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + console.log("Pre " + block.port + " " + block.height); global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; @@ -719,6 +720,7 @@ function altblockUnlocker() { }); } else if (is_valid_request && (!is_pplns_block || block.pay_ready === true)) { if (block.pay_value !== 0) { + console.log("Pay " + block.port + " " + block.height); altblockPayments(block, function() { return next(); } ); } else { if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; From 6974a8204624d2d67ce6c2b3cbf9eb51512f0b59 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 09:12:01 -0800 Subject: [PATCH 0706/1496] Debug --- lib/blockManager.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 4d93545cf..9029615e7 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -790,25 +790,27 @@ function altblockPayments(block, cb) { } switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: + console.log("Start2 " + block.port + " " + block.height); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { + console.log("Finish2 " + block.port + " " + block.height); if (err === null && block.height === header.height && block.value >= header.reward /*&& block.difficulty === header.difficulty*/){ - global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { - if (anchor_err === null){ - if (paymentInProgress) { - console.error("Skipping payment as there's a payment in progress"); - return cb(); - } + //global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { + //if (anchor_err === null){ + //if (paymentInProgress) { + //console.error("Skipping payment as there's a payment in progress"); + //return cb(); + //} paymentInProgress = true; doPPLNSPayments(block.hash, block.pay_value, function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); return cb(); }); - } else { - console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); - return cb(); - } - }); + //} else { + // console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); + // return cb(); + //} + //}); } else { console.error("Can't get correct altblock header of " + block.port.toString() + " port by hash " + block.hash.toString('hex')); return cb(); From ba6c39ced395c5c225027840a93136a77a32f2dc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 09:49:33 -0800 Subject: [PATCH 0707/1496] Store only 2 hour old dumps --- lib/blockManager.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 9029615e7..a90a9ae05 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -280,7 +280,7 @@ function calculatePPSPayments(blockHeader, callback) { return callback(); } -function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, done_callback) { +function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is_store_dump, done_callback) { const rewardTotal = 1.0; console.log("Performing PPLNS reward pre-calculations of block " + block_hex + " on (anchor) height " + block_height); const blockDiff = block_difficulty; @@ -435,11 +435,11 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, do return done_callback(false); } const topBlockHeight = body.height; - return preCalculatePPLNSPayments(block_hex, topBlockHeight, block_difficulty, done_callback); + return preCalculatePPLNSPayments(block_hex, topBlockHeight, block_difficulty, is_store_dump, done_callback); }); return; } else { - if (fs.existsSync("./block_share_dumps/process.sh")) { + if (is_store_dump && fs.existsSync("./block_share_dumps/process.sh")) { shares4dump.sort(); shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); const fn = "block_share_dumps/" + block_hex + ".cvs"; @@ -642,7 +642,7 @@ function blockUnlocker() { return next(); } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.height, block.difficulty, function(status) { + preCalculatePPLNSPayments(block.hash, block.height, block.difficulty, true, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations of block " + block.hash + " on height " + block.height); global.database.payReadyBlock(block.hash); @@ -706,7 +706,7 @@ function altblockUnlocker() { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, function(status) { + preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, (topBlockHeight - block.anchor_height) < 60, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); global.database.payReadyAltBlock(block.hash); From 696828a219fb4e3da6ebb064f5538644a16fb580 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 09:49:51 -0800 Subject: [PATCH 0708/1496] Store only 4 hour old dumps --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index a90a9ae05..a00380f68 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -706,7 +706,7 @@ function altblockUnlocker() { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, (topBlockHeight - block.anchor_height) < 60, function(status) { + preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, (topBlockHeight - block.anchor_height) < 120, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); global.database.payReadyAltBlock(block.hash); From b24914635e783a4cef9c3cb907cb9d13f1652e31 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 13:30:30 -0800 Subject: [PATCH 0709/1496] Added short RPC wallet timeout --- lib/coins/xmr.js | 2 +- lib/support.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9ae793b7b..72511e45a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -212,7 +212,7 @@ function Coin(data){ } const miner_tx_hash = body.result.miner_tx_hash == "" ? body.result.block_header.miner_tx_hash : body.result.miner_tx_hash; - if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port+1, "get_transfer_by_txid", {"txid": miner_tx_hash}, function (body2) { + if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWalletShort(port + 1, "get_transfer_by_txid", {"txid": miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); diff --git a/lib/support.js b/lib/support.js index 9d36a6d31..fc7a94454 100644 --- a/lib/support.js +++ b/lib/support.js @@ -170,14 +170,14 @@ function rpc(host, port, method, params, callback, timeout) { return jsonRequest(host, port, data, false, callback, 'json_rpc', timeout); } -function rpc_wallet(host, port, method, params, callback) { +function rpc_wallet(host, port, method, params, callback, timeout) { let data = { id: "0", jsonrpc: "2.0", method: method, params: params }; - return jsonRequest(host, port, data, true, callback, 'json_rpc', 30*60*1000); + return jsonRequest(host, port, data, true, callback, 'json_rpc', timeout); } function https_get(url, callback) { @@ -330,10 +330,13 @@ module.exports = function () { rpc(global.config.daemon.address, port, method, params, callback, 30*1000); }, rpcWallet: function (method, params, callback) { - rpc_wallet(global.config.wallet.address, global.config.wallet.port, method, params, callback); + rpc_wallet(global.config.wallet.address, global.config.wallet.port, method, params, callback, 30*60*1000); }, rpcPortWallet: function (port, method, params, callback) { - rpc_wallet(global.config.wallet.address, port, method, params, callback); + rpc_wallet(global.config.wallet.address, port, method, params, callback, 30*60*1000); + }, + rpcPortWalletShort: function (port, method, params, callback) { + rpc_wallet(global.config.wallet.address, port, method, params, callback, 10*1000); }, circularBuffer: circularBuffer, formatDate: formatDate, From 1d89f269d37db81c1c49c872e81b3290adcc401a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 13:33:57 -0800 Subject: [PATCH 0710/1496] Removed debug --- lib/blockManager.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index a00380f68..192d162ee 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -690,9 +690,7 @@ function altblockUnlocker() { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 5) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - console.log("Start " + block.port + " " + block.height); global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { - console.log("Finish " + block.port + " " + block.height); const is_valid_request = (err === null); if (!is_valid_request) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); @@ -720,7 +718,6 @@ function altblockUnlocker() { }); } else if (is_valid_request && (!is_pplns_block || block.pay_ready === true)) { if (block.pay_value !== 0) { - console.log("Pay " + block.port + " " + block.height); altblockPayments(block, function() { return next(); } ); } else { if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; @@ -790,9 +787,7 @@ function altblockPayments(block, cb) { } switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: - console.log("Start2 " + block.port + " " + block.height); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { - console.log("Finish2 " + block.port + " " + block.height); if (err === null && block.height === header.height && block.value >= header.reward /*&& block.difficulty === header.difficulty*/){ //global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { //if (anchor_err === null){ From 907fa471d166192abd90dfd4345da7e76d4da9fb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 13:35:57 -0800 Subject: [PATCH 0711/1496] Removed debug --- lib/blockManager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 192d162ee..d48c00100 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -700,7 +700,6 @@ function altblockUnlocker() { console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); return next(); } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { - console.log("Pre " + block.port + " " + block.height); global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; From b33845cc1966bf911e25967271705377c162c30a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Dec 2019 17:31:26 -0800 Subject: [PATCH 0712/1496] Reduced time to 12h --- manage_scripts/user_del.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index e72b0f486..2c3f9af83 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -46,7 +46,7 @@ require("../init_mini.js").init(function() { } if (rows.length) { console.log("Balance last update time: " + rows[0].last_edited); - if (Date.now()/1000 - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { + if (Date.now()/1000 - global.support.formatDateFromSQL(rows[0].last_edited) < 12*60*60) { console.error("There was recent amount update. Refusing to continue!"); process.exit(1); } From 953f69a2f616395f617d80b8f0d0328a1c023c42 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Dec 2019 16:01:40 -0800 Subject: [PATCH 0713/1496] Do not process new blocks (give them time to merge) --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index d48c00100..1def3e10a 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -688,7 +688,7 @@ function altblockUnlocker() { } const topBlockHeight = body.height; async.eachSeries(blockList, function(block, next) { - if (topBlockHeight - block.anchor_height <= 5) return next(); + if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { const is_valid_request = (err === null); From 5201c82750a76ed19ce62252881153aaa7450de6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 24 Dec 2019 17:29:11 -0800 Subject: [PATCH 0714/1496] Added c29 support --- lib/coins/xmr.js | 40 +++++++++---- lib/pool.js | 152 +++++++++++++++++++++++++++-------------------- package.json | 10 +--- 3 files changed, 118 insertions(+), 84 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 72511e45a..58cbb649d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -35,6 +35,7 @@ const port2coin = { "19734": "SUMO", "13007": "IRD", "19994": "ARQ", + "33124": "XTNC", "19281": "XMV", }; const port2blob_num = { @@ -53,7 +54,8 @@ const port2blob_num = { "19734": 0, // SUMO "13007": 2, // IRD "19994": 0, // ARQ - "19281": 0, // XMV + "19281": 8, // XMV + "33124": 8, // XTNC }; const port2algo = { @@ -64,7 +66,7 @@ const port2algo = { "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR "18981": "cn/rwz", // Graft - "19281": "rx/v", // MoneroV + "19281": "c29v", // MoneroV "19734": "cn/r", // SUMO "19994": "rx/arq", // ArqMa "20189": "defyx", // Scala @@ -306,8 +308,8 @@ function Coin(data){ return blob; }; - this.constructNewBlob = function(blockTemplate, NonceBuffer, port){ - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0])); + this.constructNewBlob = function(blockTemplate, NonceBuffer, port, ring){ + return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0]), ring); }; this.constructMMParentBlockBlob = function(parentTemplateBuffer, port, childTemplateBuffer) { @@ -423,7 +425,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "rx/0": 1, "rx/loki": 1, "rx/v": 1 }; + return { "rx/0": 1, "rx/loki": 1 }; } this.getPrevAlgosPerf = function() { @@ -434,7 +436,7 @@ function Coin(data){ let coin_perf = {}; - if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["LOKI"] = coin_perf["XMV"] = algos_perf["rx/0"]; + if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["LOKI"] = algos_perf["rx/0"]; if ("cn/r" in algos_perf) coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; @@ -465,9 +467,8 @@ function Coin(data){ if ("rx/arq" in algos_perf) coin_perf["ARQ"] = algos_perf["rx/arq"]; - if ("rx/v" in algos_perf) coin_perf["XMV"] = algos_perf["rx/v"]; - - //if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; + if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; + if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; @@ -501,30 +502,43 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft - case 19281: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 19); // MoneroV case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube - //case 33124: return multiHashing.cryptonight_pico(convertedBlob, 0); // XtendCash??? case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean default: - console.error("Unknown " + blockTemplate.port + " port for PoW type"); + console.error("Unknown " + blockTemplate.port + " port for Cryptonight PoW type"); return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); } } + this.c29 = function(header, ring, port) { + switch (port) { + case 19281: return multiHashing.c29v(header, ring); // MoneroV + case 33124: return multiHashing.c29s(header, ring); // XtendCash + default: + console.error("Unknown " + port + " port for Cuckaroo PoW type"); + return multiHashing.c29s(header, ring); + } + } + + this.c29_cycle_hash = function(ring) { + return multiHashing.cycle_hash(ring); + } + this.blobTypeStr = function(port, version) { switch (port) { case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO + case 19281: return "cuckaroo"; // MoneroV case 22023: return "cryptonote_loki"; // LOKI - case 33124: return "cryptonote_loki"; // XtendCash + case 33124: return "cuckaroo"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; } diff --git a/lib/pool.js b/lib/pool.js index 4bb880152..7bc3a234d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1,6 +1,5 @@ "use strict"; const debug = require('debug')('pool'); -const uuidV4 = require('uuid/v4'); const crypto = require('crypto'); const bignum = require('bignum'); const cluster = require('cluster'); @@ -17,6 +16,13 @@ const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); const hexMatch = new RegExp("^[0-9a-f]+$"); const baseDiff = global.coinFuncs.baseDiff(); +function get_new_id() { + const min = 1000000000; + const max = 1999999999; + const id = Math.floor(Math.random() * (max - min + 1)) + min; + return id.toString(); +}; + let bannedIPs = {}; let bannedAddresses = {}; let notifyAddresses = {}; @@ -544,11 +550,7 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -//let cacheTargetHex = {}; - function getTargetHex(difficulty, size) { - //const result = cacheTargetHex[difficulty]; - //if (result) return result; let padded = new Buffer(32); padded.fill(0); const diffBuff = baseDiff.div(difficulty).toBuffer(); @@ -557,7 +559,6 @@ function getTargetHex(difficulty, size) { const buffArray = buff.toByteArray().reverse(); const buffReversed = new Buffer(buffArray); const new_result = buffReversed.toString('hex'); - //cacheTargetHex[difficulty] = new_result; return new_result; }; @@ -1033,7 +1034,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!this.proxy) { const blob = bt.nextBlob(); const newJob = { - id: crypto.pseudoRandomBytes(21).toString('base64'), + id: get_new_id(), coin: coin, blob_type_num: blob_type_num, blockHash: bt.idHash, @@ -1045,20 +1046,29 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer submissions: {} }; this.validJobs.enq(newJob); - this.cachedJob = { - blob: blob, - algo: params.algo_name, - //variant: params.variant_name, - height: bt.height, - seed_hash: bt.seed_hash, - job_id: newJob.id, - target: getTargetHex(this.difficulty, blob_type_num == 7 ? 8 : 4), - id: this.id + if (blob_type_num == 8) this.cachedJob = { + pre_pow: blob, + algo: "cuckaroo", + edgebits: 29, + proofsize: 32, + noncebytes: 4, + height: bt.height, + job_id: newJob.id, + difficulty: getTargetHex(this.difficulty), + id: this.id + } else this.cachedJob = { + blob: blob, + algo: params.algo_name, + height: bt.height, + seed_hash: bt.seed_hash, + job_id: newJob.id, + target: getTargetHex(this.difficulty, blob_type_num == 7 ? 8 : 4), + id: this.id }; } else { const blob = bt.nextBlobWithChildNonce(); const newJob = { - id: crypto.pseudoRandomBytes(21).toString('base64'), + id: get_new_id(), coin: coin, blob_type_num: blob_type_num, blockHash: bt.idHash, @@ -1076,7 +1086,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer blocktemplate_blob: blob, blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), algo: params.algo_name, - //variant: params.variant_name, difficulty: bt.difficulty, height: bt.height, seed_hash: bt.seed_hash, @@ -1371,7 +1380,9 @@ function getShareBuffer(miner, job, blockTemplate, params) { template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); } - return global.coinFuncs.constructNewBlob(template, new Buffer(params.nonce, 'hex'), blockTemplate.port); + return job.blob_type_num == 8 ? + global.coinFuncs.constructNewBlob(template, bignum(params.nonce, 10).toBuffer({endian: 'little', size: 4}), blockTemplate.port, params.pow) : + global.coinFuncs.constructNewBlob(template, new Buffer(params.nonce, 'hex'), blockTemplate.port); } catch (e) { const err_str = "Can't constructNewBlob with " + params.nonce + " nonce from " + miner.logString + ": " + e; console.error(err_str); @@ -1469,39 +1480,59 @@ function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { ); } +function hash_buff_diff(hash) { + return baseDiff.div(bignum.fromBuffer(new Buffer(hash.toByteArray().reverse()))); +} + +function report_miner_share(miner, job) { + const time_now = Date.now(); + if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { + console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); + lastMinerLogTime[miner.payout] = time_now; + } +} + function processShare(miner, job, blockTemplate, params) { - let hash; - let isTrustedShare; + let hashDiff; let shareBuffer; - const resultHash = params.result; + let isTrustedShare; + const port = blockTemplate.port; + const blob_type_num = job.blob_type_num; + const resultHash = params.result; // can be undefined for blob_type_num == 8 (and will not be used in submit_block since isTrustedShare = false) if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); - if (global.config.pool.trustedMiners && + if (blob_type_num == 8) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + const header = Buffer.concat([global.coinFuncs.convertBlob(shareBuffer, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); + if (global.coinFuncs.c29(header, params.pow, port)) { + report_miner_share(miner, job); + return invalid_share(miner); + } + hashDiff = hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow)); + isTrustedShare = false; + + } else if (global.config.pool.trustedMiners && is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && miner.trust.check_height !== job.height ) { - try { - hash = new Buffer(resultHash, 'hex'); - if (miner.payout in extra_wallet_verify) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer !== null) { - let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); - if (hash2.toString('hex') !== resultHash) { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); - } else { - extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(blockTemplate.port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); - } + hashDiff = hash_buff_diff(new Buffer(resultHash, 'hex')); + isTrustedShare = true; + if (miner.payout in extra_wallet_verify) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (shareBuffer !== null) { + let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); + const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); + if (hash2.toString('hex') !== resultHash) { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); } else { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); + extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); } + } else { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); } - } catch (err) { - return invalid_share(miner); } - isTrustedShare = true; } else { // verify share if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { @@ -1517,26 +1548,18 @@ function processShare(miner, job, blockTemplate, params) { } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (shareBuffer === null) return invalid_share(miner); - let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); + const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); + const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); if (hash.toString('hex') !== resultHash) { - let time_now = Date.now(); - if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); - lastMinerLogTime[miner.payout] = time_now; - } + report_miner_share(miner, job); return invalid_share(miner); } - - walletTrust[miner.payout] += job.rewarded_difficulty2; + hashDiff = hash_buff_diff(hash); isTrustedShare = false; + walletTrust[miner.payout] += job.rewarded_difficulty2; } - let hashArray = hash.toByteArray().reverse(); - let hashNum = bignum.fromBuffer(new Buffer(hashArray)); - let hashDiff = baseDiff.div(hashNum); - let is_block_diff_matched = false; if (hashDiff.ge(blockTemplate.difficulty)) { // Submit block to the RPC Daemon. @@ -1558,7 +1581,7 @@ function processShare(miner, job, blockTemplate, params) { blockTemplate.child_template_buffer = Buffer.from(blockTemplate.child_template_buffer); let shareBuffer2 = null; try { - shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, blockTemplate.port, blockTemplate.child_template_buffer); + shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, port, blockTemplate.child_template_buffer); } catch (e) { const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; console.error(err_str); @@ -1570,9 +1593,9 @@ function processShare(miner, job, blockTemplate, params) { is_block_diff_matched = true; } - if (is_block_diff_matched) { // Do nothing here + if (is_block_diff_matched) return true; - } else if (hashDiff.lt(job.difficulty)) { + if (hashDiff.lt(job.difficulty)) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString); @@ -1587,9 +1610,8 @@ function processShare(miner, job, blockTemplate, params) { job.rewarded_difficulty2 = 0; recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); } + return true; } - - return true; } // Message times for different miner addresses @@ -1616,8 +1638,8 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi return; } if (!params.pass) params.pass = "x"; - let difficulty = portData.difficulty; - let minerId = uuidV4(); + const difficulty = portData.difficulty; + const minerId = get_new_id(); miner = new Miner( minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] @@ -1708,9 +1730,11 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi return; } - const nonceCheck = job.blob_type_num == 7 ? nonceCheck64 : nonceCheck32; + const is_bad_nonce = job.blob_type_num == 8 ? + (typeof params.nonce !== 'number') || (typeof params.pow !== 'array') || (params.pow.length != 32) : + (typeof params.nonce !== 'string') || !(job.blob_type_num == 7 ? nonceCheck64.test(params.nonce) : nonceCheck32.test(params.nonce) ); - if ((typeof params.nonce !== 'string') || !nonceCheck.test(params.nonce)) { + if (is_bad_nonce) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); @@ -1719,6 +1743,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi } let nonce_test; + if (miner.proxy) { if (!Number.isInteger(params.poolNonce) || !Number.isInteger(params.workerNonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); @@ -1727,9 +1752,10 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi miner.storeInvalidShare(); return; } - nonce_test = `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; + nonce_test = job.blob_type_num == 8 ? params.pow.join(':') + `_${params.poolNonce}_${params.workerNonce}` + : `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; } else { - nonce_test = params.nonce; + nonce_test = job.blob_type_num == 8 ? params.pow.join(':') : params.nonce; } if (nonce_test in job.submissions) { diff --git a/package.json b/package.json index 55043da99..de01a1314 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,7 @@ "dependencies": { "async": "2.1.4", "bignum": "^0.12.5", - "bluebird": "3.4.7", "body-parser": "^1.16.0", - "bufferutil": "^1.3.0", "circular-buffer": "1.0.2", "cluster": "0.7.7", "concat-stream": "^1.6.0", @@ -31,18 +29,14 @@ "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", "range": "0.0.3", - "redis": "^2.6.5", "request": "^2.79.0", "request-json": "0.6.1", "shapeshift.io": "1.3.0", "socketio": "^1.0.0", "sprintf-js": "^1.0.3", - "sticky-cluster": "^0.3.1", - "uuid": "3.0.1", "wallet-address-validator": "0.1.0", - "zmq": "^2.15.3", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v6.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v15.1.1" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.0" } } From b8363da9541caf1222bb3ddb06870695527a1c97 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 24 Dec 2019 17:32:50 -0800 Subject: [PATCH 0715/1496] bug fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7bc3a234d..e42143510 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1056,7 +1056,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer job_id: newJob.id, difficulty: getTargetHex(this.difficulty), id: this.id - } else this.cachedJob = { + }; else this.cachedJob = { blob: blob, algo: params.algo_name, height: bt.height, From c7c4ea268e515fcf32497464336caed762114273 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 11:16:57 -0800 Subject: [PATCH 0716/1496] Added XWP support --- README.md | 1 + deployment/base.sql | 3 +++ lib/coins/xmr.js | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5d6412a6..0353cb9f8 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XTNC - ```XtazhSxz1bbJLpT2JuiD2UWFUJYSFty5SVWuF6sy2w9v8pn69smkUxkTVCQc8NKCd6CBMNDGzgdPRYBKaHdbgZ5SNptVH1yPCTQ``` * IRD - ```ir3DHyB8Ub1aAHEewMeUxQ7b7tQdWa7VL8M5oXDPohS3Me4nhwvALXM4mym2kWg9VsceT75dm6XWiWF1K4zu8RVQ1HJD8Z3R9``` * ARQ - ```ar4Ha6ZQCkKRhkKQLfexv7VZQM2MhUmMmU9hmzswCPK4T3o2rbPKZM1GxEoYg4AFQsh57PsEets7sbpU958FAvxo2RkkTQ1gE``` +* XWP - ```fh4MCJrakhWGoS6Meqp6UxGE1GNfAjKaRdPjW36rTffDiqvEq2HWEKZhrbYRw7XJb3CXxkjL3tcYGTT39m5qgjvk1ap4bVu1R``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index 952b388c3..1b0251543 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -218,6 +218,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortIRD', '0', 'int', 'Iridium coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortARQ', '0', 'int', 'ArqMa coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMV', '0', 'int', 'MoneroV coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXWP', '0', 'int', 'Swap coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -235,6 +236,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorIRD', '0', 'float', 'Iridium algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorARQ', '0', 'float', 'ArqMa algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMV', '0', 'float', 'MoneroV algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXWP', '0', 'float', 'Swap algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -288,6 +290,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11898', '', 'string', 'Address to mine to for 11898 (Turtle) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13007', '', 'string', 'Address to mine to for 13007 (Iridium) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19994', '', 'string', 'Address to mine to for 19994 (ArqMa) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19950', '', 'string', 'Address to mine to for 19950 (Swap) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunURL', '', 'string', 'MailGun URL for notifications'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 58cbb649d..a21c3afa1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -37,6 +37,7 @@ const port2coin = { "19994": "ARQ", "33124": "XTNC", "19281": "XMV", + "19950": "XWP", }; const port2blob_num = { "11181": 7, // AEON @@ -56,6 +57,7 @@ const port2blob_num = { "19994": 0, // ARQ "19281": 8, // XMV "33124": 8, // XTNC + "19950": 8, // XWP }; const port2algo = { @@ -68,6 +70,7 @@ const port2algo = { "18981": "cn/rwz", // Graft "19281": "c29v", // MoneroV "19734": "cn/r", // SUMO + "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa "20189": "defyx", // Scala "22023": "rx/loki", // LOKI @@ -467,7 +470,7 @@ function Coin(data){ if ("rx/arq" in algos_perf) coin_perf["ARQ"] = algos_perf["rx/arq"]; - if ("c29s" in algos_perf) coin_perf["XTNC"] = algos_perf["c29s"]; + if ("c29s" in algos_perf) coin_perf["XTNC"] = coin_perf["XWP"] = algos_perf["c29s"]; if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; @@ -519,6 +522,7 @@ function Coin(data){ this.c29 = function(header, ring, port) { switch (port) { case 19281: return multiHashing.c29v(header, ring); // MoneroV + case 19950: return multiHashing.c29s(header, ring); // Swap case 33124: return multiHashing.c29s(header, ring); // XtendCash default: console.error("Unknown " + port + " port for Cuckaroo PoW type"); @@ -537,6 +541,7 @@ function Coin(data){ case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO case 19281: return "cuckaroo"; // MoneroV + case 19950: return "cuckaroo"; // Swap case 22023: return "cryptonote_loki"; // LOKI case 33124: return "cuckaroo"; // XtendCash case 38081: return "cryptonote3"; // MSR From adaff4533fc46a999e36d6e2baa44cf232c50b04 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 13:48:58 -0800 Subject: [PATCH 0717/1496] Added grin stratum proto support --- lib/pool.js | 114 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 39 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e42143510..babfe2ed4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -17,8 +17,8 @@ const hexMatch = new RegExp("^[0-9a-f]+$"); const baseDiff = global.coinFuncs.baseDiff(); function get_new_id() { - const min = 1000000000; - const max = 1999999999; + const min = 100000000000000; + const max = 999999999999999; const id = Math.floor(Math.random() * (max - min + 1)) + min; return id.toString(); }; @@ -562,7 +562,7 @@ function getTargetHex(difficulty, size) { return new_result; }; -function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { +function Miner(id, login, pass, ipAddress, startingDiff, sendReplyMethod, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. // Default function is to use the password so they can login. Identifiers can be unique, payment ID is last. @@ -763,7 +763,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.proxy = agent && agent.includes('xmr-node-proxy'); this.id = id; this.ipAddress = ipAddress; - this.messageSender = messageSender; + this.sendReplyMethod = sendReplyMethod; this.connectTime = Date.now(); this.heartbeat = function () { this.lastContact = Date.now(); }; this.heartbeat(); @@ -1103,7 +1103,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.sendCoinJob = function(coin, params) { const job = this.getCoinJob(coin, params); if (job === null) return; - return this.messageSender('job', job); + return this.protocol === "grin" ? sendReplyMethod("getjobtemplate", job) : this.sendReplyMethod('job', job); }; this.sendSameCoinJob = function () { @@ -1624,24 +1624,26 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(socket, method, params, ip, portData, sendReply, sendFinalReply, pushMessage) { - let miner; - +function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, sendReplyMethod) { switch (method) { - case 'login': + case 'login': { // grin and default if (ip in bannedIPs) { - sendFinalReply("New connections from this IP address are temporarily suspended from mining (10 minutes max)"); + sendReplyFinal("New connections from this IP address are temporarily suspended from mining (10 minutes max)"); + return; + } + if (!params) { + sendReplyFinal("No params specified"); return; } if (!params.login) { - sendFinalReply("No login specified"); + sendReplyFinal("No login specified"); return; } if (!params.pass) params.pass = "x"; const difficulty = portData.difficulty; const minerId = get_new_id(); - miner = new Miner( - minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, + let miner = new Miner( + minerId, params.login, params.pass, ip, difficulty, sendReplyMethod, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); if (params.agent && cluster.worker.id == 1) minerAgents[params.agent] = 1; @@ -1651,7 +1653,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); lastMinerLogTime[miner.payout] = time_now; } - sendFinalReply(miner.error); + sendReplyFinal(miner.error); return; } @@ -1662,7 +1664,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_notification); - sendFinalReply(miner_notification + " (miner will connect after several attempts)"); + sendReplyFinal(miner_notification + " (miner will connect after several attempts)"); return; } } @@ -1688,15 +1690,38 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi } } } - sendReply(null, { - id: minerId, - job: miner.getBestCoinJob(), - status: 'OK' - }); + if (id === "Stratum") { + sendReplyMethod("login", "ok"); + miner.protocol = "grin"; + } else { + sendReply(null, { + id: minerId, + job: miner.getBestCoinJob(), + status: 'OK' + }); + miner.protocol = "default"; + } break; + } - case 'getjob': - miner = activeMiners.get(params.id); + case 'getjobtemplate': { // grin only + const minerId = socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""; + let miner = activeMiners.get(minerId); + if (!miner) { + sendReply('Unauthenticated'); + return; + } + miner.heartbeat(); + sendReplyMethod("getjobtemplate", miner.getBestCoinJob()); + break; + } + + case 'getjob': { + if (!params) { + sendReplyFinal("No params specified"); + return; + } + let miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1711,9 +1736,15 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi } miner.sendBestCoinJob(); break; + } - case 'submit': - miner = activeMiners.get(params.id); + case 'submit': { // grin and default + if (!params) { + sendReplyFinal("No params specified"); + return; + } + const minerId = params.id ? params.id : (socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""); + let miner = activeMiners.get(minerId); if (!miner) { sendReply('Unauthenticated'); return; @@ -1831,12 +1862,21 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi miner.lastShareTime = Date.now() / 1000 || 0; - sendReply(null, {status: 'OK'}); + if (miner.protocol === "grin") { + sendReplyMethod("submit", "ok"); + } else { + sendReply(null, {status: 'OK'}); + } //if (miner.debugMiner) console.log("SUBMIT OK"); break; + } - case 'keepalived': - miner = activeMiners.get(params.id); + case 'keepalived': { + if (!params) { + sendReplyFinal("No params specified"); + return; + } + let miner = activeMiners.get(params.id); if (!miner) { sendReply('Unauthenticated'); return; @@ -1846,6 +1886,7 @@ function handleMinerData(socket, method, params, ip, portData, sendReply, sendFi status: 'KEEPALIVED' }); break; + } } } @@ -2134,19 +2175,14 @@ if (cluster.isMaster) { if (global.config[portData.portType].enable !== true) { return; } - let handleMessage = function (socket, jsonData, pushMessage) { + let handleMessage = function (socket, jsonData, sendReplyMethod) { if (!jsonData.id) { console.warn('Miner RPC request missing RPC id'); return; - } - else if (!jsonData.method) { + } else if (!jsonData.method) { console.warn('Miner RPC request missing RPC method'); return; } - else if (!jsonData.params) { - console.warn('Miner RPC request missing RPC params'); - return; - } let sendReply = function (error, result) { if (!socket.writable) return; @@ -2157,7 +2193,7 @@ if (cluster.isMaster) { result: result }) + "\n"); }; - let sendFinalReply = function (error) { + let sendReplyFinal = function (error) { setTimeout(function() { if (!socket.writable) return; socket.end(JSON.stringify({ @@ -2168,7 +2204,7 @@ if (cluster.isMaster) { }) + "\n"); }, 9 * 1000); }; - handleMinerData(socket, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendFinalReply, pushMessage); + handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, sendReplyMethod); }; function socketConn(socket) { @@ -2177,7 +2213,7 @@ if (cluster.isMaster) { let dataBuffer = ''; - let pushMessage = function (method, params) { + let sendReplyMethod = function (method, params) { if (!socket.writable) return; socket.write(JSON.stringify({ jsonrpc: "2.0", @@ -2227,14 +2263,14 @@ if (cluster.isMaster) { break; } - handleMessage(socket, jsonData, pushMessage); + handleMessage(socket, jsonData, sendReplyMethod); } dataBuffer = incomplete; } }).on('error', function (err) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { - pushMessage = function () {}; + sendReplyMethod = function () {}; if (socket.miner_ids) socket.miner_ids.forEach(miner_id => activeMiners.delete(miner_id)); }); } From eb44d4a06c9649588f6003593d2d0f6c16d3e94a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 14:42:39 -0800 Subject: [PATCH 0718/1496] Bug fix --- lib/pool.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index babfe2ed4..81725aa18 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -562,7 +562,7 @@ function getTargetHex(difficulty, size) { return new_result; }; -function Miner(id, login, pass, ipAddress, startingDiff, sendReplyMethod, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { +function Miner(id, login, pass, ipAddress, startingDiff, pushMethodMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. // Default function is to use the password so they can login. Identifiers can be unique, payment ID is last. @@ -763,7 +763,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, sendReplyMethod, protoV this.proxy = agent && agent.includes('xmr-node-proxy'); this.id = id; this.ipAddress = ipAddress; - this.sendReplyMethod = sendReplyMethod; + this.pushMethodMessage = pushMethodMessage; this.connectTime = Date.now(); this.heartbeat = function () { this.lastContact = Date.now(); }; this.heartbeat(); @@ -1054,7 +1054,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, sendReplyMethod, protoV noncebytes: 4, height: bt.height, job_id: newJob.id, - difficulty: getTargetHex(this.difficulty), + difficulty: this.difficulty, id: this.id }; else this.cachedJob = { blob: blob, @@ -1103,7 +1103,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, sendReplyMethod, protoV this.sendCoinJob = function(coin, params) { const job = this.getCoinJob(coin, params); if (job === null) return; - return this.protocol === "grin" ? sendReplyMethod("getjobtemplate", job) : this.sendReplyMethod('job', job); + return this.protocol === "grin" ? pushMethodMessage("getjobtemplate", job) : this.pushMethodMessage('job', job); }; this.sendSameCoinJob = function () { @@ -1624,7 +1624,7 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, sendReplyMethod) { +function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, sendReplyMethod, pushMethodMessage) { switch (method) { case 'login': { // grin and default if (ip in bannedIPs) { @@ -1643,7 +1643,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const difficulty = portData.difficulty; const minerId = get_new_id(); let miner = new Miner( - minerId, params.login, params.pass, ip, difficulty, sendReplyMethod, 1, portData.portType, portData.port, params.agent, + minerId, params.login, params.pass, ip, difficulty, pushMethodMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); if (params.agent && cluster.worker.id == 1) minerAgents[params.agent] = 1; @@ -2175,7 +2175,7 @@ if (cluster.isMaster) { if (global.config[portData.portType].enable !== true) { return; } - let handleMessage = function (socket, jsonData, sendReplyMethod) { + let handleMessage = function (socket, jsonData, pushMethodMessage) { if (!jsonData.id) { console.warn('Miner RPC request missing RPC id'); return; @@ -2204,7 +2204,16 @@ if (cluster.isMaster) { }) + "\n"); }, 9 * 1000); }; - handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, sendReplyMethod); + let sendReplyMethod = function (method, params) { + if (!socket.writable) return; + socket.write(JSON.stringify({ + id: jsonData.id, + jsonrpc: "2.0", + method: method, + params: params + }) + "\n"); + }; + handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, sendReplyMethod, pushMethodMessage); }; function socketConn(socket) { @@ -2213,7 +2222,7 @@ if (cluster.isMaster) { let dataBuffer = ''; - let sendReplyMethod = function (method, params) { + let pushMethodMessage = function (method, params) { if (!socket.writable) return; socket.write(JSON.stringify({ jsonrpc: "2.0", @@ -2263,14 +2272,14 @@ if (cluster.isMaster) { break; } - handleMessage(socket, jsonData, sendReplyMethod); + handleMessage(socket, jsonData, pushMethodMessage); } dataBuffer = incomplete; } }).on('error', function (err) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { - sendReplyMethod = function () {}; + pushMethodMessage = function () {}; if (socket.miner_ids) socket.miner_ids.forEach(miner_id => activeMiners.delete(miner_id)); }); } From cf4a718138081859d47e249c6181d8771f8ed542 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 14:58:59 -0800 Subject: [PATCH 0719/1496] Bug fix --- lib/pool.js | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 81725aa18..d7a6c9e76 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -562,7 +562,7 @@ function getTargetHex(difficulty, size) { return new_result; }; -function Miner(id, login, pass, ipAddress, startingDiff, pushMethodMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { +function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. // Default function is to use the password so they can login. Identifiers can be unique, payment ID is last. @@ -763,7 +763,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMethodMessage, prot this.proxy = agent && agent.includes('xmr-node-proxy'); this.id = id; this.ipAddress = ipAddress; - this.pushMethodMessage = pushMethodMessage; + this.pushMessage = pushMessage; this.connectTime = Date.now(); this.heartbeat = function () { this.lastContact = Date.now(); }; this.heartbeat(); @@ -1103,7 +1103,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMethodMessage, prot this.sendCoinJob = function(coin, params) { const job = this.getCoinJob(coin, params); if (job === null) return; - return this.protocol === "grin" ? pushMethodMessage("getjobtemplate", job) : this.pushMethodMessage('job', job); + return this.protocol === "grin" ? this.pushMessage({method: "getjobtemplate", result: job}) + : this.pushMessage({method: 'job', params: job}); }; this.sendSameCoinJob = function () { @@ -1624,7 +1625,7 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, sendReplyMethod, pushMethodMessage) { +function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, sendReplyMethodResult, pushMessage) { switch (method) { case 'login': { // grin and default if (ip in bannedIPs) { @@ -1643,7 +1644,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const difficulty = portData.difficulty; const minerId = get_new_id(); let miner = new Miner( - minerId, params.login, params.pass, ip, difficulty, pushMethodMessage, 1, portData.portType, portData.port, params.agent, + minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); if (params.agent && cluster.worker.id == 1) minerAgents[params.agent] = 1; @@ -1691,7 +1692,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } } if (id === "Stratum") { - sendReplyMethod("login", "ok"); + sendReplyMethodResult("login", "ok"); miner.protocol = "grin"; } else { sendReply(null, { @@ -1712,7 +1713,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } miner.heartbeat(); - sendReplyMethod("getjobtemplate", miner.getBestCoinJob()); + sendReplyMethodResult("getjobtemplate", miner.getBestCoinJob()); break; } @@ -1863,7 +1864,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.lastShareTime = Date.now() / 1000 || 0; if (miner.protocol === "grin") { - sendReplyMethod("submit", "ok"); + sendReplyMethodResult("submit", "ok"); } else { sendReply(null, {status: 'OK'}); } @@ -2175,7 +2176,7 @@ if (cluster.isMaster) { if (global.config[portData.portType].enable !== true) { return; } - let handleMessage = function (socket, jsonData, pushMethodMessage) { + let handleMessage = function (socket, jsonData, pushMessage) { if (!jsonData.id) { console.warn('Miner RPC request missing RPC id'); return; @@ -2204,16 +2205,16 @@ if (cluster.isMaster) { }) + "\n"); }, 9 * 1000); }; - let sendReplyMethod = function (method, params) { + let sendReplyMethodResult = function (method, result) { if (!socket.writable) return; socket.write(JSON.stringify({ id: jsonData.id, jsonrpc: "2.0", method: method, - params: params + result: result }) + "\n"); }; - handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, sendReplyMethod, pushMethodMessage); + handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, sendReplyMethodResult, pushMessage); }; function socketConn(socket) { @@ -2222,13 +2223,10 @@ if (cluster.isMaster) { let dataBuffer = ''; - let pushMethodMessage = function (method, params) { + let pushMessage = function (body) { if (!socket.writable) return; - socket.write(JSON.stringify({ - jsonrpc: "2.0", - method: method, - params: params - }) + "\n"); + body.jsonrpc = "2.0"; + socket.write(JSON.stringify(body) + "\n"); }; socket.on('data', function (d) { @@ -2272,14 +2270,14 @@ if (cluster.isMaster) { break; } - handleMessage(socket, jsonData, pushMethodMessage); + handleMessage(socket, jsonData, pushMessage); } dataBuffer = incomplete; } }).on('error', function (err) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { - pushMethodMessage = function () {}; + pushMessage = function () {}; if (socket.miner_ids) socket.miner_ids.forEach(miner_id => activeMiners.delete(miner_id)); }); } From 7c8fc0ef2879c4368bfc0edffedf490a025a63c6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 15:38:24 -0800 Subject: [PATCH 0720/1496] Bug fix --- lib/pool.js | 56 +++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d7a6c9e76..7dd5ac399 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -797,16 +797,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.fixed_diff = true; this.difficulty = global.coinFuncs.niceHashDiff; } - if (login_diff_split.length === 2) { - this.fixed_diff = true; - this.difficulty = Number(login_diff_split[1]); - if (this.difficulty < global.config.pool.minDifficulty) { - this.difficulty = global.config.pool.minDifficulty; - } - if (this.difficulty > global.config.pool.maxDifficulty) { - this.difficulty = global.config.pool.maxDifficulty; - } - } // 3d) trust stuff @@ -862,25 +852,25 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi let miner = this; COINS.forEach(function(coin) { if (!(coin in miner.coin_perf)) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coin_perf"); - return; + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coin_perf"); + return; } if (!(coin in activeBlockTemplates)) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplates"); - return; + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplates"); + return; } const coinHashFactor = currCoinHashFactorMM[coin]; if (!coinHashFactor) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); - return; + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); + return; } const bt = activeBlockTemplates[coin]; const port = bt.port; const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no algo support"); - return; + if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no algo support"); + return; } let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; @@ -892,6 +882,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }); if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { + this.curr_min_diff = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)) == 8 ? 1 : global.config.pool.minDifficulty; const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; if (factor != 1) { @@ -911,6 +902,20 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi return best_coin; }; + this.curr_min_diff = global.config.pool.minDifficulty; + this.curr_coin = this.selectBestCoin(); + + if (login_diff_split.length === 2) { + this.fixed_diff = true; + this.difficulty = Number(login_diff_split[1]); + if (this.difficulty < this.curr_min_diff) { + this.difficulty = this.curr_min_diff; + } + if (this.difficulty > global.config.pool.maxDifficulty) { + this.difficulty = global.config.pool.maxDifficulty; + } + } + this.calcNewDiff = function () { const proxyMinerName = this.payout + ":" + this.identifier; let miner; @@ -920,19 +925,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (proxyMinerName in proxyMiners) { miner = proxyMiners[proxyMinerName]; target = 5; - min_diff = 10*global.config.pool.minDifficulty; + min_diff = 10 * this.curr_min_diff; history_time = 5; if (this.debugMiner) console.log(threadName + this.logString + ": calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { miner = minerWallets[this.payout]; target = 5; - min_diff = 10*global.config.pool.minDifficulty; + min_diff = 10 * this.curr_min_diff; history_time = 5; if (this.debugMiner) console.log(threadName + this.logString + ": calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; - min_diff = this.proxy ? 10*global.config.pool.minDifficulty : global.config.pool.minDifficulty; + min_diff = this.proxy ? 10 * this.curr_min_diff : this.curr_min_diff; history_time = 60; if (this.debugMiner) console.log(threadName + this.logString + ": calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } @@ -964,12 +969,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (this.fixed_diff) return false; let newDiff = Math.round(difficulty); - if (newDiff > global.config.pool.maxDifficulty) { - newDiff = global.config.pool.maxDifficulty; - } - if (newDiff < global.config.pool.minDifficulty) { - newDiff = global.config.pool.minDifficulty; - } + if (newDiff > global.config.pool.maxDifficulty) newDiff = global.config.pool.maxDifficulty; + if (newDiff < this.curr_min_diff) newDiff = this.curr_min_diff; this.newDiffRecommendation = newDiff; const ratio = Math.abs(newDiff - this.difficulty) / this.difficulty; @@ -1752,6 +1753,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } //if (miner.debugMiner) console.log("SUBMIT"); miner.heartbeat(); + if (typeof (params.job_id) === 'number') params.job_id = params.job_id.toString(); // for grin miner let job = miner.validJobs.toarray().filter(function (job) { return job.id === params.job_id; From 4f2e0bc635b7b44f7ba112db79e5d1ffb7614bee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 15:42:46 -0800 Subject: [PATCH 0721/1496] Bug fix --- lib/pool.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7dd5ac399..39bf9a4a3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -840,6 +840,27 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi })); }; + this.setNewDiff = function (difficulty) { + if (this.fixed_diff) return false; + + let newDiff = Math.round(difficulty); + if (newDiff > global.config.pool.maxDifficulty) newDiff = global.config.pool.maxDifficulty; + if (newDiff < this.curr_min_diff) newDiff = this.curr_min_diff; + + this.newDiffRecommendation = newDiff; + const ratio = Math.abs(newDiff - this.difficulty) / this.difficulty; + if (ratio < 0.2) return false; + this.newDiffToSet = newDiff; + + debug(threadName + "Difficulty change to: " + this.newDiffToSet + " For: " + this.logString); + if (this.hashes > 0) { + debug(threadName + "Hashes: " + this.hashes + " in: " + Math.floor((Date.now() - this.connectTime) / 1000) + " seconds gives: " + + Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) + " hashes/second or: " + + Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime + " difficulty versus: " + this.newDiffToSet); + } + return true; + }; + this.selectBestCoin = function() { if (this.debugMiner) console.log(threadName + this.logString + ": current coin is " + this.curr_coin); if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && currCoinHashFactorMM[this.curr_coin] && @@ -965,27 +986,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi return diff < min_diff ? min_diff : diff; }; - this.setNewDiff = function (difficulty) { - if (this.fixed_diff) return false; - - let newDiff = Math.round(difficulty); - if (newDiff > global.config.pool.maxDifficulty) newDiff = global.config.pool.maxDifficulty; - if (newDiff < this.curr_min_diff) newDiff = this.curr_min_diff; - - this.newDiffRecommendation = newDiff; - const ratio = Math.abs(newDiff - this.difficulty) / this.difficulty; - if (ratio < 0.2) return false; - this.newDiffToSet = newDiff; - - debug(threadName + "Difficulty change to: " + this.newDiffToSet + " For: " + this.logString); - if (this.hashes > 0) { - debug(threadName + "Hashes: " + this.hashes + " in: " + Math.floor((Date.now() - this.connectTime) / 1000) + " seconds gives: " + - Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) + " hashes/second or: " + - Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime + " difficulty versus: " + this.newDiffToSet); - } - return true; - }; - this.checkBan = function (validShare) { if (!global.config.pool.banEnabled) return; From b52c41ce33365a4414de7007e3ad161f8f3af069 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 15:55:20 -0800 Subject: [PATCH 0722/1496] Bug fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 39bf9a4a3..388cb5e83 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1765,7 +1765,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } const is_bad_nonce = job.blob_type_num == 8 ? - (typeof params.nonce !== 'number') || (typeof params.pow !== 'array') || (params.pow.length != 32) : + (typeof params.nonce !== 'number') || !(params.pow instanceof Array) || (params.pow.length != 32) : (typeof params.nonce !== 'string') || !(job.blob_type_num == 7 ? nonceCheck64.test(params.nonce) : nonceCheck32.test(params.nonce) ); if (is_bad_nonce) { From c046818402b84914a22450fa04cac1eda3299294 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 16:03:04 -0800 Subject: [PATCH 0723/1496] Moved to master utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de01a1314..a67dfd2c9 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git" } } From 34251be72632f0f9ced620f23fef0c2b14b9b60d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 16:11:50 -0800 Subject: [PATCH 0724/1496] Bug fix --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a21c3afa1..14ff2db00 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -531,7 +531,7 @@ function Coin(data){ } this.c29_cycle_hash = function(ring) { - return multiHashing.cycle_hash(ring); + return multiHashing.c29_cycle_hash(ring); } this.blobTypeStr = function(port, version) { From fd2b88553ab841362e3b8fccf9d6aada5b6823a4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 16:41:49 -0800 Subject: [PATCH 0725/1496] Removed XTNC support --- lib/coins/xmr.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 14ff2db00..3fd2193b6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -35,7 +35,7 @@ const port2coin = { "19734": "SUMO", "13007": "IRD", "19994": "ARQ", - "33124": "XTNC", +// "33124": "XTNC", "19281": "XMV", "19950": "XWP", }; @@ -56,7 +56,7 @@ const port2blob_num = { "13007": 2, // IRD "19994": 0, // ARQ "19281": 8, // XMV - "33124": 8, // XTNC +// "33124": 8, // XTNC "19950": 8, // XWP }; @@ -75,7 +75,7 @@ const port2algo = { "20189": "defyx", // Scala "22023": "rx/loki", // LOKI "24182": "cn-heavy/tube", // BitTube - "33124": "c29s", // XtendCash +// "33124": "c29s", // XtendCash "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR "48782": "cn/r", // Lethean @@ -470,7 +470,7 @@ function Coin(data){ if ("rx/arq" in algos_perf) coin_perf["ARQ"] = algos_perf["rx/arq"]; - if ("c29s" in algos_perf) coin_perf["XTNC"] = coin_perf["XWP"] = algos_perf["c29s"]; + if ("c29s" in algos_perf) coin_perf["XWP"] = algos_perf["c29s"]; if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; @@ -523,7 +523,7 @@ function Coin(data){ switch (port) { case 19281: return multiHashing.c29v(header, ring); // MoneroV case 19950: return multiHashing.c29s(header, ring); // Swap - case 33124: return multiHashing.c29s(header, ring); // XtendCash + //case 33124: return multiHashing.c29s(header, ring); // XtendCash default: console.error("Unknown " + port + " port for Cuckaroo PoW type"); return multiHashing.c29s(header, ring); @@ -543,7 +543,7 @@ function Coin(data){ case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 22023: return "cryptonote_loki"; // LOKI - case 33124: return "cuckaroo"; // XtendCash + //case 33124: return "cuckaroo"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; } diff --git a/package.json b/package.json index a67dfd2c9..2b8aba4dd 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.1" } } From 8a510775953588b89d84759b531fb7e8c20deeaa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Dec 2019 23:04:10 -0800 Subject: [PATCH 0726/1496] Some small fixes --- lib/pool.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 388cb5e83..79a582b8c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -558,8 +558,7 @@ function getTargetHex(difficulty, size) { const buff = padded.slice(0, size); const buffArray = buff.toByteArray().reverse(); const buffReversed = new Buffer(buffArray); - const new_result = buffReversed.toString('hex'); - return new_result; + return buffReversed.toString('hex'); }; function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { @@ -1696,11 +1695,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReplyMethodResult("login", "ok"); miner.protocol = "grin"; } else { - sendReply(null, { - id: minerId, - job: miner.getBestCoinJob(), - status: 'OK' - }); + sendReply(null, { id: minerId, job: miner.getBestCoinJob(), status: 'OK' }); miner.protocol = "default"; } break; @@ -1736,7 +1731,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } } - miner.sendBestCoinJob(); + sendReply(null, { id: miner.id, job: miner.getBestCoinJob(), status: 'OK' }); break; } @@ -1885,9 +1880,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } miner.heartbeat(); - sendReply(null, { - status: 'KEEPALIVED' - }); + sendReply(null, { status: 'KEEPALIVED' }); break; } } From 15ee0456085de82fc48008dd7eb0a86385eab694 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Dec 2019 13:20:19 -0800 Subject: [PATCH 0727/1496] Fixed getjob and added XTNC --- lib/coins/xmr.js | 12 ++++++------ lib/pool.js | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3fd2193b6..14ff2db00 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -35,7 +35,7 @@ const port2coin = { "19734": "SUMO", "13007": "IRD", "19994": "ARQ", -// "33124": "XTNC", + "33124": "XTNC", "19281": "XMV", "19950": "XWP", }; @@ -56,7 +56,7 @@ const port2blob_num = { "13007": 2, // IRD "19994": 0, // ARQ "19281": 8, // XMV -// "33124": 8, // XTNC + "33124": 8, // XTNC "19950": 8, // XWP }; @@ -75,7 +75,7 @@ const port2algo = { "20189": "defyx", // Scala "22023": "rx/loki", // LOKI "24182": "cn-heavy/tube", // BitTube -// "33124": "c29s", // XtendCash + "33124": "c29s", // XtendCash "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR "48782": "cn/r", // Lethean @@ -470,7 +470,7 @@ function Coin(data){ if ("rx/arq" in algos_perf) coin_perf["ARQ"] = algos_perf["rx/arq"]; - if ("c29s" in algos_perf) coin_perf["XWP"] = algos_perf["c29s"]; + if ("c29s" in algos_perf) coin_perf["XTNC"] = coin_perf["XWP"] = algos_perf["c29s"]; if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; @@ -523,7 +523,7 @@ function Coin(data){ switch (port) { case 19281: return multiHashing.c29v(header, ring); // MoneroV case 19950: return multiHashing.c29s(header, ring); // Swap - //case 33124: return multiHashing.c29s(header, ring); // XtendCash + case 33124: return multiHashing.c29s(header, ring); // XtendCash default: console.error("Unknown " + port + " port for Cuckaroo PoW type"); return multiHashing.c29s(header, ring); @@ -543,7 +543,7 @@ function Coin(data){ case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 22023: return "cryptonote_loki"; // LOKI - //case 33124: return "cuckaroo"; // XtendCash + case 33124: return "cuckaroo"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; } diff --git a/lib/pool.js b/lib/pool.js index 79a582b8c..fa2bdeffa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1731,7 +1731,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } } - sendReply(null, { id: miner.id, job: miner.getBestCoinJob(), status: 'OK' }); + sendReplyMethodResult("job", miner.getBestCoinJob()); break; } @@ -1863,7 +1863,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (miner.protocol === "grin") { sendReplyMethodResult("submit", "ok"); } else { - sendReply(null, {status: 'OK'}); + sendReply(null, { status: 'OK' }); } //if (miner.debugMiner) console.log("SUBMIT OK"); break; From da66d862ae158089b002891198187b8c8d5be8d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Dec 2019 13:39:20 -0800 Subject: [PATCH 0728/1496] Simplified json replies --- lib/pool.js | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index fa2bdeffa..5f61f9eb3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1625,7 +1625,7 @@ function get_miner_notification(payout) { return false; } -function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, sendReplyMethodResult, pushMessage) { +function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, pushMessage) { switch (method) { case 'login': { // grin and default if (ip in bannedIPs) { @@ -1692,7 +1692,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } } if (id === "Stratum") { - sendReplyMethodResult("login", "ok"); + sendReply(null, "ok"); miner.protocol = "grin"; } else { sendReply(null, { id: minerId, job: miner.getBestCoinJob(), status: 'OK' }); @@ -1709,7 +1709,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } miner.heartbeat(); - sendReplyMethodResult("getjobtemplate", miner.getBestCoinJob()); + sendReply(null, miner.getBestCoinJob()); break; } @@ -1731,7 +1731,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } } - sendReplyMethodResult("job", miner.getBestCoinJob()); + sendReply(null, miner.getBestCoinJob()); break; } @@ -1861,7 +1861,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.lastShareTime = Date.now() / 1000 || 0; if (miner.protocol === "grin") { - sendReplyMethodResult("submit", "ok"); + sendReply(null, "ok"); } else { sendReply(null, { status: 'OK' }); } @@ -2183,33 +2183,26 @@ if (cluster.isMaster) { let sendReply = function (error, result) { if (!socket.writable) return; socket.write(JSON.stringify({ - id: jsonData.id, jsonrpc: "2.0", - error: error ? {code: -1, message: error} : null, - result: result + id: jsonData.id, + method: jsonData.method, + error: error ? {code: -1, message: error} : null, + result: result }) + "\n"); }; let sendReplyFinal = function (error) { setTimeout(function() { if (!socket.writable) return; socket.end(JSON.stringify({ - id: jsonData.id, jsonrpc: "2.0", - error: {code: -1, message: error}, - result: null + id: jsonData.id, + method: jsonData.method, + error: {code: -1, message: error}, + result: null }) + "\n"); }, 9 * 1000); }; - let sendReplyMethodResult = function (method, result) { - if (!socket.writable) return; - socket.write(JSON.stringify({ - id: jsonData.id, - jsonrpc: "2.0", - method: method, - result: result - }) + "\n"); - }; - handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, sendReplyMethodResult, pushMessage); + handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, pushMessage); }; function socketConn(socket) { From 9c9e8b705c83951eb3a58bb86b56a801e2e3f995 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Dec 2019 15:33:03 -0800 Subject: [PATCH 0729/1496] Fixed xtk-stak compat --- lib/pool.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5f61f9eb3..d5193cad7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2182,24 +2182,26 @@ if (cluster.isMaster) { let sendReply = function (error, result) { if (!socket.writable) return; - socket.write(JSON.stringify({ + let reply = { jsonrpc: "2.0", id: jsonData.id, - method: jsonData.method, error: error ? {code: -1, message: error} : null, result: result - }) + "\n"); + }; + if (jsonData.id === "Stratum") reply.method = jsonData.method; + socket.write(JSON.stringify(reply) + "\n"); }; let sendReplyFinal = function (error) { setTimeout(function() { if (!socket.writable) return; - socket.end(JSON.stringify({ + let reply = { jsonrpc: "2.0", id: jsonData.id, - method: jsonData.method, error: {code: -1, message: error}, result: null - }) + "\n"); + }; + if (jsonData.id === "Stratum") reply.method = jsonData.method; + socket.end(JSON.stringify(reply) + "\n"); }, 9 * 1000); }; handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, pushMessage); From b5c03ae9e7e1b5355dd0281b44c1435f648ca78d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 30 Dec 2019 23:01:15 -0800 Subject: [PATCH 0730/1496] Fixed grin proto for mm.js --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d5193cad7..c71d4e19f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1046,7 +1046,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi submissions: {} }; this.validJobs.enq(newJob); - if (blob_type_num == 8) this.cachedJob = { + if (this.protocol === "grin") this.cachedJob = { pre_pow: blob, algo: "cuckaroo", edgebits: 29, From 9999de1558761750fa3fefb2e8e4b899f57d26d8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 30 Dec 2019 23:26:07 -0800 Subject: [PATCH 0731/1496] Fixed grin proto for mm.js --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c71d4e19f..7fec6e5af 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1046,9 +1046,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi submissions: {} }; this.validJobs.enq(newJob); - if (this.protocol === "grin") this.cachedJob = { + if (blob_type_num == 8) this.cachedJob = { pre_pow: blob, - algo: "cuckaroo", + algo: this.protocol === "grin" ? "cuckaroo" : params.algo_name, edgebits: 29, proofsize: 32, noncebytes: 4, From d2f606c517575ce586921f5253835e10c457df66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Jan 2020 22:56:16 -0800 Subject: [PATCH 0732/1496] Fixed XTNC support --- lib/coins/xmr.js | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 14ff2db00..7364ddc5d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -56,7 +56,7 @@ const port2blob_num = { "13007": 2, // IRD "19994": 0, // ARQ "19281": 8, // XMV - "33124": 8, // XTNC + "33124": 9, // XTNC "19950": 8, // XWP }; @@ -438,7 +438,6 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["LOKI"] = algos_perf["rx/0"]; if ("cn/r" in algos_perf) coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; @@ -543,7 +542,7 @@ function Coin(data){ case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 22023: return "cryptonote_loki"; // LOKI - case 33124: return "cuckaroo"; // XtendCash + case 33124: return "cuckaroo4"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; } diff --git a/package.json b/package.json index 2b8aba4dd..6f144fff7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.1" } } From 6741809199a06b0bec232951301fe08283eec7cc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Jan 2020 23:02:08 -0800 Subject: [PATCH 0733/1496] Fixed XTNC support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f144fff7..2b8aba4dd 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.1" } } From 942ee00eb80904710f1c4130e4a310cded1a7618 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Jan 2020 23:10:16 -0800 Subject: [PATCH 0734/1496] Fixed XTNC support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b8aba4dd..6f144fff7 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.1" } } From 4537449387a51e117f1731979c1508f3412242f0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Jan 2020 23:34:03 -0800 Subject: [PATCH 0735/1496] Fixed XTNC support --- lib/coins/xmr.js | 2 ++ lib/pool.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7364ddc5d..c9bb97a59 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -298,6 +298,8 @@ function Coin(data){ this.portBlobType = function(port, version) { return port2blob_num[port]; } + this.blobTypeGrin = function(port_blob_num) { return port_blob_num == 8 || port_blob_num == 9; } + this.convertBlob = function(blobBuffer, port){ let blob; try { diff --git a/lib/pool.js b/lib/pool.js index 7fec6e5af..a9357d206 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -902,7 +902,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }); if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - this.curr_min_diff = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)) == 8 ? 1 : global.config.pool.minDifficulty; + this.curr_min_diff = global.coinFuncs.blobTypeGrin(global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin))) ? 1 : global.config.pool.minDifficulty; const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; if (factor != 1) { @@ -1046,7 +1046,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi submissions: {} }; this.validJobs.enq(newJob); - if (blob_type_num == 8) this.cachedJob = { + if (global.coinFuncs.blobTypeGrin(blob_type_num)) this.cachedJob = { pre_pow: blob, algo: this.protocol === "grin" ? "cuckaroo" : params.algo_name, edgebits: 29, @@ -1381,7 +1381,7 @@ function getShareBuffer(miner, job, blockTemplate, params) { template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); } - return job.blob_type_num == 8 ? + return global.coinFuncs.blobTypeGrin(job.blob_type_num) ? global.coinFuncs.constructNewBlob(template, bignum(params.nonce, 10).toBuffer({endian: 'little', size: 4}), blockTemplate.port, params.pow) : global.coinFuncs.constructNewBlob(template, new Buffer(params.nonce, 'hex'), blockTemplate.port); } catch (e) { @@ -1499,12 +1499,12 @@ function processShare(miner, job, blockTemplate, params) { let isTrustedShare; const port = blockTemplate.port; const blob_type_num = job.blob_type_num; - const resultHash = params.result; // can be undefined for blob_type_num == 8 (and will not be used in submit_block since isTrustedShare = false) + const resultHash = params.result; // can be undefined for global.coinFuncs.blobTypeGrin(blob_type_num) (and will not be used in submit_block since isTrustedShare = false) if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); - if (blob_type_num == 8) { + if (global.coinFuncs.blobTypeGrin(blob_type_num)) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); const header = Buffer.concat([global.coinFuncs.convertBlob(shareBuffer, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); if (global.coinFuncs.c29(header, params.pow, port)) { @@ -1759,7 +1759,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } - const is_bad_nonce = job.blob_type_num == 8 ? + const is_bad_nonce = global.coinFuncs.blobTypeGrin(job.blob_type_num) ? (typeof params.nonce !== 'number') || !(params.pow instanceof Array) || (params.pow.length != 32) : (typeof params.nonce !== 'string') || !(job.blob_type_num == 7 ? nonceCheck64.test(params.nonce) : nonceCheck32.test(params.nonce) ); @@ -1781,10 +1781,11 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.storeInvalidShare(); return; } - nonce_test = job.blob_type_num == 8 ? params.pow.join(':') + `_${params.poolNonce}_${params.workerNonce}` - : `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; + nonce_test = global.coinFuncs.blobTypeGrin(job.blob_type_num) ? + params.pow.join(':') + `_${params.poolNonce}_${params.workerNonce}` : + `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; } else { - nonce_test = job.blob_type_num == 8 ? params.pow.join(':') : params.nonce; + nonce_test = global.coinFuncs.blobTypeGrin(job.blob_type_num) ? params.pow.join(':') : params.nonce; } if (nonce_test in job.submissions) { From f3dfc86d946222d44737716d64cf87257382c2b3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 4 Jan 2020 01:21:06 -0800 Subject: [PATCH 0736/1496] Fixed XTNC support --- lib/coins/xmr.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c9bb97a59..8e0fd2a4b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -544,7 +544,7 @@ function Coin(data){ case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 22023: return "cryptonote_loki"; // LOKI - case 33124: return "cuckaroo4"; // XtendCash + case 33124: return "cryptonote_xtnc"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; } diff --git a/package.json b/package.json index 6f144fff7..6be72616d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.1" } } From 40ce4efeeb68f77df9af88ccaec81592671e0e9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 16:37:27 -0800 Subject: [PATCH 0737/1496] Added XEQ support --- README.md | 1 + deployment/base.sql | 3 +++ lib/coins/xmr.js | 8 ++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0353cb9f8..0668a461b 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,7 @@ If you'd like to make a one time donation, the addresses are as follows: * IRD - ```ir3DHyB8Ub1aAHEewMeUxQ7b7tQdWa7VL8M5oXDPohS3Me4nhwvALXM4mym2kWg9VsceT75dm6XWiWF1K4zu8RVQ1HJD8Z3R9``` * ARQ - ```ar4Ha6ZQCkKRhkKQLfexv7VZQM2MhUmMmU9hmzswCPK4T3o2rbPKZM1GxEoYg4AFQsh57PsEets7sbpU958FAvxo2RkkTQ1gE``` * XWP - ```fh4MCJrakhWGoS6Meqp6UxGE1GNfAjKaRdPjW36rTffDiqvEq2HWEKZhrbYRw7XJb3CXxkjL3tcYGTT39m5qgjvk1ap4bVu1R``` +* XEQ - ```Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index 1b0251543..3350615e6 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -219,6 +219,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortARQ', '0', 'int', 'ArqMa coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMV', '0', 'int', 'MoneroV coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXWP', '0', 'int', 'Swap coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXEQ', '0', 'int', 'Equilibria coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -237,6 +238,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorARQ', '0', 'float', 'ArqMa algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMV', '0', 'float', 'MoneroV algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXWP', '0', 'float', 'Swap algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXEQ', '0', 'float', 'Equilibria algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -291,6 +293,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13007', '', 'string', 'Address to mine to for 13007 (Iridium) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19994', '', 'string', 'Address to mine to for 19994 (ArqMa) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19950', '', 'string', 'Address to mine to for 19950 (Swap) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', 'Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunURL', '', 'string', 'MailGun URL for notifications'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8e0fd2a4b..75277145e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -38,6 +38,7 @@ const port2coin = { "33124": "XTNC", "19281": "XMV", "19950": "XWP", + "9231" : "XEQ", }; const port2blob_num = { "11181": 7, // AEON @@ -58,6 +59,7 @@ const port2blob_num = { "19281": 8, // XMV "33124": 9, // XTNC "19950": 8, // XWP + "9231" : 0, // XEQ }; const port2algo = { @@ -79,6 +81,7 @@ const port2algo = { "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR "48782": "cn/r", // Lethean + "9231" : "cn/gpu", // XEQ }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -206,7 +209,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 22023 || port == 33124 || port == 24182) { // Loki / XtendCash / TUBE has reward as zero transaction + if (port == 22023 || port == 33124 || port == 24182 || port == 9231) { // Loki / XtendCash / TUBE / Equilibria has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Mon, 6 Jan 2020 21:18:29 -0800 Subject: [PATCH 0738/1496] Avoid daemon overload --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 03eb8505a..17ef227d1 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -451,7 +451,7 @@ function Database(){ } else { console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); orphanBlocks[blockDataDecoded.hash] = time_now; - setTimeout(function () { return callback(false) }, 30*1000); + setTimeout(function () { return callback(false) }, 30*1000 + Math.random(60)*1000); return; } } From 5bf2004e6428b2fd1de71cc5e4875f308983a509 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 21:22:16 -0800 Subject: [PATCH 0739/1496] Avoid daemon overload --- lib/local_comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 17ef227d1..8a9887c3e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -451,7 +451,7 @@ function Database(){ } else { console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); orphanBlocks[blockDataDecoded.hash] = time_now; - setTimeout(function () { return callback(false) }, 30*1000 + Math.random(60)*1000); + setTimeout(function () { return callback(false) }, 30*1000 + Math.random(30)*1000); return; } } @@ -463,7 +463,7 @@ function Database(){ } if (!(blockDataDecoded.port in potentiallyBadBlocks)) potentiallyBadBlocks[blockDataDecoded.port] = {}; potentiallyBadBlocks[blockDataDecoded.port][blockDataDecoded.hash] = 1; - setTimeout(function () { return callback(false) }, 30*1000); + setTimeout(function () { return callback(false) }, 30*1000 + Math.random(120)*1000); return; } if (!is_orphan) { // now we found good block (not orphan) and we can move potentiallyBadBlocks to badBlocks From bab52264d316073fbeb28785f9d104d619189872 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 22:14:12 -0800 Subject: [PATCH 0740/1496] Avoid daemon overload --- lib/local_comms.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 8a9887c3e..6f7adf39b 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -456,13 +456,14 @@ function Database(){ } } } - if (err || typeof(header) === 'undefined' || !header) { // bad blcok and not orphan + if (err || typeof(header) === 'undefined' || !header) { // bad block and not orphan if (blockDataDecoded.hash in badBlocks) { console.error("Invalidating " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); return callback(true); } if (!(blockDataDecoded.port in potentiallyBadBlocks)) potentiallyBadBlocks[blockDataDecoded.port] = {}; potentiallyBadBlocks[blockDataDecoded.port][blockDataDecoded.hash] = 1; + console.log("BAD"); setTimeout(function () { return callback(false) }, 30*1000 + Math.random(120)*1000); return; } From 668285e7bf61201d4d9d65935db66923a85df110 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 22:19:42 -0800 Subject: [PATCH 0741/1496] Avoid daemon overload --- lib/local_comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 6f7adf39b..fd155b9f4 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -463,8 +463,8 @@ function Database(){ } if (!(blockDataDecoded.port in potentiallyBadBlocks)) potentiallyBadBlocks[blockDataDecoded.port] = {}; potentiallyBadBlocks[blockDataDecoded.port][blockDataDecoded.hash] = 1; - console.log("BAD"); - setTimeout(function () { return callback(false) }, 30*1000 + Math.random(120)*1000); + console.log("BAD " + blockDataDecoded.hash); + setTimeout(function () { console.log("BAD2 " + blockDataDecoded.hash); return callback(false) }, 30*1000 + Math.random(120)*1000); return; } if (!is_orphan) { // now we found good block (not orphan) and we can move potentiallyBadBlocks to badBlocks From 8793822aec5d92fcd61bc03a0705e0b538b4af88 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 22:22:32 -0800 Subject: [PATCH 0742/1496] Avoid daemon overload --- lib/local_comms.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index fd155b9f4..ddaf68c0e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -463,8 +463,7 @@ function Database(){ } if (!(blockDataDecoded.port in potentiallyBadBlocks)) potentiallyBadBlocks[blockDataDecoded.port] = {}; potentiallyBadBlocks[blockDataDecoded.port][blockDataDecoded.hash] = 1; - console.log("BAD " + blockDataDecoded.hash); - setTimeout(function () { console.log("BAD2 " + blockDataDecoded.hash); return callback(false) }, 30*1000 + Math.random(120)*1000); + setTimeout(function () { return callback(false) }, 30*1000 + 120*Math.random()*1000); return; } if (!is_orphan) { // now we found good block (not orphan) and we can move potentiallyBadBlocks to badBlocks From 4de21d90811e09351428900fb62a8ef29a30c5a5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 22:26:07 -0800 Subject: [PATCH 0743/1496] Avoid daemon overload --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index ddaf68c0e..82cf1a867 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -451,7 +451,7 @@ function Database(){ } else { console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); orphanBlocks[blockDataDecoded.hash] = time_now; - setTimeout(function () { return callback(false) }, 30*1000 + Math.random(30)*1000); + setTimeout(function () { return callback(false) }, 30*1000 + 30*Math.random()*1000); return; } } From 5dbc971ba42ea814098c19ddc7ef4775f2faf55d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 22:43:33 -0800 Subject: [PATCH 0744/1496] Avoid daemon overload --- lib/local_comms.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 82cf1a867..dc6dedd1d 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -422,12 +422,19 @@ function Database(){ let potentiallyBadBlocks = {}; // port -> block hash that has issues that will move into badBlocks after we will find good block for same port let badBlocks = {}; // block hashes that we just start ignore (can't find incoming wallet tx) + let busyPorts = {}; // ports that are alredy have active getPortBlockHeaderByHash request this.storeAltBlock = function(blockId, blockData, callback){ this.refreshEnv(); try{ let blockDataDecoded = global.protos.AltBlock.decode(blockData); + if (blockDataDecoded.port in busyPorts) { + setTimeout(function () { return callback(false) }, 30*1000); + return; + } + busyPorts[blockDataDecoded.port] = 1; global.coinFuncs.getPortBlockHeaderByHash(blockDataDecoded.port, blockDataDecoded.hash, function(err, header){ + delete busyPorts[blockDataDecoded.port]; // after 5 minutes of submit attempts finally cosider this block as orphan let is_orphan = false; if (err && header) { @@ -451,7 +458,7 @@ function Database(){ } else { console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); orphanBlocks[blockDataDecoded.hash] = time_now; - setTimeout(function () { return callback(false) }, 30*1000 + 30*Math.random()*1000); + setTimeout(function () { return callback(false) }, 30*1000); return; } } @@ -463,7 +470,7 @@ function Database(){ } if (!(blockDataDecoded.port in potentiallyBadBlocks)) potentiallyBadBlocks[blockDataDecoded.port] = {}; potentiallyBadBlocks[blockDataDecoded.port][blockDataDecoded.hash] = 1; - setTimeout(function () { return callback(false) }, 30*1000 + 120*Math.random()*1000); + setTimeout(function () { return callback(false) }, 30*1000); return; } if (!is_orphan) { // now we found good block (not orphan) and we can move potentiallyBadBlocks to badBlocks From 8448336bb1464319cb97090a22f71c6d31aa4398 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Jan 2020 22:49:05 -0800 Subject: [PATCH 0745/1496] Avoid daemon overload --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 75277145e..8b2b2ea61 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -220,7 +220,7 @@ function Coin(data){ } const miner_tx_hash = body.result.miner_tx_hash == "" ? body.result.block_header.miner_tx_hash : body.result.miner_tx_hash; - if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWalletShort(port + 1, "get_transfer_by_txid", {"txid": miner_tx_hash}, function (body2) { + if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port + 1, "get_transfer_by_txid", {"txid": miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); From f49a3e50b2335e3c68631205f53f6e1a513eb9c8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 Jan 2020 00:04:45 -0800 Subject: [PATCH 0746/1496] Avoid daemon overload --- lib/local_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index dc6dedd1d..ceecedb84 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -429,6 +429,7 @@ function Database(){ try{ let blockDataDecoded = global.protos.AltBlock.decode(blockData); if (blockDataDecoded.port in busyPorts) { + console.error("Pausing altblock with " + blockDataDecoded.port.toString() + " port and " + blockDataDecoded.height.toString() + " height processing"); setTimeout(function () { return callback(false) }, 30*1000); return; } From 9458243f33741e036514de34c60091a08bbb6c14 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 Jan 2020 08:27:57 -0800 Subject: [PATCH 0747/1496] Do not touch error node --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 77e526cca..707f04067 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -736,7 +736,7 @@ function updateBlockHeader() { for (let port in min_block_rewards) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ - global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { + if (!err) global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { if (err !== null) { console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); if (port in prev_network_info) { From cc4cf55c195b896d1cfd233222db36b8a0fbdd37 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 Jan 2020 08:31:28 -0800 Subject: [PATCH 0748/1496] Do not touch error node --- lib/worker.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 707f04067..7312da574 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -737,22 +737,22 @@ function updateBlockHeader() { for (let port in min_block_rewards) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (!err) global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { - if (err !== null) { - console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); - if (port in prev_network_info) { - body.difficulty = prev_network_info[port].difficulty; - body.hash = prev_network_info[port].hash; - body.height = prev_network_info[port].height; - body.reward = prev_network_info[port].value; - body.timestamp = prev_network_info[port].ts; - } else { - body.difficulty = 0; - body.hash = 0; - body.height = 0; - body.reward = 0; - body.timestamp = 0; - } - } + //if (err !== null) { + // console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); + // if (port in prev_network_info) { + // body.difficulty = prev_network_info[port].difficulty; + // body.hash = prev_network_info[port].hash; + // body.height = prev_network_info[port].height; + // body.reward = prev_network_info[port].value; + // body.timestamp = prev_network_info[port].ts; + // } else { + // body.difficulty = 0; + // body.hash = 0; + // body.height = 0; + // body.reward = 0; + // body.timestamp = 0; + // } + //} prev_network_info[port] = info[port] = { difficulty: body.difficulty, hash: body.hash, From 1f76f1b555a3a58c7646378d4c63abc71f75cfff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 Jan 2020 10:03:03 -0800 Subject: [PATCH 0749/1496] Fixed TypeError: Cannot read property 'hasOwnProperty' of undefined --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8b2b2ea61..76ced1fd2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -174,7 +174,7 @@ function Coin(data){ this.getPortBlockHeaderByID = function(port, blockId, callback){ global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { - if (body.hasOwnProperty('result')){ + if (body && body.hasOwnProperty('result')){ return callback(null, body.result.block_header); } else { console.error(JSON.stringify(body)); From 0b004ff63223284121d24bdefca60a605dc357ce Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 Jan 2020 12:32:17 -0800 Subject: [PATCH 0750/1496] Fixed XEQ blob type --- lib/coins/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 76ced1fd2..cd7c58ae9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -59,7 +59,7 @@ const port2blob_num = { "19281": 8, // XMV "33124": 9, // XTNC "19950": 8, // XWP - "9231" : 0, // XEQ + "9231" : 5, // XEQ }; const port2algo = { @@ -541,6 +541,7 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { + case 9231 : return "cryptonote_loki"; // XEQ case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium From d0d8be48ada5a3888686ed9ab755fdd99bc59ff1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 16:59:39 -0800 Subject: [PATCH 0751/1496] Cache adjust --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 7312da574..d08ca9a15 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -238,7 +238,7 @@ function updateShareStats() { cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; } - stats_cache[miner] = stats; + //stats_cache[miner] = stats; } debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); From 086e67c83592b54a7fff012cdf4dec5951e0f748 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 17:14:39 -0800 Subject: [PATCH 0752/1496] Reverted --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index d08ca9a15..7312da574 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -238,7 +238,7 @@ function updateShareStats() { cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; } - //stats_cache[miner] = stats; + stats_cache[miner] = stats; } debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); From 2133e5ebc49833c53e5011c1dd19f550023b5510 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 17:58:12 -0800 Subject: [PATCH 0753/1496] Adjusted LMDB params --- lib/local_comms.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index ceecedb84..3abae6284 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -31,11 +31,8 @@ function Database(){ global.database.env.open({ path: global.config.db_storage_path, maxDbs: 10, - mapSize: 24 * 1024 * 1024 * 1024, - noSync: false, - mapAsync: false, - useWritemap: false, - noMetaSync: true, + mapSize: 12 * 1024 * 1024 * 1024, + useWritemap: true, maxReaders: 512 }); global.database.shareDB = this.env.openDbi({ From 9cf0dd187a7bcac115c990b80e7612903a25583d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 18:29:08 -0800 Subject: [PATCH 0754/1496] Updated LMDB tools --- deployment/install_lmdb_tools.sh | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/install_lmdb_tools.sh b/deployment/install_lmdb_tools.sh index 80b95c518..219e206ff 100644 --- a/deployment/install_lmdb_tools.sh +++ b/deployment/install_lmdb_tools.sh @@ -1,9 +1,9 @@ #!/bin/bash cd ~ -git clone https://github.com/LMDB/lmdb -cd lmdb -git checkout 4d2154397afd90ca519bfa102b2aad515159bd50 -cd libraries/liblmdb/ +git clone https://github.com/Venemo/node-lmdb.git +cd node-lmdb +git checkout v0.7.0 +cd dependencies/lmdb/libraries/liblmdb make -j `nproc` mkdir ~/.bin echo ' ' >> ~/.bashrc diff --git a/package.json b/package.json index 6be72616d..f0df441d4 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "minimist": "1.2.0", "moment": "2.21.0", "mysql": "2.15.0", - "node-lmdb": "0.4.12", + "node-lmdb": "0.7.0", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", "range": "0.0.3", From 43c54d562ac268002f7181404347cb938798db18 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 19:33:41 -0800 Subject: [PATCH 0755/1496] More debug --- lib/local_comms.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 3abae6284..8ca12b51d 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -723,14 +723,16 @@ function Database(){ let txn = this.env.beginTxn(); txn.putString(this.cacheDB, 'cacheUpdate', 'cacheUpdate'); txn.commit(); + let size = 0; txn = this.env.beginTxn(); - for (let key in cacheUpdates){ - if (cacheUpdates.hasOwnProperty(key)){ - txn.putString(this.cacheDB, key, JSON.stringify(cacheUpdates[key])); - } + for (const [key, value] of Object.entries(cacheUpdates)) { + const value_str = JSON.stringify(value); + txn.putString(this.cacheDB, key, value_str); + size += key.length + value_str.length; } txn.del(this.cacheDB, 'cacheUpdate'); txn.commit(); + console.log("Wrote " + size " + bytes to LMDB"); }; this.getOldestLockedBlockHeight = function(){ From 1b5cea1571a5178f8a605bbfe1b8f4d31650a8ec Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 19:34:14 -0800 Subject: [PATCH 0756/1496] More debug --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 8ca12b51d..476a0a37e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -732,7 +732,7 @@ function Database(){ } txn.del(this.cacheDB, 'cacheUpdate'); txn.commit(); - console.log("Wrote " + size " + bytes to LMDB"); + console.log("Wrote " + size + " + bytes to LMDB"); }; this.getOldestLockedBlockHeight = function(){ From 5033156f09f12615e128f843ea52c74f49f27272 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 19:35:33 -0800 Subject: [PATCH 0757/1496] More debug --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 476a0a37e..7f15cdfa9 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -732,7 +732,7 @@ function Database(){ } txn.del(this.cacheDB, 'cacheUpdate'); txn.commit(); - console.log("Wrote " + size + " + bytes to LMDB"); + console.log("Wrote " + size + " bytes to LMDB"); }; this.getOldestLockedBlockHeight = function(){ From 7b28456e4c84594b9290bd91e752ca637899928b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 19:42:43 -0800 Subject: [PATCH 0758/1496] Reduced full stats update --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 7312da574..a3a31a1ed 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -313,7 +313,7 @@ function updateShareStats() { }); } ], function (err, result) { - if (++cycleCount === 3) cycleCount = 0; + if (++cycleCount === 6) cycleCount = 0; setTimeout(updateShareStats, 10*1000); }); } From 50f006f19346d96c0430ea9d70bc60f164e77beb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 19:48:51 -0800 Subject: [PATCH 0759/1496] More debug --- lib/local_comms.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 7f15cdfa9..8ab52d75d 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -732,7 +732,9 @@ function Database(){ } txn.del(this.cacheDB, 'cacheUpdate'); txn.commit(); - console.log("Wrote " + size + " bytes to LMDB"); + this.env.sync(function() { + console.log("Wrote " + size + " bytes to LMDB"); + }); }; this.getOldestLockedBlockHeight = function(){ From 05e1ae482b1afab444c15d281194998b95b7389d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 19:55:38 -0800 Subject: [PATCH 0760/1496] Added GC --- lib/worker.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index a3a31a1ed..2ff4e083b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -313,7 +313,17 @@ function updateShareStats() { }); } ], function (err, result) { - if (++cycleCount === 6) cycleCount = 0; + if (++cycleCount === 6) { + cycleCount = 0; + try { + if (global.gc) { + global.gc(); + console.log("Garbage collector call compalted"); + } + } catch (e) { + console.error("No garbage collector exposed, please use --expose-gc node option"); + } + } setTimeout(updateShareStats, 10*1000); }); } From e7325fca5ff27ed68ff4b0c26c1f62705783a68e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 20:00:26 -0800 Subject: [PATCH 0761/1496] More debug --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 2ff4e083b..c7f476d1f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -290,6 +290,7 @@ function updateShareStats() { cache_updates.portMinerCount = portMinerCount; cache_updates.minerSet = minerSet; global.database.bulkSetCache(cache_updates); + cache_updates = null; let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; let pool_workers = minerCount; From fbbf65e6294b2e73ef94184c1df4000231528ec2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 20:06:32 -0800 Subject: [PATCH 0762/1496] More debug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index c7f476d1f..0c45d7338 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -319,7 +319,7 @@ function updateShareStats() { try { if (global.gc) { global.gc(); - console.log("Garbage collector call compalted"); + console.log("Garbage collector completed"); } } catch (e) { console.error("No garbage collector exposed, please use --expose-gc node option"); From 3c6efb4e1741e20a845a57a98c2cb550e9050032 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 20:15:29 -0800 Subject: [PATCH 0763/1496] More debug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0c45d7338..fe07cdb1c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -314,7 +314,7 @@ function updateShareStats() { }); } ], function (err, result) { - if (++cycleCount === 6) { + if (++cycleCount === 600) { cycleCount = 0; try { if (global.gc) { From 97b6ea3d792728bd6ef4f3e912d65d743ac447e7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 20:24:05 -0800 Subject: [PATCH 0764/1496] More debug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index fe07cdb1c..21ba93341 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -314,7 +314,7 @@ function updateShareStats() { }); } ], function (err, result) { - if (++cycleCount === 600) { + if (++cycleCount === 3) { cycleCount = 0; try { if (global.gc) { From 13904f4c35c98c721744014b17c45ab63f3711c0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:40:04 -0800 Subject: [PATCH 0765/1496] Separated worker module --- README.md | 1 + lib/pool_stats.js | 513 +++++++++++++++++++++++++++++++++++++++++++++ lib/worker.js | 524 +--------------------------------------------- 3 files changed, 523 insertions(+), 515 deletions(-) create mode 100644 lib/pool_stats.js diff --git a/README.md b/README.md index 0668a461b..71955481c 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Deployment via Installer cd ~/nodejs-pool/ pm2 start init.js --name=blockManager --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=blockManager pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=worker +pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=pool_stats pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" --no-autorestart -- --module=payments pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=remoteShare pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=longRunner diff --git a/lib/pool_stats.js b/lib/pool_stats.js new file mode 100644 index 000000000..54335a8e5 --- /dev/null +++ b/lib/pool_stats.js @@ -0,0 +1,513 @@ +"use strict"; +const debug = require("debug")("pool_stats"); +const async = require("async"); + +let threadName = "Worker Server "; + +let lastBlockCheckIsFailed = {}; + +function updatePoolStats(poolType) { + global.support.getActivePort("", function (newActivePort) { + if (newActivePort) global.config.daemon.activePort = newActivePort; + updatePoolStats2(poolType); + }); +} + +let price_btc = 0; +let price_usd = 0; +let price_eur = 0; +let min_block_rewards = {}; + +function updatePoolStats2(poolType) { + let cache; + let port_suffix = global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; + if (typeof(poolType) !== 'undefined') { + cache = global.database.getCache(poolType + "_stats"); + if (port_suffix === "") { + let cache2 = global.database.getCache(poolType + "_stats2"); + cache.totalHashes = cache2.totalHashes; + cache.roundHashes = cache2.roundHashes; + } else { + let cache2_total = global.database.getCache(poolType + "_stats2"); + let cache2_round = global.database.getCache(poolType + "_stats2" + port_suffix); + cache.totalHashes = cache2_total.totalHashes; + cache.roundHashes = cache2_round.roundHashes; + } + } else { + cache = global.database.getCache("global_stats"); + if (port_suffix === "") { + let cache2 = global.database.getCache("global_stats2"); + cache.totalHashes = cache2.totalHashes; + cache.roundHashes = cache2.roundHashes; + } else { + let cache2_total = global.database.getCache("global_stats2"); + let cache2_round = global.database.getCache("global_stats2" + port_suffix); + cache.totalHashes = cache2_total.totalHashes; + cache.roundHashes = cache2_round.roundHashes; + } + } + + let port_hash = global.database.getCache('port_hash'); + let blockList = global.database.getBlockList(poolType); + let altblockList = global.database.getAltBlockList(poolType); + let min_block_rewards2 = global.database.getCache('min_block_rewards'); + if (min_block_rewards2) min_block_rewards = min_block_rewards2; + if (!(global.config.daemon.port in min_block_rewards)) min_block_rewards[global.config.daemon.port] = 0; + + async.series([ + function (callback) { + //debug(threadName + "Checking Influx for last 5min avg for pool stats (hashRate)"); + return callback(null, cache.hash || 0); + }, + function (callback) { + //debug(threadName + "Checking Influx for last 5min avg for miner count for pool stats (miners)"); + return callback(null, cache.minerCount || 0); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for totalHashes"); + return callback(null, cache.totalHashes || 0); + }, + function (callback) { + //debug(threadName + "Checking LMDB for lastBlockFoundTime for pool stats"); + let max_time = 0; + if (blockList.length !== 0) { + max_time = Math.floor(blockList[0].ts / 1000); + } + if (altblockList.length !== 0) { + max_time = Math.max(max_time, Math.floor(altblockList[0].ts / 1000)); + } + return callback(null, max_time); + }, + function (callback) { + //debug(threadName + "Checking LMDB for lastBlockFound height for pool stats"); + if (blockList.length === 0) { + return callback(null, 0); + } + return callback(null, blockList[0].height); + }, + function (callback) { + //debug(threadName + "Checking LMDB for totalBlocksFound for pool stats"); + return callback(null, blockList.length); + }, + function (callback) { + //debug(threadName + "Checking MySQL for total miners paid"); + if (typeof(poolType) !== 'undefined') { + global.mysql.query("SELECT payment_address, payment_id FROM payments WHERE pool_type = ? group by payment_address, payment_id", [poolType]).then(function (rows) { + return callback(null, rows.length); + }); + } else { + global.mysql.query("SELECT payment_address, payment_id FROM payments group by payment_address, payment_id").then(function (rows) { + return callback(null, rows.length); + }); + } + }, + function (callback) { + //debug(threadName + "Checking MySQL for total transactions count"); + if (typeof(poolType) !== 'undefined') { + global.mysql.query("SELECT distinct(transaction_id) from payments WHERE pool_type = ?", [poolType]).then(function (rows) { + return callback(null, rows.length); + }); + } else { + global.mysql.query("SELECT count(id) as txn_count FROM transactions").then(function (rows) { + if (typeof(rows[0]) !== 'undefined') { + return callback(null, rows[0].txn_count); + } else { + return callback(null, 0); + } + }); + } + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for roundHashes"); + return callback(null, cache.roundHashes || 0); + }, + function (callback) { + //debug(threadName + "Checking LMDB for altblock count for pool stats"); + return callback(null, altblockList.length); + }, + function (callback) { + //debug(threadName + "Checking LMDB for altBlocksFound array for each specific port"); + let result = {}; + for (let i in altblockList) { + let block = altblockList[i]; + if (result.hasOwnProperty(block.port)) ++ result[block.port]; + else result[block.port] = 1; + } + return callback(null, result); + }, + function (callback) { + //debug(threadName + "Checking MySQL for activePort value"); + return callback(null, global.config.daemon.activePort); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for active_ports value"); + let active_ports = global.database.getCache('active_ports'); + return callback(null, active_ports ? active_ports : []); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for xmr_profit value"); + let xmr_profit = global.database.getCache('xmr_profit'); + return callback(null, xmr_profit ? xmr_profit.value : 0); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for coin_profit value"); + let coin_xmr_profit = global.database.getCache('coin_xmr_profit'); + return callback(null, coin_xmr_profit ? coin_xmr_profit : {}); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for xmr_profit_comment value"); + let coin_comment = global.database.getCache('coin_comment'); + return callback(null, coin_comment ? coin_comment : {}); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); + return callback(null, min_block_rewards); + }, + function (callback) { + let pending = 0; + for (let i in blockList) { + const block = blockList[i]; + if (block.valid === true && block.unlocked === false) pending += global.support.coinToDecimal(block.value); + } + for (let i in altblockList) { + const altblock = altblockList[i]; + if (altblock.valid === true && altblock.unlocked === false) pending += altblock.port in min_block_rewards ? min_block_rewards[altblock.port] : 0; + } + return callback(null, pending); + }, + function (callback) { + if (typeof(poolType) === 'undefined') { + global.support.https_get("https://api.coinmarketcap.com/v1/ticker/" + global.config.coin.name + "/?convert=EUR", function (res) { + if (res != null && res instanceof Array && res.length === 1 && typeof(res[0].price_usd) !== 'undefined' && typeof(res[0].price_eur) !== 'undefined') { + price_btc = parseFloat(res[0].price_btc); + price_usd = parseFloat(res[0].price_usd); + price_eur = parseFloat(res[0].price_eur); + } + return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); + }); + } else { + return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); + } + }, + function (callback) { + let currentEfforts = {}; + for (let port in min_block_rewards) { + const value = global.database.getCache(port != global.config.daemon.port ? "global_stats2_" + port : "global_stats2"); + if (value !== false) currentEfforts[port] = value.roundHashes; + } + return callback(null, currentEfforts); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for pplns_port_shares value"); + let pplns_port_shares = global.database.getCache('pplns_port_shares'); + return callback(null, pplns_port_shares ? pplns_port_shares : {}); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for pplns_window_time value"); + let pplns_window_time = global.database.getCache('pplns_window_time'); + return callback(null, pplns_window_time ? pplns_window_time : 0); + }, + function (callback) { + //debug(threadName + "Checking Influx for last 5min avg for pool stats (hashRate) per port"); + return callback(null, port_hash || {}); + }, + function (callback) { + //debug(threadName + "Checking LMDB cache for portMinerCount"); + return callback(null, global.database.getCache('portMinerCount') || {}); + }, + function (callback) { + let portCoinAlgo = {}; + for (let port of global.coinFuncs.getPORTS()) portCoinAlgo[port] = global.coinFuncs.algoShortTypeStr(port, 0); + return callback(null, portCoinAlgo); + }, + ], function (err, result) { + if (typeof(poolType) === 'undefined') { + poolType = 'global'; + updateBlockHeader(); + } + global.database.setCache('pool_stats_' + poolType, { + hashRate: result[0], + miners: result[1], + totalHashes: result[2], + lastBlockFoundTime: result[3] || 0, + lastBlockFound: result[4] || 0, + totalBlocksFound: result[5] || 0, + totalMinersPaid: result[6] || 0, + totalPayments: result[7] || 0, + roundHashes: result[8] || 0, + totalAltBlocksFound: result[9] || 0, + altBlocksFound: result[10] || {}, + activePort: result[11] || 0, + activePorts: result[12] || [], + activePortProfit: result[13] || 0, + coinProfit: result[14] || {}, + coinComment: result[15] || {}, + minBlockRewards: result[16] || {}, + pending: result[17] || 0, + price: result[18] || {}, + currentEfforts: result[19] || {}, + pplnsPortShares: result[20] || {}, + pplnsWindowTime: result[21] || 0, + portHash: result[22] || {}, + portMinerCount: result[23] || {}, + portCoinAlgo: result[24] || {}, + }); + }); +} + +function updatePoolPorts(poolServers) { + //debug(threadName + "Updating pool ports"); + let local_cache = {global: []}; + let portCount = 0; + global.mysql.query("select * from ports where hidden = 0 and pool_id < 1000 and lastSeen >= NOW() - INTERVAL 10 MINUTE").then(function (rows) { + rows.forEach(function (row) { + ++ portCount; + if (!local_cache.hasOwnProperty(row.port_type)) { + local_cache[row.port_type] = []; + } + local_cache[row.port_type].push({ + host: poolServers[row.pool_id], + port: row.network_port, + difficulty: row.starting_diff, + description: row.description, + miners: row.miners + }); + if (portCount === rows.length) { + let local_counts = {}; + let port_diff = {}; + let port_miners = {}; + let pool_type_count = 0; + let localPortInfo = {}; + for (let pool_type in local_cache) { // jshint ignore:line + ++ pool_type_count; + local_cache[pool_type].forEach(function (portData) { // jshint ignore:line + if (!local_counts.hasOwnProperty(portData.port)) { + local_counts[portData.port] = 0; + } + if (!port_diff.hasOwnProperty(portData.port)) { + port_diff[portData.port] = portData.difficulty; + } + if (!port_miners.hasOwnProperty(portData.port)) { + port_miners[portData.port] = 0; + } + if (port_diff[portData.port] === portData.difficulty) { + ++ local_counts[portData.port]; + port_miners[portData.port] += portData.miners; + } + localPortInfo[portData.port] = portData.description; + if (local_counts[portData.port] === Object.keys(poolServers).length) { + local_cache.global.push({ + host: { + blockID: typeof(local_cache[pool_type][0].host) === 'undefined' ? 0 : local_cache[pool_type][0].host.blockID, + blockIDTime: typeof(local_cache[pool_type][0].host) === 'undefined' ? 0 : local_cache[pool_type][0].host.blockIDTime, + hostname: global.config.pool.geoDNS, + }, + port: portData.port, + pool_type: pool_type, + difficulty: portData.difficulty, + miners: port_miners[portData.port], + description: localPortInfo[portData.port] + }); + } + }); + if (pool_type_count === Object.keys(local_cache).length) { + //debug(threadName + "Sending the following to the workers: " + JSON.stringify(local_cache)); + global.database.setCache('poolPorts', local_cache); + } + } + } + }); + }); +} + +function updatePoolInformation() { + let local_cache = {}; + //debug(threadName + "Updating pool information"); + global.mysql.query("select * from pools where id < 1000 and last_checkin >= NOW() - INTERVAL 10 MINUTE").then(function (rows) { + rows.forEach(function (row) { + local_cache[row.id] = { + ip: row.ip, + blockID: row.blockID, + blockIDTime: global.support.formatDateFromSQL(row.blockIDTime), + hostname: row.hostname + }; + if (Object.keys(local_cache).length === rows.length) { + global.database.setCache('poolServers', local_cache); + updatePoolPorts(local_cache); + } + }); + }); +} + +let prev_network_info = {}; + +function updateBlockHeader() { + let info = {}; + + let left = 0; + for (let port in min_block_rewards) ++ left; + + for (let port in min_block_rewards) { + global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ + if (!err) global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { + //if (err !== null) { + // console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); + // if (port in prev_network_info) { + // body.difficulty = prev_network_info[port].difficulty; + // body.hash = prev_network_info[port].hash; + // body.height = prev_network_info[port].height; + // body.reward = prev_network_info[port].value; + // body.timestamp = prev_network_info[port].ts; + // } else { + // body.difficulty = 0; + // body.hash = 0; + // body.height = 0; + // body.reward = 0; + // body.timestamp = 0; + // } + //} + prev_network_info[port] = info[port] = { + difficulty: body.difficulty, + hash: body.hash, + height: body.height, + value: body.reward, + ts: body.timestamp, + }; + if (port == global.config.daemon.activePort) { + info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; + info.hash = body.hash; + info.height = body.height; + info.value = body.reward; + info.ts = body.timestamp; + } + if (-- left === 0) { + info.main_height = prev_network_info[global.config.daemon.port].height; + global.database.setCache('networkBlockInfo', info); + } + }) + }, true); + } +} + +function updateWalletStats() { + async.waterfall([ + function (callback) { + // Todo: Implement within the coins/.js file. + global.support.rpcWallet('getbalance', [], function (body) { + if (body.result) { + return callback(null, { + balance: body.result.balance, + unlocked: body.result.unlocked_balance, + ts: Date.now() + }); + } else { + return callback(true, "Unable to process balance"); + } + }); + }, + function (state, callback) { + // Todo: Implement within the coins/.js file. + global.support.rpcWallet('getheight', [], function (body) { + if (body.result) { + state.height = body.result.height; + return callback(null, state); + } else if (typeof body.error !== 'undefined' && body.error.message === 'Method not found') { + state.height = 0; + return callback(null, state); + } else { + return callback(true, "Unable to get current wallet height"); + } + }); + } + ], function (err, results) { + if (err) { + return console.error("Unable to get wallet stats: " + results); + } + global.database.setCache('walletStateInfo', results); + let history = global.database.getCache('walletHistory'); + if (history === false) { + history = []; + } + history.unshift(results); + history = history.sort(global.support.tsCompare); + if (history.length > global.config.general.statsBufferLength) { + while (history.length > global.config.general.statsBufferLength) { + history.pop(); + } + } + global.database.setCache('walletHistory', history); + }); + +} + +function bad_header_start(port) { + console.error("Issue in getting block header for " + port + " port. Skipping node monitor"); + if (port in lastBlockCheckIsFailed) { + if (++ lastBlockCheckIsFailed[port] >= 5) global.support.sendEmail( + global.config.general.adminEmail, + 'Failed to query daemon for ' + port + ' port for last block header', + `The worker failed to return last block header for ` + port + ` port. Please verify if the daemon is running properly.` + ); + } else { + lastBlockCheckIsFailed[port] = 1; + } + return; +} + +function bad_header_stop(port) { + if (port in lastBlockCheckIsFailed) { + if (lastBlockCheckIsFailed[port] >= 5) global.support.sendEmail( + global.config.general.adminEmail, + 'Quering daemon for ' + port + ' port for last block header is back to normal', + `An warning was sent to you indicating that the the worker failed to return the last block header for ${port} port. + The issue seems to be solved now.` + ); + delete lastBlockCheckIsFailed[port]; + } +} + +function monitorNodes() { + global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { + global.coinFuncs.getPortLastBlockHeader(global.config.daemon.port, function (err, block) { + if (err !== null){ + bad_header_start(global.config.daemon.port); + return; + } + bad_header_stop(); + let top_height = 0; + let is_master_daemon_issue = rows.length > 1 ? true : false; + rows.forEach(function (row) { + if (row.port && row.port != global.config.daemon.port) { + console.error("INTERNAL ERROR: pool node port " + row.port + " do not match master port " + global.config.daemon.port); + is_master_daemon_issue = false; + return; + } + if (top_height < row.blockID) top_height = row.blockID; + if (Math.abs(block.height - row.blockID) > 3) { + global.support.sendEmail(global.config.general.adminEmail, + "Pool server behind in blocks", + "The pool server: " + row.hostname + " with IP: " + row.ip + " is " + (block.height - row.blockID) + " blocks behind for " + row.port + " port" + ); + } else { + is_master_daemon_issue = false; + } + }); + if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(block.height, top_height, global.config.daemon.port); + }); + }); +} + +updateShareStats(); +updatePoolStats(); +updatePoolInformation(); +updateWalletStats(); +monitorNodes(); +setInterval(updatePoolStats, 5*1000); +setInterval(updatePoolStats, 5*1000, 'pplns'); +if (global.config.pps.enable === true) setInterval(updatePoolStats, 5*1000, 'pps'); +if (global.config.solo.enable === true) setInterval(updatePoolStats, 5*1000, 'solo'); +setInterval(updatePoolInformation, 5*1000); +setInterval(updateWalletStats, 60*1000); +setInterval(monitorNodes, 5*60*1000); +// clean stats_cache from time to time +setInterval(function() { stats_cache = {}; } , 4*60*60*1000); diff --git a/lib/worker.js b/lib/worker.js index 21ba93341..48ff7889a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -3,20 +3,16 @@ const debug = require("debug")("worker"); const async = require("async"); const sprintf = require("sprintf-js").sprintf; -let threadName = "Worker Server "; let cycleCount = 0; let hashrate_avg_min = 10; let stat_change_alert = 0.3; -let lastBlockCheckIsFailed = {}; let prev_pool_state_time; let prev_pool_hashrate; let prev_pool_workers; let stats_cache = {}; - - - + function updateShareStats() { // This is an omni-worker to deal with all things share-stats related // Time based averages are worked out on ring buffers. @@ -316,14 +312,14 @@ function updateShareStats() { ], function (err, result) { if (++cycleCount === 3) { cycleCount = 0; - try { - if (global.gc) { - global.gc(); - console.log("Garbage collector completed"); - } - } catch (e) { - console.error("No garbage collector exposed, please use --expose-gc node option"); - } + //try { + // if (global.gc) { + // global.gc(); + // console.log("Garbage collector completed"); + // } + //} catch (e) { + // console.error("No garbage collector exposed, please use --expose-gc node option"); + //} } setTimeout(updateShareStats, 10*1000); }); @@ -404,508 +400,6 @@ function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { ); } -function updatePoolStats(poolType) { - global.support.getActivePort("", function (newActivePort) { - if (newActivePort) global.config.daemon.activePort = newActivePort; - updatePoolStats2(poolType); - }); -} - -let price_btc = 0; -let price_usd = 0; -let price_eur = 0; -let min_block_rewards = {}; - -function updatePoolStats2(poolType) { - let cache; - let port_suffix = global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; - if (typeof(poolType) !== 'undefined') { - cache = global.database.getCache(poolType + "_stats"); - if (port_suffix === "") { - let cache2 = global.database.getCache(poolType + "_stats2"); - cache.totalHashes = cache2.totalHashes; - cache.roundHashes = cache2.roundHashes; - } else { - let cache2_total = global.database.getCache(poolType + "_stats2"); - let cache2_round = global.database.getCache(poolType + "_stats2" + port_suffix); - cache.totalHashes = cache2_total.totalHashes; - cache.roundHashes = cache2_round.roundHashes; - } - } else { - cache = global.database.getCache("global_stats"); - if (port_suffix === "") { - let cache2 = global.database.getCache("global_stats2"); - cache.totalHashes = cache2.totalHashes; - cache.roundHashes = cache2.roundHashes; - } else { - let cache2_total = global.database.getCache("global_stats2"); - let cache2_round = global.database.getCache("global_stats2" + port_suffix); - cache.totalHashes = cache2_total.totalHashes; - cache.roundHashes = cache2_round.roundHashes; - } - } - - let port_hash = global.database.getCache('port_hash'); - let blockList = global.database.getBlockList(poolType); - let altblockList = global.database.getAltBlockList(poolType); - let min_block_rewards2 = global.database.getCache('min_block_rewards'); - if (min_block_rewards2) min_block_rewards = min_block_rewards2; - if (!(global.config.daemon.port in min_block_rewards)) min_block_rewards[global.config.daemon.port] = 0; - - async.series([ - function (callback) { - //debug(threadName + "Checking Influx for last 5min avg for pool stats (hashRate)"); - return callback(null, cache.hash || 0); - }, - function (callback) { - //debug(threadName + "Checking Influx for last 5min avg for miner count for pool stats (miners)"); - return callback(null, cache.minerCount || 0); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for totalHashes"); - return callback(null, cache.totalHashes || 0); - }, - function (callback) { - //debug(threadName + "Checking LMDB for lastBlockFoundTime for pool stats"); - let max_time = 0; - if (blockList.length !== 0) { - max_time = Math.floor(blockList[0].ts / 1000); - } - if (altblockList.length !== 0) { - max_time = Math.max(max_time, Math.floor(altblockList[0].ts / 1000)); - } - return callback(null, max_time); - }, - function (callback) { - //debug(threadName + "Checking LMDB for lastBlockFound height for pool stats"); - if (blockList.length === 0) { - return callback(null, 0); - } - return callback(null, blockList[0].height); - }, - function (callback) { - //debug(threadName + "Checking LMDB for totalBlocksFound for pool stats"); - return callback(null, blockList.length); - }, - function (callback) { - //debug(threadName + "Checking MySQL for total miners paid"); - if (typeof(poolType) !== 'undefined') { - global.mysql.query("SELECT payment_address, payment_id FROM payments WHERE pool_type = ? group by payment_address, payment_id", [poolType]).then(function (rows) { - return callback(null, rows.length); - }); - } else { - global.mysql.query("SELECT payment_address, payment_id FROM payments group by payment_address, payment_id").then(function (rows) { - return callback(null, rows.length); - }); - } - }, - function (callback) { - //debug(threadName + "Checking MySQL for total transactions count"); - if (typeof(poolType) !== 'undefined') { - global.mysql.query("SELECT distinct(transaction_id) from payments WHERE pool_type = ?", [poolType]).then(function (rows) { - return callback(null, rows.length); - }); - } else { - global.mysql.query("SELECT count(id) as txn_count FROM transactions").then(function (rows) { - if (typeof(rows[0]) !== 'undefined') { - return callback(null, rows[0].txn_count); - } else { - return callback(null, 0); - } - }); - } - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for roundHashes"); - return callback(null, cache.roundHashes || 0); - }, - function (callback) { - //debug(threadName + "Checking LMDB for altblock count for pool stats"); - return callback(null, altblockList.length); - }, - function (callback) { - //debug(threadName + "Checking LMDB for altBlocksFound array for each specific port"); - let result = {}; - for (let i in altblockList) { - let block = altblockList[i]; - if (result.hasOwnProperty(block.port)) ++ result[block.port]; - else result[block.port] = 1; - } - return callback(null, result); - }, - function (callback) { - //debug(threadName + "Checking MySQL for activePort value"); - return callback(null, global.config.daemon.activePort); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for active_ports value"); - let active_ports = global.database.getCache('active_ports'); - return callback(null, active_ports ? active_ports : []); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for xmr_profit value"); - let xmr_profit = global.database.getCache('xmr_profit'); - return callback(null, xmr_profit ? xmr_profit.value : 0); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for coin_profit value"); - let coin_xmr_profit = global.database.getCache('coin_xmr_profit'); - return callback(null, coin_xmr_profit ? coin_xmr_profit : {}); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for xmr_profit_comment value"); - let coin_comment = global.database.getCache('coin_comment'); - return callback(null, coin_comment ? coin_comment : {}); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); - return callback(null, min_block_rewards); - }, - function (callback) { - let pending = 0; - for (let i in blockList) { - const block = blockList[i]; - if (block.valid === true && block.unlocked === false) pending += global.support.coinToDecimal(block.value); - } - for (let i in altblockList) { - const altblock = altblockList[i]; - if (altblock.valid === true && altblock.unlocked === false) pending += altblock.port in min_block_rewards ? min_block_rewards[altblock.port] : 0; - } - return callback(null, pending); - }, - function (callback) { - if (typeof(poolType) === 'undefined') { - global.support.https_get("https://api.coinmarketcap.com/v1/ticker/" + global.config.coin.name + "/?convert=EUR", function (res) { - if (res != null && res instanceof Array && res.length === 1 && typeof(res[0].price_usd) !== 'undefined' && typeof(res[0].price_eur) !== 'undefined') { - price_btc = parseFloat(res[0].price_btc); - price_usd = parseFloat(res[0].price_usd); - price_eur = parseFloat(res[0].price_eur); - } - return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); - }); - } else { - return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); - } - }, - function (callback) { - let currentEfforts = {}; - for (let port in min_block_rewards) { - const value = global.database.getCache(port != global.config.daemon.port ? "global_stats2_" + port : "global_stats2"); - if (value !== false) currentEfforts[port] = value.roundHashes; - } - return callback(null, currentEfforts); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for pplns_port_shares value"); - let pplns_port_shares = global.database.getCache('pplns_port_shares'); - return callback(null, pplns_port_shares ? pplns_port_shares : {}); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for pplns_window_time value"); - let pplns_window_time = global.database.getCache('pplns_window_time'); - return callback(null, pplns_window_time ? pplns_window_time : 0); - }, - function (callback) { - //debug(threadName + "Checking Influx for last 5min avg for pool stats (hashRate) per port"); - return callback(null, port_hash || {}); - }, - function (callback) { - //debug(threadName + "Checking LMDB cache for portMinerCount"); - return callback(null, global.database.getCache('portMinerCount') || {}); - }, - function (callback) { - let portCoinAlgo = {}; - for (let port of global.coinFuncs.getPORTS()) portCoinAlgo[port] = global.coinFuncs.algoShortTypeStr(port, 0); - return callback(null, portCoinAlgo); - }, - ], function (err, result) { - if (typeof(poolType) === 'undefined') { - poolType = 'global'; - updateBlockHeader(); - } - global.database.setCache('pool_stats_' + poolType, { - hashRate: result[0], - miners: result[1], - totalHashes: result[2], - lastBlockFoundTime: result[3] || 0, - lastBlockFound: result[4] || 0, - totalBlocksFound: result[5] || 0, - totalMinersPaid: result[6] || 0, - totalPayments: result[7] || 0, - roundHashes: result[8] || 0, - totalAltBlocksFound: result[9] || 0, - altBlocksFound: result[10] || {}, - activePort: result[11] || 0, - activePorts: result[12] || [], - activePortProfit: result[13] || 0, - coinProfit: result[14] || {}, - coinComment: result[15] || {}, - minBlockRewards: result[16] || {}, - pending: result[17] || 0, - price: result[18] || {}, - currentEfforts: result[19] || {}, - pplnsPortShares: result[20] || {}, - pplnsWindowTime: result[21] || 0, - portHash: result[22] || {}, - portMinerCount: result[23] || {}, - portCoinAlgo: result[24] || {}, - }); - }); -} - -function updatePoolPorts(poolServers) { - //debug(threadName + "Updating pool ports"); - let local_cache = {global: []}; - let portCount = 0; - global.mysql.query("select * from ports where hidden = 0 and pool_id < 1000 and lastSeen >= NOW() - INTERVAL 10 MINUTE").then(function (rows) { - rows.forEach(function (row) { - ++ portCount; - if (!local_cache.hasOwnProperty(row.port_type)) { - local_cache[row.port_type] = []; - } - local_cache[row.port_type].push({ - host: poolServers[row.pool_id], - port: row.network_port, - difficulty: row.starting_diff, - description: row.description, - miners: row.miners - }); - if (portCount === rows.length) { - let local_counts = {}; - let port_diff = {}; - let port_miners = {}; - let pool_type_count = 0; - let localPortInfo = {}; - for (let pool_type in local_cache) { // jshint ignore:line - ++ pool_type_count; - local_cache[pool_type].forEach(function (portData) { // jshint ignore:line - if (!local_counts.hasOwnProperty(portData.port)) { - local_counts[portData.port] = 0; - } - if (!port_diff.hasOwnProperty(portData.port)) { - port_diff[portData.port] = portData.difficulty; - } - if (!port_miners.hasOwnProperty(portData.port)) { - port_miners[portData.port] = 0; - } - if (port_diff[portData.port] === portData.difficulty) { - ++ local_counts[portData.port]; - port_miners[portData.port] += portData.miners; - } - localPortInfo[portData.port] = portData.description; - if (local_counts[portData.port] === Object.keys(poolServers).length) { - local_cache.global.push({ - host: { - blockID: typeof(local_cache[pool_type][0].host) === 'undefined' ? 0 : local_cache[pool_type][0].host.blockID, - blockIDTime: typeof(local_cache[pool_type][0].host) === 'undefined' ? 0 : local_cache[pool_type][0].host.blockIDTime, - hostname: global.config.pool.geoDNS, - }, - port: portData.port, - pool_type: pool_type, - difficulty: portData.difficulty, - miners: port_miners[portData.port], - description: localPortInfo[portData.port] - }); - } - }); - if (pool_type_count === Object.keys(local_cache).length) { - //debug(threadName + "Sending the following to the workers: " + JSON.stringify(local_cache)); - global.database.setCache('poolPorts', local_cache); - } - } - } - }); - }); -} - -function updatePoolInformation() { - let local_cache = {}; - //debug(threadName + "Updating pool information"); - global.mysql.query("select * from pools where id < 1000 and last_checkin >= NOW() - INTERVAL 10 MINUTE").then(function (rows) { - rows.forEach(function (row) { - local_cache[row.id] = { - ip: row.ip, - blockID: row.blockID, - blockIDTime: global.support.formatDateFromSQL(row.blockIDTime), - hostname: row.hostname - }; - if (Object.keys(local_cache).length === rows.length) { - global.database.setCache('poolServers', local_cache); - updatePoolPorts(local_cache); - } - }); - }); -} - -let prev_network_info = {}; - -function updateBlockHeader() { - let info = {}; - - let left = 0; - for (let port in min_block_rewards) ++ left; - - for (let port in min_block_rewards) { - global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ - if (!err) global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { - //if (err !== null) { - // console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); - // if (port in prev_network_info) { - // body.difficulty = prev_network_info[port].difficulty; - // body.hash = prev_network_info[port].hash; - // body.height = prev_network_info[port].height; - // body.reward = prev_network_info[port].value; - // body.timestamp = prev_network_info[port].ts; - // } else { - // body.difficulty = 0; - // body.hash = 0; - // body.height = 0; - // body.reward = 0; - // body.timestamp = 0; - // } - //} - prev_network_info[port] = info[port] = { - difficulty: body.difficulty, - hash: body.hash, - height: body.height, - value: body.reward, - ts: body.timestamp, - }; - if (port == global.config.daemon.activePort) { - info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; - info.hash = body.hash; - info.height = body.height; - info.value = body.reward; - info.ts = body.timestamp; - } - if (-- left === 0) { - info.main_height = prev_network_info[global.config.daemon.port].height; - global.database.setCache('networkBlockInfo', info); - } - }) - }, true); - } -} - -function updateWalletStats() { - async.waterfall([ - function (callback) { - // Todo: Implement within the coins/.js file. - global.support.rpcWallet('getbalance', [], function (body) { - if (body.result) { - return callback(null, { - balance: body.result.balance, - unlocked: body.result.unlocked_balance, - ts: Date.now() - }); - } else { - return callback(true, "Unable to process balance"); - } - }); - }, - function (state, callback) { - // Todo: Implement within the coins/.js file. - global.support.rpcWallet('getheight', [], function (body) { - if (body.result) { - state.height = body.result.height; - return callback(null, state); - } else if (typeof body.error !== 'undefined' && body.error.message === 'Method not found') { - state.height = 0; - return callback(null, state); - } else { - return callback(true, "Unable to get current wallet height"); - } - }); - } - ], function (err, results) { - if (err) { - return console.error("Unable to get wallet stats: " + results); - } - global.database.setCache('walletStateInfo', results); - let history = global.database.getCache('walletHistory'); - if (history === false) { - history = []; - } - history.unshift(results); - history = history.sort(global.support.tsCompare); - if (history.length > global.config.general.statsBufferLength) { - while (history.length > global.config.general.statsBufferLength) { - history.pop(); - } - } - global.database.setCache('walletHistory', history); - }); - -} - -function bad_header_start(port) { - console.error("Issue in getting block header for " + port + " port. Skipping node monitor"); - if (port in lastBlockCheckIsFailed) { - if (++ lastBlockCheckIsFailed[port] >= 5) global.support.sendEmail( - global.config.general.adminEmail, - 'Failed to query daemon for ' + port + ' port for last block header', - `The worker failed to return last block header for ` + port + ` port. Please verify if the daemon is running properly.` - ); - } else { - lastBlockCheckIsFailed[port] = 1; - } - return; -} - -function bad_header_stop(port) { - if (port in lastBlockCheckIsFailed) { - if (lastBlockCheckIsFailed[port] >= 5) global.support.sendEmail( - global.config.general.adminEmail, - 'Quering daemon for ' + port + ' port for last block header is back to normal', - `An warning was sent to you indicating that the the worker failed to return the last block header for ${port} port. - The issue seems to be solved now.` - ); - delete lastBlockCheckIsFailed[port]; - } -} - -function monitorNodes() { - global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { - global.coinFuncs.getPortLastBlockHeader(global.config.daemon.port, function (err, block) { - if (err !== null){ - bad_header_start(global.config.daemon.port); - return; - } - bad_header_stop(); - let top_height = 0; - let is_master_daemon_issue = rows.length > 1 ? true : false; - rows.forEach(function (row) { - if (row.port && row.port != global.config.daemon.port) { - console.error("INTERNAL ERROR: pool node port " + row.port + " do not match master port " + global.config.daemon.port); - is_master_daemon_issue = false; - return; - } - if (top_height < row.blockID) top_height = row.blockID; - if (Math.abs(block.height - row.blockID) > 3) { - global.support.sendEmail(global.config.general.adminEmail, - "Pool server behind in blocks", - "The pool server: " + row.hostname + " with IP: " + row.ip + " is " + (block.height - row.blockID) + " blocks behind for " + row.port + " port" - ); - } else { - is_master_daemon_issue = false; - } - }); - if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(block.height, top_height, global.config.daemon.port); - }); - }); -} - updateShareStats(); -updatePoolStats(); -updatePoolInformation(); -updateWalletStats(); -monitorNodes(); -setInterval(updatePoolStats, 5*1000); -setInterval(updatePoolStats, 5*1000, 'pplns'); -if (global.config.pps.enable === true) setInterval(updatePoolStats, 5*1000, 'pps'); -if (global.config.solo.enable === true) setInterval(updatePoolStats, 5*1000, 'solo'); -setInterval(updatePoolInformation, 5*1000); -setInterval(updateWalletStats, 60*1000); -setInterval(monitorNodes, 5*60*1000); // clean stats_cache from time to time setInterval(function() { stats_cache = {}; } , 4*60*60*1000); From db2017b53c7de22ab2e89380f33d50ca2cb25608 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:41:25 -0800 Subject: [PATCH 0766/1496] Separated worker module --- lib/worker.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 48ff7889a..e2567b210 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -28,14 +28,12 @@ function updateShareStats() { function (callback) { global.coinFuncs.getLastBlockHeader(function (err, body) { if (err !== null){ - bad_header_start(global.config.daemon.port); return callback(err, "Invalid block header"); } callback(null, body.height + 1); }); }, function (height, callback) { - bad_header_stop(global.config.daemon.port); console.log("Starting stats collection for " + height + " height (history power: " + history_power + ")"); const locTime = currentTime - (hashrate_avg_min*60*1000); From 80adbf0c60611bd4afeab72fef1dff10e9da8e73 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:42:53 -0800 Subject: [PATCH 0767/1496] Separated worker module --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71955481c..ac3344c00 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Deployment via Installer cd ~/nodejs-pool/ pm2 start init.js --name=blockManager --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=blockManager pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=worker -pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=pool_stats +pm2 start init.js --name=pool_stats --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=pool_stats pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" --no-autorestart -- --module=payments pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=remoteShare pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=longRunner From 307aa33c5fa82c3805a7374f5eef24a5d27756e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:45:08 -0800 Subject: [PATCH 0768/1496] Separated worker module --- init.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.js b/init.js index 5ad2cc446..b1ec5a06b 100644 --- a/init.js +++ b/init.js @@ -98,6 +98,9 @@ global.mysql.query("SELECT * FROM config").then(function (rows) { case 'worker': require('./lib/worker.js'); break; + case 'pool_stats': + require('./lib/pool_stats.js'); + break; case 'longRunner': require('./lib/longRunner.js'); break; From 049db0b825f074ec13767776ed11031fe77adb7c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:46:12 -0800 Subject: [PATCH 0769/1496] Separated worker module --- lib/pool_stats.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 54335a8e5..57ac5e456 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -53,6 +53,7 @@ function updatePoolStats2(poolType) { let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; if (!(global.config.daemon.port in min_block_rewards)) min_block_rewards[global.config.daemon.port] = 0; + console.log("Running pool stats"); async.series([ function (callback) { From 93597c696bcf7bc9bf9b894030f22f676037820d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:47:01 -0800 Subject: [PATCH 0770/1496] Separated worker module --- lib/pool_stats.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 57ac5e456..ab69f6fd4 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -498,7 +498,6 @@ function monitorNodes() { }); } -updateShareStats(); updatePoolStats(); updatePoolInformation(); updateWalletStats(); From dd24c8a60a5b0dfabe17aba13c66d0979bda9fe6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:48:03 -0800 Subject: [PATCH 0771/1496] Separated worker module --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index ab69f6fd4..75667ffb3 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -34,6 +34,7 @@ function updatePoolStats2(poolType) { cache.roundHashes = cache2_round.roundHashes; } } else { + console.log("Running pool stats"); cache = global.database.getCache("global_stats"); if (port_suffix === "") { let cache2 = global.database.getCache("global_stats2"); @@ -53,7 +54,6 @@ function updatePoolStats2(poolType) { let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; if (!(global.config.daemon.port in min_block_rewards)) min_block_rewards[global.config.daemon.port] = 0; - console.log("Running pool stats"); async.series([ function (callback) { From 536a6b13a8f4a26b6302deb4319c2a765baeae34 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:50:03 -0800 Subject: [PATCH 0772/1496] Separated worker module --- lib/pool_stats.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 75667ffb3..60ae0fb05 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -17,6 +17,7 @@ let price_btc = 0; let price_usd = 0; let price_eur = 0; let min_block_rewards = {}; +let count = 0; function updatePoolStats2(poolType) { let cache; @@ -34,7 +35,7 @@ function updatePoolStats2(poolType) { cache.roundHashes = cache2_round.roundHashes; } } else { - console.log("Running pool stats"); + if (++ count % 10 == 0) console.log("Running pool stats"); cache = global.database.getCache("global_stats"); if (port_suffix === "") { let cache2 = global.database.getCache("global_stats2"); From 63e670a22a596ea704298cd3711d64c4fc330186 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:50:39 -0800 Subject: [PATCH 0773/1496] Separated worker module --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 60ae0fb05..6748ae173 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -35,7 +35,7 @@ function updatePoolStats2(poolType) { cache.roundHashes = cache2_round.roundHashes; } } else { - if (++ count % 10 == 0) console.log("Running pool stats"); + if (++count % 10 == 1) console.log("Running pool stats"); cache = global.database.getCache("global_stats"); if (port_suffix === "") { let cache2 = global.database.getCache("global_stats2"); From d9d5cade92b1376dddf12e06f0a0533c69bdaabc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Jan 2020 23:58:33 -0800 Subject: [PATCH 0774/1496] Separated worker module --- lib/pool_stats.js | 104 +++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 6748ae173..193988544 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -391,56 +391,56 @@ function updateBlockHeader() { } } -function updateWalletStats() { - async.waterfall([ - function (callback) { - // Todo: Implement within the coins/.js file. - global.support.rpcWallet('getbalance', [], function (body) { - if (body.result) { - return callback(null, { - balance: body.result.balance, - unlocked: body.result.unlocked_balance, - ts: Date.now() - }); - } else { - return callback(true, "Unable to process balance"); - } - }); - }, - function (state, callback) { - // Todo: Implement within the coins/.js file. - global.support.rpcWallet('getheight', [], function (body) { - if (body.result) { - state.height = body.result.height; - return callback(null, state); - } else if (typeof body.error !== 'undefined' && body.error.message === 'Method not found') { - state.height = 0; - return callback(null, state); - } else { - return callback(true, "Unable to get current wallet height"); - } - }); - } - ], function (err, results) { - if (err) { - return console.error("Unable to get wallet stats: " + results); - } - global.database.setCache('walletStateInfo', results); - let history = global.database.getCache('walletHistory'); - if (history === false) { - history = []; - } - history.unshift(results); - history = history.sort(global.support.tsCompare); - if (history.length > global.config.general.statsBufferLength) { - while (history.length > global.config.general.statsBufferLength) { - history.pop(); - } - } - global.database.setCache('walletHistory', history); - }); - -} +//function updateWalletStats() { +// async.waterfall([ +// function (callback) { +// // Todo: Implement within the coins/.js file. +// global.support.rpcWallet('getbalance', [], function (body) { +// if (body.result) { +// return callback(null, { +// balance: body.result.balance, +// unlocked: body.result.unlocked_balance, +// ts: Date.now() +// }); +// } else { +// return callback(true, "Unable to process balance"); +// } +// }); +// }, +// function (state, callback) { +// // Todo: Implement within the coins/.js file. +// global.support.rpcWallet('getheight', [], function (body) { +// if (body.result) { +// state.height = body.result.height; +// return callback(null, state); +// } else if (typeof body.error !== 'undefined' && body.error.message === 'Method not found') { +// state.height = 0; +// return callback(null, state); +// } else { +// return callback(true, "Unable to get current wallet height"); +// } +// }); +// } +// ], function (err, results) { +// if (err) { +// return console.error("Unable to get wallet stats: " + results); +// } +// global.database.setCache('walletStateInfo', results); +// let history = global.database.getCache('walletHistory'); +// if (history === false) { +// history = []; +// } +// history.unshift(results); +// history = history.sort(global.support.tsCompare); +// if (history.length > global.config.general.statsBufferLength) { +// while (history.length > global.config.general.statsBufferLength) { +// history.pop(); +// } +// } +// global.database.setCache('walletHistory', history); +// }); +// +//} function bad_header_start(port) { console.error("Issue in getting block header for " + port + " port. Skipping node monitor"); @@ -501,14 +501,14 @@ function monitorNodes() { updatePoolStats(); updatePoolInformation(); -updateWalletStats(); +//updateWalletStats(); monitorNodes(); setInterval(updatePoolStats, 5*1000); setInterval(updatePoolStats, 5*1000, 'pplns'); if (global.config.pps.enable === true) setInterval(updatePoolStats, 5*1000, 'pps'); if (global.config.solo.enable === true) setInterval(updatePoolStats, 5*1000, 'solo'); setInterval(updatePoolInformation, 5*1000); -setInterval(updateWalletStats, 60*1000); +//setInterval(updateWalletStats, 60*1000); setInterval(monitorNodes, 5*60*1000); // clean stats_cache from time to time setInterval(function() { stats_cache = {}; } , 4*60*60*1000); From 628f8ef2c441b978fcbfecc76936ced5c8795ec1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:09:07 -0800 Subject: [PATCH 0775/1496] Separated worker module --- lib/pool_stats.js | 68 +++++------------------------------------------ 1 file changed, 7 insertions(+), 61 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 193988544..ac293b257 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -254,6 +254,7 @@ function updatePoolStats2(poolType) { portMinerCount: result[23] || {}, portCoinAlgo: result[24] || {}, }); + setTimeout(updatePoolStats, 5*1000, poolType); }); } @@ -315,6 +316,7 @@ function updatePoolPorts(poolServers) { if (pool_type_count === Object.keys(local_cache).length) { //debug(threadName + "Sending the following to the workers: " + JSON.stringify(local_cache)); global.database.setCache('poolPorts', local_cache); + setTimeout(updatePoolInformation, 5*1000); } } } @@ -391,57 +393,6 @@ function updateBlockHeader() { } } -//function updateWalletStats() { -// async.waterfall([ -// function (callback) { -// // Todo: Implement within the coins/.js file. -// global.support.rpcWallet('getbalance', [], function (body) { -// if (body.result) { -// return callback(null, { -// balance: body.result.balance, -// unlocked: body.result.unlocked_balance, -// ts: Date.now() -// }); -// } else { -// return callback(true, "Unable to process balance"); -// } -// }); -// }, -// function (state, callback) { -// // Todo: Implement within the coins/.js file. -// global.support.rpcWallet('getheight', [], function (body) { -// if (body.result) { -// state.height = body.result.height; -// return callback(null, state); -// } else if (typeof body.error !== 'undefined' && body.error.message === 'Method not found') { -// state.height = 0; -// return callback(null, state); -// } else { -// return callback(true, "Unable to get current wallet height"); -// } -// }); -// } -// ], function (err, results) { -// if (err) { -// return console.error("Unable to get wallet stats: " + results); -// } -// global.database.setCache('walletStateInfo', results); -// let history = global.database.getCache('walletHistory'); -// if (history === false) { -// history = []; -// } -// history.unshift(results); -// history = history.sort(global.support.tsCompare); -// if (history.length > global.config.general.statsBufferLength) { -// while (history.length > global.config.general.statsBufferLength) { -// history.pop(); -// } -// } -// global.database.setCache('walletHistory', history); -// }); -// -//} - function bad_header_start(port) { console.error("Issue in getting block header for " + port + " port. Skipping node monitor"); if (port in lastBlockCheckIsFailed) { @@ -500,15 +451,10 @@ function monitorNodes() { } updatePoolStats(); +updatePoolStats('pplns'); +if (global.config.pps.enable === true) updatePoolStats('pps'); +if (global.config.solo.enable === true) updatePoolStats('solo'); updatePoolInformation(); -//updateWalletStats(); + monitorNodes(); -setInterval(updatePoolStats, 5*1000); -setInterval(updatePoolStats, 5*1000, 'pplns'); -if (global.config.pps.enable === true) setInterval(updatePoolStats, 5*1000, 'pps'); -if (global.config.solo.enable === true) setInterval(updatePoolStats, 5*1000, 'solo'); -setInterval(updatePoolInformation, 5*1000); -//setInterval(updateWalletStats, 60*1000); -setInterval(monitorNodes, 5*60*1000); -// clean stats_cache from time to time -setInterval(function() { stats_cache = {}; } , 4*60*60*1000); +setInterval(monitorNodes, 5*60*1000); \ No newline at end of file From d638bfcd26a17a5652b4c25c91055e6bf87e9752 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:11:06 -0800 Subject: [PATCH 0776/1496] Separated worker module --- lib/pool_stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index ac293b257..2f299e2e1 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -254,7 +254,7 @@ function updatePoolStats2(poolType) { portMinerCount: result[23] || {}, portCoinAlgo: result[24] || {}, }); - setTimeout(updatePoolStats, 5*1000, poolType); + setTimeout(updatePoolStats, 30*1000, poolType); }); } @@ -316,7 +316,7 @@ function updatePoolPorts(poolServers) { if (pool_type_count === Object.keys(local_cache).length) { //debug(threadName + "Sending the following to the workers: " + JSON.stringify(local_cache)); global.database.setCache('poolPorts', local_cache); - setTimeout(updatePoolInformation, 5*1000); + setTimeout(updatePoolInformation, 30*1000); } } } From 0b24cc42822860375957e1efd90ab6927846a168 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:11:41 -0800 Subject: [PATCH 0777/1496] Separated worker module --- lib/pool_stats.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 2f299e2e1..af9c16c7b 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -17,7 +17,6 @@ let price_btc = 0; let price_usd = 0; let price_eur = 0; let min_block_rewards = {}; -let count = 0; function updatePoolStats2(poolType) { let cache; @@ -35,7 +34,7 @@ function updatePoolStats2(poolType) { cache.roundHashes = cache2_round.roundHashes; } } else { - if (++count % 10 == 1) console.log("Running pool stats"); + console.log("Running pool stats"); cache = global.database.getCache("global_stats"); if (port_suffix === "") { let cache2 = global.database.getCache("global_stats2"); From d59e74960ba13cc9a01dde506bc477caeca37145 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:20:19 -0800 Subject: [PATCH 0778/1496] Separated worker module --- lib/pool_stats.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index af9c16c7b..362a75b6f 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -222,11 +222,8 @@ function updatePoolStats2(poolType) { return callback(null, portCoinAlgo); }, ], function (err, result) { - if (typeof(poolType) === 'undefined') { - poolType = 'global'; - updateBlockHeader(); - } - global.database.setCache('pool_stats_' + poolType, { + if (typeof(poolType) === 'undefined') updateBlockHeader(); + global.database.setCache('pool_stats_' + (typeof(poolType) === 'undefined' ? 'global' : poolType), { hashRate: result[0], miners: result[1], totalHashes: result[2], From 688eec9e1b5ccbab42ce2f296f93f475bae5d9c6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:31:26 -0800 Subject: [PATCH 0779/1496] Separated worker module --- lib/pool_stats.js | 48 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 362a75b6f..7d6844cf4 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -222,7 +222,6 @@ function updatePoolStats2(poolType) { return callback(null, portCoinAlgo); }, ], function (err, result) { - if (typeof(poolType) === 'undefined') updateBlockHeader(); global.database.setCache('pool_stats_' + (typeof(poolType) === 'undefined' ? 'global' : poolType), { hashRate: result[0], miners: result[1], @@ -344,28 +343,10 @@ let prev_network_info = {}; function updateBlockHeader() { let info = {}; - let left = 0; - for (let port in min_block_rewards) ++ left; - - for (let port in min_block_rewards) { + async.eachSeries(min_block_rewards, function(port, next) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ - if (!err) global.support.rpcPortDaemon(port,'get_info', [], function (rpcResult) { - //if (err !== null) { - // console.error("Last block header request failed for " + port + " port!: " + (body instanceof Object ? JSON.stringify(body) : body)); - // if (port in prev_network_info) { - // body.difficulty = prev_network_info[port].difficulty; - // body.hash = prev_network_info[port].hash; - // body.height = prev_network_info[port].height; - // body.reward = prev_network_info[port].value; - // body.timestamp = prev_network_info[port].ts; - // } else { - // body.difficulty = 0; - // body.hash = 0; - // body.height = 0; - // body.reward = 0; - // body.timestamp = 0; - // } - //} + if (err) return next(); + global.support.rpcPortDaemon(port, 'get_info', [], function (rpcResult) { prev_network_info[port] = info[port] = { difficulty: body.difficulty, hash: body.hash, @@ -374,19 +355,23 @@ function updateBlockHeader() { ts: body.timestamp, }; if (port == global.config.daemon.activePort) { - info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; - info.hash = body.hash; - info.height = body.height; - info.value = body.reward; - info.ts = body.timestamp; + info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; + info.hash = body.hash; + info.height = body.height; + info.value = body.reward; + info.ts = body.timestamp; } + return next; if (-- left === 0) { - info.main_height = prev_network_info[global.config.daemon.port].height; - global.database.setCache('networkBlockInfo', info); + } - }) + }); }, true); - } + }, function(err, result) { + info.main_height = prev_network_info[global.config.daemon.port].height; + global.database.setCache('networkBlockInfo', info); + setTimeout(updateBlockHeader, 30*1000); + }); } function bad_header_start(port) { @@ -451,6 +436,7 @@ updatePoolStats('pplns'); if (global.config.pps.enable === true) updatePoolStats('pps'); if (global.config.solo.enable === true) updatePoolStats('solo'); updatePoolInformation(); +updateBlockHeader(); monitorNodes(); setInterval(monitorNodes, 5*60*1000); \ No newline at end of file From 5b4e85cbcbbd34c2d6dde88030b26e955639a624 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:36:33 -0800 Subject: [PATCH 0780/1496] Separated worker module --- lib/pool_stats.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 7d6844cf4..205faab08 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -338,16 +338,14 @@ function updatePoolInformation() { }); } -let prev_network_info = {}; +let network_info = {}; function updateBlockHeader() { - let info = {}; - async.eachSeries(min_block_rewards, function(port, next) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err) return next(); global.support.rpcPortDaemon(port, 'get_info', [], function (rpcResult) { - prev_network_info[port] = info[port] = { + network_info[port] = { difficulty: body.difficulty, hash: body.hash, height: body.height, @@ -355,21 +353,18 @@ function updateBlockHeader() { ts: body.timestamp, }; if (port == global.config.daemon.activePort) { - info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; - info.hash = body.hash; - info.height = body.height; - info.value = body.reward; - info.ts = body.timestamp; - } - return next; - if (-- left === 0) { - + network_info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; + network_info.hash = body.hash; + network_info.height = body.height; + network_info.value = body.reward; + network_info.ts = body.timestamp; } + return next(); }); }, true); }, function(err, result) { - info.main_height = prev_network_info[global.config.daemon.port].height; - global.database.setCache('networkBlockInfo', info); + network_info.main_height = network_info[global.config.daemon.port].height; + global.database.setCache('networkBlockInfo', network_info); setTimeout(updateBlockHeader, 30*1000); }); } From a4956246c1fa41bb49610d83110066ce641abac4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:38:44 -0800 Subject: [PATCH 0781/1496] Separated worker module --- lib/pool_stats.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 205faab08..426192a73 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -363,7 +363,6 @@ function updateBlockHeader() { }); }, true); }, function(err, result) { - network_info.main_height = network_info[global.config.daemon.port].height; global.database.setCache('networkBlockInfo', network_info); setTimeout(updateBlockHeader, 30*1000); }); From 98514bed07297d5cc5a5f036272a1b5a45f1873f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 00:39:11 -0800 Subject: [PATCH 0782/1496] Separated worker module --- lib/pool_stats.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 426192a73..509d73911 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -353,11 +353,12 @@ function updateBlockHeader() { ts: body.timestamp, }; if (port == global.config.daemon.activePort) { - network_info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; - network_info.hash = body.hash; - network_info.height = body.height; - network_info.value = body.reward; - network_info.ts = body.timestamp; + network_info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; + network_info.hash = body.hash; + network_info.main_height = body.height; + network_info.height = body.height; + network_info.value = body.reward; + network_info.ts = body.timestamp; } return next(); }); From fa7464330415363389e5d12472a5a196a6817bdc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 07:26:22 -0800 Subject: [PATCH 0783/1496] Test --- lib/pool_stats.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 509d73911..2e38dcea6 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -342,6 +342,7 @@ let network_info = {}; function updateBlockHeader() { async.eachSeries(min_block_rewards, function(port, next) { + console.log("Port: " + port); global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err) return next(); global.support.rpcPortDaemon(port, 'get_info', [], function (rpcResult) { From 6e3547907d41447769539d5d3d4af51ece669be9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 07:28:54 -0800 Subject: [PATCH 0784/1496] Test --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 2e38dcea6..8205f4fc0 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -341,7 +341,7 @@ function updatePoolInformation() { let network_info = {}; function updateBlockHeader() { - async.eachSeries(min_block_rewards, function(port, next) { + async.eachSeries(Object.keys(min_block_rewards), function(port, next) { console.log("Port: " + port); global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err) return next(); From 534e83d78d96827d8dda9e3219cd4e98d1ba886e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 07:30:29 -0800 Subject: [PATCH 0785/1496] Test --- lib/pool_stats.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 8205f4fc0..d229af85d 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -342,7 +342,6 @@ let network_info = {}; function updateBlockHeader() { async.eachSeries(Object.keys(min_block_rewards), function(port, next) { - console.log("Port: " + port); global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err) return next(); global.support.rpcPortDaemon(port, 'get_info', [], function (rpcResult) { From f25d3e0b5bfac3bf5dbd77125b65ddb505552427 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 07:33:08 -0800 Subject: [PATCH 0786/1496] Test --- lib/pool_stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index d229af85d..86cd4c940 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -192,7 +192,7 @@ function updatePoolStats2(poolType) { }, function (callback) { let currentEfforts = {}; - for (let port in min_block_rewards) { + for (let port in global.coinFuncs.getPORTS()) { const value = global.database.getCache(port != global.config.daemon.port ? "global_stats2_" + port : "global_stats2"); if (value !== false) currentEfforts[port] = value.roundHashes; } @@ -341,7 +341,7 @@ function updatePoolInformation() { let network_info = {}; function updateBlockHeader() { - async.eachSeries(Object.keys(min_block_rewards), function(port, next) { + async.eachSeries(global.coinFuncs.getPORTS(), function(port, next) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err) return next(); global.support.rpcPortDaemon(port, 'get_info', [], function (rpcResult) { From da3d7d8a1f87e3f4d7dea3a1060bc0ecf6bef57d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 10:12:57 -0800 Subject: [PATCH 0787/1496] Test --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 86cd4c940..d45137023 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -192,7 +192,7 @@ function updatePoolStats2(poolType) { }, function (callback) { let currentEfforts = {}; - for (let port in global.coinFuncs.getPORTS()) { + for (let port of global.coinFuncs.getPORTS()) { const value = global.database.getCache(port != global.config.daemon.port ? "global_stats2_" + port : "global_stats2"); if (value !== false) currentEfforts[port] = value.roundHashes; } From bf49c8a86c7772adb09a604abd04ed62ea84c374 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 16:47:15 -0800 Subject: [PATCH 0788/1496] Added readers check --- lib/pool_stats.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index d45137023..6e60878ba 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -19,6 +19,7 @@ let price_eur = 0; let min_block_rewards = {}; function updatePoolStats2(poolType) { + console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); let cache; let port_suffix = global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; if (typeof(poolType) !== 'undefined') { From 6cb66a80de8c2d78daf230969f089f601979cca1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Jan 2020 16:47:47 -0800 Subject: [PATCH 0789/1496] Added readers check --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 6e60878ba..580c708d5 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -19,7 +19,7 @@ let price_eur = 0; let min_block_rewards = {}; function updatePoolStats2(poolType) { - console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); + //console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); let cache; let port_suffix = global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; if (typeof(poolType) !== 'undefined') { From 4f70f3320e296a9aa54fe12df239d1699f6ccff7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 19 Jan 2020 14:02:26 +0700 Subject: [PATCH 0790/1496] Fixed block unlocker stuck --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1def3e10a..733037e37 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -623,6 +623,7 @@ function blockUnlocker() { global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { console.error("Last block header request failed!"); + setTimeout(blockUnlocker, 2*60*1000); return; } const topBlockHeight = body.height; From a15ed5ebcb2cff6cb30d97f3c11c4095d672b7d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 Jan 2020 08:40:19 -0800 Subject: [PATCH 0791/1496] Do not store alt block dumps --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 733037e37..0b67f3a86 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -704,7 +704,7 @@ function altblockUnlocker() { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, (topBlockHeight - block.anchor_height) < 120, function(status) { + preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, false/*(topBlockHeight - block.anchor_height) < 120*/, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); global.database.payReadyAltBlock(block.hash); From d3cd0cb93d9ab683b9ee6412633fbf5064067951 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 Jan 2020 09:57:27 -0800 Subject: [PATCH 0792/1496] Allow to set payment --- user_scripts/pay_set.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/user_scripts/pay_set.js b/user_scripts/pay_set.js index 9aac2136a..37f60461f 100644 --- a/user_scripts/pay_set.js +++ b/user_scripts/pay_set.js @@ -9,6 +9,7 @@ if (!argv.user) { } const user = argv.user; const pass = "password"; +const pay = global.support.decimalToCoin(argv.pay ? argv.pay : 0.003); require("../init_mini.js").init(function() { async.waterfall([ @@ -23,8 +24,8 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - global.mysql.query("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (?, ?, 0, 3000000000)", [user, pass]).then(function (rows) { - console.log("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (" + user + ", " + pass + ", 0, 3000000000)"); + global.mysql.query("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (?, ?, 0, ?)", [user, pass, pay]).then(function (rows) { + console.log("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (" + user + ", " + pass + ", 0, " + pay + ")"); callback(); }); }, From b5b50a6f19c4e8d2e7d7d26048c09b4fefc0df09 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 Jan 2020 09:58:28 -0800 Subject: [PATCH 0793/1496] Allow to set payment --- user_scripts/pay_set.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_scripts/pay_set.js b/user_scripts/pay_set.js index 37f60461f..df5247250 100644 --- a/user_scripts/pay_set.js +++ b/user_scripts/pay_set.js @@ -9,9 +9,9 @@ if (!argv.user) { } const user = argv.user; const pass = "password"; -const pay = global.support.decimalToCoin(argv.pay ? argv.pay : 0.003); require("../init_mini.js").init(function() { + const pay = global.support.decimalToCoin(argv.pay ? argv.pay : 0.003); async.waterfall([ function (callback) { global.mysql.query("SELECT * FROM users WHERE username = ?", [user]).then(function (rows) { From 9d1f7fff8567ebbc8df60d0d301076df9d3e0e3c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 Jan 2020 12:47:49 -0800 Subject: [PATCH 0794/1496] Reduced LMDB max size --- lib/local_comms.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 8ab52d75d..f0f5090b6 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -31,7 +31,7 @@ function Database(){ global.database.env.open({ path: global.config.db_storage_path, maxDbs: 10, - mapSize: 12 * 1024 * 1024 * 1024, + mapSize: 4 * 1024 * 1024 * 1024, useWritemap: true, maxReaders: 512 }); @@ -723,18 +723,18 @@ function Database(){ let txn = this.env.beginTxn(); txn.putString(this.cacheDB, 'cacheUpdate', 'cacheUpdate'); txn.commit(); - let size = 0; + //let size = 0; txn = this.env.beginTxn(); for (const [key, value] of Object.entries(cacheUpdates)) { const value_str = JSON.stringify(value); txn.putString(this.cacheDB, key, value_str); - size += key.length + value_str.length; + //size += key.length + value_str.length; } txn.del(this.cacheDB, 'cacheUpdate'); txn.commit(); - this.env.sync(function() { - console.log("Wrote " + size + " bytes to LMDB"); - }); + //this.env.sync(function() { + //console.log("Wrote " + size + " bytes to LMDB"); + //}); }; this.getOldestLockedBlockHeight = function(){ From 24044e43ecdf747fd92b7d8c027e9e86d0a5fc7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 11:24:55 -0800 Subject: [PATCH 0795/1496] Improved handling of big block lists --- lib/api.js | 10 +++++----- lib/local_comms.js | 30 ++++++++---------------------- lib/pool_stats.js | 11 +++++++++-- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/lib/api.js b/lib/api.js index 9e83af606..a0a25ef0b 100644 --- a/lib/api.js +++ b/lib/api.js @@ -283,31 +283,31 @@ app.get('/pool/ports', cache('10 seconds'), function (req, res) { app.get('/pool/blocks/:pool_type', cache('10 seconds'), function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 25; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; - res.json(global.database.getBlockList(req.params.pool_type).slice(page*limit, (page + 1) * limit)); + res.json(global.database.getBlockList(req.params.pool_type, page*limit, (page + 1) * limit)); }); app.get('/pool/altblocks/:pool_type', cache('10 seconds'), function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 25; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; - res.json(global.database.getAltBlockList(req.params.pool_type).slice(page*limit, (page + 1) * limit)); + res.json(global.database.getAltBlockList(req.params.pool_type, null, page*limit, (page + 1) * limit)); }); app.get('/pool/blocks', cache('10 seconds'), function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 25; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; - res.json(global.database.getBlockList().slice(page*limit, (page + 1) * limit)); + res.json(global.database.getBlockList(null, page*limit, (page + 1) * limit)); }); app.get('/pool/altblocks', cache('10 seconds'), function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 25; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; - res.json(global.database.getAltBlockList().slice(page*limit, (page + 1) * limit)); + res.json(global.database.getAltBlockList(null, null, page*limit, (page + 1) * limit)); }); app.get('/pool/coin_altblocks/:coin_port', cache('10 seconds'), function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 25; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; - res.json(global.database.getAltBlockList(null, parseInt(req.params.coin_port)).slice(page*limit, (page + 1) * limit)); + res.json(global.database.getAltBlockList(null, parseInt(req.params.coin_port), page*limit, (page + 1) * limit)); }); app.get('/pool/payments/:pool_type', cache('1 minute'), function (req, res) { diff --git a/lib/local_comms.js b/lib/local_comms.js index f0f5090b6..569e737b0 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -87,7 +87,7 @@ function Database(){ } }; - this.getBlockList = function(pool_type){ + this.getBlockList = function(pool_type, first, last) { debug("Getting block list"); switch (pool_type) { case 'pplns': @@ -107,16 +107,9 @@ function Database(){ this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.blockDB); - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - /* - required string hash = 1; - required int64 difficulty = 2; - required int64 shares = 3; - required int64 timestamp = 4; - required POOLTYPE poolType = 5; - required bool unlocked = 6; - required bool valid = 7; - */ + for (let found = cursor.goToFirst(), i = 0; found; ++i, found = cursor.goToNext()) { + if (first && i < first) continue; + if (last && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line let blockData = global.protos.Block.decode(data); let poolType = poolTypeStr(blockData.poolType); @@ -143,7 +136,7 @@ function Database(){ } }; - this.getAltBlockList = function(pool_type, coin_port){ + this.getAltBlockList = function(pool_type, coin_port, first, last) { debug("Getting altblock list"); switch (pool_type) { case 'pplns': @@ -163,16 +156,9 @@ function Database(){ this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - /* - required string hash = 1; - required int64 difficulty = 2; - required int64 shares = 3; - required int64 timestamp = 4; - required POOLTYPE poolType = 5; - required bool unlocked = 6; - required bool valid = 7; - */ + for (let found = cursor.goToFirst(), i = 0; found; ++i, found = cursor.goToNext()) { + if (first && i < first) continue; + if (last && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); let poolType = poolTypeStr(blockData.poolType); diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 580c708d5..ea5899920 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -18,6 +18,9 @@ let price_usd = 0; let price_eur = 0; let min_block_rewards = {}; +let blockList = (); +let altblockList = (); + function updatePoolStats2(poolType) { //console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); let cache; @@ -50,8 +53,12 @@ function updatePoolStats2(poolType) { } let port_hash = global.database.getCache('port_hash'); - let blockList = global.database.getBlockList(poolType); - let altblockList = global.database.getAltBlockList(poolType); + blockList = blockList.length ? blockList.slice(0, blockList.length > 1000 ? blockList.length - 1000 : 0).concat( + global.database.getBlockList(poolType, blockList.length - 1000)) + : global.database.getBlockList(poolType); + altblockList = altblockList.length ? blockList.slice(0, altblockList.length > 10000 ? altblockList.length - 10000 : 0).concat( + global.database.getBlockList(poolType, altblockList.length - 10000)) + : global.database.getAltBlockList(poolType); let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; if (!(global.config.daemon.port in min_block_rewards)) min_block_rewards[global.config.daemon.port] = 0; From 1878f53cda919ddda30b2abbfbf090b6caddfc43 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 11:26:27 -0800 Subject: [PATCH 0796/1496] Improved handling of big block lists --- lib/pool_stats.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index ea5899920..98392f65e 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -17,9 +17,8 @@ let price_btc = 0; let price_usd = 0; let price_eur = 0; let min_block_rewards = {}; - -let blockList = (); -let altblockList = (); +let blockList = []; +let altblockList = []; function updatePoolStats2(poolType) { //console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); From 6486927698b3a0b1c3df4a966a6989b7da9bce47 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 11:30:14 -0800 Subject: [PATCH 0797/1496] Improved handling of big block lists --- lib/pool_stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 98392f65e..2a622f3b2 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -55,8 +55,8 @@ function updatePoolStats2(poolType) { blockList = blockList.length ? blockList.slice(0, blockList.length > 1000 ? blockList.length - 1000 : 0).concat( global.database.getBlockList(poolType, blockList.length - 1000)) : global.database.getBlockList(poolType); - altblockList = altblockList.length ? blockList.slice(0, altblockList.length > 10000 ? altblockList.length - 10000 : 0).concat( - global.database.getBlockList(poolType, altblockList.length - 10000)) + altblockList = altblockList.length ? altblockList.slice(0, altblockList.length > 10000 ? altblockList.length - 10000 : 0).concat( + global.database.getAltBlockList(poolType, altblockList.length - 10000)) : global.database.getAltBlockList(poolType); let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; From d0799e0b0cb8fd60e554e5024c6e71f34308aa6c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 11:34:13 -0800 Subject: [PATCH 0798/1496] Improved handling of big block lists --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 2a622f3b2..1cbdac012 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -56,7 +56,7 @@ function updatePoolStats2(poolType) { global.database.getBlockList(poolType, blockList.length - 1000)) : global.database.getBlockList(poolType); altblockList = altblockList.length ? altblockList.slice(0, altblockList.length > 10000 ? altblockList.length - 10000 : 0).concat( - global.database.getAltBlockList(poolType, altblockList.length - 10000)) + global.database.getAltBlockList(poolType, null, altblockList.length - 10000)) : global.database.getAltBlockList(poolType); let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; From f076d6e724608b66ead9cd5a1eea8ffe01e849f0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 11:48:56 -0800 Subject: [PATCH 0799/1496] Improved handling of big block lists --- lib/local_comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 569e737b0..052345d98 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -107,7 +107,7 @@ function Database(){ this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.blockDB); - for (let found = cursor.goToFirst(), i = 0; found; ++i, found = cursor.goToNext()) { + for (let found = cursor.goToLast(), i = 0; found; ++i, found = cursor.goToPrev()) { if (first && i < first) continue; if (last && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line @@ -156,7 +156,7 @@ function Database(){ this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); - for (let found = cursor.goToFirst(), i = 0; found; ++i, found = cursor.goToNext()) { + for (let found = cursor.goToLast(), i = 0; found; ++i, found = cursor.goToPrev()) { if (first && i < first) continue; if (last && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line From 5c225381f0a867d9aefca156144776f55e10f58e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 11:50:36 -0800 Subject: [PATCH 0800/1496] Improved handling of big block lists --- lib/local_comms.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 052345d98..87109bb96 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -130,7 +130,7 @@ function Database(){ } cursor.close(); txn.abort(); - return response.sort(global.support.blockCompare); + return response; //.sort(global.support.blockCompare); } catch (e){ return response; } @@ -183,7 +183,7 @@ function Database(){ } cursor.close(); txn.abort(); - return response.sort(global.support.tsCompare); + return response; //.sort(global.support.tsCompare); } catch (e){ return response; } From a816fd83073d13a69e1a88ac36e6c63b559fffee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 12:07:23 -0800 Subject: [PATCH 0801/1496] Improved handling of big block lists --- lib/pool_stats.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 1cbdac012..15790b992 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -52,11 +52,9 @@ function updatePoolStats2(poolType) { } let port_hash = global.database.getCache('port_hash'); - blockList = blockList.length ? blockList.slice(0, blockList.length > 1000 ? blockList.length - 1000 : 0).concat( - global.database.getBlockList(poolType, blockList.length - 1000)) + blockList = blockList.length ? blockList.slice(1000).concat(global.database.getBlockList(poolType, 0, 1000)) : global.database.getBlockList(poolType); - altblockList = altblockList.length ? altblockList.slice(0, altblockList.length > 10000 ? altblockList.length - 10000 : 0).concat( - global.database.getAltBlockList(poolType, null, altblockList.length - 10000)) + altblockList = altblockList.length ? altblockList.slice(10000).concat(global.database.getAltBlockList(poolType, null, 0, 10000)) : global.database.getAltBlockList(poolType); let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; From ba123de16d478ebb1dda037f19bd79c5d79a5415 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 12:24:34 -0800 Subject: [PATCH 0802/1496] Improved handling of big block lists --- lib/pool_stats.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 15790b992..eb7708d5b 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -2,7 +2,9 @@ const debug = require("debug")("pool_stats"); const async = require("async"); -let threadName = "Worker Server "; +const threadName = "Worker Server "; +const max_blocks = 1000; +const max_altblocks = 10000; let lastBlockCheckIsFailed = {}; @@ -19,6 +21,8 @@ let price_eur = 0; let min_block_rewards = {}; let blockList = []; let altblockList = []; +let altblockFound = {}; +let altblockFoundDone = 0; function updatePoolStats2(poolType) { //console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); @@ -52,9 +56,9 @@ function updatePoolStats2(poolType) { } let port_hash = global.database.getCache('port_hash'); - blockList = blockList.length ? blockList.slice(1000).concat(global.database.getBlockList(poolType, 0, 1000)) + blockList = blockList.length ? blockList.slice(max_blocks).concat(global.database.getBlockList(poolType, 0, max_blocks)) : global.database.getBlockList(poolType); - altblockList = altblockList.length ? altblockList.slice(10000).concat(global.database.getAltBlockList(poolType, null, 0, 10000)) + altblockList = altblockList.length ? altblockList.slice(max_altblocks).concat(global.database.getAltBlockList(poolType, null, 0, max_altblocks)) : global.database.getAltBlockList(poolType); let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; @@ -133,13 +137,14 @@ function updatePoolStats2(poolType) { }, function (callback) { //debug(threadName + "Checking LMDB for altBlocksFound array for each specific port"); - let result = {}; for (let i in altblockList) { + if (i >= altblockList.length - altblockFoundDone) break; let block = altblockList[i]; - if (result.hasOwnProperty(block.port)) ++ result[block.port]; - else result[block.port] = 1; + if (result.hasOwnProperty(block.port)) ++ altblockFound[block.port]; + else altblockFound[block.port] = 1; } - return callback(null, result); + altblockFoundDone = altblockList.length; + return callback(null, altblockFound); }, function (callback) { //debug(threadName + "Checking MySQL for activePort value"); @@ -172,10 +177,12 @@ function updatePoolStats2(poolType) { function (callback) { let pending = 0; for (let i in blockList) { + if (i > max_blocks) break; const block = blockList[i]; if (block.valid === true && block.unlocked === false) pending += global.support.coinToDecimal(block.value); } for (let i in altblockList) { + if (i > max_altblocks) break; const altblock = altblockList[i]; if (altblock.valid === true && altblock.unlocked === false) pending += altblock.port in min_block_rewards ? min_block_rewards[altblock.port] : 0; } From a802b0499e808b5b37cd44046a6c09cef3776240 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 12:25:22 -0800 Subject: [PATCH 0803/1496] Improved handling of big block lists --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index eb7708d5b..3908ff305 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -140,7 +140,7 @@ function updatePoolStats2(poolType) { for (let i in altblockList) { if (i >= altblockList.length - altblockFoundDone) break; let block = altblockList[i]; - if (result.hasOwnProperty(block.port)) ++ altblockFound[block.port]; + if (altblockFound.hasOwnProperty(block.port)) ++ altblockFound[block.port]; else altblockFound[block.port] = 1; } altblockFoundDone = altblockList.length; From 3b9a03d517c1f0f150a10e93c87c23d9e1a3896f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 12:46:44 -0800 Subject: [PATCH 0804/1496] Improved handling of big block lists --- lib/local_comms.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 87109bb96..596d6c247 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -107,13 +107,13 @@ function Database(){ this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.blockDB); - for (let found = cursor.goToLast(), i = 0; found; ++i, found = cursor.goToPrev()) { - if (first && i < first) continue; + for (let found = cursor.goToLast(), i = 0; found; found = cursor.goToPrev()) { if (last && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line let blockData = global.protos.Block.decode(data); let poolType = poolTypeStr(blockData.poolType); - if (blockData.poolType === pool_type || pool_type === false) { + if (pool_type === false || blockData.poolType === pool_type) { + if (first && i++ < first) return; response.push({ ts: blockData.timestamp, hash: blockData.hash, @@ -156,13 +156,13 @@ function Database(){ this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); - for (let found = cursor.goToLast(), i = 0; found; ++i, found = cursor.goToPrev()) { - if (first && i < first) continue; + for (let found = cursor.goToLast(), i = 0; found; found = cursor.goToPrev()) { if (last && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); let poolType = poolTypeStr(blockData.poolType); - if (blockData.poolType === pool_type || pool_type === false && (!coin_port || blockData.port === coin_port)) { + if ((pool_type === false || blockData.poolType === pool_type) && (!coin_port || blockData.port === coin_port)) { + if (first && i++ < first) return; response.push({ ts: blockData.timestamp, hash: blockData.hash, From 899f3b03109f1439ab4fc7f467e6370eabce211c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Feb 2020 12:55:23 -0800 Subject: [PATCH 0805/1496] Improved handling of big block lists --- lib/local_comms.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 596d6c247..06f7d9c4c 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -108,12 +108,12 @@ function Database(){ let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.blockDB); for (let found = cursor.goToLast(), i = 0; found; found = cursor.goToPrev()) { - if (last && i >= last) break; + if (typeof last !== 'undefined' && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line let blockData = global.protos.Block.decode(data); let poolType = poolTypeStr(blockData.poolType); if (pool_type === false || blockData.poolType === pool_type) { - if (first && i++ < first) return; + if (typeof first !== 'undefined' && i++ < first) return; response.push({ ts: blockData.timestamp, hash: blockData.hash, @@ -157,12 +157,12 @@ function Database(){ let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); for (let found = cursor.goToLast(), i = 0; found; found = cursor.goToPrev()) { - if (last && i >= last) break; + if (typeof last !== 'undefined' && i >= last) break; cursor.getCurrentBinary(function (key, data) { // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); let poolType = poolTypeStr(blockData.poolType); if ((pool_type === false || blockData.poolType === pool_type) && (!coin_port || blockData.port === coin_port)) { - if (first && i++ < first) return; + if (typeof first !== 'undefined' && i++ < first) return; response.push({ ts: blockData.timestamp, hash: blockData.hash, From 686d60a9dd84940aa8bb8df8ca73b65bdd07ecea Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 25 Feb 2020 09:14:10 -1000 Subject: [PATCH 0806/1496] Fix for tor --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index a9357d206..56edf1452 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -119,7 +119,7 @@ function messageHandler(message) { if (cluster.isMaster) { sendToWorkers(message); } else { - bannedIPs[message.data] = 1; + if (message.data != "127.0.0.1") bannedIPs[message.data] = 1; } break; case 'newBlockTemplate': From d416dd5b2e0a99362be3624f8543f99a9e5cf473 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 26 Feb 2020 13:17:33 -1000 Subject: [PATCH 0807/1496] Fixed XTA --- lib/coins/xmr.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index cd7c58ae9..f08b7d01b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -34,6 +34,7 @@ const port2coin = { "48782": "LTHN", "19734": "SUMO", "13007": "IRD", + "13102": "XTA", "19994": "ARQ", "33124": "XTNC", "19281": "XMV", @@ -55,6 +56,7 @@ const port2blob_num = { "48782": 0, // LTHN "19734": 0, // SUMO "13007": 2, // IRD + "13102": 0, // XTA "19994": 0, // ARQ "19281": 8, // XMV "33124": 9, // XTNC @@ -67,6 +69,7 @@ const port2algo = { "11898": "argon2/chukwa", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD + "13102": "rx/0", // XTA "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR "18981": "cn/rwz", // Graft @@ -209,7 +212,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 22023 || port == 33124 || port == 24182 || port == 9231) { // Loki / XtendCash / TUBE / Equilibria has reward as zero transaction + if (port == 22023 || port == 33124 || port == 24182 || port == 13102) { // Loki / XtendCash / TUBE / Italocoin has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Wed, 26 Feb 2020 13:18:14 -1000 Subject: [PATCH 0808/1496] Added XTA coin --- README.md | 1 + deployment/base.sql | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index ac3344c00..15ec0db3f 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,7 @@ If you'd like to make a one time donation, the addresses are as follows: * ARQ - ```ar4Ha6ZQCkKRhkKQLfexv7VZQM2MhUmMmU9hmzswCPK4T3o2rbPKZM1GxEoYg4AFQsh57PsEets7sbpU958FAvxo2RkkTQ1gE``` * XWP - ```fh4MCJrakhWGoS6Meqp6UxGE1GNfAjKaRdPjW36rTffDiqvEq2HWEKZhrbYRw7XJb3CXxkjL3tcYGTT39m5qgjvk1ap4bVu1R``` * XEQ - ```Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb``` +* XTA - ```ipN5cNhm7RXAGACP4ZXki4afT3iJ1A6Ka5U4cswE6fBPDcv8JpivurBj3vu1bXwPyb8KZEGsFUYMmToFG4N9V9G72X4WpAQ8L``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index 3350615e6..228ce83ea 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -220,6 +220,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMV', '0', 'int', 'MoneroV coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXWP', '0', 'int', 'Swap coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXEQ', '0', 'int', 'Equilibria coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTA', '0', 'int', 'Italocoin coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -239,6 +240,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMV', '0', 'float', 'MoneroV algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXWP', '0', 'float', 'Swap algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXEQ', '0', 'float', 'Equilibria algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTA', '0', 'float', 'Italocoin algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -293,6 +295,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13007', '', 'string', 'Address to mine to for 13007 (Iridium) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19994', '', 'string', 'Address to mine to for 19994 (ArqMa) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19950', '', 'string', 'Address to mine to for 19950 (Swap) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13102', '', 'string', 'Address to mine to for 13102 (Italocoin) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', 'Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); From c0cd6f0d763f7548e9559131f0218f309835b8c3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 26 Feb 2020 13:57:12 -1000 Subject: [PATCH 0809/1496] Fixed for XTA --- lib/coins/xmr.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f08b7d01b..090f9b893 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -380,11 +380,15 @@ function Coin(data){ if (is_mm) { this.reserved_offset = found_reserved_offset; } else { - // here we are OK with +1 difference because we put extra byte into pool_nonce_size - if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { - console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + blob); + if (template.reserved_offset) { + // here we are OK with +1 difference because we put extra byte into pool_nonce_size + if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { + console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + blob); + } + this.reserved_offset = template.reserved_offset; + } else { + this.reserved_offset = found_reserved_offset; } - this.reserved_offset = template.reserved_offset; } } else { console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in block " + ": " + blob); From ffe457f381d60f958c925b280c8fd882db26f917 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 27 Feb 2020 11:49:30 -1000 Subject: [PATCH 0810/1496] Fixed payment race condition --- lib/blockManager.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 0b67f3a86..59546c244 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -738,6 +738,10 @@ function altblockUnlocker() { } function blockPayments(block, cb) { + if (paymentInProgress) { + console.error("Skipping payment as there's a payment in progress"); + return cb(); + } switch (block.poolType) { case global.protos.POOLTYPE.PPS: // PPS is paid out per share find per block, so this is handled in the main block-find loop. @@ -791,10 +795,10 @@ function altblockPayments(block, cb) { if (err === null && block.height === header.height && block.value >= header.reward /*&& block.difficulty === header.difficulty*/){ //global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { //if (anchor_err === null){ - //if (paymentInProgress) { - //console.error("Skipping payment as there's a payment in progress"); - //return cb(); - //} + if (paymentInProgress) { + console.error("Skipping payment as there's a payment in progress"); + return cb(); + } paymentInProgress = true; doPPLNSPayments(block.hash, block.pay_value, function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); From 068e778b020e8d07dad82fa73ba5440a653f3929 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Mar 2020 10:45:21 -0800 Subject: [PATCH 0811/1496] No not check recent updates --- manage_scripts/user_del_force.js | 113 +++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 manage_scripts/user_del_force.js diff --git a/manage_scripts/user_del_force.js b/manage_scripts/user_del_force.js new file mode 100644 index 000000000..d2671310f --- /dev/null +++ b/manage_scripts/user_del_force.js @@ -0,0 +1,113 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.user) { + console.error("Please specify user address to delete"); + process.exit(1); +} +const user = argv.user; + +require("../init_mini.js").init(function() { + const parts = user.split("."); + const address = parts.length === 1 ? user : parts[0]; + const payment_id = parts.length === 2 ? parts[1] : null; + + console.log("Address: " + address); + console.log("PaymentID: " + payment_id); + console.log("Max payment to remove: " + global.config.payout.walletMin); + let rows2remove = 0; + + const where_str = payment_id === null ? "payment_address = '" + address + "' AND payment_id IS NULL" + : "payment_address = '" + address + "' AND payment_id = '" + payment_id + "'"; + + async.waterfall([ + function (callback) { + global.mysql.query("SELECT * FROM users WHERE username = ?", [user]).then(function (rows) { + if (rows.length > 1) { + console.error("Too many users were selected!"); + process.exit(1); + } + console.log("Found rows in users table: " + rows.length); + rows2remove += rows.length; + callback(); + }); + }, + function (callback) { + global.mysql.query("SELECT * FROM balance WHERE " + where_str).then(function (rows) { + if (rows.length > 1) { + console.error("Too many users were selected!"); + process.exit(1); + } + if (rows.length === 1 && rows[0].amount >= global.support.decimalToCoin(global.config.payout.walletMin)) { + console.error("Too big payment left: " + global.support.coinToDecimal(rows[0].amount)); + process.exit(1); + } + console.log("Found rows in balance table: " + rows.length); + rows2remove += rows.length; + callback(); + }); + }, + function (callback) { + global.mysql.query("SELECT * FROM payments WHERE " + where_str).then(function (rows) { + console.log("Found rows in payments table: " + rows.length); + rows2remove += rows.length; + callback(); + }); + }, + function (callback) { + const address = global.database.getCache(user); + const stats = global.database.getCache("stats:" + user); + const history = global.database.getCache("history:" + user); + const identifiers = global.database.getCache("identifiers:" + user); + + if (address != false) console.log("Cache key is not empty: " + user); + if (stats != false) console.log("Cache key is not empty: " + "stats:" + user); + if (history != false) console.log("Cache key is not empty: " + "history:" + user); + if (identifiers != false) console.log("Cache key is not empty: " + "identifiers:" + user); + callback(); + + }, + function (callback) { + if (!rows2remove) { // to check that we accidently do not remove something usefull from LMDB cache + console.error("User was not found in SQL. Refusing to proceed to LMDB cache cleaning"); + process.exit(1); + } + callback(); + + }, + function (callback) { + global.mysql.query("DELETE FROM users WHERE username = ?", [user]).then(function (rows) { + console.log("DELETE FROM users WHERE username = " + user); + callback(); + }); + }, + function (callback) { + global.mysql.query("DELETE FROM balance WHERE " + where_str, [user]).then(function (rows) { + console.log("DELETE FROM balance WHERE " + where_str); + callback(); + }); + }, + function (callback) { + global.mysql.query("DELETE FROM payments WHERE " + where_str, [user]).then(function (rows) { + console.log("DELETE FROM payments WHERE " + where_str); + callback(); + }); + }, + function (callback) { + console.log("Deleting LMDB cache keys"); + let txn = global.database.env.beginTxn(); + if (global.database.getCache(user)) txn.del(global.database.cacheDB, user); + if (global.database.getCache("stats:" + user)) txn.del(global.database.cacheDB, "stats:" + user); + if (global.database.getCache("history:" + user)) txn.del(global.database.cacheDB, "history:" + user); + if (global.database.getCache("identifiers:" + user)) txn.del(global.database.cacheDB, "identifiers:" + user); + txn.commit(); + callback(); + }, + function (callback) { + console.log("DONE"); + process.exit(0); + } + ]); +}); From c75e960d913ddf48049a4b59e7bf294b9a66f2fe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Mar 2020 11:44:58 -0800 Subject: [PATCH 0812/1496] Dero support --- README.md | 1 + deployment/base.sql | 3 +++ lib/coins/xmr.js | 10 ++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 15ec0db3f..89e120a9e 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XWP - ```fh4MCJrakhWGoS6Meqp6UxGE1GNfAjKaRdPjW36rTffDiqvEq2HWEKZhrbYRw7XJb3CXxkjL3tcYGTT39m5qgjvk1ap4bVu1R``` * XEQ - ```Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb``` * XTA - ```ipN5cNhm7RXAGACP4ZXki4afT3iJ1A6Ka5U4cswE6fBPDcv8JpivurBj3vu1bXwPyb8KZEGsFUYMmToFG4N9V9G72X4WpAQ8L``` +* DERO - ```dERokvcrnuWH1ai1QmZQc9cgxrLwE3rX3TbhdrnLmi3BVZmf197qd5FaFqmPMp5dZ3igXfVQwUUMgTSjpVKDtUeb6DT2xp64XJ``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index 228ce83ea..360eb3387 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -221,6 +221,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXWP', '0', 'int', 'Swap coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXEQ', '0', 'int', 'Equilibria coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTA', '0', 'int', 'Italocoin coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortDERO', '0', 'int', 'Dero coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -241,6 +242,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXWP', '0', 'float', 'Swap algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXEQ', '0', 'float', 'Equilibria algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTA', '0', 'float', 'Italocoin algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorDERO', '0', 'float', 'Dero algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -296,6 +298,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19994', '', 'string', 'Address to mine to for 19994 (ArqMa) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19950', '', 'string', 'Address to mine to for 19950 (Swap) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13102', '', 'string', 'Address to mine to for 13102 (Italocoin) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20206', '', 'string', 'Address to mine to for 20206 (Dero) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', 'Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 090f9b893..ec82fcd9e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -40,6 +40,7 @@ const port2coin = { "19281": "XMV", "19950": "XWP", "9231" : "XEQ", + "20206": "DERO", }; const port2blob_num = { "11181": 7, // AEON @@ -62,6 +63,7 @@ const port2blob_num = { "33124": 9, // XTNC "19950": 8, // XWP "9231" : 5, // XEQ + "20206": 0, // DERO }; const port2algo = { @@ -85,6 +87,7 @@ const port2algo = { "38081": "cn/half", // MSR "48782": "cn/r", // Lethean "9231" : "cn/gpu", // XEQ + "20206": "astrobwt", // DERO }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -191,8 +194,8 @@ function Coin(data){ }; this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ - // TRTL/IRD does not get getblock LTHN / AEON have composite tx - if (port == 11898 || port == 13007 || port == 48782 || port == 11181) { + // TRTL/IRD does not get getblock LTHN / AEON / DERO have composite tx + if (port == 11898 || port == 13007 || port == 48782 || port == 11181 || port == 20206) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); @@ -484,6 +487,8 @@ function Coin(data){ if ("c29s" in algos_perf) coin_perf["XTNC"] = coin_perf["XWP"] = algos_perf["c29s"]; if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; + if ("astrobwt" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt"]; + if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; @@ -521,6 +526,7 @@ function Coin(data){ case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala + case 20206: return multiHashing.astrobwt(convertedBlob); // Dero case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero From 24e844b85436fa99d1fcc4ab4751c547e4be0702 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Mar 2020 12:29:29 -0800 Subject: [PATCH 0813/1496] Updated astrobwt support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ec82fcd9e..1cc9c6add 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -526,7 +526,7 @@ function Coin(data){ case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala - case 20206: return multiHashing.astrobwt(convertedBlob); // Dero + case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero From 69d83891c2fae9090b5067f6aa70da37e2ee6db3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Mar 2020 15:03:33 -0800 Subject: [PATCH 0814/1496] Dero support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0df441d4..7a13eac4e 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v16.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.0" } } From 7cd397797b09e5ec43d79b4ea7d278d0f9e9f050 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Mar 2020 20:59:57 -0800 Subject: [PATCH 0815/1496] Fixed for DERO --- lib/coins/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1cc9c6add..2da44d871 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -394,7 +394,8 @@ function Coin(data){ } } } else { - console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in block " + ": " + blob); + // exception for DERO + if (this.port != 20206) console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in block " + ": " + blob); this.reserved_offset = template.reserved_offset; } From 3723aa1c304e0a868726778de955abf6f5dd7935 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Mar 2020 23:39:04 -0800 Subject: [PATCH 0816/1496] Fixed for DERO --- lib/coins/xmr.js | 67 +++++++++++++++++++++++++++++------------------- lib/pool.js | 5 +++- 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2da44d871..2fbc7c6fe 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -63,7 +63,7 @@ const port2blob_num = { "33124": 9, // XTNC "19950": 8, // XWP "9231" : 5, // XEQ - "20206": 0, // DERO + "20206": 10, // DERO }; const port2algo = { @@ -307,12 +307,16 @@ function Coin(data){ this.portBlobType = function(port, version) { return port2blob_num[port]; } - this.blobTypeGrin = function(port_blob_num) { return port_blob_num == 8 || port_blob_num == 9; } + this.blobTypeGrin = function(blob_type_num) { return blob_type_num == 8 || blob_type_num == 9; } + + this.blobTypeDero = function(blob_type_num) { return blob_type_num == 10; } this.convertBlob = function(blobBuffer, port){ + const blob_type_num = this.portBlobType(port, blobBuffer[0]); + if (this.blobTypeDero(blob_type_num)) return blobBuffer; let blob; try { - blob = cnUtil.convert_blob(blobBuffer, this.portBlobType(port, blobBuffer[0])); + blob = cnUtil.convert_blob(blobBuffer, blob_type_num); } catch (e) { const err_str = "Can't do port " + port + " convert_blob " + blobBuffer.toString('hex') + " with blob type " + this.portBlobType(port, blobBuffer[0]) + ": " + e; console.error(err_str); @@ -323,7 +327,11 @@ function Coin(data){ }; this.constructNewBlob = function(blockTemplate, NonceBuffer, port, ring){ - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port, blockTemplate[0]), ring); + const blob_type_num = this.portBlobType(port, blockTemplate[0]); + if (this.blobTypeDero(blob_type_num)) { + NonceBuffer.copy(blockTemplate, 39, 0, 4); + return blockTemplate; + } else return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, blob_type_num, ring); }; this.constructMMParentBlockBlob = function(parentTemplateBuffer, port, childTemplateBuffer) { @@ -368,35 +376,39 @@ function Coin(data){ this.child_template_buffer = template.child_template_buffer; } - const blob = is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob; + const is_dero = this.blobTypeDero(port2blob_num[this.port]); + const blob = is_dero ? template.blockhashing_blob : (is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob); this.idHash = crypto.createHash('md5').update(blob).digest('hex'); // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); - const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; - const found_reserved_offset_template = blob.indexOf(template_hex); - - if (found_reserved_offset_template !== -1) { - const found_reserved_offset = (found_reserved_offset_template >> 1) + 2; - if (is_mm) { - this.reserved_offset = found_reserved_offset; - } else { - if (template.reserved_offset) { - // here we are OK with +1 difference because we put extra byte into pool_nonce_size - if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { - console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + blob); - } - this.reserved_offset = template.reserved_offset; - } else { - this.reserved_offset = found_reserved_offset; - } - } - } else { - // exception for DERO - if (this.port != 20206) console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in block " + ": " + blob); - this.reserved_offset = template.reserved_offset; + if (!is_dero) { + const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; + const found_reserved_offset_template = blob.indexOf(template_hex); + + if (found_reserved_offset_template !== -1) { + const found_reserved_offset = (found_reserved_offset_template >> 1) + 2; + if (is_mm) { + this.reserved_offset = found_reserved_offset; + } else { + if (template.reserved_offset) { + // here we are OK with +1 difference because we put extra byte into pool_nonce_size + if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { + console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + blob); + } + this.reserved_offset = template.reserved_offset; + } else { + this.reserved_offset = found_reserved_offset; + } + } + } else { + console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in block " + ": " + blob); + this.reserved_offset = template.reserved_offset; + } + } else { // exception for DERO + this.reserved_offset = template.reserved_offset + 1; } if (!("prev_hash" in template)) { // Get prev_hash from blob @@ -563,6 +575,7 @@ function Coin(data){ case 12211: return "cryptonote_ryo"; // RYO case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap + case 20206: return "cryptonote_dero"; // Dero case 22023: return "cryptonote_loki"; // LOKI case 33124: return "cryptonote_xtnc"; // XtendCash case 38081: return "cryptonote3"; // MSR diff --git a/lib/pool.js b/lib/pool.js index 56edf1452..f553afe2a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1401,7 +1401,10 @@ function invalid_share(miner) { } function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, isRetrySubmitBlock) { - global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [shareBuffer.toString('hex')], function (rpcResult) { + const params = global.coinFuncs.blobTypeDero(job.blob_type_num) ? + [ blockTemplate.blocktemplate_blob, shareBuffer.toString('hex') ] : + [ shareBuffer.toString('hex') ]; + global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', params, function (rpcResult) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); From a5a3e9c689b08dfe00e653b0c18fa726f45e57c1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Mar 2020 23:47:23 -0800 Subject: [PATCH 0817/1496] Fixed for DERO --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2fbc7c6fe..04fee2610 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -376,7 +376,7 @@ function Coin(data){ this.child_template_buffer = template.child_template_buffer; } - const is_dero = this.blobTypeDero(port2blob_num[this.port]); + const is_dero = global.coinFuncs.blobTypeDero(port2blob_num[this.port]); const blob = is_dero ? template.blockhashing_blob : (is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob); this.idHash = crypto.createHash('md5').update(blob).digest('hex'); From 9d94cd8045d768589933a7f7ac13934c9a741273 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 00:34:10 -0800 Subject: [PATCH 0818/1496] Debug change --- lib/support.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/support.js b/lib/support.js index fc7a94454..0926f4b93 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,6 +248,7 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } + if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -258,6 +259,7 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } + if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From 33579ad9e29f6218c0fd7b81f1a86ac88d5fa5b6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 00:35:25 -0800 Subject: [PATCH 0819/1496] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 0926f4b93..8dc7e4b46 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,7 +248,7 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(100.0); + //if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -259,7 +259,7 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(20206); + //if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From cf64da1a7e054552f56da560e72fb6af00bdab0d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 01:01:43 -0800 Subject: [PATCH 0820/1496] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 8dc7e4b46..0926f4b93 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,7 +248,7 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } - //if (coin == "DERO") return callback(100.0); + if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -259,7 +259,7 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } - //if (coin == "DERO") return callback(20206); + if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From 1d7d1f021f2f1cea3b8fce7ca88905b5060de491 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 01:01:46 -0800 Subject: [PATCH 0821/1496] Debug change --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index f553afe2a..ad2758e94 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1551,10 +1551,13 @@ function processShare(miner, job, blockTemplate, params) { return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (port == 20206) console.error("!1: " + shareBuffer.toString('hex')); if (shareBuffer === null) return invalid_share(miner); const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); + if (port == 20206) console.error("!2a: " + hash.toString('hex')); + if (port == 20206) console.error("!2b: " + resultHash); if (hash.toString('hex') !== resultHash) { report_miner_share(miner, job); return invalid_share(miner); From e5f81a312669b509eaef7bba8f402372d0b8ce37 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 01:03:17 -0800 Subject: [PATCH 0822/1496] Debug change --- lib/pool.js | 6 +++--- lib/support.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ad2758e94..a2cb319ad 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1551,13 +1551,13 @@ function processShare(miner, job, blockTemplate, params) { return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (port == 20206) console.error("!1: " + shareBuffer.toString('hex')); + //if (port == 20206) console.error("!1: " + shareBuffer.toString('hex')); if (shareBuffer === null) return invalid_share(miner); const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); - if (port == 20206) console.error("!2a: " + hash.toString('hex')); - if (port == 20206) console.error("!2b: " + resultHash); + //if (port == 20206) console.error("!2a: " + hash.toString('hex')); + //if (port == 20206) console.error("!2b: " + resultHash); if (hash.toString('hex') !== resultHash) { report_miner_share(miner, job); return invalid_share(miner); diff --git a/lib/support.js b/lib/support.js index 0926f4b93..8dc7e4b46 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,7 +248,7 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(100.0); + //if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -259,7 +259,7 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(20206); + //if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From 37dc020cce52ed342007768011b9d7610b6b95cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 02:15:59 -0800 Subject: [PATCH 0823/1496] Fixed AstroBWT --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a13eac4e..1abe2873f 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.1" } } From 8a8b769e6e1a451e9cf5f8764f76ae0bd6912250 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 02:18:10 -0800 Subject: [PATCH 0824/1496] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 8dc7e4b46..0926f4b93 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,7 +248,7 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } - //if (coin == "DERO") return callback(100.0); + if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -259,7 +259,7 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } - //if (coin == "DERO") return callback(20206); + if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From 8cfca16a613cc7bfdf3b6775df3e3ed39fb51d1c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 02:24:54 -0800 Subject: [PATCH 0825/1496] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 0926f4b93..8dc7e4b46 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,7 +248,7 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(100.0); + //if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -259,7 +259,7 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(20206); + //if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From 32cb02542b694f59a62d575d283381c776c3aa50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 02:30:41 -0800 Subject: [PATCH 0826/1496] Fixed AstroBWT --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1abe2873f..2b1cfc7ec 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.2" } } From 174ec41a1989a5ea18aae24849185bbac749e8d4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 02:31:01 -0800 Subject: [PATCH 0827/1496] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 8dc7e4b46..0926f4b93 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,7 +248,7 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } - //if (coin == "DERO") return callback(100.0); + if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -259,7 +259,7 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } - //if (coin == "DERO") return callback(20206); + if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From 52f1661aba3b74a82ea222f09bee3a532606aed8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 02:34:27 -0800 Subject: [PATCH 0828/1496] Debug change --- lib/pool.js | 3 --- lib/support.js | 2 -- 2 files changed, 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a2cb319ad..f553afe2a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1551,13 +1551,10 @@ function processShare(miner, job, blockTemplate, params) { return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - //if (port == 20206) console.error("!1: " + shareBuffer.toString('hex')); if (shareBuffer === null) return invalid_share(miner); const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); - //if (port == 20206) console.error("!2a: " + hash.toString('hex')); - //if (port == 20206) console.error("!2b: " + resultHash); if (hash.toString('hex') !== resultHash) { report_miner_share(miner, job); return invalid_share(miner); diff --git a/lib/support.js b/lib/support.js index 0926f4b93..fc7a94454 100644 --- a/lib/support.js +++ b/lib/support.js @@ -248,7 +248,6 @@ function getCoinHashFactor(coin, callback) { console.error("Can't get config.daemon.coinHashFactor" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(100.0); callback(parseFloat(rows[0].item_value)); }); } @@ -259,7 +258,6 @@ function getActivePort(coin, callback) { console.error("Can't get config.daemon.activePort" + coin + " value"); return callback(null); } - if (coin == "DERO") return callback(20206); callback(parseInt(rows[0].item_value)); }); } From 238aca4ef81878746ecd771637df6b438287105e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 03:55:11 -0800 Subject: [PATCH 0829/1496] Fixed DERO block id --- lib/coins/xmr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 04fee2610..c6fd423fc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -345,7 +345,9 @@ function Coin(data){ }; this.getBlockID = function(blockBuffer, port){ - return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blockBuffer[0])); + const blob_type_num = this.portBlobType(port, blobBuffer[0]); + if (this.blobTypeDero(blob_type_num)) return crypto.createHash('md5').update(blockBuffer).digest(); + return cnUtil.get_block_id(blockBuffer, blob_type_num); }; this.BlockTemplate = function(template) { From c4a3babfad4687ab6ecdd7501e59bac58da78be9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 04:04:08 -0800 Subject: [PATCH 0830/1496] Fixed DERO block id --- lib/coins/xmr.js | 4 +--- lib/pool.js | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c6fd423fc..b4ff60184 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -345,9 +345,7 @@ function Coin(data){ }; this.getBlockID = function(blockBuffer, port){ - const blob_type_num = this.portBlobType(port, blobBuffer[0]); - if (this.blobTypeDero(blob_type_num)) return crypto.createHash('md5').update(blockBuffer).digest(); - return cnUtil.get_block_id(blockBuffer, blob_type_num); + return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blobBuffer[0])); }; this.BlockTemplate = function(template) { diff --git a/lib/pool.js b/lib/pool.js index f553afe2a..e261680d4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1444,7 +1444,8 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi } } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { // Success! Submitted a block without an issue. - const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); + const blockFastHash = global.coinFuncs.blobTypeDero(global.coinFuncs.portBlobType(port, shareBuffer[0])) ? + rpcResult.blid : global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", block hex: \n" + shareBuffer.toString('hex') From 002ba71ae0c5d525449fcfe335db2a2d106af89e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 04:06:35 -0800 Subject: [PATCH 0831/1496] Fixed DERO block id --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e261680d4..ffd3bd6c5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1444,7 +1444,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi } } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { // Success! Submitted a block without an issue. - const blockFastHash = global.coinFuncs.blobTypeDero(global.coinFuncs.portBlobType(port, shareBuffer[0])) ? + const blockFastHash = global.coinFuncs.blobTypeDero(global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0])) ? rpcResult.blid : global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + From 6dc59d7d9941d09d00eba9125aeef4a58fb64056 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 04:18:06 -0800 Subject: [PATCH 0832/1496] Fixed DERO block id --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b4ff60184..04fee2610 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -345,7 +345,7 @@ function Coin(data){ }; this.getBlockID = function(blockBuffer, port){ - return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blobBuffer[0])); + return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blockBuffer[0])); }; this.BlockTemplate = function(template) { From a9c3dcfb8f35cd841b79a231a85502fa56c26c94 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 04:50:20 -0800 Subject: [PATCH 0833/1496] Fixed DERO block id --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ffd3bd6c5..2bfd41ffe 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1445,7 +1445,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.blobTypeDero(global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0])) ? - rpcResult.blid : global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); + rpcResult.result.blid : global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", block hex: \n" + shareBuffer.toString('hex') From 6ffabbb162d5790d13ef6f9280895abf5603e12b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 09:01:21 -0800 Subject: [PATCH 0834/1496] Fixed DERO --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2bfd41ffe..a2ff9348a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -284,6 +284,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.port = parseInt(port); template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; + if ("topoheight" in rpc_template) template.height = rpc_template.topoheight; // use topoheight for DERO if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); @@ -307,9 +308,8 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { - const rpc_template = rpcResponse.result; - const template = process_rpc_template(rpc_template, coin, activePort, coinHashFactor, isHashFactorChange); - debug(threadName + "New block template found at " + rpc_template.height + " height"); + const template = process_rpc_template(rpcResponse.result, coin, activePort, coinHashFactor, isHashFactorChange); + debug(threadName + "New block template found at " + template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); setNewBlockTemplate(template); From 9c0738e1cdb2236621652edfbbc112de3eef5a65 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 09:03:29 -0800 Subject: [PATCH 0835/1496] Revert "Fixed DERO" This reverts commit 6ffabbb162d5790d13ef6f9280895abf5603e12b. --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a2ff9348a..2bfd41ffe 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -284,7 +284,6 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.port = parseInt(port); template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; - if ("topoheight" in rpc_template) template.height = rpc_template.topoheight; // use topoheight for DERO if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); @@ -308,8 +307,9 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { - const template = process_rpc_template(rpcResponse.result, coin, activePort, coinHashFactor, isHashFactorChange); - debug(threadName + "New block template found at " + template.height + " height"); + const rpc_template = rpcResponse.result; + const template = process_rpc_template(rpc_template, coin, activePort, coinHashFactor, isHashFactorChange); + debug(threadName + "New block template found at " + rpc_template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); setNewBlockTemplate(template); From 622917f2802060bb9af18148c9f95415f5b04dd3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 09:04:28 -0800 Subject: [PATCH 0836/1496] Revert "Revert "Fixed DERO"" This reverts commit 9c0738e1cdb2236621652edfbbc112de3eef5a65. --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2bfd41ffe..a2ff9348a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -284,6 +284,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.port = parseInt(port); template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; + if ("topoheight" in rpc_template) template.height = rpc_template.topoheight; // use topoheight for DERO if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); @@ -307,9 +308,8 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { - const rpc_template = rpcResponse.result; - const template = process_rpc_template(rpc_template, coin, activePort, coinHashFactor, isHashFactorChange); - debug(threadName + "New block template found at " + rpc_template.height + " height"); + const template = process_rpc_template(rpcResponse.result, coin, activePort, coinHashFactor, isHashFactorChange); + debug(threadName + "New block template found at " + template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); setNewBlockTemplate(template); From 55f5877ee1d4b8bdd4875cc8f2ce6a25c8e622b2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 09:59:06 -0800 Subject: [PATCH 0837/1496] Fixed AstroBWT --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b1cfc7ec..ad0742d3f 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.2" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.3" } } From 5add963ea5ba3a642f55732d09c6fb28ec89370d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 14:08:26 -0800 Subject: [PATCH 0838/1496] Removed topoheight usage --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index a2ff9348a..aa22c4958 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -284,7 +284,6 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.port = parseInt(port); template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; - if ("topoheight" in rpc_template) template.height = rpc_template.topoheight; // use topoheight for DERO if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); From 60aadfc6b42af591920014b114870c29ea3f269d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 14:13:35 -0800 Subject: [PATCH 0839/1496] Do not use block height --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 59546c244..0dd34ee44 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -691,7 +691,7 @@ function altblockUnlocker() { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { + global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { const is_valid_request = (err === null); if (!is_valid_request) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); From 626a8ceca5f8d7a2b65acf0e42b8dd985d1bcd4d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 15:24:14 -0800 Subject: [PATCH 0840/1496] Async lists --- lib/blockManager.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 0dd34ee44..7964d1502 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -692,14 +692,15 @@ function altblockUnlocker() { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { - const is_valid_request = (err === null); - if (!is_valid_request) { + if (err !== null) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); - } - if (is_valid_request && body.hash !== block.hash) { - global.database.invalidateAltBlock(block.id); - console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); - return next(); + global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { + if (err === null && body.hash !== block.hash) { + global.database.invalidateAltBlock(block.id); + console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); + } + return next(); + }); } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ @@ -716,7 +717,7 @@ function altblockUnlocker() { return next(); } }); - } else if (is_valid_request && (!is_pplns_block || block.pay_ready === true)) { + } else if (!is_pplns_block || block.pay_ready === true) { if (block.pay_value !== 0) { altblockPayments(block, function() { return next(); } ); } else { From 4ee0fe7699bad3001c7d26a470d73d5ed27f40ac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 15:36:12 -0800 Subject: [PATCH 0841/1496] Alloy 0 MSR blocks --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 04fee2610..0b84dd5c0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -234,7 +234,7 @@ function Coin(data){ const reward = body2.result.transfer.amount; if (reward !== reward_check || reward == 0) { - if (port == 38081 && reward < reward_check && reward != 0) { // MSR can have uncle block reward here + if (port == 38081 && reward < reward_check /*&& reward != 0*/) { // MSR can have uncle block reward here } else { console.error(port + ": block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); return callback(true, body); From f6b154af2a83db76dcdc6c94346f2e400622a042 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 15:59:40 -0800 Subject: [PATCH 0842/1496] More debug --- lib/blockManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 7964d1502..75e015a3c 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -691,9 +691,10 @@ function altblockUnlocker() { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; + console.log(block.port + ": " + block.hash); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { if (err !== null) { - console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); + console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { if (err === null && body.hash !== block.hash) { global.database.invalidateAltBlock(block.id); From 463d71eb45e37af3ec74022ce96d7009c9427fd1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 16:04:56 -0800 Subject: [PATCH 0843/1496] More debug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 75e015a3c..c5d997893 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -691,7 +691,7 @@ function altblockUnlocker() { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - console.log(block.port + ": " + block.hash); + //console.log(block.port + ": " + block.hash); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { if (err !== null) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); From fd58d1e3e02bb6204f0199d5c17ce1f6380c9d90 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 16:18:06 -0800 Subject: [PATCH 0844/1496] More debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0b84dd5c0..623287d84 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -226,7 +226,7 @@ function Coin(data){ } const miner_tx_hash = body.result.miner_tx_hash == "" ? body.result.block_header.miner_tx_hash : body.result.miner_tx_hash; - if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWallet(port + 1, "get_transfer_by_txid", {"txid": miner_tx_hash}, function (body2) { + if (is_our_block && body.result.hasOwnProperty('miner_tx_hash')) global.support.rpcPortWalletShort(port + 1, "get_transfer_by_txid", {"txid": miner_tx_hash}, function (body2) { if (typeof(body2) === 'undefined' || body2.hasOwnProperty('error') || !body2.hasOwnProperty('result') || !body2.result.hasOwnProperty('transfer') || !body2.result.transfer.hasOwnProperty('amount')) { console.error(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); From b38081075a8c79117d7a9eb2eb409541dd335750 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 18:06:22 -0800 Subject: [PATCH 0845/1496] Moved to CMC pro API --- deployment/base.sql | 1 + lib/pool_stats.js | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 360eb3387..b24f25d50 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -301,6 +301,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20206', '', 'string', 'Address to mine to for 20206 (Dero) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', 'Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunURL', '', 'string', 'MailGun URL for notifications'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunNoCert', 'false', 'bool', 'Disable certificate check for MailGun'); diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 3908ff305..d4d3f745e 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -1,4 +1,4 @@ -"use strict"; +"use strict"; ^ const debug = require("debug")("pool_stats"); const async = require("async"); @@ -24,6 +24,29 @@ let altblockList = []; let altblockFound = {}; let altblockFoundDone = 0; +function get_cmc_price(symbol, callback) { + const COIN = global.config.coin.name; + global.support.https_get("https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + COIN + "&convert=" + symbol + "&CMC_PRO_API_KEY=" + global.config.general.cmcKey, function (res) { + return callback( + res instanceof Object && "data" in res && COIN in res.data && "quote" in res.data[COIN] && symbol in res.data[COIN].quote + ? parseFloat(res.data[COIN].quote[symbol].price) : 0 + ); + }); +} + +function get_cmc(callback) { + get_cmc_price("USD", function(usd) { + get_cmc_price("EUR", function(eur) { + get_cmc_price("BTC", function(btc) { + price_btc = btc ? btc : price_btc; + price_usd = usd ? usd : price_usd; + price_eur = eur ? eur : price_eur; + return callback({ btc: price_btc, usd: price_usd, eur: price_eur }); + }); + }); + }); +} + function updatePoolStats2(poolType) { //console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); let cache; @@ -189,18 +212,9 @@ function updatePoolStats2(poolType) { return callback(null, pending); }, function (callback) { - if (typeof(poolType) === 'undefined') { - global.support.https_get("https://api.coinmarketcap.com/v1/ticker/" + global.config.coin.name + "/?convert=EUR", function (res) { - if (res != null && res instanceof Array && res.length === 1 && typeof(res[0].price_usd) !== 'undefined' && typeof(res[0].price_eur) !== 'undefined') { - price_btc = parseFloat(res[0].price_btc); - price_usd = parseFloat(res[0].price_usd); - price_eur = parseFloat(res[0].price_eur); - } - return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); - }); - } else { - return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); - } + if (typeof(poolType) === 'undefined' && price_btc == 0 && price_usd == 0 && price_eur == 0) { + return get_cmc(function(prices) { return callback(null, prices); }); + } else return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); }, function (callback) { let currentEfforts = {}; @@ -446,4 +460,6 @@ updatePoolInformation(); updateBlockHeader(); monitorNodes(); -setInterval(monitorNodes, 5*60*1000); \ No newline at end of file +setInterval(monitorNodes, 5*60*1000); +setInterval(get_cmc, 15*60*1000); + From 207f1a026fe1e6158f30444aacbdcea3e3dff716 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 18:07:09 -0800 Subject: [PATCH 0846/1496] Moved to CMC pro API --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index d4d3f745e..6e35440c4 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -1,4 +1,4 @@ -"use strict"; ^ +"use strict"; const debug = require("debug")("pool_stats"); const async = require("async"); From d88cd035217b5a3f9e0d5aaf047d940856a82149 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 18:08:21 -0800 Subject: [PATCH 0847/1496] Moved to CMC pro API --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 6e35440c4..f7d3c9f66 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -26,7 +26,7 @@ let altblockFoundDone = 0; function get_cmc_price(symbol, callback) { const COIN = global.config.coin.name; - global.support.https_get("https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + COIN + "&convert=" + symbol + "&CMC_PRO_API_KEY=" + global.config.general.cmcKey, function (res) { + global.support.https_get("https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?slug=" + COIN + "&convert=" + symbol + "&CMC_PRO_API_KEY=" + global.config.general.cmcKey, function (res) { return callback( res instanceof Object && "data" in res && COIN in res.data && "quote" in res.data[COIN] && symbol in res.data[COIN].quote ? parseFloat(res.data[COIN].quote[symbol].price) : 0 From 7f223c84558f7b3bca8834acc4c669e795e75f41 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 18:09:36 -0800 Subject: [PATCH 0848/1496] Moved to CMC pro API --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index f7d3c9f66..54db4f65c 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -25,7 +25,7 @@ let altblockFound = {}; let altblockFoundDone = 0; function get_cmc_price(symbol, callback) { - const COIN = global.config.coin.name; + const COIN = global.config.coin.name.toLowerCase(); global.support.https_get("https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?slug=" + COIN + "&convert=" + symbol + "&CMC_PRO_API_KEY=" + global.config.general.cmcKey, function (res) { return callback( res instanceof Object && "data" in res && COIN in res.data && "quote" in res.data[COIN] && symbol in res.data[COIN].quote From 3953743190975b61e85bc9f16c77b848efe92416 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 18:17:37 -0800 Subject: [PATCH 0849/1496] Moved to CMC pro API --- lib/pool_stats.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 54db4f65c..e70af04b0 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -25,12 +25,14 @@ let altblockFound = {}; let altblockFoundDone = 0; function get_cmc_price(symbol, callback) { - const COIN = global.config.coin.name.toLowerCase(); - global.support.https_get("https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?slug=" + COIN + "&convert=" + symbol + "&CMC_PRO_API_KEY=" + global.config.general.cmcKey, function (res) { - return callback( - res instanceof Object && "data" in res && COIN in res.data && "quote" in res.data[COIN] && symbol in res.data[COIN].quote - ? parseFloat(res.data[COIN].quote[symbol].price) : 0 - ); + const slug = global.config.coin.name.toLowerCase(); + global.support.https_get("https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?slug=" + slug + "&convert=" + symbol + "&CMC_PRO_API_KEY=" + global.config.general.cmcKey, function (res) { + if (res instanceof Object && "data" in res && "quote" in res.data[Object.keys(res.data)[0]] && symbol in res.data[Object.keys(res.data)[0]].quote) { + return callback(parseFloat(res.data[Object.keys(res.data)[0]].quote[symbol].price)); + } else { + console.error("Can't get price data from: " + JSON.stringify(res)); + return callback(0); + } }); } From ca9e79afa8e4bc3b02ccd3a2e76766a3c0eeeada Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 19:22:01 -0800 Subject: [PATCH 0850/1496] Moved to CMC pro API --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index e70af04b0..87f43469c 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -463,5 +463,5 @@ updateBlockHeader(); monitorNodes(); setInterval(monitorNodes, 5*60*1000); -setInterval(get_cmc, 15*60*1000); +setInterval(get_cmc, 15*60*1000, function() {}); From 4def1e3b1eee8e50b103feea326d426b0fcc8a53 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Mar 2020 19:22:01 -0800 Subject: [PATCH 0851/1496] Moved to CMC pro API --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index e70af04b0..87f43469c 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -463,5 +463,5 @@ updateBlockHeader(); monitorNodes(); setInterval(monitorNodes, 5*60*1000); -setInterval(get_cmc, 15*60*1000); +setInterval(get_cmc, 15*60*1000, function() {}); From e4dabfdda1d346ebeab8dfd82b83886cebbb469a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 9 Mar 2020 08:14:39 -0700 Subject: [PATCH 0852/1496] Added coin --- lib/coins/xmr.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 623287d84..53a817513 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -41,6 +41,7 @@ const port2coin = { "19950": "XWP", "9231" : "XEQ", "20206": "DERO", + "18181": "XMC", }; const port2blob_num = { "11181": 7, // AEON @@ -64,6 +65,7 @@ const port2blob_num = { "19950": 8, // XWP "9231" : 5, // XEQ "20206": 10, // DERO + "18181": 0, // XMC }; const port2algo = { @@ -88,6 +90,7 @@ const port2algo = { "48782": "cn/r", // Lethean "9231" : "cn/gpu", // XEQ "20206": "astrobwt", // DERO + "18181": "cn/0", // XMC }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -502,6 +505,8 @@ function Coin(data){ if ("astrobwt" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt"]; + if ("cn/0" in algos_perf) coin_perf["XMC"] = algos_perf["cn/0"]; + if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; @@ -535,6 +540,7 @@ function Coin(data){ case 13102: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // Italocoin case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR + case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa From 67c2d24996d1ea7a92df614994f8c2557cb8872c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 17:30:32 -0700 Subject: [PATCH 0853/1496] External share validator --- deployment/base.sql | 3 + lib/coins/xmr.js | 61 +++++++++- lib/pool.js | 278 +++++++++++++++++++++++--------------------- 3 files changed, 211 insertions(+), 131 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index b24f25d50..33ebaa192 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -222,6 +222,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXEQ', '0', 'int', 'Equilibria coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTA', '0', 'int', 'Italocoin coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortDERO', '0', 'int', 'Dero coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMC', '0', 'int', 'XMC coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -243,6 +244,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXEQ', '0', 'float', 'Equilibria algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTA', '0', 'float', 'Italocoin algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorDERO', '0', 'float', 'Dero algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMC', '0', 'float', 'XMC algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -299,6 +301,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19950', '', 'string', 'Address to mine to for 19950 (Swap) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13102', '', 'string', 'Address to mine to for 13102 (Italocoin) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20206', '', 'string', 'Address to mine to for 20206 (Dero) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_18181', '', 'string', 'Address to mine to for 18181 (XMC) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', 'Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 53a817513..97638bc92 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -6,6 +6,7 @@ const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); const process = require('process'); const fs = require('fs'); +const net = require('net'); const child_process = require('child_process'); let hexChars = new RegExp("[0-9a-f]+"); @@ -530,7 +531,7 @@ function Coin(data){ return "algo array must include at least one supported pool algo: [" + Object.keys(algos).join(", ") + "]"; } - this.cryptoNight = function(convertedBlob, blockTemplate) { + this.slowHash = function(convertedBlob, blockTemplate) { switch (blockTemplate.port) { case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon @@ -557,6 +558,64 @@ function Coin(data){ } } + this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { + let jsonInput; + switch (blockTemplate.port) { + case 13102: + case 18081: + case 19994: + case 20189: + case 22023: + case 34568: + jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "seed_hash": blockTemplate.seed_hash }; + break; + case 19734: + case 48782: + jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "height": blockTemplate.height }; + break; + case 11181: + return cb(slowHash(convertedBlob, blockTemplate)); // AEON K12 is too fast + default: + jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; + } + let socket = new net.Socket(); + let is_cb = false; + let return_cb = function(result) { + if (is_cb) return; + is_cb = true; + return cb(result); + } + let timer = setTimeout(function() { + socket.destroy(); + return return_cb(null); + }, 10*1000); + socket.connect(2222, "127.0.0.1", function () { + socket.write(JSON.stringify(jsonInput) + "\n"); + }); + + let message = ""; + socket.on('data', function (buff) { + message += buff.toString(); + }); + + socket.on("end", function () { + clearTimeout(timer); + timer = null; + try { + const jsonOutput = JSON.parse(message); + if (!("result" in jsonOutput)) return return_cb(null); + return return_cb(Buffer.from(jsonOutput.result, 'hex')); + } catch (e) { + return return_cb(null); + } + }); + + socket.on('error', function() { + socket.destroy(); + return return_cb(null); + }); + } + this.c29 = function(header, ring, port) { switch (port) { case 19281: return multiHashing.c29v(header, ring); // MoneroV diff --git a/lib/pool.js b/lib/pool.js index aa22c4958..80340ee31 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1410,7 +1410,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); + const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; } @@ -1496,10 +1496,7 @@ function report_miner_share(miner, job) { } } -function processShare(miner, job, blockTemplate, params) { - let hashDiff; - let shareBuffer; - let isTrustedShare; +function processShare(miner, job, blockTemplate, params, processShareCB) { const port = blockTemplate.port; const blob_type_num = job.blob_type_num; const resultHash = params.result; // can be undefined for global.coinFuncs.blobTypeGrin(blob_type_num) (and will not be used in submit_block since isTrustedShare = false) @@ -1507,115 +1504,135 @@ function processShare(miner, job, blockTemplate, params) { if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); - if (global.coinFuncs.blobTypeGrin(blob_type_num)) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - const header = Buffer.concat([global.coinFuncs.convertBlob(shareBuffer, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); - if (global.coinFuncs.c29(header, params.pow, port)) { - report_miner_share(miner, job); - return invalid_share(miner); + let verifyShare = function(verifyShareCB) { + if (global.coinFuncs.blobTypeGrin(blob_type_num)) { + const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + const header = Buffer.concat([global.coinFuncs.convertBlob(shareBuffer, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); + if (global.coinFuncs.c29(header, params.pow, port)) { + report_miner_share(miner, job); + return processShareCB(invalid_share(miner)); + } + return verifyShareCB(hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow)), shareBuffer, false, null); } - hashDiff = hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow)); - isTrustedShare = false; - - } else if (global.config.pool.trustedMiners && - is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && - miner.trust.check_height !== job.height - ) { - hashDiff = hash_buff_diff(new Buffer(resultHash, 'hex')); - isTrustedShare = true; - if (miner.payout in extra_wallet_verify) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer !== null) { - let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); - const hash2 = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); - if (hash2.toString('hex') !== resultHash) { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); + + let resultBuffer; + try { + resultBuffer = Buffer.from(resultHash, 'hex'); + } catch(e) { + return processShareCB(invalid_share(miner)); + } + const hashDiff = hash_buff_diff(resultBuffer); + + if (global.config.pool.trustedMiners && + is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && + miner.trust.check_height !== job.height + ) { + let shareBuffer = null; + if (miner.payout in extra_wallet_verify) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (shareBuffer !== null) { + const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); + const hash2 = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + if (hash2.toString('hex') !== resultHash) { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); + } else { + extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); + } } else { - extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); + console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); } - } else { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); } - } - } else { // verify share - if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); - if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); + return verifyShareCB(hashDiff, shareBuffer, true, null); + } else { // verify share + if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); + if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); + } + process.send({type: 'throttledShare'}); + addProxyMiner(miner); + const proxyMinerName = miner.payout + ":" + miner.identifier; + proxyMiners[proxyMinerName].hashes += job.difficulty; + adjustMinerDiff(miner); + return processShareCB(null); } - process.send({type: 'throttledShare'}); - addProxyMiner(miner); - const proxyMinerName = miner.payout + ":" + miner.identifier; - proxyMiners[proxyMinerName].hashes += job.difficulty; - adjustMinerDiff(miner); - return null; - } - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer === null) return invalid_share(miner); - const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); - const hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate); - - if (hash.toString('hex') !== resultHash) { - report_miner_share(miner, job); - return invalid_share(miner); - } - hashDiff = hash_buff_diff(hash); - isTrustedShare = false; - walletTrust[miner.payout] += job.rewarded_difficulty2; - } - - let is_block_diff_matched = false; - - if (hashDiff.ge(blockTemplate.difficulty)) { // Submit block to the RPC Daemon. - if (!shareBuffer) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (!shareBuffer) return invalid_share(miner); + const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (shareBuffer === null) return processShareCB(invalid_share(miner)); + const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); + + const isBlockDiffMatched = hashDiff.ge(blockTemplate.difficulty); + if (isBlockDiffMatched) { + const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + if (hash.toString('hex') !== resultHash) { + report_miner_share(miner, job); + return processShareCB(invalid_share(miner)); + } + walletTrust[miner.payout] += job.rewarded_difficulty2; + return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); + } else global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { + if (hash === null || hash.toString('hex') !== resultHash) { + report_miner_share(miner, job); + return processShareCB(invalid_share(miner)); + } + walletTrust[miner.payout] += job.rewarded_difficulty2; + return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); + }); } - submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, true, true); - is_block_diff_matched = true; - } + }; - const is_mm = "child_template" in blockTemplate; - if (is_mm && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. - if (!shareBuffer) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (!shareBuffer) return invalid_share(miner); - } - // need to properly restore child template buffer here since it went via message string and was restored not correctly - blockTemplate.child_template_buffer = Buffer.from(blockTemplate.child_template_buffer); - let shareBuffer2 = null; - try { - shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, port, blockTemplate.child_template_buffer); - } catch (e) { - const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; - console.error(err_str); - global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't construct_mm_child_block_blob", err_str); - return invalid_share(miner); + verifyShare(function(hashDiff, shareBuffer, isTrustedShare, isBlockDiffMatched) { + let isBlockDiffMatched = isBlockDiffMatched === null ? hashDiff.ge(blockTemplate.difficulty) : isBlockDiffMatched; + + if (isBlockDiffMatched) { // Submit block to the RPC Daemon. + if (!shareBuffer) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (!shareBuffer) return processShareCB(invalid_share(miner)); + } + submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, true, true); } - if (shareBuffer2 === null) return invalid_share(miner); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, hashDiff, isTrustedShare, false, true); - is_block_diff_matched = true; - } - - if (is_block_diff_matched) return true; - - if (hashDiff.lt(job.difficulty)) { - let time_now = Date.now(); - if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString); - lastMinerLogTime[miner.payout] = time_now; + + const is_mm = "child_template" in blockTemplate; + if (is_mm && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. + if (!shareBuffer) { + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (!shareBuffer) return processShareCB(invalid_share(miner)); + } + // need to properly restore child template buffer here since it went via message string and was restored not correctly + blockTemplate.child_template_buffer = Buffer.from(blockTemplate.child_template_buffer); + let shareBuffer2 = null; + try { + shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, port, blockTemplate.child_template_buffer); + } catch (e) { + const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't construct_mm_child_block_blob", err_str); + return processShareCB(invalid_share(miner)); + } + if (shareBuffer2 === null) return processShareCB(invalid_share(miner)); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, hashDiff, isTrustedShare, false, true); + isBlockDiffMatched = true; } - return invalid_share(miner); - - } else { - recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); - // record child proc share for rewarded_difficulty effort calcs status but with 0 rewards (all included in parent share) - if (is_mm) { - job.rewarded_difficulty2 = 0; - recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); + + if (isBlockDiffMatched) return processShareCB(true); + + if (hashDiff.lt(job.difficulty)) { + let time_now = Date.now(); + if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { + console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString); + lastMinerLogTime[miner.payout] = time_now; + } + return processShareCB(invalid_share(miner)); + + } else { + recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); + // record child proc share for rewarded_difficulty effort calcs status but with 0 rewards (all included in parent share) + if (is_mm) { + job.rewarded_difficulty2 = 0; + recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); + } + return processShareCB(true); } - return true; - } + }); } // Message times for different miner addresses @@ -1839,37 +1856,38 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se job.rewarded_difficulty2 = job.rewarded_difficulty * job.coinHashFactor; - let shareAccepted = processShare(miner, job, blockTemplate, params); - if (shareAccepted === null) { - sendReply('Throttled down share submission (please use high fixed diff or use xmr-node-proxy)'); - return; - } - miner.checkBan(shareAccepted); + processShare(miner, job, blockTemplate, params, function(shareAccepted) { + if (shareAccepted === null) { + sendReply('Throttled down share submission (please use high fixed diff or use xmr-node-proxy)'); + return; + } + miner.checkBan(shareAccepted); - if (global.config.pool.trustedMiners) { - if (shareAccepted) { - miner.trust.trust += job.rewarded_difficulty2; - miner.trust.check_height = 0; - } else { - debug(threadName + "Share trust broken by " + miner.logString); - miner.storeInvalidShare(); - miner.trust.trust = 0; + if (global.config.pool.trustedMiners) { + if (shareAccepted) { + miner.trust.trust += job.rewarded_difficulty2; + miner.trust.check_height = 0; + } else { + debug(threadName + "Share trust broken by " + miner.logString); + miner.storeInvalidShare(); + miner.trust.trust = 0; + } } - } - if (!shareAccepted) { - sendReply('Low difficulty share'); - return; - } + if (!shareAccepted) { + sendReply('Low difficulty share'); + return; + } - miner.lastShareTime = Date.now() / 1000 || 0; + miner.lastShareTime = Date.now() / 1000 || 0; - if (miner.protocol === "grin") { - sendReply(null, "ok"); - } else { - sendReply(null, { status: 'OK' }); - } - //if (miner.debugMiner) console.log("SUBMIT OK"); + if (miner.protocol === "grin") { + sendReply(null, "ok"); + } else { + sendReply(null, { status: 'OK' }); + } + //if (miner.debugMiner) console.log("SUBMIT OK"); + }); break; } From 90895377df711459980d3601599ac689a8fea650 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 17:31:46 -0700 Subject: [PATCH 0854/1496] Debug code --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 97638bc92..ecb24ffac 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,6 +559,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { + return cb(slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: From 58e4e1b62dfd83442b4113f3dfa734263737ebfd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 17:32:49 -0700 Subject: [PATCH 0855/1496] Fix bug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 80340ee31..fa01e4d18 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1581,7 +1581,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { }; verifyShare(function(hashDiff, shareBuffer, isTrustedShare, isBlockDiffMatched) { - let isBlockDiffMatched = isBlockDiffMatched === null ? hashDiff.ge(blockTemplate.difficulty) : isBlockDiffMatched; + isBlockDiffMatched = isBlockDiffMatched === null ? hashDiff.ge(blockTemplate.difficulty) : isBlockDiffMatched; if (isBlockDiffMatched) { // Submit block to the RPC Daemon. if (!shareBuffer) { From f624ba4bbbf17bdb191cc06e312d0c69548e0917 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 17:33:34 -0700 Subject: [PATCH 0856/1496] Fix bug --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ecb24ffac..23a3f3c64 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,7 +559,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - return cb(slowHash(convertedBlob, blockTemplate)); // !!! + return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: @@ -575,7 +575,7 @@ function Coin(data){ jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "height": blockTemplate.height }; break; case 11181: - return cb(slowHash(convertedBlob, blockTemplate)); // AEON K12 is too fast + return cb(this.slowHash(convertedBlob, blockTemplate)); // AEON K12 is too fast default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } From 427886db4f58d90f5658b66117ab93a418101a32 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 17:34:40 -0700 Subject: [PATCH 0857/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 23a3f3c64..793044283 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,7 +559,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! + //return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: From 82da8f870c71e0db2dbdb76521dd90cf34bcab4d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 17:37:02 -0700 Subject: [PATCH 0858/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 793044283..23a3f3c64 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,7 +559,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - //return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! + return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: From ee6d168f1f4714bbf0d8a0b8489d8f9dd715d620 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 17:59:47 -0700 Subject: [PATCH 0859/1496] Debug code --- lib/coins/xmr.js | 16 ++++++++-------- lib/pool.js | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 23a3f3c64..89cabab7d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,10 +559,10 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! + //return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! let jsonInput; switch (blockTemplate.port) { - case 13102: + case 13102: case 18081: case 19994: case 20189: @@ -575,7 +575,7 @@ function Coin(data){ jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "height": blockTemplate.height }; break; case 11181: - return cb(this.slowHash(convertedBlob, blockTemplate)); // AEON K12 is too fast + return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // AEON K12 is too fast default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } @@ -594,18 +594,18 @@ function Coin(data){ socket.write(JSON.stringify(jsonInput) + "\n"); }); - let message = ""; + let buffall = ""; socket.on('data', function (buff) { - message += buff.toString(); + buffall += buff; }); socket.on("end", function () { clearTimeout(timer); - timer = null; + timer = null; try { - const jsonOutput = JSON.parse(message); + const jsonOutput = JSON.parse(buffall.toString()); if (!("result" in jsonOutput)) return return_cb(null); - return return_cb(Buffer.from(jsonOutput.result, 'hex')); + return return_cb(jsonOutput.result); } catch (e) { return return_cb(null); } diff --git a/lib/pool.js b/lib/pool.js index fa01e4d18..dade6a908 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1562,15 +1562,15 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const isBlockDiffMatched = hashDiff.ge(blockTemplate.difficulty); if (isBlockDiffMatched) { - const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash.toString('hex') !== resultHash) { + const buff = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + if (buff.toString('hex') !== resultHash) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } walletTrust[miner.payout] += job.rewarded_difficulty2; return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); } else global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { - if (hash === null || hash.toString('hex') !== resultHash) { + if (hash !== resultHash) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } From 412b9eddf16fb75f1852763a0db800b9f9b31077 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 18:01:39 -0700 Subject: [PATCH 0860/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 89cabab7d..dec833d42 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,7 +559,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - //return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! + return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: From 6d7d5c5c07d27749cf97e326f4f2ceb12b3ff3dc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 18:11:40 -0700 Subject: [PATCH 0861/1496] Debug code --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index dec833d42..c1f5336a2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,7 +559,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! + //return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: @@ -589,7 +589,7 @@ function Coin(data){ let timer = setTimeout(function() { socket.destroy(); return return_cb(null); - }, 10*1000); + }, 60*1000); socket.connect(2222, "127.0.0.1", function () { socket.write(JSON.stringify(jsonInput) + "\n"); }); From 86ea2e5778b269a1085bfd114da8986ee7763600 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 18:15:31 -0700 Subject: [PATCH 0862/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c1f5336a2..441538bde 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -559,7 +559,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - //return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! + return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: From d3167e5f123e9ada2a2151bd991112ba45b6aa13 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 18:32:24 -0700 Subject: [PATCH 0863/1496] Debug code --- lib/coins/xmr.js | 10 +++++++--- lib/pool.js | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 441538bde..b405a533d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -531,7 +531,7 @@ function Coin(data){ return "algo array must include at least one supported pool algo: [" + Object.keys(algos).join(", ") + "]"; } - this.slowHash = function(convertedBlob, blockTemplate) { + this.slowHashBuff = function(convertedBlob, blockTemplate) { switch (blockTemplate.port) { case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon @@ -558,8 +558,12 @@ function Coin(data){ } } + this.slowHash = function(convertedBlob, blockTemplate) { + return this.slowHashBuff(convertedBlob, blockTemplate).toString("hex"); + } + this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // !!! + return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: @@ -575,7 +579,7 @@ function Coin(data){ jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "height": blockTemplate.height }; break; case 11181: - return cb(this.slowHash(convertedBlob, blockTemplate).toString("hex")); // AEON K12 is too fast + return cb(this.slowHash(convertedBlob, blockTemplate)); // AEON K12 is too fast default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } diff --git a/lib/pool.js b/lib/pool.js index dade6a908..9f0f76108 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1411,7 +1411,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash.toString('hex') !== resultHash) isNotifyAdmin = false; + if (hash !== resultHash) isNotifyAdmin = false; } console.error(threadName + "Error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + @@ -1533,7 +1533,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (shareBuffer !== null) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); const hash2 = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash2.toString('hex') !== resultHash) { + if (hash2 !== resultHash) { console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); } else { extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); @@ -1562,8 +1562,8 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const isBlockDiffMatched = hashDiff.ge(blockTemplate.difficulty); if (isBlockDiffMatched) { - const buff = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (buff.toString('hex') !== resultHash) { + const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + if (hash !== resultHash) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } From 68b5a09b0c3e3dc9d99ab0903c0beb2325d0725c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 18:53:45 -0700 Subject: [PATCH 0864/1496] Debug code --- lib/coins/xmr.js | 82 ++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b405a533d..74b5da04a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -131,6 +131,49 @@ function get_algos() { } const all_algos = get_algos(); const mm_child_port_set = get_mm_child_port_set(mm_port_set); + +let shareVerifyQueue = async.queue(function (task, queueCB) { + const jsonInput = task.jsonInput; + const cb = task.cb; + + let socket = new net.Socket(); + let is_cb = false; + let return_cb = function(result) { + if (is_cb) return; + is_cb = true; + cb(result); + return queueCB(); + } + let timer = setTimeout(function() { + socket.destroy(); + return return_cb(null); + }, 60*1000); + socket.connect(2222, "127.0.0.1", function () { + socket.write(JSON.stringify(jsonInput) + "\n"); + }); + + let buffall = ""; + socket.on('data', function (buff) { + buffall += buff; + }); + + socket.on("end", function () { + clearTimeout(timer); + timer = null; + try { + const jsonOutput = JSON.parse(buffall.toString()); + if (!("result" in jsonOutput)) return return_cb(null); + return return_cb(jsonOutput.result); + } catch (e) { + return return_cb(null); + } + }); + + socket.on('error', function() { + socket.destroy(); + return return_cb(null); + }); +}, 32); function Coin(data){ this.bestExchange = global.config.payout.bestExchange; @@ -563,7 +606,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! + //return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: @@ -583,42 +626,7 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - let socket = new net.Socket(); - let is_cb = false; - let return_cb = function(result) { - if (is_cb) return; - is_cb = true; - return cb(result); - } - let timer = setTimeout(function() { - socket.destroy(); - return return_cb(null); - }, 60*1000); - socket.connect(2222, "127.0.0.1", function () { - socket.write(JSON.stringify(jsonInput) + "\n"); - }); - - let buffall = ""; - socket.on('data', function (buff) { - buffall += buff; - }); - - socket.on("end", function () { - clearTimeout(timer); - timer = null; - try { - const jsonOutput = JSON.parse(buffall.toString()); - if (!("result" in jsonOutput)) return return_cb(null); - return return_cb(jsonOutput.result); - } catch (e) { - return return_cb(null); - } - }); - - socket.on('error', function() { - socket.destroy(); - return return_cb(null); - }); + return shareVerifyQueue.push({"jsonInput": jsonInput, "cb": cb}); } this.c29 = function(header, ring, port) { From bd44b48d6f412efd7397fa8a89af2fc8ea5f0882 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 18:54:30 -0700 Subject: [PATCH 0865/1496] Debug code --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 74b5da04a..34e18356d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -7,6 +7,7 @@ const debug = require('debug')('coinFuncs'); const process = require('process'); const fs = require('fs'); const net = require('net'); +const async = require('async'); const child_process = require('child_process'); let hexChars = new RegExp("[0-9a-f]+"); From 9a69a13056541565c5d3d2b5d613cf39041ff94e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 19:02:46 -0700 Subject: [PATCH 0866/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 34e18356d..95b24f4db 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -607,7 +607,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - //return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! + return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: From 9613557d447b8ead5014edf0cc0698a60d4e1cdc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 19:05:55 -0700 Subject: [PATCH 0867/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 95b24f4db..4872fd892 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -627,7 +627,7 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - return shareVerifyQueue.push({"jsonInput": jsonInput, "cb": cb}); + return shareVerifyQueue.unshift({"jsonInput": jsonInput, "cb": cb}); } this.c29 = function(header, ring, port) { From 5d485dd3238338aafa36b1717315185a70d89154 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 19:06:01 -0700 Subject: [PATCH 0868/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4872fd892..ee0b09894 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -607,7 +607,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! + //return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! let jsonInput; switch (blockTemplate.port) { case 13102: From 81eceea9e65cddb5aa5ffd2cfa11e977405e1611 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 19:24:30 -0700 Subject: [PATCH 0869/1496] Debug code --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 9f0f76108..b2b75dfd4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1570,6 +1570,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { walletTrust[miner.payout] += job.rewarded_difficulty2; return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); } else global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { + hash = hash === null ? global.coinFuncs.slowHash(convertedBlob, blockTemplate) : hash; if (hash !== resultHash) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); From 64a83081c350a1db9f4dd2a0c2454445ddb96ee7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 19:50:58 -0700 Subject: [PATCH 0870/1496] Added verify shares host config --- config_example.json | 1 + lib/coins/xmr.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config_example.json b/config_example.json index cf3ea8a5b..74703db10 100644 --- a/config_example.json +++ b/config_example.json @@ -3,6 +3,7 @@ "bind_ip": "127.0.0.1", "hostname": "testpool.com", "db_storage_path": "CHANGEME", + "verify_shares_host": null, "coin": "xmr", "mysql": { "connectionLimit": 20, diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ee0b09894..db2184943 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -149,7 +149,7 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { socket.destroy(); return return_cb(null); }, 60*1000); - socket.connect(2222, "127.0.0.1", function () { + socket.connect(2222, global.config.verify_shares_host, function () { socket.write(JSON.stringify(jsonInput) + "\n"); }); @@ -607,7 +607,7 @@ function Coin(data){ } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { - //return cb(this.slowHash(convertedBlob, blockTemplate)); // !!! + if (!global.config.verify_shares_host) return cb(this.slowHash(convertedBlob, blockTemplate)); let jsonInput; switch (blockTemplate.port) { case 13102: From 98f5ac1bf9564cdf8ff4674c3806d5dc05a4365e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 20:32:49 -0700 Subject: [PATCH 0871/1496] Debug code --- lib/coins/xmr.js | 8 +++++++- lib/remote_comms.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index db2184943..3a7c1751c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -175,7 +175,13 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { return return_cb(null); }); }, 32); - + +setInterval(function(queue_obj){ + if (queue_obj.length() > 1000 && global.database.thread_id === '(Master) '){ + console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); + } +}, 30*1000, this.shareVerifyQueue); + function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; diff --git a/lib/remote_comms.js b/lib/remote_comms.js index e857034ab..70c382b00 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -66,7 +66,7 @@ function Database() { setInterval(function(queue_obj){ if ((queue_obj.length() > 20 || queue_obj.running() > 20) && global.database.thread_id === '(Master) '){ - console.log(global.database.thread_id + "Queue debug state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); + console.log(global.database.thread_id + "Remote queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, this.sendQueue); From fd535debc0948204580eea3f585fa435bcf8aab8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 20:34:09 -0700 Subject: [PATCH 0872/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3a7c1751c..0b276446c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -180,7 +180,7 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 1000 && global.database.thread_id === '(Master) '){ console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } -}, 30*1000, this.shareVerifyQueue); +}, 30*1000, shareVerifyQueue); function Coin(data){ this.bestExchange = global.config.payout.bestExchange; From 234cb65349ab9b6c9a7557a627d2ff2534fbef4d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 20:36:21 -0700 Subject: [PATCH 0873/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0b276446c..61e00a8c7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -177,7 +177,7 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - if (queue_obj.length() > 1000 && global.database.thread_id === '(Master) '){ + if (queue_obj.length() > 100 && global.database.thread_id === '(Master) '){ console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); From a0796eed8b1124f6373315f772c3bdb25e1cb019 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 20:38:07 -0700 Subject: [PATCH 0874/1496] Debug code --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 61e00a8c7..f551ab898 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -177,7 +177,7 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - if (queue_obj.length() > 100 && global.database.thread_id === '(Master) '){ + if (queue_obj.length() > 100){ console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); From 23dc83b815ffa264a14ad8a1c764fd987f819913 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 22:47:09 -0700 Subject: [PATCH 0875/1496] Reduced template update --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b2b75dfd4..75c549573 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -359,7 +359,7 @@ function templateUpdate(coin, repeating) { } if (activePort !== global.config.daemon["activePort" + coin]) { console.log(threadName + "Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); - if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); + if (repeating === true) setTimeout(templateUpdate, 100, coin, repeating); } else if (err === null) { const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { @@ -368,7 +368,7 @@ function templateUpdate(coin, repeating) { } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } - if (repeating === true) setTimeout(templateUpdate, 50, coin, repeating); + if (repeating === true) setTimeout(templateUpdate, 100, coin, repeating); } else { failedPortLastBlockHeaderCoinHashFactor[coin] = coinHashFactor; console.error(threadName + "Last block header request for " + activePort + " port failed!"); @@ -2073,7 +2073,7 @@ if (cluster.isMaster) { if ("activePort" + coin in global.config.daemon) { setInterval(updateActivePort, 5*1000, coin); templateUpdate(coin); - setTimeout(templateUpdate, 50, coin, true); + setTimeout(templateUpdate, 100, coin, true); } else { console.warn("global.config.daemon." + "activePort" + coin + " is not defined, so ignoring its coin changes"); } @@ -2081,7 +2081,7 @@ if (cluster.isMaster) { } templateUpdate(""); - setTimeout(templateUpdate, 50, "", true); + setTimeout(templateUpdate, 100, "", true); global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); } else { From 89ad9172946451c14ab6ce4c10653122acdad6c0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 22:48:10 -0700 Subject: [PATCH 0876/1496] Reduced template update --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f551ab898..3a8cb5d2d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -177,7 +177,7 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - if (queue_obj.length() > 100){ + if (queue_obj.length() > 1000){ console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); From 9362ad8dd14530de2dba9e25a5bac168ad77abd9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 23:33:04 -0700 Subject: [PATCH 0877/1496] Added block notify support --- lib/coins/xmr.js | 8 ++++---- lib/pool.js | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3a8cb5d2d..5be556fdd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -153,16 +153,16 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { socket.write(JSON.stringify(jsonInput) + "\n"); }); - let buffall = ""; - socket.on('data', function (buff) { - buffall += buff; + let buff = ""; + socket.on('data', function (buff1) { + buff += buff1; }); socket.on("end", function () { clearTimeout(timer); timer = null; try { - const jsonOutput = JSON.parse(buffall.toString()); + const jsonOutput = JSON.parse(buff.toString()); if (!("result" in jsonOutput)) return return_cb(null); return return_cb(jsonOutput.result); } catch (e) { diff --git a/lib/pool.js b/lib/pool.js index 75c549573..7e745c09a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -16,6 +16,9 @@ const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); const hexMatch = new RegExp("^[0-9a-f]+$"); const baseDiff = global.coinFuncs.baseDiff(); +const BLOCK_NOTIFY_PORT = 2223; +const DAEMON_POLL_MS = 100; + function get_new_id() { const min = 100000000000000; const max = 999999999999999; @@ -359,7 +362,7 @@ function templateUpdate(coin, repeating) { } if (activePort !== global.config.daemon["activePort" + coin]) { console.log(threadName + "Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); - if (repeating === true) setTimeout(templateUpdate, 100, coin, repeating); + if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); } else if (err === null) { const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { @@ -368,7 +371,7 @@ function templateUpdate(coin, repeating) { } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } - if (repeating === true) setTimeout(templateUpdate, 100, coin, repeating); + if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); } else { failedPortLastBlockHeaderCoinHashFactor[coin] = coinHashFactor; console.error(threadName + "Last block header request for " + activePort + " port failed!"); @@ -2073,7 +2076,7 @@ if (cluster.isMaster) { if ("activePort" + coin in global.config.daemon) { setInterval(updateActivePort, 5*1000, coin); templateUpdate(coin); - setTimeout(templateUpdate, 100, coin, true); + setTimeout(templateUpdate, DAEMON_POLL_MS, coin, true); } else { console.warn("global.config.daemon." + "activePort" + coin + " is not defined, so ignoring its coin changes"); } @@ -2081,9 +2084,40 @@ if (cluster.isMaster) { } templateUpdate(""); - setTimeout(templateUpdate, 100, "", true); + setTimeout(templateUpdate, DAEMON_POLL_MS, "", true); global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); + let block_notify_server = net.createServer(function (socket) { + let timer = setTimeout(function() { + console.error(threadName + "Timeout waiting for block notify input"); + socket.destroy(); + }, 3*1000); + let buff = ""; + socket.on('data', function (buff1) { + buff += buff1; + }); + socket.on('end', function () { + clearTimeout(timer); + timer = null; + const port = parseInt(buff.toString()); + const coin = global.coinFuncs.PORT2COIN(port); + if (typeof(coin) == undefined) { + console.error(threadName + "Block notify for unknown coin with " + port + " port"); + } else { + console.error(threadName + "Block notify for coin " + coin + " with " + port + " port"); + templateUpdate(coin); + } + }); + socket.on('error', function() { + console.error(threadName + "Socket error on block notify port"); + socket.destroy(); + }); + }); + + block_notify_server.listen(BLOCK_NOTIFY_PORT, "127.0.0.1", function() { + console.log(threadName + "Blocl notify server on " + BLOCK_NOTIFY_PORT + " port started"); + }); + } else { currCoinHashFactor[""] = currCoinHashFactorMM[""] = 1; templateUpdate(""); From 936d69f3039a44e266d440f960ce185294061b2b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Mar 2020 23:36:59 -0700 Subject: [PATCH 0878/1496] Added block notify support --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7e745c09a..11fbde6d6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -17,7 +17,7 @@ const hexMatch = new RegExp("^[0-9a-f]+$"); const baseDiff = global.coinFuncs.baseDiff(); const BLOCK_NOTIFY_PORT = 2223; -const DAEMON_POLL_MS = 100; +const DAEMON_POLL_MS = 500; function get_new_id() { const min = 100000000000000; @@ -2101,7 +2101,7 @@ if (cluster.isMaster) { timer = null; const port = parseInt(buff.toString()); const coin = global.coinFuncs.PORT2COIN(port); - if (typeof(coin) == undefined) { + if (typeof(coin) === 'undefined') { console.error(threadName + "Block notify for unknown coin with " + port + " port"); } else { console.error(threadName + "Block notify for coin " + coin + " with " + port + " port"); From a31efab41d92ee073578eee6e9da4d5d44639f05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 12 Mar 2020 00:08:03 -0700 Subject: [PATCH 0879/1496] Added block notify support --- block_notify.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 block_notify.sh diff --git a/block_notify.sh b/block_notify.sh new file mode 100755 index 000000000..dce9fe99d --- /dev/null +++ b/block_notify.sh @@ -0,0 +1,2 @@ +#!/bin/bash +/bin/echo 18081 | /bin/nc -N localhost 2223 \ No newline at end of file From b6bff530cd03ad42a607b7eed39766c4c2405d80 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 12 Mar 2020 00:15:48 -0700 Subject: [PATCH 0880/1496] Added block notify --- deployment/monero.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/monero.service b/deployment/monero.service index 86fcb3694..5778a19ee 100644 --- a/deployment/monero.service +++ b/deployment/monero.service @@ -5,7 +5,7 @@ After=network.target [Service] Type=forking GuessMainPID=no -ExecStart=/usr/local/src/monero/build/release/bin/monerod --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc --prune-blockchain +ExecStart=/usr/local/src/monero/build/release/bin/monerod --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc --prune-blockchain --block-notify '/bin/bash /home/user/nodejs-pool/block_notify.sh' Restart=always User=monerodaemon From b75b0906081721aaba58889c037a7b3a69eef9a2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Mar 2020 10:51:01 -0700 Subject: [PATCH 0881/1496] Disable block notify message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 11fbde6d6..0d3cc9556 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2104,7 +2104,7 @@ if (cluster.isMaster) { if (typeof(coin) === 'undefined') { console.error(threadName + "Block notify for unknown coin with " + port + " port"); } else { - console.error(threadName + "Block notify for coin " + coin + " with " + port + " port"); + //console.log(threadName + "Block notify for coin " + coin + " with " + port + " port"); templateUpdate(coin); } }); From 03cfcd0049caaa046856c6094d346c936bf90daf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 15 Mar 2020 08:48:50 -0700 Subject: [PATCH 0882/1496] Fixed XMC reward --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5be556fdd..ea17c8bfb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -269,7 +269,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 22023 || port == 33124 || port == 24182 || port == 13102) { // Loki / XtendCash / TUBE / Italocoin has reward as zero transaction + if (port == 22023 || port == 33124 || port == 24182 || port == 13102 || port == 18181) { // Loki / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Tue, 17 Mar 2020 20:11:16 -0700 Subject: [PATCH 0883/1496] Increased share verify buffer --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ea17c8bfb..5784b0ce5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -174,7 +174,7 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { socket.destroy(); return return_cb(null); }); -}, 32); +}, 64); setInterval(function(queue_obj){ if (queue_obj.length() > 1000){ From 664b206ded902a08d90ea06484b54a3eefaab69d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 21:48:25 -0700 Subject: [PATCH 0884/1496] Handle verify share queue --- lib/coins/xmr.js | 20 ++++++++++++++------ lib/pool.js | 7 ++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5784b0ce5..068187b11 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -134,6 +134,11 @@ const all_algos = get_algos(); const mm_child_port_set = get_mm_child_port_set(mm_port_set); let shareVerifyQueue = async.queue(function (task, queueCB) { + if (Date.now() - task.time > 5*60*1000) { + cb(null); + return queueCB(); + } + const jsonInput = task.jsonInput; const cb = task.cb; @@ -147,7 +152,7 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { } let timer = setTimeout(function() { socket.destroy(); - return return_cb(null); + return return_cb(false); }, 60*1000); socket.connect(2222, global.config.verify_shares_host, function () { socket.write(JSON.stringify(jsonInput) + "\n"); @@ -163,20 +168,23 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { timer = null; try { const jsonOutput = JSON.parse(buff.toString()); - if (!("result" in jsonOutput)) return return_cb(null); + if (!("result" in jsonOutput)) return return_cb(false); return return_cb(jsonOutput.result); } catch (e) { - return return_cb(null); + return return_cb(false); } }); socket.on('error', function() { socket.destroy(); - return return_cb(null); + return return_cb(false); }); -}, 64); +}, 32); setInterval(function(queue_obj){ + queue_obj.remove(function(task) { + return Date.now() - task.time > 5*60*1000; + }); if (queue_obj.length() > 1000){ console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } @@ -633,7 +641,7 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - return shareVerifyQueue.unshift({"jsonInput": jsonInput, "cb": cb}); + return shareVerifyQueue.unshift({ "jsonInput": jsonInput, "cb": cb, "time": Date.now() }); } this.c29 = function(header, ring, port) { diff --git a/lib/pool.js b/lib/pool.js index 0d3cc9556..fb7e19814 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1573,7 +1573,12 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { walletTrust[miner.payout] += job.rewarded_difficulty2; return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); } else global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { - hash = hash === null ? global.coinFuncs.slowHash(convertedBlob, blockTemplate) : hash; + if (hash === null) { + return processShareCB(null); + } else if (hash === false) { + console.error(threadName + "Processed share locally instead of remotely!"); + hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + } if (hash !== resultHash) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); From aac24830d59bbde09b8f1a794b9aa983e4b01f77 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 21:51:53 -0700 Subject: [PATCH 0885/1496] Handle verify share queue --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 068187b11..e66f6f0b5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -182,9 +182,9 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - queue_obj.remove(function(task) { - return Date.now() - task.time > 5*60*1000; - }); + //queue_obj.remove(function(task) { + // return Date.now() - task.time > 5*60*1000; + //}); if (queue_obj.length() > 1000){ console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } From 66883c6f8db8c0a55b8b115d72b647004d33d91e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 21:58:06 -0700 Subject: [PATCH 0886/1496] Upgraded async --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad0742d3f..a829ab0ab 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "author": "Multiple", "license": "MIT", "dependencies": { - "async": "2.1.4", + "async": "3.2.0", "bignum": "^0.12.5", "body-parser": "^1.16.0", "circular-buffer": "1.0.2", From 36959c7c02457bdd8bb05de909857f75341ea234 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 22:00:10 -0700 Subject: [PATCH 0887/1496] Handle verify share queue --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e66f6f0b5..068187b11 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -182,9 +182,9 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - //queue_obj.remove(function(task) { - // return Date.now() - task.time > 5*60*1000; - //}); + queue_obj.remove(function(task) { + return Date.now() - task.time > 5*60*1000; + }); if (queue_obj.length() > 1000){ console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } From 6fc1f719918b406d263566184a01345588937c95 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 22:02:41 -0700 Subject: [PATCH 0888/1496] Handle verify share queue --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 068187b11..ca3cba7d5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -182,10 +182,10 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - queue_obj.remove(function(task) { - return Date.now() - task.time > 5*60*1000; - }); - if (queue_obj.length() > 1000){ + if (queue_obj.length() > 1000) { + queue_obj.remove(function(task) { + return Date.now() - task.time > 5*60*1000; + }); console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); From d9281b4d01403aac463d123e14c110bacd5fa56e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 22:21:32 -0700 Subject: [PATCH 0889/1496] Handle verify share queue --- lib/coins/xmr.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ca3cba7d5..50d7fe256 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -184,7 +184,11 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { queue_obj.remove(function(task) { - return Date.now() - task.time > 5*60*1000; + if (Date.now() - task.time > 5*60*1000) { + task.cb(null); + return true; + } + return false; }); console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } From b63233e4294d29c9b596560184b06e0c15e445b2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 22:23:49 -0700 Subject: [PATCH 0890/1496] Handle verify share queue --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 50d7fe256..9ee9c7fa9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -185,7 +185,7 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { queue_obj.remove(function(task) { if (Date.now() - task.time > 5*60*1000) { - task.cb(null); + task.cb(null); return true; } return false; From 752c1ce84fed920d54aa79bb57fc3b79284a8ea8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 22:33:13 -0700 Subject: [PATCH 0891/1496] Handle verify share queue --- lib/coins/xmr.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9ee9c7fa9..841459ba9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -183,13 +183,13 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { - queue_obj.remove(function(task) { - if (Date.now() - task.time > 5*60*1000) { - task.cb(null); - return true; - } - return false; - }); + //queue_obj.remove(function(task) { + // if (Date.now() - task.time > 5*60*1000) { + // task.cb(null); + // return true; + // } + // return false; + //}); console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); From 0db69605324734e9099bf6232556648d29aea4fa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Mar 2020 23:27:42 -0700 Subject: [PATCH 0892/1496] Handle verify share queue --- lib/coins/xmr.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 841459ba9..48bf7bd56 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -134,13 +134,13 @@ const all_algos = get_algos(); const mm_child_port_set = get_mm_child_port_set(mm_port_set); let shareVerifyQueue = async.queue(function (task, queueCB) { + const cb = task.cb; if (Date.now() - task.time > 5*60*1000) { cb(null); return queueCB(); } const jsonInput = task.jsonInput; - const cb = task.cb; let socket = new net.Socket(); let is_cb = false; @@ -183,13 +183,13 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { - //queue_obj.remove(function(task) { - // if (Date.now() - task.time > 5*60*1000) { - // task.cb(null); - // return true; - // } - // return false; - //}); + queue_obj.remove(function(task) { + if (Date.now() - task.time > 5*60*1000) { + task.cb(null); + return true; + } + return false; + }); console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); From f27718ce243f02fde1ab773d62601747ef17a687 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 00:46:08 -0700 Subject: [PATCH 0893/1496] Debug --- lib/remote_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 70c382b00..02e7627d1 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -9,6 +9,7 @@ function Database() { this.sendQueue = async.queue(function (task, callback) { async.doUntil( function (intCallback) { + console.log(global.config.general.shareHost); request.post({url: global.config.general.shareHost, body: task.body, forever: true}, function (error, response, body) { if (!error) { return intCallback(null, response.statusCode); From ec2482f97c9df7048b24bd57f8243ae20768b2b7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 00:48:47 -0700 Subject: [PATCH 0894/1496] Debug --- lib/remote_comms.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 02e7627d1..172eb8a13 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -9,11 +9,14 @@ function Database() { this.sendQueue = async.queue(function (task, callback) { async.doUntil( function (intCallback) { - console.log(global.config.general.shareHost); request.post({url: global.config.general.shareHost, body: task.body, forever: true}, function (error, response, body) { if (!error) { return intCallback(null, response.statusCode); } + console.log(error); + console.log(response); + console.log(body); + return intCallback(null, 0); }); }, From e60d3d0ef3e80990db42f8d3e2c523ef4923523a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 00:51:11 -0700 Subject: [PATCH 0895/1496] Debug --- lib/remote_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 172eb8a13..690b066cc 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -21,6 +21,7 @@ function Database() { }); }, function (data) { + console.log("!!!" + data); return data === 200; }, function () { From 1621640b6891ebbc75a2daf69d09c4583d43d14d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 00:58:28 -0700 Subject: [PATCH 0896/1496] Downgraded async --- lib/coins/xmr.js | 14 +++++++------- lib/remote_comms.js | 5 ----- package.json | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 48bf7bd56..75b46c1de 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -183,13 +183,13 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { - queue_obj.remove(function(task) { - if (Date.now() - task.time > 5*60*1000) { - task.cb(null); - return true; - } - return false; - }); + //queue_obj.remove(function(task) { + // if (Date.now() - task.time > 5*60*1000) { + // task.cb(null); + // return true; + // } + // return false; + //}); console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 690b066cc..70c382b00 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -13,15 +13,10 @@ function Database() { if (!error) { return intCallback(null, response.statusCode); } - console.log(error); - console.log(response); - console.log(body); - return intCallback(null, 0); }); }, function (data) { - console.log("!!!" + data); return data === 200; }, function () { diff --git a/package.json b/package.json index a829ab0ab..ad0742d3f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "author": "Multiple", "license": "MIT", "dependencies": { - "async": "3.2.0", + "async": "2.1.4", "bignum": "^0.12.5", "body-parser": "^1.16.0", "circular-buffer": "1.0.2", From 04dccc1430353b10cd0c668db4cc072a2a0c570d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 01:19:59 -0700 Subject: [PATCH 0897/1496] Proper async update --- lib/blockManager.js | 6 +++--- lib/coins/xmr.js | 14 +++++++------- lib/payment_systems/xmr.js | 4 ++-- lib/remote_comms.js | 4 ++-- lib/worker.js | 4 ++-- package.json | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index c5d997893..961f34e2d 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -391,15 +391,15 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is cursor.close(); txn.abort(); setImmediate(callback, null, totalPaid); - }, function (totalPayment) { + }, function (totalPayment, whilstCB) { blockCheckHeight = blockCheckHeight - 1; debug("Decrementing the block chain check height to:" + blockCheckHeight); if (totalPayment >= rewardTotal) { debug("Loop 1: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); - return false; + return whilstCB(false); } else { debug("Loop 2: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); - return blockCheckHeight !== 0; + return whilstCB(blockCheckHeight !== 0); } }, function (err) { diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 75b46c1de..48bf7bd56 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -183,13 +183,13 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { - //queue_obj.remove(function(task) { - // if (Date.now() - task.time > 5*60*1000) { - // task.cb(null); - // return true; - // } - // return false; - //}); + queue_obj.remove(function(task) { + if (Date.now() - task.time > 5*60*1000) { + task.cb(null); + return true; + } + return false; + }); console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); } }, 30*1000, shareVerifyQueue); diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 388795d79..add4d46d0 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -243,8 +243,8 @@ let xmrToQueue = async.queue(function (task, callback) { } }); }, - function (xmrCallback) { - return xmrCallback !== "TO_BE_CREATED"; + function (xmrCallback, untilCB) { + return untilCB(xmrCallback !== "TO_BE_CREATED"); }, function () { intCallback(null, txnID); diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 70c382b00..c048e673a 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -16,8 +16,8 @@ function Database() { return intCallback(null, 0); }); }, - function (data) { - return data === 200; + function (data, untilCB) { + return untilCB(data === 200); }, function () { callback(); diff --git a/lib/worker.js b/lib/worker.js index e2567b210..166fcffe3 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -142,8 +142,8 @@ function updateShareStats() { debug("On " + height + " height iterated " + count + " elements"); return callback_until(null, oldestTime); - }, function (oldestTime) { - return ++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime; + }, function (oldestTime, untilCB) { + return untilCB(++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime); }, function (err) { debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); diff --git a/package.json b/package.json index ad0742d3f..a829ab0ab 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "author": "Multiple", "license": "MIT", "dependencies": { - "async": "2.1.4", + "async": "3.2.0", "bignum": "^0.12.5", "body-parser": "^1.16.0", "circular-buffer": "1.0.2", From e4a96a666d6bf116effd7ecb94c8b6d3259d590a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 08:48:26 -0700 Subject: [PATCH 0898/1496] Fixed async loops --- lib/blockManager.js | 4 ++-- lib/payment_systems/xmr.js | 2 +- lib/remote_comms.js | 9 +++------ lib/worker.js | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 961f34e2d..7640a4b3f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -396,10 +396,10 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is debug("Decrementing the block chain check height to:" + blockCheckHeight); if (totalPayment >= rewardTotal) { debug("Loop 1: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); - return whilstCB(false); + return whilstCB(null, false); } else { debug("Loop 2: Total Payment: " + totalPayment + " Amount Paid: " + rewardTotal + " Amount Total: " + totalPaid); - return whilstCB(blockCheckHeight !== 0); + return whilstCB(null, blockCheckHeight !== 0); } }, function (err) { diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index add4d46d0..63ce59aeb 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -244,7 +244,7 @@ let xmrToQueue = async.queue(function (task, callback) { }); }, function (xmrCallback, untilCB) { - return untilCB(xmrCallback !== "TO_BE_CREATED"); + return untilCB(null, xmrCallback !== "TO_BE_CREATED"); }, function () { intCallback(null, txnID); diff --git a/lib/remote_comms.js b/lib/remote_comms.js index c048e673a..faf018bf0 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -10,17 +10,14 @@ function Database() { async.doUntil( function (intCallback) { request.post({url: global.config.general.shareHost, body: task.body, forever: true}, function (error, response, body) { - if (!error) { - return intCallback(null, response.statusCode); - } - return intCallback(null, 0); + return intCallback(null, error ? 0 : response.statusCode); }); }, function (data, untilCB) { - return untilCB(data === 200); + return untilCB(null, data === 200); }, function () { - callback(); + return callback(); }); }, require('os').cpus().length*32); diff --git a/lib/worker.js b/lib/worker.js index 166fcffe3..6d072cea2 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -143,7 +143,7 @@ function updateShareStats() { return callback_until(null, oldestTime); }, function (oldestTime, untilCB) { - return untilCB(++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime); + return untilCB(null, ++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime); }, function (err) { debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); From bc5407ae59101fc4a3f08abe7da8cd7fd47cf740 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 10:07:00 -0700 Subject: [PATCH 0899/1496] Updated to new async version --- lib/blockManager.js | 4 ++-- lib/payment_systems/xmr.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 7640a4b3f..1d59a2075 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -157,7 +157,7 @@ function full_stop(err) { let block_unlock_callback = null; let prev_balance_sum = null; -balanceQueue.drain = function () { +balanceQueue.drain(function () { if (!paymentInProgress) { debug("balanceQueue.drain: paymentInProgress is false"); return; @@ -190,7 +190,7 @@ balanceQueue.drain = function () { prev_balance_sum = null; paymentInProgress = false; }); -}; +}); function calculatePPSPayments(blockHeader, callback) { if (global.config.pps.enable === false) return callback(); diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 63ce59aeb..8209a429e 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -360,10 +360,10 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { }, 1); -paymentQueue.drain = function(){ +paymentQueue.drain(function(){ console.log("Payment queue drained"); global.database.setCache('lastPaymentCycle', Math.floor(Date.now()/1000)); -}; +}); function updateShapeshiftCompletion() { global.mysql.query("SELECT * FROM shapeshiftTxn WHERE txnStatus NOT IN ('complete', 'error')").then(function (rows) { From 40c6beb1a156c7684dd56c71aa3eff0f24748e05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Mar 2020 10:27:42 -0700 Subject: [PATCH 0900/1496] Updated to new async version --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1d59a2075..6882122d9 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -109,8 +109,8 @@ let balanceQueue = async.queue(function (task, callback) { return intCallback(null, balanceIDCache[cacheKey]); } else { createBalanceQueue.push(task, function () {}); - async.until(function () { - return cacheKey in balanceIDCache; + async.until(function (untilCB) { + return untilCB(null, cacheKey in balanceIDCache); }, function (intCallback) { createBalanceQueue.push(task, function () { return intCallback(null, balanceIDCache[cacheKey]); From 6832017b101be3dfc41f662eb9901496f8171d8a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Mar 2020 09:51:53 -0700 Subject: [PATCH 0901/1496] Dump ports --- manage_scripts/dump_shares_port.js | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 manage_scripts/dump_shares_port.js diff --git a/manage_scripts/dump_shares_port.js b/manage_scripts/dump_shares_port.js new file mode 100644 index 000000000..c643f0c35 --- /dev/null +++ b/manage_scripts/dump_shares_port.js @@ -0,0 +1,45 @@ +"use strict"; + +let range = require('range'); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.port) { + console.error("Please specify port to dump"); + process.exit(1); +} +const port = argv.port; + +let depth = 10; +if (argv.depth) depth = argv.depth; + +console.log("Dumping shares for " + user + " user"); +if (paymentid) console.log("Dumping shares for " + paymentid + " paymentid"); +if (worker) console.log("Dumping shares for " + worker + " worker"); + +require("../init_mini.js").init(function() { + + global.coinFuncs.getLastBlockHeader(function (err, body) { + if (err !== null) { + console.error("Invalid block header"); + process.exit(1); + } + let lastBlock = body.height + 1; + let txn = global.database.env.beginTxn({readOnly: true}); + + let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); + range.range(lastBlock, lastBlock - depth, -1).forEach(function (blockID) { + for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let shareData = global.protos.Share.decode(data); + if (shareData.port === port) { + var d = new Date(shareData.timestamp); + console.log(d.toString() + ": " + JSON.stringify(shareData)) + } + }); + } + }); + cursor.close(); + txn.commit(); + process.exit(0); + }); +}); From 36f493663867de92207cb79d0fe8802f31f3e22a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Mar 2020 09:53:11 -0700 Subject: [PATCH 0902/1496] Dump ports --- manage_scripts/dump_shares_port.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/manage_scripts/dump_shares_port.js b/manage_scripts/dump_shares_port.js index c643f0c35..485de4e64 100644 --- a/manage_scripts/dump_shares_port.js +++ b/manage_scripts/dump_shares_port.js @@ -12,9 +12,7 @@ const port = argv.port; let depth = 10; if (argv.depth) depth = argv.depth; -console.log("Dumping shares for " + user + " user"); -if (paymentid) console.log("Dumping shares for " + paymentid + " paymentid"); -if (worker) console.log("Dumping shares for " + worker + " worker"); +console.log("Dumping shares for " + port + " port"); require("../init_mini.js").init(function() { From eb94fb3f003dc4c842a80e67813994e663c8c78a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Mar 2020 11:14:37 -0700 Subject: [PATCH 0903/1496] Limit miner diff by BT diff --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index fb7e19814..aa11f9d13 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1031,6 +1031,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.newDiffRecommendation = null; } + if (this.difficulty > bt.difficulty) this.difficulty = bt.difficulty; + const blob_type_num = global.coinFuncs.portBlobType(bt.port); if (!this.proxy) { From 1c7520a9dd0d463f05cdbb35e10f06587cfddd63 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Mar 2020 14:35:27 -0700 Subject: [PATCH 0904/1496] Fixed message --- manage_scripts/get_block_hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/get_block_hash.js b/manage_scripts/get_block_hash.js index 85f572617..975765133 100644 --- a/manage_scripts/get_block_hash.js +++ b/manage_scripts/get_block_hash.js @@ -9,7 +9,7 @@ if (!argv.port) { const port = argv.port; if (!argv.hash) { - console.error("Please specify height"); + console.error("Please specify hash"); process.exit(1); } const hash = argv.hash; From 008b22bc5f174b47dee7be9e9b07483ec02c5bd9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Mar 2020 14:46:24 -0700 Subject: [PATCH 0905/1496] Added DERO orphan status check --- lib/local_comms.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 06f7d9c4c..929dff9a2 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -427,7 +427,8 @@ function Database(){ header.error.message.indexOf("can't get block by hash") > -1 || header.error.message.indexOf("Requested hash wasn't found in main blockchain") > -1 ); - if (is_orphan1 || is_orphan2) { + const is_orphan3 = header.topoheight && header.topoheight === -1; + if (is_orphan1 || is_orphan2 || is_orphan3) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { if (time_now - orphanBlocks[blockDataDecoded.hash] > 10*60*1000) { From 298a73d8bdbdc4ccce36cb1b76ece0f62faaf9c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Mar 2020 14:47:46 -0700 Subject: [PATCH 0906/1496] Fixed message --- manage_scripts/get_block_hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/get_block_hash.js b/manage_scripts/get_block_hash.js index 975765133..792405493 100644 --- a/manage_scripts/get_block_hash.js +++ b/manage_scripts/get_block_hash.js @@ -15,7 +15,7 @@ if (!argv.hash) { const hash = argv.hash; require("../init_mini.js").init(function() { - global.coinFuncs.getPortAnyBlockHeaderByHash(port, hash, true, function (err_header, body_header) { + global.coinFuncs.getPortAnyBlockHeaderByHash(port, hash, false, function (err_header, body_header) { console.log("err:" + JSON.stringify(err_header)); console.log("body:" + JSON.stringify(body_header)); process.exit(0); From e5b41a1d6bd89674222bb9ef450bd7a2671faeed Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Mar 2020 21:37:16 -0700 Subject: [PATCH 0907/1496] Do not retry notify BT updates --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index aa11f9d13..79aecc0d8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -376,12 +376,12 @@ function templateUpdate(coin, repeating) { failedPortLastBlockHeaderCoinHashFactor[coin] = coinHashFactor; console.error(threadName + "Last block header request for " + activePort + " port failed!"); coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdate, 1000, coin, repeating); + if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); } }); else if (cluster.isMaster) { //console.error(threadName + "Last block header request for " + activePort + " port was skipped!"); coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdate, 1000, coin, repeating); + if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); } } @@ -2112,7 +2112,7 @@ if (cluster.isMaster) { console.error(threadName + "Block notify for unknown coin with " + port + " port"); } else { //console.log(threadName + "Block notify for coin " + coin + " with " + port + " port"); - templateUpdate(coin); + templateUpdate(coin, false); } }); socket.on('error', function() { From 224f7b6bca256a76e6d9d2136b8e0aefffb47c60 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Mar 2020 22:25:17 -0700 Subject: [PATCH 0908/1496] Do not retry notify BT updates --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 79aecc0d8..e5fe0b271 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -378,10 +378,10 @@ function templateUpdate(coin, repeating) { coinHashFactorUpdate(coin, 0); if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); } - }); else if (cluster.isMaster) { + }); else if (cluster.isMaster && repeating !== false) { //console.error(threadName + "Last block header request for " + activePort + " port was skipped!"); coinHashFactorUpdate(coin, 0); - if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); + setTimeout(templateUpdate, 1000, coin, repeating); } } From dee10fb242ff02e80afe135b6dd5c89cbcb0bc5d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 21 Mar 2020 19:33:06 -0700 Subject: [PATCH 0909/1496] Removed activePort usage --- lib/pool.js | 172 +++++++++++++++++++--------------------------------- 1 file changed, 62 insertions(+), 110 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e5fe0b271..5d601aa74 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -33,13 +33,12 @@ let notifyAddresses = {}; let activeMiners = new Map(); let lastBlockHash = {}; // coin key -let lastCoinHashFactor = {}; // coin key, last set individual coin hash factor -let currCoinHashFactor = {}; // coin key, current individual coin hash factor -let currCoinHashFactorMM = {}; // coin key, current individual coin hash factor that includes merged mining factor let activeBlockTemplates = {}; // coin key let pastBlockTemplates = {}; // coin key -> global.support.circularBuffer -> activeBlockTemplates -let lastPortErrorTime = {}; // main coin port +let newCoinHashFactor = {}; // coin key, current individual coin hash factor, set in updateCoinHashFactor +let lastCoinHashFactor = {}; // coin key, last set individual coin hash factor, set in setNewCoinHashFactor +let lastCoinHashFactorMM = {}; // coin key, current individual coin hash factor that includes merged mining factor, set in setNewCoinHashFactor let lastBlockFixTime = {}; // time when blocks were checked to be in line with other nodes or when fix_daemon_sh was attempted let lastBlockFixCount = {}; // number of times fix_daemon_sh was run @@ -237,45 +236,16 @@ function checkAliveMiners() { if (elapsed > 50) console.error(threadName + "checkAliveMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); } -function set_hash_factor(coin, hash_factor) { - currCoinHashFactor[coin] = hash_factor; -} - -// global.config.daemon["activePort" + coin] is only updated in master thread -function updateActivePort(coin) { - global.support.getActivePort(coin, function (newActivePort) { - const oldActivePort = global.config.daemon["activePort" + coin]; - if (newActivePort === null) { - if (coin === "" && oldActivePort != global.config.daemon.port) { - console.error("Error getting activePort, so rolling back to main port"); - global.config.daemon.activePort = global.config.daemon.port; - } else { - console.error("Error getting activePort" + coin); - coinHashFactorUpdate(coin, 0); - } +// coin hash factor is only updated in master thread +function updateCoinHashFactor(coin) { + global.support.getCoinHashFactor(coin, function (coinHashFactor) { + if (coinHashFactor === null) { + console.error("Error getting coinHashFactor for " + coin + " coin"); + coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); + } else if (!coinHashFactor) { + coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); } else { - if (coin !== "") { - global.support.getCoinHashFactor(coin, function (newCoinHashFactor) { - if (newCoinHashFactor === null) { - console.error("Error getting coinHashFactor" + coin); - coinHashFactorUpdate(coin, 0); - } else { - if (!newActivePort || !newCoinHashFactor) coinHashFactorUpdate(coin, 0); - else set_hash_factor(coin, newCoinHashFactor); - if (oldActivePort !== newActivePort) { - console.log("Changing activePort" + coin + " from " + oldActivePort + " to " + newActivePort); - global.config.daemon["activePort" + coin] = newActivePort; - } - } - }); - } else if (oldActivePort !== newActivePort) { - if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*60*1000) { - console.log("Changing activePort" + coin + " from " + oldActivePort + " to " + newActivePort); - global.config.daemon["activePort" + coin] = newActivePort; - } else if ((Date.now() - lastPortErrorTime[newActivePort]) % 60*1000 < 6*1000) { // print every 10th message - console.warn("Avoiding changing recently problem activePort" + coin + " from " + oldActivePort + " to " + newActivePort); - } - } + newCoinHashFactor[coin] = coinHashFactor; } }); } @@ -303,25 +273,25 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa } // templateUpdateReal is only called in master thread (except the beginning of a worker thread) -function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange) { - global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { - if (activePort !== global.config.daemon["activePort" + coin]) { - console.log("Aborting " + activePort + " last block template request because " + "activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); +function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { + global.coinFuncs.getPortBlockTemplate(port, function (rpcResponse) { + if (!newCoinHashFactor[coin]) { + console.log("Aborting " + port + " last block template request because " + coin + " already has zero hash factor"); return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { - const template = process_rpc_template(rpcResponse.result, coin, activePort, coinHashFactor, isHashFactorChange); + const template = process_rpc_template(rpcResponse.result, coin, port, coinHashFactor, isHashFactorChange); debug(threadName + "New block template found at " + template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); setNewBlockTemplate(template); // update parent coins if current coin was updated now - if (activePort in global.coinFuncs.getMM_CHILD_PORTS()) { - const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[activePort]; + if (port in global.coinFuncs.getMM_CHILD_PORTS()) { + const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[port]; for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.PORT2COIN(parent_port); if (parent_coin in activeBlockTemplates) { - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, currCoinHashFactor[parent_coin], false); + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, newCoinHashFactor[parent_coin], false); sendToWorkers({type: 'newBlockTemplate', data: parent_template}); setNewBlockTemplate(parent_template); } @@ -331,57 +301,48 @@ function templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange setNewBlockTemplate(template); } } else { - console.error("Block template request failed for " + activePort + " port."); + console.error("Block template request failed for " + port + " port."); coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdateReal, 3000, coin, activePort, coinHashFactor, isHashFactorChange); + setTimeout(templateUpdateReal, 3000, coin, port, coinHashFactor, isHashFactorChange); } }); } function coinHashFactorUpdate(coin, coinHashFactor) { if (coin === "") return; - if (currCoinHashFactor[coin] === 0 && coinHashFactor === 0) return; + if (coinHashFactor === 0 && lastCoinHashFactor[coin] === 0) return; if (cluster.isMaster) { - //console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor); + //console.log('[*] New ' + coin + ' coin hash factor is set from ' + newCoinHashFactor[coin] + ' to ' + coinHashFactor); let data = { coin: coin, coinHashFactor: coinHashFactor }; sendToWorkers({type: 'newCoinHashFactor', data: data}); } setNewCoinHashFactor(true, coin, coinHashFactor); } -let failedPortLastBlockHeaderCoinHashFactor = {}; - // templateUpdate is only called in master thread (except the beginning of a worker thread) function templateUpdate(coin, repeating) { - const activePort = global.config.daemon["activePort" + coin]; - let coinHashFactor = currCoinHashFactor[coin]; - if (activePort && (coinHashFactor || (coin in failedPortLastBlockHeaderCoinHashFactor))) global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { - if (coin in failedPortLastBlockHeaderCoinHashFactor) { - if (!coinHashFactor) coinHashFactor = failedPortLastBlockHeaderCoinHashFactor[coin]; - delete failedPortLastBlockHeaderCoinHashFactor[coin]; - } - if (activePort !== global.config.daemon["activePort" + coin]) { - console.log(threadName + "Aborting " + activePort + " last block header request because activePort" + coin + " was already changed to " + global.config.daemon["activePort" + coin] + " port"); + const port = global.coinFuncs.COIN2PORT(parent_port); + const coinHashFactor = newCoinHashFactor[coin]; + if (coinHashFactor) global.coinFuncs.getPortLastBlockHeader(port, function (err, body) { + if (!newCoinHashFactor[coin]) { + console.log(threadName + "Aborting " + port + " last block header request because " + coin + " already has zero hash factor"); if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); } else if (err === null) { - const isHashFactorChange = !(coin in lastCoinHashFactor) || Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; + const isHashFactorChange = Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; - templateUpdateReal(coin, activePort, coinHashFactor, isHashFactorChange); + templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange); } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); } else { - failedPortLastBlockHeaderCoinHashFactor[coin] = coinHashFactor; - console.error(threadName + "Last block header request for " + activePort + " port failed!"); + console.error(threadName + "Last block header request for " + port + " port failed!"); coinHashFactorUpdate(coin, 0); if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); } - }); else if (cluster.isMaster && repeating !== false) { - //console.error(threadName + "Last block header request for " + activePort + " port was skipped!"); - coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdate, 1000, coin, repeating); + }); else if (cluster.isMaster) { + if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); } } @@ -410,7 +371,7 @@ function anchorBlockUpdate() { function getCoinJobParams(coin) { let params = {}; params.bt = activeBlockTemplates[coin]; - params.coinHashFactor = currCoinHashFactorMM[coin]; + params.coinHashFactor = lastCoinHashFactorMM[coin]; params.algo_name = global.coinFuncs.algoShortTypeStr(params.bt.port, params.bt.buffer[0]); //params.variant_name = params.algo_name.split('/')[1]; return params; @@ -418,19 +379,18 @@ function getCoinJobParams(coin) { function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_height) { if (isHashFactorChange) lastCoinHashFactor[coin] = coinHashFactor; + const prevCoinHashFactorMM = lastCoinHashFactorMM[coin]; + lastCoinHashFactorMM[coin] = coinHashFactor; // used in miner.selectBestCoin - // used in miner.selectBestCoin - currCoinHashFactorMM[coin] = coinHashFactor; const port = global.coinFuncs.COIN2PORT(coin); const is_mm = port in global.coinFuncs.getMM_PORTS(); if (is_mm) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); - if (child_coin in lastCoinHashFactor) currCoinHashFactorMM[coin] += lastCoinHashFactor[child_coin]; + lastCoinHashFactorMM[coin] += lastCoinHashFactor[child_coin]; } - if (coin !== "") { - if (cluster.isMaster) console.log('[*] New ' + coin + ' coin hash factor is set from ' + currCoinHashFactor[coin] + ' to ' + coinHashFactor + (is_mm ? ' (MM: ' + currCoinHashFactorMM[coin] + ')' : "")); - set_hash_factor(coin, coinHashFactor); + if (cluster.isMaster && coin !== "" && prevCoinHashFactorMM != lastCoinHashFactorMM[coin]) { + console.log('[*] New ' + coin + ' coin hash factor is set from ' + prevCoinHashFactorMM + ' to ' + coinHashFactor + (is_mm ? ' (MM: ' + lastCoinHashFactorMM[coin] + ')' : "")); } if (!(coin in activeBlockTemplates)) return; @@ -439,9 +399,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[port]; for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.PORT2COIN(parent_port); - if (parent_coin in lastCoinHashFactor) { - setNewCoinHashFactor(true, parent_coin, lastCoinHashFactor[parent_coin], 0); - } + setNewCoinHashFactor(true, parent_coin, lastCoinHashFactor[parent_coin], 0); } } @@ -454,7 +412,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he const algo = global.coinFuncs.algoShortTypeStr(port, block_version); strLogPrefix = "Full BT update for coin " + coin; - if (cluster.isMaster) console.log(threadName + strLogPrefix + " with hash factor changed to " + currCoinHashFactorMM[coin]); + if (cluster.isMaster) console.log(threadName + strLogPrefix + " with hash factor changed to " + lastCoinHashFactorMM[coin]); if (check_height) { for (var [minerId, miner] of activeMiners) { @@ -472,7 +430,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he } else { strLogPrefix = "Fast BT update for coin " + coin; - if (cluster.isMaster) console.log(threadName + strLogPrefix + " with the same " + currCoinHashFactorMM[coin] + " hash factor"); + if (cluster.isMaster) console.log(threadName + strLogPrefix + " with the same " + lastCoinHashFactorMM[coin] + " hash factor"); const params = getCoinJobParams(coin); if (check_height) { @@ -864,7 +822,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.selectBestCoin = function() { if (this.debugMiner) console.log(threadName + this.logString + ": current coin is " + this.curr_coin); - if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && currCoinHashFactorMM[this.curr_coin] && + if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && lastCoinHashFactorMM[this.curr_coin] && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { return this.curr_coin; @@ -881,7 +839,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplates"); return; } - const coinHashFactor = currCoinHashFactorMM[coin]; + const coinHashFactor = lastCoinHashFactorMM[coin]; if (!coinHashFactor) { if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); return; @@ -906,7 +864,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { this.curr_min_diff = global.coinFuncs.blobTypeGrin(global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin))) ? 1 : global.config.pool.minDifficulty; const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; - const factor = curr_hash_factor / currCoinHashFactorMM[best_coin]; + const factor = curr_hash_factor / lastCoinHashFactorMM[best_coin]; if (factor != 1) { if (this.hashes === 0) { this.setNewDiff(this.difficulty * factor); @@ -917,7 +875,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } } this.curr_coin = best_coin; - this.curr_coin_hash_factor = currCoinHashFactorMM[best_coin]; + this.curr_coin_hash_factor = lastCoinHashFactorMM[best_coin]; this.curr_coin_time = Date.now(); if (global.config.pool.trustedMiners) this.trust.check_height = activeBlockTemplates[best_coin].height; } @@ -1944,11 +1902,11 @@ setInterval(function dump_vars() { s.write("\n\n\nlastCoinHashFactor:\n"); s.write(JSON.stringify(lastCoinHashFactor, null, '\t') + "\n"); - s.write("\n\n\ncurrCoinHashFactor:\n"); - s.write(JSON.stringify(currCoinHashFactor, null, '\t') + "\n"); + s.write("\n\n\nnewCoinHashFactor:\n"); + s.write(JSON.stringify(newCoinHashFactor, null, '\t') + "\n"); - s.write("\n\n\ncurrCoinHashFactorMM:\n"); - s.write(JSON.stringify(currCoinHashFactorMM, null, '\t') + "\n"); + s.write("\n\n\nlastCoinHashFactorMM:\n"); + s.write(JSON.stringify(lastCoinHashFactorMM, null, '\t') + "\n"); s.write("\n\n\nactiveBlockTemplates:\n"); s.write(JSON.stringify(activeBlockTemplates, null, '\t') + "\n"); @@ -2072,22 +2030,16 @@ if (cluster.isMaster) { }); - if (!global.config.daemon.activePort) { - console.warn("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); - global.config.daemon.activePort = global.config.daemon.port; - } else { - currCoinHashFactor[""] = currCoinHashFactorMM[""] = 1; - setInterval(updateActivePort, 3*1000, ""); + if (global.config.daemon.enableAlgoSwitching) { + newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { - currCoinHashFactor[coin] = currCoinHashFactorMM[coin] = 0; - if ("activePort" + coin in global.config.daemon) { - setInterval(updateActivePort, 5*1000, coin); - templateUpdate(coin); - setTimeout(templateUpdate, DAEMON_POLL_MS, coin, true); - } else { - console.warn("global.config.daemon." + "activePort" + coin + " is not defined, so ignoring its coin changes"); - } + newCoinHashFactor[coin] = lastCoinHashFactor[coin] = lastCoinHashFactorMM[coin] = 0; + setInterval(updateCoinHashFactor, 5*1000, coin); + templateUpdate(coin); + setTimeout(templateUpdate, DAEMON_POLL_MS, coin, true); }); + } else { + console.warn("global.config.daemon.enableAlgoSwitching is not enabled"); } templateUpdate(""); @@ -2126,11 +2078,11 @@ if (cluster.isMaster) { }); } else { - currCoinHashFactor[""] = currCoinHashFactorMM[""] = 1; + newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; templateUpdate(""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { - currCoinHashFactor[coin] = currCoinHashFactorMM[coin] = 0; - if ("activePort" + coin in global.config.daemon) templateUpdate(coin); + newCoinHashFactor[coin] = lastCoinHashFactor[coin] = lastCoinHashFactorMM[coin] = 0; + templateUpdate(coin); }); anchorBlockUpdate(); setInterval(anchorBlockUpdate, 3*1000); From 05afd03cac3639fb4a01bb73cc4b7da356a52d69 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 21 Mar 2020 19:35:25 -0700 Subject: [PATCH 0910/1496] Removed activePort usage --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5d601aa74..4a976b2a5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -321,7 +321,7 @@ function coinHashFactorUpdate(coin, coinHashFactor) { // templateUpdate is only called in master thread (except the beginning of a worker thread) function templateUpdate(coin, repeating) { - const port = global.coinFuncs.COIN2PORT(parent_port); + const port = global.coinFuncs.COIN2PORT(coin); const coinHashFactor = newCoinHashFactor[coin]; if (coinHashFactor) global.coinFuncs.getPortLastBlockHeader(port, function (err, body) { if (!newCoinHashFactor[coin]) { From 5296ae6b91891e59e287cf5732c2f6d90d744a50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Mar 2020 12:28:17 -0700 Subject: [PATCH 0911/1496] Limit usage of newCoinHashFactor to update template/header functions --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4a976b2a5..4a47d3ba2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -291,7 +291,7 @@ function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.PORT2COIN(parent_port); if (parent_coin in activeBlockTemplates) { - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, newCoinHashFactor[parent_coin], false); + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, lastCoinHashFactor[parent_coin], false); sendToWorkers({type: 'newBlockTemplate', data: parent_template}); setNewBlockTemplate(parent_template); } From a68e8ab0637e1e83e78cdc6ff4f1ec5ee73a3672 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 24 Mar 2020 17:10:59 -0700 Subject: [PATCH 0912/1496] Added noemail notify silent miners --- lib/worker.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 6d072cea2..60868b98e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -247,11 +247,14 @@ function updateShareStats() { if (miner.indexOf('_') <= -1) continue; // This is a worker case. - let address_parts = miner.split(/_(.+)/); - let address = address_parts[0]; - get_address_email(address, function (email) { - setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, email, currentTime); - }); + const address_parts = miner.split(/_(.+)/); + const worker = address_parts[1]; + if (!worker.includes('silent')) { + const address = address_parts[0]; + get_address_email(address, function (email) { + setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, email, currentTime); + }); + } } debug("Old worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); @@ -263,11 +266,14 @@ function updateShareStats() { if (miner.indexOf('_') <= -1) continue; // This is a worker case. - let address_parts = miner.split(/_(.+)/); - let address = address_parts[0]; - get_address_email(address, function (email) { - send_worker_started_hashing_email(miner, email, currentTime); - }); + const address_parts = miner.split(/_(.+)/); + const worker = address_parts[1]; + if (!worker.includes('silent')) { + const address = address_parts[0]; + get_address_email(address, function (email) { + send_worker_started_hashing_email(miner, email, currentTime); + }); + } } debug("New worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); From 8a5efbb1a006bba466a81a9eedd1806cb97602f1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 24 Mar 2020 20:26:52 -0700 Subject: [PATCH 0913/1496] Added email notify for restarts --- lib/worker.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index 60868b98e..a9b53f7db 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -404,6 +404,9 @@ function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { ); } + +global.support.sendEmail(global.config.general.adminEmail, "FYI: Restarting worker module", "Restarted worker module!"); + updateShareStats(); // clean stats_cache from time to time setInterval(function() { stats_cache = {}; } , 4*60*60*1000); From 14ed4833967647672e06d15cdfb8dc73080fd998 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Apr 2020 07:05:55 -0700 Subject: [PATCH 0914/1496] Fixed undefined string --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index a9b53f7db..3882fabe7 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -249,7 +249,7 @@ function updateShareStats() { // This is a worker case. const address_parts = miner.split(/_(.+)/); const worker = address_parts[1]; - if (!worker.includes('silent')) { + if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { const address = address_parts[0]; get_address_email(address, function (email) { setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, email, currentTime); @@ -268,7 +268,7 @@ function updateShareStats() { // This is a worker case. const address_parts = miner.split(/_(.+)/); const worker = address_parts[1]; - if (!worker.includes('silent')) { + if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { const address = address_parts[0]; get_address_email(address, function (email) { send_worker_started_hashing_email(miner, email, currentTime); From 3994f07dd50be424a847f1fb336e70b83d029d4f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 Apr 2020 08:15:28 -0700 Subject: [PATCH 0915/1496] Added early DB overflow warning --- deployment/base.sql | 1 + lib/local_comms.js | 3 +++ lib/worker.js | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 33ebaa192..2b7925014 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -310,6 +310,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunNoCert', 'false', 'bool', 'Disable certificate check for MailGun'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'emailFrom', '', 'string', 'From address for the notification emails'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'testnet', 'false', 'bool', 'Does this pool use testnet?'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'blockCleanWarning', '360', 'int', 'Blocks before longRunner cleaner module will start to warn.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'enable', 'true', 'bool', 'Enable PPLNS on the pool.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('solo', 'enable', 'true', 'bool', 'Enable SOLO mining on the pool'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewAmount', '.011', 'float', 'Amount to charge for the txn fee'); diff --git a/lib/local_comms.js b/lib/local_comms.js index 929dff9a2..40a48b38f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -843,6 +843,9 @@ function Database(){ } } else { + if (body.height - oldestLockedBlockHeight > global.config.general.blockCleanWarning) { + global.support.sendEmail(global.config.general.adminEmail, "longRunner module can not clean DB good enough", "longRunner can not clean " + (body.height - oldestLockedBlockHeight) + " block from DB!"); + } /* Otherwise, start the scan from the oldest locked block downwards. This protects against the blockManager being messed up and not unlocking blocks. diff --git a/lib/worker.js b/lib/worker.js index 3882fabe7..83ef74061 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -405,7 +405,7 @@ function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { } -global.support.sendEmail(global.config.general.adminEmail, "FYI: Restarting worker module", "Restarted worker module!"); +global.support.sendEmail(global.config.general.adminEmail, "Restarting worker module", "Restarted worker module!"); updateShareStats(); // clean stats_cache from time to time From 055ef69bffa8eba61f71b0529d626823bd086079 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Apr 2020 17:44:52 -0700 Subject: [PATCH 0916/1496] Fixed bug when proxy miner is deleted --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4a47d3ba2..6b2b7326b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -204,7 +204,7 @@ function retargetMiners() { let proxyMiners = {}; function addProxyMiner(miner) { - if (miner.proxyMinerName) return; + if (miner.proxyMinerName && miner.proxyMinerName in proxyMiners) return; const proxyMinerName = miner.payout + ":" + miner.identifier; miner.proxyMinerName = proxyMinerName; From cea059bc4fba672c17f56211ae165f9188b4c27a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 12 Apr 2020 09:54:53 -0700 Subject: [PATCH 0917/1496] Increased DB size --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 40a48b38f..ac905e49d 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -31,7 +31,7 @@ function Database(){ global.database.env.open({ path: global.config.db_storage_path, maxDbs: 10, - mapSize: 4 * 1024 * 1024 * 1024, + mapSize: 8 * 1024 * 1024 * 1024, useWritemap: true, maxReaders: 512 }); From c512ffe673afb1840ca64209357aba11f7c04779 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 22 Apr 2020 08:56:11 -0700 Subject: [PATCH 0918/1496] Precalc payments for blocks that has daemon issues --- lib/blockManager.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 6882122d9..82d492aee 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -693,16 +693,7 @@ function altblockUnlocker() { const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; //console.log(block.port + ": " + block.hash); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { - if (err !== null) { - console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); - global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { - if (err === null && body.hash !== block.hash) { - global.database.invalidateAltBlock(block.id); - console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); - } - return next(); - }); - } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; @@ -718,6 +709,15 @@ function altblockUnlocker() { return next(); } }); + } else if (err !== null) { + console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); + global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { + if (err === null && body.hash !== block.hash) { + global.database.invalidateAltBlock(block.id); + console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); + } + return next(); + }); } else if (!is_pplns_block || block.pay_ready === true) { if (block.pay_value !== 0) { altblockPayments(block, function() { return next(); } ); From b2511a1a309f1cf9f43d950a49b31609886051a8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 22 Apr 2020 09:30:09 -0700 Subject: [PATCH 0919/1496] Detect orphan DERO blocks --- lib/blockManager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 82d492aee..d96214783 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -709,6 +709,10 @@ function altblockUnlocker() { return next(); } }); + } else if (body.topoheight && body.topoheight === -1) { + global.database.invalidateAltBlock(block.id); + console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); + return next(); } else if (err !== null) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { From 16bd8098f33a4981f9e93530b5f202effd310fe9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 May 2020 15:20:03 -0700 Subject: [PATCH 0920/1496] Fixed block stats --- lib/pool_stats.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 87f43469c..78a636042 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -81,10 +81,28 @@ function updatePoolStats2(poolType) { } let port_hash = global.database.getCache('port_hash'); - blockList = blockList.length ? blockList.slice(max_blocks).concat(global.database.getBlockList(poolType, 0, max_blocks)) - : global.database.getBlockList(poolType); - altblockList = altblockList.length ? altblockList.slice(max_altblocks).concat(global.database.getAltBlockList(poolType, null, 0, max_altblocks)) - : global.database.getAltBlockList(poolType); + if (blockList.length) { + const newBlocks = global.database.getBlockList(poolType, 0, max_blocks); + let addBlocks = []; + for (let block of newBlocks) { + if (block.hash == blockList[0].hash) break; + addBlocks.unshift(block); + } + blockList = blockList.concat(addBlocks); + } else { + blockList = global.database.getBlockList(poolType); + } + if (altblockList.length) { + const newBlocks = global.database.getAltBlockList(poolType, null, 0, max_altblocks); + let addBlocks = []; + for (let block of newBlocks) { + if (block.hash == blockList[0].hash) break; + addBlocks.unshift(block); + } + altblockList = altblockList.concat(addBlocks); + } else { + altblockList = global.database.getAltBlockList(poolType); + } let min_block_rewards2 = global.database.getCache('min_block_rewards'); if (min_block_rewards2) min_block_rewards = min_block_rewards2; if (!(global.config.daemon.port in min_block_rewards)) min_block_rewards[global.config.daemon.port] = 0; From a95b0d04b2b0e8f11bcb2ee4aa2226d49c8e1dc6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 May 2020 15:22:47 -0700 Subject: [PATCH 0921/1496] Fixed block stats --- lib/pool_stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 78a636042..f9a0944fe 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -96,7 +96,7 @@ function updatePoolStats2(poolType) { const newBlocks = global.database.getAltBlockList(poolType, null, 0, max_altblocks); let addBlocks = []; for (let block of newBlocks) { - if (block.hash == blockList[0].hash) break; + if (block.hash == altblockList[0].hash) break; addBlocks.unshift(block); } altblockList = altblockList.concat(addBlocks); From a819830a7f610efee495657435e9f429997d428c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 May 2020 19:44:49 -0700 Subject: [PATCH 0922/1496] Fixed block stats --- lib/pool_stats.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index f9a0944fe..9e1cbc75c 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -86,9 +86,9 @@ function updatePoolStats2(poolType) { let addBlocks = []; for (let block of newBlocks) { if (block.hash == blockList[0].hash) break; - addBlocks.unshift(block); + addBlocks.push(block); } - blockList = blockList.concat(addBlocks); + blockList = addBlocks.concat(blockList); } else { blockList = global.database.getBlockList(poolType); } @@ -97,9 +97,9 @@ function updatePoolStats2(poolType) { let addBlocks = []; for (let block of newBlocks) { if (block.hash == altblockList[0].hash) break; - addBlocks.unshift(block); + addBlocks.push(block); } - altblockList = altblockList.concat(addBlocks); + altblockList = addBlocks.concat(altblockList); } else { altblockList = global.database.getAltBlockList(poolType); } From df8af1f5f52259a7b5ef4c94940b8dfb90996b8e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 May 2020 19:55:31 -0700 Subject: [PATCH 0923/1496] Updated minimist --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a829ab0ab..b24c44003 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "express": "4.14.0", "apicache": "1.2.1", "jsonwebtoken": "^7.2.1", - "minimist": "1.2.0", + "minimist": ">=1.2.3", "moment": "2.21.0", "mysql": "2.15.0", "node-lmdb": "0.7.0", From 4a32ac3c0a8aab5245b93821e65020dfb489041d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 May 2020 09:33:16 -0700 Subject: [PATCH 0924/1496] Fixed block stats --- lib/pool_stats.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 9e1cbc75c..b1efa4506 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -81,25 +81,27 @@ function updatePoolStats2(poolType) { } let port_hash = global.database.getCache('port_hash'); - if (blockList.length) { + if (blockList.length > max_blocks) { const newBlocks = global.database.getBlockList(poolType, 0, max_blocks); - let addBlocks = []; + let new_block_count = 0; + let prev_block_index = 0; for (let block of newBlocks) { - if (block.hash == blockList[0].hash) break; - addBlocks.push(block); + if (block.hash == blockList[prev_block_index].hash) ++ prev_block_index; + else ++ new_block_count; } - blockList = addBlocks.concat(blockList); + blockList = newBlocks.concat(blockList.slice(max_blocks - new_block_count)); } else { blockList = global.database.getBlockList(poolType); } - if (altblockList.length) { + if (altblockList.length > max_altblocks) { const newBlocks = global.database.getAltBlockList(poolType, null, 0, max_altblocks); - let addBlocks = []; + let new_block_count = 0; + let prev_block_index = 0; for (let block of newBlocks) { - if (block.hash == altblockList[0].hash) break; - addBlocks.push(block); + if (block.hash == altblockList[prev_block_index].hash) ++ prev_block_index; + else ++ new_block_count; } - altblockList = addBlocks.concat(altblockList); + altblockList = newBlocks.concat(altblockList.slice(max_altblocks - new_block_count)); } else { altblockList = global.database.getAltBlockList(poolType); } From 4e3d9a172b9944afef0f92393797afc8d10cbd93 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 May 2020 19:53:21 -0700 Subject: [PATCH 0925/1496] Updated api endpoints --- deployment/base.sql | 1 + lib/api.js | 27 +++++++++++++++++++++------ lib/payment_systems/xmr.js | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 2b7925014..cc9853ec5 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -260,6 +260,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'soloFee', '.4', 'float', 'Fee charged for usage of the solo mining pool'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'exchangeMin', '1', 'float', 'Minimum XMR balance for payout to exchange/payment ID'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'walletMin', '.3', 'float', 'Minimum XMR balance for payout to personal wallet'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'defaultPay', '.3', 'float', 'Default XMR balance for payout'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'devDonation', '3', 'float', 'Donation to XMR core development'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'poolDevDonation', '3', 'float', 'Donation to pool developer'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'denom', '.000001', 'float', 'Minimum balance that will be paid out to.'); diff --git a/lib/api.js b/lib/api.js index a0a25ef0b..57e3558ce 100644 --- a/lib/api.js +++ b/lib/api.js @@ -508,24 +508,39 @@ app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { }); app.get('/user/:address', function (req, res) { - global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE username = ?", [req.params.address]).then(function(row){ - return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}}); + global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE username = ? LIMIT 1", [req.params.address]).then(function(row){ + if (row.length == 1) { + return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}}); + } else { + return res.json({msg: {payout_threshold: global.support.decimalToCoin(global.config.payout.defaultPay), email_enabled: 0}}); + } }); }); -app.post('/user/toggleEmail', function (req, res) { +app.post('/user/subscribeEmail', function (req, res) { const enabled = req.body.enabled; - if (!enabled) return res.status(401).send({'success': false, 'msg': "Can't set enabled to a wrong value"}); + if (!enabled) return res.status(401).send({'success': false, 'msg': "No \"enabled\" parameter was found"}); global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, req.body.username]).then(function () { - return res.json({'msg': 'Email toggled'}); + return res.json({'msg': 'Email preferences were updated'}); + }); +}); + +app.post('/user/unsubscribeEmail', function (req, res) { + global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.body.username]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + return res.json({'msg': 'Unknown XMR address provided or it was already unsubscribed from emails'}); + } else { + return res.json({'msg': 'Your email was unsubscribed from further notifications'}); + } }); }); app.post('/user/updateThreshold', function (req, res) { const threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); + if (!req.body.username || global.database.getCache(req.body.username) === false) return res.status(401).send({'success': false, 'msg': "Can't set threshold for unknown user"}); const threshold2 = global.support.decimalToCoin(threshold < global.config.payout.walletMin ? global.config.payout.walletMin : threshold); - global.mysql.query("UPDATE users SET payout_threshold = ? WHERE username = ?", [threshold2, req.body.username]).then(function () { + global.mysql.query("INSERT INTO users (username, payout_threshold) VALUES (?, ?) ON DUPLICATE KEY UPDATE payout_threshold=?", [req.body.username, threshold2, threshold2]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold2)}); }); }); diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 8209a429e..34ce0d1cc 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -705,7 +705,7 @@ function makePayments() { if ((row.payment_address + (row.payment_id ? ('.' + row.payment_id) : '')) in payeeObjects) return next(); // avoid doing payment for different pool types at the same time let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { - let threshold = global.support.decimalToCoin(0.3); + let threshold = global.support.decimalToCoin(global.config.payout.defaultPay); let custom_threshold = false; if (userRow.length !== 0 && userRow[0].payout_threshold != 0) { threshold = userRow[0].payout_threshold; From b82aad5b8ebd1ec00acfc5e146ec3b79b7a157c7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 May 2020 20:07:46 -0700 Subject: [PATCH 0926/1496] Updated api endpoints --- lib/api.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/api.js b/lib/api.js index 57e3558ce..ccefd3141 100644 --- a/lib/api.js +++ b/lib/api.js @@ -507,6 +507,16 @@ app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { }); }); +app.post('/miner/:address/unsubscribeEmail', function (req, res) { + global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.params.address]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + return res.json({'msg': 'Unknown XMR address provided or it was already unsubscribed from emails'}); + } else { + return res.json({'msg': 'Your email was unsubscribed from further notifications'}); + } + }); +}); + app.get('/user/:address', function (req, res) { global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE username = ? LIMIT 1", [req.params.address]).then(function(row){ if (row.length == 1) { @@ -525,16 +535,6 @@ app.post('/user/subscribeEmail', function (req, res) { }); }); -app.post('/user/unsubscribeEmail', function (req, res) { - global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.body.username]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - return res.json({'msg': 'Unknown XMR address provided or it was already unsubscribed from emails'}); - } else { - return res.json({'msg': 'Your email was unsubscribed from further notifications'}); - } - }); -}); - app.post('/user/updateThreshold', function (req, res) { const threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); From e834f5dddc4f291c14b2e280c64f478a1a73768c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 May 2020 20:09:32 -0700 Subject: [PATCH 0927/1496] Updated api endpoints --- lib/api.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/api.js b/lib/api.js index ccefd3141..1620dc03f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -507,16 +507,6 @@ app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { }); }); -app.post('/miner/:address/unsubscribeEmail', function (req, res) { - global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.params.address]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - return res.json({'msg': 'Unknown XMR address provided or it was already unsubscribed from emails'}); - } else { - return res.json({'msg': 'Your email was unsubscribed from further notifications'}); - } - }); -}); - app.get('/user/:address', function (req, res) { global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE username = ? LIMIT 1", [req.params.address]).then(function(row){ if (row.length == 1) { @@ -535,6 +525,16 @@ app.post('/user/subscribeEmail', function (req, res) { }); }); +app.get('/user/:address/unsubscribeEmail', function (req, res) { + global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.params.address]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + return res.json({'msg': 'Unknown XMR address provided or it was already unsubscribed from emails'}); + } else { + return res.json({'msg': 'Your email was unsubscribed from further notifications'}); + } + }); +}); + app.post('/user/updateThreshold', function (req, res) { const threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); From 3362433d26ecc31789dd373b22d2c614cfa30ff8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 May 2020 09:20:07 -0700 Subject: [PATCH 0928/1496] Compute top --- block_share_dumps/calc_mo_cvs_top.js | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 block_share_dumps/calc_mo_cvs_top.js diff --git a/block_share_dumps/calc_mo_cvs_top.js b/block_share_dumps/calc_mo_cvs_top.js new file mode 100644 index 000000000..2cc85aca0 --- /dev/null +++ b/block_share_dumps/calc_mo_cvs_top.js @@ -0,0 +1,75 @@ +"use strict"; + +if (Boolean(process.stdin.isTTY) || process.argv.length !== 2) { + console.log("Usage: unxz -c .cvs.xz | node calc_mo_cvs_top.js"); + console.log(" wget -O - https://block-share-dumps.moneroocean.stream/.cvs.xz | unxz -c | node calc_mo_cvs_top.js"); + process.exit(1); +} + +let stdin = ""; + +process.stdin.on('data', function(data) { + stdin += data.toString(); +}); + +function human_hashrate(hashes) { + const power = Math.pow(10, 2 || 0); + if (hashes > 1000000000000) return String(Math.round((hashes / 1000000000000) * power) / power) + " TH/s"; + if (hashes > 1000000000) return String(Math.round((hashes / 1000000000) * power) / power) + " GH/s"; + if (hashes > 1000000) return String(Math.round((hashes / 1000000) * power) / power) + " MH/s"; + if (hashes > 1000) return String(Math.round((hashes / 1000) * power) / power) + " KH/s"; + return Math.floor( hashes || 0 ) + " H/s" +}; + +process.stdin.on('end', function() { + let pplns_window = 0; + let oldest_timestamp = 0; + let newest_timestamp = 0; + + let wallets = {}; + + let my_share_count = 0; + let my_xmr_diff = 0; + let my_xmr_diff_payed = 0; + let my_coin_raw_diff = {}; + let my_coin_xmr_diff = {}; + + for (let line of stdin.split("\n")) { + if (line.substring(0, 1) == "#") continue; + const items = line.split('\t'); + if (items.length < 7) { + console.error("Skipped invalid line: " + line); + continue; + } + const wallet = items[0]; + const timestamp = parseInt(items[1], 16); + const raw_diff = parseInt(items[2]); + const count = parseInt(items[3]); + const coin = items[4]; + const xmr_diff = parseInt(items[5]); + const xmr_diff_payed = items[6] == "" ? xmr_diff : parseInt(items[6]); + pplns_window += xmr_diff; + if (!oldest_timestamp || timestamp < oldest_timestamp) oldest_timestamp = timestamp; + if (newest_timestamp < timestamp) newest_timestamp = timestamp; + if (!(wallet in wallets)) wallets[wallet] = { + share_count: 0, + xmr_diff: 0, + xmr_diff_payed: 0, + coin_raw_diff: {}, + coin_xmr_diff: {}, + }; + wallets[wallet].share_count += count; + wallets[wallet].xmr_diff += xmr_diff; + wallets[wallet].xmr_diff_payed += xmr_diff_payed; + if (!(coin in wallets[wallet].coin_raw_diff)) wallets[wallet].coin_raw_diff[coin] = 0; + wallets[wallet].coin_raw_diff[coin] += raw_diff; + if (!(coin in wallets[wallet].coin_xmr_diff)) wallets[wallet].coin_xmr_diff[coin] = 0; + wallets[wallet].coin_xmr_diff[coin] += xmr_diff; + } + + for (let wallet of Object.keys(wallets).sort((a, b) => (wallets[a].xmr_diff < wallets[b].xmr_diff) ? 1 : -1)) { + console.log(wallet + ": " + wallets[wallet].xmr_diff); + } + + process.exit(0); +}); \ No newline at end of file From ca277875ba4defcc20dd750ea676829def8d07fd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 May 2020 17:32:47 -0700 Subject: [PATCH 0929/1496] Updated API --- lib/api.js | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/lib/api.js b/lib/api.js index 1620dc03f..fce8fc684 100644 --- a/lib/api.js +++ b/lib/api.js @@ -510,9 +510,9 @@ app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { app.get('/user/:address', function (req, res) { global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE username = ? LIMIT 1", [req.params.address]).then(function(row){ if (row.length == 1) { - return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}}); + return res.json({payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}); } else { - return res.json({msg: {payout_threshold: global.support.decimalToCoin(global.config.payout.defaultPay), email_enabled: 0}}); + return res.json({payout_threshold: global.support.decimalToCoin(global.config.payout.defaultPay), email_enabled: 0}); } }); }); @@ -520,15 +520,48 @@ app.get('/user/:address', function (req, res) { app.post('/user/subscribeEmail', function (req, res) { const enabled = req.body.enabled; if (!enabled) return res.status(401).send({'success': false, 'msg': "No \"enabled\" parameter was found"}); - global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, req.body.username]).then(function () { - return res.json({'msg': 'Email preferences were updated'}); - }); + const username = req.body.username; + if (!username) return res.status(401).send({'success': false, 'msg': "No \"username\" parameter was found"}); + const from = req.body.from; + const to = req.body.to; + if (!from && to) { + global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND email = NULL", [enabled, to, username]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + if (global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set email for unknown user"}); + global.mysql.query("INSERT INTO users (username, enable_email, email) VALUES (?, ?, ?)", [username, enabled, to]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + return res.status(401).json({'error': 'FROM email does not match'}); + } else { + return res.json({'msg': 'Email preferences were updated'}); + } + }); + } else { + return res.json({'msg': 'Email preferences were updated'}); + } + }); + } else if (from && to) { + global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND email = ?", [enabled, to, username, from]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + return res.status(401).json({'error': 'FROM email does not match'}); + } else { + return res.json({'msg': 'Email preferences were updated'}); + } + }); + } else { + global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, username]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + return res.status(401).json({'error': 'This XMR address does not have email subscription'}); + } else { + return res.json({'msg': 'Email preferences were updated'}); + } + }); + } }); app.get('/user/:address/unsubscribeEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.params.address]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - return res.json({'msg': 'Unknown XMR address provided or it was already unsubscribed from emails'}); + return res.status(401).json({'error': 'This XMR address does not have email subscription'}); } else { return res.json({'msg': 'Your email was unsubscribed from further notifications'}); } @@ -538,9 +571,10 @@ app.get('/user/:address/unsubscribeEmail', function (req, res) { app.post('/user/updateThreshold', function (req, res) { const threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); - if (!req.body.username || global.database.getCache(req.body.username) === false) return res.status(401).send({'success': false, 'msg': "Can't set threshold for unknown user"}); + const username = req.body.username; + if (!username || global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set threshold for unknown user"}); const threshold2 = global.support.decimalToCoin(threshold < global.config.payout.walletMin ? global.config.payout.walletMin : threshold); - global.mysql.query("INSERT INTO users (username, payout_threshold) VALUES (?, ?) ON DUPLICATE KEY UPDATE payout_threshold=?", [req.body.username, threshold2, threshold2]).then(function () { + global.mysql.query("INSERT INTO users (username, payout_threshold) VALUES (?, ?) ON DUPLICATE KEY UPDATE payout_threshold=?", [username, threshold2, threshold2]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold2)}); }); }); From c5f1dd4f65a01102c67a38b98157f0e780666868 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 May 2020 18:01:30 -0700 Subject: [PATCH 0930/1496] Updated API --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index fce8fc684..78723f55c 100644 --- a/lib/api.js +++ b/lib/api.js @@ -519,7 +519,7 @@ app.get('/user/:address', function (req, res) { app.post('/user/subscribeEmail', function (req, res) { const enabled = req.body.enabled; - if (!enabled) return res.status(401).send({'success': false, 'msg': "No \"enabled\" parameter was found"}); + if (!("enabled" in req.body)) return res.status(401).send({'success': false, 'msg': "No \"enabled\" parameter was found"}); const username = req.body.username; if (!username) return res.status(401).send({'success': false, 'msg': "No \"username\" parameter was found"}); const from = req.body.from; From c2e6d9dcace5e01ca83b013475ef5abeec07d273 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 May 2020 18:14:27 -0700 Subject: [PATCH 0931/1496] Updated API --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 78723f55c..bd8eb3d32 100644 --- a/lib/api.js +++ b/lib/api.js @@ -528,8 +528,8 @@ app.post('/user/subscribeEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND email = NULL", [enabled, to, username]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { if (global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set email for unknown user"}); - global.mysql.query("INSERT INTO users (username, enable_email, email) VALUES (?, ?, ?)", [username, enabled, to]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + global.mysql.query("INSERT INTO users (username, enable_email, email) VALUES (?, ?, ?)", [username, enabled, to]).then(function (err, rows) { + if (err) { return res.status(401).json({'error': 'FROM email does not match'}); } else { return res.json({'msg': 'Email preferences were updated'}); From 8eb389bea13e95b8d6643f37f03f27354215a606 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 May 2020 18:21:15 -0700 Subject: [PATCH 0932/1496] Updated API --- lib/api.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/api.js b/lib/api.js index bd8eb3d32..917282f28 100644 --- a/lib/api.js +++ b/lib/api.js @@ -528,13 +528,11 @@ app.post('/user/subscribeEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND email = NULL", [enabled, to, username]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { if (global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set email for unknown user"}); - global.mysql.query("INSERT INTO users (username, enable_email, email) VALUES (?, ?, ?)", [username, enabled, to]).then(function (err, rows) { - if (err) { - return res.status(401).json({'error': 'FROM email does not match'}); - } else { - return res.json({'msg': 'Email preferences were updated'}); - } - }); + global.mysql.query("INSERT INTO users (username, enable_email, email) VALUES (?, ?, ?)", [username, enabled, to]).then(function () { + return res.json({'msg': 'Email preferences were updated'}); + }).catch(function(err) { + return res.status(401).json({'error': 'Please specify valid FROM email'}); + }); } else { return res.json({'msg': 'Email preferences were updated'}); } From 41aa9a2c4533a4eb37e55cbf946b322cfa196c9c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 May 2020 19:06:00 -0700 Subject: [PATCH 0933/1496] Updated API --- lib/api.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/api.js b/lib/api.js index 917282f28..baf3354fb 100644 --- a/lib/api.js +++ b/lib/api.js @@ -518,14 +518,24 @@ app.get('/user/:address', function (req, res) { }); app.post('/user/subscribeEmail', function (req, res) { - const enabled = req.body.enabled; - if (!("enabled" in req.body)) return res.status(401).send({'success': false, 'msg': "No \"enabled\" parameter was found"}); const username = req.body.username; if (!username) return res.status(401).send({'success': false, 'msg': "No \"username\" parameter was found"}); - const from = req.body.from; - const to = req.body.to; - if (!from && to) { - global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND email = NULL", [enabled, to, username]).then(function (result) { + if (!("enabled" in req.body)) return res.status(401).send({'success': false, 'msg': "No \"enabled\" parameter was found"}); + if (!("from" in req.body)) return res.status(401).send({'success': false, 'msg': "No \"from\" parameter was found"}); + if (!("to" in req.body)) return res.status(401).send({'success': false, 'msg': "No \"to\" parameter was found"}); + const enabled = req.body.enabled; + const from = req.body.from; + const to = req.body.to; + if (from === "" && to === "") { + global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, username]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + return res.status(401).json({'error': 'This XMR address does not have email subscription'}); + } else { + return res.json({'msg': 'Email preferences were updated'}); + } + }); + } else if (from === "") { + global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND (email IS NULL OR email = '')", [enabled, to, username]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { if (global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set email for unknown user"}); global.mysql.query("INSERT INTO users (username, enable_email, email) VALUES (?, ?, ?)", [username, enabled, to]).then(function () { @@ -537,7 +547,7 @@ app.post('/user/subscribeEmail', function (req, res) { return res.json({'msg': 'Email preferences were updated'}); } }); - } else if (from && to) { + } else { global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND email = ?", [enabled, to, username, from]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { return res.status(401).json({'error': 'FROM email does not match'}); @@ -545,16 +555,8 @@ app.post('/user/subscribeEmail', function (req, res) { return res.json({'msg': 'Email preferences were updated'}); } }); - } else { - global.mysql.query("UPDATE users SET enable_email = ? WHERE username = ?", [enabled, username]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - return res.status(401).json({'error': 'This XMR address does not have email subscription'}); - } else { - return res.json({'msg': 'Email preferences were updated'}); - } - }); } -}); +} app.get('/user/:address/unsubscribeEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.params.address]).then(function (result) { From 881f68b0d0041ac526c8ad2088527b10d1a96ea4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 May 2020 19:11:42 -0700 Subject: [PATCH 0934/1496] Updated API --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index baf3354fb..fb6de0ab6 100644 --- a/lib/api.js +++ b/lib/api.js @@ -556,7 +556,7 @@ app.post('/user/subscribeEmail', function (req, res) { } }); } -} +}); app.get('/user/:address/unsubscribeEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = 0 WHERE username = ?", [req.params.address]).then(function (result) { From f6257ea29824089b12889a3905022a4e539d397e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 May 2020 14:06:45 -0700 Subject: [PATCH 0935/1496] Added remote extra share verify --- lib/pool.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6b2b7326b..e9668af85 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1495,12 +1495,15 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (shareBuffer !== null) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); - const hash2 = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash2 !== resultHash) { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); - } else { - extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); - } + global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { + if (hash === null || hash === false) { + console.error(threadName + "Can't verify share remotely!"); + } else if (hash !== resultHash) { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); + } else { + extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); + } + }); } else { console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); } From ae95e7d698cbe0240c3f12a08afa5ff213c8072f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 May 2020 10:41:02 -0700 Subject: [PATCH 0936/1496] Updated monero version --- deployment/upgrade_monero.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 7bdd7514c..1fd1699b8 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.15.0.1 &&\ +sudo git checkout v0.15.0.5 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 9124f1b5924d88a276f23c7c13b72014d1d5b0c3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 May 2020 08:57:30 -0700 Subject: [PATCH 0937/1496] Added news.sh --- deployment/upgrade_monero.bash | 2 +- manage_scripts/news.sh | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 manage_scripts/news.sh diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 1fd1699b8..e195ad332 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -10,5 +10,5 @@ sudo git checkout v0.15.0.5 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ -(sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make) &&\ +(sudo USE_SINGLE_BUILDDIR=1 nice make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 nice make) &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" diff --git a/manage_scripts/news.sh b/manage_scripts/news.sh new file mode 100755 index 000000000..fa4727e11 --- /dev/null +++ b/manage_scripts/news.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +subject=$1 +body=$2 + +if [ -z "$subject" ]; then echo "Set subject as first script paaameter"; exit 1; fi +if [ -z "$body" ]; then echo "Set bosy as second script paaameter"; exit 1; fi + +node cache_set.js --key=news --value='{created: "'$(date +%s)'", subject: "'$subject'", body: "'$body'"}' From a4543d0640608669f31a2ec9a103339e7ef85ccd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 May 2020 09:10:43 -0700 Subject: [PATCH 0938/1496] Fixed quotes --- manage_scripts/news.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/news.sh b/manage_scripts/news.sh index fa4727e11..82dfe2c8d 100755 --- a/manage_scripts/news.sh +++ b/manage_scripts/news.sh @@ -6,4 +6,4 @@ body=$2 if [ -z "$subject" ]; then echo "Set subject as first script paaameter"; exit 1; fi if [ -z "$body" ]; then echo "Set bosy as second script paaameter"; exit 1; fi -node cache_set.js --key=news --value='{created: "'$(date +%s)'", subject: "'$subject'", body: "'$body'"}' +node cache_set.js --key=news --value='{"created": "'$(date +%s)'", "subject": "'$subject'", "body": "'$body'"}' \ No newline at end of file From 0fe630029ffe89b66d5428c6aa7afa2a6d1c116b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 May 2020 09:16:24 -0700 Subject: [PATCH 0939/1496] Added news endpoint --- lib/api.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/api.js b/lib/api.js index fb6de0ab6..48bd06c41 100644 --- a/lib/api.js +++ b/lib/api.js @@ -198,6 +198,11 @@ app.get('/pool/address_type/:address', cache('10 seconds'), function (req, res) } }); +app.get('/pool/motd', cors(), cache('60 seconds'), function (req, res) { + const news = global.database.getCache('news'); + res.json({created: news.created, subject: news.subject, body: news.body}); +}); + app.get('/pool/stats', cors(), cache('10 seconds'), function (req, res) { let localCache = global.database.getCache('pool_stats_global'); delete(localCache.minerHistory); From aa423508096713184d548cd20399e3996d77813b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 May 2020 10:04:37 -0700 Subject: [PATCH 0940/1496] Fixed quotes --- manage_scripts/news.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/news.sh b/manage_scripts/news.sh index 82dfe2c8d..c1fe4479b 100755 --- a/manage_scripts/news.sh +++ b/manage_scripts/news.sh @@ -6,4 +6,4 @@ body=$2 if [ -z "$subject" ]; then echo "Set subject as first script paaameter"; exit 1; fi if [ -z "$body" ]; then echo "Set bosy as second script paaameter"; exit 1; fi -node cache_set.js --key=news --value='{"created": "'$(date +%s)'", "subject": "'$subject'", "body": "'$body'"}' \ No newline at end of file +node cache_set.js --key=news --value='{"created": "'$(date +%s)'", "subject": "'"$subject"'", "body": "'"$body"'"}' \ No newline at end of file From af830ffe49b52714d0b8c78e1d09ba2e8ce4fe14 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 May 2020 18:50:53 -0700 Subject: [PATCH 0941/1496] Updated to v16 monerod --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 905709262..1e3884b6b 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.15.0.1 +sudo git checkout v0.16.0.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 744695f0c..95d6c3e62 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.15.0.1 +sudo git checkout v0.16.0.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 860dae811..feed3d2ac 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.15.0.1 +sudo git checkout v0.16.0.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index e195ad332..5bdd156c5 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.15.0.5 &&\ +sudo git checkout v0.16.0.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 1b399fb69deba9a09b78d719a989cae9b046eafe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Jun 2020 17:25:15 -0700 Subject: [PATCH 0942/1496] Update XMR address --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89e120a9e..e9e25799e 100644 --- a/README.md +++ b/README.md @@ -257,7 +257,7 @@ For assistance, please contact MoneroOcean at support@moneroocean.stream. Developer Donations =================== If you'd like to make a one time donation, the addresses are as follows: -* XMR - ```44qJYxdbuqSKarYnDSXB6KLbsH4yR65vpJe3ELLDii9i4ZgKpgQXZYR4AMJxBJbfbKZGWUxZU42QyZSsP4AyZZMbJBCrWr1``` +* XMR - ```89TxfrUmqJJcb1V124WsUzA78Xa3UYHt7Bg8RGMhXVeZYPN8cE5CZEk58Y1m23ZMLHN7wYeJ9da5n5MXharEjrm41hSnWHL``` * AEON - ```WmsEg3RuUKCcEvFBtXcqRnGYfiqGJLP1FGBYiNMgrcdUjZ8iMcUn2tdcz59T89inWr9Vae4APBNf7Bg2DReFP5jr23SQqaDMT``` * ETN - ```etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1``` * SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` From 58e03efa4401558ffb833cc3e28afeccdbbcdcd7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 1 Jul 2020 12:11:26 -0700 Subject: [PATCH 0943/1496] Typo fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b24c44003..4e4ebc9e5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodejs-pool", "version": "0.0.1", - "description": "IMproved version of Snipa22 nodejs-pool", + "description": "Improved version of Snipa22 nodejs-pool", "main": "init.js", "repository": { "type": "git", From 687589ac54eca8d230a738236a18b03026d4ad03 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 2 Jul 2020 19:15:46 -0700 Subject: [PATCH 0944/1496] Updated daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 1e3884b6b..35620e13f 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.16.0.0 +sudo git checkout v0.16.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 95d6c3e62..346b28f42 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.16.0.0 +sudo git checkout v0.16.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index feed3d2ac..257410fd7 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.16.0.0 +sudo git checkout v0.16.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 5bdd156c5..03e386d4f 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.16.0.0 &&\ +sudo git checkout v0.16.0.1 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 3de14c2320012a9ee774de514825e9f9d1e54cdb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Jul 2020 21:20:49 -0700 Subject: [PATCH 0945/1496] Added CCX support --- README.md | 1 + deployment/base.sql | 3 +++ lib/coins/xmr.js | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9e25799e..8075a2b93 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XEQ - ```Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb``` * XTA - ```ipN5cNhm7RXAGACP4ZXki4afT3iJ1A6Ka5U4cswE6fBPDcv8JpivurBj3vu1bXwPyb8KZEGsFUYMmToFG4N9V9G72X4WpAQ8L``` * DERO - ```dERokvcrnuWH1ai1QmZQc9cgxrLwE3rX3TbhdrnLmi3BVZmf197qd5FaFqmPMp5dZ3igXfVQwUUMgTSjpVKDtUeb6DT2xp64XJ``` +* CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index cc9853ec5..7c332fd88 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -220,6 +220,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMV', '0', 'int', 'MoneroV coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXWP', '0', 'int', 'Swap coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXEQ', '0', 'int', 'Equilibria coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortCCX', '0', 'int', 'Conceal coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTA', '0', 'int', 'Italocoin coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortDERO', '0', 'int', 'Dero coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMC', '0', 'int', 'XMC coin daemon RPC port or 0'); @@ -242,6 +243,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMV', '0', 'float', 'MoneroV algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXWP', '0', 'float', 'Swap algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXEQ', '0', 'float', 'Equilibria algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorCCX', '0', 'float', 'Conceal algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTA', '0', 'float', 'Italocoin algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorDERO', '0', 'float', 'Dero algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMC', '0', 'float', 'XMC algo hash price factor relative to coinHashFactor'); @@ -303,6 +305,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_13102', '', 'string', 'Address to mine to for 13102 (Italocoin) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20206', '', 'string', 'Address to mine to for 20206 (Dero) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_18181', '', 'string', 'Address to mine to for 18181 (XMC) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_16000', '', 'string', 'Address to mine to for 16000 (CCX) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', 'Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 48bf7bd56..b63e8447f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -44,6 +44,7 @@ const port2coin = { "9231" : "XEQ", "20206": "DERO", "18181": "XMC", + "16000": "CCX", }; const port2blob_num = { "11181": 7, // AEON @@ -68,6 +69,7 @@ const port2blob_num = { "9231" : 5, // XEQ "20206": 10, // DERO "18181": 0, // XMC + "16000": 2, // TRTL }; const port2algo = { @@ -93,6 +95,7 @@ const port2algo = { "9231" : "cn/gpu", // XEQ "20206": "astrobwt", // DERO "18181": "cn/0", // XMC + "16000": "cn/ccx", // CCX }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -261,7 +264,7 @@ function Coin(data){ this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ // TRTL/IRD does not get getblock LTHN / AEON / DERO have composite tx - if (port == 11898 || port == 13007 || port == 48782 || port == 11181 || port == 20206) { + if (port == 11898 || port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { console.error(JSON.stringify(body)); @@ -570,6 +573,8 @@ function Coin(data){ if ("cn/0" in algos_perf) coin_perf["XMC"] = algos_perf["cn/0"]; + if ("cn/ccx" in algos_perf) coin_perf["CCX"] = algos_perf["cn/ccx"]; + if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; @@ -601,6 +606,7 @@ function Coin(data){ case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium case 13102: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // Italocoin + case 16000: return multiHashing.cryptonight(convertedBlob, 17, blockTemplate.height); // Conceal case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC @@ -670,6 +676,7 @@ function Coin(data){ case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO + case 16000: return "forknote2"; // CCX case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero From 918f926e4295d0586ce0e332b6419b281c21ce31 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Jul 2020 21:41:32 -0700 Subject: [PATCH 0946/1496] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e4ebc9e5..0ff14b597 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v17.0.3" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v19.0.0" } } From ff67abbc895e0cef3713d580c942763571cc560e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Jul 2020 21:49:03 -0700 Subject: [PATCH 0947/1496] Fixed blob type --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b63e8447f..fb4cac9f5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -69,7 +69,7 @@ const port2blob_num = { "9231" : 5, // XEQ "20206": 10, // DERO "18181": 0, // XMC - "16000": 2, // TRTL + "16000": 0, // TRTL }; const port2algo = { @@ -676,7 +676,6 @@ function Coin(data){ case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO - case 16000: return "forknote2"; // CCX case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero From 94eaea43de1419ac548967e2d6efe43431da7e12 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 7 Jul 2020 09:11:20 -0700 Subject: [PATCH 0948/1496] Better error messages --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index fb4cac9f5..3dc832fbc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -465,7 +465,7 @@ function Coin(data){ if (template.reserved_offset) { // here we are OK with +1 difference because we put extra byte into pool_nonce_size if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { - console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in block " + ": " + blob); + console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in " + this.port + " block " + ": " + blob); } this.reserved_offset = template.reserved_offset; } else { @@ -473,7 +473,7 @@ function Coin(data){ } } } else { - console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in block " + ": " + blob); + console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in " + this.port + " block " + ": " + blob); this.reserved_offset = template.reserved_offset; } } else { // exception for DERO From bd72463be593fdbf98b028540034cb061ac4b747 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 14 Jul 2020 15:45:47 -0700 Subject: [PATCH 0949/1496] Increased share merge diff --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e9668af85..7e44c48ab 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1204,7 +1204,7 @@ function recordShareData(miner, job, shareDiff, isBlockCandidate, hashHex, isTru let db_job_height = global.config.daemon.port == blockTemplate.port ? blockTemplate.height : anchorBlockHeight; - if (job.difficulty >= 1000000 || isBlockCandidate) { + if (job.difficulty >= 100000000 || isBlockCandidate) { storeShareDiv(miner, job.rewarded_difficulty, job.rewarded_difficulty2, 1, miner.identifier, blockTemplate.port, db_job_height, blockTemplate.difficulty, isBlockCandidate, isTrustedShare); //global.database.storeShare(db_job_height, global.protos.Share.encode({ // shares: job.rewarded_difficulty, @@ -1251,7 +1251,7 @@ function recordShareData(miner, job, shareDiff, isBlockCandidate, hashHex, isTru let acc2 = worker.acc2; let share_num = worker.share_num; - if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > 60*1000 || acc >= 1000000) { + if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > 60*1000 || acc >= 100000000) { if (acc != 0) { debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); storeShareDiv(miner, acc, acc2, share_num, worker_name, blockTemplate.port, height, difficulty, false, isTrustedShare); From d7de3cdb7bd24924600315fa0b4be3cbf7c63355 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 14 Jul 2020 19:43:19 -0700 Subject: [PATCH 0950/1496] Added pre TUBE and Haven support --- lib/coins/xmr.js | 33 ++++++++++++++++++++++++++------- lib/pool.js | 15 ++++++++------- package.json | 3 ++- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3dc832fbc..5439ec649 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1,6 +1,7 @@ "use strict"; const bignum = require('bignum'); const cnUtil = require('cryptoforknote-util'); +const xhvUtil = require('haven-nodejs-wrapper'); const multiHashing = require('cryptonight-hashing'); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); @@ -51,11 +52,13 @@ const port2blob_num = { "11898": 2, // TRTL "12211": 4, // RYO "17750": 0, // XHV + //"17750": 101, // XHV "18081": 0, // XMR "18981": 0, // GRFT "20189": 0, // XTC "22023": 5, // LOKI "24182": 0, // TUBE + //"24182": 10, // TUBE "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN @@ -67,7 +70,7 @@ const port2blob_num = { "33124": 9, // XTNC "19950": 8, // XWP "9231" : 5, // XEQ - "20206": 10, // DERO + "20206": 100, // DERO "18181": 0, // XMC "16000": 0, // TRTL }; @@ -88,6 +91,7 @@ const port2algo = { "20189": "defyx", // Scala "22023": "rx/loki", // LOKI "24182": "cn-heavy/tube", // BitTube + //"24182": "c29b", // BitTube "33124": "c29s", // XtendCash "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR @@ -376,18 +380,24 @@ function Coin(data){ this.portBlobType = function(port, version) { return port2blob_num[port]; } - this.blobTypeGrin = function(blob_type_num) { return blob_type_num == 8 || blob_type_num == 9; } + this.blobTypeGrin = function(blob_type_num) { return blob_type_num == 8 || blob_type_num == 9 || blob_type_num == 10; } - this.blobTypeDero = function(blob_type_num) { return blob_type_num == 10; } + this.c29ProofSize = function(blob_type_num) { return blob_type_num == 10 ? 40 : 32; } + + this.nonceSize = function(blob_type_num) { return blob_type_num == 7 ? 8 : 4; } + + this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } + + this.blobTypeHaven = function(blob_type_num) { return false /*blob_type_num == 101*/; } this.convertBlob = function(blobBuffer, port){ const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; let blob; try { - blob = cnUtil.convert_blob(blobBuffer, blob_type_num); + blob = this.blobTypeHaven(blob_type_num) ? xhvUtil.convert_blob(blobBuffer) : cnUtil.convert_blob(blobBuffer, blob_type_num); } catch (e) { - const err_str = "Can't do port " + port + " convert_blob " + blobBuffer.toString('hex') + " with blob type " + this.portBlobType(port, blobBuffer[0]) + ": " + e; + const err_str = "Can't do port " + port + " convert_blob " + blobBuffer.toString('hex') + " with blob type " + blob_type_num + ": " + e; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't convert_blob", err_str); throw new Error(e); @@ -400,7 +410,11 @@ function Coin(data){ if (this.blobTypeDero(blob_type_num)) { NonceBuffer.copy(blockTemplate, 39, 0, 4); return blockTemplate; - } else return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, blob_type_num, ring); + } else if (this.blobTypeHaven(blob_type_num)) { + return xhvUtil.construct_block_blob(blockTemplate, NonceBuffer); + } else { + return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, blob_type_num, ring); + } }; this.constructMMParentBlockBlob = function(parentTemplateBuffer, port, childTemplateBuffer) { @@ -414,7 +428,8 @@ function Coin(data){ }; this.getBlockID = function(blockBuffer, port){ - return cnUtil.get_block_id(blockBuffer, this.portBlobType(port, blockBuffer[0])); + const blob_type_num = this.portBlobType(port, blobBuffer[0]); + return this.blobTypeHaven(blob_type_num) ? xhvUtil.get_block_id(blockBuffer) : cnUtil.get_block_id(blockBuffer, blob_type_num); }; this.BlockTemplate = function(template) { @@ -568,6 +583,7 @@ function Coin(data){ if ("c29s" in algos_perf) coin_perf["XTNC"] = coin_perf["XWP"] = algos_perf["c29s"]; if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; + if ("c29b" in algos_perf) coin_perf["TUBE"] = algos_perf["c29b"]; if ("astrobwt" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt"]; @@ -658,6 +674,7 @@ function Coin(data){ switch (port) { case 19281: return multiHashing.c29v(header, ring); // MoneroV case 19950: return multiHashing.c29s(header, ring); // Swap + case 24182: return multiHashing.c29b(header, ring); // TUBE case 33124: return multiHashing.c29s(header, ring); // XtendCash default: console.error("Unknown " + port + " port for Cuckaroo PoW type"); @@ -676,10 +693,12 @@ function Coin(data){ case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO + //case 17750: return "haven"; // XHV case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero case 22023: return "cryptonote_loki"; // LOKI + //case 24182: return "cryptonote_tube"; // TUBE case 33124: return "cryptonote_xtnc"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; diff --git a/lib/pool.js b/lib/pool.js index 7e44c48ab..ff1f9b995 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1012,7 +1012,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi pre_pow: blob, algo: this.protocol === "grin" ? "cuckaroo" : params.algo_name, edgebits: 29, - proofsize: 32, + proofsize: global.coinFuncs.c29ProofSize(blob_type_num), noncebytes: 4, height: bt.height, job_id: newJob.id, @@ -1024,7 +1024,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi height: bt.height, seed_hash: bt.seed_hash, job_id: newJob.id, - target: getTargetHex(this.difficulty, blob_type_num == 7 ? 8 : 4), + target: getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num)), id: this.id }; } else { @@ -1751,9 +1751,10 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } - const is_bad_nonce = global.coinFuncs.blobTypeGrin(job.blob_type_num) ? - (typeof params.nonce !== 'number') || !(params.pow instanceof Array) || (params.pow.length != 32) : - (typeof params.nonce !== 'string') || !(job.blob_type_num == 7 ? nonceCheck64.test(params.nonce) : nonceCheck32.test(params.nonce) ); + const blob_type_num = job.blob_type_num; + const is_bad_nonce = global.coinFuncs.blobTypeGrin(blob_type_num) ? + (typeof params.nonce !== 'number') || !(params.pow instanceof Array) || (params.pow.length != global.coinFuncs.c29ProofSize(blob_type_num)) : + (typeof params.nonce !== 'string') || !(global.coinFuncs.nonceSize(blob_type_num) == 8 ? nonceCheck64.test(params.nonce) : nonceCheck32.test(params.nonce) ); if (is_bad_nonce) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); @@ -1773,11 +1774,11 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.storeInvalidShare(); return; } - nonce_test = global.coinFuncs.blobTypeGrin(job.blob_type_num) ? + nonce_test = global.coinFuncs.blobTypeGrin(blob_type_num) ? params.pow.join(':') + `_${params.poolNonce}_${params.workerNonce}` : `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; } else { - nonce_test = global.coinFuncs.blobTypeGrin(job.blob_type_num) ? params.pow.join(':') : params.nonce; + nonce_test = global.coinFuncs.blobTypeGrin(blob_type_num) ? params.pow.join(':') : params.nonce; } if (nonce_test in job.submissions) { diff --git a/package.json b/package.json index 0ff14b597..84b1e9633 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v7.0.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.0.0", + "haven-nodejs-wrapper": "git+https://github.com/haven-protocol-org/haven-nodejs-wrapper.git#3833f057c85569c52c3d75f7b63da1179bdc6930", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v19.0.0" } } From 0637414bf17c36c63e717f233799d092625ac1f5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 14 Jul 2020 21:07:55 -0700 Subject: [PATCH 0951/1496] Use experimental Haven utils --- lib/coins/xmr.js | 13 ++++--------- package.json | 3 +-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5439ec649..e3471f9f8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1,7 +1,6 @@ "use strict"; const bignum = require('bignum'); const cnUtil = require('cryptoforknote-util'); -const xhvUtil = require('haven-nodejs-wrapper'); const multiHashing = require('cryptonight-hashing'); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); @@ -52,7 +51,7 @@ const port2blob_num = { "11898": 2, // TRTL "12211": 4, // RYO "17750": 0, // XHV - //"17750": 101, // XHV + //"17750": 11, // XHV "18081": 0, // XMR "18981": 0, // GRFT "20189": 0, // XTC @@ -388,14 +387,12 @@ function Coin(data){ this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } - this.blobTypeHaven = function(blob_type_num) { return false /*blob_type_num == 101*/; } - this.convertBlob = function(blobBuffer, port){ const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; let blob; try { - blob = this.blobTypeHaven(blob_type_num) ? xhvUtil.convert_blob(blobBuffer) : cnUtil.convert_blob(blobBuffer, blob_type_num); + blob = cnUtil.convert_blob(blobBuffer, blob_type_num); } catch (e) { const err_str = "Can't do port " + port + " convert_blob " + blobBuffer.toString('hex') + " with blob type " + blob_type_num + ": " + e; console.error(err_str); @@ -410,8 +407,6 @@ function Coin(data){ if (this.blobTypeDero(blob_type_num)) { NonceBuffer.copy(blockTemplate, 39, 0, 4); return blockTemplate; - } else if (this.blobTypeHaven(blob_type_num)) { - return xhvUtil.construct_block_blob(blockTemplate, NonceBuffer); } else { return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, blob_type_num, ring); } @@ -429,7 +424,7 @@ function Coin(data){ this.getBlockID = function(blockBuffer, port){ const blob_type_num = this.portBlobType(port, blobBuffer[0]); - return this.blobTypeHaven(blob_type_num) ? xhvUtil.get_block_id(blockBuffer) : cnUtil.get_block_id(blockBuffer, blob_type_num); + return cnUtil.get_block_id(blockBuffer, blob_type_num); }; this.BlockTemplate = function(template) { @@ -693,7 +688,7 @@ function Coin(data){ case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO - //case 17750: return "haven"; // XHV + //case 17750: return "cryptonote_xhv"; // XHV case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero diff --git a/package.json b/package.json index 84b1e9633..042b920fe 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.0.0", - "haven-nodejs-wrapper": "git+https://github.com/haven-protocol-org/haven-nodejs-wrapper.git#3833f057c85569c52c3d75f7b63da1179bdc6930", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.1.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v19.0.0" } } From 4b007919d32776502809061944b66394f987a4bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 16 Jul 2020 09:07:14 -0700 Subject: [PATCH 0952/1496] Added extra debug --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e3471f9f8..46fb12512 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -423,6 +423,7 @@ function Coin(data){ }; this.getBlockID = function(blockBuffer, port){ + if (!blobBuffer) console.error("Port " + port + " has undefined blockBuffer!"); const blob_type_num = this.portBlobType(port, blobBuffer[0]); return cnUtil.get_block_id(blockBuffer, blob_type_num); }; From 2a9dea3e965a453adcbccc4d1195bc400939f7bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 16 Jul 2020 10:12:49 -0700 Subject: [PATCH 0953/1496] Bug fix --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 46fb12512..e0cc77f31 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -423,8 +423,7 @@ function Coin(data){ }; this.getBlockID = function(blockBuffer, port){ - if (!blobBuffer) console.error("Port " + port + " has undefined blockBuffer!"); - const blob_type_num = this.portBlobType(port, blobBuffer[0]); + const blob_type_num = this.portBlobType(port, blockBuffer[0]); return cnUtil.get_block_id(blockBuffer, blob_type_num); }; From adbe2aab461ca147d6718a0b1e6a241623564e68 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 16 Jul 2020 10:58:47 -0700 Subject: [PATCH 0954/1496] Fixed Haven ringct --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 042b920fe..2bd3ba725 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.1.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.1.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v19.0.0" } } From 5962c8ad24d5ad26ed62f1c8f3e247171a2d84ac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 16 Jul 2020 20:52:11 -0700 Subject: [PATCH 0955/1496] Added Panther algo support --- lib/coins/xmr.js | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e0cc77f31..aa0a13a9f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -88,6 +88,7 @@ const port2algo = { "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa "20189": "defyx", // Scala + //"20189": "panther", // Scala "22023": "rx/loki", // LOKI "24182": "cn-heavy/tube", // BitTube //"24182": "c29b", // BitTube @@ -553,6 +554,7 @@ function Coin(data){ else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; if ("defyx" in algos_perf) coin_perf["XTC"] = algos_perf["defyx"]; + //if ("panther" in algos_perf) coin_perf["XTC"] = algos_perf["panther"]; if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; @@ -625,6 +627,7 @@ function Coin(data){ case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala + //case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube diff --git a/package.json b/package.json index 2bd3ba725..e08fecbfa 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.1.1", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v19.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v20.0.0" } } From 3a5e355988e8cd7adf5252893b1aa6c5c2d4a5a6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Jul 2020 09:09:59 -0700 Subject: [PATCH 0956/1496] Updated after XHV fork --- lib/coins/xmr.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index aa0a13a9f..3cc7ca43b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -50,8 +50,7 @@ const port2blob_num = { "11181": 7, // AEON "11898": 2, // TRTL "12211": 4, // RYO - "17750": 0, // XHV - //"17750": 11, // XHV + "17750": 11, // XHV "18081": 0, // XMR "18981": 0, // GRFT "20189": 0, // XTC @@ -691,7 +690,7 @@ function Coin(data){ case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO - //case 17750: return "cryptonote_xhv"; // XHV + case 17750: return "cryptonote_xhv"; // XHV case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero From ba141e93c85b8a2895500eedf1e0e3f3b4babf0e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 20 Jul 2020 11:55:42 -0700 Subject: [PATCH 0957/1496] Disabled Haxen for old xmrig --- lib/coins/xmr.js | 12 ++++++++++++ lib/pool.js | 1 + lib/support.js | 1 + 3 files changed, 14 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3cc7ca43b..bfc4544a9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -748,6 +748,18 @@ function Coin(data){ return false; }; + this.is_miner_agent_no_haven_support = function(agent) { + let m; + if (m = reXMRig.exec(agent)) { + const majorv = parseInt(m[1]) * 10000; + const minorv = parseInt(m[2]) * 100; + if (majorv + minorv < 60300) { + return true; + } + } + return false; + }; + this.get_miner_agent_not_supported_algo = function(agent) { let m; if (m = reXMRSTAKRX.exec(agent)) { diff --git a/lib/pool.js b/lib/pool.js index ff1f9b995..521804432 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -666,6 +666,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.setAlgos = function(algos, algos_perf, algo_min_time) { this.algos = {}; for (let i in algos) this.algos[algos[i]] = 1; + if (global.coinFuncs.is_miner_agent_no_haven_support(this.agent)) delete this.algos["cn-heavy/xhv"]; const check = global.coinFuncs.algoCheck(this.algos); if (check !== true) return check; if ("cn-pico" in this.algos) this.algos["cn-pico/trtl"] = 1; diff --git a/lib/support.js b/lib/support.js index fc7a94454..0f022ad4c 100644 --- a/lib/support.js +++ b/lib/support.js @@ -125,6 +125,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { client.headers["Content-Type"] = "application/json"; client.headers["Content-Length"] = data.length; client.headers["Accept"] = "application/json"; + if (global.config.daemon.basicAuth) client.headers["Authorization"] = global.config.daemon.basicAuth; if (is_wallet && global.config.payout.rpcPasswordEnabled && global.config.payout.rpcPasswordPath){ fs.readFile(port === global.config.daemon.port ? global.config.payout.rpcPasswordPath : global.config.payout["rpcPasswordPath" + port.toString()], 'utf8', function(err, data){ if (err){ From e14fdb7b6a5bc6bf0879ae568ddc744fbb3ec039 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 29 Jul 2020 17:29:10 -0700 Subject: [PATCH 0958/1496] Added TUBE4 support --- README.md | 2 +- deployment/base.sql | 3 ++- lib/coins/xmr.js | 20 ++++++-------------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8075a2b93..2ae7f60ef 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,7 @@ If you'd like to make a one time donation, the addresses are as follows: * RYO - ```RYoLsi22qnoKYhnv1DwHBXcGe9QK6P9zmekwQnHdUAak7adFBK4i32wFTszivQ9wEPeugbXr2UD7tMd6ogf1dbHh76G5UszE7k1``` * XTL - ```Se3Qr5s83AxjCtYrkkqg6QXJagCVi8dELbHb5Cnemw4rMk3xZzEX3kQfWrbTZPpdAJSP3enA6ri3DcvdkERkGKE518vyPQTyi``` * XHV - ```hvxyEmtbqs5TEk9U2tCxyfGx2dyGD1g8EBspdr3GivhPchkvnMHtpCR2fGLc5oEY42UGHVBMBANPge5QJ7BDXSMu1Ga2KFspQR``` -* TUBE - ```bxcpZTr4C41NshmJM9Db7FBE5crarjaDXVUApRbsCxHHBf8Jkqjwjzz1zmWHhm9trWNhrY1m4RpcS7tmdG4ykdHG2kTgDcbKJ``` +* TUBE - ```TubedBNkgkTbd2CBmLQSwW58baJNghD9xdmctiRXjrW3dE8xpUcoXimY4J5UMrnUBrUDmfQrbxRYRX9s5tQe7pWYNF2QiAdH1Fh``` * LOKI - ```L6XqN6JDedz5Ub8KxpMYRCUoQCuyEA8EegEmeQsdP5FCNuXJavcrxPvLhpqY6emphGTYVrmAUVECsE9drafvY2hXUTJz6rW``` * TRTL - ```TRTLv2x2bac17cngo1r2wt3CaxN8ckoWHe2TX7dc8zW8Fc9dpmxAvhVX4u4zPjpv9WeALm2koBLF36REVvsLmeufZZ1Yx6uWkYG``` * XTNC - ```XtazhSxz1bbJLpT2JuiD2UWFUJYSFty5SVWuF6sy2w9v8pn69smkUxkTVCQc8NKCd6CBMNDGzgdPRYBKaHdbgZ5SNptVH1yPCTQ``` diff --git a/deployment/base.sql b/deployment/base.sql index 7c332fd88..6ee43ec48 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -200,6 +200,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'retargetTime', '60', 'int', 'Time between difficulty retargets'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'port', '18081', 'int', 'Monero Daemon RPC Port'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'basicAuth', '', 'string', 'Basic auth header if needed by daemon'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePort', '18081', 'int', 'Main coin active daemon RPC port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortRYO', '0', 'int', 'Ryo coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortSUMO', '0', 'int', 'SUMO coin daemon RPC port or 0'); @@ -293,7 +294,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_12211', '', 'string', 'Address to mine to for 12211 (RYO) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11181', '', 'string', 'Address to mine to for 11181 (Aeon) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_17750', '', 'string', 'Address to mine to for 17750 (Haven) port.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_24182', '', 'string', 'Address to mine to for 24182 (BitTube) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_25182', '', 'string', 'Address to mine to for 25182 (BitTube) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Torque) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_22023', '', 'string', 'Address to mine to for 22023 (Loki) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_31014', '', 'string', 'Address to mine to for 31014 (Saronite) port.'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index bfc4544a9..9a3a0562e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -30,7 +30,7 @@ const port2coin = { "18981": "GRFT", "20189": "XTC", "22023": "LOKI", - "24182": "TUBE", + "25182": "TUBE", "34568": "WOW", "38081": "MSR", "48782": "LTHN", @@ -55,8 +55,7 @@ const port2blob_num = { "18981": 0, // GRFT "20189": 0, // XTC "22023": 5, // LOKI - "24182": 0, // TUBE - //"24182": 10, // TUBE + "25182": 10, // TUBE "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN @@ -89,8 +88,7 @@ const port2algo = { "20189": "defyx", // Scala //"20189": "panther", // Scala "22023": "rx/loki", // LOKI - "24182": "cn-heavy/tube", // BitTube - //"24182": "c29b", // BitTube + "25182": "c29b", // BitTube "33124": "c29s", // XtendCash "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR @@ -287,7 +285,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 22023 || port == 33124 || port == 24182 || port == 13102 || port == 18181) { // Loki / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction + if (port == 22023 || port == 33124 || port == 25182 || port == 13102 || port == 18181) { // Loki / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Wed, 29 Jul 2020 19:53:00 -0700 Subject: [PATCH 0959/1496] c29b fix --- lib/coins/xmr.js | 4 ++-- lib/pool.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9a3a0562e..5b438abec 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -671,8 +671,8 @@ function Coin(data){ } } - this.c29_cycle_hash = function(ring) { - return multiHashing.c29_cycle_hash(ring); + this.c29_cycle_hash = function(ring, blob_type_num) { + return blob_type_num == 10 ? multiHashing.c29b_cycle_hash(ring) : multiHashing.c29_cycle_hash(ring); } this.blobTypeStr = function(port, version) { diff --git a/lib/pool.js b/lib/pool.js index 521804432..c7bf99c1f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1476,7 +1476,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - return verifyShareCB(hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow)), shareBuffer, false, null); + return verifyShareCB(hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num)), shareBuffer, false, null); } let resultBuffer; From 97767898e07c8445af457ee9ca987b8ade8afa55 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 Jul 2020 20:46:17 -0700 Subject: [PATCH 0960/1496] Updated XLA coin --- lib/coins/xmr.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5b438abec..2f5aa70f3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -85,8 +85,7 @@ const port2algo = { "19734": "cn/r", // SUMO "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa - "20189": "defyx", // Scala - //"20189": "panther", // Scala + "20189": "panther", // Scala "22023": "rx/loki", // LOKI "25182": "c29b", // BitTube "33124": "c29s", // XtendCash @@ -550,8 +549,7 @@ function Coin(data){ if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; - if ("defyx" in algos_perf) coin_perf["XTC"] = algos_perf["defyx"]; - //if ("panther" in algos_perf) coin_perf["XTC"] = algos_perf["panther"]; + if ("panther" in algos_perf) coin_perf["XTC"] = algos_perf["panther"]; if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; @@ -618,8 +616,7 @@ function Coin(data){ case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa - case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 1); // Scala - //case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala + case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero From a2fb0874536c78046c3c816e6ad9309690de8a8e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 Jul 2020 23:34:04 -0700 Subject: [PATCH 0961/1496] Updated XLA --- README.md | 2 +- deployment/base.sql | 6 +++--- lib/coins/xmr.js | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2ae7f60ef..ca3f754cd 100644 --- a/README.md +++ b/README.md @@ -267,7 +267,7 @@ If you'd like to make a one time donation, the addresses are as follows: * WOW - ```Wo3yjV8UkwvbJDCB1Jy7vvXv3aaQu3K8YMG6tbY3Jo2KApfyf5RByZiBXy95bzmoR3AvPgNq6rHzm98LoHTkzjiA2dY7sqQMJ``` * XMV - ```XvyVfpAYp3zSuvdtoHgnDzMUf7GAeiumeUgVC7RTq6SfgtzGEzy4dUgfEEfD5adk1kN4dfVZdT3zZdgSD2xmVBs627Vwt2C3Ey``` * RYO - ```RYoLsi22qnoKYhnv1DwHBXcGe9QK6P9zmekwQnHdUAak7adFBK4i32wFTszivQ9wEPeugbXr2UD7tMd6ogf1dbHh76G5UszE7k1``` -* XTL - ```Se3Qr5s83AxjCtYrkkqg6QXJagCVi8dELbHb5Cnemw4rMk3xZzEX3kQfWrbTZPpdAJSP3enA6ri3DcvdkERkGKE518vyPQTyi``` +* XLA - ```SvkpUizij25ZGRHGb1c8ZTAHp3VyNFU3NQuQR1PtMyCqdpoZpaYAGMfG99z5guuoktY13nrhEerqYNKXvoxD7cUM1xA6Z5rRY``` * XHV - ```hvxyEmtbqs5TEk9U2tCxyfGx2dyGD1g8EBspdr3GivhPchkvnMHtpCR2fGLc5oEY42UGHVBMBANPge5QJ7BDXSMu1Ga2KFspQR``` * TUBE - ```TubedBNkgkTbd2CBmLQSwW58baJNghD9xdmctiRXjrW3dE8xpUcoXimY4J5UMrnUBrUDmfQrbxRYRX9s5tQe7pWYNF2QiAdH1Fh``` * LOKI - ```L6XqN6JDedz5Ub8KxpMYRCUoQCuyEA8EegEmeQsdP5FCNuXJavcrxPvLhpqY6emphGTYVrmAUVECsE9drafvY2hXUTJz6rW``` diff --git a/deployment/base.sql b/deployment/base.sql index 6ee43ec48..f86885c96 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -212,7 +212,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXHV', '0', 'int', 'Haven coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortAEON', '0', 'int', 'Aeon coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortMSR', '0', 'int', 'Masari coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTC', '0', 'int', 'Torque coin daemon RPC port or 0'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXLA', '0', 'int', 'Scala coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLTHN', '0', 'int', 'Lethean coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortGRFT', '0', 'int', 'Graft coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); @@ -235,7 +235,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXHV', '0', 'float', 'Haven algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorAEON', '0', 'float', 'Aeon algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorMSR', '0', 'float', 'Masari algo hash price factor relative to coinHashFactor'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTC', '0', 'float', 'Torque algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXLA', '0', 'float', 'Scala algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLTHN', '0', 'float', 'Lethean algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorGRFT', '0', 'float', 'Graft algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorTRTL', '0', 'float', 'Turtle algo hash price factor relative to coinHashFactor'); @@ -295,7 +295,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11181', '', 'string', 'Address to mine to for 11181 (Aeon) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_17750', '', 'string', 'Address to mine to for 17750 (Haven) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_25182', '', 'string', 'Address to mine to for 25182 (BitTube) port.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20189', '', 'string', 'Address to mine to for 20189 (Torque) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_11812', '', 'string', 'Address to mine to for 11812 (Scala) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_22023', '', 'string', 'Address to mine to for 22023 (Loki) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_31014', '', 'string', 'Address to mine to for 31014 (Saronite) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_33124', '', 'string', 'Address to mine to for 33124 (XtendCash) port.'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2f5aa70f3..58f1333f4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -28,7 +28,7 @@ const port2coin = { "17750": "XHV", "18081": "", "18981": "GRFT", - "20189": "XTC", + "11812": "XLA", "22023": "LOKI", "25182": "TUBE", "34568": "WOW", @@ -53,7 +53,7 @@ const port2blob_num = { "17750": 11, // XHV "18081": 0, // XMR "18981": 0, // GRFT - "20189": 0, // XTC + "11812": 0, // XLA "22023": 5, // LOKI "25182": 10, // TUBE "34568": 0, // WOW @@ -85,7 +85,7 @@ const port2algo = { "19734": "cn/r", // SUMO "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa - "20189": "panther", // Scala + "11812": "panther", // Scala "22023": "rx/loki", // LOKI "25182": "c29b", // BitTube "33124": "c29s", // XtendCash @@ -549,7 +549,7 @@ function Coin(data){ if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; - if ("panther" in algos_perf) coin_perf["XTC"] = algos_perf["panther"]; + if ("panther" in algos_perf) coin_perf["XLA"] = algos_perf["panther"]; if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; @@ -616,7 +616,7 @@ function Coin(data){ case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa - case 20189: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala + case 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero @@ -639,7 +639,7 @@ function Coin(data){ case 13102: case 18081: case 19994: - case 20189: + case 11812: case 22023: case 34568: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "seed_hash": blockTemplate.seed_hash }; From 6ab16ad07f5348343d5e58f09d683a61f680152a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Aug 2020 00:18:33 -0700 Subject: [PATCH 0962/1496] Removed error message --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 58f1333f4..dc0de8c13 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -480,7 +480,7 @@ function Coin(data){ } } } else { - console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in " + this.port + " block " + ": " + blob); + //console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in " + this.port + " block " + ": " + blob); this.reserved_offset = template.reserved_offset; } } else { // exception for DERO From 203363aa779723ecd9c39f79601f99cdc56a4523 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Aug 2020 08:41:52 -0700 Subject: [PATCH 0963/1496] Updated algo name --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index dc0de8c13..ec35b6adb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -85,7 +85,7 @@ const port2algo = { "19734": "cn/r", // SUMO "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa - "11812": "panther", // Scala + "11812": "panthera", // Scala "22023": "rx/loki", // LOKI "25182": "c29b", // BitTube "33124": "c29s", // XtendCash @@ -549,7 +549,7 @@ function Coin(data){ if ("cn/half" in algos_perf) coin_perf["MSR"] = algos_perf["cn/half"]; else if ("cn/fast2" in algos_perf) coin_perf["MSR"] = algos_perf["cn/fast2"]; - if ("panther" in algos_perf) coin_perf["XLA"] = algos_perf["panther"]; + if ("panthera" in algos_perf) coin_perf["XLA"] = algos_perf["panthera"]; if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; From 4f75e6fc2d1638c3ea05d3fe5ae6f52953e82592 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 5 Aug 2020 23:32:46 -0700 Subject: [PATCH 0964/1496] Fix for huge miners to avoid mining small diff coins --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index c7bf99c1f..353df407c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -849,6 +849,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const port = bt.port; const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); + if (miner.difficulty > bt.difficulty) { + return; + } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no algo support"); return; From f3e2e9d115abf2ba7059396147222d658c8e69da Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Aug 2020 00:05:56 -0700 Subject: [PATCH 0965/1496] Fix for huge miners to avoid mining small diff coins --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 353df407c..61c876d33 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -849,7 +849,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const port = bt.port; const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (miner.difficulty > bt.difficulty) { + if (miner.difficulty > bt.difficulty * 2) { return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { From ed061aabcfc1378e68348794ed824434f95e314b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Aug 2020 00:07:12 -0700 Subject: [PATCH 0966/1496] Fix for huge miners to avoid mining small diff coins --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 61c876d33..1260dc6a6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -849,7 +849,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const port = bt.port; const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (miner.difficulty > bt.difficulty * 2) { + if (miner.difficulty > bt.difficulty * 3) { return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { From 16fdfa34ddf454bbec7c6b01961e772f904a5a90 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 Aug 2020 22:20:33 -0700 Subject: [PATCH 0967/1496] Fixed for c29 coins --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1260dc6a6..07de183ce 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -849,7 +849,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const port = bt.port; const block_version = bt.buffer[0]; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - if (miner.difficulty > bt.difficulty * 3) { + + const factor = (typeof(miner.curr_coin_hash_factor) === 'undefined' ? 1 : miner.curr_coin_hash_factor) / coinHashFactor; + if (miner.difficulty * factor > bt.difficulty * 3) { return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { From 6d67d624486a44377a5a8136f03abb350db7d240 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 29 Aug 2020 09:06:39 -0700 Subject: [PATCH 0968/1496] Do not panic if transaction is rejected by daemon --- lib/payment_systems/xmr.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 34ce0d1cc..0bc204717 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -343,7 +343,13 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { global.support.rpcWallet(transferFunc, paymentDetails, function (body) { debug("Payment made: " + JSON.stringify(body)); if (body.hasOwnProperty('error') || !body.hasOwnProperty('result')) { - if (typeof(body.error) !== 'undefined' && body.error.hasOwnProperty('message') && (body.error.message === "not enough money" || body.error.message === "not enough unlocked money")){ + if ( typeof(body.error) !== 'undefined' && + body.error.hasOwnProperty('message') && + ( body.error.message === "not enough money" || + body.error.message === "not enough unlocked money" || + body.error.message === "transaction was rejected by daemon" + ) + ) { console.error("Issue making payments, not enough money, will try later"); setTimeout(getbalance, 10*60*1000); } else { From 6ede11fb706265ef19e0c8b02c9e343b741ce861 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 Sep 2020 04:13:01 +0000 Subject: [PATCH 0969/1496] XTA coin update --- lib/coins/xmr.js | 35 +++++++++++++++++++++++++++-------- package.json | 4 ++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ec35b6adb..476b9f502 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -61,7 +61,7 @@ const port2blob_num = { "48782": 0, // LTHN "19734": 0, // SUMO "13007": 2, // IRD - "13102": 0, // XTA + "13102": 12, // XTA "19994": 0, // ARQ "19281": 8, // XMV "33124": 9, // XTNC @@ -77,7 +77,7 @@ const port2algo = { "11898": "argon2/chukwa", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD - "13102": "rx/0", // XTA + "13102": "c29i", // XTA "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR "18981": "cn/rwz", // Graft @@ -376,9 +376,23 @@ function Coin(data){ this.portBlobType = function(port, version) { return port2blob_num[port]; } - this.blobTypeGrin = function(blob_type_num) { return blob_type_num == 8 || blob_type_num == 9 || blob_type_num == 10; } + this.blobTypeGrin = function(blob_type_num) { + switch (blob_type_num) { + case 8: + case 9: + case 10: + case 12: return true; + default: return false; + } + } - this.c29ProofSize = function(blob_type_num) { return blob_type_num == 10 ? 40 : 32; } + this.c29ProofSize = function(blob_type_num) { + switch (blob_type_num) { + case 10: return 40; + case 12: return 48; + default: return 32; + } + } this.nonceSize = function(blob_type_num) { return blob_type_num == 7 ? 8 : 4; } @@ -542,7 +556,7 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["LOKI"] = coin_perf["XTA"] = algos_perf["rx/0"]; + if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["LOKI"] = algos_perf["rx/0"]; if ("cn/r" in algos_perf) coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; @@ -571,6 +585,7 @@ function Coin(data){ if ("c29s" in algos_perf) coin_perf["XTNC"] = coin_perf["XWP"] = algos_perf["c29s"]; if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; if ("c29b" in algos_perf) coin_perf["TUBE"] = algos_perf["c29b"]; + if ("c29i" in algos_perf) coin_perf["XTA"] = algos_perf["c29i"]; if ("astrobwt" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt"]; @@ -608,7 +623,6 @@ function Coin(data){ case 11898: return multiHashing.argon2(convertedBlob, 0); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium - case 13102: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // Italocoin case 16000: return multiHashing.cryptonight(convertedBlob, 17, blockTemplate.height); // Conceal case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR @@ -636,7 +650,6 @@ function Coin(data){ if (!global.config.verify_shares_host) return cb(this.slowHash(convertedBlob, blockTemplate)); let jsonInput; switch (blockTemplate.port) { - case 13102: case 18081: case 19994: case 11812: @@ -658,6 +671,7 @@ function Coin(data){ this.c29 = function(header, ring, port) { switch (port) { + case 13102: return multiHashing.c29i(header, ring); // MoneroV case 19281: return multiHashing.c29v(header, ring); // MoneroV case 19950: return multiHashing.c29s(header, ring); // Swap case 25182: return multiHashing.c29b(header, ring); // TUBE @@ -669,7 +683,11 @@ function Coin(data){ } this.c29_cycle_hash = function(ring, blob_type_num) { - return blob_type_num == 10 ? multiHashing.c29b_cycle_hash(ring) : multiHashing.c29_cycle_hash(ring); + switch (blob_type_num) { + case 10: return multiHashing.c29b_cycle_hash(ring); + case 12: return multiHashing.c29i_cycle_hash(ring); + default: return multiHashing.c29_cycle_hash(ring); + } } this.blobTypeStr = function(port, version) { @@ -679,6 +697,7 @@ function Coin(data){ case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO + case 13102: return "cryptonote_xta"; // Italocoin case 17750: return "cryptonote_xhv"; // XHV case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap diff --git a/package.json b/package.json index e08fecbfa..c744db57a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.1.1", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v20.0.0" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.2.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v21.0.0" } } From 49b692d56a988da9533f0f3f5409168b573edf21 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 12 Sep 2020 16:59:48 +0000 Subject: [PATCH 0970/1496] DERO reward fix --- lib/coins/xmr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 476b9f502..91ac824a1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -266,7 +266,9 @@ function Coin(data){ // TRTL/IRD does not get getblock LTHN / AEON / DERO have composite tx if (port == 11898 || port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { - if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { + if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || + (port == 20206 && body.result.block_header.depth < 100) // DERO can change block reward overtime? + ) { console.error(JSON.stringify(body)); return callback(true, body); } From 18c344a2dcd6adcf2a19afb35cc9429b32eb246c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 23 Sep 2020 04:22:10 +0000 Subject: [PATCH 0971/1496] Updated to v17 monero daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 35620e13f..48f57cd66 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.16.0.1 +sudo git checkout v0.17.0.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 346b28f42..44ce587a2 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.16.0.1 +sudo git checkout v0.17.0.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 257410fd7..31e9d855c 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.16.0.1 +sudo git checkout v0.17.0.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 03e386d4f..0de56b26d 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.16.0.1 &&\ +sudo git checkout v0.17.0.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 723f5a3b3876f50aea297628433d0344917feff8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 28 Sep 2020 15:21:59 +0000 Subject: [PATCH 0972/1496] Updated to v17.0.1 monero daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 48f57cd66..b86f78c96 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.0.0 +sudo git checkout v0.17.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 44ce587a2..c8fa336d2 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.0.0 +sudo git checkout v0.17.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 31e9d855c..41852da40 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.0.0 +sudo git checkout v0.17.0.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 0de56b26d..1c2dc120a 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.0.0 &&\ +sudo git checkout v0.17.0.1 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 6a42eba412ee3d15f3eb745d71ef137d8b5f6c04 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 29 Sep 2020 18:37:03 +0000 Subject: [PATCH 0973/1496] Switched to release monero build --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index b86f78c96..85254314e 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -22,7 +22,7 @@ cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero sudo git checkout v0.17.0.1 -sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 +sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon sudo systemctl daemon-reload diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index c8fa336d2..00c69c8e8 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -22,7 +22,7 @@ cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero sudo git checkout v0.17.0.1 -sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 +sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon sudo systemctl daemon-reload diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 41852da40..93982a6c2 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -18,7 +18,7 @@ cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero sudo git checkout v0.17.0.1 -sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 make || exit 0 +sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon sudo systemctl daemon-reload diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 1c2dc120a..82db2dfd6 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -10,5 +10,5 @@ sudo git checkout v0.17.0.1 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ -(sudo USE_SINGLE_BUILDDIR=1 nice make -j$(nproc) || sudo USE_SINGLE_BUILDDIR=1 nice make) &&\ +sudo USE_SINGLE_BUILDDIR=1 nice make release &&\ echo "Done building the new Monero daemon! Please go ahead and reboot monero with: sudo systemctl restart monero as soon as the pool source is updated!" From 0d1a6df75cc210a5969646ff91054cf973f445be Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Oct 2020 15:45:42 +0000 Subject: [PATCH 0974/1496] Updated to v17.1 monero daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 85254314e..fd078ca80 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.0.1 +sudo git checkout v0.17.1.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 00c69c8e8..8021d37a1 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.0.1 +sudo git checkout v0.17.1.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 93982a6c2..b4e585fc4 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.0.1 +sudo git checkout v0.17.1.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 82db2dfd6..b892a9d4d 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.0.1 &&\ +sudo git checkout v0.17.1.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From d0f41a824dad63fa6a1ddeda7eb115ec16f35c85 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Oct 2020 17:21:56 +0000 Subject: [PATCH 0975/1496] Do not reject other new DERO blocks --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 91ac824a1..697bbb5f1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -267,7 +267,7 @@ function Coin(data){ if (port == 11898 || port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || - (port == 20206 && body.result.block_header.depth < 100) // DERO can change block reward overtime? + (is_our_block && port == 20206 && body.result.block_header.depth < 100) // DERO can change block reward overtime? ) { console.error(JSON.stringify(body)); return callback(true, body); From a3db6275f4c52f4474521a9b4ce0262f9f3c4a45 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Oct 2020 16:16:42 +0000 Subject: [PATCH 0976/1496] Updated to v17.1.1 monero daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index fd078ca80..daddc1439 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.0 +sudo git checkout v0.17.1.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 8021d37a1..527b6be7f 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.0 +sudo git checkout v0.17.1.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index b4e585fc4..b372def42 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.0 +sudo git checkout v0.17.1.1 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index b892a9d4d..0f5e1a2d3 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.0 &&\ +sudo git checkout v0.17.1.1 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 6b15ad18e8a3ec9ea668366617a44538453086bb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Oct 2020 19:31:14 +0000 Subject: [PATCH 0977/1496] Added ability to lock user payments --- deployment/base.sql | 1 + lib/api.js | 10 ++++++++-- user_scripts/lock_pay.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 user_scripts/lock_pay.js diff --git a/deployment/base.sql b/deployment/base.sql index f86885c96..e8c331ad6 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -165,6 +165,7 @@ CREATE TABLE `users` ( `admin` tinyint(1) DEFAULT '0', `payout_threshold` bigint(16) DEFAULT '0', `enable_email` tinyint(1) DEFAULT '1', + `payout_threshold_lock` tinyint(1) DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `users_id_uindex` (`id`), UNIQUE KEY `users_username_uindex` (`username`) diff --git a/lib/api.js b/lib/api.js index 48bd06c41..256ce5ebd 100644 --- a/lib/api.js +++ b/lib/api.js @@ -579,8 +579,14 @@ app.post('/user/updateThreshold', function (req, res) { const username = req.body.username; if (!username || global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set threshold for unknown user"}); const threshold2 = global.support.decimalToCoin(threshold < global.config.payout.walletMin ? global.config.payout.walletMin : threshold); - global.mysql.query("INSERT INTO users (username, payout_threshold) VALUES (?, ?) ON DUPLICATE KEY UPDATE payout_threshold=?", [username, threshold2, threshold2]).then(function () { - return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold2)}); + global.mysql.query("SELECT * FROM users WHERE username = ? AND payout_threshold_lock = '0'", [req.body.username]).then(function (rows) { + if (rows.length === 1) { + global.mysql.query("INSERT INTO users (username, payout_threshold) VALUES (?, ?) ON DUPLICATE KEY UPDATE payout_threshold=?", [username, threshold2, threshold2]).then(function () { + return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold2)}); + }); + } else { + return res.status(401).send({'success': false, 'msg':"Can't update locked payment threshold"}); + } }); }); diff --git a/user_scripts/lock_pay.js b/user_scripts/lock_pay.js new file mode 100644 index 000000000..819e7bf89 --- /dev/null +++ b/user_scripts/lock_pay.js @@ -0,0 +1,35 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.user) { + console.error("Please specify user address to set"); + process.exit(1); +} + +const user = argv.user; + +require("../init_mini.js").init(function() { + async.waterfall([ + function (callback) { + global.mysql.query("SELECT * FROM users WHERE username = ?", [user]).then(function (rows) { + if (rows.length != 1) { + console.error("User password and thus email is not yet set"); + process.exit(1); + } + callback(); + }); + }, + function (callback) { + global.mysql.query("UPDATE users SET payout_threshold_lock = '1' WHERE username = ?", [user]).then(function (rows) { + console.log("UPDATE users SET payout_threshold_lock = '1' WHERE username = " + user); + callback(); + }); + }, + function (callback) { + console.log("Done."); + process.exit(0); + } + ]); +}); From aede07a06a0a60febeeacf41b9156ea68c386dfd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 03:29:19 +0000 Subject: [PATCH 0978/1496] argon2/chukwav2 support --- lib/coins/xmr.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 697bbb5f1..dbb380e53 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -74,7 +74,7 @@ const port2blob_num = { const port2algo = { "11181": "k12", // Aeon - "11898": "argon2/chukwa", // TRTL + "11898": "argon2/chukwav2", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD "13102": "c29i", // XTA @@ -595,8 +595,8 @@ function Coin(data){ if ("cn/ccx" in algos_perf) coin_perf["CCX"] = algos_perf["cn/ccx"]; - if ("argon2/chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwa"]; - else if ("chukwa" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwa"]; + if ("argon2/chukwav2" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwav2"]; + else if ("chukwav2" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwav2"]; return coin_perf; } @@ -622,7 +622,7 @@ function Coin(data){ switch (blockTemplate.port) { case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon - case 11898: return multiHashing.argon2(convertedBlob, 0); // TRTL + case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium case 16000: return multiHashing.cryptonight(convertedBlob, 17, blockTemplate.height); // Conceal diff --git a/package.json b/package.json index c744db57a..25857df92 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.2.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v21.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.0.0" } } From f787e0cd42ac1969a27229d82374f1bb70ce1f54 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:01:54 +0000 Subject: [PATCH 0979/1496] New TRTL API support --- deployment/base.sql | 1 + lib/coins/xmr.js | 112 +++++++++++++++++++++++++++++++------------- lib/pool.js | 14 ++++-- lib/pool_stats.js | 24 +++++----- lib/support.js | 78 ++++++++++++------------------ 5 files changed, 133 insertions(+), 96 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index e8c331ad6..7c60b839d 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -202,6 +202,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'port', '18081', 'int', 'Monero Daemon RPC Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'basicAuth', '', 'string', 'Basic auth header if needed by daemon'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'X-API-KEY', '', 'string', 'Turtle wallet API auth header'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePort', '18081', 'int', 'Main coin active daemon RPC port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortRYO', '0', 'int', 'Ryo coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortSUMO', '0', 'int', 'SUMO coin daemon RPC port or 0'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index dbb380e53..a3f791356 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -29,7 +29,7 @@ const port2coin = { "18081": "", "18981": "GRFT", "11812": "XLA", - "22023": "LOKI", +// "22023": "LOKI", "25182": "TUBE", "34568": "WOW", "38081": "MSR", @@ -54,7 +54,7 @@ const port2blob_num = { "18081": 0, // XMR "18981": 0, // GRFT "11812": 0, // XLA - "22023": 5, // LOKI +// "22023": 5, // LOKI "25182": 10, // TUBE "34568": 0, // WOW "38081": 6, // MSR @@ -86,7 +86,7 @@ const port2algo = { "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa "11812": "panthera", // Scala - "22023": "rx/loki", // LOKI +// "22023": "rx/loki", // LOKI "25182": "c29b", // BitTube "33124": "c29s", // XtendCash "34568": "rx/wow", // Wownero @@ -248,14 +248,26 @@ function Coin(data){ this.niceHashDiff = 400000; this.getPortBlockHeaderByID = function(port, blockId, callback){ - global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { - if (body && body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); + if (port == 11898) { + global.support.rpcPortDaemon2(port, 'block/' + blockId, null, function (body) { + if (body) { + return callback(null, body); + } else { + console.error(JSON.stringify(body)); + return callback(true, body); + } + }); + } else { + global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { + if (body && body.hasOwnProperty('result')) { + return callback(null, body.result.block_header); + } else { + console.error(JSON.stringify(body)); + return callback(true, body); + } + }); + + } }; this.getBlockHeaderByID = function(blockId, callback){ @@ -264,7 +276,15 @@ function Coin(data){ this.getPortAnyBlockHeaderByHash = function(port, blockHash, is_our_block, callback){ // TRTL/IRD does not get getblock LTHN / AEON / DERO have composite tx - if (port == 11898 || port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { + if (port == 11898) { + global.support.rpcPortDaemon2(port, 'block/' + blockHash, null, function (body) { + if (typeof(body) === 'undefined') { + console.error(JSON.stringify(body)); + return callback(true, body); + } + return callback(null, body); + }); + } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || (is_our_block && port == 20206 && body.result.block_header.depth < 100) // DERO can change block reward overtime? @@ -286,7 +306,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 22023 || port == 33124 || port == 25182 || port == 13102 || port == 18181) { // Loki / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction + if (/*port == 22023 ||*/ port == 33124 || port == 25182 || port == 13102 || port == 18181) { // Loki / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Fri, 23 Oct 2020 19:10:04 +0000 Subject: [PATCH 0980/1496] New TRTL API support --- lib/support.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/support.js b/lib/support.js index 305d8c184..5a5a7a84d 100644 --- a/lib/support.js +++ b/lib/support.js @@ -120,11 +120,9 @@ function jsonRequest(host, port, data, callback, path, timeout) { } else { uri = "http://" + host + ":" + port + "/"; } - debug("JSON URI: " + uri + path + " Args: " + JSON.stringify(data)); let client = requestJson.createClient(uri, {timeout: timeout}); - client.headers["Content-Type"] = "application/json"; - client.headers["Accept"] = "application/json"; - client.headers["Content-Length"] = data.length; + client.headers["Content-Type"] = "application/json"; + client.headers["Accept"] = "application/json"; if (global.config.daemon.basicAuth) client.headers["Authorization"] = global.config.daemon.basicAuth; if (global.config.daemon["X-API-KEY"]) client.headers["X-API-KEY"] = global.config.daemon["X-API-KEY"]; let reply_fn = function (err, res, body) { @@ -136,8 +134,12 @@ function jsonRequest(host, port, data, callback, path, timeout) { return callback(body); }; if (data) { - client.post(path, data, reply_fn); + const data_str = JSON.stringify(data); + client.headers["Content-Length"] = data_str.length; + debug("JSON URI: " + uri + path + " Args: " + data_str); + client.post(path, data_str, reply_fn); } else { + debug("JSON URI: " + uri + path); client.get(path, reply_fn); } } From 8880d6dbc9d5f0a7ae52e21279c0b277a4abf7f5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:12:20 +0000 Subject: [PATCH 0981/1496] New TRTL API support --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 5a5a7a84d..212d7684a 100644 --- a/lib/support.js +++ b/lib/support.js @@ -134,7 +134,7 @@ function jsonRequest(host, port, data, callback, path, timeout) { return callback(body); }; if (data) { - const data_str = JSON.stringify(data); + const data_str = JSON.stringify(data) + "\n"; client.headers["Content-Length"] = data_str.length; debug("JSON URI: " + uri + path + " Args: " + data_str); client.post(path, data_str, reply_fn); From 1351befff05edd63b4ef1dead18849c2b0f62f24 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:22:05 +0000 Subject: [PATCH 0982/1496] New TRTL API support --- lib/support.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/support.js b/lib/support.js index 212d7684a..7af22771e 100644 --- a/lib/support.js +++ b/lib/support.js @@ -120,7 +120,7 @@ function jsonRequest(host, port, data, callback, path, timeout) { } else { uri = "http://" + host + ":" + port + "/"; } - let client = requestJson.createClient(uri, {timeout: timeout}); + let client = request.createClient(uri, {timeout: timeout}); client.headers["Content-Type"] = "application/json"; client.headers["Accept"] = "application/json"; if (global.config.daemon.basicAuth) client.headers["Authorization"] = global.config.daemon.basicAuth; @@ -134,10 +134,10 @@ function jsonRequest(host, port, data, callback, path, timeout) { return callback(body); }; if (data) { - const data_str = JSON.stringify(data) + "\n"; - client.headers["Content-Length"] = data_str.length; - debug("JSON URI: " + uri + path + " Args: " + data_str); - client.post(path, data_str, reply_fn); + const data2 = typeof data === 'string' ? data : JSON.stringify(data); + client.headers["Content-Length"] = data2.length; + debug("JSON URI: " + uri + path + " Args: " + data2); + client.post(path, data2, reply_fn); } else { debug("JSON URI: " + uri + path); client.get(path, reply_fn); From 621ae7ec85b4b1c4c1295598a6009f0e7b1e24f8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:34:52 +0000 Subject: [PATCH 0983/1496] New TRTL API support --- lib/support.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/support.js b/lib/support.js index 7af22771e..f92a09ed6 100644 --- a/lib/support.js +++ b/lib/support.js @@ -114,17 +114,21 @@ function sendEmailAdmin(subject, body){ } function jsonRequest(host, port, data, callback, path, timeout) { - let uri; - if (global.config.rpc.https) { - uri = "https://" + host + ":" + port + "/"; - } else { - uri = "http://" + host + ":" + port + "/"; - } - let client = request.createClient(uri, {timeout: timeout}); - client.headers["Content-Type"] = "application/json"; - client.headers["Accept"] = "application/json"; - if (global.config.daemon.basicAuth) client.headers["Authorization"] = global.config.daemon.basicAuth; - if (global.config.daemon["X-API-KEY"]) client.headers["X-API-KEY"] = global.config.daemon["X-API-KEY"]; + let options = { + url: (global.config.rpc.https ? "https://" : "http://") + host + ":" + port + "/" + path, + method: data ? "POST" : "GET", + headers: { + "Content-Type": "application/json", + "Accept": "application/json" + } + }; + if (global.config.daemon.basicAuth) options.headers["Authorization"] = global.config.daemon.basicAuth; + if (global.config.daemon["X-API-KEY"]) options.headers["X-API-KEY"] = global.config.daemon["X-API-KEY"]; + if (data) { + const data2 = typeof data === 'string' ? data : JSON.stringify(data); + options.headers["Content-Length"] = data2.length; + options.body = data2; + } let reply_fn = function (err, res, body) { if (err) { if (typeof(err) === "string") console.error("Error doing " + uri + path + " request: " + err); @@ -133,15 +137,8 @@ function jsonRequest(host, port, data, callback, path, timeout) { debug("JSON result: " + JSON.stringify(body)); return callback(body); }; - if (data) { - const data2 = typeof data === 'string' ? data : JSON.stringify(data); - client.headers["Content-Length"] = data2.length; - debug("JSON URI: " + uri + path + " Args: " + data2); - client.post(path, data2, reply_fn); - } else { - debug("JSON URI: " + uri + path); - client.get(path, reply_fn); - } + debug("JSON URI: " + uri + path + " Args: " + JSON.stringify(options)); + request(options, reply_fn); } function rpc(host, port, method, params, callback, timeout) { From 6004c6d1398c0754b00f7d49b6fc61d5c4ccc9d8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:35:36 +0000 Subject: [PATCH 0984/1496] New TRTL API support --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index f92a09ed6..e772b60b5 100644 --- a/lib/support.js +++ b/lib/support.js @@ -137,7 +137,7 @@ function jsonRequest(host, port, data, callback, path, timeout) { debug("JSON result: " + JSON.stringify(body)); return callback(body); }; - debug("JSON URI: " + uri + path + " Args: " + JSON.stringify(options)); + debug("JSON REQUST: " + JSON.stringify(options)); request(options, reply_fn); } From 6c2804de64870222661309959f5b4f1fdacde4eb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:39:09 +0000 Subject: [PATCH 0985/1496] New TRTL API support --- lib/support.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index e772b60b5..745d013b2 100644 --- a/lib/support.js +++ b/lib/support.js @@ -134,8 +134,15 @@ function jsonRequest(host, port, data, callback, path, timeout) { if (typeof(err) === "string") console.error("Error doing " + uri + path + " request: " + err); return callback(err); } - debug("JSON result: " + JSON.stringify(body)); - return callback(body); + let json; + try { + json = JSON.parse(str); + } catch (e) { + debug("JSON parse exception: " + body); + return callback("JSON parse exception: " + body); + } + debug("JSON result: " + JSON.stringify(json)); + return callback(json); }; debug("JSON REQUST: " + JSON.stringify(options)); request(options, reply_fn); From ecef27c3aa926072a8e0999aa59f3d93d1d30e27 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:39:57 +0000 Subject: [PATCH 0986/1496] New TRTL API support --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 745d013b2..dfd4862d2 100644 --- a/lib/support.js +++ b/lib/support.js @@ -136,7 +136,7 @@ function jsonRequest(host, port, data, callback, path, timeout) { } let json; try { - json = JSON.parse(str); + json = JSON.parse(body); } catch (e) { debug("JSON parse exception: " + body); return callback("JSON parse exception: " + body); From 71ececcf922ce8a8c425ae3c85718cc6e75db0e1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 19:56:39 +0000 Subject: [PATCH 0987/1496] New TRTL API support --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index d96214783..a70fb73d0 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -691,7 +691,7 @@ function altblockUnlocker() { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - //console.log(block.port + ": " + block.hash); + console.log(block.port + ": " + block.hash); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { From 5820b19fed7ecb43bbbe125bc9c5debb78edb553 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 20:21:14 +0000 Subject: [PATCH 0988/1496] Improved wow block handling --- lib/blockManager.js | 73 +++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index a70fb73d0..07e628dd6 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -691,49 +691,52 @@ function altblockUnlocker() { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - console.log(block.port + ": " + block.hash); - global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { - if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { - global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { - if (anchor_err === null){ - payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, false/*(topBlockHeight - block.anchor_height) < 120*/, function(status) { - if (status) { - console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); - global.database.payReadyAltBlock(block.hash); + if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { + if (anchor_err === null){ + payReadyBlockHashCalc[block.hash] = 1; + preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, false/*(topBlockHeight - block.anchor_height) < 120*/, function(status) { + if (status) { + console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); + global.database.payReadyAltBlock(block.hash); + } + return next(); + }); + } else { + console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); + return next(); + } + }); + } else if (!is_pplns_block || block.pay_ready === true) { + if (block.pay_value !== 0) { + console.log(block.port + ": " + block.hash); + global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { + if (body.topoheight && body.topoheight === -1) { + global.database.invalidateAltBlock(block.id); + console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); + return next(); + } else if (err !== null) { + console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); + global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { + if (err === null && body.hash !== block.hash) { + global.database.invalidateAltBlock(block.id); + console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); } return next(); }); } else { - console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); - return next(); + altblockPayments(block, function() { return next(); } ); } - }); - } else if (body.topoheight && body.topoheight === -1) { - global.database.invalidateAltBlock(block.id); - console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); - return next(); - } else if (err !== null) { - console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); - global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { - if (err === null && body.hash !== block.hash) { - global.database.invalidateAltBlock(block.id); - console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); - } - return next(); - }); - } else if (!is_pplns_block || block.pay_ready === true) { - if (block.pay_value !== 0) { - altblockPayments(block, function() { return next(); } ); - } else { - if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; - blockHeightWait[block.port].push(block.height); - return next(); - } + }); } else { + if (!(block.port in blockHeightWait)) blockHeightWait[block.port] = []; + blockHeightWait[block.port].push(block.height); return next(); } - }); + } else { + return next(); + } + }, function() { for (let port in blockHeightWait) { console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); From 9338f0946ff968460d315f6adac0c090251c5fb0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 21:16:34 +0000 Subject: [PATCH 0989/1496] New TRTL API support --- lib/coins/xmr.js | 6 +++--- lib/pool.js | 8 ++++---- manage_scripts/get_block_template.js | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a3f791356..abd6c1308 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -382,14 +382,14 @@ function Coin(data){ address: global.config.pool[port == global.config.daemon.port ? "address" : "address_" + port.toString()], reserveSize: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size }, function(body){ - return callback(body); + return callback(body ? body : null); }); } else { global.support.rpcPortDaemon(port, 'getblocktemplate', { reserve_size: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size, wallet_address: global.config.pool[port == global.config.daemon.port ? "address" : "address_" + port.toString()] }, function(body){ - return callback(body); + return callback(body && body.result && body.result : null); }); } }; @@ -494,7 +494,7 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream. - this.blocktemplate_blob = template.blocktemplate_blob; + this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : template.blob; this.difficulty = template.difficulty; this.height = template.height; this.seed_hash = template.seed_hash; diff --git a/lib/pool.js b/lib/pool.js index a5e0167de..fb163d072 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -274,13 +274,13 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa // templateUpdateReal is only called in master thread (except the beginning of a worker thread) function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { - global.coinFuncs.getPortBlockTemplate(port, function (rpcResponse) { + global.coinFuncs.getPortBlockTemplate(port, function (body_bt) { if (!newCoinHashFactor[coin]) { console.log("Aborting " + port + " last block template request because " + coin + " already has zero hash factor"); return; } - if (rpcResponse && typeof rpcResponse.result !== 'undefined') { - const template = process_rpc_template(rpcResponse.result, coin, port, coinHashFactor, isHashFactorChange); + if (body_bt) { + const template = process_rpc_template(body_bt, coin, port, coinHashFactor, isHashFactorChange); debug(threadName + "New block template found at " + template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); @@ -301,7 +301,7 @@ function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { setNewBlockTemplate(template); } } else { - console.error("Block template request failed for " + port + " port."); + console.error("Block template request failed for " + port + " port"); coinHashFactorUpdate(coin, 0); setTimeout(templateUpdateReal, 3000, coin, port, coinHashFactor, isHashFactorChange); } diff --git a/manage_scripts/get_block_template.js b/manage_scripts/get_block_template.js index c2fc7f8f0..9e5e4d8db 100644 --- a/manage_scripts/get_block_template.js +++ b/manage_scripts/get_block_template.js @@ -9,8 +9,7 @@ if (!argv.port) { const port = argv.port; require("../init_mini.js").init(function() { - global.coinFuncs.getPortBlockTemplate(port, function (err_header, body_header) { - console.log("err:" + JSON.stringify(err_header)); + global.coinFuncs.getPortBlockTemplate(port, function (body_header) { console.log("body:" + JSON.stringify(body_header)); process.exit(0); }); From c7e34d3f533092873829a5274bb2e34e92c8cc41 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Oct 2020 21:17:59 +0000 Subject: [PATCH 0990/1496] New TRTL API support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index abd6c1308..cee5c6d5f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -389,7 +389,7 @@ function Coin(data){ reserve_size: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size, wallet_address: global.config.pool[port == global.config.daemon.port ? "address" : "address_" + port.toString()] }, function(body){ - return callback(body && body.result && body.result : null); + return callback(body && body.result ? body.result : null); }); } }; From e049f0005589f8d380ce83841db34b31348633c6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 00:01:01 +0000 Subject: [PATCH 0991/1496] Fixed TRTL blob --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index cee5c6d5f..0ddad32a6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -509,7 +509,7 @@ function Coin(data){ } const is_dero = global.coinFuncs.blobTypeDero(port2blob_num[this.port]); - const blob = is_dero ? template.blockhashing_blob : (is_mm ? template.parent_blocktemplate_blob : template.blocktemplate_blob); + const blob = is_dero ? template.blockhashing_blob : (is_mm ? template.parent_blocktemplate_blob : this.blocktemplate_blob); this.idHash = crypto.createHash('md5').update(blob).digest('hex'); From e6b5ad07cea0e7038cdf8b154fb56faac595385e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 01:30:37 +0000 Subject: [PATCH 0992/1496] Fixed TRTL blob --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0ddad32a6..1f3b42a01 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -543,7 +543,7 @@ function Coin(data){ } } else { //console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in " + this.port + " block " + ": " + blob); - this.reserved_offset = template.reserved_offset; + this.reserved_offset = template.reserved_offset ? template.reserved_offset : template.reservedOffset; } } else { // exception for DERO this.reserved_offset = template.reserved_offset + 1; From 46f2b5bb11a2f2eeb81daa2693d308ef53312166 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 04:13:28 +0000 Subject: [PATCH 0993/1496] New TRTL API support --- lib/coins/xmr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1f3b42a01..245cc925e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -494,7 +494,7 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream. - this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : template.blob; + this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : (template.blob ? template.blob : ""); this.difficulty = template.difficulty; this.height = template.height; this.seed_hash = template.seed_hash; @@ -549,6 +549,8 @@ function Coin(data){ this.reserved_offset = template.reserved_offset + 1; } + if (!this.reserved_offset) this.reserved_offset = 0; // to avoid hard crash + if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); this.buffer.copy(prev_hash, 0, 7, 39); From e623e95528d5a540a5b207e0aab2fc302d7d948d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 04:18:23 +0000 Subject: [PATCH 0994/1496] New TRTL API support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 245cc925e..b1de59916 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -494,7 +494,7 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream. - this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : (template.blob ? template.blob : ""); + this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : (template.blob ? template.blob : extra_nonce_mm_template_hex); this.difficulty = template.difficulty; this.height = template.height; this.seed_hash = template.seed_hash; From e7ecad8763bee8fc8e35144370a497fb2a4db9fd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 07:51:50 +0000 Subject: [PATCH 0995/1496] Restored timeout --- lib/support.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/support.js b/lib/support.js index dfd4862d2..f2be0fd0f 100644 --- a/lib/support.js +++ b/lib/support.js @@ -116,11 +116,12 @@ function sendEmailAdmin(subject, body){ function jsonRequest(host, port, data, callback, path, timeout) { let options = { url: (global.config.rpc.https ? "https://" : "http://") + host + ":" + port + "/" + path, - method: data ? "POST" : "GET", - headers: { - "Content-Type": "application/json", - "Accept": "application/json" - } + method: data ? "POST" : "GET", + timeout: timeout, + headers: { + "Content-Type": "application/json", + "Accept": "application/json" + } }; if (global.config.daemon.basicAuth) options.headers["Authorization"] = global.config.daemon.basicAuth; if (global.config.daemon["X-API-KEY"]) options.headers["X-API-KEY"] = global.config.daemon["X-API-KEY"]; From 8e098f31e628297444e4557c41c8b67c040ae588 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 08:29:24 +0000 Subject: [PATCH 0996/1496] New TRTL API support --- lib/pool.js | 19 ++++++++++++++++--- lib/support.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index fb163d072..27e3f4d4c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1369,7 +1369,7 @@ function invalid_share(miner) { } function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, isRetrySubmitBlock) { - let reply_fn = function (rpcResult) { + let reply_fn = function (rpcResult, rpcStatus) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); @@ -1382,7 +1382,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi console.error(threadName + "Error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + - miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error) + + miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + ", error: " + JSON.stringify(rpcResult.error) + ", block hex: \n" + shareBuffer.toString('hex') ); @@ -1416,8 +1416,21 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi ", block hex: \n" + shareBuffer.toString('hex') ); recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); - } else { + } else if (rpcResult && rpcStatus == 202 && blockTemplate.port == 11898) { // TRTL + // Success! Submitted a block without an issue. + const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); + console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + + ", block hex: \n" + shareBuffer.toString('hex') + ); + recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); + } else { // something not expected happened if (isRetrySubmitBlock) { + console.error(threadName + "Unknown error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + + miner.logString + ", isTrustedShare: " + isTrustedShare + ", error: " + JSON.stringify(rpcResult) + + ", block hex: \n" + shareBuffer.toString('hex') + ); setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, false); } else { // RPC bombed out massively. diff --git a/lib/support.js b/lib/support.js index f2be0fd0f..537fd4e54 100644 --- a/lib/support.js +++ b/lib/support.js @@ -143,7 +143,7 @@ function jsonRequest(host, port, data, callback, path, timeout) { return callback("JSON parse exception: " + body); } debug("JSON result: " + JSON.stringify(json)); - return callback(json); + return callback(json, res); }; debug("JSON REQUST: " + JSON.stringify(options)); request(options, reply_fn); From 31adc1c95ad00281e7a68d345e51c71f49c8aac1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 08:44:34 +0000 Subject: [PATCH 0997/1496] New TRTL API support --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 27e3f4d4c..09a92d255 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1382,8 +1382,8 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi console.error(threadName + "Error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + - miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + ", error: " + JSON.stringify(rpcResult.error) + - ", block hex: \n" + shareBuffer.toString('hex') + miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + ", rpcStatus: " + rpcStatus + + ", error: " + JSON.stringify(rpcResult.error) + ", block hex: \n" + shareBuffer.toString('hex') ); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time @@ -1397,7 +1397,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "Input: " + shareBuffer.toString('hex') + "\n" + threadName + "Error submitting " + blockTemplate.coin + " block at " + blockTemplate.height + " height from " + miner.logString + - ", isTrustedShare: " + isTrustedShare + " error: " + JSON.stringify(rpcResult.error) + ", isTrustedShare: " + isTrustedShare + " error (" + (typeof rpcResult.error) + "): " + JSON.stringify(rpcResult.error) ); }); }, 2*1000); @@ -1416,7 +1416,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi ", block hex: \n" + shareBuffer.toString('hex') ); recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); - } else if (rpcResult && rpcStatus == 202 && blockTemplate.port == 11898) { // TRTL + } else if (rpcResult && typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898) { // TRTL // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + @@ -1428,7 +1428,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi if (isRetrySubmitBlock) { console.error(threadName + "Unknown error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + - miner.logString + ", isTrustedShare: " + isTrustedShare + ", error: " + JSON.stringify(rpcResult) + + miner.logString + ", isTrustedShare: " + isTrustedShare + ", rpcStatus: " + rpcStatus + ", error (" + (typeof rpcResult) + "): " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') ); setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, false); From cd53e38231fcae52729782dd6998814c1c11db6f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 08:47:17 +0000 Subject: [PATCH 0998/1496] New TRTL API support --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 537fd4e54..bbd2cac03 100644 --- a/lib/support.js +++ b/lib/support.js @@ -143,7 +143,7 @@ function jsonRequest(host, port, data, callback, path, timeout) { return callback("JSON parse exception: " + body); } debug("JSON result: " + JSON.stringify(json)); - return callback(json, res); + return callback(json, response.statusCode); }; debug("JSON REQUST: " + JSON.stringify(options)); request(options, reply_fn); From a0100f7e37c0a1806811a5235a04c8d5ca43fe87 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Oct 2020 08:47:52 +0000 Subject: [PATCH 0999/1496] New TRTL API support --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index bbd2cac03..f0ac68a58 100644 --- a/lib/support.js +++ b/lib/support.js @@ -143,7 +143,7 @@ function jsonRequest(host, port, data, callback, path, timeout) { return callback("JSON parse exception: " + body); } debug("JSON result: " + JSON.stringify(json)); - return callback(json, response.statusCode); + return callback(json, res.statusCode); }; debug("JSON REQUST: " + JSON.stringify(options)); request(options, reply_fn); From 70cdb01a4d7920de6f26d96fad6a137f1326354e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Oct 2020 04:25:04 +0000 Subject: [PATCH 1000/1496] Fixed payment threshold update for not accounts without email --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 256ce5ebd..3d4d521e2 100644 --- a/lib/api.js +++ b/lib/api.js @@ -579,8 +579,8 @@ app.post('/user/updateThreshold', function (req, res) { const username = req.body.username; if (!username || global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set threshold for unknown user"}); const threshold2 = global.support.decimalToCoin(threshold < global.config.payout.walletMin ? global.config.payout.walletMin : threshold); - global.mysql.query("SELECT * FROM users WHERE username = ? AND payout_threshold_lock = '0'", [req.body.username]).then(function (rows) { - if (rows.length === 1) { + global.mysql.query("SELECT * FROM users WHERE username = ? AND payout_threshold_lock = '1'", [req.body.username]).then(function (rows) { + if (rows.length === 0) { global.mysql.query("INSERT INTO users (username, payout_threshold) VALUES (?, ?) ON DUPLICATE KEY UPDATE payout_threshold=?", [username, threshold2, threshold2]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold2)}); }); From 72cf9d8cd233ebe37d8a7c1006998ec37af0ffe5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Oct 2020 04:33:20 +0000 Subject: [PATCH 1001/1496] Fixed payment threshold update for not accounts without email --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 3d4d521e2..9d1439767 100644 --- a/lib/api.js +++ b/lib/api.js @@ -579,7 +579,7 @@ app.post('/user/updateThreshold', function (req, res) { const username = req.body.username; if (!username || global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set threshold for unknown user"}); const threshold2 = global.support.decimalToCoin(threshold < global.config.payout.walletMin ? global.config.payout.walletMin : threshold); - global.mysql.query("SELECT * FROM users WHERE username = ? AND payout_threshold_lock = '1'", [req.body.username]).then(function (rows) { + global.mysql.query("SELECT * FROM users WHERE username = ? AND payout_threshold_lock = '1'", [username]).then(function (rows) { if (rows.length === 0) { global.mysql.query("INSERT INTO users (username, payout_threshold) VALUES (?, ?) ON DUPLICATE KEY UPDATE payout_threshold=?", [username, threshold2, threshold2]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold2)}); From b89991b54ac5f94fb584a826eb06e5f7643f5823 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:36:14 +0000 Subject: [PATCH 1002/1496] Draft implementation of Ravencoin --- lib/coins/xmr.js | 73 ++++++++++++++++++++++++++++-------------------- lib/pool.js | 3 +- lib/support.js | 1 - package.json | 2 +- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b1de59916..635fa607c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -29,7 +29,6 @@ const port2coin = { "18081": "", "18981": "GRFT", "11812": "XLA", -// "22023": "LOKI", "25182": "TUBE", "34568": "WOW", "38081": "MSR", @@ -45,31 +44,32 @@ const port2coin = { "20206": "DERO", "18181": "XMC", "16000": "CCX", + "8766" : "RVN", }; const port2blob_num = { - "11181": 7, // AEON - "11898": 2, // TRTL - "12211": 4, // RYO - "17750": 11, // XHV - "18081": 0, // XMR - "18981": 0, // GRFT - "11812": 0, // XLA -// "22023": 5, // LOKI - "25182": 10, // TUBE - "34568": 0, // WOW - "38081": 6, // MSR - "48782": 0, // LTHN - "19734": 0, // SUMO - "13007": 2, // IRD - "13102": 12, // XTA - "19994": 0, // ARQ - "19281": 8, // XMV - "33124": 9, // XTNC - "19950": 8, // XWP - "9231" : 5, // XEQ + "11181": 7, // AEON + "11898": 2, // TRTL + "12211": 4, // RYO + "17750": 11, // XHV + "18081": 0, // XMR + "18981": 0, // GRFT + "11812": 0, // XLA + "25182": 10, // TUBE + "34568": 0, // WOW + "38081": 6, // MSR + "48782": 0, // LTHN + "19734": 0, // SUMO + "13007": 2, // IRD + "13102": 12, // XTA + "19994": 0, // ARQ + "19281": 8, // XMV + "33124": 9, // XTNC + "19950": 8, // XWP + "9231" : 5, // XEQ + "18181": 0, // XMC + "16000": 0, // CCX "20206": 100, // DERO - "18181": 0, // XMC - "16000": 0, // TRTL + "8766" : 101, // RVN }; const port2algo = { @@ -86,7 +86,6 @@ const port2algo = { "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa "11812": "panthera", // Scala -// "22023": "rx/loki", // LOKI "25182": "c29b", // BitTube "33124": "c29s", // XtendCash "34568": "rx/wow", // Wownero @@ -96,6 +95,7 @@ const port2algo = { "20206": "astrobwt", // DERO "18181": "cn/0", // XMC "16000": "cn/ccx", // CCX + "8766" : "kawpow/rvn", // RVN }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -202,7 +202,7 @@ function Coin(data){ this.data = data; //let instanceId = crypto.randomBytes(4); let instanceId = new Buffer(4); - instanceId.writeUInt32LE( ((global.config.pool_id % (1<<16)) << 16) + (process.pid % (1<<16)) ); + instanceId.writeUInt32LE( ((global.config.pool_id % (1<<16)) << 16) + (process.pid % (1<<16)) ); console.log("Generated instanceId: " + instanceId.toString('hex')); this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address @@ -379,11 +379,22 @@ function Coin(data){ this.getPortBlockTemplate = function(port, callback) { if (port == 11898) { global.support.rpcPortDaemon2(port, 'block/template', { - address: global.config.pool[port == global.config.daemon.port ? "address" : "address_" + port.toString()], + address: global.config.pool["address_" + port.toString()], reserveSize: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size }, function(body){ return callback(body ? body : null); }); + } else if (port == 8766) { + global.support.rpcPortDaemon2(port, '', { + method: 'getblocktemplate', + params: [{ + capabilities: [ "coinbasetxn", "workid", "coinbase/append" ], + rules: [ "segwit" ] + }] + }, function(body){ + return callback(body ? cnUtils.RavenBlockTemplate(body, global.config.pool["address_" + port.toString()]) : null); + }); + } else { global.support.rpcPortDaemon(port, 'getblocktemplate', { reserve_size: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size, @@ -596,7 +607,7 @@ function Coin(data){ } this.getDefaultAlgosPerf = function() { - return { "rx/0": 1/*, "rx/loki": 1*/ }; + return { "rx/0": 1 }; } this.getPrevAlgosPerf = function() { @@ -606,7 +617,7 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("rx/0" in algos_perf) coin_perf[""] /*= coin_perf["LOKI"]*/ = algos_perf["rx/0"]; + if ("rx/0" in algos_perf) coin_perf[""] = algos_perf["rx/0"]; if ("cn/r" in algos_perf) coin_perf["SUMO"] = coin_perf["LTHN"] = algos_perf["cn/r"]; @@ -619,7 +630,7 @@ function Coin(data){ if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; - //if ("rx/loki" in algos_perf) coin_perf["LOKI"] = algos_perf["rx/loki"]; + if ("kawpow/rvn" in algos_perf) coin_perf["RVN"] = algos_perf["kawpow/rvn"]; if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; @@ -666,8 +677,9 @@ function Coin(data){ return "algo array must include at least one supported pool algo: [" + Object.keys(algos).join(", ") + "]"; } - this.slowHashBuff = function(convertedBlob, blockTemplate) { + this.slowHashBuff = function(convertedBlob, blockTemplate, job) { switch (blockTemplate.port) { + case 8766: return multiHashing.kawpow(blockTemplate.height, convertedBlob, Buffer.from(job.target_hex, 'hex')); // RVN case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL @@ -682,7 +694,6 @@ function Coin(data){ case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero - //case 22023: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 18); // Loki case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean diff --git a/lib/pool.js b/lib/pool.js index 09a92d255..80ca8a393 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -45,7 +45,6 @@ let lastBlockFixCount = {}; // number of times fix_daemon_sh was run let threadName; let minerCount = []; -let BlockTemplate = global.coinFuncs.BlockTemplate; let totalShares = 0, trustedShares = 0, normalShares = 0, invalidShares = 0, outdatedShares = 0, throttledShares = 0; // wallet -> { connectTime, count (miner), hashes, last_ver_shares } @@ -484,7 +483,7 @@ function setNewBlockTemplate(template) { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } - activeBlockTemplates[coin] = new BlockTemplate(template); + activeBlockTemplates[coin] = new global.coinFuncs.BlockTemplate(template); const height = activeBlockTemplates[coin].height; diff --git a/lib/support.js b/lib/support.js index f0ac68a58..b35a55d0d 100644 --- a/lib/support.js +++ b/lib/support.js @@ -2,7 +2,6 @@ const CircularBuffer = require('circular-buffer'); const https = require('https'); const request = require('request'); -const requestJson = require('request-json'); const moment = require('moment'); const debug = require('debug')('support'); const fs = require('fs'); diff --git a/package.json b/package.json index 25857df92..b4266729a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "async": "3.2.0", - "bignum": "^0.12.5", + "bignum": "^0.13.1", "body-parser": "^1.16.0", "circular-buffer": "1.0.2", "cluster": "0.7.7", From 89f1c26ad0c61be71dadda06e963d6241f29c53c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:39:10 +0000 Subject: [PATCH 1003/1496] Draft implementation of Ravencoin --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 80ca8a393..8b87bcf0d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -238,6 +238,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { + if (coin === "RVN") coinHashFactor = 100; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); From 163e66baf9f22154028da554a05153570db64612 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:51:15 +0000 Subject: [PATCH 1004/1496] Draft implementation of Ravencoin --- lib/coins/xmr.js | 10 ++++++++++ lib/pool.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 635fa607c..69fd4626b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -360,6 +360,16 @@ function Coin(data){ return callback(true, body); } }); + } else if (port == 8766) { + global.support.rpcPortDaemon2(port, '', { method: 'getbestblockheader' }, function (body) { + if (typeof(body) !== 'undefined'){ + body.hash = body.hex; + return callback(null, body); + } else { + if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); + return callback(true, body); + } + }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ diff --git a/lib/pool.js b/lib/pool.js index 8b87bcf0d..9e374e0ab 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -327,7 +327,7 @@ function templateUpdate(coin, repeating) { if (!newCoinHashFactor[coin]) { console.log(threadName + "Aborting " + port + " last block header request because " + coin + " already has zero hash factor"); if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); - } else if (err === null) { + } else if (err === null && !body.hash) { const isHashFactorChange = Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; From 4c6d594e50ab00059b71bceca7f7586e0f4e3638 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:52:16 +0000 Subject: [PATCH 1005/1496] Draft implementation of Ravencoin --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9e374e0ab..ffbbc4e9e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -327,7 +327,7 @@ function templateUpdate(coin, repeating) { if (!newCoinHashFactor[coin]) { console.log(threadName + "Aborting " + port + " last block header request because " + coin + " already has zero hash factor"); if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); - } else if (err === null && !body.hash) { + } else if (err === null && body.hash) { const isHashFactorChange = Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; From 797736f5caaebfe51aecbbf7f632f0c87b017945 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:54:16 +0000 Subject: [PATCH 1006/1496] Draft implementation of Ravencoin --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 69fd4626b..df85db69d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -353,7 +353,7 @@ function Coin(data){ this.getPortLastBlockHeader = function(port, callback, no_error_report) { if (port == 11898) { global.support.rpcPortDaemon2(port, 'block/last', null, function (body) { - if (typeof(body) !== 'undefined'){ + if (typeof(body) === 'object'){ return callback(null, body); } else { if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); @@ -362,7 +362,7 @@ function Coin(data){ }); } else if (port == 8766) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockheader' }, function (body) { - if (typeof(body) !== 'undefined'){ + if (typeof(body) === 'object'){ body.hash = body.hex; return callback(null, body); } else { From 0950119dbfd3ff17f3fc8abe5712b0fde5ecea8b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:55:32 +0000 Subject: [PATCH 1007/1496] Draft implementation of Ravencoin --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index df85db69d..5c528508d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -361,7 +361,7 @@ function Coin(data){ } }); } else if (port == 8766) { - global.support.rpcPortDaemon2(port, '', { method: 'getbestblockheader' }, function (body) { + global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (typeof(body) === 'object'){ body.hash = body.hex; return callback(null, body); From efad007e196522cbd00a1b4684f3047b658f5ad0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:59:08 +0000 Subject: [PATCH 1008/1496] Draft implementation of Ravencoin --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5c528508d..7be2d5cd8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -363,7 +363,7 @@ function Coin(data){ } else if (port == 8766) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (typeof(body) === 'object'){ - body.hash = body.hex; + body.hash = body.result; return callback(null, body); } else { if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); From c83d7bec9458603ad5c4eed356ed4d089bc3a604 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 30 Oct 2020 23:59:42 +0000 Subject: [PATCH 1009/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7be2d5cd8..1d57c3d8b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -402,7 +402,7 @@ function Coin(data){ rules: [ "segwit" ] }] }, function(body){ - return callback(body ? cnUtils.RavenBlockTemplate(body, global.config.pool["address_" + port.toString()]) : null); + return callback(body ? cnUtil.RavenBlockTemplate(body, global.config.pool["address_" + port.toString()]) : null); }); } else { From 37be21567a8dfdd43c9aea75ec0bffc65d752102 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 00:01:12 +0000 Subject: [PATCH 1010/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1d57c3d8b..94be54786 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -402,6 +402,7 @@ function Coin(data){ rules: [ "segwit" ] }] }, function(body){ + console.log(global.config.pool["address_" + port.toString()]); return callback(body ? cnUtil.RavenBlockTemplate(body, global.config.pool["address_" + port.toString()]) : null); }); From 0eff02b0cfcae6cfbab97575e59d02cda8ab96e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 00:21:34 +0000 Subject: [PATCH 1011/1496] Draft implementation of Ravencoin utils --- README.md | 1 + deployment/base.sql | 28 +++------------------------- lib/coins/xmr.js | 5 ++--- lib/pool_stats.js | 40 +++++++++------------------------------- lib/support.js | 10 ---------- 5 files changed, 15 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index ca3f754cd..ab0738684 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XTA - ```ipN5cNhm7RXAGACP4ZXki4afT3iJ1A6Ka5U4cswE6fBPDcv8JpivurBj3vu1bXwPyb8KZEGsFUYMmToFG4N9V9G72X4WpAQ8L``` * DERO - ```dERokvcrnuWH1ai1QmZQc9cgxrLwE3rX3TbhdrnLmi3BVZmf197qd5FaFqmPMp5dZ3igXfVQwUUMgTSjpVKDtUeb6DT2xp64XJ``` * CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` +* RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index 7c60b839d..06db036d3 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -203,30 +203,6 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'port', '18081', 'int', 'Monero Daemon RPC Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'basicAuth', '', 'string', 'Basic auth header if needed by daemon'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'X-API-KEY', '', 'string', 'Turtle wallet API auth header'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePort', '18081', 'int', 'Main coin active daemon RPC port'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortRYO', '0', 'int', 'Ryo coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortSUMO', '0', 'int', 'SUMO coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLOKI', '0', 'int', 'Loki coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXRN', '0', 'int', 'Saronite coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTNC', '0', 'int', 'XtencCash coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortWOW', '0', 'int', 'Wownero coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTUBE', '0', 'int', 'BitTube coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXHV', '0', 'int', 'Haven coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortAEON', '0', 'int', 'Aeon coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortMSR', '0', 'int', 'Masari coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXLA', '0', 'int', 'Scala coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortLTHN', '0', 'int', 'Lethean coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortGRFT', '0', 'int', 'Graft coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortTRTL', '0', 'int', 'Turtle coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortIRD', '0', 'int', 'Iridium coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortARQ', '0', 'int', 'ArqMa coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMV', '0', 'int', 'MoneroV coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXWP', '0', 'int', 'Swap coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXEQ', '0', 'int', 'Equilibria coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortCCX', '0', 'int', 'Conceal coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXTA', '0', 'int', 'Italocoin coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortDERO', '0', 'int', 'Dero coin daemon RPC port or 0'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'activePortXMC', '0', 'int', 'XMC coin daemon RPC port or 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); @@ -250,6 +226,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXTA', '0', 'float', 'Italocoin algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorDERO', '0', 'float', 'Dero algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMC', '0', 'float', 'XMC algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRVN', '0', 'float', 'RVN algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -309,7 +286,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_20206', '', 'string', 'Address to mine to for 20206 (Dero) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_18181', '', 'string', 'Address to mine to for 18181 (XMC) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_16000', '', 'string', 'Address to mine to for 16000 (CCX) port.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', 'Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb', 'string', 'Address to mine to for 9231 (Equilibria) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', '', 'string', 'Address to mine to for 9231 (Equilibria) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8766', '', 'string', 'Address to mine to for 8766 (Ravencoin) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 94be54786..08430c61d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -391,7 +391,7 @@ function Coin(data){ global.support.rpcPortDaemon2(port, 'block/template', { address: global.config.pool["address_" + port.toString()], reserveSize: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size - }, function(body){ + }, function(body) { return callback(body ? body : null); }); } else if (port == 8766) { @@ -401,8 +401,7 @@ function Coin(data){ capabilities: [ "coinbasetxn", "workid", "coinbase/append" ], rules: [ "segwit" ] }] - }, function(body){ - console.log(global.config.pool["address_" + port.toString()]); + }, function(body) { return callback(body ? cnUtil.RavenBlockTemplate(body, global.config.pool["address_" + port.toString()]) : null); }); diff --git a/lib/pool_stats.js b/lib/pool_stats.js index ef6654356..8cba56565 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -8,13 +8,6 @@ const max_altblocks = 10000; let lastBlockCheckIsFailed = {}; -function updatePoolStats(poolType) { - global.support.getActivePort("", function (newActivePort) { - if (newActivePort) global.config.daemon.activePort = newActivePort; - updatePoolStats2(poolType); - }); -} - let price_btc = 0; let price_usd = 0; let price_eur = 0; @@ -49,35 +42,20 @@ function get_cmc(callback) { }); } -function updatePoolStats2(poolType) { +function updatePoolStats(poolType) { //console.log("Cleaned " + global.database.env.mdb_reader_check() + " stale readers"); let cache; - let port_suffix = global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; if (typeof(poolType) !== 'undefined') { cache = global.database.getCache(poolType + "_stats"); - if (port_suffix === "") { - let cache2 = global.database.getCache(poolType + "_stats2"); - cache.totalHashes = cache2.totalHashes; - cache.roundHashes = cache2.roundHashes; - } else { - let cache2_total = global.database.getCache(poolType + "_stats2"); - let cache2_round = global.database.getCache(poolType + "_stats2" + port_suffix); - cache.totalHashes = cache2_total.totalHashes; - cache.roundHashes = cache2_round.roundHashes; - } + let cache2 = global.database.getCache(poolType + "_stats2"); + cache.totalHashes = cache2.totalHashes; + cache.roundHashes = cache2.roundHashes; } else { console.log("Running pool stats"); cache = global.database.getCache("global_stats"); - if (port_suffix === "") { - let cache2 = global.database.getCache("global_stats2"); - cache.totalHashes = cache2.totalHashes; - cache.roundHashes = cache2.roundHashes; - } else { - let cache2_total = global.database.getCache("global_stats2"); - let cache2_round = global.database.getCache("global_stats2" + port_suffix); - cache.totalHashes = cache2_total.totalHashes; - cache.roundHashes = cache2_round.roundHashes; - } + let cache2 = global.database.getCache("global_stats2"); + cache.totalHashes = cache2.totalHashes; + cache.roundHashes = cache2.roundHashes; } let port_hash = global.database.getCache('port_hash'); @@ -193,7 +171,7 @@ function updatePoolStats2(poolType) { }, function (callback) { //debug(threadName + "Checking MySQL for activePort value"); - return callback(null, global.config.daemon.activePort); + return callback(null, global.config.daemon.port); }, function (callback) { //debug(threadName + "Checking LMDB cache for active_ports value"); @@ -399,7 +377,7 @@ function updateBlockHeader() { value: body.reward, ts: body.timestamp, }; - if (port == global.config.daemon.activePort) { + if (port == global.config.daemon.port) { global.support.rpcPortDaemon(port, 'get_info', [], function (rpcResult) { network_info.difficulty = rpcResult.result ? rpcResult.result.difficulty : body.difficulty; network_info.hash = body.hash; diff --git a/lib/support.js b/lib/support.js index b35a55d0d..119e5f2b3 100644 --- a/lib/support.js +++ b/lib/support.js @@ -234,16 +234,6 @@ function getCoinHashFactor(coin, callback) { }); } -function getActivePort(coin, callback) { - global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'activePort" + coin + "'").then(function (rows) { - if (rows.length != 1) { - console.error("Can't get config.daemon.activePort" + coin + " value"); - return callback(null); - } - callback(parseInt(rows[0].item_value)); - }); -} - function setCoinHashFactor(coin, coinHashFactor) { global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'coinHashFactor" + coin + "'", [coinHashFactor]); global.config.daemon["coinHashFactor" + coin] = coinHashFactor; From 4a2a7a5c9a37a39056fb0e8c74f0a0265de5ed10 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 00:22:14 +0000 Subject: [PATCH 1012/1496] Draft implementation of Ravencoin utils --- lib/support.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 119e5f2b3..53f6a41ff 100644 --- a/lib/support.js +++ b/lib/support.js @@ -331,7 +331,6 @@ module.exports = function () { sendEmailAdmin: sendEmailAdmin, tsCompare: tsCompare, getCoinHashFactor: getCoinHashFactor, - getActivePort: getActivePort, setCoinHashFactor: setCoinHashFactor, setActivePort: setActivePort, https_get: https_get, From f553d38e623ac20ac58d7dedc56b85961fea1c98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 00:29:05 +0000 Subject: [PATCH 1013/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 08430c61d..564de4055 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -353,7 +353,7 @@ function Coin(data){ this.getPortLastBlockHeader = function(port, callback, no_error_report) { if (port == 11898) { global.support.rpcPortDaemon2(port, 'block/last', null, function (body) { - if (typeof(body) === 'object'){ + if (typeof(body) === 'object') { return callback(null, body); } else { if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); @@ -362,7 +362,7 @@ function Coin(data){ }); } else if (port == 8766) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { - if (typeof(body) === 'object'){ + if (typeof(body) === 'object' && body.result) { body.hash = body.result; return callback(null, body); } else { @@ -382,7 +382,7 @@ function Coin(data){ } }; - this.getLastBlockHeader = function(callback){ + this.getLastBlockHeader = function(callback) { return this.getPortLastBlockHeader(global.config.daemon.port, callback); }; @@ -402,7 +402,7 @@ function Coin(data){ rules: [ "segwit" ] }] }, function(body) { - return callback(body ? cnUtil.RavenBlockTemplate(body, global.config.pool["address_" + port.toString()]) : null); + return callback(body && body.result ? cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()]) : null); }); } else { From 4a0d141b2dfc07e847486511e5ff71b584ac5e9a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 00:31:39 +0000 Subject: [PATCH 1014/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 564de4055..e27e78531 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -515,6 +515,7 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream. + console.log(JSON.stringify(template)); this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : (template.blob ? template.blob : extra_nonce_mm_template_hex); this.difficulty = template.difficulty; this.height = template.height; From dc796d35cc21c29f42f79987430a7e3066da1f74 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 00:49:36 +0000 Subject: [PATCH 1015/1496] Draft implementation of Ravencoin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4266729a..adea3dcb3 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v8.2.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.0.0" } } From e6c63cb30557040114c3b905d1194b29fcbd8a6f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 01:53:48 +0000 Subject: [PATCH 1016/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e27e78531..8f56e74e3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -200,9 +200,8 @@ setInterval(function(queue_obj){ function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; - //let instanceId = crypto.randomBytes(4); let instanceId = new Buffer(4); - instanceId.writeUInt32LE( ((global.config.pool_id % (1<<16)) << 16) + (process.pid % (1<<16)) ); + instanceId.writeUInt32LE( ((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22)) ); console.log("Generated instanceId: " + instanceId.toString('hex')); this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address From e097e0c8406c3f6c875ded7c57820aa303e55a13 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 02:04:07 +0000 Subject: [PATCH 1017/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8f56e74e3..f3fb3fb6f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -201,6 +201,11 @@ function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; let instanceId = new Buffer(4); + console.log(global.config.pool_id); + console.log((global.config.pool_id % (1<<10)); + console.log(((global.config.pool_id % (1<<10)) << 22)); +console.log((process.pid % (1<<22))); +console.log(((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))); instanceId.writeUInt32LE( ((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22)) ); console.log("Generated instanceId: " + instanceId.toString('hex')); this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing From 52161b38b8974f97b51f7b8247a79ef4e0befe27 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 02:04:27 +0000 Subject: [PATCH 1018/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f3fb3fb6f..7f39d3611 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -202,7 +202,7 @@ function Coin(data){ this.data = data; let instanceId = new Buffer(4); console.log(global.config.pool_id); - console.log((global.config.pool_id % (1<<10)); + console.log((global.config.pool_id % (1<<10))); console.log(((global.config.pool_id % (1<<10)) << 22)); console.log((process.pid % (1<<22))); console.log(((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))); From 2b29b0c32dd33dacb52de761a0e83651c88a191e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 02:06:35 +0000 Subject: [PATCH 1019/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7f39d3611..3f02a8748 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -203,10 +203,10 @@ function Coin(data){ let instanceId = new Buffer(4); console.log(global.config.pool_id); console.log((global.config.pool_id % (1<<10))); - console.log(((global.config.pool_id % (1<<10)) << 22)); + console.log(((global.config.pool_id % (1<<10)) <<< 22)); console.log((process.pid % (1<<22))); -console.log(((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))); - instanceId.writeUInt32LE( ((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22)) ); +console.log(((global.config.pool_id % (1<<10)) <<< 22) + (process.pid % (1<<22))); + instanceId.writeUInt32LE( ((global.config.pool_id % (1<<10)) <<< 22) + (process.pid % (1<<22)) ); console.log("Generated instanceId: " + instanceId.toString('hex')); this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address From c41be3ba4e6608306f2c189f7d5c153ec832a4b1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 02:08:51 +0000 Subject: [PATCH 1020/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3f02a8748..0f72ad5ca 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -203,10 +203,10 @@ function Coin(data){ let instanceId = new Buffer(4); console.log(global.config.pool_id); console.log((global.config.pool_id % (1<<10))); - console.log(((global.config.pool_id % (1<<10)) <<< 22)); + console.log((((global.config.pool_id % (1<<10)) << 22)) >>> 0); console.log((process.pid % (1<<22))); -console.log(((global.config.pool_id % (1<<10)) <<< 22) + (process.pid % (1<<22))); - instanceId.writeUInt32LE( ((global.config.pool_id % (1<<10)) <<< 22) + (process.pid % (1<<22)) ); +console.log((((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))) >>> 0); + instanceId.writeUInt32LE( (((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))) >>> 0 ); console.log("Generated instanceId: " + instanceId.toString('hex')); this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address From ba5b5ee679c30219876682123c4e6e8879422a6b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 02:10:15 +0000 Subject: [PATCH 1021/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0f72ad5ca..6d4489e7b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -201,11 +201,6 @@ function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; let instanceId = new Buffer(4); - console.log(global.config.pool_id); - console.log((global.config.pool_id % (1<<10))); - console.log((((global.config.pool_id % (1<<10)) << 22)) >>> 0); -console.log((process.pid % (1<<22))); -console.log((((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))) >>> 0); instanceId.writeUInt32LE( (((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))) >>> 0 ); console.log("Generated instanceId: " + instanceId.toString('hex')); this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing From 07daf63215ee42b3320a4c2c653fb060b7cfef47 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 05:57:40 +0000 Subject: [PATCH 1022/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6d4489e7b..f91e8d508 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -514,7 +514,6 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream. - console.log(JSON.stringify(template)); this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : (template.blob ? template.blob : extra_nonce_mm_template_hex); this.difficulty = template.difficulty; this.height = template.height; @@ -602,6 +601,8 @@ function Coin(data){ // Don't convert the buffer to something hashable. You bad. return this.buffer.toString('hex'); }; + + if (this.coin == "RVN") console.log(global.coinFuncs.convertRavenBlob(this.buffer).toString('hex')); }; this.getPORTS = function() { return ports; } From c934a478d0c172048e8e800d916b534e03d4bd53 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 05:59:48 +0000 Subject: [PATCH 1023/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f91e8d508..d6373cd24 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -602,7 +602,7 @@ function Coin(data){ return this.buffer.toString('hex'); }; - if (this.coin == "RVN") console.log(global.coinFuncs.convertRavenBlob(this.buffer).toString('hex')); + if (this.coin == "RVN") console.log(cnUtil.convertRavenBlob(this.buffer).toString('hex')); }; this.getPORTS = function() { return ports; } From b7c40372c964e3e2ca122c643fd8c77a3015c515 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 06:01:01 +0000 Subject: [PATCH 1024/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d6373cd24..7f2b34daf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -601,7 +601,7 @@ function Coin(data){ // Don't convert the buffer to something hashable. You bad. return this.buffer.toString('hex'); }; - + if (this.coin == "RVN") console.log(this.buffer.toString('hex')); if (this.coin == "RVN") console.log(cnUtil.convertRavenBlob(this.buffer).toString('hex')); }; From 229cd2c4ba122be962362f2ec8a1569b5b5085ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 06:06:44 +0000 Subject: [PATCH 1025/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7f2b34daf..2268244e7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -536,6 +536,10 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); + if (this.coin == "RVN") console.log(this.buffer.toString('hex')); + if (this.coin == "RVN") console.log(cnUtil.convertRavenBlob(this.buffer).toString('hex')); + + if (!is_dero) { const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; const found_reserved_offset_template = blob.indexOf(template_hex); @@ -601,8 +605,6 @@ function Coin(data){ // Don't convert the buffer to something hashable. You bad. return this.buffer.toString('hex'); }; - if (this.coin == "RVN") console.log(this.buffer.toString('hex')); - if (this.coin == "RVN") console.log(cnUtil.convertRavenBlob(this.buffer).toString('hex')); }; this.getPORTS = function() { return ports; } From 8eecefc5078db0a804b89d42ada4156234384565 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 31 Oct 2020 06:37:51 +0000 Subject: [PATCH 1026/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 8 ++++---- lib/pool.js | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2268244e7..8c2855d88 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -460,9 +460,12 @@ function Coin(data){ this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } + this.blobTypeRaven = function(blob_type_num) { return blob_type_num == 101; } + this.convertBlob = function(blobBuffer, port){ const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; + if (this.blobTypeRaven(blob_type_num)) return cnUtil.convertRavenBlob(blobBuffer); let blob; try { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); @@ -536,10 +539,6 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); - if (this.coin == "RVN") console.log(this.buffer.toString('hex')); - if (this.coin == "RVN") console.log(cnUtil.convertRavenBlob(this.buffer).toString('hex')); - - if (!is_dero) { const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; const found_reserved_offset_template = blob.indexOf(template_hex); @@ -766,6 +765,7 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { + case 8766: return "raven"; // RVN case 9231 : return "cryptonote_loki"; // XEQ case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL diff --git a/lib/pool.js b/lib/pool.js index ffbbc4e9e..a73341ce8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1024,7 +1024,15 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi job_id: newJob.id, difficulty: this.difficulty, id: this.id - }; else this.cachedJob = { + }; else if (global.coinFuncs.blobTypeRaven(blob_type_num)) this.cachedJob = [ + newJob.id, + blob, + bt.seed_hash, + target, // ????? + true, + bt.rpc.height, + bt.rpc.bits + ]; else this.cachedJob = { blob: blob, algo: params.algo_name, height: bt.height, From 1f85c229bc6c630ab39af88c776ff0ee97c100f9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Nov 2020 21:48:13 +0000 Subject: [PATCH 1027/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 38 ++++++++----- lib/pool.js | 135 +++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 3 files changed, 127 insertions(+), 48 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8c2855d88..34a380270 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -418,9 +418,12 @@ function Coin(data){ return this.getPortBlockTemplate(global.config.daemon.port, callback); }; - this.baseDiff = function(){ + this.baseDiff = function() { return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); }; + this.baseRavenDiff = function() { + return bignum('00000000FF000000000000000000000000000000000000000000000000000000', 16); + }; this.validatePlainAddress = function(address){ // This function should be able to be called from the async library, as we need to BLOCK ever so slightly to verify the address. @@ -456,15 +459,23 @@ function Coin(data){ } } - this.nonceSize = function(blob_type_num) { return blob_type_num == 7 ? 8 : 4; } + this.nonceSize = function(blob_type_num) { + switch (blob_type_num) { + case 7: + case 101: return 8; + default: return 4; + } + } this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } this.blobTypeRaven = function(blob_type_num) { return blob_type_num == 101; } - this.convertBlob = function(blobBuffer, port){ + this.targetRavenDiff = function(diff) { return cnUtil.targetRavenDiff(diff); } + + this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); - if (this.blobTypeDero(blob_type_num)) return blobBuffer; + if (this.blobTypeDero(blob_type_num)) return blobBuffer; if (this.blobTypeRaven(blob_type_num)) return cnUtil.convertRavenBlob(blobBuffer); let blob; try { @@ -478,13 +489,12 @@ function Coin(data){ return blob; }; - this.constructNewBlob = function(blockTemplate, NonceBuffer, port, ring){ + this.constructNewBlob = function(blockTemplate, nonce, port, maxhash) { const blob_type_num = this.portBlobType(port, blockTemplate[0]); - if (this.blobTypeDero(blob_type_num)) { - NonceBuffer.copy(blockTemplate, 39, 0, 4); - return blockTemplate; - } else { - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, blob_type_num, ring); + switch (blob_type_num) { + case 100: return cnUtil.constructNewGrinBlob(blockTemplate, bignum(nonce, 10).toBuffer({endian: 'little', size: 4})); + case 101: return cnUtil.constructNewRavenBlob(blockTemplate, bignum(nonce, 16).toBuffer({endian: 'little', size: 8}), bignum(mixhash, 16).toBuffer({endian: 'little', size: 32})); + default: return cnUtil.construct_block_blob(blockTemplate, new Buffer(nonce, 'hex'), blob_type_num); } }; @@ -689,9 +699,9 @@ function Coin(data){ return "algo array must include at least one supported pool algo: [" + Object.keys(algos).join(", ") + "]"; } - this.slowHashBuff = function(convertedBlob, blockTemplate, job) { + this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { - case 8766: return multiHashing.kawpow(blockTemplate.height, convertedBlob, Buffer.from(job.target_hex, 'hex')); // RVN + case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL @@ -715,8 +725,8 @@ function Coin(data){ } } - this.slowHash = function(convertedBlob, blockTemplate) { - return this.slowHashBuff(convertedBlob, blockTemplate).toString("hex"); + this.slowHash = function(convertedBlob, blockTemplate, nonce, mixhash) { + return this.slowHashBuff(convertedBlob, blockTemplate, nonce, mixhash).toString("hex"); } this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { diff --git a/lib/pool.js b/lib/pool.js index a73341ce8..504b764ab 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -10,11 +10,13 @@ const tls = require('tls'); const fs = require('fs'); const child_process = require('child_process'); -const httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; -const nonceCheck32 = new RegExp("^[0-9a-f]{8}$"); -const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); -const hexMatch = new RegExp("^[0-9a-f]+$"); -const baseDiff = global.coinFuncs.baseDiff(); +const httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; +const nonceCheck32 = new RegExp("^[0-9a-f]{8}$"); +const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); +const hashCheck32 = new RegExp("^[0-9a-f]{64}$"); +const hexMatch = new RegExp("^(?:[0-9a-f][0-9a-f])+$"); +const baseDiff = global.coinFuncs.baseDiff(); +const baseRavenDiff = global.coinFuncs.baseRavenDiff(); const BLOCK_NOTIFY_PORT = 2223; const DAEMON_POLL_MS = 500; @@ -510,15 +512,10 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -function getTargetHex(difficulty, size) { - let padded = new Buffer(32); - padded.fill(0); - const diffBuff = baseDiff.div(difficulty).toBuffer(); - diffBuff.copy(padded, 32 - diffBuff.length); - const buff = padded.slice(0, size); - const buffArray = buff.toByteArray().reverse(); - const buffReversed = new Buffer(buffArray); - return buffReversed.toString('hex'); +function getTargetHex(diff, size, diff1) { + const size2 = size * 2; + const diff2 = diff1.div(diff).toBuffer({endian: 'little', size: size}).toString('hex').substr(0, size2); + return '0'.repeat(size2 - diff2.length) + diff2; }; function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { @@ -1028,7 +1025,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi newJob.id, blob, bt.seed_hash, - target, // ????? + getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num), baseRavenDiff), true, bt.rpc.height, bt.rpc.bits @@ -1038,7 +1035,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi height: bt.height, seed_hash: bt.seed_hash, job_id: newJob.id, - target: getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num)), + target: getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num), baseDiff), id: this.id }; } else { @@ -1357,9 +1354,7 @@ function getShareBuffer(miner, job, blockTemplate, params) { template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); } - return global.coinFuncs.blobTypeGrin(job.blob_type_num) ? - global.coinFuncs.constructNewBlob(template, bignum(params.nonce, 10).toBuffer({endian: 'little', size: 4}), blockTemplate.port, params.pow) : - global.coinFuncs.constructNewBlob(template, new Buffer(params.nonce, 'hex'), blockTemplate.port); + return global.coinFuncs.constructNewBlob(template, params.nonce, blockTemplate.port, params.mixhash); } catch (e) { const err_str = "Can't constructNewBlob with " + params.nonce + " nonce from " + miner.logString + ": " + e; console.error(err_str); @@ -1478,8 +1473,8 @@ function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { ); } -function hash_buff_diff(hash) { - return baseDiff.div(bignum.fromBuffer(new Buffer(hash.toByteArray().reverse()))); +function hash_buff_diff(hash, diff1) { + return diff1.div(bignum.fromBuffer(hash, {endian: 'little', size: 32})); } function report_miner_share(miner, job) { @@ -1493,7 +1488,9 @@ function report_miner_share(miner, job) { function processShare(miner, job, blockTemplate, params, processShareCB) { const port = blockTemplate.port; const blob_type_num = job.blob_type_num; - const resultHash = params.result; // can be undefined for global.coinFuncs.blobTypeGrin(blob_type_num) (and will not be used in submit_block since isTrustedShare = false) + // can be undefined for global.coinFuncs.blobTypeGrin(blob_type_num) or global.coinFuncs.blobTypeRaven(blob_type_num) + // (if undefined will not be used in submit_block since isTrustedShare = false) + const resultHash = params.result; if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); @@ -1506,7 +1503,18 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - return verifyShareCB(hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num)), shareBuffer, false, null); + return verifyShareCB(hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num), baseDiff), shareBuffer, false, null); + } + + if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + const convertedBlob = global.coinFuncs.convertRavenBlob(shareBuffer); + if (params.header_hash !== convertedBlob) { + report_miner_share(miner, job); + return processShareCB(invalid_share(miner)); + } + const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate, params.nonce, params.mixhash); + return verifyShareCB(hash_buff_diff(hash, baseRavenDiff), shareBuffer, false, null); } let resultBuffer; @@ -1515,12 +1523,12 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } catch(e) { return processShareCB(invalid_share(miner)); } - const hashDiff = hash_buff_diff(resultBuffer); + const hashDiff = hash_buff_diff(resultBuffer, baseDiff); - if (global.config.pool.trustedMiners && - is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && - miner.trust.check_height !== job.height - ) { + if ( global.config.pool.trustedMiners && + is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && + miner.trust.check_height !== job.height + ) { let shareBuffer = null; if (miner.payout in extra_wallet_verify) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1540,6 +1548,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } return verifyShareCB(hashDiff, shareBuffer, true, null); + } else { // verify share if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { @@ -1650,6 +1659,20 @@ function get_miner_notification(payout) { function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, pushMessage) { switch (method) { + case 'mining.authorize': // eth (raven) only + if (!params || typeof params !== 'array') { + sendReplyFinal("No params specified"); + return; + } + params = { + login: params[0], + pass: params[1], + agent: "[ethminer]", + algo: [ "kawpow/rvn" ], + "algo-perf": { "kawpow/rvn": 1 }, + }; + // continue to normal login + case 'login': { // grin and default if (ip in bannedIPs) { sendReplyFinal("New connections from this IP address are temporarily suspended from mining (10 minutes max)"); @@ -1717,6 +1740,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (id === "Stratum") { sendReply(null, "ok"); miner.protocol = "grin"; + } else if (method === 'mining.authorize') { + sendReply(null, true); } else { sendReply(null, { id: minerId, job: miner.getBestCoinJob(), status: 'OK' }); miner.protocol = "default"; @@ -1724,6 +1749,11 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se break; } + case 'mining.subscribe': { // eth (raven) only + sendReply(null, [ null, "" ]); // empty extranonce (extra once is specificed in coinbase tx) + break; + } + case 'getjobtemplate': { // grin only const minerId = socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""; let miner = activeMiners.get(minerId); @@ -1758,6 +1788,30 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se break; } + case 'mining.submit': + if (!params || typeof params !== 'array') { + sendReply("No params specified"); + return; + } + + if ( params.length != 5 || + typeof params[1] !== 'string' || + typeof params[2] !== 'string' || + typeof params[3] !== 'string' || + typeof params[4] !== 'string' + ) { + sendReply("No correct params specified"); + return; + } + + params = { + job_id: message.params[1], + nonce: message.params[2].substr(2), + header_hash: message.params[3].substr(2), + mixhash: message.params[4].substr(2), + }; + // continue to normal login + case 'submit': { // grin and default if (!params) { sendReplyFinal("No params specified"); @@ -1783,11 +1837,26 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } const blob_type_num = job.blob_type_num; - const is_bad_nonce = global.coinFuncs.blobTypeGrin(blob_type_num) ? - (typeof params.nonce !== 'number') || !(params.pow instanceof Array) || (params.pow.length != global.coinFuncs.c29ProofSize(blob_type_num)) : - (typeof params.nonce !== 'string') || !(global.coinFuncs.nonceSize(blob_type_num) == 8 ? nonceCheck64.test(params.nonce) : nonceCheck32.test(params.nonce) ); - - if (is_bad_nonce) { + const nonce_sanity_check = function(blob_type_num, params) { + if (global.coinFuncs.blobTypeGrin(blob_type_num)) { + if (typeof params.nonce !== 'number') return false; + if (!(params.pow instanceof Array)) return false; + if (params.pow.length != global.coinFuncs.c29ProofSize(blob_type_num)) return false; + } else { + if (typeof params.nonce !== 'string') return false; + if (global.coinFuncs.nonceSize(blob_type_num) == 8) { + if (!nonceCheck64.test(params.nonce)) return false; + if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + if (!hashCheck32.test(params.mixhash)) return false; + } + } else { + if (!nonceCheck32.test(params.nonce)) return false; + } + if (!hashCheck32.test(params.result)) return false; + } + return true; + }; + if (!nonce_sanity_check(blob_type_num, params)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); diff --git a/package.json b/package.json index adea3dcb3..88f41545f 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.0" } } From 9f6c5b5ebbdbbab0abdb325beb984718b0725b34 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Nov 2020 22:08:06 +0000 Subject: [PATCH 1028/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 504b764ab..91416a763 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1661,7 +1661,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se switch (method) { case 'mining.authorize': // eth (raven) only if (!params || typeof params !== 'array') { - sendReplyFinal("No params specified"); + sendReplyFinal("No params specified: " + typeof params); return; } params = { From e6db938c7138b8e4a7b8e2af2fbf8a6e2a6d8296 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Nov 2020 22:09:55 +0000 Subject: [PATCH 1029/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 91416a763..0031cf7a7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1661,7 +1661,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se switch (method) { case 'mining.authorize': // eth (raven) only if (!params || typeof params !== 'array') { - sendReplyFinal("No params specified: " + typeof params); + sendReplyFinal("No params specified1"); return; } params = { @@ -1679,7 +1679,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } if (!params) { - sendReplyFinal("No params specified"); + sendReplyFinal("No params specified2"); return; } if (!params.login) { From f7615f2bee0f06f50501f161f694bcb11b0f4e83 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Nov 2020 22:11:30 +0000 Subject: [PATCH 1030/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0031cf7a7..351754ae4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1661,7 +1661,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se switch (method) { case 'mining.authorize': // eth (raven) only if (!params || typeof params !== 'array') { - sendReplyFinal("No params specified1"); + sendReplyFinal("No params specified:" + (typeof params)); return; } params = { @@ -1679,7 +1679,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } if (!params) { - sendReplyFinal("No params specified2"); + sendReplyFinal("No params specified"); return; } if (!params.login) { From ecdb1be1cd8552aa1037fa6be3662f63b4718b53 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Nov 2020 22:13:07 +0000 Subject: [PATCH 1031/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 351754ae4..7e5d30f0f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1661,7 +1661,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se switch (method) { case 'mining.authorize': // eth (raven) only if (!params || typeof params !== 'array') { - sendReplyFinal("No params specified:" + (typeof params)); + sendReplyFinal("No params specified: " + JSON.stringify(params)); return; } params = { From e8989b3ed5cc24357074efd6c3cebe4ac25b1514 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Nov 2020 22:15:28 +0000 Subject: [PATCH 1032/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7e5d30f0f..065904e91 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1660,8 +1660,8 @@ function get_miner_notification(payout) { function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, pushMessage) { switch (method) { case 'mining.authorize': // eth (raven) only - if (!params || typeof params !== 'array') { - sendReplyFinal("No params specified: " + JSON.stringify(params)); + if (!params || !(params instanceof Array)) { + sendReplyFinal("No array params specified"); return; } params = { @@ -1789,8 +1789,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } case 'mining.submit': - if (!params || typeof params !== 'array') { - sendReply("No params specified"); + if (!params || !(params instanceof Array)) { + sendReply("No array params specified"); return; } From c13bc005d0501b008de602bc50c28076040aff63 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Nov 2020 22:36:10 +0000 Subject: [PATCH 1033/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 1 + lib/pool.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 34a380270..b86d090b6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -530,6 +530,7 @@ function Coin(data){ this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : (template.blob ? template.blob : extra_nonce_mm_template_hex); this.difficulty = template.difficulty; this.height = template.height; + this.bits = template.bits; this.seed_hash = template.seed_hash; this.coin = template.coin; this.port = template.port; diff --git a/lib/pool.js b/lib/pool.js index 065904e91..7dda01577 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1027,8 +1027,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi bt.seed_hash, getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num), baseRavenDiff), true, - bt.rpc.height, - bt.rpc.bits + bt.height, + bt.bits ]; else this.cachedJob = { blob: blob, algo: params.algo_name, From adc76b0756375e3c6f5b7987a502f92bf291035e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 02:41:14 +0000 Subject: [PATCH 1034/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7dda01577..9e5d80ac1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1076,8 +1076,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.sendCoinJob = function(coin, params) { const job = this.getCoinJob(coin, params); if (job === null) return; - return this.protocol === "grin" ? this.pushMessage({method: "getjobtemplate", result: job}) - : this.pushMessage({method: 'job', params: job}); + let method; + case (this.protocol) { + case "grin": method = "getjobtemplate"; break; + case "raven": method = "mining.notify"; break; + default: method = "job"; + } + return this.pushMessage({method: method, result: job}); }; this.sendSameCoinJob = function () { @@ -1742,6 +1747,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.protocol = "grin"; } else if (method === 'mining.authorize') { sendReply(null, true); + miner.protocol = "raven"; + miner.sendBestCoinJob(); } else { sendReply(null, { id: minerId, job: miner.getBestCoinJob(), status: 'OK' }); miner.protocol = "default"; From f3f6b02fcedeffdab3c50c820bc0b8a90c226109 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 02:41:44 +0000 Subject: [PATCH 1035/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9e5d80ac1..31e8dbc1e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1077,7 +1077,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const job = this.getCoinJob(coin, params); if (job === null) return; let method; - case (this.protocol) { + switch (this.protocol) { case "grin": method = "getjobtemplate"; break; case "raven": method = "mining.notify"; break; default: method = "job"; From e959e582d8173b100f8eba75cf059de151191b20 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 02:44:51 +0000 Subject: [PATCH 1036/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 31e8dbc1e..6a97b635d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1076,13 +1076,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.sendCoinJob = function(coin, params) { const job = this.getCoinJob(coin, params); if (job === null) return; - let method; switch (this.protocol) { - case "grin": method = "getjobtemplate"; break; - case "raven": method = "mining.notify"; break; - default: method = "job"; + case "grin": return this.pushMessage({method: "getjobtemplate", result: job}); + case "raven": return this.pushMessage({method: "mining.notify", params: job}); + default: return this.pushMessage({method: "job", params: job}); } - return this.pushMessage({method: method, result: job}); }; this.sendSameCoinJob = function () { From d968cc44cba1fe134abbb280607ec0185648b7b1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 04:57:01 +0000 Subject: [PATCH 1037/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6a97b635d..1ff4dde29 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1810,10 +1810,10 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } params = { - job_id: message.params[1], - nonce: message.params[2].substr(2), - header_hash: message.params[3].substr(2), - mixhash: message.params[4].substr(2), + job_id: params[1], + nonce: params[2].substr(2), + header_hash: params[3].substr(2), + mixhash: params[4].substr(2), }; // continue to normal login From c42458e6a0cce98a30e1f79ab49e6ba124e4c86d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:02:33 +0000 Subject: [PATCH 1038/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1ff4dde29..b303751dd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 1 }, + "algo-perf": { "kawpow/rvn": 10000000 }, }; // continue to normal login From a55bbd0539823db839df230a06bfeef52ece2ba5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:03:52 +0000 Subject: [PATCH 1039/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b303751dd..77358043e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 10000000 }, + "algo-perf": { "kawpow/rvn": 10000000000 }, }; // continue to normal login From 10f6b9d7db4071f79246f63aa8bdbc2b27f52adc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:04:45 +0000 Subject: [PATCH 1040/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 77358043e..bfff7fe86 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 10000000000 }, + "algo-perf": { "kawpow/rvn": 1000000 }, }; // continue to normal login From a7f5086bfd5e29e4dc7fe79deaf5d7ba921415ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:06:01 +0000 Subject: [PATCH 1041/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bfff7fe86..08428f17a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 1000000 }, + "algo-perf": { "kawpow/rvn": 1000 }, }; // continue to normal login From 3f0533b422b73e66f8e18b246797514fb154a3a8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:07:13 +0000 Subject: [PATCH 1042/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 08428f17a..bfff7fe86 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 1000 }, + "algo-perf": { "kawpow/rvn": 1000000 }, }; // continue to normal login From f2a857490feaffa40cf19f5f8dfec3800fd04e39 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:08:17 +0000 Subject: [PATCH 1043/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bfff7fe86..53b8b0a7e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 1000000 }, + "algo-perf": { "kawpow/rvn": 100000000 }, }; // continue to normal login From b86c3a4964a7747e14a50a129ee1c2a912ce9d08 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:10:49 +0000 Subject: [PATCH 1044/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 53b8b0a7e..b303751dd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 100000000 }, + "algo-perf": { "kawpow/rvn": 10000000 }, }; // continue to normal login From ff09da3a7d5faad83303a43f88937f2f35ada523 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:11:52 +0000 Subject: [PATCH 1045/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b303751dd..bfff7fe86 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1672,7 +1672,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se pass: params[1], agent: "[ethminer]", algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 10000000 }, + "algo-perf": { "kawpow/rvn": 1000000 }, }; // continue to normal login From 5467f4aa7c050f46133545759974fc19c9a8714e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 05:52:18 +0000 Subject: [PATCH 1046/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bfff7fe86..ba4f4a3d1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1853,11 +1853,14 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (!nonceCheck64.test(params.nonce)) return false; if (global.coinFuncs.blobTypeRaven(blob_type_num)) { if (!hashCheck32.test(params.mixhash)) return false; + if (!hashCheck32.test(params.header_hash)) return false; + } else { + if (!hashCheck32.test(params.result)) return false; } } else { if (!nonceCheck32.test(params.nonce)) return false; + if (!hashCheck32.test(params.result)) return false; } - if (!hashCheck32.test(params.result)) return false; } return true; }; From 5d32a3f02e5a5ff57a6546373e1aa83e09f80681 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 06:39:18 +0000 Subject: [PATCH 1047/1496] Diff debug --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index ba4f4a3d1..d6c5654ba 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -798,6 +798,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }; this.setNewDiff = function (difficulty) { + console.log("!!! DEBUG DIFF: " + difficulty); if (this.fixed_diff) return false; let newDiff = Math.round(difficulty); @@ -868,6 +869,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.curr_min_diff = global.coinFuncs.blobTypeGrin(global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin))) ? 1 : global.config.pool.minDifficulty; const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / lastCoinHashFactorMM[best_coin]; + console.log("!!! DEBUG FACTOR: " + factor); if (factor != 1) { if (this.hashes === 0) { this.setNewDiff(this.difficulty * factor); @@ -993,6 +995,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } if (this.difficulty > bt.difficulty) this.difficulty = bt.difficulty; + console.log("!!! DEBUG DIFF2: " + bt.difficulty); const blob_type_num = global.coinFuncs.portBlobType(bt.port); From a4bb6760c467ccf40e8a1fde2284497dd94f4497 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 07:07:11 +0000 Subject: [PATCH 1048/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d6c5654ba..4c7d83425 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -512,9 +512,15 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -function getTargetHex(diff, size, diff1) { +function getTargetHex(diff, size) { const size2 = size * 2; - const diff2 = diff1.div(diff).toBuffer({endian: 'little', size: size}).toString('hex').substr(0, size2); + const diff2 = baseDiff.div(diff).toBuffer({endian: 'little', size: size}).toString('hex').substr(0, size2); + return '0'.repeat(size2 - diff2.length) + diff2; +}; + +function getRavenTargetHex(diff) { + const size2 = 64; + const diff2 = baseRavenDiff.div(diff).toBuffer().toString('hex').substr(0, size2); return '0'.repeat(size2 - diff2.length) + diff2; }; @@ -1028,7 +1034,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi newJob.id, blob, bt.seed_hash, - getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num), baseRavenDiff), + getRavenTargetHex(this.difficulty), true, bt.height, bt.bits @@ -1038,7 +1044,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi height: bt.height, seed_hash: bt.seed_hash, job_id: newJob.id, - target: getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num), baseDiff), + target: getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num)), id: this.id }; } else { From bcbda4f85fc2bf42ea2aaa7da56af3579615850e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 15:21:00 +0000 Subject: [PATCH 1049/1496] Added pool db overlflow handler --- lib/worker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 83ef74061..4e36bb374 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -289,7 +289,12 @@ function updateShareStats() { } cache_updates.portMinerCount = portMinerCount; cache_updates.minerSet = minerSet; - global.database.bulkSetCache(cache_updates); + try { + global.database.bulkSetCache(cache_updates); + } catch (e) { + console.error("Can't wite to pool DB: " + e); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool DB is overflowed!", "Can't wite to pool DB: " + e); + } cache_updates = null; let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; From 2a402a05fbbf2ee7dd25b18c1f3ca245ea83b2aa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 16:24:35 +0000 Subject: [PATCH 1050/1496] Update LMDB used --- deployment/install_lmdb_tools.sh | 3 ++- lib/local_comms.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/deployment/install_lmdb_tools.sh b/deployment/install_lmdb_tools.sh index 219e206ff..f072ffed8 100644 --- a/deployment/install_lmdb_tools.sh +++ b/deployment/install_lmdb_tools.sh @@ -1,8 +1,9 @@ #!/bin/bash cd ~ +rm -rf node-lmdb git clone https://github.com/Venemo/node-lmdb.git cd node-lmdb -git checkout v0.7.0 +git checkout 5941c1e553de4ae1d57a67d355b7c2dd87feaea6 cd dependencies/lmdb/libraries/liblmdb make -j `nproc` mkdir ~/.bin diff --git a/lib/local_comms.js b/lib/local_comms.js index ac905e49d..1fd2759f4 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -31,7 +31,7 @@ function Database(){ global.database.env.open({ path: global.config.db_storage_path, maxDbs: 10, - mapSize: 8 * 1024 * 1024 * 1024, + mapSize: 16 * 1024 * 1024 * 1024, useWritemap: true, maxReaders: 512 }); From e909a4ac224ec0c1f6ac03f489581f596b1a7e05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 16:31:27 +0000 Subject: [PATCH 1051/1496] Update LMDB used --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88f41545f..f5e20cb06 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "minimist": ">=1.2.3", "moment": "2.21.0", "mysql": "2.15.0", - "node-lmdb": "0.7.0", + "node-lmdb": "5941c1e553de4ae1d57a67d355b7c2dd87feaea6", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", "range": "0.0.3", From 0a2654be2f6e4c20e1f3607737f6470c3526f710 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 16:32:15 +0000 Subject: [PATCH 1052/1496] Update LMDB used --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5e20cb06..f10c345d9 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "minimist": ">=1.2.3", "moment": "2.21.0", "mysql": "2.15.0", - "node-lmdb": "5941c1e553de4ae1d57a67d355b7c2dd87feaea6", + "node-lmdb": "#5941c1e553de4ae1d57a67d355b7c2dd87feaea6", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", "range": "0.0.3", From e3007d7e7eb1d8652c09ac6f09ff0a15384c7049 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 16:33:36 +0000 Subject: [PATCH 1053/1496] Update LMDB used --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f10c345d9..82d1786be 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "minimist": ">=1.2.3", "moment": "2.21.0", "mysql": "2.15.0", - "node-lmdb": "#5941c1e553de4ae1d57a67d355b7c2dd87feaea6", + "node-lmdb": "git+https://github.com/Venemo/node-lmdb.git#5941c1e553de4ae1d57a67d355b7c2dd87feaea6", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", "range": "0.0.3", From a513a50a30ffa69e98e4dbfa42cb9ffb2ccbd6cc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:00:09 +0000 Subject: [PATCH 1054/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4c7d83425..1015a3272 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 100; // !!! + if (coin === "RVN") coinHashFactor = 10000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -807,7 +807,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi console.log("!!! DEBUG DIFF: " + difficulty); if (this.fixed_diff) return false; - let newDiff = Math.round(difficulty); + let newDiff = difficulty; //Math.round(difficulty); if (newDiff > global.config.pool.maxDifficulty) newDiff = global.config.pool.maxDifficulty; if (newDiff < this.curr_min_diff) newDiff = this.curr_min_diff; @@ -872,7 +872,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }); if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { - this.curr_min_diff = global.coinFuncs.blobTypeGrin(global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin))) ? 1 : global.config.pool.minDifficulty; + const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)); + if (global.coinFuncs.blobTypeGrin(blob_type_num)) { + this.curr_min_diff = 1; + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + this.curr_min_diff = 0.01; + } else { + this.curr_min_diff = global.config.pool.minDifficulty; + } const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / lastCoinHashFactorMM[best_coin]; console.log("!!! DEBUG FACTOR: " + factor); @@ -952,7 +959,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi target = 2 * global.config.pool.retargetTime; if (period < target) period = target; } - const diff = Math.floor(hashes * target / period); + const diff = hashes * target / period; //Math.floor(hashes * target / period); return diff < min_diff ? min_diff : diff; }; @@ -1921,8 +1928,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const max_late_time = global.config.pool.targetTime*1000; if (late_time < max_late_time) { let factor = (max_late_time - late_time) / max_late_time; - job.rewarded_difficulty = Math.floor(job.difficulty * Math.pow(factor, 6)); - if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; + job.rewarded_difficulty = job.difficulty * Math.pow(factor, 6); //Math.floor(job.difficulty * Math.pow(factor, 6)); + //if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; } else { is_outdated = true; } @@ -1945,6 +1952,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } job.rewarded_difficulty2 = job.rewarded_difficulty * job.coinHashFactor; + job.rewarded_difficulty = Math.floor(job.rewarded_difficulty); + if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; processShare(miner, job, blockTemplate, params, function(shareAccepted) { if (shareAccepted === null) { From c630ddee433885d6a29309392befc1acfecde69b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:21:57 +0000 Subject: [PATCH 1055/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 5 ++++- lib/pool.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b86d090b6..0196e70d0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -476,7 +476,6 @@ function Coin(data){ this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; - if (this.blobTypeRaven(blob_type_num)) return cnUtil.convertRavenBlob(blobBuffer); let blob; try { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); @@ -489,6 +488,10 @@ function Coin(data){ return blob; }; + this.convertRavenBlob = function(blobBuffer) { + return cnUtil.convertRavenBlob(blobBuffer) + }; + this.constructNewBlob = function(blockTemplate, nonce, port, maxhash) { const blob_type_num = this.portBlobType(port, blockTemplate[0]); switch (blob_type_num) { diff --git a/lib/pool.js b/lib/pool.js index 1015a3272..58045e381 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 10000; // !!! + if (coin === "RVN") coinHashFactor = 100000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -876,7 +876,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_min_diff = 1; } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - this.curr_min_diff = 0.01; + this.curr_min_diff = 0.001; } else { this.curr_min_diff = global.config.pool.minDifficulty; } From f1c6db5f7b870fd6f58b3d78dfcbb2b4aebfd668 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:25:31 +0000 Subject: [PATCH 1056/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 5 +---- lib/pool.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 0196e70d0..b86d090b6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -476,6 +476,7 @@ function Coin(data){ this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; + if (this.blobTypeRaven(blob_type_num)) return cnUtil.convertRavenBlob(blobBuffer); let blob; try { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); @@ -488,10 +489,6 @@ function Coin(data){ return blob; }; - this.convertRavenBlob = function(blobBuffer) { - return cnUtil.convertRavenBlob(blobBuffer) - }; - this.constructNewBlob = function(blockTemplate, nonce, port, maxhash) { const blob_type_num = this.portBlobType(port, blockTemplate[0]); switch (blob_type_num) { diff --git a/lib/pool.js b/lib/pool.js index 58045e381..69ba43086 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1527,7 +1527,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (global.coinFuncs.blobTypeRaven(blob_type_num)) { const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - const convertedBlob = global.coinFuncs.convertRavenBlob(shareBuffer); + const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); if (params.header_hash !== convertedBlob) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); From 8cde597f5456e433d84cd8e575f0f1bcf0f493b6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:27:01 +0000 Subject: [PATCH 1057/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 69ba43086..2abd4e3c3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 100000; // !!! + if (coin === "RVN") coinHashFactor = 1000000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -876,7 +876,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_min_diff = 1; } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - this.curr_min_diff = 0.001; + this.curr_min_diff = 0.0001; } else { this.curr_min_diff = global.config.pool.minDifficulty; } From 2b5f1489fb8dae9829fbc5ff550dc7f0f1d1200d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:29:04 +0000 Subject: [PATCH 1058/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2abd4e3c3..69ba43086 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 1000000; // !!! + if (coin === "RVN") coinHashFactor = 100000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -876,7 +876,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_min_diff = 1; } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - this.curr_min_diff = 0.0001; + this.curr_min_diff = 0.001; } else { this.curr_min_diff = global.config.pool.minDifficulty; } From 705e447d4d801fc4707e61821a236360de23ba6f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:31:33 +0000 Subject: [PATCH 1059/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 69ba43086..0e7d69b81 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -876,7 +876,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_min_diff = 1; } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - this.curr_min_diff = 0.001; + this.curr_min_diff = 0.1; } else { this.curr_min_diff = global.config.pool.minDifficulty; } From 323bdc57193744626c707bcf252ea9f4f86650b0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:32:59 +0000 Subject: [PATCH 1060/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 0e7d69b81..949d3617a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 100000; // !!! + if (coin === "RVN") coinHashFactor = 1000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); From 147e26e90e160c649cd8b175c43142b09dc6b1d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:33:51 +0000 Subject: [PATCH 1061/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 949d3617a..dc5a0affa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 1000; // !!! + if (coin === "RVN") coinHashFactor = 100; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); From 657cb53ad8f5e764b500355994867dfa38d0c9d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:35:14 +0000 Subject: [PATCH 1062/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index dc5a0affa..83d640b43 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 100; // !!! + if (coin === "RVN") coinHashFactor = 1000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -873,10 +873,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)); - if (global.coinFuncs.blobTypeGrin(blob_type_num)) { + if (global.coinFuncs.blobTypeGrin(blob_type_num) || global.coinFuncs.blobTypeRaven(blob_type_num)) { this.curr_min_diff = 1; - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - this.curr_min_diff = 0.1; } else { this.curr_min_diff = global.config.pool.minDifficulty; } From d55006b6012e91ebd2539691bc1d1e71aa00e044 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:37:07 +0000 Subject: [PATCH 1063/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 83d640b43..80a82aa8d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -807,7 +807,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi console.log("!!! DEBUG DIFF: " + difficulty); if (this.fixed_diff) return false; - let newDiff = difficulty; //Math.round(difficulty); + let newDiff = Math.round(difficulty); if (newDiff > global.config.pool.maxDifficulty) newDiff = global.config.pool.maxDifficulty; if (newDiff < this.curr_min_diff) newDiff = this.curr_min_diff; @@ -957,7 +957,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi target = 2 * global.config.pool.retargetTime; if (period < target) period = target; } - const diff = hashes * target / period; //Math.floor(hashes * target / period); + const diff = Math.floor(hashes * target / period); return diff < min_diff ? min_diff : diff; }; From 371e3f743178fc3fb8f660d021ce8edff7116e6d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:39:55 +0000 Subject: [PATCH 1064/1496] Revert "Draft implementation of Ravencoin utils" This reverts commit d55006b6012e91ebd2539691bc1d1e71aa00e044. --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 80a82aa8d..83d640b43 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -807,7 +807,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi console.log("!!! DEBUG DIFF: " + difficulty); if (this.fixed_diff) return false; - let newDiff = Math.round(difficulty); + let newDiff = difficulty; //Math.round(difficulty); if (newDiff > global.config.pool.maxDifficulty) newDiff = global.config.pool.maxDifficulty; if (newDiff < this.curr_min_diff) newDiff = this.curr_min_diff; @@ -957,7 +957,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi target = 2 * global.config.pool.retargetTime; if (period < target) period = target; } - const diff = Math.floor(hashes * target / period); + const diff = hashes * target / period; //Math.floor(hashes * target / period); return diff < min_diff ? min_diff : diff; }; From 149709a7decaf1db1b9e86557c0c0c5398734aac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:43:15 +0000 Subject: [PATCH 1065/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 83d640b43..42bbb695a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 1000; // !!! + if (coin === "RVN") coinHashFactor = 10000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -519,8 +519,9 @@ function getTargetHex(diff, size) { }; function getRavenTargetHex(diff) { + const diff1 = 0x00000000ff000000000000000000000000000000000000000000000000000000; const size2 = 64; - const diff2 = baseRavenDiff.div(diff).toBuffer().toString('hex').substr(0, size2); + const diff2 = (diff1 / diff).toString(16).substr(0, size2); return '0'.repeat(size2 - diff2.length) + diff2; }; @@ -873,8 +874,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (best_coin_perf < 0) return false; if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)); - if (global.coinFuncs.blobTypeGrin(blob_type_num) || global.coinFuncs.blobTypeRaven(blob_type_num)) { + if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_min_diff = 1; + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + this.curr_min_diff = 0.1; } else { this.curr_min_diff = global.config.pool.minDifficulty; } From 59c0ac9c88ef6aece4896d23b6cc545ea7c8b7b4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:44:28 +0000 Subject: [PATCH 1066/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 42bbb695a..6b300f503 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 10000; // !!! + if (coin === "RVN") coinHashFactor = 100000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -877,7 +877,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_min_diff = 1; } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - this.curr_min_diff = 0.1; + this.curr_min_diff = 0.01; } else { this.curr_min_diff = global.config.pool.minDifficulty; } From 608e9580df5bf32418074541ef6ce54898e239d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 19:50:21 +0000 Subject: [PATCH 1067/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b86d090b6..d830055f5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -489,7 +489,7 @@ function Coin(data){ return blob; }; - this.constructNewBlob = function(blockTemplate, nonce, port, maxhash) { + this.constructNewBlob = function(blockTemplate, nonce, port, mixhash) { const blob_type_num = this.portBlobType(port, blockTemplate[0]); switch (blob_type_num) { case 100: return cnUtil.constructNewGrinBlob(blockTemplate, bignum(nonce, 10).toBuffer({endian: 'little', size: 4})); From 59045e059ca1df39a0c23fe38900f2ea5f76db1b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 21:48:38 +0000 Subject: [PATCH 1068/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 2 +- lib/pool.js | 61 ++++++++++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d830055f5..882bdd735 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -422,7 +422,7 @@ function Coin(data){ return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); }; this.baseRavenDiff = function() { - return bignum('00000000FF000000000000000000000000000000000000000000000000000000', 16); + return parseInt('0x00000000ff000000000000000000000000000000000000000000000000000000'); }; this.validatePlainAddress = function(address){ diff --git a/lib/pool.js b/lib/pool.js index 6b300f503..d9f67d974 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -519,9 +519,8 @@ function getTargetHex(diff, size) { }; function getRavenTargetHex(diff) { - const diff1 = 0x00000000ff000000000000000000000000000000000000000000000000000000; const size2 = 64; - const diff2 = (diff1 / diff).toString(16).substr(0, size2); + const diff2 = (baseRavenDiff / diff).toString(16).substr(0, size2); return '0'.repeat(size2 - diff2.length) + diff2; }; @@ -1219,7 +1218,7 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { } } -function recordShareData(miner, job, shareDiff, isBlockCandidate, hashHex, isTrustedShare, blockTemplate) { +function recordShareData(miner, job, isBlockCandidate, hashHex, isTrustedShare, blockTemplate) { miner.hashes += job.difficulty; let proxyMinerName = miner.payout + ":" + miner.identifier; if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.difficulty; @@ -1354,10 +1353,10 @@ function recordShareData(miner, job, shareDiff, isBlockCandidate, hashHex, isTru } if (isTrustedShare) { process.send({type: 'trustedShare'}); - debug(threadName + "Accepted trusted share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); + debug(threadName + "Accepted trusted share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + " from: " + miner.logString); } else { process.send({type: 'normalShare'}); - debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); + debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + " from: " + miner.logString); } if (activeBlockTemplates[job.coin].idHash !== blockTemplate.idHash) { process.send({type: 'outdatedShare'}); @@ -1391,11 +1390,11 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, isRetrySubmitBlock) { +function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock) { let reply_fn = function (rpcResult, rpcStatus) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. - recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); + recordShareData(miner, job, false, null, isTrustedShare, blockTemplate); let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); @@ -1438,7 +1437,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", block hex: \n" + shareBuffer.toString('hex') ); - recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); + recordShareData(miner, job, true, blockFastHash, isTrustedShare, blockTemplate); } else if (rpcResult && typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898) { // TRTL // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); @@ -1446,7 +1445,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') ); - recordShareData(miner, job, hashDiff.toString(), true, blockFastHash, isTrustedShare, blockTemplate); + recordShareData(miner, job, true, blockFastHash, isTrustedShare, blockTemplate); } else { // something not expected happened if (isRetrySubmitBlock) { console.error(threadName + "Unknown error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + @@ -1454,7 +1453,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDi miner.logString + ", isTrustedShare: " + isTrustedShare + ", rpcStatus: " + rpcStatus + ", error (" + (typeof rpcResult) + "): " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') ); - setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, isParentBlock, false); + setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, false); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1493,8 +1492,19 @@ function is_safe_to_trust(reward_diff, miner_wallet, miner_trust) { ); } -function hash_buff_diff(hash, diff1) { - return diff1.div(bignum.fromBuffer(hash, {endian: 'little', size: 32})); +function hashBuffDiff(hash) { // bignum as result + return baseDiff.div(bignum.fromBuffer(hash, {endian: 'little', size: 32})); +} + +function hashRavenBuffDiff(hash) { // float as result + return baseRavenDiff / bignum.fromBuffer(hash, {endian: 'little', size: 32}).toNumber(); +} + +// will work for numbers and bignum +function ge(l, r) { + if (typeof l === 'object') return l.ge(r); + if (typeof r === 'object') return !r.lt(l); + return l >= r; } function report_miner_share(miner, job) { @@ -1523,18 +1533,19 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - return verifyShareCB(hash_buff_diff(global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num), baseDiff), shareBuffer, false, null); + return verifyShareCB(hashBuffDiff(global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num)), shareBuffer, false, null); } if (global.coinFuncs.blobTypeRaven(blob_type_num)) { const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); - if (params.header_hash !== convertedBlob) { + if (params.header_hash !== convertedBlob.toString("hex")) { + console.error("Wrong header hash:" + params.header_hash + " " + convertedBlob.toString("hex")); report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate, params.nonce, params.mixhash); - return verifyShareCB(hash_buff_diff(hash, baseRavenDiff), shareBuffer, false, null); + return verifyShareCB(hashRavenBuffDiff(hash), shareBuffer, false, null); } let resultBuffer; @@ -1543,7 +1554,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } catch(e) { return processShareCB(invalid_share(miner)); } - const hashDiff = hash_buff_diff(resultBuffer, baseDiff); + const hashDiff = hashBuffDiff(resultBuffer); if ( global.config.pool.trustedMiners && is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && @@ -1586,7 +1597,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (shareBuffer === null) return processShareCB(invalid_share(miner)); const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); - const isBlockDiffMatched = hashDiff.ge(blockTemplate.difficulty); + const isBlockDiffMatched = ge(hashDiff, blockTemplate.difficulty); if (isBlockDiffMatched) { const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); if (hash !== resultHash) { @@ -1613,18 +1624,18 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { }; verifyShare(function(hashDiff, shareBuffer, isTrustedShare, isBlockDiffMatched) { - isBlockDiffMatched = isBlockDiffMatched === null ? hashDiff.ge(blockTemplate.difficulty) : isBlockDiffMatched; + isBlockDiffMatched = isBlockDiffMatched === null ? ge(hashDiff, blockTemplate.difficulty) : isBlockDiffMatched; if (isBlockDiffMatched) { // Submit block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return processShareCB(invalid_share(miner)); } - submit_block(miner, job, blockTemplate, shareBuffer, resultHash, hashDiff, isTrustedShare, true, true); + submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, true, true); } const is_mm = "child_template" in blockTemplate; - if (is_mm && hashDiff.ge(blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. + if (is_mm && ge(hashDiff, blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return processShareCB(invalid_share(miner)); @@ -1641,26 +1652,26 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { return processShareCB(invalid_share(miner)); } if (shareBuffer2 === null) return processShareCB(invalid_share(miner)); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, hashDiff, isTrustedShare, false, true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, isTrustedShare, false, true); isBlockDiffMatched = true; } if (isBlockDiffMatched) return processShareCB(true); - if (hashDiff.lt(job.difficulty)) { + if (!ge(hashDiff, job.difficulty)) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { - console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString); + console.warn(threadName + "Rejected low diff (" + hashDiff + " < " + job.difficulty + ") share from miner " + miner.logString); lastMinerLogTime[miner.payout] = time_now; } return processShareCB(invalid_share(miner)); } else { - recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate); + recordShareData(miner, job, false, null, isTrustedShare, blockTemplate); // record child proc share for rewarded_difficulty effort calcs status but with 0 rewards (all included in parent share) if (is_mm) { job.rewarded_difficulty2 = 0; - recordShareData(miner, job, hashDiff.toString(), false, null, isTrustedShare, blockTemplate.child_template); + recordShareData(miner, job, false, null, isTrustedShare, blockTemplate.child_template); } return processShareCB(true); } From 2ccfb46266ec42afce8fa96273d75bc591cf0448 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 21:59:50 +0000 Subject: [PATCH 1069/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 882bdd735..92a5164bf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -702,7 +702,7 @@ function Coin(data){ this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { - case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN + case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce.reverse(), 'hex'), Buffer.from(mixhash, 'hex')); // RVN case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL From c5caa141a323bf15068e02d7e116c02321f2bd60 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 22:03:14 +0000 Subject: [PATCH 1070/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 92a5164bf..16a1945d5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -184,6 +184,12 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }); }, 32); +function reverseBuffer(buff) { + let reversed = new Buffer(buff.length); + for (var i = buff.length - 1; i >= 0; i--) reversed[buff.length - i - 1] = buff[i]; + return reversed; +} + setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { queue_obj.remove(function(task) { @@ -702,7 +708,7 @@ function Coin(data){ this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { - case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce.reverse(), 'hex'), Buffer.from(mixhash, 'hex')); // RVN + case 8766: return multiHashing.kawpow(convertedBlob, reverseBuffer(Buffer.from(nonce, 'hex')), Buffer.from(mixhash, 'hex')); // RVN case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL From 5b0eca6fdf1db24af0b5d09436b868df4fa813e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 23:01:15 +0000 Subject: [PATCH 1071/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 8 +------- package.json | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 16a1945d5..882bdd735 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -184,12 +184,6 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }); }, 32); -function reverseBuffer(buff) { - let reversed = new Buffer(buff.length); - for (var i = buff.length - 1; i >= 0; i--) reversed[buff.length - i - 1] = buff[i]; - return reversed; -} - setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { queue_obj.remove(function(task) { @@ -708,7 +702,7 @@ function Coin(data){ this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { - case 8766: return multiHashing.kawpow(convertedBlob, reverseBuffer(Buffer.from(nonce, 'hex')), Buffer.from(mixhash, 'hex')); // RVN + case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL diff --git a/package.json b/package.json index 82d1786be..9150cf45b 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From c6a59ea1838a92131eecccd9108b22eaf66b8a0c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Nov 2020 23:22:32 +0000 Subject: [PATCH 1072/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d9f67d974..e88175cb0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1506,8 +1506,7 @@ function ge(l, r) { if (typeof r === 'object') return !r.lt(l); return l >= r; } - -function report_miner_share(miner, job) { + function report_miner_share(miner, job) { const time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); @@ -1544,7 +1543,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate, params.nonce, params.mixhash); + const hash = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate, params.nonce, params.mixhash); return verifyShareCB(hashRavenBuffDiff(hash), shareBuffer, false, null); } From 1393397de34638b694a8d25b5e904ac407bc70b5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 01:54:46 +0000 Subject: [PATCH 1073/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 882bdd735..432dc71d2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -256,6 +256,14 @@ function Coin(data){ return callback(true, body); } }); + } else if (port == 8766) { + global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { + if (!body || !body.result) { + console.error(JSON.stringify(body)); + return callback(true, body); + } + return this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); + }); } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { if (body && body.hasOwnProperty('result')) { @@ -283,6 +291,14 @@ function Coin(data){ } return callback(null, body); }); + } else if (port == 8766) { + global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash ] }, function (body) { + if (typeof(body) === 'undefined') { + console.error(JSON.stringify(body)); + return callback(true, body); + } + return callback(null, body); + }); } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || From 0afc4fd30d1ca08a8b98d318a8f55fd8a03907d6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 01:56:05 +0000 Subject: [PATCH 1074/1496] Draft implementation of Ravencoin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9150cf45b..f2a8309b3 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From 239283ea054ceccf9b5e38afd8a51cdd9661f699 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 02:19:16 +0000 Subject: [PATCH 1075/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 432dc71d2..49f59e20c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -377,13 +377,11 @@ function Coin(data){ }); } else if (port == 8766) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { - if (typeof(body) === 'object' && body.result) { - body.hash = body.result; - return callback(null, body); - } else { - if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); + if (!body || !body.result) { + console.error(JSON.stringify(body)); return callback(true, body); } + return this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { From a73863d9b9c9ef4d26298c83f177bdafb2f49da0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 02:21:06 +0000 Subject: [PATCH 1076/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 49f59e20c..17c7e3485 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -257,12 +257,13 @@ function Coin(data){ } }); } else if (port == 8766) { + let _this = this; global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - return this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); + return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { @@ -376,12 +377,13 @@ function Coin(data){ } }); } else if (port == 8766) { + let _this = this; global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - return this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); + return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { From 33372e9f62af4be31c257282cf9d93f51a2ae8c6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 04:31:12 +0000 Subject: [PATCH 1077/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 17c7e3485..4ffcfc921 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -294,11 +294,11 @@ function Coin(data){ }); } else if (port == 8766) { global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash ] }, function (body) { - if (typeof(body) === 'undefined') { + if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - return callback(null, body); + return callback(null, body.result); }); } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { From 18754b409eed1f484011ce5731071282a6e45dfd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 05:06:48 +0000 Subject: [PATCH 1078/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e88175cb0..8645e0053 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 100000; // !!! + if (coin === "RVN") coinHashFactor = 2000000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); From 64a28b1c12fea9104c5685a78247f8e246bc14dc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 21:21:45 +0000 Subject: [PATCH 1079/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8645e0053..7ba790087 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1092,10 +1092,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.sendCoinJob = function(coin, params) { const job = this.getCoinJob(coin, params); if (job === null) return; - switch (this.protocol) { - case "grin": return this.pushMessage({method: "getjobtemplate", result: job}); - case "raven": return this.pushMessage({method: "mining.notify", params: job}); - default: return this.pushMessage({method: "job", params: job}); + const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); + if (this.protocol == "grin") { + return this.pushMessage({method: "getjobtemplate", result: job}); + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + return this.pushMessage({method: "mining.notify", params: job}); + } else { + return this.pushMessage({method: "job", params: job}); } }; @@ -1775,7 +1778,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.protocol = "raven"; miner.sendBestCoinJob(); } else { - sendReply(null, { id: minerId, job: miner.getBestCoinJob(), status: 'OK' }); + // extra_nonce is for AutoClient xmrig mode + sendReply(null, { id: minerId, job: miner.getBestCoinJob(), extra_nonce: "", status: 'OK' }); miner.protocol = "default"; } break; From 31fdbf0cafd2d1032fe511d420c0e5dd3f00e2d4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 22:39:16 +0000 Subject: [PATCH 1080/1496] Draft implementation of Ravencoin utils --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4ffcfc921..760b9e6e1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -95,7 +95,7 @@ const port2algo = { "20206": "astrobwt", // DERO "18181": "cn/0", // XMC "16000": "cn/ccx", // CCX - "8766" : "kawpow/rvn", // RVN + "8766" : "kawpow", // RVN }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -669,7 +669,7 @@ function Coin(data){ if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; - if ("kawpow/rvn" in algos_perf) coin_perf["RVN"] = algos_perf["kawpow/rvn"]; + if ("kawpow" in algos_perf) coin_perf["RVN"] = algos_perf["kawpow"]; if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; From 2568b64f6130bb9bed5473b8ca6feb554061bb2c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 23:00:01 +0000 Subject: [PATCH 1081/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7ba790087..d694b5833 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1775,11 +1775,18 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.protocol = "grin"; } else if (method === 'mining.authorize') { sendReply(null, true); - miner.protocol = "raven"; + //miner.protocol = "raven"; miner.sendBestCoinJob(); } else { - // extra_nonce is for AutoClient xmrig mode - sendReply(null, { id: minerId, job: miner.getBestCoinJob(), extra_nonce: "", status: 'OK' }); + const coin = miner.selectBestCoin(); + const job = miner.getCoinJob(coin, getCoinJobParams(coin)); + const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); + if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + sendReply(null, true); + miner.pushMessage({method: "mining.notify", params: job}); + } else { + sendReply(null, { id: minerId, job: job, status: 'OK' }); + } miner.protocol = "default"; } break; From ae258df6f572675a2b549b69c29a39358db0e8c4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 23:04:46 +0000 Subject: [PATCH 1082/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d694b5833..602f7c9a6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1782,7 +1782,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const job = miner.getCoinJob(coin, getCoinJobParams(coin)); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - sendReply(null, true); + sendReply(null, { algo: "kawpow", extra_nonce: "" }); miner.pushMessage({method: "mining.notify", params: job}); } else { sendReply(null, { id: minerId, job: job, status: 'OK' }); From c3d5321320ef6eb8d284ba73422d7823614ffa09 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 23:06:53 +0000 Subject: [PATCH 1083/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 602f7c9a6..f99827e18 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1782,7 +1782,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const job = miner.getCoinJob(coin, getCoinJobParams(coin)); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - sendReply(null, { algo: "kawpow", extra_nonce: "" }); + sendReply(null, { id: minerId, algo: "kawpow", extra_nonce: "" }); miner.pushMessage({method: "mining.notify", params: job}); } else { sendReply(null, { id: minerId, job: job, status: 'OK' }); From d2de15a23bf8446097511d964c774d5fb59f00ef Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 23:14:40 +0000 Subject: [PATCH 1084/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f99827e18..602f7c9a6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1782,7 +1782,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const job = miner.getCoinJob(coin, getCoinJobParams(coin)); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - sendReply(null, { id: minerId, algo: "kawpow", extra_nonce: "" }); + sendReply(null, { algo: "kawpow", extra_nonce: "" }); miner.pushMessage({method: "mining.notify", params: job}); } else { sendReply(null, { id: minerId, job: job, status: 'OK' }); From f85c4150b306c75d4841abdcac8c7854112c7f1c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Nov 2020 23:22:04 +0000 Subject: [PATCH 1085/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 602f7c9a6..f99827e18 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1782,7 +1782,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const job = miner.getCoinJob(coin, getCoinJobParams(coin)); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - sendReply(null, { algo: "kawpow", extra_nonce: "" }); + sendReply(null, { id: minerId, algo: "kawpow", extra_nonce: "" }); miner.pushMessage({method: "mining.notify", params: job}); } else { sendReply(null, { id: minerId, job: job, status: 'OK' }); From 42b4a9cba8d085ea3a02311406d9a69e71733757 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Nov 2020 01:46:03 +0000 Subject: [PATCH 1086/1496] Removed debug stuff --- lib/pool.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f99827e18..52943aba5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,6 @@ function checkAliveMiners() { // coin hash factor is only updated in master thread function updateCoinHashFactor(coin) { global.support.getCoinHashFactor(coin, function (coinHashFactor) { - if (coin === "RVN") coinHashFactor = 2000000; // !!! if (coinHashFactor === null) { console.error("Error getting coinHashFactor for " + coin + " coin"); coinHashFactorUpdate(coin, newCoinHashFactor[coin] = 0); @@ -804,7 +803,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }; this.setNewDiff = function (difficulty) { - console.log("!!! DEBUG DIFF: " + difficulty); if (this.fixed_diff) return false; let newDiff = difficulty; //Math.round(difficulty); @@ -882,7 +880,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; const factor = curr_hash_factor / lastCoinHashFactorMM[best_coin]; - console.log("!!! DEBUG FACTOR: " + factor); if (factor != 1) { if (this.hashes === 0) { this.setNewDiff(this.difficulty * factor); @@ -1008,7 +1005,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } if (this.difficulty > bt.difficulty) this.difficulty = bt.difficulty; - console.log("!!! DEBUG DIFF2: " + bt.difficulty); const blob_type_num = global.coinFuncs.portBlobType(bt.port); From 2cb3537de7f27e9eda40f0fa39534fb99f173ac4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Nov 2020 02:48:16 +0000 Subject: [PATCH 1087/1496] Added no block template error message --- lib/coins/xmr.js | 2 -- lib/pool.js | 16 ++++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 760b9e6e1..b272cd8e4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -10,8 +10,6 @@ const net = require('net'); const async = require('async'); const child_process = require('child_process'); -let hexChars = new RegExp("[0-9a-f]+"); - const reXMRig = /XMRig(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\./; // 2.8.0 const reXMRSTAKRX = /\w+-stak-rx\/(\d+)\.(\d+)\.(\d+)/; // 1.0.1 const reXMRSTAK = /\w+-stak(?:-[a-zA-Z]+)?\/(\d+)\.(\d+)\.(\d+)/; // 2.5.0 diff --git a/lib/pool.js b/lib/pool.js index 52943aba5..d887e3727 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1775,13 +1775,17 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.sendBestCoinJob(); } else { const coin = miner.selectBestCoin(); - const job = miner.getCoinJob(coin, getCoinJobParams(coin)); - const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); - if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - sendReply(null, { id: minerId, algo: "kawpow", extra_nonce: "" }); - miner.pushMessage({method: "mining.notify", params: job}); + if (coin !== false) { + const job = miner.getCoinJob(coin, getCoinJobParams(coin)); + const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); + if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + sendReply(null, { id: minerId, algo: "kawpow", extra_nonce: "" }); + miner.pushMessage({method: "mining.notify", params: job}); + } else { + sendReply(null, { id: minerId, job: job, status: 'OK' }); + } } else { - sendReply(null, { id: minerId, job: job, status: 'OK' }); + sendReplyFinal("No block template yet"); } miner.protocol = "default"; } From 8253ca8ef4123ea70e9af269c2b5957f6a010fb9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Nov 2020 02:48:20 +0000 Subject: [PATCH 1088/1496] Added no block template error message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d887e3727..9cd0802af 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1785,7 +1785,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReply(null, { id: minerId, job: job, status: 'OK' }); } } else { - sendReplyFinal("No block template yet"); + sendReplyFinal("No block template yet. Please wait."); } miner.protocol = "default"; } From d5ca96d87eab9210196df14cca462d75b3cb10f8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Nov 2020 04:27:26 +0000 Subject: [PATCH 1089/1496] Fixed for invalid shares --- lib/pool.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 9cd0802af..86408c7fe 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1526,6 +1526,10 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { let verifyShare = function(verifyShareCB) { if (global.coinFuncs.blobTypeGrin(blob_type_num)) { const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (shareBuffer === null) { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); + return processShareCB(invalid_share(miner)); + } const header = Buffer.concat([global.coinFuncs.convertBlob(shareBuffer, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); if (global.coinFuncs.c29(header, params.pow, port)) { report_miner_share(miner, job); @@ -1536,6 +1540,10 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (global.coinFuncs.blobTypeRaven(blob_type_num)) { const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (shareBuffer === null) { + console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); + return processShareCB(invalid_share(miner)); + } const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); if (params.header_hash !== convertedBlob.toString("hex")) { console.error("Wrong header hash:" + params.header_hash + " " + convertedBlob.toString("hex")); From 9729e4e0f58a144f0ee4e5a2cc49a91f534ddf42 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Nov 2020 04:49:52 +0000 Subject: [PATCH 1090/1496] Fixed blob types for dero and grin --- lib/coins/xmr.js | 14 +++++++++----- lib/pool.js | 12 +++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b272cd8e4..8c1efa7a4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -503,12 +503,16 @@ function Coin(data){ return blob; }; - this.constructNewBlob = function(blockTemplate, nonce, port, mixhash) { + this.constructNewBlob = function(blockTemplate, nonce, port, cycle, mixhash) { const blob_type_num = this.portBlobType(port, blockTemplate[0]); - switch (blob_type_num) { - case 100: return cnUtil.constructNewGrinBlob(blockTemplate, bignum(nonce, 10).toBuffer({endian: 'little', size: 4})); - case 101: return cnUtil.constructNewRavenBlob(blockTemplate, bignum(nonce, 16).toBuffer({endian: 'little', size: 8}), bignum(mixhash, 16).toBuffer({endian: 'little', size: 32})); - default: return cnUtil.construct_block_blob(blockTemplate, new Buffer(nonce, 'hex'), blob_type_num); + if (global.coinFuncs.blobTypeGrin(blob_type_num)) { + return cnUtil.construct_block_blob(blockTemplate, bignum(nonce, 10).toBuffer({endian: 'little', size: 4}), port, cycle); + } else if (global.coinFuncs.blobTypeDero(blob_type_num)) { + return cnUtil.constructNewDeroBlob(blockTemplate, new Buffer(nonce, 'hex')); + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + return cnUtil.constructNewRavenBlob(blockTemplate, bignum(nonce, 16).toBuffer({endian: 'little', size: 8}), bignum(mixhash, 16).toBuffer({endian: 'little', size: 32})); + } else { + return cnUtil.construct_block_blob(blockTemplate, new Buffer(nonce, 'hex'), blob_type_num); } }; diff --git a/lib/pool.js b/lib/pool.js index 86408c7fe..31bb87871 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1372,7 +1372,7 @@ function getShareBuffer(miner, job, blockTemplate, params) { template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); } - return global.coinFuncs.constructNewBlob(template, params.nonce, blockTemplate.port, params.mixhash); + return global.coinFuncs.constructNewBlob(template, params.nonce, blockTemplate.port, params.pow, params.mixhash); } catch (e) { const err_str = "Can't constructNewBlob with " + params.nonce + " nonce from " + miner.logString + ": " + e; console.error(err_str); @@ -1526,10 +1526,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { let verifyShare = function(verifyShareCB) { if (global.coinFuncs.blobTypeGrin(blob_type_num)) { const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer === null) { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); - return processShareCB(invalid_share(miner)); - } + if (shareBuffer === null) return processShareCB(invalid_share(miner)); const header = Buffer.concat([global.coinFuncs.convertBlob(shareBuffer, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); if (global.coinFuncs.c29(header, params.pow, port)) { report_miner_share(miner, job); @@ -1540,10 +1537,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (global.coinFuncs.blobTypeRaven(blob_type_num)) { const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer === null) { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); - return processShareCB(invalid_share(miner)); - } + if (shareBuffer === null) return processShareCB(invalid_share(miner)); const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); if (params.header_hash !== convertedBlob.toString("hex")) { console.error("Wrong header hash:" + params.header_hash + " " + convertedBlob.toString("hex")); From c82afb6cd2680dfdfda1cb743d22020fc91a567a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Nov 2020 04:55:56 +0000 Subject: [PATCH 1091/1496] Draft implementation of Ravencoin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f2a8309b3..5f0986cf8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From 10715c12fff157e01ace9cf176168d29e541bb88 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Nov 2020 15:50:23 +0000 Subject: [PATCH 1092/1496] Fixed blob contruction for grin --- lib/coins/xmr.js | 16 +++++++++++----- lib/pool.js | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8c1efa7a4..69f568450 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -503,16 +503,22 @@ function Coin(data){ return blob; }; - this.constructNewBlob = function(blockTemplate, nonce, port, cycle, mixhash) { + this.constructNewBlob = function(blockTemplate, params, port) { const blob_type_num = this.portBlobType(port, blockTemplate[0]); if (global.coinFuncs.blobTypeGrin(blob_type_num)) { - return cnUtil.construct_block_blob(blockTemplate, bignum(nonce, 10).toBuffer({endian: 'little', size: 4}), port, cycle); + return cnUtil.construct_block_blob(blockTemplate, + bignum(params.nonce, 10).toBuffer({endian: 'little', size: 4}), + blob_type_num, params.pow + ); } else if (global.coinFuncs.blobTypeDero(blob_type_num)) { - return cnUtil.constructNewDeroBlob(blockTemplate, new Buffer(nonce, 'hex')); + return cnUtil.constructNewDeroBlob(blockTemplate, new Buffer(params.nonce, 'hex')); } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - return cnUtil.constructNewRavenBlob(blockTemplate, bignum(nonce, 16).toBuffer({endian: 'little', size: 8}), bignum(mixhash, 16).toBuffer({endian: 'little', size: 32})); + return cnUtil.constructNewRavenBlob(blockTemplate, + bignum(params.nonce, 16).toBuffer({endian: 'little', size: 8}), + bignum(params.mixhash, 16).toBuffer({endian: 'little', size: 32}) + ); } else { - return cnUtil.construct_block_blob(blockTemplate, new Buffer(nonce, 'hex'), blob_type_num); + return cnUtil.construct_block_blob(blockTemplate, new Buffer(params.nonce, 'hex'), blob_type_num); } }; diff --git a/lib/pool.js b/lib/pool.js index 31bb87871..f0f0c0e99 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1372,9 +1372,9 @@ function getShareBuffer(miner, job, blockTemplate, params) { template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); } - return global.coinFuncs.constructNewBlob(template, params.nonce, blockTemplate.port, params.pow, params.mixhash); + return global.coinFuncs.constructNewBlob(template, params, blockTemplate.port); } catch (e) { - const err_str = "Can't constructNewBlob with " + params.nonce + " nonce from " + miner.logString + ": " + e; + const err_str = "Can't constructNewBlob of " + blockTemplate.port + " port with " + JSON.stringify(params) + " params from " + miner.logString + ": " + e; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't constructNewBlob", err_str); return null; From 3b1f04c4ddbb1304a734cf78c21f08fcc1c86e7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Nov 2020 16:34:23 +0000 Subject: [PATCH 1093/1496] Draft implementation of Ravencoin utils --- lib/pool.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f0f0c0e99..f5d781f54 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1465,12 +1465,16 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus } } }; + + const blockhex = shareBuffer.toString('hex'); if (blockTemplate.port == 11898) { - global.support.rpcPortDaemon2(blockTemplate.port, 'block', shareBuffer.toString('hex'), reply_fn); + global.support.rpcPortDaemon2(blockTemplate.port, "block", blockhex, reply_fn); + } else if (global.coinFuncs.blobTypeRaven(job.blob_type_num)) { + global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "submitblock", params: [ blockhex ] }, reply_fn); } else if (global.coinFuncs.blobTypeDero(job.blob_type_num)) { - global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [ blockTemplate.blocktemplate_blob, shareBuffer.toString('hex') ], reply_fn); + global.support.rpcPortDaemon(blockTemplate.port, "submitblock", [ blockTemplate.blocktemplate_blob, blockhex ], reply_fn); } else { - global.support.rpcPortDaemon(blockTemplate.port, 'submitblock', [ shareBuffer.toString('hex') ], reply_fn); + global.support.rpcPortDaemon(blockTemplate.port, "submitblock", [ blockhex ], reply_fn); } } From c736edce7942bdcd09d96af3be6cec5eb3151a03 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Nov 2020 16:20:31 +0000 Subject: [PATCH 1094/1496] Added more miner debug --- lib/pool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index f5d781f54..5d0ef6fd8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2363,6 +2363,7 @@ if (cluster.isMaster) { result: result }; if (jsonData.id === "Stratum") reply.method = jsonData.method; + debug("[MINER] REPLY TO MINER: " + JSON.stringify(reply)); socket.write(JSON.stringify(reply) + "\n"); }; let sendReplyFinal = function (error) { @@ -2375,9 +2376,11 @@ if (cluster.isMaster) { result: null }; if (jsonData.id === "Stratum") reply.method = jsonData.method; + debug("[MINER] FINAL REPLY TO MINER: " + JSON.stringify(reply)); socket.end(JSON.stringify(reply) + "\n"); }, 9 * 1000); }; + debug("[MINER] GOT FROM MINER: " + JSON.stringify(jsonData)); handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, pushMessage); }; @@ -2390,6 +2393,7 @@ if (cluster.isMaster) { let pushMessage = function (body) { if (!socket.writable) return; body.jsonrpc = "2.0"; + debug("[MINER] PUSH TO MINER: " + JSON.stringify(body)); socket.write(JSON.stringify(body) + "\n"); }; From 7b67465bcfd6ef696a12a702f81de8b0895a01cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 8 Nov 2020 05:30:53 +0000 Subject: [PATCH 1095/1496] Fixed Raven TRM --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 5d0ef6fd8..db9b8a4ef 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2010,6 +2010,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (miner.protocol === "grin") { sendReply(null, "ok"); + } else if (global.coinFuncs.blobTypeRaven(blob_type_num) { + sendReply(null, true); } else { sendReply(null, { status: 'OK' }); } From 74b35b1f3fbe661151c95d59ee199c834fb4de23 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 8 Nov 2020 05:33:40 +0000 Subject: [PATCH 1096/1496] Fixed Raven TRM --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index db9b8a4ef..6c58355d4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2010,7 +2010,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (miner.protocol === "grin") { sendReply(null, "ok"); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num) { + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { sendReply(null, true); } else { sendReply(null, { status: 'OK' }); From 885fa8029795dce38119f738faf148c47944f348 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 8 Nov 2020 05:54:49 +0000 Subject: [PATCH 1097/1496] Extra debug --- lib/pool.js | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6c58355d4..1b76ccd8e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1582,7 +1582,12 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); } } - return verifyShareCB(hashDiff, shareBuffer, true, null); + if (miner.lastSlowHashAsyncDelay) { + setTimeout(function { return verifyShareCB(hashDiff, shareBuffer, true, null); }, miner.lastSlowHashAsyncDelay); + debug("[MINER] Delay " + miner.lastSlowHashAsyncDelay); + } else { + return verifyShareCB(hashDiff, shareBuffer, true, null); + } } else { // verify share if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); @@ -1610,20 +1615,25 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } walletTrust[miner.payout] += job.rewarded_difficulty2; return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); - } else global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { - if (hash === null) { - return processShareCB(null); - } else if (hash === false) { - console.error(threadName + "Processed share locally instead of remotely!"); - hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - } - if (hash !== resultHash) { - report_miner_share(miner, job); - return processShareCB(invalid_share(miner)); - } - walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); - }); + } else { + const time_now = Date.now(); + global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { + if (hash === null) { + return processShareCB(null); + } else if (hash === false) { + console.error(threadName + "Processed share locally instead of remotely!"); + hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + } + if (hash !== resultHash) { + report_miner_share(miner, job); + return processShareCB(invalid_share(miner)); + } + miner.lastSlowHashAsyncDelay = Date.now() - time_now; + if (miner.lastSlowHashAsyncDelay > 1000) miner.lastSlowHashAsyncDelay = 1000; + walletTrust[miner.payout] += job.rewarded_difficulty2; + return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); + }); + } } }; From 0a0190e57ac59053b398322d0835437d3d0febb2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 8 Nov 2020 05:55:15 +0000 Subject: [PATCH 1098/1496] Extra debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1b76ccd8e..0754e82d8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1583,7 +1583,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } if (miner.lastSlowHashAsyncDelay) { - setTimeout(function { return verifyShareCB(hashDiff, shareBuffer, true, null); }, miner.lastSlowHashAsyncDelay); + setTimeout(function() { return verifyShareCB(hashDiff, shareBuffer, true, null); }, miner.lastSlowHashAsyncDelay); debug("[MINER] Delay " + miner.lastSlowHashAsyncDelay); } else { return verifyShareCB(hashDiff, shareBuffer, true, null); From 6188a15de5f1a723b7e0d7f21a0511034d8fe4b9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 8 Nov 2020 18:16:22 +0000 Subject: [PATCH 1099/1496] Extra debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 0754e82d8..82bd85c32 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -854,6 +854,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const factor = (typeof(miner.curr_coin_hash_factor) === 'undefined' ? 1 : miner.curr_coin_hash_factor) / coinHashFactor; if (miner.difficulty * factor > bt.difficulty * 3) { + debug("[MINER] Rejected best " + coin + " coin due to high diff " + miner.difficulty + " " + factor + " " + bt.difficulty); return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { @@ -1787,7 +1788,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se miner.protocol = "grin"; } else if (method === 'mining.authorize') { sendReply(null, true); - //miner.protocol = "raven"; + miner.protocol = "auto"; miner.sendBestCoinJob(); } else { const coin = miner.selectBestCoin(); From 17ec202851fdf1f9b783d8950e0acc13b60364be Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 8 Nov 2020 18:51:11 +0000 Subject: [PATCH 1100/1496] Fixed initial diff setup --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 82bd85c32..69a833501 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -884,6 +884,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (factor != 1) { if (this.hashes === 0) { this.setNewDiff(this.difficulty * factor); + if (this.newDiffToSet) { + this.difficulty = this.newDiffToSet; + this.newDiffToSet = null; + this.newDiffRecommendation = null; + } } else { this.hashes *= factor; if (this.hashesShift) this.hashesShift *= factor; From fced5bca70773046939b13bdfde1b139c78fd1a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 9 Nov 2020 01:26:55 +0000 Subject: [PATCH 1101/1496] Updated monero daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index daddc1439..b62b42583 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.1 +sudo git checkout v0.17.1.3 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 527b6be7f..4efab5951 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.1 +sudo git checkout v0.17.1.3 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index b372def42..fe6ece806 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.1 +sudo git checkout v0.17.1.3 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 0f5e1a2d3..5de0c5921 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.1 &&\ +sudo git checkout v0.17.1.3 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 7c3fa8cb9fedcb6f46feb04aff37d2f4c0758308 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 01:58:30 +0000 Subject: [PATCH 1102/1496] Fixed blob parsing and more correct removed miner handling --- lib/coins/xmr.js | 13 ++++++++----- lib/pool.js | 17 +++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 69f568450..25749c7a8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -490,15 +490,18 @@ function Coin(data){ this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; - if (this.blobTypeRaven(blob_type_num)) return cnUtil.convertRavenBlob(blobBuffer); let blob; try { - blob = cnUtil.convert_blob(blobBuffer, blob_type_num); + if (this.blobTypeRaven(blob_type_num)) { + blob = cnUtil.convertRavenBlob(blobBuffer); + } else { + blob = cnUtil.convert_blob(blobBuffer, blob_type_num); + } } catch (e) { const err_str = "Can't do port " + port + " convert_blob " + blobBuffer.toString('hex') + " with blob type " + blob_type_num + ": " + e; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't convert_blob", err_str); - throw new Error(e); + return null; } return blob; }; @@ -630,10 +633,10 @@ function Coin(data){ // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserved_offset); // Convert the buffer into something hashable. - return global.coinFuncs.convertBlob(this.buffer, this.port).toString('hex'); + return global.coinFuncs.convertBlob(this.buffer, this.port); }; // Make it so you can get the raw block buffer out. - this.nextBlobWithChildNonce = function () { + this.nextBlobWithChildNonceHex = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserved_offset); // Don't convert the buffer to something hashable. You bad. diff --git a/lib/pool.js b/lib/pool.js index 69a833501..7ce876346 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -226,6 +226,7 @@ function removeMiner(miner) { if (proxyMinerName && proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; activeMiners.delete(miner.id); + miner.removed_miner = true; } function checkAliveMiners() { @@ -721,6 +722,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.error = ""; this.valid_miner = true; + this.removed_miner = false; this.proxy = agent && agent.includes('xmr-node-proxy'); this.id = id; @@ -1015,7 +1017,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const blob_type_num = global.coinFuncs.portBlobType(bt.port); if (!this.proxy) { - const blob = bt.nextBlob(); + const blob = bt.nextBlob(); + if (!blob) return null; + const blob_hex = blob.toString('hex'); const newJob = { id: get_new_id(), coin: coin, @@ -1030,7 +1034,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }; this.validJobs.enq(newJob); if (global.coinFuncs.blobTypeGrin(blob_type_num)) this.cachedJob = { - pre_pow: blob, + pre_pow: blob_hex, algo: this.protocol === "grin" ? "cuckaroo" : params.algo_name, edgebits: 29, proofsize: global.coinFuncs.c29ProofSize(blob_type_num), @@ -1041,14 +1045,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi id: this.id }; else if (global.coinFuncs.blobTypeRaven(blob_type_num)) this.cachedJob = [ newJob.id, - blob, + blob_hex, bt.seed_hash, getRavenTargetHex(this.difficulty), true, bt.height, bt.bits ]; else this.cachedJob = { - blob: blob, + blob: blob_hex, algo: params.algo_name, height: bt.height, seed_hash: bt.seed_hash, @@ -1057,7 +1061,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi id: this.id }; } else { - const blob = bt.nextBlobWithChildNonce(); + const blob_hex = bt.nextBlobWithChildNonceHex(); const newJob = { id: get_new_id(), coin: coin, @@ -1074,7 +1078,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }; this.validJobs.enq(newJob); this.cachedJob = { - blocktemplate_blob: blob, + blocktemplate_blob: blob_hex, blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), algo: params.algo_name, difficulty: bt.difficulty, @@ -2000,6 +2004,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; processShare(miner, job, blockTemplate, params, function(shareAccepted) { + if (miner.removed_miner) return; if (shareAccepted === null) { sendReply('Throttled down share submission (please use high fixed diff or use xmr-node-proxy)'); return; From 2f975d99e17e955c2404a0668d19e240e65a2942 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 17:09:43 +0000 Subject: [PATCH 1103/1496] Optimize stuff --- lib/pool.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7ce876346..b57c35f77 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1618,12 +1618,14 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const isBlockDiffMatched = ge(hashDiff, blockTemplate.difficulty); if (isBlockDiffMatched) { - const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash !== resultHash) { - report_miner_share(miner, job); - return processShareCB(invalid_share(miner)); + if (miner.validShares === 0) { + const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + if (hash !== resultHash) { + report_miner_share(miner, job); + return processShareCB(invalid_share(miner)); + } + walletTrust[miner.payout] += job.rewarded_difficulty2; } - walletTrust[miner.payout] += job.rewarded_difficulty2; return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); } else { const time_now = Date.now(); From 5460ddb3492f1015c0d815b89e122f5dff1efe53 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 19:15:19 +0000 Subject: [PATCH 1104/1496] Share handling optimization --- lib/pool.js | 132 +++++++++++++++++++++------------------------------- 1 file changed, 54 insertions(+), 78 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b57c35f77..171e93f4d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1241,93 +1241,69 @@ function recordShareData(miner, job, isBlockCandidate, hashHex, isTrustedShare, is_walletAccFinalizer[wallet_key] = false; } - let db_job_height = global.config.daemon.port == blockTemplate.port ? blockTemplate.height : anchorBlockHeight; - - if (job.difficulty >= 100000000 || isBlockCandidate) { - storeShareDiv(miner, job.rewarded_difficulty, job.rewarded_difficulty2, 1, miner.identifier, blockTemplate.port, db_job_height, blockTemplate.difficulty, isBlockCandidate, isTrustedShare); - //global.database.storeShare(db_job_height, global.protos.Share.encode({ - // shares: job.rewarded_difficulty, - // shares2: job.rewarded_difficulty2, - // paymentAddress: miner.address, - // paymentID: miner.paymentID, - // foundBlock: isBlockCandidate, - // trustedShare: isTrustedShare, - // poolType: miner.poolTypeEnum, - // poolID: global.config.pool_id, - // blockDiff: blockTemplate.difficulty, - // bitcoin: miner.bitcoin, - // blockHeight: db_job_height, - // timestamp: time_now, - // identifier: miner.identifier, - // port: blockTemplate.port, - // share_num: 1 - //})); + const db_job_height = global.config.daemon.port == blockTemplate.port ? blockTemplate.height : anchorBlockHeight; - } else { - - let wallet = walletAcc[wallet_key]; - - let worker_name = miner.identifier in wallet || walletWorkerCount[wallet_key] < 50 ? miner.identifier : "all_other_workers"; - - if (!(worker_name in wallet)) { - if (worker_name !== "all_other_workers") ++ walletWorkerCount[wallet_key]; - debug("!!! " + wallet_key + ": adding new worker " + worker_name + " (num " + walletWorkerCount[wallet_key] + ")"); - wallet[worker_name] = {}; - let worker = wallet[worker_name]; - worker.height = db_job_height; - worker.difficulty = blockTemplate.difficulty; - worker.time = time_now; - worker.acc = 0; - worker.acc2 = 0; - worker.share_num = 0; - } + let wallet = walletAcc[wallet_key]; + const worker_name = miner.identifier in wallet || walletWorkerCount[wallet_key] < 50 ? miner.identifier : "all_other_workers"; + if (!(worker_name in wallet)) { + if (worker_name !== "all_other_workers") ++ walletWorkerCount[wallet_key]; + debug("!!! " + wallet_key + ": adding new worker " + worker_name + " (num " + walletWorkerCount[wallet_key] + ")"); + wallet[worker_name] = {}; let worker = wallet[worker_name]; + worker.height = db_job_height; + worker.difficulty = blockTemplate.difficulty; + worker.time = time_now; + worker.acc = 0; + worker.acc2 = 0; + worker.share_num = 0; + } - let height = worker.height; - let difficulty = worker.difficulty; - let acc = worker.acc; - let acc2 = worker.acc2; - let share_num = worker.share_num; - - if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > 60*1000 || acc >= 100000000) { - if (acc != 0) { - debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); - storeShareDiv(miner, acc, acc2, share_num, worker_name, blockTemplate.port, height, difficulty, false, isTrustedShare); - //global.database.storeShare(height, global.protos.Share.encode({ - // shares: acc, - // shares2: acc2, - // paymentAddress: miner.address, - // paymentID: miner.paymentID, - // foundBlock: false, - // trustedShare: isTrustedShare, - // poolType: miner.poolTypeEnum, - // poolID: global.config.pool_id, - // blockDiff: difficulty, - // bitcoin: miner.bitcoin, - // blockHeight: height, - // timestamp: time_now, - // identifier: worker_name, - // port: blockTemplate.port, - // share_num: share_num - //})); - } + let worker = wallet[worker_name]; - worker.height = db_job_height; - worker.difficulty = blockTemplate.difficulty; - worker.time = time_now; - worker.acc = job.rewarded_difficulty; - worker.acc2 = job.rewarded_difficulty2; - worker.share_num = 1; + let height = worker.height; + let difficulty = worker.difficulty; + let acc = worker.acc; + let acc2 = worker.acc2; + let share_num = worker.share_num; - } else { - worker.acc += job.rewarded_difficulty; - worker.acc2 += job.rewarded_difficulty2; - ++ worker.share_num; + if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > 60*1000 || acc >= 100000000) { + if (acc != 0) { + debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); + storeShareDiv(miner, acc, acc2, share_num, worker_name, blockTemplate.port, height, difficulty, false, isTrustedShare); + //global.database.storeShare(height, global.protos.Share.encode({ + // shares: acc, + // shares2: acc2, + // paymentAddress: miner.address, + // paymentID: miner.paymentID, + // foundBlock: false, + // trustedShare: isTrustedShare, + // poolType: miner.poolTypeEnum, + // poolID: global.config.pool_id, + // blockDiff: difficulty, + // bitcoin: miner.bitcoin, + // blockHeight: height, + // timestamp: time_now, + // identifier: worker_name, + // port: blockTemplate.port, + // share_num: share_num + //})); } - debug("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + blockTemplate.difficulty + " " + worker.time + " " + worker.acc + " (+" + job.rewarded_difficulty + ")"); + worker.height = db_job_height; + worker.difficulty = blockTemplate.difficulty; + worker.time = time_now; + worker.acc = job.rewarded_difficulty; + worker.acc2 = job.rewarded_difficulty2; + worker.share_num = 1; + + } else { + worker.acc += job.rewarded_difficulty; + worker.acc2 += job.rewarded_difficulty2; + ++ worker.share_num; } + + debug("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + blockTemplate.difficulty + " " + worker.time + " " + worker.acc + " (+" + job.rewarded_difficulty + ")"); if (is_walletAccFinalizer[wallet_key] === false) { is_walletAccFinalizer[wallet_key] = true; From a49484ecc94156774dbccab178464c32bb477b53 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 19:19:09 +0000 Subject: [PATCH 1105/1496] Share handling optimization --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 171e93f4d..f71dc00d7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -207,7 +207,7 @@ let proxyMiners = {}; function addProxyMiner(miner) { if (miner.proxyMinerName && miner.proxyMinerName in proxyMiners) return; - const proxyMinerName = miner.payout + ":" + miner.identifier; + const proxyMinerName = miner.payout; // + ":" + miner.identifier; miner.proxyMinerName = proxyMinerName; if (!(proxyMinerName in proxyMiners)) { From 59492ffd75402ef32a6f69947509df99786c8041 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 19:19:49 +0000 Subject: [PATCH 1106/1496] Share handling optimization --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f71dc00d7..171e93f4d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -207,7 +207,7 @@ let proxyMiners = {}; function addProxyMiner(miner) { if (miner.proxyMinerName && miner.proxyMinerName in proxyMiners) return; - const proxyMinerName = miner.payout; // + ":" + miner.identifier; + const proxyMinerName = miner.payout + ":" + miner.identifier; miner.proxyMinerName = proxyMinerName; if (!(proxyMinerName in proxyMiners)) { From d6d8fe58b2fb8d63a7f7aff650481b0c218535ac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 19:20:52 +0000 Subject: [PATCH 1107/1496] Share handling optimization --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 171e93f4d..3c0284a99 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -207,7 +207,7 @@ let proxyMiners = {}; function addProxyMiner(miner) { if (miner.proxyMinerName && miner.proxyMinerName in proxyMiners) return; - const proxyMinerName = miner.payout + ":" + miner.identifier; + const proxyMinerName = miner.payout; //+ ":" + miner.identifier; miner.proxyMinerName = proxyMinerName; if (!(proxyMinerName in proxyMiners)) { @@ -1229,7 +1229,7 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { function recordShareData(miner, job, isBlockCandidate, hashHex, isTrustedShare, blockTemplate) { miner.hashes += job.difficulty; - let proxyMinerName = miner.payout + ":" + miner.identifier; + let proxyMinerName = miner.payout; // + ":" + miner.identifier; if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.difficulty; let time_now = Date.now(); @@ -1583,7 +1583,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } process.send({type: 'throttledShare'}); addProxyMiner(miner); - const proxyMinerName = miner.payout + ":" + miner.identifier; + const proxyMinerName = miner.payout; // + ":" + miner.identifier; proxyMiners[proxyMinerName].hashes += job.difficulty; adjustMinerDiff(miner); return processShareCB(null); @@ -1754,7 +1754,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se activeMiners.set(minerId, miner); if (!miner.proxy) { - let proxyMinerName = miner.payout + ":" + miner.identifier; + let proxyMinerName = miner.payout; // + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { addProxyMiner(miner); if (proxyMiners[proxyMinerName].hashes) adjustMinerDiff(miner); From ccd93ac93035cdc738e3aba6c6062bafe6f241ce Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 19:44:37 +0000 Subject: [PATCH 1108/1496] Share handling optimization --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3c0284a99..044e889c9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -920,7 +920,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } this.calcNewDiff = function () { - const proxyMinerName = this.payout + ":" + this.identifier; + const proxyMinerName = this.payout; // + ":" + this.identifier; let miner; let target; let min_diff; From 40f482339627fc7c4592838a3c80f77595280042 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Nov 2020 20:55:29 +0000 Subject: [PATCH 1109/1496] Share handling optimization --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 044e889c9..fb3b18532 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1594,7 +1594,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const isBlockDiffMatched = ge(hashDiff, blockTemplate.difficulty); if (isBlockDiffMatched) { - if (miner.validShares === 0) { + if (miner.validShares === 0 && (!(miner.payout in minerWallets) || minerWallets[miner.payout].hashes === 0)) { const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); if (hash !== resultHash) { report_miner_share(miner, job); From 35de468ed66b76b22118f9a56c54f1d1968efa2f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 14 Nov 2020 18:21:12 +0000 Subject: [PATCH 1110/1496] Share handling optimization --- lib/pool.js | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index fb3b18532..be26de557 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1375,11 +1375,9 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock) { +function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { let reply_fn = function (rpcResult, rpcStatus) { - if (rpcResult.error) { - // Did not manage to submit a block. Log and continue on. - recordShareData(miner, job, false, null, isTrustedShare, blockTemplate); + if (rpcResult.error) { // did not manage to submit a block let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); @@ -1414,6 +1412,9 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus miner.trust.trust = 0; walletTrust[miner.payout] = 0; } + + if (submit_blockCB) submit_blockCB(false); + } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.blobTypeDero(global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0])) ? @@ -1422,7 +1423,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + ", block hex: \n" + shareBuffer.toString('hex') ); - recordShareData(miner, job, true, blockFastHash, isTrustedShare, blockTemplate); + if (submit_blockCB) submit_blockCB(true); } else if (rpcResult && typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898) { // TRTL // Success! Submitted a block without an issue. const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); @@ -1430,7 +1431,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') ); - recordShareData(miner, job, true, blockFastHash, isTrustedShare, blockTemplate); + if (submit_blockCB) submit_blockCB(true); } else { // something not expected happened if (isRetrySubmitBlock) { console.error(threadName + "Unknown error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + @@ -1438,7 +1439,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus miner.logString + ", isTrustedShare: " + isTrustedShare + ", rpcStatus: " + rpcStatus + ", error (" + (typeof rpcResult) + "): " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') ); - setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, false); + setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, false, submit_blockCB); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1448,6 +1449,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "RPC Error. Please check logs for details" ); + if (submit_blockCB) submit_blockCB(false); } } }; @@ -1495,7 +1497,8 @@ function ge(l, r) { if (typeof r === 'object') return !r.lt(l); return l >= r; } - function report_miner_share(miner, job) { + +function report_miner_share(miner, job) { const time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); @@ -1594,15 +1597,27 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const isBlockDiffMatched = ge(hashDiff, blockTemplate.difficulty); if (isBlockDiffMatched) { - if (miner.validShares === 0 && (!(miner.payout in minerWallets) || minerWallets[miner.payout].hashes === 0)) { + if (miner.validShares || (miner.payout in minerWallets && minerWallets[miner.payout].hashes)) { + submit_block(miner, job, blockTemplate, shareBuffer, resultHash, true, true, true, function(block_submit_result) { + if (!block_submit_result) { + const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); + if (hash !== resultHash) { + report_miner_share(miner, job); + return processShareCB(invalid_share(miner)); + } + } + walletTrust[miner.payout] += job.rewarded_difficulty2; + return verifyShareCB(hashDiff, shareBuffer, false, true); + }); + } else { const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); if (hash !== resultHash) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } walletTrust[miner.payout] += job.rewarded_difficulty2; - } - return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); + return verifyShareCB(hashDiff, shareBuffer, false, null); + } } else { const time_now = Date.now(); global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { @@ -1619,24 +1634,24 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { miner.lastSlowHashAsyncDelay = Date.now() - time_now; if (miner.lastSlowHashAsyncDelay > 1000) miner.lastSlowHashAsyncDelay = 1000; walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, shareBuffer, false, isBlockDiffMatched); + return verifyShareCB(hashDiff, shareBuffer, false, false); }); } } }; verifyShare(function(hashDiff, shareBuffer, isTrustedShare, isBlockDiffMatched) { - isBlockDiffMatched = isBlockDiffMatched === null ? ge(hashDiff, blockTemplate.difficulty) : isBlockDiffMatched; - - if (isBlockDiffMatched) { // Submit block to the RPC Daemon. + if (isBlockDiffMatched === null && ge(hashDiff, blockTemplate.difficulty)) { // Submit block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); if (!shareBuffer) return processShareCB(invalid_share(miner)); } submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, true, true); + isBlockDiffMatched = true; } const is_mm = "child_template" in blockTemplate; + let isBlockDiffMatchedMM = false; if (is_mm && ge(hashDiff, blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1655,11 +1670,9 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } if (shareBuffer2 === null) return processShareCB(invalid_share(miner)); submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, isTrustedShare, false, true); - isBlockDiffMatched = true; + isBlockDiffMatchedMM = true; } - if (isBlockDiffMatched) return processShareCB(true); - if (!ge(hashDiff, job.difficulty)) { let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { @@ -1669,11 +1682,11 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { return processShareCB(invalid_share(miner)); } else { - recordShareData(miner, job, false, null, isTrustedShare, blockTemplate); + recordShareData(miner, job, isBlockDiffMatched, null, isTrustedShare, blockTemplate); // record child proc share for rewarded_difficulty effort calcs status but with 0 rewards (all included in parent share) if (is_mm) { job.rewarded_difficulty2 = 0; - recordShareData(miner, job, false, null, isTrustedShare, blockTemplate.child_template); + recordShareData(miner, job, isBlockDiffMatchedMM, null, isTrustedShare, blockTemplate.child_template); } return processShareCB(true); } From e37a60febc796bf4cb121aa1a93c9e618d2d12d0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 14 Nov 2020 20:57:25 +0000 Subject: [PATCH 1111/1496] Share handling optimization --- lib/pool.js | 99 +++++++++++++++++++++-------------------------------- 1 file changed, 39 insertions(+), 60 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index be26de557..7561215a3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1227,12 +1227,12 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { } } -function recordShareData(miner, job, isBlockCandidate, hashHex, isTrustedShare, blockTemplate) { +function recordShareData(miner, job, isTrustedShare, blockTemplate) { miner.hashes += job.difficulty; let proxyMinerName = miner.payout; // + ":" + miner.identifier; if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.difficulty; - let time_now = Date.now(); + const time_now = Date.now(); let wallet_key = miner.wallet_key + blockTemplate.port; if (!(wallet_key in walletAcc)) { @@ -1271,23 +1271,6 @@ function recordShareData(miner, job, isBlockCandidate, hashHex, isTrustedShare, if (acc != 0) { debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); storeShareDiv(miner, acc, acc2, share_num, worker_name, blockTemplate.port, height, difficulty, false, isTrustedShare); - //global.database.storeShare(height, global.protos.Share.encode({ - // shares: acc, - // shares2: acc2, - // paymentAddress: miner.address, - // paymentID: miner.paymentID, - // foundBlock: false, - // trustedShare: isTrustedShare, - // poolType: miner.poolTypeEnum, - // poolID: global.config.pool_id, - // blockDiff: difficulty, - // bitcoin: miner.bitcoin, - // blockHeight: height, - // timestamp: time_now, - // identifier: worker_name, - // port: blockTemplate.port, - // share_num: share_num - //})); } worker.height = db_job_height; @@ -1310,32 +1293,6 @@ function recordShareData(miner, job, isBlockCandidate, hashHex, isTrustedShare, setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner, blockTemplate.port); } - if (isBlockCandidate) { - if (global.config.daemon.port == blockTemplate.port) { - global.database.storeBlock(blockTemplate.height, global.protos.Block.encode({ - hash: hashHex, - difficulty: blockTemplate.difficulty, - shares: 0, - timestamp: time_now, - poolType: miner.poolTypeEnum, - unlocked: false, - valid: true - })); - } else { - global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ - hash: hashHex, - difficulty: blockTemplate.difficulty, - shares: 0, - timestamp: time_now, - poolType: miner.poolTypeEnum, - unlocked: false, - valid: true, - port: blockTemplate.port, - height: blockTemplate.height, - anchor_height: anchorBlockHeight - })); - } - } if (isTrustedShare) { process.send({type: 'trustedShare'}); debug(threadName + "Accepted trusted share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + " from: " + miner.logString); @@ -1415,23 +1372,48 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus if (submit_blockCB) submit_blockCB(false); - } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { - // Success! Submitted a block without an issue. + // Success! Submitted a block without an issue. + } else if ( rpcResult && ( + typeof(rpcResult.result) !== 'undefined' || + ( typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898 ) + ) + ) { + const blockFastHash = global.coinFuncs.blobTypeDero(global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0])) ? rpcResult.result.blid : global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); - console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + - ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult.result) + - ", block hex: \n" + shareBuffer.toString('hex') - ); - if (submit_blockCB) submit_blockCB(true); - } else if (rpcResult && typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898) { // TRTL - // Success! Submitted a block without an issue. - const blockFastHash = global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') ); + + const time_now = Date.now(); + if (global.config.daemon.port == blockTemplate.port) { + global.database.storeBlock(blockTemplate.height, global.protos.Block.encode({ + hash: blockFastHash, + difficulty: blockTemplate.difficulty, + shares: 0, + timestamp: time_now, + poolType: miner.poolTypeEnum, + unlocked: false, + valid: true + })); + } else { + global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ + hash: blockFastHash, + difficulty: blockTemplate.difficulty, + shares: 0, + timestamp: time_now, + poolType: miner.poolTypeEnum, + unlocked: false, + valid: true, + port: blockTemplate.port, + height: blockTemplate.height, + anchor_height: anchorBlockHeight + })); + } + if (submit_blockCB) submit_blockCB(true); + } else { // something not expected happened if (isRetrySubmitBlock) { console.error(threadName + "Unknown error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + @@ -1647,11 +1629,9 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (!shareBuffer) return processShareCB(invalid_share(miner)); } submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, true, true); - isBlockDiffMatched = true; } const is_mm = "child_template" in blockTemplate; - let isBlockDiffMatchedMM = false; if (is_mm && ge(hashDiff, blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. if (!shareBuffer) { shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1670,7 +1650,6 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } if (shareBuffer2 === null) return processShareCB(invalid_share(miner)); submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, isTrustedShare, false, true); - isBlockDiffMatchedMM = true; } if (!ge(hashDiff, job.difficulty)) { @@ -1682,11 +1661,11 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { return processShareCB(invalid_share(miner)); } else { - recordShareData(miner, job, isBlockDiffMatched, null, isTrustedShare, blockTemplate); + recordShareData(miner, job, isTrustedShare, blockTemplate); // record child proc share for rewarded_difficulty effort calcs status but with 0 rewards (all included in parent share) if (is_mm) { job.rewarded_difficulty2 = 0; - recordShareData(miner, job, isBlockDiffMatchedMM, null, isTrustedShare, blockTemplate.child_template); + recordShareData(miner, job, isTrustedShare, blockTemplate.child_template); } return processShareCB(true); } From 11731510ade94339bcc10de5456718e71f0ff18d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Nov 2020 19:41:16 +0000 Subject: [PATCH 1112/1496] More precise raven hashrate calc --- lib/data.proto | 2 +- lib/pool.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/data.proto b/lib/data.proto index 653703822..f40793683 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -26,7 +26,7 @@ message InvalidShare{ } message Share { - required int64 shares = 1; + required double shares = 1; required string paymentAddress = 2; required bool foundBlock = 3; optional string paymentID = 4; diff --git a/lib/pool.js b/lib/pool.js index 7561215a3..9b7d7adf7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1970,8 +1970,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } job.rewarded_difficulty2 = job.rewarded_difficulty * job.coinHashFactor; - job.rewarded_difficulty = Math.floor(job.rewarded_difficulty); - if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; + //job.rewarded_difficulty = Math.floor(job.rewarded_difficulty); + //if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; processShare(miner, job, blockTemplate, params, function(shareAccepted) { if (miner.removed_miner) return; From 4e0c6bd911806ae0215d00c27e682ac131b59d88 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Nov 2020 20:16:45 +0000 Subject: [PATCH 1113/1496] Transition to raw_share usage --- lib/api.js | 269 ------------------------------------------------- lib/data.proto | 3 +- lib/pool.js | 21 +--- 3 files changed, 5 insertions(+), 288 deletions(-) diff --git a/lib/api.js b/lib/api.js index 9d1439767..7af69f90f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -686,277 +686,8 @@ secureRoutes.post('/changePayoutThreshold', function (req, res) { }); }); -// Administrative routes/APIs - -/*adminRoutes.use(function (req, res, next) { - let token = req.body.token || req.query.token || req.headers['x-access-token']; - if (token) { - jwt.verify(token, global.config.api.secKey, function (err, decoded) { - if (decoded.admin !== 1) { - return res.status(403).send({ - success: false, - msg: 'You are not an admin.' - }); - } - if (err) { - return res.json({success: false, msg: 'Failed to authenticate token.'}); - } else { - req.decoded = decoded; - next(); - } - }); - - } else { - return res.status(403).send({ - success: false, - msg: 'No token provided.' - }); - } -}); - -adminRoutes.get('/stats', function (req, res) { - // Admin interface stats. - // For each pool type + global, we need the following: - // Total Owed, Total Paid, Total Mined, Total Blocks, Average Luck - let intCache = { - 'pplns': {owed: 0, paid: 0, mined: 0, shares: 0, targetShares: 0}, - 'pps': {owed: 0, paid: 0, mined: 0, shares: 0, targetShares: 0}, - 'solo': {owed: 0, paid: 0, mined: 0, shares: 0, targetShares: 0}, - 'global': {owed: 0, paid: 0, mined: 0, shares: 0, targetShares: 0}, - 'fees': {owed: 0, paid: 0, mined: 0, shares: 0, targetShares: 0} - }; - async.series([ - function (callback) { - global.mysql.query("select * from balance").then(function (rows) { - rows.forEach(function (row) { - intCache[row.pool_type].owed += row.amount; - intCache.global.owed += row.amount; - }); - }).then(function () { - return callback(null); - }); - }, - function (callback) { - global.mysql.query("select * from payments").then(function (rows) { - rows.forEach(function (row) { - intCache[row.pool_type].paid += row.amount; - intCache.global.paid += row.amount; - }); - }).then(function () { - return callback(null); - }); - }, - function (callback) { - global.database.getBlockList().forEach(function (block) { - intCache[block.pool_type].mined += block.value; - intCache.global.mined += block.value; - intCache[block.pool_type].shares += block.shares; - intCache.global.shares += block.shares; - intCache[block.pool_type].targetShares += block.diff; - intCache.global.targetShares += block.diff; - }); - return callback(null); - } - ], function () { - return res.json(intCache); - }); -}); - -adminRoutes.get('/wallet', function (req, res) { - // Stats for the admin interface. - // Load the wallet state from cache, NOTHING HAS DIRECT ACCESS. - // walletStateInfo - return res.json(global.database.getCache('walletStateInfo')); -}); - -adminRoutes.get('/wallet/history', function (req, res) { - // walletHistory - if (req.decoded.admin === 1) { - return res.json(global.database.getCache('walletHistory')); - } -}); - -adminRoutes.get('/ports', function (req, res) { - let retVal = []; - global.mysql.query("SELECT * FROM port_config").then(function (rows) { - rows.forEach(function (row) { - retVal.push({ - port: row.poolPort, - diff: row.difficulty, - desc: row.portDesc, - portType: row.portType, - hidden: row.hidden === 1, - ssl: row.ssl === 1 - }); - }); - }).then(function () { - return res.json(retVal); - }); -}); - -adminRoutes.post('/ports', function (req, res) { - global.mysql.query("SELECT * FROM port_config WHERE poolPort = ?", [req.body.port]).then(function (rows) { - if (rows.length !== 0) { - return "Port already exists with that port number."; - } - if (req.body.diff > global.config.pool.maxDifficulty || req.body.diff < global.config.pool.minDifficulty) { - return "Invalid difficulty."; - } - if (["pplns", "solo", "pps"].indexOf(req.body.portType) === -1) { - return "Invalid port type"; - } - global.mysql.query("INSERT INTO port_config (poolPort, difficulty, portDesc, portType, hidden, ssl) VALUES (?, ?, ?, ?, ?, ?)", - [req.body.port, req.body.diff, req.body.desc, req.body.portType, req.body.hidden === 1, req.body.ssl === 1]); - }).then(function (err) { - if (typeof(err) === 'string') { - return res.json({success: false, msg: err}); - } - return res.json({success: true, msg: "Added port to database"}); - }); -}); - -adminRoutes.put('/ports', function (req, res) { - let portNumber = Number(req.body.portNum); - global.mysql.query("SELECT * FROM port_config WHERE poolPort = ?", [portNumber]).then(function (rows) { - if (rows.length === 0) { - return "Port doesn't exist in the database"; - } - if (req.body.diff > global.config.pool.maxDifficulty || req.body.diff < global.config.pool.minDifficulty) { - return "Invalid difficulty."; - } - if (["pplns", "solo", "pps"].indexOf(req.body.portType) === -1) { - return "Invalid port type"; - } - global.mysql.query("UPDATE port_config SET difficulty=?, portDesc=?, portType=?, hidden=?, ssl=? WHERE poolPort = ?", - [req.body.diff, req.body.desc, req.body.portType, req.body.hidden === 1, req.body.ssl === 1, portNumber]); - }).then(function (err) { - if (typeof(err) === 'string') { - return res.json({success: false, msg: err}); - } - return res.json({success: true, msg: "Updated port in database"}); - }); -}); - -adminRoutes.delete('/ports', function (req, res) { - let portNumber = Number(req.body.portNum); - global.mysql.query("SELECT * FROM port_config WHERE poolPort = ?", [portNumber]).then(function (rows) { - if (rows.length === 0) { - return "Port doesn't exist in the database"; - } - global.mysql.query("DELETE FROM port_config WHERE poolPort = ?", [portNumber]); - }).then(function (err) { - if (typeof(err) === 'string') { - return res.json({success: false, msg: err}); - } - return res.json({success: true, msg: "Added port to database"}); - }); -}); - -adminRoutes.get('/config', function (req, res) { - let retVal = []; - global.mysql.query("SELECT * FROM config").then(function (rows) { - rows.forEach(function (row) { - retVal.push({ - id: row.id, - module: row.module, - item: row.item, - value: row.item_value, - type: row.item_type, - desc: row.item_desc - }); - }); - }).then(function () { - return res.json(retVal); - }); -}); - -adminRoutes.put('/config', function (req, res) { - let configID = Number(req.body.id); - global.mysql.query("SELECT * FROM config WHERE id = ?", [configID]).then(function (rows) { - if (rows.length === 0) { - return "Config item doesn't exist in the database"; - } - global.mysql.query("UPDATE config SET item_value=? WHERE id = ?", [req.body.value, configID]); - }).then(function (err) { - if (typeof(err) === 'string') { - return res.json({success: false, msg: err}); - } - return res.json({success: true, msg: "Updated port in database"}); - }); -}); - -adminRoutes.get('/userList', function (req, res) { - // List of all the users in the system. - // Might as well do it all, right? :3 - // Data Format to be documented. - let intCache = {}; - global.mysql.query("select sum(balance.amount) as amt_due, sum(payments.amount) as amt_paid," + - "balance.payment_address as address, balance.payment_id as payment_id from balance LEFT JOIN payments on " + - "payments.payment_address=balance.payment_address or payments.payment_id=balance.payment_id " + - "group by address, payment_id").then(function (rows) { - rows.forEach(function (row) { - let key = row.address; - if (row.payment_id !== null) { - key += '.' + row.payment_id; - } - intCache[key] = { - paid: row.amt_paid, - due: row.amt_due, - address: key, - workers: [], - lastHash: 0, - totalHashes: 0, - hashRate: 0, - goodShares: 0, - badShares: 0 - }; - }); - }).then(function () { - let minerList = global.database.getCache('minerList'); - if (minerList) { - minerList.forEach(function (miner) { - let minerData = miner.split('_'); - let minerCache = global.database.getCache(miner); - if (!minerCache.hasOwnProperty('goodShares')) { - minerCache.goodShares = 0; - minerCache.badShares = 0; - } - if (!intCache.hasOwnProperty(minerData[0])) { - intCache[minerData[0]] = {paid: 0, due: 0, address: minerData[0], workers: []}; - } - if (typeof(minerData[1]) !== 'undefined') { - intCache[minerData[0]].workers.push({ - worker: minerData[1], - hashRate: minerCache.hash, - lastHash: minerCache.lastHash, - totalHashes: minerCache.totalHashes, - goodShares: minerCache.goodShares, - badShares: minerCache.badShares - }); - } else { - intCache[minerData[0]].lastHash = minerCache.lastHash; - intCache[minerData[0]].totalHashes = minerCache.totalHashes; - intCache[minerData[0]].hashRate = minerCache.hash; - intCache[minerData[0]].goodShares = minerCache.goodShares; - intCache[minerData[0]].badShares = minerCache.badShares; - } - }); - let retList = []; - for (let minerId in intCache) { - if (intCache.hasOwnProperty(minerId)) { - let miner = intCache[minerId]; - retList.push(miner); - } - } - return res.json(retList); - } - return res.json([]); - }); -});*/ - // apply the routes to our application with the prefix /api app.use('/authed', secureRoutes); -//app.use('/admin', adminRoutes); // Authenticated routes diff --git a/lib/data.proto b/lib/data.proto index f40793683..52e71e231 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -26,7 +26,7 @@ message InvalidShare{ } message Share { - required double shares = 1; + required int64 shares = 1; required string paymentAddress = 2; required bool foundBlock = 3; optional string paymentID = 4; @@ -41,6 +41,7 @@ message Share { optional int32 port = 13; optional int64 shares2 = 14; optional int64 share_num = 15; + required float raw_shares = 16; } message Block { diff --git a/lib/pool.js b/lib/pool.js index 9b7d7adf7..7dd8a8f1b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1139,6 +1139,7 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam paymentAddress: miner.address, paymentID: miner.paymentID, shares: share_reward, + raw_shares: share_reward, shares2: share_reward2, share_num: share_num, identifier: worker_name, @@ -1158,12 +1159,13 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam const paymentAddress = payout_split[0]; const paymentID = payout_split.length === 2 ? payout_split[1] : null; const payoutPercent = miner.payout_div[payout]; - const shares = Math.floor(share_reward * payoutPercent / 100); + const shares = share_reward * payoutPercent / 100; const shares2 = Math.floor(share_reward2 * payoutPercent / 100); global.database.storeShare(bt_height, global.protos.Share.encode({ paymentAddress: paymentAddress, paymentID: paymentID, shares: shares, + raw_shares: shares, shares2: shares2, share_num: share_num, identifier: worker_name, @@ -1194,23 +1196,6 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { let height = worker.height; debug("!!! " + wallet_key + " / " + worker_name + ": storing old worker share " + height + " " + worker.difficulty + " " + time_now + " " + acc); storeShareDiv(miner, acc, worker.acc2, worker.share_num, worker_name, bt_port, height, worker.difficulty, false, true); - //global.database.storeShare(height, global.protos.Share.encode({ - // shares: acc, - // shares2: worker.acc2, - // paymentAddress: miner_address, - // paymentID: miner_paymentID, - // foundBlock: false, - // trustedShare: true, - // poolType: miner_poolTypeEnum, - // poolID: global.config.pool_id, - // blockDiff: worker.difficulty, - // bitcoin: miner_bitcoin, - // blockHeight: height, - // timestamp: time_now, - // identifier: worker_name, - // port: bt_port, - // share_num: worker.share_num - //})); } debug("!!! " + wallet_key + ": removing old worker " + worker_name); if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; From 48c850e71f8d2b2dad0de882c6bf30b510d8a60d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Nov 2020 20:17:07 +0000 Subject: [PATCH 1114/1496] Transition to raw_share usage --- lib/data.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data.proto b/lib/data.proto index 52e71e231..edca40a0c 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -41,7 +41,7 @@ message Share { optional int32 port = 13; optional int64 shares2 = 14; optional int64 share_num = 15; - required float raw_shares = 16; + optional float raw_shares = 16; } message Block { From 72a622803bae244584353e9afba227c57fbab76b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Nov 2020 21:44:03 +0000 Subject: [PATCH 1115/1496] Transition to raw_share usage --- lib/blockManager.js | 4 ++-- lib/local_comms.js | 26 +++++++++++++------------- lib/remoteShare.js | 2 +- lib/worker.js | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 07e628dd6..bff4ddaa4 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -246,7 +246,7 @@ function calculatePPSPayments(blockHeader, callback) { amount: 0 }; } - let amountToPay = Math.floor((shareData.shares / blockDiff) * rewardTotal); + let amountToPay = Math.floor((shareData.raw_shares / blockDiff) * rewardTotal); let feesToPay = Math.floor(amountToPay * (global.config.payout.ppsFee / 100)); if (shareData.bitcoin === true) { feesToPay += Math.floor(amountToPay * (global.config.payout.btcFee / 100)); @@ -369,7 +369,7 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is const poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); const amountToPay2 = amountToPay - feesToPay; - shares4dump.push(userIdentifier.slice(-16) + "\t" + shareData.timestamp.toString(16) + "\t" + shareData.shares + "\t" + shareData.share_num + "\t" + + shares4dump.push(userIdentifier.slice(-16) + "\t" + shareData.timestamp.toString(16) + "\t" + shareData.raw_shares + "\t" + shareData.share_num + "\t" + global.coinFuncs.PORT2COIN_FULL(shareData.port) + "\t" + amountToPay + "\t" + (amountToPay === amountToPay2 ? "" : amountToPay2)); addPayment(userIdentifier, amountToPay2); diff --git a/lib/local_comms.js b/lib/local_comms.js index 1fd2759f4..e5312723f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -199,7 +199,7 @@ function Database(){ shareObject.forEach(function(share){ //Data is the share object at this point. ++ shareCount; - if (typeof(share.shares) === "number") { + if (typeof(share.raw_shares) === "number") { if (!shares.hasOwnProperty(share.blockHeight)) { shares[share.blockHeight] = []; } @@ -216,21 +216,21 @@ function Database(){ cachedData[stats_type1] = { totalHashes: 0, roundHashes: 0 }; } if (port_suffix === "") { - cachedData[global_stats1].totalHashes += share.shares; - cachedData[global_stats1].roundHashes += share.shares; - cachedData[stats_type1].totalHashes += share.shares; - cachedData[stats_type1].roundHashes += share.shares; + cachedData[global_stats1].totalHashes += share.raw_shares; + cachedData[global_stats1].roundHashes += share.raw_shares; + cachedData[stats_type1].totalHashes += share.raw_shares; + cachedData[stats_type1].roundHashes += share.raw_shares; } else { let global_stats2 = global_stats1 + port_suffix; let stats_type2 = stats_type1 + port_suffix; if (!(global_stats2 in cachedData)) cachedData[global_stats2] = { totalHashes: 0, roundHashes: 0 }; if (!(stats_type2 in cachedData)) cachedData[stats_type2] = { totalHashes: 0, roundHashes: 0 }; - cachedData[global_stats1].totalHashes += share.shares; - cachedData[global_stats2].totalHashes += share.shares; - cachedData[global_stats2].roundHashes += share.shares; - cachedData[stats_type1].totalHashes += share.shares; - cachedData[stats_type2].totalHashes += share.shares; - cachedData[stats_type2].roundHashes += share.shares; + cachedData[global_stats1].totalHashes += share.raw_shares; + cachedData[global_stats2].totalHashes += share.raw_shares; + cachedData[global_stats2].roundHashes += share.raw_shares; + cachedData[stats_type1].totalHashes += share.raw_shares; + cachedData[stats_type2].totalHashes += share.raw_shares; + cachedData[stats_type2].roundHashes += share.raw_shares; } if (!cachedData.hasOwnProperty(minerID)) { cachedData[minerID] = {totalHashes: 0, goodShares: 0}; @@ -238,8 +238,8 @@ function Database(){ if (!cachedData.hasOwnProperty(minerIDWithIdentifier)) { cachedData[minerIDWithIdentifier] = {totalHashes: 0, goodShares: 0}; } - cachedData[minerIDWithIdentifier].totalHashes += share.shares; - cachedData[minerID].totalHashes += share.shares; + cachedData[minerIDWithIdentifier].totalHashes += share.raw_shares; + cachedData[minerID].totalHashes += share.raw_shares; const share_num = typeof(share.share_num) !== 'undefined' && share.share_num ? share.share_num : 1; cachedData[minerIDWithIdentifier].goodShares += share_num; cachedData[minerID].goodShares += share_num; diff --git a/lib/remoteShare.js b/lib/remoteShare.js index e1efc970d..69747fd44 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -24,7 +24,7 @@ app.use(function(req, res, next){ // Master/Slave communication Handling function messageHandler(message) { - if (typeof message.shares === "number"){ + if (typeof message.raw_shares === "number"){ shareData.push(message); } } diff --git a/lib/worker.js b/lib/worker.js index 4e36bb374..4ab041737 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -106,19 +106,19 @@ function updateShareStats() { } const port = typeof(share.port) !== 'undefined' && share.port ? share.port : global.config.daemon.port; - if (port in localPortHashes) localPortHashes[port] += share.shares; - else localPortHashes[port] = share.shares; + if (port in localPortHashes) localPortHashes[port] += share.raw_shares; + else localPortHashes[port] = share.raw_shares; if (!shares2) return; // use virtual shares from child block mining only for global pool stats if (minerID in minerPortSet) { - localStats.miners[minerID] += share.shares; + localStats.miners[minerID] += share.raw_shares; localStats.miners2[minerID] += shares2; if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; } else { ++ localMinerCount[minerType]; ++ localMinerCount.global; - localStats.miners[minerID] = share.shares; + localStats.miners[minerID] = share.raw_shares; localStats.miners2[minerID] = shares2; localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; @@ -126,11 +126,11 @@ function updateShareStats() { } if (minerIDWithIdentifier in minerSet) { - localStats.miners[minerIDWithIdentifier] += share.shares; + localStats.miners[minerIDWithIdentifier] += share.raw_shares; localStats.miners2[minerIDWithIdentifier] += shares2; if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; } else { - localStats.miners[minerIDWithIdentifier] = share.shares; + localStats.miners[minerIDWithIdentifier] = share.raw_shares; localStats.miners2[minerIDWithIdentifier] = shares2; localTimes.miners[minerIDWithIdentifier] = share.timestamp; minerSet[minerIDWithIdentifier] = 1; From 19cb2e53d0ba2d15a524582f98f005a09018390e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Nov 2020 21:56:55 +0000 Subject: [PATCH 1116/1496] More precise raven hashrate calc --- lib/worker.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 4ab041737..8db41e8ad 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -152,7 +152,7 @@ function updateShareStats() { let cache_updates = {}; // pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { - const hash = Math.floor(localStats[key] / (hashrate_avg_min*60)) + 1; + const hash = localStats[key] / (hashrate_avg_min*60); const lastHash = localTimes[key]; const minerCount = localMinerCount[key]; let cachedData = global.database.getCache(key + "_stats"); @@ -190,7 +190,7 @@ function updateShareStats() { } cache_updates[key + "_stats"] = cachedData; }); - for (let port in localPortHashes) localPortHashes[port] = Math.floor(localPortHashes[port] / (hashrate_avg_min*60)) + 1; + for (let port in localPortHashes) localPortHashes[port] = localPortHashes[port] / (hashrate_avg_min*60); cache_updates["port_hash"] = localPortHashes; for (let miner in minerSet) { let stats; @@ -210,8 +210,8 @@ function updateShareStats() { } } - stats.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; - stats.hash2 = Math.floor(localStats.miners2[miner] / (hashrate_avg_min*60)) + 1; + stats.hash = localStats.miners[miner] / (hashrate_avg_min*60); + stats.hash2 = localStats.miners2[miner] / (hashrate_avg_min*60); stats.lastHash = localTimes.miners[miner]; cache_updates[keyStats] = { hash: stats.hash, hash2: stats.hash2, lastHash: stats.lastHash }; @@ -297,7 +297,7 @@ function updateShareStats() { } cache_updates = null; - let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; + let pool_hashrate = localStats.global / (hashrate_avg_min*60); let pool_workers = minerCount; console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { From b2f0de7daa3f21c38c964d341d748568db970699 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Nov 2020 22:03:02 +0000 Subject: [PATCH 1117/1496] Transition to raw_share usage --- lib/data.proto | 4 ++-- lib/pool.js | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/data.proto b/lib/data.proto index edca40a0c..7f5fbc6c0 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -26,7 +26,7 @@ message InvalidShare{ } message Share { - required int64 shares = 1; + optional int64 shares = 1; required string paymentAddress = 2; required bool foundBlock = 3; optional string paymentID = 4; @@ -41,7 +41,7 @@ message Share { optional int32 port = 13; optional int64 shares2 = 14; optional int64 share_num = 15; - optional float raw_shares = 16; + required float raw_shares = 16; } message Block { diff --git a/lib/pool.js b/lib/pool.js index 7dd8a8f1b..07cc7b084 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1138,7 +1138,6 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam global.database.storeShare(bt_height, global.protos.Share.encode({ paymentAddress: miner.address, paymentID: miner.paymentID, - shares: share_reward, raw_shares: share_reward, shares2: share_reward2, share_num: share_num, @@ -1164,7 +1163,6 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam global.database.storeShare(bt_height, global.protos.Share.encode({ paymentAddress: paymentAddress, paymentID: paymentID, - shares: shares, raw_shares: shares, shares2: shares2, share_num: share_num, From 0c130cc06bcf75a0fd4150b338f793134b237845 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Nov 2020 22:09:33 +0000 Subject: [PATCH 1118/1496] Transition to raw_share usage --- lib/data.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data.proto b/lib/data.proto index 7f5fbc6c0..e72db63fa 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -41,7 +41,7 @@ message Share { optional int32 port = 13; optional int64 shares2 = 14; optional int64 share_num = 15; - required float raw_shares = 16; + optional float raw_shares = 16; } message Block { From a0bc599798ec3a541522166e474b37907e19c5b6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Nov 2020 22:05:21 +0000 Subject: [PATCH 1119/1496] Fixed extranonce location --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f0986cf8..363875e45 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.3", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From b0e4125ebfc816b136f5d04d0ead63325d8973a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Nov 2020 22:29:58 +0000 Subject: [PATCH 1120/1496] Fixed RVN block id calc --- lib/pool.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 07cc7b084..250403e82 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1362,8 +1362,11 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus ) ) { - const blockFastHash = global.coinFuncs.blobTypeDero(global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0])) ? - rpcResult.result.blid : global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex'); + const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0]); + const blockFastHash = global.coinFuncs.blobTypeDero(blob_type_num) ? rpcResult.result.blid : + ( global.coinFuncs.blobTypeRaven(blob_type_num) ? resultHash.toString('hex') : + global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex') + ); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') @@ -1474,9 +1477,8 @@ function report_miner_share(miner, job) { function processShare(miner, job, blockTemplate, params, processShareCB) { const port = blockTemplate.port; const blob_type_num = job.blob_type_num; - // can be undefined for global.coinFuncs.blobTypeGrin(blob_type_num) or global.coinFuncs.blobTypeRaven(blob_type_num) - // (if undefined will not be used in submit_block since isTrustedShare = false) - const resultHash = params.result; + // recomputed for global.coinFuncs.blobTypeGrin(blob_type_num) or global.coinFuncs.blobTypeRaven(blob_type_num) + let resultHash = params.result; if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); @@ -1490,7 +1492,8 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - return verifyShareCB(hashBuffDiff(global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num)), shareBuffer, false, null); + resultHash = global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num); + return verifyShareCB(hashBuffDiff(resultHash), shareBuffer, false, null); } if (global.coinFuncs.blobTypeRaven(blob_type_num)) { @@ -1502,8 +1505,8 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - const hash = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate, params.nonce, params.mixhash); - return verifyShareCB(hashRavenBuffDiff(hash), shareBuffer, false, null); + resultHash = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate, params.nonce, params.mixhash); + return verifyShareCB(hashRavenBuffDiff(resultHash), shareBuffer, false, null); } let resultBuffer; From 90324dd34a7c3a76882910787e59545161791192 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Nov 2020 22:36:56 +0000 Subject: [PATCH 1121/1496] Fixed bad RVN block detection --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 250403e82..3824f05ed 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1357,7 +1357,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus // Success! Submitted a block without an issue. } else if ( rpcResult && ( - typeof(rpcResult.result) !== 'undefined' || + ( typeof(rpcResult.result) !== 'undefined' && rpcResult.result !== "high-hash" ) || ( typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898 ) ) ) { From 4f12a6ad26bfd3fd54db497685bd06e096533fcd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Nov 2020 22:40:36 +0000 Subject: [PATCH 1122/1496] Fixed bad RVN block detection --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3824f05ed..efdebb2cb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1317,7 +1317,7 @@ function invalid_share(miner) { function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { let reply_fn = function (rpcResult, rpcStatus) { - if (rpcResult.error) { // did not manage to submit a block + if (rpcResult && (rpcResult.error || rpcResult.result === "high-hash")) { // did not manage to submit a block let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); @@ -1357,7 +1357,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus // Success! Submitted a block without an issue. } else if ( rpcResult && ( - ( typeof(rpcResult.result) !== 'undefined' && rpcResult.result !== "high-hash" ) || + typeof(rpcResult.result) !== 'undefined' || ( typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898 ) ) ) { From ba30143620dd9aa0c5c36aafeca14b8d29715a5b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 1 Dec 2020 17:15:54 +0000 Subject: [PATCH 1123/1496] Replaced deleted merkle-bitcoin repo --- lib/support.js | 6 ------ package.json | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/support.js b/lib/support.js index 53f6a41ff..ee506ff3f 100644 --- a/lib/support.js +++ b/lib/support.js @@ -239,11 +239,6 @@ function setCoinHashFactor(coin, coinHashFactor) { global.config.daemon["coinHashFactor" + coin] = coinHashFactor; } -function setActivePort(coin, activePort) { - global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort" + coin + "'", [activePort]); - global.config.daemon["activePort" + coin] = activePort; -} - function formatDate(date) { // Date formatting for MySQL date time fields. return moment(date).format('YYYY-MM-DD HH:mm:ss'); @@ -332,7 +327,6 @@ module.exports = function () { tsCompare: tsCompare, getCoinHashFactor: getCoinHashFactor, setCoinHashFactor: setCoinHashFactor, - setActivePort: setActivePort, https_get: https_get, }; }; diff --git a/package.json b/package.json index 363875e45..7920aba91 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.3", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.4", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From b8752a847a138e468d0b69c43ea8ae1e0118d63e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 1 Dec 2020 21:51:48 +0000 Subject: [PATCH 1124/1496] Updated monero daemon version --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index b62b42583..2f3f59fe5 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.3 +sudo git checkout v0.17.1.5 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 4efab5951..4fe56050e 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.3 +sudo git checkout v0.17.1.5 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index fe6ece806..654553f56 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.3 +sudo git checkout v0.17.1.5 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 5de0c5921..1cac9b4fd 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.3 &&\ +sudo git checkout v0.17.1.5 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From f94b50f9787bf8c2d29a5b0cb7a64a2412f8273d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 7 Dec 2020 02:16:18 +0000 Subject: [PATCH 1125/1496] constructNewRavenBlob fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7920aba91..00ddde718 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.4", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.5", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From b3c48e2529fb27dca5c5598d3cddc849294ed263 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 7 Dec 2020 18:41:03 +0000 Subject: [PATCH 1126/1496] Updated monero daemon version --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 2f3f59fe5..6d4052549 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.5 +sudo git checkout v0.17.1.6 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 4fe56050e..d64477496 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.5 +sudo git checkout v0.17.1.6 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 654553f56..692634cbc 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.5 +sudo git checkout v0.17.1.6 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 1cac9b4fd..92b9b5e8a 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.5 &&\ +sudo git checkout v0.17.1.6 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 044d99d4605d1cbf1527d7939b24eb7519aef54f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 Dec 2020 08:23:05 +0000 Subject: [PATCH 1127/1496] Improved error reporting --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index efdebb2cb..94e60e408 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1328,7 +1328,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus console.error(threadName + "Error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + ", rpcStatus: " + rpcStatus + - ", error: " + JSON.stringify(rpcResult.error) + ", block hex: \n" + shareBuffer.toString('hex') + ", error: " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') ); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time @@ -1342,7 +1342,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "Input: " + shareBuffer.toString('hex') + "\n" + threadName + "Error submitting " + blockTemplate.coin + " block at " + blockTemplate.height + " height from " + miner.logString + - ", isTrustedShare: " + isTrustedShare + " error (" + (typeof rpcResult.error) + "): " + JSON.stringify(rpcResult.error) + ", isTrustedShare: " + isTrustedShare + " error ): " + JSON.stringify(rpcResult) ); }); }, 2*1000); From 533abe5a34121234fc600b306b03dd02515a2455 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 Dec 2020 22:46:39 +0000 Subject: [PATCH 1128/1496] Fixed raven block prev hash calc --- lib/coins/xmr.js | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 25749c7a8..87ca09404 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -614,7 +614,8 @@ function Coin(data){ if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); - this.buffer.copy(prev_hash, 0, 7, 39); + const prev_hash_start = global.coinFuncs.blobTypeRaven(port2blob_num[this.port]) ? 4 : 7; + this.buffer.copy(prev_hash, 0, prev_hash_start, prev_hash_start + 32); this.prev_hash = prev_hash.toString('hex'); } else { this.prev_hash = template.prev_hash; diff --git a/package.json b/package.json index 00ddde718..baa238c5d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.5", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.6", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From b77517c64ce69eb02ba6cd959d417ccbbe34fcc2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 00:39:41 +0000 Subject: [PATCH 1129/1496] Fixed raven block prev hash calc --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index baa238c5d..893877146 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.6", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.7", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From 663d0b3b6e7c104467d3a839af1fbc5b2fbe7cfe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 01:16:17 +0000 Subject: [PATCH 1130/1496] Fixed raven block prev hash calc --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 893877146..e7a0b083f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.7", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.8", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From e3c16e1b038a18a1afc379e023a738dd35e4982c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 01:45:38 +0000 Subject: [PATCH 1131/1496] Fixed raven block prev hash calc --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e7a0b083f..84083843d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.8", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.9", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From 67b94a885a4efabd76733cc70c07487273719994 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 02:58:55 +0000 Subject: [PATCH 1132/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 84083843d..b37d8106a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.9", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.10", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From 153ea222991cea4ace184eff6cdcb771c2f574be Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 03:02:44 +0000 Subject: [PATCH 1133/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b37d8106a..472f364fb 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.10", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.11", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From a7055dcbbd90dde48ea75079bab116bbc2ddc9aa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 03:08:04 +0000 Subject: [PATCH 1134/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 472f364fb..b57f2980a 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.11", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.12", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From de81df33385c801c66b866574a7aaa3e66b87c33 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 03:46:30 +0000 Subject: [PATCH 1135/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b57f2980a..3bcf93358 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.12", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.13", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From 3757ae15e929ea0fa0d1fb5aa05a91374ac30889 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 04:19:47 +0000 Subject: [PATCH 1136/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3bcf93358..97e3e99f6 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.13", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.14", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From d56a92e87963d2b5f2e590d2a40fa101c8950b07 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 04:21:46 +0000 Subject: [PATCH 1137/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 97e3e99f6..118618048 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.14", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.15", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From c5577fd8b1e83f6ebf1538b0a96488ecc443c05d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 04:26:35 +0000 Subject: [PATCH 1138/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 118618048..2f7b28bf5 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.15", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.16", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From f004af532fd85e37345d3a54151aa51a14a37e4b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Dec 2020 06:53:40 +0000 Subject: [PATCH 1139/1496] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f7b28bf5..9ea748b03 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.16", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.17", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From 7424fd702ee20f85f1da90003ce50b1b557ef85a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 Dec 2020 20:56:36 +0000 Subject: [PATCH 1140/1496] Updated monero daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 6d4052549..bcce4deff 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.6 +sudo git checkout v0.17.1.7 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index d64477496..645ff8804 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.6 +sudo git checkout v0.17.1.7 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 692634cbc..551038759 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.6 +sudo git checkout v0.17.1.7 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 92b9b5e8a..18443b2e7 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.6 &&\ +sudo git checkout v0.17.1.7 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 73e8d970ebfdb65070b63017abe5ad095ed134d6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 Dec 2020 15:26:42 +0000 Subject: [PATCH 1141/1496] Updated for CCX fork --- lib/coins/xmr.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 87ca09404..375110f96 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -92,7 +92,7 @@ const port2algo = { "9231" : "cn/gpu", // XEQ "20206": "astrobwt", // DERO "18181": "cn/0", // XMC - "16000": "cn/ccx", // CCX + "16000": "cn/gpu", // CCX "8766" : "kawpow", // RVN }; @@ -677,7 +677,7 @@ function Coin(data){ if ("panthera" in algos_perf) coin_perf["XLA"] = algos_perf["panthera"]; - if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; + if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["CCX"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; @@ -703,8 +703,6 @@ function Coin(data){ if ("cn/0" in algos_perf) coin_perf["XMC"] = algos_perf["cn/0"]; - if ("cn/ccx" in algos_perf) coin_perf["CCX"] = algos_perf["cn/ccx"]; - if ("argon2/chukwav2" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwav2"]; else if ("chukwav2" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwav2"]; @@ -736,7 +734,7 @@ function Coin(data){ case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium - case 16000: return multiHashing.cryptonight(convertedBlob, 17, blockTemplate.height); // Conceal + case 16000: return multiHashing.cryptonight(convertedBlob, 11); // CCX case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC From 8a63d6a3d796f7796b1d46874754e3e73010b99e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 Dec 2020 02:16:46 +0000 Subject: [PATCH 1142/1496] Fix for RVN block detection --- lib/coins/xmr.js | 1 + lib/pool.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 375110f96..afa6eaf12 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -296,6 +296,7 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } + body.result.reward = 5000 * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 return callback(null, body.result); }); } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { diff --git a/lib/pool.js b/lib/pool.js index 94e60e408..4385edeec 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1315,6 +1315,12 @@ function invalid_share(miner) { return false; } +function reverseBuffer(buff) { + let reversed = new Buffer(buff.length); + for (var i = buff.length - 1; i >= 0; i--) reversed[buff.length - i - 1] = buff[i]; + return reversed; +} + function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { let reply_fn = function (rpcResult, rpcStatus) { if (rpcResult && (rpcResult.error || rpcResult.result === "high-hash")) { // did not manage to submit a block @@ -1364,7 +1370,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0]); const blockFastHash = global.coinFuncs.blobTypeDero(blob_type_num) ? rpcResult.result.blid : - ( global.coinFuncs.blobTypeRaven(blob_type_num) ? resultHash.toString('hex') : + ( global.coinFuncs.blobTypeRaven(blob_type_num) ? reverseBuffer(resultHash).toString('hex') : global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex') ); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + From 6a2c0d6495b088d78c49bda00c91e14571c73196 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 Dec 2020 02:47:45 +0000 Subject: [PATCH 1143/1496] Simplified block addition --- manage_scripts/altblock_add.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/manage_scripts/altblock_add.js b/manage_scripts/altblock_add.js index cb24f186b..e19b27fe9 100644 --- a/manage_scripts/altblock_add.js +++ b/manage_scripts/altblock_add.js @@ -24,18 +24,18 @@ require("../init_mini.js").init(function() { const body3 = { "hash": body2.hash, "difficulty": body2.difficulty, - "shares": body2.shares, - "timestamp": body2.timestamp, - "poolType": body2.poolType, - "unlocked": body2.unlocked, - "valid": body2.valid, "port": body2.port, "height": body2.height, - "anchor_height": body2.anchor_height, "value": body2.value, - "pay_value": body2.pay_value, - "pay_stage": body2.pay_stage, - "pay_status": body2.pay_status + "anchor_height": body2.anchor_height, + "timestamp": timestamp * 1000, + "shares": body2.shares || body2.difficulty, + "poolType": body2.poolType || 0, + "unlocked": body2.unlocked || false, + "valid": body2.valid || true, + "pay_value": body2.pay_value || 0, + "pay_stage": body2.pay_stage || "", + "pay_status": body2.pay_status || "" }; if (typeof (body3.hash) === 'undefined' || typeof (body3.difficulty) === 'undefined' || From 7b8d4c2b486692fe165cbc7222207d61e5d6c303 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Dec 2020 20:04:52 +0000 Subject: [PATCH 1144/1496] Serialize block and altblock unlocking to avoid OOM --- lib/blockManager.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index bff4ddaa4..d4478330e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -603,11 +603,10 @@ function calculateSoloPayments(blockHeader) { let payReadyBlockHashCalc = {}; -function blockUnlocker() { +function blockUnlocker(blockUnlockerCB) { if (is_full_stop) { debug("Dropping all block unlocks"); - setTimeout(blockUnlocker, 2*60*1000); - return; + return blockUnlockerCB(); } // if (scanInProgress) { // debug("Skipping block unlocker run as there's a scan in progress"); @@ -615,16 +614,14 @@ function blockUnlocker() { // } if (paymentInProgress) { console.error("Skipping block unlocker run as there's a payment in progress"); - setTimeout(blockUnlocker, 2*60*1000); - return; + return blockUnlockerCB(); } console.log("Running block unlocker"); let blockList = global.database.getValidLockedBlocks(); global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { console.error("Last block header request failed!"); - setTimeout(blockUnlocker, 2*60*1000); - return; + return blockUnlockerCB(); } const topBlockHeight = body.height; async.eachSeries(blockList, function(block, next) { @@ -657,16 +654,15 @@ function blockUnlocker() { } }); }, function() { - setTimeout(blockUnlocker, 2*60*1000); + return blockUnlockerCB(); }); }); } -function altblockUnlocker() { +function altblockUnlocker(altblockUnlockerCB) { if (is_full_stop) { debug("Dropping all altblock unlocks"); - setTimeout(altblockUnlocker, 2*60*1000); - return; + return altblockUnlockerCB(); } // if (scanInProgress) { // debug("Skipping altblock unlocker run as there's a scan in progress"); @@ -675,8 +671,7 @@ function altblockUnlocker() { // } if (paymentInProgress) { console.error("Skipping altblock unlocker run as there's a payment in progress"); - setTimeout(altblockUnlocker, 2*60*1000); - return; + return altblockUnlockerCB(); } let blockList = global.database.getValidLockedAltBlocks(); console.log("Running altblock unlocker for " + blockList.length + " blocks"); @@ -684,8 +679,7 @@ function altblockUnlocker() { global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { console.error("Last block header request failed!"); - setTimeout(altblockUnlocker, 2*60*1000); - return; + return altblockUnlockerCB(); } const topBlockHeight = body.height; async.eachSeries(blockList, function(block, next) { @@ -741,7 +735,7 @@ function altblockUnlocker() { for (let port in blockHeightWait) { console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); } - setTimeout(altblockUnlocker, 2*60*1000); + return altblockUnlockerCB(); }); }); } @@ -894,5 +888,10 @@ function altblockPayments(block, cb) { //initial_sync(); -blockUnlocker(); -altblockUnlocker(); \ No newline at end of file +function blockUnlockerNext() { + altblockUnlocker(function() { + setTimeout(blockUnlocker, 2*60*1000, blockUnlockerNext); + }); +} + +blockUnlocker(blockUnlockerNext); From 9fe0419340b48bda4a2f43c28ecc4349c888912a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 27 Dec 2020 04:53:13 +0000 Subject: [PATCH 1145/1496] Added RVN nicehash support --- lib/pool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4385edeec..62e7e0ecc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1102,7 +1102,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (this.protocol == "grin") { return this.pushMessage({method: "getjobtemplate", result: job}); } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - return this.pushMessage({method: "mining.notify", params: job}); + this.pushMessage({method: "mining.set_target", params: [ job[3] ]}); + return this.pushMessage({method: "mining.notify", params: job, id:null}); } else { return this.pushMessage({method: "job", params: job}); } @@ -1781,7 +1782,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } case 'mining.subscribe': { // eth (raven) only - sendReply(null, [ null, "" ]); // empty extranonce (extra once is specificed in coinbase tx) + sendReply(null, [ null, "00" ]); // empty extranonce (extra once is specificed in coinbase tx) break; } From e43f89472703f7e077bc0ac64c48834b72fc7665 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 27 Dec 2020 07:38:25 +0000 Subject: [PATCH 1146/1496] Removed extra debug output --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ea748b03..7209e79b8 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.17", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.18", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" } } From d27261b43c641b72bad99ef0984ff47de9b1339d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 31 Dec 2020 17:13:15 +0000 Subject: [PATCH 1147/1496] Updated monero daemon version --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index bcce4deff..812d5fbd1 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.7 +sudo git checkout v0.17.1.8 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 645ff8804..90318cf26 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.7 +sudo git checkout v0.17.1.8 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 551038759..bb2204447 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.7 +sudo git checkout v0.17.1.8 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 18443b2e7..c58a83183 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.7 &&\ +sudo git checkout v0.17.1.8 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From a2c65e14d268ecc7b829a3f4d211fbaed4069558 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 4 Jan 2021 20:05:27 +0000 Subject: [PATCH 1148/1496] Added RVN nicehash support --- lib/pool.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 62e7e0ecc..12298171b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -28,6 +28,13 @@ function get_new_id() { return id.toString(); }; +function get_new_rvn_id() { + const min = 0x1000; + const max = 0xFFFF; + const id = Math.floor(Math.random() * (max - min + 1)) + min; + return id.toString(16); +}; + let bannedIPs = {}; let bannedAddresses = {}; let notifyAddresses = {}; @@ -1019,9 +1026,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (!this.proxy) { const blob = bt.nextBlob(); if (!blob) return null; + const isGrin = global.coinFuncs.blobTypeGrin(blob_type_num); + const isRvn = !is_grin && global.coinFuncs.blobTypeRaven(blob_type_num); const blob_hex = blob.toString('hex'); const newJob = { - id: get_new_id(), + id: isRvn ? get_new_rvn_id() : get_new_id(), coin: coin, blob_type_num: blob_type_num, blockHash: bt.idHash, @@ -1033,7 +1042,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi submissions: {} }; this.validJobs.enq(newJob); - if (global.coinFuncs.blobTypeGrin(blob_type_num)) this.cachedJob = { + if (isGrin) this.cachedJob = { pre_pow: blob_hex, algo: this.protocol === "grin" ? "cuckaroo" : params.algo_name, edgebits: 29, @@ -1043,7 +1052,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi job_id: newJob.id, difficulty: this.difficulty, id: this.id - }; else if (global.coinFuncs.blobTypeRaven(blob_type_num)) this.cachedJob = [ + }; else if (isRvn) this.cachedJob = [ newJob.id, blob_hex, bt.seed_hash, From 14a8be46a9ae77144216604f78475a8c259afee1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jan 2021 16:58:40 +0000 Subject: [PATCH 1149/1496] Updated monero daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 812d5fbd1..962df87e5 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.8 +sudo git checkout v0.17.1.9 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 90318cf26..952fa8097 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.8 +sudo git checkout v0.17.1.9 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index bb2204447..a4562d8a7 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.8 +sudo git checkout v0.17.1.9 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index c58a83183..e77085de9 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.8 &&\ +sudo git checkout v0.17.1.9 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From c73f3304955eb76e36016cc938c29410bfe1e5f4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jan 2021 17:28:49 +0000 Subject: [PATCH 1150/1496] Typo fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 12298171b..da57cd622 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1027,7 +1027,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const blob = bt.nextBlob(); if (!blob) return null; const isGrin = global.coinFuncs.blobTypeGrin(blob_type_num); - const isRvn = !is_grin && global.coinFuncs.blobTypeRaven(blob_type_num); + const isRvn = !isGrin && global.coinFuncs.blobTypeRaven(blob_type_num); const blob_hex = blob.toString('hex'); const newJob = { id: isRvn ? get_new_rvn_id() : get_new_id(), From 5236200b3c17d34768655e2aaf666b48ff187dd3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jan 2021 18:14:15 +0000 Subject: [PATCH 1151/1496] Fix for RVN orphan detection --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index d4478330e..aca2833d5 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -705,7 +705,7 @@ function altblockUnlocker(altblockUnlockerCB) { if (block.pay_value !== 0) { console.log(block.port + ": " + block.hash); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { - if (body.topoheight && body.topoheight === -1) { + if ((body.topoheight && body.topoheight === -1) || body.confirmations === -1) { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); return next(); From b90ae1273093a00c7bfed473fa861654f9d0f449 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jan 2021 18:19:00 +0000 Subject: [PATCH 1152/1496] Added script to remove block --- manage_scripts/altblock_del.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 manage_scripts/altblock_del.js diff --git a/manage_scripts/altblock_del.js b/manage_scripts/altblock_del.js new file mode 100644 index 000000000..d884296ec --- /dev/null +++ b/manage_scripts/altblock_del.js @@ -0,0 +1,17 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.timestamp) { + console.error("Please specify altblock time"); + process.exit(1); +} +const timestamp = argv.timestamp; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn(); + txn.del(global.database.altblockDB, timestamp); + txn.commit(); + console.log("Altblock with " + timestamp + " timestamp removed! Exiting!"); + process.exit(0); +}); From fb3ef6a9659d1ff7521792005bcd59915f09196a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jan 2021 19:45:07 +0000 Subject: [PATCH 1153/1496] Added api rate limiter --- lib/api.js | 7 +++++++ package.json | 1 + 2 files changed, 8 insertions(+) diff --git a/lib/api.js b/lib/api.js index 7af69f90f..a7bed18d1 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,6 +1,7 @@ "use strict"; const express = require('express'); // call express const apicache = require('apicache'); +const rateLimit = require('express-rate-limit') const app = express(); // define our app using express const cache = apicache.middleware; const server = require('http').createServer(app); @@ -36,6 +37,12 @@ app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); +app.set('trust proxy', 1); +app.use(rateLimit({ + windowMs: 15 * 60 * 1000, // 15 minutes + max: 1000 // limit each IP to 100 requests per windowMs +})); + function get_identifiers(address) { return global.database.getCache('identifiers:' + address); } diff --git a/package.json b/package.json index 7209e79b8..ede2f1ed2 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "debug": "2.6.9", "express": "4.14.0", "apicache": "1.2.1", + "express-rate-limit": "5.2.3", "jsonwebtoken": "^7.2.1", "minimist": ">=1.2.3", "moment": "2.21.0", From c1098cbeb2449e16fccaeb2bb3d6094ecf5608b4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 Jan 2021 22:55:00 +0000 Subject: [PATCH 1154/1496] Reduced API call limit --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index a7bed18d1..abf423e99 100644 --- a/lib/api.js +++ b/lib/api.js @@ -40,7 +40,7 @@ app.use(bodyParser.json()); app.set('trust proxy', 1); app.use(rateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes - max: 1000 // limit each IP to 100 requests per windowMs + max: 500 // limit each IP to 500 requests per time window })); function get_identifiers(address) { From f706ba2d7623fda90de3d203354c51457b064cc1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 15 Jan 2021 04:03:45 +0000 Subject: [PATCH 1155/1496] Ethash support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ede2f1ed2..161c9419d 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.18", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v22.1.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.0.0" } } From 745cc2d6659b06513351552ce95bc9fc28b9d6d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Jan 2021 23:18:26 +0000 Subject: [PATCH 1156/1496] Eth draft support --- lib/coins/xmr.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index afa6eaf12..7fd631e47 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -43,6 +43,7 @@ const port2coin = { "18181": "XMC", "16000": "CCX", "8766" : "RVN", + "8545" : "ETH", }; const port2blob_num = { "11181": 7, // AEON @@ -68,6 +69,7 @@ const port2blob_num = { "16000": 0, // CCX "20206": 100, // DERO "8766" : 101, // RVN + "8545" : 102, // ETH }; const port2algo = { @@ -195,6 +197,14 @@ setInterval(function(queue_obj){ } }, 30*1000, shareVerifyQueue); +function calcEthReward(txs) { + let fee = 0; + txs.forEach(function(tx) { + fee += parseInt(Number(tx.gas), 10) * parseInt(Number(tx.gasPrice), 10); + }); + return 2 + fee / 1000000000000000000; +} + function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; @@ -263,6 +273,15 @@ function Coin(data){ } return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); + } else if (port == 8545) { + global.support.rpcPortDaemon2(port, '', { method: 'eth_getBlockByNumber', params: [ "0x" + blockId.toString(16), true ] }, function (body) { + if (!body || !body.result) { + console.error(JSON.stringify(body)); + return callback(true, body); + } + body.result.reward = calcEthReward(body.result.transactions); + return callback(null, body.result); + }); } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { if (body && body.hasOwnProperty('result')) { @@ -299,6 +318,15 @@ function Coin(data){ body.result.reward = 5000 * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 return callback(null, body.result); }); + } else if (port == 8545) { + global.support.rpcPortDaemon2(port, '', { method: 'eth_getBlockByHash', params: [ blockHash, true ] }, function (body) { + if (!body || !body.result) { + console.error(JSON.stringify(body)); + return callback(true, body); + } + body.result.reward = calcEthReward(body.result.transactions); + return callback(null, body.result); + }); } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || From 937b1af0f5baf5e3ee963df7f67d057c748a6c98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Jan 2021 23:59:16 +0000 Subject: [PATCH 1157/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7fd631e47..48634cd83 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -319,7 +319,7 @@ function Coin(data){ return callback(null, body.result); }); } else if (port == 8545) { - global.support.rpcPortDaemon2(port, '', { method: 'eth_getBlockByHash', params: [ blockHash, true ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); From 0beb468df50cf2af740b9bea6762926c1a671dfb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 00:03:54 +0000 Subject: [PATCH 1158/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 48634cd83..ee7e5ce4f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -319,7 +319,7 @@ function Coin(data){ return callback(null, body.result); }); } else if (port == 8545) { - global.support.rpcPortDaemon2(port, '', { method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); From 90a3e36dfaf66b8c9283fd4dc84c88f9eaefd8e0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 00:04:45 +0000 Subject: [PATCH 1159/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ee7e5ce4f..00f1f2753 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -319,7 +319,7 @@ function Coin(data){ return callback(null, body.result); }); } else if (port == 8545) { - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); From 9f75661f56f5cbda564693c562a956d9ac31dec6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 00:10:04 +0000 Subject: [PATCH 1160/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 00f1f2753..918589037 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -200,7 +200,7 @@ setInterval(function(queue_obj){ function calcEthReward(txs) { let fee = 0; txs.forEach(function(tx) { - fee += parseInt(Number(tx.gas), 10) * parseInt(Number(tx.gasPrice), 10); + fee += parseInt(Number(tx.gas), 16) * parseInt(Number(tx.gasPrice), 16); }); return 2 + fee / 1000000000000000000; } From ca10a7423aff0e5e5a783174448a70f1ffa310b0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 00:12:49 +0000 Subject: [PATCH 1161/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 918589037..afa75f1dd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -200,7 +200,7 @@ setInterval(function(queue_obj){ function calcEthReward(txs) { let fee = 0; txs.forEach(function(tx) { - fee += parseInt(Number(tx.gas), 16) * parseInt(Number(tx.gasPrice), 16); + fee += parseInt(tx.gas) * parseInt(tx.gasPrice); }); return 2 + fee / 1000000000000000000; } From 1b99ca6174cd5377039cf95a1391df9b2a568a83 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 00:42:48 +0000 Subject: [PATCH 1162/1496] Eth draft support --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index afa75f1dd..204e024d5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -200,9 +200,9 @@ setInterval(function(queue_obj){ function calcEthReward(txs) { let fee = 0; txs.forEach(function(tx) { - fee += parseInt(tx.gas) * parseInt(tx.gasPrice); + fee += parseInt(tx.gas) * parseInt(tx.gasPrice) / 1000000000000000000; }); - return 2 + fee / 1000000000000000000; + return 2 + fee; } function Coin(data){ From aece2626295d4cd5ab367bd400bc152f07f781e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 01:23:31 +0000 Subject: [PATCH 1163/1496] Eth draft support --- lib/coins/xmr.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 204e024d5..ac394e388 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -197,12 +197,17 @@ setInterval(function(queue_obj){ } }, 30*1000, shareVerifyQueue); -function calcEthReward(txs) { +function calcEthReward(block) { + let max_gas_sum = 0; + block.transactions.forEach(function(tx) { + max_gas_sum += parseInt(tx.gas); + }); + const gas_factor = block.gasUsed / max_gas_sum; let fee = 0; - txs.forEach(function(tx) { - fee += parseInt(tx.gas) * parseInt(tx.gasPrice) / 1000000000000000000; + block.transactions.forEach(function(tx) { + fee += parseInt(tx.gas) * gas_factor * parseInt(tx.gasPrice); }); - return 2 + fee; + return 2 + fee / 1000000000000000000; } function Coin(data){ @@ -279,7 +284,7 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - body.result.reward = calcEthReward(body.result.transactions); + body.result.reward = calcEthReward(body.result); return callback(null, body.result); }); } else { From 433fddd5e518b05e148de2244d31409b7e8b9cf0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 01:29:04 +0000 Subject: [PATCH 1164/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ac394e388..91a31c4b2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -329,7 +329,7 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - body.result.reward = calcEthReward(body.result.transactions); + body.result.reward = calcEthReward(body.result); return callback(null, body.result); }); } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { From 82b9902fe855d2fc8b88fecc4ae7493db736b93d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 01:30:45 +0000 Subject: [PATCH 1165/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 91a31c4b2..ddab1e5b5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -202,7 +202,7 @@ function calcEthReward(block) { block.transactions.forEach(function(tx) { max_gas_sum += parseInt(tx.gas); }); - const gas_factor = block.gasUsed / max_gas_sum; + const gas_factor = block.gasLimit / max_gas_sum; let fee = 0; block.transactions.forEach(function(tx) { fee += parseInt(tx.gas) * gas_factor * parseInt(tx.gasPrice); From 50329542843641dfe531c8410296a4d7085957fa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:02:59 +0000 Subject: [PATCH 1166/1496] Eth draft support --- lib/coins/xmr.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ddab1e5b5..93115b887 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -197,17 +197,12 @@ setInterval(function(queue_obj){ } }, 30*1000, shareVerifyQueue); -function calcEthReward(block) { - let max_gas_sum = 0; - block.transactions.forEach(function(tx) { - max_gas_sum += parseInt(tx.gas); - }); - const gas_factor = block.gasLimit / max_gas_sum; +function calcEthReward(block, tx_reciepts) { let fee = 0; - block.transactions.forEach(function(tx) { - fee += parseInt(tx.gas) * gas_factor * parseInt(tx.gasPrice); + tx_reciepts.forEach(function(tx) { + fee += parseInt(tx.gasUsed) * parseInt(tx.gasPrice); }); - return 2 + fee / 1000000000000000000; + return 2 + block.uncles.length / 32 + fee / 1000000000000000000; } function Coin(data){ @@ -284,8 +279,14 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - body.result.reward = calcEthReward(body.result); - return callback(null, body.result); + global.support.rpcPortDaemon2(port, '', { method: 'parity_getBlockReceipts', params: [ "0x" + blockId.toString(16) ] }, function (body2) { + if (!body2 || !body2.result) { + console.error(JSON.stringify(body2)); + return callback(true, body2); + } + body.result.reward = calcEthReward(body.result. body2); + return callback(null, body.result); + }); }); } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { @@ -329,8 +330,14 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - body.result.reward = calcEthReward(body.result); - return callback(null, body.result); + global.support.rpcPortDaemon2(port, '', { method: 'parity_getBlockReceipts', params: [ body.number ] }, function (body2) { + if (!body2 || !body2.result) { + console.error(JSON.stringify(body2)); + return callback(true, body2); + } + body.result.reward = calcEthReward(body.result. body2); + return callback(null, body.result); + }); }); } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { From f7b6933a57d861acb872271c7ba8b67665acd2e6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:04:11 +0000 Subject: [PATCH 1167/1496] Eth draft support --- lib/coins/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 93115b887..697040eb0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -274,12 +274,12 @@ function Coin(data){ return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); } else if (port == 8545) { - global.support.rpcPortDaemon2(port, '', { method: 'eth_getBlockByNumber', params: [ "0x" + blockId.toString(16), true ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'eth_getBlockByNumber', params: [ "0x" + blockId.toString(16), true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { method: 'parity_getBlockReceipts', params: [ "0x" + blockId.toString(16) ] }, function (body2) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ "0x" + blockId.toString(16) ] }, function (body2) { if (!body2 || !body2.result) { console.error(JSON.stringify(body2)); return callback(true, body2); @@ -330,7 +330,7 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { method: 'parity_getBlockReceipts', params: [ body.number ] }, function (body2) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ body.number ] }, function (body2) { if (!body2 || !body2.result) { console.error(JSON.stringify(body2)); return callback(true, body2); From 70ad0685325eeefea626133ce812fd08a8335ace Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:04:51 +0000 Subject: [PATCH 1168/1496] Eth draft support --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 697040eb0..54efdfacb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -284,7 +284,7 @@ function Coin(data){ console.error(JSON.stringify(body2)); return callback(true, body2); } - body.result.reward = calcEthReward(body.result. body2); + body.result.reward = calcEthReward(body.result. body2.result); return callback(null, body.result); }); }); @@ -335,7 +335,7 @@ function Coin(data){ console.error(JSON.stringify(body2)); return callback(true, body2); } - body.result.reward = calcEthReward(body.result. body2); + body.result.reward = calcEthReward(body.result. body2.result); return callback(null, body.result); }); }); From 460216c745ecff55149ebb887210572e165cede6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:05:12 +0000 Subject: [PATCH 1169/1496] Eth draft support --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 54efdfacb..e685cfc0b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -284,7 +284,7 @@ function Coin(data){ console.error(JSON.stringify(body2)); return callback(true, body2); } - body.result.reward = calcEthReward(body.result. body2.result); + body.result.reward = calcEthReward(body.result, body2.result); return callback(null, body.result); }); }); @@ -335,7 +335,7 @@ function Coin(data){ console.error(JSON.stringify(body2)); return callback(true, body2); } - body.result.reward = calcEthReward(body.result. body2.result); + body.result.reward = calcEthReward(body.result, body2.result); return callback(null, body.result); }); }); From f3c5ffc5d7c494b2255bcec9eeb55e9d2261a307 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:07:46 +0000 Subject: [PATCH 1170/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e685cfc0b..1adab2c0e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -330,7 +330,7 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ body.number ] }, function (body2) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ body.result.number ] }, function (body2) { if (!body2 || !body2.result) { console.error(JSON.stringify(body2)); return callback(true, body2); From f10dd16e89328d0ced6f98e68e618e74757dc8d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:13:47 +0000 Subject: [PATCH 1171/1496] Eth draft support --- lib/coins/xmr.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1adab2c0e..fc5feb553 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -198,9 +198,12 @@ setInterval(function(queue_obj){ }, 30*1000, shareVerifyQueue); function calcEthReward(block, tx_reciepts) { - let fee = 0; + let gas_prices = {}; + block.transactions.forEach(function(tx) { + gas_prices[tx.hash] = parseInt(tx.gasPrice); + }); tx_reciepts.forEach(function(tx) { - fee += parseInt(tx.gasUsed) * parseInt(tx.gasPrice); + fee += parseInt(tx.gasUsed) * gas_prices[tx.transactionHash]; }); return 2 + block.uncles.length / 32 + fee / 1000000000000000000; } From cc08e24895dac3567a03fcfefb703a486c8d4766 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:14:13 +0000 Subject: [PATCH 1172/1496] Eth draft support --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index fc5feb553..3cba55f05 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -202,6 +202,7 @@ function calcEthReward(block, tx_reciepts) { block.transactions.forEach(function(tx) { gas_prices[tx.hash] = parseInt(tx.gasPrice); }); + let fee = 0; tx_reciepts.forEach(function(tx) { fee += parseInt(tx.gasUsed) * gas_prices[tx.transactionHash]; }); From f28add41fa2bfe397ce4ba6e0372fc866bb0ad82 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 02:34:10 +0000 Subject: [PATCH 1173/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3cba55f05..ea782bc10 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -206,7 +206,7 @@ function calcEthReward(block, tx_reciepts) { tx_reciepts.forEach(function(tx) { fee += parseInt(tx.gasUsed) * gas_prices[tx.transactionHash]; }); - return 2 + block.uncles.length / 32 + fee / 1000000000000000000; + return (2 + 2 * (block.uncles.length / 32)) * 1000000000000000000 + fee; } function Coin(data){ From 224b8292a768ffe7944d18892e432276cb1ed108 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 17:31:25 +0000 Subject: [PATCH 1174/1496] Eth draft support --- lib/coins/xmr.js | 16 ++++++++++++++-- lib/pool.js | 23 +++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ea782bc10..f88cc76d1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -96,6 +96,7 @@ const port2algo = { "18181": "cn/0", // XMC "16000": "cn/gpu", // CCX "8766" : "kawpow", // RVN + "8545" : "ethash", // ETH }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -278,12 +279,13 @@ function Coin(data){ return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); } else if (port == 8545) { - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'eth_getBlockByNumber', params: [ "0x" + blockId.toString(16), true ] }, function (body) { + const blockId2 = blockId === "latest" ? blockId : "0x" + blockId.toString(16); + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'eth_getBlockByNumber', params: [ blockId2, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ "0x" + blockId.toString(16) ] }, function (body2) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ blockId2 ] }, function (body2) { if (!body2 || !body2.result) { console.error(JSON.stringify(body2)); return callback(true, body2); @@ -428,6 +430,8 @@ function Coin(data){ } return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); + } else if (port == 8545) { + return this.getPortBlockHeaderByID(port, "latest", callback); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ @@ -452,6 +456,7 @@ function Coin(data){ }, function(body) { return callback(body ? body : null); }); + } else if (port == 8766) { global.support.rpcPortDaemon2(port, '', { method: 'getblocktemplate', @@ -463,6 +468,11 @@ function Coin(data){ return callback(body && body.result ? cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()]) : null); }); + } else if (port == 8545) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: "eth_getWork", "params": [] }, function(body) { + return callback(body && body.result ? cnUtil.EthBlockTemplate(body.result) : null); + }); + } else { global.support.rpcPortDaemon(port, 'getblocktemplate', { reserve_size: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size, @@ -774,6 +784,7 @@ function Coin(data){ this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN + case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // ETH case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL @@ -847,6 +858,7 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { + case 8545: return "eth"; // ETH case 8766: return "raven"; // RVN case 9231 : return "cryptonote_loki"; // XEQ case 11181: return "aeon"; // Aeon diff --git a/lib/pool.js b/lib/pool.js index da57cd622..d18d34fe2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -83,7 +83,7 @@ if (cluster.isMaster) { throttledShares = 0; }, 30*1000); } else { - threadName = "(Worker " + cluster.worker.id + " - " + process.pid + ") "; + threadName = "(Worker " + cluster.worker.id2 + " - " + process.pid + ") "; // reset last verified share counters every VER_SHARES_PERIOD seconds setInterval(function () { for (let wallet in minerWallets) { @@ -204,7 +204,7 @@ function retargetMiners() { } const elapsed = Date.now() - time_before; if (elapsed > 50) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); - process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id, ports: minerCount } }); + process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id2, ports: minerCount } }); } // wallet " " proxy miner name -> { connectTime, count (miner), hashes } @@ -512,7 +512,7 @@ let walletTrust = {}; // wallet last seen time (all wallets that are not detected for more than 1 day are removed) let walletLastSeeTime = {}; -// miner agent strings (for cluster.worker.id == 1) +// miner agent strings (for cluster.worker.id2 == 1) let minerAgents = {}; var reEmail = /^\S+@\S+\.\S+$/; @@ -1720,7 +1720,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); - if (params.agent && cluster.worker.id == 1) minerAgents[params.agent] = 1; + if (params.agent && cluster.worker.id2 == 1) minerAgents[params.agent] = 1; let time_now = Date.now(); if (!miner.valid_miner) { if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { @@ -2037,7 +2037,7 @@ if (global.config.general.allowStuckPoolKill && fs.existsSync("block_template_is } setInterval(function dump_vars() { - const fn = "dump" + (cluster.isMaster ? "" : "_" + cluster.worker.id.toString()); + const fn = "dump" + (cluster.isMaster ? "" : "_" + cluster.worker.id2.toString()); fs.access(fn, fs.F_OK, function(err) { if (!err) return; console.log("DUMPING VARS TO " + fn + " FILE"); @@ -2166,6 +2166,7 @@ if (cluster.isMaster) { for (let i = 0; i < numWorkers; i++) { let worker = cluster.fork(); + worker.id2 = worker.id; worker.on('message', messageHandler); } @@ -2176,10 +2177,12 @@ if (cluster.isMaster) { cluster.on('exit', function (worker, code, signal) { console.error('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal); console.log('Starting a new worker'); + const prev_id = worker.id; worker = cluster.fork(); + worker.id2 = prev_id; worker.on('message', messageHandler); - global.support.sendEmail(global.config.general.adminEmail, "FYI: Started new worker " + worker.id, - "Hello,\r\nMaster thread of " + global.config.hostname + " starts new worker with id " + worker.id); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Started new worker " + worker.id2, + "Hello,\r\nMaster thread of " + global.config.hostname + " starts new worker with id " + worker.id2); }); @@ -2301,10 +2304,10 @@ if (cluster.isMaster) { delete walletLastSeeTime[wallet]; } } - const fn = "wallet_trust_" + cluster.worker.id.toString(); + const fn = "wallet_trust_" + cluster.worker.id2.toString(); fs.writeFile(fn, str, function(err) { if (err) console.error("Error saving " + fn + " file"); }); - if (cluster.worker.id == 1) { + if (cluster.worker.id2 == 1) { let str2 = ""; for (let agent in minerAgents) { str2 += agent + "\n"; } const fn2 = "miner_agents"; @@ -2328,7 +2331,7 @@ if (cluster.isMaster) { console.log("WILL EXTRA CHECK WALLET: '" + line + "'"); extra_wallet_verify[line] = 1; }); - const fn = "extra_verify_wallet_hashes_" + cluster.worker.id.toString(); + const fn = "extra_verify_wallet_hashes_" + cluster.worker.id2.toString(); fs.writeFile(fn, extra_verify_wallet_hashes.join("\n"), function(err) { if (err) console.error("Error saving " + fn + " file"); }); extra_verify_wallet_hashes = []; }); From 70736e5cc61d0b29d91aa50935368509ac37de9a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 17:47:07 +0000 Subject: [PATCH 1175/1496] Eth draft support --- lib/pool.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d18d34fe2..5a8e5ab79 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -83,7 +83,7 @@ if (cluster.isMaster) { throttledShares = 0; }, 30*1000); } else { - threadName = "(Worker " + cluster.worker.id2 + " - " + process.pid + ") "; + threadName = "(Worker " + process.env['WORKER_ID'] + " - " + process.pid + ") "; // reset last verified share counters every VER_SHARES_PERIOD seconds setInterval(function () { for (let wallet in minerWallets) { @@ -204,7 +204,7 @@ function retargetMiners() { } const elapsed = Date.now() - time_before; if (elapsed > 50) console.error(threadName + "retargetMiners() consumed " + elapsed + " ms for " + activeMiners.size + " miners"); - process.send({type: 'minerPortCount', data: { worker_id: cluster.worker.id2, ports: minerCount } }); + process.send({type: 'minerPortCount', data: { worker_id: process.env['WORKER_ID'], ports: minerCount } }); } // wallet " " proxy miner name -> { connectTime, count (miner), hashes } @@ -512,7 +512,7 @@ let walletTrust = {}; // wallet last seen time (all wallets that are not detected for more than 1 day are removed) let walletLastSeeTime = {}; -// miner agent strings (for cluster.worker.id2 == 1) +// miner agent strings (for process.env['WORKER_ID'] == 1) let minerAgents = {}; var reEmail = /^\S+@\S+\.\S+$/; @@ -1720,7 +1720,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); - if (params.agent && cluster.worker.id2 == 1) minerAgents[params.agent] = 1; + if (params.agent && process.env['WORKER_ID'] == 1) minerAgents[params.agent] = 1; let time_now = Date.now(); if (!miner.valid_miner) { if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { @@ -2037,7 +2037,7 @@ if (global.config.general.allowStuckPoolKill && fs.existsSync("block_template_is } setInterval(function dump_vars() { - const fn = "dump" + (cluster.isMaster ? "" : "_" + cluster.worker.id2.toString()); + const fn = "dump" + (cluster.isMaster ? "" : "_" + process.env['WORKER_ID'].toString()); fs.access(fn, fs.F_OK, function(err) { if (!err) return; console.log("DUMPING VARS TO " + fn + " FILE"); @@ -2165,8 +2165,7 @@ if (cluster.isMaster) { console.log('Master cluster setting up ' + numWorkers + ' workers...'); for (let i = 0; i < numWorkers; i++) { - let worker = cluster.fork(); - worker.id2 = worker.id; + let worker = cluster.fork({ WORKER_ID: i + 1 }); worker.on('message', messageHandler); } @@ -2177,12 +2176,11 @@ if (cluster.isMaster) { cluster.on('exit', function (worker, code, signal) { console.error('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal); console.log('Starting a new worker'); - const prev_id = worker.id; - worker = cluster.fork(); - worker.id2 = prev_id; + const prev_worker_id = worker.id; + worker = cluster.fork({ WORKER_ID: prev_worker_id }); worker.on('message', messageHandler); - global.support.sendEmail(global.config.general.adminEmail, "FYI: Started new worker " + worker.id2, - "Hello,\r\nMaster thread of " + global.config.hostname + " starts new worker with id " + worker.id2); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Started new worker " + prev_worker_id, + "Hello,\r\nMaster thread of " + global.config.hostname + " starts new worker with id " + prev_worker_id); }); @@ -2304,10 +2302,10 @@ if (cluster.isMaster) { delete walletLastSeeTime[wallet]; } } - const fn = "wallet_trust_" + cluster.worker.id2.toString(); + const fn = "wallet_trust_" + process.env['WORKER_ID'].toString(); fs.writeFile(fn, str, function(err) { if (err) console.error("Error saving " + fn + " file"); }); - if (cluster.worker.id2 == 1) { + if (process.env['WORKER_ID'] == 1) { let str2 = ""; for (let agent in minerAgents) { str2 += agent + "\n"; } const fn2 = "miner_agents"; @@ -2331,7 +2329,7 @@ if (cluster.isMaster) { console.log("WILL EXTRA CHECK WALLET: '" + line + "'"); extra_wallet_verify[line] = 1; }); - const fn = "extra_verify_wallet_hashes_" + cluster.worker.id2.toString(); + const fn = "extra_verify_wallet_hashes_" + process.env['WORKER_ID'].toString(); fs.writeFile(fn, extra_verify_wallet_hashes.join("\n"), function(err) { if (err) console.error("Error saving " + fn + " file"); }); extra_verify_wallet_hashes = []; }); From 07e1ca1c6c6689e13d34acacadc042e1b97deb46 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 19:44:31 +0000 Subject: [PATCH 1176/1496] Eth draft support --- deployment/base.sql | 7 +++++++ lib/pool.js | 33 ++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 06db036d3..866fad984 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -98,6 +98,13 @@ CREATE TABLE `pools` ( PRIMARY KEY (`id`), UNIQUE KEY `pools_id_uindex` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `pool_workers` ( + `id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT, + `pool_id` int(11) NOT NULL, + `worker_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `pool_workers_id_uindex` (`pool_id`, `worker_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `port_config` ( `poolPort` int(11) NOT NULL, `difficulty` int(11) DEFAULT '1000', diff --git a/lib/pool.js b/lib/pool.js index 5a8e5ab79..e64672ab8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2089,6 +2089,24 @@ setInterval(function dump_vars() { }); }, 60*1000); +let master_cluster_worker_id_map = {}; + +function getUniqueWorkerID(cb) { + global.mysql.query("INSERT INTO pool_workers (pool_id, worker_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE id=id", [global.config.pool_id, process.env['WORKER_ID']], function(err,rows) { + if (err) { + console.error("Can't register unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); + process.exit(1); + } + global.mysql.query("SELECT id FROM pool_workers WHERE pool_id = ? AND worker_id", [global.config.pool_id, process.env['WORKER_ID']]).then(function (rows) { + if (rows.length !== 1) { + console.error("Can't get unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); + process.exit(1); + } + return cb(rows[0].id); + }); + }); +} + if (cluster.isMaster) { const numWorkers = require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { @@ -2165,7 +2183,7 @@ if (cluster.isMaster) { console.log('Master cluster setting up ' + numWorkers + ' workers...'); for (let i = 0; i < numWorkers; i++) { - let worker = cluster.fork({ WORKER_ID: i + 1 }); + let worker = cluster.fork({ WORKER_ID: master_cluster_worker_id_map[i + 1] = i + 1 }); worker.on('message', messageHandler); } @@ -2176,8 +2194,10 @@ if (cluster.isMaster) { cluster.on('exit', function (worker, code, signal) { console.error('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal); console.log('Starting a new worker'); - const prev_worker_id = worker.id; + const prev_worker_id = master_cluster_worker_id_map[worker.id]; + delete master_cluster_worker_id_map[worker.id]; worker = cluster.fork({ WORKER_ID: prev_worker_id }); + master_cluster_worker_id_map[worker.id] = prev_worker_id; worker.on('message', messageHandler); global.support.sendEmail(global.config.general.adminEmail, "FYI: Started new worker " + prev_worker_id, "Hello,\r\nMaster thread of " + global.config.hostname + " starts new worker with id " + prev_worker_id); @@ -2228,10 +2248,13 @@ if (cluster.isMaster) { }); block_notify_server.listen(BLOCK_NOTIFY_PORT, "127.0.0.1", function() { - console.log(threadName + "Blocl notify server on " + BLOCK_NOTIFY_PORT + " port started"); + console.log(threadName + "Block notify server on " + BLOCK_NOTIFY_PORT + " port started"); }); -} else { +} else getUniqueWorkerID(function(uniqueWorkerID) { + + console.log(threadName + "Starting pool worker with " + uniqueWorkerID + " unique id"); + newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; templateUpdate(""); if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { @@ -2475,4 +2498,4 @@ if (cluster.isMaster) { }); } }); -} +}); From eb4b056392811a268c0299afd9bcb727e7ab1ec9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 19:54:10 +0000 Subject: [PATCH 1177/1496] Eth draft support --- lib/pool.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e64672ab8..832262886 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2092,11 +2092,7 @@ setInterval(function dump_vars() { let master_cluster_worker_id_map = {}; function getUniqueWorkerID(cb) { - global.mysql.query("INSERT INTO pool_workers (pool_id, worker_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE id=id", [global.config.pool_id, process.env['WORKER_ID']], function(err,rows) { - if (err) { - console.error("Can't register unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); - process.exit(1); - } + global.mysql.query("INSERT INTO pool_workers (pool_id, worker_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE id=id", [global.config.pool_id, process.env['WORKER_ID']]).then(function() { global.mysql.query("SELECT id FROM pool_workers WHERE pool_id = ? AND worker_id", [global.config.pool_id, process.env['WORKER_ID']]).then(function (rows) { if (rows.length !== 1) { console.error("Can't get unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); @@ -2104,6 +2100,9 @@ function getUniqueWorkerID(cb) { } return cb(rows[0].id); }); + }).catch(function(err) { + console.error("Can't register unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); + process.exit(1); }); } From 4314dd14e9bd798dbd42ae6f0f1496a4604a351d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 20:12:59 +0000 Subject: [PATCH 1178/1496] Eth draft support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 832262886..48f814796 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2093,7 +2093,7 @@ let master_cluster_worker_id_map = {}; function getUniqueWorkerID(cb) { global.mysql.query("INSERT INTO pool_workers (pool_id, worker_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE id=id", [global.config.pool_id, process.env['WORKER_ID']]).then(function() { - global.mysql.query("SELECT id FROM pool_workers WHERE pool_id = ? AND worker_id", [global.config.pool_id, process.env['WORKER_ID']]).then(function (rows) { + global.mysql.query("SELECT id FROM pool_workers WHERE pool_id = ? AND worker_id = ?", [global.config.pool_id, process.env['WORKER_ID']]).then(function (rows) { if (rows.length !== 1) { console.error("Can't get unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); process.exit(1); From 317b8a97c8bbc360e0697f7c8bbe15d94a7a422a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Jan 2021 20:41:54 +0000 Subject: [PATCH 1179/1496] Eth draft support --- lib/pool.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 48f814796..4fdfaff33 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2092,17 +2092,19 @@ setInterval(function dump_vars() { let master_cluster_worker_id_map = {}; function getUniqueWorkerID(cb) { - global.mysql.query("INSERT INTO pool_workers (pool_id, worker_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE id=id", [global.config.pool_id, process.env['WORKER_ID']]).then(function() { - global.mysql.query("SELECT id FROM pool_workers WHERE pool_id = ? AND worker_id = ?", [global.config.pool_id, process.env['WORKER_ID']]).then(function (rows) { - if (rows.length !== 1) { - console.error("Can't get unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); + global.mysql.query("SELECT id FROM pool_workers WHERE pool_id = ? AND worker_id = ?", [global.config.pool_id, process.env['WORKER_ID']]).then(function (rows) { + if (rows.length === 0) { + global.mysql.query("INSERT INTO pool_workers (pool_id, worker_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE id=id", [global.config.pool_id, process.env['WORKER_ID']]).then(function() { + return getUniqueWorkerID(cb); + }).catch(function(err) { + console.error("Can't register unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); process.exit(1); - } - return cb(rows[0].id); - }); - }).catch(function(err) { - console.error("Can't register unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); - process.exit(1); + }); + } else if (rows.length !== 1) { + console.error("Can't get unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); + process.exit(1); + } + return cb(rows[0].id); }); } From 050ccb270ae133497200316ff3112b083827636a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 07:30:06 +0000 Subject: [PATCH 1180/1496] Eth draft support --- lib/coins/xmr.js | 63 +++++++---- lib/pool.js | 284 ++++++++++++++++++++++++++++------------------- package.json | 4 +- 3 files changed, 216 insertions(+), 135 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f88cc76d1..7193a2d46 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -280,12 +280,13 @@ function Coin(data){ }); } else if (port == 8545) { const blockId2 = blockId === "latest" ? blockId : "0x" + blockId.toString(16); - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'eth_getBlockByNumber', params: [ blockId2, true ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByNumber', params: [ blockId2, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ blockId2 ] }, function (body2) { + if (blockId === "latest") return callback(null, body.result); // do not need rewards for the latest block + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ blockId2 ] }, function (body2) { if (!body2 || !body2.result) { console.error(JSON.stringify(body2)); return callback(true, body2); @@ -331,12 +332,12 @@ function Coin(data){ return callback(null, body.result); }); } else if (port == 8545) { - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: 'parity_getBlockReceipts', params: [ body.result.number ] }, function (body2) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ body.result.number ] }, function (body2) { if (!body2 || !body2.result) { console.error(JSON.stringify(body2)); return callback(true, body2); @@ -469,7 +470,7 @@ function Coin(data){ }); } else if (port == 8545) { - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 0, method: "eth_getWork", "params": [] }, function(body) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { return callback(body && body.result ? cnUtil.EthBlockTemplate(body.result) : null); }); @@ -490,9 +491,8 @@ function Coin(data){ this.baseDiff = function() { return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); }; - this.baseRavenDiff = function() { - return parseInt('0x00000000ff000000000000000000000000000000000000000000000000000000'); - }; + this.baseRavenDiff = cnUtil.baseRavenDiff; + this.baseEthDiff = cnUtil.baseEthDiff; this.validatePlainAddress = function(address){ // This function should be able to be called from the async library, as we need to BLOCK ever so slightly to verify the address. @@ -531,20 +531,21 @@ function Coin(data){ this.nonceSize = function(blob_type_num) { switch (blob_type_num) { case 7: - case 101: return 8; + case 101: + case 102: return 8; default: return 4; } } - this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } + this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } this.blobTypeRaven = function(blob_type_num) { return blob_type_num == 101; } - this.targetRavenDiff = function(diff) { return cnUtil.targetRavenDiff(diff); } + this.blobTypeEth = function(blob_type_num) { return blob_type_num == 102; } this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); - if (this.blobTypeDero(blob_type_num)) return blobBuffer; + if (this.blobTypeDero(blob_type_num)) return blobBuffer; let blob; try { if (this.blobTypeRaven(blob_type_num)) { @@ -608,8 +609,7 @@ function Coin(data){ // With up to 4 billion clients (minerNonce/extraNonce) // Overkill? Sure. But that's what we do here. Overkill. - // Set these params equal to values we get from upstream. - this.blocktemplate_blob = template.blocktemplate_blob ? template.blocktemplate_blob : (template.blob ? template.blob : extra_nonce_mm_template_hex); + // Set these params equal to values we get from upstream (if they are set) this.difficulty = template.difficulty; this.height = template.height; this.bits = template.bits; @@ -617,6 +617,24 @@ function Coin(data){ this.coin = template.coin; this.port = template.port; + const port_blob_num = port2blob_num[this.port]; + const is_eth = global.coinFuncs.blobTypeEth(port_blob_num); + + if (template.blocktemplate_blob) { + this.blocktemplate_blob = template.blocktemplate_blob; + } else if (template.blob) { + this.blocktemplate_blob = template.blob; + } else if (is_eth) { + const hash = template.hash; + this.hash = this.idHash = this.prev_hash = hash; + this.block_version = 0; + this.nextBlobHex = function () { return hash; }; + return; + } else { + console.error("INTERNAL ERROR: No blob in " + this.port + " port block template: " + JSON.stringify(template)); + this.blocktemplate_blob = extra_nonce_mm_template_hex; // to avoid hard crash + } + const is_mm = "child_template" in template; if (is_mm) { @@ -624,13 +642,14 @@ function Coin(data){ this.child_template_buffer = template.child_template_buffer; } - const is_dero = global.coinFuncs.blobTypeDero(port2blob_num[this.port]); + const is_dero = global.coinFuncs.blobTypeDero(port_blob_num); const blob = is_dero ? template.blockhashing_blob : (is_mm ? template.parent_blocktemplate_blob : this.blocktemplate_blob); this.idHash = crypto.createHash('md5').update(blob).digest('hex'); // Set this.buffer to the binary decoded version of the BT blob this.buffer = new Buffer(blob, 'hex'); + this.block_version = this.buffer[0]; if (!is_dero) { const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; @@ -665,7 +684,10 @@ function Coin(data){ this.reserved_offset = template.reserved_offset + 1; } - if (!this.reserved_offset) this.reserved_offset = 0; // to avoid hard crash + if (!this.reserved_offset) { + console.error("INTERNAL ERROR: No reserved offset in " + this.port + " port block template: " + JSON.stringify(template)); + this.reserved_offset = 0; // to avoid hard crash + } if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = new Buffer(32); @@ -685,11 +707,12 @@ function Coin(data){ // The clientPoolLocation is for multi-thread/multi-server pools to handle the nonce for each of their tiers. this.clientPoolLocation = this.reserved_offset + 8; - this.nextBlob = function () { + this.nextBlobHex = function () { // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserved_offset); // Convert the buffer into something hashable. - return global.coinFuncs.convertBlob(this.buffer, this.port); + const blob = global.coinFuncs.convertBlob(this.buffer, this.port); + return blob ? blob.toString('hex') : null; }; // Make it so you can get the raw block buffer out. this.nextBlobWithChildNonceHex = function () { @@ -738,6 +761,8 @@ function Coin(data){ if ("kawpow" in algos_perf) coin_perf["RVN"] = algos_perf["kawpow"]; + if ("ethash" in algos_perf) coin_perf["ETH"] = algos_perf["ethash"]; + if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; @@ -784,7 +809,7 @@ function Coin(data){ this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN - case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // ETH + case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL diff --git a/lib/pool.js b/lib/pool.js index 4fdfaff33..56fd5fef8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -17,22 +17,34 @@ const hashCheck32 = new RegExp("^[0-9a-f]{64}$"); const hexMatch = new RegExp("^(?:[0-9a-f][0-9a-f])+$"); const baseDiff = global.coinFuncs.baseDiff(); const baseRavenDiff = global.coinFuncs.baseRavenDiff(); +const baseEthDiff = global.coinFuncs.baseEthDiff(); const BLOCK_NOTIFY_PORT = 2223; const DAEMON_POLL_MS = 500; +const id_min = 100000000000000; +let id = id_min; + function get_new_id() { - const min = 100000000000000; - const max = 999999999999999; - const id = Math.floor(Math.random() * (max - min + 1)) + min; + if (++id > 999999999999999) id = id_min; return id.toString(); }; -function get_new_rvn_id() { - const min = 0x1000; - const max = 0xFFFF; - const id = Math.floor(Math.random() * (max - min + 1)) + min; - return id.toString(16); +const eth_job_id_min = 0x1000; +let eth_job_id = eth_job_id_min; + +function get_new_eth_job_id() { + if (++eth_job_id > 0xFFFF) eth_job_id = eth_job_id_min; + return eth_job_id.toString(16); +}; + +let UNIQUE_WORKER_ID; +const eth_extranonce_id_min = 0x1000; +let eth_extranonce_id = eth_extranonce_id_min; + +function get_new_eth_extranonce_id() { + if (++eth_extranonce_id > 0xFFFF) eth_extranonce_id = eth_extranonce_id_min; + return UNIQUE_WORKER_ID.toString(16) + eth_extranonce_id.toString(16); }; let bannedIPs = {}; @@ -259,13 +271,16 @@ function updateCoinHashFactor(coin) { }); } -function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange) { +function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange, latest_block_body) { let template = Object.assign({}, rpc_template); template.coin = coin; template.port = parseInt(port); template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; + // calc height for eth_getWork + const blob_type_num = global.coinFuncs.portBlobType(template.port); + if (global.coinFuncs.blobTypeEth(blob_type_num)) template.height = parseInt(latest_block_body.number) + 1; if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); @@ -282,14 +297,14 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa } // templateUpdateReal is only called in master thread (except the beginning of a worker thread) -function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { +function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange, latest_block_body) { global.coinFuncs.getPortBlockTemplate(port, function (body_bt) { if (!newCoinHashFactor[coin]) { console.log("Aborting " + port + " last block template request because " + coin + " already has zero hash factor"); return; } if (body_bt) { - const template = process_rpc_template(body_bt, coin, port, coinHashFactor, isHashFactorChange); + const template = process_rpc_template(body_bt, coin, port, coinHashFactor, isHashFactorChange, latest_block_body); debug(threadName + "New block template found at " + template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); @@ -300,7 +315,7 @@ function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.PORT2COIN(parent_port); if (parent_coin in activeBlockTemplates) { - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, lastCoinHashFactor[parent_coin], false); + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, lastCoinHashFactor[parent_coin], false, latest_block_body); sendToWorkers({type: 'newBlockTemplate', data: parent_template}); setNewBlockTemplate(parent_template); } @@ -312,7 +327,7 @@ function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { } else { console.error("Block template request failed for " + port + " port"); coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdateReal, 3000, coin, port, coinHashFactor, isHashFactorChange); + setTimeout(templateUpdateReal, 3000, coin, port, coinHashFactor, isHashFactorChange, latest_block_body); } }); } @@ -340,7 +355,7 @@ function templateUpdate(coin, repeating) { const isHashFactorChange = Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; - templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange); + templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange, body); } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } @@ -381,7 +396,7 @@ function getCoinJobParams(coin) { let params = {}; params.bt = activeBlockTemplates[coin]; params.coinHashFactor = lastCoinHashFactorMM[coin]; - params.algo_name = global.coinFuncs.algoShortTypeStr(params.bt.port, params.bt.buffer[0]); + params.algo_name = global.coinFuncs.algoShortTypeStr(params.bt.port, params.bt.block_version); //params.variant_name = params.algo_name.split('/')[1]; return params; }; @@ -417,7 +432,7 @@ function setNewCoinHashFactor(isHashFactorChange, coin, coinHashFactor, check_he if (isHashFactorChange) { const port = activeBlockTemplates[coin].port; - const block_version = activeBlockTemplates[coin].buffer[0]; + const block_version = activeBlockTemplates[coin].block_version; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); strLogPrefix = "Full BT update for coin " + coin; @@ -531,6 +546,12 @@ function getRavenTargetHex(diff) { return '0'.repeat(size2 - diff2.length) + diff2; }; +function getEthTargetHex(diff) { + const size2 = 64; + const diff2 = (baseEthDiff / diff).toString(16).substr(0, size2); + return '0'.repeat(size2 - diff2.length) + diff2; +}; + function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -858,7 +879,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } const bt = activeBlockTemplates[coin]; const port = bt.port; - const block_version = bt.buffer[0]; + const block_version = bt.block_version; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); const factor = (typeof(miner.curr_coin_hash_factor) === 'undefined' ? 1 : miner.curr_coin_hash_factor) / coinHashFactor; @@ -883,7 +904,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)); if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_min_diff = 1; - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { this.curr_min_diff = 0.01; } else { this.curr_min_diff = global.config.pool.minDifficulty; @@ -1022,19 +1043,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (this.difficulty > bt.difficulty) this.difficulty = bt.difficulty; const blob_type_num = global.coinFuncs.portBlobType(bt.port); + const isEth = global.coinFuncs.blobTypeEth(blob_type_num); - if (!this.proxy) { - const blob = bt.nextBlob(); - if (!blob) return null; + if (!this.proxy || isEth) { + const blob_hex = bt.nextBlobHex(); + if (!blob_hex) return null; const isGrin = global.coinFuncs.blobTypeGrin(blob_type_num); - const isRvn = !isGrin && global.coinFuncs.blobTypeRaven(blob_type_num); - const blob_hex = blob.toString('hex'); + const isRvn = global.coinFuncs.blobTypeRaven(blob_type_num); const newJob = { - id: isRvn ? get_new_rvn_id() : get_new_id(), + id: isRvn ? get_new_eth_job_id() : get_new_id(), coin: coin, blob_type_num: blob_type_num, blockHash: bt.idHash, - extraNonce: bt.extraNonce, + extraNonce: isEth ? this.eth_extranonce : bt.extraNonce, height: bt.height, seed_hash: bt.seed_hash, difficulty: this.difficulty, @@ -1060,6 +1081,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi true, bt.height, bt.bits + ]; else if (isEth) this.cachedJob = [ + newJob.id, + bt.seed_hash, + blob_hex, + true, ]; else this.cachedJob = { blob: blob_hex, algo: params.algo_name, @@ -1088,7 +1114,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.validJobs.enq(newJob); this.cachedJob = { blocktemplate_blob: blob_hex, - blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.buffer[0]), + blob_type: global.coinFuncs.blobTypeStr(bt.port, bt.block_version), algo: params.algo_name, difficulty: bt.difficulty, height: bt.height, @@ -1110,8 +1136,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (this.protocol == "grin") { return this.pushMessage({method: "getjobtemplate", result: job}); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - this.pushMessage({method: "mining.set_target", params: [ job[3] ]}); + } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { + const target = global.coinFuncs.blobTypeEth(blob_type_num) ? getEthTargetHex(this.difficulty) : job[3]; + if (!this.last_target || this.last_target !== target) { + this.pushMessage({method: "mining.set_target", params: [ target ]}); + this.last_target = target; + } return this.pushMessage({method: "mining.notify", params: job, id:null}); } else { return this.pushMessage({method: "job", params: job}); @@ -1325,18 +1355,13 @@ function invalid_share(miner) { return false; } -function reverseBuffer(buff) { - let reversed = new Buffer(buff.length); - for (var i = buff.length - 1; i >= 0; i--) reversed[buff.length - i - 1] = buff[i]; - return reversed; -} - -function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { +function submit_block(miner, job, blockTemplate, blockData, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { let reply_fn = function (rpcResult, rpcStatus) { + const blockDataStr = Buffer.isBuffer(blockData) ? blockData.toString('hex') : JSON.stringify(blockData); if (rpcResult && (rpcResult.error || rpcResult.result === "high-hash")) { // did not manage to submit a block let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { - const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); + const convertedBlob = global.coinFuncs.convertBlob(blockData, blockTemplate.port); const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); if (hash !== resultHash) isNotifyAdmin = false; } @@ -1344,7 +1369,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus console.error(threadName + "Error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", isTrustedShare: " + isTrustedShare + ", valid: " + isNotifyAdmin + ", rpcStatus: " + rpcStatus + - ", error: " + JSON.stringify(rpcResult) + ", block hex: \n" + shareBuffer.toString('hex') + ", error: " + JSON.stringify(rpcResult) + ", block hex: \n" + blockDataStr ); if (isNotifyAdmin) setTimeout(function() { // only alert if block height is not changed in the nearest time @@ -1356,7 +1381,7 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus if (blockTemplate.height == body.height + 1) global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't submit " + blockTemplate.coin + " block to deamon on " + blockTemplate.port + " port", "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + - "Input: " + shareBuffer.toString('hex') + "\n" + + "Input: " + blockDataStr + "\n" + threadName + "Error submitting " + blockTemplate.coin + " block at " + blockTemplate.height + " height from " + miner.logString + ", isTrustedShare: " + isTrustedShare + " error ): " + JSON.stringify(rpcResult) ); @@ -1378,14 +1403,14 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus ) ) { - const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, shareBuffer[0]); + const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, blockTemplate.block_version); const blockFastHash = global.coinFuncs.blobTypeDero(blob_type_num) ? rpcResult.result.blid : - ( global.coinFuncs.blobTypeRaven(blob_type_num) ? reverseBuffer(resultHash).toString('hex') : - global.coinFuncs.getBlockID(shareBuffer, blockTemplate.port).toString('hex') + ( global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num) ? resultHash.toString('hex') : + global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex') ); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + - ", block hex: \n" + shareBuffer.toString('hex') + ", block hex: \n" + blockDataStr ); const time_now = Date.now(); @@ -1421,15 +1446,15 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus console.error(threadName + "Unknown error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + blockTemplate.height + " (active block template height: " + activeBlockTemplates[blockTemplate.coin].height + ") from " + miner.logString + ", isTrustedShare: " + isTrustedShare + ", rpcStatus: " + rpcStatus + ", error (" + (typeof rpcResult) + "): " + JSON.stringify(rpcResult) + - ", block hex: \n" + shareBuffer.toString('hex') + ", block hex: \n" + blockDataStr ); - setTimeout(submit_block, 500, miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, isParentBlock, false, submit_blockCB); + setTimeout(submit_block, 500, miner, job, blockTemplate, blockData, resultHash, isTrustedShare, isParentBlock, false, submit_blockCB); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't submit block to deamon on " + blockTemplate.port + " port", - "Input: " + shareBuffer.toString('hex') + "\n" + + "Input: " + blockDataStr + "\n" + "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + "RPC Error. Please check logs for details" ); @@ -1438,15 +1463,16 @@ function submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrus } }; - const blockhex = shareBuffer.toString('hex'); if (blockTemplate.port == 11898) { - global.support.rpcPortDaemon2(blockTemplate.port, "block", blockhex, reply_fn); + global.support.rpcPortDaemon2(blockTemplate.port, "block", blockData.toString('hex'), reply_fn); } else if (global.coinFuncs.blobTypeRaven(job.blob_type_num)) { - global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "submitblock", params: [ blockhex ] }, reply_fn); + global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "submitblock", params: [ blockData.toString('hex') ] }, reply_fn); + } else if (global.coinFuncs.blobTypeEth(job.blob_type_num)) { + global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "parity_submitWorkDetail", params: blockData, jsonrpc: "2.0", id: 0 }, reply_fn); } else if (global.coinFuncs.blobTypeDero(job.blob_type_num)) { - global.support.rpcPortDaemon(blockTemplate.port, "submitblock", [ blockTemplate.blocktemplate_blob, blockhex ], reply_fn); + global.support.rpcPortDaemon(blockTemplate.port, "submitblock", [ blockTemplate.blocktemplate_blob, blockData.toString('hex') ], reply_fn); } else { - global.support.rpcPortDaemon(blockTemplate.port, "submitblock", [ blockhex ], reply_fn); + global.support.rpcPortDaemon(blockTemplate.port, "submitblock", [ blockData.toString('hex') ], reply_fn); } } @@ -1472,7 +1498,11 @@ function hashBuffDiff(hash) { // bignum as result } function hashRavenBuffDiff(hash) { // float as result - return baseRavenDiff / bignum.fromBuffer(hash, {endian: 'little', size: 32}).toNumber(); + return baseRavenDiff / bignum.fromBuffer(hash).toNumber(); +} + +function hashEthBuffDiff(hash) { // float as result + return baseEthDiff / bignum.fromBuffer(hash).toNumber(); } // will work for numbers and bignum @@ -1493,38 +1523,42 @@ function report_miner_share(miner, job) { function processShare(miner, job, blockTemplate, params, processShareCB) { const port = blockTemplate.port; const blob_type_num = job.blob_type_num; - // recomputed for global.coinFuncs.blobTypeGrin(blob_type_num) or global.coinFuncs.blobTypeRaven(blob_type_num) - let resultHash = params.result; if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); let verifyShare = function(verifyShareCB) { if (global.coinFuncs.blobTypeGrin(blob_type_num)) { - const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer === null) return processShareCB(invalid_share(miner)); - const header = Buffer.concat([global.coinFuncs.convertBlob(shareBuffer, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); + const blockData = getShareBuffer(miner, job, blockTemplate, params); + if (blockData === null) return processShareCB(invalid_share(miner)); + const header = Buffer.concat([global.coinFuncs.convertBlob(blockData, port), bignum(params.nonce, 10).toBuffer({endian: 'big', size: 4})]); if (global.coinFuncs.c29(header, params.pow, port)) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - resultHash = global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num); - return verifyShareCB(hashBuffDiff(resultHash), shareBuffer, false, null); - } + const resultHash = global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num); + return verifyShareCB(hashBuffDiff(resultHash), resultHash, blockData, false, true); - if (global.coinFuncs.blobTypeRaven(blob_type_num)) { - const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer === null) return processShareCB(invalid_share(miner)); - const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + const blockData = getShareBuffer(miner, job, blockTemplate, params); + if (blockData === null) return processShareCB(invalid_share(miner)); + const convertedBlob = global.coinFuncs.convertBlob(blockData, port); if (params.header_hash !== convertedBlob.toString("hex")) { console.error("Wrong header hash:" + params.header_hash + " " + convertedBlob.toString("hex")); report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - resultHash = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate, params.nonce, params.mixhash); - return verifyShareCB(hashRavenBuffDiff(resultHash), shareBuffer, false, null); + const resultHash = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate, params.nonce, params.mixhash); + return verifyShareCB(hashRavenBuffDiff(resultHash), resultHash, blockData, false, true); + + } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { + const hashes = global.coinFuncs.slowHashBuff(Buffer.from(blockTemplate.hash, 'hex'), blockTemplate, params.nonce); + const resultHash = hashes[0].toString('hex'); + const blockData = [ "0x" + params.nonce, "0x" + blockTemplate.hash, "0x" + hashes[1].toString('hex') ]; + return verifyShareCB(hashEthBuffDiff(resultHash), resultHash, blockData, false, true); } + const resultHash = params.result; let resultBuffer; try { resultBuffer = Buffer.from(resultHash, 'hex'); @@ -1537,11 +1571,11 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && miner.trust.check_height !== job.height ) { - let shareBuffer = null; + let blockData = null; if (miner.payout in extra_wallet_verify) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer !== null) { - const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); + blockData = getShareBuffer(miner, job, blockTemplate, params); + if (blockData !== null) { + const convertedBlob = global.coinFuncs.convertBlob(blockData, port); global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { if (hash === null || hash === false) { console.error(threadName + "Can't verify share remotely!"); @@ -1556,10 +1590,10 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } if (miner.lastSlowHashAsyncDelay) { - setTimeout(function() { return verifyShareCB(hashDiff, shareBuffer, true, null); }, miner.lastSlowHashAsyncDelay); + setTimeout(function() { return verifyShareCB(hashDiff, resultHash, blockData, true, true); }, miner.lastSlowHashAsyncDelay); debug("[MINER] Delay " + miner.lastSlowHashAsyncDelay); } else { - return verifyShareCB(hashDiff, shareBuffer, true, null); + return verifyShareCB(hashDiff, resultHash, blockData, true, true); } } else { // verify share @@ -1575,14 +1609,14 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { adjustMinerDiff(miner); return processShareCB(null); } - const shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (shareBuffer === null) return processShareCB(invalid_share(miner)); - const convertedBlob = global.coinFuncs.convertBlob(shareBuffer, port); + const blockData = getShareBuffer(miner, job, blockTemplate, params); + if (blockData === null) return processShareCB(invalid_share(miner)); + const convertedBlob = global.coinFuncs.convertBlob(blockData, port); const isBlockDiffMatched = ge(hashDiff, blockTemplate.difficulty); if (isBlockDiffMatched) { if (miner.validShares || (miner.payout in minerWallets && minerWallets[miner.payout].hashes)) { - submit_block(miner, job, blockTemplate, shareBuffer, resultHash, true, true, true, function(block_submit_result) { + submit_block(miner, job, blockTemplate, blockData, resultHash, true, true, true, function(block_submit_result) { if (!block_submit_result) { const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); if (hash !== resultHash) { @@ -1591,7 +1625,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, shareBuffer, false, true); + return verifyShareCB(hashDiff, resultHash, blockData, false, false); }); } else { const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); @@ -1600,7 +1634,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { return processShareCB(invalid_share(miner)); } walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, shareBuffer, false, null); + return verifyShareCB(hashDiff, resultHash, blockData, false, true); } } else { const time_now = Date.now(); @@ -1618,34 +1652,34 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { miner.lastSlowHashAsyncDelay = Date.now() - time_now; if (miner.lastSlowHashAsyncDelay > 1000) miner.lastSlowHashAsyncDelay = 1000; walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, shareBuffer, false, false); + return verifyShareCB(hashDiff, resultHash, blockData, false, false); }); } } }; - verifyShare(function(hashDiff, shareBuffer, isTrustedShare, isBlockDiffMatched) { - if (isBlockDiffMatched === null && ge(hashDiff, blockTemplate.difficulty)) { // Submit block to the RPC Daemon. - if (!shareBuffer) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (!shareBuffer) return processShareCB(invalid_share(miner)); + verifyShare(function(hashDiff, resultHash, blockData, isTrustedShare, isNeedCheckBlockDiff) { + if (isNeedCheckBlockDiff && ge(hashDiff, blockTemplate.difficulty)) { // Submit block to the RPC Daemon. + if (!blockData) { + blockData = getShareBuffer(miner, job, blockTemplate, params); + if (!blockData) return processShareCB(invalid_share(miner)); } - submit_block(miner, job, blockTemplate, shareBuffer, resultHash, isTrustedShare, true, true); + submit_block(miner, job, blockTemplate, blockData, resultHash, isTrustedShare, true, true); } const is_mm = "child_template" in blockTemplate; if (is_mm && ge(hashDiff, blockTemplate.child_template.difficulty)) { // Submit child block to the RPC Daemon. - if (!shareBuffer) { - shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - if (!shareBuffer) return processShareCB(invalid_share(miner)); + if (!blockData) { + blockData = getShareBuffer(miner, job, blockTemplate, params); + if (!blockData) return processShareCB(invalid_share(miner)); } // need to properly restore child template buffer here since it went via message string and was restored not correctly blockTemplate.child_template_buffer = Buffer.from(blockTemplate.child_template_buffer); let shareBuffer2 = null; try { - shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(shareBuffer, port, blockTemplate.child_template_buffer); + shareBuffer2 = global.coinFuncs.constructMMChildBlockBlob(blockData, port, blockTemplate.child_template_buffer); } catch (e) { - const err_str = "Can't construct_mm_child_block_blob with " + shareBuffer.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; + const err_str = "Can't construct_mm_child_block_blob with " + blockData.toString('hex') + " parent block and " + blockTemplate.child_template_buffer.toString('hex') + " child block share buffers from " + miner.logString + ": " + e; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't construct_mm_child_block_blob", err_str); return processShareCB(invalid_share(miner)); @@ -1686,7 +1720,7 @@ function get_miner_notification(payout) { function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, pushMessage) { switch (method) { - case 'mining.authorize': // eth (raven) only + case 'mining.authorize': // Eth/Raven only if (!params || !(params instanceof Array)) { sendReplyFinal("No array params specified"); return; @@ -1694,13 +1728,13 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se params = { login: params[0], pass: params[1], - agent: "[ethminer]", - algo: [ "kawpow/rvn" ], - "algo-perf": { "kawpow/rvn": 1000000 }, + agent: socket.eth_agent ? socket.eth_agent : "[generic_ethminer]", + algo: [ "kawpow" ], + "algo-perf": { "kawpow": 1 }, }; // continue to normal login - case 'login': { // grin and default + case 'login': { // Grin and default if (ip in bannedIPs) { sendReplyFinal("New connections from this IP address are temporarily suspended from mining (10 minutes max)"); return; @@ -1720,6 +1754,10 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); + if (method === 'mining.authorize') { + socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); + miner.eth_extranonce = socket.eth_extranonce; + } if (params.agent && process.env['WORKER_ID'] == 1) minerAgents[params.agent] = 1; let time_now = Date.now(); if (!miner.valid_miner) { @@ -1776,22 +1814,30 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (coin !== false) { const job = miner.getCoinJob(coin, getCoinJobParams(coin)); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); - if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + if (global.coinFuncs.blobTypeRaven(blob_type_num)) { // xmrig specifics sendReply(null, { id: minerId, algo: "kawpow", extra_nonce: "" }); miner.pushMessage({method: "mining.notify", params: job}); } else { sendReply(null, { id: minerId, job: job, status: 'OK' }); } } else { - sendReplyFinal("No block template yet. Please wait."); + sendReplyFinal("No block template yet. Please wait."); } miner.protocol = "default"; } break; } - case 'mining.subscribe': { // eth (raven) only - sendReply(null, [ null, "00" ]); // empty extranonce (extra once is specificed in coinbase tx) + case 'mining.subscribe': { // Raven/Eth only + if (params && (params instanceof Array) && params.length >= 1) socket.eth_agent = params[0]; + socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); + // extranonce is not really needed for Raven (extraonce is specificed as part of coinbase tx) + sendReply(null, [ [ "mining.notify", get_new_id(), "EthereumStratum/1.0.0" ], socket.eth_extranonce ]); + break; + } + + case 'mining.extranonce.subscribe': { // Raven/Eth only + sendReply(null, true); break; } @@ -1835,22 +1881,30 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } - if ( params.length != 5 || - typeof params[1] !== 'string' || - typeof params[2] !== 'string' || - typeof params[3] !== 'string' || - typeof params[4] !== 'string' - ) { + for (const param of params) if (typeof param !== 'string') { sendReply("No correct params specified"); return; } - params = { - job_id: params[1], - nonce: params[2].substr(2), - header_hash: params[3].substr(2), - mixhash: params[4].substr(2), - }; + switch (params.length) { + case 3: params = { + job_id: params[1], + nonce: params[2], + }; break; + + case 5: params = { + job_id: params[1], + nonce: params[2].substr(2), + header_hash: params[3].substr(2), + mixhash: params[4].substr(2), + }; break; + + default: + sendReply("No correct params specified"); + return; + } + + // continue to normal login case 'submit': { // grin and default @@ -1886,11 +1940,13 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } else { if (typeof params.nonce !== 'string') return false; if (global.coinFuncs.nonceSize(blob_type_num) == 8) { + const isEth = global.coinFuncs.blobTypeEth(blob_type_num); + if (isEth) params.nonce = job.extraNonce + params.nonce; if (!nonceCheck64.test(params.nonce)) return false; if (global.coinFuncs.blobTypeRaven(blob_type_num)) { if (!hashCheck32.test(params.mixhash)) return false; if (!hashCheck32.test(params.header_hash)) return false; - } else { + } else if (!isEth) { if (!hashCheck32.test(params.result)) return false; } } else { @@ -2003,7 +2059,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (miner.protocol === "grin") { sendReply(null, "ok"); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { sendReply(null, true); } else { sendReply(null, { status: 'OK' }); @@ -2253,8 +2309,8 @@ if (cluster.isMaster) { }); } else getUniqueWorkerID(function(uniqueWorkerID) { - - console.log(threadName + "Starting pool worker with " + uniqueWorkerID + " unique id"); + UNIQUE_WORKER_ID = uniqueWorkerID; + console.log(threadName + "Starting pool worker with " + UNIQUE_WORKER_ID + " unique id"); newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; templateUpdate(""); diff --git a/package.json b/package.json index 161c9419d..b6955a30b 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.0.18", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.0.0" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.1.0" } } From 1c83a0724bfd6e9c5cb025f7b41c6c3fa24afe4f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 08:10:26 +0000 Subject: [PATCH 1181/1496] Eth draft support --- deployment/base.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 866fad984..597046bd7 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -234,6 +234,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorDERO', '0', 'float', 'Dero algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMC', '0', 'float', 'XMC algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRVN', '0', 'float', 'RVN algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorETH', '0', 'float', 'ETH algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); @@ -295,6 +296,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_16000', '', 'string', 'Address to mine to for 16000 (CCX) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', '', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8766', '', 'string', 'Address to mine to for 8766 (Ravencoin) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8545', '', 'string', 'Address to mine to for 8545 (Ethereum) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); From 0102d674750448cdc51374cae8b9b1c9a99c48e6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 08:39:04 +0000 Subject: [PATCH 1182/1496] Eth draft support --- lib/coins/xmr.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 7193a2d46..32c6a6db0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -280,7 +280,7 @@ function Coin(data){ }); } else if (port == 8545) { const blockId2 = blockId === "latest" ? blockId : "0x" + blockId.toString(16); - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByNumber', params: [ blockId2, true ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByNumber', params: [ blockId2, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); diff --git a/package.json b/package.json index b6955a30b..2214f6503 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.1.0" } } From 613e411a0a44df84630ccd67ce8fbbe93a81d090 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 08:43:14 +0000 Subject: [PATCH 1183/1496] Eth draft support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2214f6503..2a77e70ae 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.1.0" } } From 38999fd60769e98e8284495c6ca00989ae91c8ab Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 18:33:50 +0000 Subject: [PATCH 1184/1496] Improved user del --- manage_scripts/user_del_force.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/manage_scripts/user_del_force.js b/manage_scripts/user_del_force.js index d2671310f..0901c87db 100644 --- a/manage_scripts/user_del_force.js +++ b/manage_scripts/user_del_force.js @@ -56,6 +56,13 @@ require("../init_mini.js").init(function() { callback(); }); }, + function (callback) { + global.mysql.query("SELECT * FROM block_balance WHERE " + where_str).then(function (rows) { + console.log("Found rows in block_balance table: " + rows.length); + rows2remove += rows.length; + callback(); + }); + }, function (callback) { const address = global.database.getCache(user); const stats = global.database.getCache("stats:" + user); @@ -95,6 +102,12 @@ require("../init_mini.js").init(function() { callback(); }); }, + function (callback) { + global.mysql.query("DELETE FROM block_balance WHERE " + where_str, [user]).then(function (rows) { + console.log("DELETE FROM block_balance WHERE " + where_str); + callback(); + }); + }, function (callback) { console.log("Deleting LMDB cache keys"); let txn = global.database.env.beginTxn(); From 3ffaa520db84eacab8e30c757346ff9f4dc38c5a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 18:45:09 +0000 Subject: [PATCH 1185/1496] Improved user del --- manage_scripts/user_del.js | 6 +++--- manage_scripts/user_del_force.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index 2c3f9af83..19b8b57a0 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -19,7 +19,7 @@ require("../init_mini.js").init(function() { console.log("Max payment to remove: " + global.config.payout.walletMin); let rows2remove = 0; - const where_str = payment_id === null ? "payment_address = '" + address + "' AND payment_id IS NULL" + const where_str = payment_id === null ? "payment_address = '" + address + "' AND (payment_id IS NULL OR payment_id = '')" : "payment_address = '" + address + "' AND payment_id = '" + payment_id + "'"; async.waterfall([ @@ -91,13 +91,13 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - global.mysql.query("DELETE FROM balance WHERE " + where_str, [user]).then(function (rows) { + global.mysql.query("DELETE FROM balance WHERE " + where_str).then(function (rows) { console.log("DELETE FROM balance WHERE " + where_str); callback(); }); }, function (callback) { - global.mysql.query("DELETE FROM payments WHERE " + where_str, [user]).then(function (rows) { + global.mysql.query("DELETE FROM payments WHERE " + where_str).then(function (rows) { console.log("DELETE FROM payments WHERE " + where_str); callback(); }); diff --git a/manage_scripts/user_del_force.js b/manage_scripts/user_del_force.js index 0901c87db..18cfe3a7b 100644 --- a/manage_scripts/user_del_force.js +++ b/manage_scripts/user_del_force.js @@ -19,7 +19,7 @@ require("../init_mini.js").init(function() { console.log("Max payment to remove: " + global.config.payout.walletMin); let rows2remove = 0; - const where_str = payment_id === null ? "payment_address = '" + address + "' AND payment_id IS NULL" + const where_str = payment_id === null ? "payment_address = '" + address + "' AND (payment_id IS NULL OR payment_id = '')" : "payment_address = '" + address + "' AND payment_id = '" + payment_id + "'"; async.waterfall([ @@ -91,19 +91,19 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - global.mysql.query("DELETE FROM balance WHERE " + where_str, [user]).then(function (rows) { + global.mysql.query("DELETE FROM balance WHERE " + where_str).then(function (rows) { console.log("DELETE FROM balance WHERE " + where_str); callback(); }); }, function (callback) { - global.mysql.query("DELETE FROM payments WHERE " + where_str, [user]).then(function (rows) { + global.mysql.query("DELETE FROM payments WHERE " + where_str).then(function (rows) { console.log("DELETE FROM payments WHERE " + where_str); callback(); }); }, function (callback) { - global.mysql.query("DELETE FROM block_balance WHERE " + where_str, [user]).then(function (rows) { + global.mysql.query("DELETE FROM block_balance WHERE " + where_str).then(function (rows) { console.log("DELETE FROM block_balance WHERE " + where_str); callback(); }); From 538ee08439acc21e5c18de609661514fb1265511 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 21:08:17 +0000 Subject: [PATCH 1186/1496] Eth draft support --- lib/coins/xmr.js | 7 +++---- lib/pool.js | 24 +++++++----------------- package.json | 2 +- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 32c6a6db0..ed76fca57 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -285,6 +285,7 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } + body.result.height = parseInt(body.result.number); if (blockId === "latest") return callback(null, body.result); // do not need rewards for the latest block global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ blockId2 ] }, function (body2) { if (!body2 || !body2.result) { @@ -343,6 +344,7 @@ function Coin(data){ return callback(true, body2); } body.result.reward = calcEthReward(body.result, body2.result); + body.result.height = parseInt(body.result.number); return callback(null, body.result); }); }); @@ -488,11 +490,8 @@ function Coin(data){ return this.getPortBlockTemplate(global.config.daemon.port, callback); }; - this.baseDiff = function() { - return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); - }; + this.baseDiff = cnUtils.baseDiff; this.baseRavenDiff = cnUtil.baseRavenDiff; - this.baseEthDiff = cnUtil.baseEthDiff; this.validatePlainAddress = function(address){ // This function should be able to be called from the async library, as we need to BLOCK ever so slightly to verify the address. diff --git a/lib/pool.js b/lib/pool.js index 56fd5fef8..88943504c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -17,7 +17,6 @@ const hashCheck32 = new RegExp("^[0-9a-f]{64}$"); const hexMatch = new RegExp("^(?:[0-9a-f][0-9a-f])+$"); const baseDiff = global.coinFuncs.baseDiff(); const baseRavenDiff = global.coinFuncs.baseRavenDiff(); -const baseEthDiff = global.coinFuncs.baseEthDiff(); const BLOCK_NOTIFY_PORT = 2223; const DAEMON_POLL_MS = 500; @@ -271,16 +270,13 @@ function updateCoinHashFactor(coin) { }); } -function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange, latest_block_body) { +function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFactorChange) { let template = Object.assign({}, rpc_template); template.coin = coin; template.port = parseInt(port); template.coinHashFactor = coinHashFactor; template.isHashFactorChange = isHashFactorChange; - // calc height for eth_getWork - const blob_type_num = global.coinFuncs.portBlobType(template.port); - if (global.coinFuncs.blobTypeEth(blob_type_num)) template.height = parseInt(latest_block_body.number) + 1; if (port in global.coinFuncs.getMM_PORTS()) { const child_coin = global.coinFuncs.PORT2COIN(global.coinFuncs.getMM_PORTS()[port]); @@ -297,14 +293,14 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa } // templateUpdateReal is only called in master thread (except the beginning of a worker thread) -function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange, latest_block_body) { +function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { global.coinFuncs.getPortBlockTemplate(port, function (body_bt) { if (!newCoinHashFactor[coin]) { console.log("Aborting " + port + " last block template request because " + coin + " already has zero hash factor"); return; } if (body_bt) { - const template = process_rpc_template(body_bt, coin, port, coinHashFactor, isHashFactorChange, latest_block_body); + const template = process_rpc_template(body_bt, coin, port, coinHashFactor, isHashFactorChange); debug(threadName + "New block template found at " + template.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: template}); @@ -315,7 +311,7 @@ function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange, late for (let parent_port in parent_ports) { const parent_coin = global.coinFuncs.PORT2COIN(parent_port); if (parent_coin in activeBlockTemplates) { - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, lastCoinHashFactor[parent_coin], false, latest_block_body); + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, lastCoinHashFactor[parent_coin], false); sendToWorkers({type: 'newBlockTemplate', data: parent_template}); setNewBlockTemplate(parent_template); } @@ -327,7 +323,7 @@ function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange, late } else { console.error("Block template request failed for " + port + " port"); coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdateReal, 3000, coin, port, coinHashFactor, isHashFactorChange, latest_block_body); + setTimeout(templateUpdateReal, 3000, coin, port, coinHashFactor, isHashFactorChange); } }); } @@ -355,7 +351,7 @@ function templateUpdate(coin, repeating) { const isHashFactorChange = Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; - templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange, body); + templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange); } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } @@ -546,12 +542,6 @@ function getRavenTargetHex(diff) { return '0'.repeat(size2 - diff2.length) + diff2; }; -function getEthTargetHex(diff) { - const size2 = 64; - const diff2 = (baseEthDiff / diff).toString(16).substr(0, size2); - return '0'.repeat(size2 - diff2.length) + diff2; -}; - function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -1137,7 +1127,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (this.protocol == "grin") { return this.pushMessage({method: "getjobtemplate", result: job}); } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { - const target = global.coinFuncs.blobTypeEth(blob_type_num) ? getEthTargetHex(this.difficulty) : job[3]; + const target = global.coinFuncs.blobTypeEth(blob_type_num) ? getTargetHex(this.difficulty, 8) : job[3]; if (!this.last_target || this.last_target !== target) { this.pushMessage({method: "mining.set_target", params: [ target ]}); this.last_target = target; diff --git a/package.json b/package.json index 2a77e70ae..b4700a85d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.3", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.1.0" } } From 2689944f8f179111903a38107b5aaa492410fd8a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 21:12:39 +0000 Subject: [PATCH 1187/1496] Eth draft support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ed76fca57..77c02e3de 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -490,7 +490,7 @@ function Coin(data){ return this.getPortBlockTemplate(global.config.daemon.port, callback); }; - this.baseDiff = cnUtils.baseDiff; + this.baseDiff = cnUtil.baseDiff; this.baseRavenDiff = cnUtil.baseRavenDiff; this.validatePlainAddress = function(address){ From 0aaa0e7272bf85c3eacf74742d13d1472bb6af00 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 21:14:57 +0000 Subject: [PATCH 1188/1496] Eth draft support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4700a85d..98e6e8b17 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.3", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.4", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.1.0" } } From 2cbd30a237659a3b4409d2daece489d37b414d80 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 23:21:30 +0000 Subject: [PATCH 1189/1496] Eth draft support --- lib/pool.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 88943504c..69a51ce75 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -29,21 +29,23 @@ function get_new_id() { return id.toString(); }; -const eth_job_id_min = 0x1000; -let eth_job_id = eth_job_id_min; +function pad_hex(num, bytes) { // up to 8 bytes + return ("000000000000000" + num.toString(16)).substr(-bytes*2); +} + +let eth_job_id = 0; function get_new_eth_job_id() { - if (++eth_job_id > 0xFFFF) eth_job_id = eth_job_id_min; - return eth_job_id.toString(16); + if (++eth_job_id > 0xFFFF) eth_job_id = 0; + return pad_hex(eth_job_id, 2); }; let UNIQUE_WORKER_ID; -const eth_extranonce_id_min = 0x1000; -let eth_extranonce_id = eth_extranonce_id_min; +let eth_extranonce_id = 0; function get_new_eth_extranonce_id() { - if (++eth_extranonce_id > 0xFFFF) eth_extranonce_id = eth_extranonce_id_min; - return UNIQUE_WORKER_ID.toString(16) + eth_extranonce_id.toString(16); + if (++eth_extranonce_id > 0xFFFF) eth_extranonce_id = 0; + return pad_hex(UNIQUE_WORKER_ID, 1) + pad_hex(eth_extranonce_id, 2); }; let bannedIPs = {}; From 83cf495e8951aecc0911b470edf237b6eeaa8b7e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 23:26:04 +0000 Subject: [PATCH 1190/1496] Eth draft support --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 69a51ce75..b29fb0b4c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1493,8 +1493,8 @@ function hashRavenBuffDiff(hash) { // float as result return baseRavenDiff / bignum.fromBuffer(hash).toNumber(); } -function hashEthBuffDiff(hash) { // float as result - return baseEthDiff / bignum.fromBuffer(hash).toNumber(); +function hashEthBuffDiff(hash) { // bignum as result + return baseDiff.div(bignum.fromBuffer(hash)); } // will work for numbers and bignum From 888d502c3cb01cbd19e2b0651272b9feb8621805 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 23:38:56 +0000 Subject: [PATCH 1191/1496] Eth draft support --- lib/pool.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b29fb0b4c..b8bf59c69 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -29,8 +29,8 @@ function get_new_id() { return id.toString(); }; -function pad_hex(num, bytes) { // up to 8 bytes - return ("000000000000000" + num.toString(16)).substr(-bytes*2); +function pad_hex(num, bytes) { + return ("00".repeat(bytes) + num.toString(16)).substr(-bytes*2); } let eth_job_id = 0; @@ -544,6 +544,12 @@ function getRavenTargetHex(diff) { return '0'.repeat(size2 - diff2.length) + diff2; }; +function getEthTargetHex(diff, size) { + const size2 = size * 2; + const diff2 = baseDiff.div(diff).toString('hex').substr(0, size2); + return '0'.repeat(size2 - diff2.length) + diff2; +}; + function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -1129,7 +1135,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (this.protocol == "grin") { return this.pushMessage({method: "getjobtemplate", result: job}); } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { - const target = global.coinFuncs.blobTypeEth(blob_type_num) ? getTargetHex(this.difficulty, 8) : job[3]; + const target = global.coinFuncs.blobTypeEth(blob_type_num) ? getEthTargetHex(this.difficulty, 8) : job[3]; if (!this.last_target || this.last_target !== target) { this.pushMessage({method: "mining.set_target", params: [ target ]}); this.last_target = target; From 05ed4ebaa629853cc9ed48811020c1c23946ff74 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 23:40:32 +0000 Subject: [PATCH 1192/1496] Eth draft support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b8bf59c69..7320f2c7e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -546,7 +546,7 @@ function getRavenTargetHex(diff) { function getEthTargetHex(diff, size) { const size2 = size * 2; - const diff2 = baseDiff.div(diff).toString('hex').substr(0, size2); + const diff2 = baseDiff.div(diff).toBuffer().toString('hex').substr(0, size2); return '0'.repeat(size2 - diff2.length) + diff2; }; From e7d0916d776f98ead825da11b66e679600e644a1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 23:50:17 +0000 Subject: [PATCH 1193/1496] Eth draft support --- lib/pool.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7320f2c7e..1f89c4fed 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -544,12 +544,6 @@ function getRavenTargetHex(diff) { return '0'.repeat(size2 - diff2.length) + diff2; }; -function getEthTargetHex(diff, size) { - const size2 = size * 2; - const diff2 = baseDiff.div(diff).toBuffer().toString('hex').substr(0, size2); - return '0'.repeat(size2 - diff2.length) + diff2; -}; - function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. @@ -1134,13 +1128,21 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (this.protocol == "grin") { return this.pushMessage({method: "getjobtemplate", result: job}); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { - const target = global.coinFuncs.blobTypeEth(blob_type_num) ? getEthTargetHex(this.difficulty, 8) : job[3]; + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + const target = job[3]; if (!this.last_target || this.last_target !== target) { this.pushMessage({method: "mining.set_target", params: [ target ]}); this.last_target = target; } return this.pushMessage({method: "mining.notify", params: job, id:null}); + } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { + const diff = this.difficulty / 0x100000000; + if (!this.last_diff || this.last_diff !== diff) { + this.pushMessage({method: "mining.set_difficulty", params: [ diff ]}); + this.last_diff = diff; + } + return this.pushMessage({method: "mining.notify", params: job, id:null}); + } else { return this.pushMessage({method: "job", params: job}); } From 0871839fb6c74f758e848fe955cbf337b75c5757 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Jan 2021 23:53:12 +0000 Subject: [PATCH 1194/1496] Eth draft support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1f89c4fed..19f3cd0f5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1555,7 +1555,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const hashes = global.coinFuncs.slowHashBuff(Buffer.from(blockTemplate.hash, 'hex'), blockTemplate, params.nonce); const resultHash = hashes[0].toString('hex'); const blockData = [ "0x" + params.nonce, "0x" + blockTemplate.hash, "0x" + hashes[1].toString('hex') ]; - return verifyShareCB(hashEthBuffDiff(resultHash), resultHash, blockData, false, true); + return verifyShareCB(hashBuffDiff(resultHash), resultHash, blockData, false, true); } const resultHash = params.result; From d19c7771071fad05e1793a59c9ad7931ab853a0b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Jan 2021 00:11:44 +0000 Subject: [PATCH 1195/1496] Eth draft support --- lib/pool.js | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 19f3cd0f5..a44be7442 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1355,15 +1355,15 @@ function invalid_share(miner) { return false; } -function submit_block(miner, job, blockTemplate, blockData, resultHash, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { +function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { let reply_fn = function (rpcResult, rpcStatus) { const blockDataStr = Buffer.isBuffer(blockData) ? blockData.toString('hex') : JSON.stringify(blockData); if (rpcResult && (rpcResult.error || rpcResult.result === "high-hash")) { // did not manage to submit a block let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(blockData, blockTemplate.port); - const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash !== resultHash) isNotifyAdmin = false; + const buff = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate); + if (!buff.equals(resultBuff)) isNotifyAdmin = false; } console.error(threadName + "Error submitting " + blockTemplate.coin + " (port " + blockTemplate.port + ") block at height " + @@ -1405,7 +1405,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultHash, isTruste const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, blockTemplate.block_version); const blockFastHash = global.coinFuncs.blobTypeDero(blob_type_num) ? rpcResult.result.blid : - ( global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num) ? resultHash.toString('hex') : + ( global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num) ? resultBuff.toString('hex') : global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex') ); console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + @@ -1448,7 +1448,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultHash, isTruste miner.logString + ", isTrustedShare: " + isTrustedShare + ", rpcStatus: " + rpcStatus + ", error (" + (typeof rpcResult) + "): " + JSON.stringify(rpcResult) + ", block hex: \n" + blockDataStr ); - setTimeout(submit_block, 500, miner, job, blockTemplate, blockData, resultHash, isTrustedShare, isParentBlock, false, submit_blockCB); + setTimeout(submit_block, 500, miner, job, blockTemplate, blockData, resultBuff, isTrustedShare, isParentBlock, false, submit_blockCB); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1536,8 +1536,8 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - const resultHash = global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num); - return verifyShareCB(hashBuffDiff(resultHash), resultHash, blockData, false, true); + const resultBuff = global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num); + return verifyShareCB(hashBuffDiff(resultBuff), resultBuff, blockData, false, true); } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { const blockData = getShareBuffer(miner, job, blockTemplate, params); @@ -1548,24 +1548,24 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } - const resultHash = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate, params.nonce, params.mixhash); - return verifyShareCB(hashRavenBuffDiff(resultHash), resultHash, blockData, false, true); + const resultBuff = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate, params.nonce, params.mixhash); + return verifyShareCB(hashRavenBuffDiff(resultBuff), resultBuff, blockData, false, true); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { const hashes = global.coinFuncs.slowHashBuff(Buffer.from(blockTemplate.hash, 'hex'), blockTemplate, params.nonce); - const resultHash = hashes[0].toString('hex'); + const resultBuff = hashes[0]; const blockData = [ "0x" + params.nonce, "0x" + blockTemplate.hash, "0x" + hashes[1].toString('hex') ]; - return verifyShareCB(hashBuffDiff(resultHash), resultHash, blockData, false, true); + return verifyShareCB(hashEthBuffDiff(resultBuff), resultBuff, blockData, false, true); } const resultHash = params.result; - let resultBuffer; + let resultBuff; try { - resultBuffer = Buffer.from(resultHash, 'hex'); + resultBuff = Buffer.from(resultHash, 'hex'); } catch(e) { return processShareCB(invalid_share(miner)); } - const hashDiff = hashBuffDiff(resultBuffer); + const hashDiff = hashBuffDiff(resultBuff); if ( global.config.pool.trustedMiners && is_safe_to_trust(job.rewarded_difficulty2, miner.payout, miner.trust.trust) && @@ -1590,10 +1590,10 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } if (miner.lastSlowHashAsyncDelay) { - setTimeout(function() { return verifyShareCB(hashDiff, resultHash, blockData, true, true); }, miner.lastSlowHashAsyncDelay); + setTimeout(function() { return verifyShareCB(hashDiff, resultBuff, blockData, true, true); }, miner.lastSlowHashAsyncDelay); debug("[MINER] Delay " + miner.lastSlowHashAsyncDelay); } else { - return verifyShareCB(hashDiff, resultHash, blockData, true, true); + return verifyShareCB(hashDiff, resultBuff, blockData, true, true); } } else { // verify share @@ -1616,25 +1616,25 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const isBlockDiffMatched = ge(hashDiff, blockTemplate.difficulty); if (isBlockDiffMatched) { if (miner.validShares || (miner.payout in minerWallets && minerWallets[miner.payout].hashes)) { - submit_block(miner, job, blockTemplate, blockData, resultHash, true, true, true, function(block_submit_result) { + submit_block(miner, job, blockTemplate, blockData, resultBuff, true, true, true, function(block_submit_result) { if (!block_submit_result) { - const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash !== resultHash) { + const buff = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate); + if (!buff.equals(resultBuff)) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } } walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, resultHash, blockData, false, false); + return verifyShareCB(hashDiff, resultBuff, blockData, false, false); }); } else { - const hash = global.coinFuncs.slowHash(convertedBlob, blockTemplate); - if (hash !== resultHash) { + const buff = global.coinFuncs.slowHashBuff(convertedBlob, blockTemplate); + if (!buff.equals(resultBuff)) { report_miner_share(miner, job); return processShareCB(invalid_share(miner)); } walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, resultHash, blockData, false, true); + return verifyShareCB(hashDiff, resultBuff, blockData, false, true); } } else { const time_now = Date.now(); @@ -1652,19 +1652,19 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { miner.lastSlowHashAsyncDelay = Date.now() - time_now; if (miner.lastSlowHashAsyncDelay > 1000) miner.lastSlowHashAsyncDelay = 1000; walletTrust[miner.payout] += job.rewarded_difficulty2; - return verifyShareCB(hashDiff, resultHash, blockData, false, false); + return verifyShareCB(hashDiff, resultBuff, blockData, false, false); }); } } }; - verifyShare(function(hashDiff, resultHash, blockData, isTrustedShare, isNeedCheckBlockDiff) { + verifyShare(function(hashDiff, resultBuff, blockData, isTrustedShare, isNeedCheckBlockDiff) { if (isNeedCheckBlockDiff && ge(hashDiff, blockTemplate.difficulty)) { // Submit block to the RPC Daemon. if (!blockData) { blockData = getShareBuffer(miner, job, blockTemplate, params); if (!blockData) return processShareCB(invalid_share(miner)); } - submit_block(miner, job, blockTemplate, blockData, resultHash, isTrustedShare, true, true); + submit_block(miner, job, blockTemplate, blockData, resultBuff, isTrustedShare, true, true); } const is_mm = "child_template" in blockTemplate; @@ -1685,7 +1685,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { return processShareCB(invalid_share(miner)); } if (shareBuffer2 === null) return processShareCB(invalid_share(miner)); - submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultHash, isTrustedShare, false, true); + submit_block(miner, job, blockTemplate.child_template, shareBuffer2, resultBuff, isTrustedShare, false, true); } if (!ge(hashDiff, job.difficulty)) { From ad213337ede2f3231c8dab1e174f99dcfc95cc08 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Jan 2021 00:26:36 +0000 Subject: [PATCH 1196/1496] Eth draft support --- lib/pool.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a44be7442..e8d7037aa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1,3 +1,4 @@ + "use strict"; const debug = require('debug')('pool'); const crypto = require('crypto'); @@ -72,7 +73,7 @@ let totalShares = 0, trustedShares = 0, normalShares = 0, invalidShares = 0, out // wallet -> { connectTime, count (miner), hashes, last_ver_shares } // this is need to thottle down some high share count miners let minerWallets = {}; -const MAX_VER_SHARES_PER_SEC = 10; // per thread +const MAX_VER_SHARES_PER_SEC = 5; // per thread const VER_SHARES_PERIOD = 5; Buffer.prototype.toByteArray = function () { @@ -1527,6 +1528,21 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); + let shareThrottled() { + if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); + } + process.send({type: 'throttledShare'}); + addProxyMiner(miner); + const proxyMinerName = miner.payout; // + ":" + miner.identifier; + proxyMiners[proxyMinerName].hashes += job.difficulty; + adjustMinerDiff(miner); + return true; + } + return false; + } + let verifyShare = function(verifyShareCB) { if (global.coinFuncs.blobTypeGrin(blob_type_num)) { const blockData = getShareBuffer(miner, job, blockTemplate, params); @@ -1552,6 +1568,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { return verifyShareCB(hashRavenBuffDiff(resultBuff), resultBuff, blockData, false, true); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { + if (shareThrottled()) return processShareCB(null); const hashes = global.coinFuncs.slowHashBuff(Buffer.from(blockTemplate.hash, 'hex'), blockTemplate, params.nonce); const resultBuff = hashes[0]; const blockData = [ "0x" + params.nonce, "0x" + blockTemplate.hash, "0x" + hashes[1].toString('hex') ]; @@ -1598,17 +1615,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } else { // verify share if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); - if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); - } - process.send({type: 'throttledShare'}); - addProxyMiner(miner); - const proxyMinerName = miner.payout; // + ":" + miner.identifier; - proxyMiners[proxyMinerName].hashes += job.difficulty; - adjustMinerDiff(miner); - return processShareCB(null); - } + if (shareThrottled()) return processShareCB(null); const blockData = getShareBuffer(miner, job, blockTemplate, params); if (blockData === null) return processShareCB(invalid_share(miner)); const convertedBlob = global.coinFuncs.convertBlob(blockData, port); @@ -2034,7 +2041,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se processShare(miner, job, blockTemplate, params, function(shareAccepted) { if (miner.removed_miner) return; if (shareAccepted === null) { - sendReply('Throttled down share submission (please use high fixed diff or use xmr-node-proxy)'); + sendReply('Throttled down share submission (please increase difficulty)'); return; } miner.checkBan(shareAccepted); From b700452556cc1885f88e5891defe0fe2f225a92d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Jan 2021 00:27:04 +0000 Subject: [PATCH 1197/1496] Eth draft support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e8d7037aa..8bdd65498 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1528,7 +1528,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); - let shareThrottled() { + let shareThrottled = function() { if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); From 9ded35d0896eab9bb1d00e8e6f6d22f2fa850bdb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Jan 2021 03:13:18 +0000 Subject: [PATCH 1198/1496] Allow to forget bad diff --- lib/pool.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8bdd65498..fa9917382 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -966,9 +966,15 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (this.debugMiner) console.log(threadName + this.logString + ": calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } if (miner.connectTimeShift) { - if (Date.now() - miner.connectTimeShift > history_time*60*1000) { - miner.connectTime = miner.connectTimeShift; - miner.hashes -= miner.hashesShift; + const timeSinceLastShift = Date.now() - miner.connectTimeShift; + const timeWindow = history_time*60*1000; + if (timeSinceLastShift > timeWindow) { + if (timeSinceLastShift > 2*timeWindow) { // forget all + miner.hashes = 0; + } else { + miner.connectTime = miner.connectTimeShift; + miner.hashes -= miner.hashesShift; + } miner.connectTimeShift = Date.now(); miner.hashesShift = miner.hashes; } From 2ce252ef29c7f5acf95c09648fd79b171d31022c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Jan 2021 15:19:54 +0000 Subject: [PATCH 1199/1496] Fixed ETH block hash detection --- lib/pool.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index fa9917382..8091cb403 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1410,12 +1410,19 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste ) ) { + let newBlockHash; const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, blockTemplate.block_version); - const blockFastHash = global.coinFuncs.blobTypeDero(blob_type_num) ? rpcResult.result.blid : - ( global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num) ? resultBuff.toString('hex') : - global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex') - ); - console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + blockFastHash + " found at height " + blockTemplate.height + " by " + miner.logString + + if (global.coinFuncs.blobTypeDero(blob_type_num)) { + newBlockHash = rpcResult.result.blid; + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + newBlockHash = resultBuff.toString('hex'); + } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { + newBlockHash = rpcResult.result.substr(2); + } else { + newBlockHash = global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex'); + } + + console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + newBlockHash + " found at height " + blockTemplate.height + " by " + miner.logString + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + ", block hex: \n" + blockDataStr ); @@ -1423,7 +1430,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste const time_now = Date.now(); if (global.config.daemon.port == blockTemplate.port) { global.database.storeBlock(blockTemplate.height, global.protos.Block.encode({ - hash: blockFastHash, + hash: newBlockHash, difficulty: blockTemplate.difficulty, shares: 0, timestamp: time_now, @@ -1433,7 +1440,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste })); } else { global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ - hash: blockFastHash, + hash: newBlockHash, difficulty: blockTemplate.difficulty, shares: 0, timestamp: time_now, From 142eaeff9546f1cdec350a8bd1681e1564d3f70d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Jan 2021 18:12:58 +0000 Subject: [PATCH 1200/1496] Meta-miner support for ETH/RVN --- lib/pool.js | 28 ++++++++++++++-------------- lib/pool_stats.js | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8091cb403..9d35a959a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1141,14 +1141,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.pushMessage({method: "mining.set_target", params: [ target ]}); this.last_target = target; } - return this.pushMessage({method: "mining.notify", params: job, id:null}); + return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name, id:null}); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { const diff = this.difficulty / 0x100000000; if (!this.last_diff || this.last_diff !== diff) { this.pushMessage({method: "mining.set_difficulty", params: [ diff ]}); this.last_diff = diff; } - return this.pushMessage({method: "mining.notify", params: job, id:null}); + return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name, id:null}); } else { return this.pushMessage({method: "job", params: job}); @@ -1775,8 +1775,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se params.algo, params["algo-perf"], params["algo-min-time"] ); if (method === 'mining.authorize') { - socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); - miner.eth_extranonce = socket.eth_extranonce; + miner.eth_extranonce = socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); } if (params.agent && process.env['WORKER_ID'] == 1) minerAgents[params.agent] = 1; let time_now = Date.now(); @@ -1822,23 +1821,24 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } } } - if (id === "Stratum") { + if (id === "Stratum") { // if grin miner is connected directly to the pool sendReply(null, "ok"); miner.protocol = "grin"; - } else if (method === 'mining.authorize') { + } else if (method === 'mining.authorize') { // if raven/eth miner is connected directly to the pool sendReply(null, true); - miner.protocol = "auto"; + miner.protocol = "eth"; // technically equivalent to "default" miner.sendBestCoinJob(); - } else { + } else { // if meta-miner or xmrig or something else connected const coin = miner.selectBestCoin(); if (coin !== false) { - const job = miner.getCoinJob(coin, getCoinJobParams(coin)); + const params = getCoinJobParams(coin); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); - if (global.coinFuncs.blobTypeRaven(blob_type_num)) { // xmrig specifics - sendReply(null, { id: minerId, algo: "kawpow", extra_nonce: "" }); - miner.pushMessage({method: "mining.notify", params: job}); + if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { // xmrig specifics + miner.eth_extranonce = socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); + sendReply(null, { id: minerId, algo: params.algo_name, extra_nonce: miner.eth_extranonce }); + miner.sendCoinJob(coin, params); } else { - sendReply(null, { id: minerId, job: job, status: 'OK' }); + sendReply(null, { id: minerId, job: miner.getCoinJob(coin, params), status: 'OK' }); } } else { sendReplyFinal("No block template yet. Please wait."); @@ -1861,7 +1861,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se break; } - case 'getjobtemplate': { // grin only + case 'getjobtemplate': { // grin-mode miner only const minerId = socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""; let miner = activeMiners.get(minerId); if (!miner) { diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 8cba56565..917d94528 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -371,11 +371,11 @@ function updateBlockHeader() { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err) return next(); network_info[port] = { - difficulty: body.difficulty, + difficulty: parseInt(body.difficulty), hash: body.hash ? body.hash : body.hashrate, height: body.height, value: body.reward, - ts: body.timestamp, + ts: parseInt(body.timestamp), }; if (port == global.config.daemon.port) { global.support.rpcPortDaemon(port, 'get_info', [], function (rpcResult) { From 75f10c71d719a55bc8104c0b886e296a3d6e56d8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 22:46:26 +0000 Subject: [PATCH 1201/1496] Nicehash 2 bytes nonce support --- deployment/base.sql | 2 +- lib/pool.js | 57 ++++++++++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 597046bd7..0f1f2e88e 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -99,7 +99,7 @@ CREATE TABLE `pools` ( UNIQUE KEY `pools_id_uindex` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `pool_workers` ( - `id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT, + `id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT=0, `pool_id` int(11) NOT NULL, `worker_id` int(11) NOT NULL, PRIMARY KEY (`id`), diff --git a/lib/pool.js b/lib/pool.js index 9d35a959a..bbb754b38 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -22,31 +22,36 @@ const baseRavenDiff = global.coinFuncs.baseRavenDiff(); const BLOCK_NOTIFY_PORT = 2223; const DAEMON_POLL_MS = 500; -const id_min = 100000000000000; -let id = id_min; - +let decId = 0; function get_new_id() { - if (++id > 999999999999999) id = id_min; - return id.toString(); + if (++decId > 999999999999999) decId = 0; + return decId.toString(10); }; -function pad_hex(num, bytes) { - return ("00".repeat(bytes) + num.toString(16)).substr(-bytes*2); +function pad_hex(str, bytes) { + const bytes2 = bytes * 2; + return ("00".repeat(bytes) + str.substr(0, bytes2)).substr(-bytes2); } -let eth_job_id = 0; +let ethJobId = 0; function get_new_eth_job_id() { - if (++eth_job_id > 0xFFFF) eth_job_id = 0; - return pad_hex(eth_job_id, 2); + if (++ethJobId > 0xFFFF) ethJobId = 0; + return pad_hex(ethJobId.toString(16), 2); }; -let UNIQUE_WORKER_ID; -let eth_extranonce_id = 0; +let uniqueWorkerId; +let uniqueWorkerIdBits; +let ethExtraonceId = 0; function get_new_eth_extranonce_id() { - if (++eth_extranonce_id > 0xFFFF) eth_extranonce_id = 0; - return pad_hex(UNIQUE_WORKER_ID, 1) + pad_hex(eth_extranonce_id, 2); + if (++ethExtraonceId >= 1 << (16 - uniqueWorkerIdBits)) { + ethExtraonceId = 0; + const err_str = threadName + "Pool server " + global.config.hostname " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool node has extranonce overflow", err_str); + } + return pad_hex((ethExtraonceId << uniqueWorkerIdBits) + uniqueWorkerId, 2); }; let bannedIPs = {}; @@ -534,15 +539,11 @@ var reEmail = /^\S+@\S+\.\S+$/; let walletLastCheckTime = {}; function getTargetHex(diff, size) { - const size2 = size * 2; - const diff2 = baseDiff.div(diff).toBuffer({endian: 'little', size: size}).toString('hex').substr(0, size2); - return '0'.repeat(size2 - diff2.length) + diff2; + return pad_hex(baseDiff.div(diff).toBuffer({endian: 'little', size: size}).toString('hex'), size); }; function getRavenTargetHex(diff) { - const size2 = 64; - const diff2 = (baseRavenDiff / diff).toString(16).substr(0, size2); - return '0'.repeat(size2 - diff2.length) + diff2; + return pad_hex((baseRavenDiff / diff).toString(16), 32); }; function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { @@ -2180,7 +2181,13 @@ function getUniqueWorkerID(cb) { console.error("Can't get unique pool worker for " + global.config.pool_id + " pool_id and " + process.env['WORKER_ID'] + " worker_id"); process.exit(1); } - return cb(rows[0].id); + global.mysql.query("SELECT MAX(id) as maxId FROM pool_workers").then(function (rows_max) { + if (rows_max.length !== 1) { + console.error("Can't get max id from pool_workers table"); + process.exit(1); + } + return cb(rows[0].id, rows_max[0].maxId); + }): }); } @@ -2328,9 +2335,11 @@ if (cluster.isMaster) { console.log(threadName + "Block notify server on " + BLOCK_NOTIFY_PORT + " port started"); }); -} else getUniqueWorkerID(function(uniqueWorkerID) { - UNIQUE_WORKER_ID = uniqueWorkerID; - console.log(threadName + "Starting pool worker with " + UNIQUE_WORKER_ID + " unique id"); +} else getUniqueWorkerID(function(id, maxId) { + uniqueWorkerId = id; + uniqueWorkerIdBits = 0; + while (maxId) { maxId >>= 1; ++ uniqueWorkerIdBits; } + console.log(threadName + "Starting pool worker with " + uniqueWorkerId + " unique id and " + uniqueWorkerIdBits + " reserved bits"); newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; templateUpdate(""); From 3f353576a824cf341f2731c69f80e19c56082d43 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 22:48:03 +0000 Subject: [PATCH 1202/1496] Nicehash 2 bytes nonce support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bbb754b38..fe72ccde8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -47,7 +47,7 @@ let ethExtraonceId = 0; function get_new_eth_extranonce_id() { if (++ethExtraonceId >= 1 << (16 - uniqueWorkerIdBits)) { ethExtraonceId = 0; - const err_str = threadName + "Pool server " + global.config.hostname " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; + const err_str = threadName + "Pool server " + global.config.hostname + " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool node has extranonce overflow", err_str); } From f3331d355bb3685dabf135158832a5d4014584ef Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 22:48:31 +0000 Subject: [PATCH 1203/1496] Nicehash 2 bytes nonce support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index fe72ccde8..f9da872bd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2187,7 +2187,7 @@ function getUniqueWorkerID(cb) { process.exit(1); } return cb(rows[0].id, rows_max[0].maxId); - }): + }); }); } From d227ef51859104d8993f9f4a5c0de1f68d7161bb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 22:50:02 +0000 Subject: [PATCH 1204/1496] Nicehash 2 bytes nonce support --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f9da872bd..4fd26dc6c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -30,7 +30,7 @@ function get_new_id() { function pad_hex(str, bytes) { const bytes2 = bytes * 2; - return ("00".repeat(bytes) + str.substr(0, bytes2)).substr(-bytes2); + return ("00".repeat(bytes) + str.subst r(0, bytes2)).substr(-bytes2); } let ethJobId = 0; @@ -51,7 +51,7 @@ function get_new_eth_extranonce_id() { console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool node has extranonce overflow", err_str); } - return pad_hex((ethExtraonceId << uniqueWorkerIdBits) + uniqueWorkerId, 2); + return pad_hex(((ethExtraonceId << uniqueWorkerIdBits) + uniqueWorkerId).toString(16), 2); }; let bannedIPs = {}; From a7ceacd70baaa7dd2b2e82c326a2595fc52330ec Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 22:50:24 +0000 Subject: [PATCH 1205/1496] Nicehash 2 bytes nonce support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4fd26dc6c..cc6b97761 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -30,7 +30,7 @@ function get_new_id() { function pad_hex(str, bytes) { const bytes2 = bytes * 2; - return ("00".repeat(bytes) + str.subst r(0, bytes2)).substr(-bytes2); + return ("00".repeat(bytes) + str.substr(0, bytes2)).substr(-bytes2); } let ethJobId = 0; From 43f7c6cedd57c94f855ebc129423f451283b4795 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 23:07:22 +0000 Subject: [PATCH 1206/1496] Nicehash eth/rvn diff support --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cc6b97761..4d5dd5032 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -781,7 +781,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (agent && agent.includes('NiceHash')) { this.fixed_diff = true; - this.difficulty = global.coinFuncs.niceHashDiff; + if (this.difficulty < global.coinFuncs.niceHashDiff) this.difficulty = global.coinFuncs.niceHashDiff; } // 3d) trust stuff From c9c329d26f739ddb965ab13c92983ef94d57290b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 23:41:13 +0000 Subject: [PATCH 1207/1496] Nicehash rvn fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4d5dd5032..82f4b6c78 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1139,7 +1139,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { const target = job[3]; if (!this.last_target || this.last_target !== target) { - this.pushMessage({method: "mining.set_target", params: [ target ]}); + this.pushMessage({method: "mining.set_target", params: [ target ], id:null}); this.last_target = target; } return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name, id:null}); From cccd753404b1174daa145cd4f0521a13b9668dd1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Jan 2021 23:53:36 +0000 Subject: [PATCH 1208/1496] Nicehash eth fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 82f4b6c78..13e36ad17 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1149,7 +1149,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.pushMessage({method: "mining.set_difficulty", params: [ diff ]}); this.last_diff = diff; } - return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name, id:null}); + return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name}); } else { return this.pushMessage({method: "job", params: job}); From f5947a971d0b33988e01972f09e801ec2e3fbdff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Jan 2021 04:17:47 +0000 Subject: [PATCH 1209/1496] More strict unauth handling --- lib/pool.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 13e36ad17..33c371898 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1866,7 +1866,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const minerId = socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""; let miner = activeMiners.get(minerId); if (!miner) { - sendReply('Unauthenticated'); + sendReplyFinal('Unauthenticated'); return; } miner.heartbeat(); @@ -1881,7 +1881,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } let miner = activeMiners.get(params.id); if (!miner) { - sendReply('Unauthenticated'); + sendReplyFinal('Unauthenticated'); return; } miner.heartbeat(); @@ -1936,7 +1936,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const minerId = params.id ? params.id : (socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""); let miner = activeMiners.get(minerId); if (!miner) { - sendReply('Unauthenticated'); + sendReplyFinal('Unauthenticated'); return; } //if (miner.debugMiner) console.log("SUBMIT"); @@ -2090,14 +2090,16 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se break; } + case 'keepalive': case 'keepalived': { if (!params) { sendReplyFinal("No params specified"); return; } - let miner = activeMiners.get(params.id); + const minerId = params.id ? params.id : (socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""); + let miner = activeMiners.get(minerId); if (!miner) { - sendReply('Unauthenticated'); + sendReplyFinal('Unauthenticated'); return; } miner.heartbeat(); From 664bbd3a75eec67a02cd6fa5ca488e343a2854bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Jan 2021 07:05:57 +0000 Subject: [PATCH 1210/1496] Removed rate limiter --- lib/api.js | 7 ------- package.json | 1 - 2 files changed, 8 deletions(-) diff --git a/lib/api.js b/lib/api.js index abf423e99..7af69f90f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,7 +1,6 @@ "use strict"; const express = require('express'); // call express const apicache = require('apicache'); -const rateLimit = require('express-rate-limit') const app = express(); // define our app using express const cache = apicache.middleware; const server = require('http').createServer(app); @@ -37,12 +36,6 @@ app.use(cors()); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); -app.set('trust proxy', 1); -app.use(rateLimit({ - windowMs: 15 * 60 * 1000, // 15 minutes - max: 500 // limit each IP to 500 requests per time window -})); - function get_identifiers(address) { return global.database.getCache('identifiers:' + address); } diff --git a/package.json b/package.json index 98e6e8b17..272b605a0 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "debug": "2.6.9", "express": "4.14.0", "apicache": "1.2.1", - "express-rate-limit": "5.2.3", "jsonwebtoken": "^7.2.1", "minimist": ">=1.2.3", "moment": "2.21.0", From 5c18246455f1abeb53747a38abd0e838e69e866b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 17:41:02 +0000 Subject: [PATCH 1211/1496] Fixed diff calc for algo switches --- lib/pool.js | 87 +++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 49 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 33c371898..4a12a93ef 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -769,21 +769,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.wallet_key = this.payout + " " + this.bitcoin + " " + this.poolTypeEnum + " " + JSON.stringify(this.payout_div) + " "; - // 3c) diff stuff + // 3c) diff calc stuff this.lastShareTime = Math.floor(Date.now() / 1000); this.validShares = 0; this.invalidShares = 0; this.hashes = 0; - this.fixed_diff = false; - this.difficulty = startingDiff; - - if (agent && agent.includes('NiceHash')) { - this.fixed_diff = true; - if (this.difficulty < global.coinFuncs.niceHashDiff) this.difficulty = global.coinFuncs.niceHashDiff; - } - // 3d) trust stuff if (global.config.pool.trustedMiners) { @@ -828,11 +820,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.setNewDiff = function (difficulty) { if (this.fixed_diff) return false; - - let newDiff = difficulty; //Math.round(difficulty); - if (newDiff > global.config.pool.maxDifficulty) newDiff = global.config.pool.maxDifficulty; - if (newDiff < this.curr_min_diff) newDiff = this.curr_min_diff; - + const newDiff = difficulty; this.newDiffRecommendation = newDiff; const ratio = Math.abs(newDiff - this.difficulty) / this.difficulty; if (ratio < 0.2) return false; @@ -903,22 +891,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } else { this.curr_min_diff = global.config.pool.minDifficulty; } - const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; - const factor = curr_hash_factor / lastCoinHashFactorMM[best_coin]; - if (factor != 1) { - if (this.hashes === 0) { - this.setNewDiff(this.difficulty * factor); - if (this.newDiffToSet) { - this.difficulty = this.newDiffToSet; - this.newDiffToSet = null; - this.newDiffRecommendation = null; - } - } else { - this.hashes *= factor; - if (this.hashesShift) this.hashesShift *= factor; - this.setNewDiff(this.calcNewDiff()); - } - } this.curr_coin = best_coin; this.curr_coin_hash_factor = lastCoinHashFactorMM[best_coin]; this.curr_coin_time = Date.now(); @@ -927,20 +899,31 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi return best_coin; }; - this.curr_min_diff = global.config.pool.minDifficulty; - this.curr_coin = this.selectBestCoin(); + // 3e) set diff stuff + + this.fixed_diff = false; + this.difficulty = startingDiff; if (login_diff_split.length === 2) { this.fixed_diff = true; this.difficulty = Number(login_diff_split[1]); - if (this.difficulty < this.curr_min_diff) { - this.difficulty = this.curr_min_diff; + if (this.difficulty < global.config.pool.minDifficulty) { + this.difficulty = global.config.pool.minDifficulty; } if (this.difficulty > global.config.pool.maxDifficulty) { this.difficulty = global.config.pool.maxDifficulty; } } + if (agent && agent.includes('NiceHash')) { + this.fixed_diff = true; + if (this.difficulty < global.coinFuncs.niceHashDiff) this.difficulty = global.coinFuncs.niceHashDiff; + } + + this.curr_coin_hash_factor = 1; + this.curr_min_diff = global.config.pool.minDifficulty; + this.curr_coin = this.selectBestCoin(); + this.calcNewDiff = function () { const proxyMinerName = this.payout; // + ":" + this.identifier; let miner; @@ -968,9 +951,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } if (miner.connectTimeShift) { const timeSinceLastShift = Date.now() - miner.connectTimeShift; - const timeWindow = history_time*60*1000; + const timeWindow = history_time * 60 * 1000; if (timeSinceLastShift > timeWindow) { - if (timeSinceLastShift > 2*timeWindow) { // forget all + if (timeSinceLastShift > 2 * timeWindow) { // forget all miner.hashes = 0; } else { miner.connectTime = miner.connectTimeShift; @@ -992,7 +975,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi target = 2 * global.config.pool.retargetTime; if (period < target) period = target; } - const diff = hashes * target / period; //Math.floor(hashes * target / period); + const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; + const diff = hashes * target / period * curr_coin_hash_factor; return diff < min_diff ? min_diff : diff; }; @@ -1040,7 +1024,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.newDiffRecommendation = null; } - if (this.difficulty > bt.difficulty) this.difficulty = bt.difficulty; + let coin_diff = this.difficulty / this.curr_coin_hash_factor; + if (coin_diff < this.curr_min_diff) coin_diff = curr_min_diff; + if (coin_diff > bt.difficulty) coin_diff = bt.difficulty; const blob_type_num = global.coinFuncs.portBlobType(bt.port); const isEth = global.coinFuncs.blobTypeEth(blob_type_num); @@ -1058,7 +1044,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi extraNonce: isEth ? this.eth_extranonce : bt.extraNonce, height: bt.height, seed_hash: bt.seed_hash, - difficulty: this.difficulty, + difficulty: coin_diff, coinHashFactor: params.coinHashFactor, submissions: {} }; @@ -1071,13 +1057,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi noncebytes: 4, height: bt.height, job_id: newJob.id, - difficulty: this.difficulty, + difficulty: coin_diff, id: this.id }; else if (isRvn) this.cachedJob = [ newJob.id, blob_hex, bt.seed_hash, - getRavenTargetHex(this.difficulty), + getRavenTargetHex(coin_diff), true, bt.height, bt.bits @@ -1086,13 +1072,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi bt.seed_hash, blob_hex, true, + coin_diff ]; else this.cachedJob = { blob: blob_hex, algo: params.algo_name, height: bt.height, seed_hash: bt.seed_hash, job_id: newJob.id, - target: getTargetHex(this.difficulty, global.coinFuncs.nonceSize(blob_type_num)), + target: getTargetHex(coin_diff, global.coinFuncs.nonceSize(blob_type_num)), id: this.id }; } else { @@ -1105,7 +1092,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi extraNonce: bt.extraNonce, height: bt.height, seed_hash: bt.seed_hash, - difficulty: this.difficulty, + difficulty: coin_diff, clientPoolLocation: bt.clientPoolLocation, clientNonceLocation: bt.clientNonceLocation, coinHashFactor: params.coinHashFactor, @@ -1122,7 +1109,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi reserved_offset: bt.reserved_offset, client_nonce_offset: bt.clientNonceLocation, client_pool_offset: bt.clientPoolLocation, - target_diff: this.difficulty, + target_diff: coin_diff, job_id: newJob.id, id: this.id }; @@ -1144,7 +1131,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name, id:null}); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { - const diff = this.difficulty / 0x100000000; + const diff = job.pop() / 0x100000000; if (!this.last_diff || this.last_diff !== diff) { this.pushMessage({method: "mining.set_difficulty", params: [ diff ]}); this.last_diff = diff; @@ -1259,9 +1246,10 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { } function recordShareData(miner, job, isTrustedShare, blockTemplate) { - miner.hashes += job.difficulty; + const normalized_diff = job.difficulty * miner.curr_coin_hash_factor; + miner.hashes += normalized_diff; let proxyMinerName = miner.payout; // + ":" + miner.identifier; - if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.difficulty; + if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += normalized_diff; const time_now = Date.now(); let wallet_key = miner.wallet_key + blockTemplate.port; @@ -1539,7 +1527,8 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const port = blockTemplate.port; const blob_type_num = job.blob_type_num; - if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; + const normalized_diff = job.difficulty * miner.curr_coin_hash_factor; + if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += normalized_diff; walletLastSeeTime[miner.payout] = Date.now(); let shareThrottled = function() { @@ -1550,7 +1539,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { process.send({type: 'throttledShare'}); addProxyMiner(miner); const proxyMinerName = miner.payout; // + ":" + miner.identifier; - proxyMiners[proxyMinerName].hashes += job.difficulty; + proxyMiners[proxyMinerName].hashes += normalized_diff; adjustMinerDiff(miner); return true; } From df38d28fedfce7120e8aac624faf0f2d9e8e6494 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 17:45:10 +0000 Subject: [PATCH 1212/1496] Fixed diff calc for algo switches --- lib/pool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4a12a93ef..825c71e83 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -975,8 +975,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi target = 2 * global.config.pool.retargetTime; if (period < target) period = target; } - const curr_hash_factor = typeof(this.curr_coin_hash_factor) === 'undefined' ? 1 : this.curr_coin_hash_factor; - const diff = hashes * target / period * curr_coin_hash_factor; + const diff = hashes * target / period; return diff < min_diff ? min_diff : diff; }; From d59cfe25b277539bd6a6c6ab08e40a5b4428f991 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 17:47:01 +0000 Subject: [PATCH 1213/1496] Fixed diff calc for algo switches --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 825c71e83..87d1f9cb0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1024,7 +1024,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } let coin_diff = this.difficulty / this.curr_coin_hash_factor; - if (coin_diff < this.curr_min_diff) coin_diff = curr_min_diff; + if (coin_diff < this.curr_min_diff) coin_diff = this.curr_min_diff; if (coin_diff > bt.difficulty) coin_diff = bt.difficulty; const blob_type_num = global.coinFuncs.portBlobType(bt.port); From 0505d754037b5a7464b3bf51d6d34ab1bd82a812 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 18:34:02 +0000 Subject: [PATCH 1214/1496] Added extra wallet debug --- lib/coins/xmr.js | 1 - lib/pool.js | 41 ++++++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 77c02e3de..af2666544 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -216,7 +216,6 @@ function Coin(data){ let instanceId = new Buffer(4); instanceId.writeUInt32LE( (((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))) >>> 0 ); console.log("Generated instanceId: " + instanceId.toString('hex')); - this.testDevAddress = "41jrqvF7Cb7bU6SzL2pbaP4UrYTqf5wfHUqiMnNwztYg71XjbC2udj6hrN8b6npQyC2WUVFoXDViP3GFMZEYbUgR9TwJX6B"; // Address for live pool testing this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address this.poolDevAddress = "499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE"; // MoneroOcean Address diff --git a/lib/pool.js b/lib/pool.js index 87d1f9cb0..738f05e89 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -538,6 +538,8 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; +let wallet_debug = {}; + function getTargetHex(diff, size) { return pad_hex(baseDiff.div(diff).toBuffer({endian: 'little', size: size}).toString('hex'), size); }; @@ -584,7 +586,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } } - this.debugMiner = this.payout == global.coinFuncs.testDevAddress; + this.debugMiner = this.payout in wallet_debug; this.email = pass_split.length === 2 ? pass_split[1] : ""; this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + ipAddress + ")"; this.agent = agent; @@ -836,7 +838,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }; this.selectBestCoin = function() { - if (this.debugMiner) console.log(threadName + this.logString + ": current coin is " + this.curr_coin); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: current coin is " + this.curr_coin); if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && lastCoinHashFactorMM[this.curr_coin] && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { @@ -847,16 +849,16 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi let miner = this; COINS.forEach(function(coin) { if (!(coin in miner.coin_perf)) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coin_perf"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no coin_perf"); return; } if (!(coin in activeBlockTemplates)) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no activeBlockTemplates"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no activeBlockTemplates"); return; } const coinHashFactor = lastCoinHashFactorMM[coin]; if (!coinHashFactor) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no coinHashFactor"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no coinHashFactor"); return; } const bt = activeBlockTemplates[coin]; @@ -870,12 +872,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": no algo support"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no algo support"); return; } let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; - if (miner.debugMiner) console.log(threadName + miner.logString + ": " + coin + ": " + coin_perf); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": " + coin_perf); if (coin_perf > best_coin_perf) { best_coin = coin; best_coin_perf = coin_perf; @@ -935,19 +937,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi target = 5; min_diff = 10 * this.curr_min_diff; history_time = 5; - if (this.debugMiner) console.log(threadName + this.logString + ": calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { miner = minerWallets[this.payout]; target = 5; min_diff = 10 * this.curr_min_diff; history_time = 5; - if (this.debugMiner) console.log(threadName + this.logString + ": calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; min_diff = this.proxy ? 10 * this.curr_min_diff : this.curr_min_diff; history_time = 60; - if (this.debugMiner) console.log(threadName + this.logString + ": calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } if (miner.connectTimeShift) { const timeSinceLastShift = Date.now() - miner.connectTimeShift; @@ -1616,7 +1618,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } else { // verify share - if (miner.debugMiner) console.log(threadName + miner.logString + ": verify share"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: verify share"); if (shareThrottled()) return processShareCB(null); const blockData = getShareBuffer(miner, job, blockTemplate, params); if (blockData === null) return processShareCB(invalid_share(miner)); @@ -1763,6 +1765,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); + if (miner.debugMiner) socket.debugMiner = 1; //console.log(threadName + miner.logString + " [WALLET DEBUG]: " + method + ": " + JSON.stringify(params)); if (method === 'mining.authorize') { miner.eth_extranonce = socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); } @@ -2432,6 +2435,18 @@ if (cluster.isMaster) { fs.writeFile(fn, extra_verify_wallet_hashes.join("\n"), function(err) { if (err) console.error("Error saving " + fn + " file"); }); extra_verify_wallet_hashes = []; }); + const wallet_debug_fn = "wallet_debug.txt"; + wallet_debug_verify = {}; + fs.access(wallet_debug_fn, fs.F_OK, function(err) { + if (err) return; + let rs = fs.createReadStream(wallet_debug_fn); + rs.on('error', function() { console.error("Can't open " + wallet_debug_fn + " file"); }); + let lineReader = require('readline').createInterface({ input: rs }); + lineReader.on('line', function (line) { + console.log("WILL EXTRA DEBUG WALLET: '" + line + "'"); + wallet_debug[line] = 1; + }); + }); }, 5*60*1000); let lastGarbageFromIpTime = {}; @@ -2459,6 +2474,7 @@ if (cluster.isMaster) { }; if (jsonData.id === "Stratum") reply.method = jsonData.method; debug("[MINER] REPLY TO MINER: " + JSON.stringify(reply)); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: reply " + JSON.stringify(reply)); socket.write(JSON.stringify(reply) + "\n"); }; let sendReplyFinal = function (error) { @@ -2472,11 +2488,13 @@ if (cluster.isMaster) { }; if (jsonData.id === "Stratum") reply.method = jsonData.method; debug("[MINER] FINAL REPLY TO MINER: " + JSON.stringify(reply)); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: final reply " + JSON.stringify(reply)); socket.end(JSON.stringify(reply) + "\n"); }, 9 * 1000); }; debug("[MINER] GOT FROM MINER: " + JSON.stringify(jsonData)); handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, pushMessage); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: recieved " + JSON.stringify(jsonData)); }; function socketConn(socket) { @@ -2489,6 +2507,7 @@ if (cluster.isMaster) { if (!socket.writable) return; body.jsonrpc = "2.0"; debug("[MINER] PUSH TO MINER: " + JSON.stringify(body)); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: push " + JSON.stringify(body)); socket.write(JSON.stringify(body) + "\n"); }; From ba7611944f0d72b203280f88f9f6d2dcc45f8c78 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 18:40:19 +0000 Subject: [PATCH 1215/1496] Added extra wallet debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 738f05e89..29472cd97 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2436,7 +2436,7 @@ if (cluster.isMaster) { extra_verify_wallet_hashes = []; }); const wallet_debug_fn = "wallet_debug.txt"; - wallet_debug_verify = {}; + wallet_debug = {}; fs.access(wallet_debug_fn, fs.F_OK, function(err) { if (err) return; let rs = fs.createReadStream(wallet_debug_fn); From b185b0daf35bb7d718f440a50725bf6c75d0dff0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 18:49:59 +0000 Subject: [PATCH 1216/1496] Added extra wallet debug --- lib/pool.js | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 29472cd97..41cf6936f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1,4 +1,3 @@ - "use strict"; const debug = require('debug')('pool'); const crypto = require('crypto'); @@ -838,7 +837,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi }; this.selectBestCoin = function() { - if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: current coin is " + this.curr_coin); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] current coin is " + this.curr_coin); if (typeof(this.curr_coin) !== 'undefined' && this.curr_coin_time && lastCoinHashFactorMM[this.curr_coin] && Date.now() - this.curr_coin_time < this.algo_min_time*1000 ) { @@ -849,16 +848,16 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi let miner = this; COINS.forEach(function(coin) { if (!(coin in miner.coin_perf)) { - if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no coin_perf"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] " + coin + ": no coin_perf"); return; } if (!(coin in activeBlockTemplates)) { - if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no activeBlockTemplates"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] " + coin + ": no activeBlockTemplates"); return; } const coinHashFactor = lastCoinHashFactorMM[coin]; if (!coinHashFactor) { - if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no coinHashFactor"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] " + coin + ": no coinHashFactor"); return; } const bt = activeBlockTemplates[coin]; @@ -872,12 +871,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { - if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": no algo support"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] " + coin + ": no algo support"); return; } let coin_perf = miner.coin_perf[coin] * coinHashFactor; if (miner.curr_coin === coin) coin_perf *= 1.05; - if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: " + coin + ": " + coin_perf); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] " + coin + ": " + coin_perf); if (coin_perf > best_coin_perf) { best_coin = coin; best_coin_perf = coin_perf; @@ -937,19 +936,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi target = 5; min_diff = 10 * this.curr_min_diff; history_time = 5; - if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { miner = minerWallets[this.payout]; target = 5; min_diff = 10 * this.curr_min_diff; history_time = 5; - if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; min_diff = this.proxy ? 10 * this.curr_min_diff : this.curr_min_diff; history_time = 60; - if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG]: calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } if (miner.connectTimeShift) { const timeSinceLastShift = Date.now() - miner.connectTimeShift; @@ -1599,15 +1598,15 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const convertedBlob = global.coinFuncs.convertBlob(blockData, port); global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { if (hash === null || hash === false) { - console.error(threadName + "Can't verify share remotely!"); + console.error(threadName + "[EXTRA CHECK] Can't verify share remotely!"); } else if (hash !== resultHash) { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); + console.error(threadName + miner.logString + " [EXTRA CHECK] INVALID SHARE OF " + job.rewarded_difficulty2 + " REWARD HASHES"); } else { extra_verify_wallet_hashes.push(miner.payout + " " + convertedBlob.toString('hex') + " " + resultHash + " " + global.coinFuncs.algoShortTypeStr(port) + " " + blockTemplate.height + " " + blockTemplate.seed_hash); } }); } else { - console.error("EXTRA WALLET VERIFY " + miner.payout + ": CAN'T MAKE SHARE BUFFER"); + console.error(threadName + miner.logString + " [EXTRA CHECK] CAN'T MAKE SHARE BUFFER"); } } if (miner.lastSlowHashAsyncDelay) { @@ -1618,7 +1617,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } else { // verify share - if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG]: verify share"); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] verify share"); if (shareThrottled()) return processShareCB(null); const blockData = getShareBuffer(miner, job, blockTemplate, params); if (blockData === null) return processShareCB(invalid_share(miner)); @@ -1765,7 +1764,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); - if (miner.debugMiner) socket.debugMiner = 1; //console.log(threadName + miner.logString + " [WALLET DEBUG]: " + method + ": " + JSON.stringify(params)); + if (miner.debugMiner) socket.debugMiner = 1; //console.log(threadName + miner.logString + " [WALLET DEBUG] " + method + ": " + JSON.stringify(params)); if (method === 'mining.authorize') { miner.eth_extranonce = socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); } @@ -2428,7 +2427,7 @@ if (cluster.isMaster) { rs.on('error', function() { console.error("Can't open " + extra_wallet_verify_fn + " file"); }); let lineReader = require('readline').createInterface({ input: rs }); lineReader.on('line', function (line) { - console.log("WILL EXTRA CHECK WALLET: '" + line + "'"); + console.log(threadName + "[EXTRA CHECK] added: '" + line + "'"); extra_wallet_verify[line] = 1; }); const fn = "extra_verify_wallet_hashes_" + process.env['WORKER_ID'].toString(); @@ -2443,7 +2442,7 @@ if (cluster.isMaster) { rs.on('error', function() { console.error("Can't open " + wallet_debug_fn + " file"); }); let lineReader = require('readline').createInterface({ input: rs }); lineReader.on('line', function (line) { - console.log("WILL EXTRA DEBUG WALLET: '" + line + "'"); + console.log(threadName + "[WALET DEBUG] added: '" + line + "'"); wallet_debug[line] = 1; }); }); @@ -2474,7 +2473,7 @@ if (cluster.isMaster) { }; if (jsonData.id === "Stratum") reply.method = jsonData.method; debug("[MINER] REPLY TO MINER: " + JSON.stringify(reply)); - if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: reply " + JSON.stringify(reply)); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG] reply " + JSON.stringify(reply)); socket.write(JSON.stringify(reply) + "\n"); }; let sendReplyFinal = function (error) { @@ -2488,13 +2487,13 @@ if (cluster.isMaster) { }; if (jsonData.id === "Stratum") reply.method = jsonData.method; debug("[MINER] FINAL REPLY TO MINER: " + JSON.stringify(reply)); - if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: final reply " + JSON.stringify(reply)); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG] final reply " + JSON.stringify(reply)); socket.end(JSON.stringify(reply) + "\n"); }, 9 * 1000); }; debug("[MINER] GOT FROM MINER: " + JSON.stringify(jsonData)); handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, pushMessage); - if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: recieved " + JSON.stringify(jsonData)); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG] recieved " + JSON.stringify(jsonData)); }; function socketConn(socket) { @@ -2507,7 +2506,7 @@ if (cluster.isMaster) { if (!socket.writable) return; body.jsonrpc = "2.0"; debug("[MINER] PUSH TO MINER: " + JSON.stringify(body)); - if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG]: push " + JSON.stringify(body)); + if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG] push " + JSON.stringify(body)); socket.write(JSON.stringify(body) + "\n"); }; From 5a34f18c79e29a56d872ace0ab268d96ad2adf3b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 18:54:04 +0000 Subject: [PATCH 1217/1496] Added extra wallet debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 41cf6936f..2ef47cc55 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2442,7 +2442,7 @@ if (cluster.isMaster) { rs.on('error', function() { console.error("Can't open " + wallet_debug_fn + " file"); }); let lineReader = require('readline').createInterface({ input: rs }); lineReader.on('line', function (line) { - console.log(threadName + "[WALET DEBUG] added: '" + line + "'"); + console.log(threadName + "[WALLET DEBUG] added: '" + line + "'"); wallet_debug[line] = 1; }); }); From 337a9c5559b8e8506a36cd64a4a26ab73814f4ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 20:00:42 +0000 Subject: [PATCH 1218/1496] Added extra wallet debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2ef47cc55..de65e5dc9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -867,7 +867,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const factor = (typeof(miner.curr_coin_hash_factor) === 'undefined' ? 1 : miner.curr_coin_hash_factor) / coinHashFactor; if (miner.difficulty * factor > bt.difficulty * 3) { - debug("[MINER] Rejected best " + coin + " coin due to high diff " + miner.difficulty + " " + factor + " " + bt.difficulty); + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] Rejected best " + coin + " coin due to high diff " + miner.difficulty + " " + factor + " " + bt.difficulty); return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { From cf35d0d47b0072b2c9474a547b62bbd12af534ed Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 20:10:56 +0000 Subject: [PATCH 1219/1496] Fixed big diff processing --- lib/pool.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index de65e5dc9..f8611a419 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -865,9 +865,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const block_version = bt.block_version; const algo = global.coinFuncs.algoShortTypeStr(port, block_version); - const factor = (typeof(miner.curr_coin_hash_factor) === 'undefined' ? 1 : miner.curr_coin_hash_factor) / coinHashFactor; - if (miner.difficulty * factor > bt.difficulty * 3) { - if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] Rejected best " + coin + " coin due to high diff " + miner.difficulty + " " + factor + " " + bt.difficulty); + if (miner.difficulty / coinHashFactor > bt.difficulty * 3) { + if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] Rejected best " + coin + " coin due to high diff " + miner.difficulty + " " + coinHashFactor + " " + bt.difficulty); return; } if (!global.coinFuncs.isMinerSupportAlgo(algo, miner.algos)) { From 2b441fe9ddbca5fc776a09139e1822a9befcc241 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 20:27:57 +0000 Subject: [PATCH 1220/1496] Correct default nicehash diff for eth/RVN --- lib/pool.js | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f8611a419..c8a9a7091 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -885,11 +885,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (typeof(this.curr_coin) === 'undefined' || this.curr_coin != best_coin) { const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)); if (global.coinFuncs.blobTypeGrin(blob_type_num)) { - this.curr_min_diff = 1; - } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { - this.curr_min_diff = 0.01; + this.curr_coin_min_diff = 1; + } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + this.curr_coin_min_diff = 0.01; + } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { + this.curr_coin_min_diff = 0.01 * 0x100000000; } else { - this.curr_min_diff = global.config.pool.minDifficulty; + this.curr_coin_min_diff = global.config.pool.minDifficulty; } this.curr_coin = best_coin; this.curr_coin_hash_factor = lastCoinHashFactorMM[best_coin]; @@ -915,14 +917,22 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } } + this.curr_coin_hash_factor = 1; + this.curr_coin_min_diff = global.config.pool.minDifficulty; + this.curr_coin = this.selectBestCoin(); + if (agent && agent.includes('NiceHash')) { this.fixed_diff = true; - if (this.difficulty < global.coinFuncs.niceHashDiff) this.difficulty = global.coinFuncs.niceHashDiff; - } + let minNiceHashDiff; + const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(this.curr_coin)); + if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { + minNiceHashDiff = global.coinFuncs.niceHashDiff * 50; + } else { + minNiceHashDiff = global.coinFuncs.niceHashDiff; + } - this.curr_coin_hash_factor = 1; - this.curr_min_diff = global.config.pool.minDifficulty; - this.curr_coin = this.selectBestCoin(); + if (this.difficulty < minNiceHashDiff) this.difficulty = minNiceHashDiff; + } this.calcNewDiff = function () { const proxyMinerName = this.payout; // + ":" + this.identifier; @@ -933,19 +943,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi if (proxyMinerName in proxyMiners) { miner = proxyMiners[proxyMinerName]; target = 5; - min_diff = 10 * this.curr_min_diff; + min_diff = 10 * global.config.pool.minDifficulty; history_time = 5; if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { miner = minerWallets[this.payout]; target = 5; - min_diff = 10 * this.curr_min_diff; + min_diff = 10 * global.config.pool.minDifficulty; history_time = 5; if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; - min_diff = this.proxy ? 10 * this.curr_min_diff : this.curr_min_diff; + min_diff = this.proxy ? 10 * global.config.pool.minDifficulty : global.config.pool.minDifficulty; history_time = 60; if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } @@ -1024,7 +1034,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi } let coin_diff = this.difficulty / this.curr_coin_hash_factor; - if (coin_diff < this.curr_min_diff) coin_diff = this.curr_min_diff; + if (coin_diff < this.curr_coin_min_diff) coin_diff = this.curr_coin_min_diff; if (coin_diff > bt.difficulty) coin_diff = bt.difficulty; const blob_type_num = global.coinFuncs.portBlobType(bt.port); From 3726aa10873ea2d191194739f665ba9b4050edad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 21:56:50 +0000 Subject: [PATCH 1221/1496] Removed =0 --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 0f1f2e88e..597046bd7 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -99,7 +99,7 @@ CREATE TABLE `pools` ( UNIQUE KEY `pools_id_uindex` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `pool_workers` ( - `id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT=0, + `id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT, `pool_id` int(11) NOT NULL, `worker_id` int(11) NOT NULL, PRIMARY KEY (`id`), From 5f3d7d48dc23a1aa7103c4e8e4c6983d4a644efb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Jan 2021 22:55:58 +0000 Subject: [PATCH 1222/1496] Added extra wallet debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index c8a9a7091..a7b5733fc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -964,8 +964,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi const timeWindow = history_time * 60 * 1000; if (timeSinceLastShift > timeWindow) { if (timeSinceLastShift > 2 * timeWindow) { // forget all + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] forget diff"); miner.hashes = 0; } else { + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] diff window shift from " + miner.connectTimeShift + " and " + miner.hashesShift + " hashes"); miner.connectTime = miner.connectTimeShift; miner.hashes -= miner.hashesShift; } From 7d5ca30d8d3e809bed166eb073c4eef6333a0aa5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 29 Jan 2021 00:07:33 +0000 Subject: [PATCH 1223/1496] Fixed job norm diff --- lib/pool.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a7b5733fc..0fa5d875a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -968,9 +968,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi miner.hashes = 0; } else { if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] diff window shift from " + miner.connectTimeShift + " and " + miner.hashesShift + " hashes"); - miner.connectTime = miner.connectTimeShift; miner.hashes -= miner.hashesShift; } + miner.connectTime = miner.connectTimeShift; miner.connectTimeShift = Date.now(); miner.hashesShift = miner.hashes; } @@ -1056,6 +1056,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi height: bt.height, seed_hash: bt.seed_hash, difficulty: coin_diff, + norm_diff: coin_diff * this.curr_coin_hash_factor, coinHashFactor: params.coinHashFactor, submissions: {} }; @@ -1257,10 +1258,9 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { } function recordShareData(miner, job, isTrustedShare, blockTemplate) { - const normalized_diff = job.difficulty * miner.curr_coin_hash_factor; - miner.hashes += normalized_diff; + miner.hashes += job.norm_diff; let proxyMinerName = miner.payout; // + ":" + miner.identifier; - if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += normalized_diff; + if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName].hashes += job.norm_diff; const time_now = Date.now(); let wallet_key = miner.wallet_key + blockTemplate.port; @@ -1538,8 +1538,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const port = blockTemplate.port; const blob_type_num = job.blob_type_num; - const normalized_diff = job.difficulty * miner.curr_coin_hash_factor; - if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += normalized_diff; + if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.norm_diff; walletLastSeeTime[miner.payout] = Date.now(); let shareThrottled = function() { @@ -1550,7 +1549,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { process.send({type: 'throttledShare'}); addProxyMiner(miner); const proxyMinerName = miner.payout; // + ":" + miner.identifier; - proxyMiners[proxyMinerName].hashes += normalized_diff; + proxyMiners[proxyMinerName].hashes += job.norm_diff; adjustMinerDiff(miner); return true; } From 4330200bde613d6d9b915fec988857b15867f1fb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 29 Jan 2021 05:43:18 +0000 Subject: [PATCH 1224/1496] Fixed ETH uncle reward calc --- lib/blockManager.js | 2 +- lib/coins/xmr.js | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index aca2833d5..712378107 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -709,7 +709,7 @@ function altblockUnlocker(altblockUnlockerCB) { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); return next(); - } else if (err !== null) { + } else if (err !== null && block.port != 8545) { console.error("Can't get altblock of " + block.port + " port with " + block.height + " height"); global.coinFuncs.getPortBlockHeaderByID(block.port, block.height, (err, body) => { if (err === null && body.hash !== block.hash) { diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index af2666544..b00b21e57 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -198,6 +198,9 @@ setInterval(function(queue_obj){ } }, 30*1000, shareVerifyQueue); +const ETH_BASE_REWARD = 2; +const ETH_MULTIPLIER = 1000000000000000000; + function calcEthReward(block, tx_reciepts) { let gas_prices = {}; block.transactions.forEach(function(tx) { @@ -207,7 +210,7 @@ function calcEthReward(block, tx_reciepts) { tx_reciepts.forEach(function(tx) { fee += parseInt(tx.gasUsed) * gas_prices[tx.transactionHash]; }); - return (2 + 2 * (block.uncles.length / 32)) * 1000000000000000000 + fee; + return (ETH_BASE_REWARD + ETH_BASE_REWARD * (block.uncles.length / 32)) * ETH_MULTIPLIER + fee; } function Coin(data){ @@ -332,19 +335,37 @@ function Coin(data){ return callback(null, body.result); }); } else if (port == 8545) { + let _this = this; global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { if (!body || !body.result) { console.error(JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ body.result.number ] }, function (body2) { - if (!body2 || !body2.result) { - console.error(JSON.stringify(body2)); - return callback(true, body2); - } - body.result.reward = calcEthReward(body.result, body2.result); - body.result.height = parseInt(body.result.number); - return callback(null, body.result); + body.result.height = parseInt(body.result.number); + _this.getPortBlockHeaderByID(port, body.result.height, function(err, body_height) { + if (err) return callback(true, body); + if (body.result.hash === body_height.hash) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ body.result.number ] }, function (body2) { + if (!body2 || !body2.result) { + console.error(JSON.stringify(body2)); + return callback(true, body2); + } + body.result.reward = calcEthReward(body.result, body2.result); + return callback(null, body.result); + }); + + // uncle block? + } else async.eachSeries(Array(16).fill().map((element, index) => body.result.height + index - 7), function(block_height, next) { + _this.getPortBlockHeaderByID(port, block_height, function(err, body_height) { + if (err) return next(); + const uncleIndex = body_height.uncles.indexOf("0x" + blockHash); + if (uncleIndex === -1 || uncleIndex >= 7) return next(); + return next((ETH_BASE_REWARD * (7 - uncleIndex) / 8) * ETH_MULTIPLIER); + }); + }, function(uncleReward) { + body.result.reward = uncleReward ? uncleReward : null; + return callback(null, body.result); + }); }); }); } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { From 6c7476948805e9615201f001bb545e759ab56140 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Jan 2021 03:30:01 +0000 Subject: [PATCH 1225/1496] Added Raven block caching --- lib/coins/xmr.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b00b21e57..ad926f285 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -434,6 +434,8 @@ function Coin(data){ return this.getPortBlockHeaderByHash(global.config.daemon.port, blockHash, callback); }; + this.ravenBlockHashCache = {}; + this.getPortLastBlockHeader = function(port, callback, no_error_report) { if (port == 11898) { global.support.rpcPortDaemon2(port, 'block/last', null, function (body) { @@ -451,7 +453,11 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); + if (body.result in _this.ravenBlockHashCache) return callback(null, _this.ravenBlockHashCache[body.result]); + _this.getPortAnyBlockHeaderByHash(port, body.result, false, function (err, body2) { + if (err === null) _this.ravenBlockHashCache[body.result] = body2.result; + return callback(err, body2); + }); }); } else if (port == 8545) { return this.getPortBlockHeaderByID(port, "latest", callback); From 0105edd40caf9bea0c366ee96d2964548840bc35 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Jan 2021 03:33:45 +0000 Subject: [PATCH 1226/1496] Added Raven block caching --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ad926f285..21dd448bf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -455,7 +455,7 @@ function Coin(data){ } if (body.result in _this.ravenBlockHashCache) return callback(null, _this.ravenBlockHashCache[body.result]); _this.getPortAnyBlockHeaderByHash(port, body.result, false, function (err, body2) { - if (err === null) _this.ravenBlockHashCache[body.result] = body2.result; + if (err === null) _this.ravenBlockHashCache[body.result] = body2; return callback(err, body2); }); }); From 39022f774317f998c4fc1fd5c3d07e86bfc0b400 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 30 Jan 2021 03:40:06 +0000 Subject: [PATCH 1227/1496] Added Raven block caching --- lib/coins/xmr.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 21dd448bf..132401c11 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -434,8 +434,6 @@ function Coin(data){ return this.getPortBlockHeaderByHash(global.config.daemon.port, blockHash, callback); }; - this.ravenBlockHashCache = {}; - this.getPortLastBlockHeader = function(port, callback, no_error_report) { if (port == 11898) { global.support.rpcPortDaemon2(port, 'block/last', null, function (body) { @@ -453,9 +451,12 @@ function Coin(data){ console.error(JSON.stringify(body)); return callback(true, body); } - if (body.result in _this.ravenBlockHashCache) return callback(null, _this.ravenBlockHashCache[body.result]); + if (_this.lastRavenBlockHash === body.result) return callback(null, _this.lastRavenBlock); _this.getPortAnyBlockHeaderByHash(port, body.result, false, function (err, body2) { - if (err === null) _this.ravenBlockHashCache[body.result] = body2; + if (err === null) { + _this.lastRavenBlockHash = body.result; + _this.lastRavenBlock = body2; + } return callback(err, body2); }); }); From d1bfa0a59c43a7f6217feb6109e1780ae998afc4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Feb 2021 22:53:37 +0000 Subject: [PATCH 1228/1496] Fixed ETH uncle reward formula --- lib/coins/xmr.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 132401c11..2183f1eaf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -357,12 +357,16 @@ function Coin(data){ // uncle block? } else async.eachSeries(Array(16).fill().map((element, index) => body.result.height + index - 7), function(block_height, next) { _this.getPortBlockHeaderByID(port, block_height, function(err, body_height) { - if (err) return next(); + if (err) { + if (is_our_block) return next(false); // need to wait for more blocks before it will be reported as uncle + return next(); + } const uncleIndex = body_height.uncles.indexOf("0x" + blockHash); if (uncleIndex === -1 || uncleIndex >= 7) return next(); - return next((ETH_BASE_REWARD * (7 - uncleIndex) / 8) * ETH_MULTIPLIER); + return next((ETH_BASE_REWARD * (8 - (body_height.uncles.length - uncleIndex)) / 8) * ETH_MULTIPLIER); }); }, function(uncleReward) { + if (uncleReward === false) return callback(true, body); body.result.reward = uncleReward ? uncleReward : null; return callback(null, body.result); }); From afe3abe05a93279954be6895c2c2ebca1923f258 Mon Sep 17 00:00:00 2001 From: Charlie Shaw Date: Fri, 5 Feb 2021 10:26:51 -0600 Subject: [PATCH 1229/1496] update deploy caddy download url --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 962df87e5..857d3977c 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -48,7 +48,7 @@ cd build sudo ln -s `pwd` /var/www CADDY_DOWNLOAD_DIR=$(mktemp -d) cd $CADDY_DOWNLOAD_DIR -curl -sL "https://snipanet.com/caddy.tar.gz" | tar -xz caddy init/linux-systemd/caddy.service +curl -sL "https://github.com/caddyserver/caddy/releases/download/v2.3.0/caddy_2.3.0_linux_amd64.tar.gz" | tar -xz caddy init/linux-systemd/caddy.service sudo mv caddy /usr/local/bin sudo chown root:root /usr/local/bin/caddy sudo chmod 755 /usr/local/bin/caddy From 8e8ad010ee2f0790b7c4f87879ab5366b5d9ff8f Mon Sep 17 00:00:00 2001 From: Charlie Shaw Date: Fri, 5 Feb 2021 10:51:01 -0600 Subject: [PATCH 1230/1496] readme updates --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index ab0738684..eb5e2b2fc 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Setup Instructions Server Requirements ------------------- +* Ubuntu 16.04, 18.04 (confirmed working) * 4 Gb Ram * 2 CPU Cores (with AES_NI) * 150 Gb SSD-Backed Storage - If you're doing a multi-server install, the leaf nodes do not need this much storage. They just need enough storage to hold the blockchain for your node. The pool comes configured to use up to 60Gb of storage for LMDB. Assuming you have the longRunner worker running, it should never get near this size, but be aware that it /can/ bloat readily if things error, so be ready for this! @@ -88,8 +89,6 @@ The installer assumes that you will be running a single-node instance and using The following raw binaries **MUST BE AVAILABLE FOR IT TO BOOTSTRAP**: * sudo -I've confirmed that the default server 16.04 installation has these requirements. - The pool comes pre-configured with values for Monero (XMR), these may need to be changed depending on the exact requirements of your coin. Other coins will likely be added down the road, and most likely will have configuration.sqls provided to overwrite the base configurations for their needs, but can be configured within the frontend as well. The pool ALSO applies a series of patches: Fluffy Blocks, Additional Open P2P Connections, 128 Txn Bug Fix. If you don't like these, replace the auto-installed monerod fixes! From 8410d296557cab37cdd295ce238abe4bd6f09fd6 Mon Sep 17 00:00:00 2001 From: Charlie Shaw Date: Fri, 5 Feb 2021 11:08:32 -0600 Subject: [PATCH 1231/1496] caddy free commercial license --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 857d3977c..1ff35f8fc 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -48,7 +48,7 @@ cd build sudo ln -s `pwd` /var/www CADDY_DOWNLOAD_DIR=$(mktemp -d) cd $CADDY_DOWNLOAD_DIR -curl -sL "https://github.com/caddyserver/caddy/releases/download/v2.3.0/caddy_2.3.0_linux_amd64.tar.gz" | tar -xz caddy init/linux-systemd/caddy.service +curl -sL "https://github.com/caddyserver/caddy/releases/download/v0.10.8/caddy_v0.10.8_linux_amd64.tar.gz" | tar -xz caddy init/linux-systemd/caddy.service sudo mv caddy /usr/local/bin sudo chown root:root /usr/local/bin/caddy sudo chmod 755 /usr/local/bin/caddy From 830740551381b9b616ebab4411de05a3dcf635f8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Feb 2021 21:42:52 +0000 Subject: [PATCH 1232/1496] Potentialy fixed issue with stuck block template for non algo switching pools --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0fa5d875a..aa6f707d4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2290,8 +2290,11 @@ if (cluster.isMaster) { }); + newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; + templateUpdate(""); + setTimeout(templateUpdate, DAEMON_POLL_MS, "", true); + if (global.config.daemon.enableAlgoSwitching) { - newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; if (global.config.daemon.enableAlgoSwitching) COINS.forEach(function(coin) { newCoinHashFactor[coin] = lastCoinHashFactor[coin] = lastCoinHashFactorMM[coin] = 0; setInterval(updateCoinHashFactor, 5*1000, coin); @@ -2302,8 +2305,6 @@ if (cluster.isMaster) { console.warn("global.config.daemon.enableAlgoSwitching is not enabled"); } - templateUpdate(""); - setTimeout(templateUpdate, DAEMON_POLL_MS, "", true); global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " online", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " is online"); let block_notify_server = net.createServer(function (socket) { From 5ddf301293d87c33b402d18584c4f52756af666d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 14 Feb 2021 00:03:06 +0000 Subject: [PATCH 1233/1496] Avoid errors in case of non algo switching pool --- deployment/base.sql | 1 + lib/pool_stats.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 597046bd7..88aa41bd6 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -264,6 +264,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'exchangeRate', '0', 'float', 'Current exchange rate'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'bestExchange', 'xmrto', 'string', 'Current best exchange'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'mixIn', '10', 'int', 'Mixin count for coins that support such things.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'ethWalletPass', '', 'string', 'Ethereum wallet password'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferLength', '480', 'int', 'Number of items to be cached in the stats buffers.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferHours', '24', 'int', 'Number of hours to be cached in the stats buffers.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pps', 'enable', 'false', 'bool', 'Enable PPS or not'); diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 917d94528..211c07099 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -367,7 +367,8 @@ function updatePoolInformation() { let network_info = {}; function updateBlockHeader() { - async.eachSeries(global.coinFuncs.getPORTS(), function(port, next) { + const ports = global.config.daemon.enableAlgoSwitching ? global.coinFuncs.getPORTS() : [ global.config.daemon.port ]; + async.eachSeries(ports, function(port, next) { global.coinFuncs.getPortLastBlockHeader(port, function(err, body){ if (err) return next(); network_info[port] = { From 6c4e924020bf7ad42ee33be5e5e9f4a37056ed0a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Feb 2021 15:59:46 +0000 Subject: [PATCH 1234/1496] New function to update block value --- manage_scripts/altblock_fix_raw_reward.js | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 manage_scripts/altblock_fix_raw_reward.js diff --git a/manage_scripts/altblock_fix_raw_reward.js b/manage_scripts/altblock_fix_raw_reward.js new file mode 100644 index 000000000..10cbbf61f --- /dev/null +++ b/manage_scripts/altblock_fix_raw_reward.js @@ -0,0 +1,41 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.hash) { + console.error("Please specify altblock hash"); + process.exit(1); +} +const hash = argv.hash; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn(); + let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + if (blockData.hash === hash) { + console.log("Found altblock with " + blockData.hash + " hash"); + global.coinFuncs.getPortAnyBlockHeaderByHash(blockData.port, argv.hash, false, function (err, body) { + if (err) { + cursor.close(); + txn.commit(); + console.error("Can't get block header"); + process.exit(1); + } + console.log("Changing raw block reward from " + blockData.value + " to " + body.reward); + //blockData.value = body.reward; + //txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + txn.commit(); + cursor.close(); + console.log("Changed altblock"); + process.exit(0); + }); + } + }); + } + cursor.close(); + txn.commit(); + console.log("Not found altblock with " + hash + " hash"); + process.exit(1); +}); From 5af15aeab6107361b191504c221275ad908f3231 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Feb 2021 16:03:58 +0000 Subject: [PATCH 1235/1496] New function to update block value --- manage_scripts/altblock_fix_raw_reward.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/manage_scripts/altblock_fix_raw_reward.js b/manage_scripts/altblock_fix_raw_reward.js index 10cbbf61f..6fc046367 100644 --- a/manage_scripts/altblock_fix_raw_reward.js +++ b/manage_scripts/altblock_fix_raw_reward.js @@ -11,12 +11,14 @@ const hash = argv.hash; require("../init_mini.js").init(function() { let txn = global.database.env.beginTxn(); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + let is_found = 0; for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); - if (blockData.hash === hash) { + if (!is_found && blockData.hash === hash) { console.log("Found altblock with " + blockData.hash + " hash"); global.coinFuncs.getPortAnyBlockHeaderByHash(blockData.port, argv.hash, false, function (err, body) { + is_found = 1; if (err) { cursor.close(); txn.commit(); @@ -34,8 +36,10 @@ require("../init_mini.js").init(function() { } }); } - cursor.close(); - txn.commit(); - console.log("Not found altblock with " + hash + " hash"); - process.exit(1); + if (!is_found) { + cursor.close(); + txn.commit(); + console.log("Not found altblock with " + hash + " hash"); + process.exit(1); + } }); From 35b1a2e1bda815dbf24cab24a6dbe5d121e9e299 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Feb 2021 16:04:28 +0000 Subject: [PATCH 1236/1496] New function to update block value --- manage_scripts/altblock_fix_raw_reward.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/altblock_fix_raw_reward.js b/manage_scripts/altblock_fix_raw_reward.js index 6fc046367..c1162a202 100644 --- a/manage_scripts/altblock_fix_raw_reward.js +++ b/manage_scripts/altblock_fix_raw_reward.js @@ -17,8 +17,8 @@ require("../init_mini.js").init(function() { let blockData = global.protos.AltBlock.decode(data); if (!is_found && blockData.hash === hash) { console.log("Found altblock with " + blockData.hash + " hash"); + is_found = 1; global.coinFuncs.getPortAnyBlockHeaderByHash(blockData.port, argv.hash, false, function (err, body) { - is_found = 1; if (err) { cursor.close(); txn.commit(); From 1859eb436c1ae07d7515f511f63788cf6c859191 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Feb 2021 16:05:49 +0000 Subject: [PATCH 1237/1496] New function to update block value --- manage_scripts/altblock_fix_raw_reward.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manage_scripts/altblock_fix_raw_reward.js b/manage_scripts/altblock_fix_raw_reward.js index c1162a202..6be4a892e 100644 --- a/manage_scripts/altblock_fix_raw_reward.js +++ b/manage_scripts/altblock_fix_raw_reward.js @@ -26,8 +26,8 @@ require("../init_mini.js").init(function() { process.exit(1); } console.log("Changing raw block reward from " + blockData.value + " to " + body.reward); - //blockData.value = body.reward; - //txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + blockData.value = body.reward; + txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); txn.commit(); cursor.close(); console.log("Changed altblock"); From d184f0c992c610134f228440141b01ce34e3beb1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Feb 2021 20:56:29 +0000 Subject: [PATCH 1238/1496] Improved ETH extranonce handling --- lib/pool.js | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index aa6f707d4..862bcc425 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -41,16 +41,20 @@ function get_new_eth_job_id() { let uniqueWorkerId; let uniqueWorkerIdBits; -let ethExtraonceId = 0; +let freeEthExtranonces = [...Array(1 << (16 - uniqueWorkerIdBits)).keys()]; function get_new_eth_extranonce_id() { - if (++ethExtraonceId >= 1 << (16 - uniqueWorkerIdBits)) { - ethExtraonceId = 0; - const err_str = threadName + "Pool server " + global.config.hostname + " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; - console.error(err_str); - global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool node has extranonce overflow", err_str); + if (!freeEthExtranonces.length) { + const err_str = threadName + "Pool server " + global.config.hostname + " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool node has extranonce overflow", err_str); + return null; } - return pad_hex(((ethExtraonceId << uniqueWorkerIdBits) + uniqueWorkerId).toString(16), 2); + return freeEthExtranonces.pop(); +}; + +function eth_extranonce(id) { + return id === null ? null : pad_hex(((id << uniqueWorkerIdBits) + uniqueWorkerId).toString(16), 2); }; let bannedIPs = {}; @@ -1776,7 +1780,14 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se ); if (miner.debugMiner) socket.debugMiner = 1; //console.log(threadName + miner.logString + " [WALLET DEBUG] " + method + ": " + JSON.stringify(params)); if (method === 'mining.authorize') { - miner.eth_extranonce = socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); + const new_id = socket.eth_extranonce_id ? socket.eth_extranonce_id : get_new_eth_extranonce_id(); + if (new_id !== null) { + socket.eth_extranonce_id = new_id; + miner.eth_extranonce = eth_extranonce(new_id); + } else { + miner.valid_miner = false; + miner.error = "Not enough extranoces. Switch to other pool node."; + } } if (params.agent && process.env['WORKER_ID'] == 1) minerAgents[params.agent] = 1; let time_now = Date.now(); @@ -1835,9 +1846,15 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const params = getCoinJobParams(coin); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { // xmrig specifics - miner.eth_extranonce = socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); - sendReply(null, { id: minerId, algo: params.algo_name, extra_nonce: miner.eth_extranonce }); - miner.sendCoinJob(coin, params); + const new_id = socket.eth_extranonce_id ? socket.eth_extranonce_id : get_new_eth_extranonce_id(); + if (new_id !== null) { + socket.eth_extranonce_id = new_id; + miner.eth_extranonce = eth_extranonce(new_id); + sendReply(null, { id: minerId, algo: params.algo_name, extra_nonce: miner.eth_extranonce }); + miner.sendCoinJob(coin, params); + } else { + sendReplyFinal("Not enough extranoces. Switch to other pool node."); + } } else { sendReply(null, { id: minerId, job: miner.getCoinJob(coin, params), status: 'OK' }); } @@ -1851,9 +1868,14 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se case 'mining.subscribe': { // Raven/Eth only if (params && (params instanceof Array) && params.length >= 1) socket.eth_agent = params[0]; - socket.eth_extranonce = socket.eth_extranonce ? socket.eth_extranonce : get_new_eth_extranonce_id(); - // extranonce is not really needed for Raven (extraonce is specificed as part of coinbase tx) - sendReply(null, [ [ "mining.notify", get_new_id(), "EthereumStratum/1.0.0" ], socket.eth_extranonce ]); + const new_id = socket.eth_extranonce_id ? socket.eth_extranonce_id : get_new_eth_extranonce_id(); + if (new_id !== null) { + socket.eth_extranonce_id = new_id; + // extranonce is not really needed for Raven (extraonce is specificed as part of coinbase tx) + sendReply(null, [ [ "mining.notify", get_new_id(), "EthereumStratum/1.0.0" ], eth_extranonce(new_id) ]); + } else { + sendReplyFinal("Not enough extranoces. Switch to other pool node."); + } break; } @@ -2571,6 +2593,7 @@ if (cluster.isMaster) { }).on('close', function () { pushMessage = function () {}; if (socket.miner_ids) socket.miner_ids.forEach(miner_id => activeMiners.delete(miner_id)); + if ("eth_extranonce_id" in socket) freeEthExtranonces.push(socket.eth_extranonce_id); }); } From cf0688e47d9c29c1db6508625b293f373760a4aa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Feb 2021 21:02:13 +0000 Subject: [PATCH 1239/1496] Improved ETH extranonce handling --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 862bcc425..ad5211ccc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -44,6 +44,7 @@ let uniqueWorkerIdBits; let freeEthExtranonces = [...Array(1 << (16 - uniqueWorkerIdBits)).keys()]; function get_new_eth_extranonce_id() { +console.log(get_new_eth_extranonce_id); if (!freeEthExtranonces.length) { const err_str = threadName + "Pool server " + global.config.hostname + " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; console.error(err_str); From 70eaef5c1b91567174fd204773136cded6e81ea3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Feb 2021 21:04:45 +0000 Subject: [PATCH 1240/1496] Improved ETH extranonce handling --- lib/pool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ad5211ccc..f308e34de 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -41,10 +41,10 @@ function get_new_eth_job_id() { let uniqueWorkerId; let uniqueWorkerIdBits; -let freeEthExtranonces = [...Array(1 << (16 - uniqueWorkerIdBits)).keys()]; +let freeEthExtranonces = []; function get_new_eth_extranonce_id() { -console.log(get_new_eth_extranonce_id); +console.log(freeEthExtranonces.length); if (!freeEthExtranonces.length) { const err_str = threadName + "Pool server " + global.config.hostname + " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; console.error(err_str); @@ -2365,6 +2365,7 @@ if (cluster.isMaster) { uniqueWorkerId = id; uniqueWorkerIdBits = 0; while (maxId) { maxId >>= 1; ++ uniqueWorkerIdBits; } + freeEthExtranonces = [...Array(1 << (16 - uniqueWorkerIdBits)).keys()]; console.log(threadName + "Starting pool worker with " + uniqueWorkerId + " unique id and " + uniqueWorkerIdBits + " reserved bits"); newCoinHashFactor[""] = lastCoinHashFactor[""] = lastCoinHashFactorMM[""] = 1; From 171e7eb21376b08b915ecbbda3263a2432131406 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Feb 2021 21:06:20 +0000 Subject: [PATCH 1241/1496] Improved ETH extranonce handling --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f308e34de..0687614cc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -44,7 +44,6 @@ let uniqueWorkerIdBits; let freeEthExtranonces = []; function get_new_eth_extranonce_id() { -console.log(freeEthExtranonces.length); if (!freeEthExtranonces.length) { const err_str = threadName + "Pool server " + global.config.hostname + " has overlow extranonce of " + (16 - uniqueWorkerIdBits) + " bits"; console.error(err_str); From c3538b13cf1f3da97deea98862f5c3685d57ffcf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Feb 2021 21:32:26 +0000 Subject: [PATCH 1242/1496] Upped proxy def target time --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0687614cc..b09f1dd46 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -946,19 +946,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi let history_time; if (proxyMinerName in proxyMiners) { miner = proxyMiners[proxyMinerName]; - target = 5; + target = 15; min_diff = 10 * global.config.pool.minDifficulty; history_time = 5; if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { miner = minerWallets[this.payout]; - target = 5; + target = 15; min_diff = 10 * global.config.pool.minDifficulty; history_time = 5; if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); } else { miner = this; - target = this.proxy ? 5 : global.config.pool.targetTime; + target = this.proxy ? 15 : global.config.pool.targetTime; min_diff = this.proxy ? 10 * global.config.pool.minDifficulty : global.config.pool.minDifficulty; history_time = 60; if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); From f65910ee1045b4c897ae3fb0ddfdf648dbb57eb1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Feb 2021 21:24:39 +0000 Subject: [PATCH 1243/1496] Fixed mining stuck altcoins --- deployment/base.sql | 8 ++++---- lib/pool.js | 23 ++++++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 88aa41bd6..26aa1ae3d 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -248,9 +248,9 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'pplnsFee', '.6', 'float', 'Fee charged for the usage of the PPLNS pool'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'propFee', '.7', 'float', 'Fee charged for the usage of the proportial pool'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'soloFee', '.4', 'float', 'Fee charged for usage of the solo mining pool'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'exchangeMin', '1', 'float', 'Minimum XMR balance for payout to exchange/payment ID'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'walletMin', '.3', 'float', 'Minimum XMR balance for payout to personal wallet'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'defaultPay', '.3', 'float', 'Default XMR balance for payout'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'exchangeMin', '.1', 'float', 'Minimum XMR balance for payout to exchange/payment ID'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'walletMin', '.01', 'float', 'Minimum XMR balance for payout to personal wallet'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'defaultPay', '.1', 'float', 'Default XMR balance for payout'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'devDonation', '3', 'float', 'Donation to XMR core development'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'poolDevDonation', '3', 'float', 'Donation to pool developer'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'denom', '.000001', 'float', 'Minimum balance that will be paid out to.'); @@ -308,7 +308,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'blockCleanWarning', '360', 'int', 'Blocks before longRunner cleaner module will start to warn.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'enable', 'true', 'bool', 'Enable PPLNS on the pool.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('solo', 'enable', 'true', 'bool', 'Enable SOLO mining on the pool'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewAmount', '.011', 'float', 'Amount to charge for the txn fee'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewAmount', '.001', 'float', 'Amount to charge for the txn fee'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewEnd', '4', 'float', 'Value at which txn fee amount drops to 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'rpcPasswordEnabled', 'false', 'bool', 'Does the wallet use a RPC password?'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'rpcPasswordPath', '', 'string', 'Path and file for the RPC password file location'); diff --git a/lib/pool.js b/lib/pool.js index b09f1dd46..fc1da174f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -503,8 +503,12 @@ function setNewBlockTemplate(template) { return; } } - activeBlockTemplates[coin].timeOutdate = Date.now() + 4*1000; - if (!(coin in pastBlockTemplates)) pastBlockTemplates[coin] = global.support.circularBuffer(10); + activeBlockTemplates[coin].timeCreated = Date.now(); + if (coin in pastBlockTemplates) { + pastBlockTemplates[coin].get(0).timeoutTime = Date.now() + 4*1000; + } else { + pastBlockTemplates[coin] = global.support.circularBuffer(10); + } pastBlockTemplates[coin].enq(activeBlockTemplates[coin]); if (activeBlockTemplates[coin].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } @@ -2041,10 +2045,10 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return t.idHash === job.blockHash; })[0]; let is_outdated = false; - if (blockTemplate && blockTemplate.timeOutdate) { - const late_time = Date.now() - blockTemplate.timeOutdate; + if (blockTemplate && blockTemplate.timeoutTime) { + const late_time = Date.now() - blockTemplate.timeoutTime; if (late_time > 0) { - const max_late_time = global.config.pool.targetTime*1000; + const max_late_time = global.config.pool.targetTime * 1000; if (late_time < max_late_time) { let factor = (max_late_time - late_time) / max_late_time; job.rewarded_difficulty = job.difficulty * Math.pow(factor, 6); //Math.floor(job.difficulty * Math.pow(factor, 6)); @@ -2055,8 +2059,8 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } } if (!blockTemplate || is_outdated) { - let err_str = is_outdated ? "Block outdated" : "Block expired"; - let time_now = Date.now(); + const err_str = is_outdated ? "Block outdated" : "Block expired"; + const time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); lastMinerLogTime[miner.payout] = time_now; @@ -2068,6 +2072,11 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } } else { blockTemplate = activeBlockTemplates[job.coin]; + // kill miner if it mines block template for disabled coin for more than some time + if (!lastCoinHashFactorMM[job.coin] && Date.now() - blockTemplate.timeCreated > 10*60*1000) { + sendReplyFinal("This algo was temporary disabled due to coin daemon issues. Consider using https://github.com/MoneroOcean/meta-miner to allow your miner auto algo switch in this case."); + return; + } } job.rewarded_difficulty2 = job.rewarded_difficulty * job.coinHashFactor; From 789194b51d368ab25d1ce4642cd8364d40836dcf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Feb 2021 18:07:17 +0000 Subject: [PATCH 1244/1496] Added bad/good shares to allWorkerData --- lib/api.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/api.js b/lib/api.js index 7af69f90f..f2436463c 100644 --- a/lib/api.js +++ b/lib/api.js @@ -60,9 +60,12 @@ function getAllWorkerStats(address, callback){ global: { lts: globalStatsCache !== false ? Math.floor(globalStatsCache.lastHash / 1000) : false, identifer: 'global', - hash: globalStatsCache !== false ? globalStatsCache.hash : false, - hash2: globalStatsCache !== false ? globalStatsCache.hash2 : false, - totalHash: globalCache !== false ? globalCache.totalHashes : false + hash: globalStatsCache !== false ? globalStatsCache.hash : false, + hash2: globalStatsCache !== false ? globalStatsCache.hash2 : false, + totalHash: globalCache !== false ? globalCache.totalHashes : false, + validShares: globalCache !== false ? Number(globalCache.goodShares) : false, + invalidShares: globalCache !== false ? Number(globalCache.badShares) : false + } }; if (identifiers === false || identifiers.length == 0) return callback(null, returnData); @@ -74,9 +77,11 @@ function getAllWorkerStats(address, callback){ returnData[identifier] = { lts: cachedStatsData !== false ? Math.floor(cachedStatsData.lastHash / 1000) : false, identifer: identifier, - hash: cachedStatsData !== false ? cachedStatsData.hash : false, - hash2: cachedStatsData !== false ? cachedStatsData.hash2 : false, - totalHash: cachedData !== false ? cachedData.totalHashes : false + hash: cachedStatsData !== false ? cachedStatsData.hash : false, + hash2: cachedStatsData !== false ? cachedStatsData.hash2 : false, + totalHash: cachedData !== false ? cachedData.totalHashes : false, + validShares: cachedData !== false ? Number(cachedData.goodShares) : false, + invalidShares: cachedData !== false ? Number(cachedData.badShares) : false }; if (++ intCounter === identifiers.length) return callback(null, returnData); }); From fe8713e84183e79a4fbae69003b5d39690211034 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 23 Feb 2021 18:19:40 +0000 Subject: [PATCH 1245/1496] Added bad/good shares to allWorkerData --- lib/api.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/api.js b/lib/api.js index f2436463c..a81ee334e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -58,13 +58,13 @@ function getAllWorkerStats(address, callback){ let globalStatsCache = global.database.getCache("stats:" + address); let returnData = { global: { - lts: globalStatsCache !== false ? Math.floor(globalStatsCache.lastHash / 1000) : false, - identifer: 'global', + lts: globalStatsCache !== false ? Math.floor(globalStatsCache.lastHash / 1000) : false, + identifer: 'global', hash: globalStatsCache !== false ? globalStatsCache.hash : false, hash2: globalStatsCache !== false ? globalStatsCache.hash2 : false, totalHash: globalCache !== false ? globalCache.totalHashes : false, validShares: globalCache !== false ? Number(globalCache.goodShares) : false, - invalidShares: globalCache !== false ? Number(globalCache.badShares) : false + invalidShares: globalCache !== false ? (globalCache.badShares ? Number(globalCache.badShares) : 0) : false } }; @@ -75,13 +75,13 @@ function getAllWorkerStats(address, callback){ let cachedData = global.database.getCache(id2); let cachedStatsData = global.database.getCache("stats:" + id2); returnData[identifier] = { - lts: cachedStatsData !== false ? Math.floor(cachedStatsData.lastHash / 1000) : false, - identifer: identifier, + lts: cachedStatsData !== false ? Math.floor(cachedStatsData.lastHash / 1000) : false, + identifer: identifier, hash: cachedStatsData !== false ? cachedStatsData.hash : false, hash2: cachedStatsData !== false ? cachedStatsData.hash2 : false, totalHash: cachedData !== false ? cachedData.totalHashes : false, validShares: cachedData !== false ? Number(cachedData.goodShares) : false, - invalidShares: cachedData !== false ? Number(cachedData.badShares) : false + invalidShares: cachedData !== false ? (cachedData.badShares ? Number(cachedData.badShares) : 0) : false }; if (++ intCounter === identifiers.length) return callback(null, returnData); }); @@ -105,13 +105,13 @@ function getAddressStats(address, extCallback){ function (callback) { debug(threadName + "Checking Influx for last 10min avg for /miner/address/stats"); return callback(null, { - hash: cachedStatsData.hash, - hash2: cachedStatsData.hash2, - identifier: 'global', - lastHash: Math.floor(cachedStatsData.lastHash / 1000), - totalHashes: cachedData.totalHashes, - validShares: Number(cachedData.goodShares), - invalidShares: Number(cachedData.badShares) + hash: cachedStatsData.hash, + hash2: cachedStatsData.hash2, + identifier: 'global', + lastHash: Math.floor(cachedStatsData.lastHash / 1000), + totalHashes: cachedData.totalHashes, + validShares: Number(cachedData.goodShares), + invalidShares: cachedData.badShares ? Number(cachedData.badShares) : 0 }); }, function (returnData, callback) { @@ -487,13 +487,13 @@ app.get('/miner/:address/stats/:identifier', cache('10 seconds'), function (req, let cachedData = global.database.getCache(memcKey); let cachedStatsData = global.database.getCache("stats:" + memcKey); return res.json({ - lts: Math.floor(cachedStatsData.lastHash / 1000), - identifer: identifier, - hash: cachedStatsData.hash, - hash2: cachedStatsData.hash2, - totalHash: cachedData.totalHashes, - validShares: Number(cachedData.goodShares), - invalidShares: Number(cachedData.badShares) + lts: Math.floor(cachedStatsData.lastHash / 1000), + identifer: identifier, + hash: cachedStatsData.hash, + hash2: cachedStatsData.hash2, + totalHash: cachedData.totalHashes, + validShares: Number(cachedData.goodShares), + invalidShares: cachedData.badShares ? Number(cachedData.badShares) : 0 }); }); From 4d01d38fa989741c7f28abbc94fb98e9a66361e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Feb 2021 16:27:17 +0000 Subject: [PATCH 1246/1496] Do not store zero reward blocks --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index e5312723f..419bee6d8 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -448,7 +448,7 @@ function Database(){ } } } - if (err || typeof(header) === 'undefined' || !header) { // bad block and not orphan + if (err || typeof(header) === 'undefined' || !header || !header.reward) { // bad block and not orphan if (blockDataDecoded.hash in badBlocks) { console.error("Invalidating " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); return callback(true); From 67bb889db5882f5eec1414a9a56ce275f27d74dc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Mar 2021 03:44:12 +0000 Subject: [PATCH 1247/1496] Fixed ETH uncle block rewards --- lib/coins/xmr.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2183f1eaf..b84a3eeb0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -267,7 +267,7 @@ function Coin(data){ if (body) { return callback(null, body); } else { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); return callback(true, body); } }); @@ -275,7 +275,7 @@ function Coin(data){ let _this = this; global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); return callback(true, body); } return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); @@ -284,14 +284,14 @@ function Coin(data){ const blockId2 = blockId === "latest" ? blockId : "0x" + blockId.toString(16); global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByNumber', params: [ blockId2, true ] }, function (body) { if (!body || !body.result) { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); return callback(true, body); } body.result.height = parseInt(body.result.number); if (blockId === "latest") return callback(null, body.result); // do not need rewards for the latest block global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ blockId2 ] }, function (body2) { if (!body2 || !body2.result) { - console.error(JSON.stringify(body2)); + console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body2)); return callback(true, body2); } body.result.reward = calcEthReward(body.result, body2.result); @@ -303,7 +303,7 @@ function Coin(data){ if (body && body.hasOwnProperty('result')) { return callback(null, body.result.block_header); } else { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); return callback(true, body); } }); @@ -320,7 +320,7 @@ function Coin(data){ if (port == 11898) { global.support.rpcPortDaemon2(port, 'block/' + blockHash, null, function (body) { if (typeof(body) === 'undefined') { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } return callback(null, body); @@ -328,7 +328,7 @@ function Coin(data){ } else if (port == 8766) { global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash ] }, function (body) { if (!body || !body.result) { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } body.result.reward = 5000 * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 @@ -338,7 +338,7 @@ function Coin(data){ let _this = this; global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { if (!body || !body.result) { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } body.result.height = parseInt(body.result.number); @@ -347,7 +347,7 @@ function Coin(data){ if (body.result.hash === body_height.hash) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ body.result.number ] }, function (body2) { if (!body2 || !body2.result) { - console.error(JSON.stringify(body2)); + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body2)); return callback(true, body2); } body.result.reward = calcEthReward(body.result, body2.result); @@ -362,8 +362,14 @@ function Coin(data){ return next(); } const uncleIndex = body_height.uncles.indexOf("0x" + blockHash); - if (uncleIndex === -1 || uncleIndex >= 7) return next(); - return next((ETH_BASE_REWARD * (8 - (body_height.uncles.length - uncleIndex)) / 8) * ETH_MULTIPLIER); + if (uncleIndex === -1) return next(); + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getUncleByBlockHashAndIndex', params: [ "0x" + blockHash, "0x" + uncleIndex.toString(16) ] }, function (body_uncle) { + if (!body_uncle || !body_uncle.result) { + console.error("eth_getUncleByBlockHashAndIndex:" + JSON.stringify(body_uncle)); + return next(); + } + return next((ETH_BASE_REWARD * (8 - (parseInt(body_height.number) - parseInt(body_uncle.number))) / 8) * ETH_MULTIPLIER); + }); }); }, function(uncleReward) { if (uncleReward === false) return callback(true, body); @@ -377,14 +383,14 @@ function Coin(data){ if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || (is_our_block && port == 20206 && body.result.block_header.depth < 100) // DERO can change block reward overtime? ) { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } return callback(null, body.result.block_header); }); } else global.support.rpcPortDaemon(port, 'getblock', {"hash": blockHash}, function (body) { if (typeof(body) === 'undefined' || !body.hasOwnProperty('result')) { - console.error(JSON.stringify(body)); + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } @@ -452,7 +458,7 @@ function Coin(data){ let _this = this; global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { - console.error(JSON.stringify(body)); + console.error("getPortLastBlockHeader(" + port + "): " + JSON.stringify(body)); return callback(true, body); } if (_this.lastRavenBlockHash === body.result) return callback(null, _this.lastRavenBlock); From a9c30aaf3829faddc031d087107946a0c9586285 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Mar 2021 03:48:14 +0000 Subject: [PATCH 1248/1496] Fixed ETH uncle block rewards --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b84a3eeb0..eaf4f359d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -363,9 +363,9 @@ function Coin(data){ } const uncleIndex = body_height.uncles.indexOf("0x" + blockHash); if (uncleIndex === -1) return next(); - global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getUncleByBlockHashAndIndex', params: [ "0x" + blockHash, "0x" + uncleIndex.toString(16) ] }, function (body_uncle) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getUncleByBlockNumberAndIndex', params: [ "0x" + block_height.toString(16), "0x" + uncleIndex.toString(16) ] }, function (body_uncle) { if (!body_uncle || !body_uncle.result) { - console.error("eth_getUncleByBlockHashAndIndex:" + JSON.stringify(body_uncle)); + console.error("eth_getUncleByBlockNumberAndIndex(0x" + block_height.toString(16) + ", 0x" + uncleIndex.toString(16) + "): " + JSON.stringify(body_uncle)); return next(); } return next((ETH_BASE_REWARD * (8 - (parseInt(body_height.number) - parseInt(body_uncle.number))) / 8) * ETH_MULTIPLIER); From b5afac8512c01ad84b8190315b1f3dbbafc3b96c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Mar 2021 03:51:10 +0000 Subject: [PATCH 1249/1496] Fixed ETH uncle block rewards --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index eaf4f359d..53751f642 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -368,7 +368,7 @@ function Coin(data){ console.error("eth_getUncleByBlockNumberAndIndex(0x" + block_height.toString(16) + ", 0x" + uncleIndex.toString(16) + "): " + JSON.stringify(body_uncle)); return next(); } - return next((ETH_BASE_REWARD * (8 - (parseInt(body_height.number) - parseInt(body_uncle.number))) / 8) * ETH_MULTIPLIER); + return next((ETH_BASE_REWARD * (8 - (parseInt(body_height.number) - parseInt(body_uncle.result.number))) / 8) * ETH_MULTIPLIER); }); }); }, function(uncleReward) { From 288ba8ec3bfe2e4219ce1d110557384b90fcb734 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Mar 2021 17:41:02 +0000 Subject: [PATCH 1250/1496] TRTL orphan support --- deployment/base.sql | 1 + lib/blockManager.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 26aa1ae3d..6da30e9fd 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -318,6 +318,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingSubject', 'Status of your worker(s)', 'string', 'Subject of email sent to miner when worker stops hashing'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerStartHashingBody', 'Your worker: %(worker)s has started submitting hashes at: %(timestamp)s UTC\n', 'string', 'Email sent to the miner when their worker starts hashing'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerStartHashingSubject', 'Status of your worker(s)', 'string', 'Subject of email sent to miner when worker starts hashing'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('adminEmail', '', 'Email of pool admin for alert notification stuff'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'emailSig', 'NodeJS-Pool Administration Team', 'string', 'Signature line for the emails.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'timer', '120', 'int', 'Number of minutes between main payment daemon cycles'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'timerRetry', '25', 'int', 'Number of minutes between payment daemon retrying due to not enough funds'); diff --git a/lib/blockManager.js b/lib/blockManager.js index 712378107..eb7db90ed 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -705,7 +705,10 @@ function altblockUnlocker(altblockUnlockerCB) { if (block.pay_value !== 0) { console.log(block.port + ": " + block.hash); global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, (err, body) => { - if ((body.topoheight && body.topoheight === -1) || body.confirmations === -1) { + if ( ( body.topoheight && body.topoheight === -1) || + body.confirmations === -1 || + ( body.error instanceof Object && body.error.message === "The requested hash could not be found." ) + ) { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); return next(); From 7e2e51678263386a266566bd5d79b353595cef54 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Mar 2021 15:47:11 +0000 Subject: [PATCH 1251/1496] Show block dumps for all payed block --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index eb7db90ed..4e51bad5a 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -685,11 +685,11 @@ function altblockUnlocker(altblockUnlockerCB) { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true && block.value) { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, false/*(topBlockHeight - block.anchor_height) < 120*/, function(status) { + preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, true, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); global.database.payReadyAltBlock(block.hash); From e062ba53245b40ff1b4c46adb0e8247a3445ec69 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 5 Mar 2021 19:25:19 +0000 Subject: [PATCH 1252/1496] Fixed adminEmail record --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 6da30e9fd..6b83fd4c1 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -318,7 +318,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingSubject', 'Status of your worker(s)', 'string', 'Subject of email sent to miner when worker stops hashing'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerStartHashingBody', 'Your worker: %(worker)s has started submitting hashes at: %(timestamp)s UTC\n', 'string', 'Email sent to the miner when their worker starts hashing'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerStartHashingSubject', 'Status of your worker(s)', 'string', 'Subject of email sent to miner when worker starts hashing'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('adminEmail', '', 'Email of pool admin for alert notification stuff'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'adminEmail', '', 'string', 'Email of pool admin for alert notification stuff'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'emailSig', 'NodeJS-Pool Administration Team', 'string', 'Signature line for the emails.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'timer', '120', 'int', 'Number of minutes between main payment daemon cycles'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'timerRetry', '25', 'int', 'Number of minutes between payment daemon retrying due to not enough funds'); From e61d72f0326e411106e54882a56d0918f9547e05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 19:20:52 +0000 Subject: [PATCH 1253/1496] Added paid_blocks table --- deployment/base.sql | 21 +-- lib/blockManager.js | 436 +++++++------------------------------------- 2 files changed, 77 insertions(+), 380 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 6b83fd4c1..59637df21 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -17,6 +17,15 @@ CREATE TABLE `balance` ( UNIQUE KEY `balance_payment_address_pool_type_bitcoin_payment_id_uindex` (`payment_address`,`pool_type`,`bitcoin`,`payment_id`), KEY `balance_payment_address_payment_id_index` (`payment_address`,`payment_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `paid_blocks` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `paid_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `hex` varchar(128) NOT NULL, + `amount` bigint(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `paid_blocks_paid_time` (`paid_time`), + UNIQUE KEY `paid_blocks_hex` (`hex`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `block_balance` ( `id` int(11) NOT NULL AUTO_INCREMENT, `hex` varchar(128) NOT NULL, @@ -46,18 +55,6 @@ CREATE TABLE `notifications` ( PRIMARY KEY (`id`), UNIQUE KEY `notifications_id_uindex` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `block_log` ( - `id` int(11) NOT NULL COMMENT 'Block Height', - `orphan` tinyint(1) DEFAULT '1', - `hex` varchar(128) NOT NULL, - `find_time` timestamp NULL DEFAULT NULL, - `reward` bigint(20) DEFAULT NULL, - `difficulty` bigint(20) DEFAULT NULL, - `major_version` int(11) DEFAULT NULL, - `minor_version` int(11) DEFAULT NULL, - PRIMARY KEY (`hex`), - UNIQUE KEY `block_log_hex_uindex` (`hex`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `config` ( `id` int(11) NOT NULL AUTO_INCREMENT, `module` varchar(32) DEFAULT NULL, diff --git a/lib/blockManager.js b/lib/blockManager.js index 4e51bad5a..24d7eef7f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -7,50 +7,11 @@ const child_process = require('child_process'); // This file is for managing the block databases within the SQL database. // Primary Tasks: -// Sync the chain into the block_log database. - Scan on startup for missing data, starting from block 0 // Maintain a check for valid blocks in the system. (Only last number of blocks required for validation of payouts) - Perform every 2 minutes. Scan on the main blocks table as well for sanity sake. // Maintain the block_log database in order to ensure payments happen smoothly. - Scan every 1 second for a change in lastblockheader, if it changes, insert into the DB. -//let blockIDCache = []; let paymentInProgress = false; -//let scanInProgress = false; -//let blockHexCache = {}; -//let lastBlock = 0; let balanceIDCache = {}; -//let blockScannerTask; -//let blockQueue = async.queue(function (task, callback) { -// global.coinFuncs.getBlockHeaderByID(task.blockID, (err, body) => { -// if (err !== null) { -// console.error("Can't get block with " + task.blockID + " height"); -// return callback(); -// } -// if (body.hash in blockHexCache) { -// return callback(); -// } -// debug("Adding block to block_log, ID: " + task.blockID); -// blockIDCache.push(task.blockID); -// blockHexCache[body.hash] = null; -// global.mysql.query("INSERT INTO block_log (id, orphan, hex, find_time, reward, difficulty, major_version, minor_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", -// [task.blockID, body.orphan_status, body.hash, global.support.formatDate(body.timestamp * 1000), body.reward, body.difficulty, body.major_version, body.minor_version]).then(function () { -// return calculatePPSPayments(body, callback); -// }).catch(function (err) { -// debug("BlockHexCache Check: " + body.hash in blockHexCache); -// debug("BlockIDCache Check: " + blockIDCache.hasOwnProperty(task.blockID)); -// debug("Hex: " + body.hash + " Height:" + task.blockID); -// console.error("Tried to reprocess a block that'd already been processed"); -// console.error(JSON.stringify(err)); -// return callback(); -// }); -// }); -//}, 16); - -//blockQueue.drain = function () { -// debug("blockQueue drained: unlocking remainder of blockManager functionality"); -// scanInProgress = false; -// if (typeof(blockScannerTask) === 'undefined'){ -// blockScannerTask = setInterval(blockScanner, 1000); -// } -//}; let createBlockBalanceQueue = async.queue(function (task, callback) { global.mysql.query("REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES (?, ?, ?, ?)", [task.hex, task.payment_address, task.payment_id, task.amount]).then(function (result) { @@ -94,53 +55,50 @@ let createBalanceQueue = async.queue(function (task, callback) { }, 1); let balanceQueue = async.queue(function (task, callback) { - const pool_type = task.pool_type; - const bitcoin = task.bitcoin; - const amount = task.amount; - const payment_address = task.payment_address; - let payment_id = null; - if (typeof(task.payment_id) !== 'undefined' && task.payment_id !== null && task.payment_id.length > 10) payment_id = task.payment_id; - task.payment_id = payment_id; - debug("Processing balance increment task: " + JSON.stringify(task)); - async.waterfall([ - function (intCallback) { - let cacheKey = payment_address + pool_type + bitcoin + payment_id; - if (cacheKey in balanceIDCache) { + const pool_type = task.pool_type; + const bitcoin = task.bitcoin; + const amount = task.amount; + const payment_address = task.payment_address; + let payment_id = null; + if (typeof(task.payment_id) !== 'undefined' && task.payment_id !== null && task.payment_id.length > 10) payment_id = task.payment_id; + task.payment_id = payment_id; + debug("Processing balance increment task: " + JSON.stringify(task)); + async.waterfall([ + function (intCallback) { + let cacheKey = payment_address + pool_type + bitcoin + payment_id; + if (cacheKey in balanceIDCache) { + return intCallback(null, balanceIDCache[cacheKey]); + } else { + createBalanceQueue.push(task, function () {}); + async.until(function (untilCB) { + return untilCB(null, cacheKey in balanceIDCache); + }, function (intCallback) { + createBalanceQueue.push(task, function () { + return intCallback(null, balanceIDCache[cacheKey]); + }); + }, function () { return intCallback(null, balanceIDCache[cacheKey]); - } else { - createBalanceQueue.push(task, function () {}); - async.until(function (untilCB) { - return untilCB(null, cacheKey in balanceIDCache); - }, function (intCallback) { - createBalanceQueue.push(task, function () { - return intCallback(null, balanceIDCache[cacheKey]); - }); - }, function () { - return intCallback(null, balanceIDCache[cacheKey]); - } - ); } - }, - function (balance_id, intCallback) { - debug("Made it to the point that I can update the balance for: " + balance_id + " for the amount: " + amount); - global.mysql.query("UPDATE balance SET amount = amount+? WHERE id = ?", [amount, balance_id]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - console.error("Can't do SQL balance update: UPDATE balance SET amount = amount+" + amount + " WHERE id = " + balance_id + ";") - } - return intCallback(null); - }).catch(function (err) { - console.error(err); - console.error("Can't do SQL balance update: UPDATE balance SET amount = amount+" + amount + " WHERE id = " + balance_id + ";") - }); - } - ], - function () { - return callback(); + ); } - ) - ; - }, 24 -); + }, + function (balance_id, intCallback) { + debug("Made it to the point that I can update the balance for: " + balance_id + " for the amount: " + amount); + global.mysql.query("UPDATE balance SET amount = amount+? WHERE id = ?", [amount, balance_id]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { + console.error("Can't do SQL balance update: UPDATE balance SET amount = amount+" + amount + " WHERE id = " + balance_id + ";") + } + return intCallback(null); + }).catch(function (err) { + console.error(err); + console.error("Can't do SQL balance update: UPDATE balance SET amount = amount+" + amount + " WHERE id = " + balance_id + ";") + }); + } + ], + function () { + return callback(); + }); +}, 24); let is_full_stop = false; @@ -192,94 +150,6 @@ balanceQueue.drain(function () { }); }); -function calculatePPSPayments(blockHeader, callback) { - if (global.config.pps.enable === false) return callback(); - console.log("Performing PPS payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); - let paymentData = {}; - paymentData[global.config.payout.feeAddress] = { - pool_type: 'fees', - payment_address: global.config.payout.feeAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - paymentData[global.coinFuncs.coinDevAddress] = { - pool_type: 'fees', - payment_address: global.coinFuncs.coinDevAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - paymentData[global.coinFuncs.poolDevAddress] = { - pool_type: 'fees', - payment_address: global.coinFuncs.poolDevAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - let totalPayments = 0; - if (global.config.pps.enable === true) { - let txn = global.database.env.beginTxn({readOnly: true}); - let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - for (let found = (cursor.goToRange(blockHeader.height) === blockHeader.height); found; found = cursor.goToNextDup()) { - cursor.getCurrentBinary(function (key, data) { // jshint ignore:line - let shareData; - try { - shareData = global.protos.Share.decode(data); - } catch (e) { - console.error(e); - return; - } - let blockDiff = blockHeader.difficulty; - let rewardTotal = blockHeader.reward; - if (shareData.poolType === global.protos.POOLTYPE.PPS) { - let userIdentifier = shareData.paymentAddress; - if (shareData.paymentID) { - userIdentifier = userIdentifier + "." + shareData.paymentID; - } - if (!(userIdentifier in paymentData)) { - paymentData[userIdentifier] = { - pool_type: 'pps', - payment_address: shareData.paymentAddress, - payment_id: shareData.paymentID, - bitcoin: shareData.bitcoin, - amount: 0 - }; - } - let amountToPay = Math.floor((shareData.raw_shares / blockDiff) * rewardTotal); - let feesToPay = Math.floor(amountToPay * (global.config.payout.ppsFee / 100)); - if (shareData.bitcoin === true) { - feesToPay += Math.floor(amountToPay * (global.config.payout.btcFee / 100)); - } - amountToPay -= feesToPay; - paymentData[userIdentifier].amount = paymentData[userIdentifier].amount + amountToPay; - let donations = 0; - if(global.config.payout.devDonation > 0){ - let devDonation = (feesToPay * (global.config.payout.devDonation / 100)); - donations += devDonation; - paymentData[global.coinFuncs.coinDevAddress].amount = paymentData[global.coinFuncs.coinDevAddress].amount + devDonation ; - } - if(global.config.payout.poolDevDonation > 0){ - let poolDevDonation = (feesToPay * (global.config.payout.poolDevDonation / 100)); - donations += poolDevDonation; - paymentData[global.coinFuncs.poolDevAddress].amount = paymentData[global.coinFuncs.poolDevAddress].amount + poolDevDonation; - } - paymentData[global.config.payout.feeAddress].amount = paymentData[global.config.payout.feeAddress].amount + feesToPay - donations; - } - }); - } - cursor.close(); - txn.abort(); - } - Object.keys(paymentData).forEach(function (key) { - balanceQueue.push(paymentData[key], function () { - }); - totalPayments += paymentData[key].amount; - }); - console.log("PPS payout cycle complete on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / blockHeader.reward) * 100 + "%"); - return callback(); -} - function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is_store_dump, done_callback) { const rewardTotal = 1.0; console.log("Performing PPLNS reward pre-calculations of block " + block_hex + " on (anchor) height " + block_height); @@ -505,12 +375,16 @@ function doPPLNSPayments(block_hex, block_reward, unlock_callback) { global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (rows.length) { - block_unlock_callback = unlock_callback; - rows.forEach(function (row) { - row.amount = Math.floor(row.amount * block_reward); - row.pool_type = "pplns"; - row.bitcoin = 0; - balanceQueue.push(row, function () {}); + global.mysql.query("INSERT INTO paid_blocks (hex, amount) VALUES (?,?)", [block_hex, block_reward]).then(function () { + block_unlock_callback = unlock_callback; + rows.forEach(function (row) { + row.amount = Math.floor(row.amount * block_reward); + row.pool_type = "pplns"; + row.bitcoin = 0; + balanceQueue.push(row, function () {}); + }); + }).catch(function (error) { + console.error("Block " + block_hex + " can not be inserted into paid_blocks table"); }); } else { console.error("Block " + block_hex + " has no payments in SQL"); @@ -519,88 +393,6 @@ function doPPLNSPayments(block_hex, block_reward, unlock_callback) { }); } -function calculateSoloPayments(blockHeader) { - console.log("Performing Solo payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); - let txn = global.database.env.beginTxn({readOnly: true}); - let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - let paymentData = {}; - paymentData[global.config.payout.feeAddress] = { - pool_type: 'fees', - payment_address: global.config.payout.feeAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - paymentData[global.coinFuncs.coinDevAddress] = { - pool_type: 'fees', - payment_address: global.coinFuncs.coinDevAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - paymentData[global.coinFuncs.poolDevAddress] = { - pool_type: 'fees', - payment_address: global.coinFuncs.poolDevAddress, - payment_id: null, - bitcoin: 0, - amount: 0 - }; - let totalPayments = 0; - for (let found = (cursor.goToRange(blockHeader.height) === blockHeader.height); found; found = cursor.goToNextDup()) { - cursor.getCurrentBinary(function (key, data) { // jshint ignore:line - let shareData; - try { - shareData = global.protos.Share.decode(data); - } catch (e) { - console.error(e); - return; - } - let rewardTotal = blockHeader.reward; - if (shareData.poolType === global.protos.POOLTYPE.SOLO && shareData.foundBlock === true) { - let userIdentifier = shareData.paymentAddress; - if (shareData.paymentID) { - userIdentifier = userIdentifier + "." + shareData.paymentID; - } - if (!(userIdentifier in paymentData)) { - paymentData[userIdentifier] = { - pool_type: 'solo', - payment_address: shareData.paymentAddress, - payment_id: shareData.paymentID, - bitcoin: shareData.bitcoin, - amount: 0 - }; - } - let feesToPay = Math.floor(rewardTotal * (global.config.payout.soloFee / 100)); - if (shareData.bitcoin === true) { - feesToPay += Math.floor(rewardTotal * (global.config.payout.btcFee / 100)); - } - rewardTotal -= feesToPay; - paymentData[userIdentifier].amount = rewardTotal; - let donations = 0; - if(global.config.payout.devDonation > 0){ - let devDonation = (feesToPay * (global.config.payout.devDonation / 100)); - donations += devDonation; - paymentData[global.coinFuncs.coinDevAddress].amount = paymentData[global.coinFuncs.coinDevAddress].amount + devDonation ; - } - if(global.config.payout.poolDevDonation > 0){ - let poolDevDonation = (feesToPay * (global.config.payout.poolDevDonation / 100)); - donations += poolDevDonation; - paymentData[global.coinFuncs.poolDevAddress].amount = paymentData[global.coinFuncs.poolDevAddress].amount + poolDevDonation; - } - paymentData[global.config.payout.feeAddress].amount = feesToPay - donations; - } - }); - } - cursor.close(); - txn.abort(); - Object.keys(paymentData).forEach(function (key) { - balanceQueue.push(paymentData[key], function () { - }); - totalPayments += paymentData[key].amount; - }); - console.log("Solo payout cycle complete on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / blockHeader.reward) * 100 + "%"); -} - let payReadyBlockHashCalc = {}; function blockUnlocker(blockUnlockerCB) { @@ -608,10 +400,6 @@ function blockUnlocker(blockUnlockerCB) { debug("Dropping all block unlocks"); return blockUnlockerCB(); } -// if (scanInProgress) { -// debug("Skipping block unlocker run as there's a scan in progress"); -// return; -// } if (paymentInProgress) { console.error("Skipping block unlocker run as there's a payment in progress"); return blockUnlockerCB(); @@ -634,8 +422,6 @@ function blockUnlocker(blockUnlockerCB) { const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; if (body.hash !== block.hash) { global.database.invalidateBlock(block.height); - //global.mysql.query("UPDATE block_log SET orphan = true WHERE hex = ?", [block.hash]); - //blockIDCache.splice(blockIDCache.indexOf(block.height)); console.log("Invalidating block " + block.height + " due to being an orphan block"); return next(); } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { @@ -664,11 +450,6 @@ function altblockUnlocker(altblockUnlockerCB) { debug("Dropping all altblock unlocks"); return altblockUnlockerCB(); } -// if (scanInProgress) { -// debug("Skipping altblock unlocker run as there's a scan in progress"); -// setTimeout(altblockUnlocker, 2*60*1000); -// return; -// } if (paymentInProgress) { console.error("Skipping altblock unlocker run as there's a payment in progress"); return altblockUnlockerCB(); @@ -685,8 +466,8 @@ function altblockUnlocker(altblockUnlockerCB) { async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; - if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true && block.value) { - global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { + if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { + if (block.value) global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, true, function(status) { @@ -700,7 +481,9 @@ function altblockUnlocker(altblockUnlockerCB) { console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); return next(); } - }); + }); else global.support.sendEmail(global.config.general.adminEmail, "FYI: blockManager saw zero value locked block", + "Hello,\r\nThe blockManager saw zero value locked block " + block.hash.toString('hex') + ); } else if (!is_pplns_block || block.pay_ready === true) { if (block.pay_value !== 0) { console.log(block.port + ": " + block.hash); @@ -749,11 +532,6 @@ function blockPayments(block, cb) { return cb(); } switch (block.poolType) { - case global.protos.POOLTYPE.PPS: - // PPS is paid out per share find per block, so this is handled in the main block-find loop. - global.database.unlockBlock(block.hash); - return cb(); - case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getBlockHeaderByHash(block.hash, function (err, header) { if (err === null && block.height === header.height && block.value === header.reward && block.difficulty === header.difficulty){ @@ -775,15 +553,7 @@ function blockPayments(block, cb) { } }); break; - case global.protos.POOLTYPE.SOLO: - global.coinFuncs.getBlockHeaderByHash(block.hash, function (err, header) { - if (err === null){ - calculateSoloPayments(header); - global.database.unlockBlock(block.hash); - } - return cb(); - }); - break; + default: console.error("Unknown payment type. FREAKOUT"); return cb(); @@ -798,24 +568,17 @@ function altblockPayments(block, cb) { switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { - if (err === null && block.height === header.height && block.value >= header.reward /*&& block.difficulty === header.difficulty*/){ - //global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { - //if (anchor_err === null){ - if (paymentInProgress) { - console.error("Skipping payment as there's a payment in progress"); - return cb(); - } - paymentInProgress = true; - doPPLNSPayments(block.hash, block.pay_value, function() { - console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); - global.database.unlockAltBlock(block.hash); - return cb(); - }); - //} else { - // console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); - // return cb(); - //} - //}); + if (err === null && block.height === header.height && block.value >= header.reward){ + if (paymentInProgress) { + console.error("Skipping payment as there's a payment in progress"); + return cb(); + } + paymentInProgress = true; + doPPLNSPayments(block.hash, block.pay_value, function() { + console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); + global.database.unlockAltBlock(block.hash); + return cb(); + }); } else { console.error("Can't get correct altblock header of " + block.port.toString() + " port by hash " + block.hash.toString('hex')); return cb(); @@ -828,69 +591,6 @@ function altblockPayments(block, cb) { } } -//function blockScanner() { -// let inc_check = 0; -// if (scanInProgress) { -// debug("Skipping scan as there's one in progress."); -// return; -// } -// scanInProgress = true; -// global.coinFuncs.getLastBlockHeader(function (err, blockHeader) { -// if (err === null){ -// if (lastBlock === blockHeader.height) { -// //debug("No new work to be performed, block header matches last block"); -// scanInProgress = false; -// return; -// } -// debug("Parsing data for new blocks"); -// lastBlock = blockHeader.height; -// range.range(0, (blockHeader.height - Math.floor(global.config.payout.blocksRequired/2))).forEach(function (blockID) { -// if (!blockIDCache.hasOwnProperty(blockID)) { -// ++ inc_check; -// blockQueue.push({blockID: blockID}, function (err) { -// debug("Completed block scan on " + blockID); -// if (err) { -// console.error("Error processing " + blockID); -// } -// }); -// } -// }); -// if (inc_check === 0) { -// debug("No new work to be performed, initial scan complete"); -// scanInProgress = false; -// blockScannerTask = setInterval(blockScanner, 1000); -// } -// } else { -// console.error(`Upstream error from the block daemon. Resetting scanner due to: ${JSON.stringify(blockHeader)}`); -// scanInProgress = false; -// blockScannerTask = setInterval(blockScanner, 1000); -// } -// }); -//} - -//function initial_sync() { -// console.log("Performing boot-sync"); -// global.mysql.query("SELECT id, hex FROM block_log WHERE orphan = 0").then(function (rows) { -// let intCount = 0; -// rows.forEach(function (row) { -// ++ intCount; -// blockIDCache.push(row.id); -// blockHexCache[row.hex] = null; -// }); -// }).then(function () { -// // Enable block scanning for 1 seconds to update the block log. -// blockScanner(); -// // Scan every 120 seconds for invalidated blocks -// setInterval(blockUnlocker, 2*60*1000); -// blockUnlocker(); -// altblockUnlocker(); -// debug("Blocks loaded from SQL: " + blockIDCache.length); -// console.log("Boot-sync from SQL complete: pending completion of queued jobs to get back to work."); -// }); -//} - -//initial_sync(); - function blockUnlockerNext() { altblockUnlocker(function() { setTimeout(blockUnlocker, 2*60*1000, blockUnlockerNext); From 400bcac69f28d3924c1d98dd469540909200e218 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 20:01:19 +0000 Subject: [PATCH 1254/1496] Keep info about last week paid block --- lib/longRunner.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index d3630fdde..0498a4d50 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -82,19 +82,22 @@ function cleanBlockBalanceTable() { global.database.getValidLockedBlocks().forEach(function (block) { locked_block_hashes[block.hash] = 1; }); global.database.getValidLockedAltBlocks().forEach(function (block) { locked_block_hashes[block.hash] = 1; }); - let deleted_row_count = 0; - global.mysql.query("SELECT DISTINCT hex FROM block_balance").then(function (rows) { - rows.forEach(function (row) { - if (row.hex in locked_block_hashes) return; - if (row.hex in saw_block_hash_before) { - cleanBlockBalanceTableQueue.push(row, function () {}); - delete saw_block_hash_before[row.hex]; - ++ deleted_row_count; - } else { - saw_block_hash_before[row.hex] = 1; - } - }); + global.mysql.query("SELECT hex FROM paid_blocks WHERE paid_time > (NOW() - INTERVAL 7 DAY)").then(function (rows_keep) { + rows_keep.forEach(function (row) { locked_block_hashes[row.hex] = 1; }); + let deleted_row_count = 0; + global.mysql.query("SELECT DISTINCT hex FROM block_balance").then(function (rows) { + rows.forEach(function (row) { + if (row.hex in locked_block_hashes) return; + if (row.hex in saw_block_hash_before) { + cleanBlockBalanceTableQueue.push(row, function () {}); + delete saw_block_hash_before[row.hex]; + ++ deleted_row_count; + } else { + saw_block_hash_before[row.hex] = 1; + } + }); console.log("Finished cleaning the block balance table. Removed " + deleted_row_count + " rows."); + }); }); } From 984b3a74c95d057ebde7befb098c7a49d386deaa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 20:06:19 +0000 Subject: [PATCH 1255/1496] Extra log info --- lib/local_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index 419bee6d8..b4b052d19 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -843,6 +843,7 @@ function Database(){ } } else { + console.log("Block depth to keep is " + (body.height - oldestLockedBlockHeight)); if (body.height - oldestLockedBlockHeight > global.config.general.blockCleanWarning) { global.support.sendEmail(global.config.general.adminEmail, "longRunner module can not clean DB good enough", "longRunner can not clean " + (body.height - oldestLockedBlockHeight) + " block from DB!"); } From a76f8d8768aaf2c2208f6282ccfe56c0ead30055 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 20:36:24 +0000 Subject: [PATCH 1256/1496] Added basis for block prepayment calc for the same anchor height --- lib/blockManager.js | 72 ++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 24d7eef7f..a19a8e19e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -150,9 +150,9 @@ balanceQueue.drain(function () { }); }); -function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is_store_dump, done_callback) { +function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, is_store_dump, done_callback) { const rewardTotal = 1.0; - console.log("Performing PPLNS reward pre-calculations of block " + block_hex + " on (anchor) height " + block_height); + console.log("Performing PPLNS reward pre-calculations of block " + block_hexes.join(', ') + " on (anchor) height " + block_height); const blockDiff = block_difficulty; const windowPPLNS = blockDiff * global.config.pplns.shareMulti; @@ -294,10 +294,10 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is let is_pay_done = false; if (totalPayments == 0) { - console.warn("PPLNS payout cycle for " + block_hex + " block does not have any shares so will be redone using top height"); + console.warn("PPLNS payout cycle for " + block_hexes.join(', ') + " block does not have any shares so will be redone using top height"); global.support.sendEmail(global.config.general.adminEmail, "FYI: No shares to pay block, so it was corrected by using the top height", - "PPLNS payout cycle for " + block_hex + " block does not have any shares so will be redone using top height" + "PPLNS payout cycle for " + block_hexes.join(', ') + " block does not have any shares so will be redone using top height" ); global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { @@ -305,14 +305,14 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is return done_callback(false); } const topBlockHeight = body.height; - return preCalculatePPLNSPayments(block_hex, topBlockHeight, block_difficulty, is_store_dump, done_callback); + return preCalculatePPLNSPayments(block_hexes, topBlockHeight, block_difficulty, is_store_dump, done_callback); }); return; } else { if (is_store_dump && fs.existsSync("./block_share_dumps/process.sh")) { shares4dump.sort(); shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); - const fn = "block_share_dumps/" + block_hex + ".cvs"; + const fn = "block_share_dumps/" + block_hexes[0] + ".cvs"; fs.writeFile(fn, shares4dump.join("\n"), function(err) { if (err) { console.error("Error saving " + fn + " file"); @@ -320,9 +320,11 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is if (is_pay_done) return done_callback(is_ok); return; } - child_process.exec("./block_share_dumps/process.sh " + fn, function callback(error, stdout, stderr) { - if (error) console.error("./block_share_dumps/process.sh " + fn + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); - else console.log("./block_share_dumps/process.sh " + fn + ": complete"); + let fns = ""; + block_hexes.forEach(function(block_hex) { fns += " block_share_dumps/" + block_hex + ".cvs" }); + child_process.exec("./block_share_dumps/process.sh" + fns, function callback(error, stdout, stderr) { + if (error) console.error("./block_share_dumps/process.sh" + fns + ": returned error exit code: " + error.code + "\n" + stdout + "\n" + stderr); + else console.log("./block_share_dumps/process.sh" + fns + ": complete"); is_dump_done = true; if (is_pay_done) return done_callback(is_ok); }); @@ -336,31 +338,33 @@ function preCalculatePPLNSPayments(block_hex, block_height, block_difficulty, is const is_need_correction = Math.abs(totalPayments/default_window - 1) > 0.0001; const pay_window = is_need_correction ? totalPayments : default_window; - let add_count = 0; - Object.keys(paymentData).forEach(function (key) { - if (paymentData[key].amount) { - paymentData[key].hex = block_hex; - paymentData[key].amount = paymentData[key].amount / pay_window; - ++ add_count; - createBlockBalanceQueue.push(paymentData[key], function (status) { - if (status === false) is_ok = false; - if (--add_count == 0) { - is_pay_done = true; - if (is_dump_done) return done_callback(is_ok); - } - }); + block_hexes.forEach(function(block_hex) { + let add_count = 0; + Object.keys(paymentData).forEach(function (key) { + if (paymentData[key].amount) { + paymentData[key].hex = block_hex; + paymentData[key].amount = paymentData[key].amount / pay_window; + ++ add_count; + createBlockBalanceQueue.push(paymentData[key], function (status) { + if (status === false) is_ok = false; + if (--add_count == 0) { + is_pay_done = true; + if (is_dump_done) return done_callback(is_ok); + } + }); + } + }); + + console.log("PPLNS pre-payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); + if (is_need_correction) { + console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); + global.support.sendEmail(global.config.general.adminEmail, + "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", + "PPLNS payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + + "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" + ); } }); - - console.log("PPLNS payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); - if (is_need_correction) { - console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); - global.support.sendEmail(global.config.general.adminEmail, - "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", - "PPLNS payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + - "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" - ); - } }); } @@ -426,7 +430,7 @@ function blockUnlocker(blockUnlockerCB) { return next(); } else if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.height, block.difficulty, true, function(status) { + preCalculatePPLNSPayments( [ block.hash ], block.height, block.difficulty, true, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations of block " + block.hash + " on height " + block.height); global.database.payReadyBlock(block.hash); @@ -470,7 +474,7 @@ function altblockUnlocker(altblockUnlockerCB) { if (block.value) global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments(block.hash, block.anchor_height, anchor_header.difficulty, true, function(status) { + preCalculatePPLNSPayments([ block.hash ], block.anchor_height, anchor_header.difficulty, true, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); global.database.payReadyAltBlock(block.hash); From 02470758d2c89769067afb8a4fef3b56a394092e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 20:41:19 +0000 Subject: [PATCH 1257/1496] Added basis for block prepayment calc for the same anchor height --- lib/blockManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index a19a8e19e..240cf11e6 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -338,8 +338,9 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, const is_need_correction = Math.abs(totalPayments/default_window - 1) > 0.0001; const pay_window = is_need_correction ? totalPayments : default_window; + let add_count = 0; + block_hexes.forEach(function(block_hex) { - let add_count = 0; Object.keys(paymentData).forEach(function (key) { if (paymentData[key].amount) { paymentData[key].hex = block_hex; From 01aee1780455728b24965d9fbc37d39216d57e1a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 21:07:04 +0000 Subject: [PATCH 1258/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 50 ++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 240cf11e6..e463418be 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -468,25 +468,16 @@ function altblockUnlocker(altblockUnlockerCB) { return altblockUnlockerCB(); } const topBlockHeight = body.height; + let preCalcAnchorBlockHashes = {}; async.eachSeries(blockList, function(block, next) { if (topBlockHeight - block.anchor_height <= 60) return next(); const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { - if (block.value) global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { - if (anchor_err === null){ - payReadyBlockHashCalc[block.hash] = 1; - preCalculatePPLNSPayments([ block.hash ], block.anchor_height, anchor_header.difficulty, true, function(status) { - if (status) { - console.log("Completed PPLNS reward pre-calculations on altblock " + block.hash + " on anchor height " + block.anchor_height); - global.database.payReadyAltBlock(block.hash); - } - return next(); - }); - } else { - console.error("Can't get correct anchor block header by height " + block.anchor_height.toString()); - return next(); - } - }); else global.support.sendEmail(global.config.general.adminEmail, "FYI: blockManager saw zero value locked block", + if (block.value) { + if (!(block.anchor_height in preCalcAnchorBlockHashes)) preCalcAnchorBlockHashes[block.anchor_height] = []; + preCalcAnchorBlockHashes[block.anchor_height].push(block.hash); + payReadyBlockHashCalc[block.hash] = 1; + } else global.support.sendEmail(global.config.general.adminEmail, "FYI: blockManager saw zero value locked block", "Hello,\r\nThe blockManager saw zero value locked block " + block.hash.toString('hex') ); } else if (!is_pplns_block || block.pay_ready === true) { @@ -523,10 +514,31 @@ function altblockUnlocker(altblockUnlockerCB) { } }, function() { - for (let port in blockHeightWait) { - console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); - } - return altblockUnlockerCB(); + console.log("Running altblock prepayment for " + Object.keys(preCalcAnchorBlockHashes).length + " anchor heights"); + async.eachSeries(Object.keys(preCalcAnchorBlockHashes), function(anchor_height, next) { + global.coinFuncs.getBlockHeaderByID(anchor_height, function (anchor_err, anchor_header) { + if (anchor_err === null){ + const block_hexes = preCalcAnchorBlockHashes[anchor_height]; + preCalculatePPLNSPayments(block_hexes, anchor_height, anchor_header.difficulty, true, function(status) { + if (status) { + console.log("Completed PPLNS reward pre-calculations on altblock " + block_hexes.join(", ") + " on anchor height " + anchor_height); + block_hexes.forEach(function (block_hex) { + global.database.payReadyAltBlock(block_hex); + }); + } + return next(); + }); + } else { + console.error("Can't get correct anchor block header by height " + anchor_height); + return next(); + } + }); + }, function() { + for (let port in blockHeightWait) { + console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); + } + return altblockUnlockerCB(); + }); }); }); } From 938ce6f567a7b47a3df2e8592e9cadce9f46b101 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 21:08:01 +0000 Subject: [PATCH 1259/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e463418be..805b4b5de 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -521,7 +521,7 @@ function altblockUnlocker(altblockUnlockerCB) { const block_hexes = preCalcAnchorBlockHashes[anchor_height]; preCalculatePPLNSPayments(block_hexes, anchor_height, anchor_header.difficulty, true, function(status) { if (status) { - console.log("Completed PPLNS reward pre-calculations on altblock " + block_hexes.join(", ") + " on anchor height " + anchor_height); + console.log("Completed PPLNS reward pre-calculations on altblock " + block_hexes.join(", ") + " on anchor height " + anchor_height + "\n"); block_hexes.forEach(function (block_hex) { global.database.payReadyAltBlock(block_hex); }); From c496336316e45c208e3955654aaec2f19ed22b3a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 21:09:33 +0000 Subject: [PATCH 1260/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 805b4b5de..be736c394 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -139,7 +139,7 @@ balanceQueue.drain(function () { } let balance_sum = rows[0].amt; if (balance_sum !== prev_balance_sum) { - console.log("Total balance changed from " + global.support.coinToDecimal(prev_balance_sum) + " to " + global.support.coinToDecimal(balance_sum)); + console.log("Total balance changed from " + global.support.coinToDecimal(prev_balance_sum) + " to " + global.support.coinToDecimal(balance_sum) + "\n"); block_unlock_callback(); } else { full_stop("Total balance not changed from " + prev_balance_sum + " to " + balance_sum); From a99ff61cb0fb5ba81acfbe319c1c04b5151ae87f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 21:22:07 +0000 Subject: [PATCH 1261/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index be736c394..cc30867fc 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -476,7 +476,6 @@ function altblockUnlocker(altblockUnlockerCB) { if (block.value) { if (!(block.anchor_height in preCalcAnchorBlockHashes)) preCalcAnchorBlockHashes[block.anchor_height] = []; preCalcAnchorBlockHashes[block.anchor_height].push(block.hash); - payReadyBlockHashCalc[block.hash] = 1; } else global.support.sendEmail(global.config.general.adminEmail, "FYI: blockManager saw zero value locked block", "Hello,\r\nThe blockManager saw zero value locked block " + block.hash.toString('hex') ); @@ -514,11 +513,14 @@ function altblockUnlocker(altblockUnlockerCB) { } }, function() { - console.log("Running altblock prepayment for " + Object.keys(preCalcAnchorBlockHashes).length + " anchor heights"); + console.log("Running altblock pre-payment for " + Object.keys(preCalcAnchorBlockHashes).length + " anchor heights"); async.eachSeries(Object.keys(preCalcAnchorBlockHashes), function(anchor_height, next) { global.coinFuncs.getBlockHeaderByID(anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ const block_hexes = preCalcAnchorBlockHashes[anchor_height]; + block_hexes.forEach(function (block_hex) { + payReadyBlockHashCalc[block_hex] = 1; + }); preCalculatePPLNSPayments(block_hexes, anchor_height, anchor_header.difficulty, true, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations on altblock " + block_hexes.join(", ") + " on anchor height " + anchor_height + "\n"); From 1f16ad919b9963259ed3db72d1f91b3d6ab24c98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 21:23:21 +0000 Subject: [PATCH 1262/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index cc30867fc..e10b93603 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -479,6 +479,7 @@ function altblockUnlocker(altblockUnlockerCB) { } else global.support.sendEmail(global.config.general.adminEmail, "FYI: blockManager saw zero value locked block", "Hello,\r\nThe blockManager saw zero value locked block " + block.hash.toString('hex') ); + return next(); } else if (!is_pplns_block || block.pay_ready === true) { if (block.pay_value !== 0) { console.log(block.port + ": " + block.hash); From 4a83b857f54db13d200c1645c3b73f3739790d02 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 21:27:17 +0000 Subject: [PATCH 1263/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e10b93603..b646704a4 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -522,7 +522,7 @@ function altblockUnlocker(altblockUnlockerCB) { block_hexes.forEach(function (block_hex) { payReadyBlockHashCalc[block_hex] = 1; }); - preCalculatePPLNSPayments(block_hexes, anchor_height, anchor_header.difficulty, true, function(status) { + preCalculatePPLNSPayments(block_hexes, parseInt(anchor_height), anchor_header.difficulty, true, function(status) { if (status) { console.log("Completed PPLNS reward pre-calculations on altblock " + block_hexes.join(", ") + " on anchor height " + anchor_height + "\n"); block_hexes.forEach(function (block_hex) { From 9b9b70c10621ce5c9141fee61b0b107878446f02 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 21:40:10 +0000 Subject: [PATCH 1264/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index b646704a4..c00dfdf1d 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -355,17 +355,16 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, }); } }); - - console.log("PPLNS pre-payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); - if (is_need_correction) { - console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); - global.support.sendEmail(global.config.general.adminEmail, - "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", - "PPLNS payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + - "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" - ); - } }); + console.log("PPLNS pre-payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); + if (is_need_correction) { + console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); + global.support.sendEmail(global.config.general.adminEmail, + "Warning: Not enought shares to pay block correctly, so it was corrected by upscaling miner rewards!", + "PPLNS payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")\n" + + "(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))" + ); + } }); } From 81f942d5b55e18f6fbac9ad4911a99bafa9a477a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 22:57:23 +0000 Subject: [PATCH 1265/1496] Added block_payments api --- lib/api.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/api.js b/lib/api.js index a81ee334e..8ce9315c0 100644 --- a/lib/api.js +++ b/lib/api.js @@ -469,6 +469,47 @@ app.get('/miner/:address/payments', cache('1 minute'), function (req, res) { }); }); +app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) { + const limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; + const page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; + + const address_parts = req.params.address.split('.'); + const address = address_parts[0]; + const payment_id = address_parts[1]; + const where_str = typeof(payment_id) === 'undefined' + ? "payment_address = '" + address + "' AND (payment_id IS NULL OR payment_id = '')" + : "payment_address = '" + address + "' AND payment_id = '" + payment_id + "'"; + + global.mysql.query("SELECT * FROM paid_blocks WHERE paid_time > (NOW() - INTERVAL 7 DAY) ORDER BY id DESC LIMIT ? OFFSET ?", [limit, page * limit]).then(function (rows) { + if (rows.length === 0) return res.json([]); + let block_hexes = []; + rows.forEach(function (row) { block_hexes.push(row.hex); }); + + global.mysql.query("SELECT hex, amount FROM block_balance WHERE " + where_str + " AND hex IN (" + block_hexes.join() + ")").then(function (rows2) { + let block_miner_shares = {}; + rows2.forEach(function (row2) { block_miner_shares[row2.hex] = row2.amount; }); + let response = []; + rows.forEach(function (row) { + const miner_payment_share = row.hex in block_miner_shares ? block_miner_shares[row.hex] : 0; + response.push({ + id: row.id, + ts: row.paid_time, + hash: row.hex, + value_percent: miner_payment_share * 100.0f, + value: parseInt(miner_payment_share * row.amount) + }); + }); + return res.json(response.sort(global.support.tsCompare)); + }).catch(function (err) { + console.error(threadName + "Error getting block_balance miner block payments: " + JSON.stringify(err)); + return res.json({error: 'Issue getting block payments'}); + }); + }).catch(function (err) { + console.error(threadName + "Error getting paid_blocks miner block payments: " + JSON.stringify(err)); + return res.json({error: 'Issue getting block payments'}); + }); +}); + app.get('/miner/:address/stats/allWorkers', cache('10 seconds'), function (req, res) { getAllWorkerStats(req.params.address, function(err, data){ return res.json(data); From 14e6217832fc25b6b3d7984fa53e37577018c8a2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 22:58:47 +0000 Subject: [PATCH 1266/1496] Added block_payments api --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 8ce9315c0..ae1118e67 100644 --- a/lib/api.js +++ b/lib/api.js @@ -495,7 +495,7 @@ app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) id: row.id, ts: row.paid_time, hash: row.hex, - value_percent: miner_payment_share * 100.0f, + value_percent: miner_payment_share * 100.0, value: parseInt(miner_payment_share * row.amount) }); }); From aee4292f1a1ad79ed4cd0413049b63285d492604 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 23:04:52 +0000 Subject: [PATCH 1267/1496] Added block_payments api --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index ae1118e67..e13aebbb7 100644 --- a/lib/api.js +++ b/lib/api.js @@ -483,7 +483,7 @@ app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) global.mysql.query("SELECT * FROM paid_blocks WHERE paid_time > (NOW() - INTERVAL 7 DAY) ORDER BY id DESC LIMIT ? OFFSET ?", [limit, page * limit]).then(function (rows) { if (rows.length === 0) return res.json([]); let block_hexes = []; - rows.forEach(function (row) { block_hexes.push(row.hex); }); + rows.forEach(function (row) { block_hexes.push('"' + row.hex + '"'); }); global.mysql.query("SELECT hex, amount FROM block_balance WHERE " + where_str + " AND hex IN (" + block_hexes.join() + ")").then(function (rows2) { let block_miner_shares = {}; From 6b163e89e74089d9c2404ad7773fabc51e79d049 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 23:07:58 +0000 Subject: [PATCH 1268/1496] Added block_payments api --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index e13aebbb7..630524b21 100644 --- a/lib/api.js +++ b/lib/api.js @@ -493,7 +493,7 @@ app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) const miner_payment_share = row.hex in block_miner_shares ? block_miner_shares[row.hex] : 0; response.push({ id: row.id, - ts: row.paid_time, + ts: (new Date(row.paid_time)).getTime(), hash: row.hex, value_percent: miner_payment_share * 100.0, value: parseInt(miner_payment_share * row.amount) From 78b27a1c2db2188e120433d3cf9b88db2af01a3e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 6 Mar 2021 23:10:11 +0000 Subject: [PATCH 1269/1496] Added block_payments api --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 630524b21..ec55a5287 100644 --- a/lib/api.js +++ b/lib/api.js @@ -496,7 +496,7 @@ app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) ts: (new Date(row.paid_time)).getTime(), hash: row.hex, value_percent: miner_payment_share * 100.0, - value: parseInt(miner_payment_share * row.amount) + value: miner_payment_share * row.amount / global.config.general.sigDivisor }); }); return res.json(response.sort(global.support.tsCompare)); From 008ad4573e31ff5f4f842e91f4639ae916cc098c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 00:06:59 +0000 Subject: [PATCH 1270/1496] Added block_payments api --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index ec55a5287..b5d406d2c 100644 --- a/lib/api.js +++ b/lib/api.js @@ -470,7 +470,7 @@ app.get('/miner/:address/payments', cache('1 minute'), function (req, res) { }); app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) { - const limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; + const limit = typeof(req.query.limit) !== 'undefined' ? (Number(req.query.limit) > 100 ? 100 : Number(req.query.limit)) : 10; const page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; const address_parts = req.params.address.split('.'); From 86f618bdc722ccaab176aac90ed5b4e3402ae581 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 00:28:58 +0000 Subject: [PATCH 1271/1496] Added block found time and port --- deployment/base.sql | 2 ++ lib/api.js | 2 ++ lib/blockManager.js | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 59637df21..67c71c9ce 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -19,7 +19,9 @@ CREATE TABLE `balance` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `paid_blocks` ( `id` int(11) NOT NULL AUTO_INCREMENT, + `found_time` timestamp NOT NULL, `paid_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `port` int NOT NULL, `hex` varchar(128) NOT NULL, `amount` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), diff --git a/lib/api.js b/lib/api.js index b5d406d2c..4a6ee092b 100644 --- a/lib/api.js +++ b/lib/api.js @@ -494,6 +494,8 @@ app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) response.push({ id: row.id, ts: (new Date(row.paid_time)).getTime(), + ts_found: (new Date(row.found_time)).getTime(), + port: row.port, hash: row.hex, value_percent: miner_payment_share * 100.0, value: miner_payment_share * row.amount / global.config.general.sigDivisor diff --git a/lib/blockManager.js b/lib/blockManager.js index c00dfdf1d..2d34f7c8b 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -368,7 +368,7 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, }); } -function doPPLNSPayments(block_hex, block_reward, unlock_callback) { +function doPPLNSPayments(block_hex, block_reward, block_port, block_timestamp, unlock_callback) { console.log("Performing PPLNS payout of block " + block_hex + " with value " + global.support.coinToDecimal(block_reward)); global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { if (typeof(rows[0]) === 'undefined' || typeof(rows[0].amt) === 'undefined') { @@ -379,7 +379,7 @@ function doPPLNSPayments(block_hex, block_reward, unlock_callback) { global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (rows.length) { - global.mysql.query("INSERT INTO paid_blocks (hex, amount) VALUES (?,?)", [block_hex, block_reward]).then(function () { + global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,?)", [block_hex, block_reward, block_port, block_timestamp]).then(function () { block_unlock_callback = unlock_callback; rows.forEach(function (row) { row.amount = Math.floor(row.amount * block_reward); @@ -559,7 +559,7 @@ function blockPayments(block, cb) { return cb(); } paymentInProgress = true; - doPPLNSPayments(block.hash, block.value, function() { + doPPLNSPayments(block.hash, block.value, global.config.daemon.port, block.timestamp, function() { console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockBlock(block.hash); return cb(); @@ -593,7 +593,7 @@ function altblockPayments(block, cb) { return cb(); } paymentInProgress = true; - doPPLNSPayments(block.hash, block.pay_value, function() { + doPPLNSPayments(block.hash, block.pay_value, block.port, block.timestamp, function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); return cb(); From d1a777919b5fdbc7689c22b14c9937fc77cf8e13 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 00:37:47 +0000 Subject: [PATCH 1272/1496] Added block found time and port --- deployment/base.sql | 2 +- lib/blockManager.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 67c71c9ce..cdbbf153c 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -19,8 +19,8 @@ CREATE TABLE `balance` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `paid_blocks` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `found_time` timestamp NOT NULL, `paid_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `found_time` timestamp NOT NULL, `port` int NOT NULL, `hex` varchar(128) NOT NULL, `amount` bigint(20) DEFAULT NULL, diff --git a/lib/blockManager.js b/lib/blockManager.js index 2d34f7c8b..5f9b960ad 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -379,7 +379,7 @@ function doPPLNSPayments(block_hex, block_reward, block_port, block_timestamp, u global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (rows.length) { - global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,?)", [block_hex, block_reward, block_port, block_timestamp]).then(function () { + global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,SEC_TO_TIME(?))", [block_hex, block_reward, block_port, block_timestamp]).then(function () { block_unlock_callback = unlock_callback; rows.forEach(function (row) { row.amount = Math.floor(row.amount * block_reward); From 67c3f856e676fb91123f66bc1cd3d7d49d259c86 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 00:40:34 +0000 Subject: [PATCH 1273/1496] Added block found time and port --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 5f9b960ad..c4a4a1ba3 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -379,7 +379,7 @@ function doPPLNSPayments(block_hex, block_reward, block_port, block_timestamp, u global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (rows.length) { - global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,SEC_TO_TIME(?))", [block_hex, block_reward, block_port, block_timestamp]).then(function () { + global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,SEC_TO_TIME(?))", [block_hex, block_reward, parseInt(block_port), block_timestamp / 1000]).then(function () { block_unlock_callback = unlock_callback; rows.forEach(function (row) { row.amount = Math.floor(row.amount * block_reward); From 368199077864614eab642ce4dfc04bfb49c228c3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 00:42:33 +0000 Subject: [PATCH 1274/1496] Added block found time and port --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index c4a4a1ba3..4905079e9 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -379,7 +379,7 @@ function doPPLNSPayments(block_hex, block_reward, block_port, block_timestamp, u global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (rows.length) { - global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,SEC_TO_TIME(?))", [block_hex, block_reward, parseInt(block_port), block_timestamp / 1000]).then(function () { + global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,SEC_TO_TIME(?))", [block_hex, block_reward, parseInt(block_port), parseInt(block_timestamp / 1000)]).then(function () { block_unlock_callback = unlock_callback; rows.forEach(function (row) { row.amount = Math.floor(row.amount * block_reward); From 7dfdf5ec2759a447a58d4147ac8cca0055e4bd32 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 00:48:52 +0000 Subject: [PATCH 1275/1496] Added block found time and port --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 4905079e9..c5f0c920f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -379,7 +379,7 @@ function doPPLNSPayments(block_hex, block_reward, block_port, block_timestamp, u global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (rows.length) { - global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,SEC_TO_TIME(?))", [block_hex, block_reward, parseInt(block_port), parseInt(block_timestamp / 1000)]).then(function () { + global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,?)", [block_hex, block_reward, parseInt(block_port), global.support.formatDate(block_timestamp)]).then(function () { block_unlock_callback = unlock_callback; rows.forEach(function (row) { row.amount = Math.floor(row.amount * block_reward); From b2dd23fe11573e81975513c1e38d6f89cb094dc6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 01:29:25 +0000 Subject: [PATCH 1276/1496] Added block found time and port --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index c5f0c920f..0ec8facab 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -380,6 +380,7 @@ function doPPLNSPayments(block_hex, block_reward, block_port, block_timestamp, u global.mysql.query("SELECT payment_address, payment_id, amount FROM block_balance WHERE hex = ?", [block_hex]).then(function (rows) { if (rows.length) { global.mysql.query("INSERT INTO paid_blocks (hex, amount, port, found_time) VALUES (?,?,?,?)", [block_hex, block_reward, parseInt(block_port), global.support.formatDate(block_timestamp)]).then(function () { + console.log("Adding total due to " + rows.length + " miners"); block_unlock_callback = unlock_callback; rows.forEach(function (row) { row.amount = Math.floor(row.amount * block_reward); From 6b8c25ec7e2fe07059a4c37cfc2e16adda883dff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 01:54:06 +0000 Subject: [PATCH 1277/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 0ec8facab..cf2c30136 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -343,10 +343,11 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, block_hexes.forEach(function(block_hex) { Object.keys(paymentData).forEach(function (key) { if (paymentData[key].amount) { - paymentData[key].hex = block_hex; - paymentData[key].amount = paymentData[key].amount / pay_window; + let paymentData2 = paymentData[key]; + paymentData2.hex = block_hex; + paymentData2.amount /= pay_window; ++ add_count; - createBlockBalanceQueue.push(paymentData[key], function (status) { + createBlockBalanceQueue.push(paymentData2, function (status) { if (status === false) is_ok = false; if (--add_count == 0) { is_pay_done = true; From ab8ab7fb36b6563b2ca55b147e4e69ef3aee8f7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 02:00:04 +0000 Subject: [PATCH 1278/1496] Merge reward calc for same anchor height --- manage_scripts/altblock_recalc_distro.js | 44 ++++++++++++++++++++++++ manage_scripts/altblock_revalidate.js | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 manage_scripts/altblock_recalc_distro.js diff --git a/manage_scripts/altblock_recalc_distro.js b/manage_scripts/altblock_recalc_distro.js new file mode 100644 index 000000000..03173321f --- /dev/null +++ b/manage_scripts/altblock_recalc_distro.js @@ -0,0 +1,44 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.hash) { + console.error("Please specify altblock hash"); + process.exit(1); +} +const hash = argv.hash; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn(); + let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + let is_found = true; + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + if (blockData.hash === hash) { + is_found = true; + global.coinFuncs.getPortBlockHeaderByHash(blockData.port, hash, (err, body) => { + if (err !== null) { + console.log("Altblock with " + hash + " hash still has invalid hash for " + blockData.port + " port! Exiting!"); + cursor.close(); + txn.commit(); + process.exit(1); + } + console.log("Changing alt-block pay_ready from " + blockData.pay_ready + " to true"); + blockData.pay_ready = false; + txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + cursor.close(); + txn.commit(); + console.log("Altblock with " + hash + " hash was validated! Exiting!"); + process.exit(0); + }); + } + }); + } + if (!is_found) { + cursor.close(); + txn.commit(); + console.log("Not found altblock with " + hash + " hash"); + process.exit(1); + } +}); diff --git a/manage_scripts/altblock_revalidate.js b/manage_scripts/altblock_revalidate.js index 4c6bbee57..e2f649b7c 100644 --- a/manage_scripts/altblock_revalidate.js +++ b/manage_scripts/altblock_revalidate.js @@ -26,7 +26,7 @@ require("../init_mini.js").init(function() { } blockData.valid = true; blockData.unlocked = false; - if (blockData.value != body.reward) console.log("Changing alt-block vlaue from " + blockData.value + " to " + body.reward); + if (blockData.value != body.reward) console.log("Changing alt-block value from " + blockData.value + " to " + body.reward); blockData.value = body.reward; txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); cursor.close(); From 2c74099fb0407d3dc532c329de61d0359463127e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 02:24:07 +0000 Subject: [PATCH 1279/1496] Merge reward calc for same anchor height --- lib/blockManager.js | 12 +++++++++--- manage_scripts/altblock_recalc_distro.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index cf2c30136..31af50ae2 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -342,10 +342,16 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, block_hexes.forEach(function(block_hex) { Object.keys(paymentData).forEach(function (key) { + const payment = paymentData[key]; if (paymentData[key].amount) { - let paymentData2 = paymentData[key]; - paymentData2.hex = block_hex; - paymentData2.amount /= pay_window; + const paymentData2 = { + pool_type: 'pplns', + payment_address: payment.payment_address, + payment_id: payment.payment_id, + bitcoin: 0, + amount: payment.amount / pay_window, + hex: block_hex, + }; ++ add_count; createBlockBalanceQueue.push(paymentData2, function (status) { if (status === false) is_ok = false; diff --git a/manage_scripts/altblock_recalc_distro.js b/manage_scripts/altblock_recalc_distro.js index 03173321f..73bc18537 100644 --- a/manage_scripts/altblock_recalc_distro.js +++ b/manage_scripts/altblock_recalc_distro.js @@ -24,7 +24,7 @@ require("../init_mini.js").init(function() { txn.commit(); process.exit(1); } - console.log("Changing alt-block pay_ready from " + blockData.pay_ready + " to true"); + console.log("Changing alt-block pay_ready from " + blockData.pay_ready + " to false"); blockData.pay_ready = false; txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); cursor.close(); From 39c31fd793c83c217edf056598c8b8bd352cc936 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 03:16:33 +0000 Subject: [PATCH 1280/1496] Added DB close --- lib/local_comms.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index b4b052d19..36f6cfd99 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -945,4 +945,9 @@ function Database(){ }, 900000); // Set DB env reload for every 15 minutes. } +process.on('SIGINT', function() { + global.database.env.close(); +}); + + module.exports = Database; From b4005258456383c5125a140441934a70b0feaa16 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 03:22:19 +0000 Subject: [PATCH 1281/1496] Added DB close --- lib/local_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index 36f6cfd99..4b03b1fb3 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -946,6 +946,7 @@ function Database(){ } process.on('SIGINT', function() { + console.log("closing DB"); global.database.env.close(); }); From 957b9d875ff1133f8e1bc132536fc6cca5f084d1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 03:27:44 +0000 Subject: [PATCH 1282/1496] Added DB close --- lib/local_comms.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 4b03b1fb3..77cf37730 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -946,8 +946,9 @@ function Database(){ } process.on('SIGINT', function() { - console.log("closing DB"); + console.log("Starting closing DB"); global.database.env.close(); + setTimeout(function() { console.log("Finished closing DB"); }, 1000); }); From 892c182aec1984d1f805ad5c0a854e7299eca80e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 03:30:21 +0000 Subject: [PATCH 1283/1496] Added DB close --- lib/local_comms.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 77cf37730..1b31c37d8 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -946,9 +946,8 @@ function Database(){ } process.on('SIGINT', function() { - console.log("Starting closing DB"); + console.log("Closing DB"); global.database.env.close(); - setTimeout(function() { console.log("Finished closing DB"); }, 1000); }); From a669a7d192754b5d8181d569ff65f1c05fd8a374 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 04:56:37 +0000 Subject: [PATCH 1284/1496] Changed ts to secs --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 4a6ee092b..12cd18beb 100644 --- a/lib/api.js +++ b/lib/api.js @@ -493,8 +493,8 @@ app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) const miner_payment_share = row.hex in block_miner_shares ? block_miner_shares[row.hex] : 0; response.push({ id: row.id, - ts: (new Date(row.paid_time)).getTime(), - ts_found: (new Date(row.found_time)).getTime(), + ts: (new Date(row.paid_time)).getTime() / 1000, + ts_found: (new Date(row.found_time)).getTime() / 1000, port: row.port, hash: row.hex, value_percent: miner_payment_share * 100.0, From 8223090706a97913d92155ec6fbc5de35188a121 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Mar 2021 05:16:19 +0000 Subject: [PATCH 1285/1496] Fixed --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index cdbbf153c..9169a4836 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -20,7 +20,7 @@ CREATE TABLE `balance` ( CREATE TABLE `paid_blocks` ( `id` int(11) NOT NULL AUTO_INCREMENT, `paid_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `found_time` timestamp NOT NULL, + `found_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `port` int NOT NULL, `hex` varchar(128) NOT NULL, `amount` bigint(20) DEFAULT NULL, From 80014e243e04a9b81848314b4e240408b1d88556 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Mar 2021 15:06:29 +0000 Subject: [PATCH 1286/1496] Simplified update pay_set.js --- user_scripts/pay_set.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/user_scripts/pay_set.js b/user_scripts/pay_set.js index df5247250..0beeb2746 100644 --- a/user_scripts/pay_set.js +++ b/user_scripts/pay_set.js @@ -8,24 +8,13 @@ if (!argv.user) { process.exit(1); } const user = argv.user; -const pass = "password"; require("../init_mini.js").init(function() { const pay = global.support.decimalToCoin(argv.pay ? argv.pay : 0.003); async.waterfall([ function (callback) { - global.mysql.query("SELECT * FROM users WHERE username = ?", [user]).then(function (rows) { - if (rows.length == 1) { - console.error("Your password is already set, so can not set it again"); - console.log("Found rows in users table: " + rows.length); - process.exit(1); - } - callback(); - }); - }, - function (callback) { - global.mysql.query("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (?, ?, 0, ?)", [user, pass, pay]).then(function (rows) { - console.log("INSERT INTO users (username, email, enable_email, payout_threshold) VALUES (" + user + ", " + pass + ", 0, " + pay + ")"); + global.mysql.query("UPDATE users SET payout_threshold=? WHERE user=?", [pay, user]).then(function (rows) { + console.log("UPDATE users SET payout_threshold=" + pay + " WHERE user=" + user); callback(); }); }, From 8c14f9359a126fccbdc6f2e50c2dfcc69231c29f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Mar 2021 15:07:31 +0000 Subject: [PATCH 1287/1496] Simplified update pay_set.js --- user_scripts/pay_set.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_scripts/pay_set.js b/user_scripts/pay_set.js index 0beeb2746..85db21c16 100644 --- a/user_scripts/pay_set.js +++ b/user_scripts/pay_set.js @@ -14,7 +14,7 @@ require("../init_mini.js").init(function() { async.waterfall([ function (callback) { global.mysql.query("UPDATE users SET payout_threshold=? WHERE user=?", [pay, user]).then(function (rows) { - console.log("UPDATE users SET payout_threshold=" + pay + " WHERE user=" + user); + console.log("UPDATE users SET payout_threshold=" + pay + " WHERE username=" + user); callback(); }); }, From a07592e5fa983681b96cbd71954500bd8b51deea Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Mar 2021 15:08:15 +0000 Subject: [PATCH 1288/1496] Simplified update pay_set.js --- user_scripts/pay_set.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_scripts/pay_set.js b/user_scripts/pay_set.js index 85db21c16..1c559cc8e 100644 --- a/user_scripts/pay_set.js +++ b/user_scripts/pay_set.js @@ -13,7 +13,7 @@ require("../init_mini.js").init(function() { const pay = global.support.decimalToCoin(argv.pay ? argv.pay : 0.003); async.waterfall([ function (callback) { - global.mysql.query("UPDATE users SET payout_threshold=? WHERE user=?", [pay, user]).then(function (rows) { + global.mysql.query("UPDATE users SET payout_threshold=? WHERE username=?", [pay, user]).then(function (rows) { console.log("UPDATE users SET payout_threshold=" + pay + " WHERE username=" + user); callback(); }); From 06b4aef4fb61256cce563009a23e909934f68005 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 9 Mar 2021 19:01:43 +0000 Subject: [PATCH 1289/1496] Added rigid support --- lib/blockManager.js | 2 +- lib/pool.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 31af50ae2..bbbeb2c61 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -343,7 +343,7 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, block_hexes.forEach(function(block_hex) { Object.keys(paymentData).forEach(function (key) { const payment = paymentData[key]; - if (paymentData[key].amount) { + if (payment.amount) { const paymentData2 = { pool_type: 'pplns', payment_address: payment.payment_address, diff --git a/lib/pool.js b/lib/pool.js index fc1da174f..4d109b41e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -555,7 +555,7 @@ function getRavenTargetHex(diff) { return pad_hex((baseRavenDiff / diff).toString(16), 32); }; -function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { +function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, protoVersion, portType, port, agent, algos, algos_perf, algo_min_time) { // Username Layout -
. // Password Layout - .. // Default function is to use the password so they can login. Identifiers can be unique, payment ID is last. @@ -580,7 +580,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, pushMessage, protoVersi this.payout = this.address = login_paymentid_split[0]; this.paymentID = null; - this.identifier = agent && agent.includes('MinerGate') ? "MinerGate" : pass_split[0].substring(0, 64); + this.identifier = agent && agent.includes('MinerGate') ? "MinerGate" : (rigid ? rigid : pass_split[0]).substring(0, 64); if (typeof(login_paymentid_split[1]) !== 'undefined') { if (login_paymentid_split[1].length === 64 && hexMatch.test(login_paymentid_split[1]) && global.coinFuncs.validatePlainAddress(this.address)) { this.paymentID = login_paymentid_split[1]; @@ -1779,7 +1779,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const difficulty = portData.difficulty; const minerId = get_new_id(); let miner = new Miner( - minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, + minerId, params.login, params.pass, params.rigid, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"], params["algo-min-time"] ); if (miner.debugMiner) socket.debugMiner = 1; //console.log(threadName + miner.logString + " [WALLET DEBUG] " + method + ": " + JSON.stringify(params)); From 4e4cee5fd916fc559c8356edc156ee35c9840f2f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 00:38:39 +0000 Subject: [PATCH 1290/1496] Extra share debug --- lib/coins/xmr.js | 13 ++++++++++--- lib/pool.js | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 53751f642..ba58b2af2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -187,14 +187,21 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { + let miner_address = {}; queue_obj.remove(function(task) { + if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; + else ++ miner_address[task.miner_address]; if (Date.now() - task.time > 5*60*1000) { task.cb(null); return true; } return false; }); - console.log(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); + console.error(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); + Object.keys(miner_address).forEach(function(key) { + const value = miner_address[key]; + if (value > 100) console.error("Too many shares from " + key + ": " + value); + }); } }, 30*1000, shareVerifyQueue); @@ -873,7 +880,7 @@ function Coin(data){ return this.slowHashBuff(convertedBlob, blockTemplate, nonce, mixhash).toString("hex"); } - this.slowHashAsync = function(convertedBlob, blockTemplate, cb) { + this.slowHashAsync = function(convertedBlob, blockTemplate, miner_address, cb) { if (!global.config.verify_shares_host) return cb(this.slowHash(convertedBlob, blockTemplate)); let jsonInput; switch (blockTemplate.port) { @@ -893,7 +900,7 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - return shareVerifyQueue.unshift({ "jsonInput": jsonInput, "cb": cb, "time": Date.now() }); + return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: miner_address }); } this.c29 = function(header, ring, port) { diff --git a/lib/pool.js b/lib/pool.js index 4d109b41e..d4f767e0c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1614,7 +1614,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { blockData = getShareBuffer(miner, job, blockTemplate, params); if (blockData !== null) { const convertedBlob = global.coinFuncs.convertBlob(blockData, port); - global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { + global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, miner.payout, function(hash) { if (hash === null || hash === false) { console.error(threadName + "[EXTRA CHECK] Can't verify share remotely!"); } else if (hash !== resultHash) { @@ -1666,7 +1666,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } } else { const time_now = Date.now(); - global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, function(hash) { + global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, miner.payout, function(hash) { if (hash === null) { return processShareCB(null); } else if (hash === false) { From 5fbbaab23db9aadd0c7a1d2891abd81d85067b3d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 00:56:54 +0000 Subject: [PATCH 1291/1496] Extra share debug --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ba58b2af2..6476dfcff 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -189,6 +189,7 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { let miner_address = {}; queue_obj.remove(function(task) { + console.error(task.miner_address); if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; else ++ miner_address[task.miner_address]; if (Date.now() - task.time > 5*60*1000) { From d0f2e488d9f353b7950db304d1d06a1b514dd565 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 00:59:38 +0000 Subject: [PATCH 1292/1496] Extra share debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6476dfcff..6be341faf 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -189,7 +189,7 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { let miner_address = {}; queue_obj.remove(function(task) { - console.error(task.miner_address); + console.error(JSON.stringify(task)); if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; else ++ miner_address[task.miner_address]; if (Date.now() - task.time > 5*60*1000) { From 3b70a82f5f3a1aa70c34911f8ca844666335f4bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:01:01 +0000 Subject: [PATCH 1293/1496] Extra share debug --- lib/coins/xmr.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6be341faf..ba58b2af2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -189,7 +189,6 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 1000) { let miner_address = {}; queue_obj.remove(function(task) { - console.error(JSON.stringify(task)); if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; else ++ miner_address[task.miner_address]; if (Date.now() - task.time > 5*60*1000) { From 3c3d79ed7bc0a90b6a39ef223ca43f88ba56909d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:03:36 +0000 Subject: [PATCH 1294/1496] Extra share debug --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ba58b2af2..8af89ecf7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -900,6 +900,7 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } + console.log(miner_address); return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: miner_address }); } From 7ca988ef154fc9867bba2866f484945e0c6bfa18 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:08:23 +0000 Subject: [PATCH 1295/1496] Extra share debug --- lib/coins/xmr.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8af89ecf7..ba58b2af2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -900,7 +900,6 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - console.log(miner_address); return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: miner_address }); } From 5c9ab2272fcc43db228b9bd7fcf023f879a96821 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:08:45 +0000 Subject: [PATCH 1296/1496] Extra share debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ba58b2af2..6863028a5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -139,7 +139,7 @@ const mm_child_port_set = get_mm_child_port_set(mm_port_set); let shareVerifyQueue = async.queue(function (task, queueCB) { const cb = task.cb; - if (Date.now() - task.time > 5*60*1000) { + if (Date.now() - task.time > 60*1000) { cb(null); return queueCB(); } From 27b91d04bcb27e6db452922198b4e646c51a5c5b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:36:27 +0000 Subject: [PATCH 1297/1496] Extra share debug --- lib/coins/xmr.js | 8 ++++---- lib/pool.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6863028a5..294a4120e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -139,7 +139,7 @@ const mm_child_port_set = get_mm_child_port_set(mm_port_set); let shareVerifyQueue = async.queue(function (task, queueCB) { const cb = task.cb; - if (Date.now() - task.time > 60*1000) { + if (Date.now() - task.time > 1*60*1000) { cb(null); return queueCB(); } @@ -186,12 +186,12 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - if (queue_obj.length() > 1000) { + if (queue_obj.length() > 0) { let miner_address = {}; queue_obj.remove(function(task) { if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; else ++ miner_address[task.miner_address]; - if (Date.now() - task.time > 5*60*1000) { + if (Date.now() - task.time > 1*60*1000) { task.cb(null); return true; } @@ -200,7 +200,7 @@ setInterval(function(queue_obj){ console.error(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); Object.keys(miner_address).forEach(function(key) { const value = miner_address[key]; - if (value > 100) console.error("Too many shares from " + key + ": " + value); + if (value > 0) console.error("Too many shares from " + key + ": " + value); }); } }, 30*1000, shareVerifyQueue); diff --git a/lib/pool.js b/lib/pool.js index d4f767e0c..9934eae16 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1006,13 +1006,13 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro if (validShare) { ++ this.validShares; } else { + ++ this.invalidShares; if (this.validShares === 0) { console.error(threadName + "Suspended miner IP for submitting bad share with zero trust " + this.logString); removeMiner(this); process.send({type: 'banIP', data: this.ipAddress}); return; } - ++ this.invalidShares; } const shareCount = this.validShares + this.invalidShares; From e6e5d7d25a0f566e7be9ad05075bea2e9a7e0c61 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:38:37 +0000 Subject: [PATCH 1298/1496] Extra share debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 294a4120e..19a2173e8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -900,7 +900,7 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: miner_address }); + return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: "xxx" }); } this.c29 = function(header, ring, port) { From ff83068e2b545112d51911e0c478ff681335903f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:41:53 +0000 Subject: [PATCH 1299/1496] Extra share debug --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 19a2173e8..5f6991ebc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -189,6 +189,7 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 0) { let miner_address = {}; queue_obj.remove(function(task) { + console.log(task.miner_address + " " + task.time); if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; else ++ miner_address[task.miner_address]; if (Date.now() - task.time > 1*60*1000) { From db153d78b0fb7711b33674f73f3133810e0b3611 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:44:25 +0000 Subject: [PATCH 1300/1496] Extra share debug --- lib/coins/xmr.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5f6991ebc..294a4120e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -189,7 +189,6 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 0) { let miner_address = {}; queue_obj.remove(function(task) { - console.log(task.miner_address + " " + task.time); if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; else ++ miner_address[task.miner_address]; if (Date.now() - task.time > 1*60*1000) { @@ -901,7 +900,7 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: "xxx" }); + return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: miner_address }); } this.c29 = function(header, ring, port) { From f6cb0fcfd01a91fc503b75ee013950c91260ce2b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:48:35 +0000 Subject: [PATCH 1301/1496] Extra share debug --- lib/coins/xmr.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 294a4120e..8314e4c42 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -189,10 +189,11 @@ setInterval(function(queue_obj){ if (queue_obj.length() > 0) { let miner_address = {}; queue_obj.remove(function(task) { - if (!(task.miner_address in miner_address)) miner_address[task.miner_address] = 1; - else ++ miner_address[task.miner_address]; - if (Date.now() - task.time > 1*60*1000) { - task.cb(null); + const d = task.data; + if (!(d.miner_address in miner_address)) miner_address[d.miner_address] = 1; + else ++ miner_address[d.miner_address]; + if (Date.now() - d.time > 1*60*1000) { + d.cb(null); return true; } return false; From d2f7363598da16612c455216a3d89bd962280961 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 01:49:36 +0000 Subject: [PATCH 1302/1496] Extra share debug --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8314e4c42..2288a14fd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -186,7 +186,7 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { }, 32); setInterval(function(queue_obj){ - if (queue_obj.length() > 0) { + if (queue_obj.length() > 1000) { let miner_address = {}; queue_obj.remove(function(task) { const d = task.data; @@ -201,7 +201,7 @@ setInterval(function(queue_obj){ console.error(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); Object.keys(miner_address).forEach(function(key) { const value = miner_address[key]; - if (value > 0) console.error("Too many shares from " + key + ": " + value); + if (value > 100) console.error("Too many shares from " + key + ": " + value); }); } }, 30*1000, shareVerifyQueue); From b8c63601c0600b9ddd957400fad85c71574c48d0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 02:05:55 +0000 Subject: [PATCH 1303/1496] Wallet tmp bans --- lib/pool.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9934eae16..086f4259a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -57,7 +57,8 @@ function eth_extranonce(id) { return id === null ? null : pad_hex(((id << uniqueWorkerIdBits) + uniqueWorkerId).toString(16), 2); }; -let bannedIPs = {}; +let bannedTmpIPs = {}; +let bannedTmpWallets = {}; let bannedAddresses = {}; let notifyAddresses = {}; @@ -151,7 +152,8 @@ function messageHandler(message) { if (cluster.isMaster) { sendToWorkers(message); } else { - if (message.data != "127.0.0.1") bannedIPs[message.data] = 1; + if (message.data != "127.0.0.1") bannedTmpIPs[message.data] = 1; + else if (message.wallet) bannedTmpWallets[message.wallet] = 1; } break; case 'newBlockTemplate': @@ -644,6 +646,11 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.valid_miner = false; return; } + if (address in bannedTmpWallets) { + this.error = "Temporary (10 minutes max) banned payment address " + address; + this.valid_miner = false; + return; + } if (address in this.payout_div) { this.error = "You can't repeat payment split address " + address; this.valid_miner = false; @@ -675,6 +682,12 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro return; } + if (this.payout in bannedTmpWallets) { + this.error = "Temporary (10 minutes max) banned payment address " + this.payout; + this.valid_miner = false; + return; + } + if (global.coinFuncs.exchangeAddresses.indexOf(this.address) !== -1 && !(this.paymentID)) { this.error = "Exchange addresses need 64 hex character long payment IDs. Please specify it after your wallet address as follows after dot: Wallet.PaymentID"; this.valid_miner = false; @@ -1010,7 +1023,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro if (this.validShares === 0) { console.error(threadName + "Suspended miner IP for submitting bad share with zero trust " + this.logString); removeMiner(this); - process.send({type: 'banIP', data: this.ipAddress}); + process.send({type: 'banIP', data: this.ipAddress, wallet: this.payout}); return; } } @@ -1020,7 +1033,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro if (100 * this.invalidShares / shareCount >= global.config.pool.banPercent) { console.error(threadName + "Suspended miner IP for submitting too many bad shares recently " + this.logString); removeMiner(this); - process.send({type: 'banIP', data: this.ipAddress}); + process.send({type: 'banIP', data: this.ipAddress, wallet: this.payout}); } else { this.invalidShares = 0; this.validShares = 0; @@ -1763,7 +1776,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se // continue to normal login case 'login': { // Grin and default - if (ip in bannedIPs) { + if (ip in bannedTmpIPs) { sendReplyFinal("New connections from this IP address are temporarily suspended from mining (10 minutes max)"); return; } @@ -2387,7 +2400,8 @@ if (cluster.isMaster) { setInterval(checkAliveMiners, 60*1000); setInterval(retargetMiners, global.config.pool.retargetTime * 1000); setInterval(function () { - bannedIPs = {}; + bannedTmpIPs = {}; + bannedTmpWallets = {}; }, 10*60*1000); function add_bans(is_show) { From 918f2368d1ebe27849fd1c0dd5109435dd835d0b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 02:44:43 +0000 Subject: [PATCH 1304/1496] Added multiple share verify servers --- lib/coins/xmr.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2288a14fd..36662d4d1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -137,6 +137,8 @@ function get_algos() { const all_algos = get_algos(); const mm_child_port_set = get_mm_child_port_set(mm_port_set); +let next_verify_share_host = 0; + let shareVerifyQueue = async.queue(function (task, queueCB) { const cb = task.cb; if (Date.now() - task.time > 1*60*1000) { @@ -158,7 +160,9 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { socket.destroy(); return return_cb(false); }, 60*1000); - socket.connect(2222, global.config.verify_shares_host, function () { + const verify_share_host = global.config.verify_shares_host instanceof String ? global.config.verify_shares_host : + global.config.verify_shares_host[next_verify_share_host++ % global.config.verify_shares_host.length]; + socket.connect(2222, verify_shares_host, function () { socket.write(JSON.stringify(jsonInput) + "\n"); }); From df3c19a1c094e4110526743aa4ac3acfcd9229fe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 02:49:07 +0000 Subject: [PATCH 1305/1496] Added multiple share verify servers --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 36662d4d1..db188e90f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -160,8 +160,8 @@ let shareVerifyQueue = async.queue(function (task, queueCB) { socket.destroy(); return return_cb(false); }, 60*1000); - const verify_share_host = global.config.verify_shares_host instanceof String ? global.config.verify_shares_host : - global.config.verify_shares_host[next_verify_share_host++ % global.config.verify_shares_host.length]; + const verify_shares_host = global.config.verify_shares_host instanceof String ? global.config.verify_shares_host : + global.config.verify_shares_host[next_verify_share_host++ % global.config.verify_shares_host.length]; socket.connect(2222, verify_shares_host, function () { socket.write(JSON.stringify(jsonInput) + "\n"); }); From 22daa1f58d43fc5b84225eca6e075d02516ebcc8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 04:17:28 +0000 Subject: [PATCH 1306/1496] Separate queue for verify servers --- lib/coins/xmr.js | 151 +++++++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 69 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index db188e90f..25b80bbbc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -137,78 +137,82 @@ function get_algos() { const all_algos = get_algos(); const mm_child_port_set = get_mm_child_port_set(mm_port_set); -let next_verify_share_host = 0; - -let shareVerifyQueue = async.queue(function (task, queueCB) { - const cb = task.cb; - if (Date.now() - task.time > 1*60*1000) { - cb(null); - return queueCB(); - } - - const jsonInput = task.jsonInput; - - let socket = new net.Socket(); - let is_cb = false; - let return_cb = function(result) { - if (is_cb) return; - is_cb = true; - cb(result); - return queueCB(); - } - let timer = setTimeout(function() { - socket.destroy(); - return return_cb(false); - }, 60*1000); - const verify_shares_host = global.config.verify_shares_host instanceof String ? global.config.verify_shares_host : - global.config.verify_shares_host[next_verify_share_host++ % global.config.verify_shares_host.length]; - socket.connect(2222, verify_shares_host, function () { - socket.write(JSON.stringify(jsonInput) + "\n"); - }); - - let buff = ""; - socket.on('data', function (buff1) { - buff += buff1; - }); - - socket.on("end", function () { - clearTimeout(timer); - timer = null; - try { - const jsonOutput = JSON.parse(buff.toString()); - if (!("result" in jsonOutput)) return return_cb(false); - return return_cb(jsonOutput.result); - } catch (e) { - return return_cb(false); +let shareVerifyQueue = []; +let shareVerifyQueueErrorTime = []; + +global.config.verify_shares_host.forEach(function(verify_shares_host, index) { + shareVerifyQueue[index] = async.queue(function (task, queueCB) { + const cb = task.cb; + if (Date.now() - task.time > 1*60*1000) { + cb(null); + return queueCB(); } - }); - - socket.on('error', function() { - socket.destroy(); - return return_cb(false); - }); -}, 32); - -setInterval(function(queue_obj){ - if (queue_obj.length() > 1000) { - let miner_address = {}; - queue_obj.remove(function(task) { - const d = task.data; - if (!(d.miner_address in miner_address)) miner_address[d.miner_address] = 1; - else ++ miner_address[d.miner_address]; - if (Date.now() - d.time > 1*60*1000) { - d.cb(null); - return true; + + const jsonInput = task.jsonInput; + + let socket = new net.Socket(); + let is_cb = false; + let return_cb = function(result) { + if (is_cb) return; + is_cb = true; + cb(result); + return queueCB(); + } + let timer = setTimeout(function() { + socket.destroy(); + shareVerifyQueueErrorTime[index] = Date.now(); + return return_cb(false); + }, 60*1000); + socket.connect(2222, verify_shares_host, function () { + socket.write(JSON.stringify(jsonInput) + "\n"); + }); + + let buff = ""; + socket.on('data', function (buff1) { + buff += buff1; + }); + + socket.on("end", function () { + clearTimeout(timer); + timer = null; + try { + const jsonOutput = JSON.parse(buff.toString()); + if (!("result" in jsonOutput)) return return_cb(false); + return return_cb(jsonOutput.result); + } catch (e) { + shareVerifyQueueErrorTime[index] = Date.now(); + return return_cb(false); } - return false; }); - console.error(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); - Object.keys(miner_address).forEach(function(key) { - const value = miner_address[key]; - if (value > 100) console.error("Too many shares from " + key + ": " + value); + + socket.on('error', function() { + socket.destroy(); + shareVerifyQueueErrorTime[index] = Date.now(); + return return_cb(false); }); - } -}, 30*1000, shareVerifyQueue); + }, 16); + + setInterval(function(queue_obj){ + if (queue_obj.length() > 1000) { + let miner_address = {}; + queue_obj.remove(function(task) { + const d = task.data; + if (!(d.miner_address in miner_address)) miner_address[d.miner_address] = 1; + else ++ miner_address[d.miner_address]; + if (Date.now() - d.time > 1*60*1000) { + d.cb(null); + return true; + } + return false; + }); + console.error(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); + Object.keys(miner_address).forEach(function(key) { + const value = miner_address[key]; + if (value > 100) console.error("Too many shares from " + key + ": " + value); + }); + } + }, 30*1000, shareVerifyQueue[index]); +}); const ETH_BASE_REWARD = 2; const ETH_MULTIPLIER = 1000000000000000000; @@ -885,6 +889,8 @@ function Coin(data){ return this.slowHashBuff(convertedBlob, blockTemplate, nonce, mixhash).toString("hex"); } + this.verify_share_host_index = 0; + this.slowHashAsync = function(convertedBlob, blockTemplate, miner_address, cb) { if (!global.config.verify_shares_host) return cb(this.slowHash(convertedBlob, blockTemplate)); let jsonInput; @@ -905,7 +911,14 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - return shareVerifyQueue.unshift({ jsonInput: jsonInput, cb: cb, time: Date.now(), miner_address: miner_address }); + const time_now = Date.now(); + const host_count = global.config.verify_shares_host.length; + let max_attempts = host_count; + do { + ++ verify_share_host_index; + if (verify_share_host_index >= host_count) verify_share_host_index = 0; + } while (--max_attempts && shareVerifyQueueErrorTime[verify_share_host_index] && time_now - shareVerifyQueueErrorTime[verify_share_host_index] < 60*1000); + return shareVerifyQueue[verify_share_host_index].unshift({ jsonInput: jsonInput, cb: cb, time: time_now, miner_address: miner_address }); } this.c29 = function(header, ring, port) { From 55cd05c07f54f28acd4c8a4d084c774e39938d91 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 04:24:41 +0000 Subject: [PATCH 1307/1496] Separate queue for verify servers --- lib/coins/xmr.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 25b80bbbc..61a2f66ed 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -160,6 +160,11 @@ global.config.verify_shares_host.forEach(function(verify_shares_host, index) { } let timer = setTimeout(function() { socket.destroy(); + if (!shareVerifyQueueErrorTime[index] || Date.now() - shareVerifyQueueErrorTime[index] > 30*60*1000) { + const err_str = "Server " + global.config.hostname + " timeouted share verification to " + verify_shares_host; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); + } shareVerifyQueueErrorTime[index] = Date.now(); return return_cb(false); }, 60*1000); @@ -180,6 +185,11 @@ global.config.verify_shares_host.forEach(function(verify_shares_host, index) { if (!("result" in jsonOutput)) return return_cb(false); return return_cb(jsonOutput.result); } catch (e) { + if (!shareVerifyQueueErrorTime[index] || Date.now() - shareVerifyQueueErrorTime[index] > 30*60*1000) { + const err_str = "Server " + global.config.hostname + " got wrong JSON from " + verify_shares_host; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); + } shareVerifyQueueErrorTime[index] = Date.now(); return return_cb(false); } @@ -187,6 +197,11 @@ global.config.verify_shares_host.forEach(function(verify_shares_host, index) { socket.on('error', function() { socket.destroy(); + if (!shareVerifyQueueErrorTime[index] || Date.now() - shareVerifyQueueErrorTime[index] > 30*60*1000) { + const err_str = "Server " + global.config.hostname + " got socket error from " + verify_shares_host; + console.error(err_str); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); + } shareVerifyQueueErrorTime[index] = Date.now(); return return_cb(false); }); @@ -917,7 +932,7 @@ function Coin(data){ do { ++ verify_share_host_index; if (verify_share_host_index >= host_count) verify_share_host_index = 0; - } while (--max_attempts && shareVerifyQueueErrorTime[verify_share_host_index] && time_now - shareVerifyQueueErrorTime[verify_share_host_index] < 60*1000); + } while (--max_attempts && shareVerifyQueueErrorTime[verify_share_host_index] && time_now - shareVerifyQueueErrorTime[verify_share_host_index] < 5*60*1000); return shareVerifyQueue[verify_share_host_index].unshift({ jsonInput: jsonInput, cb: cb, time: time_now, miner_address: miner_address }); } From 4ea84444e4855d58fe99b2967d9eb1cb893ba366 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 04:34:11 +0000 Subject: [PATCH 1308/1496] Separate queue for verify servers --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 61a2f66ed..b61c6ffef 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -930,10 +930,10 @@ function Coin(data){ const host_count = global.config.verify_shares_host.length; let max_attempts = host_count; do { - ++ verify_share_host_index; - if (verify_share_host_index >= host_count) verify_share_host_index = 0; - } while (--max_attempts && shareVerifyQueueErrorTime[verify_share_host_index] && time_now - shareVerifyQueueErrorTime[verify_share_host_index] < 5*60*1000); - return shareVerifyQueue[verify_share_host_index].unshift({ jsonInput: jsonInput, cb: cb, time: time_now, miner_address: miner_address }); + ++ this.verify_share_host_index; + if (this.verify_share_host_index >= host_count) this.verify_share_host_index = 0; + } while (--max_attempts && shareVerifyQueueErrorTime[this.verify_share_host_index] && time_now - shareVerifyQueueErrorTime[this.verify_share_host_index] < 5*60*1000); + return shareVerifyQueue[this.verify_share_host_index].unshift({ jsonInput: jsonInput, cb: cb, time: time_now, miner_address: miner_address }); } this.c29 = function(header, ring, port) { From 76ab68df898b0e1ffecd222f58ae0c8923a2b3ff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Mar 2021 05:26:48 +0000 Subject: [PATCH 1309/1496] Added multiple share verify servers --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b61c6ffef..eed9dc249 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -140,7 +140,7 @@ const mm_child_port_set = get_mm_child_port_set(mm_port_set); let shareVerifyQueue = []; let shareVerifyQueueErrorTime = []; -global.config.verify_shares_host.forEach(function(verify_shares_host, index) { +if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(function(verify_shares_host, index) { shareVerifyQueue[index] = async.queue(function (task, queueCB) { const cb = task.cb; if (Date.now() - task.time > 1*60*1000) { From 4df184fb382b6fc68f14e4672f10fe42b3e440e0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Mar 2021 01:55:41 +0000 Subject: [PATCH 1310/1496] Improving balancing of multi share verify servers --- lib/coins/xmr.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index eed9dc249..fce997e8c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -160,7 +160,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f } let timer = setTimeout(function() { socket.destroy(); - if (!shareVerifyQueueErrorTime[index] || Date.now() - shareVerifyQueueErrorTime[index] > 30*60*1000) { + if (shareVerifyQueueErrorTime[index] && Date.now() - shareVerifyQueueErrorTime[index] < 10*1000) { const err_str = "Server " + global.config.hostname + " timeouted share verification to " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -185,7 +185,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f if (!("result" in jsonOutput)) return return_cb(false); return return_cb(jsonOutput.result); } catch (e) { - if (!shareVerifyQueueErrorTime[index] || Date.now() - shareVerifyQueueErrorTime[index] > 30*60*1000) { + if (shareVerifyQueueErrorTime[index] && Date.now() - shareVerifyQueueErrorTime[index] < 10*1000) { const err_str = "Server " + global.config.hostname + " got wrong JSON from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -197,7 +197,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f socket.on('error', function() { socket.destroy(); - if (!shareVerifyQueueErrorTime[index] || Date.now() - shareVerifyQueueErrorTime[index] > 30*60*1000) { + if (shareVerifyQueueErrorTime[index] && Date.now() - shareVerifyQueueErrorTime[index] < 10*1000) { const err_str = "Server " + global.config.hostname + " got socket error from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -926,14 +926,30 @@ function Coin(data){ default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } - const time_now = Date.now(); - const host_count = global.config.verify_shares_host.length; - let max_attempts = host_count; - do { - ++ this.verify_share_host_index; - if (this.verify_share_host_index >= host_count) this.verify_share_host_index = 0; - } while (--max_attempts && shareVerifyQueueErrorTime[this.verify_share_host_index] && time_now - shareVerifyQueueErrorTime[this.verify_share_host_index] < 5*60*1000); - return shareVerifyQueue[this.verify_share_host_index].unshift({ jsonInput: jsonInput, cb: cb, time: time_now, miner_address: miner_address }); + const time_now = Date.now(); + let best_index = null; + let min_queue_size = null; + let max_noerr_time = null; + shareVerifyQueue.forEach(function(queue_obj, index) { + if (shareVerifyQueueErrorTime[index] && time_now - shareVerifyQueueErrorTime[index] < 5*60*1000) return; + if (min_queue_size === null || queue_obj.length() < min_queue_size) { + best_index = index; + min_queue_size = queue_obj.length(); + } + }); + if (best_index === null) shareVerifyQueueErrorTime.forEach(function(last_error_time, index) { + const noerr_time = time_now - last_error_time; + if (max_noerr_time === null || noerr_time > max_noerr_time) { + best_index = index; + max_noerr_time = noerr_time; + } + }); + return shareVerifyQueue[best_index].unshift({ + jsonInput: jsonInput, + cb: cb, + time: time_now, + miner_address: miner_address + }); } this.c29 = function(header, ring, port) { From 137c2bfd2d5fc5915653e928cad7101cbf82cf18 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 12 Mar 2021 15:53:46 +0000 Subject: [PATCH 1311/1496] Improving balancing of multi share verify servers --- lib/coins/xmr.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index fce997e8c..c646c2cd2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -139,8 +139,11 @@ const mm_child_port_set = get_mm_child_port_set(mm_port_set); let shareVerifyQueue = []; let shareVerifyQueueErrorTime = []; +let shareVerifyQueueCount = []; if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(function(verify_shares_host, index) { + shareVerifyQueueErrorTime[index] = 0; + shareVerifyQueueCount[index] = 0; shareVerifyQueue[index] = async.queue(function (task, queueCB) { const cb = task.cb; if (Date.now() - task.time > 1*60*1000) { @@ -160,12 +163,13 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f } let timer = setTimeout(function() { socket.destroy(); - if (shareVerifyQueueErrorTime[index] && Date.now() - shareVerifyQueueErrorTime[index] < 10*1000) { + if (shareVerifyQueueCount[index] > 10) { const err_str = "Server " + global.config.hostname + " timeouted share verification to " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); } shareVerifyQueueErrorTime[index] = Date.now(); + ++ shareVerifyQueueCount[index]; return return_cb(false); }, 60*1000); socket.connect(2222, verify_shares_host, function () { @@ -183,26 +187,29 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f try { const jsonOutput = JSON.parse(buff.toString()); if (!("result" in jsonOutput)) return return_cb(false); + shareVerifyQueueCount[index] = 0; return return_cb(jsonOutput.result); } catch (e) { - if (shareVerifyQueueErrorTime[index] && Date.now() - shareVerifyQueueErrorTime[index] < 10*1000) { + if (shareVerifyQueueCount[index] > 10) { const err_str = "Server " + global.config.hostname + " got wrong JSON from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); } shareVerifyQueueErrorTime[index] = Date.now(); + ++ shareVerifyQueueCount[index]; return return_cb(false); } }); socket.on('error', function() { socket.destroy(); - if (shareVerifyQueueErrorTime[index] && Date.now() - shareVerifyQueueErrorTime[index] < 10*1000) { + if (shareVerifyQueueCount[index] > 10) { const err_str = "Server " + global.config.hostname + " got socket error from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); } shareVerifyQueueErrorTime[index] = Date.now(); + ++ shareVerifyQueueCount[index]; return return_cb(false); }); }, 16); @@ -931,7 +938,7 @@ function Coin(data){ let min_queue_size = null; let max_noerr_time = null; shareVerifyQueue.forEach(function(queue_obj, index) { - if (shareVerifyQueueErrorTime[index] && time_now - shareVerifyQueueErrorTime[index] < 5*60*1000) return; + if (time_now - shareVerifyQueueErrorTime[index] < 5*60*1000) return; if (min_queue_size === null || queue_obj.length() < min_queue_size) { best_index = index; min_queue_size = queue_obj.length(); From 702f731602bd902caa042ce504bbab06cb9b9583 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 16 Mar 2021 03:59:24 +0000 Subject: [PATCH 1312/1496] Added check for invalid block reward --- manage_scripts/altblock_revalidate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/altblock_revalidate.js b/manage_scripts/altblock_revalidate.js index e2f649b7c..654d0074d 100644 --- a/manage_scripts/altblock_revalidate.js +++ b/manage_scripts/altblock_revalidate.js @@ -18,7 +18,7 @@ require("../init_mini.js").init(function() { if (blockData.hash === hash) { is_found = true; global.coinFuncs.getPortBlockHeaderByHash(blockData.port, hash, (err, body) => { - if (err !== null) { + if (err !== null || !body.reward) { console.log("Altblock with " + hash + " hash still has invalid hash for " + blockData.port + " port! Exiting!"); cursor.close(); txn.commit(); From 1ad4f50b4e9e750def750aeddcfb5fbb4ec3ea45 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 16 Mar 2021 04:08:24 +0000 Subject: [PATCH 1313/1496] Added check for invalid block reward --- manage_scripts/altblock_revalidate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manage_scripts/altblock_revalidate.js b/manage_scripts/altblock_revalidate.js index 654d0074d..ba295e0ae 100644 --- a/manage_scripts/altblock_revalidate.js +++ b/manage_scripts/altblock_revalidate.js @@ -26,8 +26,8 @@ require("../init_mini.js").init(function() { } blockData.valid = true; blockData.unlocked = false; - if (blockData.value != body.reward) console.log("Changing alt-block value from " + blockData.value + " to " + body.reward); - blockData.value = body.reward; + //if (blockData.value != body.reward) console.log("Changing alt-block value from " + blockData.value + " to " + body.reward); + //blockData.value = body.reward; txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); cursor.close(); txn.commit(); From 3b810c0e2be65afd6d6ba62d536aa4e294269fc8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Mar 2021 21:10:56 +0000 Subject: [PATCH 1314/1496] More debug --- lib/coins/xmr.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c646c2cd2..5a567999e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -139,11 +139,11 @@ const mm_child_port_set = get_mm_child_port_set(mm_port_set); let shareVerifyQueue = []; let shareVerifyQueueErrorTime = []; -let shareVerifyQueueCount = []; +let shareVerifyQueueErrorCount = []; if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(function(verify_shares_host, index) { - shareVerifyQueueErrorTime[index] = 0; - shareVerifyQueueCount[index] = 0; + shareVerifyQueueErrorTime[index] = 0; + shareVerifyQueueErrorCount[index] = 0; shareVerifyQueue[index] = async.queue(function (task, queueCB) { const cb = task.cb; if (Date.now() - task.time > 1*60*1000) { @@ -163,13 +163,13 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f } let timer = setTimeout(function() { socket.destroy(); - if (shareVerifyQueueCount[index] > 10) { + if (shareVerifyQueueErrorCount[index] > 10) { const err_str = "Server " + global.config.hostname + " timeouted share verification to " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); } shareVerifyQueueErrorTime[index] = Date.now(); - ++ shareVerifyQueueCount[index]; + ++ shareVerifyQueueErrorCount[index]; return return_cb(false); }, 60*1000); socket.connect(2222, verify_shares_host, function () { @@ -187,35 +187,35 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f try { const jsonOutput = JSON.parse(buff.toString()); if (!("result" in jsonOutput)) return return_cb(false); - shareVerifyQueueCount[index] = 0; + shareVerifyQueueErrorCount[index] = 0; return return_cb(jsonOutput.result); } catch (e) { - if (shareVerifyQueueCount[index] > 10) { + if (shareVerifyQueueErrorCount[index] > 10) { const err_str = "Server " + global.config.hostname + " got wrong JSON from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); } shareVerifyQueueErrorTime[index] = Date.now(); - ++ shareVerifyQueueCount[index]; + ++ shareVerifyQueueErrorCount[index]; return return_cb(false); } }); socket.on('error', function() { socket.destroy(); - if (shareVerifyQueueCount[index] > 10) { + if (shareVerifyQueueErrorCount[index] > 10) { const err_str = "Server " + global.config.hostname + " got socket error from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); } shareVerifyQueueErrorTime[index] = Date.now(); - ++ shareVerifyQueueCount[index]; + ++ shareVerifyQueueErrorCount[index]; return return_cb(false); }); }, 16); - setInterval(function(queue_obj){ - if (queue_obj.length() > 1000) { + setInterval(function(queue_obj, index){ + if (queue_obj.length() > 0) { let miner_address = {}; queue_obj.remove(function(task) { const d = task.data; @@ -227,13 +227,13 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f } return false; }); - console.error(global.database.thread_id + "Share verify queue state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); + console.error(global.database.thread_id + "Share verify queue " + index + " state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); Object.keys(miner_address).forEach(function(key) { const value = miner_address[key]; if (value > 100) console.error("Too many shares from " + key + ": " + value); }); } - }, 30*1000, shareVerifyQueue[index]); + }, 30*1000, shareVerifyQueue[index], index); }); const ETH_BASE_REWARD = 2; From 4db5cd0fc58da370578de7dc839f27c0ccd3e7d9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Mar 2021 21:14:10 +0000 Subject: [PATCH 1315/1496] More debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5a567999e..9ddfa9996 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -215,7 +215,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f }, 16); setInterval(function(queue_obj, index){ - if (queue_obj.length() > 0) { + if (queue_obj.length() >= 0) { let miner_address = {}; queue_obj.remove(function(task) { const d = task.data; From 35fb50b1461e7ebb1eefdf21c34f7039fed33f4f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Mar 2021 21:22:58 +0000 Subject: [PATCH 1316/1496] Improved share verify load balancing --- lib/coins/xmr.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9ddfa9996..e6de4155b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -227,7 +227,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f } return false; }); - console.error(global.database.thread_id + "Share verify queue " + index + " state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); + console.error(global.database.thread_id + "Share verify queue " + index + " state: " + queue_obj.length() + " items in the queue " + queue_obj.running() + " items being processed"); Object.keys(miner_address).forEach(function(key) { const value = miner_address[key]; if (value > 100) console.error("Too many shares from " + key + ": " + value); @@ -939,9 +939,10 @@ function Coin(data){ let max_noerr_time = null; shareVerifyQueue.forEach(function(queue_obj, index) { if (time_now - shareVerifyQueueErrorTime[index] < 5*60*1000) return; - if (min_queue_size === null || queue_obj.length() < min_queue_size) { + const qlength = queue_obj.length() + queue_obj.running(); + if (min_queue_size === null || qlength < min_queue_size) { best_index = index; - min_queue_size = queue_obj.length(); + min_queue_size = qlength; } }); if (best_index === null) shareVerifyQueueErrorTime.forEach(function(last_error_time, index) { From dc8053457951fef109215d2d393349c352b1d65f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Mar 2021 21:26:15 +0000 Subject: [PATCH 1317/1496] Remove debug --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e6de4155b..5e928f015 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -215,7 +215,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f }, 16); setInterval(function(queue_obj, index){ - if (queue_obj.length() >= 0) { + if (queue_obj.length() >= 1000) { let miner_address = {}; queue_obj.remove(function(task) { const d = task.data; From e97bf526053679cd1d6264d36cfdee2a003da6dd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Mar 2021 05:05:05 +0000 Subject: [PATCH 1318/1496] Disable useless pool ip check --- lib/pool.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 086f4259a..d4e7fd6e6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -120,14 +120,14 @@ global.database.thread_id = threadName; const COINS = global.coinFuncs.getCOINS(); function registerPool() { - global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { - rows.forEach(function (row) { - if (row.ip !== global.config.bind_ip) { - console.error("Pool ID in use already for a different IP. Update MySQL or change pool ID."); - process.exit(1); - } - }); - }).then(function () { + //global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { + // rows.forEach(function (row) { + // if (row.ip !== global.config.bind_ip) { + // console.error("Pool ID in use already for a different IP. Update MySQL or change pool ID."); + // process.exit(1); + // } + // }); + //}).then(function () { global.mysql.query("INSERT INTO pools (id, ip, last_checkin, active, hostname) VALUES (?, ?, now(), ?, ?) ON DUPLICATE KEY UPDATE last_checkin=now(), active=?", [global.config.pool_id, global.config.bind_ip, true, global.config.hostname, true]); global.mysql.query("DELETE FROM ports WHERE pool_id = ?", [global.config.pool_id]).then(function () { @@ -141,7 +141,7 @@ function registerPool() { } }); }); - }); + //}); } // Master/Slave communication Handling From 06bd923ae43ebfcda07b57d6aaa10054c5f26ef7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Mar 2021 06:19:48 +0000 Subject: [PATCH 1319/1496] Disable useless pool ip check --- lib/pool.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d4e7fd6e6..70e506a0e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -120,28 +120,19 @@ global.database.thread_id = threadName; const COINS = global.coinFuncs.getCOINS(); function registerPool() { - //global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { - // rows.forEach(function (row) { - // if (row.ip !== global.config.bind_ip) { - // console.error("Pool ID in use already for a different IP. Update MySQL or change pool ID."); - // process.exit(1); - // } - // }); - //}).then(function () { - global.mysql.query("INSERT INTO pools (id, ip, last_checkin, active, hostname) VALUES (?, ?, now(), ?, ?) ON DUPLICATE KEY UPDATE last_checkin=now(), active=?", - [global.config.pool_id, global.config.bind_ip, true, global.config.hostname, true]); - global.mysql.query("DELETE FROM ports WHERE pool_id = ?", [global.config.pool_id]).then(function () { - global.config.ports.forEach(function (port) { - if ('ssl' in port && port.ssl === true) { - global.mysql.query("INSERT INTO ports (pool_id, network_port, starting_diff, port_type, description, hidden, ip_address, ssl_port) values (?, ?, ?, ?, ?, ?, ?, 1)", - [global.config.pool_id, port.port, port.difficulty, port.portType, port.desc, port.hidden, global.config.bind_ip]); - } else { - global.mysql.query("INSERT INTO ports (pool_id, network_port, starting_diff, port_type, description, hidden, ip_address, ssl_port) values (?, ?, ?, ?, ?, ?, ?, 0)", - [global.config.pool_id, port.port, port.difficulty, port.portType, port.desc, port.hidden, global.config.bind_ip]); - } - }); + global.mysql.query("INSERT INTO pools (id, ip, last_checkin, active, hostname) VALUES (?, ?, now(), ?, ?) ON DUPLICATE KEY UPDATE last_checkin=now(), active=?", + [global.config.pool_id, global.config.bind_ip, true, global.config.hostname, true]); + global.mysql.query("DELETE FROM ports WHERE pool_id = ?", [global.config.pool_id]).then(function () { + global.config.ports.forEach(function (port) { + if ('ssl' in port && port.ssl === true) { + global.mysql.query("INSERT INTO ports (pool_id, network_port, starting_diff, port_type, description, hidden, ip_address, ssl_port) values (?, ?, ?, ?, ?, ?, ?, 1)", + [global.config.pool_id, port.port, port.difficulty, port.portType, port.desc, port.hidden, global.config.bind_ip]); + } else { + global.mysql.query("INSERT INTO ports (pool_id, network_port, starting_diff, port_type, description, hidden, ip_address, ssl_port) values (?, ?, ?, ?, ?, ?, ?, 0)", + [global.config.pool_id, port.port, port.difficulty, port.portType, port.desc, port.hidden, global.config.bind_ip]); + } }); - //}); + }); } // Master/Slave communication Handling From 5a605a6af4ba1a24ba2698166b3a4e18b712f191 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Mar 2021 01:26:12 +0000 Subject: [PATCH 1320/1496] Fixed localhost check for ipv6 --- lib/pool.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 70e506a0e..3b77ed8e5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -10,13 +10,14 @@ const tls = require('tls'); const fs = require('fs'); const child_process = require('child_process'); -const httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; -const nonceCheck32 = new RegExp("^[0-9a-f]{8}$"); -const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); -const hashCheck32 = new RegExp("^[0-9a-f]{64}$"); -const hexMatch = new RegExp("^(?:[0-9a-f][0-9a-f])+$"); -const baseDiff = global.coinFuncs.baseDiff(); -const baseRavenDiff = global.coinFuncs.baseRavenDiff(); +const httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; +const nonceCheck32 = new RegExp("^[0-9a-f]{8}$"); +const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); +const hashCheck32 = new RegExp("^[0-9a-f]{64}$"); +const hexMatch = new RegExp("^(?:[0-9a-f][0-9a-f])+$"); +const localhostCheck = new RegExp("127\.0\.0\.1$"); +const baseDiff = global.coinFuncs.baseDiff(); +const baseRavenDiff = global.coinFuncs.baseRavenDiff(); const BLOCK_NOTIFY_PORT = 2223; const DAEMON_POLL_MS = 500; @@ -143,7 +144,7 @@ function messageHandler(message) { if (cluster.isMaster) { sendToWorkers(message); } else { - if (message.data != "127.0.0.1") bannedTmpIPs[message.data] = 1; + if (!localhostCheck.test(message.data)) bannedTmpIPs[message.data] = 1; else if (message.wallet) bannedTmpWallets[message.wallet] = 1; } break; From 12fb61e849ad5ce41aa8717ab4449672478ce830 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Mar 2021 01:28:21 +0000 Subject: [PATCH 1321/1496] Fixed localhost check for ipv6 --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3b77ed8e5..cf2276927 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -15,7 +15,7 @@ const nonceCheck32 = new RegExp("^[0-9a-f]{8}$"); const nonceCheck64 = new RegExp("^[0-9a-f]{16}$"); const hashCheck32 = new RegExp("^[0-9a-f]{64}$"); const hexMatch = new RegExp("^(?:[0-9a-f][0-9a-f])+$"); -const localhostCheck = new RegExp("127\.0\.0\.1$"); +const localhostCheck = new RegExp(/127\.0\.0\.1$/); const baseDiff = global.coinFuncs.baseDiff(); const baseRavenDiff = global.coinFuncs.baseRavenDiff(); From 59b7c0d9594c7ce73a35cec3db76b5b4df87cabd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Mar 2021 01:56:31 +0000 Subject: [PATCH 1322/1496] Fixed install script --- deployment/deploy.bash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 1ff35f8fc..a3d813406 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -10,19 +10,20 @@ ROOT_SQL_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) CURUSER=$(whoami) sudo timedatectl set-timezone Etc/UTC sudo apt-get update -sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade +DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND apt-get -y upgrade sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libcap2-bin git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev +DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND apt-get -y install libcap2-bin git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp cd /usr/local/src -sudo git clone --recursive https://github.com/monero-project/monero.git +sudo git clone https://github.com/monero-project/monero.git cd monero sudo git checkout v0.17.1.9 -sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 +sudo git submodule update --init +USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make -j$(nproc) release || USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon sudo systemctl daemon-reload From a24bcd90d484a18f5dbb92d541ccb3611bd8e912 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Mar 2021 01:58:21 +0000 Subject: [PATCH 1323/1496] Fixed install script --- deployment/deploy_test.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 952fa8097..f90cfa263 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -14,7 +14,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev mysql-server lmdb-utils libzmq3-dev +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev mysql-server lmdb-utils libzmq3-dev libssl-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp From 3d48ca9475b080633576b2b9bb78683ff5083e22 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Mar 2021 02:00:48 +0000 Subject: [PATCH 1324/1496] Fixed install script --- deployment/deploy_test.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index f90cfa263..fdb551d8f 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -14,7 +14,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev mysql-server lmdb-utils libzmq3-dev libssl-dev +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev mysql-server lmdb-utils libzmq3-dev libssl-dev pkg-config cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp From d81b327e545fb7e0867dfd01c82c996e4653cb52 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Mar 2021 02:03:05 +0000 Subject: [PATCH 1325/1496] Fixed install script --- deployment/deploy_test.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index fdb551d8f..5d21be7ad 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -14,7 +14,7 @@ sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev mysql-server lmdb-utils libzmq3-dev libssl-dev pkg-config +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev libgtest-dev mysql-server lmdb-utils libzmq3-dev libssl-dev pkg-config cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp From 726decb9513f66d41db4dc9c1659de7b76f3afa3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Mar 2021 16:45:23 +0000 Subject: [PATCH 1326/1496] Updated default params --- deployment/base.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 9169a4836..1ce18cdaa 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -264,8 +264,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'bestExchange', 'xmrto', 'string', 'Current best exchange'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'mixIn', '10', 'int', 'Mixin count for coins that support such things.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'ethWalletPass', '', 'string', 'Ethereum wallet password'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferLength', '480', 'int', 'Number of items to be cached in the stats buffers.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferHours', '24', 'int', 'Number of hours to be cached in the stats buffers.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferLength', '1000', 'int', 'Number of items to be cached in the stats buffers.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'statsBufferHours', '72', 'int', 'Number of hours to be cached in the stats buffers.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pps', 'enable', 'false', 'bool', 'Enable PPS or not'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'shareMulti', '2', 'int', 'Multiply this times difficulty to set the N in PPLNS'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'shareMultiLog', '3', 'int', 'How many times the difficulty of the current block do we keep in shares before clearing them out'); @@ -307,12 +307,12 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'blockCleanWarning', '360', 'int', 'Blocks before longRunner cleaner module will start to warn.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pplns', 'enable', 'true', 'bool', 'Enable PPLNS on the pool.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('solo', 'enable', 'true', 'bool', 'Enable SOLO mining on the pool'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewAmount', '.001', 'float', 'Amount to charge for the txn fee'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewAmount', '.0001', 'float', 'Amount to charge for the txn fee'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeSlewEnd', '4', 'float', 'Value at which txn fee amount drops to 0'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'rpcPasswordEnabled', 'false', 'bool', 'Does the wallet use a RPC password?'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'rpcPasswordPath', '', 'string', 'Path and file for the RPC password file location'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'maxPaymentTxns', '15', 'int', 'Maximum number of transactions in a single payment'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'shareHost', '', 'string', 'Host that receives share information'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'shareHost', 'http://localhost/leafApi', 'string', 'Host that receives share information'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingBody', 'Your worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n', 'string', 'Email sent to the miner when their worker stops hashing'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingSubject', 'Status of your worker(s)', 'string', 'Subject of email sent to miner when worker stops hashing'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerStartHashingBody', 'Your worker: %(worker)s has started submitting hashes at: %(timestamp)s UTC\n', 'string', 'Email sent to the miner when their worker starts hashing'); @@ -321,7 +321,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'emailSig', 'NodeJS-Pool Administration Team', 'string', 'Signature line for the emails.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'timer', '120', 'int', 'Number of minutes between main payment daemon cycles'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'timerRetry', '25', 'int', 'Number of minutes between payment daemon retrying due to not enough funds'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'priority', '0', 'int', 'Payout priority setting. 0 = use default (4x fee); 1 = low prio (1x fee)'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'priority', '1', 'int', 'Payout priority setting. 0 = use default (4x fee); 1 = low prio (1x fee)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'allowStuckPoolKill', 'false', 'bool', 'Allow to kill the pool in case of stuck block template'); INSERT INTO pool.users (username, pass, email, admin, payout_threshold) VALUES ('Administrator', null, 'Password123', 1, 0); INSERT INTO pool.port_config (poolPort, difficulty, portDesc, portType, hidden, `ssl`) VALUES (3333, 1000, 'Low-End Hardware (Up to 30-40 h/s)', 'pplns', 0, 0); From 55753d25deb0766b0177811d3a067a088b12b491 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Mar 2021 22:25:46 +0000 Subject: [PATCH 1327/1496] Fixed first block payment bug --- lib/blockManager.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index bbbeb2c61..e71951709 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -124,10 +124,6 @@ balanceQueue.drain(function () { debug("balanceQueue.drain: block_unlock_callback is not defined"); return; } - if (prev_balance_sum === null) { - debug("balanceQueue.drain: prev_balance_sum is not defined"); - return; - } console.log("balanceQueue drained: performing block unlocking"); global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { if (typeof(rows[0]) === 'undefined' || typeof(rows[0].amt) === 'undefined') { From 86cbd7486465484035e606bbb317bc1673992d11 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Mar 2021 22:26:14 +0000 Subject: [PATCH 1328/1496] Updated setup script --- deployment/base.sql | 6 ++++-- deployment/caddyfile | 1 - deployment/deploy.bash | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 1ce18cdaa..f8b8b702c 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -1,6 +1,8 @@ CREATE DATABASE pool; -GRANT ALL ON pool.* TO pool@`127.0.0.1` IDENTIFIED BY '98erhfiuehw987fh23d'; -GRANT ALL ON pool.* TO pool@localhost IDENTIFIED BY '98erhfiuehw987fh23d'; +CREATE USER pool@`127.0.0.1` IDENTIFIED WITH mysql_native_password BY '98erhfiuehw987fh23d'; +CREATE USER pool@localhost IDENTIFIED WITH mysql_native_password BY '98erhfiuehw987fh23d'; +GRANT ALL ON pool.* TO pool@`127.0.0.1`; +GRANT ALL ON pool.* TO pool@localhost; FLUSH PRIVILEGES; USE pool; ALTER DATABASE pool DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; diff --git a/deployment/caddyfile b/deployment/caddyfile index 9352fcfe5..5f075a99e 100644 --- a/deployment/caddyfile +++ b/deployment/caddyfile @@ -14,5 +14,4 @@ Access-Control-Allow-Headers "Content-Type, x-access-token" } gzip - mime .manifest text/cache-manifest } diff --git a/deployment/deploy.bash b/deployment/deploy.bash index a3d813406..429cdd687 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -14,7 +14,7 @@ DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND apt-get -y up sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOT_SQL_PASS" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOT_SQL_PASS" echo -e "[client]\nuser=root\npassword=$ROOT_SQL_PASS" | sudo tee /root/.my.cnf -DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND apt-get -y install libcap2-bin git python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev +DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND apt-get -y install libcap2-bin git python python-virtualenv python3-virtualenv curl ntp build-essential screen cmake pkg-config libboost-all-dev libevent-dev libunbound-dev libminiupnpc-dev libunwind8-dev liblzma-dev libldns-dev libexpat1-dev mysql-server lmdb-utils libzmq3-dev libsodium-dev cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp @@ -31,8 +31,8 @@ sudo systemctl enable monero sudo systemctl start monero curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash source ~/.nvm/nvm.sh -nvm install v8.11.3 -nvm alias default v8.11.3 +nvm install v14.16.0 +nvm alias default v14.16.0 cd ~/nodejs-pool npm install npm install -g pm2 @@ -40,16 +40,18 @@ openssl req -subj "/C=IT/ST=Pool/L=Daemon/O=Mining Pool/CN=mining.pool" -newkey mkdir ~/pool_db/ sed -r "s/(\"db_storage_path\": ).*/\1\"\/home\/$CURUSER\/pool_db\/\",/" config_example.json > config.json cd ~ -git clone https://github.com/mesh0000/poolui.git -cd poolui -npm install -./node_modules/bower/bin/bower update -./node_modules/gulp/bin/gulp.js build +git clone https://github.com/MoneroOcean/moneroocean-gui.git +cd moneroocean-gui +DEBIAN_FRONTEND=noninteractive sudo --preserve-env=DEBIAN_FRONTEND sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils +apt install -y libx11-xcb1 libxcomposite-dev libxcursor-dev libxcursor-dev libxi-dev libxtst-dev libcups2-dev libxss-dev libxrandr-dev libatk1.0-0 libatk-bridge2.0-0 +npm install -g uglifycss uglify-js html-minifier +npm install -D critical@latest +./build.sh cd build sudo ln -s `pwd` /var/www CADDY_DOWNLOAD_DIR=$(mktemp -d) cd $CADDY_DOWNLOAD_DIR -curl -sL "https://github.com/caddyserver/caddy/releases/download/v0.10.8/caddy_v0.10.8_linux_amd64.tar.gz" | tar -xz caddy init/linux-systemd/caddy.service +curl -sL "https://github.com/caddyserver/caddy/releases/download/v0.11.5/caddy_v0.11.5_linux_amd64.tar.gz" | tar -xz caddy init/linux-systemd/caddy.service sudo mv caddy /usr/local/bin sudo chown root:root /usr/local/bin/caddy sudo chmod 755 /usr/local/bin/caddy From 6bcc094cf1a3fbd9ba1a1f8d3b4eb4d400f3137a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Mar 2021 16:05:10 +0000 Subject: [PATCH 1329/1496] Fixed XNP diff --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index cf2276927..7dbd0ab37 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1118,6 +1118,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro height: bt.height, seed_hash: bt.seed_hash, difficulty: coin_diff, + norm_diff: coin_diff * this.curr_coin_hash_factor, clientPoolLocation: bt.clientPoolLocation, clientNonceLocation: bt.clientNonceLocation, coinHashFactor: params.coinHashFactor, From 5a0a4363205ec4240494045b580d91188bd551cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Mar 2021 16:38:36 +0000 Subject: [PATCH 1330/1496] Added throttle share config --- README.md | 4 ++-- deployment/base.sql | 2 ++ lib/pool.js | 12 +++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index eb5e2b2fc..f64df6607 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ Setup Instructions Server Requirements ------------------- -* Ubuntu 16.04, 18.04 (confirmed working) -* 4 Gb Ram +* Ubuntu 20.04, 18.04 (confirmed working) +* 8 Gb Ram * 2 CPU Cores (with AES_NI) * 150 Gb SSD-Backed Storage - If you're doing a multi-server install, the leaf nodes do not need this much storage. They just need enough storage to hold the blockchain for your node. The pool comes configured to use up to 60Gb of storage for LMDB. Assuming you have the longRunner worker running, it should never get near this size, but be aware that it /can/ bloat readily if things error, so be ready for this! * Notably, this happens to be approximately the size of a 4Gb linode instance, which is where the majority of automated deployment testing happened! diff --git a/deployment/base.sql b/deployment/base.sql index f8b8b702c..7592b04a1 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -203,6 +203,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'banPercent', '25', 'int', 'Percentage of shares that need to be invalid to be banned.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'banThreshold', '30', 'int', 'Number of shares before bans can begin'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustedMiners', 'true', 'bool', 'Enable the miner trust system'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleSharePerSec', '5', 'bool', 'Number of shares per second (per thread) after pool will throttle shares'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleShareWindow', '5', 'bool', 'Length of share throttle window in seconds'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustChange', '1', 'int', 'Change in the miner trust in percent'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustMin', '20', 'int', 'Minimum level of miner trust'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustPenalty', '30', 'int', 'Number of shares that must be successful to be trusted, reset to this value if trust share is broken'); diff --git a/lib/pool.js b/lib/pool.js index 7dbd0ab37..60d736f99 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -83,8 +83,6 @@ let totalShares = 0, trustedShares = 0, normalShares = 0, invalidShares = 0, out // wallet -> { connectTime, count (miner), hashes, last_ver_shares } // this is need to thottle down some high share count miners let minerWallets = {}; -const MAX_VER_SHARES_PER_SEC = 5; // per thread -const VER_SHARES_PERIOD = 5; Buffer.prototype.toByteArray = function () { return Array.prototype.slice.call(this, 0); @@ -108,12 +106,12 @@ if (cluster.isMaster) { }, 30*1000); } else { threadName = "(Worker " + process.env['WORKER_ID'] + " - " + process.pid + ") "; - // reset last verified share counters every VER_SHARES_PERIOD seconds + // reset last verified share counters every global.config.pool.minerThrottleShareWindow seconds setInterval(function () { for (let wallet in minerWallets) { minerWallets[wallet].last_ver_shares = 0; } - }, VER_SHARES_PERIOD*1000); + }, global.config.pool.minerThrottleShareWindow*1000); } global.database.thread_id = threadName; @@ -959,7 +957,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro min_diff = 10 * global.config.pool.minDifficulty; history_time = 5; if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); - } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= global.config.pool.minerThrottleSharePerSec * global.config.pool.minerThrottleShareWindow) { miner = minerWallets[this.payout]; target = 15; min_diff = 10 * global.config.pool.minDifficulty; @@ -1556,8 +1554,8 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { walletLastSeeTime[miner.payout] = Date.now(); let shareThrottled = function() { - if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - if (minerWallets[miner.payout].last_ver_shares === MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= global.config.pool.minerThrottleSharePerSec * global.config.pool.minerThrottleShareWindow) { + if (minerWallets[miner.payout].last_ver_shares === global.config.pool.minerThrottleSharePerSec * global.config.pool.minerThrottleShareWindow) { console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); } process.send({type: 'throttledShare'}); From b92aeecc38ef3525901993f64d787df11a5d0e3d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Mar 2021 19:58:00 +0000 Subject: [PATCH 1331/1496] Fixed type --- deployment/base.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 7592b04a1..b7a1906c4 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -203,8 +203,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'banPercent', '25', 'int', 'Percentage of shares that need to be invalid to be banned.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'banThreshold', '30', 'int', 'Number of shares before bans can begin'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustedMiners', 'true', 'bool', 'Enable the miner trust system'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleSharePerSec', '5', 'bool', 'Number of shares per second (per thread) after pool will throttle shares'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleShareWindow', '5', 'bool', 'Length of share throttle window in seconds'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleSharePerSec', '5', 'int', 'Number of shares per second (per thread) after pool will throttle shares'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleShareWindow', '5', 'int', 'Length of share throttle window in seconds'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustChange', '1', 'int', 'Change in the miner trust in percent'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustMin', '20', 'int', 'Minimum level of miner trust'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustPenalty', '30', 'int', 'Number of shares that must be successful to be trusted, reset to this value if trust share is broken'); From 4fdfe8a1a2049cc1903ae10675bcfe25e714fdf0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Mar 2021 21:44:04 +0000 Subject: [PATCH 1332/1496] Added wallet acc time param --- deployment/base.sql | 1 + lib/pool.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index b7a1906c4..561a87076 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -205,6 +205,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustedMiners', 'true', 'bool', 'Enable the miner trust system'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleSharePerSec', '5', 'int', 'Number of shares per second (per thread) after pool will throttle shares'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleShareWindow', '5', 'int', 'Length of share throttle window in seconds'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'shareAccTime', '60', 'int', 'Length of time shares are accumulated in seconds'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustChange', '1', 'int', 'Change in the miner trust in percent'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustMin', '20', 'int', 'Minimum level of miner trust'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustPenalty', '30', 'int', 'Number of shares that must be successful to be trusted, reset to this value if trust share is broken'); diff --git a/lib/pool.js b/lib/pool.js index 60d736f99..b7ad87730 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1247,7 +1247,7 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { let time_now = Date.now(); for (let worker_name in wallet) { let worker = wallet[worker_name]; - if (time_now - worker.time > 60*1000) { + if (time_now - worker.time > global.config.pool.shareAccTime*1000) { let acc = worker.acc; if (acc != 0) { let height = worker.height; @@ -1263,7 +1263,7 @@ function walletAccFinalizer(wallet_key, miner, bt_port) { } if (is_something_left) { - setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner, bt_port); + setTimeout(walletAccFinalizer, global.config.pool.shareAccTime*1000, wallet_key, miner, bt_port); } else { is_walletAccFinalizer[wallet_key] = false; } @@ -1309,7 +1309,7 @@ function recordShareData(miner, job, isTrustedShare, blockTemplate) { let acc2 = worker.acc2; let share_num = worker.share_num; - if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > 60*1000 || acc >= 100000000) { + if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > global.config.pool.shareAccTime*1000 || acc >= 100000000) { if (acc != 0) { debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); storeShareDiv(miner, acc, acc2, share_num, worker_name, blockTemplate.port, height, difficulty, false, isTrustedShare); @@ -1332,7 +1332,7 @@ function recordShareData(miner, job, isTrustedShare, blockTemplate) { if (is_walletAccFinalizer[wallet_key] === false) { is_walletAccFinalizer[wallet_key] = true; - setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner, blockTemplate.port); + setTimeout(walletAccFinalizer, global.config.pool.shareAccTime*1000, wallet_key, miner, blockTemplate.port); } if (isTrustedShare) { From 33db9ac7f382ead0868ea5ba79eb6f8bac622a26 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Mar 2021 16:10:49 +0000 Subject: [PATCH 1333/1496] Adjusted diffs --- deployment/base.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 561a87076..bc2358ec8 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -243,8 +243,8 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('rpc', 'https', 'false', 'bool', 'Enable RPC over SSL'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'maxDifficulty', '500000', 'int', 'Maximum difficulty for VarDiff'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minDifficulty', '100', 'int', 'Minimum difficulty for VarDiff'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'maxDifficulty', '10000000000000', 'int', 'Maximum difficulty for VarDiff'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minDifficulty', '10000', 'int', 'Minimum difficulty for VarDiff'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'varDiffVariance', '20', 'int', 'Percentage out of the target time that difficulty changes'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'varDiffMaxChange', '125', 'int', 'Percentage amount that the difficulty may change'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'btcFee', '1.5', 'float', 'Fee charged for auto withdrawl via BTC'); From a8d14d0eee59805b1f2d3faeda9efdf55a0b1a9a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Mar 2021 17:36:09 +0000 Subject: [PATCH 1334/1496] Added new share dump script for all shares --- manage_scripts/dump_shares_all.js | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 manage_scripts/dump_shares_all.js diff --git a/manage_scripts/dump_shares_all.js b/manage_scripts/dump_shares_all.js new file mode 100644 index 000000000..7846e21bd --- /dev/null +++ b/manage_scripts/dump_shares_all.js @@ -0,0 +1,35 @@ +"use strict"; + +let range = require('range'); +const argv = require('minimist')(process.argv.slice(2)); + +let depth = 10; +if (argv.depth) depth = argv.depth; + +console.log("Dumping shares"); + +require("../init_mini.js").init(function() { + + global.coinFuncs.getLastBlockHeader(function (err, body) { + if (err !== null) { + console.error("Invalid block header"); + process.exit(1); + } + let lastBlock = body.height + 1; + let txn = global.database.env.beginTxn({readOnly: true}); + + let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); + range.range(lastBlock, lastBlock - depth, -1).forEach(function (blockID) { + for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let shareData = global.protos.Share.decode(data); + var d = new Date(shareData.timestamp); + console.log(d.toString() + ": " + JSON.stringify(shareData)) + }); + } + }); + cursor.close(); + txn.commit(); + process.exit(0); + }); +}); From 6668efa3c19bf3a0fd585ba1581439bc8078de8a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Mar 2021 01:31:47 +0000 Subject: [PATCH 1335/1496] Fixed XHV reward calc --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5e928f015..480e42be2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -438,7 +438,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (/*port == 22023 ||*/ port == 33124 || port == 25182 || port == 13102 || port == 18181) { // Loki / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction + if (port == 17750 || port == 33124 || port == 25182 || port == 13102 || port == 18181) { // XHV / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction reward_check = minerTx.vout[0].amount; } else { for (var i=0; i Date: Wed, 31 Mar 2021 16:31:55 +0000 Subject: [PATCH 1336/1496] Allow multiblock share accumulation --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b7ad87730..560825e6f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1309,7 +1309,7 @@ function recordShareData(miner, job, isTrustedShare, blockTemplate) { let acc2 = worker.acc2; let share_num = worker.share_num; - if (height !== db_job_height || difficulty !== blockTemplate.difficulty || time_now - worker.time > global.config.pool.shareAccTime*1000 || acc >= 100000000) { + if (time_now - worker.time > global.config.pool.shareAccTime*1000 || acc >= 100000000) { if (acc != 0) { debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); storeShareDiv(miner, acc, acc2, share_num, worker_name, blockTemplate.port, height, difficulty, false, isTrustedShare); From ce16a4bb8e0bbd65f8c89d950dd3f30da674db16 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Apr 2021 17:30:59 +0000 Subject: [PATCH 1337/1496] Do not lower high miner diff if wallet diff if lower --- lib/pool.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 560825e6f..20068dbdc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -951,27 +951,29 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro let target; let min_diff; let history_time; - if (proxyMinerName in proxyMiners) { - miner = proxyMiners[proxyMinerName]; + const time_now = Date.now(); + let proxyMiner = proxyMiners[proxyMinerName]; + if (proxyMiner && proxyMiner.hashes / (time_now - proxyMiner.connectTime) > this.difficulty) { + miner = proxyMiner; target = 15; min_diff = 10 * global.config.pool.minDifficulty; history_time = 5; - if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc proxy miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc proxy miner diff: " + miner.hashes + " / " + ((time_now - miner.connectTime) / 1000)); } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= global.config.pool.minerThrottleSharePerSec * global.config.pool.minerThrottleShareWindow) { miner = minerWallets[this.payout]; target = 15; min_diff = 10 * global.config.pool.minDifficulty; history_time = 5; - if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc throttled miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc throttled miner diff: " + miner.hashes + " / " + ((time_now - miner.connectTime) / 1000)); } else { miner = this; target = this.proxy ? 15 : global.config.pool.targetTime; min_diff = this.proxy ? 10 * global.config.pool.minDifficulty : global.config.pool.minDifficulty; history_time = 60; - if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc miner diff: " + miner.hashes + " / " + ((Date.now() - miner.connectTime) / 1000)); + if (this.debugMiner) console.log(threadName + this.logString + " [WALLET DEBUG] calc miner diff: " + miner.hashes + " / " + ((time_now - miner.connectTime) / 1000)); } if (miner.connectTimeShift) { - const timeSinceLastShift = Date.now() - miner.connectTimeShift; + const timeSinceLastShift = time_now - miner.connectTimeShift; const timeWindow = history_time * 60 * 1000; if (timeSinceLastShift > timeWindow) { if (timeSinceLastShift > 2 * timeWindow) { // forget all @@ -982,16 +984,16 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro miner.hashes -= miner.hashesShift; } miner.connectTime = miner.connectTimeShift; - miner.connectTimeShift = Date.now(); + miner.connectTimeShift = time_now; miner.hashesShift = miner.hashes; } } else { - miner.connectTimeShift = Date.now(); + miner.connectTimeShift = time_now; miner.hashesShift = miner.hashes; } let hashes = miner.hashes; - let period = (Date.now() - miner.connectTime) / 1000; + let period = (time_now - miner.connectTime) / 1000; if (hashes === 0) { hashes = this.difficulty; From b7fb900998cc7878231e33ccafe32b895642031a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Apr 2021 02:49:38 +0000 Subject: [PATCH 1338/1496] Added log about shre storing --- lib/remoteShare.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 69747fd44..ab9cafb63 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -82,6 +82,7 @@ app.post('/leafApi', function (req, res) { function storeShares(){ if (Object.keys(shareData).length > 0){ + console.log('Storing ' + Object.keys(shareData).length + ' shares'); global.database.storeBulkShares(shareData); shareData = []; } From 88bf1a3ded6d2290c70d198628f3fc6e14d7c87e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 5 Apr 2021 17:07:13 +0000 Subject: [PATCH 1339/1496] Fix big threshold settting --- lib/api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 12cd18beb..75913646f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -622,8 +622,9 @@ app.get('/user/:address/unsubscribeEmail', function (req, res) { }); app.post('/user/updateThreshold', function (req, res) { - const threshold = req.body.threshold; + let threshold = req.body.threshold; if (!threshold) return res.status(401).send({'success': false, 'msg': "Can't set threshold to a wrong value"}); + if (threshold > 1000) threshold = 1000; const username = req.body.username; if (!username || global.database.getCache(username) === false) return res.status(401).send({'success': false, 'msg': "Can't set threshold for unknown user"}); const threshold2 = global.support.decimalToCoin(threshold < global.config.payout.walletMin ? global.config.payout.walletMin : threshold); From 313dec8753b60a9ad96f64945abb7d99b7f43897 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 12 Apr 2021 14:18:34 +0000 Subject: [PATCH 1340/1496] Update monerod to v0.17.2.0 --- README.md | 2 +- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- lib/pool.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f64df6607..ede17ba8f 100644 --- a/README.md +++ b/README.md @@ -262,7 +262,7 @@ If you'd like to make a one time donation, the addresses are as follows: * SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` * GRFT - ```GACadqdXj5eNLnyNxvQ56wcmsmVCFLkHQKgtaQXNEE5zjMDJkWcMVju2aYtxbTnZgBboWYmHovuiH1Ahm4g2N5a7LuMQrpT``` * MSR - ```5hnMXUKArLDRue5tWsNpbmGLsLQibt23MEsV3VGwY6MGStYwfTqHkff4BgvziprTitbcDYYpFXw2rEgXeipsABTtEmcmnCK``` -* ITNS - ```iz53aMEaKJ25zB8xku3FQK5VVvmu2v6DENnbGHRmn659jfrGWBH1beqAzEVYaKhTyMZcxLJAdaCW3Kof1DwTiTbp1DSqLae3e``` +* LTHN - ```iz53aMEaKJ25zB8xku3FQK5VVvmu2v6DENnbGHRmn659jfrGWBH1beqAzEVYaKhTyMZcxLJAdaCW3Kof1DwTiTbp1DSqLae3e``` * WOW - ```Wo3yjV8UkwvbJDCB1Jy7vvXv3aaQu3K8YMG6tbY3Jo2KApfyf5RByZiBXy95bzmoR3AvPgNq6rHzm98LoHTkzjiA2dY7sqQMJ``` * XMV - ```XvyVfpAYp3zSuvdtoHgnDzMUf7GAeiumeUgVC7RTq6SfgtzGEzy4dUgfEEfD5adk1kN4dfVZdT3zZdgSD2xmVBs627Vwt2C3Ey``` * RYO - ```RYoLsi22qnoKYhnv1DwHBXcGe9QK6P9zmekwQnHdUAak7adFBK4i32wFTszivQ9wEPeugbXr2UD7tMd6ogf1dbHh76G5UszE7k1``` diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 429cdd687..904f35869 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.9 +sudo git checkout v0.17.2.0 sudo git submodule update --init USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make -j$(nproc) release || USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 5d21be7ad..c1d93847c 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.9 +sudo git checkout v0.17.2.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index a4562d8a7..0a0503c13 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.1.9 +sudo git checkout v0.17.2.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index e77085de9..e4a3f83bb 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.1.9 &&\ +sudo git checkout v0.17.2.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ diff --git a/lib/pool.js b/lib/pool.js index 20068dbdc..85cd14657 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -946,12 +946,12 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro } this.calcNewDiff = function () { - const proxyMinerName = this.payout; // + ":" + this.identifier; let miner; let target; let min_diff; let history_time; const time_now = Date.now(); + const proxyMinerName = this.payout; // + ":" + this.identifier; let proxyMiner = proxyMiners[proxyMinerName]; if (proxyMiner && proxyMiner.hashes / (time_now - proxyMiner.connectTime) > this.difficulty) { miner = proxyMiner; From 9eb9eeee34e919692194e9ea9b7ce0d476feb894 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 12:56:28 +0000 Subject: [PATCH 1341/1496] Moved to eth_getWork based artificial last block header --- lib/coins/xmr.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 480e42be2..1f0d55549 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -509,7 +509,11 @@ function Coin(data){ }); }); } else if (port == 8545) { - return this.getPortBlockHeaderByID(port, "latest", callback); + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { + if (!body) return null; + const bt = cnUtil.EthBlockTemplate(body.result); + return { hash: bt.hash, timestamp: Date.now(), difficulty: bt.difficulty, height: bt.height }; + }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ From 52e81c9bb83537d7966dfd6ef62a54c783385231 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 13:12:56 +0000 Subject: [PATCH 1342/1496] Moved to eth_getWork based artificial last block header --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1f0d55549..05736496e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -512,7 +512,7 @@ function Coin(data){ global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { if (!body) return null; const bt = cnUtil.EthBlockTemplate(body.result); - return { hash: bt.hash, timestamp: Date.now(), difficulty: bt.difficulty, height: bt.height }; + return callback(null, { hash: bt.hash, timestamp: Date.now(), difficulty: bt.difficulty, height: bt.height }); }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { From 546d393320ead23f235597bc96bf12fa9401f53e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 13:28:36 +0000 Subject: [PATCH 1343/1496] Moved to eth_getWork based artificial last block header --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 05736496e..2f6548519 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -510,7 +510,7 @@ function Coin(data){ }); } else if (port == 8545) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { - if (!body) return null; + if (!body) return callback(true, body); const bt = cnUtil.EthBlockTemplate(body.result); return callback(null, { hash: bt.hash, timestamp: Date.now(), difficulty: bt.difficulty, height: bt.height }); }); From bd89bf3ded218ce7eeb4c72d7ac93616a069ecfb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 14:01:00 +0000 Subject: [PATCH 1344/1496] Moved to eth_getWork based artificial last block header --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2f6548519..aec9187ef 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -510,7 +510,7 @@ function Coin(data){ }); } else if (port == 8545) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { - if (!body) return callback(true, body); + if (!body || !body.result) return callback(true, body); const bt = cnUtil.EthBlockTemplate(body.result); return callback(null, { hash: bt.hash, timestamp: Date.now(), difficulty: bt.difficulty, height: bt.height }); }); From ea7fbf5ee1a40eb046473aa6e9cc6f70fd938012 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 14:53:44 +0000 Subject: [PATCH 1345/1496] Moved to eth_getWork based artificial last block header --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index aec9187ef..39fcf0272 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -510,7 +510,7 @@ function Coin(data){ }); } else if (port == 8545) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { - if (!body || !body.result) return callback(true, body); + if (!body || !body.result || !(body.result instanceof Array)) return callback(true, body); const bt = cnUtil.EthBlockTemplate(body.result); return callback(null, { hash: bt.hash, timestamp: Date.now(), difficulty: bt.difficulty, height: bt.height }); }); From b60c0bfd6cfd9d5d3107107705f87209962b559d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 15:27:03 +0000 Subject: [PATCH 1346/1496] Moved to eth_getWork based artificial last block header --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 39fcf0272..51240a537 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -512,7 +512,7 @@ function Coin(data){ global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { if (!body || !body.result || !(body.result instanceof Array)) return callback(true, body); const bt = cnUtil.EthBlockTemplate(body.result); - return callback(null, { hash: bt.hash, timestamp: Date.now(), difficulty: bt.difficulty, height: bt.height }); + return callback(null, { hash: bt.hash, timestamp: Date.now() / 1000, difficulty: bt.difficulty, height: bt.height }); }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { From 8cec8fbecfcb41125837f53d14c1babd9855808d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 21:15:11 +0000 Subject: [PATCH 1347/1496] More intellegent miner history update to optimize worker time --- lib/worker.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 8db41e8ad..29beb5342 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -12,6 +12,7 @@ let prev_pool_hashrate; let prev_pool_workers; let stats_cache = {}; +let miner_history_update_time = {}; function updateShareStats() { // This is an omni-worker to deal with all things share-stats related @@ -192,6 +193,7 @@ function updateShareStats() { }); for (let port in localPortHashes) localPortHashes[port] = localPortHashes[port] / (hashrate_avg_min*60); cache_updates["port_hash"] = localPortHashes; + let history_update_count = 0; for (let miner in minerSet) { let stats; let keyStats = "stats:" + miner; @@ -229,7 +231,13 @@ function updateShareStats() { } } } - cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; + if ( stats.hashHistory.length < global.config.general.statsBufferLength || + !(miner in miner_history_update_time) || (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 10*60*1000) + ) { + cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; + miner_history_update_time[miner] = currentTime; + ++ history_update_count; + } } stats_cache[miner] = stats; From b977e4b5587531f694e6a29251e8ee0a4f747a9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 21:18:56 +0000 Subject: [PATCH 1348/1496] More intellegent miner history update to optimize worker time --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 29beb5342..de8a64c95 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -307,7 +307,7 @@ function updateShareStats() { let pool_hashrate = localStats.global / (hashrate_avg_min*60); let pool_workers = minerCount; - console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); + console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; From 216cf0439c9b23ee1a8cdc3bfaa263d266a5aa21 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 22:07:05 +0000 Subject: [PATCH 1349/1496] Optimized ETH bt processing --- lib/coins/xmr.js | 2 +- lib/pool.js | 60 ++++++++++++++++++++++++++---------------------- lib/worker.js | 3 ++- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 51240a537..a07f82c93 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -512,7 +512,7 @@ function Coin(data){ global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: "eth_getWork", "params": [] }, function(body) { if (!body || !body.result || !(body.result instanceof Array)) return callback(true, body); const bt = cnUtil.EthBlockTemplate(body.result); - return callback(null, { hash: bt.hash, timestamp: Date.now() / 1000, difficulty: bt.difficulty, height: bt.height }); + return callback(null, { hash: bt.hash, timestamp: Date.now() / 1000, difficulty: bt.difficulty, height: bt.height, seed_hash: bt.seed_hash }); }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { diff --git a/lib/pool.js b/lib/pool.js index 85cd14657..af0b28ff6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -295,39 +295,45 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa return template; } -// templateUpdateReal is only called in master thread (except the beginning of a worker thread) -function templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange) { - global.coinFuncs.getPortBlockTemplate(port, function (body_bt) { +// templateUpdate3 is only called in master thread (except the beginning of a worker thread) +function templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt) { + const template = process_rpc_template(body_bt, coin, port, coinHashFactor, isHashFactorChange); + debug(threadName + "New block template found at " + template.height + " height"); + if (cluster.isMaster) { + sendToWorkers({type: 'newBlockTemplate', data: template}); + setNewBlockTemplate(template); + // update parent coins if current coin was updated now + if (port in global.coinFuncs.getMM_CHILD_PORTS()) { + const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[port]; + for (let parent_port in parent_ports) { + const parent_coin = global.coinFuncs.PORT2COIN(parent_port); + if (parent_coin in activeBlockTemplates) { + const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, lastCoinHashFactor[parent_coin], false); + sendToWorkers({type: 'newBlockTemplate', data: parent_template}); + setNewBlockTemplate(parent_template); + } + } + } + } else { + setNewBlockTemplate(template); + } +} + +// templateUpdate2 is only called in master thread (except the beginning of a worker thread) +function templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body_header) { + if (port == 8545) { + return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_header); + } else global.coinFuncs.getPortBlockTemplate(port, function (body_bt) { if (!newCoinHashFactor[coin]) { console.log("Aborting " + port + " last block template request because " + coin + " already has zero hash factor"); return; } - if (body_bt) { - const template = process_rpc_template(body_bt, coin, port, coinHashFactor, isHashFactorChange); - debug(threadName + "New block template found at " + template.height + " height"); - if (cluster.isMaster) { - sendToWorkers({type: 'newBlockTemplate', data: template}); - setNewBlockTemplate(template); - // update parent coins if current coin was updated now - if (port in global.coinFuncs.getMM_CHILD_PORTS()) { - const parent_ports = global.coinFuncs.getMM_CHILD_PORTS()[port]; - for (let parent_port in parent_ports) { - const parent_coin = global.coinFuncs.PORT2COIN(parent_port); - if (parent_coin in activeBlockTemplates) { - const parent_template = process_rpc_template(activeBlockTemplates[parent_coin], parent_coin, parent_port, lastCoinHashFactor[parent_coin], false); - sendToWorkers({type: 'newBlockTemplate', data: parent_template}); - setNewBlockTemplate(parent_template); - } - } - } - } else { - setNewBlockTemplate(template); - } - } else { + if (!body_bt) { console.error("Block template request failed for " + port + " port"); coinHashFactorUpdate(coin, 0); - setTimeout(templateUpdateReal, 3000, coin, port, coinHashFactor, isHashFactorChange); + return setTimeout(templateUpdate2, 3000, coin, port, coinHashFactor, isHashFactorChange); } + return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); }); } @@ -354,7 +360,7 @@ function templateUpdate(coin, repeating) { const isHashFactorChange = Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { lastBlockHash[coin] = body.hash; - templateUpdateReal(coin, port, coinHashFactor, isHashFactorChange); + templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body); } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } diff --git a/lib/worker.js b/lib/worker.js index de8a64c95..2e9715140 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -232,7 +232,8 @@ function updateShareStats() { } } if ( stats.hashHistory.length < global.config.general.statsBufferLength || - !(miner in miner_history_update_time) || (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 10*60*1000) + !(miner in miner_history_update_time) || + (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 10*60*1000) ) { cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; miner_history_update_time[miner] = currentTime; From fb74aface00bdb53099c7dd91b2a1d0472b6cba3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Apr 2021 22:38:11 +0000 Subject: [PATCH 1350/1496] Decreased default new BT poll interval if block push server is not activated --- deployment/base.sql | 1 + lib/pool.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index bc2358ec8..c4d4b797b 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -214,6 +214,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'port', '18081', 'int', 'Monero Daemon RPC Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'basicAuth', '', 'string', 'Basic auth header if needed by daemon'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'X-API-KEY', '', 'string', 'Turtle wallet API auth header'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'pollInterval', '100', 'int', 'Time in ms between pool daemon checks for new blocks'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRYO', '0', 'float', 'Ryo algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSUMO', '0', 'float', 'SUMO algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorLOKI', '0', 'float', 'Loki algo hash price factor relative to coinHashFactor'); diff --git a/lib/pool.js b/lib/pool.js index af0b28ff6..41c2d1ec1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -368,10 +368,10 @@ function templateUpdate(coin, repeating) { } else { console.error(threadName + "Last block header request for " + port + " port failed!"); coinHashFactorUpdate(coin, 0); - if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); + if (repeating !== false) setTimeout(templateUpdate, global.config.daemon.pollInterval, coin, repeating); } }); else if (cluster.isMaster) { - if (repeating !== false) setTimeout(templateUpdate, 1000, coin, repeating); + if (repeating !== false) setTimeout(templateUpdate, global.config.daemon.pollInterval, coin, repeating); } } From 89793dceec0423117b698b6ad22c976411b26d0e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Apr 2021 05:42:32 +0000 Subject: [PATCH 1351/1496] Optimized resource usage --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 2e9715140..853a197dd 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -233,7 +233,7 @@ function updateShareStats() { } if ( stats.hashHistory.length < global.config.general.statsBufferLength || !(miner in miner_history_update_time) || - (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 10*60*1000) + (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 30*60*1000) ) { cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; miner_history_update_time[miner] = currentTime; From 362ec5be28d6442950660ae67776149a02d42e82 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Apr 2021 05:52:28 +0000 Subject: [PATCH 1352/1496] Optimized resource usage --- lib/worker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 853a197dd..56061d6ed 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -236,7 +236,7 @@ function updateShareStats() { (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 30*60*1000) ) { cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; - miner_history_update_time[miner] = currentTime; + miner_history_update_timex[miner] = currentTime; ++ history_update_count; } } @@ -422,5 +422,5 @@ function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { global.support.sendEmail(global.config.general.adminEmail, "Restarting worker module", "Restarted worker module!"); updateShareStats(); -// clean stats_cache from time to time -setInterval(function() { stats_cache = {}; } , 4*60*60*1000); +// clean caches from time to time +setInterval(function() { stats_cache = {}; miner_history_update_time = {}; } , 4*60*60*1000); From 85204c4f6770d57b51f8d4c7bbba4baaea5beb35 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Apr 2021 05:53:34 +0000 Subject: [PATCH 1353/1496] Optimized resource usage --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 56061d6ed..bafdb1d71 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -236,7 +236,7 @@ function updateShareStats() { (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 30*60*1000) ) { cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; - miner_history_update_timex[miner] = currentTime; + miner_history_update_time[miner] = currentTime; ++ history_update_count; } } From f917b5a1d586d8eb4a43bbb40833acc68cbe5c8e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Apr 2021 17:25:20 +0000 Subject: [PATCH 1354/1496] Optimized resource usage --- lib/worker.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index bafdb1d71..faab83e79 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -194,6 +194,10 @@ function updateShareStats() { for (let port in localPortHashes) localPortHashes[port] = localPortHashes[port] / (hashrate_avg_min*60); cache_updates["port_hash"] = localPortHashes; let history_update_count = 0; + + // need to clean stats_cache only after we update all current miner histories to avoid stats gaps + const is_clean_stats_cache = cycleCount === 0 && Object.keys(miner_history_update_time).length === 0; + for (let miner in minerSet) { let stats; let keyStats = "stats:" + miner; @@ -243,6 +247,10 @@ function updateShareStats() { stats_cache[miner] = stats; } + if (is_clean_stats_cache) { + console.log("Cleaning stats_cache"); + stats_cache = {}; + } debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); // remove old workers @@ -393,7 +401,7 @@ function send_worker_started_hashing_email(miner, email, currentTime) { } function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { - if (miner in workers_started_hashing_time && Date.now() - workers_started_hashing_time[miner] <= 5*60*1000) { + if (miner in workers_started_hashing_time && Date.now() - workers_started_hashing_time[miner] <= 10*60*1000) { delete workers_started_hashing_time[miner]; return; } @@ -423,4 +431,7 @@ global.support.sendEmail(global.config.general.adminEmail, "Restarting worker mo updateShareStats(); // clean caches from time to time -setInterval(function() { stats_cache = {}; miner_history_update_time = {}; } , 4*60*60*1000); +setInterval(function() { + console.log("Cleaning miner history cache"); + miner_history_update_time = {}; +}, 2*60*60*1000); From 060149a3cf650a73349cf74ff48fc71154742a71 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Apr 2021 18:01:30 +0000 Subject: [PATCH 1355/1496] Optimized resource usage --- lib/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index faab83e79..2fc7f65b5 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -306,6 +306,7 @@ function updateShareStats() { } cache_updates.portMinerCount = portMinerCount; cache_updates.minerSet = minerSet; + const db_write_start_time = Date.now(); try { global.database.bulkSetCache(cache_updates); } catch (e) { @@ -316,7 +317,7 @@ function updateShareStats() { let pool_hashrate = localStats.global / (hashrate_avg_min*60); let pool_workers = minerCount; - console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); + console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + ((Date.now() - currentTime) / 1000) + " (" + ((Date.now() - db_write_start_time) / 1000) + " db write) seconds. Pool hashrate is: " + pool_hashrate); if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; From dab19f7ec7ca0d44ee925b8f2a58be88c4ae7819 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Apr 2021 18:05:02 +0000 Subject: [PATCH 1356/1496] Optimized resource usage --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 2fc7f65b5..f98e5a450 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -317,7 +317,7 @@ function updateShareStats() { let pool_hashrate = localStats.global / (hashrate_avg_min*60); let pool_workers = minerCount; - console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + ((Date.now() - currentTime) / 1000) + " (" + ((Date.now() - db_write_start_time) / 1000) + " db write) seconds. Pool hashrate is: " + pool_hashrate); + console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + ((Date.now() - currentTime) / 1000) + " seconds (" + ((Date.now() - db_write_start_time) / 1000) + " seconds DB write). Pool hashrate is: " + pool_hashrate); if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; From 7b9e4006ffec852f8a3b947660d07c1cc8d99034 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Apr 2021 05:18:10 +0000 Subject: [PATCH 1357/1496] Optimized resource usage --- lib/worker.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index f98e5a450..f6f24f09e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -19,7 +19,7 @@ function updateShareStats() { // Time based averages are worked out on ring buffers. // Buffer lengths? You guessed it, configured in SQL. // Stats timeouts are 30 seconds, so everything for buffers should be there. - let currentTime = Date.now(); + const currentTime = Date.now(); // power to ensure we can keep up to global.config.general.statsBufferHours in global.config.general.statsBufferLength array // here N = log(history_power, global.config.general.statsBufferLength) is number of attemps required on average to remove top left history point (the oldest one) // we just select history_power so that is till happen on global.config.general.statsBufferHours * 60 attemps on average @@ -195,9 +195,6 @@ function updateShareStats() { cache_updates["port_hash"] = localPortHashes; let history_update_count = 0; - // need to clean stats_cache only after we update all current miner histories to avoid stats gaps - const is_clean_stats_cache = cycleCount === 0 && Object.keys(miner_history_update_time).length === 0; - for (let miner in minerSet) { let stats; let keyStats = "stats:" + miner; @@ -247,10 +244,7 @@ function updateShareStats() { stats_cache[miner] = stats; } - if (is_clean_stats_cache) { - console.log("Cleaning stats_cache"); - stats_cache = {}; - } + debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); // remove old workers @@ -317,7 +311,10 @@ function updateShareStats() { let pool_hashrate = localStats.global / (hashrate_avg_min*60); let pool_workers = minerCount; - console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + ((Date.now() - currentTime) / 1000) + " seconds (" + ((Date.now() - db_write_start_time) / 1000) + " seconds DB write). Pool hashrate is: " + pool_hashrate); + console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + + ((Date.now() - currentTime) / 1000) + " seconds (" + ((Date.now() - db_write_start_time) / 1000) + " seconds DB write). " + + "Pool hashrate is: " + pool_hashrate + ); if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; @@ -433,6 +430,12 @@ global.support.sendEmail(global.config.general.adminEmail, "Restarting worker mo updateShareStats(); // clean caches from time to time setInterval(function() { - console.log("Cleaning miner history cache"); + console.log("Cleaning caches"); + const currentTime = Date.now(); + for (let miner in stats_cache) { + if (!(miner in miner_history_update_time) || currentTime - miner_history_update_time[miner] > 60*60*1000) { + delete stats_cache[miner]; + } + } miner_history_update_time = {}; }, 2*60*60*1000); From 75881c7f11410e00afaa45cfb5866211abf1791c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Apr 2021 15:11:59 +0000 Subject: [PATCH 1358/1496] Optimized resource usage --- lib/worker.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index f6f24f09e..78e0a2ab1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -430,12 +430,15 @@ global.support.sendEmail(global.config.general.adminEmail, "Restarting worker mo updateShareStats(); // clean caches from time to time setInterval(function() { - console.log("Cleaning caches"); + console.log("Cleaning caches (" + Object.keys(stats_cache).length + " stats, " + Object.keys(miner_history_update_time).length + " histories)"); const currentTime = Date.now(); + let stats_cache2 = {}; for (let miner in stats_cache) { - if (!(miner in miner_history_update_time) || currentTime - miner_history_update_time[miner] > 60*60*1000) { - delete stats_cache[miner]; + if (miner in miner_history_update_time && currentTime - miner_history_update_time[miner] < 60*60*1000) { + stats_cache2[miner] = stats_cache[miner]; } } + stats_cache = stats_cache2; + console.log("After cleaning: " + Object.keys(stats_cache).length + " stats left"); miner_history_update_time = {}; }, 2*60*60*1000); From 7be4bf09a60d400ab7ac18ff0293db99937cf3fc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Apr 2021 19:04:56 +0000 Subject: [PATCH 1359/1496] Optimized resource usage --- lib/worker.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 78e0a2ab1..faf94908b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -222,14 +222,14 @@ function updateShareStats() { stats.hashHistory.unshift({ts: currentTime, hs: stats.hash, hs2: stats.hash2}); if (stats.hashHistory.length > global.config.general.statsBufferLength) { while (stats.hashHistory.length > global.config.general.statsBufferLength) { - const last_index = stats.hashHistory.length - 1; - if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { + //const last_index = stats.hashHistory.length - 1; + //if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { stats.hashHistory.pop(); - } else { + //} else { // here we remove larger indexes (that are more distant in time) with more probability - const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); - stats.hashHistory.splice(index_to_remove, 1); - } + // const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); + // stats.hashHistory.splice(index_to_remove, 1); + //} } } if ( stats.hashHistory.length < global.config.general.statsBufferLength || From 24e5e8693770a28792f2a327989f3613f86231a7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Apr 2021 03:00:43 +0000 Subject: [PATCH 1360/1496] More strict miner tracking --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 41c2d1ec1..52d3b2291 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -243,6 +243,7 @@ function addProxyMiner(miner) { } function removeMiner(miner) { + if (!miner) return; const proxyMinerName = miner.proxyMinerName; if (proxyMinerName && proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; @@ -2532,7 +2533,7 @@ if (cluster.isMaster) { if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG] reply " + JSON.stringify(reply)); socket.write(JSON.stringify(reply) + "\n"); }; - let sendReplyFinal = function (error) { + let sendReplyFinal = function (error, timeout) { setTimeout(function() { if (!socket.writable) return; let reply = { @@ -2545,7 +2546,7 @@ if (cluster.isMaster) { debug("[MINER] FINAL REPLY TO MINER: " + JSON.stringify(reply)); if (socket.debugMiner) console.log(threadName + " [WALLET DEBUG] final reply " + JSON.stringify(reply)); socket.end(JSON.stringify(reply) + "\n"); - }, 9 * 1000); + }, (timeout ? timeout : 9) * 1000); }; debug("[MINER] GOT FROM MINER: " + JSON.stringify(jsonData)); handleMinerData(socket, jsonData.id, jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, sendReplyFinal, pushMessage); @@ -2615,7 +2616,7 @@ if (cluster.isMaster) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { pushMessage = function () {}; - if (socket.miner_ids) socket.miner_ids.forEach(miner_id => activeMiners.delete(miner_id)); + if (socket.miner_ids) socket.miner_ids.forEach(miner_id => removeMiner(activeMiners.get(miner_id))); if ("eth_extranonce_id" in socket) freeEthExtranonces.push(socket.eth_extranonce_id); }); } From 297610c1429e71181305631a1b22421bdb349f7b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Apr 2021 03:53:52 +0000 Subject: [PATCH 1361/1496] Added large worker miner bans --- deployment/base.sql | 1 + lib/pool.js | 58 ++++++++++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index c4d4b797b..6f8286873 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -205,6 +205,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustedMiners', 'true', 'bool', 'Enable the miner trust system'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleSharePerSec', '5', 'int', 'Number of shares per second (per thread) after pool will throttle shares'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minerThrottleShareWindow', '5', 'int', 'Length of share throttle window in seconds'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'workerMax', '1000', 'int', 'Max number of worker connection before pool starts to issue bans'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'shareAccTime', '60', 'int', 'Length of time shares are accumulated in seconds'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustChange', '1', 'int', 'Change in the miner trust in percent'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'trustMin', '20', 'int', 'Minimum level of miner trust'); diff --git a/lib/pool.js b/lib/pool.js index 52d3b2291..c270648af 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -58,10 +58,11 @@ function eth_extranonce(id) { return id === null ? null : pad_hex(((id << uniqueWorkerIdBits) + uniqueWorkerId).toString(16), 2); }; -let bannedTmpIPs = {}; -let bannedTmpWallets = {}; -let bannedAddresses = {}; -let notifyAddresses = {}; +let bannedTmpIPs = {}; // ip banned for short time +let bannedTmpWallets = {}; // wallets banned for short time +let bannedBigTmpWallets = {}; // wallets banned for a long time +let bannedAddresses = {}; // forever banned wallets +let notifyAddresses = {}; // wallet notifications let activeMiners = new Map(); @@ -228,7 +229,8 @@ let proxyMiners = {}; function addProxyMiner(miner) { if (miner.proxyMinerName && miner.proxyMinerName in proxyMiners) return; - const proxyMinerName = miner.payout; //+ ":" + miner.identifier; + const wallet = miner.payout; + const proxyMinerName = wallet; //+ ":" + miner.identifier; miner.proxyMinerName = proxyMinerName; if (!(proxyMinerName in proxyMiners)) { @@ -238,12 +240,18 @@ function addProxyMiner(miner) { proxyMiners[proxyMinerName].hashes = 0; console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); } else { - ++ proxyMiners[proxyMinerName].count; + if (++ proxyMiners[proxyMinerName].count > global.config.pool.workerMax) { + console.error("Starting to long ban " + wallet + " miner address"); + bannedBigTmpWallets[wallet] = 1; + for (var [minerId2, miner2] of activeMiners) if (miner2.payout === wallet) removeMiner(miner2); + return false; + } } + return true; } function removeMiner(miner) { - if (!miner) return; + if (!miner || miner.removed_miner) return; const proxyMinerName = miner.proxyMinerName; if (proxyMinerName && proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; @@ -648,6 +656,12 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.valid_miner = false; return; } + if (address in bannedBigTmpWallets) { + this.error = "Temporary (one hour max) ban since you connected too many workers. Please use proxy (https://github.com/MoneroOcean/xmrig-proxy)"; + this.valid_miner = false; + this.delay_reply = 600; + return; + } if (address in this.payout_div) { this.error = "You can't repeat payment split address " + address; this.valid_miner = false; @@ -685,6 +699,13 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro return; } + if (this.payout in bannedBigTmpWallets) { + this.error = "Temporary (one hour max) ban since you connected too many workers. Please use proxy (https://github.com/MoneroOcean/xmrig-proxy)"; + this.valid_miner = false; + this.delay_reply = 600; + return; + } + if (global.coinFuncs.exchangeAddresses.indexOf(this.address) !== -1 && !(this.paymentID)) { this.error = "Exchange addresses need 64 hex character long payment IDs. Please specify it after your wallet address as follows after dot: Wallet.PaymentID"; this.valid_miner = false; @@ -1568,10 +1589,11 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); } process.send({type: 'throttledShare'}); - addProxyMiner(miner); - const proxyMinerName = miner.payout; // + ":" + miner.identifier; - proxyMiners[proxyMinerName].hashes += job.norm_diff; - adjustMinerDiff(miner); + if (addProxyMiner(miner)) { + const proxyMinerName = miner.payout; // + ":" + miner.identifier; + proxyMiners[proxyMinerName].hashes += job.norm_diff; + adjustMinerDiff(miner); + } return true; } return false; @@ -1813,8 +1835,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); lastMinerLogTime[miner.payout] = time_now; } - sendReplyFinal(miner.error); - return; + return sendReplyFinal(miner.error, miner.delay_reply); } const miner_agent_notification = !global.coinFuncs.algoMainCheck(miner.algos) && global.coinFuncs.algoPrevMainCheck(miner.algos) ? @@ -1824,8 +1845,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_notification); - sendReplyFinal(miner_notification + " (miner will connect after several attempts)"); - return; + return sendReplyFinal(miner_notification + " (miner will connect after several attempts)"); } } @@ -1836,7 +1856,9 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (!miner.proxy) { let proxyMinerName = miner.payout; // + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { - addProxyMiner(miner); + if (!addProxyMiner(miner)) { + return sendReplyFinal("Temporary (one hour max) ban since you connected too many workers. Please use proxy (https://github.com/MoneroOcean/xmrig-proxy)", 600); + } if (proxyMiners[proxyMinerName].hashes) adjustMinerDiff(miner); } else { if (!(miner.payout in minerWallets)) { @@ -2404,6 +2426,10 @@ if (cluster.isMaster) { bannedTmpWallets = {}; }, 10*60*1000); + setInterval(function () { + bannedBigTmpWallets = {}; + }, 60*60*1000); + function add_bans(is_show) { global.mysql.query("SELECT mining_address, reason FROM bans").then(function (rows) { bannedAddresses = {}; From 8c81f9a7c7dadff320ba6d86848db71e8728b6ca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Apr 2021 03:59:53 +0000 Subject: [PATCH 1362/1496] Added large worker miner bans --- lib/pool.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c270648af..15fa8be14 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -241,7 +241,7 @@ function addProxyMiner(miner) { console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); } else { if (++ proxyMiners[proxyMinerName].count > global.config.pool.workerMax) { - console.error("Starting to long ban " + wallet + " miner address"); + console.error(threadName + "Starting to long ban " + wallet + " miner address"); bannedBigTmpWallets[wallet] = 1; for (var [minerId2, miner2] of activeMiners) if (miner2.payout === wallet) removeMiner(miner2); return false; @@ -2230,6 +2230,15 @@ setInterval(function dump_vars() { s.write("\n\n\nis_walletAccFinalizer:\n"); s.write(JSON.stringify(is_walletAccFinalizer, null, '\t') + "\n"); + s.write("\n\n\nbannedTmpIPs:\n"); + s.write(JSON.stringify(bannedTmpIPs, null, '\t') + "\n"); + + s.write("\n\n\nbannedTmpWallets:\n"); + s.write(JSON.stringify(bannedTmpWallets, null, '\t') + "\n"); + + s.write("\n\n\nbannedBigTmpWallets:\n"); + s.write(JSON.stringify(bannedBigTmpWallets, null, '\t') + "\n"); + s.end(); }); }, 60*1000); From bd944cdaba6fa662818e31c6596057701689117c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Apr 2021 19:44:31 +0000 Subject: [PATCH 1363/1496] Updated utils version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 272b605a0..a44e32c11 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.1.4", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.2.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.1.0" } } From 68aab2fcb37ffcb7db8d7a3ddbe002fea47e7a9b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Apr 2021 20:29:22 +0000 Subject: [PATCH 1364/1496] Worker script debug --- lib/local_comms.js | 8 ++++++-- lib/worker.js | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 1b31c37d8..f40c32320 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -26,8 +26,7 @@ function Database(){ this.dirtyenv = false; - this.initEnv = function(){ - global.database.env = new this.lmdb.Env(); + this.openEnv = function() { global.database.env.open({ path: global.config.db_storage_path, maxDbs: 10, @@ -60,6 +59,11 @@ function Database(){ name: 'cache', create: true }); + }; + + this.initEnv = function(){ + global.database.env = new this.lmdb.Env(); + global.database.openEnv(); global.database.intervalID = setInterval(function(){ global.database.env.sync(function(){}); }, 60000); // Sync the DB every 60 seconds diff --git a/lib/worker.js b/lib/worker.js index faf94908b..f76bf5388 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -234,7 +234,7 @@ function updateShareStats() { } if ( stats.hashHistory.length < global.config.general.statsBufferLength || !(miner in miner_history_update_time) || - (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 30*60*1000) + (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 10*60*1000) ) { cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; miner_history_update_time[miner] = currentTime; @@ -304,7 +304,7 @@ function updateShareStats() { try { global.database.bulkSetCache(cache_updates); } catch (e) { - console.error("Can't wite to pool DB: " + e); + console.error("Can't write to pool DB: " + e); global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool DB is overflowed!", "Can't wite to pool DB: " + e); } cache_updates = null; @@ -441,4 +441,6 @@ setInterval(function() { stats_cache = stats_cache2; console.log("After cleaning: " + Object.keys(stats_cache).length + " stats left"); miner_history_update_time = {}; -}, 2*60*60*1000); + global.database.env.close(); + global.database.openEnv(); +}, 1*60*60*1000); From 85c5d091171b6937a155f123fc6e7df55c547e32 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Apr 2021 20:32:46 +0000 Subject: [PATCH 1365/1496] Worker script debug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index f76bf5388..d86104fa9 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -443,4 +443,4 @@ setInterval(function() { miner_history_update_time = {}; global.database.env.close(); global.database.openEnv(); -}, 1*60*60*1000); +}, 10*60*1000); From 9ef2379aca74a7be0036df3d78699d15a22c53f8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Apr 2021 20:47:01 +0000 Subject: [PATCH 1366/1496] Worker script debug --- lib/local_comms.js | 44 +++++--------------------------------------- lib/worker.js | 2 +- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index f40c32320..bc3003deb 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -24,9 +24,9 @@ function Database(){ this.altblockDB = null; this.cacheDB = null; - this.dirtyenv = false; - this.openEnv = function() { + this.initEnv = function(){ + global.database.env = new this.lmdb.Env(); global.database.env.open({ path: global.config.db_storage_path, maxDbs: 10, @@ -59,20 +59,13 @@ function Database(){ name: 'cache', create: true }); - }; - - this.initEnv = function(){ - global.database.env = new this.lmdb.Env(); - global.database.openEnv(); - global.database.intervalID = setInterval(function(){ - global.database.env.sync(function(){}); - }, 60000); // Sync the DB every 60 seconds - global.database.dirtyenv = false; + //global.database.intervalID = setInterval(function(){ + // global.database.env.sync(function(){}); + //}, 60000); // Sync the DB every 60 seconds console.log("Database Worker: LMDB Env Initialized."); }; this.incrementCacheData = function(key, data){ - this.refreshEnv(); let txn = this.env.beginTxn(); let cached = txn.getString(this.cacheDB, key); if (cached !== null){ @@ -108,7 +101,6 @@ function Database(){ } let response = []; try{ - this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.blockDB); for (let found = cursor.goToLast(), i = 0; found; found = cursor.goToPrev()) { @@ -157,7 +149,6 @@ function Database(){ } let response = []; try{ - this.refreshEnv(); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); for (let found = cursor.goToLast(), i = 0; found; found = cursor.goToPrev()) { @@ -332,7 +323,6 @@ function Database(){ }; this.getBlockByID = function(blockID){ - this.refreshEnv(); debug("Getting the data for blockID: " + blockID); let txn = this.env.beginTxn({readOnly: true}); let data = txn.getBinary(this.blockDB, blockID); @@ -350,7 +340,6 @@ function Database(){ let orphanBlocks = {}; this.storeBlock = function(blockId, blockData, callback){ - this.refreshEnv(); try{ let blockDataDecoded = global.protos.Block.decode(blockData); global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ @@ -412,7 +401,6 @@ function Database(){ let busyPorts = {}; // ports that are alredy have active getPortBlockHeaderByHash request this.storeAltBlock = function(blockId, blockData, callback){ - this.refreshEnv(); try{ let blockDataDecoded = global.protos.AltBlock.decode(blockData); if (blockDataDecoded.port in busyPorts) { @@ -500,7 +488,6 @@ function Database(){ }; this.invalidateBlock = function(blockId){ - this.refreshEnv(); let txn = this.env.beginTxn(); let blockData = global.protos.Block.decode(txn.getBinary(this.blockDB, blockId)); blockData.valid = false; @@ -510,7 +497,6 @@ function Database(){ }; this.invalidateAltBlock = function(blockId){ - this.refreshEnv(); let txn = this.env.beginTxn(); let blockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, blockId)); blockData.valid = false; @@ -520,7 +506,6 @@ function Database(){ }; this.changeAltBlockPayStageStatus = function(blockId, pay_stage, pay_status){ - this.refreshEnv(); let txn = this.env.beginTxn(); let blockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, blockId)); blockData.pay_stage = pay_stage; @@ -530,7 +515,6 @@ function Database(){ }; this.moveAltBlockReward = function(srcBlockId, dstBlockId, srcAmount){ - this.refreshEnv(); let txn = this.env.beginTxn(); let srcBlockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, srcBlockId)); let dstBlockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, dstBlockId)); @@ -545,7 +529,6 @@ function Database(){ }; this.changeAltBlockPayValue = function(blockId, pay_value){ - this.refreshEnv(); let txn = this.env.beginTxn(); let blockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, blockId)); blockData.pay_value = pay_value; @@ -554,7 +537,6 @@ function Database(){ }; this.getValidLockedBlocks = function(){ - this.refreshEnv(); let txn = this.env.beginTxn({readOnly: true}); let cursor = new this.lmdb.Cursor(txn, this.blockDB); let blockList = []; @@ -573,7 +555,6 @@ function Database(){ }; this.getValidLockedAltBlocks = function(){ - this.refreshEnv(); let txn = this.env.beginTxn({readOnly: true}); let cursor = new this.lmdb.Cursor(txn, this.altblockDB); let blockList = []; @@ -592,7 +573,6 @@ function Database(){ }; this.isAltBlockInDB = function(port, height){ - this.refreshEnv(); let txn = this.env.beginTxn({readOnly: true}); let cursor = new this.lmdb.Cursor(txn, this.altblockDB); let isBlockFound = false; @@ -610,7 +590,6 @@ function Database(){ }; this.unlockBlock = function(blockHex){ - this.refreshEnv(); let txn = this.env.beginTxn(); let cursor = new this.lmdb.Cursor(txn, this.blockDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { @@ -629,7 +608,6 @@ function Database(){ }; this.unlockAltBlock = function(blockHex){ - this.refreshEnv(); let txn = this.env.beginTxn(); let cursor = new this.lmdb.Cursor(txn, this.altblockDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { @@ -648,7 +626,6 @@ function Database(){ }; this.payReadyBlock = function(blockHex){ - this.refreshEnv(); let txn = this.env.beginTxn(); let cursor = new this.lmdb.Cursor(txn, this.blockDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { @@ -667,7 +644,6 @@ function Database(){ }; this.payReadyAltBlock = function(blockHex){ - this.refreshEnv(); let txn = this.env.beginTxn(); let cursor = new this.lmdb.Cursor(txn, this.altblockDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { @@ -688,7 +664,6 @@ function Database(){ this.getCache = function(cacheKey){ debug("Getting Key: "+cacheKey); try { - this.refreshEnv(); let txn = this.env.beginTxn({readOnly: true}); let cached = txn.getString(this.cacheDB, cacheKey); txn.abort(); @@ -704,7 +679,6 @@ function Database(){ this.setCache = function(cacheKey, cacheData){ debug("Setting Key: "+cacheKey+ " Data: " + JSON.stringify(cacheData)); - this.refreshEnv(); let txn = this.env.beginTxn(); txn.putString(this.cacheDB, cacheKey, JSON.stringify(cacheData)); txn.commit(); @@ -734,7 +708,6 @@ function Database(){ This function returns a decompressed block proto for the first locked block in the system as part of the share depth functions. DO NOT BLINDLY REPLACE getLastBlock WITH THIS FUNCTION. */ - this.refreshEnv(); debug("Getting the oldest locked block in the system"); let oldestLockedBlockHeight = null; @@ -912,7 +885,6 @@ function Database(){ } if (global.config.general.blockCleaner === true){ if(data.length > 0){ - global.database.refreshEnv(); let totalDeleted = 0; let totalDeleted2 = 0; console.log("Block cleaning started: removing " + data.length + " block share records"); @@ -941,12 +913,6 @@ function Database(){ console.log("Done cleaning up the share DB"); }); }; - - this.refreshEnv = function(){}; - - setInterval(function(){ - global.database.dirtyenv = true; - }, 900000); // Set DB env reload for every 15 minutes. } process.on('SIGINT', function() { diff --git a/lib/worker.js b/lib/worker.js index d86104fa9..304604152 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -442,5 +442,5 @@ setInterval(function() { console.log("After cleaning: " + Object.keys(stats_cache).length + " stats left"); miner_history_update_time = {}; global.database.env.close(); - global.database.openEnv(); + global.database.initEnv(); }, 10*60*1000); From 4cad38f7088dab7f2783c53bb4d9fc8161ced2d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Apr 2021 03:24:20 +0000 Subject: [PATCH 1367/1496] Worker script debug --- lib/worker.js | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 304604152..a2c4614b3 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -222,14 +222,14 @@ function updateShareStats() { stats.hashHistory.unshift({ts: currentTime, hs: stats.hash, hs2: stats.hash2}); if (stats.hashHistory.length > global.config.general.statsBufferLength) { while (stats.hashHistory.length > global.config.general.statsBufferLength) { - //const last_index = stats.hashHistory.length - 1; - //if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { + const last_index = stats.hashHistory.length - 1; + if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { stats.hashHistory.pop(); - //} else { + } else { // here we remove larger indexes (that are more distant in time) with more probability - // const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); - // stats.hashHistory.splice(index_to_remove, 1); - //} + const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); + stats.hashHistory.splice(index_to_remove, 1); + } } } if ( stats.hashHistory.length < global.config.general.statsBufferLength || @@ -263,7 +263,7 @@ function updateShareStats() { if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { const address = address_parts[0]; get_address_email(address, function (email) { - setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, email, currentTime); + setTimeout(delayed_send_worker_stopped_hashing_email, 10*60*1000, miner, email, currentTime); }); } } @@ -281,9 +281,11 @@ function updateShareStats() { const worker = address_parts[1]; if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { const address = address_parts[0]; - get_address_email(address, function (email) { - send_worker_started_hashing_email(miner, email, currentTime); - }); + if (miner in workers_stopped_hashing_email_time) { + get_address_email(address, function (email) { + send_worker_started_hashing_email(miner, email, currentTime); + }); + } } } @@ -378,24 +380,22 @@ function get_address_email(address, callback) { function send_worker_started_hashing_email(miner, email, currentTime) { workers_started_hashing_time[miner] = currentTime; - if (miner in workers_stopped_hashing_email_time) { - delete workers_stopped_hashing_email_time[miner]; - - let address_parts = miner.split(/_(.+)/); - let address = address_parts[0]; - let worker = address_parts[1]; - // toAddress, subject, body - let emailData = { - worker: worker, - timestamp: global.support.formatDate(currentTime), - poolEmailSig: global.config.general.emailSig - }; - global.support.sendEmail(email, - sprintf(global.config.email.workerStartHashingSubject, emailData), - sprintf(global.config.email.workerStartHashingBody, emailData), - address - ); - } + delete workers_stopped_hashing_email_time[miner]; + + let address_parts = miner.split(/_(.+)/); + let address = address_parts[0]; + let worker = address_parts[1]; + // toAddress, subject, body + let emailData = { + worker: worker, + timestamp: global.support.formatDate(currentTime), + poolEmailSig: global.config.general.emailSig + }; + global.support.sendEmail(email, + sprintf(global.config.email.workerStartHashingSubject, emailData), + sprintf(global.config.email.workerStartHashingBody, emailData), + address + ); } function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { @@ -430,6 +430,8 @@ global.support.sendEmail(global.config.general.adminEmail, "Restarting worker mo updateShareStats(); // clean caches from time to time setInterval(function() { + //console.log("TODO: Investigate why missive slowdown happens unless I restart this"); + //process.exit(); console.log("Cleaning caches (" + Object.keys(stats_cache).length + " stats, " + Object.keys(miner_history_update_time).length + " histories)"); const currentTime = Date.now(); let stats_cache2 = {}; @@ -441,6 +443,4 @@ setInterval(function() { stats_cache = stats_cache2; console.log("After cleaning: " + Object.keys(stats_cache).length + " stats left"); miner_history_update_time = {}; - global.database.env.close(); - global.database.initEnv(); -}, 10*60*1000); +}, 2*60*60*1000); From 53a5eebe54664811834e63c4fd28bee5338ce6ab Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Apr 2021 03:47:19 +0000 Subject: [PATCH 1368/1496] Worker script debug --- lib/worker.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index a2c4614b3..484db5f36 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -221,14 +221,19 @@ function updateShareStats() { if (cycleCount === 0) { stats.hashHistory.unshift({ts: currentTime, hs: stats.hash, hs2: stats.hash2}); if (stats.hashHistory.length > global.config.general.statsBufferLength) { + const is_worker = miner.indexOf('_') >= 0; while (stats.hashHistory.length > global.config.general.statsBufferLength) { - const last_index = stats.hashHistory.length - 1; - if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { + if (is_worker) { stats.hashHistory.pop(); } else { - // here we remove larger indexes (that are more distant in time) with more probability - const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); - stats.hashHistory.splice(index_to_remove, 1); + const last_index = stats.hashHistory.length - 1; + if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { + stats.hashHistory.pop(); + } else { + // here we remove larger indexes (that are more distant in time) with more probability + const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); + stats.hashHistory.splice(index_to_remove, 1); + } } } } From 887a268dc27dc049040bb54f11a5e41f8346c560 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Apr 2021 21:21:24 +0000 Subject: [PATCH 1369/1496] Worker script debug --- lib/worker.js | 604 ++++++++++++++++++++++++-------------------------- 1 file changed, 293 insertions(+), 311 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 484db5f36..f635247ad 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -13,8 +13,8 @@ let prev_pool_workers; let stats_cache = {}; let miner_history_update_time = {}; - -function updateShareStats() { + +function updateShareStats2(height, callback) { // This is an omni-worker to deal with all things share-stats related // Time based averages are worked out on ring buffers. // Buffer lengths? You guessed it, configured in SQL. @@ -25,334 +25,316 @@ function updateShareStats() { // we just select history_power so that is till happen on global.config.general.statsBufferHours * 60 attemps on average const history_power = Math.log(global.config.general.statsBufferLength) / Math.log(global.config.general.statsBufferHours * 60); - async.waterfall([ - function (callback) { - global.coinFuncs.getLastBlockHeader(function (err, body) { - if (err !== null){ - return callback(err, "Invalid block header"); + console.log("Starting stats collection for " + height + " height (history power: " + history_power + ")"); + + const locTime = currentTime - (hashrate_avg_min*60*1000); + const identifierTime = currentTime - (2*hashrate_avg_min*60*1000); + + let identifiers = {}; + let minerSet = {}; + let minerPortSet = {}; + let minerCount = 0; + let localMinerCount = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 }; + let localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; + let localPortHashes = {}; + let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; + + let loopBreakout = 0; + let oldestTime = currentTime; + let txn = global.database.env.beginTxn({readOnly: true}); + + do { + let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); + let count = 0; + for (let found = cursor.goToRange(height) === height; found; ++ count, found = cursor.goToNextDup()) { + cursor.getCurrentBinary(function (key, share) { // jshint ignore:line + try { + share = global.protos.Share.decode(share); + } catch (e) { + console.error(share); + continue; + } + if (share.timestamp < oldestTime) oldestTime = share.timestamp; + if (share.timestamp <= identifierTime) continue; + + let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 + ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; + + const identifier = share.identifier; + + if (minerID in identifiers) { + if (identifiers[minerID].indexOf(identifier) < 0) { + identifiers[minerID].push(identifier); + ++ minerCount; + } + } else { + identifiers[minerID] = [identifier]; + ++ minerCount; } - callback(null, body.height + 1); - }); - }, - function (height, callback) { - console.log("Starting stats collection for " + height + " height (history power: " + history_power + ")"); - - const locTime = currentTime - (hashrate_avg_min*60*1000); - const identifierTime = currentTime - (2*hashrate_avg_min*60*1000); - - let identifiers = {}; - let minerSet = {}; - let minerPortSet = {}; - let minerCount = 0; - let localMinerCount = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 }; - let localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; - let localPortHashes = {}; - let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; - let loopBreakout = 0; - - async.doUntil(function (callback_until) { - let oldestTime = currentTime; - let txn = global.database.env.beginTxn({readOnly: true}); - let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - let count = 0; - for (let found = cursor.goToRange(height) === height; found; ++ count, found = cursor.goToNextDup()) { - cursor.getCurrentBinary(function (key, share) { // jshint ignore:line - try { - share = global.protos.Share.decode(share); - } catch (e) { - console.error(share); - return; - } - if (share.timestamp < oldestTime) oldestTime = share.timestamp; - if (share.timestamp <= identifierTime) return; - - let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 - ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; - - const identifier = share.identifier; - - if (minerID in identifiers) { - if (identifiers[minerID].indexOf(identifier) < 0) { - identifiers[minerID].push(identifier); - ++ minerCount; - } - } else { - identifiers[minerID] = [identifier]; - ++ minerCount; - } - - if (share.timestamp <= locTime) return; - - let minerIDWithIdentifier = minerID + "_" + identifier; - const shares2 = share.shares2; - localStats.global += shares2; - if (localTimes.global < share.timestamp) localTimes.global = share.timestamp; - let minerType; - switch (share.poolType) { - case global.protos.POOLTYPE.PPLNS: - minerType = 'pplns'; - localStats.pplns += shares2; - if (localTimes.pplns < share.timestamp) localTimes.pplns = share.timestamp; - break; - case global.protos.POOLTYPE.PPS: - localStats.pps += shares2; - minerType = 'pps'; - if (localTimes.pps < share.timestamp) localTimes.pps = share.timestamp; - break; - case global.protos.POOLTYPE.SOLO: - localStats.solo += shares2; - minerType = 'solo'; - if (localTimes.solo < share.timestamp) localTimes.solo = share.timestamp; - break; - } - - const port = typeof(share.port) !== 'undefined' && share.port ? share.port : global.config.daemon.port; - if (port in localPortHashes) localPortHashes[port] += share.raw_shares; - else localPortHashes[port] = share.raw_shares; - if (!shares2) return; // use virtual shares from child block mining only for global pool stats + if (share.timestamp <= locTime) continue; + + let minerIDWithIdentifier = minerID + "_" + identifier; + const shares2 = share.shares2; + localStats.global += shares2; + if (localTimes.global < share.timestamp) localTimes.global = share.timestamp; + let minerType; + switch (share.poolType) { + case global.protos.POOLTYPE.PPLNS: + minerType = 'pplns'; + localStats.pplns += shares2; + if (localTimes.pplns < share.timestamp) localTimes.pplns = share.timestamp; + break; + case global.protos.POOLTYPE.PPS: + localStats.pps += shares2; + minerType = 'pps'; + if (localTimes.pps < share.timestamp) localTimes.pps = share.timestamp; + break; + case global.protos.POOLTYPE.SOLO: + localStats.solo += shares2; + minerType = 'solo'; + if (localTimes.solo < share.timestamp) localTimes.solo = share.timestamp; + break; + } - if (minerID in minerPortSet) { - localStats.miners[minerID] += share.raw_shares; - localStats.miners2[minerID] += shares2; - if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; - } else { - ++ localMinerCount[minerType]; - ++ localMinerCount.global; - localStats.miners[minerID] = share.raw_shares; - localStats.miners2[minerID] = shares2; - localTimes.miners[minerID] = share.timestamp; - minerSet[minerID] = 1; - minerPortSet[minerID] = port; - } + const port = typeof(share.port) !== 'undefined' && share.port ? share.port : global.config.daemon.port; + if (port in localPortHashes) localPortHashes[port] += share.raw_shares; + else localPortHashes[port] = share.raw_shares; + + if (!shares2) continue; // use virtual shares from child block mining only for global pool stats + + if (minerID in minerPortSet) { + localStats.miners[minerID] += share.raw_shares; + localStats.miners2[minerID] += shares2; + if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; + } else { + ++ localMinerCount[minerType]; + ++ localMinerCount.global; + localStats.miners[minerID] = share.raw_shares; + localStats.miners2[minerID] = shares2; + localTimes.miners[minerID] = share.timestamp; + minerSet[minerID] = 1; + minerPortSet[minerID] = port; + } - if (minerIDWithIdentifier in minerSet) { - localStats.miners[minerIDWithIdentifier] += share.raw_shares; - localStats.miners2[minerIDWithIdentifier] += shares2; - if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; - } else { - localStats.miners[minerIDWithIdentifier] = share.raw_shares; - localStats.miners2[minerIDWithIdentifier] = shares2; - localTimes.miners[minerIDWithIdentifier] = share.timestamp; - minerSet[minerIDWithIdentifier] = 1; - } - }); + if (minerIDWithIdentifier in minerSet) { + localStats.miners[minerIDWithIdentifier] += share.raw_shares; + localStats.miners2[minerIDWithIdentifier] += shares2; + if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; + } else { + localStats.miners[minerIDWithIdentifier] = share.raw_shares; + localStats.miners2[minerIDWithIdentifier] = shares2; + localTimes.miners[minerIDWithIdentifier] = share.timestamp; + minerSet[minerIDWithIdentifier] = 1; } - cursor.close(); - txn.abort(); - debug("On " + height + " height iterated " + count + " elements"); - return callback_until(null, oldestTime); - - }, function (oldestTime, untilCB) { - return untilCB(null, ++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime); - - }, function (err) { - debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); - let prevMinerSet = global.database.getCache('minerSet'); - if (prevMinerSet === false) prevMinerSet = minerSet; - let cache_updates = {}; - // pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 - ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { - const hash = localStats[key] / (hashrate_avg_min*60); - const lastHash = localTimes[key]; - const minerCount = localMinerCount[key]; - let cachedData = global.database.getCache(key + "_stats"); - if (cachedData !== false) { - cachedData.hash = hash; - cachedData.lastHash = lastHash; - cachedData.minerCount = minerCount; - if (!cachedData.hasOwnProperty("hashHistory")) { - cachedData.hashHistory = []; - cachedData.minerHistory = []; - } - if (cycleCount === 0) { - cachedData.hashHistory.unshift({ts: currentTime, hs: cachedData.hash}); - if (cachedData.hashHistory.length > global.config.general.statsBufferLength) { - while (cachedData.hashHistory.length > global.config.general.statsBufferLength) { - cachedData.hashHistory.pop(); - } - } - cachedData.minerHistory.unshift({ts: currentTime, cn: cachedData.minerCount}); - if (cachedData.minerHistory.length > global.config.general.statsBufferLength) { - while (cachedData.minerHistory.length > global.config.general.statsBufferLength) { - cachedData.minerHistory.pop(); - } - } - } - } else { - cachedData = { - hash: hash, - totalHashes: 0, - lastHash: lastHash, - minerCount: minerCount, - hashHistory: [{ts: currentTime, hs: hash}], - minerHistory: [{ts: currentTime, cn: minerCount}] - }; + }); + } + cursor.close(); + debug("On " + height + " height iterated " + count + " elements"); + } while (++loopBreakout <= 60 && --height >= 0 && oldestTime > identifierTime); + txn.abort(); + + debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); + let prevMinerSet = global.database.getCache('minerSet'); + if (prevMinerSet === false) prevMinerSet = minerSet; + let cache_updates = {}; + // pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 + ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { + const hash = localStats[key] / (hashrate_avg_min*60); + const lastHash = localTimes[key]; + const minerCount = localMinerCount[key]; + let cachedData = global.database.getCache(key + "_stats"); + if (cachedData !== false) { + cachedData.hash = hash; + cachedData.lastHash = lastHash; + cachedData.minerCount = minerCount; + if (!cachedData.hasOwnProperty("hashHistory")) { + cachedData.hashHistory = []; + cachedData.minerHistory = []; + } + if (cycleCount === 0) { + cachedData.hashHistory.unshift({ts: currentTime, hs: cachedData.hash}); + if (cachedData.hashHistory.length > global.config.general.statsBufferLength) { + while (cachedData.hashHistory.length > global.config.general.statsBufferLength) { + cachedData.hashHistory.pop(); } - cache_updates[key + "_stats"] = cachedData; - }); - for (let port in localPortHashes) localPortHashes[port] = localPortHashes[port] / (hashrate_avg_min*60); - cache_updates["port_hash"] = localPortHashes; - let history_update_count = 0; - - for (let miner in minerSet) { - let stats; - let keyStats = "stats:" + miner; - let keyHistory = "history:" + miner; + } + cachedData.minerHistory.unshift({ts: currentTime, cn: cachedData.minerCount}); + if (cachedData.minerHistory.length > global.config.general.statsBufferLength) { + while (cachedData.minerHistory.length > global.config.general.statsBufferLength) { + cachedData.minerHistory.pop(); + } + } + } + } else { + cachedData = { + hash: hash, + totalHashes: 0, + lastHash: lastHash, + minerCount: minerCount, + hashHistory: [{ts: currentTime, hs: hash}], + minerHistory: [{ts: currentTime, cn: minerCount}] + }; + } + cache_updates[key + "_stats"] = cachedData; + }); + for (let port in localPortHashes) localPortHashes[port] = localPortHashes[port] / (hashrate_avg_min*60); + cache_updates["port_hash"] = localPortHashes; + let history_update_count = 0; + + for (let miner in minerSet) { + let stats; + let keyStats = "stats:" + miner; + let keyHistory = "history:" + miner; + + if (miner in stats_cache) { + stats = stats_cache[miner]; + } else { + stats = global.database.getCache(keyStats); + if (!stats) stats = {}; + let history_stats = global.database.getCache(keyHistory); + if (history_stats) { + stats.hashHistory = history_stats.hashHistory; + } else { + stats.hashHistory = []; + } + } - if (miner in stats_cache) { - stats = stats_cache[miner]; + stats.hash = localStats.miners[miner] / (hashrate_avg_min*60); + stats.hash2 = localStats.miners2[miner] / (hashrate_avg_min*60); + stats.lastHash = localTimes.miners[miner]; + cache_updates[keyStats] = { hash: stats.hash, hash2: stats.hash2, lastHash: stats.lastHash }; + + if (cycleCount === 0) { + stats.hashHistory.unshift({ts: currentTime, hs: stats.hash, hs2: stats.hash2}); + if (stats.hashHistory.length > global.config.general.statsBufferLength) { + const is_worker = miner.indexOf('_') >= 0; + while (stats.hashHistory.length > global.config.general.statsBufferLength) { + if (is_worker) { + stats.hashHistory.pop(); } else { - stats = global.database.getCache(keyStats); - if (!stats) stats = {}; - let history_stats = global.database.getCache(keyHistory); - if (history_stats) { - stats.hashHistory = history_stats.hashHistory; + const last_index = stats.hashHistory.length - 1; + if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { + stats.hashHistory.pop(); } else { - stats.hashHistory = []; + // here we remove larger indexes (that are more distant in time) with more probability + const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); + stats.hashHistory.splice(index_to_remove, 1); } } + } + } + if ( stats.hashHistory.length < global.config.general.statsBufferLength || + !(miner in miner_history_update_time) || + (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 10*60*1000) + ) { + cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; + miner_history_update_time[miner] = currentTime; + ++ history_update_count; + } + } - stats.hash = localStats.miners[miner] / (hashrate_avg_min*60); - stats.hash2 = localStats.miners2[miner] / (hashrate_avg_min*60); - stats.lastHash = localTimes.miners[miner]; - cache_updates[keyStats] = { hash: stats.hash, hash2: stats.hash2, lastHash: stats.lastHash }; - - if (cycleCount === 0) { - stats.hashHistory.unshift({ts: currentTime, hs: stats.hash, hs2: stats.hash2}); - if (stats.hashHistory.length > global.config.general.statsBufferLength) { - const is_worker = miner.indexOf('_') >= 0; - while (stats.hashHistory.length > global.config.general.statsBufferLength) { - if (is_worker) { - stats.hashHistory.pop(); - } else { - const last_index = stats.hashHistory.length - 1; - if ((currentTime - stats.hashHistory[last_index].ts) / 1000 / 3600 > global.config.general.statsBufferHours) { - stats.hashHistory.pop(); - } else { - // here we remove larger indexes (that are more distant in time) with more probability - const index_to_remove = (last_index * (1 - Math.pow(Math.random(), history_power))).toFixed(); - stats.hashHistory.splice(index_to_remove, 1); - } - } - } - } - if ( stats.hashHistory.length < global.config.general.statsBufferLength || - !(miner in miner_history_update_time) || - (history_update_count < 5000 && currentTime - miner_history_update_time[miner] > 10*60*1000) - ) { - cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; - miner_history_update_time[miner] = currentTime; - ++ history_update_count; - } - } + stats_cache[miner] = stats; + } - stats_cache[miner] = stats; - } + debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); + + // remove old workers + for (let miner in prevMinerSet) { + if (miner in minerSet) continue; // we still have this miner in current set + //debug("Removing: " + miner + " as an active miner from the cache."); + let minerStats = global.database.getCache(miner); + if (!minerStats) continue; + minerStats.hash = 0; + cache_updates[miner] = minerStats; + if (miner.indexOf('_') <= -1) continue; + + // This is a worker case. + const address_parts = miner.split(/_(.+)/); + const worker = address_parts[1]; + if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { + const address = address_parts[0]; + get_address_email(address, function (email) { + setTimeout(delayed_send_worker_stopped_hashing_email, 10*60*1000, miner, email, currentTime); + }); + } + } - debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); - - // remove old workers - for (let miner in prevMinerSet) { - if (miner in minerSet) continue; // we still have this miner in current set - //debug("Removing: " + miner + " as an active miner from the cache."); - let minerStats = global.database.getCache(miner); - if (!minerStats) continue; - minerStats.hash = 0; - cache_updates[miner] = minerStats; - if (miner.indexOf('_') <= -1) continue; - - // This is a worker case. - const address_parts = miner.split(/_(.+)/); - const worker = address_parts[1]; - if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { - const address = address_parts[0]; - get_address_email(address, function (email) { - setTimeout(delayed_send_worker_stopped_hashing_email, 10*60*1000, miner, email, currentTime); - }); - } - } + debug("Old worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); + + // find new workers + for (let miner in minerSet) { + if (miner in prevMinerSet) continue; // we still have this miner in previous set + //debug("Adding: " + miner + " as an active miner to the cache."); + if (miner.indexOf('_') <= -1) continue; + + // This is a worker case. + const address_parts = miner.split(/_(.+)/); + const worker = address_parts[1]; + if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { + const address = address_parts[0]; + if (miner in workers_stopped_hashing_email_time) { + get_address_email(address, function (email) { + send_worker_started_hashing_email(miner, email, currentTime); + }); + } + } + } - debug("Old worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); - - // find new workers - for (let miner in minerSet) { - if (miner in prevMinerSet) continue; // we still have this miner in previous set - //debug("Adding: " + miner + " as an active miner to the cache."); - if (miner.indexOf('_') <= -1) continue; - - // This is a worker case. - const address_parts = miner.split(/_(.+)/); - const worker = address_parts[1]; - if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { - const address = address_parts[0]; - if (miner in workers_stopped_hashing_email_time) { - get_address_email(address, function (email) { - send_worker_started_hashing_email(miner, email, currentTime); - }); - } - } - } + debug("New worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); - debug("New worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); + Object.keys(identifiers).forEach(function (key) { + cache_updates['identifiers:' + key] = identifiers[key]; + }); + let portMinerCount = {}; + for (let miner in minerPortSet) { + const port = minerPortSet[miner]; + if (port in portMinerCount) ++ portMinerCount[port]; + else portMinerCount[port] = 1; + } + cache_updates.portMinerCount = portMinerCount; + cache_updates.minerSet = minerSet; + const db_write_start_time = Date.now(); + try { + global.database.bulkSetCache(cache_updates); + } catch (e) { + console.error("Can't write to pool DB: " + e); + global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool DB is overflowed!", "Can't wite to pool DB: " + e); + } - Object.keys(identifiers).forEach(function (key) { - cache_updates['identifiers:' + key] = identifiers[key]; - }); - let portMinerCount = {}; - for (let miner in minerPortSet) { - const port = minerPortSet[miner]; - if (port in portMinerCount) ++ portMinerCount[port]; - else portMinerCount[port] = 1; - } - cache_updates.portMinerCount = portMinerCount; - cache_updates.minerSet = minerSet; - const db_write_start_time = Date.now(); - try { - global.database.bulkSetCache(cache_updates); - } catch (e) { - console.error("Can't write to pool DB: " + e); - global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool DB is overflowed!", "Can't wite to pool DB: " + e); - } - cache_updates = null; - - let pool_hashrate = localStats.global / (hashrate_avg_min*60); - let pool_workers = minerCount; - console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + - ((Date.now() - currentTime) / 1000) + " seconds (" + ((Date.now() - db_write_start_time) / 1000) + " seconds DB write). " + - "Pool hashrate is: " + pool_hashrate - ); - if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { - let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; - let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; - if (pool_hashrate_ratio < (1-stat_change_alert) || pool_hashrate_ratio > (1+stat_change_alert) || - pool_workers_ratio < (1-stat_change_alert) || pool_workers_ratio > (1+stat_change_alert)) { - global.support.sendEmail(global.config.general.adminEmail, - "FYI: Pool hashrate/workers changed significantly", - "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + " (" + pool_hashrate_ratio + ")\n" + - "Pool number of workers changed from " + prev_pool_workers + " to " + pool_workers + " (" + pool_workers_ratio + ")\n" - ); - } - prev_pool_hashrate = pool_hashrate; - prev_pool_workers = pool_workers; - prev_pool_state_time = currentTime; - } - callback(null); - }); + let pool_hashrate = localStats.global / (hashrate_avg_min*60); + let pool_workers = minerCount; + console.log("Processed " + minerCount + " workers (" + history_update_count + " history) for " + + ((Date.now() - currentTime) / 1000) + " seconds (" + ((Date.now() - db_write_start_time) / 1000) + " seconds DB write). " + + "Pool hashrate is: " + pool_hashrate + ); + if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { + let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; + let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; + if (pool_hashrate_ratio < (1-stat_change_alert) || pool_hashrate_ratio > (1+stat_change_alert) || + pool_workers_ratio < (1-stat_change_alert) || pool_workers_ratio > (1+stat_change_alert)) { + global.support.sendEmail(global.config.general.adminEmail, + "FYI: Pool hashrate/workers changed significantly", + "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + " (" + pool_hashrate_ratio + ")\n" + + "Pool number of workers changed from " + prev_pool_workers + " to " + pool_workers + " (" + pool_workers_ratio + ")\n" + ); } - ], function (err, result) { - if (++cycleCount === 3) { - cycleCount = 0; - //try { - // if (global.gc) { - // global.gc(); - // console.log("Garbage collector completed"); - // } - //} catch (e) { - // console.error("No garbage collector exposed, please use --expose-gc node option"); - //} + prev_pool_hashrate = pool_hashrate; + prev_pool_workers = pool_workers; + prev_pool_state_time = currentTime; + } + return callback(); +} + +function updateShareStats() { + global.coinFuncs.getLastBlockHeader(function (err, body) { + if (err !== null){ + return setTimeout(updateShareStats, 10*1000); } - setTimeout(updateShareStats, 10*1000); + updateShareStats2(body.height + 1, function() { + if (++cycleCount === 3) cycleCount = 0; + setTimeout(updateShareStats, 10*1000); + }); }); } From 7215db76b845c7dc28166f29c64aebcf971c7dc3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Apr 2021 21:25:37 +0000 Subject: [PATCH 1370/1496] Worker script debug --- lib/worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index f635247ad..e7e24408f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -52,10 +52,10 @@ function updateShareStats2(height, callback) { share = global.protos.Share.decode(share); } catch (e) { console.error(share); - continue; + return; } if (share.timestamp < oldestTime) oldestTime = share.timestamp; - if (share.timestamp <= identifierTime) continue; + if (share.timestamp <= identifierTime) return; let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; @@ -72,7 +72,7 @@ function updateShareStats2(height, callback) { ++ minerCount; } - if (share.timestamp <= locTime) continue; + if (share.timestamp <= locTime) return; let minerIDWithIdentifier = minerID + "_" + identifier; const shares2 = share.shares2; @@ -101,7 +101,7 @@ function updateShareStats2(height, callback) { if (port in localPortHashes) localPortHashes[port] += share.raw_shares; else localPortHashes[port] = share.raw_shares; - if (!shares2) continue; // use virtual shares from child block mining only for global pool stats + if (!shares2) return; // use virtual shares from child block mining only for global pool stats if (minerID in minerPortSet) { localStats.miners[minerID] += share.raw_shares; From af5d3b79e16bd86109d52a4da1b44135e94d18e3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Apr 2021 21:39:41 +0000 Subject: [PATCH 1371/1496] Worker script debug --- lib/worker.js | 157 ++++++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 82 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index e7e24408f..adce01a0a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -14,6 +14,12 @@ let prev_pool_workers; let stats_cache = {}; let miner_history_update_time = {}; +const pool_type_str = { + global.protos.POOLTYPE.PPLNS: 'pplns', + global.protos.POOLTYPE.PPS: 'pps', + global.protos.POOLTYPE.SOLO: 'solo', +}; + function updateShareStats2(height, callback) { // This is an omni-worker to deal with all things share-stats related // Time based averages are worked out on ring buffers. @@ -42,96 +48,83 @@ function updateShareStats2(height, callback) { let loopBreakout = 0; let oldestTime = currentTime; let txn = global.database.env.beginTxn({readOnly: true}); + let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); do { - let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); let count = 0; - for (let found = cursor.goToRange(height) === height; found; ++ count, found = cursor.goToNextDup()) { - cursor.getCurrentBinary(function (key, share) { // jshint ignore:line - try { - share = global.protos.Share.decode(share); - } catch (e) { - console.error(share); - return; - } - if (share.timestamp < oldestTime) oldestTime = share.timestamp; - if (share.timestamp <= identifierTime) return; - - let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 - ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; - - const identifier = share.identifier; - - if (minerID in identifiers) { - if (identifiers[minerID].indexOf(identifier) < 0) { - identifiers[minerID].push(identifier); - ++ minerCount; - } - } else { - identifiers[minerID] = [identifier]; - ++ minerCount; - } + for (let found = cursor.goToRange(height) === height; found; ++ count, found = cursor.goToNextDup()) cursor.getCurrentBinary(function (key, share) { // jshint ignore:line + try { + share = global.protos.Share.decode(share); + } catch (e) { + console.error(share); + return; + } + if (share.timestamp < oldestTime) oldestTime = share.timestamp; + if (share.timestamp <= identifierTime) return; - if (share.timestamp <= locTime) return; - - let minerIDWithIdentifier = minerID + "_" + identifier; - const shares2 = share.shares2; - localStats.global += shares2; - if (localTimes.global < share.timestamp) localTimes.global = share.timestamp; - let minerType; - switch (share.poolType) { - case global.protos.POOLTYPE.PPLNS: - minerType = 'pplns'; - localStats.pplns += shares2; - if (localTimes.pplns < share.timestamp) localTimes.pplns = share.timestamp; - break; - case global.protos.POOLTYPE.PPS: - localStats.pps += shares2; - minerType = 'pps'; - if (localTimes.pps < share.timestamp) localTimes.pps = share.timestamp; - break; - case global.protos.POOLTYPE.SOLO: - localStats.solo += shares2; - minerType = 'solo'; - if (localTimes.solo < share.timestamp) localTimes.solo = share.timestamp; - break; - } + const minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 + ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; - const port = typeof(share.port) !== 'undefined' && share.port ? share.port : global.config.daemon.port; - if (port in localPortHashes) localPortHashes[port] += share.raw_shares; - else localPortHashes[port] = share.raw_shares; - - if (!shares2) return; // use virtual shares from child block mining only for global pool stats - - if (minerID in minerPortSet) { - localStats.miners[minerID] += share.raw_shares; - localStats.miners2[minerID] += shares2; - if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; - } else { - ++ localMinerCount[minerType]; - ++ localMinerCount.global; - localStats.miners[minerID] = share.raw_shares; - localStats.miners2[minerID] = shares2; - localTimes.miners[minerID] = share.timestamp; - minerSet[minerID] = 1; - minerPortSet[minerID] = port; - } + const identifier = share.identifier; - if (minerIDWithIdentifier in minerSet) { - localStats.miners[minerIDWithIdentifier] += share.raw_shares; - localStats.miners2[minerIDWithIdentifier] += shares2; - if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; - } else { - localStats.miners[minerIDWithIdentifier] = share.raw_shares; - localStats.miners2[minerIDWithIdentifier] = shares2; - localTimes.miners[minerIDWithIdentifier] = share.timestamp; - minerSet[minerIDWithIdentifier] = 1; - } - }); - } - cursor.close(); + if (minerID in identifiers) { + if (identifiers[minerID].indexOf(identifier) < 0) { + identifiers[minerID].push(identifier); + ++ minerCount; + } + } else { + identifiers[minerID] = [identifier]; + ++ minerCount; + } + + if (share.timestamp <= locTime) return; + + const minerIDWithIdentifier = minerID + "_" + identifier; + const shares2 = share.shares2; + localStats.global += shares2; + if (localTimes.global < share.timestamp) localTimes.global = share.timestamp; + const minerType = pool_type_str[share.poolType]; + if (!minerType) { + console.error("Wrong share pool type found: " + share.poolType); + return; + } + localStats[minerType] += shares2; + if (localTimes[minerType] < share.timestamp) localTimes[minerType] = share.timestamp; + + const port = typeof(share.port) !== 'undefined' && share.port ? share.port : global.config.daemon.port; + if (port in localPortHashes) localPortHashes[port] += share.raw_shares; + else localPortHashes[port] = share.raw_shares; + + if (!shares2) return; // use virtual shares from child block mining only for global pool stats + + if (minerID in minerPortSet) { + localStats.miners[minerID] += share.raw_shares; + localStats.miners2[minerID] += shares2; + if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; + } else { + ++ localMinerCount[minerType]; + ++ localMinerCount.global; + localStats.miners[minerID] = share.raw_shares; + localStats.miners2[minerID] = shares2; + localTimes.miners[minerID] = share.timestamp; + minerSet[minerID] = 1; + minerPortSet[minerID] = port; + } + + if (minerIDWithIdentifier in minerSet) { + localStats.miners[minerIDWithIdentifier] += share.raw_shares; + localStats.miners2[minerIDWithIdentifier] += shares2; + if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; + } else { + localStats.miners[minerIDWithIdentifier] = share.raw_shares; + localStats.miners2[minerIDWithIdentifier] = shares2; + localTimes.miners[minerIDWithIdentifier] = share.timestamp; + minerSet[minerIDWithIdentifier] = 1; + } + }); debug("On " + height + " height iterated " + count + " elements"); } while (++loopBreakout <= 60 && --height >= 0 && oldestTime > identifierTime); + cursor.close(); txn.abort(); debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); From d25a8f3b102feb9e67cf4df44460be256658b25e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Apr 2021 21:41:06 +0000 Subject: [PATCH 1372/1496] Worker script debug --- lib/worker.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index adce01a0a..28283752c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -14,11 +14,10 @@ let prev_pool_workers; let stats_cache = {}; let miner_history_update_time = {}; -const pool_type_str = { - global.protos.POOLTYPE.PPLNS: 'pplns', - global.protos.POOLTYPE.PPS: 'pps', - global.protos.POOLTYPE.SOLO: 'solo', -}; +let pool_type_str = {}; +pool_type_str[global.protos.POOLTYPE.PPLNS] = 'pplns'; +pool_type_str[global.protos.POOLTYPE.PPS] = 'pps'; +pool_type_str[global.protos.POOLTYPE.SOLO] = 'solo'; function updateShareStats2(height, callback) { // This is an omni-worker to deal with all things share-stats related From 96d7605eb779ea1b630a8f1f9dc11bcf784dc77d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Apr 2021 23:23:22 +0000 Subject: [PATCH 1373/1496] Worker script debug --- lib/worker.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 28283752c..cbb516e8e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -1,6 +1,5 @@ "use strict"; -const debug = require("debug")("worker"); -const async = require("async"); +const debug = require("debug")("worker"); const sprintf = require("sprintf-js").sprintf; let cycleCount = 0; @@ -409,8 +408,6 @@ global.support.sendEmail(global.config.general.adminEmail, "Restarting worker mo updateShareStats(); // clean caches from time to time setInterval(function() { - //console.log("TODO: Investigate why missive slowdown happens unless I restart this"); - //process.exit(); console.log("Cleaning caches (" + Object.keys(stats_cache).length + " stats, " + Object.keys(miner_history_update_time).length + " histories)"); const currentTime = Date.now(); let stats_cache2 = {}; From d203346f126daf9637297f3a658b79f340ab8e0d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Apr 2021 02:37:42 +0000 Subject: [PATCH 1374/1496] Worker script debug --- lib/worker.js | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index cbb516e8e..d22443ef1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -18,6 +18,18 @@ pool_type_str[global.protos.POOLTYPE.PPLNS] = 'pplns'; pool_type_str[global.protos.POOLTYPE.PPS] = 'pps'; pool_type_str[global.protos.POOLTYPE.SOLO] = 'solo'; +let identifiers = {}; +let minerSet = {}; +let minerPortSet = {}; +let localMinerCount = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 }; +let localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; +let localPortHashes = {}; +let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; + +let prevMinerSet = {}; +let cache_updates = {}; +let portMinerCount = {}; + function updateShareStats2(height, callback) { // This is an omni-worker to deal with all things share-stats related // Time based averages are worked out on ring buffers. @@ -34,14 +46,15 @@ function updateShareStats2(height, callback) { const locTime = currentTime - (hashrate_avg_min*60*1000); const identifierTime = currentTime - (2*hashrate_avg_min*60*1000); - let identifiers = {}; - let minerSet = {}; - let minerPortSet = {}; let minerCount = 0; - let localMinerCount = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 }; - let localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; - let localPortHashes = {}; - let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; + + identifiers = {}; + minerSet = {}; + minerPortSet = {}; + localMinerCount = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 }; + localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; + localPortHashes = {}; + localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; let loopBreakout = 0; let oldestTime = currentTime; @@ -126,9 +139,9 @@ function updateShareStats2(height, callback) { txn.abort(); debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); - let prevMinerSet = global.database.getCache('minerSet'); + prevMinerSet = global.database.getCache('minerSet'); if (prevMinerSet === false) prevMinerSet = minerSet; - let cache_updates = {}; + cache_updates = {}; // pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { const hash = localStats[key] / (hashrate_avg_min*60); @@ -277,7 +290,8 @@ function updateShareStats2(height, callback) { Object.keys(identifiers).forEach(function (key) { cache_updates['identifiers:' + key] = identifiers[key]; }); - let portMinerCount = {}; + + portMinerCount = {}; for (let miner in minerPortSet) { const port = minerPortSet[miner]; if (port in portMinerCount) ++ portMinerCount[port]; From cde19d5e1707fb2d772404b926cdfccd3731c9c9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Apr 2021 02:39:31 +0000 Subject: [PATCH 1375/1496] Worker script debug --- lib/worker.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index d22443ef1..1825565b5 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -18,17 +18,17 @@ pool_type_str[global.protos.POOLTYPE.PPLNS] = 'pplns'; pool_type_str[global.protos.POOLTYPE.PPS] = 'pps'; pool_type_str[global.protos.POOLTYPE.SOLO] = 'solo'; -let identifiers = {}; -let minerSet = {}; -let minerPortSet = {}; -let localMinerCount = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 }; -let localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; +let identifiers = {}; +let minerSet = {}; +let minerPortSet = {}; +let localMinerCount = {}; +let localStats = {}; let localPortHashes = {}; -let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; +let localTimes = {}; -let prevMinerSet = {}; -let cache_updates = {}; -let portMinerCount = {}; +let prevMinerSet = {}; +let cache_updates = {}; +let portMinerCount = {}; function updateShareStats2(height, callback) { // This is an omni-worker to deal with all things share-stats related From 3dc36a9d643b7ed47c635d8ea3f3baa9b0b61122 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Apr 2021 13:27:56 +0000 Subject: [PATCH 1376/1496] Worker script debug --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 1825565b5..a1e876588 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -306,6 +306,7 @@ function updateShareStats2(height, callback) { console.error("Can't write to pool DB: " + e); global.support.sendEmail(global.config.general.adminEmail, "FYI: Pool DB is overflowed!", "Can't wite to pool DB: " + e); } + cache_updates = {}; let pool_hashrate = localStats.global / (hashrate_avg_min*60); let pool_workers = minerCount; From 670aeeffaf65f179d10968a50e79b670d6c1fa01 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Apr 2021 23:13:50 +0000 Subject: [PATCH 1377/1496] Worker script email fix --- lib/pool.js | 3 ++- lib/worker.js | 58 +++++++++++++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 15fa8be14..bf16f0b5f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -240,7 +240,7 @@ function addProxyMiner(miner) { proxyMiners[proxyMinerName].hashes = 0; console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); } else { - if (++ proxyMiners[proxyMinerName].count > global.config.pool.workerMax) { + if (++ proxyMiners[proxyMinerName].count > global.config.pool.workerMax && !miner.xmrig_proxy) { console.error(threadName + "Starting to long ban " + wallet + " miner address"); bannedBigTmpWallets[wallet] = 1; for (var [minerId2, miner2] of activeMiners) if (miner2.payout === wallet) removeMiner(miner2); @@ -787,6 +787,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.removed_miner = false; this.proxy = agent && agent.includes('xmr-node-proxy'); + this.xmrig_proxy = agent && agent.includes('xmrig-proxy'); this.id = id; this.ipAddress = ipAddress; this.pushMessage = pushMessage; diff --git a/lib/worker.js b/lib/worker.js index a1e876588..fb4accdf7 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -257,10 +257,7 @@ function updateShareStats2(height, callback) { const address_parts = miner.split(/_(.+)/); const worker = address_parts[1]; if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { - const address = address_parts[0]; - get_address_email(address, function (email) { - setTimeout(delayed_send_worker_stopped_hashing_email, 10*60*1000, miner, email, currentTime); - }); + setTimeout(delayed_send_worker_stopped_hashing_email, 10*60*1000, miner, currentTime); } } @@ -276,8 +273,9 @@ function updateShareStats2(height, callback) { const address_parts = miner.split(/_(.+)/); const worker = address_parts[1]; if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { - const address = address_parts[0]; + workers_started_hashing_time[miner] = currentTime; if (miner in workers_stopped_hashing_email_time) { + const address = address_parts[0]; get_address_email(address, function (email) { send_worker_started_hashing_email(miner, email, currentTime); }); @@ -357,6 +355,7 @@ function get_address_email(address, callback) { let currentTime = Date.now(); if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { minerEmailTime[address] = currentTime; + minerEmail[address] = null; global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { if (rows.length === 0) { delete minerEmail[address]; @@ -364,15 +363,21 @@ function get_address_email(address, callback) { } else { minerEmail[address] = rows[0].email; } - callback(minerEmail[address]); + return callback(minerEmail[address]); + }).catch(function (error) { + console.error("Can't get email address for " + address ": " + error.message); + return; }); } else if (address in minerEmail) { - callback(minerEmail[address]); + if (minerEmail[address] === null) { // not yet ready (retry again in 10 secs) + if (currentTime - minerEmailTime[address] < 5*1000) return setTimeout(get_address_email, 10*1000, address, callback); + } else { + return callback(minerEmail[address]); + } } } function send_worker_started_hashing_email(miner, email, currentTime) { - workers_started_hashing_time[miner] = currentTime; delete workers_stopped_hashing_email_time[miner]; let address_parts = miner.split(/_(.+)/); @@ -391,30 +396,33 @@ function send_worker_started_hashing_email(miner, email, currentTime) { ); } -function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { +function delayed_send_worker_stopped_hashing_email(miner, currentTime) { if (miner in workers_started_hashing_time && Date.now() - workers_started_hashing_time[miner] <= 10*60*1000) { delete workers_started_hashing_time[miner]; return; } delete workers_started_hashing_time[miner]; - workers_stopped_hashing_email_time[miner] = Date.now(); - let address_parts = miner.split(/_(.+)/); - let address = address_parts[0]; - let worker = address_parts[1]; - // toAddress, subject, body - let emailData = { - worker: worker, - timestamp: global.support.formatDate(currentTime), - poolEmailSig: global.config.general.emailSig - }; - - global.support.sendEmail(email, - sprintf(global.config.email.workerNotHashingSubject, emailData), - sprintf(global.config.email.workerNotHashingBody, emailData), - address - ); + const address_parts = miner.split(/_(.+)/); + const address = address_parts[0]; + + get_address_email(address, function (email) { + workers_stopped_hashing_email_time[miner] = Date.now(); + const worker = address_parts[1]; + + // toAddress, subject, body + const emailData = { + worker: worker, + timestamp: global.support.formatDate(currentTime), + poolEmailSig: global.config.general.emailSig + }; + global.support.sendEmail(email, + sprintf(global.config.email.workerNotHashingSubject, emailData), + sprintf(global.config.email.workerNotHashingBody, emailData), + address + ); + }); } From 96a1969bf6f68bc2139a4ce21c8e02b4c1381e6b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Apr 2021 23:16:01 +0000 Subject: [PATCH 1378/1496] Worker script email fix --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index fb4accdf7..47385c08d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -365,7 +365,7 @@ function get_address_email(address, callback) { } return callback(minerEmail[address]); }).catch(function (error) { - console.error("Can't get email address for " + address ": " + error.message); + console.error("Can't get email address for " + address + ": " + error.message); return; }); } else if (address in minerEmail) { From 35e7e03b8e8caf2b19e3c0396de63e496c2c7209 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Apr 2021 23:26:01 +0000 Subject: [PATCH 1379/1496] Worker script email fix --- lib/worker.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 47385c08d..14ddddaaf 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -257,7 +257,10 @@ function updateShareStats2(height, callback) { const address_parts = miner.split(/_(.+)/); const worker = address_parts[1]; if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { - setTimeout(delayed_send_worker_stopped_hashing_email, 10*60*1000, miner, currentTime); + if (!(miner in workers_stopped_hashing_time)) { + workers_stopped_hashing_time[miner] = currentTime; + setTimeout(delayed_send_worker_stopped_hashing_email, 10*60*1000, miner, currentTime); + } } } @@ -275,6 +278,8 @@ function updateShareStats2(height, callback) { if (typeof(worker) !== 'undefined' && !worker.includes('silent')) { workers_started_hashing_time[miner] = currentTime; if (miner in workers_stopped_hashing_email_time) { + delete workers_stopped_hashing_time[miner]; + delete workers_stopped_hashing_email_time[miner]; const address = address_parts[0]; get_address_email(address, function (email) { send_worker_started_hashing_email(miner, email, currentTime); @@ -349,6 +354,7 @@ let minerEmailTime = {}; // worker name -> time let workers_started_hashing_time = {}; +let workers_stopped_hashing_time = {}; let workers_stopped_hashing_email_time = {}; function get_address_email(address, callback) { @@ -378,8 +384,6 @@ function get_address_email(address, callback) { } function send_worker_started_hashing_email(miner, email, currentTime) { - delete workers_stopped_hashing_email_time[miner]; - let address_parts = miner.split(/_(.+)/); let address = address_parts[0]; let worker = address_parts[1]; From 55b3639a5ef3b05437019dd36dcc4a8d6d7b08da Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Apr 2021 00:18:38 +0000 Subject: [PATCH 1380/1496] Type fix --- lib/blockManager.js | 2 +- lib/local_comms.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e71951709..0fd1b6c71 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -307,7 +307,7 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, } else { if (is_store_dump && fs.existsSync("./block_share_dumps/process.sh")) { shares4dump.sort(); - shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_payed"); + shares4dump.unshift("#last_16_chars_of_xmr_address\ttimestamp\traw_share_diff\tshare_count\tshare_coin\txmr_share_diff\txmr_share_diff_paid"); const fn = "block_share_dumps/" + block_hexes[0] + ".cvs"; fs.writeFile(fn, shares4dump.join("\n"), function(err) { if (err) { diff --git a/lib/local_comms.js b/lib/local_comms.js index bc3003deb..6a96ca401 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -520,8 +520,8 @@ function Database(){ let dstBlockData = global.protos.AltBlock.decode(txn.getBinary(this.altblockDB, dstBlockId)); dstBlockData.value += srcAmount; srcBlockData.value = 0; - srcBlockData.pay_stage = "Payed by other block"; - srcBlockData.pay_status = "Will be payed by block " + dstBlockData.hash + " on " + dstBlockData.height + " height"; + srcBlockData.pay_stage = "Paid by other block"; + srcBlockData.pay_status = "Will be paid by block " + dstBlockData.hash + " on " + dstBlockData.height + " height"; srcBlockData.unlocked = true; txn.putBinary(this.altblockDB, srcBlockId, global.protos.AltBlock.encode(srcBlockData)); txn.putBinary(this.altblockDB, dstBlockId, global.protos.AltBlock.encode(dstBlockData)); From a44babfc8a874bf871ed1c9c1d527e6554664cf6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 03:26:22 +0000 Subject: [PATCH 1381/1496] Avoid dupblicate block in DB --- lib/local_comms.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 6a96ca401..d4b21d095 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -471,9 +471,16 @@ function Database(){ return callback(true); } let txn = global.database.env.beginTxn(); - while (txn.getBinary(global.database.altblockDB, blockId) !== null) { - console.error("Can't store altblock with " + blockId.toString() + " key, trying to increment it"); - ++ blockId; + let blockData2; + while ((blockData2 = txn.getBinary(global.database.altblockDB, blockId)) !== null) { + const blockDataDecoded2 = global.protos.Block.decode(blockData2); + if (blockDataDecoded2.hash === blockDataDecoded.hash) { + txn.abort(); + console.error("Can't store already stored altblock with " + blockDataDecoded.hash.toString() + " hash: " + JSON.stringify(blockDataDecoded)); + return callback(true); + } + console.error("Can't store altblock with " + blockId.toString() + " key, trying to increment it"); + ++ blockId; } txn.putBinary(global.database.altblockDB, blockId, blockData); txn.commit(); From 69fd2a5d34c965d2f56f99763d41562a8793e95c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 03:48:51 +0000 Subject: [PATCH 1382/1496] Fixed XHV reward check --- lib/coins/xmr.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a07f82c93..720792449 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -454,7 +454,10 @@ function Coin(data){ console.error(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": " + JSON.stringify(body2)); return callback(true, body.result.block_header); } - const reward = body2.result.transfer.amount; + let reward = body2.result.transfer.amount; + if (port == 17750) { + body2.result.transfers.forEach(function(transfer) { if (transfer.asset_type === "XHV") reward = transfer.amount; }); + } if (reward !== reward_check || reward == 0) { if (port == 38081 && reward < reward_check /*&& reward != 0*/) { // MSR can have uncle block reward here From aaf683ffe24c994af548f9ff9b2a442f588b7dbf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 03:51:46 +0000 Subject: [PATCH 1383/1496] Fixed XHV reward check --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index d4b21d095..143f1380b 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -473,7 +473,7 @@ function Database(){ let txn = global.database.env.beginTxn(); let blockData2; while ((blockData2 = txn.getBinary(global.database.altblockDB, blockId)) !== null) { - const blockDataDecoded2 = global.protos.Block.decode(blockData2); + const blockDataDecoded2 = global.protos.AltBlock.decode(blockData2); if (blockDataDecoded2.hash === blockDataDecoded.hash) { txn.abort(); console.error("Can't store already stored altblock with " + blockDataDecoded.hash.toString() + " hash: " + JSON.stringify(blockDataDecoded)); From f04af5ae6e39dd9c3d61c03b7e26666868cbc0fe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 04:27:12 +0000 Subject: [PATCH 1384/1496] Automated block add --- manage_scripts/altblock_add_auto.js | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 manage_scripts/altblock_add_auto.js diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js new file mode 100644 index 000000000..49d690f25 --- /dev/null +++ b/manage_scripts/altblock_add_auto.js @@ -0,0 +1,66 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.port) { + console.error("Please specify port"); + process.exit(1); +} +const port = argv.port; + +if (!argv.hash) { + console.error("Please specify hash"); + process.exit(1); +} +const hash = argv.hash; + +require("../init_mini.js").init(function() { + global.coinFuncs.getLastBlockHeader() + global.coinFuncs.getLastBlockHeader(function (err, last_block_body) { + if (err !== null){ + console.error("Can't get last block info"); + process.exit(0); + } + global.coinFuncs.getPortAnyBlockHeaderByHash(port, hash, true, function (err_header, body_header) { + if (err_header) { + console.error("Can't get block info"); + console.error("err:" + JSON.stringify(err_header)); + console.error("body:" + JSON.stringify(body_header)); + process.exit(0); + } + if (!body_header.timestamp) { + console.error("Can't get block timestamp: " + JSON.stringify(body_header)); + process.exit(0); + } + if (!body_header.difficulty) { + console.error("Can't get block difficilty: " + JSON.stringify(body_header)); + process.exit(0); + } + if (!body_header.height) { + console.error("Can't get block height: " + JSON.stringify(body_header)); + process.exit(0); + } + + global.database.storeAltBlock(body_header.timestamp, global.protos.AltBlock.encode({ + hash: hash, + difficulty: body_header.difficulty, + shares: 0, + timestamp: body_header.timestamp, + poolType: global.protos.POOLTYPE.PPLNS, + unlocked: false, + valid: true, + port: port, + height: body_header.timestamp, + anchor_height: last_block_body.height + }), function(data){ + if (!data){ + console.error("Block not stored"); + } else { + console.log("Block stored"); + } + process.exit(0); + }); + }); + }); +}); + From 561d866848cf7ce0f757c191451394a1906aad9a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 04:30:09 +0000 Subject: [PATCH 1385/1496] Automated block add --- manage_scripts/altblock_add_auto.js | 1 - 1 file changed, 1 deletion(-) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index 49d690f25..a9968919b 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -15,7 +15,6 @@ if (!argv.hash) { const hash = argv.hash; require("../init_mini.js").init(function() { - global.coinFuncs.getLastBlockHeader() global.coinFuncs.getLastBlockHeader(function (err, last_block_body) { if (err !== null){ console.error("Can't get last block info"); From a42bee62b3bd4fb663eb8d6c2048bbbdace05e92 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 04:31:24 +0000 Subject: [PATCH 1386/1496] Automated block add --- manage_scripts/altblock_add_auto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index a9968919b..0e6dc6fcd 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -55,7 +55,7 @@ require("../init_mini.js").init(function() { if (!data){ console.error("Block not stored"); } else { - console.log("Block stored"); + console.log("Block with " + port + " port and " + hash + " stored"); } process.exit(0); }); From cfc0cc763f054af309e8e1b14b613d0ee1302af5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 04:34:09 +0000 Subject: [PATCH 1387/1496] Automated block add --- manage_scripts/altblock_add_auto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index 0e6dc6fcd..d3b660f9e 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -49,7 +49,7 @@ require("../init_mini.js").init(function() { unlocked: false, valid: true, port: port, - height: body_header.timestamp, + height: body_header.height, anchor_height: last_block_body.height }), function(data){ if (!data){ From 1c2d67ad0d5d4b475492707401ad56766ad30023 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Apr 2021 04:36:39 +0000 Subject: [PATCH 1388/1496] Automated block add --- manage_scripts/altblock_add_auto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index d3b660f9e..8294641ee 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -44,7 +44,7 @@ require("../init_mini.js").init(function() { hash: hash, difficulty: body_header.difficulty, shares: 0, - timestamp: body_header.timestamp, + timestamp: body_header.timestamp * 1000, poolType: global.protos.POOLTYPE.PPLNS, unlocked: false, valid: true, From a30c97d413ca72c724b785305cca11d41c43ec9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 May 2021 15:09:49 +0000 Subject: [PATCH 1389/1496] Extra manage script --- manage_scripts/fix_negative_ex_xmr_balance.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 manage_scripts/fix_negative_ex_xmr_balance.js diff --git a/manage_scripts/fix_negative_ex_xmr_balance.js b/manage_scripts/fix_negative_ex_xmr_balance.js new file mode 100644 index 000000000..c34084c77 --- /dev/null +++ b/manage_scripts/fix_negative_ex_xmr_balance.js @@ -0,0 +1,25 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +require("../init_mini.js").init(function() { + const xmr_balance = global.database.getCache("xmr_balance"); + if (xmr_balance !== false) { + if (xmr_balance.value && xmr_balance.value > 0) { + console.error("Can't fix xmr_balance: " + JSON.stringify(xmr_balance)); + process.exit(1); + return; + } + const xmr_balance2 = { value: -xmr_balance.expected_increase, expected_increase: xmr_balance.expected_increase }; + console.log("In 10 seconds is going to change xmr_balance from " + JSON.stringify(xmr_balance) + " into " + JSON.stringify(xmr_balance2)); + setTimeout(10*1000, function() { + global.database.setCache("xmr_balance", xmr_balance2); + console.log("Done."); + process.exit(0); + }); + } else { + console.error("Key xmr_balance is not found"); + process.exit(1); + } +}); + From d4a391be570d0b1e82199b4e2a7aae013a02108c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 May 2021 15:10:56 +0000 Subject: [PATCH 1390/1496] Extra manage script --- manage_scripts/fix_negative_ex_xmr_balance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/fix_negative_ex_xmr_balance.js b/manage_scripts/fix_negative_ex_xmr_balance.js index c34084c77..d10279d52 100644 --- a/manage_scripts/fix_negative_ex_xmr_balance.js +++ b/manage_scripts/fix_negative_ex_xmr_balance.js @@ -5,7 +5,7 @@ const argv = require('minimist')(process.argv.slice(2)); require("../init_mini.js").init(function() { const xmr_balance = global.database.getCache("xmr_balance"); if (xmr_balance !== false) { - if (xmr_balance.value && xmr_balance.value > 0) { + if (!xmr_balance.value || xmr_balance.value < 0) { console.error("Can't fix xmr_balance: " + JSON.stringify(xmr_balance)); process.exit(1); return; From e967cb253e103da28fc565acb80f7933a660017a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 May 2021 15:11:54 +0000 Subject: [PATCH 1391/1496] Extra manage script --- manage_scripts/fix_negative_ex_xmr_balance.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manage_scripts/fix_negative_ex_xmr_balance.js b/manage_scripts/fix_negative_ex_xmr_balance.js index d10279d52..072acf42a 100644 --- a/manage_scripts/fix_negative_ex_xmr_balance.js +++ b/manage_scripts/fix_negative_ex_xmr_balance.js @@ -12,11 +12,11 @@ require("../init_mini.js").init(function() { } const xmr_balance2 = { value: -xmr_balance.expected_increase, expected_increase: xmr_balance.expected_increase }; console.log("In 10 seconds is going to change xmr_balance from " + JSON.stringify(xmr_balance) + " into " + JSON.stringify(xmr_balance2)); - setTimeout(10*1000, function() { + setTimeout(function() { global.database.setCache("xmr_balance", xmr_balance2); console.log("Done."); process.exit(0); - }); + }, 10*1000); } else { console.error("Key xmr_balance is not found"); process.exit(1); From 4a4169deb9a8f3762fb3c1541404975eabdeae5d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 6 May 2021 15:56:18 +0000 Subject: [PATCH 1392/1496] Added limited eth pool support --- config_example.json | 1 + lib/pool.js | 1 + 2 files changed, 2 insertions(+) diff --git a/config_example.json b/config_example.json index 74703db10..7c070264f 100644 --- a/config_example.json +++ b/config_example.json @@ -1,5 +1,6 @@ { "pool_id": 0, + "eth_pool_support": 1, "bind_ip": "127.0.0.1", "hostname": "testpool.com", "db_storage_path": "CHANGEME", diff --git a/lib/pool.js b/lib/pool.js index bf16f0b5f..b12f38239 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2247,6 +2247,7 @@ setInterval(function dump_vars() { let master_cluster_worker_id_map = {}; function getUniqueWorkerID(cb) { + if (!global.config.eth_pool_support) return cb(0, 1); global.mysql.query("SELECT id FROM pool_workers WHERE pool_id = ? AND worker_id = ?", [global.config.pool_id, process.env['WORKER_ID']]).then(function (rows) { if (rows.length === 0) { global.mysql.query("INSERT INTO pool_workers (pool_id, worker_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE id=id", [global.config.pool_id, process.env['WORKER_ID']]).then(function() { From 04caed59cb75f2cf0e95e1fae3b12bad95c202e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 14 May 2021 04:50:08 +0000 Subject: [PATCH 1393/1496] Added extra verify host --- deployment/base.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/base.sql b/deployment/base.sql index 6f8286873..2d7c5e03a 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -242,6 +242,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRVN', '0', 'float', 'RVN algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorETH', '0', 'float', 'ETH algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'verifyHost', '', 'string', 'Use to extra daemon height verify check'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('rpc', 'https', 'false', 'bool', 'Enable RPC over SSL'); From a0a35b494abda0dc5f439dd099c51a7158034e84 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 19 May 2021 14:11:08 +0000 Subject: [PATCH 1394/1496] Increased protobuf altblock value for ETH --- lib/data.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data.proto b/lib/data.proto index e72db63fa..4accb1756 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -67,7 +67,7 @@ message AltBlock { required int32 port = 8; required int32 height = 9; required int32 anchor_height = 10; - optional int64 value = 11; + optional int128 value = 11; optional int64 pay_value = 12; optional string pay_stage = 13; optional string pay_status = 14; From 15bbb8ba15d89d92029ec7de135dd8579a71911f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 19 May 2021 14:12:18 +0000 Subject: [PATCH 1395/1496] Restored protobuf altblock value for ETH --- lib/data.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/data.proto b/lib/data.proto index 4accb1756..e72db63fa 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -67,7 +67,7 @@ message AltBlock { required int32 port = 8; required int32 height = 9; required int32 anchor_height = 10; - optional int128 value = 11; + optional int64 value = 11; optional int64 pay_value = 12; optional string pay_stage = 13; optional string pay_status = 14; From 0801ddb6db30e58a6628b51f336ad619e96c9775 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 19 May 2021 14:15:47 +0000 Subject: [PATCH 1396/1496] Increased protobuf altblock value for ETH --- lib/data.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/data.proto b/lib/data.proto index e72db63fa..cc1c1ef5e 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -67,8 +67,8 @@ message AltBlock { required int32 port = 8; required int32 height = 9; required int32 anchor_height = 10; - optional int64 value = 11; - optional int64 pay_value = 12; + optional uint64 value = 11; + optional uint64 pay_value = 12; optional string pay_stage = 13; optional string pay_status = 14; optional bool pay_ready = 15; From b2a57e8f500e4fbf0bde188bd6046256a176a098 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 28 May 2021 22:54:45 +0000 Subject: [PATCH 1397/1496] Added BLOC support --- README.md | 1 + deployment/base.sql | 2 ++ lib/coins/xmr.js | 35 ++++++++++++++++++++--------------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ede17ba8f..2de8c2a41 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XTA - ```ipN5cNhm7RXAGACP4ZXki4afT3iJ1A6Ka5U4cswE6fBPDcv8JpivurBj3vu1bXwPyb8KZEGsFUYMmToFG4N9V9G72X4WpAQ8L``` * DERO - ```dERokvcrnuWH1ai1QmZQc9cgxrLwE3rX3TbhdrnLmi3BVZmf197qd5FaFqmPMp5dZ3igXfVQwUUMgTSjpVKDtUeb6DT2xp64XJ``` * CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` +* BLOC - ```abLoc5iUG4a6oAb2dqygxkS5M2uHWx16zHb9fUWMzpSEDwm6T7PSq2MLdHonWZ16CGfnJKRomq75aZyviTo6ZjHeYQMzNAEkjMg``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` diff --git a/deployment/base.sql b/deployment/base.sql index 2d7c5e03a..5de34f495 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -241,6 +241,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXMC', '0', 'float', 'XMC algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRVN', '0', 'float', 'RVN algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorETH', '0', 'float', 'ETH algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorBLOC', '0', 'float', 'BLOC algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'verifyHost', '', 'string', 'Use to extra daemon height verify check'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); @@ -305,6 +306,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9231', '', 'string', 'Address to mine to for 9231 (Equilibria) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8766', '', 'string', 'Address to mine to for 8766 (Ravencoin) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8545', '', 'string', 'Address to mine to for 8545 (Ethereum) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_2086', '', 'string', 'Address to mine to for 2086 (BLOC) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 720792449..3bbd1e5b5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -20,7 +20,7 @@ const reSRBMULTI = /SRBMiner-MULTI\/(\d+)\.(\d+)\.(\d+)/; // 0.1.5 const pool_nonce_size = 16+1; // 1 extra byte for old XMR and new TRTL daemon bugs const port2coin = { - "11181": "AEON", +// "11181": "AEON", "11898": "TRTL", "12211": "RYO", "17750": "XHV", @@ -40,13 +40,14 @@ const port2coin = { "19950": "XWP", "9231" : "XEQ", "20206": "DERO", - "18181": "XMC", +// "18181": "XMC", "16000": "CCX", "8766" : "RVN", "8545" : "ETH", + "2086" : "BLOC", }; const port2blob_num = { - "11181": 7, // AEON +// "11181": 7, // AEON "11898": 2, // TRTL "12211": 4, // RYO "17750": 11, // XHV @@ -65,15 +66,16 @@ const port2blob_num = { "33124": 9, // XTNC "19950": 8, // XWP "9231" : 5, // XEQ - "18181": 0, // XMC +// "18181": 0, // XMC "16000": 0, // CCX "20206": 100, // DERO "8766" : 101, // RVN "8545" : 102, // ETH + "2086" : 2, // BLOC }; const port2algo = { - "11181": "k12", // Aeon +// "11181": "k12", // Aeon "11898": "argon2/chukwav2", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD @@ -93,10 +95,11 @@ const port2algo = { "48782": "cn/r", // Lethean "9231" : "cn/gpu", // XEQ "20206": "astrobwt", // DERO - "18181": "cn/0", // XMC +// "18181": "cn/0", // XMC "16000": "cn/gpu", // CCX "8766" : "kawpow", // RVN "8545" : "ethash", // ETH + "2086" : "cn-heavy/xhv", // BLOC }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -416,7 +419,7 @@ function Coin(data){ }); }); }); - } else if (port == 13007 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { + } else if (port == 13007 || port == 2086 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || (is_our_block && port == 20206 && body.result.block_header.depth < 100) // DERO can change block reward overtime? @@ -846,9 +849,9 @@ function Coin(data){ if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; - if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = algos_perf["cn-heavy/xhv"]; + if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = coin_perf["BLOC"] = algos_perf["cn-heavy/xhv"]; - if ("k12" in algos_perf) coin_perf["AEON"] = algos_perf["k12"]; + //if ("k12" in algos_perf) coin_perf["AEON"] = algos_perf["k12"]; if ("cn-pico" in algos_perf) coin_perf["IRD"] = algos_perf["cn-pico"]; else if ("cn-pico/trtl" in algos_perf) coin_perf["IRD"] = algos_perf["cn-pico/trtl"]; @@ -862,7 +865,7 @@ function Coin(data){ if ("astrobwt" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt"]; - if ("cn/0" in algos_perf) coin_perf["XMC"] = algos_perf["cn/0"]; + //if ("cn/0" in algos_perf) coin_perf["XMC"] = algos_perf["cn/0"]; if ("argon2/chukwav2" in algos_perf) coin_perf["TRTL"] = algos_perf["argon2/chukwav2"]; else if ("chukwav2" in algos_perf) coin_perf["TRTL"] = algos_perf["chukwav2"]; @@ -889,17 +892,18 @@ function Coin(data){ this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { + case 2086: return multiHashing.cryptonight_heavy(convertedBlob, 1); // BLOC case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ - case 11181: return multiHashing.k12(convertedBlob); // Aeon + //case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium case 16000: return multiHashing.cryptonight(convertedBlob, 11); // CCX case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR - case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC + //case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa @@ -935,8 +939,8 @@ function Coin(data){ case 48782: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "height": blockTemplate.height }; break; - case 11181: - return cb(this.slowHash(convertedBlob, blockTemplate)); // AEON K12 is too fast + //case 11181: + // return cb(this.slowHash(convertedBlob, blockTemplate)); // AEON K12 is too fast default: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex') }; } @@ -990,10 +994,11 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { + case 2086: return "forknote2"; // BLOC case 8545: return "eth"; // ETH case 8766: return "raven"; // RVN case 9231 : return "cryptonote_loki"; // XEQ - case 11181: return "aeon"; // Aeon + //case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO From caf694de2d55d02334e5383d958d75314c406ead Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 29 May 2021 02:30:29 +0000 Subject: [PATCH 1398/1496] Added BLOC support --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3bbd1e5b5..5e66e8e29 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -71,7 +71,7 @@ const port2blob_num = { "20206": 100, // DERO "8766" : 101, // RVN "8545" : 102, // ETH - "2086" : 2, // BLOC + "2086" : 1, // BLOC }; const port2algo = { @@ -994,7 +994,7 @@ function Coin(data){ this.blobTypeStr = function(port, version) { switch (port) { - case 2086: return "forknote2"; // BLOC + case 2086: return "forknote1"; // BLOC case 8545: return "eth"; // ETH case 8766: return "raven"; // RVN case 9231 : return "cryptonote_loki"; // XEQ From 7a5e6ee4099dc200f4ee8bd2b10e185c4c9b695b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 May 2021 21:02:11 +0000 Subject: [PATCH 1399/1496] Added block payment grouping --- lib/blockManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 0fd1b6c71..121079c8e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -477,8 +477,9 @@ function altblockUnlocker(altblockUnlockerCB) { const is_pplns_block = block.poolType == global.protos.POOLTYPE.PPLNS; if (is_pplns_block && !(block.hash in payReadyBlockHashCalc) && block.pay_ready !== true) { if (block.value) { - if (!(block.anchor_height in preCalcAnchorBlockHashes)) preCalcAnchorBlockHashes[block.anchor_height] = []; - preCalcAnchorBlockHashes[block.anchor_height].push(block.hash); + const anchor_height = block.anchor_height - (block.anchor_height % global.config.payout.anchorRound); + if (!(anchor_height in preCalcAnchorBlockHashes)) preCalcAnchorBlockHashes[anchor_height] = []; + preCalcAnchorBlockHashes[anchor_height].push(block.hash); } else global.support.sendEmail(global.config.general.adminEmail, "FYI: blockManager saw zero value locked block", "Hello,\r\nThe blockManager saw zero value locked block " + block.hash.toString('hex') ); From b59b5d2089c121b18aec5579d709c8c2f83175e7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 30 May 2021 21:02:15 +0000 Subject: [PATCH 1400/1496] Added block payment grouping --- deployment/base.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/base.sql b/deployment/base.sql index 5de34f495..142d87b8a 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -263,6 +263,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'poolDevDonation', '3', 'float', 'Donation to pool developer'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'denom', '.000001', 'float', 'Minimum balance that will be paid out to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'blocksRequired', '30', 'int', 'Blocks required to validate a payout before it''s performed.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'anchorRound', '1', 'int', 'Round anchor height to group payment block pre-calc better. 1 - no round, 2 - round to every even block, 3 - round to every 3-rd block, etc.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'sigDivisor', '1000000000000', 'int', 'Divisor for turning coin into human readable amounts '); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feesForTXN', '10', 'int', 'Amount of XMR that is left from the fees to pay miner fees.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'maxTxnValue', '250', 'int', 'Maximum amount of XMR to send in a single transaction'); From ecc65f5d37deda5856c5af5be684524a4efaa4f9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 16:33:55 +0000 Subject: [PATCH 1401/1496] LMDB DB rescue --- manage_scripts/mdb_copy.js | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 manage_scripts/mdb_copy.js diff --git a/manage_scripts/mdb_copy.js b/manage_scripts/mdb_copy.js new file mode 100644 index 000000000..754f6cc3c --- /dev/null +++ b/manage_scripts/mdb_copy.js @@ -0,0 +1,83 @@ +"use strict"; + +const lmdb = require('node-lmdb'); + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.dir) { + console.error("Please specify output lmdb dir"); + process.exit(1); +} + +if (!argv.size) { + console.error("Please specify output lmdb size in GB"); + process.exit(1); +} + +require("../init_mini.js").init(function() { + let env2 = new this.lmdb.Env(); + env2.open({ + path: argv.dir, + maxDbs: 10, + mapSize: argv.size * 1024 * 1024 * 1024, + useWritemap: true, + maxReaders: 512 + }); + let shareDB2 = this.env.openDbi({ + name: 'shares', + create: true, + dupSort: true, + dupFixed: false, + integerDup: true, + integerKey: true, + keyIsUint32: true + }); + let blockDB2 = this.env.openDbi({ + name: 'blocks', + create: true, + integerKey: true, + keyIsUint32: true + }); + let altblockDB2 = this.env.openDbi({ + name: 'altblocks', + create: true, + integerKey: true, + keyIsUint32: true + }); + let cacheDB2 = this.env.openDbi({ + name: 'cache', + create: true + }); + + console.log("Copying blocks"); + { + let txn = global.database.env.beginTxn({readOnly: true}); + let txn2 = env2.beginTxn(); + let cursor = new global.database.lmdb.Cursor(txn, global.database.blockDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentBinary(function(key, data) { + txn2.putBinary(global.database.blockDB, key, data); + }); + } + cursor.close(); + txn.commit(); + txn2.commit(); + } + + console.log("Copying altblocks"); + { let txn = global.database.env.beginTxn({readOnly: true}); + let txn2 = env2.beginTxn(); + let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentBinary(function(key, data) { + txn2.putBinary(global.database.altblockDB, key, data); + }); + } + cursor.close(); + txn.commit(); + txn2.commit(); + } + + console.log("DONE"); + process.exit(0); +}); From 22c54d877d852c769daaa3deedde8dc930b18e51 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 16:37:04 +0000 Subject: [PATCH 1402/1496] LMDB DB rescue --- manage_scripts/mdb_copy.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/manage_scripts/mdb_copy.js b/manage_scripts/mdb_copy.js index 754f6cc3c..6607680a5 100644 --- a/manage_scripts/mdb_copy.js +++ b/manage_scripts/mdb_copy.js @@ -15,7 +15,7 @@ if (!argv.size) { } require("../init_mini.js").init(function() { - let env2 = new this.lmdb.Env(); + let env2 = new lmdb.Env(); env2.open({ path: argv.dir, maxDbs: 10, @@ -23,7 +23,7 @@ require("../init_mini.js").init(function() { useWritemap: true, maxReaders: 512 }); - let shareDB2 = this.env.openDbi({ + let shareDB2 = env2.openDbi({ name: 'shares', create: true, dupSort: true, @@ -32,19 +32,19 @@ require("../init_mini.js").init(function() { integerKey: true, keyIsUint32: true }); - let blockDB2 = this.env.openDbi({ + let blockDB2 = env2.openDbi({ name: 'blocks', create: true, integerKey: true, keyIsUint32: true }); - let altblockDB2 = this.env.openDbi({ + let altblockDB2 = env2.openDbi({ name: 'altblocks', create: true, integerKey: true, keyIsUint32: true }); - let cacheDB2 = this.env.openDbi({ + let cacheDB2 = env2.openDbi({ name: 'cache', create: true }); @@ -78,6 +78,7 @@ require("../init_mini.js").init(function() { txn2.commit(); } + env2.close(); console.log("DONE"); process.exit(0); }); From 01ac77f5fd69d81c7f83aab4a3cf9517afef36bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 16:43:02 +0000 Subject: [PATCH 1403/1496] LMDB DB rescue --- manage_scripts/mdb_copy.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/manage_scripts/mdb_copy.js b/manage_scripts/mdb_copy.js index 6607680a5..9ab77bc64 100644 --- a/manage_scripts/mdb_copy.js +++ b/manage_scripts/mdb_copy.js @@ -56,7 +56,7 @@ require("../init_mini.js").init(function() { let cursor = new global.database.lmdb.Cursor(txn, global.database.blockDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentBinary(function(key, data) { - txn2.putBinary(global.database.blockDB, key, data); + txn2.putBinary(blockDB2, key, data); }); } cursor.close(); @@ -70,7 +70,7 @@ require("../init_mini.js").init(function() { let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentBinary(function(key, data) { - txn2.putBinary(global.database.altblockDB, key, data); + txn2.putBinary(altblockDB2, key, data); }); } cursor.close(); @@ -78,6 +78,21 @@ require("../init_mini.js").init(function() { txn2.commit(); } + console.log("Copying shares"); + { let txn = global.database.env.beginTxn({readOnly: true}); + let txn2 = env2.beginTxn(); + let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentBinary(function(key, data) { + txn2.putBinary(shareDB2, key, data); + }); + } + cursor.close(); + txn.commit(); + txn2.commit(); + } + + env2.close(); console.log("DONE"); process.exit(0); From e128e9bc1e034b58fcac08b848251bd414a1afd5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 16:44:00 +0000 Subject: [PATCH 1404/1496] LMDB DB rescue --- manage_scripts/mdb_copy.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/manage_scripts/mdb_copy.js b/manage_scripts/mdb_copy.js index 9ab77bc64..5a7ba72d1 100644 --- a/manage_scripts/mdb_copy.js +++ b/manage_scripts/mdb_copy.js @@ -92,6 +92,21 @@ require("../init_mini.js").init(function() { txn2.commit(); } + console.log("Copying cache"); + { let txn = global.database.env.beginTxn({readOnly: true}); + let txn2 = env2.beginTxn(); + let cursor = new global.database.lmdb.Cursor(txn, global.database.cacheDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentBinary(function(key, data) { + txn2.putBinary(cacheDB2, key, data); + }); + } + cursor.close(); + txn.commit(); + txn2.commit(); + } + + env2.close(); console.log("DONE"); From 263a0adf289ac0908a364b11eb383ddfbb36267c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 16:47:23 +0000 Subject: [PATCH 1405/1496] LMDB DB rescue --- manage_scripts/mdb_copy.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/manage_scripts/mdb_copy.js b/manage_scripts/mdb_copy.js index 5a7ba72d1..64c12d3b1 100644 --- a/manage_scripts/mdb_copy.js +++ b/manage_scripts/mdb_copy.js @@ -1,6 +1,7 @@ "use strict"; const lmdb = require('node-lmdb'); +const fs = require('fs'); const argv = require('minimist')(process.argv.slice(2)); @@ -9,6 +10,11 @@ if (!argv.dir) { process.exit(1); } +if (fs.existsSync(argv.dir + "/data.mdb")) { + console.error("Please specify empty output lmdb dir"); + process.exit(1); +} + if (!argv.size) { console.error("Please specify output lmdb size in GB"); process.exit(1); From ac9d60048cd589b6bf1b3d8a5aef8f457f9f33c5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 19:59:11 +0000 Subject: [PATCH 1406/1496] Improved storing block precalc info --- lib/blockManager.js | 61 ++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 121079c8e..210c4ec51 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -14,16 +14,26 @@ let paymentInProgress = false; let balanceIDCache = {}; let createBlockBalanceQueue = async.queue(function (task, callback) { - global.mysql.query("REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES (?, ?, ?, ?)", [task.hex, task.payment_address, task.payment_id, task.amount]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || (result.affectedRows != 1 && result.affectedRows != 2)) { + let sqlq; + let sqlp = []; + task.hexes.forEach(function(block_hex) { + if (!sqlq) sqlq = "REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES (?, ?, ?, ?)"; + else sqlq += ", (?, ?, ?, ?)"; + sqlp.push(block_hex); + sqlp.push(task.payment_address); + sqlp.push(task.payment_id); + sqlp.push(task.amount); + }); + global.mysql.query(sqlq, sqlp).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows < task.hexes.length) { console.error(JSON.stringify(result)); - console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); + console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + JSON.stringify(task.hexes) + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); return callback(false); } return callback(true); }).catch(function (err) { console.error(err); - console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + task.hex + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); + console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + JSON.stringify(task.hexes) + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); return callback(false); }); }, 1); @@ -336,29 +346,28 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, let add_count = 0; - block_hexes.forEach(function(block_hex) { - Object.keys(paymentData).forEach(function (key) { - const payment = paymentData[key]; - if (payment.amount) { - const paymentData2 = { - pool_type: 'pplns', - payment_address: payment.payment_address, - payment_id: payment.payment_id, - bitcoin: 0, - amount: payment.amount / pay_window, - hex: block_hex, - }; - ++ add_count; - createBlockBalanceQueue.push(paymentData2, function (status) { - if (status === false) is_ok = false; - if (--add_count == 0) { - is_pay_done = true; - if (is_dump_done) return done_callback(is_ok); - } - }); - } - }); + Object.keys(paymentData).forEach(function (key) { + const payment = paymentData[key]; + if (payment.amount) { + const paymentData2 = { + pool_type: 'pplns', + payment_address: payment.payment_address, + payment_id: payment.payment_id, + bitcoin: 0, + amount: payment.amount / pay_window, + hexes: block_hexes, + }; + ++ add_count; + createBlockBalanceQueue.push(paymentData2, function (status) { + if (status === false) is_ok = false; + if (--add_count == 0) { + is_pay_done = true; + if (is_dump_done) return done_callback(is_ok); + } + }); + } }); + console.log("PPLNS pre-payout cycle complete on block: " + block_height + " Payout Percentage: " + (totalPayments / pay_window) * 100 + "% (precisely " + totalPayments + " / " + pay_window + ")"); if (is_need_correction) { console.warn("(This PPLNS payout cycle complete on block was corrected: " + block_height + " Payout Percentage: " + (totalPayments / default_window) * 100 + "% (precisely " + totalPayments + " / " + default_window + "))"); From 87875615c8d76837283fe2698e7147376fdd4cb5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 20:21:34 +0000 Subject: [PATCH 1407/1496] Improved storing block precalc info --- lib/blockManager.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 210c4ec51..9065f0a28 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -14,26 +14,21 @@ let paymentInProgress = false; let balanceIDCache = {}; let createBlockBalanceQueue = async.queue(function (task, callback) { - let sqlq; + const sqlq = "REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES ?"; let sqlp = []; task.hexes.forEach(function(block_hex) { - if (!sqlq) sqlq = "REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES (?, ?, ?, ?)"; - else sqlq += ", (?, ?, ?, ?)"; - sqlp.push(block_hex); - sqlp.push(task.payment_address); - sqlp.push(task.payment_id); - sqlp.push(task.amount); + sqlp.push([block_hex, task.payment_address, task.payment_id, task.amount]); }); global.mysql.query(sqlq, sqlp).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows < task.hexes.length) { console.error(JSON.stringify(result)); - console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + JSON.stringify(task.hexes) + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); + console.error("Can't do SQL block balance replace: " + sqlq + " with " + JSON.stringify(sqlp)); return callback(false); } return callback(true); }).catch(function (err) { console.error(err); - console.error("Can't do SQL block balance replace: REPLACE INTO block_balance (" + JSON.stringify(task.hexes) + ", " + task.payment_address + ", " + task.payment_id + ", " + task.amount + ");"); + console.error("Can't do SQL block balance replace: " + sqlq + " with " + JSON.stringify(sqlp)); return callback(false); }); }, 1); From afb4187f448da8f868c53315c802fd06fda64e45 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 20:45:11 +0000 Subject: [PATCH 1408/1496] Improved storing block precalc info --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 9065f0a28..26c030873 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -19,7 +19,7 @@ let createBlockBalanceQueue = async.queue(function (task, callback) { task.hexes.forEach(function(block_hex) { sqlp.push([block_hex, task.payment_address, task.payment_id, task.amount]); }); - global.mysql.query(sqlq, sqlp).then(function (result) { + global.mysql.query(sqlq, [sqlp]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows < task.hexes.length) { console.error(JSON.stringify(result)); console.error("Can't do SQL block balance replace: " + sqlq + " with " + JSON.stringify(sqlp)); From fbf85fdaa80aec39c7d7a21e6b3343a6d55250c9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 20:58:37 +0000 Subject: [PATCH 1409/1496] Improved storing block precalc info --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 26c030873..77dbad0c9 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -14,7 +14,7 @@ let paymentInProgress = false; let balanceIDCache = {}; let createBlockBalanceQueue = async.queue(function (task, callback) { - const sqlq = "REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES ?"; + const sqlq = "INSERT INTO block_balance (hex, payment_address, payment_id, amount) VALUES ?"; let sqlp = []; task.hexes.forEach(function(block_hex) { sqlp.push([block_hex, task.payment_address, task.payment_id, task.amount]); From 8893a2297aeb3fc83083e219abb580c2c657203c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 21:00:16 +0000 Subject: [PATCH 1410/1496] Improved storing block precalc info --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 77dbad0c9..9c46a4a81 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -20,7 +20,7 @@ let createBlockBalanceQueue = async.queue(function (task, callback) { sqlp.push([block_hex, task.payment_address, task.payment_id, task.amount]); }); global.mysql.query(sqlq, [sqlp]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows < task.hexes.length) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != task.hexes.length) { console.error(JSON.stringify(result)); console.error("Can't do SQL block balance replace: " + sqlq + " with " + JSON.stringify(sqlp)); return callback(false); From cf1fadc19bcec552429b44d7f8001351f7d6911f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 Jun 2021 21:43:52 +0000 Subject: [PATCH 1411/1496] Improved storing block precalc info --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 9c46a4a81..26c030873 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -14,13 +14,13 @@ let paymentInProgress = false; let balanceIDCache = {}; let createBlockBalanceQueue = async.queue(function (task, callback) { - const sqlq = "INSERT INTO block_balance (hex, payment_address, payment_id, amount) VALUES ?"; + const sqlq = "REPLACE INTO block_balance (hex, payment_address, payment_id, amount) VALUES ?"; let sqlp = []; task.hexes.forEach(function(block_hex) { sqlp.push([block_hex, task.payment_address, task.payment_id, task.amount]); }); global.mysql.query(sqlq, [sqlp]).then(function (result) { - if (!result.hasOwnProperty("affectedRows") || result.affectedRows != task.hexes.length) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows < task.hexes.length) { console.error(JSON.stringify(result)); console.error("Can't do SQL block balance replace: " + sqlq + " with " + JSON.stringify(sqlp)); return callback(false); From 3b904fadb0ecf79443decfb5b540edc94521b889 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 Jun 2021 18:49:37 +0000 Subject: [PATCH 1412/1496] Fixed DERO block processing' --- lib/coins/xmr.js | 4 +--- lib/local_comms.js | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5e66e8e29..112dc83c0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -421,9 +421,7 @@ function Coin(data){ }); } else if (port == 13007 || port == 2086 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { - if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') || - (is_our_block && port == 20206 && body.result.block_header.depth < 100) // DERO can change block reward overtime? - ) { + if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') ) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } diff --git a/lib/local_comms.js b/lib/local_comms.js index 143f1380b..daa9bc248 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -440,6 +440,10 @@ function Database(){ } } } + if (blockDataDecoded.port == 20206 && header.depth < 50) { + setTimeout(function () { return callback(false) }, 30*1000); + return; + } if (err || typeof(header) === 'undefined' || !header || !header.reward) { // bad block and not orphan if (blockDataDecoded.hash in badBlocks) { console.error("Invalidating " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); From d6f15b5f505f6b817a06dac47336492f5e32c594 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 Jun 2021 18:56:55 +0000 Subject: [PATCH 1413/1496] Fixed DERO block processing --- lib/local_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index daa9bc248..b6f1f9341 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -441,6 +441,7 @@ function Database(){ } } if (blockDataDecoded.port == 20206 && header.depth < 50) { + console.log("Delaying " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); setTimeout(function () { return callback(false) }, 30*1000); return; } From b97c2b5b06cf8107611225e1a47aa1144434c1d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 Jun 2021 19:13:48 +0000 Subject: [PATCH 1414/1496] Fixed DERO block processing --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index b6f1f9341..361d61812 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -440,7 +440,7 @@ function Database(){ } } } - if (blockDataDecoded.port == 20206 && header.depth < 50) { + if (blockDataDecoded.port == 20206 && header.depth < 30) { console.log("Delaying " + blockDataDecoded.port + " port block hash " + blockDataDecoded.hash); setTimeout(function () { return callback(false) }, 30*1000); return; From 139d131608c711de8d4081fa7e640fcbae93a43a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 13 Jul 2021 18:49:13 +0000 Subject: [PATCH 1415/1496] More even block payments --- lib/blockManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 26c030873..9dfd77fe9 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -523,8 +523,9 @@ function altblockUnlocker(altblockUnlockerCB) { }, function() { console.log("Running altblock pre-payment for " + Object.keys(preCalcAnchorBlockHashes).length + " anchor heights"); + let maxPreCount = 10; async.eachSeries(Object.keys(preCalcAnchorBlockHashes), function(anchor_height, next) { - global.coinFuncs.getBlockHeaderByID(anchor_height, function (anchor_err, anchor_header) { + if (--maxPreCount > 0) global.coinFuncs.getBlockHeaderByID(anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ const block_hexes = preCalcAnchorBlockHashes[anchor_height]; block_hexes.forEach(function (block_hex) { From 245dab3d3f8e1374a92512539306680c843b551b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 13 Jul 2021 19:00:34 +0000 Subject: [PATCH 1416/1496] More even block payments --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 9dfd77fe9..6473d6716 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -544,7 +544,7 @@ function altblockUnlocker(altblockUnlockerCB) { console.error("Can't get correct anchor block header by height " + anchor_height); return next(); } - }); + }); else return next(); }, function() { for (let port in blockHeightWait) { console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); From a553e6120e21b5b74c23530052cda0bc8edd67b3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 13 Jul 2021 19:01:47 +0000 Subject: [PATCH 1417/1496] More even block payments --- lib/blockManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 6473d6716..9586d23a2 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -525,7 +525,8 @@ function altblockUnlocker(altblockUnlockerCB) { console.log("Running altblock pre-payment for " + Object.keys(preCalcAnchorBlockHashes).length + " anchor heights"); let maxPreCount = 10; async.eachSeries(Object.keys(preCalcAnchorBlockHashes), function(anchor_height, next) { - if (--maxPreCount > 0) global.coinFuncs.getBlockHeaderByID(anchor_height, function (anchor_err, anchor_header) { + if (--maxPreCount < 0) return next(); + global.coinFuncs.getBlockHeaderByID(anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ const block_hexes = preCalcAnchorBlockHashes[anchor_height]; block_hexes.forEach(function (block_hex) { @@ -544,7 +545,7 @@ function altblockUnlocker(altblockUnlockerCB) { console.error("Can't get correct anchor block header by height " + anchor_height); return next(); } - }); else return next(); + }); }, function() { for (let port in blockHeightWait) { console.log("Waiting for altblock with " + port + " port and " + blockHeightWait[port].join(", ") + " height(s) pay value"); From 0a13d4ad84d200621756b68c8d4511c822e4e359 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Jul 2021 20:29:13 +0000 Subject: [PATCH 1418/1496] ERG support (draft) --- README.md | 17 ++++++----- deployment/base.sql | 2 ++ deployment/deploy.bash | 4 +-- deployment/deploy_test.bash | 4 +-- deployment/leaf.bash | 4 +-- lib/api.js | 4 +-- lib/coins/xmr.js | 60 ++++++++++++++++++++++++++++++++----- lib/pool.js | 4 +-- package.json | 5 ++-- 9 files changed, 76 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 2de8c2a41..133a4b915 100644 --- a/README.md +++ b/README.md @@ -60,14 +60,14 @@ Deployment via Installer ```shell cd ~/nodejs-pool/ -pm2 start init.js --name=blockManager --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=blockManager -pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=worker -pm2 start init.js --name=pool_stats --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=pool_stats -pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" --no-autorestart -- --module=payments -pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=remoteShare -pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=longRunner -pm2 start init.js --name=pool --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=pool -pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=api +pm2 start init.js --name=blockManager --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=blockManager +pm2 start init.js --name=worker --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=worker +pm2 start init.js --name=pool_stats --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=pool_stats +pm2 start init.js --name=payments --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" --no-autorestart -- --module=payments +pm2 start init.js --name=remoteShare --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=remoteShare +pm2 start init.js --name=longRunner --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=longRunner +pm2 start init.js --name=pool --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=pool +pm2 start init.js --name=api --kill-timeout 10000 --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=api pm2 restart api ``` @@ -281,6 +281,7 @@ If you'd like to make a one time donation, the addresses are as follows: * CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` * BLOC - ```abLoc5iUG4a6oAb2dqygxkS5M2uHWx16zHb9fUWMzpSEDwm6T7PSq2MLdHonWZ16CGfnJKRomq75aZyviTo6ZjHeYQMzNAEkjMg``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` +* ERG - ```9fe533kUzAE57YfPP6o3nzsYMKN2W2uCxvg8KG8Vn5DDeJGetRw``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index 142d87b8a..945811e74 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -242,6 +242,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRVN', '0', 'float', 'RVN algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorETH', '0', 'float', 'ETH algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorBLOC', '0', 'float', 'BLOC algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorERG', '0', 'float', 'ERG algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'verifyHost', '', 'string', 'Use to extra daemon height verify check'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); @@ -308,6 +309,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8766', '', 'string', 'Address to mine to for 8766 (Ravencoin) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8545', '', 'string', 'Address to mine to for 8545 (Ethereum) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_2086', '', 'string', 'Address to mine to for 2086 (BLOC) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9053', '', 'string', 'Address to mine to for 9053 (ERG) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 904f35869..4de6a0456 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -31,8 +31,8 @@ sudo systemctl enable monero sudo systemctl start monero curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash source ~/.nvm/nvm.sh -nvm install v14.16.0 -nvm alias default v14.16.0 +nvm install v14.17.3 +nvm alias default v14.17.3 cd ~/nodejs-pool npm install npm install -g pm2 diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index c1d93847c..ed1d85017 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -30,8 +30,8 @@ sudo systemctl enable monero sudo systemctl start monero curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash source ~/.nvm/nvm.sh -nvm install v8.11.3 -nvm alias default v8.11.3 +nvm install v14.17.3 +nvm alias default v14.17.3 cd ~/nodejs-pool npm install npm install -g pm2 diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 0a0503c13..af87093f7 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -26,8 +26,8 @@ sudo systemctl enable monero sudo systemctl start monero curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash source ~/.nvm/nvm.sh -nvm install v8.11.3 -nvm alias default v8.11.3 +nvm install v14.17.3 +nvm alias default v14.17.3 cd ~/nodejs-pool npm install npm install -g pm2 diff --git a/lib/api.js b/lib/api.js index 75913646f..b4e3c5d53 100644 --- a/lib/api.js +++ b/lib/api.js @@ -14,7 +14,7 @@ const jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens const crypto = require('crypto'); const cors = require('cors'); -let addressBase58Prefix = cnUtil.address_decode(new Buffer(global.config.pool.address)); +let addressBase58Prefix = cnUtil.address_decode(Buffer.from(global.config.pool.address)); let threadName = ""; if (cluster.isMaster) { @@ -194,7 +194,7 @@ app.get('/config', cache('5 minutes'), function (req, res) { // Pool APIs app.get('/pool/address_type/:address', cache('10 seconds'), function (req, res) { let address = req.params.address; - if (addressBase58Prefix === cnUtil.address_decode(new Buffer(address))) { + if (addressBase58Prefix === cnUtil.address_decode(Buffer.from(address))) { res.json({valid: true, address_type: global.config.general.coinCode}); } else if (btcValidator.validate(this.address) && global.config.general.allowBitcoin) { res.json({valid: true, address_type: 'BTC'}); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 112dc83c0..4b333c8c9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -45,6 +45,7 @@ const port2coin = { "8766" : "RVN", "8545" : "ETH", "2086" : "BLOC", + "9053" : "ERG", }; const port2blob_num = { // "11181": 7, // AEON @@ -72,6 +73,7 @@ const port2blob_num = { "8766" : 101, // RVN "8545" : 102, // ETH "2086" : 1, // BLOC + "9053" : 103, // ERG }; const port2algo = { @@ -100,6 +102,7 @@ const port2algo = { "8766" : "kawpow", // RVN "8545" : "ethash", // ETH "2086" : "cn-heavy/xhv", // BLOC + "9053" : "autolykos2", // ERG }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -254,10 +257,19 @@ function calcEthReward(block, tx_reciepts) { return (ETH_BASE_REWARD + ETH_BASE_REWARD * (block.uncles.length / 32)) * ETH_MULTIPLIER + fee; } +function calcErgReward(block_tx) { + let reward = 0; + block_tx.forEach(function(tx) { + if (tx.dataInputs.length) continue; + reward += outputs[outputs.length-1].value; + }); + return reward; +} + function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; - let instanceId = new Buffer(4); + let instanceId = Buffer.alloc(4); instanceId.writeUInt32LE( (((global.config.pool_id % (1<<10)) << 22) + (process.pid % (1<<22))) >>> 0 ); console.log("Generated instanceId: " + instanceId.toString('hex')); this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address @@ -339,6 +351,15 @@ function Coin(data){ return callback(null, body.result); }); }); + } else if (port == 9053) { + let _this = this; + global.support.rpcPortDaemon2(port, 'blocks/at/' + blockId, null, function (body) { + if (!body || !(body instanceof Array) || body.length != 1) { + console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); + return callback(true, body); + } + return _this.getPortAnyBlockHeaderByHash(port, body[0], false, callback); + }); } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { if (body && body.hasOwnProperty('result')) { @@ -419,6 +440,15 @@ function Coin(data){ }); }); }); + } else if (port == 9053) { + global.support.rpcPortDaemon2(port, 'blocks/' + blockHash, null, function (body) { + if (!body || !body.header) { + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); + return callback(true, body); + } + body.header.reward = calcErgReward(body.blockTransactions.transactions); + return callback(null, body.header); + }); } else if (port == 13007 || port == 2086 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if ( typeof(body) === 'undefined' || !body.hasOwnProperty('result') ) { @@ -518,6 +548,12 @@ function Coin(data){ const bt = cnUtil.EthBlockTemplate(body.result); return callback(null, { hash: bt.hash, timestamp: Date.now() / 1000, difficulty: bt.difficulty, height: bt.height, seed_hash: bt.seed_hash }); }); + } else if (port == 9053) { + global.support.rpcPortDaemon2(port, 'mining/candidate', null, function(body) { + if (!body || !body.pk) return callback(true, body); + const bt = cnUtil.ErgBlockTemplate(body); + return callback(null, { hash: bt.hash, timestamp: Date.now() / 1000, difficulty: bt.difficulty, height: bt.height, hash2: bt.hash2 }); + }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ @@ -559,6 +595,12 @@ function Coin(data){ return callback(body && body.result ? cnUtil.EthBlockTemplate(body.result) : null); }); + } else if (port == 9053) { + global.support.rpcPortDaemon2(port, 'mining/candidate', null, function(body) { + return callback(body && body.pk ? cnUtil.ErgBlockTemplate(body) : null); + }); + + } else { global.support.rpcPortDaemon(port, 'getblocktemplate', { reserve_size: port in mm_port_set ? mm_nonce_size + pool_nonce_size : pool_nonce_size, @@ -578,7 +620,7 @@ function Coin(data){ this.validatePlainAddress = function(address){ // This function should be able to be called from the async library, as we need to BLOCK ever so slightly to verify the address. - address = new Buffer(address); + address = Buffer.from(address); let code = cnUtil.address_decode(address); return code === this.prefix || code === this.subPrefix; }; @@ -586,7 +628,7 @@ function Coin(data){ this.validateAddress = function(address){ if (this.validatePlainAddress(address)) return true; // This function should be able to be called from the async library, as we need to BLOCK ever so slightly to verify the address. - address = new Buffer(address); + address = Buffer.from(address); return cnUtil.address_decode_integrated(address) === this.intPrefix; }; @@ -652,14 +694,14 @@ function Coin(data){ blob_type_num, params.pow ); } else if (global.coinFuncs.blobTypeDero(blob_type_num)) { - return cnUtil.constructNewDeroBlob(blockTemplate, new Buffer(params.nonce, 'hex')); + return cnUtil.constructNewDeroBlob(blockTemplate, Buffer.from(params.nonce, 'hex')); } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { return cnUtil.constructNewRavenBlob(blockTemplate, bignum(params.nonce, 16).toBuffer({endian: 'little', size: 8}), bignum(params.mixhash, 16).toBuffer({endian: 'little', size: 32}) ); } else { - return cnUtil.construct_block_blob(blockTemplate, new Buffer(params.nonce, 'hex'), blob_type_num); + return cnUtil.construct_block_blob(blockTemplate, Buffer.from(params.nonce, 'hex'), blob_type_num); } }; @@ -730,7 +772,7 @@ function Coin(data){ this.idHash = crypto.createHash('md5').update(blob).digest('hex'); // Set this.buffer to the binary decoded version of the BT blob - this.buffer = new Buffer(blob, 'hex'); + this.buffer = Buffer.from(blob, 'hex'); this.block_version = this.buffer[0]; if (!is_dero) { @@ -772,7 +814,7 @@ function Coin(data){ } if (!("prev_hash" in template)) { // Get prev_hash from blob - let prev_hash = new Buffer(32); + let prev_hash = Buffer.alloc(32); const prev_hash_start = global.coinFuncs.blobTypeRaven(port2blob_num[this.port]) ? 4 : 7; this.buffer.copy(prev_hash, 0, prev_hash_start, prev_hash_start + 32); this.prev_hash = prev_hash.toString('hex'); @@ -845,6 +887,8 @@ function Coin(data){ if ("ethash" in algos_perf) coin_perf["ETH"] = algos_perf["ethash"]; + if ("autolykos2" in algos_perf) coin_perf["ERG"] = algos_perf["autolykos2"]; + if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = coin_perf["BLOC"] = algos_perf["cn-heavy/xhv"]; @@ -893,6 +937,7 @@ function Coin(data){ case 2086: return multiHashing.cryptonight_heavy(convertedBlob, 1); // BLOC case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH + case 9053: return multiHashing.autolykos2_hash(convertedBlob, blockTemplate.height); // ERG case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ //case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL @@ -995,6 +1040,7 @@ function Coin(data){ case 2086: return "forknote1"; // BLOC case 8545: return "eth"; // ETH case 8766: return "raven"; // RVN + case 9053: return "erg"; // ERG case 9231 : return "cryptonote_loki"; // XEQ //case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL diff --git a/lib/pool.js b/lib/pool.js index b12f38239..105b31c9d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -296,7 +296,7 @@ function process_rpc_template(rpc_template, coin, port, coinHashFactor, isHashFa template.child_template = activeBlockTemplates[child_coin]; template.child_template_buffer = template.child_template.buffer; template.parent_blocktemplate_blob = global.coinFuncs.constructMMParentBlockBlob( - new Buffer(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer + Buffer.from(rpc_template.blocktemplate_blob, 'hex'), port, template.child_template_buffer ).toString('hex'); } } @@ -1381,7 +1381,7 @@ function recordShareData(miner, job, isTrustedShare, blockTemplate) { function getShareBuffer(miner, job, blockTemplate, params) { try { - let template = new Buffer(blockTemplate.buffer.length); + let template = Buffer.from(blockTemplate.buffer.length); blockTemplate.buffer.copy(template); template.writeUInt32BE(job.extraNonce, blockTemplate.reserved_offset); if (miner.proxy) { diff --git a/package.json b/package.json index a44e32c11..0390243c1 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "cluster": "0.7.7", "concat-stream": "^1.6.0", "cors": "^2.8.1", - "crypto": "0.0.3", "debug": "2.6.9", "express": "4.14.0", "apicache": "1.2.1", @@ -36,7 +35,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v9.2.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v23.1.0" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.2", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v24.0.1" } } From abe9c0f659d22f58b7042f67aceaf71acc7298a3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Jul 2021 20:33:22 +0000 Subject: [PATCH 1419/1496] ERG support (draft) --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4b333c8c9..87f8ccdb6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -260,7 +260,7 @@ function calcEthReward(block, tx_reciepts) { function calcErgReward(block_tx) { let reward = 0; block_tx.forEach(function(tx) { - if (tx.dataInputs.length) continue; + if (tx.dataInputs.length) return; reward += outputs[outputs.length-1].value; }); return reward; From 5793dc013a1e6748f8e950bc5d5f359875642bb4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Jul 2021 21:08:04 +0000 Subject: [PATCH 1420/1496] ERG support (draft) --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 105b31c9d..37b00c3a4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1381,7 +1381,7 @@ function recordShareData(miner, job, isTrustedShare, blockTemplate) { function getShareBuffer(miner, job, blockTemplate, params) { try { - let template = Buffer.from(blockTemplate.buffer.length); + let template = Buffer.alloc(blockTemplate.buffer.length); blockTemplate.buffer.copy(template); template.writeUInt32BE(job.extraNonce, blockTemplate.reserved_offset); if (miner.proxy) { From 90d2eb142a1e3de98611c98e91b12f1895352d6f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Jul 2021 02:15:02 +0000 Subject: [PATCH 1421/1496] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0390243c1..6fafa76a8 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.3", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v24.0.1" } } From 8d4cd95c31b3bf6df88dd2bf07cf6fef70d16570 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Jul 2021 04:33:46 +0000 Subject: [PATCH 1422/1496] Invalidate block --- manage_scripts/altblock_revalidate.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manage_scripts/altblock_revalidate.js b/manage_scripts/altblock_revalidate.js index ba295e0ae..4bcba3638 100644 --- a/manage_scripts/altblock_revalidate.js +++ b/manage_scripts/altblock_revalidate.js @@ -19,7 +19,14 @@ require("../init_mini.js").init(function() { is_found = true; global.coinFuncs.getPortBlockHeaderByHash(blockData.port, hash, (err, body) => { if (err !== null || !body.reward) { - console.log("Altblock with " + hash + " hash still has invalid hash for " + blockData.port + " port! Exiting!"); + if (blockData.valid) { + blockData.valid = false; + blockData.unlocked = true; + txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + console.log("Altblock with " + hash + " hash became invalid for " + blockData.port + " port! Exiting!"); + } else { + console.log("Altblock with " + hash + " hash still has invalid hash for " + blockData.port + " port! Exiting!"); + } cursor.close(); txn.commit(); process.exit(1); From 88c9f161dca930b8e81403f838921fe22d5095ef Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Jul 2021 20:01:09 +0000 Subject: [PATCH 1423/1496] More efficient invalid share storage --- lib/data.proto | 1 + lib/local_comms.js | 4 ++-- lib/pool.js | 21 +++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/data.proto b/lib/data.proto index cc1c1ef5e..18f9b8e14 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -23,6 +23,7 @@ message InvalidShare{ required string paymentAddress = 1; optional string paymentID = 2; required string identifier = 3; + optional int32 count = 4; } message Share { diff --git a/lib/local_comms.js b/lib/local_comms.js index 361d61812..3cce2376a 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -313,8 +313,8 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - this.incrementCacheData(minerIDWithIdentifier, [{location: 'badShares', value: 1}]); - this.incrementCacheData(minerID, [{location: 'badShares', value: 1}]); + this.incrementCacheData(minerIDWithIdentifier, [{location: 'badShares', value: share.count ? share.count : 1}]); + this.incrementCacheData(minerID, [{location: 'badShares', share.count ? share.count : 1}]); callback(true); } catch (e){ console.error("Ran into an error storing an invalid share. Damn!"); diff --git a/lib/pool.js b/lib/pool.js index 37b00c3a4..8d005e166 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -852,11 +852,20 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.cachedJob = null; this.storeInvalidShare = function() { - global.database.storeInvalidShare(global.protos.InvalidShare.encode({ - paymentAddress: this.address, - paymentID: this.paymentID, - identifier: this.identifier - })); + const time_now = Date.now(); + if (this.invalidShareCount) ++ this.invalidShareCount; + else this.invalidShareCount = 1; + if (!this.lastInvalidShareTime || time_now - this.lastInvalidShareTime > 10*60*1000) { + let _this = this; + global.database.storeInvalidShare(global.protos.InvalidShare.encode({ + paymentAddress: _this.address, + paymentID: _this.paymentID, + identifier: _this.identifier, + count: _this.invalidShareCount + })); + this.lastInvalidShareTime = time_now; + this.invalidShareCount = 0; + } }; this.setNewDiff = function (difficulty) { @@ -2095,7 +2104,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } } if (!blockTemplate || is_outdated) { - const err_str = is_outdated ? "Block outdated" : "Block expired"; + const err_str = blockTemplate ? "Block outdated" : "Block expired"; const time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 30*1000) { console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); From 7ce457b2aa427815fdd7592bc44a401a6428114b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Jul 2021 16:45:16 +0000 Subject: [PATCH 1424/1496] Fixed typo --- lib/local_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 3cce2376a..5fb90ef7e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -314,7 +314,7 @@ function Database(){ } let minerIDWithIdentifier = minerID + "_" + share.identifier; this.incrementCacheData(minerIDWithIdentifier, [{location: 'badShares', value: share.count ? share.count : 1}]); - this.incrementCacheData(minerID, [{location: 'badShares', share.count ? share.count : 1}]); + this.incrementCacheData(minerID, [{location: 'badShares', value: share.count ? share.count : 1}]); callback(true); } catch (e){ console.error("Ran into an error storing an invalid share. Damn!"); From 027e43418874a1aac057a94abcdfff85f4db5e92 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Jul 2021 00:05:19 +0000 Subject: [PATCH 1425/1496] ERG support fix --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 87f8ccdb6..a2f499eee 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -261,7 +261,7 @@ function calcErgReward(block_tx) { let reward = 0; block_tx.forEach(function(tx) { if (tx.dataInputs.length) return; - reward += outputs[outputs.length-1].value; + reward += tx.outputs[tx.outputs.length-1].value; }); return reward; } From 20221b6ec52b6dd5dd52444ab9b7a1010ba6b748 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Jul 2021 00:28:42 +0000 Subject: [PATCH 1426/1496] ERG support fix --- lib/coins/xmr.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a2f499eee..e88c0bcb1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -257,12 +257,17 @@ function calcEthReward(block, tx_reciepts) { return (ETH_BASE_REWARD + ETH_BASE_REWARD * (block.uncles.length / 32)) * ETH_MULTIPLIER + fee; } -function calcErgReward(block_tx) { +function calcErgReward(height, block_tx) { let reward = 0; - block_tx.forEach(function(tx) { - if (tx.dataInputs.length) return; - reward += tx.outputs[tx.outputs.length-1].value; - }); + if (block_tx.length && block_tx[0].outputs.length == 2 && block_tx[0].outputs[1].creationHeight == height) { + reward += block_tx[0].outputs[1].value; + } + if (block_tx.length > 1) { + const last_tx = block_tx[block_tx.length - 1]; + if (last_tx.outputs.length == 1 && last_tx.outputs[0].creationHeight == height) { + reward += last_tx.outputs[0].value; + } + } return reward; } @@ -446,7 +451,7 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - body.header.reward = calcErgReward(body.blockTransactions.transactions); + body.header.reward = calcErgReward(body.header.height, body.blockTransactions.transactions); return callback(null, body.header); }); } else if (port == 13007 || port == 2086 || port == 48782 || port == 11181 || port == 20206 || port == 16000) { From 066f7dd4879b95121d882af72c9cb4a736f7841c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 01:40:21 +0000 Subject: [PATCH 1427/1496] Fixed install --- deployment/leaf.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index af87093f7..1b6102a4c 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -15,9 +15,10 @@ cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git sudo systemctl enable ntp cd /usr/local/src -sudo git clone --recursive https://github.com/monero-project/monero.git +sudo git clone https://github.com/monero-project/monero.git cd monero sudo git checkout v0.17.2.0 +sudo git submodule update --init sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon From 567bc0d0d42c168a2c3fe8fadfe23bf9827c07f0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 03:29:06 +0000 Subject: [PATCH 1428/1496] ERG support draft --- lib/coins/xmr.js | 65 ++++++++++++------------ lib/pool.js | 127 ++++++++++++++++++++++++++++++----------------- package.json | 2 +- 3 files changed, 116 insertions(+), 78 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e88c0bcb1..4f918a582 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -660,24 +660,27 @@ function Coin(data){ this.nonceSize = function(blob_type_num) { switch (blob_type_num) { case 7: - case 101: - case 102: return 8; + case 101: // RVN + case 102: // ETH + case 103: return 8; // ERG default: return 4; } } - this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } + this.blobTypeDero = function(blob_type_num) { return blob_type_num == 100; } - this.blobTypeRaven = function(blob_type_num) { return blob_type_num == 101; } + this.blobTypeRvn = function(blob_type_num) { return blob_type_num == 101; } - this.blobTypeEth = function(blob_type_num) { return blob_type_num == 102; } + this.blobTypeEth = function(blob_type_num) { return blob_type_num == 102; } + + this.blobTypeErg = function(blob_type_num) { return blob_type_num == 103; } this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; let blob; try { - if (this.blobTypeRaven(blob_type_num)) { + if (this.blobTypeRvn(blob_type_num)) { blob = cnUtil.convertRavenBlob(blobBuffer); } else { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); @@ -700,7 +703,7 @@ function Coin(data){ ); } else if (global.coinFuncs.blobTypeDero(blob_type_num)) { return cnUtil.constructNewDeroBlob(blockTemplate, Buffer.from(params.nonce, 'hex')); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { return cnUtil.constructNewRavenBlob(blockTemplate, bignum(params.nonce, 16).toBuffer({endian: 'little', size: 8}), bignum(params.mixhash, 16).toBuffer({endian: 'little', size: 32}) @@ -746,14 +749,14 @@ function Coin(data){ this.coin = template.coin; this.port = template.port; - const port_blob_num = port2blob_num[this.port]; - const is_eth = global.coinFuncs.blobTypeEth(port_blob_num); + const port_blob_num = port2blob_num[this.port]; + const isExtraNonceBT = global.coinFuncs.blobTypeEth(port_blob_num) || global.coinFuncs.blobTypeErg(port_blob_num); if (template.blocktemplate_blob) { this.blocktemplate_blob = template.blocktemplate_blob; } else if (template.blob) { this.blocktemplate_blob = template.blob; - } else if (is_eth) { + } else if (isExtraNonceBT) { const hash = template.hash; this.hash = this.idHash = this.prev_hash = hash; this.block_version = 0; @@ -820,7 +823,7 @@ function Coin(data){ if (!("prev_hash" in template)) { // Get prev_hash from blob let prev_hash = Buffer.alloc(32); - const prev_hash_start = global.coinFuncs.blobTypeRaven(port2blob_num[this.port]) ? 4 : 7; + const prev_hash_start = global.coinFuncs.blobTypeRvn(port2blob_num[this.port]) ? 4 : 7; this.buffer.copy(prev_hash, 0, prev_hash_start, prev_hash_start + 32); this.prev_hash = prev_hash.toString('hex'); } else { @@ -939,27 +942,27 @@ function Coin(data){ this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { switch (blockTemplate.port) { - case 2086: return multiHashing.cryptonight_heavy(convertedBlob, 1); // BLOC + case 2086: return multiHashing.cryptonight_heavy(convertedBlob, 1); // BLOC case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN - case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH - case 9053: return multiHashing.autolykos2_hash(convertedBlob, blockTemplate.height); // ERG - case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ - //case 11181: return multiHashing.k12(convertedBlob); // Aeon - case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL - case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO - case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium - case 16000: return multiHashing.cryptonight(convertedBlob, 11); // CCX - case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven - case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR - //case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC - case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft - case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO - case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa - case 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala - case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero - case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero - case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR - case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean + case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH + case 9053: return multiHashing.autolykos2_hashes(convertedBlob, blockTemplate.height); // ERG + case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ + //case 11181: return multiHashing.k12(convertedBlob); // Aeon + case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL + case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO + case 13007: return multiHashing.cryptonight_pico(convertedBlob, 0); // Iridium + case 16000: return multiHashing.cryptonight(convertedBlob, 11); // CCX + case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven + case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR + //case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC + case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft + case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO + case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa + case 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala + case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero + case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero + case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR + case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean default: console.error("Unknown " + blockTemplate.port + " port for Cryptonight PoW type"); return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); diff --git a/lib/pool.js b/lib/pool.js index 8d005e166..94d19e5f7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -935,10 +935,12 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(best_coin)); if (global.coinFuncs.blobTypeGrin(blob_type_num)) { this.curr_coin_min_diff = 1; - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { this.curr_coin_min_diff = 0.01; } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { this.curr_coin_min_diff = 0.01 * 0x100000000; + } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { + this.curr_coin_min_diff = 0.01 * 0x100000000; } else { this.curr_coin_min_diff = global.config.pool.minDifficulty; } @@ -974,7 +976,10 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.fixed_diff = true; let minNiceHashDiff; const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(this.curr_coin)); - if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { + if ( global.coinFuncs.blobTypeRvn(blob_type_num) || + global.coinFuncs.blobTypeEth(blob_type_num) || + global.coinFuncs.blobTypeErg(blob_type_num) + ) { minNiceHashDiff = global.coinFuncs.niceHashDiff * 50; } else { minNiceHashDiff = global.coinFuncs.niceHashDiff; @@ -1092,18 +1097,20 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro const blob_type_num = global.coinFuncs.portBlobType(bt.port); const isEth = global.coinFuncs.blobTypeEth(blob_type_num); + const isErg = global.coinFuncs.blobTypeErg(blob_type_num); + const isExtraNonceBT = isEth || isErg; - if (!this.proxy || isEth) { + if (!this.proxy || isExtraNonceBT) { const blob_hex = bt.nextBlobHex(); if (!blob_hex) return null; const isGrin = global.coinFuncs.blobTypeGrin(blob_type_num); - const isRvn = global.coinFuncs.blobTypeRaven(blob_type_num); + const isRvn = global.coinFuncs.blobTypeRvn(blob_type_num); const newJob = { id: isRvn ? get_new_eth_job_id() : get_new_id(), coin: coin, blob_type_num: blob_type_num, blockHash: bt.idHash, - extraNonce: isEth ? this.eth_extranonce : bt.extraNonce, + extraNonce: isExtraNonceBT ? this.eth_extranonce : bt.extraNonce, height: bt.height, seed_hash: bt.seed_hash, difficulty: coin_diff, @@ -1135,7 +1142,17 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro bt.seed_hash, blob_hex, true, - coin_diff + coin_diff // this will be popped and used for separate mining.set_difficulty message + ]; else if (isErg) this.cachedJob = [ + newJob.id, + bt.height, + bt.hash, + "", + "", + 2, // curl http://localhost:9053/info: parameters.blockVersion + getTargetHex(coin_diff, global.coinFuncs.nonceSize(blob_type_num)), + "" + true ]; else this.cachedJob = { blob: blob_hex, algo: params.algo_name, @@ -1187,7 +1204,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); if (this.protocol == "grin") { return this.pushMessage({method: "getjobtemplate", result: job}); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { const target = job[3]; if (!this.last_target || this.last_target !== target) { this.pushMessage({method: "mining.set_target", params: [ target ], id:null}); @@ -1202,6 +1219,9 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro } return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name}); + } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { + return this.pushMessage({method: "mining.notify", params: job, algo: params.algo_name}); + } else { return this.pushMessage({method: "job", params: job}); } @@ -1457,8 +1477,9 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste // Success! Submitted a block without an issue. } else if ( rpcResult && ( - typeof(rpcResult.result) !== 'undefined' || - ( typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898 ) + ( typeof(rpcResult.result) !== 'undefined' ) || + ( rpcResult.response !== 'rejected' ) || // ERG + ( typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898 ) // TRTL ) ) { @@ -1466,7 +1487,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, blockTemplate.block_version); if (global.coinFuncs.blobTypeDero(blob_type_num)) { newBlockHash = rpcResult.result.blid; - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(blob_type_num) || global.coinFuncs.blobTypeErg(blob_type_num)) { newBlockHash = resultBuff.toString('hex'); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { newBlockHash = rpcResult.result.substr(2); @@ -1531,10 +1552,12 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste if (blockTemplate.port == 11898) { global.support.rpcPortDaemon2(blockTemplate.port, "block", blockData.toString('hex'), reply_fn); - } else if (global.coinFuncs.blobTypeRaven(job.blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(job.blob_type_num)) { global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "submitblock", params: [ blockData.toString('hex') ] }, reply_fn); } else if (global.coinFuncs.blobTypeEth(job.blob_type_num)) { global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "parity_submitWorkDetail", params: blockData, jsonrpc: "2.0", id: 0 }, reply_fn); + } else if (global.coinFuncs.blobTypeErg(job.blob_type_num)) { + global.support.rpcPortDaemon2(blockTemplate.port, "mining/solution", {"n": blockData}, reply_fn); } else if (global.coinFuncs.blobTypeDero(job.blob_type_num)) { global.support.rpcPortDaemon(blockTemplate.port, "submitblock", [ blockTemplate.blocktemplate_blob, blockData.toString('hex') ], reply_fn); } else { @@ -1621,7 +1644,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const resultBuff = global.coinFuncs.c29_cycle_hash(params.pow, blob_type_num); return verifyShareCB(hashBuffDiff(resultBuff), resultBuff, blockData, false, true); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { const blockData = getShareBuffer(miner, job, blockTemplate, params); if (blockData === null) return processShareCB(invalid_share(miner)); const convertedBlob = global.coinFuncs.convertBlob(blockData, port); @@ -1639,6 +1662,12 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { const resultBuff = hashes[0]; const blockData = [ "0x" + params.nonce, "0x" + blockTemplate.hash, "0x" + hashes[1].toString('hex') ]; return verifyShareCB(hashEthBuffDiff(resultBuff), resultBuff, blockData, false, true); + + } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { + if (shareThrottled()) return processShareCB(null); + const coinbaseBuffer = Buffer.concat([Buffer.from(blockTemplate.hash, 'hex'), Buffer.from(params.nonce, 'hex')]); + const hashes = global.coinFuncs.slowHashBuff(coinbaseBuffer, blockTemplate); + return verifyShareCB(hashEthBuffDiff(hashes[1]), hashes[0], params.nonce, false, true); } const resultHash = params.result; @@ -1793,7 +1822,7 @@ function get_miner_notification(payout) { function handleMinerData(socket, id, method, params, ip, portData, sendReply, sendReplyFinal, pushMessage) { switch (method) { - case 'mining.authorize': // Eth/Raven only + case 'mining.authorize': // Eth/Raven/Erg only if (!params || !(params instanceof Array)) { sendReplyFinal("No array params specified"); return; @@ -1894,7 +1923,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (coin !== false) { const params = getCoinJobParams(coin); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); - if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { // xmrig specifics + if (global.coinFuncs.blobTypeRvn(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { // xmrig specifics const new_id = socket.eth_extranonce_id ? socket.eth_extranonce_id : get_new_eth_extranonce_id(); if (new_id !== null) { socket.eth_extranonce_id = new_id; @@ -1915,7 +1944,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se break; } - case 'mining.subscribe': { // Raven/Eth only + case 'mining.subscribe': { // Raven/Eth/Erg only if (params && (params instanceof Array) && params.length >= 1) socket.eth_agent = params[0]; const new_id = socket.eth_extranonce_id ? socket.eth_extranonce_id : get_new_eth_extranonce_id(); if (new_id !== null) { @@ -1937,7 +1966,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const minerId = socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""; let miner = activeMiners.get(minerId); if (!miner) { - sendReplyFinal('Unauthenticated'); + sendReplyFinal("Unauthenticated"); return; } miner.heartbeat(); @@ -1952,7 +1981,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } let miner = activeMiners.get(params.id); if (!miner) { - sendReplyFinal('Unauthenticated'); + sendReplyFinal("Unauthenticated"); return; } miner.heartbeat(); @@ -1978,25 +2007,14 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } - switch (params.length) { - case 3: params = { - job_id: params[1], - nonce: params[2], - }; break; - - case 5: params = { - job_id: params[1], - nonce: params[2].substr(2), - header_hash: params[3].substr(2), - mixhash: params[4].substr(2), - }; break; - - default: - sendReply("No correct params specified"); - return; + if (params.length >= 3) params = { + job_id: params[1], + raw_params: params + } else { + sendReply("No correct params specified"); + return; } - // continue to normal login case 'submit': { // grin and default @@ -2007,7 +2025,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const minerId = params.id ? params.id : (socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""); let miner = activeMiners.get(minerId); if (!miner) { - sendReplyFinal('Unauthenticated'); + sendReplyFinal("Unauthenticated"); return; } //if (miner.debugMiner) console.log("SUBMIT"); @@ -2019,11 +2037,27 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se })[0]; if (!job) { - sendReply('Invalid job id'); + sendReply("Invalid job id"); return; } const blob_type_num = job.blob_type_num; + + if (method === 'mining.submit') { + if (global.coinFuncs.blobTypeRvn(blob_type_num)) { + params.nonce = params.raw_params[2]; + } else if (global.coinFuncs.blobTypeEth(blob_type_num) && params.raw_params.length >= 5) { + params.nonce = params.raw_params[2].substr(2); + params.header_hash = params.raw_params[3].substr(2); + params.mixhash = params.raw_params[4].substr(2); + } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { + params.nonce = params.raw_params[2]; + } else { + sendReply("Invalid job params"); + return; + } + } + const nonce_sanity_check = function(blob_type_num, params) { if (global.coinFuncs.blobTypeGrin(blob_type_num)) { if (typeof params.nonce !== 'number') return false; @@ -2032,13 +2066,14 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } else { if (typeof params.nonce !== 'string') return false; if (global.coinFuncs.nonceSize(blob_type_num) == 8) { - const isEth = global.coinFuncs.blobTypeEth(blob_type_num); - if (isEth) params.nonce = job.extraNonce + params.nonce; + const isExtraNonceBT = global.coinFuncs.blobTypeEth(blob_type_num) || + global.coinFuncs.blobTypeErg(blob_type_num); + if (isExtraNonceBT) params.nonce = job.extraNonce + params.nonce; if (!nonceCheck64.test(params.nonce)) return false; - if (global.coinFuncs.blobTypeRaven(blob_type_num)) { + if (global.coinFuncs.blobTypeRvn(blob_type_num)) { if (!hashCheck32.test(params.mixhash)) return false; if (!hashCheck32.test(params.header_hash)) return false; - } else if (!isEth) { + } else if (!isExtraNonceBT) { if (!hashCheck32.test(params.result)) return false; } } else { @@ -2051,7 +2086,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (!nonce_sanity_check(blob_type_num, params)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); - sendReply('Duplicate share'); + sendReply("Duplicate share"); miner.storeInvalidShare(); return; } @@ -2062,7 +2097,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (!Number.isInteger(params.poolNonce) || !Number.isInteger(params.workerNonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); - sendReply('Duplicate share'); + sendReply("Duplicate share"); miner.storeInvalidShare(); return; } @@ -2076,7 +2111,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (nonce_test in job.submissions) { console.warn(threadName + 'Duplicate miner share with ' + nonce_test + ' nonce from ' + miner.logString); miner.checkBan(false); - sendReply('Duplicate share'); + sendReply("Duplicate share"); miner.storeInvalidShare(); return; } @@ -2148,7 +2183,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } if (!shareAccepted) { - sendReply('Low difficulty share'); + sendReply("Low difficulty share"); return; } @@ -2156,7 +2191,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (miner.protocol === "grin") { sendReply(null, "ok"); - } else if (global.coinFuncs.blobTypeRaven(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { sendReply(null, true); } else { sendReply(null, { status: 'OK' }); @@ -2175,7 +2210,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const minerId = params.id ? params.id : (socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""); let miner = activeMiners.get(minerId); if (!miner) { - sendReplyFinal('Unauthenticated'); + sendReplyFinal("Unauthenticated"); return; } miner.heartbeat(); diff --git a/package.json b/package.json index 6fafa76a8..0d93bc36b 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v24.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v24.0.2" } } From 24d77f789aea5f06e7379311a3ce16719632dad5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 03:35:54 +0000 Subject: [PATCH 1429/1496] ERG support draft --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 94d19e5f7..9e77e7a82 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1151,7 +1151,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro "", 2, // curl http://localhost:9053/info: parameters.blockVersion getTargetHex(coin_diff, global.coinFuncs.nonceSize(blob_type_num)), - "" + "", true ]; else this.cachedJob = { blob: blob_hex, From 07835ba09eac8b09cc5a3ba42e0187d978c1d7a5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 03:36:27 +0000 Subject: [PATCH 1430/1496] ERG support draft --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9e77e7a82..c8b02cade 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2010,7 +2010,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (params.length >= 3) params = { job_id: params[1], raw_params: params - } else { + }; else { sendReply("No correct params specified"); return; } From 690f555c34a1af62368ee9b610d261f0b2e00ed3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 04:04:42 +0000 Subject: [PATCH 1431/1496] ERG support draft --- lib/pool.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c8b02cade..8435fdc8c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2044,14 +2044,12 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se const blob_type_num = job.blob_type_num; if (method === 'mining.submit') { - if (global.coinFuncs.blobTypeRvn(blob_type_num)) { + if (global.coinFuncs.blobTypeEth(blob_type_num) || global.coinFuncs.blobTypeErg(blob_type_num)) { params.nonce = params.raw_params[2]; } else if (global.coinFuncs.blobTypeEth(blob_type_num) && params.raw_params.length >= 5) { params.nonce = params.raw_params[2].substr(2); params.header_hash = params.raw_params[3].substr(2); params.mixhash = params.raw_params[4].substr(2); - } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { - params.nonce = params.raw_params[2]; } else { sendReply("Invalid job params"); return; From 173c343c0e595655a65af62063e0f14816b3cb38 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 04:08:25 +0000 Subject: [PATCH 1432/1496] ERG support draft --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8435fdc8c..d59110ab5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2046,7 +2046,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (method === 'mining.submit') { if (global.coinFuncs.blobTypeEth(blob_type_num) || global.coinFuncs.blobTypeErg(blob_type_num)) { params.nonce = params.raw_params[2]; - } else if (global.coinFuncs.blobTypeEth(blob_type_num) && params.raw_params.length >= 5) { + } else if (global.coinFuncs.blobTypeRvn(blob_type_num) && params.raw_params.length >= 5) { params.nonce = params.raw_params[2].substr(2); params.header_hash = params.raw_params[3].substr(2); params.mixhash = params.raw_params[4].substr(2); From cb781adde77ebb5bc919489918e4e0b579bae6dd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 04:57:02 +0000 Subject: [PATCH 1433/1496] ERG support draft --- lib/coins/xmr.js | 3 +-- lib/pool.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4f918a582..2e130bd4d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -661,8 +661,7 @@ function Coin(data){ switch (blob_type_num) { case 7: case 101: // RVN - case 102: // ETH - case 103: return 8; // ERG + case 102: return 8; // ETH default: return 4; } } diff --git a/lib/pool.js b/lib/pool.js index d59110ab5..1bfb2de60 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1150,7 +1150,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro "", "", 2, // curl http://localhost:9053/info: parameters.blockVersion - getTargetHex(coin_diff, global.coinFuncs.nonceSize(blob_type_num)), + baseDiff.div(coin_diff).toString(), "", true ]; else this.cachedJob = { From 8970ca1d92a80132863138ce109d96ffdbb5d58b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 22:08:52 +0000 Subject: [PATCH 1434/1496] ERG support draft --- lib/coins/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2e130bd4d..fb24be313 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -660,8 +660,9 @@ function Coin(data){ this.nonceSize = function(blob_type_num) { switch (blob_type_num) { case 7: - case 101: // RVN - case 102: return 8; // ETH + case 101: // RVN + case 102: // ETH + case 103: return 8; // ERG default: return 4; } } From 2a6d0a431f813cfb33add2e1f112cd90a9988776 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 22:25:34 +0000 Subject: [PATCH 1435/1496] ERG support draft --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1bfb2de60..d34382876 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2189,7 +2189,10 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (miner.protocol === "grin") { sendReply(null, "ok"); - } else if (global.coinFuncs.blobTypeRvn(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { + } else if ( global.coinFuncs.blobTypeRvn(blob_type_num) || + global.coinFuncs.blobTypeEth(blob_type_num) || + global.coinFuncs.blobTypeErg(blob_type_num) + ) { sendReply(null, true); } else { sendReply(null, { status: 'OK' }); From 203b603e48db02b3fa972feac64a32f0b9ea6d2a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jul 2021 23:46:43 +0000 Subject: [PATCH 1436/1496] ERG support draft --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d34382876..f49a6c7e7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1950,7 +1950,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (new_id !== null) { socket.eth_extranonce_id = new_id; // extranonce is not really needed for Raven (extraonce is specificed as part of coinbase tx) - sendReply(null, [ [ "mining.notify", get_new_id(), "EthereumStratum/1.0.0" ], eth_extranonce(new_id) ]); + sendReply(null, [ [ "mining.notify", get_new_id(), "EthereumStratum/1.0.0" ], eth_extranonce(new_id), 6 ]); } else { sendReplyFinal("Not enough extranoces. Switch to other pool node."); } From 6c005893107aea2bfb0482328df08156f192399c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Jul 2021 00:08:57 +0000 Subject: [PATCH 1437/1496] ERG support draft --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f49a6c7e7..8a320c12e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1923,7 +1923,10 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se if (coin !== false) { const params = getCoinJobParams(coin); const blob_type_num = global.coinFuncs.portBlobType(global.coinFuncs.COIN2PORT(coin)); - if (global.coinFuncs.blobTypeRvn(blob_type_num) || global.coinFuncs.blobTypeEth(blob_type_num)) { // xmrig specifics + if ( global.coinFuncs.blobTypeRvn(blob_type_num) || + global.coinFuncs.blobTypeEth(blob_type_num) || + global.coinFuncs.blobTypeErg(blob_type_num) + ) { // xmrig specifics const new_id = socket.eth_extranonce_id ? socket.eth_extranonce_id : get_new_eth_extranonce_id(); if (new_id !== null) { socket.eth_extranonce_id = new_id; From a519a029b5979610e196ab9f67964fc61f7bc505 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Jul 2021 02:02:05 +0000 Subject: [PATCH 1438/1496] Fixed disabled BT miners disconnect --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8a320c12e..86848e046 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -510,7 +510,6 @@ function setNewBlockTemplate(template) { return; } } - activeBlockTemplates[coin].timeCreated = Date.now(); if (coin in pastBlockTemplates) { pastBlockTemplates[coin].get(0).timeoutTime = Date.now() + 4*1000; } else { @@ -527,6 +526,7 @@ function setNewBlockTemplate(template) { } activeBlockTemplates[coin] = new global.coinFuncs.BlockTemplate(template); + activeBlockTemplates[coin].timeCreated = Date.now(); const height = activeBlockTemplates[coin].height; From 875f9e2153c079e3e72d8a44b485ffd01671c195 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 00:05:12 +0000 Subject: [PATCH 1439/1496] ERG support draft --- lib/coins/xmr.js | 12 ++++++------ lib/pool.js | 2 +- lib/support.js | 10 ++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index fb24be313..9798dfac4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -28,7 +28,7 @@ const port2coin = { "18981": "GRFT", "11812": "XLA", "25182": "TUBE", - "34568": "WOW", +// "34568": "WOW", "38081": "MSR", "48782": "LTHN", "19734": "SUMO", @@ -56,7 +56,7 @@ const port2blob_num = { "18981": 0, // GRFT "11812": 0, // XLA "25182": 10, // TUBE - "34568": 0, // WOW +// "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN "19734": 0, // SUMO @@ -92,7 +92,7 @@ const port2algo = { "11812": "panthera", // Scala "25182": "c29b", // BitTube "33124": "c29s", // XtendCash - "34568": "rx/wow", // Wownero +// "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR "48782": "cn/r", // Lethean "9231" : "cn/gpu", // XEQ @@ -889,7 +889,7 @@ function Coin(data){ if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["CCX"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; - if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; +// if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; if ("kawpow" in algos_perf) coin_perf["RVN"] = algos_perf["kawpow"]; @@ -960,7 +960,7 @@ function Coin(data){ case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero - case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero +// case 34568: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 17); // Wownero case 38081: return multiHashing.cryptonight(convertedBlob, 9); // MSR case 48782: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // Lethean default: @@ -983,7 +983,7 @@ function Coin(data){ case 19994: case 11812: case 22023: - case 34568: +// case 34568: jsonInput = { "algo": port2algo[blockTemplate.port], "blob": convertedBlob.toString('hex'), "seed_hash": blockTemplate.seed_hash }; break; case 19734: diff --git a/lib/pool.js b/lib/pool.js index 86848e046..a17c0a799 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1961,7 +1961,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } case 'mining.extranonce.subscribe': { // Raven/Eth only - sendReply(null, true); + sendReply(null, false); break; } diff --git a/lib/support.js b/lib/support.js index ee506ff3f..222c896f5 100644 --- a/lib/support.js +++ b/lib/support.js @@ -122,8 +122,14 @@ function jsonRequest(host, port, data, callback, path, timeout) { "Accept": "application/json" } }; - if (global.config.daemon.basicAuth) options.headers["Authorization"] = global.config.daemon.basicAuth; - if (global.config.daemon["X-API-KEY"]) options.headers["X-API-KEY"] = global.config.daemon["X-API-KEY"]; + if (global.config.daemon.basicAuth) { + options.headers["Authorization"] = global.config.daemon.basicAuth; + } + if (global.config.daemon["X-API-KEY"]) { + options.headers["X-API-KEY"] = global.config.daemon["X-API-KEY"]; + options.headers["api_key"] = global.config.daemon["X-API-KEY"]; + } + if (data) { const data2 = typeof data === 'string' ? data : JSON.stringify(data); options.headers["Content-Length"] = data2.length; From 4368d53dc83ba0d4d4233066b0601cf28ffd2aaf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 00:10:59 +0000 Subject: [PATCH 1440/1496] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d93bc36b..9eaca4060 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "debug": "2.6.9", - "express": "4.14.0", + "express": "^4.17.1", "apicache": "1.2.1", "jsonwebtoken": "^7.2.1", "minimist": ">=1.2.3", From 15a8b9decbc4243abc059536f1e4d16bdcdc4cf9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 00:14:01 +0000 Subject: [PATCH 1441/1496] npm audit --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 9eaca4060..f88b8747c 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "request": "^2.79.0", "request-json": "0.6.1", "shapeshift.io": "1.3.0", - "socketio": "^1.0.0", "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", From f64f4820cc10783bf675f5d5f92a458d4a43b5f6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 00:19:42 +0000 Subject: [PATCH 1442/1496] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f88b8747c..667af5ef2 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "protocol-buffers": "^3.2.1", "range": "0.0.3", "request": "^2.79.0", - "request-json": "0.6.1", + "request-json": "0.6.5", "shapeshift.io": "1.3.0", "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", From 7f94369150f0abd29bb1136d39a48f7854b71106 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 00:21:57 +0000 Subject: [PATCH 1443/1496] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 667af5ef2..2a59013a6 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "debug": "2.6.9", "express": "^4.17.1", "apicache": "1.2.1", - "jsonwebtoken": "^7.2.1", + "jsonwebtoken": "^8.5.1", "minimist": ">=1.2.3", "moment": "2.21.0", "mysql": "2.15.0", From e7333a39adfcc436a14df02cc3c8596711dc20f0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 00:25:15 +0000 Subject: [PATCH 1444/1496] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a59013a6..11b523ff1 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "jsonwebtoken": "^8.5.1", "minimist": ">=1.2.3", "moment": "2.21.0", - "mysql": "2.15.0", + "mysql": "2.18.1", "node-lmdb": "git+https://github.com/Venemo/node-lmdb.git#5941c1e553de4ae1d57a67d355b7c2dd87feaea6", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", From 8f4f1480a10b8b7ca14d64c7f649bff86a662f6d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 16:12:45 +0000 Subject: [PATCH 1445/1496] Fixed issues with eth nbminer --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index a17c0a799..86848e046 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1961,7 +1961,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } case 'mining.extranonce.subscribe': { // Raven/Eth only - sendReply(null, false); + sendReply(null, true); break; } From c6d85264d421f40b76acf1d956cb7aa9c811da69 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jul 2021 16:13:42 +0000 Subject: [PATCH 1446/1496] Increased miner timeouts in case of stale BT --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 86848e046..49d9a212e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2154,7 +2154,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } else { blockTemplate = activeBlockTemplates[job.coin]; // kill miner if it mines block template for disabled coin for more than some time - if (!lastCoinHashFactorMM[job.coin] && Date.now() - blockTemplate.timeCreated > 10*60*1000) { + if (!lastCoinHashFactorMM[job.coin] && Date.now() - blockTemplate.timeCreated > 60*60*1000) { sendReplyFinal("This algo was temporary disabled due to coin daemon issues. Consider using https://github.com/MoneroOcean/meta-miner to allow your miner auto algo switch in this case."); return; } From ad041014a4b6d2c87cfd2d3d4347615feb8c635c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Aug 2021 06:57:49 +0000 Subject: [PATCH 1447/1496] Fixed to works with many blocks --- manage_scripts/altblock_change_stage.js | 50 ++++++++++++------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/manage_scripts/altblock_change_stage.js b/manage_scripts/altblock_change_stage.js index 3d7bb25f0..bbd60b1f4 100644 --- a/manage_scripts/altblock_change_stage.js +++ b/manage_scripts/altblock_change_stage.js @@ -1,39 +1,37 @@ "use strict"; -const argv = require('minimist')(process.argv.slice(2)); - -if (!argv.hash) { - console.error("Please specify altblock hash"); - process.exit(1); -} -const hash = argv.hash; +const argv = require('minimist')(process.argv.slice(2), { '--': true }); if (!argv.stage) { - console.error("Please specify new stage value"); - process.exit(1); + console.error("Please specify new stage value"); + process.exit(1); } const stage = argv.stage; +let hashes = {}; +for (const h of argv['--']) { + hashes[h] = 1; +} + require("../init_mini.js").init(function() { - let txn = global.database.env.beginTxn(); + let changed = 0; + let txn = global.database.env.beginTxn(); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - cursor.getCurrentBinary(function(key, data){ // jshint ignore:line - let blockData = global.protos.AltBlock.decode(data); - if (blockData.hash === hash) { - console.log("Found altblock with " + blockData.hash + " hash"); - blockData.pay_stage = stage; - console.log("Put \"" + blockData.pay_stage + "\" stage to block"); - txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); - txn.commit(); - cursor.close(); - console.log("Changed altblock"); - process.exit(0); - } - }); + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + if (blockData.hash in hashes) { + console.log("Found altblock with " + blockData.hash + " hash"); + blockData.pay_stage = stage; + console.log("Put \"" + blockData.pay_stage + "\" stage to block"); + txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + console.log("Changed altblock"); + changed = 1; + } + }); } cursor.close(); txn.commit(); - console.log("Not found altblock with " + hash + " hash"); - process.exit(1); -}); + if (!changed) console.log("Not found altblocks with specified hashes"); + process.exit(0); +}); \ No newline at end of file From 2f726c0ab1982ad70b0f0a61353cfe974d78791c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Aug 2021 19:34:00 +0000 Subject: [PATCH 1448/1496] Updated ETH price calc --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 9798dfac4..e15705038 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -254,6 +254,7 @@ function calcEthReward(block, tx_reciepts) { tx_reciepts.forEach(function(tx) { fee += parseInt(tx.gasUsed) * gas_prices[tx.transactionHash]; }); + fee -= parseInt(block.baseFeePerGas) * parseInt(block.gasUsed); return (ETH_BASE_REWARD + ETH_BASE_REWARD * (block.uncles.length / 32)) * ETH_MULTIPLIER + fee; } From 3964c1a9bf0b34709b32fd78a4fb3ea5b79c6d7a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Aug 2021 02:34:17 +0000 Subject: [PATCH 1449/1496] Fixed underfined blid dero case --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 49d9a212e..bbdbd48f2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1478,7 +1478,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste // Success! Submitted a block without an issue. } else if ( rpcResult && ( ( typeof(rpcResult.result) !== 'undefined' ) || - ( rpcResult.response !== 'rejected' ) || // ERG + ( rpcResult.response !== 'rejected' && global.coinFuncs.blobTypeErg(blob_type_num) ) || // ERG ( typeof rpcResult === 'string' && rpcStatus == 202 && blockTemplate.port == 11898 ) // TRTL ) ) { From 1ca9717d4e01255bea96ebf88b5a75f6a9d713b7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Aug 2021 05:09:06 +0000 Subject: [PATCH 1450/1496] Fixed underfined blid dero case --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bbdbd48f2..8d41d30ad 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1437,6 +1437,7 @@ function invalid_share(miner) { function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTrustedShare, isParentBlock, isRetrySubmitBlock, submit_blockCB) { let reply_fn = function (rpcResult, rpcStatus) { const blockDataStr = Buffer.isBuffer(blockData) ? blockData.toString('hex') : JSON.stringify(blockData); + const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, blockTemplate.block_version); if (rpcResult && (rpcResult.error || rpcResult.result === "high-hash")) { // did not manage to submit a block let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { @@ -1484,7 +1485,6 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste ) { let newBlockHash; - const blob_type_num = global.coinFuncs.portBlobType(blockTemplate.port, blockTemplate.block_version); if (global.coinFuncs.blobTypeDero(blob_type_num)) { newBlockHash = rpcResult.result.blid; } else if (global.coinFuncs.blobTypeRvn(blob_type_num) || global.coinFuncs.blobTypeErg(blob_type_num)) { From 6d4939a3e140d2171f3bca83794a53a9e908d7bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Aug 2021 05:36:52 +0000 Subject: [PATCH 1451/1496] Fixed erg block id detection --- lib/pool.js | 92 +++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8d41d30ad..95fa63398 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1484,49 +1484,57 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste ) ) { - let newBlockHash; - if (global.coinFuncs.blobTypeDero(blob_type_num)) { - newBlockHash = rpcResult.result.blid; - } else if (global.coinFuncs.blobTypeRvn(blob_type_num) || global.coinFuncs.blobTypeErg(blob_type_num)) { - newBlockHash = resultBuff.toString('hex'); - } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { - newBlockHash = rpcResult.result.substr(2); - } else { - newBlockHash = global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex'); - } + const get_block_id = function(cb) { + if (global.coinFuncs.blobTypeDero(blob_type_num)) { + return cb(rpcResult.result.blid); + } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { + return cb(resultBuff.toString('hex')); + } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { + global.coinFuncs.getPortBlockHeaderByID(blockTemplate.port, blockTemplate.height, function(err, body) { + if (err === null && body.powSolutions.pk === blockTemplate.hash2) return cb(body.id); + return cb("0000000000000000000000000000000000000000000000000000000000000000"); + }); + } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { + return cb(rpcResult.result.substr(2)); + } else { + return cb(global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex')); + } + }; - console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + newBlockHash + " found at height " + blockTemplate.height + " by " + miner.logString + - ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + - ", block hex: \n" + blockDataStr - ); + get_block_id(function(newBlockHash) { + console.log(threadName + "New " + blockTemplate.coin + " (port " + blockTemplate.port + ") block " + newBlockHash + " found at height " + blockTemplate.height + " by " + miner.logString + + ", isTrustedShare: " + isTrustedShare + " - submit result: " + JSON.stringify(rpcResult) + + ", block hex: \n" + blockDataStr + ); - const time_now = Date.now(); - if (global.config.daemon.port == blockTemplate.port) { - global.database.storeBlock(blockTemplate.height, global.protos.Block.encode({ - hash: newBlockHash, - difficulty: blockTemplate.difficulty, - shares: 0, - timestamp: time_now, - poolType: miner.poolTypeEnum, - unlocked: false, - valid: true - })); - } else { - global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ - hash: newBlockHash, - difficulty: blockTemplate.difficulty, - shares: 0, - timestamp: time_now, - poolType: miner.poolTypeEnum, - unlocked: false, - valid: true, - port: blockTemplate.port, - height: blockTemplate.height, - anchor_height: anchorBlockHeight - })); - } - - if (submit_blockCB) submit_blockCB(true); + const time_now = Date.now(); + if (global.config.daemon.port == blockTemplate.port) { + global.database.storeBlock(blockTemplate.height, global.protos.Block.encode({ + hash: newBlockHash, + difficulty: blockTemplate.difficulty, + shares: 0, + timestamp: time_now, + poolType: miner.poolTypeEnum, + unlocked: false, + valid: true + })); + } else { + global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ + hash: newBlockHash, + difficulty: blockTemplate.difficulty, + shares: 0, + timestamp: time_now, + poolType: miner.poolTypeEnum, + unlocked: false, + valid: true, + port: blockTemplate.port, + height: blockTemplate.height, + anchor_height: anchorBlockHeight + })); + } + + if (submit_blockCB) submit_blockCB(true); + }); } else { // something not expected happened if (isRetrySubmitBlock) { @@ -1667,7 +1675,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (shareThrottled()) return processShareCB(null); const coinbaseBuffer = Buffer.concat([Buffer.from(blockTemplate.hash, 'hex'), Buffer.from(params.nonce, 'hex')]); const hashes = global.coinFuncs.slowHashBuff(coinbaseBuffer, blockTemplate); - return verifyShareCB(hashEthBuffDiff(hashes[1]), hashes[0], params.nonce, false, true); + return verifyShareCB(hashEthBuffDiff(hashes[1]), null, params.nonce, false, true); } const resultHash = params.result; From c54d873cf8fa027951afda7cfae9662ac846a32b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Aug 2021 07:00:54 +0000 Subject: [PATCH 1452/1496] Added ms timestamp fix --- manage_scripts/altblock_add_auto.js | 1 + 1 file changed, 1 insertion(+) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index 8294641ee..427877c5e 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -31,6 +31,7 @@ require("../init_mini.js").init(function() { console.error("Can't get block timestamp: " + JSON.stringify(body_header)); process.exit(0); } + if ((Date.now() / 1000) < body_header.timestamp) body_header.timestamp /= 1000; if (!body_header.difficulty) { console.error("Can't get block difficilty: " + JSON.stringify(body_header)); process.exit(0); From e2217ec6d87320ab0f8f895d6f093ad4d3138d86 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Aug 2021 07:01:47 +0000 Subject: [PATCH 1453/1496] Added ms timestamp fix --- manage_scripts/altblock_add_auto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index 427877c5e..108c96dc7 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -31,7 +31,7 @@ require("../init_mini.js").init(function() { console.error("Can't get block timestamp: " + JSON.stringify(body_header)); process.exit(0); } - if ((Date.now() / 1000) < body_header.timestamp) body_header.timestamp /= 1000; + if ((Date.now() / 1000) < body_header.timestamp) body_header.timestamp = parseInt(body_header.timestamp / 1000); if (!body_header.difficulty) { console.error("Can't get block difficilty: " + JSON.stringify(body_header)); process.exit(0); From 6330ff85f2d75f87906291dea520b1724011e350 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 9 Aug 2021 16:17:12 +0000 Subject: [PATCH 1454/1496] More ERG debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 95fa63398..0bc6e809f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1491,6 +1491,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste return cb(resultBuff.toString('hex')); } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { global.coinFuncs.getPortBlockHeaderByID(blockTemplate.port, blockTemplate.height, function(err, body) { + console.log("ERG submit: " + JSON.stringify(body)); if (err === null && body.powSolutions.pk === blockTemplate.hash2) return cb(body.id); return cb("0000000000000000000000000000000000000000000000000000000000000000"); }); From 1e5e6b7dbfc810753fae693d19cfe7d89b39d5df Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 10 Aug 2021 14:14:19 +0000 Subject: [PATCH 1455/1496] Added delay to get new ERG block hash --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 0bc6e809f..bbe184372 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1490,7 +1490,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { return cb(resultBuff.toString('hex')); } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { - global.coinFuncs.getPortBlockHeaderByID(blockTemplate.port, blockTemplate.height, function(err, body) { + setTimeout(global.coinFuncs.getPortBlockHeaderByID, 10*1000, blockTemplate.port, blockTemplate.height, function(err, body) { console.log("ERG submit: " + JSON.stringify(body)); if (err === null && body.powSolutions.pk === blockTemplate.hash2) return cb(body.id); return cb("0000000000000000000000000000000000000000000000000000000000000000"); From 31b47a6c5e917df251273fe0461d6391efd91f33 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Aug 2021 16:03:52 +0000 Subject: [PATCH 1456/1496] Added rx/graft support --- lib/coins/xmr.js | 26 +++++++++++--------------- lib/pool.js | 1 + package.json | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e15705038..bec9db58c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -84,7 +84,7 @@ const port2algo = { "13102": "c29i", // XTA "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR - "18981": "cn/rwz", // Graft + "18981": "rx/graft", // Graft "19281": "c29v", // MoneroV "19734": "cn/r", // SUMO "19950": "c29s", // Swap @@ -331,13 +331,12 @@ function Coin(data){ } }); } else if (port == 8766) { - let _this = this; global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); return callback(true, body); } - return _this.getPortAnyBlockHeaderByHash(port, body.result, false, callback); + return global.coinFuncs.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); } else if (port == 8545) { const blockId2 = blockId === "latest" ? blockId : "0x" + blockId.toString(16); @@ -358,13 +357,12 @@ function Coin(data){ }); }); } else if (port == 9053) { - let _this = this; global.support.rpcPortDaemon2(port, 'blocks/at/' + blockId, null, function (body) { if (!body || !(body instanceof Array) || body.length != 1) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); return callback(true, body); } - return _this.getPortAnyBlockHeaderByHash(port, body[0], false, callback); + return global.coinFuncs.getPortAnyBlockHeaderByHash(port, body[0], false, callback); }); } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { @@ -403,14 +401,13 @@ function Coin(data){ return callback(null, body.result); }); } else if (port == 8545) { - let _this = this; global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } body.result.height = parseInt(body.result.number); - _this.getPortBlockHeaderByID(port, body.result.height, function(err, body_height) { + global.coinFuncs.getPortBlockHeaderByID(port, body.result.height, function(err, body_height) { if (err) return callback(true, body); if (body.result.hash === body_height.hash) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'parity_getBlockReceipts', params: [ body.result.number ] }, function (body2) { @@ -424,7 +421,7 @@ function Coin(data){ // uncle block? } else async.eachSeries(Array(16).fill().map((element, index) => body.result.height + index - 7), function(block_height, next) { - _this.getPortBlockHeaderByID(port, block_height, function(err, body_height) { + global.coinFuncs.getPortBlockHeaderByID(port, block_height, function(err, body_height) { if (err) { if (is_our_block) return next(false); // need to wait for more blocks before it will be reported as uncle return next(); @@ -533,17 +530,16 @@ function Coin(data){ } }); } else if (port == 8766) { - let _this = this; global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { console.error("getPortLastBlockHeader(" + port + "): " + JSON.stringify(body)); return callback(true, body); } - if (_this.lastRavenBlockHash === body.result) return callback(null, _this.lastRavenBlock); - _this.getPortAnyBlockHeaderByHash(port, body.result, false, function (err, body2) { + if (global.coinFuncs.lastRavenBlockHash === body.result) return callback(null, global.coinFuncs.lastRavenBlock); + global.coinFuncs.getPortAnyBlockHeaderByHash(port, body.result, false, function (err, body2) { if (err === null) { - _this.lastRavenBlockHash = body.result; - _this.lastRavenBlock = body2; + global.coinFuncs.lastRavenBlockHash = body.result; + global.coinFuncs.lastRavenBlock = body2; } return callback(err, body2); }); @@ -898,7 +894,7 @@ function Coin(data){ if ("autolykos2" in algos_perf) coin_perf["ERG"] = algos_perf["autolykos2"]; - if ("cn/rwz" in algos_perf) coin_perf["GRFT"] = algos_perf["cn/rwz"]; + if ("rx/graft" in algos_perf) coin_perf["GRFT"] = algos_perf["rx/graft"]; if ("cn-heavy/xhv" in algos_perf) coin_perf["XHV"] = coin_perf["BLOC"] = algos_perf["cn-heavy/xhv"]; @@ -956,7 +952,7 @@ function Coin(data){ case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR //case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC - case 18981: return multiHashing.cryptonight(convertedBlob, 14); // Graft + case 18981: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 20); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO case 19994: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 2); // ArqMa case 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala diff --git a/lib/pool.js b/lib/pool.js index bbe184372..ff545f36e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1492,6 +1492,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { setTimeout(global.coinFuncs.getPortBlockHeaderByID, 10*1000, blockTemplate.port, blockTemplate.height, function(err, body) { console.log("ERG submit: " + JSON.stringify(body)); + console.log("ERG submit2: " + blockTemplate.hash2); if (err === null && body.powSolutions.pk === blockTemplate.hash2) return cb(body.id); return cb("0000000000000000000000000000000000000000000000000000000000000000"); }); diff --git a/package.json b/package.json index 11b523ff1..da02265eb 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v24.0.2" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v25.0.0" } } From b31f38818bb42a2ae2d70a725cdbeedd827198e1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Aug 2021 02:26:21 +0000 Subject: [PATCH 1457/1496] Bug fixes --- lib/coins/xmr.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index bec9db58c..b28c2519f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -756,6 +756,7 @@ function Coin(data){ } else if (isExtraNonceBT) { const hash = template.hash; this.hash = this.idHash = this.prev_hash = hash; + this.hash2 = template.hash2; this.block_version = 0; this.nextBlobHex = function () { return hash; }; return; @@ -977,6 +978,7 @@ function Coin(data){ let jsonInput; switch (blockTemplate.port) { case 18081: + case 18981: case 19994: case 11812: case 22023: From 63951734d3945a7b1aa6cbaa318080822e7202da Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Aug 2021 22:01:19 +0000 Subject: [PATCH 1458/1496] Increased verify queue --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b28c2519f..c633807f1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -218,7 +218,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f ++ shareVerifyQueueErrorCount[index]; return return_cb(false); }); - }, 16); + }, 32); setInterval(function(queue_obj, index){ if (queue_obj.length() >= 1000) { From 4f5ae145c4d9fb066348f897297b6116d720bc80 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Aug 2021 22:02:35 +0000 Subject: [PATCH 1459/1496] Increased verify queue --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c633807f1..5e3f81144 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -999,7 +999,7 @@ function Coin(data){ let min_queue_size = null; let max_noerr_time = null; shareVerifyQueue.forEach(function(queue_obj, index) { - if (time_now - shareVerifyQueueErrorTime[index] < 5*60*1000) return; + if (time_now - shareVerifyQueueErrorTime[index] < 1*60*1000) return; const qlength = queue_obj.length() + queue_obj.running(); if (min_queue_size === null || qlength < min_queue_size) { best_index = index; From 30159c1a60d81ce0a972165faa66cd29298eace9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Aug 2021 22:11:42 +0000 Subject: [PATCH 1460/1496] Increased verify queue --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5e3f81144..6476a5020 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -169,7 +169,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f } let timer = setTimeout(function() { socket.destroy(); - if (shareVerifyQueueErrorCount[index] > 10) { + if (shareVerifyQueueErrorCount[index] > 100) { const err_str = "Server " + global.config.hostname + " timeouted share verification to " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -196,7 +196,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f shareVerifyQueueErrorCount[index] = 0; return return_cb(jsonOutput.result); } catch (e) { - if (shareVerifyQueueErrorCount[index] > 10) { + if (shareVerifyQueueErrorCount[index] > 100) { const err_str = "Server " + global.config.hostname + " got wrong JSON from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -209,7 +209,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f socket.on('error', function() { socket.destroy(); - if (shareVerifyQueueErrorCount[index] > 10) { + if (shareVerifyQueueErrorCount[index] > 100) { const err_str = "Server " + global.config.hostname + " got socket error from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -999,7 +999,7 @@ function Coin(data){ let min_queue_size = null; let max_noerr_time = null; shareVerifyQueue.forEach(function(queue_obj, index) { - if (time_now - shareVerifyQueueErrorTime[index] < 1*60*1000) return; + if (time_now - shareVerifyQueueErrorTime[index] < 1*60*1000 && shareVerifyQueueErrorCount[index] > 100) return; const qlength = queue_obj.length() + queue_obj.running(); if (min_queue_size === null || qlength < min_queue_size) { best_index = index; From 3210b1b99625685d1c8d285139314dcf9c52d0b0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Aug 2021 22:16:58 +0000 Subject: [PATCH 1461/1496] Increased verify queue --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 6476a5020..226ad75f4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -218,7 +218,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f ++ shareVerifyQueueErrorCount[index]; return return_cb(false); }); - }, 32); + }, 16); setInterval(function(queue_obj, index){ if (queue_obj.length() >= 1000) { From e24212f0608bed47dd1af3adc2eee70ff1aaea50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Aug 2021 22:23:26 +0000 Subject: [PATCH 1462/1496] Increased verify queue --- lib/coins/xmr.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 226ad75f4..1b3db7401 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -169,7 +169,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f } let timer = setTimeout(function() { socket.destroy(); - if (shareVerifyQueueErrorCount[index] > 100) { + if (shareVerifyQueueErrorCount[index] > 10) { const err_str = "Server " + global.config.hostname + " timeouted share verification to " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -196,7 +196,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f shareVerifyQueueErrorCount[index] = 0; return return_cb(jsonOutput.result); } catch (e) { - if (shareVerifyQueueErrorCount[index] > 100) { + if (shareVerifyQueueErrorCount[index] > 10) { const err_str = "Server " + global.config.hostname + " got wrong JSON from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -209,7 +209,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f socket.on('error', function() { socket.destroy(); - if (shareVerifyQueueErrorCount[index] > 100) { + if (shareVerifyQueueErrorCount[index] > 10) { const err_str = "Server " + global.config.hostname + " got socket error from " + verify_shares_host; console.error(err_str); global.support.sendEmail(global.config.general.adminEmail, "FYI: Can't verify share", err_str); @@ -999,7 +999,7 @@ function Coin(data){ let min_queue_size = null; let max_noerr_time = null; shareVerifyQueue.forEach(function(queue_obj, index) { - if (time_now - shareVerifyQueueErrorTime[index] < 1*60*1000 && shareVerifyQueueErrorCount[index] > 100) return; + if (time_now - shareVerifyQueueErrorTime[index] < 1*60*1000 && shareVerifyQueueErrorCount[index] > 10) return; const qlength = queue_obj.length() + queue_obj.running(); if (min_queue_size === null || qlength < min_queue_size) { best_index = index; From 01593406c9c5ec80cb7d8bc5279ff3cd6303424e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 31 Aug 2021 18:53:59 +0000 Subject: [PATCH 1463/1496] Added external wallet support --- deployment/base.sql | 4 ++++ lib/support.js | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 945811e74..d01ae6a02 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -246,6 +246,10 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'verifyHost', '', 'string', 'Use to extra daemon height verify check'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_18081', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_8545', '127.0.0.1', 'string', 'ETH Daemon RPC Wallet IP'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_8766', '127.0.0.1', 'string', 'RVN Daemon RPC Wallet IP'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_9053', '127.0.0.1', 'string', 'ERG Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '18082', 'int', 'Monero Daemon RPC Wallet Port'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('rpc', 'https', 'false', 'bool', 'Enable RPC over SSL'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'maxDifficulty', '10000000000000', 'int', 'Maximum difficulty for VarDiff'); diff --git a/lib/support.js b/lib/support.js index 222c896f5..e65805479 100644 --- a/lib/support.js +++ b/lib/support.js @@ -294,6 +294,12 @@ function tsCompare(a, b) { return 0; } +function port_wallet_ip(port) { + const ip = global.config.wallet["address_" + port.toString()]; + if (ip) return ip; + return global.config.wallet.address; +} + module.exports = function () { return { rpcDaemon: function (method, params, callback) { @@ -306,19 +312,19 @@ module.exports = function () { rpc2(global.config.daemon.address, port, method, params, callback, 30*1000); }, rpcWallet: function (method, params, callback) { - rpc(global.config.wallet.address, global.config.wallet.port, method, params, callback, 30*60*1000); + rpc(port_wallet_ip(global.config.wallet.port), global.config.wallet.port, method, params, callback, 30*60*1000); }, rpcPortWallet: function (port, method, params, callback) { - rpc(global.config.wallet.address, port, method, params, callback, 30*60*1000); + rpc(port_wallet_ip(port), port, method, params, callback, 30*60*1000); }, rpcPortWallet2: function (port, method, params, callback) { - rpc2(global.config.wallet.address, port, method, params, callback, 30*60*1000); + rpc2(port_wallet_ip(port), port, method, params, callback, 30*60*1000); }, rpcPortWalletShort: function (port, method, params, callback) { - rpc(global.config.wallet.address, port, method, params, callback, 10*1000); + rpc(port_wallet_ip(port), port, method, params, callback, 10*1000); }, rpcPortWalletShort2: function (port, method, params, callback) { - rpc2(global.config.wallet.address, port, method, params, callback, 10*1000); + rpc2(port_wallet_ip(port), port, method, params, callback, 10*1000); }, circularBuffer: circularBuffer, formatDate: formatDate, From 47d7ecffeccce319313fcb298b324f89639be2a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 1 Sep 2021 03:39:07 +0000 Subject: [PATCH 1464/1496] Added LMDB size param --- deployment/base.sql | 1 + lib/local_comms.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index d01ae6a02..c95759566 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -340,6 +340,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'timerRetry', '25', 'int', 'Number of minutes between payment daemon retrying due to not enough funds'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'priority', '1', 'int', 'Payout priority setting. 0 = use default (4x fee); 1 = low prio (1x fee)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'allowStuckPoolKill', 'false', 'bool', 'Allow to kill the pool in case of stuck block template'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'dbSizeGB', '24', 'int', 'LMDB size in GBs'); INSERT INTO pool.users (username, pass, email, admin, payout_threshold) VALUES ('Administrator', null, 'Password123', 1, 0); INSERT INTO pool.port_config (poolPort, difficulty, portDesc, portType, hidden, `ssl`) VALUES (3333, 1000, 'Low-End Hardware (Up to 30-40 h/s)', 'pplns', 0, 0); INSERT INTO pool.port_config (poolPort, difficulty, portDesc, portType, hidden, `ssl`) VALUES (5555, 5000, 'Medium-Range Hardware (Up to 160 h/s)', 'pplns', 0, 0); diff --git a/lib/local_comms.js b/lib/local_comms.js index 5fb90ef7e..43148f7d3 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -30,7 +30,7 @@ function Database(){ global.database.env.open({ path: global.config.db_storage_path, maxDbs: 10, - mapSize: 16 * 1024 * 1024 * 1024, + mapSize: global.config.general.dbSizeGB * 1024 * 1024 * 1024, useWritemap: true, maxReaders: 512 }); From b7d677325cf1b62f5bc25864bfa3b250e470ae76 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 1 Sep 2021 17:43:16 +0000 Subject: [PATCH 1465/1496] Fixed typo --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index c95759566..9b4b7ecd1 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -246,7 +246,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'verifyHost', '', 'string', 'Use to extra daemon height verify check'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_18081', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_18082', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_8545', '127.0.0.1', 'string', 'ETH Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_8766', '127.0.0.1', 'string', 'RVN Daemon RPC Wallet IP'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address_9053', '127.0.0.1', 'string', 'ERG Daemon RPC Wallet IP'); From 6aa6661b14bcdcee2a06ec94e8bcceb1c0c66a42 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 10 Sep 2021 22:55:28 +0000 Subject: [PATCH 1466/1496] Updated moenro daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 4de6a0456..99e5aadf2 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.2.0 +sudo git checkout v0.17.3.0 sudo git submodule update --init USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make -j$(nproc) release || USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index ed1d85017..0c55e7018 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.2.0 +sudo git checkout v0.17.3.0 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 1b6102a4c..864e1bb21 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.2.0 +sudo git checkout v0.17.3.0 sudo git submodule update --init sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index e4a3f83bb..2c6a17204 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.2.0 &&\ +sudo git checkout v0.17.3.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From 80eb971fb5c9fb2df37b111049b54b3eab6c725e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 10 Sep 2021 22:58:16 +0000 Subject: [PATCH 1467/1496] Updated moenro daemon --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 99e5aadf2..9bfa07da0 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.3.0 +sudo git checkout v0.17.2.3 sudo git submodule update --init USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make -j$(nproc) release || USE_SINGLE_BUILDDIR=1 sudo --preserve-env=USE_SINGLE_BUILDDIR make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 0c55e7018..98e6aaab5 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -21,7 +21,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone --recursive https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.3.0 +sudo git checkout v0.17.2.3 sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 864e1bb21..792cf895f 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -17,7 +17,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.17.3.0 +sudo git checkout v0.17.2.3 sudo git submodule update --init sudo USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || sudo USE_SINGLE_BUILDDIR=1 make release || exit 0 sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 2c6a17204..5068725c0 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.3.0 &&\ +sudo git checkout v0.17.2.3 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From d76db565b6707a550af6a26723a34f9daf5df030 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Sep 2021 06:34:59 +0000 Subject: [PATCH 1468/1496] Improved cache cleaning --- lib/longRunner.js | 54 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 0498a4d50..a4eb56bd9 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -3,10 +3,11 @@ const async = require("async"); function cleanCacheDB() { - console.log("Cleaning up the cache DB"); - let count = 0; + console.log("Cleaning up the cache DB. Searching for items to delete/update"); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.cacheDB); + let updated = {}; + let deleted = []; for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentString(function(key, data){ // jshint ignore:line if (key.length < global.config.pool.address.length) return; // min XMR address length @@ -24,10 +25,7 @@ function cleanCacheDB() { if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; } if (!isAlive) { - data2 = []; - let txn2 = global.database.env.beginTxn(); - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn2.commit(); + updated{key} = JSON.stringify([]); } } catch (e) { @@ -39,12 +37,9 @@ function cleanCacheDB() { if (!stats) return; if (!global.database.getCache("history:" + key)) return; if (Date.now() - stats.lastHash > 7*24*60*60*1000) { - let txn2 = global.database.env.beginTxn(); - txn2.del(global.database.cacheDB, key); - txn2.del(global.database.cacheDB, "history:" + key); - txn2.del(global.database.cacheDB, "stats:" + key); - txn2.commit(); - ++ count; + deleted.push(key); + deleted.push("history:" + key); + deleted.push("stats:" + key); } } else if (!key.includes("_") && key.includes("stats:")) { // zero frozen account hashrate after 24h @@ -52,9 +47,7 @@ function cleanCacheDB() { let data2 = JSON.parse(data); if ((data2.hash || data2.hash2) && Date.now() - data2.lastHash > 24*60*60*1000) { data2.hash = data2.hash2 = 0; - let txn2 = global.database.env.beginTxn(); - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn2.commit(); + updated{key} = JSON.stringify(data2); } } catch (e) { console.error("Bad cache data with " + key + " key"); @@ -66,7 +59,36 @@ function cleanCacheDB() { cursor.close(); txn.commit(); - console.log("Deleted cache items: " + count); + + console.log("Deleting cache items: " + deleted.length); + + let chunkSize = 0; + txn = global.database.env.beginTxn(); + deleted.forEach(function(key) { + ++ chunkSize; + txn.del(global.database.cacheDB, key); + if (chunkSize > 500) { + txn.commit(); + txn = global.database.env.beginTxn(); + chunkSize = 0; + } + }); + txn.commit(); + + console.log("Updating cache items: " + Object.keys(updated).length); + + chunkSize = 0; + txn = global.database.env.beginTxn(); + for (const [key, value] of updated.entries()) { + ++ chunkSize; + txn2.putString(global.database.cacheDB, key, value); + if (chunkSize > 500) { + txn.commit(); + txn = global.database.env.beginTxn(); + chunkSize = 0; + } + } + txn.commit(); } let saw_block_hash_before = {}; From 691764b5f227b0b7aebbba4a1aa4f39088f2a9a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Sep 2021 06:37:06 +0000 Subject: [PATCH 1469/1496] Improved cache cleaning --- lib/longRunner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index a4eb56bd9..43847f02f 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -25,7 +25,7 @@ function cleanCacheDB() { if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; } if (!isAlive) { - updated{key} = JSON.stringify([]); + updated[key] = JSON.stringify([]); } } catch (e) { @@ -47,7 +47,7 @@ function cleanCacheDB() { let data2 = JSON.parse(data); if ((data2.hash || data2.hash2) && Date.now() - data2.lastHash > 24*60*60*1000) { data2.hash = data2.hash2 = 0; - updated{key} = JSON.stringify(data2); + updated[key] = JSON.stringify(data2); } } catch (e) { console.error("Bad cache data with " + key + " key"); From 09a2b7f0bcfad914b9bc3bdbcf09b6fc5a90199a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Sep 2021 06:42:46 +0000 Subject: [PATCH 1470/1496] Improved cache cleaning --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 43847f02f..c8a2cb279 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -79,7 +79,7 @@ function cleanCacheDB() { chunkSize = 0; txn = global.database.env.beginTxn(); - for (const [key, value] of updated.entries()) { + for (const [key, value] of Object.entries(updated)) { ++ chunkSize; txn2.putString(global.database.cacheDB, key, value); if (chunkSize > 500) { From 0ead15781ed0d0d0611bc371a8eff77458799ec3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Sep 2021 06:45:46 +0000 Subject: [PATCH 1471/1496] Improved cache cleaning --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index c8a2cb279..c6bdcfb2c 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -81,7 +81,7 @@ function cleanCacheDB() { txn = global.database.env.beginTxn(); for (const [key, value] of Object.entries(updated)) { ++ chunkSize; - txn2.putString(global.database.cacheDB, key, value); + txn.putString(global.database.cacheDB, key, value); if (chunkSize > 500) { txn.commit(); txn = global.database.env.beginTxn(); From 2089c8ec30d241caa560a9d3d99e2e3181374fc9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 26 Sep 2021 14:50:43 +0000 Subject: [PATCH 1472/1496] Increased time between monerod restarts --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ff545f36e..9162ca83e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2368,7 +2368,7 @@ if (cluster.isMaster) { console.error("!!! Current block height " + height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + port + " port"); if (!(port in lastBlockFixTime)) lastBlockFixTime[port] = Date.now(); - if (Date.now() - lastBlockFixTime[port] > 5*60*1000) { + if (Date.now() - lastBlockFixTime[port] > 20*60*1000) { if (!(port in lastBlockFixCount)) lastBlockFixCount[port] = 1; else ++ lastBlockFixCount[port]; From 8c12993a8b991a73f125aa13dc68cceeaf6109bb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Nov 2021 19:41:27 +0000 Subject: [PATCH 1473/1496] Fixed N calc for ERG --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da02265eb..fda03c0b6 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v25.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v25.0.1" } } From 677410b9b0102f27e27b7c11451b4790d87e366c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 7 Nov 2021 19:52:55 +0000 Subject: [PATCH 1474/1496] Fixed N calc for ERG --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fda03c0b6..9dc9df364 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v25.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v25.0.2" } } From 2ba2db6f43211a5cc3ae5560c1c81ae2082b451b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Nov 2021 15:42:39 +0000 Subject: [PATCH 1475/1496] Up utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9dc9df364..e54fe8cce 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.0.3", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.1.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v25.0.2" } } From 8c87aae0b3322fe611b1e071bfc451c5f1ac73f5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 19:26:54 +0000 Subject: [PATCH 1476/1496] GR support --- lib/coins/xmr.js | 113 +++++++++++++++++++++++++++-------------------- lib/pool.js | 6 +-- package.json | 4 +- 3 files changed, 69 insertions(+), 54 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1b3db7401..a39846663 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -46,6 +46,7 @@ const port2coin = { "8545" : "ETH", "2086" : "BLOC", "9053" : "ERG", + "9998" : "RTM", }; const port2blob_num = { // "11181": 7, // AEON @@ -74,6 +75,7 @@ const port2blob_num = { "8545" : 102, // ETH "2086" : 1, // BLOC "9053" : 103, // ERG + "9998" : 104, // RTM }; const port2algo = { @@ -103,6 +105,7 @@ const port2algo = { "8545" : "ethash", // ETH "2086" : "cn-heavy/xhv", // BLOC "9053" : "autolykos2", // ERG + "9998" : "ghostrider", // RTM }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -330,7 +333,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766) { + } else if (port == 8766 || port == 9998) { global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); @@ -391,13 +394,13 @@ function Coin(data){ } return callback(null, body); }); - } else if (port == 8766) { + } else if (port == 8766 || port == 9998) { global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - body.result.reward = 5000 * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 + body.result.reward = (port == 8766 ? 5000 : 3750) * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 return callback(null, body.result); }); } else if (port == 8545) { @@ -529,7 +532,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766) { + } else if (port == 8766 || port == 9998) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { console.error("getPortLastBlockHeader(" + port + "): " + JSON.stringify(body)); @@ -581,7 +584,7 @@ function Coin(data){ return callback(body ? body : null); }); - } else if (port == 8766) { + } else if (port == 8766 || port == 9998) { global.support.rpcPortDaemon2(port, '', { method: 'getblocktemplate', params: [{ @@ -672,13 +675,17 @@ function Coin(data){ this.blobTypeErg = function(blob_type_num) { return blob_type_num == 103; } - this.convertBlob = function(blobBuffer, port) { + this.blobTypeRtm = function(blob_type_num) { return blob_type_num == 104; } + + this.convertBlob = function(blobBuffer, port, bt) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; let blob; try { if (this.blobTypeRvn(blob_type_num)) { blob = cnUtil.convertRavenBlob(blobBuffer); + } else if (this.blobTypeRtm(blob_type_num)) { + blob = cnUtil.convertRtmBlob(blobBuffer); } else { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); } @@ -705,6 +712,8 @@ function Coin(data){ bignum(params.nonce, 16).toBuffer({endian: 'little', size: 8}), bignum(params.mixhash, 16).toBuffer({endian: 'little', size: 32}) ); + } else if (global.coinFuncs.blobTypeRtm(blob_type_num)) { + return cnUtil.constructNewRtmBlob(blockTemplate, Buffer.from(params.nonce, 'hex')); } else { return cnUtil.construct_block_blob(blockTemplate, Buffer.from(params.nonce, 'hex'), blob_type_num); } @@ -747,22 +756,24 @@ function Coin(data){ this.port = template.port; const port_blob_num = port2blob_num[this.port]; - const isExtraNonceBT = global.coinFuncs.blobTypeEth(port_blob_num) || global.coinFuncs.blobTypeErg(port_blob_num); if (template.blocktemplate_blob) { this.blocktemplate_blob = template.blocktemplate_blob; } else if (template.blob) { this.blocktemplate_blob = template.blob; - } else if (isExtraNonceBT) { - const hash = template.hash; - this.hash = this.idHash = this.prev_hash = hash; - this.hash2 = template.hash2; - this.block_version = 0; - this.nextBlobHex = function () { return hash; }; - return; } else { - console.error("INTERNAL ERROR: No blob in " + this.port + " port block template: " + JSON.stringify(template)); - this.blocktemplate_blob = extra_nonce_mm_template_hex; // to avoid hard crash + const isExtraNonceBT = global.coinFuncs.blobTypeEth(port_blob_num) || global.coinFuncs.blobTypeErg(port_blob_num); + if (isExtraNonceBT) { + const hash = template.hash; + this.hash = this.idHash = this.prev_hash = hash; + this.hash2 = template.hash2; + this.block_version = 0; + this.nextBlobHex = function () { return hash; }; + return; + } else { + console.error("INTERNAL ERROR: No blob in " + this.port + " port block template: " + JSON.stringify(template)); + this.blocktemplate_blob = extra_nonce_mm_template_hex; // to avoid hard crash + } } const is_mm = "child_template" in template; @@ -781,37 +792,39 @@ function Coin(data){ this.buffer = Buffer.from(blob, 'hex'); this.block_version = this.buffer[0]; - if (!is_dero) { - const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; - const found_reserved_offset_template = blob.indexOf(template_hex); - - if (found_reserved_offset_template !== -1) { - const found_reserved_offset = (found_reserved_offset_template >> 1) + 2; - if (is_mm) { - this.reserved_offset = found_reserved_offset; - } else { - if (template.reserved_offset) { - // here we are OK with +1 difference because we put extra byte into pool_nonce_size - if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { - console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in " + this.port + " block " + ": " + blob); - } - this.reserved_offset = template.reserved_offset; - } else if (template.reservedOffset) { - // here we are OK with +1 difference because we put extra byte into pool_nonce_size - if (found_reserved_offset != template.reservedOffset && found_reserved_offset + 1 != template.reservedOffset) { - console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reservedOffset + " reported by daemon in " + this.port + " block " + ": " + blob); - } - this.reserved_offset = template.reservedOffset; - } else { - this.reserved_offset = found_reserved_offset; - } - } - } else { - //console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in " + this.port + " block " + ": " + blob); - this.reserved_offset = template.reserved_offset ? template.reserved_offset : template.reservedOffset; - } - } else { // exception for DERO - this.reserved_offset = template.reserved_offset + 1; + if (global.coinFuncs.blobTypeRvn(port_blob_num) || global.coinFuncs.blobTypeRtm(port_blob_num)) { + this.reserved_offset = template.reserved_offset; + } else if (is_dero) { // exception for DERO + this.reserved_offset = template.reserved_offset + 1; + } else { + const template_hex = (template.port in mm_port_set && !is_mm) ? extra_nonce_mm_template_hex : extra_nonce_template_hex; + const found_reserved_offset_template = blob.indexOf(template_hex); + + if (found_reserved_offset_template !== -1) { + const found_reserved_offset = (found_reserved_offset_template >> 1) + 2; + if (is_mm) { + this.reserved_offset = found_reserved_offset; + } else { + if (template.reserved_offset) { + // here we are OK with +1 difference because we put extra byte into pool_nonce_size + if (found_reserved_offset != template.reserved_offset && found_reserved_offset + 1 != template.reserved_offset) { + console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reserved_offset + " reported by daemon in " + this.port + " block " + ": " + blob); + } + this.reserved_offset = template.reserved_offset; + } else if (template.reservedOffset) { + // here we are OK with +1 difference because we put extra byte into pool_nonce_size + if (found_reserved_offset != template.reservedOffset && found_reserved_offset + 1 != template.reservedOffset) { + console.error("INTERNAL ERROR: Found reserved offset " + found_reserved_offset + " do not match " + template.reservedOffset + " reported by daemon in " + this.port + " block " + ": " + blob); + } + this.reserved_offset = template.reservedOffset; + } else { + this.reserved_offset = found_reserved_offset; + } + } + } else { + //console.error("INTERNAL ERROR: Can not find reserved offset template '" + template_hex + "' in " + this.port + " block " + ": " + blob); + this.reserved_offset = template.reserved_offset ? template.reserved_offset : template.reservedOffset; + } } if (!this.reserved_offset) { @@ -841,7 +854,7 @@ function Coin(data){ // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserved_offset); // Convert the buffer into something hashable. - const blob = global.coinFuncs.convertBlob(this.buffer, this.port); + const blob = global.coinFuncs.convertBlob(this.buffer, this.port, this); return blob ? blob.toString('hex') : null; }; // Make it so you can get the raw block buffer out. @@ -942,6 +955,7 @@ function Coin(data){ switch (blockTemplate.port) { case 2086: return multiHashing.cryptonight_heavy(convertedBlob, 1); // BLOC case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN + case 9998: return multiHashing.cryptonight(convertedBlob, 18); // RTM case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH case 9053: return multiHashing.autolykos2_hashes(convertedBlob, blockTemplate.height); // ERG case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ @@ -1048,7 +1062,8 @@ function Coin(data){ case 8545: return "eth"; // ETH case 8766: return "raven"; // RVN case 9053: return "erg"; // ERG - case 9231 : return "cryptonote_loki"; // XEQ + case 9231: return "cryptonote_loki"; // XEQ + case 9998: return "raptoreum"; // RTM //case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium diff --git a/lib/pool.js b/lib/pool.js index 9162ca83e..02713d9f4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1562,7 +1562,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste if (blockTemplate.port == 11898) { global.support.rpcPortDaemon2(blockTemplate.port, "block", blockData.toString('hex'), reply_fn); - } else if (global.coinFuncs.blobTypeRvn(job.blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(job.blob_type_num) || global.coinFuncs.blobTypeRtm(job.blob_type_num)) { global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "submitblock", params: [ blockData.toString('hex') ] }, reply_fn); } else if (global.coinFuncs.blobTypeEth(job.blob_type_num)) { global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "parity_submitWorkDetail", params: blockData, jsonrpc: "2.0", id: 0 }, reply_fn); @@ -2016,7 +2016,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } for (const param of params) if (typeof param !== 'string') { - sendReply("No correct params specified"); + sendReply("Not correct params specified"); return; } @@ -2024,7 +2024,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se job_id: params[1], raw_params: params }; else { - sendReply("No correct params specified"); + sendReply("Not correct params specified"); return; } diff --git a/package.json b/package.json index e54fe8cce..708a57ad4 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v10.1.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v25.0.2" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.0.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From 72d08a9d6c1073d4edcbee70819ba27f459e8ae5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 19:30:49 +0000 Subject: [PATCH 1477/1496] GR support --- deployment/base.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 9b4b7ecd1..b48f04709 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -243,6 +243,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorETH', '0', 'float', 'ETH algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorBLOC', '0', 'float', 'BLOC algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorERG', '0', 'float', 'ERG algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorRTM', '0', 'float', 'RTM algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'enableAlgoSwitching', 'false', 'bool', 'Enable smart miners (need additional altblockManager module)'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'verifyHost', '', 'string', 'Use to extra daemon height verify check'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Monero Daemon RPC Wallet IP'); @@ -314,6 +315,7 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_8545', '', 'string', 'Address to mine to for 8545 (Ethereum) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_2086', '', 'string', 'Address to mine to for 2086 (BLOC) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9053', '', 'string', 'Address to mine to for 9053 (ERG) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9998', '', 'string', 'Address to mine to for 9998 (RTM) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'cmcKey', '', 'string', 'CMC API Key for notification'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'mailgunKey', '', 'string', 'MailGun API Key for notification'); From fbc25e3a4eff8df6fcb611e73b50ac8f65020ad1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 19:58:35 +0000 Subject: [PATCH 1478/1496] GR support --- README.md | 1 + lib/worker.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 133a4b915..5cc0712e9 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,7 @@ If you'd like to make a one time donation, the addresses are as follows: * CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` * BLOC - ```abLoc5iUG4a6oAb2dqygxkS5M2uHWx16zHb9fUWMzpSEDwm6T7PSq2MLdHonWZ16CGfnJKRomq75aZyviTo6ZjHeYQMzNAEkjMg``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` +* RTM - ```RUCyaEZxQu3Eure73XPQ57si813RYAMQKC``` * ERG - ```9fe533kUzAE57YfPP6o3nzsYMKN2W2uCxvg8KG8Vn5DDeJGetRw``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` diff --git a/lib/worker.js b/lib/worker.js index 14ddddaaf..f8c03058e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -4,7 +4,7 @@ const sprintf = require("sprintf-js").sprintf; let cycleCount = 0; let hashrate_avg_min = 10; -let stat_change_alert = 0.3; +let stat_change_alert = 0.6; let prev_pool_state_time; let prev_pool_hashrate; From 8345ac68017225f238de593f07279b4900ce5c65 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 20:25:55 +0000 Subject: [PATCH 1479/1496] GR support --- lib/coins/xmr.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a39846663..8de1989d0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -592,7 +592,10 @@ function Coin(data){ rules: [ "segwit" ] }] }, function(body) { - return callback(body && body.result ? cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()]) : null); + if (body && body.result) switch (port) { + case 8766: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()]) : null); + case 9998: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()]) : null); + } else return callback(null); }); } else if (port == 8545) { From d1bf15ea47748ee2545c621bbdb7f5f5648335ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 20:26:39 +0000 Subject: [PATCH 1480/1496] GR support --- lib/coins/xmr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8de1989d0..ee31e9835 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -593,8 +593,8 @@ function Coin(data){ }] }, function(body) { if (body && body.result) switch (port) { - case 8766: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()]) : null); - case 9998: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()]) : null); + case 8766: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); + case 9998: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); } else return callback(null); }); From 4e6118bc36157e162d93087c0584d69e8c566074 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 20:31:09 +0000 Subject: [PATCH 1481/1496] GR support --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ee31e9835..4bd3f8dfc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -401,6 +401,7 @@ function Coin(data){ return callback(true, body); } body.result.reward = (port == 8766 ? 5000 : 3750) * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 + if (port == 9998) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); } else if (port == 8545) { From 182e6667b6168dbe92be5be3371b37bf5d4eef2a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 20:37:53 +0000 Subject: [PATCH 1482/1496] GR support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4bd3f8dfc..f1794ba66 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -593,7 +593,7 @@ function Coin(data){ rules: [ "segwit" ] }] }, function(body) { - if (body && body.result) switch (port) { + if (body && body.result) switch (parseInt(port)) { case 8766: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); case 9998: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); } else return callback(null); From 30d899e07c5e6656976924cbb57054e0e0ac65af Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 21:09:01 +0000 Subject: [PATCH 1483/1496] GR support --- lib/coins/xmr.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f1794ba66..72443de33 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -908,6 +908,8 @@ function Coin(data){ if ("kawpow" in algos_perf) coin_perf["RVN"] = algos_perf["kawpow"]; + if ("ghostrider" in algos_perf) coin_perf["RTM"] = algos_perf["ghostrider"]; + if ("ethash" in algos_perf) coin_perf["ETH"] = algos_perf["ethash"]; if ("autolykos2" in algos_perf) coin_perf["ERG"] = algos_perf["autolykos2"]; From 4e0004a4cbd2745e08c4c81fd53a420a22cb2287 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 21:34:17 +0000 Subject: [PATCH 1484/1496] GR support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 72443de33..1e42ccf01 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -717,7 +717,7 @@ function Coin(data){ bignum(params.mixhash, 16).toBuffer({endian: 'little', size: 32}) ); } else if (global.coinFuncs.blobTypeRtm(blob_type_num)) { - return cnUtil.constructNewRtmBlob(blockTemplate, Buffer.from(params.nonce, 'hex')); + return cnUtil.constructNewRtmBlob(blockTemplate, Buffer.from(params.nonce, 'hex').reverse()); } else { return cnUtil.construct_block_blob(blockTemplate, Buffer.from(params.nonce, 'hex'), blob_type_num); } From 5292088940c1e04619478959be612f1176ff39cc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 21:36:55 +0000 Subject: [PATCH 1485/1496] GR support --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1e42ccf01..3c88fd7cd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -958,6 +958,7 @@ function Coin(data){ } this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { + console.log("!!!" + convertedBlob.toString('hex')); switch (blockTemplate.port) { case 2086: return multiHashing.cryptonight_heavy(convertedBlob, 1); // BLOC case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN From f0c056c187ae7e0d5a4e14995d3db5fce5a49e49 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 21:46:07 +0000 Subject: [PATCH 1486/1496] GR support --- lib/coins/xmr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3c88fd7cd..b15656c71 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -717,7 +717,7 @@ function Coin(data){ bignum(params.mixhash, 16).toBuffer({endian: 'little', size: 32}) ); } else if (global.coinFuncs.blobTypeRtm(blob_type_num)) { - return cnUtil.constructNewRtmBlob(blockTemplate, Buffer.from(params.nonce, 'hex').reverse()); + return cnUtil.constructNewRtmBlob(blockTemplate, Buffer.from(params.nonce, 'hex')); } else { return cnUtil.construct_block_blob(blockTemplate, Buffer.from(params.nonce, 'hex'), blob_type_num); } From a0851d26caa810b1918c108b35c3645975bceb02 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 22:01:59 +0000 Subject: [PATCH 1487/1496] GR support --- lib/coins/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b15656c71..d07fa06a4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -681,7 +681,7 @@ function Coin(data){ this.blobTypeRtm = function(blob_type_num) { return blob_type_num == 104; } - this.convertBlob = function(blobBuffer, port, bt) { + this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; let blob; @@ -689,6 +689,7 @@ function Coin(data){ if (this.blobTypeRvn(blob_type_num)) { blob = cnUtil.convertRavenBlob(blobBuffer); } else if (this.blobTypeRtm(blob_type_num)) { + console.log("!!!b " + blobBuffer.toString('hex')); blob = cnUtil.convertRtmBlob(blobBuffer); } else { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); @@ -858,7 +859,7 @@ function Coin(data){ // Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset. this.buffer.writeUInt32BE(++this.extraNonce, this.reserved_offset); // Convert the buffer into something hashable. - const blob = global.coinFuncs.convertBlob(this.buffer, this.port, this); + const blob = global.coinFuncs.convertBlob(this.buffer, this.port); return blob ? blob.toString('hex') : null; }; // Make it so you can get the raw block buffer out. From 14e01178d778be88a25f008c7c2c9930058fab94 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 22:41:07 +0000 Subject: [PATCH 1488/1496] GR support --- lib/coins/xmr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d07fa06a4..ad449adfe 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -595,7 +595,9 @@ function Coin(data){ }, function(body) { if (body && body.result) switch (parseInt(port)) { case 8766: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); - case 9998: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); + case 9998: +console.log("!!! " + JSON.stringify(body.result)); + return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); } else return callback(null); }); From 0b40678db0fffd1b357eb9b8458378fec5d8a50b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Nov 2021 23:12:50 +0000 Subject: [PATCH 1489/1496] GR support --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ad449adfe..d8e83977a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -693,6 +693,7 @@ console.log("!!! " + JSON.stringify(body.result)); } else if (this.blobTypeRtm(blob_type_num)) { console.log("!!!b " + blobBuffer.toString('hex')); blob = cnUtil.convertRtmBlob(blobBuffer); + console.log("!!!b2 " + blob.toString('hex')); } else { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); } From c8a84fee9132abd42ac02ad1b118457259e98783 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 1 Dec 2021 01:00:20 +0000 Subject: [PATCH 1490/1496] GR support --- lib/coins/xmr.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d8e83977a..dae94b9dc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -595,9 +595,7 @@ function Coin(data){ }, function(body) { if (body && body.result) switch (parseInt(port)) { case 8766: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); - case 9998: -console.log("!!! " + JSON.stringify(body.result)); - return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); + case 9998: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); } else return callback(null); }); @@ -691,9 +689,7 @@ console.log("!!! " + JSON.stringify(body.result)); if (this.blobTypeRvn(blob_type_num)) { blob = cnUtil.convertRavenBlob(blobBuffer); } else if (this.blobTypeRtm(blob_type_num)) { - console.log("!!!b " + blobBuffer.toString('hex')); blob = cnUtil.convertRtmBlob(blobBuffer); - console.log("!!!b2 " + blob.toString('hex')); } else { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); } @@ -962,7 +958,6 @@ console.log("!!! " + JSON.stringify(body.result)); } this.slowHashBuff = function(convertedBlob, blockTemplate, nonce, mixhash) { - console.log("!!!" + convertedBlob.toString('hex')); switch (blockTemplate.port) { case 2086: return multiHashing.cryptonight_heavy(convertedBlob, 1); // BLOC case 8766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // RVN From 09d9f48afa1274843714e3c67c00485477645658 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 1 Dec 2021 20:41:51 +0000 Subject: [PATCH 1491/1496] Blob fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 708a57ad4..c063d2164 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From 2784b83ced84dd4e9557008c36e55596051b994f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Dec 2021 01:12:44 +0000 Subject: [PATCH 1492/1496] Added RTM block ID function --- lib/coins/xmr.js | 4 ++++ lib/pool.js | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index dae94b9dc..51dbd8b2c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -738,6 +738,10 @@ function Coin(data){ return cnUtil.get_block_id(blockBuffer, blob_type_num); }; + this.blockHashBuff = function(blockBuffer){ + return cnUtil.blockHashBuff(blockBuffer); + }; + this.BlockTemplate = function(template) { // Generating a block template is a simple thing. Ask for a boatload of information, and go from there. // Important things to consider. diff --git a/lib/pool.js b/lib/pool.js index 02713d9f4..6ff58ab2c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1489,10 +1489,10 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste return cb(rpcResult.result.blid); } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { return cb(resultBuff.toString('hex')); + } else if (global.coinFuncs.blobTypeRtm(blob_type_num)) { + return cb(global.coinFuncs.blockHashBuff(resultBuff).toString('hex')); } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { setTimeout(global.coinFuncs.getPortBlockHeaderByID, 10*1000, blockTemplate.port, blockTemplate.height, function(err, body) { - console.log("ERG submit: " + JSON.stringify(body)); - console.log("ERG submit2: " + blockTemplate.hash2); if (err === null && body.powSolutions.pk === blockTemplate.hash2) return cb(body.id); return cb("0000000000000000000000000000000000000000000000000000000000000000"); }); diff --git a/package.json b/package.json index c063d2164..05819584f 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.0.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From 98b7eeafb09afa9b1f172ce9fcb6af3b20eb4f9d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Dec 2021 01:23:32 +0000 Subject: [PATCH 1493/1496] Adapted for RTM --- manage_scripts/altblock_add_auto.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index 108c96dc7..fafe2f9a7 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -27,6 +27,8 @@ require("../init_mini.js").init(function() { console.error("body:" + JSON.stringify(body_header)); process.exit(0); } + if (!body_header.timestamp) body_header.timestamp = body_header.time; + if (!body_header.timestamp) body_header.timestamp = body_header.mediantime; if (!body_header.timestamp) { console.error("Can't get block timestamp: " + JSON.stringify(body_header)); process.exit(0); From 6e7c0405b27be0d8ea3a688e8ad9cb22f9c9b08f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 9 Dec 2021 15:21:59 +0000 Subject: [PATCH 1494/1496] Added RTM block ID function --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6ff58ab2c..0f1bbc0e1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1490,7 +1490,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { return cb(resultBuff.toString('hex')); } else if (global.coinFuncs.blobTypeRtm(blob_type_num)) { - return cb(global.coinFuncs.blockHashBuff(resultBuff).toString('hex')); + return cb(resultBuff.toString('hex')); } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { setTimeout(global.coinFuncs.getPortBlockHeaderByID, 10*1000, blockTemplate.port, blockTemplate.height, function(err, body) { if (err === null && body.powSolutions.pk === blockTemplate.hash2) return cb(body.id); From 637ceb98afffe29df6c7813376a5313f5176f4c3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 12 Dec 2021 02:59:57 +0000 Subject: [PATCH 1495/1496] Added RTM block ID function --- lib/coins/xmr.js | 10 +++++----- lib/pool.js | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 51dbd8b2c..48cc187a7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -735,11 +735,11 @@ function Coin(data){ this.getBlockID = function(blockBuffer, port){ const blob_type_num = this.portBlobType(port, blockBuffer[0]); - return cnUtil.get_block_id(blockBuffer, blob_type_num); - }; - - this.blockHashBuff = function(blockBuffer){ - return cnUtil.blockHashBuff(blockBuffer); + if (global.coinFuncs.blobTypeRtm(blob_type_num)) { + return cnUtil.blockHashBuff(cnUtil.convertRtmBlob(blockBuffer)); + } else { + return cnUtil.get_block_id(blockBuffer, blob_type_num); + } }; this.BlockTemplate = function(template) { diff --git a/lib/pool.js b/lib/pool.js index 0f1bbc0e1..2599cc359 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1489,8 +1489,6 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste return cb(rpcResult.result.blid); } else if (global.coinFuncs.blobTypeRvn(blob_type_num)) { return cb(resultBuff.toString('hex')); - } else if (global.coinFuncs.blobTypeRtm(blob_type_num)) { - return cb(resultBuff.toString('hex')); } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { setTimeout(global.coinFuncs.getPortBlockHeaderByID, 10*1000, blockTemplate.port, blockTemplate.height, function(err, body) { if (err === null && body.powSolutions.pk === blockTemplate.hash2) return cb(body.id); From 0406ac0f80d0ceaa91327eb1f1834f886c8e0ea9 Mon Sep 17 00:00:00 2001 From: Rachel Bautista <93613902+via06@users.noreply.github.com> Date: Wed, 5 Jan 2022 05:30:42 +0800 Subject: [PATCH 1496/1496] Rename deployment/base.sql to via06@github.com/create/new/database/moneraocean:master.base.sql --- .../create/new/database/moneraocean:master.base.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename deployment/base.sql => via06@github.com/create/new/database/moneraocean:master.base.sql (100%) diff --git a/deployment/base.sql b/via06@github.com/create/new/database/moneraocean:master.base.sql similarity index 100% rename from deployment/base.sql rename to via06@github.com/create/new/database/moneraocean:master.base.sql