From 9608020290c2e3bd806ff7254bb0eea40a930c21 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Wed, 1 Nov 2017 11:24:16 -0700 Subject: [PATCH 0001/2430] Update README.md --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 9e50019f..57dc4136 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,3 @@ -SUPER IMPORTANT UPDATE UNTIL THIS UPDATE DISAPPEARS -=================================================== -None of the following applies if you installed the pool AFTER June 2nd 2017, as the installers will do this work for you. - -The pool currently uses a version of LMDB that is not supported in Ubuntu 16.04 at this time. Please run: bash deployment/install_lmdb_tools.sh once from the root of the installation to load the LMDB tools, this will put them somewhere handy on your path, and drop a new alias to them so they can be used to introspect your database. - -If you had installed the pool prior to 6/2/2017, PLEASE make sure you run a npm install before you restart services. - Pool Design/Theory ================== The nodejs-pool is built around a small series of core daemons that share access to a single LMDB table for tracking of shares, with MySQL being used to centralize configurations and ensure simple access from local/remote nodes. The core daemons follow: From 552c1f05252ca19fa6f32ea7c8f2fb177d082a8c Mon Sep 17 00:00:00 2001 From: Tim Garrity Date: Wed, 1 Nov 2017 21:31:45 -0400 Subject: [PATCH 0002/2430] Aeon update Check AEON-Notes.md --- AEON-Notes.md | 9 +++ README.md | 8 +++ deployment/aeon.service | 13 ++++ deployment/deploy_aeon.bash | 96 ++++++++++++++++++++++++++ lib/local_comms.js | 133 +++++++++--------------------------- 5 files changed, 160 insertions(+), 99 deletions(-) create mode 100644 AEON-Notes.md create mode 100644 deployment/aeon.service create mode 100644 deployment/deploy_aeon.bash diff --git a/AEON-Notes.md b/AEON-Notes.md new file mode 100644 index 00000000..5952d6be --- /dev/null +++ b/AEON-Notes.md @@ -0,0 +1,9 @@ +# Notes about AEON coin + +#### Special considerations for AEON + +NodeJS-Pool and PoolUI were built with monero in mind. While a recent update has made the pool compatible with Cryptonight-lite, the UI itself, by another developer, was hardcoded for Monero. Due to this there's a few things that need to be changed for the pool to successfully work. + + - aeond does not have a blockchain import function. So this makes downloading a blockchain.bin and importing it a bit difficult to do. I have included in my deploy.bash script a url i'm providing to keep the blockchain up to date within atleast a week delay, but it's unusable at the moment + - Until the PoolUI can be updated to allow for coins to be changed via a config, we're going to need to use a separate fork that I'll provide. I'll be working to try to include what I can to make the fork work for Monero AND aeon, but for the purpose here, my main goal will be for Aeon's compatibility. + - NodeJS-Pool is a bit more complex than CryptoNote Uni Pool, but it appears to be working just fine for our purpsoes. I highly recommend testing it for 1-2blocks if possible. \ No newline at end of file diff --git a/README.md b/README.md index 57dc4136..9e50019f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +SUPER IMPORTANT UPDATE UNTIL THIS UPDATE DISAPPEARS +=================================================== +None of the following applies if you installed the pool AFTER June 2nd 2017, as the installers will do this work for you. + +The pool currently uses a version of LMDB that is not supported in Ubuntu 16.04 at this time. Please run: bash deployment/install_lmdb_tools.sh once from the root of the installation to load the LMDB tools, this will put them somewhere handy on your path, and drop a new alias to them so they can be used to introspect your database. + +If you had installed the pool prior to 6/2/2017, PLEASE make sure you run a npm install before you restart services. + Pool Design/Theory ================== The nodejs-pool is built around a small series of core daemons that share access to a single LMDB table for tracking of shares, with MySQL being used to centralize configurations and ensure simple access from local/remote nodes. The core daemons follow: diff --git a/deployment/aeon.service b/deployment/aeon.service new file mode 100644 index 00000000..c805bdad --- /dev/null +++ b/deployment/aeon.service @@ -0,0 +1,13 @@ +[Unit] +Description=Aeon Daemon +After=network.target + +[Service] +Type=forking +GuessMainPID=no +ExecStart=/usr/local/src/aeon/build/release/bin/aeon --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc +Restart=always +User=aeondaemon + +[Install] +WantedBy=multi-user.target diff --git a/deployment/deploy_aeon.bash b/deployment/deploy_aeon.bash new file mode 100644 index 00000000..c4536692 --- /dev/null +++ b/deployment/deploy_aeon.bash @@ -0,0 +1,96 @@ +#!/bin/bash +echo "This assumes that you are doing a green-field install. If you're not, please exit in the next 15 seconds." +sleep 15 +echo "Continuing install, this will prompt you for your password if you're not already running as root and you didn't enable passwordless sudo. Please do not run me as root!" +if [[ `whoami` == "root" ]]; then + echo "You ran me as root! Do not run me as root!" + exit 1 +fi +ROOT_SQL_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) +CURUSER=$(whoami) +echo "Etc/UTC" | sudo tee -a /etc/timezone +sudo rm -rf /etc/localtime +sudo ln -s /usr/share/zoneinfo/Zulu /etc/localtime +sudo dpkg-reconfigure -f noninteractive tzdata +sudo apt-get update +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 +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 https://github.com/aeonix/aeon.git +#cd aeon +#sudo git checkout v0.9.14.0 +#sudo make -j$(nproc) +#sudo cp ~/nodejs-pool/deployment/aeon.service /lib/systemd/system/ +#sudo useradd -m aeondaemon -d /home/aeondaemon +#sudo -u aeondaemon mkdir /home/aeondaemon/.aeon +#BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u aeondaemon mktemp -d) +#sudo -u aeondaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.bin http://74.208.156.45/blockchain.raw +#sudo -u aeondaemon mv $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.bin /home/aeondaemon/.aeon/blockchain.bin +#sudo -u aeondaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR +#sudo systemctl daemon-reload +#sudo systemctl enable aeon +#sudo systemctl start aeon +curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash +source ~/.nvm/nvm.sh +nvm install v6.9.2 +cd ~/nodejs-pool +npm install +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 +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 +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 +sudo mv caddy /usr/local/bin +sudo chown root:root /usr/local/bin/caddy +sudo chmod 755 /usr/local/bin/caddy +sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy +sudo groupadd -g 33 www-data +sudo useradd -g www-data --no-user-group --home-dir /var/www --no-create-home --shell /usr/sbin/nologin --system --uid 33 www-data +sudo mkdir /etc/caddy +sudo chown -R root:www-data /etc/caddy +sudo mkdir /etc/ssl/caddy +sudo chown -R www-data:root /etc/ssl/caddy +sudo chmod 0770 /etc/ssl/caddy +sudo cp ~/nodejs-pool/deployment/caddyfile /etc/caddy/Caddyfile +sudo chown www-data:www-data /etc/caddy/Caddyfile +sudo chmod 444 /etc/caddy/Caddyfile +sudo sh -c "sed 's/ProtectHome=true/ProtectHome=false/' init/linux-systemd/caddy.service > /etc/systemd/system/caddy.service" +sudo chown root:root /etc/systemd/system/caddy.service +sudo chmod 644 /etc/systemd/system/caddy.service +sudo systemctl daemon-reload +sudo systemctl enable caddy.service +sudo systemctl start caddy.service +rm -rf $CADDY_DOWNLOAD_DIR +cd ~ +sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin `pwd`/.nvm/versions/node/v6.9.2/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` +cd ~/nodejs-pool +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 +mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')" +mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" +pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api +bash ~/nodejs-pool/deployment/install_lmdb_tools.sh +cd ~/nodejs-pool/sql_sync/ +env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin node sql_sync.js +echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" diff --git a/lib/local_comms.js b/lib/local_comms.js index 59558930..b86bea4e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -517,115 +517,38 @@ function Database(){ txn.commit(); }; - this.getOldestLockedBlock = function(){ - /* - 6-29-2017 - Snipa - - 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 txn = this.env.beginTxn({readOnly: true}); - let cursor = new this.lmdb.Cursor(txn, this.blockDB); - let highestBlock = null; - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - if (highestBlock !== null){ - break; - } - cursor.getCurrentBinary(function(key, data){ // jshint ignore:line - let blockData = global.protos.Block.decode(data); - if (blockData.unlocked === false){ - highestBlock = blockData; - } - }); - } - cursor.close(); - txn.commit(); - if (highestBlock !== null) { - debug("Got the oldest locked block in the system at height: " + JSON.stringify(highestBlock)); - } else { - debug("There are no unlocked blocks in the system. Woohoo!"); - } - return highestBlock; - }; - this.cleanShareDB = function() { /* - This function takes the difficulty of the current block, and the last PPS block. If it's 0, save everything, - UNLESS global.config.pps.enable is FALSE, then feel free to trash it. - Due to LMDB under current config, we must delete entire keys, due to this, we save diff * shareMulti * 1.3 - - 6/29/2017 - Fixed bug with the way the system got blocks. getLastBlock gets the most recent block. - getOldestLockedBlock gets the oldest block in the system that's locked. This ensures that shares for that block - can't be destroyed, and that there's enough depth past that point to ensure the system will have the ability - to make payouts based on the shareMultiLog. Thanks suhz for finding this. Sorry it hit your aeon pool hard. - :( -- Snipa - - If current_height - global.payout.blocksRequired > lastLockedBlock, then set the scan start to - current_height - global.payout.blocksRequired - 1 so that we have the full block in case of PPS. - Otherwise, use the lastPPLNSBlock as the scan start. There we go. Stupid logic! - - Math check! - cur_height = 100, blocksRequired=20, lastPPLNSLockedBlock.height=90 - In this case, the functional depth required for SOLO is 80 - 1, giving us 79 as our start - cur_height = 100, blocksRequired=20, lastPPLNSLockedBlock.height=70 - In this case, the PPLNS locked block is older than the current height - the required amount, so start is 70. - - PPS height no longer matters! Yay! - Solo really doesn't matter, as block finder gets everything. - If there is no valid locked block to start from, aka all blocks are unlocked, then scan from the current height - of the chain, as there's no way for the system to have older blocks. We only need to save extra in the case - 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. + This function takes the difficulty of the current block, and the last PPS block. If it's 0, save everything, + UNLESS global.config.pps.enable is FALSE, then feel free to trash it. + Due to LMDB under current config, we must delete entire keys, due to this, we save diff * shareMultiLog * 1.5 + global.config.pplns.shareMultiLog should be at least 1.5x your shareMulti, in case of diff spikiing */ - let oldestLockedBlock = this.getOldestLockedBlock(); + let lastPPSBlock = this.getLastBlock(); + if (global.config.pps.enable){ + lastPPSBlock = this.getLastBlock(global.protos.POOLTYPE.PPS); + if (lastPPSBlock === 0){ + return; + } + } + let lastPPLNSBlock = this.getLastBlock(global.protos.POOLTYPE.PPLNS); + debug("Last PPS block: "+lastPPSBlock); + // Hopping into async, we need the current block height to know where to start our indexing... async.waterfall([ function(callback){ - global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { - oldestLockedBlock.height = result.height; - console.log(`Got the oldest block`); - callback(null, oldestLockedBlock); - }); - }, - function(oldestLockedBlock, callback){ global.coinFuncs.getLastBlockHeader(function(err, body){ - if (oldestLockedBlock === null){ - /* - If there's no locked blocks, then allow the system to scan from the PPS depth downwards if PPS - is enabled. - Save enough shares so that the diff * share multi * 30% for buffer. - */ - if (global.config.pps.enable){ - // If PPS is enabled, we scan for new blocks at cur height - blocksRequired/2. - // We need to save shares back that far at the least. - callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); - } else { - // Otherwise, we can just start from the current height. Woo! - callback(null, body.height, Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); - } - - } else { - /* - Otherwise, start the scan from the oldest locked block downwards. - This protects against the blockManager being messed up and not unlocking blocks. - This will ensure that enough shares are in place to unlock all blocks. - If the block is Solo, PPLNS or PPS, it doesn't matter. - */ - if (global.config.pps.enable && oldestLockedBlock.height > body.height - Math.floor(global.config.payout.blocksRequired/2)) { - // If PPS is enabled, and the oldestLockedBlock.height > the PPS minimum, start from the PPS minimum. - callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); - } else { - // If PPS isn't enabled, or the oldestLockedBlock.height < the PPS minimum, then start from there. - callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 1.3)); - } + if (err) { + return callback(true, body); } + return callback(null, body.height, Math.floor(body.difficulty * 1.5 * global.config.pplns.shareMultiLog)); }); }, function (lastBlock, difficulty, callback) { let shareCount = 0; + let ppsFound = false; let pplnsFound = false; let blockList = []; - console.log("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); + debug("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); range.range(0, lastBlock+1).forEach(function (blockID) { blockID = (blockID - lastBlock+1) * -1; if (blockID < 0){ @@ -635,7 +558,7 @@ function Database(){ let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); for (let found = (cursor.goToRange(blockID) === blockID); found; found = cursor.goToNextDup()) { - if (pplnsFound){ + if (ppsFound && pplnsFound){ cursor.getCurrentBinary(function(key, data) { // jshint ignore:line if (blockList.indexOf(key) === -1){ blockList.push(key); @@ -643,6 +566,9 @@ function Database(){ }); } else { cursor.getCurrentBinary(function(key, data) { // jshint ignore:line + if (key < lastPPSBlock){ + ppsFound = true; + } try{ let shareData = global.protos.Share.decode(data); if (shareData.poolType === global.protos.POOLTYPE.PPLNS){ @@ -663,11 +589,19 @@ function Database(){ callback(null, blockList); } ], function(err, data){ - if (global.config.general.blockCleaner === true){ + if (err === null && global.config.general.blockCleaner === true){ if(data.length > 0){ global.database.refreshEnv(); + let blockList = global.database.getBlockList(); + debug("Got the block list"); let totalDeleted = 0; data.forEach(function(block){ + if ((blockList.indexOf(block) !== -1 && !blockList.unlocked) || block > lastPPLNSBlock){ + // Don't delete locked blocks. ffs. + // Don't delete blocks that could contain shares. Even if it's unlikely as all getout. + debug("Skipped deleting block: " + block); + return; + } totalDeleted += 1; let txn = global.database.env.beginTxn(); txn.del(global.database.shareDB, block); @@ -679,11 +613,12 @@ function Database(){ global.database.env.sync(function(){ }); } else { - console.log("Block cleaning disabled. Would have removed: " + JSON.stringify(data)); + console.log("Block cleaning disabled. Would of removed: " + JSON.stringify(data)); } }); }; + this.refreshEnv = function(){}; setInterval(function(){ From cf4e7cefe83f989f88ef7fae555930922f39160d Mon Sep 17 00:00:00 2001 From: Tim Garrity Date: Wed, 1 Nov 2017 21:35:48 -0400 Subject: [PATCH 0003/2430] Backport an update from parent repo My push overwrote a recent update from the parent NodeJS-Pool repo. This puts it back. --- lib/local_comms.js | 129 +++++++++++++++++++++++++++++++++------------ 1 file changed, 95 insertions(+), 34 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index b86bea4e..dea4d04e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -517,38 +517,111 @@ function Database(){ txn.commit(); }; - this.cleanShareDB = function() { + this.getOldestLockedBlock = function(){ /* - This function takes the difficulty of the current block, and the last PPS block. If it's 0, save everything, - UNLESS global.config.pps.enable is FALSE, then feel free to trash it. - Due to LMDB under current config, we must delete entire keys, due to this, we save diff * shareMultiLog * 1.5 - global.config.pplns.shareMultiLog should be at least 1.5x your shareMulti, in case of diff spikiing - */ - let lastPPSBlock = this.getLastBlock(); - if (global.config.pps.enable){ - lastPPSBlock = this.getLastBlock(global.protos.POOLTYPE.PPS); - if (lastPPSBlock === 0){ - return; + 6-29-2017 - Snipa - + 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 txn = this.env.beginTxn({readOnly: true}); + let cursor = new this.lmdb.Cursor(txn, this.blockDB); + let highestBlock = null; + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + if (highestBlock !== null){ + break; } + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.Block.decode(data); + if (blockData.unlocked === false){ + highestBlock = blockData; + } + }); } - let lastPPLNSBlock = this.getLastBlock(global.protos.POOLTYPE.PPLNS); - debug("Last PPS block: "+lastPPSBlock); - // Hopping into async, we need the current block height to know where to start our indexing... + cursor.close(); + txn.commit(); + if (highestBlock !== null) { + debug("Got the oldest locked block in the system at height: " + JSON.stringify(highestBlock)); + } else { + debug("There are no unlocked blocks in the system. Woohoo!"); + } + return highestBlock; + }; + + this.cleanShareDB = function() { + /* + This function takes the difficulty of the current block, and the last PPS block. If it's 0, save everything, + UNLESS global.config.pps.enable is FALSE, then feel free to trash it. + Due to LMDB under current config, we must delete entire keys, due to this, we save diff * shareMulti * 1.3 + 6/29/2017 - Fixed bug with the way the system got blocks. getLastBlock gets the most recent block. + getOldestLockedBlock gets the oldest block in the system that's locked. This ensures that shares for that block + can't be destroyed, and that there's enough depth past that point to ensure the system will have the ability + to make payouts based on the shareMultiLog. Thanks suhz for finding this. Sorry it hit your aeon pool hard. + :( -- Snipa + If current_height - global.payout.blocksRequired > lastLockedBlock, then set the scan start to + current_height - global.payout.blocksRequired - 1 so that we have the full block in case of PPS. + Otherwise, use the lastPPLNSBlock as the scan start. There we go. Stupid logic! + Math check! + cur_height = 100, blocksRequired=20, lastPPLNSLockedBlock.height=90 + In this case, the functional depth required for SOLO is 80 - 1, giving us 79 as our start + cur_height = 100, blocksRequired=20, lastPPLNSLockedBlock.height=70 + In this case, the PPLNS locked block is older than the current height - the required amount, so start is 70. + PPS height no longer matters! Yay! + Solo really doesn't matter, as block finder gets everything. + If there is no valid locked block to start from, aka all blocks are unlocked, then scan from the current height + of the chain, as there's no way for the system to have older blocks. We only need to save extra in the case + 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. + */ + let oldestLockedBlock = this.getOldestLockedBlock(); async.waterfall([ function(callback){ + global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { + oldestLockedBlock.height = result.height; + console.log(`Got the oldest block`); + callback(null, oldestLockedBlock); + }); + }, + function(oldestLockedBlock, callback){ global.coinFuncs.getLastBlockHeader(function(err, body){ - if (err) { - return callback(true, body); + if (oldestLockedBlock === null){ + /* + If there's no locked blocks, then allow the system to scan from the PPS depth downwards if PPS + is enabled. + Save enough shares so that the diff * share multi * 30% for buffer. + */ + if (global.config.pps.enable){ + // If PPS is enabled, we scan for new blocks at cur height - blocksRequired/2. + // We need to save shares back that far at the least. + callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); + } else { + // Otherwise, we can just start from the current height. Woo! + callback(null, body.height, Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); + } + + } else { + /* + Otherwise, start the scan from the oldest locked block downwards. + This protects against the blockManager being messed up and not unlocking blocks. + This will ensure that enough shares are in place to unlock all blocks. + If the block is Solo, PPLNS or PPS, it doesn't matter. + */ + if (global.config.pps.enable && oldestLockedBlock.height > body.height - Math.floor(global.config.payout.blocksRequired/2)) { + // If PPS is enabled, and the oldestLockedBlock.height > the PPS minimum, start from the PPS minimum. + callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); + } else { + // If PPS isn't enabled, or the oldestLockedBlock.height < the PPS minimum, then start from there. + callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 1.3)); + } } - return callback(null, body.height, Math.floor(body.difficulty * 1.5 * global.config.pplns.shareMultiLog)); }); }, function (lastBlock, difficulty, callback) { let shareCount = 0; - let ppsFound = false; let pplnsFound = false; let blockList = []; - debug("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); + console.log("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); range.range(0, lastBlock+1).forEach(function (blockID) { blockID = (blockID - lastBlock+1) * -1; if (blockID < 0){ @@ -558,7 +631,7 @@ function Database(){ let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); for (let found = (cursor.goToRange(blockID) === blockID); found; found = cursor.goToNextDup()) { - if (ppsFound && pplnsFound){ + if (pplnsFound){ cursor.getCurrentBinary(function(key, data) { // jshint ignore:line if (blockList.indexOf(key) === -1){ blockList.push(key); @@ -566,9 +639,6 @@ function Database(){ }); } else { cursor.getCurrentBinary(function(key, data) { // jshint ignore:line - if (key < lastPPSBlock){ - ppsFound = true; - } try{ let shareData = global.protos.Share.decode(data); if (shareData.poolType === global.protos.POOLTYPE.PPLNS){ @@ -589,19 +659,11 @@ function Database(){ callback(null, blockList); } ], function(err, data){ - if (err === null && global.config.general.blockCleaner === true){ + if (global.config.general.blockCleaner === true){ if(data.length > 0){ global.database.refreshEnv(); - let blockList = global.database.getBlockList(); - debug("Got the block list"); let totalDeleted = 0; data.forEach(function(block){ - if ((blockList.indexOf(block) !== -1 && !blockList.unlocked) || block > lastPPLNSBlock){ - // Don't delete locked blocks. ffs. - // Don't delete blocks that could contain shares. Even if it's unlikely as all getout. - debug("Skipped deleting block: " + block); - return; - } totalDeleted += 1; let txn = global.database.env.beginTxn(); txn.del(global.database.shareDB, block); @@ -613,12 +675,11 @@ function Database(){ global.database.env.sync(function(){ }); } else { - console.log("Block cleaning disabled. Would of removed: " + JSON.stringify(data)); + console.log("Block cleaning disabled. Would have removed: " + JSON.stringify(data)); } }); }; - this.refreshEnv = function(){}; setInterval(function(){ From c857051a800c863d28a86f2770a9a3fd00b7cfa2 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Tue, 7 Nov 2017 11:37:02 -0800 Subject: [PATCH 0004/2430] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb39ed91..55a51f2b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "jsonwebtoken": "^7.2.1", "minimist": "1.2.0", "moment": "2.17.1", - "mysql": "2.12.0", + "mysql": "^2.12.0", "node-lmdb": "0.4.12", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", From 4355319863c2cef6fe57b6b581663432c1425f4f Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Tue, 7 Nov 2017 11:40:18 -0800 Subject: [PATCH 0005/2430] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 55a51f2b..76368b3f 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "jsonwebtoken": "^7.2.1", "minimist": "1.2.0", "moment": "2.17.1", - "mysql": "^2.12.0", + "mysql": "2.15.0", "node-lmdb": "0.4.12", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", From 4e5c4cfd6270a29007675bc0c09d4c821e628689 Mon Sep 17 00:00:00 2001 From: MineMoneroPRO Date: Fri, 10 Nov 2017 00:18:47 +0300 Subject: [PATCH 0006/2430] Update local_comms.js fix for #145 --- lib/local_comms.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 59558930..4d0b2139 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -581,12 +581,16 @@ function Database(){ let oldestLockedBlock = this.getOldestLockedBlock(); async.waterfall([ function(callback){ - global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { - oldestLockedBlock.height = result.height; - console.log(`Got the oldest block`); - callback(null, oldestLockedBlock); - }); - }, + if (oldestLockedBlock === null) { + callback(null, oldestLockedBlock) + } else { + global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { + oldestLockedBlock.height = result.height; + console.log(Got the oldest block); + callback(null, oldestLockedBlock); + }); + } + }, function(oldestLockedBlock, callback){ global.coinFuncs.getLastBlockHeader(function(err, body){ if (oldestLockedBlock === null){ @@ -691,4 +695,4 @@ function Database(){ }, 900000); // Set DB env reload for every 15 minutes. } -module.exports = Database; \ No newline at end of file +module.exports = Database; From f0ecc9678d8698d8c5f9b5ed8fbeee0041317aff Mon Sep 17 00:00:00 2001 From: MineMoneroPRO Date: Fri, 10 Nov 2017 00:47:26 +0300 Subject: [PATCH 0007/2430] Update local_comms.js --- 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 4d0b2139..72d24d36 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -586,7 +586,7 @@ function Database(){ } else { global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { oldestLockedBlock.height = result.height; - console.log(Got the oldest block); + console.log(`Got the oldest block`); callback(null, oldestLockedBlock); }); } From 9782b11313aedba62b7a81fb928218ee98951909 Mon Sep 17 00:00:00 2001 From: Warcop Date: Sun, 12 Nov 2017 20:31:13 -0500 Subject: [PATCH 0008/2430] Update deploy.bash Update checkout for 0.11.1.0 --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 741c7b6d..bc1cef18 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,7 +26,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.11.0.0 +sudo git checkout v0.11.1.0 curl https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ From 0882e68b3848de565e1aae07226a0a82e99c4ab0 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Mon, 13 Nov 2017 10:45:24 -0800 Subject: [PATCH 0009/2430] RemoteShare update. --- lib/remoteShare.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 0c564aef..43a01292 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -105,4 +105,7 @@ if (cluster.isMaster) { app.listen(8000, function () { console.log('Process ' + process.pid + ' is listening to all incoming requests'); }); + app.listen('/tmp/remoteShare.sock', function () { + console.log('Process ' + process.pid + ' is listening to all incoming requests'); + }); } From 7c17a71d5ba6607e66c08e2b6f15632b23650a7f Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Mon, 13 Nov 2017 10:45:48 -0800 Subject: [PATCH 0010/2430] Whoops, removing the socket listen. --- lib/remoteShare.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 43a01292..0c564aef 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -105,7 +105,4 @@ if (cluster.isMaster) { app.listen(8000, function () { console.log('Process ' + process.pid + ' is listening to all incoming requests'); }); - app.listen('/tmp/remoteShare.sock', function () { - console.log('Process ' + process.pid + ' is listening to all incoming requests'); - }); } From b8f063efa421b3da4173709fe1486c91fb6f9625 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 15:54:21 +0100 Subject: [PATCH 0011/2430] Updated minimum nicehash support difficulty Updated minimum nicehash support difficulty from 200000 to 400000. --- 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 558e0fb0..a4521110 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -40,7 +40,7 @@ function Coin(data){ this.supportsAutoExchange = true; - this.niceHashDiff = 200000; + this.niceHashDiff = 400000; this.getBlockHeaderByID = function(blockId, callback){ global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { From b257740de0cb1122fba59ab40b0f7662394f28ec Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 15:59:35 +0100 Subject: [PATCH 0012/2430] Fixed underscores in email worker names Fixed underscores in worker names used in emails from pool (previously they were cut till the first underscore in them). --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 8714ca9a..cd8df46a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -216,7 +216,7 @@ function updateShareStats() { console.log("Removing: " + miner + " as an active miner from the cache."); if (miner.indexOf('_') > -1) { // This is a worker case. - let address_parts = miner.split('_'); + let address_parts = miner.split(/_(.+)/); let address = address_parts[0]; let worker = address_parts[1]; global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { From 589a20314c106c7aa2c226574d1569224a651280 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 16:09:13 +0100 Subject: [PATCH 0013/2430] Merge shares and trim worker names This code accumulates shares before storing them reducing network and pool database loads. In addition, it trims too long worker names before storing them. Shares are accumulated for one minute or until new block height. All share info is preserved intact with exception of shareType (trusted or not trusted share), which is not really used after that. In addition, individual worker names are used until there are 100 of them. After that, they are accumulated in one worker with "all_other_workers" name. --- lib/pool.js | 135 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 121 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b0e1e46d..1de2ed0f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -535,22 +535,129 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } } +// store wallet_key (address, paymentID, bitcoin, poolTypeEnum) -> worker_name -> shareType -> (height, difficulty, time, acc) +let walletAcc = {}; +// number of worker_name for wallet_key (so we do not count the by iteration) +let walletWorkerCount = {}; +// time of last scan for dead worker_name +let walletWorkerScanTime = {}; + function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareType, blockTemplate) { miner.hashes += job.difficulty; - global.database.storeShare(job.height, global.protos.Share.encode({ - shares: job.difficulty, - paymentAddress: miner.address, - paymentID: miner.paymentID, - foundBlock: blockCandidate, - trustedShare: shareType, - poolType: miner.poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: activeBlockTemplate.difficulty, - bitcoin: miner.bitcoin, - blockHeight: job.height, - timestamp: Date.now(), - identifier: miner.identifier - })); + + let safe_worker_name = miner.identifier.substring(0, 64); + + if (blockCandidate) { + + global.database.storeShare(job.height, global.protos.Share.encode({ + shares: job.difficulty, + paymentAddress: miner.address, + paymentID: miner.paymentID, + foundBlock: blockCandidate, + trustedShare: shareType, + poolType: miner.poolTypeEnum, + poolID: global.config.pool_id, + blockDiff: activeBlockTemplate.difficulty, + bitcoin: miner.bitcoin, + blockHeight: job.height, + timestamp: Date.now(), + identifier: safe_worker_name + })); + + } else { + + let time_now = Date.now(); + let wallet_key = miner.address + " " + miner.paymentID + " " + miner.bitcoin + " " + miner.poolTypeEnum; + + if (!(wallet_key in walletAcc)) { + walletAcc[wallet_key] = {}; + walletWorkerCount[wallet_key] = 0; + walletWorkerScanTime[wallet_key] = time_now; + } + + let wallet = walletAcc[wallet_key]; + + let worker_name = safe_worker_name in wallet || walletWorkerCount[wallet_key] < 100 ? safe_worker_name : "all_other_workers"; + + if (!(worker_name in wallet)) { + if (worker_name !== "all_other_workers") ++ walletWorkerCount[wallet_key]; + //console.log("!!! " + wallet_key + ": adding new worker " + worker_name + " (num " + walletWorkerCount[wallet_key] + ")"); + wallet[worker_name] = {}; + let worker = wallet[worker_name]; + worker["height"] = job.height; + worker["difficulty"] = activeBlockTemplate.difficulty; + worker["time"] = time_now; + worker["acc"] = 0; + } + + let worker = wallet[worker_name]; + + let height = worker["height"]; + let difficulty = worker["difficulty"]; + + if (height !== job.height || difficulty !== activeBlockTemplate.difficulty || time_now - worker["time"] > 60*1000) { + let acc = worker["acc"]; + if (acc != 0) { + //console.log("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); + global.database.storeShare(height, global.protos.Share.encode({ + shares: acc, + paymentAddress: miner.address, + paymentID: miner.paymentID, + foundBlock: blockCandidate, + trustedShare: shareType, + poolType: miner.poolTypeEnum, + poolID: global.config.pool_id, + blockDiff: difficulty, + bitcoin: miner.bitcoin, + blockHeight: height, + timestamp: time_now, + identifier: worker_name + })); + } + + worker["height"] = job.height; + worker["difficulty"] = activeBlockTemplate.difficulty; + worker["time"] = time_now; + worker["acc"] = job.difficulty; + + if (time_now - walletWorkerScanTime[wallet_key] > 60*1000) { + //console.log("!!! " + wallet_key + ": scanning for old worker names"); + for (let worker_name2 in wallet) { + let worker2 = wallet[worker_name2]; + if (time_now - worker2["time"] > 5*60*1000) { + let acc2 = worker2["acc"]; + if (acc2 != 0) { + //console.log("!!! " + wallet_key + " / " + worker_name2 + ": storing old worker share " + height2 + " " + difficulty2 + " " + time_now + " " + acc2); + global.database.storeShare(height2, global.protos.Share.encode({ + shares: acc2, + paymentAddress: miner.address, + paymentID: miner.paymentID, + foundBlock: blockCandidate, + trustedShare: true, + poolType: miner.poolTypeEnum, + poolID: global.config.pool_id, + blockDiff: worker2["difficulty"], + bitcoin: miner.bitcoin, + blockHeight: worker2["height"], + timestamp: time_now, + identifier: worker_name2 + })); + } + //console.log("!!! " + wallet_key + ": removing old worker " + worker_name2); + if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; + delete wallet[worker_name2]; + } + } + walletWorkerScanTime[wallet_key] = time_now; + } + + } else { + worker["acc"] += job.difficulty; + } + + //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + job.height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.difficulty + ")"); + } + if (blockCandidate) { global.database.storeBlock(job.height, global.protos.Block.encode({ hash: hashHex, From d76fc6edb632c62b07adfeb9d0b9527b538f48df Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 17:50:12 +0100 Subject: [PATCH 0014/2430] Fixed copy paste-error --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1de2ed0f..5d5b9f15 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -628,7 +628,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy let acc2 = worker2["acc"]; if (acc2 != 0) { //console.log("!!! " + wallet_key + " / " + worker_name2 + ": storing old worker share " + height2 + " " + difficulty2 + " " + time_now + " " + acc2); - global.database.storeShare(height2, global.protos.Share.encode({ + global.database.storeShare(worker2["height"], global.protos.Share.encode({ shares: acc2, paymentAddress: miner.address, paymentID: miner.paymentID, From f479b5b6cd5802078d86015f41cbe405bb52c160 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 21:03:14 +0100 Subject: [PATCH 0015/2430] Added immediate storing of fat shares All shares that exceed 1000000 hashes are now stored immediately (or then they accumulate such number of hashes). Worker cleaner was moved from accumulated storage condition (so it work more reliably). Fixed some typos adn rearranged some variables. --- lib/pool.js | 135 ++++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5d5b9f15..f538bc97 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -537,7 +537,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // store wallet_key (address, paymentID, bitcoin, poolTypeEnum) -> worker_name -> shareType -> (height, difficulty, time, acc) let walletAcc = {}; -// number of worker_name for wallet_key (so we do not count the by iteration) +// number of worker_name for wallet_key (so we do not count them by iteration) let walletWorkerCount = {}; // time of last scan for dead worker_name let walletWorkerScanTime = {}; @@ -547,7 +547,16 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy let safe_worker_name = miner.identifier.substring(0, 64); - if (blockCandidate) { + let time_now = Date.now(); + let wallet_key = miner.address + " " + miner.paymentID + " " + miner.bitcoin + " " + miner.poolTypeEnum; + + if (!(wallet_key in walletAcc)) { + walletAcc[wallet_key] = {}; + walletWorkerCount[wallet_key] = 0; + walletWorkerScanTime[wallet_key] = time_now; + } + + if (activeBlockTemplate.difficulty >= 1000000) { global.database.storeShare(job.height, global.protos.Share.encode({ shares: job.difficulty, @@ -560,25 +569,16 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy blockDiff: activeBlockTemplate.difficulty, bitcoin: miner.bitcoin, blockHeight: job.height, - timestamp: Date.now(), + timestamp: time_now, identifier: safe_worker_name })); } else { - - let time_now = Date.now(); - let wallet_key = miner.address + " " + miner.paymentID + " " + miner.bitcoin + " " + miner.poolTypeEnum; - - if (!(wallet_key in walletAcc)) { - walletAcc[wallet_key] = {}; - walletWorkerCount[wallet_key] = 0; - walletWorkerScanTime[wallet_key] = time_now; - } - + let wallet = walletAcc[wallet_key]; - + let worker_name = safe_worker_name in wallet || walletWorkerCount[wallet_key] < 100 ? safe_worker_name : "all_other_workers"; - + if (!(worker_name in wallet)) { if (worker_name !== "all_other_workers") ++ walletWorkerCount[wallet_key]; //console.log("!!! " + wallet_key + ": adding new worker " + worker_name + " (num " + walletWorkerCount[wallet_key] + ")"); @@ -589,75 +589,76 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy worker["time"] = time_now; worker["acc"] = 0; } - + let worker = wallet[worker_name]; - + let height = worker["height"]; let difficulty = worker["difficulty"]; - - if (height !== job.height || difficulty !== activeBlockTemplate.difficulty || time_now - worker["time"] > 60*1000) { - let acc = worker["acc"]; + let acc = worker["acc"]; + + if (height !== job.height || difficulty !== activeBlockTemplate.difficulty || time_now - worker["time"] > 60*1000 || acc >= 1000000) { if (acc != 0) { //console.log("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); global.database.storeShare(height, global.protos.Share.encode({ - shares: acc, - paymentAddress: miner.address, - paymentID: miner.paymentID, - foundBlock: blockCandidate, - trustedShare: shareType, - poolType: miner.poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: difficulty, - bitcoin: miner.bitcoin, - blockHeight: height, - timestamp: time_now, - identifier: worker_name - })); + shares: acc, + paymentAddress: miner.address, + paymentID: miner.paymentID, + foundBlock: blockCandidate, + trustedShare: shareType, + poolType: miner.poolTypeEnum, + poolID: global.config.pool_id, + blockDiff: difficulty, + bitcoin: miner.bitcoin, + blockHeight: height, + timestamp: time_now, + identifier: worker_name + })); } - + worker["height"] = job.height; worker["difficulty"] = activeBlockTemplate.difficulty; worker["time"] = time_now; worker["acc"] = job.difficulty; - - if (time_now - walletWorkerScanTime[wallet_key] > 60*1000) { - //console.log("!!! " + wallet_key + ": scanning for old worker names"); - for (let worker_name2 in wallet) { - let worker2 = wallet[worker_name2]; - if (time_now - worker2["time"] > 5*60*1000) { - let acc2 = worker2["acc"]; - if (acc2 != 0) { - //console.log("!!! " + wallet_key + " / " + worker_name2 + ": storing old worker share " + height2 + " " + difficulty2 + " " + time_now + " " + acc2); - global.database.storeShare(worker2["height"], global.protos.Share.encode({ - shares: acc2, - paymentAddress: miner.address, - paymentID: miner.paymentID, - foundBlock: blockCandidate, - trustedShare: true, - poolType: miner.poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: worker2["difficulty"], - bitcoin: miner.bitcoin, - blockHeight: worker2["height"], - timestamp: time_now, - identifier: worker_name2 - })); - } - //console.log("!!! " + wallet_key + ": removing old worker " + worker_name2); - if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; - delete wallet[worker_name2]; - } - } - walletWorkerScanTime[wallet_key] = time_now; - } - + } else { worker["acc"] += job.difficulty; } - + //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + job.height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.difficulty + ")"); } + if (time_now - walletWorkerScanTime[wallet_key] > 60*1000) { + //console.log("!!! " + wallet_key + ": scanning for old worker names"); + for (let worker_name2 in wallet) { + let worker2 = wallet[worker_name2]; + if (time_now - worker2["time"] > 5*60*1000) { + let acc2 = worker2["acc"]; + if (acc2 != 0) { + let height2 = worker2["height"]; + //console.log("!!! " + wallet_key + " / " + worker_name2 + ": storing old worker share " + height2 + " " + worker2["difficulty"] + " " + time_now + " " + acc2); + global.database.storeShare(height2, global.protos.Share.encode({ + shares: acc2, + paymentAddress: miner.address, + paymentID: miner.paymentID, + foundBlock: blockCandidate, + trustedShare: true, + poolType: miner.poolTypeEnum, + poolID: global.config.pool_id, + blockDiff: worker2["difficulty"], + bitcoin: miner.bitcoin, + blockHeight: height2, + timestamp: time_now, + identifier: worker_name2 + })); + } + //console.log("!!! " + wallet_key + ": removing old worker " + worker_name2); + if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; + delete wallet[worker_name2]; + } + } + walletWorkerScanTime[wallet_key] = time_now; + } + if (blockCandidate) { global.database.storeBlock(job.height, global.protos.Block.encode({ hash: hashHex, From 54a7f7bd3aa0ee90e0d77da04f2b6517964efce4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 21:15:49 +0100 Subject: [PATCH 0016/2430] Fixed bug with fat share detection Fixed bug with fat share detection --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f538bc97..99852fed 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -556,7 +556,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy walletWorkerScanTime[wallet_key] = time_now; } - if (activeBlockTemplate.difficulty >= 1000000) { + if (job.difficulty >= 1000000) { global.database.storeShare(job.height, global.protos.Share.encode({ shares: job.difficulty, From bce6727b5847ab0343095ecfeade1ad5b6914769 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 21:26:25 +0100 Subject: [PATCH 0017/2430] Poper text alignment --- lib/pool.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 99852fed..32c0200d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -600,19 +600,19 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy if (acc != 0) { //console.log("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); global.database.storeShare(height, global.protos.Share.encode({ - shares: acc, - paymentAddress: miner.address, - paymentID: miner.paymentID, - foundBlock: blockCandidate, - trustedShare: shareType, - poolType: miner.poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: difficulty, - bitcoin: miner.bitcoin, - blockHeight: height, - timestamp: time_now, - identifier: worker_name - })); + shares: acc, + paymentAddress: miner.address, + paymentID: miner.paymentID, + foundBlock: blockCandidate, + trustedShare: shareType, + poolType: miner.poolTypeEnum, + poolID: global.config.pool_id, + blockDiff: difficulty, + bitcoin: miner.bitcoin, + blockHeight: height, + timestamp: time_now, + identifier: worker_name + })); } worker["height"] = job.height; From 6f29cc06859c8031920a6bb083bd6ad8729045c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 21:49:12 +0100 Subject: [PATCH 0018/2430] Fixed bug Fixed bug with missing variable definition. --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 32c0200d..c7a3ecef 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -629,6 +629,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy if (time_now - walletWorkerScanTime[wallet_key] > 60*1000) { //console.log("!!! " + wallet_key + ": scanning for old worker names"); + let wallet = walletAcc[wallet_key]; for (let worker_name2 in wallet) { let worker2 = wallet[worker_name2]; if (time_now - worker2["time"] > 5*60*1000) { From 4ea6382925a6921b0806404ee8c8255edcb21dbc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 25 Nov 2017 21:55:29 +0100 Subject: [PATCH 0019/2430] Reduced share storage from old workers to one minute Reduced share storage from old workers to one minute. Why keep them for 5 minutes? --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c7a3ecef..facef8d9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -632,7 +632,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy let wallet = walletAcc[wallet_key]; for (let worker_name2 in wallet) { let worker2 = wallet[worker_name2]; - if (time_now - worker2["time"] > 5*60*1000) { + if (time_now - worker2["time"] > 60*1000) { let acc2 = worker2["acc"]; if (acc2 != 0) { let height2 = worker2["height"]; From 1af1af7c21bf3f903fd952f5f15ae348c2b08b80 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 26 Nov 2017 18:59:49 +0100 Subject: [PATCH 0020/2430] Fixed typo --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index facef8d9..2cfd5f56 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -653,7 +653,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy })); } //console.log("!!! " + wallet_key + ": removing old worker " + worker_name2); - if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; + if (worker_name2 !== "all_other_workers") -- walletWorkerCount[wallet_key]; delete wallet[worker_name2]; } } From 3d1b02f8a593810064a319e0dc986acf7418c6a0 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Mon, 27 Nov 2017 11:23:43 -0800 Subject: [PATCH 0021/2430] Update local_comms.js --- lib/local_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index f1971765..ac70fea7 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -425,6 +425,7 @@ function Database(){ let txn = this.env.beginTxn(); let blockData = global.protos.Block.decode(txn.getBinary(this.blockDB, blockId)); blockData.valid = false; + blockData.unlocked = true; txn.putBinary(this.blockDB, blockId, global.protos.Block.encode(blockData)); txn.commit(); }; From ec32102acc2cee3ce644032bd090712df33be989 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 29 Nov 2017 08:50:16 +0100 Subject: [PATCH 0022/2430] Increared accepted package size Increased accepted package size to 100KB (sometimes xmrig-proxy and xmr-proxy hit that limit with flurry of low diff shares). MoneroOcean leaf nodes are behind gateways that will controll that better. --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2cfd5f56..cf85c60e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1012,7 +1012,7 @@ if (cluster.isMaster) { socket.on('data', function (d) { dataBuffer += d; - if (Buffer.byteLength(dataBuffer, 'utf8') > 10240) { //10KB + if (Buffer.byteLength(dataBuffer, 'utf8') > 102400) { //100KB dataBuffer = null; console.warn(threadName + 'Excessive packet size from: ' + socket.remoteAddress); socket.destroy(); From fab2f1c44520273cf4f1712a26ea58dd8968ac9f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 29 Nov 2017 16:10:10 +0100 Subject: [PATCH 0023/2430] Added script to unlock blocks To help longRunner to clean stuff like orphan blocks (now not really needed after recent Snipa's fix) --- debug_scripts/block_unlocker.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 debug_scripts/block_unlocker.js diff --git a/debug_scripts/block_unlocker.js b/debug_scripts/block_unlocker.js new file mode 100644 index 00000000..c50bc16d --- /dev/null +++ b/debug_scripts/block_unlocker.js @@ -0,0 +1,19 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +comms = require('../lib/local_comms'); +global.database = new comms(); +global.database.initEnv(); +global.database.unlockBlock(argv.hash); +console.log("Block "+argv.hash+" unlocked! Exiting!"); +process.exit(); From 4993b8fcbdf6f73c75b1b9e9f584caa0607fa43f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 3 Dec 2017 18:02:49 +0100 Subject: [PATCH 0024/2430] Increased number of saved shares Increased number of saved shares to avoid problems with incorrect statistics (cleaned shares can lead to 260% block effort cap in block history). Now it is raised to 1000%. With share accumulator it is now possible to store more shares without much problems. --- 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 ac70fea7..052252c4 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -602,7 +602,7 @@ function Database(){ callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); } else { // Otherwise, we can just start from the current height. Woo! - callback(null, body.height, Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); + callback(null, body.height, Math.floor(body.difficulty * global.config.pplns.shareMulti * 5)); } } else { @@ -617,7 +617,7 @@ function Database(){ callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); } else { // If PPS isn't enabled, or the oldestLockedBlock.height < the PPS minimum, then start from there. - callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 1.3)); + callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 5)); } } }); From b5c098ec8205b04bc8ec9e20e49e8c97a9e7d961 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 3 Dec 2017 18:04:09 +0100 Subject: [PATCH 0025/2430] Same thing for PPS --- 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 052252c4..58cc1068 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -599,7 +599,7 @@ function Database(){ if (global.config.pps.enable){ // If PPS is enabled, we scan for new blocks at cur height - blocksRequired/2. // We need to save shares back that far at the least. - callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); + callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 5)); } else { // Otherwise, we can just start from the current height. Woo! callback(null, body.height, Math.floor(body.difficulty * global.config.pplns.shareMulti * 5)); @@ -614,7 +614,7 @@ function Database(){ */ if (global.config.pps.enable && oldestLockedBlock.height > body.height - Math.floor(global.config.payout.blocksRequired/2)) { // If PPS is enabled, and the oldestLockedBlock.height > the PPS minimum, start from the PPS minimum. - callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 1.3)); + callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 5)); } else { // If PPS isn't enabled, or the oldestLockedBlock.height < the PPS minimum, then start from there. callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 5)); From 01f9b242f33b5b116e783da3cd4a8e53dec2c367 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 4 Dec 2017 15:08:17 +0100 Subject: [PATCH 0026/2430] Reduced number of unique workers from 100 to 50 To better match 4 CPU core VPS (200 working accross 4 VPS threads are more suitable number). --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cf85c60e..fffdfe4b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -577,7 +577,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy let wallet = walletAcc[wallet_key]; - let worker_name = safe_worker_name in wallet || walletWorkerCount[wallet_key] < 100 ? safe_worker_name : "all_other_workers"; + let worker_name = safe_worker_name in wallet || walletWorkerCount[wallet_key] < 50 ? safe_worker_name : "all_other_workers"; if (!(worker_name in wallet)) { if (worker_name !== "all_other_workers") ++ walletWorkerCount[wallet_key]; From 53e8c8e8b30da8c6d52bffb828f0c4a94d0e0c4b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 5 Dec 2017 21:19:05 +0100 Subject: [PATCH 0027/2430] Switched the latest monerod and MoneroOcean fork repo Switched deployment to the latest monerod v0.11.1.0 and MoneroOcean fork repo. --- deployment/deploy.bash | 6 +++--- deployment/leaf.bash | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 741c7b6d..9dc183db 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -16,7 +16,7 @@ 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/Snipa22/nodejs-pool.git # Change this depending on how the deployment goes. +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 @@ -26,8 +26,8 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.11.0.0 -curl https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v +sudo git checkout v0.11.1.0 +curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 0c4940bc..f61a4a45 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -12,7 +12,7 @@ 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 libgtest-dev libzmq3-dev cd ~ -git clone https://github.com/Snipa22/nodejs-pool.git # Change this depending on how the deployment goes. +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 @@ -22,8 +22,8 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.11.0.0 -curl https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v +sudo git checkout v0.11.1.0 +curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon From 5bf5f99d6c9f699fedfeedd82b4a43032ed95e6c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Dec 2017 10:02:30 +0100 Subject: [PATCH 0028/2430] Added wallet trust and invalid share worket name limiting Added wallet trust system (to avoid CPU overload after constant miner reconnections that happen during mining botnet swarms) and invalid share worker name limiting. --- lib/pool.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index fffdfe4b..60acc87f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -206,6 +206,13 @@ let VarDiff = (function () { }; })(); + +// here we keep verified share number of a specific wallet (miner.payout) +// it will reset to 0 after invalid share is found +// if walletTrust exceeds certain threshold (global.config.pool.trustThreshold * 100) then low diff (<=16000) new workers for this wallet are started with high trust +// this is needed to avoid CPU overload after constant miner reconnections that happen during mining botnet swarms +let walletTrust = {}; + function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent) { // Username Layout -
. // Password Layout - .. @@ -342,9 +349,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.logString = this.address + " ID: " + this.identifier + " IP: " + this.ipAddress; if (global.config.pool.trustedMiners) { + if (!(this.payout in walletTrust)) walletTrust[this.payout] = 0; + let is_trusted_wallet = this.difficulty <= 16001 && this.payout in walletTrust && walletTrust[this.payout] > global.config.pool.trustThreshold * 100; this.trust = { - threshold: global.config.pool.trustThreshold, - probability: 256, + threshold: is_trusted_wallet ? 1 : global.config.pool.trustThreshold, + probability: is_trusted_wallet ? global.config.pool.trustMin : 256, penalty: 0 }; } @@ -356,7 +365,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.invalidShareProto = global.protos.InvalidShare.encode({ paymentAddress: this.address, paymentID: this.paymentID, - identifier: this.identifier + identifier: this.identifier.substring(0, 64) }); // Support functions for how miners activate and run. @@ -709,6 +718,7 @@ function processShare(miner, job, blockTemplate, params) { convertedBlob = global.coinFuncs.convertBlob(shareBuffer); hash = global.coinFuncs.cryptoNight(convertedBlob); shareType = false; + ++ walletTrust[miner.payout]; } if (hash.toString('hex') !== resultHash) { console.error(threadName + "Bad share from miner " + miner.logString); @@ -721,6 +731,7 @@ function processShare(miner, job, blockTemplate, params) { miner.incremented = false; } miner.messageSender('job', miner.getJob()); + walletTrust[miner.payout] = 0; return false; } From 8e2585c75fed32e653c485528067eb0aea26d0c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Dec 2017 00:04:20 +0100 Subject: [PATCH 0029/2430] Fix for stuck rapid block template updates Fix for stuck rapid block template updates --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 60acc87f..d7c79a9d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -175,7 +175,7 @@ function templateUpdate(repeating) { setTimeout(templateUpdate, 300); } } else { - setTimeout(templateUpdate, 300, false); + setTimeout(templateUpdate, 300, repeating); } }); } From 8d8e684a11428ed5bd66153aabee65f59ca52749 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Dec 2017 00:54:18 +0100 Subject: [PATCH 0030/2430] Reduced wallet trust multiplier --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d7c79a9d..623a62d5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -350,7 +350,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (global.config.pool.trustedMiners) { if (!(this.payout in walletTrust)) walletTrust[this.payout] = 0; - let is_trusted_wallet = this.difficulty <= 16001 && this.payout in walletTrust && walletTrust[this.payout] > global.config.pool.trustThreshold * 100; + let is_trusted_wallet = this.difficulty <= 16001 && this.payout in walletTrust && walletTrust[this.payout] > global.config.pool.trustThreshold * 10; this.trust = { threshold: is_trusted_wallet ? 1 : global.config.pool.trustThreshold, probability: is_trusted_wallet ? global.config.pool.trustMin : 256, From a4fade8a26a3fbe34404f8b7d4b257864c7251ca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Dec 2017 01:25:25 +0100 Subject: [PATCH 0031/2430] Increased timeout in case of monerod failure --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 623a62d5..bcacf29b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -175,7 +175,7 @@ function templateUpdate(repeating) { setTimeout(templateUpdate, 300); } } else { - setTimeout(templateUpdate, 300, repeating); + setTimeout(templateUpdate, 3000, repeating); } }); } From 33b2ce1edb8e274f06cec73b1f149ec784f7d0ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Dec 2017 08:56:29 +0100 Subject: [PATCH 0032/2430] Disabled trust for big shares --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bcacf29b..be3534dd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -709,7 +709,7 @@ function processShare(miner, job, blockTemplate, params) { let hash; let shareType; - if (global.config.pool.trustedMiners && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && + if (global.config.pool.trustedMiners && miner.difficulty < 500000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability) { hash = new Buffer(resultHash, 'hex'); shareType = true; From 92be309e604cbc465a0bffde6d66d11c7a743804 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Dec 2017 09:44:52 +0100 Subject: [PATCH 0033/2430] Fixed EOL That caused merge issues. --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index cd8df46a..c757dba2 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -534,4 +534,4 @@ setInterval(updatePoolStats, 5000, 'pps'); setInterval(updatePoolStats, 5000, 'solo'); setInterval(updatePoolInformation, 5000); setInterval(updateWalletStats, 60000); -setInterval(monitorNodes, 300000); \ No newline at end of file +setInterval(monitorNodes, 300000); From 73db799655a756f666ebe42564398256fc2e5647 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Dec 2017 10:24:42 +0100 Subject: [PATCH 0034/2430] Returned more conservative wallet trust level --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index be3534dd..70b80c40 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -350,7 +350,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (global.config.pool.trustedMiners) { if (!(this.payout in walletTrust)) walletTrust[this.payout] = 0; - let is_trusted_wallet = this.difficulty <= 16001 && this.payout in walletTrust && walletTrust[this.payout] > global.config.pool.trustThreshold * 10; + let is_trusted_wallet = this.difficulty <= 16001 && this.payout in walletTrust && walletTrust[this.payout] > global.config.pool.trustThreshold * 100; this.trust = { threshold: is_trusted_wallet ? 1 : global.config.pool.trustThreshold, probability: is_trusted_wallet ? global.config.pool.trustMin : 256, From 83789e48f9a0c275ca3876464bd9d3dc0455aefa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 7 Dec 2017 18:36:25 +0100 Subject: [PATCH 0035/2430] Enable PPS DB scan only if PPS is actually enabled --- lib/blockManager.js | 106 +++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 89fccc36..1ad5fb6a 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -120,7 +120,9 @@ let balanceQueue = async.queue(function (task, callback) { ); function calculatePPSPayments(blockHeader, callback) { - console.log("Performing PPS payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); + if (global.config.payout.pps === true) { + 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', @@ -144,63 +146,67 @@ function calculatePPSPayments(blockHeader, callback) { amount: 0 }; let totalPayments = 0; - 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.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.pps === 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; } - 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; + 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.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; } - paymentData[global.config.payout.feeAddress].amount = paymentData[global.config.payout.feeAddress].amount + feesToPay - donations; - } - }); + }); + } + cursor.close(); + txn.abort(); } - 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 + "%"); + if (global.config.payout.pps === true) { + 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(); } From f603aa53c1701fffc2187137ca62c15c8cff95e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Dec 2017 13:01:58 +0100 Subject: [PATCH 0036/2430] Reduced time interval for stat hashrate averaging and live workers Reduced time interval for stat hashrate averaging and live workers. Should help to reduce load of this the most resource LMDB scan component. In addition, we do averages on website GUI so doing long averaging here is too CPU/RAM expensive. --- lib/worker.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index c757dba2..4d564316 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -6,6 +6,7 @@ const sprintf = require("sprintf-js").sprintf; let threadName = "Worker Server "; let cycleCount = 0; let lastBlockHash = null; +let hashrate_avg_min = 5; function updateShareStats() { // This is an omni-worker to deal with all things share-stats related @@ -24,8 +25,8 @@ function updateShareStats() { }); }, function (height, callback) { - let locTime = Date.now() - 600000; - let identifierTime = Date.now() - 1800000; + let locTime = Date.now() - (hashrate_avg_min*60*1000); + let identifierTime = Date.now() - (2*hashrate_avg_min*60*1000); let localStats = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}}; let localMinerCount = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0}; let localTimes = { @@ -142,7 +143,7 @@ function updateShareStats() { ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { let cachedData = global.database.getCache(key + "_stats"); if (cachedData !== false) { - cachedData.hash = Math.floor(localStats[key] / 600); + cachedData.hash = Math.floor(localStats[key] / (hashrate_avg_min*60)); cachedData.lastHash = localTimes[key]; cachedData.minerCount = localMinerCount[key]; if (!cachedData.hasOwnProperty("hashHistory")) { @@ -165,7 +166,7 @@ function updateShareStats() { } } else { cachedData = { - hash: Math.floor(localStats[key] / 600), + hash: Math.floor(localStats[key] / (hashrate_avg_min*60)), totalHashes: 0, lastHash: localTimes[key], minerCount: localMinerCount[key], @@ -184,7 +185,7 @@ function updateShareStats() { } let cachedData = global.database.getCache(miner); if (cachedData !== false) { - cachedData.hash = Math.floor(localStats.miners[miner] / 600); + cachedData.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)); cachedData.lastHash = localTimes.miners[miner]; if (!cachedData.hasOwnProperty("hashHistory")) { cachedData.hashHistory = []; @@ -199,7 +200,7 @@ function updateShareStats() { } } else { cachedData = { - hash: Math.floor(localStats.miners[miner] / 600), + hash: Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)), totalHashes: 0, lastHash: localTimes.miners[miner], hashHistory: [{ts: currentTime, hs: cachedData.hash}], From 1c2a8bdf3324b6e314a0e5da3a321602f449859a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Dec 2017 15:14:14 +0100 Subject: [PATCH 0037/2430] Reduced stat update interval Reduced stat update interval. Stat history should be not affected and will update with 1 minute interval like before. --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 4d564316..abf0dec3 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -250,11 +250,11 @@ function updateShareStats() { } ], function (err, result) { cycleCount += 1; - if (cycleCount === 6){ + if (cycleCount === 3){ cycleCount = 0; } }); - setTimeout(updateShareStats, 10000); + setTimeout(updateShareStats, 20*1000); } function updatePoolStats(poolType) { From 2459a83bc7288590b7d77bdd6d836a9e9fef0ed7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Dec 2017 16:16:28 +0100 Subject: [PATCH 0038/2430] Testing more conservative LMDB write sync options Testing more conservative LMDB write sync options in attempt to reduce cache update race conditions that in particulair cause round shares reset bug. --- 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 58cc1068..cf8c2fe1 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -19,9 +19,9 @@ function Database(){ maxDbs: 10, mapSize: 24 * 1024 * 1024 * 1024, noSync: false, - mapAsync: true, + mapAsync: false, useWritemap: false, - noMetaSync: true, + noMetaSync: false, maxReaders: 512 }); global.database.shareDB = this.env.openDbi({ From 7cc23f6fbf7cbbb3e74c782db4c0a21ab38edb50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 10 Dec 2017 16:21:05 +0100 Subject: [PATCH 0039/2430] Worker email accumulator Worker email accumulator to avoid big mailgun bills. Admin emails are still delivered instantly. --- deployment/base.sql | 4 ++-- lib/support.js | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 9bb15288..e6048b31 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -225,8 +225,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', '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 ('general', 'shareHost', '', 'string', 'Host that receives share information'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingBody', 'Hello,\n\nYour worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n\nThank you,\n%(poolEmailSig)s', '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', 'Worker %(worker)s stopped hashing', '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', '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', 'Some of your worker(s) stopped hashing', 'string', 'Subject of email sent to miner when worker stops hashing'); 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/support.js b/lib/support.js index 02be5b58..483916eb 100644 --- a/lib/support.js +++ b/lib/support.js @@ -5,6 +5,7 @@ const requestJson = require('request-json'); const moment = require('moment'); const debug = require('debug')('support'); const fs = require('fs'); +const sprintf = require("sprintf-js").sprintf; function circularBuffer(size) { let buffer = CircularBuffer(size); @@ -37,7 +38,10 @@ function circularBuffer(size) { return buffer; } -function sendEmail(toAddress, subject, body){ +// accumulates email notifications up to one hour +let emailAcc = {}; + +function sendEmailReal(toAddress, subject, body){ request.post(global.config.general.mailgunURL + "/messages", { auth: { user: 'api', @@ -58,6 +62,25 @@ function sendEmail(toAddress, subject, body){ }); } +function sendEmail(toAddress, subject, body){ + if (toAddress === global.config.general.adminEmail) { + sendEmailReal(toAddress, subject, body); + } else { + let key = toAddress + "\t" + subject; + if (!(key in emailAcc)) { + emailAcc[key] = body; + setTimeout(function(email_address, email_subject) { + let key2 = email_address + "\t" + email_subject; + let email_body = emailAcc[key2]; + delete emailAcc[key2]; + sendEmailReal(email_address, email_subject, "Hello,\n\n" + email_body + sprintf("\n\nThank you,\n%s", global.config.general.emailSig)); + }, 20*60*1000, toAddress, subject); + } else { + emailAcc[key] += body; + } + } +} + function jsonRequest(host, port, data, callback, path) { path = path || 'json_rpc'; let uri; From 275e9657c01ce2727f8e0ab9f65ac668e3829251 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Dec 2017 20:52:34 +0100 Subject: [PATCH 0040/2430] Added email notificatinos about workers returned to hashing Added email notificatinos about workers returned to hashing. --- deployment/base.sql | 4 +++- lib/support.js | 2 +- lib/worker.js | 58 +++++++++++++++++++++++++-------------------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index e6048b31..22f2c2bb 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -226,7 +226,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', 'maxPaymentTxns', '5', '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', 'Some of your worker(s) stopped hashing', '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', '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 ('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/support.js b/lib/support.js index 483916eb..9862e1e9 100644 --- a/lib/support.js +++ b/lib/support.js @@ -74,7 +74,7 @@ function sendEmail(toAddress, subject, body){ let email_body = emailAcc[key2]; delete emailAcc[key2]; sendEmailReal(email_address, email_subject, "Hello,\n\n" + email_body + sprintf("\n\nThank you,\n%s", global.config.general.emailSig)); - }, 20*60*1000, toAddress, subject); + }, 30*60*1000, toAddress, subject); } else { emailAcc[key] += body; } diff --git a/lib/worker.js b/lib/worker.js index abf0dec3..25bff9ce 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -211,33 +211,39 @@ function updateShareStats() { cache_updates[miner] = cachedData; }); globalMinerList.forEach(function (miner) { - if (minerList.indexOf(miner) === -1) { - let minerStats = global.database.getCache(miner); - if (minerStats.hash !== 0) { - console.log("Removing: " + miner + " as an active miner from the cache."); - if (miner.indexOf('_') > -1) { - // This is a worker case. - let address_parts = miner.split(/_(.+)/); - let address = address_parts[0]; - let worker = address_parts[1]; - global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { - if (rows.length === 0) { - return; - } - // toAddress, subject, body - let emailData = { - worker: worker, - timestamp: global.support.formatDate(Date.now()), - poolEmailSig: global.config.general.emailSig - }; - global.support.sendEmail(rows[0].email, - sprintf(global.config.email.workerNotHashingSubject, emailData), - sprintf(global.config.email.workerNotHashingBody, emailData)); - }); - } - minerStats.hash = 0; - cache_updates[miner] = minerStats; + let minerStats = global.database.getCache(miner); + let is_stop_hashing = false; + let is_start_hashing = false; + if (minerList.indexOf(miner) === -1) { + is_stop_hashing = minerStats.hash !== 0; + } else { + is_start_hashing = cachedData !== false && minerStats.hash === 0; + } + if (is_stop_hashing || is_start_hashing) { + if (is_stop_hashing) console.log("Removing: " + miner + " as an active miner from the cache."); + if (is_start_hashing) console.log("Adding: " + miner + " as an active miner to the cache."); + if (miner.indexOf('_') > -1) { + // This is a worker case. + let address_parts = miner.split(/_(.+)/); + let address = address_parts[0]; + let worker = address_parts[1]; + global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { + if (rows.length === 0) { + return; + } + // toAddress, subject, body + let emailData = { + worker: worker, + timestamp: global.support.formatDate(Date.now()), + poolEmailSig: global.config.general.emailSig + }; + global.support.sendEmail(rows[0].email, + sprintf(is_stop_hashing ? global.config.email.workerNotHashingSubject : global.config.email.workerStartHashingSubject, emailData), + sprintf(is_stop_hashing ? global.config.email.workerNotHashingBody : global.config.email.workerStartHashingSubject, emailData)); + }); } + if (is_stop_hashing) minerStats.hash = 0; + cache_updates[miner] = minerStats; } }); Object.keys(identifiers).forEach(function (key) { From 897ce5d4c1555f2350c7e505cf073d647395cebc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Dec 2017 21:07:37 +0100 Subject: [PATCH 0041/2430] Fixed typo --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 25bff9ce..53b26029 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -217,7 +217,7 @@ function updateShareStats() { if (minerList.indexOf(miner) === -1) { is_stop_hashing = minerStats.hash !== 0; } else { - is_start_hashing = cachedData !== false && minerStats.hash === 0; + is_start_hashing = minerStats !== false && minerStats.hash === 0; } if (is_stop_hashing || is_start_hashing) { if (is_stop_hashing) console.log("Removing: " + miner + " as an active miner from the cache."); From 277b029049375dfd0965d2d3a0f6f961d5b5b204 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Dec 2017 21:27:48 +0100 Subject: [PATCH 0042/2430] Changed floor to ceil to avoid zero hashrates for active miners This is basically needed to notify about active miners only once. --- lib/worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 53b26029..c5a407d0 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -143,7 +143,7 @@ function updateShareStats() { ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { let cachedData = global.database.getCache(key + "_stats"); if (cachedData !== false) { - cachedData.hash = Math.floor(localStats[key] / (hashrate_avg_min*60)); + cachedData.hash = Math.floor(localStats[key] / (hashrate_avg_min*60)) + 1; cachedData.lastHash = localTimes[key]; cachedData.minerCount = localMinerCount[key]; if (!cachedData.hasOwnProperty("hashHistory")) { @@ -166,7 +166,7 @@ function updateShareStats() { } } else { cachedData = { - hash: Math.floor(localStats[key] / (hashrate_avg_min*60)), + hash: Math.floor(localStats[key] / (hashrate_avg_min*60)) + 1, totalHashes: 0, lastHash: localTimes[key], minerCount: localMinerCount[key], @@ -185,7 +185,7 @@ function updateShareStats() { } let cachedData = global.database.getCache(miner); if (cachedData !== false) { - cachedData.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)); + cachedData.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; cachedData.lastHash = localTimes.miners[miner]; if (!cachedData.hasOwnProperty("hashHistory")) { cachedData.hashHistory = []; @@ -200,7 +200,7 @@ function updateShareStats() { } } else { cachedData = { - hash: Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)), + hash: Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1, totalHashes: 0, lastHash: localTimes.miners[miner], hashHistory: [{ts: currentTime, hs: cachedData.hash}], From 80d9abff29b546f6af6a58d4c3524e0777f7f4e3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Dec 2017 21:44:52 +0100 Subject: [PATCH 0043/2430] Do not skip cache updates of active miners --- lib/worker.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index c5a407d0..1fc6cb8d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -217,7 +217,7 @@ function updateShareStats() { if (minerList.indexOf(miner) === -1) { is_stop_hashing = minerStats.hash !== 0; } else { - is_start_hashing = minerStats !== false && minerStats.hash === 0; + is_start_hashing = minerStats !== false && cache_updates[miner].hash !== 0 && minerStats.hash === 0; } if (is_stop_hashing || is_start_hashing) { if (is_stop_hashing) console.log("Removing: " + miner + " as an active miner from the cache."); @@ -242,8 +242,10 @@ function updateShareStats() { sprintf(is_stop_hashing ? global.config.email.workerNotHashingBody : global.config.email.workerStartHashingSubject, emailData)); }); } - if (is_stop_hashing) minerStats.hash = 0; - cache_updates[miner] = minerStats; + if (is_stop_hashing) { + minerStats.hash = 0; + cache_updates[miner] = minerStats; + } } }); Object.keys(identifiers).forEach(function (key) { From fd7f477d97fba9e6a444eaa5c0530340d73dff13 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Dec 2017 22:40:24 +0100 Subject: [PATCH 0044/2430] Fixed starting worker text --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 1fc6cb8d..d2aefaa9 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -239,7 +239,7 @@ function updateShareStats() { }; global.support.sendEmail(rows[0].email, sprintf(is_stop_hashing ? global.config.email.workerNotHashingSubject : global.config.email.workerStartHashingSubject, emailData), - sprintf(is_stop_hashing ? global.config.email.workerNotHashingBody : global.config.email.workerStartHashingSubject, emailData)); + sprintf(is_stop_hashing ? global.config.email.workerNotHashingBody : global.config.email.workerStartHashingBody, emailData)); }); } if (is_stop_hashing) { From 4c57a8890e6fd309ddc3d38e5d6dc5faf115ab6e Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Wed, 13 Dec 2017 15:14:18 -0800 Subject: [PATCH 0045/2430] Update to fix XMR.to support. --- 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 596397c0..fe664a96 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -238,7 +238,7 @@ let xmrToQueue = async.queue(function (task, callback) { } else { console.log(JSON.stringify(body)); global.mysql.query("INSERT INTO xmrtoTxn (id, address, paymentID, depositType, withdrawl, withdrawlType, returnAddress, returnAddressType, txnStatus, amountDeposited, amountSent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", - [txnID, body.xmr_receiving_address, body.xmr_required_payment_id, 'XMR', body.btc_dest_address, 'BTC', global.config.pool.address, 'XMR', body.state_str, global.support.decimalToCoin(body.xmr_amount_total), global.support.decimalToCoin(body.btc_amount)]).then(function () { + [txnID, body.xmr_receiving_address, body.xmr_required_payment_id_long, 'XMR', body.btc_dest_address, 'BTC', global.config.pool.address, 'XMR', body.state_str, global.support.decimalToCoin(body.xmr_amount_total), global.support.decimalToCoin(body.btc_amount)]).then(function () { return intCallback(null, body, global.support.decimalToCoin(body.xmr_amount_total)); }).catch(function (error) { return intCallback(error); @@ -257,7 +257,7 @@ let xmrToQueue = async.queue(function (task, callback) { ], priority: global.config.payout.priority, mixin: global.config.payout.mixIn, - payment_id: orderStatus.xmr_required_payment_id + payment_id: orderStatus.xmr_required_payment_id_long }; debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { From b0c78ca6a3a720a9f31602e26a97a9089bba5e41 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 16 Dec 2017 09:32:15 +0100 Subject: [PATCH 0046/2430] Added option to disable mailgun certificate Needed for 3-rd party mailing solution with self signed certificate. --- deployment/base.sql | 1 + lib/support.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 22f2c2bb..619df5ef 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -215,6 +215,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', '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'); +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 ('pplns', 'enable', 'true', 'bool', 'Enable PPLNS on the pool.'); diff --git a/lib/support.js b/lib/support.js index 9862e1e9..6f9597dd 100644 --- a/lib/support.js +++ b/lib/support.js @@ -52,6 +52,9 @@ function sendEmailReal(toAddress, subject, body){ to: toAddress, subject: subject, text: body + }, + agentOptions: { + rejectUnauthorized: global.config.general.mailgunNoCert === true ? false : true } }, function(err, response, body){ if (!err && response.statusCode === 200) { From e795949a5825f33ccc385abb7e2ba287a6fc04ac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 17 Dec 2017 16:14:04 +0100 Subject: [PATCH 0047/2430] Skip 0 cache updates --- 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 cf8c2fe1..3955db6f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -242,7 +242,7 @@ function Database(){ let txn = global.database.env.beginTxn(); for (let key in cachedData){ - if (cachedData.hasOwnProperty(key)){ + if (cachedData.hasOwnProperty(key) && cachedData[key].totalHashes){ let cacheStore = txn.getString(global.database.cacheDB, key); if (cacheStore === null){ txn.putString(global.database.cacheDB, key, JSON.stringify(cachedData[key])); From abf607d04511065b67fe0e703660f2274219dd6c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 Dec 2017 15:52:05 +0100 Subject: [PATCH 0048/2430] Set undefined theshold to 0.3 So I can lower min payment to 0.1 and all existing miners will not be affected. They can set 0.1 in options if needed. --- 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 fe664a96..f2099afc 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -602,7 +602,7 @@ function makePayments() { payeeObjects[row.payment_address] = payee; global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { roundCount += 1; - let threshold = 0; + let threshold = 0.3; if (userRow.length !== 0) { threshold = userRow[0].payout_threshold; } From 6a32db315e74e37aa15972cdd75ece86052f6343 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 Dec 2017 22:25:15 +0100 Subject: [PATCH 0049/2430] Added fix to avoid zero thresholds --- 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 f2099afc..feefe2da 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -603,7 +603,7 @@ function makePayments() { global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { roundCount += 1; let threshold = 0.3; - if (userRow.length !== 0) { + if (userRow.length !== 0 && userRow[0].payout_threshold != 0) { threshold = userRow[0].payout_threshold; } payee.poolType = row.pool_type; From 8813098d28fbd11df410eda14db29a47e3dcd727 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 19 Dec 2017 22:38:01 +0100 Subject: [PATCH 0050/2430] Fixed threshold amount --- 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 feefe2da..b49ac9b6 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -602,7 +602,7 @@ function makePayments() { payeeObjects[row.payment_address] = payee; global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { roundCount += 1; - let threshold = 0.3; + let threshold = 0.3 * global.config.general.sigDivisor; if (userRow.length !== 0 && userRow[0].payout_threshold != 0) { threshold = userRow[0].payout_threshold; } From 04db3153e000201baf708ef00ee04ab0cd56f26a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 08:36:26 +0100 Subject: [PATCH 0051/2430] Fixed exchange default payment threshold --- lib/payment_systems/xmr.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index b49ac9b6..7a31e56c 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -603,8 +603,10 @@ function makePayments() { global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { roundCount += 1; let threshold = 0.3 * global.config.general.sigDivisor; + let custom_threshold = false; if (userRow.length !== 0 && userRow[0].payout_threshold != 0) { threshold = userRow[0].payout_threshold; + custom_threshold = true; } payee.poolType = row.pool_type; payee.sqlID = row.id; @@ -626,15 +628,15 @@ function makePayments() { 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 && threshold !== 0))) { + } 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. debug("Adding " + payee.id + " to the list of people to pay (Integrated Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); payee.makePaymentAsIntegrated(); - } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 0) { + } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold)) && payee.bitcoin === 0) { debug("Adding " + payee.id + " to the list of people to pay (Payment ID Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); payee.makePaymentWithID(); - } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 1) { + } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && custom_threshold)) && payee.bitcoin === 1) { debug("Adding " + payee.id + " to the list of people to pay (Bitcoin Payout). Payee balance: " + global.support.coinToDecimal(payee.amount)); payee.makeBitcoinPayment(); } From 85cbdccc4640fe12f0e1660ea44f7c496d365754 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 09:25:35 +0100 Subject: [PATCH 0052/2430] Added ability to use wallet address in email footer To basically use for unsubscribe link --- lib/support.js | 11 +++++++---- lib/worker.js | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/support.js b/lib/support.js index 6f9597dd..a9a841b8 100644 --- a/lib/support.js +++ b/lib/support.js @@ -65,19 +65,22 @@ function sendEmailReal(toAddress, subject, body){ }); } -function sendEmail(toAddress, subject, body){ +function sendEmail(toAddress, subject, body, wallet){ if (toAddress === global.config.general.adminEmail) { sendEmailReal(toAddress, subject, body); } else { let key = toAddress + "\t" + subject; if (!(key in emailAcc)) { emailAcc[key] = body; - setTimeout(function(email_address, email_subject) { + setTimeout(function(email_address, email_subject, wallet) { let key2 = email_address + "\t" + email_subject; let email_body = emailAcc[key2]; delete emailAcc[key2]; - sendEmailReal(email_address, email_subject, "Hello,\n\n" + email_body + sprintf("\n\nThank you,\n%s", global.config.general.emailSig)); - }, 30*60*1000, toAddress, subject); + let emailData = { + wallet: wallet + }; + sendEmailReal(email_address, email_subject, "Hello,\n\n" + email_body + "\n\nThank you,\n" + sprintf(global.config.general.emailSig, emailData)); + }, 30*60*1000, toAddress, subject, wallet); } else { emailAcc[key] += body; } diff --git a/lib/worker.js b/lib/worker.js index d2aefaa9..81e6444f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -239,7 +239,9 @@ function updateShareStats() { }; global.support.sendEmail(rows[0].email, sprintf(is_stop_hashing ? global.config.email.workerNotHashingSubject : global.config.email.workerStartHashingSubject, emailData), - sprintf(is_stop_hashing ? global.config.email.workerNotHashingBody : global.config.email.workerStartHashingBody, emailData)); + sprintf(is_stop_hashing ? global.config.email.workerNotHashingBody : global.config.email.workerStartHashingBody, emailData), + address + ); }); } if (is_stop_hashing) { From 220307269b8b58bac9bec626baabb79a8a511e9c Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Wed, 20 Dec 2017 04:52:29 -0800 Subject: [PATCH 0053/2430] Update deploy.bash --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index bc1cef18..1be98789 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -40,7 +40,7 @@ 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 v6.9.2 +nvm install v8.9.3 cd ~/nodejs-pool npm install npm install -g pm2 From 4bc233c601cc8f50342ec9feb8d08becdbbad9b7 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Wed, 20 Dec 2017 04:53:01 -0800 Subject: [PATCH 0054/2430] Update leaf.bash --- deployment/leaf.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 0c4940bc..3c7d5eb5 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -36,13 +36,13 @@ 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 v6.9.2 +nvm install v8.9.3 cd ~/nodejs-pool npm install 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/v6.9.2/bin `pwd`/.nvm/versions/node/v6.9.2/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` +sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin `pwd`/.nvm/versions/node/v8.9.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` sudo chown -R $CURUSER. ~/.pm2 echo "Installing pm2-logrotate in the background!" pm2 install pm2-logrotate & From 3b7713b37386b97271e56921935410105b8fab1c Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Wed, 20 Dec 2017 04:53:22 -0800 Subject: [PATCH 0055/2430] Update deploy.bash --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 1be98789..53b3e5f6 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -80,7 +80,7 @@ sudo systemctl enable caddy.service sudo systemctl start caddy.service rm -rf $CADDY_DOWNLOAD_DIR cd ~ -sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin `pwd`/.nvm/versions/node/v6.9.2/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` +sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin `pwd`/.nvm/versions/node/v8.9.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` cd ~/nodejs-pool sudo chown -R $CURUSER. ~/.pm2 echo "Installing pm2-logrotate in the background!" From c6293eac29ae9834992a7f3cb40e2b116f7d030d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 15:37:17 +0100 Subject: [PATCH 0056/2430] Hide leaf servers with id >= 1000 --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 81e6444f..5c741731 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -361,7 +361,7 @@ 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 lastSeen >= NOW() - INTERVAL 10 MINUTE").then(function (rows) { + 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 += 1; if (!local_cache.hasOwnProperty(row.port_type)) { @@ -425,7 +425,7 @@ function updatePoolPorts(poolServers) { function updatePoolInformation() { let local_cache = {}; debug(threadName + "Updating pool information"); - global.mysql.query("select * from pools where last_checkin >= NOW() - INTERVAL 10 MINUTE").then(function (rows) { + 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, From b9022c5dfec09e4cc71b102b9058bab162472a1a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 16:20:24 +0100 Subject: [PATCH 0057/2430] Possible fix for cache stat counters accuracy issues Parallel remoteShare threads will update each own copy of *_stats totalHashes/roundHashes and then they are summed before display --- lib/local_comms.js | 168 ++++++++++++++++++++++++++++++++++++++------- lib/remoteShare.js | 5 ++ lib/worker.js | 4 +- 3 files changed, 152 insertions(+), 25 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 3955db6f..e8096bd8 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -9,6 +9,8 @@ function Database(){ this.shareDB = null; this.blockDB = null; this.cacheDB = null; + this.roundhashes_reset_times = []; + this.numWorkers = require('os').cpus().length; this.dirtyenv = false; @@ -50,6 +52,15 @@ function Database(){ console.log("Database Worker: LMDB Env Initialized."); }; + // this computes worker thread specific cache key for safe updates + this.worker_key = function(key) { + if (this.hasOwnProperty("worker_id")) { + return key + "_" + this.worker_id.toString(); + } else { + console.error("No worker_id was assigned!!!"); + return key; + } + } this.incrementCacheData = function(key, data){ this.refreshEnv(); @@ -58,20 +69,53 @@ function Database(){ if (cached !== null){ cached = JSON.parse(cached); data.forEach(function(intDict){ - if (!cached.hasOwnProperty(intDict.location)){ + if (!cached.hasOwnProperty(intDict.location) || intDict.value === false){ cached[intDict.location] = 0; + } else { + cached[intDict.location] += intDict.value; } - if (intDict.value === false){ + }); + txn.putString(this.cacheDB, key, JSON.stringify(cached)); + txn.commit(); + } else { + txn.abort(); + } + }; + + this.incrementCacheDataPart = function(key, data){ + this.refreshEnv(); + let txn = this.env.beginTxn(); + let cached = txn.getString(this.cacheDB, this.worker_key(key)); + if (cached !== null){ + cached = JSON.parse(cached); + let reset_time_string = txn.getString(this.cacheDB, key + '_roundhashes_reset_time'); + let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; + if (!this.roundhashes_reset_times.hasOwnProperty(key)) { + console.error("Unknown key " + key + " for this.roundhashes_reset_times!!!"); + } + data.forEach(function(intDict){ + if (intDict.location === 'roundHashes' && intDict.value === false) { cached[intDict.location] = 0; + let time_now = Date.now(); + this.roundhashes_reset_times[key] = time_now; + txn.putString(this.cacheDB, key + '_roundhashes_reset_time', time_now.toString()); + + } else if (intDict.location === 'roundHashes' && this.roundhashes_reset_times[key] < reset_time) { + cached[intDict.location] = intDict.value; + this.roundhashes_reset_times[key] = reset_time; + + } else if (!cached.hasOwnProperty(intDict.location)) { + cached[intDict.location] = 0; + } else { cached[intDict.location] += intDict.value; } }); - txn.putString(this.cacheDB, key, JSON.stringify(cached)); + txn.putString(this.cacheDB, this.worker_key(key), JSON.stringify(cached)); txn.commit(); - return; + } else { + txn.abort(); } - txn.abort(); }; this.getBlockList = function(pool_type){ @@ -154,16 +198,16 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - this.incrementCacheData('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheDataPart('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); switch (share.poolType) { case global.protos.POOLTYPE.PPLNS: - this.incrementCacheData('pplns_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheDataPart('pplns_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; case global.protos.POOLTYPE.PPS: - this.incrementCacheData('pps_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheDataPart('pps_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; case global.protos.POOLTYPE.SOLO: - this.incrementCacheData('solo_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheDataPart('solo_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; } this.incrementCacheData(minerIDWithIdentifier, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]); @@ -242,25 +286,45 @@ function Database(){ let txn = global.database.env.beginTxn(); for (let key in cachedData){ - if (cachedData.hasOwnProperty(key) && cachedData[key].totalHashes){ - let cacheStore = txn.getString(global.database.cacheDB, key); + if (cachedData.hasOwnProperty(key) && cachedData[key].totalHashes !== 0){ + // only global cachedData stats has roundHashes + let key2 = cachedData[key].hasOwnProperty('roundHashes') ? this.worker_key(key) : key; + let cacheStore = txn.getString(global.database.cacheDB, key2); if (cacheStore === null){ - txn.putString(global.database.cacheDB, key, JSON.stringify(cachedData[key])); + txn.putString(global.database.cacheDB, key2, JSON.stringify(cachedData[key])); } else { let json_cache = JSON.parse(cacheStore); - if (json_cache.hasOwnProperty('totalHashes')){ + if (json_cache.hasOwnProperty('totalHashes')) { // cachedData.totalHashes is always there for global and miners stats json_cache.totalHashes += cachedData[key].totalHashes; - json_cache.goodShares += cachedData[key].goodShares; } else { json_cache.totalHashes = cachedData[key].totalHashes; - json_cache.goodShares = cachedData[key].goodShares; } - if (cachedData[key].hasOwnProperty('roundHashes') && json_cache.hasOwnProperty('roundHashes')){ - json_cache.roundHashes += cachedData[key].roundHashes; + if (cachedData[key].hasOwnProperty('goodShares')) { + if (json_cache.hasOwnProperty('goodShares')) { + json_cache.goodShares += cachedData[key].goodShares; + } else { + json_cache.goodShares = cachedData[key].goodShares; + } + } else if (cachedData[key].hasOwnProperty('roundHashes')) { + if (json_cache.hasOwnProperty('roundHashes')) { + let reset_time_string = txn.getString(this.cacheDB, key + '_roundhashes_reset_time'); + let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; + if (!this.roundhashes_reset_times.hasOwnProperty(key)) { + console.error("Unknown key " + key + " for this.roundhashes_reset_times!!!"); + } + if (this.roundhashes_reset_times[key] < reset_time) { + json_cache.roundHashes = cachedData[key].roundHashes; + this.roundhashes_reset_times[key] = reset_time; + } else { + json_cache.roundHashes += cachedData[key].roundHashes; + } + } else { + json_cache.roundHashes = cachedData[key].roundHashes; + } } else { - json_cache.roundHashes = cachedData[key].roundHashes; + console.error("cachedData should have either goodShares or roundHashes!!!"); } - txn.putString(global.database.cacheDB, key, JSON.stringify(json_cache)); + txn.putString(global.database.cacheDB, key2, JSON.stringify(json_cache)); } } } @@ -384,16 +448,16 @@ function Database(){ let txn = global.database.env.beginTxn(); txn.putBinary(global.database.blockDB, blockId, blockData); txn.commit(); - global.database.incrementCacheData('global_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheDataPart('global_stats', [{location: 'roundHashes', value: false}]); switch (blockDataDecoded.poolType) { case global.protos.POOLTYPE.PPLNS: - global.database.incrementCacheData('pplns_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheDataPart('pplns_stats', [{location: 'roundHashes', value: false}]); break; case global.protos.POOLTYPE.PPS: - global.database.incrementCacheData('pps_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheDataPart('pps_stats', [{location: 'roundHashes', value: false}]); break; case global.protos.POOLTYPE.SOLO: - global.database.incrementCacheData('solo_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheDataPart('solo_stats', [{location: 'roundHashes', value: false}]); break; } return callback(true); @@ -496,6 +560,39 @@ function Database(){ return false; }; + this.getCacheSum = function(cacheKey){ + debug("Getting Key Sum: "+cacheKey); + try { + this.refreshEnv(); + let txn = this.env.beginTxn({readOnly: true}); + let cached = txn.getString(this.cacheDB, cacheKey); + if (cached !== null) { + debug("Result for Key Sum: " + cacheKey + " is: " + cached); + let json_cache = JSON.parse(cached); + let totalHashes = 0; + let roundHashes = 0; + for (let i = 1; i <= this.numWorkers; ++ i) { + let cached2 = txn.getString(this.cacheDB, cacheKey + "_" + i.toString()); + if (cached2 !== null) { + let json_cache2 = JSON.parse(cached2); + if (json_cache2.hasOwnProperty('totalHashes')) totalHashes += json_cache2.totalHashes; + else console.error("Key " + cacheKey + "_" + i.toString() + " does not have totalHashes!!!"); + if (json_cache2.hasOwnProperty('roundHashes')) roundHashes += json_cache2.roundHashes; + else console.error("Key " + cacheKey + "_" + i.toString() + " does not have roundHashes!!!"); + } + } + txn.abort(); + json_cache.totalHashes = totalHashes; + json_cache.roundHashes = roundHashes; + return json_cache; + } + txn.abort(); + } catch (e) { + return false; + } + return false; + }; + this.setCache = function(cacheKey, cacheData){ debug("Setting Key: "+cacheKey+ " Data: " + JSON.stringify(cacheData)); this.refreshEnv(); @@ -504,6 +601,31 @@ function Database(){ txn.commit(); }; + // this spits cache value into worker thread local value + this.splitCache = function(cacheKey){ + debug("Splitting Key: "+cacheKey); + let time_now = Date.now(); + this.roundhashes_reset_times[cacheKey] = time_now; + try { + this.refreshEnv(); + let txn = this.env.beginTxn(); + let cached = txn.getString(this.cacheDB, cacheKey); + if (cached !== null){ + let json_cache = JSON.parse(cached); + if (json_cache.hasOwnProperty('totalHashes')) json_cache.totalHashes /= this.numWorkers; + else console.error("Key " + cacheKey + " does not have totalHashes!!!"); + if (json_cache.hasOwnProperty('roundHashes')) json_cache.roundHashes /= this.numWorkers; + else console.error("Key " + cacheKey + " does not have roundHashes!!!"); + txn.putString(this.cacheDB, this.worker_key(cacheKey), JSON.stringify(json_cache)); + txn.putString(this.cacheDB, cacheKey + '_roundhashes_reset_time', '0'); + txn.commit(); + } else { + txn.abort(); + } + } catch (e) { + } + }; + this.bulkSetCache = function(cacheUpdates){ let txn = this.env.beginTxn(); txn.putString(this.cacheDB, 'cacheUpdate', 'cacheUpdate'); diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 0c564aef..0cd5823f 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -102,6 +102,11 @@ if (cluster.isMaster) { workerList.push(worker); }); } else { + global.database.worker_id = cluster.worker.id; + global.database.splitCache('global_stats'); + global.database.splitCache('pplns_stats'); + global.database.splitCache('pps_stats'); + global.database.splitCache('solo_stats'); app.listen(8000, function () { console.log('Process ' + process.pid + ' is listening to all incoming requests'); }); diff --git a/lib/worker.js b/lib/worker.js index 5c741731..2a8bcd14 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -270,9 +270,9 @@ function updateShareStats() { function updatePoolStats(poolType) { let cache; if (typeof(poolType) !== 'undefined') { - cache = global.database.getCache(poolType + "_stats"); + cache = global.database.getCacheSum(poolType + "_stats"); } else { - cache = global.database.getCache("global_stats"); + cache = global.database.getCacheSum("global_stats"); } async.series([ function (callback) { From 23ebd3666fbe6b8303294d532fe2d6a1471f3d92 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 17:38:03 +0100 Subject: [PATCH 0058/2430] Update previous roundHashes/totalHashes values So we do not loose them after process restart and later splitCache --- lib/local_comms.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index e8096bd8..14cdafca 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -564,7 +564,7 @@ function Database(){ debug("Getting Key Sum: "+cacheKey); try { this.refreshEnv(); - let txn = this.env.beginTxn({readOnly: true}); + let txn = this.env.beginTxn(); let cached = txn.getString(this.cacheDB, cacheKey); if (cached !== null) { debug("Result for Key Sum: " + cacheKey + " is: " + cached); @@ -581,9 +581,10 @@ function Database(){ else console.error("Key " + cacheKey + "_" + i.toString() + " does not have roundHashes!!!"); } } - txn.abort(); json_cache.totalHashes = totalHashes; json_cache.roundHashes = roundHashes; + txn.putString(this.cacheDB, cacheKey, JSON.stringify(json_cache)); + txn.commit(); return json_cache; } txn.abort(); From f472bab6e75b807d9a1e5ff0ceb7b51c18a38e36 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 17:53:29 +0100 Subject: [PATCH 0059/2430] Syntax error fix --- 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 14cdafca..093d2c20 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -60,7 +60,7 @@ function Database(){ console.error("No worker_id was assigned!!!"); return key; } - } + }; this.incrementCacheData = function(key, data){ this.refreshEnv(); From 724501073a3eda6cf37d01b69a79a1ad962e9a27 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 17:57:57 +0100 Subject: [PATCH 0060/2430] Fixed this --- 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 093d2c20..a468968f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -55,7 +55,7 @@ function Database(){ // this computes worker thread specific cache key for safe updates this.worker_key = function(key) { if (this.hasOwnProperty("worker_id")) { - return key + "_" + this.worker_id.toString(); + return key + "_" + global.database.worker_id.toString(); } else { console.error("No worker_id was assigned!!!"); return key; @@ -85,7 +85,7 @@ function Database(){ this.incrementCacheDataPart = function(key, data){ this.refreshEnv(); let txn = this.env.beginTxn(); - let cached = txn.getString(this.cacheDB, this.worker_key(key)); + let cached = txn.getString(this.cacheDB, global.database.worker_key(key)); if (cached !== null){ cached = JSON.parse(cached); let reset_time_string = txn.getString(this.cacheDB, key + '_roundhashes_reset_time'); @@ -111,7 +111,7 @@ function Database(){ cached[intDict.location] += intDict.value; } }); - txn.putString(this.cacheDB, this.worker_key(key), JSON.stringify(cached)); + txn.putString(this.cacheDB, global.database.worker_key(key), JSON.stringify(cached)); txn.commit(); } else { txn.abort(); @@ -288,7 +288,7 @@ function Database(){ for (let key in cachedData){ if (cachedData.hasOwnProperty(key) && cachedData[key].totalHashes !== 0){ // only global cachedData stats has roundHashes - let key2 = cachedData[key].hasOwnProperty('roundHashes') ? this.worker_key(key) : key; + let key2 = cachedData[key].hasOwnProperty('roundHashes') ? global.database.worker_key(key) : key; let cacheStore = txn.getString(global.database.cacheDB, key2); if (cacheStore === null){ txn.putString(global.database.cacheDB, key2, JSON.stringify(cachedData[key])); @@ -617,7 +617,7 @@ function Database(){ else console.error("Key " + cacheKey + " does not have totalHashes!!!"); if (json_cache.hasOwnProperty('roundHashes')) json_cache.roundHashes /= this.numWorkers; else console.error("Key " + cacheKey + " does not have roundHashes!!!"); - txn.putString(this.cacheDB, this.worker_key(cacheKey), JSON.stringify(json_cache)); + txn.putString(this.cacheDB, global.database.worker_key(cacheKey), JSON.stringify(json_cache)); txn.putString(this.cacheDB, cacheKey + '_roundhashes_reset_time', '0'); txn.commit(); } else { From 7ee688967cd59844be639dbc0561077559b610a5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 18:00:05 +0100 Subject: [PATCH 0061/2430] Fixed this/2 --- 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 a468968f..e7d6ff5f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -307,7 +307,7 @@ function Database(){ } } else if (cachedData[key].hasOwnProperty('roundHashes')) { if (json_cache.hasOwnProperty('roundHashes')) { - let reset_time_string = txn.getString(this.cacheDB, key + '_roundhashes_reset_time'); + let reset_time_string = txn.getString(global.database.cacheDB, key + '_roundhashes_reset_time'); let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; if (!this.roundhashes_reset_times.hasOwnProperty(key)) { console.error("Unknown key " + key + " for this.roundhashes_reset_times!!!"); From 76814da6ffa02ede8c4475a5c0778f907314a677 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 18:01:18 +0100 Subject: [PATCH 0062/2430] Fixed this/3 --- lib/local_comms.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index e7d6ff5f..10fe5e3e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -90,19 +90,19 @@ function Database(){ cached = JSON.parse(cached); let reset_time_string = txn.getString(this.cacheDB, key + '_roundhashes_reset_time'); let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; - if (!this.roundhashes_reset_times.hasOwnProperty(key)) { - console.error("Unknown key " + key + " for this.roundhashes_reset_times!!!"); + if (!global.database.roundhashes_reset_times.hasOwnProperty(key)) { + console.error("Unknown key " + key + " for global.database.roundhashes_reset_times!!!"); } data.forEach(function(intDict){ if (intDict.location === 'roundHashes' && intDict.value === false) { cached[intDict.location] = 0; let time_now = Date.now(); - this.roundhashes_reset_times[key] = time_now; + global.database.roundhashes_reset_times[key] = time_now; txn.putString(this.cacheDB, key + '_roundhashes_reset_time', time_now.toString()); - } else if (intDict.location === 'roundHashes' && this.roundhashes_reset_times[key] < reset_time) { + } else if (intDict.location === 'roundHashes' && global.database.roundhashes_reset_times[key] < reset_time) { cached[intDict.location] = intDict.value; - this.roundhashes_reset_times[key] = reset_time; + global.database.roundhashes_reset_times[key] = reset_time; } else if (!cached.hasOwnProperty(intDict.location)) { cached[intDict.location] = 0; @@ -309,12 +309,12 @@ function Database(){ if (json_cache.hasOwnProperty('roundHashes')) { let reset_time_string = txn.getString(global.database.cacheDB, key + '_roundhashes_reset_time'); let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; - if (!this.roundhashes_reset_times.hasOwnProperty(key)) { - console.error("Unknown key " + key + " for this.roundhashes_reset_times!!!"); + if (!global.database.roundhashes_reset_times.hasOwnProperty(key)) { + console.error("Unknown key " + key + " for global.database.roundhashes_reset_times!!!"); } - if (this.roundhashes_reset_times[key] < reset_time) { + if (global.database.roundhashes_reset_times[key] < reset_time) { json_cache.roundHashes = cachedData[key].roundHashes; - this.roundhashes_reset_times[key] = reset_time; + global.database.roundhashes_reset_times[key] = reset_time; } else { json_cache.roundHashes += cachedData[key].roundHashes; } @@ -606,7 +606,7 @@ function Database(){ this.splitCache = function(cacheKey){ debug("Splitting Key: "+cacheKey); let time_now = Date.now(); - this.roundhashes_reset_times[cacheKey] = time_now; + global.database.roundhashes_reset_times[cacheKey] = time_now; try { this.refreshEnv(); let txn = this.env.beginTxn(); From cefe99955ea32706b73d22b024748cfd3947bf6e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 18:07:36 +0100 Subject: [PATCH 0063/2430] Partial revert to previous solution --- lib/local_comms.js | 19 ++++++++++--------- lib/worker.js | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 10fe5e3e..a688f5ac 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -198,16 +198,16 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - this.incrementCacheDataPart('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); switch (share.poolType) { case global.protos.POOLTYPE.PPLNS: - this.incrementCacheDataPart('pplns_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('pplns_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; case global.protos.POOLTYPE.PPS: - this.incrementCacheDataPart('pps_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('pps_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; case global.protos.POOLTYPE.SOLO: - this.incrementCacheDataPart('solo_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('solo_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; } this.incrementCacheData(minerIDWithIdentifier, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]); @@ -288,7 +288,8 @@ function Database(){ for (let key in cachedData){ if (cachedData.hasOwnProperty(key) && cachedData[key].totalHashes !== 0){ // only global cachedData stats has roundHashes - let key2 = cachedData[key].hasOwnProperty('roundHashes') ? global.database.worker_key(key) : key; + //let key2 = cachedData[key].hasOwnProperty('roundHashes') ? global.database.worker_key(key) : key; + let key2 = key; let cacheStore = txn.getString(global.database.cacheDB, key2); if (cacheStore === null){ txn.putString(global.database.cacheDB, key2, JSON.stringify(cachedData[key])); @@ -448,16 +449,16 @@ function Database(){ let txn = global.database.env.beginTxn(); txn.putBinary(global.database.blockDB, blockId, blockData); txn.commit(); - global.database.incrementCacheDataPart('global_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('global_stats', [{location: 'roundHashes', value: false}]); switch (blockDataDecoded.poolType) { case global.protos.POOLTYPE.PPLNS: - global.database.incrementCacheDataPart('pplns_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('pplns_stats', [{location: 'roundHashes', value: false}]); break; case global.protos.POOLTYPE.PPS: - global.database.incrementCacheDataPart('pps_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('pps_stats', [{location: 'roundHashes', value: false}]); break; case global.protos.POOLTYPE.SOLO: - global.database.incrementCacheDataPart('solo_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('solo_stats', [{location: 'roundHashes', value: false}]); break; } return callback(true); diff --git a/lib/worker.js b/lib/worker.js index 2a8bcd14..5c741731 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -270,9 +270,9 @@ function updateShareStats() { function updatePoolStats(poolType) { let cache; if (typeof(poolType) !== 'undefined') { - cache = global.database.getCacheSum(poolType + "_stats"); + cache = global.database.getCache(poolType + "_stats"); } else { - cache = global.database.getCacheSum("global_stats"); + cache = global.database.getCache("global_stats"); } async.series([ function (callback) { From 2d706884e88a8a87c78b17b3a095bb1f2e111570 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 18:24:52 +0100 Subject: [PATCH 0064/2430] Fixed set check --- 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 a688f5ac..d4dd7299 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -90,7 +90,7 @@ function Database(){ cached = JSON.parse(cached); let reset_time_string = txn.getString(this.cacheDB, key + '_roundhashes_reset_time'); let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; - if (!global.database.roundhashes_reset_times.hasOwnProperty(key)) { + if (!(key in global.database.roundhashes_reset_times)) { console.error("Unknown key " + key + " for global.database.roundhashes_reset_times!!!"); } data.forEach(function(intDict){ @@ -310,7 +310,7 @@ function Database(){ if (json_cache.hasOwnProperty('roundHashes')) { let reset_time_string = txn.getString(global.database.cacheDB, key + '_roundhashes_reset_time'); let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; - if (!global.database.roundhashes_reset_times.hasOwnProperty(key)) { + if (!(key in global.database.roundhashes_reset_times)) { console.error("Unknown key " + key + " for global.database.roundhashes_reset_times!!!"); } if (global.database.roundhashes_reset_times[key] < reset_time) { From 15253ae99ebe242289762bbc3c72a8105ddd08a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 21:11:08 +0100 Subject: [PATCH 0065/2430] Significantly simplfied code to handle cache update issue Basically moved all updates to *2 keys so they are not rolled back from worker update. --- lib/local_comms.js | 168 +++++++-------------------------------------- lib/remoteShare.js | 5 -- lib/worker.js | 6 ++ 3 files changed, 29 insertions(+), 150 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index d4dd7299..9296cfe2 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -9,8 +9,6 @@ function Database(){ this.shareDB = null; this.blockDB = null; this.cacheDB = null; - this.roundhashes_reset_times = []; - this.numWorkers = require('os').cpus().length; this.dirtyenv = false; @@ -52,16 +50,6 @@ function Database(){ console.log("Database Worker: LMDB Env Initialized."); }; - // this computes worker thread specific cache key for safe updates - this.worker_key = function(key) { - if (this.hasOwnProperty("worker_id")) { - return key + "_" + global.database.worker_id.toString(); - } else { - console.error("No worker_id was assigned!!!"); - return key; - } - }; - this.incrementCacheData = function(key, data){ this.refreshEnv(); let txn = this.env.beginTxn(); @@ -82,42 +70,6 @@ function Database(){ } }; - this.incrementCacheDataPart = function(key, data){ - this.refreshEnv(); - let txn = this.env.beginTxn(); - let cached = txn.getString(this.cacheDB, global.database.worker_key(key)); - if (cached !== null){ - cached = JSON.parse(cached); - let reset_time_string = txn.getString(this.cacheDB, key + '_roundhashes_reset_time'); - let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; - if (!(key in global.database.roundhashes_reset_times)) { - console.error("Unknown key " + key + " for global.database.roundhashes_reset_times!!!"); - } - data.forEach(function(intDict){ - if (intDict.location === 'roundHashes' && intDict.value === false) { - cached[intDict.location] = 0; - let time_now = Date.now(); - global.database.roundhashes_reset_times[key] = time_now; - txn.putString(this.cacheDB, key + '_roundhashes_reset_time', time_now.toString()); - - } else if (intDict.location === 'roundHashes' && global.database.roundhashes_reset_times[key] < reset_time) { - cached[intDict.location] = intDict.value; - global.database.roundhashes_reset_times[key] = reset_time; - - } else if (!cached.hasOwnProperty(intDict.location)) { - cached[intDict.location] = 0; - - } else { - cached[intDict.location] += intDict.value; - } - }); - txn.putString(this.cacheDB, global.database.worker_key(key), JSON.stringify(cached)); - txn.commit(); - } else { - txn.abort(); - } - }; - this.getBlockList = function(pool_type){ debug("Getting block list"); switch (pool_type) { @@ -198,16 +150,16 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - this.incrementCacheData('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('global_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); switch (share.poolType) { case global.protos.POOLTYPE.PPLNS: - this.incrementCacheData('pplns_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('pplns_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; case global.protos.POOLTYPE.PPS: - this.incrementCacheData('pps_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('pps_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; case global.protos.POOLTYPE.SOLO: - this.incrementCacheData('solo_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); + this.incrementCacheData('solo_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); break; } this.incrementCacheData(minerIDWithIdentifier, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]); @@ -225,10 +177,10 @@ function Database(){ this.storeBulkShares = function(shareObject) { let cachedData = { - global_stats: {totalHashes: 0, roundHashes: 0}, - pplns_stats: {totalHashes: 0, roundHashes: 0}, - pps_stats: {totalHashes: 0, roundHashes: 0}, - solo_stats: {totalHashes: 0, roundHashes: 0} + global_stats2: {totalHashes: 0, roundHashes: 0}, + pplns_stats2: {totalHashes: 0, roundHashes: 0}, + pps_stats2: {totalHashes: 0, roundHashes: 0}, + solo_stats2: {totalHashes: 0, roundHashes: 0} }; let shares = {}; // Shares keyed by blockID let shareCount = 0; @@ -246,18 +198,18 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - cachedData.global_stats.totalHashes += share.shares; - cachedData.global_stats.roundHashes += share.shares; - let stats_type = 'pplns_stats'; + cachedData.global_stats2.totalHashes += share.shares; + cachedData.global_stats2.roundHashes += share.shares; + let stats_type = 'pplns_stats2'; switch (share.poolType) { case global.protos.POOLTYPE.PPLNS: - stats_type = 'pplns_stats'; + stats_type = 'pplns_stats2'; break; case global.protos.POOLTYPE.PPS: - stats_type = 'pps_stats'; + stats_type = 'pps_stats2'; break; case global.protos.POOLTYPE.SOLO: - stats_type = 'solo_stats'; + stats_type = 'solo_stats2'; break; } cachedData[stats_type].totalHashes += share.shares; @@ -287,12 +239,9 @@ function Database(){ let txn = global.database.env.beginTxn(); for (let key in cachedData){ if (cachedData.hasOwnProperty(key) && cachedData[key].totalHashes !== 0){ - // only global cachedData stats has roundHashes - //let key2 = cachedData[key].hasOwnProperty('roundHashes') ? global.database.worker_key(key) : key; - let key2 = key; - let cacheStore = txn.getString(global.database.cacheDB, key2); + let cacheStore = txn.getString(global.database.cacheDB, key); if (cacheStore === null){ - txn.putString(global.database.cacheDB, key2, JSON.stringify(cachedData[key])); + txn.putString(global.database.cacheDB, key, JSON.stringify(cachedData[key])); } else { let json_cache = JSON.parse(cacheStore); if (json_cache.hasOwnProperty('totalHashes')) { // cachedData.totalHashes is always there for global and miners stats @@ -308,24 +257,12 @@ function Database(){ } } else if (cachedData[key].hasOwnProperty('roundHashes')) { if (json_cache.hasOwnProperty('roundHashes')) { - let reset_time_string = txn.getString(global.database.cacheDB, key + '_roundhashes_reset_time'); - let reset_time = reset_time_string !== null ? parseInt(reset_time_string, 10) : 0; - if (!(key in global.database.roundhashes_reset_times)) { - console.error("Unknown key " + key + " for global.database.roundhashes_reset_times!!!"); - } - if (global.database.roundhashes_reset_times[key] < reset_time) { - json_cache.roundHashes = cachedData[key].roundHashes; - global.database.roundhashes_reset_times[key] = reset_time; - } else { - json_cache.roundHashes += cachedData[key].roundHashes; - } + json_cache.roundHashes += cachedData[key].roundHashes; } else { json_cache.roundHashes = cachedData[key].roundHashes; } - } else { - console.error("cachedData should have either goodShares or roundHashes!!!"); } - txn.putString(global.database.cacheDB, key2, JSON.stringify(json_cache)); + txn.putString(global.database.cacheDB, key, JSON.stringify(json_cache)); } } } @@ -449,16 +386,16 @@ function Database(){ let txn = global.database.env.beginTxn(); txn.putBinary(global.database.blockDB, blockId, blockData); txn.commit(); - global.database.incrementCacheData('global_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('global_stats2', [{location: 'roundHashes', value: false}]); switch (blockDataDecoded.poolType) { case global.protos.POOLTYPE.PPLNS: - global.database.incrementCacheData('pplns_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('pplns_stats2', [{location: 'roundHashes', value: false}]); break; case global.protos.POOLTYPE.PPS: - global.database.incrementCacheData('pps_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('pps_stats2', [{location: 'roundHashes', value: false}]); break; case global.protos.POOLTYPE.SOLO: - global.database.incrementCacheData('solo_stats', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('solo_stats2', [{location: 'roundHashes', value: false}]); break; } return callback(true); @@ -561,40 +498,6 @@ function Database(){ return false; }; - this.getCacheSum = function(cacheKey){ - debug("Getting Key Sum: "+cacheKey); - try { - this.refreshEnv(); - let txn = this.env.beginTxn(); - let cached = txn.getString(this.cacheDB, cacheKey); - if (cached !== null) { - debug("Result for Key Sum: " + cacheKey + " is: " + cached); - let json_cache = JSON.parse(cached); - let totalHashes = 0; - let roundHashes = 0; - for (let i = 1; i <= this.numWorkers; ++ i) { - let cached2 = txn.getString(this.cacheDB, cacheKey + "_" + i.toString()); - if (cached2 !== null) { - let json_cache2 = JSON.parse(cached2); - if (json_cache2.hasOwnProperty('totalHashes')) totalHashes += json_cache2.totalHashes; - else console.error("Key " + cacheKey + "_" + i.toString() + " does not have totalHashes!!!"); - if (json_cache2.hasOwnProperty('roundHashes')) roundHashes += json_cache2.roundHashes; - else console.error("Key " + cacheKey + "_" + i.toString() + " does not have roundHashes!!!"); - } - } - json_cache.totalHashes = totalHashes; - json_cache.roundHashes = roundHashes; - txn.putString(this.cacheDB, cacheKey, JSON.stringify(json_cache)); - txn.commit(); - return json_cache; - } - txn.abort(); - } catch (e) { - return false; - } - return false; - }; - this.setCache = function(cacheKey, cacheData){ debug("Setting Key: "+cacheKey+ " Data: " + JSON.stringify(cacheData)); this.refreshEnv(); @@ -603,31 +506,6 @@ function Database(){ txn.commit(); }; - // this spits cache value into worker thread local value - this.splitCache = function(cacheKey){ - debug("Splitting Key: "+cacheKey); - let time_now = Date.now(); - global.database.roundhashes_reset_times[cacheKey] = time_now; - try { - this.refreshEnv(); - let txn = this.env.beginTxn(); - let cached = txn.getString(this.cacheDB, cacheKey); - if (cached !== null){ - let json_cache = JSON.parse(cached); - if (json_cache.hasOwnProperty('totalHashes')) json_cache.totalHashes /= this.numWorkers; - else console.error("Key " + cacheKey + " does not have totalHashes!!!"); - if (json_cache.hasOwnProperty('roundHashes')) json_cache.roundHashes /= this.numWorkers; - else console.error("Key " + cacheKey + " does not have roundHashes!!!"); - txn.putString(this.cacheDB, global.database.worker_key(cacheKey), JSON.stringify(json_cache)); - txn.putString(this.cacheDB, cacheKey + '_roundhashes_reset_time', '0'); - txn.commit(); - } else { - txn.abort(); - } - } catch (e) { - } - }; - this.bulkSetCache = function(cacheUpdates){ let txn = this.env.beginTxn(); txn.putString(this.cacheDB, 'cacheUpdate', 'cacheUpdate'); @@ -707,7 +585,7 @@ function Database(){ } else { global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { oldestLockedBlock.height = result.height; - console.log(`Got the oldest block`); + console.log("Got the oldest block"); callback(null, oldestLockedBlock); }); } diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 0cd5823f..0c564aef 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -102,11 +102,6 @@ if (cluster.isMaster) { workerList.push(worker); }); } else { - global.database.worker_id = cluster.worker.id; - global.database.splitCache('global_stats'); - global.database.splitCache('pplns_stats'); - global.database.splitCache('pps_stats'); - global.database.splitCache('solo_stats'); app.listen(8000, function () { console.log('Process ' + process.pid + ' is listening to all incoming requests'); }); diff --git a/lib/worker.js b/lib/worker.js index 5c741731..d22a4c47 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -271,8 +271,14 @@ function updatePoolStats(poolType) { let cache; if (typeof(poolType) !== 'undefined') { cache = global.database.getCache(poolType + "_stats"); + let cache2 = global.database.getCache(poolType + "_stats2"); + cache.totalHashes = cache2.totalHashes; + cache.roundHashes = cache2.roundHashes; } else { cache = global.database.getCache("global_stats"); + let cache2 = global.database.getCache("global_stats2"); + cache.totalHashes = cache2.totalHashes; + cache.roundHashes = cache2.roundHashes; } async.series([ function (callback) { From 0c6a2fef873c875c1fa50bd7f63f40af893aca66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 21:49:09 +0100 Subject: [PATCH 0066/2430] Returned previous waterfall BT update logic To be able to do 3sec cooldowns in case of monerod failure to avoid its overload with 0.3s requests --- lib/pool.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 11c222e0..0d56d482 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -171,10 +171,9 @@ function templateUpdate(repeating) { newBlockTemplate(rpcResponse); } } + if (repeating === true) setTimeout(templateUpdate, 300, true); } else { - if (repeating !== true) { - setTimeout(templateUpdate, 300); - } + setTimeout(templateUpdate, 3000, repeating); } }); } @@ -975,7 +974,7 @@ if (cluster.isMaster) { workerList.push(worker); }); templateUpdate(); - setInterval(templateUpdate, 300, true); + setTimeout(templateUpdate, 300, 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 { setInterval(checkAliveMiners, 30000); From c1be0858fd00add2dc1d89d6f8ee36c2002c8067 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 20 Dec 2017 22:30:31 +0100 Subject: [PATCH 0067/2430] Added error message for BT errors --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 0d56d482..f177f262 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -173,6 +173,7 @@ function templateUpdate(repeating) { } if (repeating === true) setTimeout(templateUpdate, 300, true); } else { + console.error("Block template request failed!"); setTimeout(templateUpdate, 3000, repeating); } }); From 3d028f552d5e04019df109d8c070748a06250de5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Dec 2017 08:26:45 +0100 Subject: [PATCH 0068/2430] Returned no meta sync LMDB option After recent cache update fix this is no longer needed to triage the problem --- 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 9296cfe2..4257f54b 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -21,7 +21,7 @@ function Database(){ noSync: false, mapAsync: false, useWritemap: false, - noMetaSync: false, + noMetaSync: true, maxReaders: 512 }); global.database.shareDB = this.env.openDbi({ From 702ddee0860a40fdf64588341bc7911eb92eab87 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Thu, 21 Dec 2017 06:46:34 -0800 Subject: [PATCH 0069/2430] Update deploy.bash --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 53b3e5f6..01e2e4c1 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -91,5 +91,5 @@ mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api bash ~/nodejs-pool/deployment/install_lmdb_tools.sh cd ~/nodejs-pool/sql_sync/ -env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin node sql_sync.js +env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin node sql_sync.js echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" From 86de0c13f746d65f6251fcaf935d87893464307f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 21 Dec 2017 17:00:26 +0100 Subject: [PATCH 0070/2430] Added BT caching --- lib/pool.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f177f262..52cad6b7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -17,6 +17,8 @@ let baseDiff = global.coinFuncs.baseDiff(); let pastBlockTemplates = global.support.circularBuffer(4); let activeMiners = []; let activeBlockTemplate; +let lastBlockTemplateUpdateTime; +let lastBlockHash; let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; let threadName; @@ -154,7 +156,7 @@ function checkAliveMiners() { } } -function templateUpdate(repeating) { +function templateUpdateReal() { global.coinFuncs.getBlockTemplate(global.config.pool.address, function (rpcResponse) { if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; @@ -171,10 +173,26 @@ function templateUpdate(repeating) { newBlockTemplate(rpcResponse); } } - if (repeating === true) setTimeout(templateUpdate, 300, true); } else { console.error("Block template request failed!"); - setTimeout(templateUpdate, 3000, repeating); + setTimeout(templateUpdateReal, 3000); + } + }); +} + +function templateUpdate(repeating) { + global.coinFuncs.getLastBlockHeader(function (err, body) { + if (err === null) { + let time_now = Date.now(); + if (!lastBlockHash || body.hash !== lastBlockHash || !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 10*1000) { + lastBlockHash = body.hash; + lastBlockTemplateUpdateTime = time_now; + templateUpdateReal(); + } + if (repeating === true) setTimeout(templateUpdate, 100, repeating); + } else { + console.error("Last block header request failed failed!"); + setTimeout(templateUpdate, 1000, repeating); } }); } @@ -975,7 +993,7 @@ if (cluster.isMaster) { workerList.push(worker); }); templateUpdate(); - setTimeout(templateUpdate, 300, 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 { setInterval(checkAliveMiners, 30000); From d31bfedfa0da54c9a5a75d07cae11c67d067c34f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Dec 2017 00:17:41 +0100 Subject: [PATCH 0071/2430] Garbage check of nonce --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 52cad6b7..38a0768d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -861,7 +861,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } - params.nonce = params.nonce.substr(0, 8).toLowerCase(); + params.nonce = (typeof params.nonce === 'string' ? params.nonce.substr(0, 8).toLowerCase() : ""); if (!nonceCheck.test(params.nonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); miner.checkBan(false); From 90d5ae3a09fdfd2c1fe165fb52cb273f19d0698c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Dec 2017 09:59:46 +0100 Subject: [PATCH 0072/2430] Switched to more correct way to move from float to coin number --- 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 7a31e56c..fc7bdf38 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -602,7 +602,7 @@ function makePayments() { payeeObjects[row.payment_address] = payee; global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { roundCount += 1; - let threshold = 0.3 * global.config.general.sigDivisor; + let threshold = global.support.decimalToCoin(0.3); let custom_threshold = false; if (userRow.length !== 0 && userRow[0].payout_threshold != 0) { threshold = userRow[0].payout_threshold; From 686eb4ae76660d5a7907dfd1f0c6541f0d41da6a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Dec 2017 13:39:33 +0100 Subject: [PATCH 0073/2430] Added persistent wallet trust --- lib/pool.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 38a0768d..25042d58 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -27,7 +27,6 @@ let BlockTemplate = global.coinFuncs.BlockTemplate; let hexMatch = new RegExp("^[0-9a-f]+$"); let totalShares = 0, trustedShares = 0, normalShares = 0, invalidShares = 0; - Buffer.prototype.toByteArray = function () { return Array.prototype.slice.call(this, 0); }; @@ -223,7 +222,6 @@ let VarDiff = (function () { }; })(); - // here we keep verified share number of a specific wallet (miner.payout) // it will reset to 0 after invalid share is found // if walletTrust exceeds certain threshold (global.config.pool.trustThreshold * 100) then low diff (<=16000) new workers for this wallet are started with high trust @@ -1003,6 +1001,36 @@ if (cluster.isMaster) { bannedIPs = []; templateUpdate(); }, 60000); + + // load merged wallet trust from files + let numWorkers = require('os').cpus().length; + for (let i = 1; i <= numWorkers; ++ i) { + var lineReader = require('readline').createInterface({ + input: fs.createReadStream("wallet_trust_" + i.toString()) + }); + lineReader.on('line', function (line) { + let parts = line.split(/\t/); + if (parts.length != 2) { + console.error("Error line " + line + " ignored from wallet_trust_" + i.toString() + " file"); + return; + } + let wallet = parts[0]; + let trust = parseInt(parts[1], 10); + if (!(wallet in walletTrust) || trust < walletTrust[wallet]) { + console.log("Adding " + trust.toString() + " trust for " + wallet + " wallet"); + walletTrust[wallet] = trust; + } + }); + } + + // dump wallet trust to file + setInterval(function () { + let str = ""; + for (let wallet in walletTrust) str += wallet + "\t" + walletTrust[wallet].toString() + "\n"; + let fn = "wallet_trust_" + cluster.worker.id.toString(); + fs.writeFile(fn, str, function(err) { if (err) console.error("Error saving " + fn + " file"); }); + }, 60*1000); + async.each(global.config.ports, function (portData) { if (global.config[portData.portType].enable !== true) { return; From 1077f576cfc24df2907ae6591b5894959ae97cee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Dec 2017 13:52:03 +0100 Subject: [PATCH 0074/2430] Fixed case with missing trust files --- lib/pool.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 25042d58..15cce533 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1005,13 +1005,14 @@ if (cluster.isMaster) { // load merged wallet trust from files let numWorkers = require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { - var lineReader = require('readline').createInterface({ - input: fs.createReadStream("wallet_trust_" + i.toString()) - }); + let fn = "wallet_trust_" + i.toString(); + let rs = fs.createReadStream(fn); + rs.on('error', function() { console.error("Can't open " + fn + " file"); }); + let lineReader = require('readline').createInterface({ input: rs }); lineReader.on('line', function (line) { let parts = line.split(/\t/); if (parts.length != 2) { - console.error("Error line " + line + " ignored from wallet_trust_" + i.toString() + " file"); + console.error("Error line " + line + " ignored from " + fn + " file"); return; } let wallet = parts[0]; From 6c70cb30681648bece84877f3eb881eef2f4fe45 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Dec 2017 14:31:29 +0100 Subject: [PATCH 0075/2430] Added not used wallet trust removal --- lib/pool.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 15cce533..cdd1adcf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -227,6 +227,8 @@ let VarDiff = (function () { // if walletTrust exceeds certain threshold (global.config.pool.trustThreshold * 100) then low diff (<=16000) new workers for this wallet are started with high trust // this is needed to avoid CPU overload after constant miner reconnections that happen during mining botnet swarms let walletTrust = {}; +// wallet last seen time (all wallets that are not detected for more than 1 day are removed) +let walletLastSeeTime = {}; function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent) { // Username Layout -
. @@ -364,7 +366,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.logString = this.address + " ID: " + this.identifier + " IP: " + this.ipAddress; if (global.config.pool.trustedMiners) { - if (!(this.payout in walletTrust)) walletTrust[this.payout] = 0; + if (!(this.payout in walletTrust)) { + 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 * 100; this.trust = { threshold: is_trusted_wallet ? 1 : global.config.pool.trustThreshold, @@ -749,6 +754,7 @@ function processShare(miner, job, blockTemplate, params) { hash = global.coinFuncs.cryptoNight(convertedBlob); shareType = false; ++ walletTrust[miner.payout]; + walletLastSeeTime[miner.payout] = Date.now(); } if (hash.toString('hex') !== resultHash) { console.error(threadName + "Bad share from miner " + miner.logString); @@ -762,6 +768,7 @@ function processShare(miner, job, blockTemplate, params) { } miner.sendNewJob(); walletTrust[miner.payout] = 0; + walletLastSeeTime[miner.payout] = Date.now(); return false; } @@ -1011,15 +1018,17 @@ if (cluster.isMaster) { let lineReader = require('readline').createInterface({ input: rs }); lineReader.on('line', function (line) { let parts = line.split(/\t/); - if (parts.length != 2) { + if (parts.length != 3) { console.error("Error line " + line + " ignored from " + fn + " file"); return; } let wallet = parts[0]; let trust = parseInt(parts[1], 10); - if (!(wallet in walletTrust) || trust < walletTrust[wallet]) { + 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"); walletTrust[wallet] = trust; + walletLastSeeTime[wallet] = time; } }); } @@ -1027,10 +1036,18 @@ if (cluster.isMaster) { // dump wallet trust to file setInterval(function () { let str = ""; - for (let wallet in walletTrust) str += wallet + "\t" + walletTrust[wallet].toString() + "\n"; + for (let wallet in walletTrust) { + let time = walletLastSeeTime[wallet]; + if (Date.now() - time < 24*60*60*1000) { + str += wallet + "\t" + walletTrust[wallet].toString() + "\t" + time.toString() + "\n"; + } else { + delete walletTrust[wallet]; + delete walletLastSeeTime[wallet]; + } + } let fn = "wallet_trust_" + cluster.worker.id.toString(); fs.writeFile(fn, str, function(err) { if (err) console.error("Error saving " + fn + " file"); }); - }, 60*1000); + }, 10*60*1000); async.each(global.config.ports, function (portData) { if (global.config[portData.portType].enable !== true) { From 61f421e9e4c9cbf9bee8510bd5ceab734b92eff9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 22 Dec 2017 14:46:33 +0100 Subject: [PATCH 0076/2430] Added quick worker status emails for infrequent recipients --- lib/support.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index a9a841b8..1d00e5a5 100644 --- a/lib/support.js +++ b/lib/support.js @@ -38,8 +38,10 @@ function circularBuffer(size) { return buffer; } -// accumulates email notifications up to one hour +// accumulates email notifications up to one hour (email/subject -> body) let emailAcc = {}; +// last send time of email (email/subject -> time) +let emailLastSendTime = {}; function sendEmailReal(toAddress, subject, body){ request.post(global.config.general.mailgunURL + "/messages", { @@ -72,6 +74,9 @@ function sendEmail(toAddress, subject, body, wallet){ let key = toAddress + "\t" + subject; if (!(key in emailAcc)) { emailAcc[key] = body; + let time_now = Date.now(); + let is_fast_email = !(key in emailLastSendTime) || time_now - emailLastSendTime[key] > 6*60*60*1000; + emailLastSendTime[key] = time_now; setTimeout(function(email_address, email_subject, wallet) { let key2 = email_address + "\t" + email_subject; let email_body = emailAcc[key2]; @@ -80,7 +85,7 @@ function sendEmail(toAddress, subject, body, wallet){ wallet: wallet }; sendEmailReal(email_address, email_subject, "Hello,\n\n" + email_body + "\n\nThank you,\n" + sprintf(global.config.general.emailSig, emailData)); - }, 30*60*1000, toAddress, subject, wallet); + }, (is_fast_email ? 5 : 30)*60*1000, toAddress, subject, wallet); } else { emailAcc[key] += body; } From cc92889661e926f11533f8717ff9f7171f67acd5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Dec 2017 04:50:39 +0100 Subject: [PATCH 0077/2430] Adjucted parameters based on real data --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cdd1adcf..aa2770bb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -370,7 +370,7 @@ 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 * 100; + 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, From 3c35894b44f910a83851010156d1112136132c66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Dec 2017 17:54:03 +0100 Subject: [PATCH 0078/2430] Lowered threshold to check all shares too 400000 To match nicehash diff --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index aa2770bb..c30021f3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -744,7 +744,7 @@ function processShare(miner, job, blockTemplate, params) { let hash; let shareType; - if (global.config.pool.trustedMiners && miner.difficulty < 500000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && + if (global.config.pool.trustedMiners && miner.difficulty < 400000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability) { hash = new Buffer(resultHash, 'hex'); shareType = true; From c1bce55d8f23afc62af359c3bd7be7e78dd63828 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Dec 2017 21:43:14 +0100 Subject: [PATCH 0079/2430] Disabled Admin API for better security Do not use it anyway... --- lib/api.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/api.js b/lib/api.js index e4274bfe..cbb447e0 100644 --- a/lib/api.js +++ b/lib/api.js @@ -484,7 +484,7 @@ app.post('/authenticate', function (req, res) { // JWT Verification // get an instance of the router for api routes let secureRoutes = express.Router(); -let adminRoutes = express.Router(); +//let adminRoutes = express.Router(); // route middleware to verify a token secureRoutes.use(function (req, res, next) { @@ -546,7 +546,7 @@ secureRoutes.post('/changePayoutThreshold', function (req, res) { // Administrative routes/APIs -adminRoutes.use(function (req, res, next) { +/*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) { @@ -573,11 +573,9 @@ adminRoutes.use(function (req, res, next) { }); 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 - */ + // 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}, @@ -746,11 +744,9 @@ adminRoutes.put('/config', function (req, res) { }); 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. - */ + // 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 " + @@ -814,11 +810,11 @@ adminRoutes.get('/userList', function (req, res) { } return res.json([]); }); -}); +});*/ // apply the routes to our application with the prefix /api app.use('/authed', secureRoutes); -app.use('/admin', adminRoutes); +//app.use('/admin', adminRoutes); // Authenticated routes From 884c9768edbcccc7caf528270b5e2c6c24d5406a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Dec 2017 23:55:53 +0100 Subject: [PATCH 0080/2430] Optimized new/old owrker detection No longer need to loop global worker list that can only grow --- lib/worker.js | 110 +++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 51 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index d22a4c47..25635e3f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -14,7 +14,7 @@ function updateShareStats() { // Buffer lengths? You guessed it, configured in SQL. // Stats timeouts are 30 seconds, so everything for buffers should be there. let currentTime = Date.now(); - let activeAddresses = []; + //let activeAddresses = []; async.waterfall([ function (callback) { global.coinFuncs.getLastBlockHeader(function (err, body) { @@ -134,10 +134,8 @@ function updateShareStats() { return oldestTime <= identifierTime; }, function (err) { // todo: Need to finish parsing the cached data into caches for caching purproses. - let globalMinerList = global.database.getCache('minerList'); - if (globalMinerList === false) { - globalMinerList = []; - } + let prevMinerList = global.database.getCache('minerList'); + if (prevMinerList === false) prevMinerList = minerList; let cache_updates = {}; // pplns: 0, pps: 0, solo: 0, prop: 0, global: 0 ['pplns', 'pps', 'solo', 'prop', 'global'].forEach(function (key) { @@ -177,12 +175,9 @@ function updateShareStats() { cache_updates[key + "_stats"] = cachedData; }); minerList.forEach(function (miner) { - if (globalMinerList.indexOf(miner) === -1) { - globalMinerList.push(miner); - } - if (miner.indexOf('_') === -1){ - activeAddresses.push(miner); - } + //if (miner.indexOf('_') === -1){ + // activeAddresses.push(miner); + //} let cachedData = global.database.getCache(miner); if (cachedData !== false) { cachedData.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; @@ -210,50 +205,63 @@ function updateShareStats() { } cache_updates[miner] = cachedData; }); - globalMinerList.forEach(function (miner) { - let minerStats = global.database.getCache(miner); - let is_stop_hashing = false; - let is_start_hashing = false; - if (minerList.indexOf(miner) === -1) { - is_stop_hashing = minerStats.hash !== 0; - } else { - is_start_hashing = minerStats !== false && cache_updates[miner].hash !== 0 && minerStats.hash === 0; - } - if (is_stop_hashing || is_start_hashing) { - if (is_stop_hashing) console.log("Removing: " + miner + " as an active miner from the cache."); - if (is_start_hashing) console.log("Adding: " + miner + " as an active miner to the cache."); - if (miner.indexOf('_') > -1) { - // This is a worker case. - let address_parts = miner.split(/_(.+)/); - let address = address_parts[0]; - let worker = address_parts[1]; - global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { - if (rows.length === 0) { - return; - } - // toAddress, subject, body - let emailData = { - worker: worker, - timestamp: global.support.formatDate(Date.now()), - poolEmailSig: global.config.general.emailSig - }; - global.support.sendEmail(rows[0].email, - sprintf(is_stop_hashing ? global.config.email.workerNotHashingSubject : global.config.email.workerStartHashingSubject, emailData), - sprintf(is_stop_hashing ? global.config.email.workerNotHashingBody : global.config.email.workerStartHashingBody, emailData), - address - ); - }); - } - if (is_stop_hashing) { - minerStats.hash = 0; - cache_updates[miner] = minerStats; - } - } + + // remove old workers + prevMinerList.forEach(function (miner) { + if (minerList.indexOf(miner) !== -1) continue; // we still have this miner in current list + console.log("Removing: " + miner + " as an active miner from the cache."); + if (miner.indexOf('_') <= -1) continue; + + // This is a worker case. + let address_parts = miner.split(/_(.+)/); + let address = address_parts[0]; + let worker = address_parts[1]; + global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { + if (rows.length === 0) return; + // toAddress, subject, body + let emailData = { + worker: worker, + timestamp: global.support.formatDate(Date.now()), + poolEmailSig: global.config.general.emailSig + }; + /*global.support.sendEmail(rows[0].email, + sprintf(global.config.email.workerNotHashingSubject, emailData), + sprintf(global.config.email.workerNotHashingBody, emailData), + address + );*/ + }); + }); + + // find new workers + minerList.forEach(function (miner) { + if (prevMinerList.indexOf(miner) !== -1) continue; // we still have this miner in previous list + console.log("Adding: " + miner + " as an active miner to the cache."); + if (miner.indexOf('_') <= -1) continue; + + // This is a worker case. + let address_parts = miner.split(/_(.+)/); + let address = address_parts[0]; + let worker = address_parts[1]; + global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { + if (rows.length === 0) return; + // toAddress, subject, body + let emailData = { + worker: worker, + timestamp: global.support.formatDate(Date.now()), + poolEmailSig: global.config.general.emailSig + }; + /*global.support.sendEmail(rows[0].email, + sprintf(global.config.email.workerStartHashingSubject, emailData), + sprintf(global.config.email.workerStartHashingBody, emailData), + address + );*/ + }); }); + Object.keys(identifiers).forEach(function (key) { cache_updates[key + '_identifiers'] = identifiers[key]; }); - cache_updates.minerList = globalMinerList; + cache_updates.minerList = minerList; global.database.bulkSetCache(cache_updates); callback(null); }); From 97f870bcae369506bb39a2f9ae320a3fea16bc99 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Dec 2017 23:58:03 +0100 Subject: [PATCH 0081/2430] Fixed C-style --- lib/worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 25635e3f..35adc4ab 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -208,9 +208,9 @@ function updateShareStats() { // remove old workers prevMinerList.forEach(function (miner) { - if (minerList.indexOf(miner) !== -1) continue; // we still have this miner in current list + if (minerList.indexOf(miner) !== -1) return; // we still have this miner in current list console.log("Removing: " + miner + " as an active miner from the cache."); - if (miner.indexOf('_') <= -1) continue; + if (miner.indexOf('_') <= -1) return; // This is a worker case. let address_parts = miner.split(/_(.+)/); @@ -234,9 +234,9 @@ function updateShareStats() { // find new workers minerList.forEach(function (miner) { - if (prevMinerList.indexOf(miner) !== -1) continue; // we still have this miner in previous list + if (prevMinerList.indexOf(miner) !== -1) return; // we still have this miner in previous list console.log("Adding: " + miner + " as an active miner to the cache."); - if (miner.indexOf('_') <= -1) continue; + if (miner.indexOf('_') <= -1) return; // This is a worker case. let address_parts = miner.split(/_(.+)/); From d8d391807475bd5cf680b41feca953b3a578820a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Dec 2017 23:59:42 +0100 Subject: [PATCH 0082/2430] Enabled emails --- lib/worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 35adc4ab..505f196a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -224,11 +224,11 @@ function updateShareStats() { timestamp: global.support.formatDate(Date.now()), poolEmailSig: global.config.general.emailSig }; - /*global.support.sendEmail(rows[0].email, + global.support.sendEmail(rows[0].email, sprintf(global.config.email.workerNotHashingSubject, emailData), sprintf(global.config.email.workerNotHashingBody, emailData), address - );*/ + ); }); }); @@ -250,11 +250,11 @@ function updateShareStats() { timestamp: global.support.formatDate(Date.now()), poolEmailSig: global.config.general.emailSig }; - /*global.support.sendEmail(rows[0].email, + global.support.sendEmail(rows[0].email, sprintf(global.config.email.workerStartHashingSubject, emailData), sprintf(global.config.email.workerStartHashingBody, emailData), address - );*/ + ); }); }); From af0d5d6ca385e4b2ac5ececbc788080e87fa50ed Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Dec 2017 10:02:54 +0100 Subject: [PATCH 0083/2430] Fix for orphan block endless submits from leafs --- lib/local_comms.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index 4257f54b..acc6f69b 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -373,11 +373,21 @@ function Database(){ return global.protos.Block.encode(blockData); }; + // hash -> time + 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){ + // after hour of submit attempts finally cosider this block as orphan + if (err && typeof(err.message) === 'string' && err.message.indexOf("can't get block by hash") > -1) { + let time_now = Date.now(); + if (blockDataDecoded.hash in orphanBlocks) { + if (time_now - orphanBlocks[blockDataDecoded.hash] > 60*60*1000) return callback(true); + } else orphanBlocks[blockDataDecoded.hash] = time_now; + } if (err || typeof(header) === 'undefined' || !header){ return callback(false); } From 0921394443876f3aa86208f38f4f33bdac27e8e6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Dec 2017 11:43:39 +0100 Subject: [PATCH 0084/2430] Added more logging to orphan block handling --- lib/local_comms.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index acc6f69b..c5a3df21 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -385,8 +385,14 @@ function Database(){ if (err && typeof(err.message) === 'string' && err.message.indexOf("can't get block by hash") > -1) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { - if (time_now - orphanBlocks[blockDataDecoded.hash] > 60*60*1000) return callback(true); - } else orphanBlocks[blockDataDecoded.hash] = time_now; + if (time_now - orphanBlocks[blockDataDecoded.hash] > 60*60*1000) { + console.log("Stopped attempts to store orphan block " + blockDataDecoded.hash); + return callback(true); + } + } else { + console.log("Started attempts to store orphan block " + blockDataDecoded.hash); + orphanBlocks[blockDataDecoded.hash] = time_now; + } } if (err || typeof(header) === 'undefined' || !header){ return callback(false); From 6896df5048e654f9cd41819e50d394473dcf277b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Dec 2017 11:47:10 +0100 Subject: [PATCH 0085/2430] Fixed orphan block response handling --- 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 c5a3df21..88de4475 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -382,7 +382,7 @@ function Database(){ let blockDataDecoded = global.protos.Block.decode(blockData); global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ // after hour of submit attempts finally cosider this block as orphan - if (err && typeof(err.message) === 'string' && err.message.indexOf("can't get block by hash") > -1) { + if (header && header.error && typeof(header.error.message) === 'string' && header.error.message.indexOf("can't get block by hash") > -1) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { if (time_now - orphanBlocks[blockDataDecoded.hash] > 60*60*1000) { From 173475d84a440b27c52ddd4c6392a364eeec41bf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 25 Dec 2017 11:48:14 +0100 Subject: [PATCH 0086/2430] Made orphan block handling even more robust --- 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 88de4475..3da10d90 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -382,7 +382,7 @@ function Database(){ let blockDataDecoded = global.protos.Block.decode(blockData); global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ // after hour of submit attempts finally cosider this block as orphan - if (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) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { if (time_now - orphanBlocks[blockDataDecoded.hash] > 60*60*1000) { From 85d6c769a028e87194d6c7cd84458ebaf8f24fce Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 27 Dec 2017 11:35:03 +0100 Subject: [PATCH 0087/2430] Added more simple password setup and mysql request caching --- lib/pool.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c30021f3..87b1a0a5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -230,6 +230,10 @@ let walletTrust = {}; // wallet last seen time (all wallets that are not detected for more than 1 day are removed) let walletLastSeeTime = {}; +var reEmail = /^\S+@\S+\.\S+$/; +// wallet password last check time +let walletLastCheckTime = {}; + function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent) { // Username Layout -
. // Password Layout - .. @@ -239,6 +243,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // Miner Variables 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 + if (pass_split.length === 1 && reEmail.test(pass_split[0])) { + pass_split.push(pass_split[0]); + pass_split[0] = "email"; + } this.error = ""; this.identifier = pass_split[0]; this.proxy = false; @@ -307,15 +317,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer Need to do an initial registration call here. Might as well do it right... */ let payoutAddress = this.payout; - global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [this.payout]).then(function (rows) { - if (rows.length > 0) { - return; - } - if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { - return; - } - global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, pass_split[1]]); - }); + let time_now = Date.now(); + if ((!payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { + global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [this.payout]).then(function (rows) { + if (rows.length > 0) { + return; + } + if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { + return; + } + global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, pass_split[1]]); + }); + walletLastCheckTime[payoutAddress] = time_now; + } } else if (pass_split.length > 2) { this.error = "Too many options in the password field"; this.valid_miner = false; From dd460321ab5673c8d62b290cb7a5993782f397d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 27 Dec 2017 13:51:20 +0100 Subject: [PATCH 0088/2430] Fixed logic error --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 87b1a0a5..41b3d7e9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -318,7 +318,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer */ let payoutAddress = this.payout; let time_now = Date.now(); - if ((!payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { + if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [this.payout]).then(function (rows) { if (rows.length > 0) { return; From 2fee36dda2ba7752932344c3f246929ad8adb04a Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Wed, 27 Dec 2017 21:46:10 -0800 Subject: [PATCH 0089/2430] Update local_comms.js --- 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 ac70fea7..17c99756 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -628,7 +628,7 @@ function Database(){ let blockList = []; console.log("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); range.range(0, lastBlock+1).forEach(function (blockID) { - blockID = (blockID - lastBlock+1) * -1; + blockID = Number((blockID - lastBlock+1) * -1); if (blockID < 0){ return; } From cbffa25d3d7a3598dfef5632515a5aa41ba852cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 28 Dec 2017 11:07:49 +0100 Subject: [PATCH 0090/2430] Share clean bug fixes 1) Put extra guard againts unordered blocks to correctly getOldestLockedBlock 2) Checks for getLastBlockHeader error 3) Fixes PPLNS share removal for long blocks --- lib/local_comms.js | 26 ++++++++++++++++---------- lib/pool.js | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index d817506e..b82961ed 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -546,15 +546,19 @@ function Database(){ debug("Getting the oldest locked block in the system"); let txn = this.env.beginTxn({readOnly: true}); let cursor = new this.lmdb.Cursor(txn, this.blockDB); + let highestBlockKey = null; let highestBlock = null; for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - if (highestBlock !== null){ - break; - } cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let blockData = global.protos.Block.decode(data); if (blockData.unlocked === false){ - highestBlock = blockData; + if (highestBlock === null || highestBlockKey >= key) { + if (highestBlock !== null) { + console.error("Found unordered blocks with " + highestBlockKey.toString() + " and " + key.toString() + " heights"); + } + highestBlock = blockData; + highestBlockKey = key; + } } }); } @@ -608,6 +612,10 @@ function Database(){ }, function(oldestLockedBlock, callback){ global.coinFuncs.getLastBlockHeader(function(err, body){ + if (err !== null) { + console.error("Last block header request failed!"); + return; + } if (oldestLockedBlock === null){ /* If there's no locked blocks, then allow the system to scan from the PPS depth downwards if PPS @@ -645,14 +653,11 @@ function Database(){ let pplnsFound = false; let blockList = []; console.log("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); - range.range(0, lastBlock+1).forEach(function (blockID) { - blockID = Number((blockID - lastBlock+1) * -1); - if (blockID < 0){ - return; - } + range.range(lastBlock-1, 0, -1).forEach(function (blockID) { debug("Scanning block: " + blockID); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); + let pplnsCurrFound = false; for (let found = (cursor.goToRange(blockID) === blockID); found; found = cursor.goToNextDup()) { if (pplnsFound){ cursor.getCurrentBinary(function(key, data) { // jshint ignore:line @@ -672,12 +677,13 @@ function Database(){ } }); if (shareCount >= difficulty){ - pplnsFound = true; + pplnsCurrFound = true; } } } cursor.close(); txn.abort(); + if (pplnsCurrFound) pplnsFound = true; }); callback(null, blockList); } diff --git a/lib/pool.js b/lib/pool.js index 41b3d7e9..839150d1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -190,7 +190,7 @@ function templateUpdate(repeating) { } if (repeating === true) setTimeout(templateUpdate, 100, repeating); } else { - console.error("Last block header request failed failed!"); + console.error("Last block header request failed!"); setTimeout(templateUpdate, 1000, repeating); } }); From d744d8a856b6d40c2ddc69fc8d62c568e400011a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 29 Dec 2017 11:25:57 +0100 Subject: [PATCH 0091/2430] Added guard against stuck BT --- lib/pool.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 839150d1..2627a8a8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -19,6 +19,7 @@ let activeMiners = []; let activeBlockTemplate; let lastBlockTemplateUpdateTime; let lastBlockHash; +let lastBlockHashUpdateTime; let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; let threadName; @@ -180,10 +181,17 @@ function templateUpdateReal() { } function templateUpdate(repeating) { + if (lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 30*60*1000) { + console.error("Block height was not updated for half an hour. Check your monerod. Exiting..."); + fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); + process.exit(); + } global.coinFuncs.getLastBlockHeader(function (err, body) { if (err === null) { let time_now = Date.now(); - if (!lastBlockHash || body.hash !== lastBlockHash || !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 10*1000) { + let is_block_hash_updated = !lastBlockHash || body.hash !== lastBlockHash; + if (is_block_hash_updated || !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 10*1000) { + if (is_block_hash_updated) lastBlockHashUpdateTime = time_now; lastBlockHash = body.hash; lastBlockTemplateUpdateTime = time_now; templateUpdateReal(); @@ -979,6 +987,11 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } } +if (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(); +} + if (cluster.isMaster) { let numWorkers = require('os').cpus().length; global.config.ports.forEach(function (portData) { From 8587e2fe9ee9fa1a23be1b262bdb8eadff0ca985 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Jan 2018 11:18:05 +0100 Subject: [PATCH 0092/2430] Added code to store all last wallet shares ...and clean walletAcc --- lib/pool.js | 90 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2627a8a8..b264daf2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -602,11 +602,53 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } // store wallet_key (address, paymentID, bitcoin, poolTypeEnum) -> worker_name -> shareType -> (height, difficulty, time, acc) -let walletAcc = {}; +let walletAcc = {}; // number of worker_name for wallet_key (so we do not count them by iteration) -let walletWorkerCount = {}; -// time of last scan for dead worker_name -let walletWorkerScanTime = {}; +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) { + //console.log("!!! " + wallet_key + ": scanning for old worker names"); + let wallet = walletAcc[wallet_key]; + let is_something_left = false; + let time_now = Date.now(); + for (let worker_name in wallet) { + let worker = wallet[worker_name]; + if (time_now - worker["time"] > 60*1000) { + let acc = worker["acc"]; + if (acc != 0) { + let height = worker["height"]; + //console.log("!!! " + wallet_key + " / " + worker_name + ": storing old worker share " + height + " " + worker["difficulty"] + " " + time_now + " " + acc); + global.database.storeShare(height, global.protos.Share.encode({ + shares: acc, + 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 + })); + } + //console.log("!!! " + wallet_key + ": removing old worker " + worker_name); + if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; + delete wallet[worker_name]; + } else { + is_something_left = true; + } + } + + if (is_something_left) { + setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner_address, miner_paymentID, miner_bitcoin, miner_poolTypeEnum); + } else { + is_walletAccFinalizer[wallet_key] = false; + } +} function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareType, blockTemplate) { miner.hashes += job.difficulty; @@ -619,10 +661,10 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy if (!(wallet_key in walletAcc)) { walletAcc[wallet_key] = {}; walletWorkerCount[wallet_key] = 0; - walletWorkerScanTime[wallet_key] = time_now; + is_walletAccFinalizer[wallet_key] = false; } - if (job.difficulty >= 1000000) { + if (job.difficulty >= 1000000 || blockCandidate) { global.database.storeShare(job.height, global.protos.Share.encode({ shares: job.difficulty, @@ -669,7 +711,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy shares: acc, paymentAddress: miner.address, paymentID: miner.paymentID, - foundBlock: blockCandidate, + foundBlock: false, trustedShare: shareType, poolType: miner.poolTypeEnum, poolID: global.config.pool_id, @@ -693,37 +735,9 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + job.height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.difficulty + ")"); } - if (time_now - walletWorkerScanTime[wallet_key] > 60*1000) { - //console.log("!!! " + wallet_key + ": scanning for old worker names"); - let wallet = walletAcc[wallet_key]; - for (let worker_name2 in wallet) { - let worker2 = wallet[worker_name2]; - if (time_now - worker2["time"] > 60*1000) { - let acc2 = worker2["acc"]; - if (acc2 != 0) { - let height2 = worker2["height"]; - //console.log("!!! " + wallet_key + " / " + worker_name2 + ": storing old worker share " + height2 + " " + worker2["difficulty"] + " " + time_now + " " + acc2); - global.database.storeShare(height2, global.protos.Share.encode({ - shares: acc2, - paymentAddress: miner.address, - paymentID: miner.paymentID, - foundBlock: blockCandidate, - trustedShare: true, - poolType: miner.poolTypeEnum, - poolID: global.config.pool_id, - blockDiff: worker2["difficulty"], - bitcoin: miner.bitcoin, - blockHeight: height2, - timestamp: time_now, - identifier: worker_name2 - })); - } - //console.log("!!! " + wallet_key + ": removing old worker " + worker_name2); - if (worker_name2 !== "all_other_workers") -- walletWorkerCount[wallet_key]; - delete wallet[worker_name2]; - } - } - walletWorkerScanTime[wallet_key] = time_now; + 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); } if (blockCandidate) { From 993c7580ef311fe36a16cc8c94e3e8813794cc5c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Jan 2018 18:46:13 +0100 Subject: [PATCH 0093/2430] Reduce spam from invalid miner messages --- lib/pool.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b264daf2..300308c1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -848,6 +848,8 @@ function processShare(miner, job, blockTemplate, params) { return true; } +let lastMessageTime; + function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let miner = activeMiners[params.id]; // Check for ban here, so preconnected attackers can't continue to screw you @@ -866,7 +868,11 @@ 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); if (!miner.valid_miner) { - console.log("Invalid miner, disconnecting due to: " + miner.error); + let time_now = Date.now(); + if (!lastMessageTime || time_now - lastMessageTime > 10*1000) { + console.log("Invalid miner, disconnecting due to: " + miner.error); + lastMessageTime = time_now; + } sendReply(miner.error); return; } From 9c3b757cfaedd1c5b2969b40a6c5f9db7f32bbad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 1 Jan 2018 19:00:39 +0100 Subject: [PATCH 0094/2430] Reduced spam even more --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 300308c1..1fff3fc3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -869,7 +869,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent); if (!miner.valid_miner) { let time_now = Date.now(); - if (!lastMessageTime || time_now - lastMessageTime > 10*1000) { + if (!lastMessageTime || time_now - lastMessageTime > 30*1000) { console.log("Invalid miner, disconnecting due to: " + miner.error); lastMessageTime = time_now; } From b1ddc2188b1e9af383112b95fcc1e43d20d8e242 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Jan 2018 12:02:22 +0100 Subject: [PATCH 0095/2430] Whitespace --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1fff3fc3..10c65208 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -643,11 +643,11 @@ 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); - } else { - is_walletAccFinalizer[wallet_key] = false; - } + if (is_something_left) { + setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner_address, miner_paymentID, miner_bitcoin, miner_poolTypeEnum); + } else { + is_walletAccFinalizer[wallet_key] = false; + } } function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareType, blockTemplate) { From 338b1f54d612e9874b6ef60b6581547abf86093b Mon Sep 17 00:00:00 2001 From: Ace <34975638+CoinLogik@users.noreply.github.com> Date: Sun, 7 Jan 2018 20:42:24 -0500 Subject: [PATCH 0096/2430] Update README.md Makes install instructions more clear. Side note: Current "Installation assistance" donation amounts are a bit high at current XMR price :) --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9e50019f..73d1dc69 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,10 @@ Deployment via Installer 1. Add your user to `/etc/sudoers`, this must be done so the script can sudo up and do it's job. We suggest passwordless sudo. Suggested line: ` ALL=(ALL) NOPASSWD:ALL`. Our sample builds use: `pooldaemon ALL=(ALL) NOPASSWD:ALL` 2. Run the [deploy script](https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/deploy.bash) as a **NON-ROOT USER**. This is very important! This script will install the pool to whatever user it's running under! Also. Go get a coffee, this sucker bootstraps the monero installation. -3. Once it's complete, change as `config.json` appropriate. It is pre-loaded for a local install of everything, running on 127.0.0.1. This will work perfectly fine if you're using a single node setup. You will also want to run: source ~/.bashrc This will activate NVM and get things working for the following pm2 steps. -4. You'll need to change the API end point for the frontend code in the `poolui/build/globals.js` and `poolui/build/global.default.js` -- This will usually be `http(s):///api` unless you tweak caddy! -5. Check `config.json` and change as appropriate. The default database directory `/home//pool_db/` is already been created during startup. If you change the `db_storage_path` just make sure your user has write permissions for new path. Run: `pm2 restart api` to reload the API for usage. You'll also want to set `bind_ip` to the external IP of the pool server, and `hostname` to the resolvable hostname for the pool server. `pool_id` is mostly used for multi-server installations to provide unique identifiers in the backend. -6. Hop into the web interface (Should be at `http:///#/admin`), then login with `Administrator/Password123`, **MAKE SURE TO CHANGE THIS PASSWORD ONCE YOU LOGIN**. *<- This step is currently not active, we're waiting for the frontend to catch up! Head down to the Manual SQL Configuration to take a look at what needs to be done by hand for now*. +3. Once it's complete, change as `config.json` appropriate. It is pre-loaded for a local install of everything, running on 127.0.0.1. This will work perfectly fine if you're using a single node setup. You'll also want to set `bind_ip` to the external IP of the pool server, and `hostname` to the resolvable hostname for the pool server. `pool_id` is mostly used for multi-server installations to provide unique identifiers in the backend. You will also want to run: source ~/.bashrc This will activate NVM and get things working for the following pm2 steps. +4. You'll need to change the API end point for the frontend code in the `poolui/build/globals.js` and `poolui/build/globals.default.js` -- This will usually be `http(s):///api` unless you tweak caddy! +5. The default database directory `/home//pool_db/` is already been created during startup. If you change the `db_storage_path` just make sure your user has write permissions for new path. Run: `pm2 restart api` to reload the API for usage. +6. Hop into the web interface (Should be at `http:///admin.html`), then login with `Administrator/Password123`, **MAKE SURE TO CHANGE THIS PASSWORD ONCE YOU LOGIN**. *<- This step is currently not active, we're waiting for the frontend to catch up! Head down to the Manual SQL Configuration to take a look at what needs to be done by hand for now*. 7. From the admin panel, you can configure all of your pool's settings for addresses, payment thresholds, etc. 8. Once you're happy with the settings, go ahead and start all the pool daemons, commands follow. From 080eba017aed7d38b1f084d92723d6d3474d2924 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Sun, 7 Jan 2018 22:39:23 -0800 Subject: [PATCH 0097/2430] Update README.md Removed the nasty LMDB warning. More than enough time has passed. --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 73d1dc69..3a8f5680 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,3 @@ -SUPER IMPORTANT UPDATE UNTIL THIS UPDATE DISAPPEARS -=================================================== -None of the following applies if you installed the pool AFTER June 2nd 2017, as the installers will do this work for you. - -The pool currently uses a version of LMDB that is not supported in Ubuntu 16.04 at this time. Please run: bash deployment/install_lmdb_tools.sh once from the root of the installation to load the LMDB tools, this will put them somewhere handy on your path, and drop a new alias to them so they can be used to introspect your database. - -If you had installed the pool prior to 6/2/2017, PLEASE make sure you run a npm install before you restart services. - Pool Design/Theory ================== The nodejs-pool is built around a small series of core daemons that share access to a single LMDB table for tracking of shares, with MySQL being used to centralize configurations and ensure simple access from local/remote nodes. The core daemons follow: From 0ed384622fe284f92f9a1573782c9abb9d7c6e92 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Sun, 7 Jan 2018 22:48:53 -0800 Subject: [PATCH 0098/2430] Update xmr.js NH wants higher diff. --- 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 558e0fb0..a4521110 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -40,7 +40,7 @@ function Coin(data){ this.supportsAutoExchange = true; - this.niceHashDiff = 200000; + this.niceHashDiff = 400000; this.getBlockHeaderByID = function(blockId, callback){ global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { From fa698ca29d8f530a3c710c8cde939a61c19499da Mon Sep 17 00:00:00 2001 From: bluesbrothers2k Date: Tue, 9 Jan 2018 15:46:22 +0100 Subject: [PATCH 0099/2430] Fix longRunner error in local_comms.js This fix solves the longRunner throwing errors after updating to NVM 8.9.3. Should solve problems described in #217 and #230. --- 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 17c99756..0e8335e4 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -635,7 +635,7 @@ function Database(){ debug("Scanning block: " + blockID); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - for (let found = (cursor.goToRange(blockID) === blockID); found; found = cursor.goToNextDup()) { + for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { if (pplnsFound){ cursor.getCurrentBinary(function(key, data) { // jshint ignore:line if (blockList.indexOf(key) === -1){ From 66a0860e89e4cfc05c1759df8014b2af6081488b Mon Sep 17 00:00:00 2001 From: azaryc2s Date: Wed, 10 Jan 2018 14:12:18 +0100 Subject: [PATCH 0100/2430] Fixed the timestamp calculation in seconds --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c61c911e..705e7e5a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -333,7 +333,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // VarDiff System this.shareTimeBuffer = global.support.circularBuffer(8); this.shareTimeBuffer.enq(global.config.pool.targetTime); - this.lastShareTime = Date.now() / 1000 || 0; + this.lastShareTime = Math.floor(Date.now() / 1000); this.validShares = 0; this.invalidShares = 0; From 4e47a2c511e533621f35d868e4e343dd5c428796 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Jan 2018 17:20:57 +0100 Subject: [PATCH 0101/2430] Fixed stuff for PPS mode --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1ad5fb6a..1c0b304f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -120,7 +120,7 @@ let balanceQueue = async.queue(function (task, callback) { ); function calculatePPSPayments(blockHeader, callback) { - if (global.config.payout.pps === true) { + if (global.config.pps.enable === true) { console.log("Performing PPS payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); } let paymentData = {}; @@ -146,7 +146,7 @@ function calculatePPSPayments(blockHeader, callback) { amount: 0 }; let totalPayments = 0; - if (global.config.payout.pps === true) { + 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()) { @@ -204,7 +204,7 @@ function calculatePPSPayments(blockHeader, callback) { }); totalPayments += paymentData[key].amount; }); - if (global.config.payout.pps === true) { + if (global.config.pps.enable === true) { 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(); From 3b08be334fd02433b7140a9a70a70f40f6b7bd0b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Jan 2018 11:02:30 +0100 Subject: [PATCH 0102/2430] Comented useless code --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 10c65208..bf9f6697 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -205,9 +205,9 @@ function templateUpdate(repeating) { } function newBlockTemplate(template) { - let buffer = new Buffer(template.blocktemplate_blob, 'hex'); - let previous_hash = new Buffer(32); - buffer.copy(previous_hash, 0, 7, 39); + //let buffer = new Buffer(template.blocktemplate_blob, 'hex'); + //let previous_hash = new Buffer(32); + //buffer.copy(previous_hash, 0, 7, 39); console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); if (activeBlockTemplate) { pastBlockTemplates.enq(activeBlockTemplate); From 3c5b09e26e8925009c314b3442b05b3b2d7e5dcf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Jan 2018 13:02:55 +0100 Subject: [PATCH 0103/2430] Fixed some length and instanceId stuff --- lib/coins/aeon.js | 5 +++-- lib/coins/krb.js | 5 +++-- lib/coins/xmr.js | 10 +++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/coins/aeon.js b/lib/coins/aeon.js index 4d0f9346..a0b58b5f 100644 --- a/lib/coins/aeon.js +++ b/lib/coins/aeon.js @@ -11,6 +11,7 @@ function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; let instanceId = crypto.randomBytes(4); + console.log("Generated instanceId: " + instanceId.toString('hex')); this.coinDevAddress = "WmsSWgtT1JPg5e3cK41hKXSHVpKW7e47bjgiKmWZkYrhSS5LhRemNyqayaSBtAQ6517eo5PtH9wxHVmM78JDZSUu2W8PqRiNs"; // Developer Address this.poolDevAddress = "WmtvM6SoYya4qzkoPB4wX7FACWcXyFPWAYzfz7CADECgKyBemAeb3dVb3QomHjRWwGS3VYzMJAnBXfUx5CfGLFZd1U7ssdXTu"; // Snipa Address @@ -99,7 +100,7 @@ function Coin(data){ /* 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 13 bytes long now in the following format: + 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| @@ -122,7 +123,7 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob. this.buffer = new Buffer(this.blob, 'hex'); // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. - instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3); + 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. diff --git a/lib/coins/krb.js b/lib/coins/krb.js index 1494da8f..ae37b826 100644 --- a/lib/coins/krb.js +++ b/lib/coins/krb.js @@ -11,6 +11,7 @@ function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; let instanceId = crypto.randomBytes(4); + console.log("Generated instanceId: " + instanceId.toString('hex')); this.coinDevAddress = "Kdev1L9V5ow3cdKNqDpLcFFxZCqu5W2GE9xMKewsB2pUXWxcXvJaUWHcSrHuZw91eYfQFzRtGfTemReSSMN4kE445i6Etb3"; // Developer Address this.poolDevAddress = "KgseWakG2bMXHGJSsAUfzL1HykCyvD4m8gd9qgcuyZ1ufy8PqUCKRxEfAv3nahfdTrCjZByiWoCiRiohxq4u2rf2RgQ1pcJ"; // Snipa Address @@ -99,7 +100,7 @@ function Coin(data){ /* 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 13 bytes long now in the following format: + 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| @@ -122,7 +123,7 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob. this.buffer = new Buffer(this.blob, 'hex'); // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. - instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3); + 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. diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a4521110..ca46b38c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -4,13 +4,17 @@ const cnUtil = require('cryptonote-util'); const multiHashing = require('multi-hashing'); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); +const process = require('process'); let hexChars = new RegExp("[0-9a-f]+"); function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; - let instanceId = crypto.randomBytes(4); + //let instanceId = crypto.randomBytes(4); + 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.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Developer Address this.poolDevAddress = "44Ldv5GQQhP7K7t3ZBdZjkPA7Kg7dhHwk3ZM3RJqxxrecENSFx27Vq14NAMAd2HBvwEPUVVvydPRLcC69JCZDHLT2X5a4gr"; // Snipa Address @@ -113,7 +117,7 @@ function Coin(data){ /* 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 13 bytes long now in the following format: + 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| @@ -136,7 +140,7 @@ function Coin(data){ // Set this.buffer to the binary decoded version of the BT blob. this.buffer = new Buffer(this.blob, 'hex'); // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. - instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3); + 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. From 50bbac9943fe22bb22f10c8349996de9c08bf129 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Jan 2018 15:23:10 +0100 Subject: [PATCH 0104/2430] Fixed dupe jobs --- lib/coins/xmr.js | 2 +- lib/pool.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ca46b38c..8d384cb3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -81,7 +81,7 @@ function Coin(data){ this.getBlockTemplate = function(walletAddress, callback){ global.support.rpcDaemon('getblocktemplate', { - reserve_size: 17, + reserve_size: 16, wallet_address: walletAddress }, function(body){ return callback(body); diff --git a/lib/pool.js b/lib/pool.js index bf9f6697..3ab3b399 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -205,13 +205,14 @@ function templateUpdate(repeating) { } function newBlockTemplate(template) { - //let buffer = new Buffer(template.blocktemplate_blob, 'hex'); - //let previous_hash = new Buffer(32); - //buffer.copy(previous_hash, 0, 7, 39); - console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); if (activeBlockTemplate) { + if (activeBlockTemplate.previous_hash.toString('hex') === template.prev_hash) { + console.log(threadName + 'Ignoring duplicate block template updade at height: ' + template.height + '. Difficulty: ' + template.difficulty); + return; + } pastBlockTemplates.enq(activeBlockTemplate); } + console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); activeBlockTemplate = new BlockTemplate(template); for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { From dbca0d7534e6b52fe5e6bec38049a72b07d5744b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Jan 2018 15:38:25 +0100 Subject: [PATCH 0105/2430] Returned reserved size back --- 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 8d384cb3..ca46b38c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -81,7 +81,7 @@ function Coin(data){ this.getBlockTemplate = function(walletAddress, callback){ global.support.rpcDaemon('getblocktemplate', { - reserve_size: 16, + reserve_size: 17, wallet_address: walletAddress }, function(body){ return callback(body); From 7f2f57dd18fba04e6ec6f3be139482b652fea75a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 11 Jan 2018 17:23:02 +0100 Subject: [PATCH 0106/2430] Grammar fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3ab3b399..cc08edce 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -207,7 +207,7 @@ function templateUpdate(repeating) { function newBlockTemplate(template) { if (activeBlockTemplate) { if (activeBlockTemplate.previous_hash.toString('hex') === template.prev_hash) { - console.log(threadName + 'Ignoring duplicate block template updade at height: ' + template.height + '. Difficulty: ' + template.difficulty); + console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } pastBlockTemplates.enq(activeBlockTemplate); From 846b51ad11f402f9e7aabafe8b2dad54fdc78c04 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 17 Jan 2018 17:39:18 +0100 Subject: [PATCH 0107/2430] Ignore too low fixed diff --- lib/pool.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index cc08edce..8ab8965c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -136,7 +136,7 @@ function retargetMiners() { for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; - if (!miner.fixed_diff) { + if (!miner.fixed_diff || (miner.hashes > 0 && miner.difficulty * 10 < miner.calcNewDiff())) { miner.updateDifficulty(); } } @@ -447,21 +447,21 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } }; + this.calcNewDiff = function () { + let target = this.proxy ? 5 : global.config.pool.targetTime; + return Math.floor((this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * target); + }; + this.updateDifficulty = function () { if (this.hashes > 0) { - let newDiff = 0; - if (this.proxy) { - newDiff = Math.floor(Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000)))* 5); - } else { - newDiff = Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime; - } - this.setNewDiff(newDiff); + this.setNewDiff(calcNewDiff()); } else { this.updateDifficultyOld(); } }; this.setNewDiff = function (difficulty) { + this.fixed_diff = false; this.newDiff = Math.round(difficulty); debug(threadName + "Difficulty: " + this.newDiff + " For: " + this.logString + " Time Average: " + this.shareTimeBuffer.average(this.lastShareTime) + " Entries: " + this.shareTimeBuffer.size() + " Sum: " + this.shareTimeBuffer.sum()); if (this.newDiff > global.config.pool.maxDifficulty && !this.proxy) { From 10266a909f519e057cd09ff9b48b70ee8fc1db3d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 17 Jan 2018 17:44:49 +0100 Subject: [PATCH 0108/2430] Disabled pool kill by default in case of stuck BT --- 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 619df5ef..959a0755 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 ('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 ('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); 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/pool.js b/lib/pool.js index 8ab8965c..03788c50 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -181,7 +181,7 @@ function templateUpdateReal() { } function templateUpdate(repeating) { - if (lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 30*60*1000) { + if (global.config.general.allowStuckPoolKill && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 30*60*1000) { console.error("Block height was not updated for half an hour. Check your monerod. Exiting..."); fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); process.exit(); @@ -1008,7 +1008,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } } -if (fs.existsSync("block_template_is_stuck")) { +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(); } From 200f644029882447f760dd6d34b129d8fac0085d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 17 Jan 2018 17:52:19 +0100 Subject: [PATCH 0109/2430] Fixed bug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 03788c50..832dba9a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -454,7 +454,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.updateDifficulty = function () { if (this.hashes > 0) { - this.setNewDiff(calcNewDiff()); + this.setNewDiff(this.calcNewDiff()); } else { this.updateDifficultyOld(); } From 920f80f7e43da83497046c52eba3d84bb5530eb1 Mon Sep 17 00:00:00 2001 From: Ace <34975638+CoinLogik@users.noreply.github.com> Date: Wed, 17 Jan 2018 17:38:57 -0500 Subject: [PATCH 0110/2430] Add coin_code to config variables that are returned from API Makes it easier for pool UI to change UI/text rather than hard-coding "XMR" etc into UI views. For example: UI template like: `Balance: {{ balance }} XMR` Can become: ``Balance: {{ balance }} {{config.coin_code}}`` --- lib/api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index e4274bfe..cb9737bc 100644 --- a/lib/api.js +++ b/lib/api.js @@ -174,7 +174,8 @@ app.get('/config', function (req, res) { dev_donation: global.config.payout.devDonation, pool_dev_donation: global.config.payout.poolDevDonation, maturity_depth: global.config.payout.blocksRequired, - min_denom: global.config.payout.denom * global.config.general.sigDivisor + min_denom: global.config.payout.denom * global.config.general.sigDivisor, + coin_code: global.config.general.coinCode }); }); From 95362d92d1d48416542c357aad3b56767e84ad56 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Jan 2018 00:04:04 +0100 Subject: [PATCH 0111/2430] Added high diff setting for non xmr-node-proxy proxies --- lib/pool.js | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 832dba9a..2c71d12c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -143,6 +143,10 @@ function retargetMiners() { } } +// wallet " " proxy miner name -> { connectTime, count, hashes } +// this is needed to set cummulative based diff for workers provided by Atreides proxy and xmrig-proxy +let proxyMiners = {}; + function checkAliveMiners() { debug(threadName + "Verifying if miners are still alive"); for (let minerId in activeMiners) { @@ -151,6 +155,8 @@ function checkAliveMiners() { if (Date.now() - miner.lastContact > global.config.pool.minerTimeout * 1000) { process.send({type: 'removeMiner', data: miner.port}); delete activeMiners[minerId]; + let proxyMinerName = miner.payout + ":" + miner.identifier; + if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName]["count"] <= 0) delete proxyMiners[proxyMinerName]; } } } @@ -320,6 +326,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.identifier = pass_split[0] === 'x' ? addressSplit[2] : pass_split[0]; } + this.identifier = this.identifier.substring(0, 64); + if (pass_split.length === 2) { /* Email address is: pass_split[1] @@ -409,7 +417,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.invalidShareProto = global.protos.InvalidShare.encode({ paymentAddress: this.address, paymentID: this.paymentID, - identifier: this.identifier.substring(0, 64) + identifier: this.identifier }); // Support functions for how miners activate and run. @@ -448,8 +456,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.calcNewDiff = function () { - let target = this.proxy ? 5 : global.config.pool.targetTime; - return Math.floor((this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * target); + let proxyMinerName = this.payout + ":" + this.identifier; + if (proxyMinerName in proxyMiners) { + let target = 5; + return Math.floor((proxyMiners[proxyMinerName]["hashes"] / (Math.floor((Date.now() - proxyMiners[proxyMinerName]["connectTime"]) / 1000))) * target); + } else { + let target = this.proxy ? 5 : global.config.pool.targetTime; + return Math.floor((this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * target); + } }; this.updateDifficulty = function () { @@ -461,7 +475,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.setNewDiff = function (difficulty) { - this.fixed_diff = false; this.newDiff = Math.round(difficulty); debug(threadName + "Difficulty: " + this.newDiff + " For: " + this.logString + " Time Average: " + this.shareTimeBuffer.average(this.lastShareTime) + " Entries: " + this.shareTimeBuffer.size() + " Sum: " + this.shareTimeBuffer.sum()); if (this.newDiff > global.config.pool.maxDifficulty && !this.proxy) { @@ -479,6 +492,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer 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); } + if (this.fixed_diff) { + console.log("Dropped low fixed diff for " + this.payout + ":" + this.identifier " miner to " + this.newDiff + " dynamic diff"); + this.fixed_diff = false; + } this.sendNewJob(); }; @@ -496,6 +513,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (this.validShares + this.invalidShares >= global.config.pool.banThreshold) { if (this.invalidShares / this.validShares >= global.config.pool.banPercent / 100) { delete activeMiners[this.id]; + let proxyMinerName = this.payout + ":" + this.identifier; + if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName]["count"] <= 0) delete proxyMiners[proxyMinerName]; process.send({type: 'banIP', data: this.ipAddress}); } else { @@ -653,8 +672,8 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareType, blockTemplate) { miner.hashes += job.difficulty; - - let safe_worker_name = miner.identifier.substring(0, 64); + let proxyMinerName = miner.payout + ":" + miner.identifier; + 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; @@ -679,14 +698,14 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy bitcoin: miner.bitcoin, blockHeight: job.height, timestamp: time_now, - identifier: safe_worker_name + identifier: miner.identifier })); } else { let wallet = walletAcc[wallet_key]; - let worker_name = safe_worker_name in wallet || walletWorkerCount[wallet_key] < 50 ? safe_worker_name : "all_other_workers"; + 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]; @@ -879,6 +898,17 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } process.send({type: 'newMiner', data: miner.port}); activeMiners[minerId] = miner; + if (!miner.proxy && params.agent && params.agent.includes('proxy')) { + let proxyMinerName = miner.payout + ":" + miner.identifier; + if (!(proxyMinerName in proxyMiners)) { + proxyMiners[proxyMinerName] = {}; + proxyMiners[proxyMinerName]["connectTime"] = Date.now(); + proxyMiners[proxyMinerName]["count"] = 0; + proxyMiners[proxyMinerName]["hashes"] = 0; + console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); + } + ++ proxyMiners[proxyMinerName]["count"]; + } sendReply(null, { id: minerId, job: miner.getJob(), From 8f43317b59a96b1bd80a37859b28c65ef05751ba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Jan 2018 00:05:41 +0100 Subject: [PATCH 0112/2430] Fixed typo --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2c71d12c..7bbff8b8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -493,7 +493,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime + " difficulty versus: " + this.newDiff); } if (this.fixed_diff) { - console.log("Dropped low fixed diff for " + this.payout + ":" + this.identifier " miner to " + this.newDiff + " dynamic diff"); + console.log("Dropped low fixed diff for " + this.payout + ":" + this.identifier + " miner to " + this.newDiff + " dynamic diff"); this.fixed_diff = false; } this.sendNewJob(); From ce708aa9b88c77417e9c6a75cd60bf136b9d3653 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 18 Jan 2018 00:08:53 +0100 Subject: [PATCH 0113/2430] Added more log info --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7bbff8b8..904c35c6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -493,7 +493,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime + " difficulty versus: " + this.newDiff); } if (this.fixed_diff) { - console.log("Dropped low fixed diff for " + this.payout + ":" + this.identifier + " miner to " + this.newDiff + " dynamic diff"); + console.log("Dropped low fixed diff " + this.difficulty + " for " + this.payout + ":" + this.identifier + " miner to " + this.newDiff + " dynamic diff"); this.fixed_diff = false; } this.sendNewJob(); From c2b296bc13f07114e61591db7ec94e5dcae64f3b Mon Sep 17 00:00:00 2001 From: Newbie Date: Thu, 18 Jan 2018 07:42:05 +0700 Subject: [PATCH 0114/2430] Unimportant fix NaN email, credit to 1rV1N-git Perhaps, you just want to leave it like that, you can cancel pull request and I'll make change directly to my repos. --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 505f196a..a00fcde9 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -538,7 +538,7 @@ function monitorNodes() { } rows.forEach(function (row) { if (row.blockID < block.height - 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"); + 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"); } } ); From a46ceed07b9c581d9b50d5b3a947065620a1e84a Mon Sep 17 00:00:00 2001 From: Ace <34975638+CoinLogik@users.noreply.github.com> Date: Thu, 18 Jan 2018 17:05:32 -0500 Subject: [PATCH 0115/2430] Fixes: you specified keyIsUint32 on the Dbi Fixes bug where height < 0 and causes error on line 43: `Error: You specified keyIsUint32 on the Dbi, so you can't use other key types with it.` --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 8714ca9a..788f4e00 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -127,7 +127,7 @@ function updateShareStats() { }, function (oldestTime) { height -= 1; loopBreakout += 1; - if (loopBreakout > 60) { + if (loopBreakout > 60 || height < 0) { return true; } return oldestTime <= identifierTime; @@ -534,4 +534,4 @@ setInterval(updatePoolStats, 5000, 'pps'); setInterval(updatePoolStats, 5000, 'solo'); setInterval(updatePoolInformation, 5000); setInterval(updateWalletStats, 60000); -setInterval(monitorNodes, 300000); \ No newline at end of file +setInterval(monitorNodes, 300000); From 549af973d44e6dd7c8d9d5b5e097f43271f74289 Mon Sep 17 00:00:00 2001 From: Newbie Date: Fri, 19 Jan 2018 21:43:34 +0700 Subject: [PATCH 0116/2430] TypeError: Cannot read property 'height' of undefined I think the Interval could be called too soon and there isn't activeBlockTemplate yet. If I'm not right, you can cancel this PR. https://github.com/Snipa22/nodejs-pool/issues/269 https://github.com/Snipa22/nodejs-pool/issues/150 --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c61c911e..96e8d6f1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -830,7 +830,9 @@ if (cluster.isMaster) { registerPool(); setInterval(function () { global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]); - global.mysql.query("UPDATE pools SET blockIDTime = now(), blockID = ? where id = ?", [activeBlockTemplate.height, global.config.pool_id]); + if (activeBlockTemplate) { + global.mysql.query("UPDATE pools SET blockIDTime = now(), blockID = ? where id = ?", [activeBlockTemplate.height, 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]); }); From 304b3f1f4f0aaec6d776d053b6953484ea9bc1c2 Mon Sep 17 00:00:00 2001 From: Newbie Date: Fri, 19 Jan 2018 21:46:39 +0700 Subject: [PATCH 0117/2430] Fix NaN , credit to 1rV1N-git https://github.com/Snipa22/nodejs-pool/issues/86 --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 788f4e00..cb0b499b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -513,7 +513,7 @@ function monitorNodes() { } rows.forEach(function (row) { if (row.blockID < block.height - 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"); + 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"); } } ); From 4e4a72382ba6d2bec8fe043908ee58401dcef001 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jan 2018 13:56:29 +0100 Subject: [PATCH 0118/2430] More detailed messages about login errors --- lib/api.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 35377a4a..d2892632 100644 --- a/lib/api.js +++ b/lib/api.js @@ -471,11 +471,24 @@ app.post('/authenticate', function (req, res) { try{ hmac = crypto.createHmac('sha256', global.config.api.secKey).update(req.body.password).digest('hex'); } catch (e) { - return res.status(401).send({'success': false, msg: 'Invalid username/password'}); + return res.status(401).send({'success': false, msg: 'Invalid password'}); } global.mysql.query("SELECT * FROM users WHERE username = ? AND ((pass IS null AND email = ?) OR (pass = ?))", [req.body.username, req.body.password, hmac]).then(function (rows) { if (rows.length === 0) { - return res.status(401).send({'success': false, msg: 'Invalid username/password'}); + + global.mysql.query("SELECT * FROM users WHERE username = ?", [req.body.username]).then(function (rows) { + if (rows.length === 0) { + return res.status(401).send({'success': false, msg: 'Password is not set, so you can not login now.'}); + } + }); + + global.mysql.query("SELECT * FROM users WHERE username = ? AND pass IS null", [req.body.username]).then(function (rows) { + if (rows.length === 1) { + return res.status(401).send({'success': false, msg: 'Wrong password. Password equals to string after : character in your miner password field.'}); + } + }); + + return res.status(401).send({'success': false, msg: 'Wrong password. Password was set by you in Dashboard Options before.'}); } let token = jwt.sign({id: rows[0].id, admin: rows[0].admin}, global.config.api.secKey, {expiresIn: '1d'}); return res.json({'success': true, 'msg': token}); From d305e9971136345239b776fe5e90efdefed3a04a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jan 2018 14:46:30 +0100 Subject: [PATCH 0119/2430] Fixed nested requests --- lib/api.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/api.js b/lib/api.js index d2892632..9119800c 100644 --- a/lib/api.js +++ b/lib/api.js @@ -475,23 +475,21 @@ app.post('/authenticate', function (req, res) { } global.mysql.query("SELECT * FROM users WHERE username = ? AND ((pass IS null AND email = ?) OR (pass = ?))", [req.body.username, req.body.password, hmac]).then(function (rows) { if (rows.length === 0) { - global.mysql.query("SELECT * FROM users WHERE username = ?", [req.body.username]).then(function (rows) { if (rows.length === 0) { return res.status(401).send({'success': false, msg: 'Password is not set, so you can not login now.'}); } + global.mysql.query("SELECT * FROM users WHERE username = ? AND pass IS null", [req.body.username]).then(function (rows) { + if (rows.length !== 0) { + return res.status(401).send({'success': false, msg: 'Wrong password. Password equals to string after : character in your miner password field.'}); + } + return res.status(401).send({'success': false, msg: 'Wrong password. Password was set by you in Dashboard Options before.'}); + }); }); - - global.mysql.query("SELECT * FROM users WHERE username = ? AND pass IS null", [req.body.username]).then(function (rows) { - if (rows.length === 1) { - return res.status(401).send({'success': false, msg: 'Wrong password. Password equals to string after : character in your miner password field.'}); - } - }); - - return res.status(401).send({'success': false, msg: 'Wrong password. Password was set by you in Dashboard Options before.'}); + } else { + let token = jwt.sign({id: rows[0].id, admin: rows[0].admin}, global.config.api.secKey, {expiresIn: '1d'}); + return res.json({'success': true, 'msg': token}); } - let token = jwt.sign({id: rows[0].id, admin: rows[0].admin}, global.config.api.secKey, {expiresIn: '1d'}); - return res.json({'success': true, 'msg': token}); }); }); From aff2200d0ffb27a768db16b97dc0786cf556faa0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jan 2018 19:15:32 +0100 Subject: [PATCH 0120/2430] BT update --- lib/pool.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f27a2fed..616cd401 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -166,10 +166,8 @@ function templateUpdateReal() { global.coinFuncs.getBlockTemplate(global.config.pool.address, function (rpcResponse) { if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; - let buffer = new Buffer(rpcResponse.blocktemplate_blob, 'hex'); - let new_hash = new Buffer(32); - buffer.copy(new_hash, 0, 7, 39); - if (!activeBlockTemplate || new_hash.toString('hex') !== activeBlockTemplate.previous_hash.toString('hex')) { + let new_hash = crypto.createHash('md5').update(rpcResponse.blocktemplate_blob).digest('hex'); + if (!activeBlockTemplate || activeBlockTemplate.idHash !== new_hash) { debug(threadName + "New block template found at " + rpcResponse.height + " height with hash: " + new_hash.toString('hex')); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); @@ -196,7 +194,7 @@ function templateUpdate(repeating) { if (err === null) { let time_now = Date.now(); let is_block_hash_updated = !lastBlockHash || body.hash !== lastBlockHash; - if (is_block_hash_updated || !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 10*1000) { + if (is_block_hash_updated || !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 30*1000) { if (is_block_hash_updated) lastBlockHashUpdateTime = time_now; lastBlockHash = body.hash; lastBlockTemplateUpdateTime = time_now; @@ -212,7 +210,7 @@ function templateUpdate(repeating) { function newBlockTemplate(template) { if (activeBlockTemplate) { - if (activeBlockTemplate.previous_hash.toString('hex') === template.prev_hash) { + if (activeBlockTemplate.idHash === crypto.createHash('md5').update(template.blocktemplate_blob).digest('hex')) { console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From a9454a2fec6adfc1586f43c8729fcb2106f68a6b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jan 2018 19:21:46 +0100 Subject: [PATCH 0121/2430] Disabled time based update --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 616cd401..7eaa13f9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -194,7 +194,7 @@ function templateUpdate(repeating) { if (err === null) { let time_now = Date.now(); let is_block_hash_updated = !lastBlockHash || body.hash !== lastBlockHash; - if (is_block_hash_updated || !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 30*1000) { + if (is_block_hash_updated || !lastBlockTemplateUpdateTime /*|| time_now - lastBlockTemplateUpdateTime > 30*1000*/) { if (is_block_hash_updated) lastBlockHashUpdateTime = time_now; lastBlockHash = body.hash; lastBlockTemplateUpdateTime = time_now; From c4527ca17dbed46547bccfabea2f83e335251339 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jan 2018 20:11:24 +0100 Subject: [PATCH 0122/2430] Temporary disabled worker BT updates --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7eaa13f9..51665590 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -194,7 +194,7 @@ function templateUpdate(repeating) { if (err === null) { let time_now = Date.now(); let is_block_hash_updated = !lastBlockHash || body.hash !== lastBlockHash; - if (is_block_hash_updated || !lastBlockTemplateUpdateTime /*|| time_now - lastBlockTemplateUpdateTime > 30*1000*/) { + if (is_block_hash_updated /*|| !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 30*1000*/) { if (is_block_hash_updated) lastBlockHashUpdateTime = time_now; lastBlockHash = body.hash; lastBlockTemplateUpdateTime = time_now; @@ -1084,7 +1084,7 @@ if (cluster.isMaster) { templateUpdate(); setInterval(function () { bannedIPs = []; - templateUpdate(); + //templateUpdate(); }, 60000); // load merged wallet trust from files From 3ba9c4d4488cc9c7abb3196d84b143fff6536f9f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jan 2018 20:32:27 +0100 Subject: [PATCH 0123/2430] Simplified BT handling --- lib/pool.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 51665590..6e735f2c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -17,7 +17,6 @@ let baseDiff = global.coinFuncs.baseDiff(); let pastBlockTemplates = global.support.circularBuffer(4); let activeMiners = []; let activeBlockTemplate; -let lastBlockTemplateUpdateTime; let lastBlockHash; let lastBlockHashUpdateTime; let workerList = []; @@ -166,16 +165,13 @@ function templateUpdateReal() { global.coinFuncs.getBlockTemplate(global.config.pool.address, function (rpcResponse) { if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; - let new_hash = crypto.createHash('md5').update(rpcResponse.blocktemplate_blob).digest('hex'); - if (!activeBlockTemplate || activeBlockTemplate.idHash !== new_hash) { - debug(threadName + "New block template found at " + rpcResponse.height + " height with hash: " + new_hash.toString('hex')); - if (cluster.isMaster) { - sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); - newBlockTemplate(rpcResponse); - } else { - process.send({type: 'newBlockTemplate', data: rpcResponse}); - newBlockTemplate(rpcResponse); - } + debug(threadName + "New block template found at " + rpcResponse.height + " height"); + if (cluster.isMaster) { + sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); + newBlockTemplate(rpcResponse); + } else { + process.send({type: 'newBlockTemplate', data: rpcResponse}); + newBlockTemplate(rpcResponse); } } else { console.error("Block template request failed!"); @@ -194,10 +190,9 @@ function templateUpdate(repeating) { if (err === null) { let time_now = Date.now(); let is_block_hash_updated = !lastBlockHash || body.hash !== lastBlockHash; - if (is_block_hash_updated /*|| !lastBlockTemplateUpdateTime || time_now - lastBlockTemplateUpdateTime > 30*1000*/) { - if (is_block_hash_updated) lastBlockHashUpdateTime = time_now; + if (is_block_hash_updated) { + lastBlockHashUpdateTime = time_now; lastBlockHash = body.hash; - lastBlockTemplateUpdateTime = time_now; templateUpdateReal(); } if (repeating === true) setTimeout(templateUpdate, 100, repeating); @@ -210,7 +205,7 @@ function templateUpdate(repeating) { function newBlockTemplate(template) { if (activeBlockTemplate) { - if (activeBlockTemplate.idHash === crypto.createHash('md5').update(template.blocktemplate_blob).digest('hex')) { + if (activeBlockTemplate.previous_hash.toString('hex') === template.prev_hash) { console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } From 3eb4e992107700c9079106ea51315318e7e988d4 Mon Sep 17 00:00:00 2001 From: Gardner Bickford Date: Sun, 21 Jan 2018 09:55:41 +1300 Subject: [PATCH 0124/2430] Cracking the code, deciphering the text, and fixing the typos --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3a8f5680..93c6824e 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ worker - Does regular processing of statistics and sends status e-mails for non- ``` API listens on port 8001, remoteShare listens on 8000 -Xmrpool.net (The refrence implementation) uses the following setup: -* https://xmrpool.net is hosted on it's own server, as the main website is a static frontend +Xmrpool.net (The reference implementation) uses the following setup: +* https://xmrpool.net is hosted on its own server, as the main website is a static frontend * https://api.xmrpool.net hosts api, remoteShare, longRunner, payments, blockManager, worker, as these must all be hosted with access to the same LMDB database. Sample Caddyfile for API: @@ -42,7 +42,7 @@ Pre-Deploy ---------- * If you're planning on using e-mail, you'll want to setup an account at https://mailgun.com (It's free for 10k e-mails/month!), so you can notify miners. This also serves as the backend for password reset emails, along with other sorts of e-mails from the pool, including pool startup, pool Monerod daemon lags, etc so it's highly suggested! * Pre-Generate the wallets, or don't, it's up to you! You'll need the addresses after the install is complete, so I'd suggest making sure you have them available. Information on suggested setups are found below. -* If you're going to be offering PPS, PLEASE make sure you load the pool wallet with XMR before you get too far along. Your pool will trigger PPS payments on it's own, and fairly readily, so you need some float in there! +* If you're going to be offering PPS, PLEASE make sure you load the pool wallet with XMR before you get too far along. Your pool will trigger PPS payments on its own, and fairly readily, so you need some float in there! * Make a non-root user, and run the installer from there! Deployment via Installer @@ -51,7 +51,7 @@ Deployment via Installer 1. Add your user to `/etc/sudoers`, this must be done so the script can sudo up and do it's job. We suggest passwordless sudo. Suggested line: ` ALL=(ALL) NOPASSWD:ALL`. Our sample builds use: `pooldaemon ALL=(ALL) NOPASSWD:ALL` 2. Run the [deploy script](https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/deploy.bash) as a **NON-ROOT USER**. This is very important! This script will install the pool to whatever user it's running under! Also. Go get a coffee, this sucker bootstraps the monero installation. 3. Once it's complete, change as `config.json` appropriate. It is pre-loaded for a local install of everything, running on 127.0.0.1. This will work perfectly fine if you're using a single node setup. You'll also want to set `bind_ip` to the external IP of the pool server, and `hostname` to the resolvable hostname for the pool server. `pool_id` is mostly used for multi-server installations to provide unique identifiers in the backend. You will also want to run: source ~/.bashrc This will activate NVM and get things working for the following pm2 steps. -4. You'll need to change the API end point for the frontend code in the `poolui/build/globals.js` and `poolui/build/globals.default.js` -- This will usually be `http(s):///api` unless you tweak caddy! +4. You'll need to change the API endpoint for the frontend code in the `poolui/build/globals.js` and `poolui/build/globals.default.js` -- This will usually be `http(s):///api` unless you tweak caddy! 5. The default database directory `/home//pool_db/` is already been created during startup. If you change the `db_storage_path` just make sure your user has write permissions for new path. Run: `pm2 restart api` to reload the API for usage. 6. Hop into the web interface (Should be at `http:///admin.html`), then login with `Administrator/Password123`, **MAKE SURE TO CHANGE THIS PASSWORD ONCE YOU LOGIN**. *<- This step is currently not active, we're waiting for the frontend to catch up! Head down to the Manual SQL Configuration to take a look at what needs to be done by hand for now*. 7. From the admin panel, you can configure all of your pool's settings for addresses, payment thresholds, etc. @@ -81,7 +81,7 @@ The installer assumes that you will be running a single-node instance and using * MySQL Host: 127.0.0.1 * MySQL root access is only permitted as the root user, the password is in `/root/.my.cnf` * SSL Certificate is generated, self-signed, but is valid for Claymore Miners. -* The server installs and deploys Caddy as it's choice of webserver! +* The server installs and deploys Caddy as it's choice of web server! The following raw binaries **MUST BE AVAILABLE FOR IT TO BOOTSTRAP**: * sudo @@ -227,7 +227,7 @@ If on the other hand, you have no "Free pages" and your Pages used is equal to t PPS Fee Thoughts ================ -If you're considering PPS, I've spoken with [Fireice_UK](https://github.com/fireice-uk/) whom kindly did some math about what you're looking at in terms of requiements to run a PPS pool without it self-impoloding under particular risk factors, based on the work found [here](https://arxiv.org/pdf/1112.4980.pdf) +If you're considering PPS, I've spoken with [Fireice_UK](https://github.com/fireice-uk/) whom kindly did some math about what you're looking at in terms of requirements to run a PPS pool without it self-imploding under particular risk factors, based on the work found [here](https://arxiv.org/pdf/1112.4980.pdf) ```text Also I calculated the amount of XMR needed to for a PPS pool to stay afloat. Perhaps you should put them up in the README to stop some spectacular clusterfucks :D: @@ -235,13 +235,13 @@ For 1 in 1000000 chance that the pool will go bankrupt: 5% fee -> 1200 2% fee -> For 1 in 1000000000 chance: 5% fee -> 1800 2% fee -> 4500 ``` -The developers of the pool have not verified this, but based on our own usage on https://xmrpool.net/ this seems rather reasonable. You should be wary if you're consdering PPS and take you fees into account appropriately! +The developers of the pool have not verified this, but based on our own usage on https://xmrpool.net/ this seems rather reasonable. You should be wary if you're considering PPS and take you fees into account appropriately! Installation/Configuration Assistance ===================================== If you need help installing the pool from scratch, please have your servers ready, which would be Ubuntu 16.04 servers, blank and clean, DNS records pointed. These need to be x86_64 boxes with AES-NI Available. -Installation asstiance is 7 XMR, with a 3 XMR deposit, with remainder to be paid on completion. +Installation assistance is 7 XMR, with a 3 XMR deposit, with remainder to be paid on completion. Configuration assistance is 4 XMR with a 2 XMR deposit, and includes debugging your pool configurations, ensuring that everything is running, and tuning for your uses/needs. SSH access with a sudo-enabled user will be needed, preferably the user that is slated to run the pool. @@ -250,7 +250,7 @@ If you'd like assistance with setting up node-cryptonote-pool, please provide wh Assistance is not available for frontend customization at this time. -For assitance, please contact Snipa at pool_install@snipanet.com or via IRC at irc.freenode.net in the #monero-pools channel. +For assistance, please contact Snipa at pool_install@snipanet.com or via IRC at irc.freenode.net in the #monero-pools channel. Developer Donations =================== From 567be399e2e867f66497d082ce13544fdc8ec8eb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Jan 2018 07:37:28 +0100 Subject: [PATCH 0125/2430] Only kill pool from master --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6e735f2c..74bc8f07 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -181,7 +181,7 @@ function templateUpdateReal() { } function templateUpdate(repeating) { - if (global.config.general.allowStuckPoolKill && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 30*60*1000) { + if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 30*60*1000) { console.error("Block height was not updated for half an hour. Check your monerod. Exiting..."); fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); process.exit(); From ebecf580eed5a91279ce8925213d76daa878f8f0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Jan 2018 09:31:28 +0100 Subject: [PATCH 0126/2430] Drop invalid email addresses --- lib/support.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/support.js b/lib/support.js index 1d00e5a5..b5546a86 100644 --- a/lib/support.js +++ b/lib/support.js @@ -71,6 +71,11 @@ function sendEmail(toAddress, subject, body, wallet){ if (toAddress === global.config.general.adminEmail) { sendEmailReal(toAddress, subject, body); } else { + let reEmail = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; + if (!reEmail.test(toAddress)) { + console.error("Avoid sending email to invalid address '" + toAddress + "'"); + return; + } let key = toAddress + "\t" + subject; if (!(key in emailAcc)) { emailAcc[key] = body; From 85815f375bc35fc4e4b1fc59c2c817f64934f96d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Jan 2018 09:41:53 +0100 Subject: [PATCH 0127/2430] Fixed regexp . is any character actually. \. is dot. --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index b5546a86..da992ef8 100644 --- a/lib/support.js +++ b/lib/support.js @@ -71,7 +71,7 @@ function sendEmail(toAddress, subject, body, wallet){ if (toAddress === global.config.general.adminEmail) { sendEmailReal(toAddress, subject, body); } else { - let reEmail = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; + let reEmail = /^([a-zA-Z0-9_\.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!reEmail.test(toAddress)) { console.error("Avoid sending email to invalid address '" + toAddress + "'"); return; From eb4a173761795781819e1be313417e1858a3165b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Jan 2018 09:44:34 +0100 Subject: [PATCH 0128/2430] Extra email logging --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index da992ef8..c667c9f1 100644 --- a/lib/support.js +++ b/lib/support.js @@ -60,9 +60,9 @@ function sendEmailReal(toAddress, subject, body){ } }, function(err, response, body){ if (!err && response.statusCode === 200) { - console.log("Email sent successfully! Response: " + body); + console.log("Email to '" + toAddress + "' was sent successfully! Response: " + body); } else { - console.error("Did not send e-mail successfully! Response: " + body + " Response: "+JSON.stringify(response)); + console.error("Did not send e-mail to '" + toAddress + "' successfully! Response: " + body + " Response: "+JSON.stringify(response)); } }); } From d025f48195bbd50f334ff26a635fc08296041f62 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 22 Jan 2018 17:50:31 +0100 Subject: [PATCH 0129/2430] Null old miner hash --- lib/worker.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index 86e24f31..4ab9d014 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -210,6 +210,9 @@ function updateShareStats() { prevMinerList.forEach(function (miner) { if (minerList.indexOf(miner) !== -1) return; // we still have this miner in current list console.log("Removing: " + miner + " as an active miner from the cache."); + let minerStats = global.database.getCache(miner); + minerStats.hash = 0; + cache_updates[miner] = minerStats; if (miner.indexOf('_') <= -1) return; // This is a worker case. From e37780f7f6b56e405108f3f49d37b00692ba129b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 24 Jan 2018 21:44:56 +0100 Subject: [PATCH 0130/2430] REgister miner only after some basic checks --- lib/pool.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 74bc8f07..0a3bce37 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -321,26 +321,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.identifier = this.identifier.substring(0, 64); - if (pass_split.length === 2) { - /* - Email address is: pass_split[1] - Need to do an initial registration call here. Might as well do it right... - */ - let payoutAddress = this.payout; - let time_now = Date.now(); - if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { - global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [this.payout]).then(function (rows) { - if (rows.length > 0) { - return; - } - if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { - return; - } - global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, pass_split[1]]); - }); - walletLastCheckTime[payoutAddress] = time_now; - } - } else if (pass_split.length > 2) { + if (pass_split.length > 2) { this.error = "Too many options in the password field"; this.valid_miner = false; } @@ -371,6 +352,27 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.valid_miner = false; } + if (this.valid_miner && pass_split.length === 2) { + /* + Email address is: pass_split[1] + Need to do an initial registration call here. Might as well do it right... + */ + let payoutAddress = this.payout; + let time_now = Date.now(); + if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { + global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [this.payout]).then(function (rows) { + if (rows.length > 0) { + return; + } + if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { + return; + } + global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, pass_split[1]]); + }); + walletLastCheckTime[payoutAddress] = time_now; + } + } + this.id = id; this.ipAddress = ipAddress; this.messageSender = messageSender; From 45c07379244a10975028db7229cf2089d0c3fae5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Jan 2018 17:29:36 +0100 Subject: [PATCH 0131/2430] Limit daemon bombing in case of orphan and record all orphans --- lib/local_comms.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 224ea5a6..56701ff8 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -385,17 +385,20 @@ function Database(){ if (err && header && header.error && typeof(header.error.message) === 'string' && header.error.message.indexOf("can't get block by hash") > -1) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { - if (time_now - orphanBlocks[blockDataDecoded.hash] > 60*60*1000) { - console.log("Stopped attempts to store orphan block " + blockDataDecoded.hash); - return callback(true); + if (time_now - orphanBlocks[blockDataDecoded.hash] > 5*60*1000) { + console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); + err = false; + header = {}; + header.reward = 0; } } else { - console.log("Started attempts to store orphan block " + blockDataDecoded.hash); + console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); orphanBlocks[blockDataDecoded.hash] = time_now; } } if (err || typeof(header) === 'undefined' || !header){ - return callback(false); + setTimeout(function () { return callback(false) }, 1000); + return; } blockDataDecoded.value = header.reward; blockData = global.database.calculateShares(blockDataDecoded, blockId); From cefa9efd44c9dd8c1ca515c8d516f5104bd40d4f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 25 Jan 2018 21:56:10 +0100 Subject: [PATCH 0132/2430] Improved accuracy of PPLNS share accumulation --- lib/blockManager.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1c0b304f..c47f17f0 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -265,25 +265,25 @@ function calculatePPLNSPayments(blockHeader) { amount: 0 }; } - let amountToPay = Math.floor((shareData.shares / (blockDiff*global.config.pplns.shareMulti)) * rewardTotal); + let amountToPay = (shareData.shares / (blockDiff*global.config.pplns.shareMulti)) * rewardTotal; if (totalPaid + amountToPay > rewardTotal) { amountToPay = rewardTotal - totalPaid; } totalPaid += amountToPay; - let feesToPay = Math.floor(amountToPay * (global.config.payout.pplnsFee / 100)); + let feesToPay = amountToPay * (global.config.payout.pplnsFee / 100); if (shareData.bitcoin === true) { - feesToPay += Math.floor(amountToPay * (global.config.payout.btcFee / 100)); + feesToPay += 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 = Math.floor(feesToPay * (global.config.payout.devDonation / 100)); + 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 = Math.floor(feesToPay * (global.config.payout.poolDevDonation / 100)); + let poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); donations += poolDevDonation; paymentData[global.coinFuncs.poolDevAddress].amount = paymentData[global.coinFuncs.poolDevAddress].amount + poolDevDonation; } @@ -307,6 +307,7 @@ function calculatePPLNSPayments(blockHeader) { }, function (err) { let totalPayments = 0; Object.keys(paymentData).forEach(function (key) { + paymentData[key].amount = Math.floor(paymentData[key].amount); balanceQueue.push(paymentData[key], function () { }); totalPayments += paymentData[key].amount; From e3c23e6b22dd938db21979c41952a4cae605e22e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 26 Jan 2018 12:20:43 +0100 Subject: [PATCH 0133/2430] Improved precision of PPLNS rewards Moved divisions out of incremental loop (to decrease cummulative error) and reward every last bit of reward coin. --- lib/blockManager.js | 72 +++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index c47f17f0..c73149ff 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -213,8 +213,11 @@ function calculatePPSPayments(blockHeader, callback) { function calculatePPLNSPayments(blockHeader) { console.log("Performing PPLNS payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); let rewardTotal = blockHeader.reward; + let blockDiff = blockHeader.difficulty; + let windowPPLNS = blockDiff * global.config.pplns.shareMulti; let blockCheckHeight = blockHeader.height; let totalPaid = 0; + let totalShares = 0; let paymentData = {}; paymentData[global.config.payout.feeAddress] = { pool_type: 'fees', @@ -237,6 +240,31 @@ function calculatePPLNSPayments(blockHeader) { bitcoin: 0, amount: 0 }; + + function addPayment(keyAdd, valueAdd) { + if (valueAdd === 0) return; + if (totalPaid >= rewardTotal) return; + totalShares += valueAdd; + paymentData[keyAdd].amount += valueAdd; + let totalPaid2 = Math.floor(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; + } + } + }; + async.doWhilst(function (callback) { let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); @@ -265,29 +293,17 @@ function calculatePPLNSPayments(blockHeader) { amount: 0 }; } - let amountToPay = (shareData.shares / (blockDiff*global.config.pplns.shareMulti)) * rewardTotal; - if (totalPaid + amountToPay > rewardTotal) { - amountToPay = rewardTotal - totalPaid; - } - totalPaid += amountToPay; - let feesToPay = amountToPay * (global.config.payout.pplnsFee / 100); - if (shareData.bitcoin === true) { - feesToPay += 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; + + let amountToPay = shareData.shares; + 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); } }); } @@ -307,14 +323,14 @@ function calculatePPLNSPayments(blockHeader) { }, function (err) { let totalPayments = 0; Object.keys(paymentData).forEach(function (key) { - paymentData[key].amount = Math.floor(paymentData[key].amount); - balanceQueue.push(paymentData[key], function () { - }); + paymentData[key].amount = Math.floor((paymentData[key].amount / (blockDiff*global.config.pplns.shareMulti)) * 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: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward) + " Block Payouts: " + global.support.coinToDecimal(totalPayments) + " Payout Percentage: " + (totalPayments / blockHeader.reward) * 100 + "%"); + console.log("PPLNS 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 + "% (precisely " + totalPayments + " / " + blockHeader.reward + ")"); }); -} +}; function calculateSoloPayments(blockHeader) { console.log("Performing Solo payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); From 33751d6ec6cb3b5253ba55098a8a5ad2ecbdd80b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 26 Jan 2018 15:35:32 +0100 Subject: [PATCH 0134/2430] Removed not needed floor --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index c73149ff..93bc0c3e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -246,7 +246,7 @@ function calculatePPLNSPayments(blockHeader) { if (totalPaid >= rewardTotal) return; totalShares += valueAdd; paymentData[keyAdd].amount += valueAdd; - let totalPaid2 = Math.floor(totalShares / windowPPLNS * rewardTotal); + let totalPaid2 = totalShares / windowPPLNS * rewardTotal; if (totalPaid2 + 1 < rewardTotal) { // totalPaid can not overflow rewardTotal now totalPaid = totalPaid2; } else { // we need recalculate totalPaid precisely now From 2b7fe544e70b9ee93735673f6c42fed6a5b7159c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Jan 2018 15:41:49 +0100 Subject: [PATCH 0135/2430] Improved core stats reporting --- lib/pool.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0a3bce37..4d55e33d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -25,7 +25,7 @@ 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; +let totalShares = 0, trustedShares = 0, normalShares = 0, invalidShares = 0, outdatedShares = 0; Buffer.prototype.toByteArray = function () { return Array.prototype.slice.call(this, 0); @@ -35,11 +35,16 @@ Buffer.prototype.toByteArray = function () { if (cluster.isMaster) { threadName = "(Master) "; setInterval(function () { - console.log(`Processed ${trustedShares}/${normalShares}/${invalidShares}/${totalShares} Trusted/Validated/Invalid/Total shares in the last 30 seconds`); + let trustedSharesPercent = (trustedShares / totalShares * 100).toFixed(2); + let normalSharesPercent = (normalShares / totalShares * 100).toFixed(2); + let invalidSharesPercent = (invalidShares / totalShares * 100).toFixed(2); + let outdatedSharesPercent = (outdatedShares / totalShares * 100).toFixed(2); + console.log(`>>> Processed Trusted ${trustedShares} (${trustedSharesPercent}%) / Validated ${normalShares} (${normalSharesPercent}%) / Invalid ${invalidShares} (${invalidSharesPercent}%) / Outdated ${outdatedShares} (${outdatedSharesPercent}%) / Total shares ${totalShares} in the last 30 seconds`); totalShares = 0; trustedShares = 0; normalShares = 0; invalidShares = 0; + outdatedShares = 0; }, 30000); } else { threadName = "(Worker " + cluster.worker.id + " - " + process.pid + ") "; @@ -118,6 +123,9 @@ function messageHandler(message) { case 'invalidShare': invalidShares += 1; totalShares += 1; + break; + case 'outdatedShare': + outdatedShares += 1; } } @@ -773,6 +781,9 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy process.send({type: 'normalShare'}); debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + shareDiff + " from: " + miner.logString); } + if (activeBlockTemplate && activeBlockTemplate.height != job.height) { + process.send({type: 'outdatedShare'}); + } } From 26fec5ad6403cedd1d7e83ae72fc17eb2fea0001 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Jan 2018 17:21:12 +0100 Subject: [PATCH 0136/2430] Make too outdated blocks invalid --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4d55e33d..472e3d51 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -19,6 +19,7 @@ let activeMiners = []; let activeBlockTemplate; let lastBlockHash; let lastBlockHashUpdateTime; +let lastBlockTemplateUpdateTime; let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; let threadName; @@ -228,6 +229,7 @@ function newBlockTemplate(template) { miner.sendNewJob(); } } + lastBlockTemplateUpdateTime = Date.now(); } let VarDiff = (function () { @@ -985,7 +987,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return t.height === job.height; })[0]; - if (!blockTemplate) { + if (!blockTemplate || (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime && Date.now() - lastBlockTemplateUpdateTime > 10*1000)) { console.warn(threadName + 'Block expired, Height: ' + job.height + ' from ' + miner.logString); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; From f29d227bee77fa608eacd2ee9dcf8c84faf0f785 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Jan 2018 17:43:51 +0100 Subject: [PATCH 0137/2430] Extra diag for outdated block --- lib/pool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 472e3d51..dff31334 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -988,7 +988,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { })[0]; if (!blockTemplate || (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime && Date.now() - lastBlockTemplateUpdateTime > 10*1000)) { - console.warn(threadName + 'Block expired, Height: ' + job.height + ' from ' + miner.logString); + let err_str = blockTemplate ? "Block outdated" : "Block expired"; + console.warn(threadName + err_str + ', Height: ' + job.height + ' from ' + miner.logString); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; miner.incremented = true; @@ -997,7 +998,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.incremented = false; } miner.sendNewJob(); - sendReply('Block expired'); + sendReply(err_str); global.database.storeInvalidShare(miner.invalidShareProto); return; } From db1644d0cc008978646c8da9a189e998f1295057 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Jan 2018 18:08:42 +0100 Subject: [PATCH 0138/2430] Increased block outdated time --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index dff31334..42c7c504 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -987,7 +987,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return t.height === job.height; })[0]; - if (!blockTemplate || (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime && Date.now() - lastBlockTemplateUpdateTime > 10*1000)) { + if (!blockTemplate || (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime && Date.now() - lastBlockTemplateUpdateTime > 20*1000)) { let err_str = blockTemplate ? "Block outdated" : "Block expired"; console.warn(threadName + err_str + ', Height: ' + job.height + ' from ' + miner.logString); if (miner.incremented === false) { From a76eab3702b0e9a73f2f73b715350e1af78b5ddc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 28 Jan 2018 19:20:00 +0100 Subject: [PATCH 0139/2430] Decrease number of queue debug messages --- lib/remote_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/remote_comms.js b/lib/remote_comms.js index a91baaa5..d296b28f 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -58,7 +58,7 @@ function Database() { if (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"); } - }, 5000, this.sendQueue); + }, 30*1000, this.sendQueue); this.initEnv = function(){ From defcdedcf2422dd1ab5ab6e2c9068e3e20083c51 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Jan 2018 14:47:17 +0100 Subject: [PATCH 0140/2430] Reduced wait time between BT checks --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 42c7c504..ac4e9768 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -204,7 +204,7 @@ function templateUpdate(repeating) { lastBlockHash = body.hash; templateUpdateReal(); } - if (repeating === true) setTimeout(templateUpdate, 100, repeating); + if (repeating === true) setTimeout(templateUpdate, 50, repeating); } else { console.error("Last block header request failed!"); setTimeout(templateUpdate, 1000, repeating); @@ -1087,7 +1087,7 @@ if (cluster.isMaster) { workerList.push(worker); }); templateUpdate(); - setTimeout(templateUpdate, 100, true); + 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 { setInterval(checkAliveMiners, 30000); From a749269c8c71bd891673b4236666de301fcb4634 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Jan 2018 20:32:32 +0100 Subject: [PATCH 0141/2430] Some debug code readjustment and extra fee fix (display only) --- lib/payment_systems/xmr.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index fc7bdf38..86553e55 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -523,7 +523,7 @@ function Payee(amount, address, paymentID, bitcoin) { payee.trackPayment(); }); } else { - console.error("Unknown error from the wallet."); + console.error("Unknown error from the wallet: " + JSON.stringify(body)); } }); }; @@ -554,7 +554,7 @@ function Payee(amount, address, paymentID, bitcoin) { payee.trackPayment(); }); } else { - console.error("Unknown error from the wallet."); + console.error("Unknown error from the wallet: " + JSON.stringify(body)); } }); }; @@ -589,6 +589,7 @@ function Payee(amount, address, paymentID, bitcoin) { } function makePayments() { + console.log("Starting makePayments"); global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { console.log("Loaded all payees into the system for processing"); let paymentDestinations = []; @@ -597,7 +598,7 @@ function makePayments() { let payeeList = []; let payeeObjects = {}; rows.forEach(function (row) { - debug("Starting round for: " + JSON.stringify(row)); + //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) { @@ -641,8 +642,9 @@ function makePayments() { payee.makeBitcoinPayment(); } } - debug("Went: " + roundCount + " With: " + paymentDestinations.length + " Possible destinations and: " + rows.length + " Rows"); + //debug("Went: " + roundCount + " With: " + paymentDestinations.length + " Possible destinations and: " + rows.length + " Rows"); if (roundCount === rows.length && paymentDestinations.length > 0) { + debug("Doing payment to multiple people " + paymentDestinations.length); while (paymentDestinations.length > 0) { let paymentDetails = { destinations: paymentDestinations.splice(0, global.config.payout.maxPaymentTxns), @@ -657,7 +659,6 @@ function makePayments() { let totalAmount = 0; paymentDetails.destinations.forEach(function (payeeItem) { totalAmount += payeeObjects[payeeItem.address].amount; - totalAmount += payeeObjects[payeeItem.address].fee; }); 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) { @@ -668,7 +669,7 @@ function makePayments() { }); }); } else { - console.error("Unknown error from the wallet."); + console.error("Unknown error from the wallet: " + JSON.stringify(body)); } }); } @@ -676,6 +677,7 @@ function makePayments() { }); }); }); + console.log("Finishing makePayments"); } function init() { From 2bba5ab2cb1d860b48a263ab7da1c5a3a502efdd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Jan 2018 20:57:22 +0100 Subject: [PATCH 0142/2430] Added tx_key storing in logs --- 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 86553e55..ed2582a5 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -301,6 +301,7 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { } debug("Making payment based on: " + JSON.stringify(paymentDetails)); let transferFunc = 'transfer'; + paymentDetails.get_tx_key = true; global.support.rpcWallet(transferFunc, paymentDetails, function (body) { debug("Payment made: " + JSON.stringify(body)); if (body.hasOwnProperty('error')) { @@ -516,7 +517,7 @@ function Payee(amount, address, paymentID, bitcoin) { debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - debug("Successful payment sent to: " + identifier); + console.log("Successful payment sent to: " + identifier + " with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { payee.transactionID = result.insertId; @@ -547,7 +548,7 @@ function Payee(amount, address, paymentID, bitcoin) { debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - debug("Successful payment sent to: " + identifier); + console.log("Successful payment sent to: " + identifier + " with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { payee.transactionID = result.insertId; @@ -655,7 +656,7 @@ function makePayments() { paymentQueue.push(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) { - debug("Made it to the SQL insert for transactions"); + console.log("Made compound transaction with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); let totalAmount = 0; paymentDetails.destinations.forEach(function (payeeItem) { totalAmount += payeeObjects[payeeItem.address].amount; From e73c619bd51287aeca7d2d8beef1be286cf09a66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Jan 2018 21:06:14 +0100 Subject: [PATCH 0143/2430] Rearranged debug messages --- lib/payment_systems/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index ed2582a5..bb3601ac 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -590,7 +590,7 @@ function Payee(amount, address, paymentID, bitcoin) { } function makePayments() { - console.log("Starting makePayments"); + debug("Starting makePayments"); global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { console.log("Loaded all payees into the system for processing"); let paymentDestinations = []; @@ -674,11 +674,12 @@ function makePayments() { } }); } + debug("Finished processing payments for now"); } }); }); }); - console.log("Finishing makePayments"); + debug("Finished makePayments"); } function init() { From 66941aac3a94395ca1b5d8a0b5489daeaa6cbf5e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Jan 2018 21:09:52 +0100 Subject: [PATCH 0144/2430] Moved debug message --- 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 bb3601ac..a6dc6f9e 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -674,8 +674,8 @@ function makePayments() { } }); } - debug("Finished processing payments for now"); } + debug("Finished processing payments for now"); }); }); }); From a77b0ec05566150c9849b6f5226b526d6df3d70a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 29 Jan 2018 21:11:09 +0100 Subject: [PATCH 0145/2430] Only print debug message once --- 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 a6dc6f9e..02630d9a 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -675,7 +675,7 @@ function makePayments() { }); } } - debug("Finished processing payments for now"); + if (roundCount === rows.length) debug("Finished processing payments for now"); }); }); }); From 49c10ec4a292e33c5d4ab578a184a114eeabdb2f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 09:38:48 +0100 Subject: [PATCH 0146/2430] Improved error handling and reporting --- lib/payment_systems/xmr.js | 74 +++++++++++++++++++++++++++++--------- lib/pool.js | 2 +- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 02630d9a..b7be5c0e 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -11,7 +11,24 @@ let xmrAPIClient = request.createClient('https://xmr.to/api/v1/xmr2btc/'); let extraPaymentRound = false; let paymentTimer = null; +let is_full_stop = false; + +function full_stop(err) { + is_full_stop = true; + console.error("Issue making payments" + JSON.stringify(err)); + console.error("Will not make more payments until the payment daemon is restarted!"); + //toAddress, subject, body + global.support.sendEmail(global.config.general.adminEmail, "Payment daemon unable to make payment", + "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(body.error) + + ". Please investigate and restart the payment daemon as appropriate"); +} + let shapeshiftQueue = async.queue(function (task, callback) { + if (is_full_stop) { + debug("Dropping all pending shapeshift payments"); + return; + } + // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. let amount = task.amount - task.fee; // Address is the destination address IN BTC. @@ -140,6 +157,11 @@ let shapeshiftQueue = async.queue(function (task, callback) { }, 2); let xmrToQueue = async.queue(function (task, callback) { + if (is_full_stop) { + debug("Dropping all pending xmr.to payments"); + return; + } + // http://xmrto-api.readthedocs.io/en/latest/introduction.html // Documentation looks good! // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. @@ -291,6 +313,11 @@ let xmrToQueue = async.queue(function (task, callback) { }, 2); let paymentQueue = async.queue(function (paymentDetails, callback) { + if (is_full_stop) { + debug("Dropping all pending payments"); + return; + } + /* support JSON URI: http://10.0.0.2:28082/json_rpc Args: {"id":"0","jsonrpc":"2.0","method":"transfer","params":{"destinations":[{"amount":68130252045355,"address":"A2MSrn49ziBPJBh8ZNEhhbfyLMou6mao4C1F5TLGUatmUnCxZArDYkcbAnVkVEopWVeak2rKDrmc8JpoS7n5dvfN9YDPBTG"}],"mixin":4,"payment_id":"7e52c5266de9fede7fb3abc0cd88f937b38b51426f7b34ff99729d28ce4e1142"}} +1ms payments Payment made: {"id":"0","jsonrpc":"2.0","result":{"fee":40199391255,"tx_hash":"c418708643f72635edf522490bfb2cae9d42a6dc1df30dcde844862dfd88f5b3","tx_key":""}} +2s @@ -315,12 +342,7 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { extraPaymentRound = true; return callback(false); } else { - console.error("Issue making payments" + JSON.stringify(body.error)); - console.error("Will not make more payments until the payment daemon is restarted!"); - //toAddress, subject, body - global.support.sendEmail(global.config.general.adminEmail, "Payment daemon unable to make payment", - "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(body.error) + - ". Please investigate and restart the payment daemon as appropriate"); + full_stop(body.error); return; } } @@ -517,7 +539,7 @@ function Payee(amount, address, paymentID, bitcoin) { debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - console.log("Successful payment sent to: " + identifier + " with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); + console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { payee.transactionID = result.insertId; @@ -548,7 +570,7 @@ function Payee(amount, address, paymentID, bitcoin) { debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - console.log("Successful payment sent to: " + identifier + " with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); + console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { payee.transactionID = result.insertId; @@ -583,13 +605,28 @@ function Payee(amount, address, paymentID, bitcoin) { }; this.trackPayment = function () { - global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]); + global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]).then(function (err, result) { + if (err) { + console.error("Can't do "); + full_stop(err); + } + }); global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + - " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]); + " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]).then(function (err, result) { + if (err) { + console.error("Can't do "); + full_stop(err); + } + }); }; } function makePayments() { + if (is_full_stop) { + debug("Dropping all new peyment creation"); + return; + } + debug("Starting makePayments"); global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { console.log("Loaded all payees into the system for processing"); @@ -656,13 +693,20 @@ function makePayments() { paymentQueue.push(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) { - console.log("Made compound transaction with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); 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 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] + " with 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) { + [0, null, null, totalAmount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, paymentDetails.destinations.length]).then(function (err, result) { + if (err) { + 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 + ")"); + full_stop(err); + return; + } paymentDetails.destinations.forEach(function (payeeItem) { payee = payeeObjects[payeeItem.address]; payee.transactionID = result.insertId; @@ -683,8 +727,7 @@ function makePayments() { } function init() { - global.support.rpcWallet("store", [], function () { - }); + global.support.rpcWallet("store", [], function () {}); if (global.config.allowBitcoin) { determineBestExchange(); setInterval(updateXMRToCompletion, 90000); @@ -692,8 +735,7 @@ function init() { setInterval(determineBestExchange, 60000); } setInterval(function () { - global.support.rpcWallet("store", [], function () { - }); + global.support.rpcWallet("store", [], function () {}); }, 60000); console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes with a: " + global.config.payout.timerRetry + " minute delay if the wallet is out of money"); makePayments(); diff --git a/lib/pool.js b/lib/pool.js index ac4e9768..a3b1cf65 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -987,7 +987,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return t.height === job.height; })[0]; - if (!blockTemplate || (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime && Date.now() - lastBlockTemplateUpdateTime > 20*1000)) { + if (!blockTemplate || (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime && Date.now() - lastBlockTemplateUpdateTime > 5*1000)) { let err_str = blockTemplate ? "Block outdated" : "Block expired"; console.warn(threadName + err_str + ', Height: ' + job.height + ' from ' + miner.logString); if (miner.incremented === false) { From 5375191d95c539a8cd9b0f53b3e5a562d94a0276 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 09:59:14 +0100 Subject: [PATCH 0147/2430] Improvement payment error logging --- lib/payment_systems/xmr.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index b7be5c0e..2175bf73 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -541,7 +541,14 @@ function Payee(amount, address, paymentID, bitcoin) { if (body.fee && body.fee > 10) { console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { + [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (err, result) { + if (err) { + console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, " + + address + ", " + paymentID + ", " + amount + ", " + body.tx_hash.match(hexChars)[0] + ", " + global.config.payout.mixIn + ", " + body.fee + ", 1)" + ); + full_stop(err); + return; + } payee.transactionID = result.insertId; payee.trackPayment(); }); @@ -572,7 +579,14 @@ function Payee(amount, address, paymentID, bitcoin) { if (body.fee && body.fee > 10) { console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", - [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { + [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (err, result) { + if (err) { + console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, " + + address + ", " + amount + ", " + body.tx_hash.match(hexChars)[0] + ", " + global.config.payout.mixIn + ", " + body.fee + ", 1)" + ); + full_stop(err); + return; + } payee.transactionID = result.insertId; payee.trackPayment(); }); @@ -607,14 +621,16 @@ function Payee(amount, address, paymentID, bitcoin) { this.trackPayment = function () { global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]).then(function (err, result) { if (err) { - console.error("Can't do "); + console.error("Can't do: UPDATE balance SET amount = amount - " + this.amount + " WHERE id = " + this.sqlID); full_stop(err); } }); global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]).then(function (err, result) { if (err) { - console.error("Can't do "); + console.error("Can't do: INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee) VALUES (now(), now(), " + + this.poolType + ", " + this.address + ", " + this.transactionID + ", " + this.bitcoin + ", " + (this.amount - this.fee) + ", " + this.paymentID + ", " + this.fee + ")" + ); full_stop(err); } }); @@ -703,9 +719,11 @@ function makePayments() { 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 (err, result) { if (err) { - 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 + ")"); - full_stop(err); - return; + 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 + ")" + ); + full_stop(err); + return; } paymentDetails.destinations.forEach(function (payeeItem) { payee = payeeObjects[payeeItem.address]; From b4edcd4602a6183fc8aa21c951ced8b9d2ee99f1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 11:25:19 +0100 Subject: [PATCH 0148/2430] Simplified payment management --- lib/payment_systems/xmr.js | 109 +++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 48 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 2175bf73..e235339f 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -8,8 +8,6 @@ const range = require('range'); let hexChars = new RegExp("[0-9a-f]+"); let bestExchange = global.config.payout.bestExchange; let xmrAPIClient = request.createClient('https://xmr.to/api/v1/xmr2btc/'); -let extraPaymentRound = false; -let paymentTimer = null; let is_full_stop = false; @@ -322,56 +320,47 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { support JSON URI: http://10.0.0.2:28082/json_rpc Args: {"id":"0","jsonrpc":"2.0","method":"transfer","params":{"destinations":[{"amount":68130252045355,"address":"A2MSrn49ziBPJBh8ZNEhhbfyLMou6mao4C1F5TLGUatmUnCxZArDYkcbAnVkVEopWVeak2rKDrmc8JpoS7n5dvfN9YDPBTG"}],"mixin":4,"payment_id":"7e52c5266de9fede7fb3abc0cd88f937b38b51426f7b34ff99729d28ce4e1142"}} +1ms payments Payment made: {"id":"0","jsonrpc":"2.0","result":{"fee":40199391255,"tx_hash":"c418708643f72635edf522490bfb2cae9d42a6dc1df30dcde844862dfd88f5b3","tx_key":""}} +2s */ - if (paymentTimer !== null){ - clearInterval(paymentTimer); - paymentTimer = null; - } - debug("Making payment based on: " + JSON.stringify(paymentDetails)); - let transferFunc = 'transfer'; - paymentDetails.get_tx_key = true; - global.support.rpcWallet(transferFunc, paymentDetails, function (body) { - debug("Payment made: " + JSON.stringify(body)); - if (body.hasOwnProperty('error')) { - if (body.error.message === "not enough money"){ - console.error("Issue making payments, not enough money, will try later"); - if(!extraPaymentRound){ - setTimeout(function(){ - makePayments(); - }, global.config.payout.timerRetry * 60 * 1000); - } - extraPaymentRound = true; - return callback(false); - } else { - full_stop(body.error); + + debug("Trying to make payment based on: " + JSON.stringify(paymentDetails)); + + function getbalance() { + global.support.rpcWallet("getbalance", paymentDetails, function (body) { + if (body.hasOwnProperty('error') || !body.hasOwnProperty('result')) { + console.error("Can't getbalance: " + JSON.stringify(body.error)); + setTimeout(getbalance, 60*1000); return; } - } - if (paymentDetails.hasOwnProperty('payment_id')) { - console.log("Payment made to " + paymentDetails.destinations[0].address + " with PaymentID: " + paymentDetails.payment_id + " For: " + global.support.coinToDecimal(paymentDetails.destinations[0].amount) + " XMR with a " + global.support.coinToDecimal(body.result.fee) + " XMR Mining Fee"); - return callback(body.result); - } else { - if (transferFunc === 'transfer') { - console.log("Payment made out to multiple people, total fee: " + global.support.coinToDecimal(body.result.fee) + " XMR"); + if (body.result.unlocked_balance === 0) { + console.log("Waiting for balance to unlock after previous payment"); + setTimeout(getbalance, 5*60*1000); + return; } - let intCount = 0; - paymentDetails.destinations.forEach(function (details) { - console.log("Payment made to: " + details.address + " For: " + global.support.coinToDecimal(details.amount) + " XMR"); - intCount += 1; - if (intCount === paymentDetails.destinations.length) { - return callback(body.result); + console.log("Current wallet balance is " + global.support.coinToDecimal(body.result.balance) + " with " + global.support.coinToDecimal(body.result.unlocked_balance)); + + let transferFunc = 'transfer'; + paymentDetails.get_tx_key = true; + global.support.rpcWallet(transferFunc, paymentDetails, function (body) { + debug("Payment made: " + JSON.stringify(body)); + if (body.hasOwnProperty('error') || !body.hasOwnProperty('result')) { + if (body.error.message === "not enough money"){ + console.error("Issue making payments, not enough money, will try later"); + setTimeout(getbalance, 10*60*1000); + } else { + full_stop(body.error); + } + return; } + callback(body.result); }); - } - }); + }); + }; + + getbalance(); + }, 1); paymentQueue.drain = function(){ - extraPaymentRound = false; - if (global.config.payout.timer > 35791){ - console.error("Payout timer is too high. Please use a value under 35791 to avoid overflows."); - } else { - paymentTimer = setInterval(makePayments, global.config.payout.timer * 60 * 1000); - } + console.log("Payment queue drained"); global.database.setCache('lastPaymentCycle', Math.floor(Date.now()/1000)); }; @@ -639,7 +628,19 @@ function Payee(amount, address, paymentID, bitcoin) { function makePayments() { if (is_full_stop) { - debug("Dropping all new peyment creation"); + debug("Dropping all new payment creation"); + return; + } + if (paymentQueue.length()) { + debug("Payment queue is not empty so dropping all new payment creation"); + return; + } + if (shapeshiftQueue.length()) { + debug("Shapeshift payment queue is not empty so dropping all new payment creation"); + return; + } + if (xmrToQueue.length()) { + debug("xmr.to payment queue is not empty so dropping all new payment creation"); return; } @@ -714,6 +715,7 @@ function makePayments() { 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] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", @@ -754,9 +756,20 @@ function init() { } setInterval(function () { global.support.rpcWallet("store", [], function () {}); - }, 60000); - console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes with a: " + global.config.payout.timerRetry + " minute delay if the wallet is out of money"); + }, 60*1000); + + setInterval(function () { + console.log("Payment queue lengths: payment (" + paymentQueue.length() ") / shapeshift (" + shapeshiftQueue.length() + ") / xmr.to (" + xmrToQueue.length() + ")"); + }, 10*60*1000); + makePayments(); + + console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes"); + setInterval(makePayments, global.config.payout.timer * 60 * 1000); } -init(); \ No newline at end of file +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 46094d9e6c468ef93f431779f2d293410d9ebaa6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 11:27:09 +0100 Subject: [PATCH 0149/2430] Typo fix --- 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 e235339f..b10ac642 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -759,7 +759,7 @@ function init() { }, 60*1000); setInterval(function () { - console.log("Payment queue lengths: payment (" + paymentQueue.length() ") / shapeshift (" + shapeshiftQueue.length() + ") / xmr.to (" + xmrToQueue.length() + ")"); + console.log("Payment queue lengths: payment (" + paymentQueue.length() + ") / shapeshift (" + shapeshiftQueue.length() + ") / xmr.to (" + xmrToQueue.length() + ")"); }, 10*60*1000); makePayments(); From ad7c837045de67da6e8b8b630078925cd49a2e11 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 11:46:34 +0100 Subject: [PATCH 0150/2430] Fixed some bugs --- lib/payment_systems/xmr.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index b10ac642..9438771b 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -13,11 +13,11 @@ let is_full_stop = false; function full_stop(err) { is_full_stop = true; - console.error("Issue making payments" + JSON.stringify(err)); + console.error("Issue making payments: " + JSON.stringify(err)); console.error("Will not make more payments until the payment daemon is restarted!"); //toAddress, subject, body global.support.sendEmail(global.config.general.adminEmail, "Payment daemon unable to make payment", - "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(body.error) + + "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(err) + ". Please investigate and restart the payment daemon as appropriate"); } @@ -530,12 +530,12 @@ function Payee(amount, address, paymentID, bitcoin) { if (body.fee && body.fee > 10) { console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (err, result) { - if (err) { + [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).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, " + address + ", " + paymentID + ", " + amount + ", " + body.tx_hash.match(hexChars)[0] + ", " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); - full_stop(err); + full_stop(result); return; } payee.transactionID = result.insertId; @@ -568,12 +568,12 @@ function Payee(amount, address, paymentID, bitcoin) { if (body.fee && body.fee > 10) { console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", - [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (err, result) { - if (err) { + [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).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, " + address + ", " + amount + ", " + body.tx_hash.match(hexChars)[0] + ", " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); - full_stop(err); + full_stop(result); return; } payee.transactionID = result.insertId; @@ -608,19 +608,19 @@ function Payee(amount, address, paymentID, bitcoin) { }; this.trackPayment = function () { - global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]).then(function (err, result) { - if (err) { + global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { console.error("Can't do: UPDATE balance SET amount = amount - " + this.amount + " WHERE id = " + this.sqlID); - full_stop(err); + full_stop(result); } }); global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + - " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]).then(function (err, result) { - if (err) { + " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]).then(function (result) { + if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { console.error("Can't do: INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee) VALUES (now(), now(), " + this.poolType + ", " + this.address + ", " + this.transactionID + ", " + this.bitcoin + ", " + (this.amount - this.fee) + ", " + this.paymentID + ", " + this.fee + ")" ); - full_stop(err); + full_stop(result); } }); }; @@ -719,12 +719,12 @@ function makePayments() { }); 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] + " with 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 (err, result) { - if (err) { + [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 + ")" ); - full_stop(err); + full_stop(result); return; } paymentDetails.destinations.forEach(function (payeeItem) { From e3d617373d8e40b45baf6efd4edd554ddf2f3fe8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 11:54:55 +0100 Subject: [PATCH 0151/2430] Some minor fixes --- lib/payment_systems/xmr.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 9438771b..00b61814 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -522,18 +522,19 @@ function Payee(amount, address, paymentID, bitcoin) { }; let identifier = this.id; let amount = this.amount; + let fee = this.fee; let address = this.address; let paymentID = this.paymentID; let payee = this; debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); + console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).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, " - + address + ", " + paymentID + ", " + amount + ", " + body.tx_hash.match(hexChars)[0] + ", " + global.config.payout.mixIn + ", " + body.fee + ", 1)" + console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, '" + + address + "', '" + paymentID + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); full_stop(result); return; @@ -560,18 +561,19 @@ function Payee(amount, address, paymentID, bitcoin) { }; let identifier = this.id; let amount = this.amount; + let fee = this.fee; let address = this.address; let payee = this; debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(this.fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(this.fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); + console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).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, " - + address + ", " + amount + ", " + body.tx_hash.match(hexChars)[0] + ", " + global.config.payout.mixIn + ", " + body.fee + ", 1)" + console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, '" + + address + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); full_stop(result); return; @@ -721,8 +723,8 @@ function makePayments() { 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 + ")" + 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 + ")" ); full_stop(result); return; From 29b916da7576acfbce631cc930d1bd16fa58f6bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 13:03:31 +0100 Subject: [PATCH 0152/2430] Improved manual payment recovery process --- lib/payment_systems/xmr.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 00b61814..4fac44f3 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -536,6 +536,8 @@ function Payee(amount, address, paymentID, bitcoin) { console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, '" + address + "', '" + paymentID + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); + payee.transactionID = 0; + payee.manualPaymentShow(); full_stop(result); return; } @@ -575,6 +577,8 @@ function Payee(amount, address, paymentID, bitcoin) { console.error("Can't do: INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (0, '" + address + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); + payee.transactionID = 0; + payee.manualPaymentShow(); full_stop(result); return; } @@ -609,19 +613,27 @@ function Payee(amount, address, paymentID, bitcoin) { } }; + this.manualPaymentShow = function () { + console.error("Manual payment update:"); + console.error(" UPDATE balance SET amount = amount - " + this.amount + " WHERE id = " + this.sqlID + ";"); + console.error(" INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee) VALUES (now(), now(), " + + this.poolType + ", " + this.address + ", " + this.transactionID + ", " + this.bitcoin + ", " + (this.amount - this.fee) + ", " + this.paymentID + ", " + this.fee + ");" + ); + }; + this.trackPayment = function () { global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - console.error("Can't do: UPDATE balance SET amount = amount - " + this.amount + " WHERE id = " + this.sqlID); + console.error("Can't do SQL balance update"); + this.manualPaymentShow(); full_stop(result); } }); global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { - console.error("Can't do: INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee) VALUES (now(), now(), " - + this.poolType + ", " + this.address + ", " + this.transactionID + ", " + this.bitcoin + ", " + (this.amount - this.fee) + ", " + this.paymentID + ", " + this.fee + ")" - ); + console.error("Can't do SQL payments update"); + this.manualPaymentShow(); full_stop(result); } }); @@ -726,6 +738,11 @@ function makePayments() { 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; } From 48e772aa42fc3e48c399619f836a2e932e4983a5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 13:05:30 +0100 Subject: [PATCH 0153/2430] Better report strings --- lib/payment_systems/xmr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 4fac44f3..38a040b7 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -529,7 +529,7 @@ function Payee(amount, address, paymentID, bitcoin) { debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); + console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - 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, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { @@ -570,7 +570,7 @@ function Payee(amount, address, paymentID, bitcoin) { debug("Payment Details: " + JSON.stringify(paymentDetails)); paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { - console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - body.fee) + ") with tx_hash " + body.tx_hash.match(hexChars)[0] + " with tx_key " + body.tx_key); + console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - 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, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { @@ -731,7 +731,7 @@ function makePayments() { 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] + " with tx_key " + body.tx_key); + 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) { From bf1d5807ad4046ddf88556c381330153c6341e61 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 13:06:48 +0100 Subject: [PATCH 0154/2430] Better report strings --- 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 38a040b7..e642468d 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -335,7 +335,7 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { setTimeout(getbalance, 5*60*1000); return; } - console.log("Current wallet balance is " + global.support.coinToDecimal(body.result.balance) + " with " + global.support.coinToDecimal(body.result.unlocked_balance)); + console.log("Current wallet balance is " + global.support.coinToDecimal(body.result.balance) + " with " + global.support.coinToDecimal(body.result.unlocked_balance) + " unlocked balance"); let transferFunc = 'transfer'; paymentDetails.get_tx_key = true; From 668fe7ab7c0ddc5cc017d83a0580fa2b42fac54a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 13:40:50 +0100 Subject: [PATCH 0155/2430] Queue status fixes --- 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 e642468d..77ec7ca2 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -645,15 +645,15 @@ function makePayments() { debug("Dropping all new payment creation"); return; } - if (paymentQueue.length()) { + if (paymentQueue.idle() === false) { debug("Payment queue is not empty so dropping all new payment creation"); return; } - if (shapeshiftQueue.length()) { + if (shapeshiftQueue.idle() === false) { debug("Shapeshift payment queue is not empty so dropping all new payment creation"); return; } - if (xmrToQueue.length()) { + if (xmrToQueue.idle() === false) { debug("xmr.to payment queue is not empty so dropping all new payment creation"); return; } @@ -778,7 +778,7 @@ function init() { }, 60*1000); setInterval(function () { - console.log("Payment queue lengths: payment (" + paymentQueue.length() + ") / shapeshift (" + shapeshiftQueue.length() + ") / xmr.to (" + xmrToQueue.length() + ")"); + console.log("Payment queue lengths: payment (" + (paymentQueue.running() + paymentQueue.length()) + ") / shapeshift (" + (shapeshiftQueue.running() + shapeshiftQueue.length()) + ") / xmr.to (" + (xmrToQueue.running() + xmrToQueue.length()) + ")"); }, 10*60*1000); makePayments(); From be2a5460a72cfd33a9d14c06cf0586fdb9184302 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 13:42:36 +0100 Subject: [PATCH 0156/2430] Text message fix --- 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 77ec7ca2..f2009b2f 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -713,7 +713,7 @@ function makePayments() { } //debug("Went: " + roundCount + " With: " + paymentDestinations.length + " Possible destinations and: " + rows.length + " Rows"); if (roundCount === rows.length && paymentDestinations.length > 0) { - debug("Doing payment to multiple people " + paymentDestinations.length); + debug("Doing payment to multiple people: " + paymentDestinations.length); while (paymentDestinations.length > 0) { let paymentDetails = { destinations: paymentDestinations.splice(0, global.config.payout.maxPaymentTxns), From b79d8474968a91860662cd6366da9cc3e4a89426 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 Jan 2018 15:30:04 +0100 Subject: [PATCH 0157/2430] Some minor logging improvements --- lib/payment_systems/xmr.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index f2009b2f..0bb92408 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -694,33 +694,32 @@ function makePayments() { if (payee.amount > threshold) { payee.setFeeAmount(); if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { - debug("Adding " + payee.id + " to the list of people to pay (OG Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); + 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. - debug("Adding " + payee.id + " to the list of people to pay (Integrated Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); + 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) { - debug("Adding " + payee.id + " to the list of people to pay (Payment ID Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); + 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) { - debug("Adding " + payee.id + " to the list of people to pay (Bitcoin Payout). Payee balance: " + global.support.coinToDecimal(payee.amount)); + console.log("[+] " + payee.id + " as separate payment to bitcoin. Amount: " + global.support.coinToDecimal(payee.amount)); payee.makeBitcoinPayment(); } } //debug("Went: " + roundCount + " With: " + paymentDestinations.length + " Possible destinations and: " + rows.length + " Rows"); if (roundCount === rows.length && paymentDestinations.length > 0) { - debug("Doing payment to multiple people: " + paymentDestinations.length); 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("Paying out: " + paymentDetails.destinations.length + " people"); + console.log("Adding payment for " + paymentDetails.destinations.length + " miners"); paymentQueue.push(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) { From 2451a0f681f0248c582f79e8caf8ca2ef9ac932c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 09:09:09 +0100 Subject: [PATCH 0158/2430] Added gradual decrease of outdated share rewards --- lib/pool.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a3b1cf65..97b38b83 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -692,7 +692,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy if (job.difficulty >= 1000000 || blockCandidate) { global.database.storeShare(job.height, global.protos.Share.encode({ - shares: job.difficulty, + shares: job.rewarded_difficulty, paymentAddress: miner.address, paymentID: miner.paymentID, foundBlock: blockCandidate, @@ -751,13 +751,13 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy worker["height"] = job.height; worker["difficulty"] = activeBlockTemplate.difficulty; worker["time"] = time_now; - worker["acc"] = job.difficulty; + worker["acc"] = job.rewarded_difficulty; } else { - worker["acc"] += job.difficulty; + worker["acc"] += job.rewarded_difficulty; } - //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + job.height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.difficulty + ")"); + //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + job.height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.rewarded_difficulty + ")"); } if (is_walletAccFinalizer[wallet_key] === false) { @@ -778,10 +778,10 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy } if (shareType) { process.send({type: 'trustedShare'}); - debug(threadName + "Accepted trusted share at difficulty: " + job.difficulty + "/" + shareDiff + " from: " + miner.logString); + debug(threadName + "Accepted trusted share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); } else { process.send({type: 'normalShare'}); - debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + shareDiff + " from: " + miner.logString); + debug(threadName + "Accepted valid share at difficulty: " + job.difficulty + "/" + job.rewarded_difficulty + "/" + shareDiff + " from: " + miner.logString); } if (activeBlockTemplate && activeBlockTemplate.height != job.height) { process.send({type: 'outdatedShare'}); @@ -987,8 +987,23 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return t.height === job.height; })[0]; - if (!blockTemplate || (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime && Date.now() - lastBlockTemplateUpdateTime > 5*1000)) { - let err_str = blockTemplate ? "Block outdated" : "Block expired"; + let is_outdated = false; + + job.rewarded_difficulty = job.difficulty; + + if (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime) { + let late_time = Date.now() - lastBlockTemplateUpdateTime; + let max_late_time = global.config.pool.targetTime*1000; + if (late_time < max_late_time) { + job.rewarded_difficulty = Math.floor(job.difficulty * (max_late_time - late_time) / max_late_time); + if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; + } else { + is_outdated = true; + } + } + + if (!blockTemplate || is_outdated) { + let err_str = is_outdated ? "Block outdated" : "Block expired"; console.warn(threadName + err_str + ', Height: ' + job.height + ' from ' + miner.logString); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; From 4bb049f8b0f27cd4333df254e64c6b0059f13660 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 11:29:04 +0100 Subject: [PATCH 0159/2430] Little bit more reporting in log messages --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 97b38b83..c1724406 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -821,7 +821,7 @@ function processShare(miner, job, blockTemplate, params) { walletLastSeeTime[miner.payout] = Date.now(); } if (hash.toString('hex') !== resultHash) { - console.error(threadName + "Bad share from miner " + miner.logString); + console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); process.send({type: 'invalidShare'}); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; @@ -1004,7 +1004,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (!blockTemplate || is_outdated) { let err_str = is_outdated ? "Block outdated" : "Block expired"; - console.warn(threadName + err_str + ', Height: ' + job.height + ' from ' + miner.logString); + console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; miner.incremented = true; From 69782b8af615eb057f47d689ed8017c04b803e98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 21:34:39 +0100 Subject: [PATCH 0160/2430] Added quadratic reduction of outdated shares and email notificatinos about payments --- lib/payment_systems/xmr.js | 26 ++++++++++++++++++++++++++ lib/pool.js | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 0bb92408..fec321a7 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -542,6 +542,8 @@ function Payee(amount, address, paymentID, bitcoin) { return; } payee.transactionID = result.insertId; + payee.tx_hash = body.tx_hash.match(hexChars)[0]; + payee.tx_key = body.tx_key; payee.trackPayment(); }); } else { @@ -583,6 +585,8 @@ function Payee(amount, address, paymentID, bitcoin) { return; } payee.transactionID = result.insertId; + payee.tx_hash = body.tx_hash.match(hexChars)[0]; + payee.tx_key = body.tx_key; payee.trackPayment(); }); } else { @@ -637,6 +641,26 @@ function Payee(amount, address, paymentID, bitcoin) { full_stop(result); } }); + global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [this.id]).then(function (rows) { + if (rows.length === 0) return; + // toAddress, subject, body + let emailData = { + payment_amount: this.amount - this.fee, + amount: this.amount, + fee: this.fee, + tx_hash: this.tx_hash, + tx_key: this.tx_key + }; + global.support.sendEmail(rows[0].email, + sprintf("Your %(payment_amount)s payment was just performed", emailData), + sprintf( + "Your payment of %(payment_amount)s (with fee %(fee)s) was just performed and total due was decreased by %(amount)s.\n" + + (this.tx_hash && this.tx_key ? "Payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s\n" : ""), + emailData + ), + this.id + ); + }); }; } @@ -748,6 +772,8 @@ function makePayments() { 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(); }); }); diff --git a/lib/pool.js b/lib/pool.js index c1724406..3e96e352 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -995,7 +995,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let late_time = Date.now() - lastBlockTemplateUpdateTime; let max_late_time = global.config.pool.targetTime*1000; if (late_time < max_late_time) { - job.rewarded_difficulty = Math.floor(job.difficulty * (max_late_time - late_time) / max_late_time); + let factor = (max_late_time - late_time) / max_late_time; + job.rewarded_difficulty = Math.floor(job.difficulty * factor * factor); if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; } else { is_outdated = true; From 2b682345f07e0a38f0fdb5009b9a0c814bb0ed1e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 21:38:58 +0100 Subject: [PATCH 0161/2430] Added email debugging --- lib/support.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index c667c9f1..0b86aa0b 100644 --- a/lib/support.js +++ b/lib/support.js @@ -43,7 +43,7 @@ let emailAcc = {}; // last send time of email (email/subject -> time) let emailLastSendTime = {}; -function sendEmailReal(toAddress, subject, body){ +function sendEmailReal(toAddress, subject, email_body){ request.post(global.config.general.mailgunURL + "/messages", { auth: { user: 'api', @@ -53,13 +53,14 @@ function sendEmailReal(toAddress, subject, body){ from: global.config.general.emailFrom, to: toAddress, subject: subject, - text: body + text: email_body }, agentOptions: { rejectUnauthorized: global.config.general.mailgunNoCert === true ? false : true } }, function(err, response, body){ if (!err && response.statusCode === 200) { + debug(email_body); console.log("Email to '" + toAddress + "' was sent successfully! Response: " + body); } else { console.error("Did not send e-mail to '" + toAddress + "' successfully! Response: " + body + " Response: "+JSON.stringify(response)); From 7a7a258d1bc64aa88f16f503c422081780f500ad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 21:47:04 +0100 Subject: [PATCH 0162/2430] Fixed this --- lib/payment_systems/xmr.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index fec321a7..1579ad52 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -641,24 +641,27 @@ function Payee(amount, address, paymentID, bitcoin) { full_stop(result); } }); - global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [this.id]).then(function (rows) { + + let payee = this; + + global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [payee.id]).then(function (rows) { if (rows.length === 0) return; // toAddress, subject, body let emailData = { - payment_amount: this.amount - this.fee, - amount: this.amount, - fee: this.fee, - tx_hash: this.tx_hash, - tx_key: this.tx_key + payment_amount: payee.amount - payee.fee, + amount: payee.amount, + fee: payee.fee, + tx_hash: payee.tx_hash, + tx_key: payee.tx_key }; global.support.sendEmail(rows[0].email, sprintf("Your %(payment_amount)s payment was just performed", emailData), sprintf( "Your payment of %(payment_amount)s (with fee %(fee)s) was just performed and total due was decreased by %(amount)s.\n" + - (this.tx_hash && this.tx_key ? "Payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s\n" : ""), + (payee.tx_hash && payee.tx_key ? "Payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s\n" : ""), emailData ), - this.id + payee.id ); }); }; From c21028314d3b4881eb7cc75807ec161b8a46e5b1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 22:09:22 +0100 Subject: [PATCH 0163/2430] Fixed missing sprintf --- lib/payment_systems/xmr.js | 1 + lib/worker.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 1579ad52..2d7ad5fb 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -4,6 +4,7 @@ const async = require("async"); const debug = require("debug")("payments"); const request = require('request-json'); const range = require('range'); +const sprintf = require("sprintf-js").sprintf; let hexChars = new RegExp("[0-9a-f]+"); let bestExchange = global.config.payout.bestExchange; diff --git a/lib/worker.js b/lib/worker.js index 4ab9d014..05737206 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -209,7 +209,7 @@ function updateShareStats() { // remove old workers prevMinerList.forEach(function (miner) { if (minerList.indexOf(miner) !== -1) return; // we still have this miner in current list - console.log("Removing: " + miner + " as an active miner from the cache."); + debug("Removing: " + miner + " as an active miner from the cache."); let minerStats = global.database.getCache(miner); minerStats.hash = 0; cache_updates[miner] = minerStats; @@ -238,7 +238,7 @@ function updateShareStats() { // find new workers minerList.forEach(function (miner) { if (prevMinerList.indexOf(miner) !== -1) return; // we still have this miner in previous list - console.log("Adding: " + miner + " as an active miner to the cache."); + debug("Adding: " + miner + " as an active miner to the cache."); if (miner.indexOf('_') <= -1) return; // This is a worker case. From c3317b51a89f28f34ca4603a228c6aa4a201b5db Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 22:45:52 +0100 Subject: [PATCH 0164/2430] Reduced number of stored shares and fixed coin representation in emails --- lib/local_comms.js | 10 +++++----- lib/payment_systems/xmr.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 56701ff8..1acfa608 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -579,7 +579,7 @@ function Database(){ /* This function takes the difficulty of the current block, and the last PPS block. If it's 0, save everything, UNLESS global.config.pps.enable is FALSE, then feel free to trash it. - Due to LMDB under current config, we must delete entire keys, due to this, we save diff * shareMulti * 1.3 + Due to LMDB under current config, we must delete entire keys, due to this, we save diff * shareMulti * 2 6/29/2017 - Fixed bug with the way the system got blocks. getLastBlock gets the most recent block. getOldestLockedBlock gets the oldest block in the system that's locked. This ensures that shares for that block can't be destroyed, and that there's enough depth past that point to ensure the system will have the ability @@ -628,10 +628,10 @@ function Database(){ if (global.config.pps.enable){ // If PPS is enabled, we scan for new blocks at cur height - blocksRequired/2. // We need to save shares back that far at the least. - callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 5)); + callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 2)); } else { // Otherwise, we can just start from the current height. Woo! - callback(null, body.height, Math.floor(body.difficulty * global.config.pplns.shareMulti * 5)); + callback(null, body.height, Math.floor(body.difficulty * global.config.pplns.shareMulti * 2)); } } else { @@ -643,10 +643,10 @@ function Database(){ */ if (global.config.pps.enable && oldestLockedBlock.height > body.height - Math.floor(global.config.payout.blocksRequired/2)) { // If PPS is enabled, and the oldestLockedBlock.height > the PPS minimum, start from the PPS minimum. - callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 5)); + callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 2)); } else { // If PPS isn't enabled, or the oldestLockedBlock.height < the PPS minimum, then start from there. - callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 5)); + callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 2)); } } }); diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 2d7ad5fb..dd1d01bf 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -649,9 +649,9 @@ function Payee(amount, address, paymentID, bitcoin) { if (rows.length === 0) return; // toAddress, subject, body let emailData = { - payment_amount: payee.amount - payee.fee, - amount: payee.amount, - fee: payee.fee, + payment_amount: global.support.coinToDecimal(payee.amount - payee.fee), + amount: global.support.coinToDecimal(payee.amount), + fee: global.support.coinToDecimal(payee.fee), tx_hash: payee.tx_hash, tx_key: payee.tx_key }; From eac1b6b814778a1882f3ba0f9a6fa3e106da0478 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 31 Jan 2018 23:10:17 +0100 Subject: [PATCH 0165/2430] Added clarification that fee is actually tx fee --- 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 dd1d01bf..2e5eb58d 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -658,7 +658,7 @@ function Payee(amount, address, paymentID, bitcoin) { global.support.sendEmail(rows[0].email, sprintf("Your %(payment_amount)s payment was just performed", emailData), sprintf( - "Your payment of %(payment_amount)s (with fee %(fee)s) was just performed and total due was decreased by %(amount)s.\n" + + "Your payment of %(payment_amount)s (with tx fee %(fee)s) was just performed and total due was decreased by %(amount)s.\n" + (payee.tx_hash && payee.tx_key ? "Payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s\n" : ""), emailData ), From 53249cdb655bcf5c98d0a2a8aa52478945204ebd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 1 Feb 2018 08:41:59 +0100 Subject: [PATCH 0166/2430] Added currency symbol into payment email --- 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 2e5eb58d..56154ad0 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -656,9 +656,9 @@ function Payee(amount, address, paymentID, bitcoin) { tx_key: payee.tx_key }; global.support.sendEmail(rows[0].email, - sprintf("Your %(payment_amount)s payment was just performed", emailData), + sprintf("Your %(payment_amount)s XMR payment was just performed", emailData), sprintf( - "Your payment of %(payment_amount)s (with tx fee %(fee)s) was just performed and total due was decreased by %(amount)s.\n" + + "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) was just performed and total due was decreased by %(amount)s XMR.\n" + (payee.tx_hash && payee.tx_key ? "Payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s\n" : ""), emailData ), From dc74abfe585d2f01600456a3f8f5a532291abbcf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 1 Feb 2018 09:13:25 +0100 Subject: [PATCH 0167/2430] Added wallet address to payment email --- lib/payment_systems/xmr.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 56154ad0..1d79f36d 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -649,6 +649,7 @@ function Payee(amount, address, paymentID, bitcoin) { if (rows.length === 0) return; // toAddress, subject, body let emailData = { + address: payee.id, payment_amount: global.support.coinToDecimal(payee.amount - payee.fee), amount: global.support.coinToDecimal(payee.amount), fee: global.support.coinToDecimal(payee.fee), @@ -658,8 +659,8 @@ function Payee(amount, address, paymentID, bitcoin) { global.support.sendEmail(rows[0].email, sprintf("Your %(payment_amount)s XMR payment was just performed", emailData), sprintf( - "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) was just performed and total due was decreased by %(amount)s XMR.\n" + - (payee.tx_hash && payee.tx_key ? "Payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s\n" : ""), + "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) to %(address)s wallet was just performed and total due was decreased by %(amount)s XMR.\n" + + (payee.tx_hash && payee.tx_key ? "Your payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" : ""), emailData ), payee.id From 310764232a8ff136ac4d5f7a064782d828c374ff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 1 Feb 2018 09:31:58 +0100 Subject: [PATCH 0168/2430] Reduced worker log message spam --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 05737206..19280189 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -474,7 +474,7 @@ function updateBlockHeader() { ts: body.result.block_header.timestamp }); } else if (body.result.block_header.hash === lastBlockHash) { - console.log("Block headers identical to historical header. Ignoring"); + debug("Block headers identical to historical header. Ignoring"); } else { console.error("GetLastBlockHeader Error during block header update"); } From 32c010f821be5e75f512b62762db91dda0faa3b3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Feb 2018 09:28:21 +0100 Subject: [PATCH 0169/2430] Making payment to multiple people first --- 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 1d79f36d..848ffb1a 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -749,7 +749,7 @@ function makePayments() { mixin: global.config.payout.mixIn }; console.log("Adding payment for " + paymentDetails.destinations.length + " miners"); - paymentQueue.push(paymentDetails, function (body) { //jshint ignore:line + 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; From 1dcdd10d7cb36313f1bac486d9349e18fd054687 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Feb 2018 17:23:51 +0100 Subject: [PATCH 0170/2430] Decreased outdated blowck rewards even more Actually after 5 seconds the reward should be almost 0. --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3e96e352..cd0c0c73 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -996,7 +996,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let 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 * factor * factor); + job.rewarded_difficulty = Math.floor(job.difficulty * Math.pow(factor, 6)); if (job.rewarded_difficulty === 0) job.rewarded_difficulty = 1; } else { is_outdated = true; From c7512a5639d0dc5e00fd6ecefd2f610d54dea43d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Feb 2018 17:28:17 +0100 Subject: [PATCH 0171/2430] Added worker logs --- lib/worker.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index 19280189..fa8e983a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -35,6 +35,7 @@ function updateShareStats() { }; let minerList = []; let identifiers = {}; + let minerCount = 0; let loopBreakout = 0; async.doUntil(function (callback_until) { let oldestTime = Date.now(); @@ -63,8 +64,10 @@ function updateShareStats() { loopCount += 1; } else if (minerID in identifiers) { identifiers[minerID].push(share.identifier); + ++ minerCount; } else { identifiers[minerID] = [share.identifier]; + ++ minerCount; } if (share.timestamp <= locTime) { return; @@ -266,6 +269,7 @@ function updateShareStats() { }); cache_updates.minerList = minerList; global.database.bulkSetCache(cache_updates); + console.log("Processed " + minerCount + " miners for " + ((Date.now() - currentTime) / 1000) + " seconds"); callback(null); }); } From 36ed358b5c2bdb2b9aaa8c07a6cb1d4ecf6e84b4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Feb 2018 17:31:22 +0100 Subject: [PATCH 0172/2430] Changing log message wording --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index fa8e983a..7f69e3b1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -269,7 +269,7 @@ function updateShareStats() { }); cache_updates.minerList = minerList; global.database.bulkSetCache(cache_updates); - console.log("Processed " + minerCount + " miners for " + ((Date.now() - currentTime) / 1000) + " seconds"); + console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds"); callback(null); }); } From 971f184cfee807528675becf7c8062c947e9e205 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Feb 2018 17:40:02 +0100 Subject: [PATCH 0173/2430] Added API to update email --- lib/api.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 9119800c..b22d3e7f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -527,8 +527,8 @@ secureRoutes.get('/tokenRefresh', function (req, res) { }); secureRoutes.get('/', function (req, res) { - global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE id = ?", [req.decoded.id]).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, email FROM users WHERE id = ?", [req.decoded.id]).then(function(row){ + return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email, email: row[0].email}}); }); }); @@ -539,6 +539,12 @@ secureRoutes.post('/changePassword', function (req, res) { }); }); +secureRoutes.post('/changeEmail', function (req, res) { + global.mysql.query("UPDATE users SET email = ? WHERE id = ?", [req.body.email, req.decoded.id]).then(function () { + return res.json({'msg': 'Updated email was set to: ' + req.body.email}); + }); +}); + secureRoutes.post('/toggleEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE id = ?", [req.decoded.id]).then(function () { return res.json({'msg': 'Email toggled'}); From f32841181fd22b2d7c515a36adcc555361832859 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Feb 2018 20:51:00 +0100 Subject: [PATCH 0174/2430] Added Binance.com 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 ca46b38c..e2ce03f6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -31,7 +31,8 @@ function Coin(data){ "46yzCCD3Mza9tRj7aqPSaxVbbePtuAeKzf8Ky2eRtcXGcEgCg1iTBio6N4sPmznfgGEUGDoBz5CLxZ2XPTyZu1yoCAG7zt6", // Shapeshift.io "463tWEBn5XZJSxLU6uLQnQ2iY9xuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ", // Bittrex "44TVPcCSHebEQp4LnapPkhb2pondb2Ed7GJJLc6TkKwtSyumUnQ6QzkCCkojZycH2MRfLcujCM7QR1gdnRULRraV4UpB5n4", // Xmr.to - "47sghzufGhJJDQEbScMCwVBimTuq6L5JiRixD8VeGbpjCTA12noXmi4ZyBZLc99e66NtnKff34fHsGRoyZk3ES1s1V4QVcB" // Poloniex + "47sghzufGhJJDQEbScMCwVBimTuq6L5JiRixD8VeGbpjCTA12noXmi4ZyBZLc99e66NtnKff34fHsGRoyZk3ES1s1V4QVcB", // Poloniex + "44tLjmXrQNrWJ5NBsEj2R77ZBEgDa3fEe9GLpSf2FRmhexPvfYDUAB7EXX1Hdb3aMQ9FLqdJ56yaAhiXoRsceGJCRS3Jxkn" // Binance.com ]; // These are addresses that MUST have a paymentID to perform logins with. this.prefix = 18; From e55eec3534757c19880b79b90442fc6805552e82 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Feb 2018 21:56:02 +0100 Subject: [PATCH 0175/2430] Added more exchanges --- 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 e2ce03f6..7dc2b27e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -32,7 +32,11 @@ function Coin(data){ "463tWEBn5XZJSxLU6uLQnQ2iY9xuNcDbjLSjkn3XAXHCbLrTTErJrBWYgHJQyrCwkNgYvyV3z8zctJLPCZy24jvb3NiTcTJ", // Bittrex "44TVPcCSHebEQp4LnapPkhb2pondb2Ed7GJJLc6TkKwtSyumUnQ6QzkCCkojZycH2MRfLcujCM7QR1gdnRULRraV4UpB5n4", // Xmr.to "47sghzufGhJJDQEbScMCwVBimTuq6L5JiRixD8VeGbpjCTA12noXmi4ZyBZLc99e66NtnKff34fHsGRoyZk3ES1s1V4QVcB", // Poloniex - "44tLjmXrQNrWJ5NBsEj2R77ZBEgDa3fEe9GLpSf2FRmhexPvfYDUAB7EXX1Hdb3aMQ9FLqdJ56yaAhiXoRsceGJCRS3Jxkn" // Binance.com + "44tLjmXrQNrWJ5NBsEj2R77ZBEgDa3fEe9GLpSf2FRmhexPvfYDUAB7EXX1Hdb3aMQ9FLqdJ56yaAhiXoRsceGJCRS3Jxkn", // Binance.com + "43c2ykU9i2KZHjV8dWff9HKurYYRkckLueYK96Qh4p1EDoEvdo8mpgNJJpPuods53PM6wNzmj4K2D1V11wvXsy9LMiaYc86", // Changelly.com + "45rTtwU6mHqSEMduDm5EvUEmFNx2Z6gQhGBJGqXAPHGyFm9qRfZFDNgDm3drL6wLTVHfVhbfHpCtwKVvDLbQDMH88jx2N6w", // ? + "4ALcw9nTAStZSshoWVUJakZ6tLwTDhixhQUQNJkCn4t3fG3MMK19WZM44HnQRvjqmz4LkkA8t565v7iBwQXx2r34HNroSAZ", // Cryptopia.co.nz + "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm" // ? ]; // These are addresses that MUST have a paymentID to perform logins with. this.prefix = 18; From 78cc31e550926f3f3b1cd7686b63feb4b912aa5b Mon Sep 17 00:00:00 2001 From: Learner Date: Sun, 4 Feb 2018 14:05:35 +0700 Subject: [PATCH 0176/2430] Add return for uniform code (not a bug, comestics) It's not a bug, just to be better look. --- lib/coins/aeon.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/aeon.js b/lib/coins/aeon.js index 4d0f9346..c68082dc 100644 --- a/lib/coins/aeon.js +++ b/lib/coins/aeon.js @@ -26,7 +26,7 @@ function Coin(data){ this.supportsAutoExchange = false; - this.niceHashDiff = 200000; + this.niceHashDiff = 400000; this.getBlockHeaderByID = function(blockId, callback){ global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { @@ -34,7 +34,7 @@ function Coin(data){ return callback(null, body.result.block_header); } else { console.error(JSON.stringify(body)); - callback(true, body); + return callback(true, body); } }); }; From 477cc23e70360586c253126792b57acd8bb5c493 Mon Sep 17 00:00:00 2001 From: Snipa22 Date: Sun, 4 Feb 2018 12:06:08 -0800 Subject: [PATCH 0177/2430] Create block_unlocker.js --- debug_scripts/block_unlocker.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 debug_scripts/block_unlocker.js diff --git a/debug_scripts/block_unlocker.js b/debug_scripts/block_unlocker.js new file mode 100644 index 00000000..ec80e588 --- /dev/null +++ b/debug_scripts/block_unlocker.js @@ -0,0 +1,19 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +comms = require('../lib/local_comms'); +global.database = new comms(); +global.database.initEnv(); +global.database.unlockBlock(argv.blockHash); +console.log("Block "+argv.blockHash+" un-locked! Exiting!"); +process.exit(); From 273d576ce57fd00ce18df858d844c50baac69ae4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 7 Feb 2018 18:18:41 +0100 Subject: [PATCH 0178/2430] Added email caching --- lib/worker.js | 73 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 7f69e3b1..46120da8 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -8,6 +8,11 @@ let cycleCount = 0; let lastBlockHash = null; let hashrate_avg_min = 5; +// cached email of specific address +let minerEmail = {}; +// time of last SQL check for specific address +let minerEmailTime = {}; + function updateShareStats() { // This is an omni-worker to deal with all things share-stats related // Time based averages are worked out on ring buffers. @@ -222,20 +227,34 @@ function updateShareStats() { let address_parts = miner.split(/_(.+)/); let address = address_parts[0]; let worker = address_parts[1]; - global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { - if (rows.length === 0) return; - // toAddress, subject, body - let emailData = { - worker: worker, - timestamp: global.support.formatDate(Date.now()), - poolEmailSig: global.config.general.emailSig - }; - global.support.sendEmail(rows[0].email, + // toAddress, subject, body + let emailData = { + worker: worker, + timestamp: global.support.formatDate(Date.now()), + poolEmailSig: global.config.general.emailSig + }; + if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { + minerEmailTime[address] = currentTime; + 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]; + return; + } else { + minerEmail[address] = rows[0].email; + } + global.support.sendEmail(minerEmail[address], + sprintf(global.config.email.workerNotHashingSubject, emailData), + sprintf(global.config.email.workerNotHashingBody, emailData), + address + ); + }); + } else if (address in minerEmail[address]) { + global.support.sendEmail(minerEmail[address], sprintf(global.config.email.workerNotHashingSubject, emailData), sprintf(global.config.email.workerNotHashingBody, emailData), address ); - }); + } }); // find new workers @@ -248,20 +267,34 @@ function updateShareStats() { let address_parts = miner.split(/_(.+)/); let address = address_parts[0]; let worker = address_parts[1]; - global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { - if (rows.length === 0) return; - // toAddress, subject, body - let emailData = { - worker: worker, - timestamp: global.support.formatDate(Date.now()), - poolEmailSig: global.config.general.emailSig - }; - global.support.sendEmail(rows[0].email, + // toAddress, subject, body + let emailData = { + worker: worker, + timestamp: global.support.formatDate(Date.now()), + poolEmailSig: global.config.general.emailSig + }; + if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { + minerEmailTime[address] = currentTime; + 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]; + return; + } else { + minerEmail[address] = rows[0].email; + } + global.support.sendEmail(minerEmail[address], + sprintf(global.config.email.workerStartHashingSubject, emailData), + sprintf(global.config.email.workerStartHashingBody, emailData), + address + ); + }); + } else if (address in minerEmail[address]) { + global.support.sendEmail(minerEmail[address], sprintf(global.config.email.workerStartHashingSubject, emailData), sprintf(global.config.email.workerStartHashingBody, emailData), address ); - }); + } }); Object.keys(identifiers).forEach(function (key) { From 91c37d4b90f11f9b976d1db92e860bdfe39bcaa4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 7 Feb 2018 18:22:04 +0100 Subject: [PATCH 0179/2430] Code fix --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 46120da8..20f150bd 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -248,7 +248,7 @@ function updateShareStats() { address ); }); - } else if (address in minerEmail[address]) { + } else if (address in minerEmail) { global.support.sendEmail(minerEmail[address], sprintf(global.config.email.workerNotHashingSubject, emailData), sprintf(global.config.email.workerNotHashingBody, emailData), @@ -288,7 +288,7 @@ function updateShareStats() { address ); }); - } else if (address in minerEmail[address]) { + } else if (address in minerEmail) { global.support.sendEmail(minerEmail[address], sprintf(global.config.email.workerStartHashingSubject, emailData), sprintf(global.config.email.workerStartHashingBody, emailData), From b7bf64903a90a63d47cf2be22d944aa97a097d4d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Feb 2018 00:19:38 +0100 Subject: [PATCH 0180/2430] Rate limit outcoming emails --- lib/support.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/support.js b/lib/support.js index 0b86aa0b..1bd7dc9b 100644 --- a/lib/support.js +++ b/lib/support.js @@ -42,8 +42,14 @@ function circularBuffer(size) { let emailAcc = {}; // last send time of email (email/subject -> time) let emailLastSendTime = {}; +let lastEmailSendTime; function sendEmailReal(toAddress, subject, email_body){ + if (lastEmailSendTime && Date.now() - lastEmailSendTime < 500) { + setTimeout(sendEmailReal, 500, toAddress, subject, email_body); + return; + } + lastEmailSendTime = Date.now(); request.post(global.config.general.mailgunURL + "/messages", { auth: { user: 'api', From 008c616696f44e0142ab392c508316a09ab00322 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Feb 2018 23:02:44 +0100 Subject: [PATCH 0181/2430] Added payment API caching --- lib/api.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index b22d3e7f..39ebc177 100644 --- a/lib/api.js +++ b/lib/api.js @@ -334,6 +334,9 @@ app.get('/pool/payments/:pool_type', function (req, res) { }); }); +// cache pool_type here just to avoid multiple SQL requests +let tx_pool_types = {}; + app.get('/pool/payments', function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; @@ -344,7 +347,7 @@ app.get('/pool/payments', function (req, res) { } let response = []; rows.forEach(function (row, index, array) { - global.mysql.query("SELECT pool_type FROM payments WHERE transaction_id = ? LIMIT 1", [row.id]).then(function (ptRows) { + if (row.id in tx_pool_types) { let ts = new Date(row.submitted_time); response.push({ id: row.id, @@ -354,12 +357,30 @@ app.get('/pool/payments', function (req, res) { fee: row.fees, value: row.xmr_amt, ts: ts.getTime(), - pool_type: ptRows[0].pool_type + pool_type: tx_pool_types[row.id] }); if (array.length === response.length) { res.json(response.sort(global.support.tsCompare)); } - }); + } else { + global.mysql.query("SELECT pool_type FROM payments WHERE transaction_id = ? LIMIT 1", [row.id]).then(function (ptRows) { + let ts = new Date(row.submitted_time); + tx_pool_types[row.id] = ptRows[0].pool_type; + response.push({ + id: row.id, + hash: row.transaction_hash, + mixins: row.mixin, + payees: row.payees, + fee: row.fees, + value: row.xmr_amt, + ts: ts.getTime(), + pool_type: ptRows[0].pool_type + }); + if (array.length === response.length) { + res.json(response.sort(global.support.tsCompare)); + } + }); + } }); }).catch(function (err) { console.error(threadName + "Error getting miner payments: " + JSON.stringify(err)); From b8978c91539d2dfe99b225b8ce4723d0e52bdb6e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Feb 2018 09:38:16 +0100 Subject: [PATCH 0182/2430] Added HitBTC echange --- 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 7dc2b27e..70dab984 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -36,7 +36,8 @@ function Coin(data){ "43c2ykU9i2KZHjV8dWff9HKurYYRkckLueYK96Qh4p1EDoEvdo8mpgNJJpPuods53PM6wNzmj4K2D1V11wvXsy9LMiaYc86", // Changelly.com "45rTtwU6mHqSEMduDm5EvUEmFNx2Z6gQhGBJGqXAPHGyFm9qRfZFDNgDm3drL6wLTVHfVhbfHpCtwKVvDLbQDMH88jx2N6w", // ? "4ALcw9nTAStZSshoWVUJakZ6tLwTDhixhQUQNJkCn4t3fG3MMK19WZM44HnQRvjqmz4LkkA8t565v7iBwQXx2r34HNroSAZ", // Cryptopia.co.nz - "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm" // ? + "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm", // ? + "41xeYWWKwtSiHju5AdyF8y5xeptuRY3j5X1XYHuB1g6ke4eRexA1iygjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3gJqjM9" // HitBTC ]; // These are addresses that MUST have a paymentID to perform logins with. this.prefix = 18; From bf446cf25a5568ccb6a2c277f8b69e46847652d8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Feb 2018 00:55:03 +0100 Subject: [PATCH 0183/2430] Pay money if threshold is reached exactly --- 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 848ffb1a..36e79729 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -720,7 +720,7 @@ function makePayments() { if (remainder !== 0) { payee.amount -= remainder; } - if (payee.amount > threshold) { + if (payee.amount >= threshold) { 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)); From 3f7009f4d913b42bebc80dcfa89421ff267eec1e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Feb 2018 09:33:30 +0100 Subject: [PATCH 0184/2430] Increased mail send rate limiting --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 1bd7dc9b..0af4f9f4 100644 --- a/lib/support.js +++ b/lib/support.js @@ -45,8 +45,8 @@ let emailLastSendTime = {}; let lastEmailSendTime; function sendEmailReal(toAddress, subject, email_body){ - if (lastEmailSendTime && Date.now() - lastEmailSendTime < 500) { - setTimeout(sendEmailReal, 500, toAddress, subject, email_body); + if (lastEmailSendTime && Date.now() - lastEmailSendTime < 1000) { + setTimeout(sendEmailReal, 1000, toAddress, subject, email_body); return; } lastEmailSendTime = Date.now(); From c702636374f62dc3764ee47056dbb9426ef05989 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 12:39:57 +0100 Subject: [PATCH 0185/2430] Initial code dump --- deployment/base.sql | 4 + lib/blockManager.js | 123 ++++++++++++++----- lib/coins/xmr.js | 28 +++-- lib/data.proto | 19 ++- lib/local_comms.js | 285 ++++++++++++++++++++++++++++++++------------ lib/pool.js | 136 +++++++++++++++------ lib/remoteShare.js | 9 ++ lib/remote_comms.js | 10 ++ lib/support.js | 3 + 9 files changed, 469 insertions(+), 148 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 959a0755..51a00245 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -179,6 +179,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', 'activePort', '18081', 'int', 'Currently Active Daemon RPC Port'); 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'); @@ -212,6 +213,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 ('pplns', 'shareMultiLog', '3', 'int', 'How many times the difficulty of the current block do we keep in shares before clearing them out'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'blockCleaner', 'true', 'bool', 'Enable the deletion of blocks or not.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address', '', 'string', 'Address to mine to, this should be the wallet-rpc address.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_18081', '', 'string', 'Address to mine to for 18081 (XMR) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19734', '', 'string', 'Address to mine to for 19734 (SUMO) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_26976', '', 'string', 'Address to mine to for 26976 (ETN) 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/blockManager.js b/lib/blockManager.js index 93bc0c3e..2e383162 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -16,22 +16,24 @@ let lastBlock = 0; let balanceIDCache = {}; let blockScannerTask; let blockQueue = async.queue(function (task, callback) { - // Todo: Implement within the coins/.js file. - global.support.rpcDaemon('getblockheaderbyheight', {"height": task.blockID}, function (body) { - let blockData = body.result.block_header; - if (blockData.hash in blockHexCache) { + global.coinFuncs.getBlockHeaderByID(task.blockID, (err, body) => { + if (err !== null) { + console.error("Can't get block with " + task.blockID + " height"); + return; + } + if (body.hash in blockHexCache) { return callback(); } debug("Adding block to block_log, ID: " + task.blockID); blockIDCache.push(task.blockID); blockHexCache[body.result.block_header.hash] = null; global.mysql.query("INSERT INTO block_log (id, orphan, hex, find_time, reward, difficulty, major_version, minor_version) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [task.blockID, blockData.orphan_status, blockData.hash, global.support.formatDate(blockData.timestamp * 1000), blockData.reward, blockData.difficulty, blockData.major_version, blockData.minor_version]).then(function () { - return calculatePPSPayments(blockData, callback); + [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: " + blockData.hash in blockHexCache); + debug("BlockHexCache Check: " + body.hash in blockHexCache); debug("BlockIDCache Check: " + blockIDCache.hasOwnProperty(task.blockID)); - debug("Hex: " + blockData.hash + " Height:" + 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(); @@ -210,12 +212,12 @@ function calculatePPSPayments(blockHeader, callback) { return callback(); } -function calculatePPLNSPayments(blockHeader) { - console.log("Performing PPLNS payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); - let rewardTotal = blockHeader.reward; - let blockDiff = blockHeader.difficulty; +function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { + 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; - let blockCheckHeight = blockHeader.height; + let blockCheckHeight = block_height; let totalPaid = 0; let totalShares = 0; let paymentData = {}; @@ -277,8 +279,8 @@ function calculatePPLNSPayments(blockHeader) { console.error(e); return; } - let blockDiff = blockHeader.difficulty; - let rewardTotal = blockHeader.reward; + let blockDiff = block_difficulty; + let rewardTotal = block_reward; if (shareData.poolType === global.protos.POOLTYPE.PPLNS) { let userIdentifier = shareData.paymentAddress; if (shareData.paymentID) { @@ -328,7 +330,7 @@ function calculatePPLNSPayments(blockHeader) { //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); totalPayments += paymentData[key].amount; }); - console.log("PPLNS 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 + "% (precisely " + totalPayments + " / " + blockHeader.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 / block_reward) * 100 + "% (precisely " + totalPayments + " / " + block_reward + ")"); }); }; @@ -421,20 +423,26 @@ function blockUnlocker() { } debug("Running block unlocker"); let blockList = global.database.getValidLockedBlocks(); - // Todo: Implement within the coins/.js file. - global.support.rpcDaemon('getlastblockheader', [], function (body) { - let blockHeight = body.result.block_header.height; - blockList.forEach(function (row) { - // Todo: Implement within the coins/.js file. - global.support.rpcDaemon('getblockheaderbyheight', {"height": row.height}, function (body) { - if (body.result.block_header.hash !== row.hash) { - global.database.invalidateBlock(row.height); - global.mysql.query("UPDATE block_log SET orphan = true WHERE hex = ?", [row.hash]); - blockIDCache.splice(blockIDCache.indexOf(body.result.block_header.height)); - console.log("Invalidating block " + body.result.block_header.height + " due to being an orphan block"); + global.coinFuncs.getLastBlockHeader(function(err, body){ + if (err !== null) { + console.error("Last block header request failed!"); + return; + } + let 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) { + 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 (blockHeight - row.height > global.config.payout.blocksRequired) { - blockPayments(row); + if (topBlockHeight - block.height > global.config.payout.blocksRequired) { + blockPayments(block); } } }); @@ -443,6 +451,30 @@ function blockUnlocker() { }); } +function altblockUnlocker() { + if (scanInProgress) { + debug("Skipping altblock unlocker run as there's a scan in progress"); + return; + } + debug("Running altblock unlocker"); + let blockList = global.database.getValidLockedAltBlocks(); + blockList.forEach(function (block) { + 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; + } + 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"); + } else { + if (block.pay_value !== 0) altblockPayments(block); + } + }); + + }); +} + function blockPayments(block) { switch (block.poolType) { case global.protos.POOLTYPE.PPS: @@ -451,9 +483,11 @@ function blockPayments(block) { break; case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getBlockHeaderByHash(block.hash, function (err, header) { - if (err === null){ - calculatePPLNSPayments(header); + if (err === null && block.height === header.height && block.value === header.reward && block.difficulty === header.difficulty){ + calculatePPLNSPayments(block.height, block.value, block.difficulty); global.database.unlockBlock(block.hash); + } else { + console.error("Can't get correct block header by hash " + block.hash.toString('hex')); } }); break; @@ -466,12 +500,37 @@ function blockPayments(block) { }); break; default: - console.log("Unknown payment type. FREAKOUT"); + console.log("Unknown payment type. FREAKOUT"); global.database.unlockBlock(block.hash); break; } } +function altblockPayments(block) { + switch (block.poolType) { + case global.protos.POOLTYPE.PPLNS: + global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { + if (err === null){ + global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { + if (anchor_err === null){ + calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty); + global.database.unlockAltBlock(block.hash); + } else { + console.error("Can't get correct block header by height " + block.anchor_height.toString()); + } + }); + } else { + console.error("Can't get correct altblock header of " + block.port.toString() + " port by hash " + block.hash.toString('hex')); + } + }); + break; + default: + console.log("Unknown payment type. FREAKOUT"); + global.database.unlockAltBlock(block.hash); + break; + } +} + function blockScanner() { let inc_check = 0; if (scanInProgress) { diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 70dab984..4ad4d523 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -63,8 +63,8 @@ function Coin(data){ }); }; - this.getBlockHeaderByHash = function(blockHash, callback){ - global.support.rpcDaemon('getblockheaderbyhash', {"hash": blockHash}, function (body) { + this.getPortBlockHeaderByHash = function(port, blockHash, callback){ + global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ return callback(null, body.result.block_header); } else { @@ -74,8 +74,12 @@ function Coin(data){ }); }; - this.getLastBlockHeader = function(callback){ - global.support.rpcDaemon('getlastblockheader', [], function (body) { + this.getBlockHeaderByHash = function(blockHash, callback){ + return this.getPortBlockHeaderByHash(global.config.daemon.port, blockHash, callback); + }; + + this.getPortLastBlockHeader = function(port, callback){ + global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ return callback(null, body.result.block_header); } else { @@ -85,15 +89,23 @@ function Coin(data){ }); }; - this.getBlockTemplate = function(walletAddress, callback){ - global.support.rpcDaemon('getblocktemplate', { + this.getLastBlockHeader = function(callback){ + return this.getPortLastBlockHeader(global.config.daemon.port, callback); + }; + + this.getPortBlockTemplate = function(port, callback){ + global.support.rpcPortDaemon(port, 'getblocktemplate', { reserve_size: 17, - wallet_address: walletAddress + wallet_address: global.config.pool["address_" + port.toString()] }, function(body){ return callback(body); }); }; + this.getBlockTemplate = function(callback){ + return this.getPortBlockTemplate(global.config.daemon.port, callback); + }; + this.baseDiff = function(){ return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); }; @@ -157,6 +169,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 daemon port + this.port = global.config.daemon.activePort; 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); diff --git a/lib/data.proto b/lib/data.proto index 0db14213..5f973c01 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -9,6 +9,7 @@ enum MESSAGETYPE { SHARE = 0; BLOCK = 1; INVALIDSHARE = 2; + ALTBLOCK = 3; } message WSData { @@ -37,6 +38,7 @@ message Share { required int32 blockHeight = 10; required int64 timestamp = 11; required string identifier = 12; + optional int32 port = 13; } message Block { @@ -48,4 +50,19 @@ message Block { required bool unlocked = 6; required bool valid = 7; optional int64 value = 8; -} \ No newline at end of file +} + +message AltBlock { + 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; + required int32 port = 8; + required int32 height = 9; + required int32 anchor_height = 10; + optional int64 value = 11; + optional int64 pay_value = 12; +} diff --git a/lib/local_comms.js b/lib/local_comms.js index 1acfa608..5176cb6a 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -8,6 +8,7 @@ function Database(){ this.env = null; this.shareDB = null; this.blockDB = null; + this.altblockDB = null; this.cacheDB = null; this.dirtyenv = false; @@ -39,6 +40,12 @@ function Database(){ integerKey: true, keyIsUint32: true }); + global.database.altblockDB = this.env.openDbi({ + name: 'altblocks', + create: true, + integerKey: true, + keyIsUint32: true + }); global.database.cacheDB = this.env.openDbi({ name: 'cache', create: true @@ -140,7 +147,7 @@ function Database(){ } }; - this.storeShare = function(blockId, shareData, callback){ + /*this.storeShare = function(blockId, shareData, callback){ // This function needs the blockID in question, and the shareData in binary format. // The binary data should be packed as per the data.proto Share protobuf format. try { @@ -173,14 +180,25 @@ function Database(){ txn.putBinary(this.shareDB, blockId, shareData); txn.commit(); callback(true); + };*/ + + this.poolTypeStr = function(poolType) { + switch (poolType) { + case global.protos.POOLTYPE.PPLNS: + return 'pplns'; + case global.protos.POOLTYPE.PPS: + return 'pps'; + case global.protos.POOLTYPE.SOLO: + return 'solo'; + default: + console.error("Unknown poolType: " + poolType.toString()); + return 'pplns'; + } }; this.storeBulkShares = function(shareObject) { let cachedData = { - global_stats2: {totalHashes: 0, roundHashes: 0}, - pplns_stats2: {totalHashes: 0, roundHashes: 0}, - pps_stats2: {totalHashes: 0, roundHashes: 0}, - solo_stats2: {totalHashes: 0, roundHashes: 0} + global_stats2: { totalHashes: 0, roundHashes: 0 } }; let shares = {}; // Shares keyed by blockID let shareCount = 0; @@ -198,20 +216,20 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - cachedData.global_stats2.totalHashes += share.shares; - cachedData.global_stats2.roundHashes += share.shares; - let stats_type = 'pplns_stats2'; - switch (share.poolType) { - case global.protos.POOLTYPE.PPLNS: - stats_type = 'pplns_stats2'; - break; - case global.protos.POOLTYPE.PPS: - stats_type = 'pps_stats2'; - break; - case global.protos.POOLTYPE.SOLO: - stats_type = 'solo_stats2'; - break; + let port_suffix = typeof(share.port) !== 'undefined' ? "_" + share.port.toString() : ""; + let global_stats = "global_stats2" + port_suffix; + let stats_type = this.poolTypeStr(share.poolType) + "_stats2" + port_suffix; + if (!(global_stats in cachedData)) { + cachedData[global_stats] = { totalHashes: 0, roundHashes: 0 }; } + if (!(stats_type in cachedData)) { + cachedData[stats_type] = { totalHashes: 0, roundHashes: 0 }; + } + if (typeof(share.port) !== 'undefined') { + cachedData["global_stats2"].totalHashes += share.shares; + } + cachedData[global_stats].totalHashes += share.shares; + cachedData[global_stats].roundHashes += share.shares; cachedData[stats_type].totalHashes += share.shares; cachedData[stats_type].roundHashes += share.shares; if (!cachedData.hasOwnProperty(minerID)) { @@ -308,7 +326,7 @@ function Database(){ } }; - this.getLastBlock = function(blockType){ + /*this.getLastBlock = function(blockType){ this.refreshEnv(); debug("Getting the last block for: "+ blockType); let txn = this.env.beginTxn({readOnly: true}); @@ -328,7 +346,7 @@ function Database(){ txn.commit(); debug("Done getting the last block for: "+ blockType + " height of: "+ highestBlock); return highestBlock; - }; + };*/ this.getBlockByID = function(blockID){ this.refreshEnv(); @@ -345,7 +363,7 @@ function Database(){ return blockData; }; - this.calculateShares = function(blockData, blockHeight){ + /*this.calculateShares = function(blockData, blockHeight){ debug("Calculating shares for "+ blockData.hash); this.refreshEnv(); let lastBlock = this.getLastBlock(blockData.poolType); @@ -371,7 +389,7 @@ function Database(){ blockData.shares = shareCount; debug("Share calculator for "+ blockData.hash + " complete, found " + shareCount + " shares."); return global.protos.Block.encode(blockData); - }; + };*/ // hash -> time let orphanBlocks = {}; @@ -381,7 +399,7 @@ function Database(){ try{ let blockDataDecoded = global.protos.Block.decode(blockData); global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ - // after hour of submit attempts finally cosider this block as orphan + // 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) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { @@ -401,22 +419,67 @@ function Database(){ return; } blockDataDecoded.value = header.reward; - blockData = global.database.calculateShares(blockDataDecoded, blockId); + //blockData = global.database.calculateShares(blockDataDecoded, blockId); + let port_str = "_" + global.config.daemon.port.toString(); + if (global.database.getCache(this.poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str) === false) { + port_str = ""; + } + let shares = global.database.getCache(this.poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; + blockDataDecoded.shares = shares ? shares.roundHashes : 0; + blockData = global.protos.Block.encode(blockDataDecoded); let txn = global.database.env.beginTxn(); txn.putBinary(global.database.blockDB, blockId, blockData); txn.commit(); - global.database.incrementCacheData('global_stats2', [{location: 'roundHashes', value: false}]); - switch (blockDataDecoded.poolType) { - case global.protos.POOLTYPE.PPLNS: - global.database.incrementCacheData('pplns_stats2', [{location: 'roundHashes', value: false}]); - break; - case global.protos.POOLTYPE.PPS: - global.database.incrementCacheData('pps_stats2', [{location: 'roundHashes', value: false}]); - break; - case global.protos.POOLTYPE.SOLO: - global.database.incrementCacheData('solo_stats2', [{location: 'roundHashes', value: false}]); - break; + global.database.incrementCacheData('global_stats2' + port_str, [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData(this.poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); + return callback(true); + }); + } catch (e) { + console.error("ERROR IN STORING BLOCK. LOOK INTO ME PLZ: " + JSON.stringify(e)); + throw new Error("Error in block storage"); + } + }; + + this.storeAltBlock = function(blockId, blockData, callback){ + this.refreshEnv(); + try{ + 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) { + let time_now = Date.now(); + if (blockDataDecoded.hash in orphanBlocks) { + if (time_now - orphanBlocks[blockDataDecoded.hash] > 5*60*1000) { + console.log("Stopped attempts to get block reward for " + blockDataDecoded.hash); + err = false; + header = {}; + header.reward = 0; + } + } else { + console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); + orphanBlocks[blockDataDecoded.hash] = time_now; + } + } + if (err || typeof(header) === 'undefined' || !header){ + setTimeout(function () { return callback(false) }, 1000); + return; + } + blockDataDecoded.value = header.reward; + blockDataDecoded.pay_value = 0; + //blockData = global.database.calculateShares(blockDataDecoded, blockId); + let port_str = "_" + blockDataDecoded.port.toString(); + let shares = global.database.getCache(this.poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; + blockDataDecoded.shares = shares ? shares.roundHashes : 0; + blockData = global.protos.AltBlock.encode(blockDataDecoded); + 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; } + txn.putBinary(global.database.altblockDB, blockId, blockData); + txn.commit(); + global.database.incrementCacheData('global_stats2' + port_str, [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData(this.poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); return callback(true); }); } catch (e) { @@ -425,7 +488,7 @@ function Database(){ } }; - this.fixBlockShares = function(blockId){ + /*this.fixBlockShares = function(blockId){ let txn = global.database.env.beginTxn(); let blockData = txn.getBinary(global.database.blockDB, blockId); txn.abort(); @@ -439,7 +502,7 @@ function Database(){ txn.commit(); } }); - }; + };*/ this.invalidateBlock = function(blockId){ this.refreshEnv(); @@ -451,6 +514,16 @@ function Database(){ txn.commit(); }; + 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; + blockData.unlocked = true; + txn.putBinary(this.altblockDB, blockId, global.protos.AltBlock.encode(blockData)); + txn.commit(); + }; + this.getValidLockedBlocks = function(){ this.refreshEnv(); let txn = this.env.beginTxn({readOnly: true}); @@ -470,6 +543,25 @@ function Database(){ return blockList; }; + this.getValidLockedAltBlocks = function(){ + this.refreshEnv(); + let txn = this.env.beginTxn({readOnly: true}); + let cursor = new this.lmdb.Cursor(txn, this.altblockDB); + let blockList = []; + 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.valid === true && blockData.unlocked === false){ + blockData.id = key; + blockList.push(blockData); + } + }); + } + cursor.close(); + txn.commit(); + return blockList; + }; + this.unlockBlock = function(blockHex){ this.refreshEnv(); let txn = this.env.beginTxn(); @@ -489,6 +581,25 @@ function Database(){ txn.commit(); }; + 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()) { + let altblockDB = this.altblockDB; + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + if (blockData.hash === blockHex){ + blockData.unlocked = true; + txn.putBinary(altblockDB, key, global.protos.AltBlock.encode(blockData)); + } + }); + altblockDB = null; + } + cursor.close(); + txn.commit(); + }; + this.lockBlock = function(blockId){ let txn = this.env.beginTxn(); let blockProto = txn.getBinary(this.blockDB, blockId); @@ -500,6 +611,17 @@ function Database(){ txn.commit(); }; + this.lockAltBlock = function(blockId){ + let txn = this.env.beginTxn(); + let blockProto = txn.getBinary(this.altblockDB, blockId); + if (blockProto !== null){ + let blockData = global.protos.AltBlock.decode(blockProto); + blockData.unlocked = false; + txn.putBinary(this.altblockDB, blockId, global.protos.AltBlock.encode(blockData)); + } + txn.commit(); + }; + this.getCache = function(cacheKey){ debug("Getting Key: "+cacheKey); try { @@ -539,7 +661,7 @@ function Database(){ txn.commit(); }; - this.getOldestLockedBlock = function(){ + this.getOldestLockedBlockHeight = function(){ /* 6-29-2017 - Snipa - This function returns a decompressed block proto for the first locked block in the system as part of the @@ -547,32 +669,46 @@ function Database(){ */ this.refreshEnv(); debug("Getting the oldest locked block in the system"); + + let oldestLockedBlockHeight = null; + let txn = this.env.beginTxn({readOnly: true}); - let cursor = new this.lmdb.Cursor(txn, this.blockDB); - let highestBlockKey = null; - let highestBlock = null; - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - cursor.getCurrentBinary(function(key, data){ // jshint ignore:line - let blockData = global.protos.Block.decode(data); - if (blockData.unlocked === false){ - if (highestBlock === null || highestBlockKey >= key) { - if (highestBlock !== null) { - console.error("Found unordered blocks with " + highestBlockKey.toString() + " and " + key.toString() + " heights"); - } - highestBlock = blockData; - highestBlockKey = key; - } - } - }); + + { let cursor = new this.lmdb.Cursor(txn, this.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.unlocked === false){ + if (oldestLockedBlockHeight === null || oldestLockedBlockHeight > blockData.anchor_height) { + oldestLockedBlockHeight = blockData.anchor_height; + } + } + }); + } + cursor.close(); } - cursor.close(); + + { let cursor = new this.lmdb.Cursor(txn, this.blockDB); + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + 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) { + oldestLockedBlockHeight = key; + } + }); + } + cursor.close(); + } + txn.commit(); - if (highestBlock !== null) { - debug("Got the oldest locked block in the system at height: " + JSON.stringify(highestBlock)); + + if (oldestLockedBlockHeight !== null) { + console.log("Got the oldest locked block in the system at height: " + oldestLockedBlockHeight.toString()); } else { - debug("There are no unlocked blocks in the system. Woohoo!"); + console.log("There are no locked blocks in the system. Woohoo!"); } - return highestBlock; + return oldestLockedBlockHeight; }; this.cleanShareDB = function() { @@ -600,26 +736,28 @@ 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. */ - let oldestLockedBlock = this.getOldestLockedBlock(); + let oldestLockedBlockHeight = this.getOldestLockedBlockHeight(); async.waterfall([ function(callback){ - if (oldestLockedBlock === null) { - callback(null, oldestLockedBlock) + if (oldestLockedBlockHeight === null) { + callback(null, null, null); } else { - global.coinFuncs.getBlockHeaderByHash(oldestLockedBlock.hash, (err, result) => { - oldestLockedBlock.height = result.height; - console.log("Got the oldest block"); - callback(null, oldestLockedBlock); + global.coinFuncs.getBlockHeaderByID(oldestLockedBlockHeight, (err, result) => { + if (err !== null) { + console.error("Can't get block with " + oldestLockedBlockHeight + " height"); + return; + } + callback(null, oldestLockedBlockHeight, result.difficulty); }); } - }, - function(oldestLockedBlock, callback){ + }, + function(oldestLockedBlockHeight, oldestLockedBlockDifficulty, callback){ global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { console.error("Last block header request failed!"); return; } - if (oldestLockedBlock === null){ + if (oldestLockedBlockHeight === null){ /* If there's no locked blocks, then allow the system to scan from the PPS depth downwards if PPS is enabled. @@ -641,12 +779,12 @@ function Database(){ This will ensure that enough shares are in place to unlock all blocks. If the block is Solo, PPLNS or PPS, it doesn't matter. */ - if (global.config.pps.enable && oldestLockedBlock.height > body.height - Math.floor(global.config.payout.blocksRequired/2)) { - // If PPS is enabled, and the oldestLockedBlock.height > the PPS minimum, start from the PPS minimum. + if (global.config.pps.enable && oldestLockedBlockHeight > body.height - Math.floor(global.config.payout.blocksRequired/2)) { + // If PPS is enabled, and the oldestLockedBlockHeight > the PPS minimum, start from the PPS minimum. callback(null, body.height - Math.floor(global.config.payout.blocksRequired/2), Math.floor(body.difficulty * global.config.pplns.shareMulti * 2)); } else { - // If PPS isn't enabled, or the oldestLockedBlock.height < the PPS minimum, then start from there. - callback(null, oldestLockedBlock.height, Math.floor(oldestLockedBlock.difficulty * global.config.pplns.shareMulti * 2)); + // If PPS isn't enabled, or the oldestLockedBlockHeight < the PPS minimum, then start from there. + callback(null, oldestLockedBlockHeight, Math.floor(oldestLockedBlockDifficulty * global.config.pplns.shareMulti * 2)); } } }); @@ -688,6 +826,7 @@ function Database(){ txn.abort(); if (pplnsCurrFound) pplnsFound = true; }); + console.log("Scan finished"); callback(null, blockList); } ], function(err, data){ diff --git a/lib/pool.js b/lib/pool.js index cd0c0c73..5d7bc557 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -170,8 +170,23 @@ function checkAliveMiners() { } } +// global.config.daemon.activePort is only updated in master thread +function updateActivePort() { + global.mysql.query("SELECT item_value FROM pool.config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { + if (rows.length != 1) { + console.error("Can't get pool.config.daemon.activePort value"); + return; + } + if (global.config.daemon.activePort && global.config.daemon.activePort !== row.item_value) { + console.log("Changing active port from " + global.config.daemon.activePort + " to " + row.item_value); + } + global.config.daemon.activePort = row.item_value; + }); +} + +// templateUpdateReal is only called in master thread function templateUpdateReal() { - global.coinFuncs.getBlockTemplate(global.config.pool.address, function (rpcResponse) { + global.coinFuncs.getPortBlockTemplate(global.config.daemon.activePort, function (rpcResponse) { if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; debug(threadName + "New block template found at " + rpcResponse.height + " height"); @@ -189,13 +204,14 @@ function templateUpdateReal() { }); } +// templateUpdate is only called in master thread function templateUpdate(repeating) { - if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 30*60*1000) { - console.error("Block height was not updated for half an hour. Check your monerod. Exiting..."); + if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 60*60*1000) { + console.error("Block height was not updated for an hour. Check your monerod. Exiting..."); fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); process.exit(); } - global.coinFuncs.getLastBlockHeader(function (err, body) { + global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function (err, body) { if (err === null) { let time_now = Date.now(); let is_block_hash_updated = !lastBlockHash || body.hash !== lastBlockHash; @@ -206,12 +222,29 @@ function templateUpdate(repeating) { } if (repeating === true) setTimeout(templateUpdate, 50, repeating); } else { - console.error("Last block header request failed!"); + console.error("Last block header request for " + global.config.daemon.activePort + " port failed!"); setTimeout(templateUpdate, 1000, repeating); } }); } +// main chain anchor block height for alt chain block +let anchorBlockHeight; + +// update main chain anchor block height for alt chain block +// anchorBlockUpdate is only called in worker threads +function anchorBlockUpdate() { + if (activeBlockTemplate && global.config.daemon.port === activeBlockTemplate.port) return; + // only need to do that separately if we mine alt chain + global.coinFuncs.getLastBlockHeader(function (err, body) { + if (err === null) { + anchorBlockHeight = body.height; + } else { + console.error("Archor last block header request failed!"); + } + }); +} + function newBlockTemplate(template) { if (activeBlockTemplate) { if (activeBlockTemplate.previous_hash.toString('hex') === template.prev_hash) { @@ -222,6 +255,9 @@ function newBlockTemplate(template) { } console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); activeBlockTemplate = new BlockTemplate(template); + if (global.config.daemon.port === activeBlockTemplate.port) { + anchorBlockHeight = activeBlockTemplate.height; + } for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; @@ -626,14 +662,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } } -// store wallet_key (address, paymentID, bitcoin, poolTypeEnum) -> worker_name -> shareType -> (height, difficulty, time, acc) +// store wallet_key (address, paymentID, bitcoin, poolTypeEnum, port) -> worker_name -> shareType -> (height, difficulty, time, acc) let walletAcc = {}; // number of worker_name for wallet_key (so we do not count them by iteration) 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) { +function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bitcoin, miner_poolTypeEnum, miner_port) { //console.log("!!! " + wallet_key + ": scanning for old worker names"); let wallet = walletAcc[wallet_key]; let is_something_left = false; @@ -657,7 +693,8 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi bitcoin: miner_bitcoin, blockHeight: height, timestamp: time_now, - identifier: worker_name + identifier: worker_name, + port: miner_port })); } //console.log("!!! " + wallet_key + ": removing old worker " + worker_name); @@ -669,7 +706,7 @@ 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); + setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner_address, miner_paymentID, miner_bitcoin, miner_poolTypeEnum, miner_port); } else { is_walletAccFinalizer[wallet_key] = false; } @@ -681,7 +718,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy 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; + let wallet_key = miner.address + " " + miner.paymentID + " " + miner.bitcoin + " " + miner.poolTypeEnum + " " + blockTemplate.port; if (!(wallet_key in walletAcc)) { walletAcc[wallet_key] = {}; @@ -689,9 +726,11 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy is_walletAccFinalizer[wallet_key] = false; } + let db_job_height = global.config.daemon.port === blockTemplate.port ? job.height : anchorBlockHeight; + if (job.difficulty >= 1000000 || blockCandidate) { - global.database.storeShare(job.height, global.protos.Share.encode({ + global.database.storeShare(db_job_height, global.protos.Share.encode({ shares: job.rewarded_difficulty, paymentAddress: miner.address, paymentID: miner.paymentID, @@ -701,9 +740,10 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy poolID: global.config.pool_id, blockDiff: activeBlockTemplate.difficulty, bitcoin: miner.bitcoin, - blockHeight: job.height, + blockHeight: db_job_height, timestamp: time_now, - identifier: miner.identifier + identifier: miner.identifier, + port: blockTemplate.port })); } else { @@ -717,7 +757,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy //console.log("!!! " + wallet_key + ": adding new worker " + worker_name + " (num " + walletWorkerCount[wallet_key] + ")"); wallet[worker_name] = {}; let worker = wallet[worker_name]; - worker["height"] = job.height; + worker["height"] = db_job_height; worker["difficulty"] = activeBlockTemplate.difficulty; worker["time"] = time_now; worker["acc"] = 0; @@ -729,7 +769,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy let difficulty = worker["difficulty"]; let acc = worker["acc"]; - if (height !== job.height || difficulty !== activeBlockTemplate.difficulty || time_now - worker["time"] > 60*1000 || acc >= 1000000) { + if (height !== db_job_height || difficulty !== activeBlockTemplate.difficulty || time_now - worker["time"] > 60*1000 || acc >= 1000000) { if (acc != 0) { //console.log("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); global.database.storeShare(height, global.protos.Share.encode({ @@ -744,11 +784,12 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy bitcoin: miner.bitcoin, blockHeight: height, timestamp: time_now, - identifier: worker_name + identifier: worker_name, + port: blockTemplate.port })); } - worker["height"] = job.height; + worker["height"] = db_job_height; worker["difficulty"] = activeBlockTemplate.difficulty; worker["time"] = time_now; worker["acc"] = job.rewarded_difficulty; @@ -757,24 +798,39 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy worker["acc"] += job.rewarded_difficulty; } - //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + job.height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.rewarded_difficulty + ")"); + //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.rewarded_difficulty + ")"); } 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); + setTimeout(walletAccFinalizer, 60*1000, wallet_key, miner.address, miner.paymentID, miner.bitcoin, miner.poolTypeEnum, blockTemplate.port); } if (blockCandidate) { - global.database.storeBlock(job.height, global.protos.Block.encode({ - hash: hashHex, - difficulty: blockTemplate.difficulty, - shares: 0, - timestamp: Date.now(), - poolType: miner.poolTypeEnum, - unlocked: false, - valid: true - })); + if (global.config.daemon.port === blockTemplate.port) { + global.database.storeBlock(job.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: job.height, + anchor_height: anchorBlockHeight + })); + } } if (shareType) { process.send({type: 'trustedShare'}); @@ -844,20 +900,20 @@ function processShare(miner, job, blockTemplate, params) { if (hashDiff.ge(blockTemplate.difficulty)) { // Submit block to the RPC Daemon. // Todo: Implement within the coins/.js file. - global.support.rpcDaemon('submitblock', [shareBuffer.toString('hex')], function (rpcResult) { + 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. console.error(threadName + "Error submitting block at height " + job.height + " from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); recordShareData(miner, job, hashDiff.toString(), false, null, shareType); // Error on submit, so we'll submit a sanity check for good measure. - templateUpdate(); + //templateUpdate(); } else if (rpcResult) { //Success! Submitted a block without an issue. let blockFastHash = global.coinFuncs.getBlockID(shareBuffer).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); - templateUpdate(); + //templateUpdate(); } else { // RPC bombed out massively. console.error(threadName + "RPC Error. Please check logs for details"); @@ -1102,17 +1158,27 @@ if (cluster.isMaster) { worker.on('message', messageHandler); workerList.push(worker); }); + + + if (!global.config.daemon.activePort) { + console.error("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); + global.config.daemon.activePort = global.config.daemon.port; + } else { + setInterval(updateActivePort, 60*1000); + } + 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 { - setInterval(checkAliveMiners, 30000); + setInterval(checkAliveMiners, 30*1000); setInterval(retargetMiners, global.config.pool.retargetTime * 1000); - templateUpdate(); + //templateUpdate(); + anchorBlockUpdate(); setInterval(function () { bannedIPs = []; - //templateUpdate(); - }, 60000); + anchorBlockUpdate(); + }, 60*1000); // load merged wallet trust from files let numWorkers = require('os').cpus().length; diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 0c564aef..e1efc970 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -53,6 +53,15 @@ app.post('/leafApi', function (req, res) { } }); break; + case global.protos.MESSAGETYPE.ALTBLOCK: + global.database.storeAltBlock(msgData.exInt, msgData.msg, function(data){ + if (!data){ + return res.status(400).end(); + } else { + return res.json({'success': true}); + } + }); + break; case global.protos.MESSAGETYPE.INVALIDSHARE: global.database.storeInvalidShare(msgData.msg, function(data){ if (!data){ diff --git a/lib/remote_comms.js b/lib/remote_comms.js index d296b28f..6b544930 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -44,6 +44,16 @@ function Database() { process.send({type: 'sendRemote', body: wsData.toString('hex')}); }; + this.storeAltBlock = function (blockId, blockData) { + let wsData = global.protos.WSData.encode({ + msgType: global.protos.MESSAGETYPE.ALTBLOCK, + key: global.config.api.authKey, + msg: blockData, + exInt: blockId + }); + process.send({type: 'sendRemote', body: wsData.toString('hex')}); + }; + this.storeInvalidShare = function (minerData) { let wsData = global.protos.WSData.encode({ msgType: global.protos.MESSAGETYPE.INVALIDSHARE, diff --git a/lib/support.js b/lib/support.js index 0af4f9f4..bc9d5fbc 100644 --- a/lib/support.js +++ b/lib/support.js @@ -215,6 +215,9 @@ module.exports = function () { rpcDaemon: function (method, params, callback) { rpc(global.config.daemon.address, global.config.daemon.port, method, params, callback); }, + rpcPortDaemon: function (port, method, params, callback) { + rpc(global.config.daemon.address, port, method, params, callback); + }, rpcWallet: function (method, params, callback) { rpc(global.config.wallet.address, global.config.wallet.port, method, params, callback); }, From 4414b968c239f8fc7ac5409825542408ad77dd7f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 14:18:30 +0100 Subject: [PATCH 0186/2430] Allow server to run even if it can't bind some ports --- lib/pool.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5d7bc557..d0f96f5b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1323,24 +1323,32 @@ if (cluster.isMaster) { } if ('ssl' in portData && portData.ssl === true) { - tls.createServer({ + let server = tls.createServer({ key: fs.readFileSync('cert.key'), cert: fs.readFileSync('cert.pem') - }, socketConn).listen(portData.port, global.config.bind_ip, function (error) { + }, socketConn); + server.listen(portData.port, global.config.bind_ip, function (error) { if (error) { console.error(threadName + "Unable to start server on: " + portData.port + " Message: " + error); return; } console.log(threadName + "Started server on port: " + portData.port); }); + server.on('error', function (error) { + console.error("Can't bind server to " + portData.port + " SSL port!"); + }); } else { - net.createServer(socketConn).listen(portData.port, global.config.bind_ip, function (error) { + let server = net.createServer(socketConn); + server.listen(portData.port, global.config.bind_ip, function (error) { if (error) { console.error(threadName + "Unable to start server on: " + portData.port + " Message: " + error); return; } console.log(threadName + "Started server on port: " + portData.port); }); + server.on('error', function (error) { + console.error("Can't bind server to " + portData.port + " port!"); + }); } }); } From c2ff6f9880840da9c7dae013c4f5acf97ff78efd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 14:51:32 +0100 Subject: [PATCH 0187/2430] More advanced kill switch that switches to main chain first --- lib/pool.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d0f96f5b..d8ccd856 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -198,7 +198,7 @@ function templateUpdateReal() { newBlockTemplate(rpcResponse); } } else { - console.error("Block template request failed!"); + console.error("Block template request failed for " + global.config.daemon.activePort + " port"); setTimeout(templateUpdateReal, 3000); } }); @@ -207,9 +207,14 @@ function templateUpdateReal() { // templateUpdate is only called in master thread function templateUpdate(repeating) { if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 60*60*1000) { - console.error("Block height was not updated for an hour. Check your monerod. Exiting..."); - fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); - process.exit(); + if (global.config.daemon.activePort === global.config.daemon.port) { + console.error("Block height was not updated for an hour. Check your monerod. Exiting..."); + fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); + process.exit(); + } else { + console.error("Alt block height on " + global.config.daemon.activePort + " port was not updated for an hour. Switching to main chain...."); + global.config.daemon.activePort = global.config.daemon.port; + } } global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function (err, body) { if (err === null) { From a8aa1f399ff9e516f8f528f3ed6389c10eb148d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 14:56:42 +0100 Subject: [PATCH 0188/2430] Use main wallet address from non _port value --- deployment/base.sql | 1 - lib/coins/xmr.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 51a00245..33adcb7f 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -213,7 +213,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 ('pplns', 'shareMultiLog', '3', 'int', 'How many times the difficulty of the current block do we keep in shares before clearing them out'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'blockCleaner', 'true', 'bool', 'Enable the deletion of blocks or not.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address', '', 'string', 'Address to mine to, this should be the wallet-rpc address.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_18081', '', 'string', 'Address to mine to for 18081 (XMR) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19734', '', 'string', 'Address to mine to for 19734 (SUMO) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_26976', '', 'string', 'Address to mine to for 26976 (ETN) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'feeAddress', '', 'string', 'Address that pool fees are sent to.'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 4ad4d523..af056d4c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -96,7 +96,7 @@ function Coin(data){ this.getPortBlockTemplate = function(port, callback){ global.support.rpcPortDaemon(port, 'getblocktemplate', { reserve_size: 17, - wallet_address: global.config.pool["address_" + port.toString()] + wallet_address: global.config.pool[port === global.config.daemon.port ? "address" : "address_" + port.toString()] }, function(body){ return callback(body); }); From 00ad9877a0f8399490024c785fd0a67fd71d346d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 15:13:34 +0100 Subject: [PATCH 0189/2430] Improving kill switch logic --- lib/pool.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d8ccd856..ba0a064d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -170,6 +170,8 @@ function checkAliveMiners() { } } +let isActivePortUpdateBlocked = false; + // global.config.daemon.activePort is only updated in master thread function updateActivePort() { global.mysql.query("SELECT item_value FROM pool.config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { @@ -178,9 +180,13 @@ function updateActivePort() { return; } if (global.config.daemon.activePort && global.config.daemon.activePort !== row.item_value) { - console.log("Changing active port from " + global.config.daemon.activePort + " to " + row.item_value); + if (isActivePortUpdateBlocked) { + console.error("Blocked change of active port from " + global.config.daemon.activePort + " to " + row.item_value); + } else { + console.log("Changing active port from " + global.config.daemon.activePort + " to " + row.item_value); + global.config.daemon.activePort = row.item_value; + } } - global.config.daemon.activePort = row.item_value; }); } @@ -206,14 +212,27 @@ function templateUpdateReal() { // templateUpdate is only called in master thread function templateUpdate(repeating) { - if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 60*60*1000) { + if (!cluster.isMaster) { + console.error("templateUpdate should not be called from a worker thread!"); + return; + } + if (global.config.general.allowStuckPoolKill && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 60*60*1000) { if (global.config.daemon.activePort === global.config.daemon.port) { + global.support.sendEmail(global.config.general.adminEmail, + "Pool server " + global.config.hostname + " was terminated", + "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was terminated due to main chain block template stuck" + ); console.error("Block height was not updated for an hour. Check your monerod. Exiting..."); fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); process.exit(); } else { + global.support.sendEmail(global.config.general.adminEmail, + "Pool server " + global.config.hostname + " was switched to main chain", + "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was switch to main chain due to block tempalte stuck on " + global.config.daemon.activePort + " port" + ); console.error("Alt block height on " + global.config.daemon.activePort + " port was not updated for an hour. Switching to main chain...."); global.config.daemon.activePort = global.config.daemon.port; + isActivePortUpdateBlocked = true; } } global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function (err, body) { From 4881f0d068ba348a1a0ae4c0d30aeae6c0d2dd9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 15:22:53 +0100 Subject: [PATCH 0190/2430] Remove activePort dependency in workers --- lib/coins/xmr.js | 2 +- lib/pool.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index af056d4c..3d59c2cc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -170,7 +170,7 @@ function Coin(data){ // 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 daemon port - this.port = global.config.daemon.activePort; + 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); diff --git a/lib/pool.js b/lib/pool.js index ba0a064d..68a46b87 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -195,6 +195,7 @@ function templateUpdateReal() { global.coinFuncs.getPortBlockTemplate(global.config.daemon.activePort, function (rpcResponse) { if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; + rpcResponse.port = global.config.daemon.activePort; debug(threadName + "New block template found at " + rpcResponse.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); From 798028f5b878391f47385627339fe85e7f9eb6a2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 15:26:29 +0100 Subject: [PATCH 0191/2430] Pass block template to recordShareData in any case --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 68a46b87..7454abbf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -929,7 +929,7 @@ function processShare(miner, job, blockTemplate, params) { if (rpcResult.error) { // Did not manage to submit a block. Log and continue on. console.error(threadName + "Error submitting block at height " + job.height + " from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); - recordShareData(miner, job, hashDiff.toString(), false, null, shareType); + recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); // Error on submit, so we'll submit a sanity check for good measure. //templateUpdate(); } else if (rpcResult) { @@ -952,7 +952,7 @@ function processShare(miner, job, blockTemplate, params) { return false; } else { - recordShareData(miner, job, hashDiff.toString(), false, null, shareType); + recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); } return true; } From fdc2166237b36a72e93800070b6cb2a04cce9aae Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 15:29:02 +0100 Subject: [PATCH 0192/2430] Fixed blockQueue --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 2e383162..009c297a 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -26,7 +26,7 @@ let blockQueue = async.queue(function (task, callback) { } debug("Adding block to block_log, ID: " + task.blockID); blockIDCache.push(task.blockID); - blockHexCache[body.result.block_header.hash] = null; + 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); From 1104905871d557340bc4c3b0c5d1db3954e4f1b8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 21:13:35 +0100 Subject: [PATCH 0193/2430] Fixed active port update --- deployment/base.sql | 2 +- lib/pool.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 33adcb7f..c4af8bba 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -214,7 +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 ('general', 'blockCleaner', 'true', 'bool', 'Enable the deletion of blocks or not.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address', '', 'string', 'Address to mine to, this should be the wallet-rpc address.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19734', '', 'string', 'Address to mine to for 19734 (SUMO) port.'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_26976', '', 'string', 'Address to mine to for 26976 (ETN) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_26968', '', 'string', 'Address to mine to for 26968 (ETN) 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/pool.js b/lib/pool.js index 7454abbf..8c0d4831 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -179,12 +179,13 @@ function updateActivePort() { console.error("Can't get pool.config.daemon.activePort value"); return; } - if (global.config.daemon.activePort && global.config.daemon.activePort !== row.item_value) { + let newActivePort = rows[0].item_value; + if (global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { if (isActivePortUpdateBlocked) { - console.error("Blocked change of active port from " + global.config.daemon.activePort + " to " + row.item_value); + console.error("Blocked change of active port from " + global.config.daemon.activePort + " to " + newActivePort); } else { - console.log("Changing active port from " + global.config.daemon.activePort + " to " + row.item_value); - global.config.daemon.activePort = row.item_value; + console.log("Changing active port from " + global.config.daemon.activePort + " to " + newActivePort); + global.config.daemon.activePort = newActivePort; } } }); From 3509c8703cff0ee0ee23c87144d1544102af63a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Feb 2018 21:25:35 +0100 Subject: [PATCH 0194/2430] Fixed activePort type --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8c0d4831..84c4604b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -179,7 +179,7 @@ function updateActivePort() { console.error("Can't get pool.config.daemon.activePort value"); return; } - let newActivePort = rows[0].item_value; + let newActivePort = parseInt(rows[0].item_value); if (global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { if (isActivePortUpdateBlocked) { console.error("Blocked change of active port from " + global.config.daemon.activePort + " to " + newActivePort); From 86fe1b3817d22d8131df87c3b93e7a0d0f341ffa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 00:38:06 +0100 Subject: [PATCH 0195/2430] Sync activePort --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 84c4604b..9940ff6e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -193,10 +193,11 @@ function updateActivePort() { // templateUpdateReal is only called in master thread function templateUpdateReal() { - global.coinFuncs.getPortBlockTemplate(global.config.daemon.activePort, function (rpcResponse) { + let activePort = global.config.daemon.activePort; + global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; - rpcResponse.port = global.config.daemon.activePort; + rpcResponse.port = activePort; debug(threadName + "New block template found at " + rpcResponse.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); @@ -206,7 +207,7 @@ function templateUpdateReal() { newBlockTemplate(rpcResponse); } } else { - console.error("Block template request failed for " + global.config.daemon.activePort + " port"); + console.error("Block template request failed for " + activePort + " port"); setTimeout(templateUpdateReal, 3000); } }); From 19c0c12f14968a5b52879f84d00cedebd8756058 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 09:34:49 +0100 Subject: [PATCH 0196/2430] Check at least one share after port switch --- lib/pool.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 9940ff6e..ccae9ec1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -281,6 +281,16 @@ function newBlockTemplate(template) { pastBlockTemplates.enq(activeBlockTemplate); } console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); + + if (activeBlockTemplate && activeBlockTemplate.port != template.port && global.config.pool.trustedMiners) { + for (let minerId in activeMiners) { + if (activeMiners.hasOwnProperty(minerId)) { + let miner = activeMiners[minerId]; + if (miner.trust.threshold === 0) miner.trust.threshold = 1; + } + } + } + activeBlockTemplate = new BlockTemplate(template); if (global.config.daemon.port === activeBlockTemplate.port) { anchorBlockHeight = activeBlockTemplate.height; From c6a805aa3b8bfe49ba0be169989b31caa7282959 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 09:38:48 +0100 Subject: [PATCH 0197/2430] Fixed worker first template update --- lib/pool.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ccae9ec1..c8f116d0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -215,11 +215,7 @@ function templateUpdateReal() { // templateUpdate is only called in master thread function templateUpdate(repeating) { - if (!cluster.isMaster) { - console.error("templateUpdate should not be called from a worker thread!"); - return; - } - if (global.config.general.allowStuckPoolKill && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 60*60*1000) { + if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 60*60*1000) { if (global.config.daemon.activePort === global.config.daemon.port) { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " was terminated", @@ -1210,7 +1206,7 @@ if (cluster.isMaster) { } else { setInterval(checkAliveMiners, 30*1000); setInterval(retargetMiners, global.config.pool.retargetTime * 1000); - //templateUpdate(); + templateUpdate(); anchorBlockUpdate(); setInterval(function () { bannedIPs = []; From 6faabb596e4ba39428b9cc2abffb2281548c95bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 10:06:27 +0100 Subject: [PATCH 0198/2430] poolTypeStr and block dump --- debug_scripts/block_dump.js | 33 +++++++++++++++++++++++++++++ lib/local_comms.js | 42 ++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 debug_scripts/block_dump.js diff --git a/debug_scripts/block_dump.js b/debug_scripts/block_dump.js new file mode 100644 index 00000000..6c413852 --- /dev/null +++ b/debug_scripts/block_dump.js @@ -0,0 +1,33 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +comms = require('../lib/local_comms'); +global.database = new comms(); +global.database.initEnv(); +global.database.lockBlock(argv.blockID); + + 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()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.Block.decode(data); + console.log(JSON.stringify(blockData)) + }); + } + cursor.close(); + } + + txn.commit(); + +process.exit(); \ No newline at end of file diff --git a/lib/local_comms.js b/lib/local_comms.js index 5176cb6a..1b06dbb3 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -3,6 +3,20 @@ let range = require('range'); let debug = require('debug')('db'); let async = require('async'); +function poolTypeStr(poolType) { + switch (poolType) { + case global.protos.POOLTYPE.PPLNS: + return 'pplns'; + case global.protos.POOLTYPE.PPS: + return 'pps'; + case global.protos.POOLTYPE.SOLO: + return 'solo'; + default: + console.error("Unknown poolType: " + poolType.toString()); + return 'pplns'; + } +} + function Database(){ this.lmdb = require('node-lmdb'); this.env = null; @@ -182,20 +196,6 @@ function Database(){ callback(true); };*/ - this.poolTypeStr = function(poolType) { - switch (poolType) { - case global.protos.POOLTYPE.PPLNS: - return 'pplns'; - case global.protos.POOLTYPE.PPS: - return 'pps'; - case global.protos.POOLTYPE.SOLO: - return 'solo'; - default: - console.error("Unknown poolType: " + poolType.toString()); - return 'pplns'; - } - }; - this.storeBulkShares = function(shareObject) { let cachedData = { global_stats2: { totalHashes: 0, roundHashes: 0 } @@ -218,7 +218,7 @@ function Database(){ let minerIDWithIdentifier = minerID + "_" + share.identifier; let port_suffix = typeof(share.port) !== 'undefined' ? "_" + share.port.toString() : ""; let global_stats = "global_stats2" + port_suffix; - let stats_type = this.poolTypeStr(share.poolType) + "_stats2" + port_suffix; + let stats_type = poolTypeStr(share.poolType) + "_stats2" + port_suffix; if (!(global_stats in cachedData)) { cachedData[global_stats] = { totalHashes: 0, roundHashes: 0 }; } @@ -421,17 +421,17 @@ function Database(){ blockDataDecoded.value = header.reward; //blockData = global.database.calculateShares(blockDataDecoded, blockId); let port_str = "_" + global.config.daemon.port.toString(); - if (global.database.getCache(this.poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str) === false) { + if (global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str) === false) { port_str = ""; } - let shares = global.database.getCache(this.poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; + let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.Block.encode(blockDataDecoded); let txn = global.database.env.beginTxn(); txn.putBinary(global.database.blockDB, blockId, blockData); txn.commit(); global.database.incrementCacheData('global_stats2' + port_str, [{location: 'roundHashes', value: false}]); - global.database.incrementCacheData(this.poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData(poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); return callback(true); }); } catch (e) { @@ -468,7 +468,7 @@ function Database(){ blockDataDecoded.pay_value = 0; //blockData = global.database.calculateShares(blockDataDecoded, blockId); let port_str = "_" + blockDataDecoded.port.toString(); - let shares = global.database.getCache(this.poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; + let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.AltBlock.encode(blockDataDecoded); let txn = global.database.env.beginTxn(); @@ -479,7 +479,7 @@ function Database(){ txn.putBinary(global.database.altblockDB, blockId, blockData); txn.commit(); global.database.incrementCacheData('global_stats2' + port_str, [{location: 'roundHashes', value: false}]); - global.database.incrementCacheData(this.poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData(poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); return callback(true); }); } catch (e) { @@ -706,7 +706,7 @@ function Database(){ if (oldestLockedBlockHeight !== null) { console.log("Got the oldest locked block in the system at height: " + oldestLockedBlockHeight.toString()); } else { - console.log("There are no locked blocks in the system. Woohoo!"); + console.log("There are no locked blocks in the system. Woohoo!"); } return oldestLockedBlockHeight; }; From 4292cd04a4a5464750fa3a722c010060d4ca7e01 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 10:12:35 +0100 Subject: [PATCH 0199/2430] Removed old line --- debug_scripts/block_dump.js | 1 - 1 file changed, 1 deletion(-) diff --git a/debug_scripts/block_dump.js b/debug_scripts/block_dump.js index 6c413852..0f2e5466 100644 --- a/debug_scripts/block_dump.js +++ b/debug_scripts/block_dump.js @@ -14,7 +14,6 @@ let comms; comms = require('../lib/local_comms'); global.database = new comms(); global.database.initEnv(); -global.database.lockBlock(argv.blockID); let txn = global.database.env.beginTxn({readOnly: true}); From 714908095ef311141f98dfa0447cde659e0e80b6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 10:13:29 +0100 Subject: [PATCH 0200/2430] Add key to log --- debug_scripts/block_dump.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_scripts/block_dump.js b/debug_scripts/block_dump.js index 0f2e5466..f3b75111 100644 --- a/debug_scripts/block_dump.js +++ b/debug_scripts/block_dump.js @@ -21,7 +21,7 @@ global.database.initEnv(); for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let blockData = global.protos.Block.decode(data); - console.log(JSON.stringify(blockData)) + console.log(key + ": " + JSON.stringify(blockData)) }); } cursor.close(); From 342b629593014c2eee9ef70e67d723af55bdb077 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 10:15:03 +0100 Subject: [PATCH 0201/2430] Altblock dump --- debug_scripts/altblock_dump.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 debug_scripts/altblock_dump.js diff --git a/debug_scripts/altblock_dump.js b/debug_scripts/altblock_dump.js new file mode 100644 index 00000000..1566bddb --- /dev/null +++ b/debug_scripts/altblock_dump.js @@ -0,0 +1,32 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +comms = require('../lib/local_comms'); +global.database = new comms(); +global.database.initEnv(); + + 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()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + console.log(key + ": " + JSON.stringify(blockData)) + }); + } + cursor.close(); + } + + txn.commit(); + +process.exit(); \ No newline at end of file From ff62b5fcc39c57874944be393ab64f47ffb3526d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 11:06:11 +0100 Subject: [PATCH 0202/2430] Debug block adding --- debug_scripts/block_add.js | 7 ++-- debug_scripts/block_add2.js | 64 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 debug_scripts/block_add2.js diff --git a/debug_scripts/block_add.js b/debug_scripts/block_add.js index d1fa2a70..9fceec92 100644 --- a/debug_scripts/block_add.js +++ b/debug_scripts/block_add.js @@ -67,7 +67,7 @@ global.mysql.query("SELECT * FROM config").then(function (rows) { optional int64 value = 8; } */ - let invalidBlockProto = global.protos.Block.encode({ + /*let invalidBlockProto = global.protos.Block.encode({ hash: "88cf2c37e1e4e8a273cbe3ec502b6975fd6c4ebe1e8889ad9d5e53a5e9cde007", difficulty: 1002932, shares: 0, @@ -87,5 +87,6 @@ global.mysql.query("SELECT * FROM config").then(function (rows) { console.log(error); console.log(JSON.stringify(response)); console.log(JSON.stringify(body)); - }); -}); \ No newline at end of file + });*/ +}); + diff --git a/debug_scripts/block_add2.js b/debug_scripts/block_add2.js new file mode 100644 index 00000000..ac5bb95a --- /dev/null +++ b/debug_scripts/block_add2.js @@ -0,0 +1,64 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); +const request = require('request'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +let coinInc; + + +// Config Table Layout +// . + +global.mysql.query("SELECT * FROM config").then(function (rows) { + rows.forEach(function (row){ + if (!global.config.hasOwnProperty(row.module)){ + global.config[row.module] = {}; + } + if (global.config[row.module].hasOwnProperty(row.item)){ + return; + } + switch(row.item_type){ + case 'int': + global.config[row.module][row.item] = parseInt(row.item_value); + break; + case 'bool': + global.config[row.module][row.item] = (row.item_value === "true"); + break; + case 'string': + global.config[row.module][row.item] = row.item_value; + break; + case 'float': + global.config[row.module][row.item] = parseFloat(row.item_value); + break; + } + }); +}).then(function(){ + global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; + coinInc = require("." + global.config.coin.funcFile); + global.coinFuncs = new coinInc(); + comms = require('../lib/remote_comms'); + global.database = new comms(); + global.database.initEnv(); + global.coinFuncs.blockedAddresses.push(global.config.pool.address); + global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); +}).then(function(){ + /*global.database.storeBlock(1509990, global.protos.Block.encode({ + hash: "a677ed7fb05ecb82bdb02f0cbb0f3099914392991225704559616658d7661748", + difficulty: 115634200078, + shares: 0, + timestamp: 1518686098779, + poolType: global.protos.POOLTYPE.PPLNS, + unlocked: false, + valid: true + }));*/ + +}); From b4a49d24631db42b4f633169f7831ee4cc47d5c7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 11:16:34 +0100 Subject: [PATCH 0203/2430] Switched to local comms --- debug_scripts/block_add2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug_scripts/block_add2.js b/debug_scripts/block_add2.js index ac5bb95a..43654517 100644 --- a/debug_scripts/block_add2.js +++ b/debug_scripts/block_add2.js @@ -45,7 +45,7 @@ global.mysql.query("SELECT * FROM config").then(function (rows) { global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; coinInc = require("." + global.config.coin.funcFile); global.coinFuncs = new coinInc(); - comms = require('../lib/remote_comms'); + comms = require('../lib/local_comms'); global.database = new comms(); global.database.initEnv(); global.coinFuncs.blockedAddresses.push(global.config.pool.address); From 714c927eee5ae815c776607127da37c36a2e03c5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 11:19:50 +0100 Subject: [PATCH 0204/2430] Fixed store blocks --- 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 1b06dbb3..2a9e2490 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -424,7 +424,7 @@ function Database(){ if (global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str) === false) { port_str = ""; } - let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; + let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str); blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.Block.encode(blockDataDecoded); let txn = global.database.env.beginTxn(); @@ -468,7 +468,7 @@ function Database(){ blockDataDecoded.pay_value = 0; //blockData = global.database.calculateShares(blockDataDecoded, blockId); let port_str = "_" + blockDataDecoded.port.toString(); - let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str).roundHashes; + let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str); blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.AltBlock.encode(blockDataDecoded); let txn = global.database.env.beginTxn(); From 183d8cba89006ca21008c764f5dd1695bfb0da9b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 12:14:08 +0100 Subject: [PATCH 0205/2430] alt block add test --- debug_scripts/altblock_add.js | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 debug_scripts/altblock_add.js diff --git a/debug_scripts/altblock_add.js b/debug_scripts/altblock_add.js new file mode 100644 index 00000000..3d5b0d40 --- /dev/null +++ b/debug_scripts/altblock_add.js @@ -0,0 +1,68 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); +const request = require('request'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +let coinInc; + + +// Config Table Layout +// . + +global.mysql.query("SELECT * FROM config").then(function (rows) { + rows.forEach(function (row){ + if (!global.config.hasOwnProperty(row.module)){ + global.config[row.module] = {}; + } + if (global.config[row.module].hasOwnProperty(row.item)){ + return; + } + switch(row.item_type){ + case 'int': + global.config[row.module][row.item] = parseInt(row.item_value); + break; + case 'bool': + global.config[row.module][row.item] = (row.item_value === "true"); + break; + case 'string': + global.config[row.module][row.item] = row.item_value; + break; + case 'float': + global.config[row.module][row.item] = parseFloat(row.item_value); + break; + } + }); +}).then(function(){ + global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; + coinInc = require("." + global.config.coin.funcFile); + global.coinFuncs = new coinInc(); + comms = require('../lib/local_comms'); + global.database = new comms(); + global.database.initEnv(); + global.coinFuncs.blockedAddresses.push(global.config.pool.address); + global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); +}).then(function(){ + let time_now = Date.now(); + /*global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ + hash: "517c5c49137d2a7b7c5c58297bea10940bbd5ba23d77d589069b16cadec95a03", + difficulty: 2149619256, + shares: 0, + timestamp: time_now, + poolType: global.protos.POOLTYPE.PPLNS, + unlocked: false, + valid: true, + port: 26968, + height: 157909, + anchor_height: 1509989 + }));*/ + +}); From a47553ded3ac63515f26148c7627d976a71883cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 12:17:42 +0100 Subject: [PATCH 0206/2430] Fixed ID name --- lib/local_comms.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 2a9e2490..983ee3ba 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -472,9 +472,9 @@ function Database(){ blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.AltBlock.encode(blockDataDecoded); 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; + while (txn.getBinary(global.database.altblockDB, blockId) !== null) { + 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 8a039e6b0a5108db43e9917579897b977658a454 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 12:46:15 +0100 Subject: [PATCH 0207/2430] Added protection against duplicate blocks and altblocks --- lib/blockManager.js | 1 + lib/local_comms.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 009c297a..f5bb9d0d 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -586,6 +586,7 @@ function initial_sync() { // Scan every 120 seconds for invalidated blocks setInterval(blockUnlocker, 120000); 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."); }); diff --git a/lib/local_comms.js b/lib/local_comms.js index 983ee3ba..8a191047 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -428,6 +428,12 @@ function Database(){ blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.Block.encode(blockDataDecoded); let txn = global.database.env.beginTxn(); + // this is very rare case if block with smae height is found by several leafs (one that is stored later should be orphan with 0 reward) + if (txn.getBinary(global.database.blockDB, blockId) !== null) { + txn.abort(); + console.error("Can't store already stored block with " + blockId.toString() + " key and " + header.reward.toString() + " value"); + return callback(true); + } txn.putBinary(global.database.blockDB, blockId, blockData); txn.commit(); global.database.incrementCacheData('global_stats2' + port_str, [{location: 'roundHashes', value: false}]); @@ -471,6 +477,10 @@ function Database(){ let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str); blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.AltBlock.encode(blockDataDecoded); + if (global.database.isAltBlockInDB(blockDataDecoded.port, blockDataDecoded.height)) { + console.error("Can't store already stored altblock with " + blockDataDecoded.port.toString() + " port and " + blockDataDecoded.height.toString() + " height and " + header.reward.toString() + " value"); + 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"); @@ -562,6 +572,24 @@ function Database(){ return blockList; }; + 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; + 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.port === port && blockData.height === height){ + isBlockFound = true; + } + }); + } + cursor.close(); + txn.commit(); + return isBlockFound; + }; + this.unlockBlock = function(blockHex){ this.refreshEnv(); let txn = this.env.beginTxn(); From 3ed3f558d08cb6d33569f6e910a90f562986fa98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 12:49:23 +0100 Subject: [PATCH 0208/2430] Added more logs for altblock payments --- lib/blockManager.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index f5bb9d0d..8d608f3b 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -468,7 +468,11 @@ function altblockUnlocker() { global.database.invalidateAltBlock(block.id); console.log("Invalidating altblock from " + block.port + " port for " + block.height + " due to being an orphan block"); } else { - if (block.pay_value !== 0) altblockPayments(block); + if (block.pay_value !== 0) { + altblockPayments(block); + } else { + console.log("Waiting for altblock with " + block.port + " port and " + block.height + " height pay value"); + } } }); From e597104d6d1b4d9feb0d8d14c51032262d24515c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 13:01:47 +0100 Subject: [PATCH 0209/2430] Added alt block unlocker on timer --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 8d608f3b..99f03ea7 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -590,6 +590,7 @@ function initial_sync() { // Scan every 120 seconds for invalidated blocks setInterval(blockUnlocker, 120000); blockUnlocker(); + setInterval(altblockUnlocker, 120000); 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 34c1dab8faea0a65714f7fa99e9b2b37c048959f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 13:07:52 +0100 Subject: [PATCH 0210/2430] Fixed missing func stuff --- lib/blockManager.js | 2 +- lib/coins/xmr.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 99f03ea7..e3ad76bc 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -514,7 +514,7 @@ function altblockPayments(block) { switch (block.poolType) { case global.protos.POOLTYPE.PPLNS: global.coinFuncs.getPortBlockHeaderByHash(block.port, block.hash, function (err, header) { - if (err === null){ + 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){ calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3d59c2cc..90c13162 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -52,8 +52,8 @@ function Coin(data){ this.niceHashDiff = 400000; - this.getBlockHeaderByID = function(blockId, callback){ - global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { + this.getPortBlockHeaderByID = function(port, blockId, callback){ + global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { if (body.hasOwnProperty('result')){ return callback(null, body.result.block_header); } else { @@ -63,6 +63,10 @@ function Coin(data){ }); }; + this.getBlockHeaderByID = function(blockId, callback){ + return this.getPortBlockHeaderByID(global.config.daemon.port, blockId, callback); + }; + this.getPortBlockHeaderByHash = function(port, blockHash, callback){ global.support.rpcPortDaemon(port, 'getblockheaderbyhash', {"hash": blockHash}, function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ From a3932d8af63c86463b6d8769e33fb491fb199c6f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 13:10:41 +0100 Subject: [PATCH 0211/2430] Added more logs for duplicate blocks --- 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 8a191047..46eeefc0 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -431,7 +431,7 @@ function Database(){ // this is very rare case if block with smae height is found by several leafs (one that is stored later should be orphan with 0 reward) if (txn.getBinary(global.database.blockDB, blockId) !== null) { txn.abort(); - console.error("Can't store already stored block with " + blockId.toString() + " key and " + header.reward.toString() + " value"); + console.error("Can't store already stored block with " + blockId.toString() + " key and " + header.reward.toString() + " value: " + JSON.stringify(blockDataDecoded)); return callback(true); } txn.putBinary(global.database.blockDB, blockId, blockData); @@ -478,7 +478,7 @@ function Database(){ blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.AltBlock.encode(blockDataDecoded); if (global.database.isAltBlockInDB(blockDataDecoded.port, blockDataDecoded.height)) { - console.error("Can't store already stored altblock with " + blockDataDecoded.port.toString() + " port and " + blockDataDecoded.height.toString() + " height and " + header.reward.toString() + " value"); + console.error("Can't store already stored altblock with " + blockDataDecoded.port.toString() + " port and " + blockDataDecoded.height.toString() + " height and " + header.reward.toString() + " value: " + JSON.stringify(blockDataDecoded)); return callback(true); } let txn = global.database.env.beginTxn(); From 99c875c4d4a80d002d774ba7401572ef420a0e23 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 13:25:31 +0100 Subject: [PATCH 0212/2430] Added extra protection agantst SQL DB fuckups --- lib/blockManager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e3ad76bc..e5532bef 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -108,7 +108,10 @@ let balanceQueue = async.queue(function (task, callback) { }, 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 () { + 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); }); } From 294aab33f45523b1467a19be14f595efbf196d44 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 15 Feb 2018 15:45:03 +0100 Subject: [PATCH 0213/2430] Added API support for altblocks --- lib/api.js | 12 ++++++++ lib/local_comms.js | 74 ++++++++++++++++++++++++++++++++++++---------- lib/support.js | 11 +++++++ 3 files changed, 82 insertions(+), 15 deletions(-) diff --git a/lib/api.js b/lib/api.js index 39ebc177..7a7f66cf 100644 --- a/lib/api.js +++ b/lib/api.js @@ -279,12 +279,24 @@ app.get('/pool/blocks/:pool_type', function (req, res) { res.json(global.database.getBlockList(req.params.pool_type).slice(page*limit, (page + 1) * limit)); }); +app.get('/pool/altblocks/:pool_type', 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)); +}); + app.get('/pool/blocks', 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)); }); +app.get('/pool/altblocks', 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)); +}); + app.get('/pool/payments/:pool_type', function (req, res) { let pool_type = req.params.pool_type; let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; diff --git a/lib/local_comms.js b/lib/local_comms.js index 46eeefc0..886c41a5 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -123,21 +123,7 @@ function Database(){ */ cursor.getCurrentBinary(function (key, data) { // jshint ignore:line let blockData = global.protos.Block.decode(data); - let poolType; - switch (blockData.poolType){ - case (global.protos.POOLTYPE.PPLNS): - poolType = 'pplns'; - break; - case (global.protos.POOLTYPE.SOLO): - poolType = 'solo'; - break; - case (global.protos.POOLTYPE.PPS): - poolType = 'pps'; - break; - default: - poolType = 'Unknown'; - break; - } + let poolType = poolTypeStr(blockData.poolType); if (blockData.poolType === pool_type || pool_type === false) { response.push({ ts: blockData.timestamp, @@ -161,6 +147,64 @@ function Database(){ } }; + this.getAltBlockList = function(pool_type){ + debug("Getting block list"); + switch (pool_type) { + case 'pplns': + pool_type = global.protos.POOLTYPE.PPLNS; + break; + case 'pps': + pool_type = global.protos.POOLTYPE.PPS; + break; + case 'solo': + pool_type = global.protos.POOLTYPE.SOLO; + break; + default: + pool_type = false; + } + 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.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; + */ + 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) { + response.push({ + ts: blockData.timestamp, + hash: blockData.hash, + diff: blockData.difficulty, + shares: blockData.shares, + height: blockData.height, + valid: blockData.valid, + unlocked: blockData.unlocked, + pool_type: poolType, + value: blockData.value, + pay_value: blockData.pay_value, + port: blockData.port + }); + } + }); + } + cursor.close(); + txn.abort(); + return response.sort(global.support.altblockCompare); + } catch (e){ + return response; + } + }; + /*this.storeShare = function(blockId, shareData, callback){ // This function needs the blockID in question, and the shareData in binary format. // The binary data should be packed as per the data.proto Share protobuf format. diff --git a/lib/support.js b/lib/support.js index bc9d5fbc..bf6f1ba4 100644 --- a/lib/support.js +++ b/lib/support.js @@ -199,6 +199,17 @@ function blockCompare(a, b) { return 0; } +function altblockCompare(a, b) { + if (a.timestamp < b.timestamp) { + return 1; + } + + if (a.timestamp > b.timestamp) { + return -1; + } + return 0; +} + function tsCompare(a, b) { if (a.ts < b.ts) { return 1; From 58159811a0561c5b50f20cc84d6685bad275f70f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Feb 2018 09:17:43 +0100 Subject: [PATCH 0214/2430] Multiple wallet support --- lib/data.proto | 2 ++ lib/support.js | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/data.proto b/lib/data.proto index 5f973c01..73d5f09f 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -65,4 +65,6 @@ message AltBlock { required int32 anchor_height = 10; optional int64 value = 11; optional int64 pay_value = 12; + optional string pay_stage = 13; + optional string pay_status = 14; } diff --git a/lib/support.js b/lib/support.js index bf6f1ba4..c016f2b7 100644 --- a/lib/support.js +++ b/lib/support.js @@ -104,7 +104,7 @@ function sendEmail(toAddress, subject, body, wallet){ } } -function jsonRequest(host, port, data, callback, path) { +function jsonRequest(host, port, data, is_wallet, callback, path) { path = path || 'json_rpc'; let uri; if (global.config.rpc.https) { @@ -117,7 +117,7 @@ function jsonRequest(host, port, data, callback, path) { client.headers["Content-Type"] = "application/json"; client.headers["Content-Length"] = data.length; client.headers["Accept"] = "application/json"; - if (global.config.payout.rpcPasswordEnabled && host === global.config.wallet.address && port === global.config.wallet.port){ + if (is_wallet && global.config.payout.rpcPasswordEnabled && global.config.payout.rpcPasswordPath){ fs.readFile(global.config.payout.rpcPasswordPath, 'utf8', function(err, data){ if (err){ console.error("RPC password enabled, unable to read the file due to: " + JSON.stringify(err)); @@ -159,8 +159,20 @@ function rpc(host, port, method, params, callback) { method: method, params: params }; - return jsonRequest(host, port, data, callback); + return jsonRequest(host, port, data, false, callback); } + +function rpc_wallet(host, port, method, params, callback) { + + let data = { + id: "0", + jsonrpc: "2.0", + method: method, + params: params + }; + return jsonRequest(host, port, data, true, callback); +} + function formatDate(date) { // Date formatting for MySQL date time fields. return moment(date).format('YYYY-MM-DD HH:mm:ss'); @@ -230,7 +242,10 @@ module.exports = function () { rpc(global.config.daemon.address, port, method, params, callback); }, rpcWallet: function (method, params, callback) { - rpc(global.config.wallet.address, global.config.wallet.port, method, params, callback); + rpc_wallet(global.config.wallet.address, global.config.wallet.port, method, params, callback); + }, + rpcPortWallet: function (port, method, params, callback) { + rpc_wallet(global.config.wallet.address, port, method, params, callback); }, jsonRequest: jsonRequest, circularBuffer: circularBuffer, From 1da5e92adf3313cf04be5234b5af642a9915b7bf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Feb 2018 08:22:59 +0100 Subject: [PATCH 0215/2430] Added separate passwords for other wallets --- lib/local_comms.js | 10 ++++++++++ lib/support.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 886c41a5..45130e86 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -578,6 +578,16 @@ function Database(){ txn.commit(); }; + 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; + blockData.pay_status = pay_status; + txn.putBinary(this.altblockDB, blockId, global.protos.AltBlock.encode(blockData)); + txn.commit(); + }; + this.getValidLockedBlocks = function(){ this.refreshEnv(); let txn = this.env.beginTxn({readOnly: true}); diff --git a/lib/support.js b/lib/support.js index c016f2b7..8d513259 100644 --- a/lib/support.js +++ b/lib/support.js @@ -118,7 +118,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path) { client.headers["Content-Length"] = data.length; client.headers["Accept"] = "application/json"; if (is_wallet && global.config.payout.rpcPasswordEnabled && global.config.payout.rpcPasswordPath){ - fs.readFile(global.config.payout.rpcPasswordPath, 'utf8', function(err, data){ + fs.readFile(port === global.config.daemon.port ? global.config.payout.rpcPasswordPath : global.config.payout["rpcPasswordPath" + port.toString()], 'utf8', function(err, data){ if (err){ console.error("RPC password enabled, unable to read the file due to: " + JSON.stringify(err)); return; From f6cef98bed03197f8a7ac0862268c6e63be05713 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Feb 2018 08:38:40 +0100 Subject: [PATCH 0216/2430] Drcreased RPC timeout to some more realistic value --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 8d513259..df1a3e2c 100644 --- a/lib/support.js +++ b/lib/support.js @@ -113,7 +113,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path) { uri = "http://" + host + ":" + port + "/"; } debug("JSON URI: " + uri + path + " Args: " + JSON.stringify(data)); - let client = requestJson.createClient(uri, {timeout: 300000}); + let client = requestJson.createClient(uri, {timeout: 30*1000}); client.headers["Content-Type"] = "application/json"; client.headers["Content-Length"] = data.length; client.headers["Accept"] = "application/json"; From 7e9ee298be59c42eac72fa2d02a4743683675c98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Feb 2018 18:57:13 +0100 Subject: [PATCH 0217/2430] Added code to update alt block pay value --- lib/local_comms.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index 45130e86..108c5812 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -588,6 +588,15 @@ function Database(){ txn.commit(); }; + 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; + txn.putBinary(this.altblockDB, blockId, global.protos.AltBlock.encode(blockData)); + txn.commit(); + }; + this.getValidLockedBlocks = function(){ this.refreshEnv(); let txn = this.env.beginTxn({readOnly: true}); From 0755a467a5f945d96f7aad2a58814edccec20022 Mon Sep 17 00:00:00 2001 From: adaxi Date: Sun, 18 Feb 2018 22:08:01 +0100 Subject: [PATCH 0218/2430] Send an email when not able to get last block header --- lib/worker.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index cb0b499b..0aec1ce7 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -521,6 +521,30 @@ function monitorNodes() { }); } +function monitorNodes() { + global.coinFuncs.getLastBlockHeader((err, block) => { + if (err !== null) { + return global.support.sendEmail( + global.config.general.adminEmail, + 'Failed to query daemon for last block header', + `The worker failed to return last block header. Please verify if the daemon is running properly.` + ); + } + const sql = 'SELECT blockID, hostname, ip FROM pools WHERE last_checkin > DATE_SUB(NOW(), INTERVAL 30 MINUTE)'; + global.mysql.query(sql).then(pools => { + pools.forEach(({ blockID, hostname, ip }) => { + if (blockID < block.height - 3) { + global.support.sendEmail( + global.config.general.adminEmail, + 'Pool server is behind in blocks', + `The pool server: ${hostname} with IP: ${ip} is ${(block.height - blockID)} blocks behind.` + ); + } + }) + }); + }); +} + updateShareStats(); updateBlockHeader(); updatePoolStats(); From c9129c14b0026f508d85d7916262c91d5440c5de Mon Sep 17 00:00:00 2001 From: adaxi Date: Sun, 18 Feb 2018 22:08:59 +0100 Subject: [PATCH 0219/2430] Remove old function --- lib/worker.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 0aec1ce7..0723bc04 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -504,23 +504,6 @@ function updateWalletStats() { } -function monitorNodes() { - global.mysql.query("SELECT blockID, hostname, ip FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { - global.coinFuncs.getLastBlockHeader(function (err, block) { - if (err !== null){ - console.error("Issue in getting block header. Skipping node monitor"); - return; - } - rows.forEach(function (row) { - if (row.blockID < block.height - 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"); - } - } - ); - }); - }); -} - function monitorNodes() { global.coinFuncs.getLastBlockHeader((err, block) => { if (err !== null) { From d7611417866b1637dd3d71e6987d87c88e81dac0 Mon Sep 17 00:00:00 2001 From: adaxi Date: Sun, 18 Feb 2018 22:33:23 +0100 Subject: [PATCH 0220/2430] Avoid spamming the administrator when the daemon is stuck. --- lib/worker.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 0723bc04..1a0e5459 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -504,13 +504,27 @@ function updateWalletStats() { } +let lastBlockCheckIsOk = true; function monitorNodes() { global.coinFuncs.getLastBlockHeader((err, block) => { if (err !== null) { - return global.support.sendEmail( + if (lastBlockCheckIsOk) { + lastBlockCheckIsOk = false; + global.support.sendEmail( + global.config.general.adminEmail, + 'Failed to query daemon for last block header', + `The worker failed to return last block header. Please verify if the daemon is running properly.` + ); + } + return + } + if (!lastBlockCheckIsOk) { + lastBlockCheckIsOk = true; + global.support.sendEmail( global.config.general.adminEmail, - 'Failed to query daemon for last block header', - `The worker failed to return last block header. Please verify if the daemon is running properly.` + 'Quering daemon 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. + The issue seems to be solved now.` ); } const sql = 'SELECT blockID, hostname, ip FROM pools WHERE last_checkin > DATE_SUB(NOW(), INTERVAL 30 MINUTE)'; @@ -525,6 +539,7 @@ function monitorNodes() { } }) }); + }); } From ae0d306842532f6a317a871deb50934810711938 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Feb 2018 11:11:59 +0100 Subject: [PATCH 0221/2430] Reject PaymentID for integrated address --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cd0c0c73..667e7dbb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -319,7 +319,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.error = "Too many options in the login field"; this.valid_miner = false; } - if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { + if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[0].length === 95 && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { this.paymentID = addressSplit[1]; this.payout = this.address + "." + this.paymentID; } else if (typeof(addressSplit[1]) !== 'undefined') { From 884b89547b8ced8ee52857c30ecceae79f437b35 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Feb 2018 11:14:27 +0100 Subject: [PATCH 0222/2430] reject PaymentID for integrated address --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c8f116d0..341e3b93 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -388,7 +388,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.error = "Too many options in the login field"; this.valid_miner = false; } - if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { + if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[0].length === 95 && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { this.paymentID = addressSplit[1]; this.payout = this.address + "." + this.paymentID; } else if (typeof(addressSplit[1]) !== 'undefined') { From 849d9ad74b2e667a6fae2039ad62d1ba3cbfe551 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Feb 2018 16:57:32 +0100 Subject: [PATCH 0223/2430] Added more generalized address check --- lib/coins/xmr.js | 6 ++++++ lib/pool.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 90c13162..91b9ed90 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -123,6 +123,12 @@ function Coin(data){ return cnUtil.address_decode_integrated(address) === this.intPrefix; }; + 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); + return cnUtil.address_decode(address) === this.prefix; + }; + this.convertBlob = function(blobBuffer){ return cnUtil.convert_blob(blobBuffer); }; diff --git a/lib/pool.js b/lib/pool.js index 341e3b93..77fc6849 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -388,7 +388,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.error = "Too many options in the login field"; this.valid_miner = false; } - if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[0].length === 95 && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { + if (typeof(addressSplit[1]) !== 'undefined' && global.coinFuncs.validatePlainAddress(addressSplit[0].length) && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { this.paymentID = addressSplit[1]; this.payout = this.address + "." + this.paymentID; } else if (typeof(addressSplit[1]) !== 'undefined') { From 2d04f962b5c68b648a75cab3b42d9cd87231341a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Feb 2018 17:17:34 +0100 Subject: [PATCH 0224/2430] Added support for altblockManager --- init.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.js b/init.js index 1a2f2577..d4dc05d1 100644 --- a/init.js +++ b/init.js @@ -80,6 +80,9 @@ global.mysql.query("SELECT * FROM config").then(function (rows) { case 'blockManager': require('./lib/blockManager.js'); break; + case 'altblockManager': + require('./lib/altblockManager.js'); + break; case 'payments': require('./lib/payments.js'); break; From 18a97bf3dc41b2aa99a1c23c30b9bd66bf89169f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Feb 2018 17:53:58 +0100 Subject: [PATCH 0225/2430] activePort manipulations --- lib/pool.js | 7 +------ lib/support.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 77fc6849..542d8ff1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -174,12 +174,7 @@ let isActivePortUpdateBlocked = false; // global.config.daemon.activePort is only updated in master thread function updateActivePort() { - global.mysql.query("SELECT item_value FROM pool.config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { - if (rows.length != 1) { - console.error("Can't get pool.config.daemon.activePort value"); - return; - } - let newActivePort = parseInt(rows[0].item_value); + getActivePort(function (newActivePort) { if (global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { if (isActivePortUpdateBlocked) { console.error("Blocked change of active port from " + global.config.daemon.activePort + " to " + newActivePort); diff --git a/lib/support.js b/lib/support.js index df1a3e2c..c2e480c6 100644 --- a/lib/support.js +++ b/lib/support.js @@ -173,6 +173,20 @@ function rpc_wallet(host, port, method, params, callback) { return jsonRequest(host, port, data, true, callback); } +function getActivePort(callback) { + global.mysql.query("SELECT item_value FROM pool.config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { + if (rows.length != 1) { + console.error("Can't get pool.config.daemon.activePort value"); + return; + } + callback(parseInt(rows[0].item_value)); + }); +} + +function setActivePort(activePort) { + global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort'", [activePort]); +} + function formatDate(date) { // Date formatting for MySQL date time fields. return moment(date).format('YYYY-MM-DD HH:mm:ss'); @@ -257,6 +271,8 @@ module.exports = function () { formatDateFromSQL: formatDateFromSQL, blockCompare: blockCompare, sendEmail: sendEmail, - tsCompare: tsCompare + tsCompare: tsCompare, + getActivePort: getActivePort, + setActivePort: setActivePort }; }; From 4c1b301874d865726ba8c7a51d13e7e3eaa23d02 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 19 Feb 2018 17:56:51 +0100 Subject: [PATCH 0226/2430] Fixed scope --- 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 542d8ff1..6fd9fbd9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -174,7 +174,7 @@ let isActivePortUpdateBlocked = false; // global.config.daemon.activePort is only updated in master thread function updateActivePort() { - getActivePort(function (newActivePort) { + global.support.getActivePort(function (newActivePort) { if (global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { if (isActivePortUpdateBlocked) { console.error("Blocked change of active port from " + global.config.daemon.activePort + " to " + newActivePort); diff --git a/lib/support.js b/lib/support.js index c2e480c6..2bc79b9a 100644 --- a/lib/support.js +++ b/lib/support.js @@ -184,6 +184,7 @@ function getActivePort(callback) { } function setActivePort(activePort) { + console.log("Setting activePort to " + activePort.toString() + " value"); global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort'", [activePort]); } From da6aad5238f526eea2d703f1101482653c65df69 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Feb 2018 10:13:42 +0100 Subject: [PATCH 0227/2430] Smooth stats transition to new schema --- lib/local_comms.js | 51 +++++++++++++++++++++++----------------------- lib/worker.js | 27 ++++++++++++++++++------ 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 108c5812..f41b632c 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -260,22 +260,27 @@ function Database(){ minerID = minerID + '.' + share.paymentID; } let minerIDWithIdentifier = minerID + "_" + share.identifier; - let port_suffix = typeof(share.port) !== 'undefined' ? "_" + share.port.toString() : ""; - let global_stats = "global_stats2" + port_suffix; - let stats_type = poolTypeStr(share.poolType) + "_stats2" + port_suffix; - if (!(global_stats in cachedData)) { - cachedData[global_stats] = { totalHashes: 0, roundHashes: 0 }; + let port_suffix = typeof(share.port) !== 'undefined' && share.port !== global.config.daemon.port ? "_" + share.port.toString() : ""; + let global_stats1 = "global_stats2"; + let stats_type1 = poolTypeStr(share.poolType) + "_stats2"; + if (!(stats_type1 in cachedData)) { + cachedData[stats_type1] = { totalHashes: 0, roundHashes: 0 }; } - if (!(stats_type in cachedData)) { - cachedData[stats_type] = { totalHashes: 0, roundHashes: 0 }; - } - if (typeof(share.port) !== 'undefined') { - cachedData["global_stats2"].totalHashes += share.shares; + 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; + } 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].roundHashes += share.shares; + cachedData[stats_type1].totalHashes += share.shares; + cachedData[stats_type2].roundHashes += share.shares; } - cachedData[global_stats].totalHashes += share.shares; - cachedData[global_stats].roundHashes += share.shares; - cachedData[stats_type].totalHashes += share.shares; - cachedData[stats_type].roundHashes += share.shares; if (!cachedData.hasOwnProperty(minerID)) { cachedData[minerID] = {totalHashes: 0, goodShares: 0}; } @@ -464,11 +469,7 @@ function Database(){ } blockDataDecoded.value = header.reward; //blockData = global.database.calculateShares(blockDataDecoded, blockId); - let port_str = "_" + global.config.daemon.port.toString(); - if (global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str) === false) { - port_str = ""; - } - let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str); + let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2"); blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.Block.encode(blockDataDecoded); let txn = global.database.env.beginTxn(); @@ -480,8 +481,8 @@ function Database(){ } txn.putBinary(global.database.blockDB, blockId, blockData); txn.commit(); - global.database.incrementCacheData('global_stats2' + port_str, [{location: 'roundHashes', value: false}]); - global.database.incrementCacheData(poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('global_stats2', [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData(poolTypeStr(blockDataDecoded.poolType) + '_stats2', [{location: 'roundHashes', value: false}]); return callback(true); }); } catch (e) { @@ -517,8 +518,8 @@ function Database(){ blockDataDecoded.value = header.reward; blockDataDecoded.pay_value = 0; //blockData = global.database.calculateShares(blockDataDecoded, blockId); - let port_str = "_" + blockDataDecoded.port.toString(); - let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_str); + let port_suffix = "_" + blockDataDecoded.port.toString(); + let shares = global.database.getCache(poolTypeStr(blockDataDecoded.poolType) + "_stats2" + port_suffix); blockDataDecoded.shares = shares ? shares.roundHashes : 0; blockData = global.protos.AltBlock.encode(blockDataDecoded); if (global.database.isAltBlockInDB(blockDataDecoded.port, blockDataDecoded.height)) { @@ -532,8 +533,8 @@ function Database(){ } txn.putBinary(global.database.altblockDB, blockId, blockData); txn.commit(); - global.database.incrementCacheData('global_stats2' + port_str, [{location: 'roundHashes', value: false}]); - global.database.incrementCacheData(poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_str, [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData('global_stats2' + port_suffix, [{location: 'roundHashes', value: false}]); + global.database.incrementCacheData(poolTypeStr(blockDataDecoded.poolType) + '_stats2' + port_suffix, [{location: 'roundHashes', value: false}]); return callback(true); }); } catch (e) { diff --git a/lib/worker.js b/lib/worker.js index 20f150bd..065fa326 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -317,16 +317,31 @@ function updateShareStats() { function updatePoolStats(poolType) { let cache; + let port_suffix = global.config.daemon.activePort && global.config.daemon.activePort !== global.config.daemon.port ? "_" + global.config.daemon.activePort.toString() : ""; if (typeof(poolType) !== 'undefined') { cache = global.database.getCache(poolType + "_stats"); - let cache2 = global.database.getCache(poolType + "_stats2"); - cache.totalHashes = cache2.totalHashes; - cache.roundHashes = cache2.roundHashes; + 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"); - let cache2 = global.database.getCache("global_stats2"); - cache.totalHashes = cache2.totalHashes; - cache.roundHashes = cache2.roundHashes; + 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; + } } async.series([ function (callback) { From 996f96eb7bef0c540629b2a1c79fbcb401020251 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Feb 2018 11:05:01 +0100 Subject: [PATCH 0228/2430] Fixed plan address validation --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6fd9fbd9..f67b5e5c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -383,7 +383,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.error = "Too many options in the login field"; this.valid_miner = false; } - if (typeof(addressSplit[1]) !== 'undefined' && global.coinFuncs.validatePlainAddress(addressSplit[0].length) && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { + if (typeof(addressSplit[1]) !== 'undefined' && global.coinFuncs.validatePlainAddress(addressSplit[0]) && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { this.paymentID = addressSplit[1]; this.payout = this.address + "." + this.paymentID; } else if (typeof(addressSplit[1]) !== 'undefined') { From ee19f37f410b45ff3cc045af1f6bf55c99d93c3b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Feb 2018 11:10:40 +0100 Subject: [PATCH 0229/2430] Moved base address check later --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f67b5e5c..66a6a400 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -383,7 +383,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.error = "Too many options in the login field"; this.valid_miner = false; } - if (typeof(addressSplit[1]) !== 'undefined' && global.coinFuncs.validatePlainAddress(addressSplit[0]) && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1])) { + if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1]) && global.coinFuncs.validatePlainAddress(addressSplit[0])) { this.paymentID = addressSplit[1]; this.payout = this.address + "." + this.paymentID; } else if (typeof(addressSplit[1]) !== 'undefined') { From 4ea8c60cec75fe878f4b2bb3d35cbb26ee0247f5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Feb 2018 21:10:15 +0100 Subject: [PATCH 0230/2430] Added totalAltBlocksFound --- lib/worker.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index 065fa326..00388a4b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -407,6 +407,10 @@ function updatePoolStats(poolType) { function (callback) { debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats"); return callback(null, cache.roundHashes || 0); + }, + function (callback) { + debug(threadName + "Checking MySQL for altblock count for pool stats"); + return callback(null, global.database.getAltBlockList(poolType).length); } ], function (err, result) { if (typeof(poolType) === 'undefined') { @@ -422,6 +426,7 @@ function updatePoolStats(poolType) { totalMinersPaid: result[6] || 0, totalPayments: result[7] || 0, roundHashes: result[8] || 0 + totalAltBlocksFound: result[9] || 0, }); }); } From c1000561550f85969cb9c331660c51c3e157012c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 20 Feb 2018 21:12:42 +0100 Subject: [PATCH 0231/2430] Fixed comma --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 00388a4b..ba766616 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -425,8 +425,8 @@ function updatePoolStats(poolType) { totalBlocksFound: result[5] || 0, totalMinersPaid: result[6] || 0, totalPayments: result[7] || 0, - roundHashes: result[8] || 0 - totalAltBlocksFound: result[9] || 0, + roundHashes: result[8] || 0, + totalAltBlocksFound: result[9] || 0 }); }); } From c47763f536d1bb8eb4d7b740b778e79d6913259a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Feb 2018 09:35:50 +0100 Subject: [PATCH 0232/2430] Added more API data --- lib/local_comms.js | 2 ++ lib/support.js | 1 - lib/worker.js | 55 ++++++++++++++++++++++++++++++++-------------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index f41b632c..a32e6a28 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -192,6 +192,8 @@ function Database(){ pool_type: poolType, value: blockData.value, pay_value: blockData.pay_value, + pay_stage: blockData.pay_stage, + pay_status: blockData.pay_status, port: blockData.port }); } diff --git a/lib/support.js b/lib/support.js index 2bc79b9a..c2e480c6 100644 --- a/lib/support.js +++ b/lib/support.js @@ -184,7 +184,6 @@ function getActivePort(callback) { } function setActivePort(activePort) { - console.log("Setting activePort to " + activePort.toString() + " value"); global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort'", [activePort]); } diff --git a/lib/worker.js b/lib/worker.js index ba766616..807cfbd0 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -343,38 +343,40 @@ function updatePoolStats(poolType) { cache.roundHashes = cache2_round.roundHashes; } } + + let blockList = global.database.getBlockList(poolType); + let altblockList = global.database.getAltBlockList(poolType); + async.series([ function (callback) { - debug(threadName + "Checking Influx for last 10min avg for pool stats"); + debug(threadName + "Checking Influx for last 5min avg for pool stats"); return callback(null, cache.hash || 0); }, function (callback) { - debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats"); + debug(threadName + "Checking Influx for last 5min avg for miner count for pool stats"); return callback(null, cache.minerCount || 0); }, function (callback) { - debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats"); + debug(threadName + "Checking LMDB cache for totalHashes"); return callback(null, cache.totalHashes || 0); }, function (callback) { - debug(threadName + "Checking MySQL for last block find time for pool stats"); - let cacheData = global.database.getBlockList(poolType); - if (cacheData.length === 0) { + debug(threadName + "Checking LMDB for last block find time for pool stats"); + if (blockList.length === 0) { return callback(null, 0); } - return callback(null, Math.floor(cacheData[0].ts / 1000)); + return callback(null, Math.floor(blockList[0].ts / 1000)); }, function (callback) { - debug(threadName + "Checking MySQL for last block find time for pool stats"); - let cacheData = global.database.getBlockList(poolType); - if (cacheData.length === 0) { + debug(threadName + "Checking LMDB for last block find time for pool stats"); + if (blockList.length === 0) { return callback(null, 0); } - return callback(null, cacheData[0].height); + return callback(null, blockList[0].height); }, function (callback) { - debug(threadName + "Checking MySQL for block count for pool stats"); - return callback(null, global.database.getBlockList(poolType).length); + debug(threadName + "Checking LMDB for block count for pool stats"); + return callback(null, blockList.length); }, function (callback) { debug(threadName + "Checking MySQL for total miners paid"); @@ -405,12 +407,28 @@ function updatePoolStats(poolType) { } }, function (callback) { - debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats"); + debug(threadName + "Checking LMDB cache for roundHashes"); return callback(null, cache.roundHashes || 0); }, function (callback) { - debug(threadName + "Checking MySQL for altblock count for pool stats"); - return callback(null, global.database.getAltBlockList(poolType).length); + debug(threadName + "Checking LMDB for altblock count for pool stats"); + return callback(null, altblockList.length); + }, + function (callback) { + debug(threadName + "Checking MySQL for activePort value"); + global.support.getActivePort(function (newActivePort) { + return callback(null, newActivePort); + }); + }, + 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 xmr_profit_comment value"); + let xmr_profit = global.database.getCache('xmr_profit_comment'); + return callback(null, xmr_profit_comment ? xmr_profit_comment.value : ""); } ], function (err, result) { if (typeof(poolType) === 'undefined') { @@ -426,7 +444,10 @@ function updatePoolStats(poolType) { totalMinersPaid: result[6] || 0, totalPayments: result[7] || 0, roundHashes: result[8] || 0, - totalAltBlocksFound: result[9] || 0 + totalAltBlocksFound: result[9] || 0, + activePort: result[10] || 0, + activePortProfit: result[11] || 0, + activePortComment: result[12] || 0 }); }); } From 98685a76cfbb10107c73e6694f81101cc2edcc95 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Feb 2018 09:38:04 +0100 Subject: [PATCH 0233/2430] Fixed var name --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 807cfbd0..54f82c31 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -427,7 +427,7 @@ function updatePoolStats(poolType) { }, function (callback) { debug(threadName + "Checking LMDB cache for xmr_profit_comment value"); - let xmr_profit = global.database.getCache('xmr_profit_comment'); + let xmr_profit_comment = global.database.getCache('xmr_profit_comment'); return callback(null, xmr_profit_comment ? xmr_profit_comment.value : ""); } ], function (err, result) { From 94ad5e3cadec5a0b10969bc2803f9924bed079d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Feb 2018 09:40:38 +0100 Subject: [PATCH 0234/2430] Added "" for empty activePortComment --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 54f82c31..73411ff4 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -447,7 +447,7 @@ function updatePoolStats(poolType) { totalAltBlocksFound: result[9] || 0, activePort: result[10] || 0, activePortProfit: result[11] || 0, - activePortComment: result[12] || 0 + activePortComment: result[12] || "" }); }); } From 753d5d2eba11bbace59b56f26634f92ddba882ba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Feb 2018 10:48:27 +0100 Subject: [PATCH 0235/2430] Worker optimizations --- lib/worker.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 73411ff4..168bee68 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -349,11 +349,11 @@ function updatePoolStats(poolType) { async.series([ function (callback) { - debug(threadName + "Checking Influx for last 5min avg for pool stats"); + 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"); + debug(threadName + "Checking Influx for last 5min avg for miner count for pool stats (miners)"); return callback(null, cache.minerCount || 0); }, function (callback) { @@ -361,21 +361,25 @@ function updatePoolStats(poolType) { return callback(null, cache.totalHashes || 0); }, function (callback) { - debug(threadName + "Checking LMDB for last block find time for pool stats"); - if (blockList.length === 0) { - return callback(null, 0); + 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, Math.floor(blockList[0].ts / 1000)); + return callback(null, max_time); }, function (callback) { - debug(threadName + "Checking LMDB for last block find time for pool stats"); + 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 block count for pool stats"); + debug(threadName + "Checking LMDB for totalBlocksFound for pool stats"); return callback(null, blockList.length); }, function (callback) { @@ -449,6 +453,7 @@ function updatePoolStats(poolType) { activePortProfit: result[11] || 0, activePortComment: result[12] || "" }); + if (typeof(poolType) === 'undefined') updateBlockHeader(); }); } @@ -538,7 +543,7 @@ function updatePoolInformation() { function updateBlockHeader() { // Todo: Implement within the coins/.js file. - global.support.rpcDaemon('getlastblockheader', [], function (body) { + global.support.rpcPortDaemon(global.config.daemon.activePort, 'getlastblockheader', [], function (body) { if (typeof body.error !== 'undefined'){ return console.error(`Issue getting last block header: ${JSON.stringify(body)}`); } @@ -552,7 +557,7 @@ function updateBlockHeader() { ts: body.result.block_header.timestamp }); } else if (body.result.block_header.hash === lastBlockHash) { - debug("Block headers identical to historical header. Ignoring"); + debug("Block headers identical to historical header. Ignoring"); } else { console.error("GetLastBlockHeader Error during block header update"); } @@ -628,16 +633,14 @@ function monitorNodes() { } updateShareStats(); -updateBlockHeader(); updatePoolStats(); updatePoolInformation(); updateWalletStats(); monitorNodes(); -setInterval(updateBlockHeader, 10000); setInterval(updatePoolStats, 5000); setInterval(updatePoolStats, 5000, 'pplns'); -setInterval(updatePoolStats, 5000, 'pps'); -setInterval(updatePoolStats, 5000, 'solo'); +if (global.config.pps.enable === true) setInterval(updatePoolStats, 5000, 'pps'); +if (global.config.solo.enable === true) setInterval(updatePoolStats, 5000, 'solo'); setInterval(updatePoolInformation, 5000); setInterval(updateWalletStats, 60000); setInterval(monitorNodes, 300000); From dc5161d915b02fd5da510c393ae19f4c2c4f77bf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Feb 2018 13:58:04 +0100 Subject: [PATCH 0236/2430] Added more stats for front-end --- lib/worker.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 168bee68..c7c5b09e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -433,6 +433,11 @@ function updatePoolStats(poolType) { debug(threadName + "Checking LMDB cache for xmr_profit_comment value"); let xmr_profit_comment = global.database.getCache('xmr_profit_comment'); return callback(null, xmr_profit_comment ? xmr_profit_comment.value : ""); + }, + function (callback) { + debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); + let min_block_rewards = global.database.getCache('min_block_rewards'); + return callback(null, min_block_rewards ? min_block_rewards : {}); } ], function (err, result) { if (typeof(poolType) === 'undefined') { @@ -451,7 +456,8 @@ function updatePoolStats(poolType) { totalAltBlocksFound: result[9] || 0, activePort: result[10] || 0, activePortProfit: result[11] || 0, - activePortComment: result[12] || "" + activePortComment: result[12] || "", + minBlockRewards: result[13] || {} }); if (typeof(poolType) === 'undefined') updateBlockHeader(); }); From 30fccb3c17331cf78757bce0e3a290986e5a8d48 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 21 Feb 2018 14:23:13 +0100 Subject: [PATCH 0237/2430] Fixed network stats update --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index c7c5b09e..d7bdc416 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -442,6 +442,7 @@ function updatePoolStats(poolType) { ], function (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; + updateBlockHeader(); } global.database.setCache('pool_stats_' + poolType, { hashRate: result[0], @@ -459,7 +460,6 @@ function updatePoolStats(poolType) { activePortComment: result[12] || "", minBlockRewards: result[13] || {} }); - if (typeof(poolType) === 'undefined') updateBlockHeader(); }); } From 6ef587ab12c15ac866fffea5bc107b541dd7485f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Feb 2018 09:27:54 +0100 Subject: [PATCH 0238/2430] Improved pm2 logging --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 93c6824e..edab164f 100644 --- a/README.md +++ b/README.md @@ -59,12 +59,13 @@ Deployment via Installer ```shell cd ~/nodejs-pool/ -pm2 start init.js --name=blockManager --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=blockManager -pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=worker -pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=payments -pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=remoteShare -pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=longRunner -pm2 start init.js --name=pool --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=pool +pm2 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:SSS Z" -- --module=worker +pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm:SSS Z" --no-autorestart -- --module=payments +pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=remoteShare +pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=longRunner +pm2 start init.js --name=pool --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=pool +pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=api pm2 restart api ``` From 0b9547e08542e299a92319dfb77767e4980bcb27 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 22 Feb 2018 09:29:19 +0100 Subject: [PATCH 0239/2430] Added missing seconds --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index edab164f..c7523492 100644 --- a/README.md +++ b/README.md @@ -60,12 +60,12 @@ 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:SSS Z" -- --module=worker -pm2 start init.js --name=payments --log-date-format="YYYY-MM-DD HH:mm:SSS Z" --no-autorestart -- --module=payments -pm2 start init.js --name=remoteShare --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=remoteShare -pm2 start init.js --name=longRunner --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=longRunner -pm2 start init.js --name=pool --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=pool -pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm:SSS Z" -- --module=api +pm2 start init.js --name=worker --log-date-format="YYYY-MM-DD HH:mm:ss:SSS Z" -- --module=worker +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 restart api ``` From a3b7a62d58517b10f1b5d81df9967ab53fb9e0c3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Feb 2018 17:55:50 +0100 Subject: [PATCH 0240/2430] Fixes related to activePort change --- deployment/base.sql | 1 + lib/pool.js | 26 ++++++++++------------- lib/worker.js | 50 ++++++++++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index c4af8bba..70fd287e 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -74,6 +74,7 @@ CREATE TABLE `pools` ( `blockID` int(11) DEFAULT NULL, `blockIDTime` timestamp NULL DEFAULT NULL, `hostname` varchar(128) DEFAULT NULL, + `port` int DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `pools_id_uindex` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/lib/pool.js b/lib/pool.js index 66a6a400..95eb8a31 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -210,13 +210,13 @@ function templateUpdateReal() { // templateUpdate is only called in master thread function templateUpdate(repeating) { - if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 60*60*1000) { + if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 2*60*60*1000) { if (global.config.daemon.activePort === global.config.daemon.port) { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " was terminated", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was terminated due to main chain block template stuck" ); - console.error("Block height was not updated for an hour. Check your monerod. Exiting..."); + console.error("Block height was not updated for hours. Check your monerod. Exiting..."); fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); process.exit(); } else { @@ -224,7 +224,7 @@ function templateUpdate(repeating) { "Pool server " + global.config.hostname + " was switched to main chain", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was switch to main chain due to block tempalte stuck on " + global.config.daemon.activePort + " port" ); - console.error("Alt block height on " + global.config.daemon.activePort + " port was not updated for an hour. Switching to main chain...."); + console.error("Alt block height on " + global.config.daemon.activePort + " port was not updated for hours. Switching to main chain...."); global.config.daemon.activePort = global.config.daemon.port; isActivePortUpdateBlocked = true; } @@ -264,24 +264,17 @@ function anchorBlockUpdate() { } function newBlockTemplate(template) { + let isExtraCheck = false; if (activeBlockTemplate) { if (activeBlockTemplate.previous_hash.toString('hex') === template.prev_hash) { console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } pastBlockTemplates.enq(activeBlockTemplate); + if (activeBlockTemplate.port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); - if (activeBlockTemplate && activeBlockTemplate.port != template.port && global.config.pool.trustedMiners) { - for (let minerId in activeMiners) { - if (activeMiners.hasOwnProperty(minerId)) { - let miner = activeMiners[minerId]; - if (miner.trust.threshold === 0) miner.trust.threshold = 1; - } - } - } - activeBlockTemplate = new BlockTemplate(template); if (global.config.daemon.port === activeBlockTemplate.port) { anchorBlockHeight = activeBlockTemplate.height; @@ -290,6 +283,7 @@ function newBlockTemplate(template) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; debug(threadName + "Updating worker " + miner.payout + " With new work at height: " + template.height); + if (isExtraCheck) miner.trust.check_height = activeBlockTemplate.height; miner.sendNewJob(); } } @@ -474,7 +468,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.trust = { threshold: is_trusted_wallet ? 1 : global.config.pool.trustThreshold, probability: is_trusted_wallet ? global.config.pool.trustMin : 256, - penalty: 0 + penalty: 0, + check_height: 0 }; } @@ -893,7 +888,7 @@ function processShare(miner, job, blockTemplate, params) { let shareType; if (global.config.pool.trustedMiners && miner.difficulty < 400000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && - crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability) { + crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability && miner.trust.check_height !== job.height) { hash = new Buffer(resultHash, 'hex'); shareType = true; } @@ -1114,6 +1109,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } miner.trust.penalty--; miner.trust.threshold--; + miner.trust.check_height = 0; } else { console.log(threadName + "Share trust broken by " + miner.logString); @@ -1161,7 +1157,7 @@ if (cluster.isMaster) { setInterval(function () { global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]); if (activeBlockTemplate) { - global.mysql.query("UPDATE pools SET blockIDTime = now(), blockID = ? where id = ?", [activeBlockTemplate.height, global.config.pool_id]); + global.mysql.query("UPDATE pools SET blockIDTime = now(), blockID = ?, port = ? where id = ?", [activeBlockTemplate.height, activeBlockTemplate.port, 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]); diff --git a/lib/worker.js b/lib/worker.js index d7bdc416..7940dfbc 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -316,6 +316,17 @@ function updateShareStats() { } function updatePoolStats(poolType) { + if (global.config.daemon.activePort) { + global.support.getActivePort(function (newActivePort) { + global.config.daemon.activePort = newActivePort; + updatePoolStats2(poolType); + }); + } else { + updatePoolStats2(poolType); + } +} + +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() : ""; if (typeof(poolType) !== 'undefined') { @@ -420,9 +431,7 @@ function updatePoolStats(poolType) { }, function (callback) { debug(threadName + "Checking MySQL for activePort value"); - global.support.getActivePort(function (newActivePort) { - return callback(null, newActivePort); - }); + return callback(null, global.config.daemon.activePort ? global.config.daemon.activePort : global.config.daemon.port); }, function (callback) { debug(threadName + "Checking LMDB cache for xmr_profit value"); @@ -622,18 +631,17 @@ function updateWalletStats() { } function monitorNodes() { - global.mysql.query("SELECT blockID, hostname, ip FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { - global.coinFuncs.getLastBlockHeader(function (err, block) { - if (err !== null){ - console.error("Issue in getting block header. Skipping node monitor"); - return; - } - rows.forEach(function (row) { - if (row.blockID < block.height - 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"); - } + global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { + rows.forEach(function (row) { + global.coinFuncs.getPortLastBlockHeader(row.port, function (err, block) { + if (err !== null){ + console.error("Issue in getting block header for " + row.port + " port. Skipping node monitor"); + return; + } + if (row.blockID < block.height - 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"); } - ); + }); }); }); } @@ -643,10 +651,10 @@ updatePoolStats(); updatePoolInformation(); updateWalletStats(); monitorNodes(); -setInterval(updatePoolStats, 5000); -setInterval(updatePoolStats, 5000, 'pplns'); -if (global.config.pps.enable === true) setInterval(updatePoolStats, 5000, 'pps'); -if (global.config.solo.enable === true) setInterval(updatePoolStats, 5000, 'solo'); -setInterval(updatePoolInformation, 5000); -setInterval(updateWalletStats, 60000); -setInterval(monitorNodes, 300000); +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); From bfac8a77dc16a2fc6ef294f98983044989a65a51 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Feb 2018 17:57:56 +0100 Subject: [PATCH 0241/2430] Some extra case for not updated leaf nodes --- lib/worker.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 7940dfbc..45eb99f3 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -633,13 +633,14 @@ function updateWalletStats() { function monitorNodes() { global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { rows.forEach(function (row) { - global.coinFuncs.getPortLastBlockHeader(row.port, function (err, block) { + let port = row.port ? row.port : global.config.daemon.port; + global.coinFuncs.getPortLastBlockHeader(port, function (err, block) { if (err !== null){ - console.error("Issue in getting block header for " + row.port + " port. Skipping node monitor"); + console.error("Issue in getting block header for " + port + " port. Skipping node monitor"); return; } if (row.blockID < block.height - 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"); + 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"); } }); }); From 7c1a25711454be57f99719f6f88c8bd3981e97f9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Feb 2018 20:09:29 +0100 Subject: [PATCH 0242/2430] Decrease anchor block query time --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 95eb8a31..180786f5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1188,7 +1188,7 @@ if (cluster.isMaster) { console.error("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); global.config.daemon.activePort = global.config.daemon.port; } else { - setInterval(updateActivePort, 60*1000); + setInterval(updateActivePort, 3*1000); } templateUpdate(); From 55f94c3c4e7e54e76d20c2d97e17bc27b205ef23 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Feb 2018 20:11:40 +0100 Subject: [PATCH 0243/2430] Switched commented console.log to debug --- lib/pool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 180786f5..8fa4f189 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -693,7 +693,7 @@ let walletWorkerCount = {}; let is_walletAccFinalizer = {}; function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bitcoin, miner_poolTypeEnum, miner_port) { - //console.log("!!! " + wallet_key + ": scanning for old worker names"); + debug("!!! " + wallet_key + ": scanning for old worker names"); let wallet = walletAcc[wallet_key]; let is_something_left = false; let time_now = Date.now(); @@ -703,7 +703,7 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi let acc = worker["acc"]; if (acc != 0) { let height = worker["height"]; - //console.log("!!! " + wallet_key + " / " + worker_name + ": storing old worker share " + height + " " + worker["difficulty"] + " " + time_now + " " + acc); + 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, paymentAddress: miner_address, @@ -720,7 +720,7 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi port: miner_port })); } - //console.log("!!! " + wallet_key + ": removing old worker " + worker_name); + debug("!!! " + wallet_key + ": removing old worker " + worker_name); if (worker_name !== "all_other_workers") -- walletWorkerCount[wallet_key]; delete wallet[worker_name]; } else { @@ -777,7 +777,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy if (!(worker_name in wallet)) { if (worker_name !== "all_other_workers") ++ walletWorkerCount[wallet_key]; - //console.log("!!! " + wallet_key + ": adding new worker " + worker_name + " (num " + 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; @@ -794,7 +794,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy if (height !== db_job_height || difficulty !== activeBlockTemplate.difficulty || time_now - worker["time"] > 60*1000 || acc >= 1000000) { if (acc != 0) { - //console.log("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); + debug("!!! " + wallet_key + " / " + worker_name + ": storing share " + height + " " + difficulty + " " + time_now + " " + acc); global.database.storeShare(height, global.protos.Share.encode({ shares: acc, paymentAddress: miner.address, @@ -821,7 +821,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy worker["acc"] += job.rewarded_difficulty; } - //console.log("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.rewarded_difficulty + ")"); + debug("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.rewarded_difficulty + ")"); } if (is_walletAccFinalizer[wallet_key] === false) { From ec66ae188406d1be2e1c3c979aad2a198a68950e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Feb 2018 20:58:10 +0100 Subject: [PATCH 0244/2430] Fixed altblock round share update --- 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 a32e6a28..60e2b344 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -307,7 +307,7 @@ function Database(){ let txn = global.database.env.beginTxn(); for (let key in cachedData){ - if (cachedData.hasOwnProperty(key) && cachedData[key].totalHashes !== 0){ + if (cachedData.hasOwnProperty(key)){ let cacheStore = txn.getString(global.database.cacheDB, key); if (cacheStore === null){ txn.putString(global.database.cacheDB, key, JSON.stringify(cachedData[key])); From a819e383bfbff868f532c6eeddfbc10dfedcd2d9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Feb 2018 21:01:42 +0100 Subject: [PATCH 0245/2430] Reduce amount of log spam --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index c2e480c6..43d76849 100644 --- a/lib/support.js +++ b/lib/support.js @@ -80,7 +80,7 @@ function sendEmail(toAddress, subject, body, wallet){ } else { let reEmail = /^([a-zA-Z0-9_\.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!reEmail.test(toAddress)) { - console.error("Avoid sending email to invalid address '" + toAddress + "'"); + debug("Avoid sending email to invalid address '" + toAddress + "'"); return; } let key = toAddress + "\t" + subject; From 9330fd9cd1abf2648455f224c4d3f379f8bc4064 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Feb 2018 06:35:54 +0100 Subject: [PATCH 0246/2430] Reverse altblockList --- lib/local_comms.js | 2 +- lib/support.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 60e2b344..6485e5e8 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -635,7 +635,7 @@ function Database(){ } cursor.close(); txn.commit(); - return blockList; + return blockList.reverse(); }; this.isAltBlockInDB = function(port, height){ diff --git a/lib/support.js b/lib/support.js index 43d76849..298af6f9 100644 --- a/lib/support.js +++ b/lib/support.js @@ -226,11 +226,11 @@ function blockCompare(a, b) { } function altblockCompare(a, b) { - if (a.timestamp < b.timestamp) { + if (a.timestamp > b.timestamp) { return 1; } - if (a.timestamp > b.timestamp) { + if (a.timestamp < b.timestamp) { return -1; } return 0; From 9220d867750522b55e78e2d427915d91379722ab Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Feb 2018 07:00:29 +0100 Subject: [PATCH 0247/2430] Second fix for altblock sort --- lib/local_comms.js | 2 +- lib/support.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 6485e5e8..60e2b344 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -635,7 +635,7 @@ function Database(){ } cursor.close(); txn.commit(); - return blockList.reverse(); + return blockList; }; this.isAltBlockInDB = function(port, height){ diff --git a/lib/support.js b/lib/support.js index 298af6f9..3a74fcd2 100644 --- a/lib/support.js +++ b/lib/support.js @@ -226,11 +226,11 @@ function blockCompare(a, b) { } function altblockCompare(a, b) { - if (a.timestamp > b.timestamp) { + if (a.ts < b.ts) { return 1; } - if (a.timestamp < b.timestamp) { + if (a.ts > b.ts) { return -1; } return 0; From 57ed13e432dc6db25d0030337a3b12381da4c791 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Feb 2018 07:06:31 +0100 Subject: [PATCH 0248/2430] Simplifying compare for altblocks --- lib/local_comms.js | 2 +- lib/support.js | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 60e2b344..d6f298dd 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -201,7 +201,7 @@ function Database(){ } cursor.close(); txn.abort(); - return response.sort(global.support.altblockCompare); + return response.sort(global.support.tsCompare); } catch (e){ return response; } diff --git a/lib/support.js b/lib/support.js index 3a74fcd2..eb570f4a 100644 --- a/lib/support.js +++ b/lib/support.js @@ -225,17 +225,6 @@ function blockCompare(a, b) { return 0; } -function altblockCompare(a, b) { - if (a.ts < b.ts) { - return 1; - } - - if (a.ts > b.ts) { - return -1; - } - return 0; -} - function tsCompare(a, b) { if (a.ts < b.ts) { return 1; From dada982c62ad990e1f8356e4d81a7abf6b0c98c9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Feb 2018 12:09:39 +0100 Subject: [PATCH 0249/2430] More share logs --- lib/local_comms.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index d6f298dd..7069fc45 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -279,8 +279,10 @@ function Database(){ 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; } if (!cachedData.hasOwnProperty(minerID)) { From fbbbb4fdcc16f0d6241ff8f7e71aa99f8f953309 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Feb 2018 20:32:49 +0100 Subject: [PATCH 0250/2430] Added main_height to stats --- lib/worker.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 45eb99f3..0c668cc5 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -6,6 +6,7 @@ const sprintf = require("sprintf-js").sprintf; let threadName = "Worker Server "; let cycleCount = 0; let lastBlockHash = null; +let lastBlockHeight = null; let hashrate_avg_min = 5; // cached email of specific address @@ -557,25 +558,29 @@ function updatePoolInformation() { } function updateBlockHeader() { - // Todo: Implement within the coins/.js file. - global.support.rpcPortDaemon(global.config.daemon.activePort, 'getlastblockheader', [], function (body) { - if (typeof body.error !== 'undefined'){ - return console.error(`Issue getting last block header: ${JSON.stringify(body)}`); - } - if (body.result && body.result.block_header.hash !== lastBlockHash) { - lastBlockHash = body.result.block_header.hash; - global.database.setCache('networkBlockInfo', { - difficulty: body.result.block_header.difficulty, - hash: body.result.block_header.hash, - height: body.result.block_header.height, - value: body.result.block_header.reward, - ts: body.result.block_header.timestamp - }); - } else if (body.result.block_header.hash === lastBlockHash) { - debug("Block headers identical to historical header. Ignoring"); - } else { - console.error("GetLastBlockHeader Error during block header update"); + global.coinFuncs.getLastBlockHeader(function(main_err, main_body){ + if (main err !== null) { + console.error("Last block header request failed!"); + return; } + global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function(err, body){ + if (err !== null) { + console.error("Last block header request failed for " + global.config.daemon.activePort + " port!"); + return; + } + if (body.hash !== lastBlockHash || main_body.height !== lastBlockHeight) { + lastBlockHash = body.hash; + lastBlockHeight = main_body.height; + global.database.setCache('networkBlockInfo', { + difficulty: body.difficulty, + hash: body.hash, + height: body.height, + main_height: main_body.height, + value: body.reward, + ts: body.timestamp + }); + } + }); }); } From 7d3540689e14dca151e4b967c13ef28c0c828490 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Feb 2018 20:34:55 +0100 Subject: [PATCH 0251/2430] Fixed typo --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0c668cc5..3f2f8c59 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -559,7 +559,7 @@ function updatePoolInformation() { function updateBlockHeader() { global.coinFuncs.getLastBlockHeader(function(main_err, main_body){ - if (main err !== null) { + if (main_err !== null) { console.error("Last block header request failed!"); return; } From 47204f4b8bb2f53500e05b05900dcc0170745ed9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Feb 2018 06:50:57 +0100 Subject: [PATCH 0252/2430] Added function for altbLock sorting --- lib/support.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/support.js b/lib/support.js index eb570f4a..a5575cf4 100644 --- a/lib/support.js +++ b/lib/support.js @@ -236,6 +236,17 @@ function tsCompare(a, b) { return 0; } +function tsCompare2(a, b) { + if (a.timestamp > b.timestamp) { + return 1; + } + + if (a.timestamp < b.timestamp) { + return -1; + } + return 0; +} + module.exports = function () { return { rpcDaemon: function (method, params, callback) { From d53479a0c5967afe009fc099dbcbf1a908ad6421 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Feb 2018 12:11:05 +0100 Subject: [PATCH 0253/2430] Really decresed anchor block update time --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8fa4f189..7888eaae 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1201,8 +1201,8 @@ if (cluster.isMaster) { anchorBlockUpdate(); setInterval(function () { bannedIPs = []; - anchorBlockUpdate(); }, 60*1000); + setInterval(anchorBlockUpdate, 3*1000); // load merged wallet trust from files let numWorkers = require('os').cpus().length; From aa8b69e020d3fae4732817de41db0f029a14fb08 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Feb 2018 15:26:36 +0100 Subject: [PATCH 0254/2430] Removed no longer needed sort function --- lib/support.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/support.js b/lib/support.js index a5575cf4..eb570f4a 100644 --- a/lib/support.js +++ b/lib/support.js @@ -236,17 +236,6 @@ function tsCompare(a, b) { return 0; } -function tsCompare2(a, b) { - if (a.timestamp > b.timestamp) { - return 1; - } - - if (a.timestamp < b.timestamp) { - return -1; - } - return 0; -} - module.exports = function () { return { rpcDaemon: function (method, params, callback) { From 460e2e26fcb1466038f41b6ece1dc1ed4d67ce22 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 12:22:52 +0100 Subject: [PATCH 0255/2430] Added more notifications about issues with getLastBlockHeader --- lib/worker.js | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 6d441197..a4440ee6 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -14,6 +14,8 @@ let minerEmail = {}; // time of last SQL check for specific address let minerEmailTime = {}; +let lastBlockCheckIsFailed = {}; + function updateShareStats() { // This is an omni-worker to deal with all things share-stats related // Time based averages are worked out on ring buffers. @@ -25,12 +27,15 @@ 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"); let locTime = Date.now() - (hashrate_avg_min*60*1000); let identifierTime = Date.now() - (2*hashrate_avg_min*60*1000); let localStats = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}}; @@ -635,7 +640,30 @@ function updateWalletStats() { } -let lastBlockCheckIsFailed = {}; +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( + 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.` + ); + } + return; +} + +function bad_header_stop(port) { + if (port in lastBlockCheckIsFailed) { + delete lastBlockCheckIsFailed[port]; + 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.` + ); + } +} function monitorNodes() { global.mysql.query("SELECT blockID, hostname, ip, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { @@ -643,26 +671,10 @@ function monitorNodes() { let port = row.port ? row.port : global.config.daemon.port; global.coinFuncs.getPortLastBlockHeader(port, function (err, block) { if (err !== null){ - console.error("Issue in getting block header for " + port + " port. Skipping node monitor"); - if (!(port in lastBlockCheckIsFailed)) { - lastBlockCheckIsFailed[port] = 1; - 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.` - ); - } + bad_header_start(port); return; } - if (port in lastBlockCheckIsFailed) { - delete lastBlockCheckIsFailed[port]; - 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.` - ); - } + bad_header_stop(); if (row.blockID < block.height - 3) { global.support.sendEmail(global.config.general.adminEmail, "Pool server behind in blocks", From 4c02d5cff9e260178ad24e6518cda692ce5590f5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 12:32:10 +0100 Subject: [PATCH 0256/2430] Added more logging of anchor block stuff --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 7888eaae..c0b9d69e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -248,6 +248,7 @@ function templateUpdate(repeating) { // main chain anchor block height for alt chain block let anchorBlockHeight; +let anchorBlockPrevHeight; // update main chain anchor block height for alt chain block // anchorBlockUpdate is only called in worker threads @@ -257,6 +258,10 @@ function anchorBlockUpdate() { global.coinFuncs.getLastBlockHeader(function (err, body) { if (err === null) { anchorBlockHeight = body.height; + if (!anchorBlockPrevHeight || anchorBlockPrevHeight != anchorBlockHeight) { + anchorBlockPrevHeight = anchorBlockHeight; + console.log("Anchor block was changed to " + anchorBlockHeight); + } } else { console.error("Archor last block header request failed!"); } From b36b762d1297b5c7c514b2246612dd6cfe15a7b8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 12:41:16 +0100 Subject: [PATCH 0257/2430] Added pool hashrate monitoring --- lib/worker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index a4440ee6..cffa457a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -15,6 +15,7 @@ let minerEmail = {}; let minerEmailTime = {}; let lastBlockCheckIsFailed = {}; +let prev_pool_hashrate; function updateShareStats() { // This is an omni-worker to deal with all things share-stats related @@ -308,7 +309,15 @@ function updateShareStats() { }); cache_updates.minerList = minerList; global.database.bulkSetCache(cache_updates); - console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds"); + let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; + console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); + if (prev_pool_hashrate && (pool_hashrate / prev_pool_hashrate) < 0.7 || (pool_hashrate / prev_pool_hashrate) > 1.3) { + global.support.sendEmail(global.config.general.adminEmail, + "Pool hashrate changed", + "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + ); + } + prev_pool_hashrate = pool_hashrate; callback(null); }); } From ddd825de2e7104f61f49fa5505756af27bcf1ddb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 12:42:48 +0100 Subject: [PATCH 0258/2430] Added number of workers email --- lib/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index cffa457a..93413e6c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -314,7 +314,8 @@ function updateShareStats() { if (prev_pool_hashrate && (pool_hashrate / prev_pool_hashrate) < 0.7 || (pool_hashrate / prev_pool_hashrate) > 1.3) { global.support.sendEmail(global.config.general.adminEmail, "Pool hashrate changed", - "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + "\n" + "Number of workers: " + minerCount ); } prev_pool_hashrate = pool_hashrate; From b732389b7cb7b9beb02aebbac94cd5014c5588a3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 12:43:52 +0100 Subject: [PATCH 0259/2430] Fixed typo --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 93413e6c..d756bce3 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -314,7 +314,7 @@ function updateShareStats() { if (prev_pool_hashrate && (pool_hashrate / prev_pool_hashrate) < 0.7 || (pool_hashrate / prev_pool_hashrate) > 1.3) { global.support.sendEmail(global.config.general.adminEmail, "Pool hashrate changed", - "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + "\n" + "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + "\n" + "Number of workers: " + minerCount ); } From 3b77b893f06659b503a013fce486f672f9f98552 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 16:36:46 +0100 Subject: [PATCH 0260/2430] Improved pool stats change email --- lib/worker.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index d756bce3..19db2b58 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -8,6 +8,7 @@ let cycleCount = 0; let lastBlockHash = null; let lastBlockHeight = null; let hashrate_avg_min = 5; +let stat_change_alert = 0.3; // cached email of specific address let minerEmail = {}; @@ -16,6 +17,7 @@ let minerEmailTime = {}; let lastBlockCheckIsFailed = {}; let prev_pool_hashrate; +let prev_pool_workers; function updateShareStats() { // This is an omni-worker to deal with all things share-stats related @@ -309,16 +311,21 @@ function updateShareStats() { }); cache_updates.minerList = minerList; global.database.bulkSetCache(cache_updates); - let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; + let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; + let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; + let pool_workers = minerCount; + let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); - if (prev_pool_hashrate && (pool_hashrate / prev_pool_hashrate) < 0.7 || (pool_hashrate / prev_pool_hashrate) > 1.3) { + 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, - "Pool hashrate changed", - "Pool hashrate changed from " + prev_pool_hashrate + " to " + pool_hashrate + "\n" + - "Number of workers: " + minerCount + "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 + ")" ); } prev_pool_hashrate = pool_hashrate; + prev_pool_workers = pool_workers; callback(null); }); } From 8503ccaed7ae9a5aea2f0d0160cf6ef0de11ac27 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 17:00:19 +0100 Subject: [PATCH 0261/2430] Changed pool dev donations address Since likely I will be the only one now to support these severe pool modifications. --- README.md | 32 +++++++++++++++----------------- lib/coins/xmr.js | 4 ++-- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c7523492..0ab28a3a 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ worker - Does regular processing of statistics and sends status e-mails for non- ``` API listens on port 8001, remoteShare listens on 8000 -Xmrpool.net (The reference implementation) uses the following setup: -* https://xmrpool.net is hosted on its own server, as the main website is a static frontend -* https://api.xmrpool.net hosts api, remoteShare, longRunner, payments, blockManager, worker, as these must all be hosted with access to the same LMDB database. +moneroocean.stream (The reference implementation) uses the following setup: +* https://moneroocean.stream is hosted on its own server, as the main website is a static frontend +* https://api.moneroocean.stream hosts api, remoteShare, longRunner, payments, blockManager, worker, as these must all be hosted with access to the same LMDB database. Sample Caddyfile for API: ```text -https://api.xmrpool.net { +https://api.moneroocean.stream { proxy /leafApi 127.0.0.1:8000 proxy / 127.0.0.1:8001 cors @@ -49,7 +49,7 @@ Deployment via Installer ------------------------ 1. Add your user to `/etc/sudoers`, this must be done so the script can sudo up and do it's job. We suggest passwordless sudo. Suggested line: ` ALL=(ALL) NOPASSWD:ALL`. Our sample builds use: `pooldaemon ALL=(ALL) NOPASSWD:ALL` -2. Run the [deploy script](https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/deploy.bash) as a **NON-ROOT USER**. This is very important! This script will install the pool to whatever user it's running under! Also. Go get a coffee, this sucker bootstraps the monero installation. +2. Run the [deploy script](https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/deploy.bash) as a **NON-ROOT USER**. This is very important! This script will install the pool to whatever user it's running under! Also. Go get a coffee, this sucker bootstraps the monero installation. 3. Once it's complete, change as `config.json` appropriate. It is pre-loaded for a local install of everything, running on 127.0.0.1. This will work perfectly fine if you're using a single node setup. You'll also want to set `bind_ip` to the external IP of the pool server, and `hostname` to the resolvable hostname for the pool server. `pool_id` is mostly used for multi-server installations to provide unique identifiers in the backend. You will also want to run: source ~/.bashrc This will activate NVM and get things working for the following pm2 steps. 4. You'll need to change the API endpoint for the frontend code in the `poolui/build/globals.js` and `poolui/build/globals.default.js` -- This will usually be `http(s):///api` unless you tweak caddy! 5. The default database directory `/home//pool_db/` is already been created during startup. If you change the `db_storage_path` just make sure your user has write permissions for new path. Run: `pm2 restart api` to reload the API for usage. @@ -71,7 +71,7 @@ pm2 restart api Install Script: ```bash -curl -L https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/deploy.bash | bash +curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/deploy.bash | bash ``` Assumptions for the installer @@ -125,7 +125,7 @@ general/emailFrom SQL import command: sudo mysql pool < ~/nodejs-pool/sample_config.sql (Adjust name/path as needed!) ``` -The shareHost configuration is designed to be pointed at wherever the leafApi endpoint exists. For xmrpool.net, we use https://api.xmrpool.net/leafApi. If you're using the automated setup script, you can use: `http:///leafApi`, as Caddy will proxy it. If you're just using localhost and a local pool serv, http://127.0.0.1:8000/leafApi will do you quite nicely +The shareHost configuration is designed to be pointed at wherever the leafApi endpoint exists. For moneroocean.stream, we use https://api.moneroocean.stream/leafApi. If you're using the automated setup script, you can use: `http:///leafApi`, as Caddy will proxy it. If you're just using localhost and a local pool serv, http://127.0.0.1:8000/leafApi will do you quite nicely Additional ports can be added as desired, samples can be found at the end of base.sql. If you're not comfortable with the MySQL command line, I highly suggest MySQL Workbench or a similar piece of software (I use datagrip!). Your root MySQL password can be found in `/root/.my.cnf` @@ -141,7 +141,7 @@ UPDATE pool.users SET email='your new password here' WHERE username='Administrat ``` The email field is used as the default password field until the password is changed, at which point, it's hashed and dumped into the password field instead, and using the email field as a password is disabled. -You should take a look at the [wiki](https://github.com/Snipa22/nodejs-pool/wiki/Configuration-Details) for specific configuration settings in the system. +You should take a look at the [wiki](https://github.com/MoneroOcean/nodejs-pool/wiki/Configuration-Details) for specific configuration settings in the system. Pool Update Procedures ====================== @@ -236,35 +236,33 @@ For 1 in 1000000 chance that the pool will go bankrupt: 5% fee -> 1200 2% fee -> For 1 in 1000000000 chance: 5% fee -> 1800 2% fee -> 4500 ``` -The developers of the pool have not verified this, but based on our own usage on https://xmrpool.net/ this seems rather reasonable. You should be wary if you're considering PPS and take you fees into account appropriately! +The developers of the pool have not verified this, but based on usage on https://xmrpool.net/ this seems rather reasonable. You should be wary if you're considering PPS and take you fees into account appropriately! Installation/Configuration Assistance ===================================== If you need help installing the pool from scratch, please have your servers ready, which would be Ubuntu 16.04 servers, blank and clean, DNS records pointed. These need to be x86_64 boxes with AES-NI Available. -Installation assistance is 7 XMR, with a 3 XMR deposit, with remainder to be paid on completion. -Configuration assistance is 4 XMR with a 2 XMR deposit, and includes debugging your pool configurations, ensuring that everything is running, and tuning for your uses/needs. +Installation assistance is 3 XMR, with a 1 XMR deposit, with remainder to be paid on completion. +Configuration assistance is 2 XMR with a 1 XMR deposit, and includes debugging your pool configurations, ensuring that everything is running, and tuning for your uses/needs. SSH access with a sudo-enabled user will be needed, preferably the user that is slated to run the pool. -If you'd like assistance with setting up node-cryptonote-pool, please provide what branch/repo you'd like to work from, as there's a variety of these. - Assistance is not available for frontend customization at this time. -For assistance, please contact Snipa at pool_install@snipanet.com or via IRC at irc.freenode.net in the #monero-pools channel. +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 - 44Ldv5GQQhP7K7t3ZBdZjkPA7Kg7dhHwk3ZM3RJqxxrecENSFx27Vq14NAMAd2HBvwEPUVVvydPRLcC69JCZDHLT2X5a4gr -* BTC - 114DGE2jmPb5CP2RGKZn6u6xtccHhZGFmM -* AEON - WmtvM6SoYya4qzkoPB4wX7FACWcXyFPWAYzfz7CADECgKyBemAeb3dVb3QomHjRWwGS3VYzMJAnBXfUx5CfGLFZd1U7ssdXTu +* XMR - 499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE Credits ======= [Zone117x](https://github.com/zone117x) - Original [node-cryptonote-pool](https://github.com/zone117x/node-cryptonote-pool) from which, the stratum implementation has been borrowed. +[Snipa](https://github.com/Snipa22) - Original [nodejs-pool](https://github.com/Snipa22/nodejs-pool) from which, the original implementation has been borrowed. + [Mesh00](https://github.com/mesh0000) - Frontend build in Angular JS [XMRPoolUI](https://github.com/mesh0000/poolui) [Wolf0](https://github.com/wolf9466/)/[OhGodAGirl](https://github.com/ohgodagirl) - Rebuild of node-multi-hashing with AES-NI [node-multi-hashing](https://github.com/Snipa22/node-multi-hashing-aesni) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 91b9ed90..a04cdc39 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -15,8 +15,8 @@ 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.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Developer Address - this.poolDevAddress = "44Ldv5GQQhP7K7t3ZBdZjkPA7Kg7dhHwk3ZM3RJqxxrecENSFx27Vq14NAMAd2HBvwEPUVVvydPRLcC69JCZDHLT2X5a4gr"; // Snipa Address + this.coinDevAddress = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"; // Monero Developers Address + this.poolDevAddress = "499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE"; // MoneroOcean Address this.blockedAddresses = [ this.coinDevAddress, From d127d85e0a1414623df7cba4893d8891e640f156 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 17:05:42 +0100 Subject: [PATCH 0262/2430] Added ETN/SUMO donation addresses as well --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0ab28a3a..bc762826 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,8 @@ Developer Donations =================== If you'd like to make a one time donation, the addresses are as follows: * XMR - 499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE +* ETN - etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1 +* SUMO - Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy Credits ======= From 58a6727850200fa9f0515dfc5dc1d07e0f2471e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Feb 2018 17:09:52 +0100 Subject: [PATCH 0263/2430] Formatting fix --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bc762826..085daecc 100644 --- a/README.md +++ b/README.md @@ -254,9 +254,9 @@ 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 -* ETN - etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1 -* SUMO - Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy +* XMR - ```499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE``` +* ETN - ```etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1``` +* SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` Credits ======= From b1aa503a2761dabb0f34ba685b5f2771460e95b2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Feb 2018 10:08:20 +0100 Subject: [PATCH 0264/2430] Added altblockManager price --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 085daecc..377384e8 100644 --- a/README.md +++ b/README.md @@ -242,8 +242,9 @@ Installation/Configuration Assistance ===================================== If you need help installing the pool from scratch, please have your servers ready, which would be Ubuntu 16.04 servers, blank and clean, DNS records pointed. These need to be x86_64 boxes with AES-NI Available. -Installation assistance is 3 XMR, with a 1 XMR deposit, with remainder to be paid on completion. -Configuration assistance is 2 XMR with a 1 XMR deposit, and includes debugging your pool configurations, ensuring that everything is running, and tuning for your uses/needs. +Installation assistance is 3 XMR, with a 1 XMR deposit, with remainder to be paid on completion. +Configuration assistance is 2 XMR with a 1 XMR deposit, and includes debugging your pool configurations, ensuring that everything is running, and tuning for your uses/needs. +altblockManager module source (that determines the most profitable coin to mine and trades them to main coin on exchange) price is 20 XMR. SSH access with a sudo-enabled user will be needed, preferably the user that is slated to run the pool. From ebdcef6d41b7d69f8619cf934400f77c4a54d437 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Feb 2018 10:18:11 +0100 Subject: [PATCH 0265/2430] Decreased email sensitivity to mining interruption caused by worker bad luck --- lib/worker.js | 95 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 19db2b58..5fbf7dea 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -39,8 +39,8 @@ function updateShareStats() { function (height, callback) { bad_header_stop(global.config.daemon.port); console.log("Starting stats collection for " + height + " height"); - let locTime = Date.now() - (hashrate_avg_min*60*1000); - let identifierTime = Date.now() - (2*hashrate_avg_min*60*1000); + let locTime = currentTime - (hashrate_avg_min*60*1000); + let identifierTime = currentTime - (2*hashrate_avg_min*60*1000); let localStats = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}}; let localMinerCount = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0}; let localTimes = { @@ -52,7 +52,7 @@ function updateShareStats() { let minerCount = 0; let loopBreakout = 0; async.doUntil(function (callback_until) { - let oldestTime = Date.now(); + let oldestTime = currentTime; let loopCount = 0; let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); @@ -235,13 +235,6 @@ function updateShareStats() { // This is a worker case. 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(Date.now()), - poolEmailSig: global.config.general.emailSig - }; if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { minerEmailTime[address] = currentTime; global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { @@ -251,18 +244,10 @@ function updateShareStats() { } else { minerEmail[address] = rows[0].email; } - global.support.sendEmail(minerEmail[address], - sprintf(global.config.email.workerNotHashingSubject, emailData), - sprintf(global.config.email.workerNotHashingBody, emailData), - address - ); + setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, currentTime); }); } else if (address in minerEmail) { - global.support.sendEmail(minerEmail[address], - sprintf(global.config.email.workerNotHashingSubject, emailData), - sprintf(global.config.email.workerNotHashingBody, emailData), - address - ); + setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, currentTime); } }); @@ -275,13 +260,6 @@ function updateShareStats() { // This is a worker case. 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(Date.now()), - poolEmailSig: global.config.general.emailSig - }; if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { minerEmailTime[address] = currentTime; global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { @@ -291,18 +269,10 @@ function updateShareStats() { } else { minerEmail[address] = rows[0].email; } - global.support.sendEmail(minerEmail[address], - sprintf(global.config.email.workerStartHashingSubject, emailData), - sprintf(global.config.email.workerStartHashingBody, emailData), - address - ); + send_worker_started_hashing_email(miner, currentTime); }); } else if (address in minerEmail) { - global.support.sendEmail(minerEmail[address], - sprintf(global.config.email.workerStartHashingSubject, emailData), - sprintf(global.config.email.workerStartHashingBody, emailData), - address - ); + send_worker_started_hashing_email(miner, currentTime); } }); @@ -338,6 +308,57 @@ function updateShareStats() { setTimeout(updateShareStats, 20*1000); } +// worker name -> time +let workers_started_hashing_time = {}; +let workers_stopped_hashing_email_time = {}; + +function send_worker_started_hashing_email(miner, currentTime) { + 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 + }; + workers_started_hashing_time[miner] = currentTime; + if (miner in workers_stopped_hashing_email_time) { + delete workers_stopped_hashing_email_time[miner]; + global.support.sendEmail(minerEmail[address], + sprintf(global.config.email.workerStartHashingSubject, emailData), + sprintf(global.config.email.workerStartHashingBody, emailData), + address + ); + } +} + +function delayed_send_worker_stopped_hashing_email(miner, currentTime) { + 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 + }; + + if (miner in workers_started_hashing_time && Date.now() - workers_started_hashing_time[miner] <= 5*60*1000) { + delete workers_started_hashing_time[miner]; + return; + } + + delete workers_started_hashing_time[miner]; + workers_stopped_hashing_email_time[miner] = Date.now(); + + global.support.sendEmail(minerEmail[address], + sprintf(global.config.email.workerNotHashingSubject, emailData), + sprintf(global.config.email.workerNotHashingBody, emailData), + address + ); +} + function updatePoolStats(poolType) { if (global.config.daemon.activePort) { global.support.getActivePort(function (newActivePort) { From d9e29897bac16cb65f08ec4277dde66a043226ac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Feb 2018 10:26:17 +0100 Subject: [PATCH 0266/2430] Better code reorg --- lib/worker.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 5fbf7dea..3d635d0c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -313,18 +313,19 @@ let workers_started_hashing_time = {}; let workers_stopped_hashing_email_time = {}; function send_worker_started_hashing_email(miner, currentTime) { - 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 - }; 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(minerEmail[address], sprintf(global.config.email.workerStartHashingSubject, emailData), sprintf(global.config.email.workerStartHashingBody, emailData), @@ -334,6 +335,14 @@ function send_worker_started_hashing_email(miner, currentTime) { } function delayed_send_worker_stopped_hashing_email(miner, currentTime) { + if (miner in workers_started_hashing_time && Date.now() - workers_started_hashing_time[miner] <= 5*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]; @@ -344,14 +353,6 @@ function delayed_send_worker_stopped_hashing_email(miner, currentTime) { poolEmailSig: global.config.general.emailSig }; - if (miner in workers_started_hashing_time && Date.now() - workers_started_hashing_time[miner] <= 5*60*1000) { - delete workers_started_hashing_time[miner]; - return; - } - - delete workers_started_hashing_time[miner]; - workers_stopped_hashing_email_time[miner] = Date.now(); - global.support.sendEmail(minerEmail[address], sprintf(global.config.email.workerNotHashingSubject, emailData), sprintf(global.config.email.workerNotHashingBody, emailData), From 3d84250d5897bafb5e35d9aeae2c8fa25a5a4f20 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Feb 2018 10:36:56 +0100 Subject: [PATCH 0267/2430] Removed code duplication --- lib/worker.js | 70 ++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 3d635d0c..77c093c0 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -10,11 +10,6 @@ let lastBlockHeight = null; let hashrate_avg_min = 5; let stat_change_alert = 0.3; -// cached email of specific address -let minerEmail = {}; -// time of last SQL check for specific address -let minerEmailTime = {}; - let lastBlockCheckIsFailed = {}; let prev_pool_hashrate; let prev_pool_workers; @@ -235,20 +230,9 @@ function updateShareStats() { // This is a worker case. let address_parts = miner.split(/_(.+)/); let address = address_parts[0]; - if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { - minerEmailTime[address] = currentTime; - 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]; - return; - } else { - minerEmail[address] = rows[0].email; - } - setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, currentTime); - }); - } else if (address in minerEmail) { - setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, currentTime); - } + get_address_email(address, function (email) { + setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, email, currentTime); + }); }); // find new workers @@ -260,20 +244,9 @@ function updateShareStats() { // This is a worker case. let address_parts = miner.split(/_(.+)/); let address = address_parts[0]; - if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { - minerEmailTime[address] = currentTime; - 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]; - return; - } else { - minerEmail[address] = rows[0].email; - } - send_worker_started_hashing_email(miner, currentTime); - }); - } else if (address in minerEmail) { - send_worker_started_hashing_email(miner, currentTime); - } + get_address_email(address, function (email) { + send_worker_started_hashing_email(miner, email, currentTime); + }); }); Object.keys(identifiers).forEach(function (key) { @@ -308,11 +281,34 @@ function updateShareStats() { setTimeout(updateShareStats, 20*1000); } +// cached email of specific address +let minerEmail = {}; +// time of last SQL check for specific address +let minerEmailTime = {}; + // worker name -> time let workers_started_hashing_time = {}; let workers_stopped_hashing_email_time = {}; -function send_worker_started_hashing_email(miner, currentTime) { +function get_address_email(address, callback) { + let currentTime = Date.now(); + if (!(address in minerEmailTime) || currentTime - minerEmailTime[address] > 10*60*1000) { + minerEmailTime[address] = currentTime; + 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]; + return; + } else { + minerEmail[address] = rows[0].email; + } + callback(minerEmail[address]); + }); + } else if (address in minerEmail) { + callback(minerEmail[address]); + } +} + +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]; @@ -326,7 +322,7 @@ function send_worker_started_hashing_email(miner, currentTime) { timestamp: global.support.formatDate(currentTime), poolEmailSig: global.config.general.emailSig }; - global.support.sendEmail(minerEmail[address], + global.support.sendEmail(email, sprintf(global.config.email.workerStartHashingSubject, emailData), sprintf(global.config.email.workerStartHashingBody, emailData), address @@ -334,7 +330,7 @@ function send_worker_started_hashing_email(miner, currentTime) { } } -function delayed_send_worker_stopped_hashing_email(miner, 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) { delete workers_started_hashing_time[miner]; return; @@ -353,7 +349,7 @@ function delayed_send_worker_stopped_hashing_email(miner, currentTime) { poolEmailSig: global.config.general.emailSig }; - global.support.sendEmail(minerEmail[address], + global.support.sendEmail(email, sprintf(global.config.email.workerNotHashingSubject, emailData), sprintf(global.config.email.workerNotHashingBody, emailData), address From 119784d4f7da2f6877ccf405df781be3916e5321 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Feb 2018 10:46:24 +0100 Subject: [PATCH 0268/2430] Do not do overlapping stats update cycles --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 77c093c0..a5cfdd70 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -277,8 +277,8 @@ function updateShareStats() { if (cycleCount === 3){ cycleCount = 0; } + setTimeout(updateShareStats, 20*1000); }); - setTimeout(updateShareStats, 20*1000); } // cached email of specific address From 24e6671fca29e27d0037851a2a751fc4084ba366 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Feb 2018 10:47:11 +0100 Subject: [PATCH 0269/2430] Decreased stats update interval --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index a5cfdd70..71dc6652 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -277,7 +277,7 @@ function updateShareStats() { if (cycleCount === 3){ cycleCount = 0; } - setTimeout(updateShareStats, 20*1000); + setTimeout(updateShareStats, 10*1000); }); } From 7a2728e1e6a8443807541270d989a612b51a8646 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Mar 2018 11:26:25 +0100 Subject: [PATCH 0270/2430] Separated history hashrate updates from total miner hashrate changes Otherwise miner totalHashes are not accurate because they are rolled back each worker update --- debug_scripts/share_dump.js | 42 +++++++++++++++++++++++++++++++++++++ lib/api.js | 26 +++++++++++++---------- lib/worker.js | 5 +++-- 3 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 debug_scripts/share_dump.js diff --git a/debug_scripts/share_dump.js b/debug_scripts/share_dump.js new file mode 100644 index 00000000..12c77613 --- /dev/null +++ b/debug_scripts/share_dump.js @@ -0,0 +1,42 @@ +"use strict"; +let range = require('range'); +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +comms = require('../lib/local_comms'); +global.database = new comms(); +global.database.initEnv(); + + let txn = global.database.env.beginTxn({readOnly: true}); + + { let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); + let lastBlock = 1520747; + range.range(lastBlock-1, 1520747-100, -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.paymentAddress === "") { + var d = new Date(shareData.timestamp); + console.log(d.toString() + ": " + JSON.stringify(shareData)) + } + }); + } + }); + cursor.close(); + } + + txn.commit(); + +process.exit(); + +// 05:43 +// 07:51 \ No newline at end of file diff --git a/lib/api.js b/lib/api.js index 7a7f66cf..40e2d6f8 100644 --- a/lib/api.js +++ b/lib/api.js @@ -39,7 +39,7 @@ app.use(bodyParser.json()); // Support Functions that are reused now function getAllWorkerHashCharts(address, callback){ let identifiers = global.database.getCache(address + '_identifiers'); - let returnData = {global: global.database.getCache(address)['hashHistory']}; + let returnData = {global: global.database.getCache("history:" + address)['hashHistory']}; if (identifiers !== false){ identifiers.sort(); } else { @@ -47,7 +47,7 @@ function getAllWorkerHashCharts(address, callback){ } let intCounter = 0; identifiers.forEach(function(identifier){ - returnData[identifier] = global.database.getCache(address+"_"+identifier)['hashHistory']; + returnData[identifier] = global.database.getCache("history:" + address+"_"+identifier)['hashHistory']; intCounter += 1; if (intCounter === identifiers.length){ return callback(null, returnData); @@ -58,10 +58,11 @@ function getAllWorkerHashCharts(address, callback){ function getAllWorkerStats(address, callback){ let identifiers = global.database.getCache(address + '_identifiers'); let globalCache = global.database.getCache(address); + let globalHistoryCache = global.database.getCache("history:" + address); let returnData = {global: { - lts: Math.floor(globalCache.lastHash / 1000), + lts: Math.floor(globalHistoryCache.lastHash / 1000), identifer: 'global', - hash: globalCache.hash, + hash: globalHistoryCache.hash, totalHash: globalCache.totalHashes }}; let intCounter = 0; @@ -70,10 +71,11 @@ function getAllWorkerStats(address, callback){ } identifiers.sort().forEach(function(identifier){ let cachedData = global.database.getCache(address+"_"+identifier); + let cachedHistoryData = global.database.getCache("history:" + address+"_"+identifier); returnData[identifier] = { - lts: Math.floor(cachedData.lastHash / 1000), + lts: Math.floor(cachedHistoryData.lastHash / 1000), identifer: identifier, - hash: cachedData.hash, + hash: cachedHistoryData.hash, totalHash: cachedData.totalHashes }; intCounter += 1; @@ -88,6 +90,7 @@ function getAddressStats(address, extCallback){ let address_pt = address_parts[0]; let payment_id = address_parts[1]; let cachedData = global.database.getCache(address); + let cachedHistoryData = global.database.getCache("history:" + address); let paidQuery = "SELECT SUM(amount) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let txnQuery = "SELECT count(id) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let unpaidQuery = "SELECT SUM(amount) as amt FROM balance WHERE payment_address = ? AND payment_id = ?"; @@ -99,7 +102,7 @@ function getAddressStats(address, extCallback){ async.waterfall([ function (callback) { debug(threadName + "Checking Influx for last 10min avg for /miner/address/stats"); - return callback(null, {hash: cachedData.hash, identifier: 'global', lastHash: Math.floor(cachedData.lastHash / 1000), + return callback(null, {hash: cachedHistoryData.hash, identifier: 'global', lastHash: Math.floor(cachedHistoryData.lastHash / 1000), totalHashes: cachedData.totalHashes, validShares: Number(cachedData.goodShares), invalidShares: Number(cachedData.badShares)}); }, function (returnData, callback) { @@ -468,10 +471,11 @@ app.get('/miner/:address/stats/:identifier', function (req, res) { lastHash: localTimes.miners[miner] */ let cachedData = global.database.getCache(memcKey); + let cachedHistoryData = global.database.getCache("history:" + memcKey); return res.json({ - lts: Math.floor(cachedData.lastHash / 1000), + lts: Math.floor(cachedHistoryData.lastHash / 1000), identifer: identifier, - hash: cachedData.hash, + hash: cachedHistoryData.hash, totalHash: cachedData.totalHashes, validShares: Number(cachedData.goodShares), invalidShares: Number(cachedData.badShares) @@ -479,7 +483,7 @@ app.get('/miner/:address/stats/:identifier', function (req, res) { }); app.get('/miner/:address/chart/hashrate', function (req, res) { - return res.json(global.database.getCache(req.params.address)['hashHistory']); + return res.json(global.database.getCache("history:" + req.params.address)['hashHistory']); }); app.get('/miner/:address/chart/hashrate/allWorkers', function (req, res) { @@ -489,7 +493,7 @@ app.get('/miner/:address/chart/hashrate/allWorkers', function (req, res) { }); app.get('/miner/:address/chart/hashrate/:identifier', function (req, res) { - return res.json(global.database.getCache(req.params.address + "_" + req.params.identifier)['hashHistory']); + return res.json(global.database.getCache("history:" + req.params.address + "_" + req.params.identifier)['hashHistory']); }); app.get('/miner/:address/stats', function (req, res) { diff --git a/lib/worker.js b/lib/worker.js index 71dc6652..d418b58d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -190,7 +190,8 @@ function updateShareStats() { //if (miner.indexOf('_') === -1){ // activeAddresses.push(miner); //} - let cachedData = global.database.getCache(miner); + let cachedData = global.database.getCache("history:" + miner); + if (cachedData === false) cachedData = global.database.getCache(miner); // for compatibility if (cachedData !== false) { cachedData.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; cachedData.lastHash = localTimes.miners[miner]; @@ -215,7 +216,7 @@ function updateShareStats() { badShares: 0 }; } - cache_updates[miner] = cachedData; + cache_updates["history:" + miner] = cachedData; }); // remove old workers From 1a173227fa60016b9877fc2549d2577f5aff9baf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Mar 2018 12:01:58 +0100 Subject: [PATCH 0271/2430] Added history cache fallback for smooth transition --- lib/api.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/api.js b/lib/api.js index 40e2d6f8..14a9bf41 100644 --- a/lib/api.js +++ b/lib/api.js @@ -59,6 +59,7 @@ function getAllWorkerStats(address, callback){ let identifiers = global.database.getCache(address + '_identifiers'); let globalCache = global.database.getCache(address); let globalHistoryCache = global.database.getCache("history:" + address); + if (globalHistoryCache === false) globalHistoryCache = globalCache; // for compatibility let returnData = {global: { lts: Math.floor(globalHistoryCache.lastHash / 1000), identifer: 'global', @@ -72,6 +73,7 @@ function getAllWorkerStats(address, callback){ identifiers.sort().forEach(function(identifier){ let cachedData = global.database.getCache(address+"_"+identifier); let cachedHistoryData = global.database.getCache("history:" + address+"_"+identifier); + if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility returnData[identifier] = { lts: Math.floor(cachedHistoryData.lastHash / 1000), identifer: identifier, @@ -91,6 +93,7 @@ function getAddressStats(address, extCallback){ let payment_id = address_parts[1]; let cachedData = global.database.getCache(address); let cachedHistoryData = global.database.getCache("history:" + address); + if (globalHistoryCache === false) globalHistoryCache = globalCache; // for compatibility let paidQuery = "SELECT SUM(amount) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let txnQuery = "SELECT count(id) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let unpaidQuery = "SELECT SUM(amount) as amt FROM balance WHERE payment_address = ? AND payment_id = ?"; @@ -472,6 +475,7 @@ app.get('/miner/:address/stats/:identifier', function (req, res) { */ let cachedData = global.database.getCache(memcKey); let cachedHistoryData = global.database.getCache("history:" + memcKey); + if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility return res.json({ lts: Math.floor(cachedHistoryData.lastHash / 1000), identifer: identifier, From db85910d4e490084f25be64ad3ab57847835e564 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Mar 2018 12:03:05 +0100 Subject: [PATCH 0272/2430] Fixed copy paste bug --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 14a9bf41..65215f96 100644 --- a/lib/api.js +++ b/lib/api.js @@ -93,7 +93,7 @@ function getAddressStats(address, extCallback){ let payment_id = address_parts[1]; let cachedData = global.database.getCache(address); let cachedHistoryData = global.database.getCache("history:" + address); - if (globalHistoryCache === false) globalHistoryCache = globalCache; // for compatibility + if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility let paidQuery = "SELECT SUM(amount) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let txnQuery = "SELECT count(id) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let unpaidQuery = "SELECT SUM(amount) as amt FROM balance WHERE payment_address = ? AND payment_id = ?"; From 0adee4b03b291cdccc0629a77a908033089a05ca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Mar 2018 12:16:24 +0100 Subject: [PATCH 0273/2430] Do not display too old stuck workers --- lib/api.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/api.js b/lib/api.js index 65215f96..8368f462 100644 --- a/lib/api.js +++ b/lib/api.js @@ -70,16 +70,19 @@ function getAllWorkerStats(address, callback){ if (identifiers === false){ return callback(null, returnData); } + let currentTime = Date.now(); identifiers.sort().forEach(function(identifier){ let cachedData = global.database.getCache(address+"_"+identifier); let cachedHistoryData = global.database.getCache("history:" + address+"_"+identifier); if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility - returnData[identifier] = { - lts: Math.floor(cachedHistoryData.lastHash / 1000), - identifer: identifier, - hash: cachedHistoryData.hash, - totalHash: cachedData.totalHashes - }; + if (currentTime - cachedHistoryData.lastHash <= 24*60*60*1000) { + returnData[identifier] = { + lts: Math.floor(cachedHistoryData.lastHash / 1000), + identifer: identifier, + hash: cachedHistoryData.hash, + totalHash: cachedData.totalHashes + }; + } intCounter += 1; if (intCounter === identifiers.length){ return callback(null, returnData); From 21e06f4ea29b70a46e12f47be53b2a20cfa194d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Mar 2018 12:19:30 +0100 Subject: [PATCH 0274/2430] Rolled back last change as basically useless --- lib/api.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/api.js b/lib/api.js index 8368f462..65215f96 100644 --- a/lib/api.js +++ b/lib/api.js @@ -70,19 +70,16 @@ function getAllWorkerStats(address, callback){ if (identifiers === false){ return callback(null, returnData); } - let currentTime = Date.now(); identifiers.sort().forEach(function(identifier){ let cachedData = global.database.getCache(address+"_"+identifier); let cachedHistoryData = global.database.getCache("history:" + address+"_"+identifier); if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility - if (currentTime - cachedHistoryData.lastHash <= 24*60*60*1000) { - returnData[identifier] = { - lts: Math.floor(cachedHistoryData.lastHash / 1000), - identifer: identifier, - hash: cachedHistoryData.hash, - totalHash: cachedData.totalHashes - }; - } + returnData[identifier] = { + lts: Math.floor(cachedHistoryData.lastHash / 1000), + identifer: identifier, + hash: cachedHistoryData.hash, + totalHash: cachedData.totalHashes + }; intCounter += 1; if (intCounter === identifiers.length){ return callback(null, returnData); From 46a0fbd56e1809770c67acc3b2286a000a4ce683 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 2 Mar 2018 18:15:25 +0100 Subject: [PATCH 0275/2430] Fxied correct anchor height to avoid occasional pool hashrate drops to 0 --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c0b9d69e..a3251c4e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -257,7 +257,7 @@ function anchorBlockUpdate() { // only need to do that separately if we mine alt chain global.coinFuncs.getLastBlockHeader(function (err, body) { if (err === null) { - anchorBlockHeight = body.height; + anchorBlockHeight = body.height + 1; if (!anchorBlockPrevHeight || anchorBlockPrevHeight != anchorBlockHeight) { anchorBlockPrevHeight = anchorBlockHeight; console.log("Anchor block was changed to " + anchorBlockHeight); From 5ed29921c496891c7bd20535aa6355871693567e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 09:58:00 +0100 Subject: [PATCH 0276/2430] Added per coin block lists to API --- lib/api.js | 6 ++++++ lib/local_comms.js | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index 65215f96..547a7655 100644 --- a/lib/api.js +++ b/lib/api.js @@ -303,6 +303,12 @@ app.get('/pool/altblocks', function (req, res) { res.json(global.database.getAltBlockList().slice(page*limit, (page + 1) * limit)); }); +app.get('/pool/coin_altblocks/:coin_port', 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, req.params.coin_port).slice(page*limit, (page + 1) * limit)); +}); + app.get('/pool/payments/:pool_type', function (req, res) { let pool_type = req.params.pool_type; let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; diff --git a/lib/local_comms.js b/lib/local_comms.js index 7069fc45..43370b55 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -147,8 +147,8 @@ function Database(){ } }; - this.getAltBlockList = function(pool_type){ - debug("Getting block list"); + this.getAltBlockList = function(pool_type, coin_port){ + debug("Getting altblock list"); switch (pool_type) { case 'pplns': pool_type = global.protos.POOLTYPE.PPLNS; @@ -180,7 +180,7 @@ function Database(){ 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) { + if (blockData.poolType === pool_type || pool_type === false && (!coin_port || blockData.port === coin_port)) { response.push({ ts: blockData.timestamp, hash: blockData.hash, From 4316031168768e0e760b82b8a040c19b4820d1b5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 10:32:31 +0100 Subject: [PATCH 0277/2430] Added altblock coints for specific coins --- lib/worker.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index d418b58d..968180cd 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -471,6 +471,16 @@ function updatePoolStats2(poolType) { 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"); + if (!min_block_rewards) return callback(null, {}); + let result = {}; + for (let block in altblockList) { + 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 ? global.config.daemon.activePort : global.config.daemon.port); @@ -487,7 +497,7 @@ function updatePoolStats2(poolType) { }, function (callback) { debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); - let min_block_rewards = global.database.getCache('min_block_rewards'); + let min_block_rewards = global.database.getCache('min_block_rewards'); return callback(null, min_block_rewards ? min_block_rewards : {}); } ], function (err, result) { @@ -506,10 +516,11 @@ function updatePoolStats2(poolType) { totalPayments: result[7] || 0, roundHashes: result[8] || 0, totalAltBlocksFound: result[9] || 0, - activePort: result[10] || 0, - activePortProfit: result[11] || 0, - activePortComment: result[12] || "", - minBlockRewards: result[13] || {} + altBlocksFound: result[10] || {}, + activePort: result[11] || 0, + activePortProfit: result[12] || 0, + activePortComment: result[13] || "", + minBlockRewards: result[14] || {} }); }); } From 3d0e5d507e050594e103f0540b721cbe63cc69f6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 10:34:44 +0100 Subject: [PATCH 0278/2430] Removed not needed code --- lib/worker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 968180cd..ca906486 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -473,7 +473,6 @@ function updatePoolStats2(poolType) { }, function (callback) { debug(threadName + "Checking LMDB for altBlocksFound array for each specific port"); - if (!min_block_rewards) return callback(null, {}); let result = {}; for (let block in altblockList) { if (result.hasOwnProperty(block.port)) ++ result[block.port]; From 76a8fdd19bcfa420409f85942b977305069b76ff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 10:45:03 +0100 Subject: [PATCH 0279/2430] Fixed array iteration --- lib/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index ca906486..d577b17f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -474,7 +474,8 @@ function updatePoolStats2(poolType) { function (callback) { debug(threadName + "Checking LMDB for altBlocksFound array for each specific port"); let result = {}; - for (let block in altblockList) { + for (let i in altblockList) { + let block = altblockList[i]; if (result.hasOwnProperty(block.port)) ++ result[block.port]; else result[block.port] = 1; } From e7c8aa83b8963fd2c42a28114971e3b265684d8d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 10:49:54 +0100 Subject: [PATCH 0280/2430] Fixed param type for coin_port --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 547a7655..b041ebd8 100644 --- a/lib/api.js +++ b/lib/api.js @@ -306,7 +306,7 @@ app.get('/pool/altblocks', function (req, res) { app.get('/pool/coin_altblocks/:coin_port', 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, req.params.coin_port).slice(page*limit, (page + 1) * limit)); + res.json(global.database.getAltBlockList(null, parseInt(req.params.coin_port)).slice(page*limit, (page + 1) * limit)); }); app.get('/pool/payments/:pool_type', function (req, res) { From 70f33fcfbfe265524076c4d6e8ee8837f3ecab36 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 11:01:02 +0100 Subject: [PATCH 0281/2430] Fixed XMR hardcode --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index b041ebd8..e323ae2d 100644 --- a/lib/api.js +++ b/lib/api.js @@ -189,7 +189,7 @@ app.get('/config', function (req, res) { app.get('/pool/address_type/:address', function (req, res) { let address = req.params.address; if (addressBase58Prefix === cnUtil.address_decode(new Buffer(address))) { - res.json({valid: true, address_type: 'XMR'}); + 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'}); } else { From 314d1ce0c3fdd49e6d79174d871c0fd5fb5ab000 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 12:27:04 +0100 Subject: [PATCH 0282/2430] Improved admin email handling --- lib/pool.js | 5 +++++ lib/support.js | 2 +- lib/worker.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a3251c4e..2d5255bb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -933,6 +933,11 @@ function processShare(miner, job, blockTemplate, params) { // Did not manage to submit a block. Log and continue on. console.error(threadName + "Error submitting block at height " + job.height + " from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); + 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" + + threadName + "Error submitting block at height " + job.height + " from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + ); // Error on submit, so we'll submit a sanity check for good measure. //templateUpdate(); } else if (rpcResult) { diff --git a/lib/support.js b/lib/support.js index eb570f4a..78dbc27c 100644 --- a/lib/support.js +++ b/lib/support.js @@ -75,7 +75,7 @@ function sendEmailReal(toAddress, subject, email_body){ } function sendEmail(toAddress, subject, body, wallet){ - if (toAddress === global.config.general.adminEmail) { + if (toAddress === global.config.general.adminEmail && subject.indexOf("FYI") === -1) { sendEmailReal(toAddress, subject, body); } else { let reEmail = /^([a-zA-Z0-9_\.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; diff --git a/lib/worker.js b/lib/worker.js index d577b17f..da1b45e7 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -263,7 +263,7 @@ function updateShareStats() { 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, - "Pool hashrate/workers changed significantly", + "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 + ")" ); From 80f509e9c5b0526902d9198ea6ba5a9a31a8ae52 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 12:37:00 +0100 Subject: [PATCH 0283/2430] Reduced log amount --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2d5255bb..36ee7ad8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -260,7 +260,7 @@ function anchorBlockUpdate() { anchorBlockHeight = body.height + 1; if (!anchorBlockPrevHeight || anchorBlockPrevHeight != anchorBlockHeight) { anchorBlockPrevHeight = anchorBlockHeight; - console.log("Anchor block was changed to " + anchorBlockHeight); + debug("Anchor block was changed to " + anchorBlockHeight); } } else { console.error("Archor last block header request failed!"); @@ -1046,7 +1046,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } if (!miner.proxy) { if (job.submissions.indexOf(params.nonce) !== -1) { - console.warn(threadName + 'Duplicate share: ' + JSON.stringify(params) + ' from ' + miner.logString); + console.warn(threadName + 'Duplicate share with ' + params.nonce.toString() + ' nonce from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); global.database.storeInvalidShare(miner.invalidShareProto); @@ -1063,7 +1063,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } let nonce_test = `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; if (job.submissions.indexOf(nonce_test) !== -1) { - console.warn(threadName + 'Duplicate share: ' + JSON.stringify(params) + ' from ' + miner.logString); + console.warn(threadName + 'Duplicate proxy share with ' + params.nonce_test.toString() + ' nonce from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); global.database.storeInvalidShare(miner.invalidShareProto); From 886ac3cf375e0b39cd63ecffd8c4adc72f4701e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 13:51:23 +0100 Subject: [PATCH 0284/2430] Synced activePort template update and BT update --- lib/pool.js | 54 +++++++++++++++++++++++++++----------------------- lib/support.js | 2 +- lib/worker.js | 2 +- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 36ee7ad8..7f2c3a8e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -171,19 +171,23 @@ function checkAliveMiners() { } let isActivePortUpdateBlocked = false; +let activePortLastUpdateTime; // global.config.daemon.activePort is only updated in master thread -function updateActivePort() { - global.support.getActivePort(function (newActivePort) { - if (global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { - if (isActivePortUpdateBlocked) { - console.error("Blocked change of active port from " + global.config.daemon.activePort + " to " + newActivePort); - } else { +function updateActivePort(callback) { + let time_now = Date.now(); + if (!isActivePortUpdateBlocked && (!activePortLastUpdateTime || time_now - activePortLastUpdateTime > 3*1000)) { + activePortLastUpdateTime = time_now; + global.support.getActivePort(function (newActivePort) { + if (newActivePort && global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { console.log("Changing active port from " + global.config.daemon.activePort + " to " + newActivePort); global.config.daemon.activePort = newActivePort; } - } - }); + callback(); + }); + } else { + callback(); + } } // templateUpdateReal is only called in master thread @@ -229,20 +233,21 @@ function templateUpdate(repeating) { isActivePortUpdateBlocked = true; } } - global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function (err, body) { - if (err === null) { - let time_now = Date.now(); - let is_block_hash_updated = !lastBlockHash || body.hash !== lastBlockHash; - if (is_block_hash_updated) { - lastBlockHashUpdateTime = time_now; - lastBlockHash = body.hash; - templateUpdateReal(); + + updateActivePort(function() { + global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function (err, body) { + if (err === null) { + if (!lastBlockHash || body.hash !== lastBlockHash) { + lastBlockHashUpdateTime = Date.now(); + lastBlockHash = body.hash; + templateUpdateReal(); + } + if (repeating === true) setTimeout(templateUpdate, 50, repeating); + } else { + console.error("Last block header request for " + global.config.daemon.activePort + " port failed!"); + setTimeout(templateUpdate, 1000, repeating); } - if (repeating === true) setTimeout(templateUpdate, 50, repeating); - } else { - console.error("Last block header request for " + global.config.daemon.activePort + " port failed!"); - setTimeout(templateUpdate, 1000, repeating); - } + }); }); } @@ -931,12 +936,12 @@ function processShare(miner, job, blockTemplate, params) { 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. - console.error(threadName + "Error submitting block at height " + job.height + " from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); + console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); 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" + - threadName + "Error submitting block at height " + job.height + " from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) ); // Error on submit, so we'll submit a sanity check for good measure. //templateUpdate(); @@ -1197,8 +1202,7 @@ if (cluster.isMaster) { if (!global.config.daemon.activePort) { console.error("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); global.config.daemon.activePort = global.config.daemon.port; - } else { - setInterval(updateActivePort, 3*1000); + isActivePortUpdateBlocked = true; } templateUpdate(); diff --git a/lib/support.js b/lib/support.js index 78dbc27c..ed26fe78 100644 --- a/lib/support.js +++ b/lib/support.js @@ -177,7 +177,7 @@ function getActivePort(callback) { global.mysql.query("SELECT item_value FROM pool.config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { if (rows.length != 1) { console.error("Can't get pool.config.daemon.activePort value"); - return; + return callback(null); } callback(parseInt(rows[0].item_value)); }); diff --git a/lib/worker.js b/lib/worker.js index da1b45e7..8bfccc44 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -360,7 +360,7 @@ function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { function updatePoolStats(poolType) { if (global.config.daemon.activePort) { global.support.getActivePort(function (newActivePort) { - global.config.daemon.activePort = newActivePort; + if (newActivePort) global.config.daemon.activePort = newActivePort; updatePoolStats2(poolType); }); } else { From ea7ccc453c60eb87c103e2d75af7ba6c2645c204 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 15:34:21 +0100 Subject: [PATCH 0285/2430] Improved miner logging --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7f2c3a8e..2d67e325 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -467,7 +467,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validShares = 0; this.invalidShares = 0; this.hashes = 0; - this.logString = this.address + " ID: " + this.identifier + " IP: " + this.ipAddress; + this.logString = this.address + " (" + this.identifier + "/" + this.ipAddress + ")"; if (global.config.pool.trustedMiners) { if (!(this.payout in walletTrust)) { @@ -992,7 +992,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (!miner.valid_miner) { let time_now = Date.now(); if (!lastMessageTime || time_now - lastMessageTime > 30*1000) { - console.log("Invalid miner, disconnecting due to: " + miner.error); + console.log("Invalid miner " + miner.logString + ", disconnecting due to: " + miner.error); lastMessageTime = time_now; } sendReply(miner.error); From 6df949ab4b468c481b9b5e95d133e664110e329c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 15:41:33 +0100 Subject: [PATCH 0286/2430] Decrease miner wallet names in logs --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2d67e325..8ff5afcd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -467,7 +467,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validShares = 0; this.invalidShares = 0; this.hashes = 0; - this.logString = this.address + " (" + this.identifier + "/" + this.ipAddress + ")"; + this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + this.ipAddress + ")"; if (global.config.pool.trustedMiners) { if (!(this.payout in walletTrust)) { From 36ef6cb2d7a942f40767304b5bf84bb93573bfcc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 15:46:49 +0100 Subject: [PATCH 0287/2430] More unified miner reporting --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8ff5afcd..a049f39e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -567,7 +567,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer Math.floor(this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * global.config.pool.targetTime + " difficulty versus: " + this.newDiff); } if (this.fixed_diff) { - console.log("Dropped low fixed diff " + this.difficulty + " for " + this.payout + ":" + this.identifier + " miner to " + this.newDiff + " dynamic diff"); + console.log("Dropped low fixed diff " + this.difficulty + " for " + this.logString + " miner to " + this.newDiff + " dynamic diff"); this.fixed_diff = false; } this.sendNewJob(); From 4d9bf83073ab1e8ec4a022616c2f75be802ef4c5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 15:56:47 +0100 Subject: [PATCH 0288/2430] More logging to get possible emails of bad miners --- lib/pool.js | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a049f39e..93386fb3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -430,26 +430,29 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.valid_miner = false; } - if (this.valid_miner && pass_split.length === 2) { - /* - Email address is: pass_split[1] - Need to do an initial registration call here. Might as well do it right... - */ - let payoutAddress = this.payout; - let time_now = Date.now(); - if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { - global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [this.payout]).then(function (rows) { - if (rows.length > 0) { - return; - } - if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { - return; - } - global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, pass_split[1]]); - }); - walletLastCheckTime[payoutAddress] = time_now; + if (pass_split.length === 2) { + this.email = pass_split[1]; + if (this.valid_miner) { + // Email address is: pass_split[1] + // Need to do an initial registration call here. Might as well do it right... + let payoutAddress = this.payout; + let time_now = Date.now(); + if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { + global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [payoutAddress]).then(function (rows) { + if (rows.length > 0) { + return; + } + if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { + return; + } + global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, pass_split[1]]); + }); + walletLastCheckTime[payoutAddress] = time_now; + } } - } + } else { + this.email = ""; + } this.id = id; this.ipAddress = ipAddress; @@ -992,7 +995,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (!miner.valid_miner) { let time_now = Date.now(); if (!lastMessageTime || time_now - lastMessageTime > 30*1000) { - console.log("Invalid miner " + miner.logString + ", disconnecting due to: " + miner.error); + console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); lastMessageTime = time_now; } sendReply(miner.error); From 9b7539acd2fbd8cfb090efd3057417ed056c5423 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 20:07:07 +0100 Subject: [PATCH 0289/2430] Removed useless message --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 93386fb3..a92d7d12 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -140,7 +140,6 @@ function sendToWorkers(data) { function retargetMiners() { debug(threadName + "Performing difficulty check on miners"); - console.log('Performing difficulty update on miners'); for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; From 57ec515f0490514fd208cdbf8dca66b2501a478c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 3 Mar 2018 21:34:21 +0100 Subject: [PATCH 0290/2430] Added 3 second time before considering share to be outdated --- lib/pool.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a92d7d12..935030ac 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1089,14 +1089,17 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime) { let late_time = Date.now() - lastBlockTemplateUpdateTime; - let 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; - } else { - is_outdated = true; - } + if (late_time > 3*1000) { + late_time -= 3*1000; + let 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; + } else { + is_outdated = true; + } + } } if (!blockTemplate || is_outdated) { From 8b5cec3516fde2651fd792e871c352e80744b8d1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 7 Mar 2018 18:40:06 +0100 Subject: [PATCH 0291/2430] Separated active port update from block template updates --- lib/pool.js | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 935030ac..522f2654 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -170,29 +170,26 @@ function checkAliveMiners() { } let isActivePortUpdateBlocked = false; -let activePortLastUpdateTime; // global.config.daemon.activePort is only updated in master thread -function updateActivePort(callback) { - let time_now = Date.now(); - if (!isActivePortUpdateBlocked && (!activePortLastUpdateTime || time_now - activePortLastUpdateTime > 3*1000)) { - activePortLastUpdateTime = time_now; +function updateActivePort() { + if (!isActivePortUpdateBlocked) { global.support.getActivePort(function (newActivePort) { if (newActivePort && global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { console.log("Changing active port from " + global.config.daemon.activePort + " to " + newActivePort); global.config.daemon.activePort = newActivePort; } - callback(); }); - } else { - callback(); } } // templateUpdateReal is only called in master thread -function templateUpdateReal() { - let activePort = global.config.daemon.activePort; +function templateUpdateReal(activePort) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { + if (activePort !== global.config.daemon.activePort) { + console.log("Aborting " + activePort " last block template request because port was already changed to " + global.config.daemon.activePort + " port"); + return; + } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; rpcResponse.port = activePort; @@ -206,7 +203,7 @@ function templateUpdateReal() { } } else { console.error("Block template request failed for " + activePort + " port"); - setTimeout(templateUpdateReal, 3000); + setTimeout(templateUpdateReal, 3000, activePort); } }); } @@ -225,7 +222,7 @@ function templateUpdate(repeating) { } else { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " was switched to main chain", - "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was switch to main chain due to block tempalte stuck on " + global.config.daemon.activePort + " port" + "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was switch to main chain due to block template stuck on " + global.config.daemon.activePort + " port" ); console.error("Alt block height on " + global.config.daemon.activePort + " port was not updated for hours. Switching to main chain...."); global.config.daemon.activePort = global.config.daemon.port; @@ -233,21 +230,26 @@ function templateUpdate(repeating) { } } - updateActivePort(function() { - global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function (err, body) { - if (err === null) { - if (!lastBlockHash || body.hash !== lastBlockHash) { - lastBlockHashUpdateTime = Date.now(); - lastBlockHash = body.hash; - templateUpdateReal(); - } - if (repeating === true) setTimeout(templateUpdate, 50, repeating); - } else { - console.error("Last block header request for " + global.config.daemon.activePort + " port failed!"); - setTimeout(templateUpdate, 1000, repeating); + let activePort = global.config.daemon.activePort; + global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + if (activePort !== global.config.daemon.activePort) { + console.log("Aborting " + activePort " last block header request because port was already changed to " + global.config.daemon.activePort + " port"); + if (repeating === true) setTimeout(templateUpdate, 50, repeating); + return; + } + if (err === null) { + if (!lastBlockHash || body.hash !== lastBlockHash) { + lastBlockHashUpdateTime = Date.now(); + lastBlockHash = body.hash; + templateUpdateReal(activePort); } - }); + if (repeating === true) setTimeout(templateUpdate, 50, repeating); + } else { + console.error("Last block header request for " + global.config.daemon.activePort + " port failed!"); + setTimeout(templateUpdate, 1000, repeating); + } }); + } // main chain anchor block height for alt chain block @@ -1207,7 +1209,8 @@ if (cluster.isMaster) { if (!global.config.daemon.activePort) { console.error("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); global.config.daemon.activePort = global.config.daemon.port; - isActivePortUpdateBlocked = true; + } else { + setInterval(updateActivePort, 3*1000); } templateUpdate(); From 573d390f72935415cd6f7e722ea2976738f23199 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 7 Mar 2018 18:41:43 +0100 Subject: [PATCH 0292/2430] Fixed syntax error --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 522f2654..889d4ef4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -187,7 +187,7 @@ function updateActivePort() { function templateUpdateReal(activePort) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { if (activePort !== global.config.daemon.activePort) { - console.log("Aborting " + activePort " last block template request because port was already changed to " + global.config.daemon.activePort + " port"); + console.log("Aborting " + activePort + " last block template request because port was already changed to " + global.config.daemon.activePort + " port"); return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { From cfb4f09e271ca494e0b430956cbad37c915c616e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 7 Mar 2018 18:42:35 +0100 Subject: [PATCH 0293/2430] And another one --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 889d4ef4..85de4eff 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -233,7 +233,7 @@ function templateUpdate(repeating) { let activePort = global.config.daemon.activePort; global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (activePort !== global.config.daemon.activePort) { - console.log("Aborting " + activePort " last block header request because port was already changed to " + global.config.daemon.activePort + " port"); + console.log("Aborting " + activePort + " last block header request because port was already changed to " + global.config.daemon.activePort + " port"); if (repeating === true) setTimeout(templateUpdate, 50, repeating); return; } From 3566fd8f5b2a32eccef41bc7a83564ca38d1974c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Mar 2018 10:56:01 +0100 Subject: [PATCH 0294/2430] Added share throttling mechanic --- lib/pool.js | 144 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 97 insertions(+), 47 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 85de4eff..6c5051fe 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -26,29 +26,42 @@ 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; +let totalShares = 0, trustedShares = 0, normalShares = 0, invalidShares = 0, outdatedShares = 0, throttledShares = 0; + +// 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 = 20; // per thread +const VER_SHARES_PERIOD = 5; Buffer.prototype.toByteArray = function () { return Array.prototype.slice.call(this, 0); }; - if (cluster.isMaster) { threadName = "(Master) "; setInterval(function () { - let trustedSharesPercent = (trustedShares / totalShares * 100).toFixed(2); - let normalSharesPercent = (normalShares / totalShares * 100).toFixed(2); - let invalidSharesPercent = (invalidShares / totalShares * 100).toFixed(2); - let outdatedSharesPercent = (outdatedShares / totalShares * 100).toFixed(2); - console.log(`>>> Processed Trusted ${trustedShares} (${trustedSharesPercent}%) / Validated ${normalShares} (${normalSharesPercent}%) / Invalid ${invalidShares} (${invalidSharesPercent}%) / Outdated ${outdatedShares} (${outdatedSharesPercent}%) / Total shares ${totalShares} in the last 30 seconds`); - totalShares = 0; - trustedShares = 0; - normalShares = 0; - invalidShares = 0; - outdatedShares = 0; + let trustedSharesPercent = (trustedShares / totalShares * 100).toFixed(2); + let normalSharesPercent = (normalShares / totalShares * 100).toFixed(2); + let invalidSharesPercent = (invalidShares / totalShares * 100).toFixed(2); + let outdatedSharesPercent = (outdatedShares / totalShares * 100).toFixed(2); + let throttledSharesPercent = (throttledShares / totalShares * 100).toFixed(2); + console.log(`>>> Processed Trusted=${trustedShares}(${trustedSharesPercent}%) / Validated=${normalShares}(${normalSharesPercent}%) / Invalid=${invalidShares}(${invalidSharesPercent}%) / Outdated=${outdatedShares}(${outdatedSharesPercent}%) / Throttled=${throttledShares}(${throttledSharesPercent}%) / Total=${totalShares} shares in the last 30 seconds`); + totalShares = 0; + trustedShares = 0; + normalShares = 0; + invalidShares = 0; + outdatedShares = 0; + throttledShares = 0; }, 30000); } else { threadName = "(Worker " + cluster.worker.id + " - " + process.pid + ") "; + // reset last verified share counters every VER_SHARES_PERIOD seconds + setInterval(function () { + for (let wallet in minerWallets) { + minerWallets[wallet].last_ver_shares = 0; + } + }, VER_SHARES_PERIOD*1000); } global.database.thread_id = threadName; @@ -127,6 +140,12 @@ function messageHandler(message) { break; case 'outdatedShare': outdatedShares += 1; + // total shares will be also increased separately as part of share type above + break; + case 'throttledShare': + throttledShares += 1; + totalShares += 1; + break; } } @@ -150,7 +169,7 @@ function retargetMiners() { } } -// wallet " " proxy miner name -> { connectTime, count, hashes } +// wallet " " proxy miner name -> { connectTime, count (miner), hashes } // this is needed to set cummulative based diff for workers provided by Atreides proxy and xmrig-proxy let proxyMiners = {}; @@ -163,7 +182,8 @@ function checkAliveMiners() { process.send({type: 'removeMiner', data: miner.port}); delete activeMiners[minerId]; let proxyMinerName = miner.payout + ":" + miner.identifier; - if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName]["count"] <= 0) delete proxyMiners[proxyMinerName]; + if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; + if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; } } } @@ -537,7 +557,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let proxyMinerName = this.payout + ":" + this.identifier; if (proxyMinerName in proxyMiners) { let target = 5; - return Math.floor((proxyMiners[proxyMinerName]["hashes"] / (Math.floor((Date.now() - proxyMiners[proxyMinerName]["connectTime"]) / 1000))) * target); + return Math.floor((proxyMiners[proxyMinerName].hashes / (Math.floor((Date.now() - proxyMiners[proxyMinerName].connectTime) / 1000))) * target); + } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares > MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + let target = 5; + return Math.floor((minerWallets[this.payout].hashes / (Math.floor((Date.now() - minerWallets[this.payout].connectTime) / 1000))) * target); } else { let target = this.proxy ? 5 : global.config.pool.targetTime; return Math.floor((this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * target); @@ -592,7 +615,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (this.invalidShares / this.validShares >= global.config.pool.banPercent / 100) { delete activeMiners[this.id]; let proxyMinerName = this.payout + ":" + this.identifier; - if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName]["count"] <= 0) delete proxyMiners[proxyMinerName]; + if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; + if (this.payout in minerWallets && --minerWallets[this.payout].count <= 0) delete minerWallets[this.payout]; process.send({type: 'banIP', data: this.ipAddress}); } else { @@ -713,11 +737,11 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi let time_now = Date.now(); for (let worker_name in wallet) { let worker = wallet[worker_name]; - if (time_now - worker["time"] > 60*1000) { - let acc = worker["acc"]; + if (time_now - worker.time > 60*1000) { + let acc = worker.acc; if (acc != 0) { - let height = worker["height"]; - debug("!!! " + wallet_key + " / " + worker_name + ": storing old worker share " + height + " " + worker["difficulty"] + " " + time_now + " " + acc); + 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, paymentAddress: miner_address, @@ -726,7 +750,7 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi trustedShare: true, poolType: miner_poolTypeEnum, poolID: global.config.pool_id, - blockDiff: worker["difficulty"], + blockDiff: worker.difficulty, bitcoin: miner_bitcoin, blockHeight: height, timestamp: time_now, @@ -752,7 +776,7 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareType, blockTemplate) { miner.hashes += job.difficulty; let proxyMinerName = miner.payout + ":" + miner.identifier; - if (proxyMinerName in proxyMiners) proxyMiners[proxyMinerName]["hashes"] += job.difficulty; + 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; @@ -794,19 +818,19 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy 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"] = activeBlockTemplate.difficulty; - worker["time"] = time_now; - worker["acc"] = 0; + worker.height = db_job_height; + worker.difficulty = activeBlockTemplate.difficulty; + worker.time = time_now; + worker.acc = 0; } let worker = wallet[worker_name]; - let height = worker["height"]; - let difficulty = worker["difficulty"]; - let acc = worker["acc"]; + let height = worker.height; + let difficulty = worker.difficulty; + let acc = worker.acc; - if (height !== db_job_height || difficulty !== activeBlockTemplate.difficulty || time_now - worker["time"] > 60*1000 || acc >= 1000000) { + if (height !== db_job_height || difficulty !== activeBlockTemplate.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({ @@ -826,16 +850,16 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy })); } - worker["height"] = db_job_height; - worker["difficulty"] = activeBlockTemplate.difficulty; - worker["time"] = time_now; - worker["acc"] = job.rewarded_difficulty; + worker.height = db_job_height; + worker.difficulty = activeBlockTemplate.difficulty; + worker.time = time_now; + worker.acc = job.rewarded_difficulty; } else { - worker["acc"] += job.rewarded_difficulty; + worker.acc += job.rewarded_difficulty; } - debug("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + activeBlockTemplate.difficulty + " " + worker["time"] + " " + worker["acc"] + " (+" + job.rewarded_difficulty + ")"); + debug("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + activeBlockTemplate.difficulty + " " + worker.time + " " + worker.acc + " (+" + job.rewarded_difficulty + ")"); } if (is_walletAccFinalizer[wallet_key] === false) { @@ -901,12 +925,21 @@ function processShare(miner, job, blockTemplate, params) { let hash; let shareType; + if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; + if (global.config.pool.trustedMiners && miner.difficulty < 400000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability && miner.trust.check_height !== job.height) { hash = new Buffer(resultHash, 'hex'); shareType = true; - } - else { + } else { // verify share + if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares > MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { + console.error(threadName + "Throttled down miner share submission from " + miner.logString); + process.send({type: 'throttledShare'}); + miner.setNewDiff(miner.calcNewDiff()); + miner.sendNewJob(); + walletLastSeeTime[miner.payout] = Date.now(); + return null; + } convertedBlob = global.coinFuncs.convertBlob(shareBuffer); hash = global.coinFuncs.cryptoNight(convertedBlob); shareType = false; @@ -1004,16 +1037,29 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } process.send({type: 'newMiner', data: miner.port}); activeMiners[minerId] = miner; - if (!miner.proxy && params.agent && params.agent.includes('proxy')) { - let proxyMinerName = miner.payout + ":" + miner.identifier; - if (!(proxyMinerName in proxyMiners)) { - proxyMiners[proxyMinerName] = {}; - proxyMiners[proxyMinerName]["connectTime"] = Date.now(); - proxyMiners[proxyMinerName]["count"] = 0; - proxyMiners[proxyMinerName]["hashes"] = 0; - console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); + if (!miner.proxy) { + if (params.agent && params.agent.includes('proxy')) { + let proxyMinerName = miner.payout + ":" + miner.identifier; + if (!(proxyMinerName in proxyMiners)) { + proxyMiners[proxyMinerName] = {}; + proxyMiners[proxyMinerName].connectTime = Date.now(); + proxyMiners[proxyMinerName].count = 1; + proxyMiners[proxyMinerName].hashes = 0; + console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); + } else { + ++ proxyMiners[proxyMinerName].count; + } + } else { + if (!(miner.payout in minerWallets)) { + minerWallets[miner.payout] = {}; + minerWallets[miner.payout].connectTime = Date.now(); + minerWallets[miner.payout].count = 1; + minerWallets[miner.payout].hashes = 0; + minerWallets[miner.payout].last_ver_shares = 0; + } else { + ++ minerWallets[miner.payout].count; + } } - ++ proxyMiners[proxyMinerName]["count"]; } sendReply(null, { id: minerId, @@ -1121,6 +1167,10 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } let shareAccepted = processShare(miner, job, blockTemplate, params); + if (shareAccepted === null) { + sendReply('Throttle down share submission (please use xmr-node-proxy)'); + return; + } miner.checkBan(shareAccepted); if (global.config.pool.trustedMiners) { From bd7c54b9064c9ee2a42eab5f622387918041f6d0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Mar 2018 11:01:38 +0100 Subject: [PATCH 0295/2430] Added better throttled share logging --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6c5051fe..84f0ed55 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -933,7 +933,7 @@ function processShare(miner, job, blockTemplate, params) { shareType = true; } else { // verify share if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares > MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - console.error(threadName + "Throttled down miner share submission from " + miner.logString); + console.error(threadName + "Throttled down miner share (diff " + job.difficulty + ") submission from " + miner.logString); process.send({type: 'throttledShare'}); miner.setNewDiff(miner.calcNewDiff()); miner.sendNewJob(); From ff2c268abb00e70db70b3b0e958a6c4a2c81591a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Mar 2018 12:54:48 +0100 Subject: [PATCH 0296/2430] Decreased acceptable number of verified shares --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 84f0ed55..6694d393 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -31,7 +31,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 = 20; // per thread +const MAX_VER_SHARES_PER_SEC = 10; // per thread const VER_SHARES_PERIOD = 5; Buffer.prototype.toByteArray = function () { From 23953c4656d81cfb9285ecce17eb6515dda1ab7a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Mar 2018 13:19:30 +0100 Subject: [PATCH 0297/2430] Reduced number of log messages about throttled miners --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6694d393..9b815ff0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -558,7 +558,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (proxyMinerName in proxyMiners) { let target = 5; return Math.floor((proxyMiners[proxyMinerName].hashes / (Math.floor((Date.now() - proxyMiners[proxyMinerName].connectTime) / 1000))) * target); - } 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 >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { let target = 5; return Math.floor((minerWallets[this.payout].hashes / (Math.floor((Date.now() - minerWallets[this.payout].connectTime) / 1000))) * target); } else { @@ -932,8 +932,9 @@ function processShare(miner, job, blockTemplate, params) { hash = new Buffer(resultHash, 'hex'); shareType = true; } else { // verify share - if (miner.payout in minerWallets && ++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); + 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); process.send({type: 'throttledShare'}); miner.setNewDiff(miner.calcNewDiff()); miner.sendNewJob(); From 8ab794788809c0535981b8b0199ffa57a20630cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 8 Mar 2018 14:58:06 +0100 Subject: [PATCH 0298/2430] Compacted share info log message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9b815ff0..fe6222c9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -46,7 +46,7 @@ if (cluster.isMaster) { let invalidSharesPercent = (invalidShares / totalShares * 100).toFixed(2); let outdatedSharesPercent = (outdatedShares / totalShares * 100).toFixed(2); let throttledSharesPercent = (throttledShares / totalShares * 100).toFixed(2); - console.log(`>>> Processed Trusted=${trustedShares}(${trustedSharesPercent}%) / Validated=${normalShares}(${normalSharesPercent}%) / Invalid=${invalidShares}(${invalidSharesPercent}%) / Outdated=${outdatedShares}(${outdatedSharesPercent}%) / Throttled=${throttledShares}(${throttledSharesPercent}%) / Total=${totalShares} shares in the last 30 seconds`); + console.log(`>>> Trusted=${trustedShares}(${trustedSharesPercent}%) / Validated=${normalShares}(${normalSharesPercent}%) / Invalid=${invalidShares}(${invalidSharesPercent}%) / Outdated=${outdatedShares}(${outdatedSharesPercent}%) / Throttled=${throttledShares}(${throttledSharesPercent}%) / Total=${totalShares} shares`); totalShares = 0; trustedShares = 0; normalShares = 0; From 1de8387fe721f58158eaf25dad549e80a00b97b9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 09:51:42 +0100 Subject: [PATCH 0299/2430] Improved throttled share message clarity --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index fe6222c9..4ca10739 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1169,7 +1169,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let shareAccepted = processShare(miner, job, blockTemplate, params); if (shareAccepted === null) { - sendReply('Throttle down share submission (please use xmr-node-proxy)'); + sendReply('Throttled down share submission (please increase diff or use xmr-node-proxy)'); return; } miner.checkBan(shareAccepted); From 55d24de663b564e19cfc7cb54c26f873f54353dc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 14:46:40 +0100 Subject: [PATCH 0300/2430] Increased outdated block grace period by one second --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4ca10739..b5415ea7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1138,8 +1138,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime) { let late_time = Date.now() - lastBlockTemplateUpdateTime; - if (late_time > 3*1000) { - late_time -= 3*1000; + if (late_time > 4*1000) { + late_time -= 4*1000; let max_late_time = global.config.pool.targetTime*1000; if (late_time < max_late_time) { let factor = (max_late_time - late_time) / max_late_time; From 49a8bf673afaf78fdaaabd3023468b59876551d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 15:07:11 +0100 Subject: [PATCH 0301/2430] Decreased longRunner period --- lib/local_comms.js | 1 + lib/longRunner.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 43370b55..8fc4d9b1 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -944,6 +944,7 @@ function Database(){ } else { console.log("Block cleaning disabled. Would have removed: " + JSON.stringify(data)); } + console.log("Done cleaning up the share DB"); }); }; diff --git a/lib/longRunner.js b/lib/longRunner.js index 4013efba..ad5098ad 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -6,5 +6,4 @@ console.log("Done cleaning up the shareDB"); setInterval(function(){ console.log("Cleaning up the share DB"); global.database.cleanShareDB(); - console.log("Done cleaning up the shareDB"); -}, 3600000); \ No newline at end of file +}, 2*60*60*1000); From 42a80a15f90e6fce6b63ce7a620f37509b926979 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 15:07:46 +0100 Subject: [PATCH 0302/2430] Decreased it even more --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index ad5098ad..988cd0b9 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -6,4 +6,4 @@ console.log("Done cleaning up the shareDB"); setInterval(function(){ console.log("Cleaning up the share DB"); global.database.cleanShareDB(); -}, 2*60*60*1000); +}, 4*60*60*1000); From ee23225a828caff6d8326d22d7eb327a0e450384 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 15:12:38 +0100 Subject: [PATCH 0303/2430] Removed extra message --- lib/longRunner.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 988cd0b9..7b19f870 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -2,7 +2,6 @@ console.log("Cleaning up the share DB"); global.database.cleanShareDB(); -console.log("Done cleaning up the shareDB"); setInterval(function(){ console.log("Cleaning up the share DB"); global.database.cleanShareDB(); From 62a1b773b37a6a23e6d7bf34dcb2ca4c56e8b8c9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 18:13:16 +0100 Subject: [PATCH 0304/2430] Worker main loop cleanup --- lib/worker.js | 58 ++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 8bfccc44..836cfb73 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -34,8 +34,8 @@ function updateShareStats() { function (height, callback) { bad_header_stop(global.config.daemon.port); console.log("Starting stats collection for " + height + " height"); - let locTime = currentTime - (hashrate_avg_min*60*1000); - let identifierTime = currentTime - (2*hashrate_avg_min*60*1000); + const locTime = currentTime - (hashrate_avg_min*60*1000); + const identifierTime = currentTime - (2*hashrate_avg_min*60*1000); let localStats = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}}; let localMinerCount = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0}; let localTimes = { @@ -48,10 +48,11 @@ function updateShareStats() { let loopBreakout = 0; async.doUntil(function (callback_until) { let oldestTime = currentTime; - let loopCount = 0; 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; found = cursor.goToNextDup()) { + ++ count; cursor.getCurrentBinary(function (key, share) { // jshint ignore:line try { share = global.protos.Share.decode(share); @@ -59,62 +60,50 @@ function updateShareStats() { console.error(share); return; } - if (share.timestamp < oldestTime) { - oldestTime = share.timestamp; - } - if (share.timestamp <= identifierTime) { - return; - } + if (share.timestamp < oldestTime) oldestTime = share.timestamp; + if (share.timestamp <= identifierTime) return; + let minerID = share.paymentAddress; if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) { minerID = minerID + '.' + share.paymentID; } - if (minerID in identifiers && identifiers[minerID].indexOf(share.identifier) >= 0) { - loopCount += 1; - } else if (minerID in identifiers) { - identifiers[minerID].push(share.identifier); - ++ minerCount; + + if (minerID in identifiers) { + if (identifiers[minerID].indexOf(share.identifier) < 0) { + identifiers[minerID].push(share.identifier); + ++ minerCount; + } } else { identifiers[minerID] = [share.identifier]; ++ minerCount; } - if (share.timestamp <= locTime) { - return; - } + + if (share.timestamp <= locTime) return; + let minerIDWithIdentifier = minerID + "_" + share.identifier; localStats.global += share.shares; - if (localTimes.global <= share.timestamp) { - localTimes.global = share.timestamp; - } + 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; - if (localTimes.pplns <= share.timestamp) { - localTimes.pplns = share.timestamp; - } + if (localTimes.pplns <= share.timestamp) localTimes.pplns = share.timestamp; break; case global.protos.POOLTYPE.PPS: localStats.pps += share.shares; minerType = 'pps'; - if (localTimes.pps <= share.timestamp) { - localTimes.pps = share.timestamp; - } + if (localTimes.pps <= share.timestamp) localTimes.pps = share.timestamp; break; case global.protos.POOLTYPE.SOLO: localStats.solo += share.shares; minerType = 'solo'; - if (localTimes.solo <= share.timestamp) { - localTimes.solo = share.timestamp; - } + if (localTimes.solo <= share.timestamp) localTimes.solo = share.timestamp; break; } if (minerList.indexOf(minerID) >= 0) { localStats.miners[minerID] += share.shares; - if (localTimes.miners[minerID] < share.timestamp) { - localTimes.miners[minerID] = share.timestamp; - } + if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; } else { localMinerCount[minerType] += 1; localMinerCount.global += 1; @@ -124,9 +113,7 @@ function updateShareStats() { } if (minerList.indexOf(minerIDWithIdentifier) >= 0) { localStats.miners[minerIDWithIdentifier] += share.shares; - if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) { - localTimes.miners[minerIDWithIdentifier] = share.timestamp; - } + if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; } else { localStats.miners[minerIDWithIdentifier] = share.shares; localTimes.miners[minerIDWithIdentifier] = share.timestamp; @@ -136,6 +123,7 @@ function updateShareStats() { } cursor.close(); txn.abort(); + debug("Height " + height + ": " + count); return callback_until(null, oldestTime); }, function (oldestTime) { height -= 1; From eba838855acf5703299f7e8aad8d637aca435fa6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 18:19:40 +0100 Subject: [PATCH 0305/2430] Adde extra error check in payment module --- 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 36e79729..f2a6dbf5 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -343,7 +343,7 @@ 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 (body.error.message === "not enough money"){ + if (body.error.hasOwnProperty('message') && body.error.message === "not enough money"){ console.error("Issue making payments, not enough money, will try later"); setTimeout(getbalance, 10*60*1000); } else { From ab4ab55fa7ab0e0bf1e3af371d4ace4c0550576b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 18:28:25 +0100 Subject: [PATCH 0306/2430] Added one extra check --- 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 f2a6dbf5..9190798c 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -343,7 +343,7 @@ 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 (body.error.hasOwnProperty('message') && body.error.message === "not enough money"){ + if (typeof(body.error) !== 'undefined' && body.error.hasOwnProperty('message') && body.error.message === "not enough money"){ console.error("Issue making payments, not enough money, will try later"); setTimeout(getbalance, 10*60*1000); } else { From 54179fec49999bfc088ae53f00bf22773797f7f8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 18:37:24 +0100 Subject: [PATCH 0307/2430] Increased RPC timeout --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index ed26fe78..0c185f46 100644 --- a/lib/support.js +++ b/lib/support.js @@ -113,7 +113,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path) { uri = "http://" + host + ":" + port + "/"; } debug("JSON URI: " + uri + path + " Args: " + JSON.stringify(data)); - let client = requestJson.createClient(uri, {timeout: 30*1000}); + let client = requestJson.createClient(uri, {timeout: 5*60*1000}); client.headers["Content-Type"] = "application/json"; client.headers["Content-Length"] = data.length; client.headers["Accept"] = "application/json"; From 2121cf15a5620d482bc210f4c2c4218712655e24 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 18:40:34 +0100 Subject: [PATCH 0308/2430] Disabled some extra debug messages --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 836cfb73..de9a9f28 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -569,7 +569,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)); + //debug(threadName + "Sending the following to the workers: " + JSON.stringify(local_cache)); global.database.setCache('poolPorts', local_cache); } } From d929739f8a3b5f08abcc2412aa7d422170240fd8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 21:27:43 +0100 Subject: [PATCH 0309/2430] Added local history cache --- lib/worker.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index de9a9f28..98c85936 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -14,6 +14,8 @@ let lastBlockCheckIsFailed = {}; let prev_pool_hashrate; let prev_pool_workers; +let local_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. @@ -133,6 +135,7 @@ function updateShareStats() { } return oldestTime <= identifierTime; }, function (err) { + debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); // todo: Need to finish parsing the cached data into caches for caching purproses. let prevMinerList = global.database.getCache('minerList'); if (prevMinerList === false) prevMinerList = minerList; @@ -178,8 +181,14 @@ function updateShareStats() { //if (miner.indexOf('_') === -1){ // activeAddresses.push(miner); //} - let cachedData = global.database.getCache("history:" + miner); - if (cachedData === false) cachedData = global.database.getCache(miner); // for compatibility + let cachedData; + let keyHistory = "history:" + miner; + if (keyHistory in local_cache) { + cachedData = local_cache[keyHistory]; + } else { + cachedData = global.database.getCache(keyHistory); + if (cachedData === false) cachedData = global.database.getCache(miner); // for compatibility + } if (cachedData !== false) { cachedData.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; cachedData.lastHash = localTimes.miners[miner]; @@ -204,7 +213,8 @@ function updateShareStats() { badShares: 0 }; } - cache_updates["history:" + miner] = cachedData; + cache_updates[keyHistory] = cachedData; + local_cache[keyHistory] = cachedData; }); // remove old workers From d1ca99b5aee288a38be0b28a8f65e3561a783538 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 21:38:23 +0100 Subject: [PATCH 0310/2430] Added local_cache cleanup and simplified its key --- lib/worker.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 98c85936..aaf70310 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -183,8 +183,8 @@ function updateShareStats() { //} let cachedData; let keyHistory = "history:" + miner; - if (keyHistory in local_cache) { - cachedData = local_cache[keyHistory]; + if (miner in local_cache) { + cachedData = local_cache[miner]; } else { cachedData = global.database.getCache(keyHistory); if (cachedData === false) cachedData = global.database.getCache(miner); // for compatibility @@ -214,7 +214,7 @@ function updateShareStats() { }; } cache_updates[keyHistory] = cachedData; - local_cache[keyHistory] = cachedData; + local_cache[miner] = cachedData; }); // remove old workers @@ -743,3 +743,5 @@ if (global.config.solo.enable === true) setInterval(updatePoolStats, 5*1000, 'so setInterval(updatePoolInformation, 5*1000); setInterval(updateWalletStats, 60*1000); setInterval(monitorNodes, 5*60*1000); +// clean local_cache from time to time +setInterval(function() { local_cache = {}; } , 4*60*60*1000); From 8edf0053ea6cc5a6d5c2931b7f52337297361aa9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 9 Mar 2018 22:46:33 +0100 Subject: [PATCH 0311/2430] Added more getbalance checks --- lib/payment_systems/xmr.js | 2 +- lib/worker.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 9190798c..d55155c7 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -326,7 +326,7 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { function getbalance() { global.support.rpcWallet("getbalance", paymentDetails, function (body) { - if (body.hasOwnProperty('error') || !body.hasOwnProperty('result')) { + if (body.hasOwnProperty('error') || !body.hasOwnProperty('result') || !body.hasOwnProperty('result') || typeof(body.result) === 'undefined' || !body.result.hasOwnProperty('unlocked_balance') || typeof(body.result.unlocked_balance) !== "number") { console.error("Can't getbalance: " + JSON.stringify(body.error)); setTimeout(getbalance, 60*1000); return; diff --git a/lib/worker.js b/lib/worker.js index aaf70310..151d5bd4 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -136,7 +136,6 @@ function updateShareStats() { return oldestTime <= identifierTime; }, function (err) { debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); - // todo: Need to finish parsing the cached data into caches for caching purproses. let prevMinerList = global.database.getCache('minerList'); if (prevMinerList === false) prevMinerList = minerList; let cache_updates = {}; From ba1a06fdae2638d1cdbd073dabc7d6e83705800b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 06:54:51 +0100 Subject: [PATCH 0312/2430] Added more logs and more compact code in worker --- lib/pool.js | 9 +++++++-- lib/worker.js | 36 ++++++++++++++---------------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b5415ea7..8d42f4b1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -983,7 +983,7 @@ function processShare(miner, job, blockTemplate, params) { ); // Error on submit, so we'll submit a sanity check for good measure. //templateUpdate(); - } else if (rpcResult) { + } else if (rpcResult && typeof(rpcResponse.result) !== 'undefined') { //Success! Submitted a block without an issue. let blockFastHash = global.coinFuncs.getBlockID(shareBuffer).toString('hex'); console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + job.height + " by " + miner.logString + @@ -992,7 +992,12 @@ function processShare(miner, job, blockTemplate, params) { //templateUpdate(); } else { // RPC bombed out massively. - console.error(threadName + "RPC Error. Please check logs for details"); + 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", + "The pool server: " + global.config.hostname + " can't submit block to deamon on " + blockTemplate.port + " port\n" + + "RPC Error. Please check logs for details" + ); } }); } diff --git a/lib/worker.js b/lib/worker.js index 151d5bd4..12db11e8 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -48,13 +48,13 @@ function updateShareStats() { let identifiers = {}; let minerCount = 0; let loopBreakout = 0; + async.doUntil(function (callback_until) { let oldestTime = currentTime; + let count = 0; 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; found = cursor.goToNextDup()) { - ++ count; + 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); @@ -65,10 +65,8 @@ function updateShareStats() { if (share.timestamp < oldestTime) oldestTime = share.timestamp; if (share.timestamp <= identifierTime) return; - let minerID = share.paymentAddress; - if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) { - minerID = minerID + '.' + share.paymentID; - } + let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 + ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; if (minerID in identifiers) { if (identifiers[minerID].indexOf(share.identifier) < 0) { @@ -107,8 +105,8 @@ function updateShareStats() { localStats.miners[minerID] += share.shares; if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; } else { - localMinerCount[minerType] += 1; - localMinerCount.global += 1; + ++ localMinerCount[minerType]; + ++ localMinerCount.global; localStats.miners[minerID] = share.shares; localTimes.miners[minerID] = share.timestamp; minerList.push(minerID); @@ -127,13 +125,10 @@ function updateShareStats() { txn.abort(); debug("Height " + height + ": " + count); return callback_until(null, oldestTime); + }, function (oldestTime) { - height -= 1; - loopBreakout += 1; - if (loopBreakout > 60 || height < 0) { - return true; - } - return oldestTime <= identifierTime; + return ++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime; + }, function (err) { debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); let prevMinerList = global.database.getCache('minerList'); @@ -271,10 +266,7 @@ function updateShareStats() { }); } ], function (err, result) { - cycleCount += 1; - if (cycleCount === 3){ - cycleCount = 0; - } + if (++cycleCount === 3) cycleCount = 0; setTimeout(updateShareStats, 10*1000); }); } @@ -528,7 +520,7 @@ function updatePoolPorts(poolServers) { 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 += 1; + ++ portCount; if (!local_cache.hasOwnProperty(row.port_type)) { local_cache[row.port_type] = []; } @@ -546,7 +538,7 @@ function updatePoolPorts(poolServers) { let pool_type_count = 0; let localPortInfo = {}; for (let pool_type in local_cache) { // jshint ignore:line - pool_type_count += 1; + ++ pool_type_count; local_cache[pool_type].forEach(function (portData) { // jshint ignore:line if (!local_counts.hasOwnProperty(portData.port)) { local_counts[portData.port] = 0; @@ -558,7 +550,7 @@ function updatePoolPorts(poolServers) { port_miners[portData.port] = 0; } if (port_diff[portData.port] === portData.difficulty) { - local_counts[portData.port] += 1; + ++ local_counts[portData.port]; port_miners[portData.port] += portData.miners; } localPortInfo[portData.port] = portData.description; From a521f405a51ea8f425b8b115f1d4fbdc3dab76b5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 18:21:06 +0100 Subject: [PATCH 0313/2430] Workers optimizations and pool fixes --- lib/payment_systems/xmr.js | 2 +- lib/pool.js | 46 +++++--- lib/worker.js | 211 ++++++++++++++++++++++++++++++------- 3 files changed, 207 insertions(+), 52 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index d55155c7..734e83b5 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -326,7 +326,7 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { function getbalance() { global.support.rpcWallet("getbalance", paymentDetails, function (body) { - if (body.hasOwnProperty('error') || !body.hasOwnProperty('result') || !body.hasOwnProperty('result') || typeof(body.result) === 'undefined' || !body.result.hasOwnProperty('unlocked_balance') || typeof(body.result.unlocked_balance) !== "number") { + if (body.hasOwnProperty('error') || !body.hasOwnProperty('result') || typeof(body.result) === 'undefined' || !body.result.hasOwnProperty('unlocked_balance') || typeof(body.result.unlocked_balance) !== "number") { console.error("Can't getbalance: " + JSON.stringify(body.error)); setTimeout(getbalance, 60*1000); return; diff --git a/lib/pool.js b/lib/pool.js index 8d42f4b1..c5ac4346 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -907,23 +907,31 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy } function processShare(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.reserveOffset); - } else { - blockTemplate.buffer.copy(template); - template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset); - template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); - template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); + 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.reserveOffset); + } else { + blockTemplate.buffer.copy(template); + template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset); + template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); + template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); + } + try { + let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex')); + return shareBuffer; + } catch (e) { + console.error("Can't constructNewBlob from " + miner.logString + ": " + e); + return null; + } } - let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex')); - let convertedBlob; let hash; let shareType; + let shareBuffer; if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; @@ -941,7 +949,15 @@ function processShare(miner, job, blockTemplate, params) { walletLastSeeTime[miner.payout] = Date.now(); return null; } - convertedBlob = global.coinFuncs.convertBlob(shareBuffer); + shareBuffer = getShareBuffer(miner, job, blockTemplate, params); + if (shareBuffer === null) { + process.send({type: 'invalidShare'}); + miner.sendNewJob(); + walletTrust[miner.payout] = 0; + walletLastSeeTime[miner.payout] = Date.now(); + return false; + } + let convertedBlob = global.coinFuncs.convertBlob(shareBuffer); hash = global.coinFuncs.cryptoNight(convertedBlob); shareType = false; ++ walletTrust[miner.payout]; @@ -967,10 +983,10 @@ function processShare(miner, job, blockTemplate, params) { 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); 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. diff --git a/lib/worker.js b/lib/worker.js index 12db11e8..8d69df63 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -15,6 +15,7 @@ let prev_pool_hashrate; let prev_pool_workers; let local_cache = {}; +let share_cache = {}; function updateShareStats() { // This is an omni-worker to deal with all things share-stats related @@ -36,34 +37,116 @@ function updateShareStats() { function (height, callback) { bad_header_stop(global.config.daemon.port); console.log("Starting stats collection for " + height + " height"); + const locTime = currentTime - (hashrate_avg_min*60*1000); const identifierTime = currentTime - (2*hashrate_avg_min*60*1000); - let localStats = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}}; - let localMinerCount = {pplns: 0, pps: 0, solo: 0, prop: 0, global: 0}; - let localTimes = { - pplns: locTime, pps: locTime, solo: locTime, prop: locTime, - global: locTime, miners: {} - }; - let minerList = []; + let identifiers = {}; + let minerList = []; 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: {} }; + let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; let loopBreakout = 0; + let new_share_cache = {}; + async.doUntil(function (callback_until) { let oldestTime = currentTime; - let count = 0; let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - for (let found = (cursor.goToRange(height) === height); found; ++ count, found = cursor.goToNextDup()) { - cursor.getCurrentBinary(function (key, share) { // jshint ignore:line + let found = cursor.goToRange(height) === height; + let is_use_cache = false; + + if (found && height in share_cache) { + let ci = share_cache[height]; + if (locTime < ci.min_timestamp && ci.last_timestamp && cursor.goToLastDup()) { + cursor.getCurrentBinary(function (key, share) { // jshint ignore:line + try { + share = global.protos.Share.decode(share); + } catch (e) { + console.error(share); + return; + } + if (share.timestamp === ci.last_timestamp) { + is_use_cache = true; + } else { + debug("Found share cache on " + height + " height was modified"); + found = cursor.goToFirstDup(); + } + }); + } + } + + if (is_use_cache) { + debug("Using share cache on " + height + " height"); + let ci = share_cache[height]; + new_share_cache[height] = ci; + + if (ci.min_timestamp < oldestTime) oldestTime = ci.min_timestamp; + + for (let minerID in ci.identifiers) { + if (minerID in identifiers) { + for (let identifier in ci.identifiers[minerID]) { + if (identifiers[minerID].indexOf(identifier) < 0) { + identifiers[minerID].push(identifier); + ++ minerCount; + } + } + } else { + identifiers[minerID] = ci.identifiers[minerID]; + minerCount += ci.identifiers[minerID].length; + } + } + + localStats.global += ci.localStats.global; + localStats.pplns += ci.localStats.pplns; + localStats.pps += ci.localStats.pps; + localStats.solo += ci.localStats.solo; + if (localTimes.global < ci.localTimes.global) localTimes.global = ci.localTimes.global; + if (localTimes.pplns < ci.localTimes.pplns) localTimes.pplns = ci.localTimes.pplns; + if (localTimes.pps < ci.localTimes.pps) localTimes.pps = ci.localTimes.pps; + if (localTimes.solo < ci.localTimes.solo) localTimes.solo = ci.localTimes.solo; + + for (let minerID in ci.minerList) { + if (minerList.indexOf(minerID) >= 0) { + localStats.miners[minerID] += ci.localStats.miners[minerID]; + if (localTimes.miners[minerID] < ci.localTimes.miners[minerID]) localTimes.miners[minerID] = ci.localTimes.miners[minerID]; + } else { + if (minerID.indexOf('_') < 0) { + ++ localMinerCount.global; + ++ localMinerCount[ci.localMinerType[minerID]]; + } + localStats.miners[minerID] = ci.localStats.miners[minerID]; + localTimes.miners[minerID] = ci.localTimes.miners[minerID]; + minerList.push(minerID); + } + } + + } else { + let ci = { + min_timestamp: currentTime, + identifiers: {}, + minerList: [], + localMinerType: {}, + localStats: { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {} }, + localTimes: { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }, + }; + let is_add_new_share_cache_item = true; + let count = 0; + for (; 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); + is_add_new_share_cache_item = false; return; } if (share.timestamp < oldestTime) oldestTime = share.timestamp; - if (share.timestamp <= identifierTime) return; + if (share.timestamp <= identifierTime) { + is_add_new_share_cache_item = false; + return; + } let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; @@ -78,27 +161,30 @@ function updateShareStats() { ++ minerCount; } - if (share.timestamp <= locTime) return; + if (share.timestamp <= locTime) { + is_add_new_share_cache_item = false; + return; + } let minerIDWithIdentifier = minerID + "_" + share.identifier; localStats.global += share.shares; - if (localTimes.global <= share.timestamp) localTimes.global = share.timestamp; + 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; - if (localTimes.pplns <= share.timestamp) localTimes.pplns = share.timestamp; + if (localTimes.pplns < share.timestamp) localTimes.pplns = share.timestamp; break; case global.protos.POOLTYPE.PPS: localStats.pps += share.shares; minerType = 'pps'; - if (localTimes.pps <= share.timestamp) localTimes.pps = share.timestamp; + if (localTimes.pps < share.timestamp) localTimes.pps = share.timestamp; break; case global.protos.POOLTYPE.SOLO: localStats.solo += share.shares; minerType = 'solo'; - if (localTimes.solo <= share.timestamp) localTimes.solo = share.timestamp; + if (localTimes.solo < share.timestamp) localTimes.solo = share.timestamp; break; } if (minerList.indexOf(minerID) >= 0) { @@ -119,17 +205,70 @@ function updateShareStats() { localTimes.miners[minerIDWithIdentifier] = share.timestamp; minerList.push(minerIDWithIdentifier); } + + // share cache item + if (is_add_new_share_cache_item) { + if (share.timestamp < ci.min_timestamp) ci.min_timestamp = share.timestamp; + ci.last_timestamp = share.timestamp; + + if (minerID in ci.identifiers) { + if (ci.identifiers[minerID].indexOf(share.identifier) < 0) { + ci.identifiers[minerID].push(share.identifier); + } + } else { + ci.identifiers[minerID] = [share.identifier]; + } + + ci.localStats.global += share.shares; + if (ci.localTimes.global <= share.timestamp) ci.localTimes.global = share.timestamp; + switch (share.poolType) { + case global.protos.POOLTYPE.PPLNS: + ci.localStats.pplns += share.shares; + if (ci.localTimes.pplns <= share.timestamp) ci.localTimes.pplns = share.timestamp; + break; + case global.protos.POOLTYPE.PPS: + ci.localStats.pps += share.shares; + if (ci.localTimes.pps <= share.timestamp) ci.localTimes.pps = share.timestamp; + break; + case global.protos.POOLTYPE.SOLO: + ci.localStats.solo += share.shares; + if (ci.localTimes.solo <= share.timestamp) ci.localTimes.solo = share.timestamp; + break; + } + if (ci.minerList.indexOf(minerID) >= 0) { + ci.localStats.miners[minerID] += share.shares; + if (ci.localTimes.miners[minerID] < share.timestamp) ci.localTimes.miners[minerID] = share.timestamp; + } else { + ci.localMinerType[minerID] = minerType; + ci.localStats.miners[minerID] = share.shares; + ci.localTimes.miners[minerID] = share.timestamp; + ci.minerList.push(minerID); + } + if (ci.minerList.indexOf(minerIDWithIdentifier) >= 0) { + ci.localStats.miners[minerIDWithIdentifier] += share.shares; + if (ci.localTimes.miners[minerIDWithIdentifier] < share.timestamp) ci.localTimes.miners[minerIDWithIdentifier] = share.timestamp; + } else { + ci.localStats.miners[minerIDWithIdentifier] = share.shares; + ci.localTimes.miners[minerIDWithIdentifier] = share.timestamp; + ci.minerList.push(minerIDWithIdentifier); + } + } }); + debug("On " + height + " height iterated " + count + " elements"); + if (is_add_new_share_cache_item) { + debug("Added new cache item on " + height + " height"); + new_share_cache[height] = ci; + } } cursor.close(); txn.abort(); - debug("Height " + height + ": " + count); return callback_until(null, oldestTime); }, function (oldestTime) { return ++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime; }, function (err) { + share_cache = new_share_cache; debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); let prevMinerList = global.database.getCache('minerList'); if (prevMinerList === false) prevMinerList = minerList; @@ -214,7 +353,7 @@ function updateShareStats() { // remove old workers prevMinerList.forEach(function (miner) { if (minerList.indexOf(miner) !== -1) return; // we still have this miner in current list - debug("Removing: " + miner + " as an active miner from the cache."); + //debug("Removing: " + miner + " as an active miner from the cache."); let minerStats = global.database.getCache(miner); minerStats.hash = 0; cache_updates[miner] = minerStats; @@ -231,7 +370,7 @@ function updateShareStats() { // find new workers minerList.forEach(function (miner) { if (prevMinerList.indexOf(miner) !== -1) return; // we still have this miner in previous list - debug("Adding: " + miner + " as an active miner to the cache."); + //debug("Adding: " + miner + " as an active miner to the cache."); if (miner.indexOf('_') <= -1) return; // This is a worker case. @@ -391,19 +530,19 @@ function updatePoolStats2(poolType) { async.series([ function (callback) { - debug(threadName + "Checking Influx for last 5min avg for pool stats (hashRate)"); + //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)"); + //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"); + //debug(threadName + "Checking LMDB cache for totalHashes"); return callback(null, cache.totalHashes || 0); }, function (callback) { - debug(threadName + "Checking LMDB for lastBlockFoundTime for pool stats"); + //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); @@ -414,18 +553,18 @@ function updatePoolStats2(poolType) { return callback(null, max_time); }, function (callback) { - debug(threadName + "Checking LMDB for lastBlockFound height for pool stats"); + //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"); + //debug(threadName + "Checking LMDB for totalBlocksFound for pool stats"); return callback(null, blockList.length); }, function (callback) { - debug(threadName + "Checking MySQL for total miners paid"); + //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); @@ -437,7 +576,7 @@ function updatePoolStats2(poolType) { } }, function (callback) { - debug(threadName + "Checking MySQL for total transactions count"); + //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); @@ -453,15 +592,15 @@ function updatePoolStats2(poolType) { } }, function (callback) { - debug(threadName + "Checking LMDB cache for roundHashes"); + //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"); + //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"); + //debug(threadName + "Checking LMDB for altBlocksFound array for each specific port"); let result = {}; for (let i in altblockList) { let block = altblockList[i]; @@ -471,21 +610,21 @@ function updatePoolStats2(poolType) { return callback(null, result); }, function (callback) { - debug(threadName + "Checking MySQL for activePort value"); + //debug(threadName + "Checking MySQL for activePort value"); return callback(null, global.config.daemon.activePort ? global.config.daemon.activePort : global.config.daemon.port); }, function (callback) { - debug(threadName + "Checking LMDB cache for xmr_profit value"); + //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 xmr_profit_comment value"); + //debug(threadName + "Checking LMDB cache for xmr_profit_comment value"); let xmr_profit_comment = global.database.getCache('xmr_profit_comment'); return callback(null, xmr_profit_comment ? xmr_profit_comment.value : ""); }, function (callback) { - debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); + //debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); let min_block_rewards = global.database.getCache('min_block_rewards'); return callback(null, min_block_rewards ? min_block_rewards : {}); } @@ -515,7 +654,7 @@ function updatePoolStats2(poolType) { } function updatePoolPorts(poolServers) { - debug(threadName + "Updating pool ports"); + //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) { @@ -581,7 +720,7 @@ function updatePoolPorts(poolServers) { function updatePoolInformation() { let local_cache = {}; - debug(threadName + "Updating pool information"); + //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] = { From 0f341323134b0c2643a258a73b9e8971d36f3aad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 18:35:36 +0100 Subject: [PATCH 0314/2430] Optimized share processing --- lib/pool.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c5ac4346..62ca26cb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -932,8 +932,10 @@ function processShare(miner, job, blockTemplate, params) { let hash; let shareType; let shareBuffer; + let resultHash = params.result; 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 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability && miner.trust.check_height !== job.height) { @@ -946,7 +948,6 @@ function processShare(miner, job, blockTemplate, params) { process.send({type: 'throttledShare'}); miner.setNewDiff(miner.calcNewDiff()); miner.sendNewJob(); - walletLastSeeTime[miner.payout] = Date.now(); return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -954,29 +955,28 @@ function processShare(miner, job, blockTemplate, params) { process.send({type: 'invalidShare'}); miner.sendNewJob(); walletTrust[miner.payout] = 0; - walletLastSeeTime[miner.payout] = Date.now(); return false; } let convertedBlob = global.coinFuncs.convertBlob(shareBuffer); hash = global.coinFuncs.cryptoNight(convertedBlob); - shareType = false; - ++ walletTrust[miner.payout]; - walletLastSeeTime[miner.payout] = Date.now(); - } - if (hash.toString('hex') !== resultHash) { - console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); - process.send({type: 'invalidShare'}); - if (miner.incremented === false) { - miner.newDiff = miner.difficulty + 1; - miner.incremented = true; - } else { - miner.newDiff = miner.difficulty - 1; - miner.incremented = false; + + if (hash.toString('hex') !== resultHash) { + console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); + process.send({type: 'invalidShare'}); + if (miner.incremented === false) { + miner.newDiff = miner.difficulty + 1; + miner.incremented = true; + } else { + miner.newDiff = miner.difficulty - 1; + miner.incremented = false; + } + miner.sendNewJob(); + walletTrust[miner.payout] = 0; + return false; } - miner.sendNewJob(); - walletTrust[miner.payout] = 0; - walletLastSeeTime[miner.payout] = Date.now(); - return false; + + ++ walletTrust[miner.payout]; + shareType = false; } let hashArray = hash.toByteArray().reverse(); From 046d08d5c2d1bde36222a2b5f881dc6fe865f9dc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 18:50:00 +0100 Subject: [PATCH 0315/2430] Fixed var name --- lib/pool.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 62ca26cb..c2fa1d91 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -906,29 +906,29 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy } -function processShare(miner, job, blockTemplate, params) { - 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.reserveOffset); - } else { - blockTemplate.buffer.copy(template); - template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset); - template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); - template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); - } - try { - let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex')); - return shareBuffer; - } catch (e) { - console.error("Can't constructNewBlob from " + miner.logString + ": " + e); - return null; - } +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.reserveOffset); + } else { + blockTemplate.buffer.copy(template); + template.writeUInt32BE(job.extraNonce, blockTemplate.reserveOffset); + template.writeUInt32BE(params.poolNonce, job.clientPoolLocation); + template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); + } + try { + let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex')); + return shareBuffer; + } catch (e) { + console.error("Can't constructNewBlob from " + miner.logString + ": " + e); + return null; } +} +function processShare(miner, job, blockTemplate, params) { let hash; let shareType; let shareBuffer; @@ -999,7 +999,7 @@ function processShare(miner, job, blockTemplate, params) { ); // Error on submit, so we'll submit a sanity check for good measure. //templateUpdate(); - } else if (rpcResult && typeof(rpcResponse.result) !== 'undefined') { + } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { //Success! Submitted a block without an issue. let blockFastHash = global.coinFuncs.getBlockID(shareBuffer).toString('hex'); console.log(threadName + "Block " + blockFastHash.substr(0, 6) + " found at height " + job.height + " by " + miner.logString + From 1dd79d97ab3f6998252511d003808f0fb1b61cdb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 19:14:14 +0100 Subject: [PATCH 0316/2430] Fixed bad cache bug --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 8d69df63..44fd106c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -355,6 +355,7 @@ function updateShareStats() { if (minerList.indexOf(miner) !== -1) return; // we still have this miner in current list //debug("Removing: " + miner + " as an active miner from the cache."); let minerStats = global.database.getCache(miner); + if (!minerStats) return; minerStats.hash = 0; cache_updates[miner] = minerStats; if (miner.indexOf('_') <= -1) return; From 9468882ebacfe0f4775793bee6ef487d27509f1e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 19:17:44 +0100 Subject: [PATCH 0317/2430] Disable cache for now --- lib/worker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index 44fd106c..0d0fd32b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -78,6 +78,8 @@ function updateShareStats() { } } + is_use_cache = false; + if (is_use_cache) { debug("Using share cache on " + height + " height"); let ci = share_cache[height]; From 614fb11942949bcf6cd3c13cb853dda553e8449b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 19:28:04 +0100 Subject: [PATCH 0318/2430] Fixed stats --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 0d0fd32b..53092436 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -79,6 +79,7 @@ function updateShareStats() { } is_use_cache = false; + found = cursor.goToFirstDup(); if (is_use_cache) { debug("Using share cache on " + height + " height"); From 171280e4b1bb93f48cecf3f3c68c44f7b8563f2e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 19:30:37 +0100 Subject: [PATCH 0319/2430] Added more debug logs --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 53092436..fef06614 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -69,6 +69,7 @@ function updateShareStats() { return; } if (share.timestamp === ci.last_timestamp) { + debug("Can use share cache on " + height + " height"); is_use_cache = true; } else { debug("Found share cache on " + height + " height was modified"); From f707098c39c8c6a12cffbcada20dc30b8182aa81 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 20:03:17 +0100 Subject: [PATCH 0320/2430] Switched to sets from arrays --- lib/worker.js | 59 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index fef06614..1189ab07 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -42,7 +42,7 @@ function updateShareStats() { const identifierTime = currentTime - (2*hashrate_avg_min*60*1000); let identifiers = {}; - let minerList = []; + let minerSet = {}; 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: {} }; @@ -79,8 +79,8 @@ function updateShareStats() { } } - is_use_cache = false; - found = cursor.goToFirstDup(); + //is_use_cache = false; + //found = cursor.goToFirstDup(); if (is_use_cache) { debug("Using share cache on " + height + " height"); @@ -91,9 +91,10 @@ function updateShareStats() { for (let minerID in ci.identifiers) { if (minerID in identifiers) { - for (let identifier in ci.identifiers[minerID]) { - if (identifiers[minerID].indexOf(identifier) < 0) { - identifiers[minerID].push(identifier); + for (let i in ci.identifiers[minerID]) { + let id = ci.identifiers[minerID][i]; + if (identifiers[minerID].indexOf(id) < 0) { + identifiers[minerID].push(id); ++ minerCount; } } @@ -112,8 +113,8 @@ function updateShareStats() { if (localTimes.pps < ci.localTimes.pps) localTimes.pps = ci.localTimes.pps; if (localTimes.solo < ci.localTimes.solo) localTimes.solo = ci.localTimes.solo; - for (let minerID in ci.minerList) { - if (minerList.indexOf(minerID) >= 0) { + for (let minerID in ci.minerSet) { + if (minerID in minerSet) { localStats.miners[minerID] += ci.localStats.miners[minerID]; if (localTimes.miners[minerID] < ci.localTimes.miners[minerID]) localTimes.miners[minerID] = ci.localTimes.miners[minerID]; } else { @@ -123,7 +124,7 @@ function updateShareStats() { } localStats.miners[minerID] = ci.localStats.miners[minerID]; localTimes.miners[minerID] = ci.localTimes.miners[minerID]; - minerList.push(minerID); + minerSet[minerID] = 1; } } @@ -131,7 +132,7 @@ function updateShareStats() { let ci = { min_timestamp: currentTime, identifiers: {}, - minerList: [], + minerSet: [], localMinerType: {}, localStats: { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {} }, localTimes: { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }, @@ -191,7 +192,7 @@ function updateShareStats() { if (localTimes.solo < share.timestamp) localTimes.solo = share.timestamp; break; } - if (minerList.indexOf(minerID) >= 0) { + if (minerID in minerSet) { localStats.miners[minerID] += share.shares; if (localTimes.miners[minerID] < share.timestamp) localTimes.miners[minerID] = share.timestamp; } else { @@ -199,15 +200,15 @@ function updateShareStats() { ++ localMinerCount.global; localStats.miners[minerID] = share.shares; localTimes.miners[minerID] = share.timestamp; - minerList.push(minerID); + minerSet[minerID] = 1; } - if (minerList.indexOf(minerIDWithIdentifier) >= 0) { + if (minerIDWithIdentifier in minerSet) { localStats.miners[minerIDWithIdentifier] += share.shares; if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; } else { localStats.miners[minerIDWithIdentifier] = share.shares; localTimes.miners[minerIDWithIdentifier] = share.timestamp; - minerList.push(minerIDWithIdentifier); + minerSet[minerIDWithIdentifier] = 1; } // share cache item @@ -228,33 +229,33 @@ function updateShareStats() { switch (share.poolType) { case global.protos.POOLTYPE.PPLNS: ci.localStats.pplns += share.shares; - if (ci.localTimes.pplns <= share.timestamp) ci.localTimes.pplns = share.timestamp; + if (ci.localTimes.pplns < share.timestamp) ci.localTimes.pplns = share.timestamp; break; case global.protos.POOLTYPE.PPS: ci.localStats.pps += share.shares; - if (ci.localTimes.pps <= share.timestamp) ci.localTimes.pps = share.timestamp; + if (ci.localTimes.pps < share.timestamp) ci.localTimes.pps = share.timestamp; break; case global.protos.POOLTYPE.SOLO: ci.localStats.solo += share.shares; - if (ci.localTimes.solo <= share.timestamp) ci.localTimes.solo = share.timestamp; + if (ci.localTimes.solo < share.timestamp) ci.localTimes.solo = share.timestamp; break; } - if (ci.minerList.indexOf(minerID) >= 0) { + if (minerID in ci.minerSet) { ci.localStats.miners[minerID] += share.shares; if (ci.localTimes.miners[minerID] < share.timestamp) ci.localTimes.miners[minerID] = share.timestamp; } else { ci.localMinerType[minerID] = minerType; ci.localStats.miners[minerID] = share.shares; ci.localTimes.miners[minerID] = share.timestamp; - ci.minerList.push(minerID); + ci.minerSet[minerID] = 1; } - if (ci.minerList.indexOf(minerIDWithIdentifier) >= 0) { + if (minerIDWithIdentifier in ci.minerSet) { ci.localStats.miners[minerIDWithIdentifier] += share.shares; if (ci.localTimes.miners[minerIDWithIdentifier] < share.timestamp) ci.localTimes.miners[minerIDWithIdentifier] = share.timestamp; } else { ci.localStats.miners[minerIDWithIdentifier] = share.shares; ci.localTimes.miners[minerIDWithIdentifier] = share.timestamp; - ci.minerList.push(minerIDWithIdentifier); + ci.minerSet[minerIDWithIdentifier] = 1; } } }); @@ -274,8 +275,8 @@ function updateShareStats() { }, function (err) { share_cache = new_share_cache; debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); - let prevMinerList = global.database.getCache('minerList'); - if (prevMinerList === false) prevMinerList = minerList; + 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) { @@ -314,7 +315,7 @@ function updateShareStats() { } cache_updates[key + "_stats"] = cachedData; }); - minerList.forEach(function (miner) { + minerSet.forEach(function (miner) { //if (miner.indexOf('_') === -1){ // activeAddresses.push(miner); //} @@ -355,8 +356,8 @@ function updateShareStats() { }); // remove old workers - prevMinerList.forEach(function (miner) { - if (minerList.indexOf(miner) !== -1) return; // we still have this miner in current list + prevMinerSet.forEach(function (miner) { + if (miner in minerSet) return; // 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) return; @@ -373,8 +374,8 @@ function updateShareStats() { }); // find new workers - minerList.forEach(function (miner) { - if (prevMinerList.indexOf(miner) !== -1) return; // we still have this miner in previous list + minerSet.forEach(function (miner) { + if (miner in prevMinerSet) return; // we still have this miner in previous set //debug("Adding: " + miner + " as an active miner to the cache."); if (miner.indexOf('_') <= -1) return; @@ -389,7 +390,7 @@ function updateShareStats() { Object.keys(identifiers).forEach(function (key) { cache_updates[key + '_identifiers'] = identifiers[key]; }); - cache_updates.minerList = minerList; + cache_updates.minerSet = minerSet; global.database.bulkSetCache(cache_updates); let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; From 8981258270397a8ad2bd1793fad94f4b050dd556 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 20:07:49 +0100 Subject: [PATCH 0321/2430] Fixed loops --- lib/worker.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 1189ab07..cbfc5c29 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -315,7 +315,7 @@ function updateShareStats() { } cache_updates[key + "_stats"] = cachedData; }); - minerSet.forEach(function (miner) { + for (let miner in minerSet) { //if (miner.indexOf('_') === -1){ // activeAddresses.push(miner); //} @@ -353,17 +353,17 @@ function updateShareStats() { } cache_updates[keyHistory] = cachedData; local_cache[miner] = cachedData; - }); + } // remove old workers - prevMinerSet.forEach(function (miner) { - if (miner in minerSet) return; // we still have this miner in current set + 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) return; + if (!minerStats) continue; minerStats.hash = 0; cache_updates[miner] = minerStats; - if (miner.indexOf('_') <= -1) return; + if (miner.indexOf('_') <= -1) continue; // This is a worker case. let address_parts = miner.split(/_(.+)/); @@ -371,13 +371,13 @@ function updateShareStats() { get_address_email(address, function (email) { setTimeout(delayed_send_worker_stopped_hashing_email, 5*60*1000, miner, email, currentTime); }); - }); + } // find new workers - minerSet.forEach(function (miner) { - if (miner in prevMinerSet) return; // we still have this miner in previous set + 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) return; + if (miner.indexOf('_') <= -1) continue; // This is a worker case. let address_parts = miner.split(/_(.+)/); @@ -385,7 +385,7 @@ function updateShareStats() { get_address_email(address, function (email) { send_worker_started_hashing_email(miner, email, currentTime); }); - }); + } Object.keys(identifiers).forEach(function (key) { cache_updates[key + '_identifiers'] = identifiers[key]; From b1da5db36c47beddc40362768e580083abb6c437 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 20:11:05 +0100 Subject: [PATCH 0322/2430] Disabled cache --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index cbfc5c29..ecd9609b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -79,8 +79,8 @@ function updateShareStats() { } } - //is_use_cache = false; - //found = cursor.goToFirstDup(); + is_use_cache = false; + found = cursor.goToFirstDup(); if (is_use_cache) { debug("Using share cache on " + height + " height"); From 98a0e844745532816deee0f9a996eccf83807fad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 20:19:22 +0100 Subject: [PATCH 0323/2430] Disabled all share cache machinery --- lib/worker.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index ecd9609b..d34d133c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -15,7 +15,7 @@ let prev_pool_hashrate; let prev_pool_workers; let local_cache = {}; -let share_cache = {}; +//let share_cache = {}; function updateShareStats() { // This is an omni-worker to deal with all things share-stats related @@ -49,16 +49,16 @@ function updateShareStats() { let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; let loopBreakout = 0; - let new_share_cache = {}; + //let new_share_cache = {}; 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 found = cursor.goToRange(height) === height; - let is_use_cache = false; + //let is_use_cache = false; - if (found && height in share_cache) { + /*if (found && height in share_cache) { let ci = share_cache[height]; if (locTime < ci.min_timestamp && ci.last_timestamp && cursor.goToLastDup()) { cursor.getCurrentBinary(function (key, share) { // jshint ignore:line @@ -80,9 +80,9 @@ function updateShareStats() { } is_use_cache = false; - found = cursor.goToFirstDup(); + found = cursor.goToFirstDup();*/ - if (is_use_cache) { + /*if (is_use_cache) { debug("Using share cache on " + height + " height"); let ci = share_cache[height]; new_share_cache[height] = ci; @@ -137,19 +137,19 @@ function updateShareStats() { localStats: { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {} }, localTimes: { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }, }; - let is_add_new_share_cache_item = true; + let is_add_new_share_cache_item = true;*/ let count = 0; for (; 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); - is_add_new_share_cache_item = false; + //is_add_new_share_cache_item = false; return; } if (share.timestamp < oldestTime) oldestTime = share.timestamp; if (share.timestamp <= identifierTime) { - is_add_new_share_cache_item = false; + //is_add_new_share_cache_item = false; return; } @@ -167,7 +167,7 @@ function updateShareStats() { } if (share.timestamp <= locTime) { - is_add_new_share_cache_item = false; + //is_add_new_share_cache_item = false; return; } @@ -212,7 +212,7 @@ function updateShareStats() { } // share cache item - if (is_add_new_share_cache_item) { + /*if (is_add_new_share_cache_item) { if (share.timestamp < ci.min_timestamp) ci.min_timestamp = share.timestamp; ci.last_timestamp = share.timestamp; @@ -257,14 +257,14 @@ function updateShareStats() { ci.localTimes.miners[minerIDWithIdentifier] = share.timestamp; ci.minerSet[minerIDWithIdentifier] = 1; } - } + }*/ }); debug("On " + height + " height iterated " + count + " elements"); - if (is_add_new_share_cache_item) { - debug("Added new cache item on " + height + " height"); - new_share_cache[height] = ci; - } - } + //if (is_add_new_share_cache_item) { + // debug("Added new cache item on " + height + " height"); + // new_share_cache[height] = ci; + //} + //} cursor.close(); txn.abort(); return callback_until(null, oldestTime); @@ -273,7 +273,7 @@ function updateShareStats() { return ++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime; }, function (err) { - share_cache = new_share_cache; + //share_cache = new_share_cache; debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); let prevMinerSet = global.database.getCache('minerSet'); if (prevMinerSet === false) prevMinerSet = minerSet; From 0375fe38e8bfa972325111ad40d75714adf468f2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 20:23:19 +0100 Subject: [PATCH 0324/2430] Added more logs --- lib/worker.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/worker.js b/lib/worker.js index d34d133c..a43d0c3a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -354,6 +354,7 @@ function updateShareStats() { cache_updates[keyHistory] = cachedData; local_cache[miner] = cachedData; } + debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); // remove old workers for (let miner in prevMinerSet) { @@ -373,6 +374,8 @@ function updateShareStats() { }); } + 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 @@ -387,6 +390,8 @@ function updateShareStats() { }); } + debug("New worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); + Object.keys(identifiers).forEach(function (key) { cache_updates[key + '_identifiers'] = identifiers[key]; }); From 5e4fd88f89e3d6aa9afc692f20d5443eee93a53b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 22:04:14 +0100 Subject: [PATCH 0325/2430] Separated history from other stats to speed up its update --- lib/api.js | 45 +++++++++++++++++++++++------------- lib/worker.js | 63 ++++++++++++++++++++++++--------------------------- 2 files changed, 58 insertions(+), 50 deletions(-) diff --git a/lib/api.js b/lib/api.js index e323ae2d..6ad1460c 100644 --- a/lib/api.js +++ b/lib/api.js @@ -58,12 +58,15 @@ function getAllWorkerHashCharts(address, callback){ function getAllWorkerStats(address, callback){ let identifiers = global.database.getCache(address + '_identifiers'); let globalCache = global.database.getCache(address); - let globalHistoryCache = global.database.getCache("history:" + address); - if (globalHistoryCache === false) globalHistoryCache = globalCache; // for compatibility + let globalStatsCache = global.database.getCache("stats:" + address); + if (globalStatsCache === false) { // for compatibility + globalStatsCache = global.database.getCache("history:" + address); + if (globalStatsCache === false) globalStatsCache = globalCache; + } let returnData = {global: { - lts: Math.floor(globalHistoryCache.lastHash / 1000), + lts: Math.floor(globalStatsCache.lastHash / 1000), identifer: 'global', - hash: globalHistoryCache.hash, + hash: globalStatsCache.hash, totalHash: globalCache.totalHashes }}; let intCounter = 0; @@ -71,13 +74,17 @@ function getAllWorkerStats(address, callback){ return callback(null, returnData); } identifiers.sort().forEach(function(identifier){ - let cachedData = global.database.getCache(address+"_"+identifier); - let cachedHistoryData = global.database.getCache("history:" + address+"_"+identifier); - if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility + let id2 = address + "_" + identifier; + let cachedData = global.database.getCache(id2); + let cachedStatsData = global.database.getCache("stats:" + id2); + if (cachedStatsData === false) { // for compatibility + cachedStatsData = global.database.getCache("history:" + id2); + if (cachedStatsData === false) cachedStatsData = cachedData; + } returnData[identifier] = { - lts: Math.floor(cachedHistoryData.lastHash / 1000), + lts: Math.floor(cachedStatsData.lastHash / 1000), identifer: identifier, - hash: cachedHistoryData.hash, + hash: cachedStatsData.hash, totalHash: cachedData.totalHashes }; intCounter += 1; @@ -92,8 +99,11 @@ function getAddressStats(address, extCallback){ let address_pt = address_parts[0]; let payment_id = address_parts[1]; let cachedData = global.database.getCache(address); - let cachedHistoryData = global.database.getCache("history:" + address); - if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility + let cachedStatsData = global.database.getCache("stats:" + address); + if (cachedStatsData === false) { // for compatibility + cachedStatsData = global.database.getCache("history:" + address); + if (cachedStatsData === false) cachedStatsData = cachedData; + } let paidQuery = "SELECT SUM(amount) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let txnQuery = "SELECT count(id) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let unpaidQuery = "SELECT SUM(amount) as amt FROM balance WHERE payment_address = ? AND payment_id = ?"; @@ -105,7 +115,7 @@ function getAddressStats(address, extCallback){ async.waterfall([ function (callback) { debug(threadName + "Checking Influx for last 10min avg for /miner/address/stats"); - return callback(null, {hash: cachedHistoryData.hash, identifier: 'global', lastHash: Math.floor(cachedHistoryData.lastHash / 1000), + return callback(null, {hash: cachedStatsData.hash, identifier: 'global', lastHash: Math.floor(cachedStatsData.lastHash / 1000), totalHashes: cachedData.totalHashes, validShares: Number(cachedData.goodShares), invalidShares: Number(cachedData.badShares)}); }, function (returnData, callback) { @@ -480,12 +490,15 @@ app.get('/miner/:address/stats/:identifier', function (req, res) { lastHash: localTimes.miners[miner] */ let cachedData = global.database.getCache(memcKey); - let cachedHistoryData = global.database.getCache("history:" + memcKey); - if (cachedHistoryData === false) cachedHistoryData = cachedData; // for compatibility + let cachedStatsData = global.database.getCache("stats:" + memcKey); + if (cachedStatsData === false) { // for compatibility + cachedStatsData = global.database.getCache("history:" + memcKey); + if (cachedStatsData === false) cachedStatsData = cachedData; + } return res.json({ - lts: Math.floor(cachedHistoryData.lastHash / 1000), + lts: Math.floor(cachedStatsData.lastHash / 1000), identifer: identifier, - hash: cachedHistoryData.hash, + hash: cachedStatsData.hash, totalHash: cachedData.totalHashes, validShares: Number(cachedData.goodShares), invalidShares: Number(cachedData.badShares) diff --git a/lib/worker.js b/lib/worker.js index a43d0c3a..2a43392e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -14,7 +14,7 @@ let lastBlockCheckIsFailed = {}; let prev_pool_hashrate; let prev_pool_workers; -let local_cache = {}; +let stats_cache = {}; //let share_cache = {}; function updateShareStats() { @@ -316,43 +316,38 @@ function updateShareStats() { cache_updates[key + "_stats"] = cachedData; }); for (let miner in minerSet) { - //if (miner.indexOf('_') === -1){ - // activeAddresses.push(miner); - //} - let cachedData; + let stats; + let keyStats = "stats:" + miner; let keyHistory = "history:" + miner; - if (miner in local_cache) { - cachedData = local_cache[miner]; + + if (miner in stats_cache) { + stats = stats_cache[miner]; } else { - cachedData = global.database.getCache(keyHistory); - if (cachedData === false) cachedData = global.database.getCache(miner); // for compatibility - } - if (cachedData !== false) { - cachedData.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; - cachedData.lastHash = localTimes.miners[miner]; - if (!cachedData.hasOwnProperty("hashHistory")) { - cachedData.hashHistory = []; + 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 (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(); - } + } + + stats.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; + stats.lastHash = localTimes.miners[miner]; + cache_updates[keyStats] = { hash: stats.hash, lastHash: stats.lastHash }; + + if (cycleCount === 0) { + stats.hashHistory.unshift({ts: currentTime, hs: stats.hash}); + if (stats.hashHistory.length > global.config.general.statsBufferLength) { + while (stats.hashHistory.length > global.config.general.statsBufferLength) { + stats.hashHistory.pop(); } } - } else { - cachedData = { - hash: Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1, - totalHashes: 0, - lastHash: localTimes.miners[miner], - hashHistory: [{ts: currentTime, hs: cachedData.hash}], - goodShares: 0, - badShares: 0 - }; + cache_updates[keyHistory] = { hashHistory: stats.hashHistory }; } - cache_updates[keyHistory] = cachedData; - local_cache[miner] = cachedData; + + stats_cache[miner] = stats; } debug("History loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); @@ -884,5 +879,5 @@ if (global.config.solo.enable === true) setInterval(updatePoolStats, 5*1000, 'so setInterval(updatePoolInformation, 5*1000); setInterval(updateWalletStats, 60*1000); setInterval(monitorNodes, 5*60*1000); -// clean local_cache from time to time -setInterval(function() { local_cache = {}; } , 4*60*60*1000); +// clean stats_cache from time to time +setInterval(function() { stats_cache = {}; } , 4*60*60*1000); From 65d4ee940dad0169a24b0202dce849aa1e21de6a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 22:23:52 +0100 Subject: [PATCH 0326/2430] Removed commented code parts --- lib/worker.js | 160 +++----------------------------------------------- 1 file changed, 7 insertions(+), 153 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 2a43392e..11473c4b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -15,7 +15,6 @@ let prev_pool_hashrate; let prev_pool_workers; let stats_cache = {}; -//let share_cache = {}; function updateShareStats() { // This is an omni-worker to deal with all things share-stats related @@ -23,7 +22,6 @@ function updateShareStats() { // Buffer lengths? You guessed it, configured in SQL. // Stats timeouts are 30 seconds, so everything for buffers should be there. let currentTime = Date.now(); - //let activeAddresses = []; async.waterfall([ function (callback) { global.coinFuncs.getLastBlockHeader(function (err, body) { @@ -49,109 +47,21 @@ function updateShareStats() { let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; let loopBreakout = 0; - //let new_share_cache = {}; - 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 found = cursor.goToRange(height) === height; - //let is_use_cache = false; - - /*if (found && height in share_cache) { - let ci = share_cache[height]; - if (locTime < ci.min_timestamp && ci.last_timestamp && cursor.goToLastDup()) { - cursor.getCurrentBinary(function (key, share) { // jshint ignore:line - try { - share = global.protos.Share.decode(share); - } catch (e) { - console.error(share); - return; - } - if (share.timestamp === ci.last_timestamp) { - debug("Can use share cache on " + height + " height"); - is_use_cache = true; - } else { - debug("Found share cache on " + height + " height was modified"); - found = cursor.goToFirstDup(); - } - }); - } - } - - is_use_cache = false; - found = cursor.goToFirstDup();*/ - - /*if (is_use_cache) { - debug("Using share cache on " + height + " height"); - let ci = share_cache[height]; - new_share_cache[height] = ci; - - if (ci.min_timestamp < oldestTime) oldestTime = ci.min_timestamp; - - for (let minerID in ci.identifiers) { - if (minerID in identifiers) { - for (let i in ci.identifiers[minerID]) { - let id = ci.identifiers[minerID][i]; - if (identifiers[minerID].indexOf(id) < 0) { - identifiers[minerID].push(id); - ++ minerCount; - } - } - } else { - identifiers[minerID] = ci.identifiers[minerID]; - minerCount += ci.identifiers[minerID].length; - } - } - - localStats.global += ci.localStats.global; - localStats.pplns += ci.localStats.pplns; - localStats.pps += ci.localStats.pps; - localStats.solo += ci.localStats.solo; - if (localTimes.global < ci.localTimes.global) localTimes.global = ci.localTimes.global; - if (localTimes.pplns < ci.localTimes.pplns) localTimes.pplns = ci.localTimes.pplns; - if (localTimes.pps < ci.localTimes.pps) localTimes.pps = ci.localTimes.pps; - if (localTimes.solo < ci.localTimes.solo) localTimes.solo = ci.localTimes.solo; - - for (let minerID in ci.minerSet) { - if (minerID in minerSet) { - localStats.miners[minerID] += ci.localStats.miners[minerID]; - if (localTimes.miners[minerID] < ci.localTimes.miners[minerID]) localTimes.miners[minerID] = ci.localTimes.miners[minerID]; - } else { - if (minerID.indexOf('_') < 0) { - ++ localMinerCount.global; - ++ localMinerCount[ci.localMinerType[minerID]]; - } - localStats.miners[minerID] = ci.localStats.miners[minerID]; - localTimes.miners[minerID] = ci.localTimes.miners[minerID]; - minerSet[minerID] = 1; - } - } - - } else { - let ci = { - min_timestamp: currentTime, - identifiers: {}, - minerSet: [], - localMinerType: {}, - localStats: { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {} }, - localTimes: { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }, - }; - let is_add_new_share_cache_item = true;*/ - let count = 0; - for (; found; ++ count, found = cursor.goToNextDup()) cursor.getCurrentBinary(function (key, share) { // jshint ignore:line + 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); - //is_add_new_share_cache_item = false; return; } if (share.timestamp < oldestTime) oldestTime = share.timestamp; - if (share.timestamp <= identifierTime) { - //is_add_new_share_cache_item = false; - return; - } + if (share.timestamp <= identifierTime) return; let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; @@ -166,10 +76,7 @@ function updateShareStats() { ++ minerCount; } - if (share.timestamp <= locTime) { - //is_add_new_share_cache_item = false; - return; - } + if (share.timestamp <= locTime) return; let minerIDWithIdentifier = minerID + "_" + share.identifier; localStats.global += share.shares; @@ -210,70 +117,17 @@ function updateShareStats() { localTimes.miners[minerIDWithIdentifier] = share.timestamp; minerSet[minerIDWithIdentifier] = 1; } - - // share cache item - /*if (is_add_new_share_cache_item) { - if (share.timestamp < ci.min_timestamp) ci.min_timestamp = share.timestamp; - ci.last_timestamp = share.timestamp; - - if (minerID in ci.identifiers) { - if (ci.identifiers[minerID].indexOf(share.identifier) < 0) { - ci.identifiers[minerID].push(share.identifier); - } - } else { - ci.identifiers[minerID] = [share.identifier]; - } - - ci.localStats.global += share.shares; - if (ci.localTimes.global <= share.timestamp) ci.localTimes.global = share.timestamp; - switch (share.poolType) { - case global.protos.POOLTYPE.PPLNS: - ci.localStats.pplns += share.shares; - if (ci.localTimes.pplns < share.timestamp) ci.localTimes.pplns = share.timestamp; - break; - case global.protos.POOLTYPE.PPS: - ci.localStats.pps += share.shares; - if (ci.localTimes.pps < share.timestamp) ci.localTimes.pps = share.timestamp; - break; - case global.protos.POOLTYPE.SOLO: - ci.localStats.solo += share.shares; - if (ci.localTimes.solo < share.timestamp) ci.localTimes.solo = share.timestamp; - break; - } - if (minerID in ci.minerSet) { - ci.localStats.miners[minerID] += share.shares; - if (ci.localTimes.miners[minerID] < share.timestamp) ci.localTimes.miners[minerID] = share.timestamp; - } else { - ci.localMinerType[minerID] = minerType; - ci.localStats.miners[minerID] = share.shares; - ci.localTimes.miners[minerID] = share.timestamp; - ci.minerSet[minerID] = 1; - } - if (minerIDWithIdentifier in ci.minerSet) { - ci.localStats.miners[minerIDWithIdentifier] += share.shares; - if (ci.localTimes.miners[minerIDWithIdentifier] < share.timestamp) ci.localTimes.miners[minerIDWithIdentifier] = share.timestamp; - } else { - ci.localStats.miners[minerIDWithIdentifier] = share.shares; - ci.localTimes.miners[minerIDWithIdentifier] = share.timestamp; - ci.minerSet[minerIDWithIdentifier] = 1; - } - }*/ }); - debug("On " + height + " height iterated " + count + " elements"); - //if (is_add_new_share_cache_item) { - // debug("Added new cache item on " + height + " height"); - // new_share_cache[height] = ci; - //} - //} + } cursor.close(); txn.abort(); + debug("On " + height + " height iterated " + count + " elements"); return callback_until(null, oldestTime); }, function (oldestTime) { return ++loopBreakout > 60 || --height < 0 || oldestTime <= identifierTime; }, function (err) { - //share_cache = new_share_cache; debug("Share loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); let prevMinerSet = global.database.getCache('minerSet'); if (prevMinerSet === false) prevMinerSet = minerSet; From d108d195e800afec9c0e9e4991b31118f0239b1f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 10 Mar 2018 22:47:42 +0100 Subject: [PATCH 0327/2430] Decreased number of duplicate messages --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c2fa1d91..e3fc9af1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1206,7 +1206,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.trust.check_height = 0; } else { - console.log(threadName + "Share trust broken by " + miner.logString); + debug(threadName + "Share trust broken by " + miner.logString); global.database.storeInvalidShare(miner.invalidShareProto); miner.trust.probability = 256; miner.trust.penalty = global.config.pool.trustPenalty; From a75eb072bc36895c44cca390aba598893ced4f5b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Mar 2018 07:57:25 +0100 Subject: [PATCH 0328/2430] Added nonce to log --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e3fc9af1..1e48e64d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -923,7 +923,7 @@ function getShareBuffer(miner, job, blockTemplate, params) { let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex')); return shareBuffer; } catch (e) { - console.error("Can't constructNewBlob from " + miner.logString + ": " + e); + console.error("Can't constructNewBlob with " + nonce + " nonce from " + miner.logString + ": " + e); return null; } } From 69fd0032a8bf0f547fb115a9c8c93796ec7eb78e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Mar 2018 08:01:39 +0100 Subject: [PATCH 0329/2430] Reduced number of duplicate message about new block to mine --- lib/pool.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1e48e64d..8351c7fe 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -304,7 +304,11 @@ function newBlockTemplate(template) { pastBlockTemplates.enq(activeBlockTemplate); if (activeBlockTemplate.port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } - console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); + if (cluster.isMaster) { + console.log('[*] New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); + } else { + debug(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); + } activeBlockTemplate = new BlockTemplate(template); if (global.config.daemon.port === activeBlockTemplate.port) { From 8b814c48bef42349b5952167e7b4c4c6c09112a8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Mar 2018 08:04:06 +0100 Subject: [PATCH 0330/2430] Added port info to new block message --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8351c7fe..89723ddd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -305,9 +305,9 @@ function newBlockTemplate(template) { if (activeBlockTemplate.port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { - console.log('[*] New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); + console.log('[*] New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } else { - debug(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); + debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } activeBlockTemplate = new BlockTemplate(template); From a331abfeda3ec08f30ccf215317ccec7d31784e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Mar 2018 13:03:17 +0100 Subject: [PATCH 0331/2430] Update moment version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76368b3f..9b4ce5d3 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "express": "4.14.0", "jsonwebtoken": "^7.2.1", "minimist": "1.2.0", - "moment": "2.17.1", + "moment": "2.21.0", "mysql": "2.15.0", "node-lmdb": "0.4.12", "promise-mysql": "3.0.0", From dd26b4f2e28312225ad7f869ab0ffe5177bf4f40 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 12 Mar 2018 06:03:40 +0100 Subject: [PATCH 0332/2430] Unlock block only after payment and do not allow parallel payment scans --- lib/blockManager.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e5532bef..e1b7e445 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -10,6 +10,7 @@ const async = require("async"); // 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; @@ -215,7 +216,12 @@ function calculatePPSPayments(blockHeader, callback) { return callback(); } -function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { +function calculatePPLNSPayments(block_height, block_reward, block_difficulty, unlock_callback) { + if (paymentInProgress) { + debug("Skipping block payment run as there's a payment in progress"); + return; + } + paymentInProgress = true; console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward)); let rewardTotal = block_reward; let blockDiff = block_difficulty; @@ -334,6 +340,8 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { 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 + ")"); + unlock_callback(); + paymentInProgress = false; }); }; @@ -424,6 +432,10 @@ function blockUnlocker() { 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; + } debug("Running block unlocker"); let blockList = global.database.getValidLockedBlocks(); global.coinFuncs.getLastBlockHeader(function(err, body){ @@ -459,6 +471,10 @@ function altblockUnlocker() { debug("Skipping altblock unlocker run as there's a scan in progress"); return; } + if (paymentInProgress) { + debug("Skipping altblock unlocker run as there's a payment in progress"); + return; + } debug("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); blockList.forEach(function (block) { @@ -491,8 +507,10 @@ function blockPayments(block) { 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){ - calculatePPLNSPayments(block.height, block.value, block.difficulty); - global.database.unlockBlock(block.hash); + calculatePPLNSPayments(block.height, block.value, block.difficulty, function() { + console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex')); + global.database.unlockBlock(block.hash); + }); } else { console.error("Can't get correct block header by hash " + block.hash.toString('hex')); } @@ -520,8 +538,10 @@ function altblockPayments(block) { 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){ - calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty); - global.database.unlockAltBlock(block.hash); + 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')); + global.database.unlockAltBlock(block.hash); + }); } else { console.error("Can't get correct block header by height " + block.anchor_height.toString()); } From 71e4302b809e71ae3801a4be873517c41154996f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 12 Mar 2018 07:00:39 +0100 Subject: [PATCH 0333/2430] Fixed log messages --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e1b7e445..2b5d3dfa 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -508,7 +508,7 @@ function blockPayments(block) { global.coinFuncs.getBlockHeaderByHash(block.hash, function (err, header) { if (err === null && block.height === header.height && block.value === header.reward && block.difficulty === header.difficulty){ calculatePPLNSPayments(block.height, block.value, block.difficulty, function() { - console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex')); + console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockBlock(block.hash); }); } else { @@ -539,7 +539,7 @@ function altblockPayments(block) { global.coinFuncs.getBlockHeaderByID(block.anchor_height, function (anchor_err, anchor_header) { if (anchor_err === null){ 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')); + console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); }); } else { From 97f140d9377fbd59b7ef0690bb49c5dda74bd5e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 12 Mar 2018 16:57:17 +0100 Subject: [PATCH 0334/2430] Update activePort local var as well --- lib/support.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/support.js b/lib/support.js index 0c185f46..f588495c 100644 --- a/lib/support.js +++ b/lib/support.js @@ -185,6 +185,7 @@ function getActivePort(callback) { function setActivePort(activePort) { global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort'", [activePort]); + global.config.daemon.activePort = activePort; } function formatDate(date) { From 595ed838e301a4de7454835ebf041fdb9c832019 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 12:49:52 +0100 Subject: [PATCH 0335/2430] Accelerated block cleaner --- lib/local_comms.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 8fc4d9b1..f39d3a9d 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -888,7 +888,7 @@ function Database(){ function (lastBlock, difficulty, callback) { let shareCount = 0; let pplnsFound = false; - let blockList = []; + let blockSet = {}; console.log("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); range.range(lastBlock-1, 0, -1).forEach(function (blockID) { debug("Scanning block: " + blockID); @@ -898,9 +898,7 @@ function Database(){ for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { if (pplnsFound){ cursor.getCurrentBinary(function(key, data) { // jshint ignore:line - if (blockList.indexOf(key) === -1){ - blockList.push(key); - } + blockSet[key] = 1; }); } else { cursor.getCurrentBinary(function(key, data) { // jshint ignore:line @@ -923,7 +921,7 @@ function Database(){ if (pplnsCurrFound) pplnsFound = true; }); console.log("Scan finished"); - callback(null, blockList); + callback(null, Array.from(blockSet.keys())); } ], function(err, data){ if (global.config.general.blockCleaner === true){ From 6348340798cbb35b97c5ea65e2e19201f4c332f6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 14:02:53 +0100 Subject: [PATCH 0336/2430] Added more robust code for block submission --- lib/pool.js | 69 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 89723ddd..328b0e6f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -928,6 +928,10 @@ function getShareBuffer(miner, job, blockTemplate, params) { 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 + ); return null; } } @@ -991,35 +995,42 @@ function processShare(miner, job, blockTemplate, params) { // Submit block to the RPC Daemon. // Todo: Implement within the coins/.js file. if (!shareBuffer) shareBuffer = getShareBuffer(miner, job, blockTemplate, params); - 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. - console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); - recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); - 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" + - threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) - ); - // Error on submit, so we'll submit a sanity check for good measure. - //templateUpdate(); - } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { - //Success! Submitted a block without an issue. - let blockFastHash = global.coinFuncs.getBlockID(shareBuffer).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); - //templateUpdate(); - } 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", - "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 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. + console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); + recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); + 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 height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + ); + } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { + //Success! Submitted a block without an issue. + let blockFastHash = global.coinFuncs.getBlockID(shareBuffer).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" + ); + } + } + }); + } + if (shareBuffer) submit_block(true); } else if (hashDiff.lt(job.difficulty)) { process.send({type: 'invalidShare'}); From 78756c41221930e646918703b1ac6922c2545c20 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 14:44:46 +0100 Subject: [PATCH 0337/2430] Fixed nodejs stuff --- 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 f39d3a9d..25fb3cf6 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -921,7 +921,7 @@ function Database(){ if (pplnsCurrFound) pplnsFound = true; }); console.log("Scan finished"); - callback(null, Array.from(blockSet.keys())); + callback(null, Array.from(Object.keys(blockSet))); } ], function(err, data){ if (global.config.general.blockCleaner === true){ From a6aae04a0a105a09b52b643379d8cc6ad570f242 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 16:43:52 +0100 Subject: [PATCH 0338/2430] Fixed key type --- 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 25fb3cf6..d844368b 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -931,9 +931,9 @@ function Database(){ data.forEach(function(block){ totalDeleted += 1; let txn = global.database.env.beginTxn(); - txn.del(global.database.shareDB, block); + txn.del(global.database.shareDB, parseInt(block)); txn.commit(); - debug("Deleted block: " + block); + debug("Deleted block: " + parseInt(block)); }); console.log("Block cleaning enabled. Removed: " +totalDeleted+ " block share records"); } From 0df54ce4f75fd39e4121e4639e34e71538c4b2e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 16:47:43 +0100 Subject: [PATCH 0339/2430] Accelerated share cleaner --- lib/local_comms.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index d844368b..da5287d0 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -896,10 +896,9 @@ function Database(){ let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); let pplnsCurrFound = false; for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { - if (pplnsFound){ - cursor.getCurrentBinary(function(key, data) { // jshint ignore:line - blockSet[key] = 1; - }); + if (pplnsFound) { + blockSet[blockID] = 1; + break; } else { cursor.getCurrentBinary(function(key, data) { // jshint ignore:line try{ From df5b5b14eacc9cfc7bb3f69482cfdc26fe318ee9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 16:53:19 +0100 Subject: [PATCH 0340/2430] Added email about not completely payed blocks --- lib/blockManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 2b5d3dfa..16547907 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -342,6 +342,12 @@ 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 / block_reward) * 100 + "% (precisely " + totalPayments + " / " + block_reward + ")"); unlock_callback(); paymentInProgress = false; + if (totalPayments != block_reward) { + 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 + ")" + ); + } }); }; From 685e42bd70e58d4341538f6cb61eea76686cf357 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 17:02:02 +0100 Subject: [PATCH 0341/2430] Added more logs to block cleaner --- 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 da5287d0..09e6d5cd 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -917,7 +917,10 @@ function Database(){ } cursor.close(); txn.abort(); - if (pplnsCurrFound) pplnsFound = true; + if (pplnsCurrFound) { + pplnsFound = true; + console.log("Found first block to be deleted at " + blockID + " height"); + } }); console.log("Scan finished"); callback(null, Array.from(Object.keys(blockSet))); @@ -927,6 +930,7 @@ function Database(){ if(data.length > 0){ global.database.refreshEnv(); let totalDeleted = 0; + console.log("Block cleaning started: removing " + data.length + " block share records"); data.forEach(function(block){ totalDeleted += 1; let txn = global.database.env.beginTxn(); @@ -934,7 +938,7 @@ function Database(){ txn.commit(); debug("Deleted block: " + parseInt(block)); }); - console.log("Block cleaning enabled. Removed: " +totalDeleted+ " block share records"); + console.log("Block cleaning finished: removed " + totalDeleted + " block share records"); } global.database.env.sync(function(){ }); From 0806704efb5883467d2919a951a81bb3a4110437 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 17:10:34 +0100 Subject: [PATCH 0342/2430] Fixed log message --- 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 09e6d5cd..d08820b2 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -919,7 +919,7 @@ function Database(){ txn.abort(); if (pplnsCurrFound) { pplnsFound = true; - console.log("Found first block to be deleted at " + blockID + " height"); + console.log("Found the first block to be deleted at " + blockID + " height"); } }); console.log("Scan finished"); From b391bb00669e7dbb34afdeee05e64e947de3245d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 17:16:10 +0100 Subject: [PATCH 0343/2430] Simplified share cleaner code --- lib/local_comms.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index d08820b2..fef1544d 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -894,7 +894,6 @@ function Database(){ debug("Scanning block: " + blockID); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - let pplnsCurrFound = false; for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { if (pplnsFound) { blockSet[blockID] = 1; @@ -911,16 +910,14 @@ function Database(){ } }); if (shareCount >= difficulty){ - pplnsCurrFound = true; + pplnsFound = true; + console.log("Found the first block to be deleted at " + blockID + " height"); + break; } } } cursor.close(); txn.abort(); - if (pplnsCurrFound) { - pplnsFound = true; - console.log("Found the first block to be deleted at " + blockID + " height"); - } }); console.log("Scan finished"); callback(null, Array.from(Object.keys(blockSet))); From e185d6b671d42747642f5a9aaacfd319d35c19a4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 17:20:04 +0100 Subject: [PATCH 0344/2430] Remove shares in one transaction --- 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 fef1544d..df02de20 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -928,13 +928,13 @@ function Database(){ global.database.refreshEnv(); let totalDeleted = 0; console.log("Block cleaning started: removing " + data.length + " block share records"); + let txn = global.database.env.beginTxn(); data.forEach(function(block){ totalDeleted += 1; - let txn = global.database.env.beginTxn(); txn.del(global.database.shareDB, parseInt(block)); - txn.commit(); debug("Deleted block: " + parseInt(block)); }); + txn.commit(); console.log("Block cleaning finished: removed " + totalDeleted + " block share records"); } global.database.env.sync(function(){ From 3f2b6a06f03df40cf5548e8f4c4bbd40cfddd712 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 17:25:02 +0100 Subject: [PATCH 0345/2430] Optimized share scanning even more --- 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 df02de20..e5c7d732 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -890,10 +890,10 @@ function Database(){ let pplnsFound = false; let blockSet = {}; console.log("Scanning from: "+lastBlock + " for more than: " + difficulty + " shares"); + let txn = global.database.env.beginTxn({readOnly: true}); + let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); range.range(lastBlock-1, 0, -1).forEach(function (blockID) { debug("Scanning block: " + blockID); - let txn = global.database.env.beginTxn({readOnly: true}); - let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); for (let found = (cursor.goToRange(parseInt(blockID)) === blockID); found; found = cursor.goToNextDup()) { if (pplnsFound) { blockSet[blockID] = 1; @@ -916,9 +916,9 @@ function Database(){ } } } - cursor.close(); - txn.abort(); }); + cursor.close(); + txn.abort(); console.log("Scan finished"); callback(null, Array.from(Object.keys(blockSet))); } From 15c1c6c13269179bb96bf65f6356e6413cabc4c0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 17:33:12 +0100 Subject: [PATCH 0346/2430] Optimized share accumulation operation --- 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 e5c7d732..85a8c36f 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -903,7 +903,7 @@ function Database(){ try{ let shareData = global.protos.Share.decode(data); if (shareData.poolType === global.protos.POOLTYPE.PPLNS){ - shareCount = shareCount + shareData.shares; + shareCount += shareData.shares; } } catch(e){ console.error("Invalid share"); From f0a22fef53f52d32d36ae1b3e42c6bd7933f73c7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 18:44:01 +0100 Subject: [PATCH 0347/2430] Fixed message text --- lib/local_comms.js | 2 +- lib/worker.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 85a8c36f..72bb695a 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -374,7 +374,7 @@ function Database(){ this.incrementCacheData(minerID, [{location: 'badShares', value: 1}]); callback(true); } catch (e){ - console.error("Ran into an error string an invalid share. Damn!"); + console.error("Ran into an error storing an invalid share. Damn!"); callback(false); } }; diff --git a/lib/worker.js b/lib/worker.js index 11473c4b..e823f79d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -256,7 +256,7 @@ function updateShareStats() { 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 + ")" + "Pool number of workers changed from " + prev_pool_workers + " to " + pool_workers + " (" + pool_workers_ratio + ")\n" ); } prev_pool_hashrate = pool_hashrate; From 85f9aaaa03927c73fcda2a8be64e7d6b3b003aee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 14 Mar 2018 20:09:31 +0100 Subject: [PATCH 0348/2430] Mark orphaned blocks sooner --- lib/local_comms.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/local_comms.js b/lib/local_comms.js index 72bb695a..466615ec 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -461,6 +461,8 @@ function Database(){ err = false; header = {}; header.reward = 0; + blockDataDecoded.valid = false; + blockDataDecoded.unlocked = true; } } else { console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); @@ -509,6 +511,8 @@ function Database(){ err = false; header = {}; header.reward = 0; + blockDataDecoded.valid = false; + blockDataDecoded.unlocked = true; } } else { console.log("Started attempts to store possibly orphan block " + blockDataDecoded.hash); From e8467782bb64618c85dab91d222e5ac886ec841a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 16 Mar 2018 11:06:13 +0100 Subject: [PATCH 0349/2430] Reduced number of message spam about queue debug state --- lib/remote_comms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 6b544930..e857034a 100644 --- a/lib/remote_comms.js +++ b/lib/remote_comms.js @@ -65,7 +65,7 @@ function Database() { }; setInterval(function(queue_obj){ - if (global.database.thread_id === '(Master) '){ + 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"); } }, 30*1000, this.sendQueue); From dea60a870ed85767f0e854f9558405b94b7eb035 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 16 Mar 2018 15:47:53 +0100 Subject: [PATCH 0350/2430] Added address ban system and some speed optimizations --- deployment/base.sql | 1 + lib/pool.js | 38 +++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 70fd287e..fe42716c 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -21,6 +21,7 @@ CREATE TABLE `bans` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ip_address` varchar(40) DEFAULT NULL, `mining_address` varchar(200) DEFAULT NULL, + `reason` varchar(200) DEFAULT NULL, `active` tinyint(1) DEFAULT '1', `ins_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), diff --git a/lib/pool.js b/lib/pool.js index 328b0e6f..94e44b44 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -11,8 +11,8 @@ const tls = require('tls'); const fs = require('fs'); let nonceCheck = new RegExp("^[0-9a-f]{8}$"); -let bannedIPs = []; -let bannedAddresses = []; +let bannedIPs = {}; +let bannedAddresses = {}; let baseDiff = global.coinFuncs.baseDiff(); let pastBlockTemplates = global.support.circularBuffer(4); let activeMiners = []; @@ -99,7 +99,7 @@ function messageHandler(message) { if (cluster.isMaster) { sendToWorkers(message); } else { - bannedIPs.push(message.data); + bannedIPs[message.data] = 1; } break; case 'newBlockTemplate': @@ -441,9 +441,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.error = "Invalid payment address provided"; this.valid_miner = false; } - if (bannedAddresses.indexOf(this.address) !== -1) { + if (this.payout in bannedAddresses) { // Banned Address - this.error = "Banned payment address provided"; + this.error = "Banned payment address provided: " + bannedAddresses[this.payout]; this.valid_miner = false; } if (global.coinFuncs.exchangeAddresses.indexOf(this.address) !== -1 && !(this.paymentID)) { @@ -665,7 +665,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer height: activeBlockTemplate.height, difficulty: this.difficulty, diffHex: this.diffHex, - submissions: [], + submissions: {}, blockHash: activeBlockTemplate.idHash }; @@ -692,7 +692,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer diffHex: this.diffHex, clientPoolLocation: activeBlockTemplate.clientPoolLocation, clientNonceLocation: activeBlockTemplate.clientNonceLocation, - submissions: [] + submissions: {} }; this.validJobs.enq(newJob); this.cachedJob = { @@ -1049,7 +1049,7 @@ let lastMessageTime; function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let miner = activeMiners[params.id]; // Check for ban here, so preconnected attackers can't continue to screw you - if (bannedIPs.indexOf(ip) !== -1) { + if (ip in bannedIPs) { // Handle IP ban off clip. sendReply("IP Address currently banned"); return; @@ -1137,14 +1137,14 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } if (!miner.proxy) { - if (job.submissions.indexOf(params.nonce) !== -1) { + 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.push(params.nonce); + job.submissions[params.nonce] = 1; } else { if (!Number.isInteger(params.poolNonce) || !Number.isInteger(params.workerNonce)) { console.warn(threadName + 'Malformed nonce: ' + JSON.stringify(params) + ' from ' + miner.logString); @@ -1154,14 +1154,14 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } let nonce_test = `${params.nonce}_${params.poolNonce}_${params.workerNonce}`; - if (job.submissions.indexOf(nonce_test) !== -1) { + if (nonce_test in job.submissions) { console.warn(threadName + 'Duplicate proxy share with ' + params.nonce_test.toString() + ' nonce from ' + miner.logString); miner.checkBan(false); sendReply('Duplicate share'); global.database.storeInvalidShare(miner.invalidShareProto); return; } - job.submissions.push(nonce_test); + job.submissions[nonce_test] = 1; } let blockTemplate = activeBlockTemplate.height === job.height ? activeBlockTemplate : pastBlockTemplates.toarray().filter(function (t) { @@ -1309,10 +1309,22 @@ if (cluster.isMaster) { templateUpdate(); anchorBlockUpdate(); setInterval(function () { - bannedIPs = []; + bannedIPs = {}; }, 60*1000); setInterval(anchorBlockUpdate, 3*1000); + function add_bans() { + global.mysql.query("SELECT mining_address, reason FROM bans").then(function (rows) { + bannedAddresses = {}; + rows.forEach(function (row) { + bannedAddresses[row.mining_address] = row.reason; + }); + }); + } + + add_bans(); + setInterval(add_bans, 10*60*1000); + // load merged wallet trust from files let numWorkers = require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { From a915932fef3d90d7d1a4df4710705e3e59d7b3cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 16 Mar 2018 15:56:01 +0100 Subject: [PATCH 0351/2430] Add more logs to address bans --- lib/pool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 94e44b44..731e4fdc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1313,16 +1313,17 @@ if (cluster.isMaster) { }, 60*1000); setInterval(anchorBlockUpdate, 3*1000); - function add_bans() { + function add_bans(is_show) { global.mysql.query("SELECT mining_address, reason FROM bans").then(function (rows) { bannedAddresses = {}; rows.forEach(function (row) { bannedAddresses[row.mining_address] = row.reason; + if (is_show) console.log("Added blocked address " + row.mining_address + ": " + row.reason); }); }); } - add_bans(); + add_bans(true); setInterval(add_bans, 10*60*1000); // load merged wallet trust from files From c4163b674cd3dac6dc62b8cede303cd4167cbe57 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 16 Mar 2018 16:45:30 +0100 Subject: [PATCH 0352/2430] Miner based message throttling --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 731e4fdc..5fc950fb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1044,7 +1044,8 @@ function processShare(miner, job, blockTemplate, params) { return true; } -let lastMessageTime; +// Message times for different miner addresses +let lastMessageTime = {}; function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let miner = activeMiners[params.id]; @@ -1065,9 +1066,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent); if (!miner.valid_miner) { let time_now = Date.now(); - if (!lastMessageTime || time_now - lastMessageTime > 30*1000) { + if (!(miner.payout in lastMessageTime) || time_now - lastMessageTime[miner.payout] > 10*60*1000) { console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); - lastMessageTime = time_now; + lastMessageTime[miner.payout] = time_now; } sendReply(miner.error); return; From 06a228ed2b9022e71a7bd57428b0b47a92c33baa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 16 Mar 2018 21:25:32 +0100 Subject: [PATCH 0353/2430] Added experimental address based miner notifications --- deployment/base.sql | 7 +++++++ lib/pool.js | 23 +++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index fe42716c..c9e9aa3b 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -27,6 +27,13 @@ CREATE TABLE `bans` ( PRIMARY KEY (`id`), UNIQUE KEY `bans_id_uindex` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `notifications` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `mining_address` varchar(200) DEFAULT NULL, + `message` varchar(200) DEFAULT NULL, + 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', diff --git a/lib/pool.js b/lib/pool.js index 5fc950fb..21fb0906 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -13,6 +13,7 @@ const fs = require('fs'); let nonceCheck = new RegExp("^[0-9a-f]{8}$"); let bannedIPs = {}; let bannedAddresses = {}; +let notifyAddresses = {}; let baseDiff = global.coinFuncs.baseDiff(); let pastBlockTemplates = global.support.circularBuffer(4); let activeMiners = []; @@ -424,7 +425,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.identifier = this.identifier.substring(0, 64); - if (pass_split.length > 2) { + if (this.valid_miner && pass_split.length > 2) { this.error = "Too many options in the password field"; this.valid_miner = false; } @@ -433,24 +434,24 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.bitcoin = 0; } else if (btcValidator.validate(this.address) && global.config.general.allowBitcoin && global.coinFuncs.supportsAutoExchange) { this.bitcoin = 1; - } else if (btcValidator.validate(this.address)) { + } else if (this.valid_miner && btcValidator.validate(this.address)) { this.error = "This pool does not allow payouts to bitcoin."; this.valid_miner = false; - } else { + } else if (this.valid_miner) { // Invalid Addresses this.error = "Invalid payment address provided"; this.valid_miner = false; } - if (this.payout in bannedAddresses) { + if (this.valid_miner && this.payout in bannedAddresses) { // Banned Address this.error = "Banned payment address provided: " + bannedAddresses[this.payout]; this.valid_miner = false; } - if (global.coinFuncs.exchangeAddresses.indexOf(this.address) !== -1 && !(this.paymentID)) { + if (this.valid_miner && global.coinFuncs.exchangeAddresses.indexOf(this.address) !== -1 && !(this.paymentID)) { this.error = "Exchange addresses need payment IDs"; this.valid_miner = false; } - if (!activeBlockTemplate) { + if (this.valid_miner && !activeBlockTemplate) { this.error = "No active block template"; this.valid_miner = false; } @@ -1073,6 +1074,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner.error); return; } + if (miner.payout in notifyAddresses) { + sendReply(notifyAddresses[miner.payout]); + } process.send({type: 'newMiner', data: miner.port}); activeMiners[minerId] = miner; if (!miner.proxy) { @@ -1322,6 +1326,13 @@ if (cluster.isMaster) { if (is_show) console.log("Added blocked address " + row.mining_address + ": " + row.reason); }); }); + global.mysql.query("SELECT mining_address, message FROM notifications").then(function (rows) { + notifyAddresses = {}; + rows.forEach(function (row) { + notifyAddresses[row.mining_address] = row.message; + if (is_show) console.log("Added notify address " + row.mining_address + ": " + row.message); + }); + }); } add_bans(true); From 8438843e1782e0f897c47d4bee25718f1a630171 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 16 Mar 2018 21:47:54 +0100 Subject: [PATCH 0354/2430] Added functional miner notifications --- lib/pool.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 21fb0906..711bf9f2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1046,7 +1046,9 @@ function processShare(miner, job, blockTemplate, params) { } // Message times for different miner addresses -let lastMessageTime = {}; +let lastMinerLogTime = {}; +// Miner notification times +let lastMinerNotifyTime = {}; function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let miner = activeMiners[params.id]; @@ -1067,15 +1069,20 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent); if (!miner.valid_miner) { let time_now = Date.now(); - if (!(miner.payout in lastMessageTime) || time_now - lastMessageTime[miner.payout] > 10*60*1000) { + if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); - lastMessageTime[miner.payout] = time_now; + lastMinerLogTime[miner.payout] = time_now; } sendReply(miner.error); return; } if (miner.payout in notifyAddresses) { - sendReply(notifyAddresses[miner.payout]); + let time_now = Date.now(); + if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { + lastMinerNotifyTime[miner.payout] = time_now; + sendReply(notifyAddresses[miner.payout]); + return; + } } process.send({type: 'newMiner', data: miner.port}); activeMiners[minerId] = miner; From ce2835bea831c1055139b13c384f454d65a0fed0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Mar 2018 06:05:25 +0100 Subject: [PATCH 0355/2430] Added PoW miner notifications --- lib/pool.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 711bf9f2..b1ba7478 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1050,6 +1050,37 @@ let lastMinerLogTime = {}; // Miner notification times let lastMinerNotifyTime = {}; +var reXMRig = /XMRig\/(\d+)\.(\d+)\./; +var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)\./; +var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; + +function get_miner_notification(payout, agent) { + if (payout in notifyAddresses) return notifyAddresses[payout]; + if (agent) { + let m; + if (m = reXMRig.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + if (majorv < 2 || (majorv === 2 && minorv < 5)) { + return "Please update XMRig miner to at least v2.5.0 before hardfork on March 28"; + } + } else if (m = reXMRSTAK.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + if (majorv < 2 || (majorv === 2 && minorv <= 2)) { + return "Please update xmr-stak miner to version AFTER v2.2.0 before hardfork on March 28"; + } + } else if (m = reCCMINER.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + if (majorv < 3) { + return "Please update ccminer-cryptonight miner to at least v3.00 before hardfork on March 28"; + } + } + } + return false; +} + function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let miner = activeMiners[params.id]; // Check for ban here, so preconnected attackers can't continue to screw you @@ -1076,11 +1107,13 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner.error); return; } - if (miner.payout in notifyAddresses) { + let miner_notification = get_miner_notification(miner.payout, params.agent); + if (miner_notification) { let time_now = Date.now(); if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; - sendReply(notifyAddresses[miner.payout]); + console.error("Sent notification to " + miner.logString + ": " + miner_notification); + sendReply(miner_notification + " (miner will connect after several attempts)"); return; } } From 2133c0f48cb8bddf41d789a71002785faab3e296 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Mar 2018 06:19:22 +0100 Subject: [PATCH 0356/2430] Added support of old xmr-stak --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b1ba7478..643b6988 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1051,7 +1051,7 @@ let lastMinerLogTime = {}; let lastMinerNotifyTime = {}; var reXMRig = /XMRig\/(\d+)\.(\d+)\./; -var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)\./; +var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; function get_miner_notification(payout, agent) { From f3c43c32fac5366c51f48e4344f5825f4f53a204 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Mar 2018 06:52:39 +0100 Subject: [PATCH 0357/2430] Disabled ccminer notifications --- lib/pool.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 643b6988..953b54d7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1052,7 +1052,8 @@ let lastMinerNotifyTime = {}; var reXMRig = /XMRig\/(\d+)\.(\d+)\./; var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; -var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; +// no point to notifiy it - it does not print error message +//var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; function get_miner_notification(payout, agent) { if (payout in notifyAddresses) return notifyAddresses[payout]; @@ -1070,13 +1071,14 @@ function get_miner_notification(payout, agent) { if (majorv < 2 || (majorv === 2 && minorv <= 2)) { return "Please update xmr-stak miner to version AFTER v2.2.0 before hardfork on March 28"; } - } else if (m = reCCMINER.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); - if (majorv < 3) { - return "Please update ccminer-cryptonight miner to at least v3.00 before hardfork on March 28"; - } } + //} else if (m = reCCMINER.exec(agent)) { + // let majorv = parseInt(m[1]); + // let minorv = parseInt(m[2]); + // if (majorv < 3) { + // return "Please update ccminer-cryptonight miner to at least v3.00 before hardfork on March 28"; + // } + //} } return false; } From 2020f1c816cdf3bf00f99f483c63097a493d9d4f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 17 Mar 2018 09:39:56 +0100 Subject: [PATCH 0358/2430] Added more details to message --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 953b54d7..f10dc3ee 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1063,13 +1063,13 @@ function get_miner_notification(payout, agent) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); if (majorv < 2 || (majorv === 2 && minorv < 5)) { - return "Please update XMRig miner to at least v2.5.0 before hardfork on March 28"; + return "Please update XMRig miner (" + agent + ") to at least v2.5.0 before hardfork on March 28"; } } else if (m = reXMRSTAK.exec(agent)) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); if (majorv < 2 || (majorv === 2 && minorv <= 2)) { - return "Please update xmr-stak miner to version AFTER v2.2.0 before hardfork on March 28"; + return "Please update xmr-stak miner (" + agent + ") to version AFTER v2.2.0 before hardfork on March 28"; } } //} else if (m = reCCMINER.exec(agent)) { From 23ed32e4126ac51e7a87b778bcede16608d8fd3f Mon Sep 17 00:00:00 2001 From: sevendoorknobs Date: Tue, 20 Mar 2018 09:52:05 -0400 Subject: [PATCH 0359/2430] Fix block_locker.js throwing keyIsUint32 error Same issue that was effecting longRunner, perhaps there are more in the code. --- 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 0e8335e4..fbfa473a 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -470,7 +470,7 @@ function Database(){ this.lockBlock = function(blockId){ let txn = this.env.beginTxn(); - let blockProto = txn.getBinary(this.blockDB, blockId); + let blockProto = txn.getBinary(this.blockDB, parseInt(blockId)); if (blockProto !== null){ let blockData = global.protos.Block.decode(blockProto); blockData.unlocked = false; From a47002a05278bf11098cecfa1aba5d3dd083364b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Mar 2018 14:25:38 +0100 Subject: [PATCH 0360/2430] Fixed possible exception TypeError: Invalid hex string --- lib/pool.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f10dc3ee..e97983db 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -948,7 +948,14 @@ function processShare(miner, job, blockTemplate, params) { if (global.config.pool.trustedMiners && miner.difficulty < 400000 && miner.trust.threshold <= 0 && miner.trust.penalty <= 0 && crypto.randomBytes(1).readUIntBE(0, 1) > miner.trust.probability && miner.trust.check_height !== job.height) { - hash = new Buffer(resultHash, 'hex'); + try { + hash = new Buffer(resultHash, 'hex'); + } catch (err) { + process.send({type: 'invalidShare'}); + miner.sendNewJob(); + walletTrust[miner.payout] = 0; + return false; + } shareType = true; } else { // verify share if (miner.payout in minerWallets && ++minerWallets[miner.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { @@ -1063,20 +1070,20 @@ function get_miner_notification(payout, agent) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); if (majorv < 2 || (majorv === 2 && minorv < 5)) { - return "Please update XMRig miner (" + agent + ") to at least v2.5.0 before hardfork on March 28"; + return "Please update XMRig miner (" + agent + ") to at least v2.5.0 before hardfork on April 6"; } } else if (m = reXMRSTAK.exec(agent)) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); if (majorv < 2 || (majorv === 2 && minorv <= 2)) { - return "Please update xmr-stak miner (" + agent + ") to version AFTER v2.2.0 before hardfork on March 28"; + return "Please update xmr-stak miner (" + agent + ") to version AFTER v2.2.0 before hardfork on April 6"; } } //} else if (m = reCCMINER.exec(agent)) { // let majorv = parseInt(m[1]); // let minorv = parseInt(m[2]); // if (majorv < 3) { - // return "Please update ccminer-cryptonight miner to at least v3.00 before hardfork on March 28"; + // return "Please update ccminer-cryptonight miner to at least v3.00 before hardfork on April 6"; // } //} } From d19b2ba15982d04f6a68bf0f3ba62463a737f35e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 23 Mar 2018 15:20:54 +0100 Subject: [PATCH 0361/2430] Drop miner trust if bad share was detected by daemon --- lib/pool.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index e97983db..793a9135 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1015,6 +1015,13 @@ function processShare(miner, job, blockTemplate, params) { "Input: " + shareBuffer.toString('hex') + "\n" + threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) ); + 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).toString('hex'); From cffc3b36231a7dea34a8a1988c90c4cc17e1aeea Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Mar 2018 14:57:43 +0100 Subject: [PATCH 0362/2430] Added new Monero PoW support --- lib/coins/xmr.js | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a04cdc39..d5109c8e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -196,8 +196,9 @@ function Coin(data){ }; }; - this.cryptoNight = multiHashing.cryptonight; - + this.cryptoNight = function(convertedBlob) { + return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0); + } } module.exports = Coin; diff --git a/package.json b/package.json index 9b4ce5d3..68924899 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ }, "optionalDependencies": { "cryptonote-util": "git://github.com/Snipa22/node-cryptonote-util.git#xmr-Nan-2.0", - "multi-hashing": "git+https://github.com/Snipa22/node-multi-hashing-aesni.git" + "multi-hashing": "git+https://github.com/MoneroOcean/node-multi-hashing-aesni.git" } } From 38b63a708663b1d474fc7bc7484556b7a34fe473 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Mar 2018 16:09:39 +0100 Subject: [PATCH 0363/2430] Changed author --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 68924899..9b35b50f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/Snipa22/node-crypto-pool.git" }, - "author": "Alexander Blair", + "author": "Multiple", "license": "MIT", "dependencies": { "async": "2.1.4", From bc17506f7af575fb1029e3a8ee1ab4f622f98f3a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Mar 2018 18:35:01 +0100 Subject: [PATCH 0364/2430] Update monerod versions --- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 91 ++++++++++++++++++++++++++++++++++ deployment/monero_test.service | 13 +++++ deployment/upgrade_monero.bash | 2 +- 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 deployment/deploy_test.bash create mode 100644 deployment/monero_test.service diff --git a/deployment/deploy.bash b/deployment/deploy.bash index eda77385..a2cafb3a 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,7 +26,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.11.1.0 +sudo git checkout v0.12.0.0 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash new file mode 100644 index 00000000..1f836882 --- /dev/null +++ b/deployment/deploy_test.bash @@ -0,0 +1,91 @@ +#!/bin/bash +echo "This assumes that you are doing a green-field install. If you're not, please exit in the next 15 seconds." +sleep 15 +echo "Continuing install, this will prompt you for your password if you're not already running as root and you didn't enable passwordless sudo. Please do not run me as root!" +if [[ `whoami` == "root" ]]; then + echo "You ran me as root! Do not run me as root!" + exit 1 +fi +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 +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 +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 ~ +sudo systemctl enable ntp +cd /usr/local/src +sudo git clone https://github.com/monero-project/monero.git +cd monero +sudo git checkout v0.12.0.0 +curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v +sudo make -j$(nproc) +sudo cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service +sudo useradd -m monerodaemon -d /home/monerodaemon +sudo systemctl daemon-reload +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.9.3 +cd ~/nodejs-pool +npm install +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 +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 +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 +sudo mv caddy /usr/local/bin +sudo chown root:root /usr/local/bin/caddy +sudo chmod 755 /usr/local/bin/caddy +sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy +sudo groupadd -g 33 www-data +sudo useradd -g www-data --no-user-group --home-dir /var/www --no-create-home --shell /usr/sbin/nologin --system --uid 33 www-data +sudo mkdir /etc/caddy +sudo chown -R root:www-data /etc/caddy +sudo mkdir /etc/ssl/caddy +sudo chown -R www-data:root /etc/ssl/caddy +sudo chmod 0770 /etc/ssl/caddy +sudo cp ~/nodejs-pool/deployment/caddyfile /etc/caddy/Caddyfile +sudo chown www-data:www-data /etc/caddy/Caddyfile +sudo chmod 444 /etc/caddy/Caddyfile +sudo sh -c "sed 's/ProtectHome=true/ProtectHome=false/' init/linux-systemd/caddy.service > /etc/systemd/system/caddy.service" +sudo chown root:root /etc/systemd/system/caddy.service +sudo chmod 644 /etc/systemd/system/caddy.service +sudo systemctl daemon-reload +sudo systemctl enable caddy.service +sudo systemctl start caddy.service +rm -rf $CADDY_DOWNLOAD_DIR +cd ~ +sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin `pwd`/.nvm/versions/node/v8.9.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` +cd ~/nodejs-pool +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 +mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')" +mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" +pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api +bash ~/nodejs-pool/deployment/install_lmdb_tools.sh +cd ~/nodejs-pool/sql_sync/ +env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin node sql_sync.js +echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" diff --git a/deployment/monero_test.service b/deployment/monero_test.service new file mode 100644 index 00000000..c3604d7f --- /dev/null +++ b/deployment/monero_test.service @@ -0,0 +1,13 @@ +[Unit] +Description=Monero Daemon +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 --test-drop-download +Restart=always +User=monerodaemon + +[Install] +WantedBy=multi-user.target diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index b8cc1e2c..ed84f07b 100644 --- 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 origin/release-v0.11.0.0 +sudo git checkout origin/release-v0.12.0.0 curl -L https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo rm -rf build sudo make -j$(nproc) From 96af515452c04d09818e805f228ccdb05b93c757 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Mar 2018 19:21:27 +0100 Subject: [PATCH 0365/2430] Fixed testnet options --- deployment/monero_test.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/monero_test.service b/deployment/monero_test.service index c3604d7f..d6a20b1e 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 --test-drop-download +ExecStart=/usr/local/src/monero/build/release/bin/monerod --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc --testnet Restart=always User=monerodaemon From 1454f9f3272592d0dc4774b1137b6356224be134 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Mar 2018 16:15:55 +0200 Subject: [PATCH 0366/2430] Added blo_type selection support --- lib/coins/xmr.js | 4 ++++ lib/pool.js | 1 + 2 files changed, 5 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d5109c8e..c6f2f8a7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -199,6 +199,10 @@ function Coin(data){ this.cryptoNight = function(convertedBlob) { return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0); } + + this.blobTypeStr = function(port) { + return "cryptonote"; + } } module.exports = Coin; diff --git a/lib/pool.js b/lib/pool.js index 793a9135..62c135b9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -698,6 +698,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); this.cachedJob = { blocktemplate_blob: blob, + blob_type: global.coinFuncs.blobTypeStr(activeBlockTemplate.port), difficulty: activeBlockTemplate.difficulty, height: activeBlockTemplate.height, reserved_offset: activeBlockTemplate.reserveOffset, From ca2a46466e866573d81dd471dd42d49a1366ac8e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Mar 2018 16:49:29 +0200 Subject: [PATCH 0367/2430] Updated repos --- lib/coins/xmr.js | 4 ++-- lib/pool.js | 12 ++++++++++-- package.json | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index c6f2f8a7..3fe0ade6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1,7 +1,7 @@ "use strict"; const bignum = require('bignum'); -const cnUtil = require('cryptonote-util'); -const multiHashing = require('multi-hashing'); +const cnUtil = require('cryptoforknote-util'); +const multiHashing = require('cryptonight-hashing'); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); const process = require('process'); diff --git a/lib/pool.js b/lib/pool.js index 62c135b9..226969ce 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1067,6 +1067,7 @@ let lastMinerNotifyTime = {}; var reXMRig = /XMRig\/(\d+)\.(\d+)\./; var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; +var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; // no point to notifiy it - it does not print error message //var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; @@ -1078,13 +1079,20 @@ function get_miner_notification(payout, agent) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); if (majorv < 2 || (majorv === 2 && minorv < 5)) { - return "Please update XMRig miner (" + agent + ") to at least v2.5.0 before hardfork on April 6"; + return "Please update your XMRig miner (" + agent + ") to at least v2.5.0 before hardfork on April 6"; } } else if (m = reXMRSTAK.exec(agent)) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); if (majorv < 2 || (majorv === 2 && minorv <= 2)) { - return "Please update xmr-stak miner (" + agent + ") to version AFTER v2.2.0 before hardfork on April 6"; + return "Please update your xmr-stak miner (" + agent + ") to version NEWER THAN v2.2.0 before hardfork on April 6"; + } + } else if (m = reXNP.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + let minorv2 = parseInt(m[3]); + if (majorv === 0 && minorv === 0 && minorv2 === 1) { + return "Please update your xmr-node-proxy (" + agent + ") to version NEWER THAN v0.0.1 before hardfork on April 6 (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } //} else if (m = reCCMINER.exec(agent)) { diff --git a/package.json b/package.json index 9b35b50f..00a812f6 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "zmq": "^2.15.3" }, "optionalDependencies": { - "cryptonote-util": "git://github.com/Snipa22/node-cryptonote-util.git#xmr-Nan-2.0", - "multi-hashing": "git+https://github.com/MoneroOcean/node-multi-hashing-aesni.git" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git" } } From e86f2e30d3c6af38ff1c5a3dc93add856a845a3d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Mar 2018 18:44:53 +0200 Subject: [PATCH 0368/2430] Updated monero versions --- 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 a2cafb3a..6af6a351 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,7 +26,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.12.0.0 +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 cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 1f836882..7c180c6a 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -26,7 +26,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.12.0.0 +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 cp ~/nodejs-pool/deployment/monero_test.service /lib/systemd/system/monero.service diff --git a/deployment/leaf.bash b/deployment/leaf.bash index f83bff8d..66aa0bcf 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -22,7 +22,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.11.1.0 +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 cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index ed84f07b..b779f519 100644 --- 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 origin/release-v0.12.0.0 +sudo git checkout origin/release-v0.12 curl -L https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v sudo rm -rf build sudo make -j$(nproc) From b6f303560419b64e467c27dbe83c8d402e742926 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Mar 2018 22:30:53 +0200 Subject: [PATCH 0369/2430] Put required xmr-stak version --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 226969ce..2a9d381b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1084,8 +1084,8 @@ function get_miner_notification(payout, agent) { } else if (m = reXMRSTAK.exec(agent)) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); - if (majorv < 2 || (majorv === 2 && minorv <= 2)) { - return "Please update your xmr-stak miner (" + agent + ") to version NEWER THAN v2.2.0 before hardfork on April 6"; + if (majorv < 2 || (majorv === 2 && minorv < 3)) { + return "Please update your xmr-stak miner (" + agent + ") to at least v2.3.0 before hardfork on April 6"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]); From f6e86c88a99e3477948fb2c66e1e7510636f3357 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sun, 25 Mar 2018 13:33:23 -0700 Subject: [PATCH 0370/2430] Update to tagged release for node-multi-hashing-aesni --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76368b3f..bbfd8766 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,6 @@ }, "optionalDependencies": { "cryptonote-util": "git://github.com/Snipa22/node-cryptonote-util.git#xmr-Nan-2.0", - "multi-hashing": "git+https://github.com/Snipa22/node-multi-hashing-aesni.git" + "multi-hashing": "git+https://github.com/Snipa22/node-multi-hashing-aesni.git#v0.1" } } From 663f39a47967f58473d3e77e510637b047b52528 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Mar 2018 11:20:13 +0200 Subject: [PATCH 0371/2430] Added AEON donation address --- README.md | 1 + lib/coins/aeon.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 377384e8..a1d0a08c 100644 --- a/README.md +++ b/README.md @@ -256,6 +256,7 @@ Developer Donations =================== If you'd like to make a one time donation, the addresses are as follows: * XMR - ```499fS1Phq64hGeqV8p2AfXbf6Ax7gP6FybcMJq6Wbvg8Hw6xms8tCmdYpPsTLSaTNuLEtW4kF2DDiWCFcw4u7wSvFD8wFWE``` +* AEON - ```WmsEg3RuUKCcEvFBtXcqRnGYfiqGJLP1FGBYiNMgrcdUjZ8iMcUn2tdcz59T89inWr9Vae4APBNf7Bg2DReFP5jr23SQqaDMT``` * ETN - ```etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1``` * SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` diff --git a/lib/coins/aeon.js b/lib/coins/aeon.js index 3034f24a..5f9cf1c4 100644 --- a/lib/coins/aeon.js +++ b/lib/coins/aeon.js @@ -13,7 +13,7 @@ function Coin(data){ let instanceId = crypto.randomBytes(4); console.log("Generated instanceId: " + instanceId.toString('hex')); this.coinDevAddress = "WmsSWgtT1JPg5e3cK41hKXSHVpKW7e47bjgiKmWZkYrhSS5LhRemNyqayaSBtAQ6517eo5PtH9wxHVmM78JDZSUu2W8PqRiNs"; // Developer Address - this.poolDevAddress = "WmtvM6SoYya4qzkoPB4wX7FACWcXyFPWAYzfz7CADECgKyBemAeb3dVb3QomHjRWwGS3VYzMJAnBXfUx5CfGLFZd1U7ssdXTu"; // Snipa Address + this.poolDevAddress = "WmsEg3RuUKCcEvFBtXcqRnGYfiqGJLP1FGBYiNMgrcdUjZ8iMcUn2tdcz59T89inWr9Vae4APBNf7Bg2DReFP5jr23SQqaDMT"; // MoneroOcean Address this.blockedAddresses = [ this.coinDevAddress, From 4cb28864b162ce99ed2a1c97c1832a75e1104bd1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Mar 2018 20:49:51 +0200 Subject: [PATCH 0372/2430] Changed throttled share error message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2a9d381b..61006124 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1275,7 +1275,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let shareAccepted = processShare(miner, job, blockTemplate, params); if (shareAccepted === null) { - sendReply('Throttled down share submission (please increase diff or use xmr-node-proxy)'); + sendReply('Throttled down share submission (please use high fixed diff or use xmr-node-proxy)'); return; } miner.checkBan(shareAccepted); From def5437a971c5362941359eb976bb791292c0860 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Mar 2018 20:54:42 +0200 Subject: [PATCH 0373/2430] Added orphan block handling for forknote --- 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 466615ec..d5e27970 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -453,7 +453,8 @@ 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) { + 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)) { let time_now = Date.now(); if (blockDataDecoded.hash in orphanBlocks) { if (time_now - orphanBlocks[blockDataDecoded.hash] > 5*60*1000) { From 71bd97026776b1624fc41a5ea65a9cc7b69e78dd Mon Sep 17 00:00:00 2001 From: CamTheGeek Date: Mon, 26 Mar 2018 15:07:52 -0400 Subject: [PATCH 0374/2430] AEON Variant changes Coin file, payment file, coinConfig updates. --- coinConfig.json | 8 + lib/coins/aeon-rebase.js | 164 +++++++ lib/payment_systems/aeon-rebase.js | 697 +++++++++++++++++++++++++++++ 3 files changed, 869 insertions(+) create mode 100644 lib/coins/aeon-rebase.js create mode 100644 lib/payment_systems/aeon-rebase.js diff --git a/coinConfig.json b/coinConfig.json index e1595a75..2cbf1015 100644 --- a/coinConfig.json +++ b/coinConfig.json @@ -24,5 +24,13 @@ "name": "Aeon Coin", "mixIn": 4, "shortCode": "AEON" + }, + "aeon-rebase": { + "funcFile": "./lib/coins/aeon-rebase.js", + "paymentFile": "./payment_systems/aeon-rebase.js", + "sigDigits": 1000000000000, + "name": "Aeon Coin", + "mixIn": 4, + "shortCode": "AEON" } } diff --git a/lib/coins/aeon-rebase.js b/lib/coins/aeon-rebase.js new file mode 100644 index 00000000..08972d6f --- /dev/null +++ b/lib/coins/aeon-rebase.js @@ -0,0 +1,164 @@ +"use strict"; +const bignum = require('bignum'); +const cnUtil = require('cryptonote-util'); +const multiHashing = require('multi-hashing'); +const crypto = require('crypto'); +const debug = require('debug')('coinFuncs'); + +let hexChars = new RegExp("[0-9a-f]+"); + +function Coin(data){ + this.bestExchange = global.config.payout.bestExchange; + this.data = data; + let instanceId = crypto.randomBytes(4); + this.coinDevAddress = "WmsSWgtT1JPg5e3cK41hKXSHVpKW7e47bjgiKmWZkYrhSS5LhRemNyqayaSBtAQ6517eo5PtH9wxHVmM78JDZSUu2W8PqRiNs"; // Developer Address + this.poolDevAddress = "WmtvM6SoYya4qzkoPB4wX7FACWcXyFPWAYzfz7CADECgKyBemAeb3dVb3QomHjRWwGS3VYzMJAnBXfUx5CfGLFZd1U7ssdXTu"; // Snipa Address + + this.blockedAddresses = [ + this.coinDevAddress, + this.poolDevAddress, + ]; + + this.exchangeAddresses = [ + "WmtK9TQ6yd2ZWZDAkRsebc2ppzUq2Wuo9XRRjHMH2fvqM3ARVqk3styJ6AavJFcpJFPFtxRGAqGFoJMZGJ6YYzQ61TYGfpykX", // Bittrex + ]; // These are addresses that MUST have a paymentID to perform logins with. + + this.prefix = 178; + //this.intPrefix = 0x2733; + + if (global.config.general.testnet === true){ + this.prefix = 0x0426; + // this.intPrefix = 0x2C27; + } + + this.supportsAutoExchange = false; + + this.niceHashDiff = 200000; + + this.getBlockHeaderByID = function(blockId, callback){ + global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { + if (body.hasOwnProperty('result')){ + return callback(null, body.result.block_header); + } else { + console.error(JSON.stringify(body)); + return callback(true, body); + } + }); + }; + + this.getBlockHeaderByHash = function(blockHash, callback){ + global.support.rpcDaemon('getblockheaderbyhash', {"hash": blockHash}, function (body) { + if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ + return callback(null, body.result.block_header); + } else { + console.error(JSON.stringify(body)); + return callback(true, body); + } + }); + }; + + this.getLastBlockHeader = function(callback){ + global.support.rpcDaemon('getlastblockheader', [], function (body) { + if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ + return callback(null, body.result.block_header); + } else { + console.error(JSON.stringify(body)); + return callback(true, body); + } + }); + }; + + this.getBlockTemplate = function(walletAddress, callback){ + global.support.rpcDaemon('getblocktemplate', { + reserve_size: 17, + wallet_address: walletAddress + }, function(body){ + return callback(body); + }); + }; + + this.baseDiff = function(){ + return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); + }; + + this.validateAddress = 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); + if (cnUtil.address_decode(address) === this.prefix){ + return true; + } + return cnUtil.address_decode_integrated(address) === this.intPrefix; + }; + + this.convertBlob = function(blobBuffer){ + return cnUtil.convert_blob(blobBuffer); + }; + + this.constructNewBlob = function(blockTemplate, NonceBuffer){ + return cnUtil.construct_block_blob(blockTemplate, NonceBuffer); + }; + + this.getBlockID = function(blockBuffer){ + return cnUtil.get_block_id(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. + The reserved space is 13 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; + // 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'); + // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. + instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3); + // 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 + 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.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. + return global.coinFuncs.convertBlob(this.buffer).toString('hex'); + }; + // Make it so you can get the raw block 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. + return this.buffer.toString('hex'); + }; + }; + + this.cryptoNight = function(convertedBlob) { + return multiHashing.cryptonight_light(convertedBlob, convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0); + } + +} + +module.exports = Coin; diff --git a/lib/payment_systems/aeon-rebase.js b/lib/payment_systems/aeon-rebase.js new file mode 100644 index 00000000..ff2059f1 --- /dev/null +++ b/lib/payment_systems/aeon-rebase.js @@ -0,0 +1,697 @@ +"use strict"; +const shapeshift = require('shapeshift.io'); +const async = require("async"); +const debug = require("debug")("payments"); +const request = require('request-json'); +const range = require('range'); + +let hexChars = new RegExp("[0-9a-f]+"); +let bestExchange = global.config.payout.bestExchange; +let xmrAPIClient = request.createClient('https://xmr.to/api/v1/xmr2btc/'); +let extraPaymentRound = false; +let paymentTimer = null; + +let shapeshiftQueue = async.queue(function (task, callback) { + // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. + let amount = task.amount - task.fee; + // Address is the destination address IN BTC. + let address = task.address; + // PaymentIDs are the paymentID's to flag as paid by this transaction. + // Should be a massive list of ID's so we can bulk-update them, by merging them with 's. + // Here we go! General process: Scan shapeshift for valid amounts of funds to xfer around. + // Once there's enough funds, then we active txn + // Do a wallet call to xfer. + // Setup a monitor on the transaction + async.waterfall([ + function (intCallback) { + // Verify if the coin is active in ShapeShift first. + shapeshift.coins(function (err, coinData) { + if (err) { + intCallback(err); + } else if (!coinData.hasOwnProperty(global.config.general.coinCode) || coinData[global.config.general.coinCode].status !== "available") { + intCallback("Coin " + global.config.general.coinCode + " Is not available at this time on shapeshift."); + } else { + intCallback(null); + } + }); + }, + function (intCallback) { + // Get the market information from shapeshift, which includes deposit limits, minimum deposits, rates, etc. + shapeshift.marketInfo(global.config.payout.shapeshiftPair, function (err, marketInfo) { + if (err) { + intCallback(err); + } else if (!marketInfo.hasOwnProperty("limit") || marketInfo.limit <= global.support.coinToDecimal(amount)) { + intCallback("Not enough coin in shapeshift to process at this time."); + } else if (!marketInfo.hasOwnProperty("min") || marketInfo.min >= global.support.coinToDecimal(amount)) { + intCallback("Not enough coin to hit the shapeshift minimum deposits."); + } else { + intCallback(null, marketInfo); + } + }); + }, + function (marketInfo, intCallback) { + // Validated there's enough coin. Time to make our dank txn. + // Return: + /* + { + "orderId": "cc49c556-e645-4c15-a943-d50a935274e4", + "sAddress": "46yzCCD3Mza9tRj7aqPSaxVbbePtuAeKzf8Ky2eRtcXGcEgCg1iTBio6N4sPmznfgGEUGDoBz5CLxZ2XPTyZu1yoCAG7zt6", + "deposit": "d8041668718e6e9d9d0fd335ee5ecd923e6fd074c41316d041cc18b779ade10e", + "depositType": "XMR", + "withdrawal": "1DbxcoCBSA9N7uZvkcvWxuLxSau9q9Pwiu", + "withdrawalType": "BTC", + "public": null, + "apiPubKey": "shapeshift", + "returnAddress": "46XWBqE1iwsVxSDP1qDrxhE1XvsZV6eALG5LwnoMdjbT4GPdy2bZTb99kagzxp2MMjUamTYZ4WgvZdFadvMimTjvR6Gv8hL", + "returnAddressType": "XMR" + } + Valid Statuses: + "received" + "complete" + "error" + "no_deposits" + Complete State Information: + { + "status": "complete", + "address": "d8041668718e6e9d9d0fd335ee5ecd923e6fd074c41316d041cc18b779ade10e", + "withdraw": "1DbxcoCBSA9N7uZvkcvWxuLxSau9q9Pwiu", + "incomingCoin": 3, + "incomingType": "XMR", + "outgoingCoin": "0.04186155", + "outgoingType": "BTC", + "transaction": "be9d97f6fc75262151f8f63e035c6ed638b9eb2a4e93fef43ea63124b045dbfb" + } + */ + shapeshift.shift(address, global.config.payout.shapeshiftPair, {returnAddress: global.config.pool.address}, function (err, returnData) { + if (err) { + intCallback(err); + } else { + global.mysql.query("INSERT INTO shapeshiftTxn (id, address, paymentID, depositType, withdrawl, withdrawlType, returnAddress, returnAddressType, txnStatus) VALUES (?,?,?,?,?,?,?,?,?)", + [returnData.orderId, returnData.sAddress, returnData.deposit, returnData.depositType, returnData.withdrawl, returnData.withdrawlType, returnData.returnAddress, returnData.returnAddressType, 'no_deposits']).then(function () { + intCallback(null, marketInfo, returnData); + }).catch(function (error) { + intCallback(error); + }); + } + }); + }, + function (marketInfo, shapeshiftTxnData, intCallback) { + // Make the payment to ShapeShift + let paymentDetails = { + destinations: [ + { + amount: amount, + address: shapeshiftTxnData.sAddress + } + ], + priority: global.config.payout.priority, + mixin: global.config.payout.mixIn, + payment_id: shapeshiftTxnData.deposit + }; + debug("Payment Details: " + JSON.stringify(paymentDetails)); + paymentQueue.push(paymentDetails, function (body) { + if (body.fee && body.fee > 10) { + intCallback(null, marketInfo, shapeshiftTxnData, body); + } else { + intCallback("Unknown error from the wallet."); + } + }); + }, + function (marketInfo, shapeshiftTxnData, body, intCallback) { + // body.tx_hash = XMR transaction hash. + // Need to add transaction. + global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees, exchange_rate, exchange_name, exchange_txn_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + [1, address, null, task.amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, global.support.decimalToCoin(marketInfo.minerFee), 1, global.support.decimalToCoin(marketInfo.rate), 'shapeshift', shapeshiftTxnData.orderId]).then(function (result) { + intCallback(null, result.insertId); + }).catch(function (error) { + intCallback(error); + }); + } + ], function (err, result) { + if (err) { + console.error("Error processing shapeshift txn: " + JSON.stringify(err)); + callback(true); + } else { + // Need to fill out this data pronto! + console.log("Processed ShapeShift transaction for: " + address + " Paid out: " + result + " payments in the db"); + callback(null, result); + } + }); +}, 2); + +let xmrToQueue = async.queue(function (task, callback) { + // http://xmrto-api.readthedocs.io/en/latest/introduction.html + // Documentation looks good! + // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. + let amount = task.amount - task.fee; + // Address is the destination address IN BTC. + let address = task.address; + // PaymentIDs are the paymentID's to flag as paid by this transaction. + // Should be a massive list of ID's so we can bulk-update them, by merging them with 's. + // Here we go! General process: Scan shapeshift for valid amounts of funds to xfer around. + // Once there's enough funds, then we active txn + // Do a wallet call to xfer. + // Setup a monitor on the transaction + async.waterfall([ + function (intCallback) { + // Verify if XMR.to is ready to get to work. + xmrAPIClient.get('order_parameter_query/', function (err, res, body) { + if (err) { + return intCallback(err); + } else if (body.error_msg) { + return intCallback(body.error_msg); + } else { + let amtOfBTC = ((amount / global.config.general.sigDivisor) * body.price).toPrecision(5); + console.log("Attempting to pay: " + address + " Amount: " + amtOfBTC + " BTC or " + amount / global.config.general.sigDivisor + " XMR"); + console.log("Response from XMR.to: " + JSON.stringify(body)); + if (body.lower_limit >= amtOfBTC) { + return intCallback("Not enough XMR to hit the minimum deposit"); + } else if (body.upper_limit <= amtOfBTC) { + return intCallback("Too much XMR to pay out to xmr.to"); + } else { + return intCallback(null, amtOfBTC); + } + } + }); + }, + function (btcValue, intCallback) { + // Validated there's enough coin. Time to make our dank txn. + // Return: + /* + { + "state": "TO_BE_CREATED", + "btc_amount": , + "btc_dest_address": "", + "uuid": "" + } + Valid Statuses: + "TO_BE_CREATED" + "UNPAID" + "UNDERPAID" + "PAID_UNCONFIRMED" + "PAID" + "BTC_SENT" + "TIMED_OUT" + "NOT_FOUND" + // Create, then immediately update with the new information w/ a status call. + */ + console.log("Amount of BTC to pay: " + btcValue); + xmrAPIClient.post('order_create/', { + btc_amount: btcValue, + btc_dest_address: address + }, function (err, res, body) { + if (err) { + return intCallback(err); + } else if (body.error_msg) { + return intCallback(body.error_msg); + } else { + return intCallback(null, body.uuid); + } + }); + }, + function (txnID, intCallback) { + // This function only exists because xmr.to is a pretty little fucking princess. + async.doUntil(function (xmrCallback) { + xmrAPIClient.post('order_status_query/', {uuid: txnID}, function (err, res, body) { + if (err) { + return intCallback(err); + } else if (body.error_msg) { + return intCallback(body.error_msg); + } else { + xmrCallback(null, body.state); + } + }); + }, + function (xmrCallback) { + return xmrCallback !== "TO_BE_CREATED"; + }, + function () { + intCallback(null, txnID); + }); + }, + function (txnID, intCallback) { + xmrAPIClient.post('order_status_query/', {uuid: txnID}, function (err, res, body) { + if (err) { + return intCallback(err); + } else if (body.error_msg) { + return intCallback(body.error_msg); + } else { + console.log(JSON.stringify(body)); + global.mysql.query("INSERT INTO xmrtoTxn (id, address, paymentID, depositType, withdrawl, withdrawlType, returnAddress, returnAddressType, txnStatus, amountDeposited, amountSent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", + [txnID, body.xmr_receiving_address, body.xmr_required_payment_id_long, 'XMR', body.btc_dest_address, 'BTC', global.config.pool.address, 'XMR', body.state_str, global.support.decimalToCoin(body.xmr_amount_total), global.support.decimalToCoin(body.btc_amount)]).then(function () { + return intCallback(null, body, global.support.decimalToCoin(body.xmr_amount_total)); + }).catch(function (error) { + return intCallback(error); + }); + } + }); + }, + function (orderStatus, xmrDeposit, intCallback) { + // Make the payment to ShapeShift + let paymentDetails = { + destinations: [ + { + amount: xmrDeposit, + address: orderStatus.xmr_receiving_address + } + ], + priority: global.config.payout.priority, + mixin: global.config.payout.mixIn, + payment_id: orderStatus.xmr_required_payment_id_long + }; + debug("Payment Details: " + JSON.stringify(paymentDetails)); + paymentQueue.push(paymentDetails, function (body) { + if (body.fee && body.fee > 10) { + return intCallback(null, orderStatus, body); + } else { + return intCallback("Unknown error from the wallet."); + } + }); + }, + function (orderStatus, body, intCallback) { + // body.tx_hash = XMR transaction hash. + // Need to add transaction. + global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees, exchange_rate, exchange_name, exchange_txn_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + [1, address, null, global.support.decimalToCoin(orderStatus.xmr_amount_total), body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1, global.support.decimalToCoin(orderStatus.xmr_price_btc), 'xmrto', orderStatus.uuid]).then(function (result) { + return intCallback(null, result.insertId); + }).catch(function (error) { + return intCallback(error); + }); + } + ], function (err, result) { + if (err) { + console.error("Error processing XMRTo txn: " + JSON.stringify(err)); + return callback("Error!"); + } else { + // Need to fill out this data pronto! + console.log("Processed XMRTo transaction for: " + address + " Paid out: " + result + " payments in the db"); + return callback(null, result); + } + }); +}, 2); + +let paymentQueue = async.queue(function (paymentDetails, callback) { + /* + support JSON URI: http://10.0.0.2:28082/json_rpc Args: {"id":"0","jsonrpc":"2.0","method":"transfer","params":{"destinations":[{"amount":68130252045355,"address":"A2MSrn49ziBPJBh8ZNEhhbfyLMou6mao4C1F5TLGUatmUnCxZArDYkcbAnVkVEopWVeak2rKDrmc8JpoS7n5dvfN9YDPBTG"}],"mixin":4,"payment_id":"7e52c5266de9fede7fb3abc0cd88f937b38b51426f7b34ff99729d28ce4e1142"}} +1ms + payments Payment made: {"id":"0","jsonrpc":"2.0","result":{"fee":40199391255,"tx_hash":"c418708643f72635edf522490bfb2cae9d42a6dc1df30dcde844862dfd88f5b3","tx_key":""}} +2s + */ + if (paymentTimer !== null){ + clearInterval(paymentTimer); + paymentTimer = null; + } + debug("Making payment based on: " + JSON.stringify(paymentDetails)); + let transferFunc = 'transfer'; + global.support.rpcWallet(transferFunc, paymentDetails, function (body) { + debug("Payment made: " + JSON.stringify(body)); + if (body.hasOwnProperty('error')) { + if (body.error.message === "not enough money"){ + console.error("Issue making payments, not enough money, will try later"); + if(!extraPaymentRound){ + setTimeout(function(){ + makePayments(); + }, global.config.payout.timerRetry * 60 * 1000); + } + extraPaymentRound = true; + return callback(false); + } else { + console.error("Issue making payments" + JSON.stringify(body.error)); + console.error("Will not make more payments until the payment daemon is restarted!"); + //toAddress, subject, body + global.support.sendEmail(global.config.general.adminEmail, "Payment daemon unable to make payment", + "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(body.error) + + ". Please investigate and restart the payment daemon as appropriate"); + return; + } + } + if (paymentDetails.hasOwnProperty('payment_id')) { + console.log("Payment made to " + paymentDetails.destinations[0].address + " with PaymentID: " + paymentDetails.payment_id + " For: " + global.support.coinToDecimal(paymentDetails.destinations[0].amount) + " AEON with a " + global.support.coinToDecimal(body.result.fee) + " AEON Mining Fee"); + return callback(body.result); + } else { + if (transferFunc === 'transfer') { + console.log(body); + console.log("Payment made out to multiple people, total fee: " + global.support.coinToDecimal(body.result.fee) + " AEON"); + } + let intCount = 0; + paymentDetails.destinations.forEach(function (details) { + console.log("Payment made to: " + details.address + " For: " + global.support.coinToDecimal(details.amount) + " AEON"); + intCount += 1; + if (intCount === paymentDetails.destinations.length) { + return callback(body.result); + } + }); + } + }); +}, 1); + +paymentQueue.drain = function(){ + extraPaymentRound = false; + if (global.config.payout.timer > 35791){ + console.error("Payout timer is too high. Please use a value under 35791 to avoid overflows."); + } else { + paymentTimer = setInterval(makePayments, global.config.payout.timer * 60 * 1000); + } + 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) { + rows.forEach(function (row) { + shapeshift.status(row.paymentID, function (err, status, returnData) { + if (err) { + return; + } + global.mysql.query("UPDATE shapeshiftTxn SET txnStatus = ? WHERE id = ?", [status, row.id]).then(function () { + if (status === 'complete') { + global.mysql.query("UPDATE shapeshiftTxn SET amountDeposited = ?, amountSent = ?, transactionHash = ? WHERE id = ?", + [global.support.decimalToCoin(returnData.incomingCoin), global.support.bitcoinDecimalToCoin(returnData.outgoingCoin), returnData.transaction, row.id]).then(function () { + global.mysql.query("UPDATE transactions SET confirmed = 1, confirmed_time = now(), btc_amt = ? WHERE exchange_txn_id = ?", [global.support.bitcoinDecimalToCoin(returnData.outgoingCoin), row.id]); + }); + } else if (status === 'error') { + // Failed txn. Need to rollback and delete all related data. Here we go! + global.mysql.query("DELETE FROM shapeshiftTxn WHERE id = ?", [row.id]); + global.mysql.query("SELECT id, xmr_amt, address FROM transactions WHERE exchange_txn_id = ?", [row.id]).then(function (rows) { + global.mysql.query("DELETE FROM transactions WHERE id = ?", [rows[0].id]); + global.mysql.query("DELETE payments WHERE transaction_id = ?", [rows[0].id]); + global.mysql.query("UPDATE balance SET amount = amount+? WHERE payment_address = ? limit 1", [rows[0].xmr_amt, rows[0].address]); + }); + console.error("Failed transaction from ShapeShift " + JSON.stringify(returnData)); + } + }); + }); + }); + }); +} + +function updateXMRToCompletion() { + global.mysql.query("SELECT * FROM xmrtoTxn WHERE txnStatus NOT IN ('PAID', 'TIMED_OUT', 'NOT_FOUND', 'BTC_SENT')").then(function (rows) { + rows.forEach(function (row) { + xmrAPIClient.post('order_status_query/', {uuid: row.id}, function (err, res, body) { + if (err) { + console.log("Error in getting order status: " + JSON.stringify(err)); + return; + } + if (body.error_msg) { + console.log("Error in getting order status: " + body.error_msg); + return; + } + global.mysql.query("UPDATE xmrtoTxn SET txnStatus = ? WHERE id = ?", [body.state, row.id]).then(function () { + if (body.status === 'BTC_SENT') { + global.mysql.query("UPDATE xmrtoTxn SET transactionHash = ? WHERE id = ?", [body.btc_transaction_id, row.id]).then(function () { + global.mysql.query("UPDATE transactions SET confirmed = 1, confirmed_time = now(), btc_amt = ? WHERE exchange_txn_id = ?", [global.support.bitcoinDecimalToCoin(body.btc_amount), row.id]); + }); + } else if (body.status === 'TIMED_OUT' || body.status === 'NOT_FOUND') { + global.mysql.query("DELETE FROM xmrtoTxn WHERE id = ?", [row.id]); + global.mysql.query("SELECT id, xmr_amt, address FROM transactions WHERE exchange_txn_id = ?", [row.id]).then(function (rows) { + global.mysql.query("DELETE FROM transactions WHERE id = ?", [rows[0].id]); + global.mysql.query("DELETE payments WHERE transaction_id = ?", [rows[0].id]); + global.mysql.query("UPDATE balance SET amount = amount+? WHERE payment_address = ? limit 1", [rows[0].xmr_amt, rows[0].address]); + }); + console.error("Failed transaction from XMRto " + JSON.stringify(body)); + } + }); + }); + }); + }); +} + +function determineBestExchange() { + async.waterfall([ + function (callback) { + // Verify if the coin is active in ShapeShift first. + shapeshift.coins(function (err, coinData) { + if (err) { + return callback(err); + } else if (!coinData.hasOwnProperty(global.config.general.coinCode) || coinData[global.config.general.coinCode].status !== "available") { + return callback("Coin " + global.config.general.coinCode + " Is not available at this time on shapeshift."); + } else { + return callback(null); + } + }); + }, + function (callback) { + // Get the market information from shapeshift, which includes deposit limits, minimum deposits, rates, etc. + shapeshift.marketInfo(global.config.payout.shapeshiftPair, function (err, marketInfo) { + if (err) { + return callback(err); + } else if (!marketInfo.hasOwnProperty("rate")) { + return callback("Shapeshift did not return the rate."); + } else { + return callback(null, global.support.bitcoinDecimalToCoin(marketInfo.rate)); + } + }); + }, + function (ssValue, callback) { + xmrAPIClient.get('order_parameter_query/', function (err, res, body) { + console.log("XMR.to pricing body: " + JSON.stringify(body)); + if (err) { + return callback(err); + } else if (body.error_msg) { + return callback(body.error_msg); + } else { + return callback(null, ssValue, global.support.bitcoinDecimalToCoin(body.price)); + } + }); + } + ], function (err, ssValue, xmrToValue) { + if (err) { + return console.error("Error processing exchange value: " + JSON.stringify(err)); + } + debug("ShapeShift Value: " + global.support.bitcoinCoinToDecimal(ssValue) + " XMR.to Value: " + global.support.bitcoinCoinToDecimal(xmrToValue)); + if (ssValue >= xmrToValue) { + console.log("ShapeShift is the better BTC exchange, current rate: " + global.support.bitcoinCoinToDecimal(ssValue)); + bestExchange = 'shapeshift'; + global.mysql.query("UPDATE config SET item_value = 'shapeshift' where item='bestExchange'"); + global.mysql.query("UPDATE config SET item_value = ? where item='exchangeRate'", [ssValue]); + } else { + console.log("XMR.to is the better BTC exchange, current rate: " + global.support.bitcoinCoinToDecimal(xmrToValue)); + bestExchange = 'xmrto'; + global.mysql.query("UPDATE config SET item_value = 'xmrto' where item='bestExchange'"); + global.mysql.query("UPDATE config SET item_value = ? where item='exchangeRate'", [xmrToValue]); + } + }); +} + +function Payee(amount, address, paymentID, bitcoin) { + this.amount = amount; + this.address = address; + this.paymentID = paymentID; + this.bitcoin = bitcoin; + this.blockID = 0; + this.poolType = ''; + this.transactionID = 0; + this.sqlID = 0; + if (paymentID === null) { + this.id = address; + } else { + this.id = address + "." + paymentID; + } + this.fee = 0; + this.baseFee = global.support.decimalToCoin(global.config.payout.feeSlewAmount); + this.setFeeAmount = function () { + if (this.amount <= global.support.decimalToCoin(global.config.payout.walletMin)) { + this.fee = this.baseFee; + } else if (this.amount <= global.support.decimalToCoin(global.config.payout.feeSlewEnd)) { + let feeValue = this.baseFee / (global.support.decimalToCoin(global.config.payout.feeSlewEnd) - global.support.decimalToCoin(global.config.payout.walletMin)); + this.fee = this.baseFee - ((this.amount - global.support.decimalToCoin(global.config.payout.walletMin)) * feeValue); + } + this.fee = Math.floor(this.fee); + }; + + this.makePaymentWithID = function () { + let paymentDetails = { + destinations: [ + { + amount: this.amount - this.fee, + address: this.address + } + ], + priority: global.config.payout.priority, + mixin: global.config.payout.mixIn, + payment_id: this.paymentID + }; + let identifier = this.id; + let amount = this.amount; + let address = this.address; + let paymentID = this.paymentID; + let payee = this; + debug("Payment Details: " + JSON.stringify(paymentDetails)); + paymentQueue.push(paymentDetails, function (body) { + if (body.fee && body.fee > 10) { + debug("Successful payment sent to: " + identifier); + global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { + payee.transactionID = result.insertId; + payee.trackPayment(); + }); + } else { + console.error("Unknown error from the wallet."); + } + }); + }; + + this.makePaymentAsIntegrated = function () { + let paymentDetails = { + destinations: [ + { + amount: this.amount - this.fee, + address: this.address + } + ], + priority: global.config.payout.priority, + mixin: global.config.payout.mixIn + }; + let identifier = this.id; + let amount = this.amount; + let address = this.address; + let payee = this; + + debug("Payment Details: " + JSON.stringify(paymentDetails)); + paymentQueue.push(paymentDetails, function (body) { + if (body.fee && body.fee > 10) { + debug("Successful payment sent to: " + identifier); + global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", + [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { + payee.transactionID = result.insertId; + payee.trackPayment(); + }); + } else { + console.error("Unknown error from the wallet."); + } + }); + }; + + this.makeBitcoinPayment = function () { + let functionalData = {address: this.address, amount: this.amount, fee: this.fee}; + let payee = this; + if (bestExchange === 'xmrto') { + xmrToQueue.push(functionalData, function (err, transactionID) { + if (err) { + return console.error("Error processing payment for " + functionalData.address); + } + payee.transactionID = transactionID; + payee.trackPayment(); + }); + } else { + shapeshiftQueue.push(functionalData, function (err, transactionID) { + if (err) { + return console.error("Error processing payment for " + functionalData.address); + } + payee.transactionID = transactionID; + payee.trackPayment(); + }); + } + }; + + this.trackPayment = function () { + global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]); + global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + + " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]); + }; +} + +function makePayments() { + global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { + 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) { + 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 += 1; + let threshold = 0; + if (userRow.length !== 0) { + threshold = userRow[0].payout_threshold; + } + payee.poolType = row.pool_type; + payee.sqlID = row.id; + if (payee.poolType === "fees" && payee.address === global.config.payout.feeAddress && payee.amount >= ((global.support.decimalToCoin(global.config.payout.feesForTXN) + global.support.decimalToCoin(global.config.payout.exchangeMin)))) { + debug("This is the fee address internal check for value"); + payee.amount -= global.support.decimalToCoin(global.config.payout.feesForTXN); + } else if (payee.address === global.config.payout.feeAddress && payee.poolType === "fees") { + debug("Unable to pay fee address."); + payee.amount = 0; + } + let remainder = payee.amount % (global.config.payout.denom * global.config.general.sigDivisor); + if (remainder !== 0) { + payee.amount -= remainder; + } + if (payee.amount > threshold) { + payee.setFeeAmount(); + if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { + debug("Adding " + payee.id + " to the list of people to pay (OG Address). Payee balance: " + 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 && threshold !== 0))) { + // 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. + debug("Adding " + payee.id + " to the list of people to pay (Integrated Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); + payee.makePaymentAsIntegrated(); + } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 0) { + debug("Adding " + payee.id + " to the list of people to pay (Payment ID Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); + payee.makePaymentWithID(); + } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 1) { + debug("Adding " + payee.id + " to the list of people to pay (Bitcoin Payout). Payee balance: " + global.support.coinToDecimal(payee.amount)); + 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("Paying out: " + paymentDetails.destinations.length + " people"); + paymentQueue.push(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) { + debug("Made it to the SQL insert for transactions"); + let totalAmount = 0; + paymentDetails.destinations.forEach(function (payeeItem) { + totalAmount += payeeObjects[payeeItem.address].amount; + totalAmount += payeeObjects[payeeItem.address].fee; + }); + 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) { + paymentDetails.destinations.forEach(function (payeeItem) { + payee = payeeObjects[payeeItem.address]; + payee.transactionID = result.insertId; + payee.trackPayment(); + }); + }); + } else { + console.error("Unknown error from the wallet."); + } + }); + } + } + }); + }); + }); +} + +function init() { + global.support.rpcWallet("store", [], function () { + }); + if (global.config.allowBitcoin) { + determineBestExchange(); + setInterval(updateXMRToCompletion, 90000); + setInterval(updateShapeshiftCompletion, 90000); + setInterval(determineBestExchange, 60000); + } + setInterval(function () { + global.support.rpcWallet("store", [], function () { + }); + }, 60000); + console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes with a: " + global.config.payout.timerRetry + " minute delay if the wallet is out of money"); + makePayments(); +} + +init(); \ No newline at end of file From 9c56eb641ec9f5c6e3a2c7b1e3f7b2fca45a0d72 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Mar 2018 09:16:47 +0200 Subject: [PATCH 0375/2430] Removed useless & --- deployment/leaf.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 66aa0bcf..ea3894fd 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -45,5 +45,5 @@ cd ~ sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin `pwd`/.nvm/versions/node/v8.9.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` sudo chown -R $CURUSER. ~/.pm2 echo "Installing pm2-logrotate in the background!" -pm2 install pm2-logrotate & +pm2 install pm2-logrotate echo "You're setup with a leaf node! Congrats" From 28b022c297ea039f31e6738b5a316478c9c28c66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Mar 2018 09:26:57 +0200 Subject: [PATCH 0376/2430] Added info about monero7 for xmr-stak --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 61006124..c9e5a4f6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1085,7 +1085,7 @@ function get_miner_notification(payout, agent) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); if (majorv < 2 || (majorv === 2 && minorv < 3)) { - return "Please update your xmr-stak miner (" + agent + ") to at least v2.3.0 before hardfork on April 6"; + return "Please update your xmr-stak miner (" + agent + ") to at least v2.3.0 before hardfork on April 6 (and use monero7 in config)"; } } else if (m = reXNP.exec(agent)) { let majorv = parseInt(m[1]); From e3f88f9f77a8ac2da7fed17f049d57ca7dfde19c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Mar 2018 10:51:47 +0200 Subject: [PATCH 0377/2430] Updated utils in all places --- lib/api.js | 2 +- lib/coins/aeon.js | 4 ++-- lib/coins/krb.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/api.js b/lib/api.js index 6ad1460c..ba8e1a2d 100644 --- a/lib/api.js +++ b/lib/api.js @@ -6,7 +6,7 @@ const cluster = require('cluster'); const async = require("async"); const debug = require("debug")("api"); const btcValidator = require('wallet-address-validator'); -const cnUtil = require('cryptonote-util'); +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'); diff --git a/lib/coins/aeon.js b/lib/coins/aeon.js index 5f9cf1c4..a64c793e 100644 --- a/lib/coins/aeon.js +++ b/lib/coins/aeon.js @@ -1,7 +1,7 @@ "use strict"; const bignum = require('bignum'); -const cnUtil = require('cryptonote-util'); -const multiHashing = require('multi-hashing'); +const cnUtil = require('cryptoforknote-util'); +const multiHashing = require('cryptonight-hashing'); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); diff --git a/lib/coins/krb.js b/lib/coins/krb.js index ae37b826..7b4d49c7 100644 --- a/lib/coins/krb.js +++ b/lib/coins/krb.js @@ -1,7 +1,7 @@ "use strict"; const bignum = require('bignum'); -const cnUtil = require('cryptonote-util'); -const multiHashing = require('multi-hashing'); +const cnUtil = require('cryptoforknote-util'); +const multiHashing = require('cryptonight-hashing'); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); From 7402a02f027e3f40824bfb48fa4ddba9634cc09d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Mar 2018 17:26:46 +0200 Subject: [PATCH 0378/2430] Added subaddress support --- 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 3fe0ade6..779effb4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -41,10 +41,12 @@ function Coin(data){ ]; // These are addresses that MUST have a paymentID to perform logins with. this.prefix = 18; + this.subPrefix = 42; this.intPrefix = 19; if (global.config.general.testnet === true){ this.prefix = 53; + this.subPrefix = 63; this.intPrefix = 54; } @@ -114,19 +116,18 @@ function Coin(data){ return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); }; - this.validateAddress = function(address){ + 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); - if (cnUtil.address_decode(address) === this.prefix){ - return true; - } - return cnUtil.address_decode_integrated(address) === this.intPrefix; + let code = cnUtil.address_decode(address); + return code === this.prefix || code === this.subPrefix; }; - this.validatePlainAddress = function(address){ + 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); - return cnUtil.address_decode(address) === this.prefix; + return cnUtil.address_decode_integrated(address) === this.intPrefix; }; this.convertBlob = function(blobBuffer){ From a5d943ea347951e66154ffb16a4f758c9de4f24c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 29 Mar 2018 09:30:07 +0200 Subject: [PATCH 0379/2430] Fix for v0.12 monero --- 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 734e83b5..ec65680e 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -343,7 +343,7 @@ 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"){ + if (typeof(body.error) !== 'undefined' && body.error.hasOwnProperty('message') && (body.error.message === "not enough money" || body.error.message === "not enough unlocked money")){ console.error("Issue making payments, not enough money, will try later"); setTimeout(getbalance, 10*60*1000); } else { From e2145cd10fef091e7aaf481e1599c54c42709ea2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 29 Mar 2018 16:13:59 +0200 Subject: [PATCH 0380/2430] Fix keepalive --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index c9e5a4f6..5c7128bb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1315,6 +1315,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply('Unauthenticated'); return; } + miner.heartbeat(); sendReply(null, { status: 'KEEPALIVED' }); From ad7baf90b8897e356ff00dcaf12bad8321d2230b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Apr 2018 09:05:45 +0200 Subject: [PATCH 0381/2430] Switched to default mixing --- lib/payment_systems/xmr.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index ec65680e..e21fcb41 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -121,7 +121,6 @@ let shapeshiftQueue = async.queue(function (task, callback) { } ], priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, payment_id: shapeshiftTxnData.deposit }; debug("Payment Details: " + JSON.stringify(paymentDetails)); @@ -277,7 +276,6 @@ let xmrToQueue = async.queue(function (task, callback) { } ], priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, payment_id: orderStatus.xmr_required_payment_id_long }; debug("Payment Details: " + JSON.stringify(paymentDetails)); @@ -518,7 +516,6 @@ function Payee(amount, address, paymentID, bitcoin) { } ], priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, payment_id: this.paymentID }; let identifier = this.id; @@ -561,8 +558,7 @@ function Payee(amount, address, paymentID, bitcoin) { address: this.address } ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn + priority: global.config.payout.priority }; let identifier = this.id; let amount = this.amount; @@ -745,8 +741,7 @@ function makePayments() { while (paymentDestinations.length > 0) { let paymentDetails = { destinations: paymentDestinations.splice(0, global.config.payout.maxPaymentTxns), - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn + priority: global.config.payout.priority }; console.log("Adding payment for " + paymentDetails.destinations.length + " miners"); paymentQueue.unshift(paymentDetails, function (body) { //jshint ignore:line From 1682b09e81edffc6195e43972ccb1b812c58bbfe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Apr 2018 10:50:40 +0200 Subject: [PATCH 0382/2430] Added agent based miner rejects after fork date --- lib/pool.js | 77 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5c7128bb..d672e376 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1068,44 +1068,44 @@ let lastMinerNotifyTime = {}; var reXMRig = /XMRig\/(\d+)\.(\d+)\./; var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; -// no point to notifiy it - it does not print error message -//var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; - -function get_miner_notification(payout, agent) { - if (payout in notifyAddresses) return notifyAddresses[payout]; - if (agent) { - let m; - if (m = reXMRig.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); - if (majorv < 2 || (majorv === 2 && minorv < 5)) { - return "Please update your XMRig miner (" + agent + ") to at least v2.5.0 before hardfork on April 6"; - } - } else if (m = reXMRSTAK.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); - if (majorv < 2 || (majorv === 2 && minorv < 3)) { - return "Please update your xmr-stak miner (" + agent + ") to at least v2.3.0 before hardfork on April 6 (and use monero7 in config)"; - } - } else if (m = reXNP.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); - let minorv2 = parseInt(m[3]); - if (majorv === 0 && minorv === 0 && minorv2 === 1) { - return "Please update your xmr-node-proxy (" + agent + ") to version NEWER THAN v0.0.1 before hardfork on April 6 (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; - } +var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; + +function get_miner_agent_notification(agent) { + let m; + if (m = reXMRig.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + if (majorv < 2 || (majorv === 2 && minorv < 5)) { + return "Please update your XMRig miner (" + agent + ") to v2.5.0+ before hardfork on April 6"; + } + } else if (m = reXMRSTAK.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + if (majorv < 2 || (majorv === 2 && minorv < 3)) { + return "Please update your xmr-stak miner (" + agent + ") to v2.3.0+ before hardfork on April 6 (and use monero7 in config)"; + } + } else if (m = reXNP.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + let minorv2 = parseInt(m[3]); + if (majorv === 0 && minorv === 0 && minorv2 === 1) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.0.2+ before hardfork on April 6 (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + } + } else if (m = reCCMINER.exec(agent)) { + let majorv = parseInt(m[1]); + let minorv = parseInt(m[2]); + if (majorv < 3) { + return "Please update ccminer-cryptonight miner to v3.00+ before hardfork on April 6"; } - //} else if (m = reCCMINER.exec(agent)) { - // let majorv = parseInt(m[1]); - // let minorv = parseInt(m[2]); - // if (majorv < 3) { - // return "Please update ccminer-cryptonight miner to at least v3.00 before hardfork on April 6"; - // } - //} } return false; } +function get_miner_notification(payout) { + if (payout in notifyAddresses) return notifyAddresses[payout]; + return false; +} + function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let miner = activeMiners[params.id]; // Check for ban here, so preconnected attackers can't continue to screw you @@ -1132,7 +1132,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner.error); return; } - let miner_notification = get_miner_notification(miner.payout, params.agent); + let miner_agent_notification = params.agent ? get_miner_agent_notification(params.agent) : false; + let miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); if (miner_notification) { let time_now = Date.now(); if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { @@ -1142,6 +1143,14 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } } + if (miner_agent_notification && anchorBlockHeight && anchorBlockHeight >= 1546000) { + if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 10*60*1000) { + lastMinerNotifyTime[miner.payout] = time_now; + console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); + } + sendReply(miner_agent_notification); + return; + } process.send({type: 'newMiner', data: miner.port}); activeMiners[minerId] = miner; if (!miner.proxy) { From c325740a2710514bdccf4c925d4c2a280c145070 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Apr 2018 22:10:05 +0200 Subject: [PATCH 0383/2430] Fixed semantic bug Thanks 1rV1N! --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index d672e376..ec53a61d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1144,6 +1144,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } } if (miner_agent_notification && anchorBlockHeight && anchorBlockHeight >= 1546000) { + let time_now = Date.now(); if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 10*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; console.error("Sent notification to " + miner.logString + ": " + miner_agent_notification); From 0ad59cd1b89a68b348380fe3153eec36f4711ec8 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Thu, 5 Apr 2018 13:58:08 -0700 Subject: [PATCH 0384/2430] Update with cryptonight-hashing for XMR. Thanks to Mayday30/MoneroOcean for updating the CN libs for the Variant hardfork. git pull; npm install; then restart services. --- lib/coins/xmr.js | 7 ++++--- lib/payment_systems/xmr.js | 2 +- package.json | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index a4521110..b51cd2d8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1,7 +1,7 @@ "use strict"; const bignum = require('bignum'); const cnUtil = require('cryptonote-util'); -const multiHashing = require('multi-hashing'); +const multiHashing = require("cryptonight-hashing"); const crypto = require('crypto'); const debug = require('debug')('coinFuncs'); @@ -162,8 +162,9 @@ function Coin(data){ }; }; - this.cryptoNight = multiHashing.cryptonight; - + this.cryptoNight = function(convertedBlob) { + return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0); + } } module.exports = Coin; diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index fe664a96..0a7a1fcf 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -304,7 +304,7 @@ let paymentQueue = async.queue(function (paymentDetails, callback) { global.support.rpcWallet(transferFunc, paymentDetails, function (body) { debug("Payment made: " + JSON.stringify(body)); if (body.hasOwnProperty('error')) { - if (body.error.message === "not enough money"){ + if (body.error.message === "not enough money" || body.error.message === "not enough unlocked money"){ console.error("Issue making payments, not enough money, will try later"); if(!extraPaymentRound){ setTimeout(function(){ diff --git a/package.json b/package.json index bbfd8766..b3ac489c 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ }, "optionalDependencies": { "cryptonote-util": "git://github.com/Snipa22/node-cryptonote-util.git#xmr-Nan-2.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git", "multi-hashing": "git+https://github.com/Snipa22/node-multi-hashing-aesni.git#v0.1" } } From b92a827cfc52673e30692e2d5c81f17b18005227 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Apr 2018 11:15:08 +0200 Subject: [PATCH 0385/2430] Revert "Switched to default mixing" This reverts commit d34580d721f3664d9f3a7cbf137460b9ec38b00f. --- lib/payment_systems/xmr.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index e21fcb41..ec65680e 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -121,6 +121,7 @@ let shapeshiftQueue = async.queue(function (task, callback) { } ], priority: global.config.payout.priority, + mixin: global.config.payout.mixIn, payment_id: shapeshiftTxnData.deposit }; debug("Payment Details: " + JSON.stringify(paymentDetails)); @@ -276,6 +277,7 @@ let xmrToQueue = async.queue(function (task, callback) { } ], priority: global.config.payout.priority, + mixin: global.config.payout.mixIn, payment_id: orderStatus.xmr_required_payment_id_long }; debug("Payment Details: " + JSON.stringify(paymentDetails)); @@ -516,6 +518,7 @@ function Payee(amount, address, paymentID, bitcoin) { } ], priority: global.config.payout.priority, + mixin: global.config.payout.mixIn, payment_id: this.paymentID }; let identifier = this.id; @@ -558,7 +561,8 @@ function Payee(amount, address, paymentID, bitcoin) { address: this.address } ], - priority: global.config.payout.priority + priority: global.config.payout.priority, + mixin: global.config.payout.mixIn }; let identifier = this.id; let amount = this.amount; @@ -741,7 +745,8 @@ function makePayments() { while (paymentDestinations.length > 0) { let paymentDetails = { destinations: paymentDestinations.splice(0, global.config.payout.maxPaymentTxns), - priority: global.config.payout.priority + 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 From dff79117d0675b3712ce7270556714970eddf001 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Apr 2018 11:16:05 +0200 Subject: [PATCH 0386/2430] Returned fixed mixing --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index c9e9aa3b..030350c3 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -215,7 +215,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', '4', 'int', 'Mixin count for coins that support such things.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'mixIn', '7', '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'); From f00281594ff85b52960e55e3d270bbd484ba4888 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Apr 2018 11:22:33 +0200 Subject: [PATCH 0387/2430] Reduced mixing even more --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 030350c3..9d1a8172 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -215,7 +215,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', '7', 'int', 'Mixin count for coins that support such things.'); +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 ('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'); From eed6bfa5156203f1e37a4eb0938aadb6d55bb6ff Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Apr 2018 23:11:17 +0200 Subject: [PATCH 0388/2430] Fixed missing pass situation and removed minergate magic --- lib/pool.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ec53a61d..ec898d95 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1116,10 +1116,13 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } switch (method) { case 'login': - if (!params.login || (!params.pass && params.agent && !params.agent.includes('MinerGate'))) { - sendReply("No login/password specified"); + if (!params.login) { + sendReply("No login specified"); return; } + 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); From be3caaf0c124993f5b0b9de410528cd485633220 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Apr 2018 23:17:56 +0200 Subject: [PATCH 0389/2430] Reduce old miner notify spam --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ec898d95..b0df7841 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1148,7 +1148,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } if (miner_agent_notification && anchorBlockHeight && anchorBlockHeight >= 1546000) { let time_now = Date.now(); - if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 10*60*1000) { + 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); } From cb7f34810732e08cb952a13991e5a85c7850d401 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 7 Apr 2018 23:19:26 +0200 Subject: [PATCH 0390/2430] Removed block height check --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b0df7841..d74bce3b 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1146,7 +1146,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } } - if (miner_agent_notification && anchorBlockHeight && anchorBlockHeight >= 1546000) { + if (miner_agent_notification) { let time_now = Date.now(); if (!(miner.payout in lastMinerNotifyTime) || time_now - lastMinerNotifyTime[miner.payout] > 60*60*1000) { lastMinerNotifyTime[miner.payout] = time_now; From 952eedadca78011e7ed6d7c490acc9a4bb363c16 Mon Sep 17 00:00:00 2001 From: Son Nguyen Date: Mon, 9 Apr 2018 16:17:12 +0700 Subject: [PATCH 0391/2430] Prevent pool crash when password is null --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index ca71820f..0721368c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -213,6 +213,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // If the password is x, aka, old-logins, we're not going to allow detailed review of miners. // Miner Variables + // prevent pool crash when pass is null + if (!pass) pass = 'x'; let pass_split = pass.split(":"); this.error = ""; this.identifier = pass_split[0]; From d8c1aa863f11844e3cddd37a3a5031de78be9c9b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 10:18:45 +0200 Subject: [PATCH 0392/2430] Added wrong miner bans --- lib/pool.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d74bce3b..1dddb968 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1065,6 +1065,9 @@ let lastMinerLogTime = {}; // Miner notification times let lastMinerNotifyTime = {}; +// Share times of miners (payout:identifier) that never submitted any good share +let badMinerLastShareTime = {}; + var reXMRig = /XMRig\/(\d+)\.(\d+)\./; var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; @@ -1135,10 +1138,19 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner.error); return; } + let time_now = Date.now(); + let miner_id = miner.payout + ":" + miner.identifier; + if (miner_id in badMinerLastShareTime) { + if (time_now - badMinerLastShareTime[miner_id] < 10*60*1000) { + sendReply("You miner " + miner.identifier + " is currently banned for submitting wrong result (up to 10 minutes)"); + return; + } else { + delete badMinerLastShareTime[miner_id]; + } + } let miner_agent_notification = params.agent ? get_miner_agent_notification(params.agent) : false; let miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); if (miner_notification) { - let time_now = Date.now(); 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); @@ -1147,7 +1159,6 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } } if (miner_agent_notification) { - let time_now = Date.now(); 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); @@ -1309,6 +1320,10 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.trust.probability = 256; miner.trust.penalty = global.config.pool.trustPenalty; miner.trust.threshold = global.config.pool.trustThreshold; + + if (miner.validShares == 0) { + badMinerLastShareTime[miner.payout + ":" + miner.identifier] = Date.now(); + } } } From 1a2fe58ca4379e68e2df6abf79d74f6a17459d49 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 10:32:14 +0200 Subject: [PATCH 0393/2430] Added more ban details --- lib/pool.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1dddb968..06896cb1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1141,8 +1141,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let time_now = Date.now(); let miner_id = miner.payout + ":" + miner.identifier; if (miner_id in badMinerLastShareTime) { - if (time_now - badMinerLastShareTime[miner_id] < 10*60*1000) { - sendReply("You miner " + miner.identifier + " is currently banned for submitting wrong result (up to 10 minutes)"); + let ban_time_left = 30*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"); return; } else { delete badMinerLastShareTime[miner_id]; @@ -1315,15 +1316,15 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.trust.check_height = 0; } else { + if (miner.trust.probability == 256) { + badMinerLastShareTime[miner.payout + ":" + miner.identifier] = Date.now(); + console.error(threadName + "Banned miner for some time " + miner.logString); + } 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; - - if (miner.validShares == 0) { - badMinerLastShareTime[miner.payout + ":" + miner.identifier] = Date.now(); - } } } From 476d5fe1acee1a23e2a1f838be7e7419dc1672c9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 11:28:11 +0200 Subject: [PATCH 0394/2430] More compact ban messages --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 06896cb1..cc5682a6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -978,7 +978,7 @@ function processShare(miner, job, blockTemplate, params) { hash = global.coinFuncs.cryptoNight(convertedBlob); if (hash.toString('hex') !== resultHash) { - console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString); + console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (miner.trust.probability == 256 ? " (banned)" : "")); process.send({type: 'invalidShare'}); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; @@ -1050,8 +1050,7 @@ function processShare(miner, job, blockTemplate, params) { } else if (hashDiff.lt(job.difficulty)) { process.send({type: 'invalidShare'}); - console.warn(threadName + "Rejected low diff share of " + hashDiff.toString() + " from: " + miner.address + " ID: " + - miner.identifier + " IP: " + miner.ipAddress); + console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString + (miner.trust.probability == 256 ? " (banned)" : "")); return false; } else { @@ -1141,11 +1140,12 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let time_now = Date.now(); let miner_id = miner.payout + ":" + miner.identifier; if (miner_id in badMinerLastShareTime) { - let ban_time_left = 30*60*1000 - (time_now - badMinerLastShareTime[miner_id]); + let ban_time_left = 60*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"); return; } else { + console.error(threadName + "Removed miner " + miner.logString + " from ban"); delete badMinerLastShareTime[miner_id]; } } @@ -1318,7 +1318,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { else { if (miner.trust.probability == 256) { badMinerLastShareTime[miner.payout + ":" + miner.identifier] = Date.now(); - console.error(threadName + "Banned miner for some time " + miner.logString); + debug(threadName + "Banned miner for some time " + miner.logString); } debug(threadName + "Share trust broken by " + miner.logString); global.database.storeInvalidShare(miner.invalidShareProto); From c8c7cbcadd0a24b1fdd0930a2b1230bf91c51195 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 11:32:24 +0200 Subject: [PATCH 0395/2430] Changed banned message --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index cc5682a6..7af4cd84 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -978,7 +978,7 @@ function processShare(miner, job, blockTemplate, params) { hash = global.coinFuncs.cryptoNight(convertedBlob); if (hash.toString('hex') !== resultHash) { - 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.probability == 256 ? " [banned]" : "")); process.send({type: 'invalidShare'}); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; @@ -1050,7 +1050,7 @@ function processShare(miner, job, blockTemplate, params) { } else if (hashDiff.lt(job.difficulty)) { process.send({type: 'invalidShare'}); - 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.probability == 256 ? " [banned]" : "")); return false; } else { From f871142c775ebe75ba369de6a3ce116cb5ac64ed Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 11:39:18 +0200 Subject: [PATCH 0396/2430] Less debug messages --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7af4cd84..07746f44 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1145,7 +1145,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply("You miner " + miner.identifier + " is currently banned for submitting wrong result for " + (ban_time_left / 1000) + " seconds"); return; } else { - console.error(threadName + "Removed miner " + miner.logString + " from ban"); + debug(threadName + "Removed miner " + miner.logString + " from ban"); delete badMinerLastShareTime[miner_id]; } } From c132c340b7ff2bc2c8b20f106df03d7e73d24e51 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 12:30:37 +0200 Subject: [PATCH 0397/2430] Reduced ban time --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 07746f44..7f15248e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1140,7 +1140,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let time_now = Date.now(); let miner_id = miner.payout + ":" + miner.identifier; if (miner_id in badMinerLastShareTime) { - let ban_time_left = 60*60*1000 - (time_now - badMinerLastShareTime[miner_id]); + let ban_time_left = 10*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"); return; From 9e5dd99c44744b4d45573de221c42f45df9342bf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 14:26:28 +0200 Subject: [PATCH 0398/2430] Moved time_now --- lib/pool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7f15248e..06c882bc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1128,8 +1128,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { 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); + let time_now = Date.now(); if (!miner.valid_miner) { - let time_now = Date.now(); if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { console.log("Invalid miner " + miner.logString + " [" + miner.email + "], disconnecting due to: " + miner.error); lastMinerLogTime[miner.payout] = time_now; @@ -1137,7 +1137,6 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner.error); return; } - let time_now = Date.now(); let miner_id = miner.payout + ":" + miner.identifier; if (miner_id in badMinerLastShareTime) { let ban_time_left = 10*60*1000 - (time_now - badMinerLastShareTime[miner_id]); From 54cca5b38168cc7ce6b3b097bc0ab3e753228a62 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 11 Apr 2018 14:30:38 +0200 Subject: [PATCH 0399/2430] Added bad share throttling --- lib/pool.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 06c882bc..ac166ab1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -960,8 +960,9 @@ function processShare(miner, job, blockTemplate, params) { shareType = 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) + 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); + } process.send({type: 'throttledShare'}); miner.setNewDiff(miner.calcNewDiff()); miner.sendNewJob(); @@ -978,7 +979,11 @@ function processShare(miner, job, blockTemplate, params) { hash = global.coinFuncs.cryptoNight(convertedBlob); if (hash.toString('hex') !== resultHash) { - console.error(threadName + "Bad share from miner (diff " + job.difficulty + ") " + miner.logString + (miner.trust.probability == 256 ? " [banned]" : "")); + 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]" : "")); + lastMinerLogTime[miner.payout] = time_now; + } process.send({type: 'invalidShare'}); if (miner.incremented === false) { miner.newDiff = miner.difficulty + 1; @@ -1047,15 +1052,19 @@ function processShare(miner, job, blockTemplate, params) { }); } if (shareBuffer) submit_block(true); - } - else if (hashDiff.lt(job.difficulty)) { + + } else if (hashDiff.lt(job.difficulty)) { + 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]" : "")); + lastMinerLogTime[miner.payout] = time_now; + } process.send({type: 'invalidShare'}); - console.warn(threadName + "Rejected low diff (" + hashDiff.toString() + " < " + job.difficulty + ") share from miner " + miner.logString + (miner.trust.probability == 256 ? " [banned]" : "")); return false; - } - else { + + } else { recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); } + return true; } From 38297783a817b0c951c44e43f7bb1e26d6404a2b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 13 Apr 2018 22:03:05 +0200 Subject: [PATCH 0400/2430] Fixed pool crash --- lib/pool.js | 1 + lib/support.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ac166ab1..7de464aa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1054,6 +1054,7 @@ function processShare(miner, job, blockTemplate, params) { if (shareBuffer) submit_block(true); } 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]" : "")); lastMinerLogTime[miner.payout] = time_now; diff --git a/lib/support.js b/lib/support.js index f588495c..4460b034 100644 --- a/lib/support.js +++ b/lib/support.js @@ -174,9 +174,9 @@ function rpc_wallet(host, port, method, params, callback) { } function getActivePort(callback) { - global.mysql.query("SELECT item_value FROM pool.config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { + global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { if (rows.length != 1) { - console.error("Can't get pool.config.daemon.activePort value"); + console.error("Can't get config.daemon.activePort value"); return callback(null); } callback(parseInt(rows[0].item_value)); From 8d8c2b2804ffc709ddb0946188f270263439ba24 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Apr 2018 09:50:30 +0200 Subject: [PATCH 0401/2430] Reduced IP ban times and improved pool state monitor --- lib/pool.js | 8 ++++---- lib/worker.js | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7de464aa..2cfe83c3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1074,7 +1074,7 @@ let lastMinerLogTime = {}; // Miner notification times let lastMinerNotifyTime = {}; -// Share times of miners (payout:identifier) that never submitted any good share +// Share times of miners (payout:identifier:ipAddress) that never submitted any good share let badMinerLastShareTime = {}; var reXMRig = /XMRig\/(\d+)\.(\d+)\./; @@ -1147,9 +1147,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(miner.error); return; } - let miner_id = miner.payout + ":" + miner.identifier; + let miner_id = miner.payout + ":" + miner.identifier + ":" + miner.ipAddress; if (miner_id in badMinerLastShareTime) { - let ban_time_left = 10*60*1000 - (time_now - badMinerLastShareTime[miner_id]); + 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"); return; @@ -1326,7 +1326,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } else { if (miner.trust.probability == 256) { - badMinerLastShareTime[miner.payout + ":" + miner.identifier] = Date.now(); + badMinerLastShareTime[miner.payout + ":" + miner.identifier + ":" + miner.ipAddress] = Date.now(); debug(threadName + "Banned miner for some time " + miner.logString); } debug(threadName + "Share trust broken by " + miner.logString); diff --git a/lib/worker.js b/lib/worker.js index e823f79d..49778412 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -11,6 +11,7 @@ let hashrate_avg_min = 5; let stat_change_alert = 0.3; let lastBlockCheckIsFailed = {}; +let prev_pool_state_time; let prev_pool_hashrate; let prev_pool_workers; @@ -246,21 +247,24 @@ function updateShareStats() { }); cache_updates.minerSet = minerSet; global.database.bulkSetCache(cache_updates); - let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; - let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; - let pool_workers = minerCount; - let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; - console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); - 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" - ); + if (!prev_pool_state_time || currentTime - prev_pool_state_time > hashrate_avg_min*60*1000) { + let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; + let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; + let pool_workers = minerCount; + let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; + console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); + 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; } - prev_pool_hashrate = pool_hashrate; - prev_pool_workers = pool_workers; callback(null); }); } From 5b52bc0874d09436c972a6120464491c92998d0b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Apr 2018 10:46:51 +0200 Subject: [PATCH 0402/2430] Fixed v7 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 779effb4..76cf4535 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -198,7 +198,7 @@ function Coin(data){ }; this.cryptoNight = function(convertedBlob) { - return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0); + return multiHashing.cryptonight(convertedBlob, 1); } this.blobTypeStr = function(port) { From 0c80b9e633d223063e04787df75459de850c1ba5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Apr 2018 13:48:39 +0200 Subject: [PATCH 0403/2430] Added algo support https://github.com/xmrig/xmrig-proxy/blob/dev/doc/STRATUM_EXT.md#mining-algorithm-negotiation --- README.md | 1 + deployment/base.sql | 1 + lib/coins/xmr.js | 8 ++++++++ lib/pool.js | 12 ++++++++---- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a1d0a08c..4518bb64 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,7 @@ If you'd like to make a one time donation, the addresses are as follows: * AEON - ```WmsEg3RuUKCcEvFBtXcqRnGYfiqGJLP1FGBYiNMgrcdUjZ8iMcUn2tdcz59T89inWr9Vae4APBNf7Bg2DReFP5jr23SQqaDMT``` * ETN - ```etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1``` * SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` +* GRFT - ```GACadqdXj5eNLnyNxvQ56wcmsmVCFLkHQKgtaQXNEE5zjMDJkWcMVju2aYtxbTnZgBboWYmHovuiH1Ahm4g2N5a7LuMQrpT``` Credits ======= diff --git a/deployment/base.sql b/deployment/base.sql index 9d1a8172..fbf5e2d2 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -224,6 +224,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', '', 'string', 'Address to mine to, this should be the wallet-rpc address.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19734', '', 'string', 'Address to mine to for 19734 (SUMO) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_26968', '', 'string', 'Address to mine to for 26968 (ETN) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_18981', '', 'string', 'Address to mine to for 18981 (GRFT) 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 76cf4535..d13dadd7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -204,6 +204,14 @@ function Coin(data){ this.blobTypeStr = function(port) { return "cryptonote"; } + + this.algoTypeStr = function(port) { + return "cryptonight"; + } + + this.variantValue = function(port) { + return 1; + } } module.exports = Coin; diff --git a/lib/pool.js b/lib/pool.js index 2cfe83c3..63893209 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -673,6 +673,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); this.cachedJob = { blob: blob, + algo: global.coinFuncs.algoTypeStr(activeBlockTemplate.port), + variant: global.coinFuncs.variantValue(activeBlockTemplate.port), job_id: newJob.id, target: target, id: this.id @@ -699,6 +701,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.cachedJob = { blocktemplate_blob: blob, blob_type: global.coinFuncs.blobTypeStr(activeBlockTemplate.port), + algo: global.coinFuncs.algoTypeStr(activeBlockTemplate.port), + variant: global.coinFuncs.variantValue(activeBlockTemplate.port), difficulty: activeBlockTemplate.difficulty, height: activeBlockTemplate.height, reserved_offset: activeBlockTemplate.reserveOffset, @@ -1097,11 +1101,11 @@ function get_miner_agent_notification(agent) { return "Please update your xmr-stak miner (" + agent + ") to v2.3.0+ before hardfork on April 6 (and use monero7 in config)"; } } else if (m = reXNP.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); + let majorv = parseInt(m[1]) * 1000; + let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv === 0 && minorv === 0 && minorv2 === 1) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.0.2+ before hardfork on April 6 (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 101) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]); From b609333d5811aae8377a30f8f1d68934a2ed4bb1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Apr 2018 14:47:56 +0200 Subject: [PATCH 0404/2430] Changed v0.1.1 xmr-node-proxy to non strict requirement now --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 63893209..d9d98245 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1104,9 +1104,12 @@ function get_miner_agent_notification(agent) { let majorv = parseInt(m[1]) * 1000; let minorv = parseInt(m[2]) * 100; let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 101) { + if (majorv + minorv + minorv2 < 2) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } + if (majorv + minorv + minorv2 < 101) { + console.error("Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"); + } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); From 51307b2b8fbe9230374b780227dd439460ef0130 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Apr 2018 15:12:19 +0200 Subject: [PATCH 0405/2430] Fixed proxy warning --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d9d98245..a6cd26fc 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1108,7 +1108,7 @@ function get_miner_agent_notification(agent) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } if (majorv + minorv + minorv2 < 101) { - console.error("Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"); + console.error("Old proxy was detected: xmr-node-proxy (" + agent + ")"); } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]); From 76e225814e5c066a092feb236fa42aa888c93956 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Apr 2018 15:18:18 +0200 Subject: [PATCH 0406/2430] More details about outdated proxy --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a6cd26fc..6c55ea64 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1086,7 +1086,7 @@ var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; -function get_miner_agent_notification(agent) { +function get_miner_agent_notification(agent, minerLogString) { let m; if (m = reXMRig.exec(agent)) { let majorv = parseInt(m[1]); @@ -1108,7 +1108,7 @@ function get_miner_agent_notification(agent) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } if (majorv + minorv + minorv2 < 101) { - console.error("Old proxy was detected: xmr-node-proxy (" + agent + ")"); + console.error("Old proxy was detected for " + minerLogString + ": xmr-node-proxy (" + agent + ")"); } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]); @@ -1165,7 +1165,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { delete badMinerLastShareTime[miner_id]; } } - let miner_agent_notification = params.agent ? get_miner_agent_notification(params.agent) : false; + let miner_agent_notification = params.agent ? get_miner_agent_notification(params.agent, miner.logString) : false; let 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 8142402dd73ac60f90ccbfc52034c04567fa6052 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Apr 2018 11:26:26 +0200 Subject: [PATCH 0407/2430] Added XNP proxy upgrade warning --- lib/pool.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6c55ea64..8d97fbaa 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1086,7 +1086,7 @@ var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; -function get_miner_agent_notification(agent, minerLogString) { +function get_miner_agent_notification(agent) { let m; if (m = reXMRig.exec(agent)) { let majorv = parseInt(m[1]); @@ -1107,9 +1107,6 @@ function get_miner_agent_notification(agent, minerLogString) { if (majorv + minorv + minorv2 < 2) { return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } - if (majorv + minorv + minorv2 < 101) { - console.error("Old proxy was detected for " + minerLogString + ": xmr-node-proxy (" + agent + ")"); - } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]); let minorv = parseInt(m[2]); @@ -1120,6 +1117,19 @@ function get_miner_agent_notification(agent, minerLogString) { return false; } +function get_miner_agent_warning_notification(agent) { + let m; + if (m = reXNP.exec(agent)) { + let majorv = parseInt(m[1]) * 1000; + let minorv = parseInt(m[2]) * 100; + let minorv2 = parseInt(m[3]); + if (majorv + minorv + minorv2 < 101) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + } + } + return false; +} + function get_miner_notification(payout) { if (payout in notifyAddresses) return notifyAddresses[payout]; return false; @@ -1165,8 +1175,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { delete badMinerLastShareTime[miner_id]; } } - let miner_agent_notification = params.agent ? get_miner_agent_notification(params.agent, miner.logString) : false; - let miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_notification(miner.payout); + let miner_agent_notification = params.agent ? get_miner_agent_notification(params.agent) : false; + let miner_notification = miner_agent_notification ? miner_agent_notification : 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; From 65138565bf1a484d65b8606e4f683f3536ff992e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Apr 2018 10:15:35 +0200 Subject: [PATCH 0408/2430] Added block re-validation stuff --- debug_scripts/altblock_validate.js | 28 ++++++++++++++++++++++++++++ lib/local_comms.js | 20 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 debug_scripts/altblock_validate.js diff --git a/debug_scripts/altblock_validate.js b/debug_scripts/altblock_validate.js new file mode 100644 index 00000000..a3685dd5 --- /dev/null +++ b/debug_scripts/altblock_validate.js @@ -0,0 +1,28 @@ +"use strict"; +let mysql = require("promise-mysql"); +let fs = require("fs"); +let argv = require('minimist')(process.argv.slice(2)); +let config = fs.readFileSync("../config.json"); +let coinConfig = fs.readFileSync("../coinConfig.json"); +let protobuf = require('protocol-buffers'); + +global.support = require("../lib/support.js")(); +global.config = JSON.parse(config); +global.mysql = mysql.createPool(global.config.mysql); +global.protos = protobuf(fs.readFileSync('../lib/data.proto')); +let comms; +comms = require('../lib/local_comms'); +global.database = new comms(); +global.database.initEnv(); + +global.coinFuncs.getPortBlockHeaderByHash(argv.blockPort, argv.blockHash, (err, body) => { + if (err !== null) { + console.log("Block "+argv.blockHash+" still has invalid hash for " + argv.blockPort + "! Exiting!"); + process.exit(); + } + global.database.validateAltBlock(argv.blockPort, argv.blockHash); + console.log("Block "+argv.blockHash+" was validated! Exiting!"); + process.exit(); +}); + + diff --git a/lib/local_comms.js b/lib/local_comms.js index 8d22976e..aa25e6bf 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -701,6 +701,26 @@ function Database(){ txn.commit(); }; + this.validateAltBlock = function(blockPort, 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.port === blockPort && blockData.hash === blockHex){ + blockData.valid = true; + blockData.unlocked = false; + txn.putBinary(altblockDB, key, global.protos.AltBlock.encode(blockData)); + } + }); + altblockDB = null; + } + cursor.close(); + txn.commit(); + }; + this.lockBlock = function(blockId){ let txn = this.env.beginTxn(); let blockProto = txn.getBinary(this.blockDB, parseInt(blockId)); From 97da63014149d30b8719f5e66b8afab2d7f0fd68 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Apr 2018 10:20:43 +0200 Subject: [PATCH 0409/2430] Fixed coin funcs --- debug_scripts/altblock_validate.js | 60 ++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/debug_scripts/altblock_validate.js b/debug_scripts/altblock_validate.js index a3685dd5..ec4a8f6d 100644 --- a/debug_scripts/altblock_validate.js +++ b/debug_scripts/altblock_validate.js @@ -11,18 +11,56 @@ global.config = JSON.parse(config); global.mysql = mysql.createPool(global.config.mysql); global.protos = protobuf(fs.readFileSync('../lib/data.proto')); let comms; -comms = require('../lib/local_comms'); -global.database = new comms(); -global.database.initEnv(); +let coinInc; -global.coinFuncs.getPortBlockHeaderByHash(argv.blockPort, argv.blockHash, (err, body) => { - if (err !== null) { - console.log("Block "+argv.blockHash+" still has invalid hash for " + argv.blockPort + "! Exiting!"); - process.exit(); - } - global.database.validateAltBlock(argv.blockPort, argv.blockHash); - console.log("Block "+argv.blockHash+" was validated! Exiting!"); - process.exit(); + +// Config Table Layout +// . + +global.mysql.query("SELECT * FROM config").then(function (rows) { + rows.forEach(function (row){ + if (!global.config.hasOwnProperty(row.module)){ + global.config[row.module] = {}; + } + if (global.config[row.module].hasOwnProperty(row.item)){ + return; + } + switch(row.item_type){ + case 'int': + global.config[row.module][row.item] = parseInt(row.item_value); + break; + case 'bool': + global.config[row.module][row.item] = (row.item_value === "true"); + break; + case 'string': + global.config[row.module][row.item] = row.item_value; + break; + case 'float': + global.config[row.module][row.item] = parseFloat(row.item_value); + break; + } + }); +}).then(function(){ + global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; + coinInc = require("." + global.config.coin.funcFile); + global.coinFuncs = new coinInc(); + comms = require('../lib/local_comms'); + global.database = new comms(); + global.database.initEnv(); + global.coinFuncs.blockedAddresses.push(global.config.pool.address); + global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); +}).then(function(){ + + global.coinFuncs.getPortBlockHeaderByHash(argv.blockPort, argv.blockHash, (err, body) => { + if (err !== null) { + console.log("Block "+argv.blockHash+" still has invalid hash for " + argv.blockPort + "! Exiting!"); + process.exit(); + } + global.database.validateAltBlock(argv.blockPort, argv.blockHash); + console.log("Block "+argv.blockHash+" was validated! Exiting!"); + process.exit(); + }); + }); From 203d9eaa5389e042f191035181c63aa3e0cd59c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Apr 2018 17:57:32 +0200 Subject: [PATCH 0410/2430] Updated miner notifications --- lib/coins/xmr.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/pool.js | 53 ++------------------------------------------ 2 files changed, 59 insertions(+), 51 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d13dadd7..2367c2c8 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -8,6 +8,12 @@ const process = require('process'); let hexChars = new RegExp("[0-9a-f]+"); +var reXMRig = /XMRig\/(\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+)/; + function Coin(data){ this.bestExchange = global.config.payout.bestExchange; this.data = data; @@ -212,6 +218,57 @@ function Coin(data){ this.variantValue = function(port) { return 1; } + + 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) { + return "Please update your XMRig miner (" + agent + ") to v2.5.0+"; + } + } else if (m = reXMRSTAK.exec(agent)) { + 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)"; + } + } 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) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check 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) { + return "Please update ccminer-cryptonight miner to v3.02+"; + } + } + return false; + }; + + this.get_miner_agent_warning_notification = function(agent) { + let m; + if (m = reXMRSTAK2.exec(agent)) { + 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.4.3+ (and use cryptonight_v7 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 < 101) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + } + } + return false; + }; } module.exports = Coin; diff --git a/lib/pool.js b/lib/pool.js index 8d97fbaa..f679acfb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1081,55 +1081,6 @@ let lastMinerNotifyTime = {}; // Share times of miners (payout:identifier:ipAddress) that never submitted any good share let badMinerLastShareTime = {}; -var reXMRig = /XMRig\/(\d+)\.(\d+)\./; -var reXMRSTAK = /xmr-stak(?:-[a-z]+)\/(\d+)\.(\d+)/; -var reXNP = /xmr-node-proxy\/(\d+)\.(\d+)\.(\d+)/; -var reCCMINER = /ccminer-cryptonight\/(\d+)\.(\d+)/; - -function get_miner_agent_notification(agent) { - let m; - if (m = reXMRig.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); - if (majorv < 2 || (majorv === 2 && minorv < 5)) { - return "Please update your XMRig miner (" + agent + ") to v2.5.0+ before hardfork on April 6"; - } - } else if (m = reXMRSTAK.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); - if (majorv < 2 || (majorv === 2 && minorv < 3)) { - return "Please update your xmr-stak miner (" + agent + ") to v2.3.0+ before hardfork on April 6 (and use monero7 in config)"; - } - } else if (m = reXNP.exec(agent)) { - let majorv = parseInt(m[1]) * 1000; - 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.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; - } - } else if (m = reCCMINER.exec(agent)) { - let majorv = parseInt(m[1]); - let minorv = parseInt(m[2]); - if (majorv < 3) { - return "Please update ccminer-cryptonight miner to v3.00+ before hardfork on April 6"; - } - } - return false; -} - -function get_miner_agent_warning_notification(agent) { - let m; - if (m = reXNP.exec(agent)) { - let majorv = parseInt(m[1]) * 1000; - let minorv = parseInt(m[2]) * 100; - let minorv2 = parseInt(m[3]); - if (majorv + minorv + minorv2 < 101) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; - } - } - return false; -} - function get_miner_notification(payout) { if (payout in notifyAddresses) return notifyAddresses[payout]; return false; @@ -1175,8 +1126,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { delete badMinerLastShareTime[miner_id]; } } - let miner_agent_notification = params.agent ? get_miner_agent_notification(params.agent) : false; - let miner_notification = miner_agent_notification ? miner_agent_notification : get_miner_agent_warning_notification(params.agent); + 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) { From de34d81f5bec1ebfabfbb74d46bd7a47f2b6bb48 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Apr 2018 23:07:50 +0200 Subject: [PATCH 0411/2430] Fixed first share miner ban --- lib/pool.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f679acfb..4ef7e071 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -174,17 +174,21 @@ function retargetMiners() { // this is needed to set cummulative based diff for workers provided by Atreides proxy and xmrig-proxy let proxyMiners = {}; +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]; + if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; + delete activeMiners[miner.id]; +} + function checkAliveMiners() { debug(threadName + "Verifying if miners are still alive"); for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; if (Date.now() - miner.lastContact > global.config.pool.minerTimeout * 1000) { - process.send({type: 'removeMiner', data: miner.port}); - delete activeMiners[minerId]; - let proxyMinerName = miner.payout + ":" + miner.identifier; - if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; - if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; + removeMiner(miner); } } } @@ -618,13 +622,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } if (this.validShares + this.invalidShares >= global.config.pool.banThreshold) { if (this.invalidShares / this.validShares >= global.config.pool.banPercent / 100) { - delete activeMiners[this.id]; - let proxyMinerName = this.payout + ":" + this.identifier; - if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; - if (this.payout in minerWallets && --minerWallets[this.payout].count <= 0) delete minerWallets[this.payout]; + removeMiner(this); process.send({type: 'banIP', data: this.ipAddress}); - } - else { + } else { this.invalidShares = 0; this.validShares = 0; } @@ -1292,11 +1292,14 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.trust.penalty--; miner.trust.threshold--; miner.trust.check_height = 0; - } - else { + + } else { if (miner.trust.probability == 256) { 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); global.database.storeInvalidShare(miner.invalidShareProto); From 31c1f06552432f5bb6d0df564998172e8e0f1914 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Apr 2018 21:11:40 +0200 Subject: [PATCH 0412/2430] More aggressive diff increase for throttled miners --- lib/pool.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4ef7e071..7a1af84a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -174,6 +174,19 @@ function retargetMiners() { // this is needed to set cummulative based diff for workers provided by Atreides proxy and xmrig-proxy let proxyMiners = {}; +function addProxyMiner(miner) { + let proxyMinerName = miner.payout + ":" + miner.identifier; + if (!(proxyMinerName in proxyMiners)) { + proxyMiners[proxyMinerName] = {}; + proxyMiners[proxyMinerName].connectTime = Date.now(); + proxyMiners[proxyMinerName].count = 1; + proxyMiners[proxyMinerName].hashes = 0; + console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); + } else { + ++ proxyMiners[proxyMinerName].count; + } +} + function removeMiner(miner) { process.send({type: 'removeMiner', data: miner.port}); let proxyMinerName = miner.payout + ":" + miner.identifier; @@ -968,6 +981,7 @@ function processShare(miner, job, blockTemplate, params) { console.error(threadName + "Throttled down miner share (diff " + job.difficulty + ") submission from " + miner.logString); } process.send({type: 'throttledShare'}); + addProxyMiner(miner); miner.setNewDiff(miner.calcNewDiff()); miner.sendNewJob(); return null; @@ -1148,17 +1162,9 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { process.send({type: 'newMiner', data: miner.port}); activeMiners[minerId] = miner; if (!miner.proxy) { - if (params.agent && params.agent.includes('proxy')) { - let proxyMinerName = miner.payout + ":" + miner.identifier; - if (!(proxyMinerName in proxyMiners)) { - proxyMiners[proxyMinerName] = {}; - proxyMiners[proxyMinerName].connectTime = Date.now(); - proxyMiners[proxyMinerName].count = 1; - proxyMiners[proxyMinerName].hashes = 0; - console.log("Starting to calculate high diff for " + proxyMinerName + " proxy"); - } else { - ++ proxyMiners[proxyMinerName].count; - } + let proxyMinerName = miner.payout + ":" + miner.identifier; + if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { + addProxyMiner(miner); } else { if (!(miner.payout in minerWallets)) { minerWallets[miner.payout] = {}; From ddde28c66369e0be92666269c8efea7b8b371197 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Apr 2018 22:36:57 +0200 Subject: [PATCH 0413/2430] Set high diff immediately after connection --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7a1af84a..24fb3e3a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -569,6 +569,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.setNewDiff(newDiff); + this.sendNewJob(); this.shareTimeBuffer.clear(); if (decreaser) { this.lastShareTime = now; @@ -592,6 +593,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.updateDifficulty = function () { if (this.hashes > 0) { this.setNewDiff(this.calcNewDiff()); + this.sendNewJob(); } else { this.updateDifficultyOld(); } @@ -619,7 +621,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer console.log("Dropped low fixed diff " + this.difficulty + " for " + this.logString + " miner to " + this.newDiff + " dynamic diff"); this.fixed_diff = false; } - this.sendNewJob(); }; this.checkBan = function (validShare) { @@ -1165,6 +1166,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let proxyMinerName = miner.payout + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { addProxyMiner(miner); + miner.setNewDiff(miner.calcNewDiff()); } else { if (!(miner.payout in minerWallets)) { minerWallets[miner.payout] = {}; From 28a8cf4bc6aa30cf64211b658bef05dfbf3c922d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Apr 2018 22:47:00 +0200 Subject: [PATCH 0414/2430] Fixed nan diff --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 24fb3e3a..c8682ec1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1166,7 +1166,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let proxyMinerName = miner.payout + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { addProxyMiner(miner); - miner.setNewDiff(miner.calcNewDiff()); + let new_diff = miner.calcNewDiff(); + if (new_diff) miner.setNewDiff(new_diff); } else { if (!(miner.payout in minerWallets)) { minerWallets[miner.payout] = {}; From aef72ee557a081ef12ee63f557f739750837949f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 23 Apr 2018 22:52:14 +0200 Subject: [PATCH 0415/2430] More elegant fix --- lib/pool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c8682ec1..f27576b6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1166,8 +1166,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let proxyMinerName = miner.payout + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { addProxyMiner(miner); - let new_diff = miner.calcNewDiff(); - if (new_diff) miner.setNewDiff(new_diff); + if (proxyMiners[proxyMinerName].hashes) miner.setNewDiff(miner.calcNewDiff()); } else { if (!(miner.payout in minerWallets)) { minerWallets[miner.payout] = {}; From 78568ffe0c69e4fa9314ead232deda9f4f7f071c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 24 Apr 2018 10:13:53 +0200 Subject: [PATCH 0416/2430] Added major coin donation addresses --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4518bb64..1036144e 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,10 @@ If you'd like to make a one time donation, the addresses are as follows: * ETN - ```etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1``` * SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` * GRFT - ```GACadqdXj5eNLnyNxvQ56wcmsmVCFLkHQKgtaQXNEE5zjMDJkWcMVju2aYtxbTnZgBboWYmHovuiH1Ahm4g2N5a7LuMQrpT``` +* BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` +* BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` +* ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` +* LTC - ```MCkjQo99VzoeZQ1piDzLDb4uqNSDRZpx55``` Credits ======= From df17e249cdd94eaece0348faa97000b47069aae3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 24 Apr 2018 12:24:16 +0200 Subject: [PATCH 0417/2430] Added info about supported exchanges --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1036144e..a60eaab4 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,8 @@ If you need help installing the pool from scratch, please have your servers read Installation assistance is 3 XMR, with a 1 XMR deposit, with remainder to be paid on completion. Configuration assistance is 2 XMR with a 1 XMR deposit, and includes debugging your pool configurations, ensuring that everything is running, and tuning for your uses/needs. -altblockManager module source (that determines the most profitable coin to mine and trades them to main coin on exchange) price is 20 XMR. +altblockManager module source (that determines the most profitable coin to mine and trades them to main coin on exchanges, in particular +TradeOgre, Qryptos, Livecoin and Cryptopia integrations) price is 20 XMR. SSH access with a sudo-enabled user will be needed, preferably the user that is slated to run the pool. From 93e9470da4ffe96e7bc96f70ae7421000763f6f3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Apr 2018 11:43:45 +0200 Subject: [PATCH 0418/2430] Added MSR/ITNS support templates --- README.md | 2 ++ deployment/base.sql | 2 ++ lib/coins/xmr.js | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a60eaab4..278335b7 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,8 @@ If you'd like to make a one time donation, the addresses are as follows: * ETN - ```etnkQMp3Hmsay2p7uxokuHRKANrMDNASwQjDUgFb5L2sDM3jqUkYQPKBkooQFHVWBzEaZVzfzrXoETX6RbMEvg4R4csxfRHLo1``` * SUMO - ```Sumoo1DGS7c9LEKZNipsiDEqRzaUB3ws7YHfUiiZpx9SQDhdYGEEbZjRET26ewuYEWAZ8uKrz6vpUZkEVY7mDCZyGnQhkLpxKmy``` * GRFT - ```GACadqdXj5eNLnyNxvQ56wcmsmVCFLkHQKgtaQXNEE5zjMDJkWcMVju2aYtxbTnZgBboWYmHovuiH1Ahm4g2N5a7LuMQrpT``` +* MSR - ```5hnMXUKArLDRue5tWsNpbmGLsLQibt23MEsV3VGwY6MGStYwfTqHkff4BgvziprTitbcDYYpFXw2rEgXeipsABTtEmcmnCK``` +* ITNS - ```iz53aMEaKJ25zB8xku3FQK5VVvmu2v6DENnbGHRmn659jfrGWBH1beqAzEVYaKhTyMZcxLJAdaCW3Kof1DwTiTbp1DSqLae3e``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index fbf5e2d2..0058585e 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -225,6 +225,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_19734', '', 'string', 'Address to mine to for 19734 (SUMO) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_26968', '', 'string', 'Address to mine to for 26968 (ETN) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_18981', '', 'string', 'Address to mine to for 18981 (GRFT) port.'); +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 ('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 2367c2c8..5f95bc59 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -208,7 +208,10 @@ function Coin(data){ } this.blobTypeStr = function(port) { - return "cryptonote"; + switch (port) { + case 48782: return "forknote2"; // ITNS + default: return "cryptonote"; + } } this.algoTypeStr = function(port) { From 32babcfe45063d7798093b99feb27546e1eda586 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Apr 2018 14:34:24 +0200 Subject: [PATCH 0419/2430] Returned original number of mins for stats averaging --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 49778412..a09c418c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -7,7 +7,7 @@ let threadName = "Worker Server "; let cycleCount = 0; let lastBlockHash = null; let lastBlockHeight = null; -let hashrate_avg_min = 5; +let hashrate_avg_min = 10; let stat_change_alert = 0.3; let lastBlockCheckIsFailed = {}; From d674ad096c7bc634d22e1c687881870135de2f1f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Apr 2018 14:41:26 +0200 Subject: [PATCH 0420/2430] Fixed stats notify --- lib/worker.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index a09c418c..4d756755 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -247,12 +247,13 @@ function updateShareStats() { }); cache_updates.minerSet = minerSet; global.database.bulkSetCache(cache_updates); + + let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; + 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) { - let pool_hashrate = Math.floor(localStats.global / (hashrate_avg_min*60)) + 1; let pool_hashrate_ratio = prev_pool_hashrate ? pool_hashrate / prev_pool_hashrate : 1; - let pool_workers = minerCount; let pool_workers_ratio = prev_pool_workers ? pool_workers / prev_pool_workers : 1; - console.log("Processed " + minerCount + " workers for " + ((Date.now() - currentTime) / 1000) + " seconds. Pool hashrate is: " + pool_hashrate); 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, From f5a06ded43875a85d9540156ecb1da172be626cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 26 Apr 2018 21:00:03 +0200 Subject: [PATCH 0421/2430] Added extra support required for ITNS --- lib/coins/xmr.js | 21 ++++++++++++++------- lib/pool.js | 6 +++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 5f95bc59..83e6200f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -136,16 +136,23 @@ function Coin(data){ return cnUtil.address_decode_integrated(address) === this.intPrefix; }; - this.convertBlob = function(blobBuffer){ - return cnUtil.convert_blob(blobBuffer); + this.portBlobType = function(port) { + switch (port) { + case 48782: return 2; // ITNS + default: return 0; + } + } + + this.convertBlob = function(blobBuffer, port){ + return cnUtil.convert_blob(blobBuffer, this.portBlobType(port)); }; - this.constructNewBlob = function(blockTemplate, NonceBuffer){ - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer); + this.constructNewBlob = function(blockTemplate, NonceBuffer, port){ + return cnUtil.construct_block_blob(blockTemplate, NonceBuffer, this.portBlobType(port)); }; - this.getBlockID = function(blockBuffer){ - return cnUtil.get_block_id(blockBuffer); + this.getBlockID = function(blockBuffer, port){ + return cnUtil.get_block_id(blockBuffer, this.portBlobType(port)); }; this.BlockTemplate = function(template) { @@ -192,7 +199,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.reserveOffset); // Convert the blob into something hashable. - return global.coinFuncs.convertBlob(this.buffer).toString('hex'); + return global.coinFuncs.convertBlob(this.buffer, this.port).toString('hex'); }; // Make it so you can get the raw block blob out. this.nextBlobWithChildNonce = function () { diff --git a/lib/pool.js b/lib/pool.js index f27576b6..e5a4ea30 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -944,7 +944,7 @@ function getShareBuffer(miner, job, blockTemplate, params) { template.writeUInt32BE(params.workerNonce, job.clientNonceLocation); } try { - let shareBuffer = global.coinFuncs.constructNewBlob(template, new Buffer(nonce, 'hex')); + 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); @@ -994,7 +994,7 @@ function processShare(miner, job, blockTemplate, params) { walletTrust[miner.payout] = 0; return false; } - let convertedBlob = global.coinFuncs.convertBlob(shareBuffer); + let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); hash = global.coinFuncs.cryptoNight(convertedBlob); if (hash.toString('hex') !== resultHash) { @@ -1049,7 +1049,7 @@ function processShare(miner, job, blockTemplate, params) { } } else if (rpcResult && typeof(rpcResult.result) !== 'undefined') { //Success! Submitted a block without an issue. - let blockFastHash = global.coinFuncs.getBlockID(shareBuffer).toString('hex'); + 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) ); From 3886344328441841d6a48463c5ef3b5fd48a4150 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Apr 2018 06:36:38 +0200 Subject: [PATCH 0422/2430] Added prove link for non integrated addresses --- lib/payment_systems/xmr.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index ec65680e..081bae3c 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -649,7 +649,8 @@ function Payee(amount, address, paymentID, bitcoin) { if (rows.length === 0) return; // toAddress, subject, body let emailData = { - address: payee.id, + address: payee.address, + address2: payee.id, payment_amount: global.support.coinToDecimal(payee.amount - payee.fee), amount: global.support.coinToDecimal(payee.amount), fee: global.support.coinToDecimal(payee.fee), @@ -659,8 +660,15 @@ function Payee(amount, address, paymentID, bitcoin) { global.support.sendEmail(rows[0].email, sprintf("Your %(payment_amount)s XMR payment was just performed", emailData), sprintf( - "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) to %(address)s wallet was just performed and total due was decreased by %(amount)s XMR.\n" + - (payee.tx_hash && payee.tx_key ? "Your payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" : ""), + "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) to %(address2)s wallet was just performed and total due was decreased by %(amount)s XMR.\n" + + (payee.tx_hash && payee.tx_key ? + "Your payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" + + (payee.address.length === 95 ? + "Or just use this link to verify payment: https://xmrchain.net/prove/%(tx_hash)/%(address)/%(tx_key)\n" + : "" + ) + : "" + ), emailData ), payee.id From 19644e20b45aa84e9d364048f4fbb3f8e24480a6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Apr 2018 06:49:37 +0200 Subject: [PATCH 0423/2430] Fixed placeholders --- 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 081bae3c..6d29d29f 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -664,7 +664,7 @@ function Payee(amount, address, paymentID, bitcoin) { (payee.tx_hash && payee.tx_key ? "Your payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" + (payee.address.length === 95 ? - "Or just use this link to verify payment: https://xmrchain.net/prove/%(tx_hash)/%(address)/%(tx_key)\n" + "Or just use this link to verify payment: https://xmrchain.net/prove/%(tx_hash)s/%(address)s/%(tx_key)s\n" : "" ) : "" From e4b9b3ddc96bc2f65cbdaf48d9606dc98366b50c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Apr 2018 11:35:15 +0200 Subject: [PATCH 0424/2430] Make port check less strict --- 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 83e6200f..7c1c13ef 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -108,7 +108,7 @@ function Coin(data){ this.getPortBlockTemplate = function(port, callback){ global.support.rpcPortDaemon(port, 'getblocktemplate', { reserve_size: 17, - wallet_address: global.config.pool[port === global.config.daemon.port ? "address" : "address_" + port.toString()] + wallet_address: global.config.pool[port == global.config.daemon.port ? "address" : "address_" + port.toString()] }, function(body){ return callback(body); }); From 61e63eb212400bd4dfe4d326d291ed4975dcb52c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 27 Apr 2018 22:55:55 +0200 Subject: [PATCH 0425/2430] Added BTC-Alpha 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 7c1c13ef..91f24436 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -43,7 +43,8 @@ function Coin(data){ "45rTtwU6mHqSEMduDm5EvUEmFNx2Z6gQhGBJGqXAPHGyFm9qRfZFDNgDm3drL6wLTVHfVhbfHpCtwKVvDLbQDMH88jx2N6w", // ? "4ALcw9nTAStZSshoWVUJakZ6tLwTDhixhQUQNJkCn4t3fG3MMK19WZM44HnQRvjqmz4LkkA8t565v7iBwQXx2r34HNroSAZ", // Cryptopia.co.nz "4BCeEPhodgPMbPWFN1dPwhWXdRX8q4mhhdZdA1dtSMLTLCEYvAj9QXjXAfF7CugEbmfBhgkqHbdgK9b2wKA6nqRZQCgvCDm", // ? - "41xeYWWKwtSiHju5AdyF8y5xeptuRY3j5X1XYHuB1g6ke4eRexA1iygjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3gJqjM9" // HitBTC + "41xeYWWKwtSiHju5AdyF8y5xeptuRY3j5X1XYHuB1g6ke4eRexA1iygjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3gJqjM9", // HitBTC + "44rouyxW44oMc1yTGXBUsL6qo9AWWeHETFiimWC3TMQEizSqqZZPnw1UXCaJrCtUC9QT25L5MZvkoGKRxZttvbkmFXA3TMG" // BTC-Alpha ]; // These are addresses that MUST have a paymentID to perform logins with. this.prefix = 18; From c056fd4f5993d5139038d60c617969686bc7d31b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 30 Apr 2018 10:07:07 +0200 Subject: [PATCH 0426/2430] Added pay verify link for integrated addresses as well --- lib/payment_systems/xmr.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 6d29d29f..751d20f0 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -663,10 +663,7 @@ function Payee(amount, address, paymentID, bitcoin) { "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) to %(address2)s wallet was just performed and total due was decreased by %(amount)s XMR.\n" + (payee.tx_hash && payee.tx_key ? "Your payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" + - (payee.address.length === 95 ? - "Or just use this link to verify payment: https://xmrchain.net/prove/%(tx_hash)s/%(address)s/%(tx_key)s\n" - : "" - ) + "Or just use this link to verify that this payment was made: https://xmrchain.net/prove/%(tx_hash)s/%(address)s/%(tx_key)s\n" : "" ), emailData From 08a77a28cad3543f0d0e47c68c65fd806814ec8c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 1 May 2018 23:08:00 +0200 Subject: [PATCH 0427/2430] Fixed Masari support --- 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 91f24436..d4732e53 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -140,6 +140,7 @@ function Coin(data){ this.portBlobType = function(port) { switch (port) { case 48782: return 2; // ITNS + case 38081: return 3; // MSR default: return 0; } } @@ -218,6 +219,7 @@ function Coin(data){ this.blobTypeStr = function(port) { switch (port) { case 48782: return "forknote2"; // ITNS + case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } } @@ -274,8 +276,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 < 101) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 102) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.2+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } return false; From a4fe4303b3d8b1a9a8ae6b619622aec82636fba8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 2 May 2018 15:36:16 +0200 Subject: [PATCH 0428/2430] Removed not required job updates --- lib/pool.js | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e5a4ea30..4ccb25c7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -391,7 +391,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.valid_miner = true; this.port = port; this.portType = portType; - this.incremented = false; switch (portType) { case 'pplns': this.poolTypeEnum = global.protos.POOLTYPE.PPLNS; @@ -568,8 +567,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer newDiff = this.difficulty + change; } - this.setNewDiff(newDiff); - this.sendNewJob(); + if (this.setNewDiff(newDiff)) this.sendNewJob(); this.shareTimeBuffer.clear(); if (decreaser) { this.lastShareTime = now; @@ -592,8 +590,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.updateDifficulty = function () { if (this.hashes > 0) { - this.setNewDiff(this.calcNewDiff()); - this.sendNewJob(); + if (this.setNewDiff(this.calcNewDiff())) this.sendNewJob(); } else { this.updateDifficultyOld(); } @@ -605,12 +602,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (this.newDiff > global.config.pool.maxDifficulty && !this.proxy) { this.newDiff = global.config.pool.maxDifficulty; } - if (this.difficulty === this.newDiff) { - return; - } if (this.newDiff < global.config.pool.minDifficulty) { this.newDiff = global.config.pool.minDifficulty; } + if (this.difficulty === this.newDiff) return false; debug(threadName + "Difficulty change to: " + this.newDiff + " For: " + this.logString); if (this.hashes > 0) { debug(threadName + "Hashes: " + this.hashes + " in: " + Math.floor((Date.now() - this.connectTime) / 1000) + " seconds gives: " + @@ -621,6 +616,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer console.log("Dropped low fixed diff " + this.difficulty + " for " + this.logString + " miner to " + this.newDiff + " dynamic diff"); this.fixed_diff = false; } + return true; }; this.checkBan = function (validShare) { @@ -983,8 +979,7 @@ function processShare(miner, job, blockTemplate, params) { } process.send({type: 'throttledShare'}); addProxyMiner(miner); - miner.setNewDiff(miner.calcNewDiff()); - miner.sendNewJob(); + if (miner.setNewDiff(miner.calcNewDiff())) miner.sendNewJob(); return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1004,13 +999,6 @@ function processShare(miner, job, blockTemplate, params) { lastMinerLogTime[miner.payout] = time_now; } process.send({type: 'invalidShare'}); - if (miner.incremented === false) { - miner.newDiff = miner.difficulty + 1; - miner.incremented = true; - } else { - miner.newDiff = miner.difficulty - 1; - miner.incremented = false; - } miner.sendNewJob(); walletTrust[miner.payout] = 0; return false; @@ -1271,13 +1259,6 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (!blockTemplate || is_outdated) { let err_str = is_outdated ? "Block outdated" : "Block expired"; console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); - if (miner.incremented === false) { - miner.newDiff = miner.difficulty + 1; - miner.incremented = true; - } else { - miner.newDiff = miner.difficulty - 1; - miner.incremented = false; - } miner.sendNewJob(); sendReply(err_str); global.database.storeInvalidShare(miner.invalidShareProto); From 4074fd4444e92d7200e51f2e70c0a8e65fdea5cb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 3 May 2018 08:46:22 +0200 Subject: [PATCH 0429/2430] Added new proxy requirement --- 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 d4732e53..2c39fcfe 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -276,8 +276,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 < 102) { - return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.2+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + if (majorv + minorv + minorv2 < 103) { + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.3+ by doing 'cd xmr-node-proxy && git pull && npm update' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } return false; From 9e19b0339826140889f4e209c5586f595f8c3abb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 May 2018 09:23:26 +0200 Subject: [PATCH 0430/2430] Added extra test of share rejected by daemon --- lib/pool.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4ccb25c7..907e88e1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -956,7 +956,7 @@ function processShare(miner, job, blockTemplate, params) { let hash; let shareType; let shareBuffer; - let resultHash = params.result; + const resultHash = params.result; if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.difficulty; walletLastSeeTime[miner.payout] = Date.now(); @@ -1020,9 +1020,15 @@ function processShare(miner, job, blockTemplate, params) { 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. - console.error(threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error)); recordShareData(miner, job, hashDiff.toString(), false, null, shareType, blockTemplate); - global.support.sendEmail(global.config.general.adminEmail, + let isNotifyAdmin = true; + if (shareType) { + let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); + 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.height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); + if (isNotifyAdmin) 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" + From f2a6308b889fbb3c858c8bf3f94588e7365ef396 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 May 2018 17:03:07 +0200 Subject: [PATCH 0431/2430] Simplified diff management --- lib/pool.js | 89 ++++++++++++++++------------------------------------- 1 file changed, 26 insertions(+), 63 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 907e88e1..4b266e29 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -343,14 +343,6 @@ function newBlockTemplate(template) { lastBlockTemplateUpdateTime = Date.now(); } -let VarDiff = (function () { - let variance = global.config.pool.varDiffVariance / 100 * global.config.pool.targetTime; - return { - tMin: global.config.pool.targetTime - variance, - tMax: global.config.pool.targetTime + variance - }; -})(); - // here we keep verified share number of a specific wallet (miner.payout) // it will reset to 0 after invalid share is found // if walletTrust exceeds certain threshold (global.config.pool.trustThreshold * 100) then low diff (<=16000) new workers for this wallet are started with high trust @@ -505,8 +497,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.heartbeat(); // VarDiff System - this.shareTimeBuffer = global.support.circularBuffer(8); - this.shareTimeBuffer.enq(global.config.pool.targetTime); this.lastShareTime = Math.floor(Date.now() / 1000); this.validShares = 0; @@ -539,73 +529,48 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer identifier: this.identifier }); - // Support functions for how miners activate and run. - this.updateDifficultyOld = function () { - let now = Math.round(Date.now() / 1000); - let avg = this.shareTimeBuffer.average(this.lastShareTime); - - let sinceLast = now - this.lastShareTime; - let decreaser = sinceLast > VarDiff.tMax; - - let newDiff; - let direction; - - if (avg > VarDiff.tMax && this.difficulty > global.config.pool.minDifficulty) { - newDiff = global.config.pool.targetTime / avg * this.difficulty; - direction = -1; - } - else if (avg < VarDiff.tMin && this.difficulty < global.config.pool.maxDifficulty) { - newDiff = global.config.pool.targetTime / avg * this.difficulty; - direction = 1; - } - else { - return; - } - - if (Math.abs(newDiff - this.difficulty) / this.difficulty * 100 > global.config.pool.maxDiffChange) { - let change = global.config.pool.maxDiffChange / 100 * this.difficulty * direction; - newDiff = this.difficulty + change; - } - - if (this.setNewDiff(newDiff)) this.sendNewJob(); - this.shareTimeBuffer.clear(); - if (decreaser) { - this.lastShareTime = now; - } - }; - this.calcNewDiff = function () { - let proxyMinerName = this.payout + ":" + this.identifier; + let hashes; + let target; + let period; + const proxyMinerName = this.payout + ":" + this.identifier; if (proxyMinerName in proxyMiners) { - let target = 5; - return Math.floor((proxyMiners[proxyMinerName].hashes / (Math.floor((Date.now() - proxyMiners[proxyMinerName].connectTime) / 1000))) * target); + hashes = proxyMiners[proxyMinerName].hashes; + target = 5; + period = (Date.now() - proxyMiners[proxyMinerName].connectTime) / 1000; } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - let target = 5; - return Math.floor((minerWallets[this.payout].hashes / (Math.floor((Date.now() - minerWallets[this.payout].connectTime) / 1000))) * target); + hashes = minerWallets[this.payout].hashes; + target = 5; + period = (Date.now() - minerWallets[this.payout].connectTime) / 1000; } else { - let target = this.proxy ? 5 : global.config.pool.targetTime; - return Math.floor((this.hashes / (Math.floor((Date.now() - this.connectTime) / 1000))) * target); + hashes = this.hashes; + target = this.proxy ? 5 : global.config.pool.targetTime; + period = (Date.now() - this.connectTime) / 1000; + } + if (hashes === 0) { + hashes = this.difficulty; + target = 2 * global.config.pool.retargetTime; + if (period < target) period = target; } + return Math.floor(hashes * target / period); }; this.updateDifficulty = function () { - if (this.hashes > 0) { - if (this.setNewDiff(this.calcNewDiff())) this.sendNewJob(); - } else { - this.updateDifficultyOld(); - } + if (this.setNewDiff(this.calcNewDiff())) this.sendNewJob(); }; this.setNewDiff = function (difficulty) { this.newDiff = Math.round(difficulty); - debug(threadName + "Difficulty: " + this.newDiff + " For: " + this.logString + " Time Average: " + this.shareTimeBuffer.average(this.lastShareTime) + " Entries: " + this.shareTimeBuffer.size() + " Sum: " + this.shareTimeBuffer.sum()); if (this.newDiff > global.config.pool.maxDifficulty && !this.proxy) { this.newDiff = global.config.pool.maxDifficulty; } if (this.newDiff < global.config.pool.minDifficulty) { this.newDiff = global.config.pool.minDifficulty; } - if (this.difficulty === this.newDiff) return false; + + const ratio = Math.abs(this.newDiff - this.difficulty) / this.difficulty; + if (ratio > 1 - 0.05 && ratio < 1 + 0.05) return false; + debug(threadName + "Difficulty change to: " + this.newDiff + " For: " + this.logString); if (this.hashes > 0) { debug(threadName + "Hashes: " + this.hashes + " in: " + Math.floor((Date.now() - this.connectTime) / 1000) + " seconds gives: " + @@ -979,7 +944,7 @@ function processShare(miner, job, blockTemplate, params) { } process.send({type: 'throttledShare'}); addProxyMiner(miner); - if (miner.setNewDiff(miner.calcNewDiff())) miner.sendNewJob(); + miner.updateDifficulty(); return null; } shareBuffer = getShareBuffer(miner, job, blockTemplate, params); @@ -1309,9 +1274,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } - let now = Date.now() / 1000 || 0; - miner.shareTimeBuffer.enq(now - miner.lastShareTime); - miner.lastShareTime = now; + miner.lastShareTime = Date.now() / 1000 || 0; sendReply(null, {status: 'OK'}); break; From 8872be938a0e30c00bc8eacb11aafc7e38695960 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 May 2018 18:36:23 +0200 Subject: [PATCH 0432/2430] Fixed keep diff thresold --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4b266e29..33576640 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -569,7 +569,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } const ratio = Math.abs(this.newDiff - this.difficulty) / this.difficulty; - if (ratio > 1 - 0.05 && ratio < 1 + 0.05) return false; + if (ratio < 0.05) return false; debug(threadName + "Difficulty change to: " + this.newDiff + " For: " + this.logString); if (this.hashes > 0) { From 2798857d8d547ca8efbb5f0fe02071015eca691e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 May 2018 18:57:26 +0200 Subject: [PATCH 0433/2430] Added time guards for potentially long jobs --- lib/pool.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 33576640..87364c65 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -160,6 +160,7 @@ function sendToWorkers(data) { function retargetMiners() { debug(threadName + "Performing difficulty check on miners"); + const time_now = Date.now(); for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; @@ -168,6 +169,8 @@ function retargetMiners() { } } } + const elapsed = Date.now() - time_now; + if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms"); } // wallet " " proxy miner name -> { connectTime, count (miner), hashes } @@ -197,14 +200,16 @@ function removeMiner(miner) { function checkAliveMiners() { debug(threadName + "Verifying if miners are still alive"); + const time_now = Date.now(); + const deadline = time_now - global.config.pool.minerTimeout * 1000; for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; - if (Date.now() - miner.lastContact > global.config.pool.minerTimeout * 1000) { - removeMiner(miner); - } + if (miner.lastContact < deadline) removeMiner(miner); } } + const elapsed = Date.now() - time_now; + if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms"); } let isActivePortUpdateBlocked = false; @@ -1343,7 +1348,7 @@ 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 { - setInterval(checkAliveMiners, 30*1000); + setInterval(checkAliveMiners, 60*1000); setInterval(retargetMiners, global.config.pool.retargetTime * 1000); templateUpdate(); anchorBlockUpdate(); From 602c89a4b0c5700d2cd143fcc2dd69be9b1677cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 07:50:37 +0200 Subject: [PATCH 0434/2430] More reliable BT issues reporting --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 4d756755..69363cf7 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -715,7 +715,7 @@ function monitorNodes() { return; } bad_header_stop(); - if (row.blockID < block.height - 3) { + 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" From 7e7ba43bbf2e6c2622038fdcf5c59413f9f77b0e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 10:21:53 +0200 Subject: [PATCH 0435/2430] More clever BT stuck delection/fix --- lib/pool.js | 110 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 35 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 87364c65..771cf960 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -9,6 +9,7 @@ const async = require('async'); const net = require('net'); const tls = require('tls'); const fs = require('fs'); +const child_process = require('child_process'); let nonceCheck = new RegExp("^[0-9a-f]{8}$"); let bannedIPs = {}; @@ -19,7 +20,8 @@ let pastBlockTemplates = global.support.circularBuffer(4); let activeMiners = []; let activeBlockTemplate; let lastBlockHash; -let lastBlockHashUpdateTime; +let lastBlockCheckTime = Date.now(); // time when block was checked to be in line with other nodes or when ./fix_daemon.sh was attempted +let lastBlockCheckTime2 = Date.now(); // time when block was checked to be in line with other nodes let lastBlockTemplateUpdateTime; let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; @@ -212,18 +214,20 @@ function checkAliveMiners() { if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms"); } -let isActivePortUpdateBlocked = false; - // global.config.daemon.activePort is only updated in master thread function updateActivePort() { - if (!isActivePortUpdateBlocked) { - global.support.getActivePort(function (newActivePort) { - if (newActivePort && global.config.daemon.activePort && global.config.daemon.activePort !== newActivePort) { - console.log("Changing active port from " + global.config.daemon.activePort + " to " + newActivePort); - global.config.daemon.activePort = newActivePort; + global.support.getActivePort(function (newActivePort) { + if (!global.config.daemon.activePort) return; + if (newActivePort === null) { + if (global.config.daemon.activePort !== global.config.daemon.port) { + console.error("Error getting active port, so rolling back to main port"); + global.config.daemon.activePort = global.config.daemon.port; } - }); - } + } else if (global.config.daemon.activePort !== newActivePort) { + console.log("Changing active port from " + global.config.daemon.activePort + " to " + newActivePort); + global.config.daemon.activePort = newActivePort; + } + }); } // templateUpdateReal is only called in master thread @@ -253,26 +257,6 @@ function templateUpdateReal(activePort) { // templateUpdate is only called in master thread function templateUpdate(repeating) { - if (global.config.general.allowStuckPoolKill && cluster.isMaster && lastBlockHashUpdateTime && Date.now() - lastBlockHashUpdateTime > 2*60*60*1000) { - if (global.config.daemon.activePort === global.config.daemon.port) { - global.support.sendEmail(global.config.general.adminEmail, - "Pool server " + global.config.hostname + " was terminated", - "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was terminated due to main chain block template stuck" - ); - console.error("Block height was not updated for hours. Check your monerod. Exiting..."); - fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); - process.exit(); - } else { - global.support.sendEmail(global.config.general.adminEmail, - "Pool server " + global.config.hostname + " was switched to main chain", - "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was switch to main chain due to block template stuck on " + global.config.daemon.activePort + " port" - ); - console.error("Alt block height on " + global.config.daemon.activePort + " port was not updated for hours. Switching to main chain...."); - global.config.daemon.activePort = global.config.daemon.port; - isActivePortUpdateBlocked = true; - } - } - let activePort = global.config.daemon.activePort; global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { if (activePort !== global.config.daemon.activePort) { @@ -282,7 +266,6 @@ function templateUpdate(repeating) { } if (err === null) { if (!lastBlockHash || body.hash !== lastBlockHash) { - lastBlockHashUpdateTime = Date.now(); lastBlockHash = body.hash; templateUpdateReal(activePort); } @@ -1307,15 +1290,72 @@ if (cluster.isMaster) { minerCount[portData.port] = 0; }); registerPool(); + setInterval(function () { - global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]); if (activeBlockTemplate) { - global.mysql.query("UPDATE pools SET blockIDTime = now(), blockID = ?, port = ? where id = ?", [activeBlockTemplate.height, activeBlockTemplate.port, global.config.pool_id]); - } + 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]); + } else { + 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]); }); - }, 10000); + }, 10*1000); + + + setInterval(function () { + if (!activeBlockTemplate) continue; + + global.mysql.query("SELECT blockID, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { + let top_height = 0; + rows.forEach(function (row) { + if (row.port != activeBlockTemplate.port) continue; + if (row.blockID > top_height) top_height = row.blockID; + }); + if (top_height) { + if (activeBlockTemplate.height < top_height) { + if (Date.now() - lastBlockCheckTime2 > 30*60*1000 && global.config.general.allowStuckPoolKill && activeBlockTemplate.port == global.config.daemon.port) { + global.support.sendEmail(global.config.general.adminEmail, + "Pool server " + global.config.hostname + " was terminated", + "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was terminated due to main chain block template stuck" + ); + console.error("Block height was not updated for a long time. Check your monerod. Exiting..."); + fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); + process.exit(); + } + if (Date.now() - lastBlockCheckTime > 10*60*1000) { + console.error("Current block height " + activeBlockTemplate.height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + activeBlockTemplate.port + " 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 " + + activeBlockTemplate.height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + + activeBlockTemplate.port + " port" + ); + if (fs.existsSync("./fix_daemon.sh")) { + child_process.exec("./fix_daemon.sh", function callback(error, stdout, stderr) { + console.log("> ./fix_daemon.sh"); + 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"); + } + lastBlockCheckTime = Date.now(); + } + } else if (activeBlockTemplate.height == top_height) { + lastBlockCheckTime = lastBlockCheckTime2 = Date.now(); + } else { + console.error("Current block height " + activeBlockTemplate.height + " is somehow greater than top height (" + top_height + ") amongst other leaf nodes for " + activeBlockTemplate.port + " port"); + lastBlockCheckTime = lastBlockCheckTime2 = Date.now(); + } + } else { + console.error("Can't get top height amongst all leaf nodes for " + activeBlockTemplate.port + " port"); + lastBlockCheckTime = lastBlockCheckTime2 = Date.now(); + } + }); + }, 60*1000); + console.log('Master cluster setting up ' + numWorkers + ' workers...'); for (let i = 0; i < numWorkers; i++) { From 604557e85f8feb0bdaa0d1fda7accfcc7baf36ae Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 10:23:48 +0200 Subject: [PATCH 0436/2430] Syntax fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 771cf960..2d6b5d95 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1304,7 +1304,7 @@ if (cluster.isMaster) { setInterval(function () { - if (!activeBlockTemplate) continue; + if (!activeBlockTemplate) 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; From 6267d0afb5e15b1627167e1852d0ba072c09a148 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 10:24:38 +0200 Subject: [PATCH 0437/2430] Syntax fix2 --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2d6b5d95..68675325 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1309,7 +1309,7 @@ if (cluster.isMaster) { global.mysql.query("SELECT blockID, port FROM pools WHERE last_checkin > date_sub(now(), interval 30 minute)").then(function (rows) { let top_height = 0; rows.forEach(function (row) { - if (row.port != activeBlockTemplate.port) continue; + if (row.port != activeBlockTemplate.port) return; if (row.blockID > top_height) top_height = row.blockID; }); if (top_height) { From 71cdbb36c687d6920d4ce09bff67a16455892ce6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 10:41:54 +0200 Subject: [PATCH 0438/2430] Fixed admin email sending in case of process exit --- lib/pool.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 68675325..0b4528c9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1314,17 +1314,18 @@ if (cluster.isMaster) { }); if (top_height) { if (activeBlockTemplate.height < top_height) { + console.error("!!! Current block height " + activeBlockTemplate.height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + activeBlockTemplate.port + " port"); if (Date.now() - lastBlockCheckTime2 > 30*60*1000 && global.config.general.allowStuckPoolKill && activeBlockTemplate.port == global.config.daemon.port) { global.support.sendEmail(global.config.general.adminEmail, - "Pool server " + global.config.hostname + " was terminated", - "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " was terminated due to main chain block template stuck" + "Pool server " + global.config.hostname + " will be terminated", + "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " will be terminated due to main chain block template stuck" ); - console.error("Block height was not updated for a long time. Check your monerod. Exiting..."); + console.error("Block height was not updated for a long time for main port. Check your monerod. Exiting..."); fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); - process.exit(); + setTimeout(function() { process.exit(); }, 30*1000); // need time for admin email sending + return; } if (Date.now() - lastBlockCheckTime > 10*60*1000) { - console.error("Current block height " + activeBlockTemplate.height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + activeBlockTemplate.port + " 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 " + From 88bfb8b4831c403c5486507717a5007bde2b52c1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 11:06:02 +0200 Subject: [PATCH 0439/2430] Added support for fixing alt daemons --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0b4528c9..0e631ea6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1333,8 +1333,8 @@ if (cluster.isMaster) { activeBlockTemplate.port + " port" ); if (fs.existsSync("./fix_daemon.sh")) { - child_process.exec("./fix_daemon.sh", function callback(error, stdout, stderr) { - console.log("> ./fix_daemon.sh"); + child_process.exec("./fix_daemon.sh " + activeBlockTemplate.port, function callback(error, stdout, stderr) { + console.log("> ./fix_daemon.sh " + activeBlockTemplate.port); console.log(stdout); console.error(stderr); if (error) console.error("./fix_daemon.sh script returned error exit code: " + error.code); From f24a623fa014934a0123f1119680e025c513964c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:08:29 +0200 Subject: [PATCH 0440/2430] More reliable stuck BT detection in case of port switching --- lib/pool.js | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0e631ea6..a0428693 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -20,8 +20,9 @@ let pastBlockTemplates = global.support.circularBuffer(4); let activeMiners = []; let activeBlockTemplate; let lastBlockHash; -let lastBlockCheckTime = Date.now(); // time when block was checked to be in line with other nodes or when ./fix_daemon.sh was attempted -let lastBlockCheckTime2 = Date.now(); // time when block was checked to be in line with other nodes +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 lastBlockGoodTime = {}; // time when blocks were checked to be in line with other nodes let lastBlockTemplateUpdateTime; let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; @@ -1308,14 +1309,19 @@ if (cluster.isMaster) { 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; rows.forEach(function (row) { - if (row.port != activeBlockTemplate.port) return; + if (row.port != port) return; if (row.blockID > top_height) top_height = row.blockID; }); if (top_height) { - if (activeBlockTemplate.height < top_height) { - console.error("!!! Current block height " + activeBlockTemplate.height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + activeBlockTemplate.port + " port"); - if (Date.now() - lastBlockCheckTime2 > 30*60*1000 && global.config.general.allowStuckPoolKill && activeBlockTemplate.port == global.config.daemon.port) { + if (height < top_height - 3) { + 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 (!(port in lastBlockGoodTime)) lastBlockGoodTime[port] = Date.now(); + + if (global.config.general.allowStuckPoolKill && port == global.config.daemon.port && Date.now() - lastBlockGoodTime[port] > 30*60*1000) { global.support.sendEmail(global.config.general.adminEmail, "Pool server " + global.config.hostname + " will be terminated", "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " will be terminated due to main chain block template stuck" @@ -1325,34 +1331,35 @@ if (cluster.isMaster) { setTimeout(function() { process.exit(); }, 30*1000); // need time for admin email sending return; } - if (Date.now() - lastBlockCheckTime > 10*60*1000) { + + if (Date.now() - lastBlockFixTime[port] > 10*60*1000) { 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 " + - activeBlockTemplate.height + " is stuck compared to top height (" + top_height + ") amongst other leaf nodes for " + - activeBlockTemplate.port + " port" + 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 " + activeBlockTemplate.port, function callback(error, stdout, stderr) { - console.log("> ./fix_daemon.sh " + activeBlockTemplate.port); + 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); + 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"); + console.error("No " + fix_daemon_sh + " script was found to fix stuff"); } - lastBlockCheckTime = Date.now(); + lastBlockFixTime[port] = Date.now(); } - } else if (activeBlockTemplate.height == top_height) { - lastBlockCheckTime = lastBlockCheckTime2 = Date.now(); } else { - console.error("Current block height " + activeBlockTemplate.height + " is somehow greater than top height (" + top_height + ") amongst other leaf nodes for " + activeBlockTemplate.port + " port"); - lastBlockCheckTime = lastBlockCheckTime2 = Date.now(); + if (height >= top_height + 3) { + console.warn("Current block height " + height + " is somehow greater than top height (" + top_height + ") amongst other leaf nodes for " + port + " port"); + } + lastBlockFixTime[port] = lastBlockGoodTime[port] = Date.now(); } } else { - console.error("Can't get top height amongst all leaf nodes for " + activeBlockTemplate.port + " port"); - lastBlockCheckTime = lastBlockCheckTime2 = Date.now(); + console.error("Can't get top height amongst all leaf nodes for " + port + " port"); + lastBlockFixTime[port] = lastBlockGoodTime[port] = Date.now(); } }); }, 60*1000); From a39b99b5c35c66d276b86dd141d1016876a3aaad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:20:23 +0200 Subject: [PATCH 0441/2430] More payment proof details --- lib/payment_systems/xmr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 751d20f0..c2abd4b6 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -663,7 +663,9 @@ function Payee(amount, address, paymentID, bitcoin) { "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) to %(address2)s wallet was just performed and total due was decreased by %(amount)s XMR.\n" + (payee.tx_hash && payee.tx_key ? "Your payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" + - "Or just use this link to verify that this payment was made: https://xmrchain.net/prove/%(tx_hash)s/%(address)s/%(tx_key)s\n" + "Here is link to verify that this payment was made: https://xmrchain.net/prove/%(tx_hash)s/%(address)s/%(tx_key)s\n" + + "You can also check that in your command line (cli) wallet using \"check_tx_key %(tx_hash)s %(tx_key)s %(address)s\" command " + + "(see https://getmonero.org/resources/user-guides/prove-payment.html for more details)\n" : "" ), emailData From 911a55e3dcd1014745f3e4e56c68a2e77e56c785 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:24:48 +0200 Subject: [PATCH 0442/2430] Some extra clarifications --- 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 c2abd4b6..061018a3 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -662,7 +662,7 @@ function Payee(amount, address, paymentID, bitcoin) { sprintf( "Your payment of %(payment_amount)s XMR (with tx fee %(fee)s XMR) to %(address2)s wallet was just performed and total due was decreased by %(amount)s XMR.\n" + (payee.tx_hash && payee.tx_key ? - "Your payment tx_hash is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" + + "Your payment tx_hash (tx_id) is %(tx_hash)s and tx_key is %(tx_key)s (can be used to verify payment)\n" + "Here is link to verify that this payment was made: https://xmrchain.net/prove/%(tx_hash)s/%(address)s/%(tx_key)s\n" + "You can also check that in your command line (cli) wallet using \"check_tx_key %(tx_hash)s %(tx_key)s %(address)s\" command " + "(see https://getmonero.org/resources/user-guides/prove-payment.html for more details)\n" From 0f9186f1de7a717bbc65d41eb173d2c8336599e4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:30:38 +0200 Subject: [PATCH 0443/2430] Added fix_daemon.sh --- fix_daemon.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 fix_daemon.sh diff --git a/fix_daemon.sh b/fix_daemon.sh new file mode 100644 index 00000000..2e39c76c --- /dev/null +++ b/fix_daemon.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sudo service monero restart From 0e83c5ad64a1aa2fee72d14358de9d4d2d5cb62d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:34:32 +0200 Subject: [PATCH 0444/2430] Added exec bit to fix_daemon.sh --- fix_daemon.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 fix_daemon.sh diff --git a/fix_daemon.sh b/fix_daemon.sh old mode 100644 new mode 100755 From e5d96ed25451407034424bd61ca95a00795f3a42 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:39:20 +0200 Subject: [PATCH 0445/2430] Fixed XNP 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 2c39fcfe..75fd5729 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -251,7 +251,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.1+ (check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.3+ by doing 'cd xmr-node-proxy && git pull && npm update' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]) * 100; From f6329489e8a3a0ba2a88c24ce4055ec666e46d25 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:44:03 +0200 Subject: [PATCH 0446/2430] Updated xmrig 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 75fd5729..89445398 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -238,7 +238,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.5.0+"; + return "Please update your XMRig miner (" + agent + ") to v2.6.1+"; } } else if (m = reXMRSTAK.exec(agent)) { let majorv = parseInt(m[1]) * 100; From a76aaa94bb14a799e1138f482a09a7c8b73bff36 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 13:46:35 +0200 Subject: [PATCH 0447/2430] Fixed XNP update instruction for original XNP --- 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 89445398..add39272 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -251,7 +251,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+ by doing 'cd xmr-node-proxy && git pull && npm update' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + return "Please update your xmr-node-proxy (" + agent + ") to version v0.1.3+ (from https://github.com/MoneroOcean/xmr-node-proxy repo)"; } } else if (m = reCCMINER.exec(agent)) { let majorv = parseInt(m[1]) * 100; From e010eb0a3ad4c8df62bf7806e30994fe87e62f93 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 May 2018 20:22:49 +0200 Subject: [PATCH 0448/2430] Added more clean payment id explanation --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index a0428693..3aff47ec 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -445,7 +445,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.valid_miner = false; } if (this.valid_miner && global.coinFuncs.exchangeAddresses.indexOf(this.address) !== -1 && !(this.paymentID)) { - this.error = "Exchange addresses need payment IDs"; + this.error = "Exchange addresses need 64 char long payment IDs. Please specify it after your wallet address as follows: wallet.paymentid"; this.valid_miner = false; } if (this.valid_miner && !activeBlockTemplate) { From 34d69c3310dc2572c8f1e8815e350e3e7a92aa2b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 6 May 2018 01:52:17 +0200 Subject: [PATCH 0449/2430] Added cn/1 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 add39272..d89026f4 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -225,7 +225,7 @@ function Coin(data){ } this.algoTypeStr = function(port) { - return "cryptonight"; + return "cryptonight/1"; } this.variantValue = function(port) { From 8f74e1cbde2c53320306a74d7061c9cf16606052 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 6 May 2018 05:37:21 +0200 Subject: [PATCH 0450/2430] Reduced time to fix BT --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3aff47ec..d93e736a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1332,7 +1332,7 @@ if (cluster.isMaster) { return; } - if (Date.now() - lastBlockFixTime[port] > 10*60*1000) { + if (Date.now() - lastBlockFixTime[port] > 5*60*1000) { 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 " + From ba03eb6320f168847394b7b34519b52e9ecf81a9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 6 May 2018 09:04:06 +0200 Subject: [PATCH 0451/2430] Made BT caused pool termination only after several definite attempts to fix it --- lib/pool.js | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d93e736a..4c56b44f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -22,7 +22,7 @@ let activeBlockTemplate; let lastBlockHash; 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 lastBlockGoodTime = {}; // time when blocks were checked to be in line with other nodes +let lastBlockFixCount = {}; // number of times fix_daemon_sh was run let lastBlockTemplateUpdateTime; let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; @@ -1318,21 +1318,23 @@ if (cluster.isMaster) { if (top_height) { if (height < top_height - 3) { 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 (!(port in lastBlockGoodTime)) lastBlockGoodTime[port] = Date.now(); - - if (global.config.general.allowStuckPoolKill && port == global.config.daemon.port && Date.now() - lastBlockGoodTime[port] > 30*60*1000) { - global.support.sendEmail(global.config.general.adminEmail, - "Pool server " + global.config.hostname + " will be terminated", - "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " will be terminated due to main chain block template stuck" - ); - console.error("Block height was not updated for a long time for main port. Check your monerod. Exiting..."); - fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); - setTimeout(function() { process.exit(); }, 30*1000); // need time for admin email sending - return; - } + if (!(port in lastBlockFixTime)) lastBlockFixTime[port] = Date.now(); if (Date.now() - lastBlockFixTime[port] > 5*60*1000) { + if (!(port in lastBlockFixCount)) lastBlockFixCount[port] = 1; + else ++ lastBlockFixCount[port]; + + if (lastBlockFixCount[port] > 5 && global.config.general.allowStuckPoolKill && port == global.config.daemon.port) { + global.support.sendEmail(global.config.general.adminEmail, + "Pool server " + global.config.hostname + " will be terminated", + "The pool server: " + global.config.hostname + " with IP: " + global.config.bind_ip + " will be terminated due to main chain block template stuck" + ); + console.error("Block height was not updated for a long time for main port. Check your monerod. Exiting..."); + fs.closeSync(fs.openSync("block_template_is_stuck", 'w')); + setTimeout(function() { process.exit(); }, 30*1000); // need time for admin email sending + 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 " + @@ -1355,11 +1357,13 @@ if (cluster.isMaster) { if (height >= top_height + 3) { console.warn("Current block height " + height + " is somehow greater than top height (" + top_height + ") amongst other leaf nodes for " + port + " port"); } - lastBlockFixTime[port] = lastBlockGoodTime[port] = Date.now(); + lastBlockFixTime[port] = Date.now(); + lastBlockFixCount[port] = 0; } } else { console.error("Can't get top height amongst all leaf nodes for " + port + " port"); - lastBlockFixTime[port] = lastBlockGoodTime[port] = Date.now(); + lastBlockFixTime[port] = Date.now(); + lastBlockFixCount[port] = 0; } }); }, 60*1000); From 9a1913a50c72c70698dbf65011705e50dc712ae8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 6 May 2018 10:19:45 +0200 Subject: [PATCH 0452/2430] Updated proxy update instruction --- 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 d89026f4..480d765f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -277,7 +277,7 @@ function Coin(data){ 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 && git pull && npm update' (or check https://github.com/MoneroOcean/xmr-node-proxy repo)"; + 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)"; } } return false; From ca1219bfd05b3a122a90943ed4e7565909889956 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 6 May 2018 10:20:09 +0200 Subject: [PATCH 0453/2430] Switched to tagged utils --- package.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 00a812f6..75fcdf8b 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,8 @@ "sticky-cluster": "^0.3.1", "uuid": "3.0.1", "wallet-address-validator": "0.1.0", - "zmq": "^2.15.3" - }, - "optionalDependencies": { - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git" + "zmq": "^2.15.3", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v1.0.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v1.0.0" } } From fdcab8a18188bfb93910e67c881687a81d4af048 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 7 May 2018 11:56:08 +0200 Subject: [PATCH 0454/2430] Updated utils --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 75fcdf8b..e40a330c 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,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", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.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.0.0" } } From 55c9c7ca8dcdefd6a4b5cd1433c9029427b1fdb9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 7 May 2018 17:01:49 +0200 Subject: [PATCH 0455/2430] Fixed utils version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e40a330c..c68e06c7 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,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", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v1.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v2.0.0" } } From 775bf6963af09e295977a6a99317793482fca9d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 May 2018 18:23:31 +0200 Subject: [PATCH 0456/2430] Fixed fixed diff drop to low dynamic diff --- lib/pool.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4c56b44f..63e4b53d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -167,7 +167,14 @@ function retargetMiners() { for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; - if (!miner.fixed_diff || (miner.hashes > 0 && miner.difficulty * 10 < miner.calcNewDiff())) { + if (miner.fixed_diff) { + const newDiff = miner.calcNewDiff(); + if (miner.difficulty * 10 < newDiff) { + console.log("Dropped low fixed diff " + miner.difficulty + " for " + this.logString + " miner to " + newDiff + " dynamic diff"); + miner.fixed_diff = false; + if (miner.setNewDiff(newDiff)) this.sendNewJob(); + } + } else { miner.updateDifficulty(); } } @@ -545,10 +552,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; this.updateDifficulty = function () { + if (this.fixed_diff) return; if (this.setNewDiff(this.calcNewDiff())) this.sendNewJob(); }; 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; @@ -566,10 +576,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer 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); } - if (this.fixed_diff) { - console.log("Dropped low fixed diff " + this.difficulty + " for " + this.logString + " miner to " + this.newDiff + " dynamic diff"); - this.fixed_diff = false; - } return true; }; From ee19200b74a6247e4a48f3bc3b0e458aae8c5aa7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 May 2018 18:29:25 +0200 Subject: [PATCH 0457/2430] Fixed bug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 63e4b53d..aadacae8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -172,7 +172,7 @@ function retargetMiners() { if (miner.difficulty * 10 < newDiff) { console.log("Dropped low fixed diff " + miner.difficulty + " for " + this.logString + " miner to " + newDiff + " dynamic diff"); miner.fixed_diff = false; - if (miner.setNewDiff(newDiff)) this.sendNewJob(); + if (miner.setNewDiff(newDiff)) miner.sendNewJob(); } } else { miner.updateDifficulty(); From e1d6825260c7f3a946ad643ec0a3cd6ba76a1ab0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 May 2018 18:33:51 +0200 Subject: [PATCH 0458/2430] Fixed bug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index aadacae8..c938fba5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -170,7 +170,7 @@ function retargetMiners() { if (miner.fixed_diff) { const newDiff = miner.calcNewDiff(); if (miner.difficulty * 10 < newDiff) { - console.log("Dropped low fixed diff " + miner.difficulty + " for " + this.logString + " miner to " + newDiff + " dynamic diff"); + 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(); } From ab05e21ccd1169f170ed9b251e77c0d4fb5daa87 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 May 2018 13:47:36 +0200 Subject: [PATCH 0459/2430] Updated monero patch --- deployment/monero_daemon.patch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/monero_daemon.patch b/deployment/monero_daemon.patch index 5f681f70..e98c4b85 100644 --- a/deployment/monero_daemon.patch +++ b/deployment/monero_daemon.patch @@ -1,13 +1,13 @@ diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp -index 4b3fa787..a2340139 100644 +index 5dfbc1d..1e0487a 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp -@@ -863,7 +863,7 @@ namespace cryptonote +@@ -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 = m_blockchain.get_txpool_tx_meta(sorted_it->second); - LOG_PRINT_L2("Considering " << sorted_it->second << ", size " << meta.blob_size << ", current block size " << total_size << "/" << max_total_size << ", current coinbase " << print_money(best_coinbase)); + txpool_tx_meta_t meta; + if (!m_blockchain.get_txpool_tx_meta(sorted_it->second, meta)) From 449d04968f41396cc5a64ebf255009437e564a17 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 May 2018 16:15:07 +0200 Subject: [PATCH 0460/2430] Fixed type --- lib/api.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api.js b/lib/api.js index ba8e1a2d..6f03c539 100644 --- a/lib/api.js +++ b/lib/api.js @@ -236,7 +236,7 @@ app.get('/pool/chart/hashrate/:pool_type', function (req, res) { case 'solo': localCache = global.database.getCache('solo_stats'); break; - case 'default': + default: return res.json({'error': 'Invalid pool type'}); } res.json(localCache['hashHistory']); @@ -255,7 +255,7 @@ app.get('/pool/chart/miners/:pool_type', function (req, res) { case 'solo': localCache = global.database.getCache('stats_solo'); break; - case 'default': + default: return res.json({'error': 'Invalid pool type'}); } res.json(localCache['minerHistory']); @@ -277,7 +277,7 @@ app.get('/pool/stats/:pool_type', function (req, res) { localCache = global.database.getCache('pool_stats_solo'); localCache.fee = global.config.payout.soloFee; break; - case 'default': + default: return res.json({'error': 'Invalid pool type'}); } delete(localCache.minerHistory); @@ -330,7 +330,7 @@ app.get('/pool/payments/:pool_type', function (req, res) { break; case 'solo': break; - case 'default': + default: return res.json({'error': 'Invalid pool type'}); } let paymentIds = []; From c210075ea4b0655f450898cf4ae218b6859f4c4c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 May 2018 19:38:30 +0200 Subject: [PATCH 0461/2430] Initial implementation draft --- lib/api.js | 2 +- lib/blockManager.js | 2 +- lib/coins/xmr.js | 4 +- lib/data.proto | 1 + lib/local_comms.js | 101 ------- lib/pool.js | 716 +++++++++++++++++++++++++++----------------- lib/support.js | 23 +- lib/worker.js | 25 +- 8 files changed, 484 insertions(+), 390 deletions(-) diff --git a/lib/api.js b/lib/api.js index 6f03c539..3203421f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -47,7 +47,7 @@ function getAllWorkerHashCharts(address, callback){ } let intCounter = 0; identifiers.forEach(function(identifier){ - returnData[identifier] = global.database.getCache("history:" + address+"_"+identifier)['hashHistory']; + returnData[identifier] = global.database.getCache("history:" + address + "_" + identifier)['hashHistory']; intCounter += 1; if (intCounter === identifiers.length){ return callback(null, returnData); diff --git a/lib/blockManager.js b/lib/blockManager.js index 16547907..024d74ab 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -305,7 +305,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }; } - let amountToPay = shareData.shares; + let amountToPay = shareData.shares2 ? shareData.shares2 : shareData.shares; 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/coins/xmr.js b/lib/coins/xmr.js index 480d765f..7f3f78b0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -30,7 +30,7 @@ function Coin(data){ "43SLUTpyTgXCNXsL43uD8FWZ5wLAdX7Ak67BgGp7dxnGhLmrffDTXoeGm2GBRm8JjigN9PTg2gnShQn5gkgE1JGWJr4gsEU", // Wolf0's address "42QWoLF7pdwMcTXDviJvNkWEHJ4TXnMBh2Cx6HNkVAW57E48Zfw6wLwDUYFDYJAqY7PLJUTz9cHWB5C4wUA7UJPu5wPf4sZ", // Wolf0's address "46gq64YYgCk88LxAadXbKLeQtCJtsLSD63NiEc3XHLz8NyPAyobACP161JbgyH2SgTau3aPUsFAYyK2RX4dHQoaN1ats6iT", // Claymore's Fee Address. - "47mr7jYTroxQMwdKoPQuJoc9Vs9S9qCUAL6Ek4qyNFWJdqgBZRn4RYY2QjQfqEMJZVWPscupSgaqmUn1dpdUTC4fQsu3yjN" // Claymore's _other_ fee address. + "47mr7jYTroxQMwdKoPQuJoc9Vs9S9qCUAL6Ek4qyNFWJdqgBZRn4RYY2QjQfqEMJZVWPscupSgaqmUn1dpdUTC4fQsu3yjN" // Claymore's _other_ fee address. ]; this.exchangeAddresses = [ @@ -195,6 +195,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 daemon port this.port = template.port; this.nextBlob = function () { diff --git a/lib/data.proto b/lib/data.proto index 73d5f09f..1eb65441 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -39,6 +39,7 @@ message Share { required int64 timestamp = 11; required string identifier = 12; optional int32 port = 13; + optional int32 shares2 = 14; } message Block { diff --git a/lib/local_comms.js b/lib/local_comms.js index aa25e6bf..e6f2477a 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -207,41 +207,6 @@ function Database(){ } }; - /*this.storeShare = function(blockId, shareData, callback){ - // This function needs the blockID in question, and the shareData in binary format. - // The binary data should be packed as per the data.proto Share protobuf format. - try { - let share = global.protos.Share.decode(shareData); - let minerID = share.paymentAddress; - if (typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10) { - minerID = minerID + '.' + share.paymentID; - } - let minerIDWithIdentifier = minerID + "_" + share.identifier; - this.incrementCacheData('global_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); - switch (share.poolType) { - case global.protos.POOLTYPE.PPLNS: - this.incrementCacheData('pplns_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); - break; - case global.protos.POOLTYPE.PPS: - this.incrementCacheData('pps_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); - break; - case global.protos.POOLTYPE.SOLO: - this.incrementCacheData('solo_stats2', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]); - break; - } - this.incrementCacheData(minerIDWithIdentifier, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]); - this.incrementCacheData(minerID, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]); - } catch (e){ - callback(false); - return; - } - this.refreshEnv(); - let txn = this.env.beginTxn(); - txn.putBinary(this.shareDB, blockId, shareData); - txn.commit(); - callback(true); - };*/ - this.storeBulkShares = function(shareObject) { let cachedData = { global_stats2: { totalHashes: 0, roundHashes: 0 } @@ -379,28 +344,6 @@ function Database(){ } }; - /*this.getLastBlock = function(blockType){ - this.refreshEnv(); - debug("Getting the last block for: "+ blockType); - let txn = this.env.beginTxn({readOnly: true}); - let cursor = new this.lmdb.Cursor(txn, this.blockDB); - let highestBlock = 0; - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - cursor.getCurrentBinary(function(key, data){ // jshint ignore:line - let blockData = global.protos.Block.decode(data); - if (blockData.poolType === blockType || typeof(blockType) === 'undefined'){ - if (found > highestBlock){ - highestBlock = found; - } - } - }); - } - cursor.close(); - txn.commit(); - debug("Done getting the last block for: "+ blockType + " height of: "+ highestBlock); - return highestBlock; - };*/ - this.getBlockByID = function(blockID){ this.refreshEnv(); debug("Getting the data for blockID: " + blockID); @@ -416,34 +359,6 @@ function Database(){ return blockData; }; - /*this.calculateShares = function(blockData, blockHeight){ - debug("Calculating shares for "+ blockData.hash); - this.refreshEnv(); - let lastBlock = this.getLastBlock(blockData.poolType); - let shareCount = 0; - range.range(lastBlock+1, blockHeight+1).forEach(function (blockID) { - let txn = global.database.env.beginTxn({readOnly: true}); - let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - for (let found = (cursor.goToRange(blockID) === blockID); found; found = cursor.goToNextDup()) { - cursor.getCurrentBinary(function(key, data) { // jshint ignore:line - try{ - let shareData = global.protos.Share.decode(data); - if (shareData.poolType === blockData.poolType){ - shareCount = shareCount + shareData.shares; - } - } catch(e){ - console.error("Invalid share"); - } - }); - } - cursor.close(); - txn.commit(); - }); - blockData.shares = shareCount; - debug("Share calculator for "+ blockData.hash + " complete, found " + shareCount + " shares."); - return global.protos.Block.encode(blockData); - };*/ - // hash -> time let orphanBlocks = {}; @@ -552,22 +467,6 @@ function Database(){ } }; - /*this.fixBlockShares = function(blockId){ - let txn = global.database.env.beginTxn(); - let blockData = txn.getBinary(global.database.blockDB, blockId); - txn.abort(); - let blockDataDecoded = global.protos.Block.decode(blockData); - global.coinFuncs.getBlockHeaderByHash(blockDataDecoded.hash, function(err, header){ - if (err === null) { - blockDataDecoded.value = header.reward; - blockData = global.database.calculateShares(blockDataDecoded, blockId); - let txn = global.database.env.beginTxn(); - txn.putBinary(global.database.blockDB, blockId, blockData); - txn.commit(); - } - }); - };*/ - this.invalidateBlock = function(blockId){ this.refreshEnv(); let txn = this.env.beginTxn(); diff --git a/lib/pool.js b/lib/pool.js index c938fba5..e62451ee 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -16,14 +16,15 @@ let bannedIPs = {}; let bannedAddresses = {}; let notifyAddresses = {}; let baseDiff = global.coinFuncs.baseDiff(); -let pastBlockTemplates = global.support.circularBuffer(4); -let activeMiners = []; -let activeBlockTemplate; -let lastBlockHash; +let activeMiners = {}; +let activeSmartMiners = {}; // miners with algos/algos-hr +let lastBlockHash = {}; // algo key +let lastAlgoHashFactor = {}; // algo key +let activeBlockTemplate = {}; // algo key +let pastBlockTemplates = {}; // algo key 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 lastBlockTemplateUpdateTime; let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; let threadName; @@ -57,7 +58,7 @@ if (cluster.isMaster) { invalidShares = 0; outdatedShares = 0; throttledShares = 0; - }, 30000); + }, 30*1000); } else { threadName = "(Worker " + cluster.worker.id + " - " + process.pid + ") "; // reset last verified share counters every VER_SHARES_PERIOD seconds @@ -70,6 +71,10 @@ if (cluster.isMaster) { global.database.thread_id = threadName; +// algo can be "", "Heavy", "Light" +function algoHashFactor(algo) { return "algoHashFactor" + algo; } +function activePortAlgo(algo) { return "activePort" + algo; } + function registerPool() { global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { rows.forEach(function (row) { @@ -108,12 +113,11 @@ function messageHandler(message) { break; case 'newBlockTemplate': debug(threadName + "Received new block template"); - if (cluster.isMaster) { - sendToWorkers(message); - newBlockTemplate(message.data); - } else { - newBlockTemplate(message.data); - } + setNewBlockTemplate(message.data); + break; + case 'newAlgoHashFactor': + debug(threadName + "Received new algo hash factor"); + setNewAlgoHashFactor(message.data.algo, message.data.algoHashFactor); break; case 'removeMiner': if (cluster.isMaster) { @@ -163,23 +167,33 @@ function sendToWorkers(data) { function retargetMiners() { debug(threadName + "Performing difficulty check on miners"); - const time_now = Date.now(); + + 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.sendNewJob(); + } + } else { + miner.updateDifficulty(); + } + } + + const time_before = Date.now(); + + for (let minerId in activeSmartMiners) { + if (activeSmartMiners.hasOwnProperty(minerId)) { + retargetMiner(activeSmartMiners[minerId]); + } + } for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { - let miner = activeMiners[minerId]; - 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.sendNewJob(); - } - } else { - miner.updateDifficulty(); - } + retargetMiner(activeMiners[minerId]); } } - const elapsed = Date.now() - time_now; + const elapsed = Date.now() - time_before; if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms"); } @@ -205,82 +219,129 @@ function removeMiner(miner) { let proxyMinerName = miner.payout + ":" + miner.identifier; if (proxyMinerName in proxyMiners && --proxyMiners[proxyMinerName].count <= 0) delete proxyMiners[proxyMinerName]; if (miner.payout in minerWallets && --minerWallets[miner.payout].count <= 0) delete minerWallets[miner.payout]; - delete activeMiners[miner.id]; + if (miner.algos) { + delete activeSmartMiners[miner.id]; + } else { + delete activeMiners[miner.id]; + } } function checkAliveMiners() { debug(threadName + "Verifying if miners are still alive"); - const time_now = Date.now(); - const deadline = time_now - global.config.pool.minerTimeout * 1000; + const time_before = Date.now(); + const deadline = time_before - global.config.pool.minerTimeout * 1000; + for (let minerId in activeSmartMiners) { + if (activeSmartMiners.hasOwnProperty(minerId)) { + let miner = activeSmartMiners[minerId]; + if (miner.lastContact < deadline) removeMiner(miner); + } + } for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; if (miner.lastContact < deadline) removeMiner(miner); } } - const elapsed = Date.now() - time_now; + const elapsed = Date.now() - time_before; if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms"); } -// global.config.daemon.activePort is only updated in master thread -function updateActivePort() { - global.support.getActivePort(function (newActivePort) { - if (!global.config.daemon.activePort) return; +// global.config.daemon[activePortAlgo(algo)] is only updated in master thread +function updateActivePort(algo) { + global.support.getActivePort(algo, function (newActivePort) { if (newActivePort === null) { - if (global.config.daemon.activePort !== global.config.daemon.port) { - console.error("Error getting active port, so rolling back to main port"); + if (algo === "" && global.config.daemon.activePort !== 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 " + activePortAlgo(algo)); + global.config.daemon[algoHashFactor(algo)] = 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; + } else { + if (newAlgoHashFactor == 0) debug("Got zero " + algoHashFactor(algo)); + global.config.daemon[algoHashFactor(algo)] = newAlgoHashFactor; + if (global.config.daemon[activePortAlgo(algo)] !== newActivePort) { + console.log("Changing " + activePortAlgo(algo) + " from " + global.config.daemon[activePortAlgo(algo)] + " to " + newActivePort); + global.config.daemon[activePortAlgo(algo)] = newActivePort; + } + } + }); + } else { + console.log("Changing " + activePortAlgo(algo) + " from " + global.config.daemon[activePortAlgo(algo)] + " to " + newActivePort); + global.config.daemon[activePortAlgo(algo)] = newActivePort; } - } else if (global.config.daemon.activePort !== newActivePort) { - console.log("Changing active port from " + global.config.daemon.activePort + " to " + newActivePort); - global.config.daemon.activePort = newActivePort; } }); } -// templateUpdateReal is only called in master thread -function templateUpdateReal(activePort) { +// templateUpdateReal is only called in master thread (except the beginning of a worker thread) +function templateUpdateReal(algo, activePort, algoHashFactor) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { - if (activePort !== global.config.daemon.activePort) { - console.log("Aborting " + activePort + " last block template request because port was already changed to " + global.config.daemon.activePort + " port"); + if (activePort !== global.config.daemon[activePortAlgo(algo)]) { + console.log("Aborting " + activePort + " last block template request because " + activePortAlgo(algo) + " was already changed to " + global.config.daemon[activePortAlgo(algo)] + " port"); return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { rpcResponse = rpcResponse.result; + rpcResponse.algo = algo; rpcResponse.port = activePort; + rpcResponse.algoHashFactor = algoHashFactor; debug(threadName + "New block template found at " + rpcResponse.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); - newBlockTemplate(rpcResponse); } else { - process.send({type: 'newBlockTemplate', data: rpcResponse}); - newBlockTemplate(rpcResponse); + setNewBlockTemplate(rpcResponse); } } else { console.error("Block template request failed for " + activePort + " port"); - setTimeout(templateUpdateReal, 3000, activePort); + algoHashFactorUpdate(algo, 0); + setTimeout(templateUpdateReal, 3000, algo, activePort); } }); } -// templateUpdate is only called in master thread -function templateUpdate(repeating) { - let activePort = global.config.daemon.activePort; +function algoHashFactorUpdate(algo, algoHashFactor) { + if (algo === "") return; + if (cluster.isMaster) { + let data = { algo: algo, algoHashFactor: algoHashFactor }; + sendToWorkers({type: 'newAlgoHashFactor', data: data}); + } else { + setNewAlgoHashFactor(algo, algoHashFactor); + } +} + +// templateUpdate is only called in master thread (except the beginning of a worker thread) +function templateUpdate(algo, repeating) { + let activePort = global.config.daemon[activePortAlgo(algo)]; global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { - if (activePort !== global.config.daemon.activePort) { - console.log("Aborting " + activePort + " last block header request because port was already changed to " + global.config.daemon.activePort + " port"); - if (repeating === true) setTimeout(templateUpdate, 50, repeating); + if (activePort !== global.config.daemon[activePortAlgo(algo)]) { + console.log("Aborting " + activePort + " last block header request because " + activePortAlgo(algo) + " was already changed to " + global.config.daemon[activePortAlgo(algo)] + " port"); + if (repeating === true) setTimeout(templateUpdate, 50, algo, repeating); return; } if (err === null) { - if (!lastBlockHash || body.hash !== lastBlockHash) { - lastBlockHash = body.hash; - templateUpdateReal(activePort); + 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) + ) { + lastAlgoHashFactor[algo] = algoHashFactor; + algoHashFactorUpdate(algo, algoHashFactor); } - if (repeating === true) setTimeout(templateUpdate, 50, repeating); + if (repeating === true) setTimeout(templateUpdate, 50, algo, repeating); } else { - console.error("Last block header request for " + global.config.daemon.activePort + " port failed!"); - setTimeout(templateUpdate, 1000, repeating); + console.error("Last block header request for " + global.config.daemon[activePortAlgo(algo)] + " port failed!"); + algoHashFactorUpdate(algo, 0); + setTimeout(templateUpdate, 1000, algo, repeating); } }); @@ -293,7 +354,7 @@ let anchorBlockPrevHeight; // update main chain anchor block height for alt chain block // anchorBlockUpdate is only called in worker threads function anchorBlockUpdate() { - if (activeBlockTemplate && global.config.daemon.port === activeBlockTemplate.port) return; + if (("" in activeBlockTemplate) && global.config.daemon.port === activeBlockTemplate[""].port) return; // only need to do that separately if we mine alt chain global.coinFuncs.getLastBlockHeader(function (err, body) { if (err === null) { @@ -308,15 +369,35 @@ function anchorBlockUpdate() { }); } -function newBlockTemplate(template) { +function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { + const time_before = Date.now(); + + if (algo !== "") global.config.daemon[algoHashFactor(algo)] = algoHashFactor; + + for (let minerId in activeSmartMiners) { + if (activeSmartMiners.hasOwnProperty(minerId)) { + let miner = activeSmartMiners[minerId]; + 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"); +} + +function setNewBlockTemplate(template) { + const algo = template.algo; let isExtraCheck = false; - if (activeBlockTemplate) { - if (activeBlockTemplate.previous_hash.toString('hex') === template.prev_hash) { - console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); + if (algo in activeBlockTemplate) { + if (activeBlockTemplate[algo].previous_hash.toString('hex') === template.prev_hash) { + console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } - pastBlockTemplates.enq(activeBlockTemplate); - if (activeBlockTemplate.port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; + if (!(algo in pastBlockTemplates)) pastBlockTemplates[algo] = global.support.circularBuffer(4); + activeBlockTemplace[algo].timeOutdate = Date.now() + 4*1000; + pastBlockTemplates[algo].enq(activeBlockTemplate[algo]); + if (activeBlockTemplate[algo].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { console.log('[*] New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); @@ -324,19 +405,27 @@ function newBlockTemplate(template) { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } - activeBlockTemplate = new BlockTemplate(template); - if (global.config.daemon.port === activeBlockTemplate.port) { - anchorBlockHeight = activeBlockTemplate.height; + activeBlockTemplate[algo] = new BlockTemplate(template); + const height = activeBlockTemplate[algo].height; + + if (algo === "" && global.config.daemon.port === activeBlockTemplate[""].port) { + anchorBlockHeight = height; } - for (let minerId in activeMiners) { + + setNewAlgoHashFactor(algo, template.algoHashFactor, isExtraCheck ? height : 0); + + const time_before = Date.now(); + + if (algo === "") for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; - debug(threadName + "Updating worker " + miner.payout + " With new work at height: " + template.height); - if (isExtraCheck) miner.trust.check_height = activeBlockTemplate.height; + if (isExtraCheck) miner.trust.check_height = height; miner.sendNewJob(); } } - lastBlockTemplateUpdateTime = Date.now(); + + const elapsed = Date.now() - time_before; + if (elapsed > 500) console.error("setNewBlockTemplate() consumed " + elapsed + " ms"); } // here we keep verified share number of a specific wallet (miner.payout) @@ -351,32 +440,119 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; -function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent) { +function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_hr) { // Username Layout -
. // Password Layout - .. // Default function is to use the password so they can login. Identifiers can be unique, payment ID is last. // 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. - // Miner Variables + let diffSplit = login.split("+"); + let addressSplit = diffSplit[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 if (pass_split.length === 1 && reEmail.test(pass_split[0])) { pass_split.push(pass_split[0]); pass_split[0] = "email"; } - this.error = ""; - this.identifier = pass_split[0]; - this.proxy = false; - if (agent && agent.includes('MinerGate')) { - this.identifier = "MinerGate"; + + // 1) set payout, identifier, email and logString + + this.payout = this.address = addressSplit[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])) { + this.paymentID = addressSplit[1]; + this.payout += "." + this.paymentID; + if (typeof(addressSplit[2]) !== 'undefined' && this.identifier === 'x') { + this.identifier = addressSplit[2].substring(0, 64); + } + } else if (this.identifier === 'x') { + this.identifier = addressSplit[1].substring(0, 64); + } } - if (agent && agent.includes('xmr-node-proxy')) { - this.proxy = true; + + 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"; + this.valid_miner = false; + return; } - this.paymentID = null; + + if (pass_split.length > 2) { + this.error = "Too many options in the password field"; + this.valid_miner = false; + return; + } + + if (this.payout in bannedAddresses) { // Banned Address + this.error = "Banned payment address provided: " + bannedAddresses[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; + return; + } + + 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 { + this.error = "Invalid payment address provided: " + this.address; + this.valid_miner = false; + return; + } + + if (!("" in activeBlockTemplate)) { + this.error = "No active block template"; + this.valid_miner = false; + return; + } + + if (algos && algos_hr) { + const status = this.setAlgos(algos, algos_hr); + if (status != "") { + this.error = status; + this.valid_miner = false; + return; + } + } + + // 3) setup valid miner stuff + + // 3a) misc stuff + + this.error = ""; this.valid_miner = true; + + this.proxy = agent && agent.includes('xmr-node-proxy'); + this.id = id; + this.ipAddress = ipAddress; + this.messageSender = messageSender; + this.connectTime = Date.now(); + this.heartbeat = function () { this.lastContact = Date.now(); }; + this.heartbeat(); + + // 3b) port stuff + this.port = port; this.portType = portType; switch (portType) { @@ -393,13 +569,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.poolTypeEnum = global.protos.POOLTYPE.PROP; break; } - let diffSplit = login.split("+"); - let addressSplit = diffSplit[0].split('.'); - this.address = addressSplit[0]; - this.payout = addressSplit[0]; + + // 3c) diff stuff + + this.lastShareTime = Math.floor(Date.now() / 1000); + this.validShares = 0; + this.invalidShares = 0; + this.hashes = 0; + this.fixed_diff = false; this.difficulty = startingDiff; - this.connectTime = Date.now(); + if (agent && agent.includes('NiceHash')) { this.fixed_diff = true; this.difficulty = global.coinFuncs.niceHashDiff; @@ -413,92 +593,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (this.difficulty > global.config.pool.maxDifficulty) { this.difficulty = global.config.pool.maxDifficulty; } - } else if (diffSplit.length > 2) { - this.error = "Too many options in the login field"; - this.valid_miner = false; - } - if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[1].length === 64 && hexMatch.test(addressSplit[1]) && global.coinFuncs.validatePlainAddress(addressSplit[0])) { - this.paymentID = addressSplit[1]; - this.payout = this.address + "." + this.paymentID; - } else if (typeof(addressSplit[1]) !== 'undefined') { - this.identifier = pass_split[0] === 'x' ? addressSplit[1] : pass_split[0]; } - if (typeof(addressSplit[2]) !== 'undefined') { - this.identifier = pass_split[0] === 'x' ? addressSplit[2] : pass_split[0]; - } - - this.identifier = this.identifier.substring(0, 64); - if (this.valid_miner && pass_split.length > 2) { - this.error = "Too many options in the password field"; - this.valid_miner = false; - } - - if (global.coinFuncs.validateAddress(this.address)) { - this.bitcoin = 0; - } else if (btcValidator.validate(this.address) && global.config.general.allowBitcoin && global.coinFuncs.supportsAutoExchange) { - this.bitcoin = 1; - } else if (this.valid_miner && btcValidator.validate(this.address)) { - this.error = "This pool does not allow payouts to bitcoin."; - this.valid_miner = false; - } else if (this.valid_miner) { - // Invalid Addresses - this.error = "Invalid payment address provided"; - this.valid_miner = false; - } - if (this.valid_miner && this.payout in bannedAddresses) { - // Banned Address - this.error = "Banned payment address provided: " + bannedAddresses[this.payout]; - this.valid_miner = false; - } - if (this.valid_miner && global.coinFuncs.exchangeAddresses.indexOf(this.address) !== -1 && !(this.paymentID)) { - this.error = "Exchange addresses need 64 char long payment IDs. Please specify it after your wallet address as follows: wallet.paymentid"; - this.valid_miner = false; - } - if (this.valid_miner && !activeBlockTemplate) { - this.error = "No active block template"; - this.valid_miner = false; - } - - if (pass_split.length === 2) { - this.email = pass_split[1]; - if (this.valid_miner) { - // Email address is: pass_split[1] - // Need to do an initial registration call here. Might as well do it right... - let payoutAddress = this.payout; - let time_now = Date.now(); - if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { - global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [payoutAddress]).then(function (rows) { - if (rows.length > 0) { - return; - } - if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { - return; - } - global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, pass_split[1]]); - }); - walletLastCheckTime[payoutAddress] = time_now; - } - } - } else { - this.email = ""; - } - - this.id = id; - this.ipAddress = ipAddress; - this.messageSender = messageSender; - this.heartbeat = function () { - this.lastContact = Date.now(); - }; - this.heartbeat(); - - // VarDiff System - this.lastShareTime = Math.floor(Date.now() / 1000); - - this.validShares = 0; - this.invalidShares = 0; - this.hashes = 0; - this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + this.ipAddress + ")"; + // 3d) trust stuff if (global.config.pool.trustedMiners) { if (!(this.payout in walletTrust)) { @@ -514,9 +611,28 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; } - this.validJobs = global.support.circularBuffer(4); - this.sentJobs = global.support.circularBuffer(8); + // 3e) password setup stuff + + let email = this.email; + if (email != "") { + // Need to do an initial registration call here. Might as well do it right... + let payoutAddress = this.payout; + let time_now = Date.now(); + if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { + global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [payoutAddress]).then(function (rows) { + if (rows.length > 0) { + return; + } + if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { + return; + } + global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, email]); + }); + walletLastCheckTime[payoutAddress] = time_now; + } + } + this.validJobs = global.support.circularBuffer(4); this.cachedJob = null; this.invalidShareProto = global.protos.InvalidShare.encode({ @@ -525,6 +641,41 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer identifier: this.identifier }); + this.setAlgos = function(algos, algos_hr) { + if (algos && (algos instanceof Array) && (algos.includes("cn/1") || algos.includes("cryptonight/1"))) { + this.algos = {}; + for (let algo in algos) this.algos[algo] = 1; + } else { + return "algo array should include cn/1 or cryptonight/1"; + } + if (algos_hr && (algos_hr instanceof Object)) { + this.algos_hr = {}; + for (let algo in algos_hr) { + if (algo.includes("heavy")) this.algos_hr["Heavy"] = algos_hr[algo]; + else if (algo.includes("lite")) this.algos_hr["Light"] = algos_hr[algo]; + else this.algos_hr[""] = algos_hr[algo]; + } + if (!this.algos_hr[""]) return "algo_hr set should include non heavy and lite hashrate"; + } else { + return "algo_hr set should be present"; + } + return ""; + }; + + this.selectBestAlgo = function() { + if (!this.algos) return ""; + let algo = ""; + let algo_hr = this.algos_hr[""]; + if ("Heavy" in this.algos_hr && this.algos_hr["Heavy"] * global.config.daemon[algoHashFactor("Heavy")] > algo_hr) { + algo = "Heavy"; + algo_hr = this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)]; + } + if ("Light" in this.algos_hr && this.algos_hr["Light"] * global.config.daemon[algoHashFactor("Light")] > algo_hr) { + algo = "Light"; + } + return algo; + } + this.calcNewDiff = function () { let hashes; let target; @@ -603,10 +754,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (protoVersion === 1) { this.getTargetHex = function () { - if (this.newDiff) { - this.difficulty = this.newDiff; - this.newDiff = null; - } let padded = new Buffer(32); padded.fill(0); let diffBuff = baseDiff.div(this.difficulty).toBuffer(); @@ -619,65 +766,63 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return buffReversed.toString('hex'); }; this.getJob = function () { - - if (this.lastBlockHeight === activeBlockTemplate.height && activeBlockTemplate.idHash === this.validJobs.get(0).blockHash && !this.newDiff && this.cachedJob !== null) { - return this.cachedJob; + const algo = this.selectBestAlgo(); + let bt = activeBlockTemplate[algo]; + if (this.jobLastBlockHash === bt.idHash && !this.newDiff && this.cachedJob !== null) return null; + this.jobLastAlgo = algo; + this.jobLastBlockHash = bt.idHash; + if (this.newDiff) { + this.difficulty = this.newDiff; + this.newDiff = null; } - + const algoHashFactor = algo === "" ? 1.0 : global.config.daemon[algoHashFactor(algo)]; if (!this.proxy) { - let blob = activeBlockTemplate.nextBlob(); + let blob = bt.nextBlob(); let target = this.getTargetHex(); - this.lastBlockHeight = activeBlockTemplate.height; - - let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), - extraNonce: activeBlockTemplate.extraNonce, - height: activeBlockTemplate.height, + blockHash: bt.idHash, + extraNonce: bt.extraNonce, + height: bt.height, difficulty: this.difficulty, diffHex: this.diffHex, - submissions: {}, - blockHash: activeBlockTemplate.idHash + algoHashFactor: algoHashFactor, + submissions: {} }; - this.validJobs.enq(newJob); this.cachedJob = { blob: blob, - algo: global.coinFuncs.algoTypeStr(activeBlockTemplate.port), - variant: global.coinFuncs.variantValue(activeBlockTemplate.port), + algo: global.coinFuncs.algoTypeStr(bt.port), + variant: global.coinFuncs.variantValue(bt.port), job_id: newJob.id, target: target, id: this.id }; } else { - let blob = activeBlockTemplate.nextBlobWithChildNonce(); - if (this.newDiff) { - this.difficulty = this.newDiff; - this.newDiff = null; - } - this.lastBlockHeight = activeBlockTemplate.height; - + let blob = bt.nextBlobWithChildNonce(); let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), - extraNonce: activeBlockTemplate.extraNonce, - height: activeBlockTemplate.height, + blockHash: bt.idHash, + extraNonce: bt.extraNonce, + height: bt.height, difficulty: this.difficulty, diffHex: this.diffHex, - clientPoolLocation: activeBlockTemplate.clientPoolLocation, - clientNonceLocation: activeBlockTemplate.clientNonceLocation, + clientPoolLocation: bt.clientPoolLocation, + clientNonceLocation: bt.clientNonceLocation, + algoHashFactor: algoHashFactor, submissions: {} }; this.validJobs.enq(newJob); this.cachedJob = { blocktemplate_blob: blob, - blob_type: global.coinFuncs.blobTypeStr(activeBlockTemplate.port), - algo: global.coinFuncs.algoTypeStr(activeBlockTemplate.port), - variant: global.coinFuncs.variantValue(activeBlockTemplate.port), - difficulty: activeBlockTemplate.difficulty, - height: activeBlockTemplate.height, - reserved_offset: activeBlockTemplate.reserveOffset, - client_nonce_offset: activeBlockTemplate.clientNonceLocation, - client_pool_offset: activeBlockTemplate.clientPoolLocation, + blob_type: global.coinFuncs.blobTypeStr(bt.port), + algo: global.coinFuncs.algoTypeStr(bt.port), + variant: global.coinFuncs.variantValue(bt.port), + 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, @@ -689,21 +834,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.sendNewJob = function() { let job = this.getJob(); - let tempJob = this.sentJobs.toarray().filter(function (intJob) { - return intJob.id === job.job_id; - })[0]; - - if (tempJob) { - console.error(`Tried sending a duped job to: ${this.address}, stopped by Snipa!`); - return; - } - this.sentJobs.enq(job); + if (job === null) return; return this.messageSender('job', job); }; } } -// store wallet_key (address, paymentID, bitcoin, poolTypeEnum, port) -> worker_name -> shareType -> (height, difficulty, time, acc) +// store wallet_key (address, paymentID, bitcoin, poolTypeEnum, port) -> worker_name -> shareType -> (height, difficulty, time, acc, acc2) let walletAcc = {}; // number of worker_name for wallet_key (so we do not count them by iteration) let walletWorkerCount = {}; @@ -719,11 +856,13 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi let worker = wallet[worker_name]; if (time_now - worker.time > 60*1000) { let acc = worker.acc; + let acc2 = worker.acc2; 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: acc2, paymentAddress: miner_address, paymentID: miner_paymentID, foundBlock: false, @@ -773,13 +912,14 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy 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: shareType, poolType: miner.poolTypeEnum, poolID: global.config.pool_id, - blockDiff: activeBlockTemplate.difficulty, + blockDiff: blockTemplate.difficulty, bitcoin: miner.bitcoin, blockHeight: db_job_height, timestamp: time_now, @@ -799,9 +939,10 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy wallet[worker_name] = {}; let worker = wallet[worker_name]; worker.height = db_job_height; - worker.difficulty = activeBlockTemplate.difficulty; + worker.difficulty = blockTemplate.difficulty; worker.time = time_now; worker.acc = 0; + worker.acc2 = 0; } let worker = wallet[worker_name]; @@ -809,12 +950,14 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy let height = worker.height; let difficulty = worker.difficulty; let acc = worker.acc; + let acc2 = worker.acc2; - if (height !== db_job_height || difficulty !== activeBlockTemplate.difficulty || time_now - worker.time > 60*1000 || acc >= 1000000) { + 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, @@ -831,15 +974,17 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy } worker.height = db_job_height; - worker.difficulty = activeBlockTemplate.difficulty; + worker.difficulty = blockTemplate.difficulty; worker.time = time_now; worker.acc = job.rewarded_difficulty; + worker.acc2 = job.rewarded_difficulty2; } else { - worker.acc += job.rewarded_difficulty; + worker.acc += job.rewarded_difficulty; + worker.acc2 += job.rewarded_difficulty2; } - debug("!!! " + wallet_key + " / " + worker_name + ": accumulating share " + db_job_height + " " + activeBlockTemplate.difficulty + " " + worker.time + " " + worker.acc + " (+" + job.rewarded_difficulty + ")"); + 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) { @@ -880,7 +1025,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 && activeBlockTemplate.height != job.height) { + if (activeBlockTemplate[blockTemplate.algo].idHash !== job.blockHash) { process.send({type: 'outdatedShare'}); } @@ -987,12 +1132,12 @@ 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.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.algo].height + ") from " + miner.logString + ", share type: " + shareType + ", valid: " + isNotifyAdmin + " error: " + JSON.stringify(rpcResult.error)); if (isNotifyAdmin) 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 height " + job.height + " (active block template height: " + activeBlockTemplate.height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + threadName + "Error submitting block at height " + job.height + " (active block template height: " + activeBlockTemplate[blockTemplate.algo].height + ") from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) ); if (global.config.pool.trustedMiners) { debug(threadName + "Share trust broken by " + miner.logString); @@ -1056,7 +1201,6 @@ function get_miner_notification(payout) { } function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { - let miner = activeMiners[params.id]; // Check for ban here, so preconnected attackers can't continue to screw you if (ip in bannedIPs) { // Handle IP ban off clip. @@ -1069,12 +1213,10 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply("No login specified"); return; } - if (!params.pass) { - params.pass = "x"; - } + 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); + let miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-hr"]); let time_now = Date.now(); if (!miner.valid_miner) { if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { @@ -1115,7 +1257,11 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } process.send({type: 'newMiner', data: miner.port}); - activeMiners[minerId] = miner; + if (miner.algos) { + activeSmartMiners[minerId] = miner; + } else { + activeMiners[minerId] = miner; + } if (!miner.proxy) { let proxyMinerName = miner.payout + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { @@ -1140,14 +1286,25 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { }); break; case 'getjob': + let miner = activeSmartMiners[params.id]; + if (!miner) miner = activeMiners[params.id]; if (!miner) { sendReply('Unauthenticated'); return; } miner.heartbeat(); + if (miner.algos && params.algo && params["algo-hr"]) { + const status = miner.setAlgos(params.algo, params["algo-hr"]); + if (status != "") { + sendReply(status); + return; + } + } miner.sendNewJob(); break; case 'submit': + let miner = activeSmartMiners[params.id]; + if (!miner) miner = activeMiners[params.id]; if (!miner) { sendReply('Unauthenticated'); return; @@ -1199,37 +1356,40 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { job.submissions[nonce_test] = 1; } - let blockTemplate = activeBlockTemplate.height === job.height ? activeBlockTemplate : pastBlockTemplates.toarray().filter(function (t) { - return t.height === job.height; - })[0]; - - let is_outdated = false; - + let blockTemplate; job.rewarded_difficulty = job.difficulty; - if (activeBlockTemplate.height != job.height && lastBlockTemplateUpdateTime) { - let late_time = Date.now() - lastBlockTemplateUpdateTime; - if (late_time > 4*1000) { - late_time -= 4*1000; - let 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; - } else { - is_outdated = true; - } - } + if (activeBlockTemplate[miner.jobLastAlgo].idHash !== job.blockHash) { + blockTemplate = pastBlockTemplates.toarray().filter(function (t) { + return t.idHash === job.blockHash; + })[0]; + let is_outdated = false; + if (blockTemplate) { + let late_time = Date.now() - blockTemplate.timeOutdate; + if (late_time > 0) { + let 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; + } else { + is_outdated = true; + } + } + } + if (!blockTemplate || is_outdated) { + let err_str = is_outdated ? "Block outdated" : "Block expired"; + console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); + miner.sendNewJob(); + sendReply(err_str); + global.database.storeInvalidShare(miner.invalidShareProto); + return; + } + } else { + blockTemplate = activeBlockTemplate[miner.jobLastAlgo]; } - if (!blockTemplate || is_outdated) { - let err_str = is_outdated ? "Block outdated" : "Block expired"; - console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); - miner.sendNewJob(); - sendReply(err_str); - global.database.storeInvalidShare(miner.invalidShareProto); - return; - } + job.rewarded_difficulty2 = job.rewarded_difficulty * job.algoHashFactor; let shareAccepted = processShare(miner, job, blockTemplate, params); if (shareAccepted === null) { @@ -1274,6 +1434,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(null, {status: 'OK'}); break; case 'keepalived': + let miner = activeSmartMiners[params.id]; + if (!miner) miner = activeMiners[params.id]; if (!miner) { sendReply('Unauthenticated'); return; @@ -1396,24 +1558,38 @@ if (cluster.isMaster) { if (!global.config.daemon.activePort) { - console.error("global.config.daemon.activePort is not defined, using fixed global.config.daemon.port instead"); + 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 { - setInterval(updateActivePort, 3*1000); + setInterval(updateActivePort, 3*1000, ""); + if (global.config.daemon.activePortHeavy && global.config.daemon.activePortLight) { + setInterval(updateActivePort, 5*1000, "Heavy"); + setInterval(updateActivePort, 5*1000, "Light"); + templateUpdate("Heavy"); + templateUpdate("Light"); + setTimeout(templateUpdate, 50, "Heavy", true); + setTimeout(templateUpdate, 50, "Light", true); + } else { + console.warn("global.config.daemon.activePortHeavy/activePortLight are not defined, so ignoring their algos"); + } } - templateUpdate(); - setTimeout(templateUpdate, 50, true); + 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 { + templateUpdate(""); + if (global.config.daemon.activePortHeavy && global.config.daemon.activePortLight) { + templateUpdate("Heavy"); + templateUpdate("Light"); + } + anchorBlockUpdate(); + setInterval(anchorBlockUpdate, 3*1000); setInterval(checkAliveMiners, 60*1000); setInterval(retargetMiners, global.config.pool.retargetTime * 1000); - templateUpdate(); - anchorBlockUpdate(); setInterval(function () { bannedIPs = {}; }, 60*1000); - setInterval(anchorBlockUpdate, 3*1000); function add_bans(is_show) { global.mysql.query("SELECT mining_address, reason FROM bans").then(function (rows) { diff --git a/lib/support.js b/lib/support.js index 4460b034..73d97782 100644 --- a/lib/support.js +++ b/lib/support.js @@ -173,19 +173,29 @@ function rpc_wallet(host, port, method, params, callback) { return jsonRequest(host, port, data, true, callback); } -function getActivePort(callback) { - global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'activePort'").then(function (rows) { +function getAlgoHashFactor(algo, callback) { + global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'algoHashFactor" + algo + "'").then(function (rows) { if (rows.length != 1) { - console.error("Can't get config.daemon.activePort value"); + console.error("Can't get config.daemon.algoHashFactor" + algo + " 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) { + if (rows.length != 1) { + console.error("Can't get config.daemon.activePort" + algo + " value"); return callback(null); } callback(parseInt(rows[0].item_value)); }); } -function setActivePort(activePort) { - global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'activePort'", [activePort]); - global.config.daemon.activePort = activePort; +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 formatDate(date) { @@ -262,6 +272,7 @@ module.exports = function () { blockCompare: blockCompare, sendEmail: sendEmail, tsCompare: tsCompare, + getAlgoHashFactor: getAlgoHashFactor, getActivePort: getActivePort, setActivePort: setActivePort }; diff --git a/lib/worker.js b/lib/worker.js index 69363cf7..56ba9746 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -44,7 +44,7 @@ function updateShareStats() { let minerSet = {}; 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: {} }; + let localStats = { pplns: 0, pps: 0, solo: 0, prop: 0, global: 0, miners: {}, miners2: {} }; let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; let loopBreakout = 0; @@ -101,21 +101,25 @@ function updateShareStats() { break; } if (minerID in minerSet) { - localStats.miners[minerID] += share.shares; + localStats.miners[minerID] += 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; - localTimes.miners[minerID] = share.timestamp; + localStats.miners[minerID] = share.shares; + localStats.miners2[minerID] = share.shares2; + localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; } if (minerIDWithIdentifier in minerSet) { - localStats.miners[minerIDWithIdentifier] += share.shares; + localStats.miners[minerIDWithIdentifier] += share.shares; + localStats.miners2[minerIDWithIdentifier] += share.shares2; if (localTimes.miners[minerIDWithIdentifier] < share.timestamp) localTimes.miners[minerIDWithIdentifier] = share.timestamp; } else { - localStats.miners[minerIDWithIdentifier] = share.shares; - localTimes.miners[minerIDWithIdentifier] = share.timestamp; + localStats.miners[minerIDWithIdentifier] = share.shares; + localStats.miners2[minerIDWithIdentifier] = share.shares2; + localTimes.miners[minerIDWithIdentifier] = share.timestamp; minerSet[minerIDWithIdentifier] = 1; } }); @@ -188,12 +192,13 @@ function updateShareStats() { } } - stats.hash = Math.floor(localStats.miners[miner] / (hashrate_avg_min*60)) + 1; + 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.lastHash = localTimes.miners[miner]; - cache_updates[keyStats] = { hash: stats.hash, lastHash: stats.lastHash }; + cache_updates[keyStats] = { hash: stats.hash, hash2: stats.hash2, lastHash: stats.lastHash }; if (cycleCount === 0) { - stats.hashHistory.unshift({ts: currentTime, hs: stats.hash}); + 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(); From 829798e2146bb83398f5c7be6442afe0afea8df4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 May 2018 20:01:51 +0200 Subject: [PATCH 0462/2430] Fixed share2 can be undef --- lib/worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 56ba9746..851145a1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -102,23 +102,23 @@ function updateShareStats() { } if (minerID in minerSet) { localStats.miners[minerID] += share.shares; - localStats.miners2[minerID] += share.shares2; + localStats.miners2[minerID] += share.shares2 ? share.shares2 : share.shares; 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] = share.shares2 ? share.shares2 : share.shares; localTimes.miners[minerID] = share.timestamp; minerSet[minerID] = 1; } if (minerIDWithIdentifier in minerSet) { localStats.miners[minerIDWithIdentifier] += share.shares; - localStats.miners2[minerIDWithIdentifier] += share.shares2; + localStats.miners2[minerIDWithIdentifier] += share.shares2 ? share.shares2 : share.shares; 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] = share.shares2 ? share.shares2 : share.shares; localTimes.miners[minerIDWithIdentifier] = share.timestamp; minerSet[minerIDWithIdentifier] = 1; } From f2da58ca5bb50f3c5650221d22602fec881c00a2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 May 2018 21:21:10 +0200 Subject: [PATCH 0463/2430] Applied workaround from https://github.com/monero-project/monero/issues/3724 --- deployment/leaf.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index ea3894fd..b9b531bc 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -24,6 +24,8 @@ sudo git clone 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 git submodule init +sudo git submodule update sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon From a7ec72220973373419160b8158dd1a98769ef2f9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 May 2018 21:22:24 +0200 Subject: [PATCH 0464/2430] Applied workaround from https://github.com/monero-project/monero/issues/3724 --- deployment/leaf.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index ea3894fd..b9b531bc 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -24,6 +24,8 @@ sudo git clone 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 git submodule init +sudo git submodule update sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon From 2f0ed0bcaddb1f484e6f2a7dbd5fae2685f498cc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 May 2018 21:33:19 +0200 Subject: [PATCH 0465/2430] Added SQL setup --- deployment/base.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 0058585e..9ff0779a 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -188,7 +188,11 @@ 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', '18081', 'int', 'Currently Active 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', '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 ('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 e47d86b76b0433deb366c0c8e598f82a622f5584 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 May 2018 21:41:43 +0200 Subject: [PATCH 0466/2430] Removed offending libs --- deployment/leaf.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index b9b531bc..a86ddc22 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 libgtest-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 cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. cd /usr/src/gtest From 7a2fc7d05888d2ef244bfc598b5add58ca5752b6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 May 2018 21:43:21 +0200 Subject: [PATCH 0467/2430] Removed offending libs --- deployment/leaf.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index b9b531bc..a86ddc22 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 libgtest-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 cd ~ git clone https://github.com/MoneroOcean/nodejs-pool.git # Change this depending on how the deployment goes. cd /usr/src/gtest From 8c52d4e8181a25993a1f827ec3b4eec56cb58584 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 09:58:23 +0200 Subject: [PATCH 0468/2430] Fixed intense 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 480d765f..40260999 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -139,7 +139,7 @@ function Coin(data){ this.portBlobType = function(port) { switch (port) { - case 48782: return 2; // ITNS + case 48782: return 0; // ITNS case 38081: return 3; // MSR default: return 0; } @@ -218,7 +218,7 @@ function Coin(data){ this.blobTypeStr = function(port) { switch (port) { - case 48782: return "forknote2"; // ITNS + case 48782: return "cryptonote"; // ITNS case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } From 4e98bfebd1c8e02d8f4236ac73e1e3a8fabc7393 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 10:14:03 +0200 Subject: [PATCH 0469/2430] Fixed intense 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 7f3f78b0..3d5201bc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -139,7 +139,7 @@ function Coin(data){ this.portBlobType = function(port) { switch (port) { - case 48782: return 2; // ITNS + case 48782: return 0; // ITNS case 38081: return 3; // MSR default: return 0; } @@ -220,7 +220,7 @@ function Coin(data){ this.blobTypeStr = function(port) { switch (port) { - case 48782: return "forknote2"; // ITNS + case 48782: return "cryptonote"; // ITNS case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } From 3ae34202e87157b285948713edf2133ac436664e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 10:46:27 +0200 Subject: [PATCH 0470/2430] Added message throttling for outdated/expired shares --- lib/pool.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e62451ee..4f9934d9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1379,7 +1379,11 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { } if (!blockTemplate || is_outdated) { let err_str = is_outdated ? "Block outdated" : "Block expired"; - console.warn(threadName + err_str + ', Height: ' + job.height + ' (diff ' + job.difficulty + ') from ' + miner.logString); + let 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; + } miner.sendNewJob(); sendReply(err_str); global.database.storeInvalidShare(miner.invalidShareProto); From df93ce03e56a207f7f52ed7eb1ad1ee73878ffa2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 11:19:04 +0200 Subject: [PATCH 0471/2430] Fixed monerod install --- deployment/deploy.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 6af6a351..dab2d32e 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 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 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 @@ -28,6 +28,8 @@ sudo git clone 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 git submodule init +sudo git submodule update sudo make -j$(nproc) sudo cp ~/nodejs-pool/deployment/monero.service /lib/systemd/system/ sudo useradd -m monerodaemon -d /home/monerodaemon From 2f30686b5efc8a7edf6c88731f0e8ed2be5bb92c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 21:39:24 +0200 Subject: [PATCH 0472/2430] Fixed extra message for active port update --- lib/pool.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4f9934d9..7a4d0cc5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -249,8 +249,9 @@ function checkAliveMiners() { // global.config.daemon[activePortAlgo(algo)] is only updated in master thread function updateActivePort(algo) { global.support.getActivePort(algo, function (newActivePort) { + const oldActivePort = global.config.daemon[activePortAlgo(algo)]; if (newActivePort === null) { - if (algo === "" && global.config.daemon.activePort !== global.config.daemon.port) { + if (algo === "" && 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 { @@ -266,14 +267,14 @@ function updateActivePort(algo) { } else { if (newAlgoHashFactor == 0) debug("Got zero " + algoHashFactor(algo)); global.config.daemon[algoHashFactor(algo)] = newAlgoHashFactor; - if (global.config.daemon[activePortAlgo(algo)] !== newActivePort) { - console.log("Changing " + activePortAlgo(algo) + " from " + global.config.daemon[activePortAlgo(algo)] + " to " + newActivePort); + if (oldActivePort !== newActivePort) { + console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); global.config.daemon[activePortAlgo(algo)] = newActivePort; } } }); - } else { - console.log("Changing " + activePortAlgo(algo) + " from " + global.config.daemon[activePortAlgo(algo)] + " to " + newActivePort); + } else if (oldActivePort !== newActivePort) { + console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); global.config.daemon[activePortAlgo(algo)] = newActivePort; } } From 2ae7fd6cfa4457f9f66c05a9eabcf264775a92b7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 21:52:41 +0200 Subject: [PATCH 0473/2430] Fixed block template guards --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7a4d0cc5..07b5fd82 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1466,8 +1466,8 @@ if (cluster.isMaster) { registerPool(); setInterval(function () { - if (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 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]); } else { global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]); } @@ -1478,12 +1478,12 @@ if (cluster.isMaster) { setInterval(function () { - if (!activeBlockTemplate) return; + if (!("" in activeBlockTemplate)) 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 = activeBlockTemplate[""].port; + const height = activeBlockTemplate[""].height; rows.forEach(function (row) { if (row.port != port) return; if (row.blockID > top_height) top_height = row.blockID; From 73e2045f3d703adaec82ab03ac18fb92059fec2d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 21:57:45 +0200 Subject: [PATCH 0474/2430] Typo fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 07b5fd82..1387626a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -396,7 +396,7 @@ function setNewBlockTemplate(template) { return; } if (!(algo in pastBlockTemplates)) pastBlockTemplates[algo] = global.support.circularBuffer(4); - activeBlockTemplace[algo].timeOutdate = Date.now() + 4*1000; + activeBlockTemplate[algo].timeOutdate = Date.now() + 4*1000; pastBlockTemplates[algo].enq(activeBlockTemplate[algo]); if (activeBlockTemplate[algo].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } From c8fdc5d99308ee905caebec76ef1619706d0d4c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 14 May 2018 22:20:04 +0200 Subject: [PATCH 0475/2430] Set BT for master thread --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 1387626a..19557077 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -296,6 +296,7 @@ function templateUpdateReal(algo, activePort, algoHashFactor) { debug(threadName + "New block template found at " + rpcResponse.height + " height"); if (cluster.isMaster) { sendToWorkers({type: 'newBlockTemplate', data: rpcResponse}); + setNewBlockTemplate(rpcResponse); } else { setNewBlockTemplate(rpcResponse); } @@ -312,6 +313,7 @@ function algoHashFactorUpdate(algo, algoHashFactor) { if (cluster.isMaster) { let data = { algo: algo, algoHashFactor: algoHashFactor }; sendToWorkers({type: 'newAlgoHashFactor', data: data}); + setNewAlgoHashFactor(algo, algoHashFactor); } else { setNewAlgoHashFactor(algo, algoHashFactor); } From 38cf752dbe1e103ace152ffa60eb1e24461af673 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 08:57:58 +0200 Subject: [PATCH 0476/2430] Reduced timeout for daemon BT comms --- lib/support.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/support.js b/lib/support.js index 73d97782..95cdb16a 100644 --- a/lib/support.js +++ b/lib/support.js @@ -104,8 +104,9 @@ function sendEmail(toAddress, subject, body, wallet){ } } -function jsonRequest(host, port, data, is_wallet, callback, path) { +function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { path = path || 'json_rpc'; + timeout = timeout || 5*60*1000; let uri; if (global.config.rpc.https) { uri = "https://" + host + ":" + port + "/"; @@ -113,7 +114,7 @@ function jsonRequest(host, port, data, is_wallet, callback, path) { uri = "http://" + host + ":" + port + "/"; } debug("JSON URI: " + uri + path + " Args: " + JSON.stringify(data)); - let client = requestJson.createClient(uri, {timeout: 5*60*1000}); + let client = requestJson.createClient(uri, {timeout: timeout}); client.headers["Content-Type"] = "application/json"; client.headers["Content-Length"] = data.length; client.headers["Accept"] = "application/json"; @@ -151,15 +152,14 @@ function jsonRequest(host, port, data, is_wallet, callback, path) { } } -function rpc(host, port, method, params, callback) { - +function rpc(host, port, method, params, callback, timeout) { let data = { id: "0", jsonrpc: "2.0", method: method, params: params }; - return jsonRequest(host, port, data, false, callback); + return jsonRequest(host, port, data, false, callback, timeout); } function rpc_wallet(host, port, method, params, callback) { @@ -250,10 +250,10 @@ function tsCompare(a, b) { module.exports = function () { return { rpcDaemon: function (method, params, callback) { - rpc(global.config.daemon.address, global.config.daemon.port, method, params, callback); + rpc(global.config.daemon.address, global.config.daemon.port, method, params, callback, 2*1000); }, rpcPortDaemon: function (port, method, params, callback) { - rpc(global.config.daemon.address, port, method, params, callback); + rpc(global.config.daemon.address, port, method, params, callback, 2*1000); }, rpcWallet: function (method, params, callback) { rpc_wallet(global.config.wallet.address, global.config.wallet.port, method, params, callback); From c9045f2d6ef0ebb4e1cc1f966c07f6b35806b86b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 08:58:58 +0200 Subject: [PATCH 0477/2430] Added basic WOW support --- deployment/base.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/base.sql b/deployment/base.sql index 9ff0779a..c0424c7e 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -231,6 +231,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_18981', '', 'string', 'Address to mine to for 18981 (GRFT) port.'); 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 ('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'); From 66d66867ff07f382076c082d2a75b034fe8bf928 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 08:59:25 +0200 Subject: [PATCH 0478/2430] Simplified ITNS support --- lib/coins/xmr.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3d5201bc..d0244887 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -139,7 +139,6 @@ function Coin(data){ this.portBlobType = function(port) { switch (port) { - case 48782: return 0; // ITNS case 38081: return 3; // MSR default: return 0; } @@ -220,7 +219,6 @@ function Coin(data){ this.blobTypeStr = function(port) { switch (port) { - case 48782: return "cryptonote"; // ITNS case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } From 57fea7bb83a5b919936af58cc080823fe26dd84b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 09:04:32 +0200 Subject: [PATCH 0479/2430] Fixed RPC --- lib/support.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/support.js b/lib/support.js index 95cdb16a..26bfa3fa 100644 --- a/lib/support.js +++ b/lib/support.js @@ -105,8 +105,6 @@ function sendEmail(toAddress, subject, body, wallet){ } function jsonRequest(host, port, data, is_wallet, callback, path, timeout) { - path = path || 'json_rpc'; - timeout = timeout || 5*60*1000; let uri; if (global.config.rpc.https) { uri = "https://" + host + ":" + port + "/"; @@ -159,18 +157,17 @@ function rpc(host, port, method, params, callback, timeout) { method: method, params: params }; - return jsonRequest(host, port, data, false, callback, timeout); + return jsonRequest(host, port, data, false, callback, 'json_rpc', timeout); } function rpc_wallet(host, port, method, params, callback) { - let data = { id: "0", jsonrpc: "2.0", method: method, params: params }; - return jsonRequest(host, port, data, true, callback); + return jsonRequest(host, port, data, true, callback, 'json_rpc', 10*60*1000); } function getAlgoHashFactor(algo, callback) { @@ -261,7 +258,6 @@ module.exports = function () { rpcPortWallet: function (port, method, params, callback) { rpc_wallet(global.config.wallet.address, port, method, params, callback); }, - jsonRequest: jsonRequest, circularBuffer: circularBuffer, formatDate: formatDate, coinToDecimal: coinToDecimal, From f0a4d16bb96b6a740d4c1d3d26223bc158394626 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 09:19:32 +0200 Subject: [PATCH 0480/2430] Added more intellegent BT port failure handling --- lib/pool.js | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 19557077..75744de7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -16,15 +16,21 @@ let bannedIPs = {}; let bannedAddresses = {}; let notifyAddresses = {}; let baseDiff = global.coinFuncs.baseDiff(); + let activeMiners = {}; let activeSmartMiners = {}; // miners with algos/algos-hr + let lastBlockHash = {}; // algo key let lastAlgoHashFactor = {}; // algo key let activeBlockTemplate = {}; // algo key let pastBlockTemplates = {}; // algo key + +let lastPortErrorTime = {}; // main algo 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 + let workerList = []; let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMining Pool Online'; let threadName; @@ -274,8 +280,12 @@ function updateActivePort(algo) { } }); } else if (oldActivePort !== newActivePort) { - console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); - global.config.daemon[activePortAlgo(algo)] = newActivePort; + if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*1000) { + console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); + global.config.daemon[activePortAlgo(algo)] = newActivePort; + } else { + console.warn("Avoiding changing recently problem " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); + } } } }); @@ -301,8 +311,16 @@ function templateUpdateReal(algo, activePort, algoHashFactor) { setNewBlockTemplate(rpcResponse); } } else { - console.error("Block template request failed for " + activePort + " port"); - algoHashFactorUpdate(algo, 0); + console.error("Block template request failed for " + activePort + " port."); + if (algo === "") { + if (global.config.daemon.activePort != global.config.daemon.port) { + console.warn("Returning to " + global.config.daemon.port + " port."); + lastPortErrorTime[global.config.daemon.activePort] = Date.now(); + global.config.daemon.activePort = global.config.daemon.port; + } + } else { + algoHashFactorUpdate(algo, 0); + } setTimeout(templateUpdateReal, 3000, algo, activePort); } }); @@ -343,7 +361,15 @@ function templateUpdate(algo, repeating) { if (repeating === true) setTimeout(templateUpdate, 50, algo, repeating); } else { console.error("Last block header request for " + global.config.daemon[activePortAlgo(algo)] + " port failed!"); - algoHashFactorUpdate(algo, 0); + if (algo === "") { + if (global.config.daemon.activePort != global.config.daemon.port) { + console.warn("Returning to " + global.config.daemon.port + " port."); + lastPortErrorTime[global.config.daemon.activePort] = Date.now(); + global.config.daemon.activePort = global.config.daemon.port; + } + } else { + algoHashFactorUpdate(algo, 0); + } setTimeout(templateUpdate, 1000, algo, repeating); } }); From 915571df071988bafd88d0591607634a23c09438 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 09:24:02 +0200 Subject: [PATCH 0481/2430] Morereliable port checks --- lib/pool.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 75744de7..4dc2bea7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -257,7 +257,7 @@ function updateActivePort(algo) { global.support.getActivePort(algo, function (newActivePort) { const oldActivePort = global.config.daemon[activePortAlgo(algo)]; if (newActivePort === null) { - if (algo === "" && oldActivePort !== global.config.daemon.port) { + if (algo === "" && 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 { @@ -313,7 +313,7 @@ function templateUpdateReal(algo, activePort, algoHashFactor) { } else { console.error("Block template request failed for " + activePort + " port."); if (algo === "") { - if (global.config.daemon.activePort != global.config.daemon.port) { + if (activePort != global.config.daemon.port) { console.warn("Returning to " + global.config.daemon.port + " port."); lastPortErrorTime[global.config.daemon.activePort] = Date.now(); global.config.daemon.activePort = global.config.daemon.port; @@ -362,7 +362,7 @@ function templateUpdate(algo, repeating) { } else { console.error("Last block header request for " + global.config.daemon[activePortAlgo(algo)] + " port failed!"); if (algo === "") { - if (global.config.daemon.activePort != global.config.daemon.port) { + if (activePort != global.config.daemon.port) { console.warn("Returning to " + global.config.daemon.port + " port."); lastPortErrorTime[global.config.daemon.activePort] = Date.now(); global.config.daemon.activePort = global.config.daemon.port; @@ -383,7 +383,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 activeBlockTemplate) && global.config.daemon.port == activeBlockTemplate[""].port) return; // only need to do that separately if we mine alt chain global.coinFuncs.getLastBlockHeader(function (err, body) { if (err === null) { @@ -437,7 +437,7 @@ function setNewBlockTemplate(template) { activeBlockTemplate[algo] = new BlockTemplate(template); const height = activeBlockTemplate[algo].height; - if (algo === "" && global.config.daemon.port === activeBlockTemplate[""].port) { + if (algo === "" && global.config.daemon.port == activeBlockTemplate[""].port) { anchorBlockHeight = height; } @@ -935,7 +935,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy 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 ? job.height : anchorBlockHeight; if (job.difficulty >= 1000000 || blockCandidate) { @@ -1022,7 +1022,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy } if (blockCandidate) { - if (global.config.daemon.port === blockTemplate.port) { + if (global.config.daemon.port == blockTemplate.port) { global.database.storeBlock(job.height, global.protos.Block.encode({ hash: hashHex, difficulty: blockTemplate.difficulty, From d67cda66f72485cd694f077b66f88c9e55aaea68 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 10:02:51 +0200 Subject: [PATCH 0482/2430] Increased penalty of bad port --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4dc2bea7..dac15450 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,7 +280,7 @@ function updateActivePort(algo) { } }); } else if (oldActivePort !== newActivePort) { - if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*1000) { + if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*60*1000) { console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); global.config.daemon[activePortAlgo(algo)] = newActivePort; } else { From b55712fe4b58a6a2cbdd4e0a87204ef878c1a966 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 10:07:32 +0200 Subject: [PATCH 0483/2430] Added problem port email --- lib/pool.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index dac15450..b7639a2d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -291,6 +291,17 @@ function updateActivePort(algo) { }); } + +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.", + "Block template request failed for " + port + " port. Returning to " + global.config.daemon.port + " port." + ); +} + // templateUpdateReal is only called in master thread (except the beginning of a worker thread) function templateUpdateReal(algo, activePort, algoHashFactor) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { @@ -313,11 +324,7 @@ function templateUpdateReal(algo, activePort, algoHashFactor) { } else { console.error("Block template request failed for " + activePort + " port."); if (algo === "") { - if (activePort != global.config.daemon.port) { - console.warn("Returning to " + global.config.daemon.port + " port."); - lastPortErrorTime[global.config.daemon.activePort] = Date.now(); - global.config.daemon.activePort = global.config.daemon.port; - } + if (activePort != global.config.daemon.port) setProblemPort(activePort); } else { algoHashFactorUpdate(algo, 0); } @@ -362,11 +369,7 @@ function templateUpdate(algo, repeating) { } else { console.error("Last block header request for " + global.config.daemon[activePortAlgo(algo)] + " port failed!"); if (algo === "") { - if (activePort != global.config.daemon.port) { - console.warn("Returning to " + global.config.daemon.port + " port."); - lastPortErrorTime[global.config.daemon.activePort] = Date.now(); - global.config.daemon.activePort = global.config.daemon.port; - } + if (activePort != global.config.daemon.port) setProblemPort(activePort); } else { algoHashFactorUpdate(algo, 0); } From 3bc26c30d6e2dfb2c3042db3d80325df15dabb98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 10:29:27 +0200 Subject: [PATCH 0484/2430] Reduce bad port spam --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b7639a2d..0f5e96ee 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -283,7 +283,7 @@ function updateActivePort(algo) { if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*60*1000) { console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); global.config.daemon[activePortAlgo(algo)] = newActivePort; - } else { + } else if ((Date.now() - lastPortErrorTime[newActivePort]) % 60*1000 < 6*1000) { // print every 10th message console.warn("Avoiding changing recently problem " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); } } From 227f9ef4c41c6c5b4044b3d5ab4fb184930e8a43 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 11:23:52 +0200 Subject: [PATCH 0485/2430] Adjusted email message and add WOW donate address --- README.md | 1 + lib/pool.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 278335b7..ebb49fd3 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,7 @@ If you'd like to make a one time donation, the addresses are as follows: * GRFT - ```GACadqdXj5eNLnyNxvQ56wcmsmVCFLkHQKgtaQXNEE5zjMDJkWcMVju2aYtxbTnZgBboWYmHovuiH1Ahm4g2N5a7LuMQrpT``` * MSR - ```5hnMXUKArLDRue5tWsNpbmGLsLQibt23MEsV3VGwY6MGStYwfTqHkff4BgvziprTitbcDYYpFXw2rEgXeipsABTtEmcmnCK``` * ITNS - ```iz53aMEaKJ25zB8xku3FQK5VVvmu2v6DENnbGHRmn659jfrGWBH1beqAzEVYaKhTyMZcxLJAdaCW3Kof1DwTiTbp1DSqLae3e``` +* WOW - ```Wo3yjV8UkwvbJDCB1Jy7vvXv3aaQu3K8YMG6tbY3Jo2KApfyf5RByZiBXy95bzmoR3AvPgNq6rHzm98LoHTkzjiA2dY7sqQMJ``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/lib/pool.js b/lib/pool.js index 0f5e96ee..19dec65d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -298,7 +298,8 @@ function setProblemPort(port) { global.config.daemon.activePort = global.config.daemon.port; global.support.sendEmail(global.config.general.adminEmail, "FYI: Block template request failed for " + port + " port.", - "Block template request failed for " + port + " port. Returning to " + global.config.daemon.port + " port." + "On pool server " + global.config.hostname + " block template request failed for " + port + " port.\n" + + "Returning to " + global.config.daemon.port + " port." ); } From c9989dfdd1ab9a83be08636452e3a2fb96b08142 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 11:26:53 +0200 Subject: [PATCH 0486/2430] Fixed miner decl --- lib/pool.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 19dec65d..1738224e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1240,6 +1240,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply("IP Address currently banned"); return; } + let miner; switch (method) { case 'login': if (!params.login) { @@ -1249,7 +1250,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { if (!params.pass) params.pass = "x"; let difficulty = portData.difficulty; let minerId = uuidV4(); - let miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-hr"]); + miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-hr"]); let time_now = Date.now(); if (!miner.valid_miner) { if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { @@ -1319,7 +1320,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { }); break; case 'getjob': - let miner = activeSmartMiners[params.id]; + miner = activeSmartMiners[params.id]; if (!miner) miner = activeMiners[params.id]; if (!miner) { sendReply('Unauthenticated'); @@ -1336,7 +1337,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { miner.sendNewJob(); break; case 'submit': - let miner = activeSmartMiners[params.id]; + miner = activeSmartMiners[params.id]; if (!miner) miner = activeMiners[params.id]; if (!miner) { sendReply('Unauthenticated'); @@ -1471,7 +1472,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { sendReply(null, {status: 'OK'}); break; case 'keepalived': - let miner = activeSmartMiners[params.id]; + miner = activeSmartMiners[params.id]; if (!miner) miner = activeMiners[params.id]; if (!miner) { sendReply('Unauthenticated'); From 185fb2c6553f5e498dff88455c79dfb5c6914859 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 11:35:00 +0200 Subject: [PATCH 0487/2430] Added set password log message --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 1738224e..46a9b30e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -660,6 +660,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return; } global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, email]); + console.log("Setting password " + email + " for " + payoutAddress); }); walletLastCheckTime[payoutAddress] = time_now; } From e784df425fde78450ca6ea88e5a3cc0959c96d7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 11:56:53 +0200 Subject: [PATCH 0488/2430] Condensed code little bit --- lib/pool.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 46a9b30e..ecc1899d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -653,12 +653,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let time_now = Date.now(); if (!(payoutAddress in walletLastCheckTime) || time_now - walletLastCheckTime[payoutAddress] > 60*1000) { global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [payoutAddress]).then(function (rows) { - if (rows.length > 0) { - return; - } - if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) { - return; - } + if (rows.length > 0) return; + if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) return; global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, email]); console.log("Setting password " + email + " for " + payoutAddress); }); From 1d5f2e9c4ed8c6328e0d918c2fb39c4ecd90bde4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 12:39:00 +0200 Subject: [PATCH 0489/2430] Added share distribution stats --- lib/blockManager.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 024d74ab..3e602142 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -277,6 +277,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }; async.doWhilst(function (callback) { + let portShares = {}; 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()) { @@ -315,11 +316,25 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un 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(); + + let sumAllPorts = 0; + for (let port in portShares) sumAllPorts += portShares[port]; + for (let port in portShares) { + console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); + } + setImmediate(callback, null, totalPaid); }, function (totalPayment) { blockCheckHeight = blockCheckHeight - 1; From 15dcda85271b6a00f6acd8aa98010ab04f3cb5db Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 12:40:45 +0200 Subject: [PATCH 0490/2430] Added share distribution stats --- lib/blockManager.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 16547907..1eb2093a 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -277,6 +277,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }; async.doWhilst(function (callback) { + let portShares = {}; 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()) { @@ -315,11 +316,26 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un 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(); + + let sumAllPorts = 0; + for (let port in portShares) sumAllPorts += portShares[port]; + for (let port in portShares) { + console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); + } + setImmediate(callback, null, totalPaid); }, function (totalPayment) { blockCheckHeight = blockCheckHeight - 1; From 405b2931b68121011fd2d1865102b3cc034c9779 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 13:33:32 +0200 Subject: [PATCH 0491/2430] Fixed pay port stats --- lib/blockManager.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1eb2093a..c68bf952 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -276,8 +276,9 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un } }; + let portShares = {}; + async.doWhilst(function (callback) { - let portShares = {}; 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()) { @@ -329,13 +330,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un } cursor.close(); txn.abort(); - - let sumAllPorts = 0; - for (let port in portShares) sumAllPorts += portShares[port]; - for (let port in portShares) { - console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); - } - setImmediate(callback, null, totalPaid); }, function (totalPayment) { blockCheckHeight = blockCheckHeight - 1; @@ -348,6 +342,11 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un return blockCheckHeight !== 0; } }, function (err) { + let sumAllPorts = 0; + for (let port in portShares) sumAllPorts += portShares[port]; + for (let port in portShares) { + console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); + } let totalPayments = 0; Object.keys(paymentData).forEach(function (key) { paymentData[key].amount = Math.floor((paymentData[key].amount / (blockDiff*global.config.pplns.shareMulti)) * rewardTotal); From fb6fe2e412943a4fac5e20fdf531a1ec2b42408e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 14:15:25 +0200 Subject: [PATCH 0492/2430] Fixed pay port stats --- lib/blockManager.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 3e602142..7841fd8e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -276,8 +276,9 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un } }; + let portShares = {}; + async.doWhilst(function (callback) { - let portShares = {}; 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()) { @@ -328,13 +329,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un } cursor.close(); txn.abort(); - - let sumAllPorts = 0; - for (let port in portShares) sumAllPorts += portShares[port]; - for (let port in portShares) { - console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); - } - setImmediate(callback, null, totalPaid); }, function (totalPayment) { blockCheckHeight = blockCheckHeight - 1; @@ -347,6 +341,11 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un return blockCheckHeight !== 0; } }, function (err) { + let sumAllPorts = 0; + for (let port in portShares) sumAllPorts += portShares[port]; + for (let port in portShares) { + console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); + } let totalPayments = 0; Object.keys(paymentData).forEach(function (key) { paymentData[key].amount = Math.floor((paymentData[key].amount / (blockDiff*global.config.pplns.shareMulti)) * rewardTotal); From a270617e6351f80c6bd2f68b0faa24741e7aee83 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 18:38:57 +0200 Subject: [PATCH 0493/2430] Improved best coin selection and debug stuff --- lib/coins/xmr.js | 11 ++++++++++- lib/pool.js | 37 ++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index d0244887..3e5d9be5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -225,7 +225,16 @@ function Coin(data){ } this.algoTypeStr = function(port) { - return "cryptonight/1"; + switch (port) { + default: return "cryptonight/1"; + } + } + + this.algoShortTypeStr = function(port) { + switch (port) { + case 38081: return "cn-heavy"; // MSR // !!! FOR DEBUGGING PURPOSES ONLY + default: return "cn/1"; + } } this.variantValue = function(port) { diff --git a/lib/pool.js b/lib/pool.js index ecc1899d..5576ea61 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -78,6 +78,7 @@ if (cluster.isMaster) { global.database.thread_id = threadName; // algo can be "", "Heavy", "Light" +const ALGOS = [ "Heavy", "Light" ]; function algoHashFactor(algo) { return "algoHashFactor" + algo; } function activePortAlgo(algo) { return "activePort" + algo; } @@ -560,6 +561,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return; } + algos = [ "cn/1", "cn-heavy" ]; // !!! FOR DEBUGGING PURPOSES ONLY + algos_hr = { "cn/1": 1000, "cn-heavy": 700 }; // !!! FOR DEBUGGING PURPOSES ONLY + if (algos && algos_hr) { const status = this.setAlgos(algos, algos_hr); if (status != "") { @@ -694,16 +698,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestAlgo = function() { if (!this.algos) return ""; - let algo = ""; - let algo_hr = this.algos_hr[""]; - if ("Heavy" in this.algos_hr && this.algos_hr["Heavy"] * global.config.daemon[algoHashFactor("Heavy")] > algo_hr) { - algo = "Heavy"; - algo_hr = this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)]; - } - if ("Light" in this.algos_hr && this.algos_hr["Light"] * global.config.daemon[algoHashFactor("Light")] > algo_hr) { - algo = "Light"; + let best_algo = ""; + let best_algo_hr = this.algos_hr[""]; + for (let algo in ALGOS) { + if (!(global.coinFuncs.algoTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) continue; + if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) continue; + if (algo in this.algos_hr && this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)] > best_algo_hr) { + best_algo = algo; + best_algo_hr = this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)]; + } } - return algo; + return best_algo; } this.calcNewDiff = function () { @@ -1598,12 +1603,11 @@ if (cluster.isMaster) { } else { setInterval(updateActivePort, 3*1000, ""); if (global.config.daemon.activePortHeavy && global.config.daemon.activePortLight) { - setInterval(updateActivePort, 5*1000, "Heavy"); - setInterval(updateActivePort, 5*1000, "Light"); - templateUpdate("Heavy"); - templateUpdate("Light"); - setTimeout(templateUpdate, 50, "Heavy", true); - setTimeout(templateUpdate, 50, "Light", true); + for (let algo in ALGOS) { + setInterval(updateActivePort, 5*1000, algo); + templateUpdate(algo); + setTimeout(templateUpdate, 50, algo, true); + } } else { console.warn("global.config.daemon.activePortHeavy/activePortLight are not defined, so ignoring their algos"); } @@ -1615,8 +1619,7 @@ if (cluster.isMaster) { } else { templateUpdate(""); if (global.config.daemon.activePortHeavy && global.config.daemon.activePortLight) { - templateUpdate("Heavy"); - templateUpdate("Light"); + for (let algo in ALGOS) templateUpdate(algo); } anchorBlockUpdate(); setInterval(anchorBlockUpdate, 3*1000); From 93bb4310740fc6eb8c4107f678dfd37b6f9899a3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 May 2018 19:01:39 +0200 Subject: [PATCH 0494/2430] Moved setAlgos func --- lib/pool.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5576ea61..1731e24e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -564,6 +564,27 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer algos = [ "cn/1", "cn-heavy" ]; // !!! FOR DEBUGGING PURPOSES ONLY algos_hr = { "cn/1": 1000, "cn-heavy": 700 }; // !!! FOR DEBUGGING PURPOSES ONLY + this.setAlgos = function(algos, algos_hr) { + if (algos && (algos instanceof Array) && (algos.includes("cn/1") || algos.includes("cryptonight/1"))) { + this.algos = {}; + for (let algo in algos) this.algos[algo] = 1; + } else { + return "algo array should include cn/1 or cryptonight/1"; + } + if (algos_hr && (algos_hr instanceof Object)) { + this.algos_hr = {}; + for (let algo in algos_hr) { + if (algo.includes("heavy")) this.algos_hr["Heavy"] = algos_hr[algo]; + else if (algo.includes("lite")) this.algos_hr["Light"] = algos_hr[algo]; + else this.algos_hr[""] = algos_hr[algo]; + } + if (!this.algos_hr[""]) return "algo_hr set should include non heavy and lite hashrate"; + } else { + return "algo_hr set should be present"; + } + return ""; + }; + if (algos && algos_hr) { const status = this.setAlgos(algos, algos_hr); if (status != "") { @@ -675,27 +696,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer identifier: this.identifier }); - this.setAlgos = function(algos, algos_hr) { - if (algos && (algos instanceof Array) && (algos.includes("cn/1") || algos.includes("cryptonight/1"))) { - this.algos = {}; - for (let algo in algos) this.algos[algo] = 1; - } else { - return "algo array should include cn/1 or cryptonight/1"; - } - if (algos_hr && (algos_hr instanceof Object)) { - this.algos_hr = {}; - for (let algo in algos_hr) { - if (algo.includes("heavy")) this.algos_hr["Heavy"] = algos_hr[algo]; - else if (algo.includes("lite")) this.algos_hr["Light"] = algos_hr[algo]; - else this.algos_hr[""] = algos_hr[algo]; - } - if (!this.algos_hr[""]) return "algo_hr set should include non heavy and lite hashrate"; - } else { - return "algo_hr set should be present"; - } - return ""; - }; - this.selectBestAlgo = function() { if (!this.algos) return ""; let best_algo = ""; From 513aa23961b71f6063d1f8f9411463290e95fc49 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 16 May 2018 09:28:59 +0200 Subject: [PATCH 0495/2430] Improved other algo handling --- lib/pool.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1731e24e..20ec614a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -281,6 +281,7 @@ function updateActivePort(algo) { } }); } else if (oldActivePort !== newActivePort) { + if (newActivePort != 38081 || newActivePort != 18081) return; // !!! FOR DEBUGGING PURPOSES ONLY if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*60*1000) { console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); global.config.daemon[activePortAlgo(algo)] = newActivePort; @@ -1602,14 +1603,14 @@ if (cluster.isMaster) { global.config.daemon.activePort = global.config.daemon.port; } else { setInterval(updateActivePort, 3*1000, ""); - if (global.config.daemon.activePortHeavy && global.config.daemon.activePortLight) { - for (let algo in ALGOS) { + for (let algo in ALGOS) { + if (global.config.daemon[activePortAlgo(algo)]) { setInterval(updateActivePort, 5*1000, algo); templateUpdate(algo); setTimeout(templateUpdate, 50, algo, true); + } else { + console.warn("global.config.daemon." + activePortAlgo(algo) + " is not defined, so ignoring its algo changes"); } - } else { - console.warn("global.config.daemon.activePortHeavy/activePortLight are not defined, so ignoring their algos"); } } From 5ed375b5764012799a1ebe4f27585d78b9a2e6c2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 16 May 2018 11:43:32 +0200 Subject: [PATCH 0496/2430] Fixed past block tempalte handling --- lib/pool.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 20ec614a..8f9dda19 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -23,7 +23,8 @@ let activeSmartMiners = {}; // miners with algos/algos-hr let lastBlockHash = {}; // algo key let lastAlgoHashFactor = {}; // algo key let activeBlockTemplate = {}; // algo key -let pastBlockTemplates = {}; // algo key + +let pastBlockTemplates = global.support.circularBuffer(10); let lastPortErrorTime = {}; // main algo port @@ -429,9 +430,8 @@ function setNewBlockTemplate(template) { console.log(threadName + 'Ignoring duplicate block template update at height: ' + template.height + '. Difficulty: ' + template.difficulty); return; } - if (!(algo in pastBlockTemplates)) pastBlockTemplates[algo] = global.support.circularBuffer(4); activeBlockTemplate[algo].timeOutdate = Date.now() + 4*1000; - pastBlockTemplates[algo].enq(activeBlockTemplate[algo]); + pastBlockTemplates.enq(activeBlockTemplate[algo]); if (activeBlockTemplate[algo].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { @@ -805,7 +805,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const algo = this.selectBestAlgo(); let bt = activeBlockTemplate[algo]; if (this.jobLastBlockHash === bt.idHash && !this.newDiff && this.cachedJob !== null) return null; - this.jobLastAlgo = algo; this.jobLastBlockHash = bt.idHash; if (this.newDiff) { this.difficulty = this.newDiff; @@ -817,6 +816,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let target = this.getTargetHex(); let newJob = { id: crypto.pseudoRandomBytes(21).toString('base64'), + algo_type: algo, blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, @@ -838,6 +838,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, blockHash: bt.idHash, extraNonce: bt.extraNonce, height: bt.height, @@ -1396,7 +1397,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { let blockTemplate; job.rewarded_difficulty = job.difficulty; - if (activeBlockTemplate[miner.jobLastAlgo].idHash !== job.blockHash) { + if (activeBlockTemplate[job.algo_type].idHash !== job.blockHash) { blockTemplate = pastBlockTemplates.toarray().filter(function (t) { return t.idHash === job.blockHash; })[0]; @@ -1427,7 +1428,7 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } } else { - blockTemplate = activeBlockTemplate[miner.jobLastAlgo]; + blockTemplate = activeBlockTemplate[job.algo_type]; } job.rewarded_difficulty2 = job.rewarded_difficulty * job.algoHashFactor; From a9470036ab7efe1c6f80097c0e374c01a9ffa921 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 11:42:47 +0200 Subject: [PATCH 0497/2430] Removed unused code --- lib/coins/aeon-rebase.js | 164 ------- lib/coins/aeon.js | 156 ------- lib/coins/krb.js | 156 ------- lib/payment_systems/aeon-rebase.js | 697 ----------------------------- lib/payment_systems/aeon.js | 257 ----------- lib/payment_systems/krb.js | 254 ----------- 6 files changed, 1684 deletions(-) delete mode 100644 lib/coins/aeon-rebase.js delete mode 100644 lib/coins/aeon.js delete mode 100644 lib/coins/krb.js delete mode 100644 lib/payment_systems/aeon-rebase.js delete mode 100644 lib/payment_systems/aeon.js delete mode 100644 lib/payment_systems/krb.js diff --git a/lib/coins/aeon-rebase.js b/lib/coins/aeon-rebase.js deleted file mode 100644 index 08972d6f..00000000 --- a/lib/coins/aeon-rebase.js +++ /dev/null @@ -1,164 +0,0 @@ -"use strict"; -const bignum = require('bignum'); -const cnUtil = require('cryptonote-util'); -const multiHashing = require('multi-hashing'); -const crypto = require('crypto'); -const debug = require('debug')('coinFuncs'); - -let hexChars = new RegExp("[0-9a-f]+"); - -function Coin(data){ - this.bestExchange = global.config.payout.bestExchange; - this.data = data; - let instanceId = crypto.randomBytes(4); - this.coinDevAddress = "WmsSWgtT1JPg5e3cK41hKXSHVpKW7e47bjgiKmWZkYrhSS5LhRemNyqayaSBtAQ6517eo5PtH9wxHVmM78JDZSUu2W8PqRiNs"; // Developer Address - this.poolDevAddress = "WmtvM6SoYya4qzkoPB4wX7FACWcXyFPWAYzfz7CADECgKyBemAeb3dVb3QomHjRWwGS3VYzMJAnBXfUx5CfGLFZd1U7ssdXTu"; // Snipa Address - - this.blockedAddresses = [ - this.coinDevAddress, - this.poolDevAddress, - ]; - - this.exchangeAddresses = [ - "WmtK9TQ6yd2ZWZDAkRsebc2ppzUq2Wuo9XRRjHMH2fvqM3ARVqk3styJ6AavJFcpJFPFtxRGAqGFoJMZGJ6YYzQ61TYGfpykX", // Bittrex - ]; // These are addresses that MUST have a paymentID to perform logins with. - - this.prefix = 178; - //this.intPrefix = 0x2733; - - if (global.config.general.testnet === true){ - this.prefix = 0x0426; - // this.intPrefix = 0x2C27; - } - - this.supportsAutoExchange = false; - - this.niceHashDiff = 200000; - - this.getBlockHeaderByID = function(blockId, callback){ - global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { - if (body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getBlockHeaderByHash = function(blockHash, callback){ - global.support.rpcDaemon('getblockheaderbyhash', {"hash": blockHash}, function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getLastBlockHeader = function(callback){ - global.support.rpcDaemon('getlastblockheader', [], function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getBlockTemplate = function(walletAddress, callback){ - global.support.rpcDaemon('getblocktemplate', { - reserve_size: 17, - wallet_address: walletAddress - }, function(body){ - return callback(body); - }); - }; - - this.baseDiff = function(){ - return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); - }; - - this.validateAddress = 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); - if (cnUtil.address_decode(address) === this.prefix){ - return true; - } - return cnUtil.address_decode_integrated(address) === this.intPrefix; - }; - - this.convertBlob = function(blobBuffer){ - return cnUtil.convert_blob(blobBuffer); - }; - - this.constructNewBlob = function(blockTemplate, NonceBuffer){ - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer); - }; - - this.getBlockID = function(blockBuffer){ - return cnUtil.get_block_id(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. - The reserved space is 13 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; - // 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'); - // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. - instanceId.copy(this.buffer, this.reserveOffset + 4, 0, 3); - // 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 - 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.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. - return global.coinFuncs.convertBlob(this.buffer).toString('hex'); - }; - // Make it so you can get the raw block 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. - return this.buffer.toString('hex'); - }; - }; - - this.cryptoNight = function(convertedBlob) { - return multiHashing.cryptonight_light(convertedBlob, convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0); - } - -} - -module.exports = Coin; diff --git a/lib/coins/aeon.js b/lib/coins/aeon.js deleted file mode 100644 index a64c793e..00000000 --- a/lib/coins/aeon.js +++ /dev/null @@ -1,156 +0,0 @@ -"use strict"; -const bignum = require('bignum'); -const cnUtil = require('cryptoforknote-util'); -const multiHashing = require('cryptonight-hashing'); -const crypto = require('crypto'); -const debug = require('debug')('coinFuncs'); - -let hexChars = new RegExp("[0-9a-f]+"); - -function Coin(data){ - this.bestExchange = global.config.payout.bestExchange; - this.data = data; - let instanceId = crypto.randomBytes(4); - console.log("Generated instanceId: " + instanceId.toString('hex')); - this.coinDevAddress = "WmsSWgtT1JPg5e3cK41hKXSHVpKW7e47bjgiKmWZkYrhSS5LhRemNyqayaSBtAQ6517eo5PtH9wxHVmM78JDZSUu2W8PqRiNs"; // Developer Address - this.poolDevAddress = "WmsEg3RuUKCcEvFBtXcqRnGYfiqGJLP1FGBYiNMgrcdUjZ8iMcUn2tdcz59T89inWr9Vae4APBNf7Bg2DReFP5jr23SQqaDMT"; // MoneroOcean Address - - this.blockedAddresses = [ - this.coinDevAddress, - this.poolDevAddress, - ]; - - this.exchangeAddresses = [ - ]; // These are addresses that MUST have a paymentID to perform logins with. - - this.prefix = 178; - - this.supportsAutoExchange = false; - - this.niceHashDiff = 400000; - - this.getBlockHeaderByID = function(blockId, callback){ - global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { - if (body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getBlockHeaderByHash = function(blockHash, callback){ - global.support.rpcDaemon('getblockheaderbyhash', {"hash": blockHash}, function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getLastBlockHeader = function(callback){ - global.support.rpcDaemon('getlastblockheader', [], function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getBlockTemplate = function(walletAddress, callback){ - global.support.rpcDaemon('getblocktemplate', { - reserve_size: 17, - wallet_address: walletAddress - }, function(body){ - return callback(body); - }); - }; - - this.baseDiff = function(){ - return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); - }; - - this.validateAddress = 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); - if (cnUtil.address_decode(address) === this.prefix){ - return true; - } - return cnUtil.address_decode_integrated(address) === this.intPrefix; - }; - - this.convertBlob = function(blobBuffer){ - return cnUtil.convert_blob(blobBuffer); - }; - - this.constructNewBlob = function(blockTemplate, NonceBuffer){ - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer); - }; - - this.getBlockID = function(blockBuffer){ - return cnUtil.get_block_id(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. - 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; - // 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'); - // 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 - 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.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. - return global.coinFuncs.convertBlob(this.buffer).toString('hex'); - }; - // Make it so you can get the raw block 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. - return this.buffer.toString('hex'); - }; - }; - - this.cryptoNight = multiHashing.cryptonight_light; - -} - -module.exports = Coin; diff --git a/lib/coins/krb.js b/lib/coins/krb.js deleted file mode 100644 index 7b4d49c7..00000000 --- a/lib/coins/krb.js +++ /dev/null @@ -1,156 +0,0 @@ -"use strict"; -const bignum = require('bignum'); -const cnUtil = require('cryptoforknote-util'); -const multiHashing = require('cryptonight-hashing'); -const crypto = require('crypto'); -const debug = require('debug')('coinFuncs'); - -let hexChars = new RegExp("[0-9a-f]+"); - -function Coin(data){ - this.bestExchange = global.config.payout.bestExchange; - this.data = data; - let instanceId = crypto.randomBytes(4); - console.log("Generated instanceId: " + instanceId.toString('hex')); - this.coinDevAddress = "Kdev1L9V5ow3cdKNqDpLcFFxZCqu5W2GE9xMKewsB2pUXWxcXvJaUWHcSrHuZw91eYfQFzRtGfTemReSSMN4kE445i6Etb3"; // Developer Address - this.poolDevAddress = "KgseWakG2bMXHGJSsAUfzL1HykCyvD4m8gd9qgcuyZ1ufy8PqUCKRxEfAv3nahfdTrCjZByiWoCiRiohxq4u2rf2RgQ1pcJ"; // Snipa Address - - this.blockedAddresses = [ - this.coinDevAddress, - this.poolDevAddress, - ]; - - this.exchangeAddresses = [ - ]; // These are addresses that MUST have a paymentID to perform logins with. - - this.prefix = 111; - - this.supportsAutoExchange = false; - - this.niceHashDiff = 200000; - - this.getBlockHeaderByID = function(blockId, callback){ - global.support.rpcDaemon('getblockheaderbyheight', {"height": blockId}, function (body) { - if (body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getBlockHeaderByHash = function(blockHash, callback){ - global.support.rpcDaemon('getblockheaderbyhash', {"hash": blockHash}, function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getLastBlockHeader = function(callback){ - global.support.rpcDaemon('getlastblockheader', [], function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ - return callback(null, body.result.block_header); - } else { - console.error(JSON.stringify(body)); - return callback(true, body); - } - }); - }; - - this.getBlockTemplate = function(walletAddress, callback){ - global.support.rpcDaemon('getblocktemplate', { - reserve_size: 17, - wallet_address: walletAddress - }, function(body){ - return callback(body); - }); - }; - - this.baseDiff = function(){ - return bignum('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16); - }; - - this.validateAddress = 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); - if (cnUtil.address_decode(address) === this.prefix){ - return true; - } - return cnUtil.address_decode_integrated(address) === this.intPrefix; - }; - - this.convertBlob = function(blobBuffer){ - return cnUtil.convert_blob(blobBuffer); - }; - - this.constructNewBlob = function(blockTemplate, NonceBuffer){ - return cnUtil.construct_block_blob(blockTemplate, NonceBuffer); - }; - - this.getBlockID = function(blockBuffer){ - return cnUtil.get_block_id(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. - 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; - // 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'); - // 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 - 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.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. - return global.coinFuncs.convertBlob(this.buffer).toString('hex'); - }; - // Make it so you can get the raw block 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. - return this.buffer.toString('hex'); - }; - }; - - this.cryptoNight = multiHashing.cryptonight; - -} - -module.exports = Coin; diff --git a/lib/payment_systems/aeon-rebase.js b/lib/payment_systems/aeon-rebase.js deleted file mode 100644 index ff2059f1..00000000 --- a/lib/payment_systems/aeon-rebase.js +++ /dev/null @@ -1,697 +0,0 @@ -"use strict"; -const shapeshift = require('shapeshift.io'); -const async = require("async"); -const debug = require("debug")("payments"); -const request = require('request-json'); -const range = require('range'); - -let hexChars = new RegExp("[0-9a-f]+"); -let bestExchange = global.config.payout.bestExchange; -let xmrAPIClient = request.createClient('https://xmr.to/api/v1/xmr2btc/'); -let extraPaymentRound = false; -let paymentTimer = null; - -let shapeshiftQueue = async.queue(function (task, callback) { - // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. - let amount = task.amount - task.fee; - // Address is the destination address IN BTC. - let address = task.address; - // PaymentIDs are the paymentID's to flag as paid by this transaction. - // Should be a massive list of ID's so we can bulk-update them, by merging them with 's. - // Here we go! General process: Scan shapeshift for valid amounts of funds to xfer around. - // Once there's enough funds, then we active txn - // Do a wallet call to xfer. - // Setup a monitor on the transaction - async.waterfall([ - function (intCallback) { - // Verify if the coin is active in ShapeShift first. - shapeshift.coins(function (err, coinData) { - if (err) { - intCallback(err); - } else if (!coinData.hasOwnProperty(global.config.general.coinCode) || coinData[global.config.general.coinCode].status !== "available") { - intCallback("Coin " + global.config.general.coinCode + " Is not available at this time on shapeshift."); - } else { - intCallback(null); - } - }); - }, - function (intCallback) { - // Get the market information from shapeshift, which includes deposit limits, minimum deposits, rates, etc. - shapeshift.marketInfo(global.config.payout.shapeshiftPair, function (err, marketInfo) { - if (err) { - intCallback(err); - } else if (!marketInfo.hasOwnProperty("limit") || marketInfo.limit <= global.support.coinToDecimal(amount)) { - intCallback("Not enough coin in shapeshift to process at this time."); - } else if (!marketInfo.hasOwnProperty("min") || marketInfo.min >= global.support.coinToDecimal(amount)) { - intCallback("Not enough coin to hit the shapeshift minimum deposits."); - } else { - intCallback(null, marketInfo); - } - }); - }, - function (marketInfo, intCallback) { - // Validated there's enough coin. Time to make our dank txn. - // Return: - /* - { - "orderId": "cc49c556-e645-4c15-a943-d50a935274e4", - "sAddress": "46yzCCD3Mza9tRj7aqPSaxVbbePtuAeKzf8Ky2eRtcXGcEgCg1iTBio6N4sPmznfgGEUGDoBz5CLxZ2XPTyZu1yoCAG7zt6", - "deposit": "d8041668718e6e9d9d0fd335ee5ecd923e6fd074c41316d041cc18b779ade10e", - "depositType": "XMR", - "withdrawal": "1DbxcoCBSA9N7uZvkcvWxuLxSau9q9Pwiu", - "withdrawalType": "BTC", - "public": null, - "apiPubKey": "shapeshift", - "returnAddress": "46XWBqE1iwsVxSDP1qDrxhE1XvsZV6eALG5LwnoMdjbT4GPdy2bZTb99kagzxp2MMjUamTYZ4WgvZdFadvMimTjvR6Gv8hL", - "returnAddressType": "XMR" - } - Valid Statuses: - "received" - "complete" - "error" - "no_deposits" - Complete State Information: - { - "status": "complete", - "address": "d8041668718e6e9d9d0fd335ee5ecd923e6fd074c41316d041cc18b779ade10e", - "withdraw": "1DbxcoCBSA9N7uZvkcvWxuLxSau9q9Pwiu", - "incomingCoin": 3, - "incomingType": "XMR", - "outgoingCoin": "0.04186155", - "outgoingType": "BTC", - "transaction": "be9d97f6fc75262151f8f63e035c6ed638b9eb2a4e93fef43ea63124b045dbfb" - } - */ - shapeshift.shift(address, global.config.payout.shapeshiftPair, {returnAddress: global.config.pool.address}, function (err, returnData) { - if (err) { - intCallback(err); - } else { - global.mysql.query("INSERT INTO shapeshiftTxn (id, address, paymentID, depositType, withdrawl, withdrawlType, returnAddress, returnAddressType, txnStatus) VALUES (?,?,?,?,?,?,?,?,?)", - [returnData.orderId, returnData.sAddress, returnData.deposit, returnData.depositType, returnData.withdrawl, returnData.withdrawlType, returnData.returnAddress, returnData.returnAddressType, 'no_deposits']).then(function () { - intCallback(null, marketInfo, returnData); - }).catch(function (error) { - intCallback(error); - }); - } - }); - }, - function (marketInfo, shapeshiftTxnData, intCallback) { - // Make the payment to ShapeShift - let paymentDetails = { - destinations: [ - { - amount: amount, - address: shapeshiftTxnData.sAddress - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, - payment_id: shapeshiftTxnData.deposit - }; - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - intCallback(null, marketInfo, shapeshiftTxnData, body); - } else { - intCallback("Unknown error from the wallet."); - } - }); - }, - function (marketInfo, shapeshiftTxnData, body, intCallback) { - // body.tx_hash = XMR transaction hash. - // Need to add transaction. - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees, exchange_rate, exchange_name, exchange_txn_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - [1, address, null, task.amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, global.support.decimalToCoin(marketInfo.minerFee), 1, global.support.decimalToCoin(marketInfo.rate), 'shapeshift', shapeshiftTxnData.orderId]).then(function (result) { - intCallback(null, result.insertId); - }).catch(function (error) { - intCallback(error); - }); - } - ], function (err, result) { - if (err) { - console.error("Error processing shapeshift txn: " + JSON.stringify(err)); - callback(true); - } else { - // Need to fill out this data pronto! - console.log("Processed ShapeShift transaction for: " + address + " Paid out: " + result + " payments in the db"); - callback(null, result); - } - }); -}, 2); - -let xmrToQueue = async.queue(function (task, callback) { - // http://xmrto-api.readthedocs.io/en/latest/introduction.html - // Documentation looks good! - // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. - let amount = task.amount - task.fee; - // Address is the destination address IN BTC. - let address = task.address; - // PaymentIDs are the paymentID's to flag as paid by this transaction. - // Should be a massive list of ID's so we can bulk-update them, by merging them with 's. - // Here we go! General process: Scan shapeshift for valid amounts of funds to xfer around. - // Once there's enough funds, then we active txn - // Do a wallet call to xfer. - // Setup a monitor on the transaction - async.waterfall([ - function (intCallback) { - // Verify if XMR.to is ready to get to work. - xmrAPIClient.get('order_parameter_query/', function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - let amtOfBTC = ((amount / global.config.general.sigDivisor) * body.price).toPrecision(5); - console.log("Attempting to pay: " + address + " Amount: " + amtOfBTC + " BTC or " + amount / global.config.general.sigDivisor + " XMR"); - console.log("Response from XMR.to: " + JSON.stringify(body)); - if (body.lower_limit >= amtOfBTC) { - return intCallback("Not enough XMR to hit the minimum deposit"); - } else if (body.upper_limit <= amtOfBTC) { - return intCallback("Too much XMR to pay out to xmr.to"); - } else { - return intCallback(null, amtOfBTC); - } - } - }); - }, - function (btcValue, intCallback) { - // Validated there's enough coin. Time to make our dank txn. - // Return: - /* - { - "state": "TO_BE_CREATED", - "btc_amount": , - "btc_dest_address": "", - "uuid": "" - } - Valid Statuses: - "TO_BE_CREATED" - "UNPAID" - "UNDERPAID" - "PAID_UNCONFIRMED" - "PAID" - "BTC_SENT" - "TIMED_OUT" - "NOT_FOUND" - // Create, then immediately update with the new information w/ a status call. - */ - console.log("Amount of BTC to pay: " + btcValue); - xmrAPIClient.post('order_create/', { - btc_amount: btcValue, - btc_dest_address: address - }, function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - return intCallback(null, body.uuid); - } - }); - }, - function (txnID, intCallback) { - // This function only exists because xmr.to is a pretty little fucking princess. - async.doUntil(function (xmrCallback) { - xmrAPIClient.post('order_status_query/', {uuid: txnID}, function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - xmrCallback(null, body.state); - } - }); - }, - function (xmrCallback) { - return xmrCallback !== "TO_BE_CREATED"; - }, - function () { - intCallback(null, txnID); - }); - }, - function (txnID, intCallback) { - xmrAPIClient.post('order_status_query/', {uuid: txnID}, function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - console.log(JSON.stringify(body)); - global.mysql.query("INSERT INTO xmrtoTxn (id, address, paymentID, depositType, withdrawl, withdrawlType, returnAddress, returnAddressType, txnStatus, amountDeposited, amountSent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", - [txnID, body.xmr_receiving_address, body.xmr_required_payment_id_long, 'XMR', body.btc_dest_address, 'BTC', global.config.pool.address, 'XMR', body.state_str, global.support.decimalToCoin(body.xmr_amount_total), global.support.decimalToCoin(body.btc_amount)]).then(function () { - return intCallback(null, body, global.support.decimalToCoin(body.xmr_amount_total)); - }).catch(function (error) { - return intCallback(error); - }); - } - }); - }, - function (orderStatus, xmrDeposit, intCallback) { - // Make the payment to ShapeShift - let paymentDetails = { - destinations: [ - { - amount: xmrDeposit, - address: orderStatus.xmr_receiving_address - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, - payment_id: orderStatus.xmr_required_payment_id_long - }; - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - return intCallback(null, orderStatus, body); - } else { - return intCallback("Unknown error from the wallet."); - } - }); - }, - function (orderStatus, body, intCallback) { - // body.tx_hash = XMR transaction hash. - // Need to add transaction. - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees, exchange_rate, exchange_name, exchange_txn_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - [1, address, null, global.support.decimalToCoin(orderStatus.xmr_amount_total), body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1, global.support.decimalToCoin(orderStatus.xmr_price_btc), 'xmrto', orderStatus.uuid]).then(function (result) { - return intCallback(null, result.insertId); - }).catch(function (error) { - return intCallback(error); - }); - } - ], function (err, result) { - if (err) { - console.error("Error processing XMRTo txn: " + JSON.stringify(err)); - return callback("Error!"); - } else { - // Need to fill out this data pronto! - console.log("Processed XMRTo transaction for: " + address + " Paid out: " + result + " payments in the db"); - return callback(null, result); - } - }); -}, 2); - -let paymentQueue = async.queue(function (paymentDetails, callback) { - /* - support JSON URI: http://10.0.0.2:28082/json_rpc Args: {"id":"0","jsonrpc":"2.0","method":"transfer","params":{"destinations":[{"amount":68130252045355,"address":"A2MSrn49ziBPJBh8ZNEhhbfyLMou6mao4C1F5TLGUatmUnCxZArDYkcbAnVkVEopWVeak2rKDrmc8JpoS7n5dvfN9YDPBTG"}],"mixin":4,"payment_id":"7e52c5266de9fede7fb3abc0cd88f937b38b51426f7b34ff99729d28ce4e1142"}} +1ms - payments Payment made: {"id":"0","jsonrpc":"2.0","result":{"fee":40199391255,"tx_hash":"c418708643f72635edf522490bfb2cae9d42a6dc1df30dcde844862dfd88f5b3","tx_key":""}} +2s - */ - if (paymentTimer !== null){ - clearInterval(paymentTimer); - paymentTimer = null; - } - debug("Making payment based on: " + JSON.stringify(paymentDetails)); - let transferFunc = 'transfer'; - global.support.rpcWallet(transferFunc, paymentDetails, function (body) { - debug("Payment made: " + JSON.stringify(body)); - if (body.hasOwnProperty('error')) { - if (body.error.message === "not enough money"){ - console.error("Issue making payments, not enough money, will try later"); - if(!extraPaymentRound){ - setTimeout(function(){ - makePayments(); - }, global.config.payout.timerRetry * 60 * 1000); - } - extraPaymentRound = true; - return callback(false); - } else { - console.error("Issue making payments" + JSON.stringify(body.error)); - console.error("Will not make more payments until the payment daemon is restarted!"); - //toAddress, subject, body - global.support.sendEmail(global.config.general.adminEmail, "Payment daemon unable to make payment", - "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(body.error) + - ". Please investigate and restart the payment daemon as appropriate"); - return; - } - } - if (paymentDetails.hasOwnProperty('payment_id')) { - console.log("Payment made to " + paymentDetails.destinations[0].address + " with PaymentID: " + paymentDetails.payment_id + " For: " + global.support.coinToDecimal(paymentDetails.destinations[0].amount) + " AEON with a " + global.support.coinToDecimal(body.result.fee) + " AEON Mining Fee"); - return callback(body.result); - } else { - if (transferFunc === 'transfer') { - console.log(body); - console.log("Payment made out to multiple people, total fee: " + global.support.coinToDecimal(body.result.fee) + " AEON"); - } - let intCount = 0; - paymentDetails.destinations.forEach(function (details) { - console.log("Payment made to: " + details.address + " For: " + global.support.coinToDecimal(details.amount) + " AEON"); - intCount += 1; - if (intCount === paymentDetails.destinations.length) { - return callback(body.result); - } - }); - } - }); -}, 1); - -paymentQueue.drain = function(){ - extraPaymentRound = false; - if (global.config.payout.timer > 35791){ - console.error("Payout timer is too high. Please use a value under 35791 to avoid overflows."); - } else { - paymentTimer = setInterval(makePayments, global.config.payout.timer * 60 * 1000); - } - 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) { - rows.forEach(function (row) { - shapeshift.status(row.paymentID, function (err, status, returnData) { - if (err) { - return; - } - global.mysql.query("UPDATE shapeshiftTxn SET txnStatus = ? WHERE id = ?", [status, row.id]).then(function () { - if (status === 'complete') { - global.mysql.query("UPDATE shapeshiftTxn SET amountDeposited = ?, amountSent = ?, transactionHash = ? WHERE id = ?", - [global.support.decimalToCoin(returnData.incomingCoin), global.support.bitcoinDecimalToCoin(returnData.outgoingCoin), returnData.transaction, row.id]).then(function () { - global.mysql.query("UPDATE transactions SET confirmed = 1, confirmed_time = now(), btc_amt = ? WHERE exchange_txn_id = ?", [global.support.bitcoinDecimalToCoin(returnData.outgoingCoin), row.id]); - }); - } else if (status === 'error') { - // Failed txn. Need to rollback and delete all related data. Here we go! - global.mysql.query("DELETE FROM shapeshiftTxn WHERE id = ?", [row.id]); - global.mysql.query("SELECT id, xmr_amt, address FROM transactions WHERE exchange_txn_id = ?", [row.id]).then(function (rows) { - global.mysql.query("DELETE FROM transactions WHERE id = ?", [rows[0].id]); - global.mysql.query("DELETE payments WHERE transaction_id = ?", [rows[0].id]); - global.mysql.query("UPDATE balance SET amount = amount+? WHERE payment_address = ? limit 1", [rows[0].xmr_amt, rows[0].address]); - }); - console.error("Failed transaction from ShapeShift " + JSON.stringify(returnData)); - } - }); - }); - }); - }); -} - -function updateXMRToCompletion() { - global.mysql.query("SELECT * FROM xmrtoTxn WHERE txnStatus NOT IN ('PAID', 'TIMED_OUT', 'NOT_FOUND', 'BTC_SENT')").then(function (rows) { - rows.forEach(function (row) { - xmrAPIClient.post('order_status_query/', {uuid: row.id}, function (err, res, body) { - if (err) { - console.log("Error in getting order status: " + JSON.stringify(err)); - return; - } - if (body.error_msg) { - console.log("Error in getting order status: " + body.error_msg); - return; - } - global.mysql.query("UPDATE xmrtoTxn SET txnStatus = ? WHERE id = ?", [body.state, row.id]).then(function () { - if (body.status === 'BTC_SENT') { - global.mysql.query("UPDATE xmrtoTxn SET transactionHash = ? WHERE id = ?", [body.btc_transaction_id, row.id]).then(function () { - global.mysql.query("UPDATE transactions SET confirmed = 1, confirmed_time = now(), btc_amt = ? WHERE exchange_txn_id = ?", [global.support.bitcoinDecimalToCoin(body.btc_amount), row.id]); - }); - } else if (body.status === 'TIMED_OUT' || body.status === 'NOT_FOUND') { - global.mysql.query("DELETE FROM xmrtoTxn WHERE id = ?", [row.id]); - global.mysql.query("SELECT id, xmr_amt, address FROM transactions WHERE exchange_txn_id = ?", [row.id]).then(function (rows) { - global.mysql.query("DELETE FROM transactions WHERE id = ?", [rows[0].id]); - global.mysql.query("DELETE payments WHERE transaction_id = ?", [rows[0].id]); - global.mysql.query("UPDATE balance SET amount = amount+? WHERE payment_address = ? limit 1", [rows[0].xmr_amt, rows[0].address]); - }); - console.error("Failed transaction from XMRto " + JSON.stringify(body)); - } - }); - }); - }); - }); -} - -function determineBestExchange() { - async.waterfall([ - function (callback) { - // Verify if the coin is active in ShapeShift first. - shapeshift.coins(function (err, coinData) { - if (err) { - return callback(err); - } else if (!coinData.hasOwnProperty(global.config.general.coinCode) || coinData[global.config.general.coinCode].status !== "available") { - return callback("Coin " + global.config.general.coinCode + " Is not available at this time on shapeshift."); - } else { - return callback(null); - } - }); - }, - function (callback) { - // Get the market information from shapeshift, which includes deposit limits, minimum deposits, rates, etc. - shapeshift.marketInfo(global.config.payout.shapeshiftPair, function (err, marketInfo) { - if (err) { - return callback(err); - } else if (!marketInfo.hasOwnProperty("rate")) { - return callback("Shapeshift did not return the rate."); - } else { - return callback(null, global.support.bitcoinDecimalToCoin(marketInfo.rate)); - } - }); - }, - function (ssValue, callback) { - xmrAPIClient.get('order_parameter_query/', function (err, res, body) { - console.log("XMR.to pricing body: " + JSON.stringify(body)); - if (err) { - return callback(err); - } else if (body.error_msg) { - return callback(body.error_msg); - } else { - return callback(null, ssValue, global.support.bitcoinDecimalToCoin(body.price)); - } - }); - } - ], function (err, ssValue, xmrToValue) { - if (err) { - return console.error("Error processing exchange value: " + JSON.stringify(err)); - } - debug("ShapeShift Value: " + global.support.bitcoinCoinToDecimal(ssValue) + " XMR.to Value: " + global.support.bitcoinCoinToDecimal(xmrToValue)); - if (ssValue >= xmrToValue) { - console.log("ShapeShift is the better BTC exchange, current rate: " + global.support.bitcoinCoinToDecimal(ssValue)); - bestExchange = 'shapeshift'; - global.mysql.query("UPDATE config SET item_value = 'shapeshift' where item='bestExchange'"); - global.mysql.query("UPDATE config SET item_value = ? where item='exchangeRate'", [ssValue]); - } else { - console.log("XMR.to is the better BTC exchange, current rate: " + global.support.bitcoinCoinToDecimal(xmrToValue)); - bestExchange = 'xmrto'; - global.mysql.query("UPDATE config SET item_value = 'xmrto' where item='bestExchange'"); - global.mysql.query("UPDATE config SET item_value = ? where item='exchangeRate'", [xmrToValue]); - } - }); -} - -function Payee(amount, address, paymentID, bitcoin) { - this.amount = amount; - this.address = address; - this.paymentID = paymentID; - this.bitcoin = bitcoin; - this.blockID = 0; - this.poolType = ''; - this.transactionID = 0; - this.sqlID = 0; - if (paymentID === null) { - this.id = address; - } else { - this.id = address + "." + paymentID; - } - this.fee = 0; - this.baseFee = global.support.decimalToCoin(global.config.payout.feeSlewAmount); - this.setFeeAmount = function () { - if (this.amount <= global.support.decimalToCoin(global.config.payout.walletMin)) { - this.fee = this.baseFee; - } else if (this.amount <= global.support.decimalToCoin(global.config.payout.feeSlewEnd)) { - let feeValue = this.baseFee / (global.support.decimalToCoin(global.config.payout.feeSlewEnd) - global.support.decimalToCoin(global.config.payout.walletMin)); - this.fee = this.baseFee - ((this.amount - global.support.decimalToCoin(global.config.payout.walletMin)) * feeValue); - } - this.fee = Math.floor(this.fee); - }; - - this.makePaymentWithID = function () { - let paymentDetails = { - destinations: [ - { - amount: this.amount - this.fee, - address: this.address - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, - payment_id: this.paymentID - }; - let identifier = this.id; - let amount = this.amount; - let address = this.address; - let paymentID = this.paymentID; - let payee = this; - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - debug("Successful payment sent to: " + identifier); - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - }; - - this.makePaymentAsIntegrated = function () { - let paymentDetails = { - destinations: [ - { - amount: this.amount - this.fee, - address: this.address - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn - }; - let identifier = this.id; - let amount = this.amount; - let address = this.address; - let payee = this; - - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - debug("Successful payment sent to: " + identifier); - global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", - [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - }; - - this.makeBitcoinPayment = function () { - let functionalData = {address: this.address, amount: this.amount, fee: this.fee}; - let payee = this; - if (bestExchange === 'xmrto') { - xmrToQueue.push(functionalData, function (err, transactionID) { - if (err) { - return console.error("Error processing payment for " + functionalData.address); - } - payee.transactionID = transactionID; - payee.trackPayment(); - }); - } else { - shapeshiftQueue.push(functionalData, function (err, transactionID) { - if (err) { - return console.error("Error processing payment for " + functionalData.address); - } - payee.transactionID = transactionID; - payee.trackPayment(); - }); - } - }; - - this.trackPayment = function () { - global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]); - global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + - " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]); - }; -} - -function makePayments() { - global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { - 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) { - 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 += 1; - let threshold = 0; - if (userRow.length !== 0) { - threshold = userRow[0].payout_threshold; - } - payee.poolType = row.pool_type; - payee.sqlID = row.id; - if (payee.poolType === "fees" && payee.address === global.config.payout.feeAddress && payee.amount >= ((global.support.decimalToCoin(global.config.payout.feesForTXN) + global.support.decimalToCoin(global.config.payout.exchangeMin)))) { - debug("This is the fee address internal check for value"); - payee.amount -= global.support.decimalToCoin(global.config.payout.feesForTXN); - } else if (payee.address === global.config.payout.feeAddress && payee.poolType === "fees") { - debug("Unable to pay fee address."); - payee.amount = 0; - } - let remainder = payee.amount % (global.config.payout.denom * global.config.general.sigDivisor); - if (remainder !== 0) { - payee.amount -= remainder; - } - if (payee.amount > threshold) { - payee.setFeeAmount(); - if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { - debug("Adding " + payee.id + " to the list of people to pay (OG Address). Payee balance: " + 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 && threshold !== 0))) { - // 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. - debug("Adding " + payee.id + " to the list of people to pay (Integrated Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); - payee.makePaymentAsIntegrated(); - } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 0) { - debug("Adding " + payee.id + " to the list of people to pay (Payment ID Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); - payee.makePaymentWithID(); - } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 1) { - debug("Adding " + payee.id + " to the list of people to pay (Bitcoin Payout). Payee balance: " + global.support.coinToDecimal(payee.amount)); - 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("Paying out: " + paymentDetails.destinations.length + " people"); - paymentQueue.push(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) { - debug("Made it to the SQL insert for transactions"); - let totalAmount = 0; - paymentDetails.destinations.forEach(function (payeeItem) { - totalAmount += payeeObjects[payeeItem.address].amount; - totalAmount += payeeObjects[payeeItem.address].fee; - }); - 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) { - paymentDetails.destinations.forEach(function (payeeItem) { - payee = payeeObjects[payeeItem.address]; - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - } - } - }); - }); - }); -} - -function init() { - global.support.rpcWallet("store", [], function () { - }); - if (global.config.allowBitcoin) { - determineBestExchange(); - setInterval(updateXMRToCompletion, 90000); - setInterval(updateShapeshiftCompletion, 90000); - setInterval(determineBestExchange, 60000); - } - setInterval(function () { - global.support.rpcWallet("store", [], function () { - }); - }, 60000); - console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes with a: " + global.config.payout.timerRetry + " minute delay if the wallet is out of money"); - makePayments(); -} - -init(); \ No newline at end of file diff --git a/lib/payment_systems/aeon.js b/lib/payment_systems/aeon.js deleted file mode 100644 index 28ba1a91..00000000 --- a/lib/payment_systems/aeon.js +++ /dev/null @@ -1,257 +0,0 @@ -"use strict"; -const async = require("async"); -const debug = require("debug")("payments"); - -let hexChars = new RegExp("[0-9a-f]+"); -let extraPaymentRound = false; -let paymentTimer = null; - -let paymentQueue = async.queue(function (paymentDetails, callback) { - if (paymentTimer !== null){ - clearInterval(paymentTimer); - paymentTimer = null; - } - debug("Making payment based on: " + JSON.stringify(paymentDetails)); - let transferFunc = 'transfer'; - global.support.rpcWallet(transferFunc, paymentDetails, function (body) { - debug("Payment made: " + JSON.stringify(body)); - if (body.hasOwnProperty('error')) { - if (body.error.message === "not enough money"){ - console.error("Issue making payments, not enough money, will try later"); - if(!extraPaymentRound){ - setTimeout(function(){ - makePayments(); - }, global.config.payout.timerRetry * 60 * 1000); - } - extraPaymentRound = true; - return callback(false); - } else { - console.error("Issue making payments" + JSON.stringify(body.error)); - console.error("Will not make more payments until the payment daemon is restarted!"); - //toAddress, subject, body - global.support.sendEmail(global.config.general.adminEmail, "Payment daemon unable to make payment", - "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(body.error) + - ". Please investigate and restart the payment daemon as appropriate"); - return; - } - } - if (paymentDetails.hasOwnProperty('payment_id')) { - console.log("Payment made to " + paymentDetails.destinations[0].address + " with PaymentID: " + paymentDetails.payment_id + " For: " + global.support.coinToDecimal(paymentDetails.destinations[0].amount) + " XMR with a " + global.support.coinToDecimal(body.result.fee) + " XMR Mining Fee"); - return callback(body.result); - } else { - if (transferFunc === 'transfer') { - console.log("Payment made out to multiple people, total fee: " + global.support.coinToDecimal(body.result.fee) + " XMR"); - } - let intCount = 0; - paymentDetails.destinations.forEach(function (details) { - console.log("Payment made to: " + details.address + " For: " + global.support.coinToDecimal(details.amount) + " XMR"); - intCount += 1; - if (intCount === paymentDetails.destinations.length) { - return callback(body.result); - } - }); - } - }); -}, 1); - -paymentQueue.drain = function(){ - extraPaymentRound = false; - if (global.config.payout.timer > 35791){ - console.error("Payout timer is too high. Please use a value under 35791 to avoid overflows."); - } else { - paymentTimer = setInterval(makePayments, global.config.payout.timer * 60 * 1000); - } - global.database.setCache('lastPaymentCycle', Math.floor(Date.now()/1000)); -}; - -function Payee(amount, address, paymentID, bitcoin) { - this.amount = amount; - this.address = address; - this.paymentID = paymentID; - this.bitcoin = bitcoin; - this.blockID = 0; - this.poolType = ''; - this.transactionID = 0; - this.sqlID = 0; - if (paymentID === null) { - this.id = address; - } else { - this.id = address + "." + paymentID; - } - this.fee = 0; - this.baseFee = global.support.decimalToCoin(global.config.payout.feeSlewAmount); - this.setFeeAmount = function () { - if (this.amount <= global.support.decimalToCoin(global.config.payout.walletMin)) { - this.fee = this.baseFee; - } else if (this.amount <= global.support.decimalToCoin(global.config.payout.feeSlewEnd)) { - let feeValue = this.baseFee / (global.support.decimalToCoin(global.config.payout.feeSlewEnd) - global.support.decimalToCoin(global.config.payout.walletMin)); - this.fee = this.baseFee - ((this.amount - global.support.decimalToCoin(global.config.payout.walletMin)) * feeValue); - } - this.fee = Math.floor(this.fee); - }; - - this.makePaymentWithID = function () { - let paymentDetails = { - destinations: [ - { - amount: this.amount - this.fee, - address: this.address - } - ], - fee: global.config.payout.fee, - unlock_time: global.config.payout.unlock_time, - mixin: global.config.payout.mixIn, - payment_id: this.paymentID - }; - let identifier = this.id; - let amount = this.amount; - let address = this.address; - let paymentID = this.paymentID; - let payee = this; - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (typeof body.tx_hash !== 'undefined') { - debug("Successful payment sent to: " + identifier); - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, global.config.payout.fee, 1]).then(function (result) { - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - }; - - this.makePaymentAsIntegrated = function () { - let paymentDetails = { - destinations: [ - { - amount: this.amount - this.fee, - address: this.address - } - ], - fee: global.config.payout.fee, - unlock_time: global.config.payout.unlock_time, - mixin: global.config.payout.mixIn - }; - let identifier = this.id; - let amount = this.amount; - let address = this.address; - let payee = this; - - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (typeof body.tx_hash !== 'undefined') { - debug("Successful payment sent to: " + identifier); - global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", - [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, global.config.payout.fee, 1]).then(function (result) { - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - }; - - this.trackPayment = function () { - global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]); - global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + - " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]); - }; -} - -function makePayments() { - global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { - 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) { - 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 += 1; - let threshold = 0; - if (userRow.length !== 0) { - threshold = userRow[0].payout_threshold; - } - payee.poolType = row.pool_type; - payee.sqlID = row.id; - if (payee.poolType === "fees" && payee.address === global.config.payout.feeAddress && payee.amount >= ((global.support.decimalToCoin(global.config.payout.feesForTXN) + global.support.decimalToCoin(global.config.payout.exchangeMin)))) { - debug("This is the fee address internal check for value"); - payee.amount -= global.support.decimalToCoin(global.config.payout.feesForTXN); - } else if (payee.address === global.config.payout.feeAddress && payee.poolType === "fees") { - debug("Unable to pay fee address."); - payee.amount = 0; - } - let remainder = payee.amount % (global.config.payout.denom * global.config.general.sigDivisor); - if (remainder !== 0) { - payee.amount -= remainder; - } - if (payee.amount > threshold) { - payee.setFeeAmount(); - if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { - debug("Adding " + payee.id + " to the list of people to pay (OG Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); - paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); - totalAmount += payee.amount; - payeeList.push(payee); - } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 0) { - debug("Adding " + payee.id + " to the list of people to pay (Payment ID Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); - payee.makePaymentWithID(); - } - } - 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), - mixin: global.config.payout.mixIn, - fee: global.config.payout.fee, - unlock_time: global.config.payout.unlock_time - }; - console.log("Paying out: " + paymentDetails.destinations.length + " people"); - paymentQueue.push(paymentDetails, function (body) { //jshint ignore:line - // This is the only section that could potentially contain multiple txns. Lets do this safely eh? - if (typeof body.tx_hash !== 'undefined') { - debug("Made it to the SQL insert for transactions"); - let totalAmount = 0; - paymentDetails.destinations.forEach(function (payeeItem) { - totalAmount += payeeObjects[payeeItem.address].amount; - totalAmount += payeeObjects[payeeItem.address].fee; - }); - 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, global.config.payout.fee, paymentDetails.destinations.length]).then(function (result) { - paymentDetails.destinations.forEach(function (payeeItem) { - payee = payeeObjects[payeeItem.address]; - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - } - } - }); - }); - }); -} - -function init() { - global.support.rpcWallet("store", [], function () { - }); - setInterval(function () { - global.support.rpcWallet("store", [], function () { - }); - }, 60000); - console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes with a: " + global.config.payout.timerRetry + " minute delay if the wallet is out of money"); - makePayments(); -} - -init(); \ No newline at end of file diff --git a/lib/payment_systems/krb.js b/lib/payment_systems/krb.js deleted file mode 100644 index bc907c1a..00000000 --- a/lib/payment_systems/krb.js +++ /dev/null @@ -1,254 +0,0 @@ -"use strict"; -const async = require("async"); -const debug = require("debug")("payments"); - -let hexChars = new RegExp("[0-9a-f]+"); -let extraPaymentRound = false; -let paymentTimer = null; - -let paymentQueue = async.queue(function (paymentDetails, callback) { - if (paymentTimer !== null){ - clearInterval(paymentTimer); - paymentTimer = null; - } - debug("Making payment based on: " + JSON.stringify(paymentDetails)); - let transferFunc = 'transfer'; - global.support.rpcWallet(transferFunc, paymentDetails, function (body) { - debug("Payment made: " + JSON.stringify(body)); - if (body.hasOwnProperty('error')) { - if (body.error.message === "not enough money"){ - console.error("Issue making payments, not enough money, will try later"); - if(!extraPaymentRound){ - setTimeout(function(){ - makePayments(); - }, global.config.payout.timerRetry * 60 * 1000); - } - extraPaymentRound = true; - return callback(false); - } else { - console.error("Issue making payments" + JSON.stringify(body.error)); - console.error("Will not make more payments until the payment daemon is restarted!"); - //toAddress, subject, body - global.support.sendEmail(global.config.general.adminEmail, "Payment daemon unable to make payment", - "Hello,\r\nThe payment daemon has hit an issue making a payment: " + JSON.stringify(body.error) + - ". Please investigate and restart the payment daemon as appropriate"); - return; - } - } - if (paymentDetails.hasOwnProperty('payment_id')) { - console.log("Payment made to " + paymentDetails.destinations[0].address + " with PaymentID: " + paymentDetails.payment_id + " For: " + global.support.coinToDecimal(paymentDetails.destinations[0].amount) + " XMR with a " + global.support.coinToDecimal(body.result.fee) + " XMR Mining Fee"); - return callback(body.result); - } else { - if (transferFunc === 'transfer') { - console.log("Payment made out to multiple people, total fee: " + global.support.coinToDecimal(body.result.fee) + " XMR"); - } - let intCount = 0; - paymentDetails.destinations.forEach(function (details) { - console.log("Payment made to: " + details.address + " For: " + global.support.coinToDecimal(details.amount) + " XMR"); - intCount += 1; - if (intCount === paymentDetails.destinations.length) { - return callback(body.result); - } - }); - } - }); -}, 1); - -paymentQueue.drain = function(){ - extraPaymentRound = false; - if (global.config.payout.timer > 35791){ - console.error("Payout timer is too high. Please use a value under 35791 to avoid overflows."); - } else { - paymentTimer = setInterval(makePayments, global.config.payout.timer * 60 * 1000); - } - global.database.setCache('lastPaymentCycle', Math.floor(Date.now()/1000)); -}; - -function Payee(amount, address, paymentID, bitcoin) { - this.amount = amount; - this.address = address; - this.paymentID = paymentID; - this.bitcoin = bitcoin; - this.blockID = 0; - this.poolType = ''; - this.transactionID = 0; - this.sqlID = 0; - if (paymentID === null) { - this.id = address; - } else { - this.id = address + "." + paymentID; - } - this.fee = 0; - this.baseFee = global.support.decimalToCoin(global.config.payout.feeSlewAmount); - this.setFeeAmount = function () { - if (this.amount <= global.support.decimalToCoin(global.config.payout.walletMin)) { - this.fee = this.baseFee; - } else if (this.amount <= global.support.decimalToCoin(global.config.payout.feeSlewEnd)) { - let feeValue = this.baseFee / (global.support.decimalToCoin(global.config.payout.feeSlewEnd) - global.support.decimalToCoin(global.config.payout.walletMin)); - this.fee = this.baseFee - ((this.amount - global.support.decimalToCoin(global.config.payout.walletMin)) * feeValue); - } - this.fee = Math.floor(this.fee); - }; - - this.makePaymentWithID = function () { - let paymentDetails = { - destinations: [ - { - amount: this.amount - this.fee, - address: this.address - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, - payment_id: this.paymentID - }; - let identifier = this.id; - let amount = this.amount; - let address = this.address; - let paymentID = this.paymentID; - let payee = this; - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - debug("Successful payment sent to: " + identifier); - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [0, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - }; - - this.makePaymentAsIntegrated = function () { - let paymentDetails = { - destinations: [ - { - amount: this.amount - this.fee, - address: this.address - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn - }; - let identifier = this.id; - let amount = this.amount; - let address = this.address; - let payee = this; - - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - debug("Successful payment sent to: " + identifier); - global.mysql.query("INSERT INTO transactions (bitcoin, address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", - [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - }; - - this.trackPayment = function () { - global.mysql.query("UPDATE balance SET amount = amount - ? WHERE id = ?", [this.amount, this.sqlID]); - global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + - " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]); - }; -} - -function makePayments() { - global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { - 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) { - 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 += 1; - let threshold = 0; - if (userRow.length !== 0) { - threshold = userRow[0].payout_threshold; - } - payee.poolType = row.pool_type; - payee.sqlID = row.id; - if (payee.poolType === "fees" && payee.address === global.config.payout.feeAddress && payee.amount >= ((global.support.decimalToCoin(global.config.payout.feesForTXN) + global.support.decimalToCoin(global.config.payout.exchangeMin)))) { - debug("This is the fee address internal check for value"); - payee.amount -= global.support.decimalToCoin(global.config.payout.feesForTXN); - } else if (payee.address === global.config.payout.feeAddress && payee.poolType === "fees") { - debug("Unable to pay fee address."); - payee.amount = 0; - } - let remainder = payee.amount % (global.config.payout.denom * global.config.general.sigDivisor); - if (remainder !== 0) { - payee.amount -= remainder; - } - if (payee.amount > threshold) { - payee.setFeeAmount(); - if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { - debug("Adding " + payee.id + " to the list of people to pay (OG Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); - paymentDestinations.push({amount: payee.amount - payee.fee, address: payee.address}); - totalAmount += payee.amount; - payeeList.push(payee); - } else if ((payee.amount >= global.support.decimalToCoin(global.config.payout.exchangeMin) || (payee.amount > threshold && threshold !== 0)) && payee.bitcoin === 0) { - debug("Adding " + payee.id + " to the list of people to pay (Payment ID Address). Payee balance: " + global.support.coinToDecimal(payee.amount)); - payee.makePaymentWithID(); - } - } - 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("Paying out: " + paymentDetails.destinations.length + " people"); - paymentQueue.push(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) { - debug("Made it to the SQL insert for transactions"); - let totalAmount = 0; - paymentDetails.destinations.forEach(function (payeeItem) { - totalAmount += payeeObjects[payeeItem.address].amount; - totalAmount += payeeObjects[payeeItem.address].fee; - }); - 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) { - paymentDetails.destinations.forEach(function (payeeItem) { - payee = payeeObjects[payeeItem.address]; - payee.transactionID = result.insertId; - payee.trackPayment(); - }); - }); - } else { - console.error("Unknown error from the wallet."); - } - }); - } - } - }); - }); - }); -} - -function init() { - global.support.rpcWallet("store", [], function () { - }); - setInterval(function () { - global.support.rpcWallet("store", [], function () { - }); - }, 60000); - console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes with a: " + global.config.payout.timerRetry + " minute delay if the wallet is out of money"); - makePayments(); -} - -init(); \ No newline at end of file From 193169247bf18d1812cd4ede85aec59ac7edf1a3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 11:45:37 +0200 Subject: [PATCH 0498/2430] Added XMV support --- README.md | 1 + deployment/base.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index ebb49fd3..9155a77a 100644 --- a/README.md +++ b/README.md @@ -264,6 +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``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index c0424c7e..382ff34c 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -232,6 +232,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 ('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'); From 2e18c1d36bc409c4794f0207a9027cc19ff46af7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 13:10:59 +0200 Subject: [PATCH 0499/2430] Added apicache --- lib/api.js | 3 +++ package.json | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/api.js b/lib/api.js index 6f03c539..2ae280d2 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,6 +1,8 @@ "use strict"; const express = require('express'); // call express +const apicache = require('apicache'); const app = express(); // define our app using express +const cache = apicache.middleware; const server = require('http').createServer(app); const cluster = require('cluster'); const async = require("async"); @@ -32,6 +34,7 @@ if(global.config.solo.enable === true){ pool_list.push('solo'); } +app.use(cache('30 seconds')); app.use(cors({origin: true})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); diff --git a/package.json b/package.json index c68e06c7..2218f921 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "crypto": "0.0.3", "debug": "2.5.1", "express": "4.14.0", + "apicache": "1.2.1", "jsonwebtoken": "^7.2.1", "minimist": "1.2.0", "moment": "2.21.0", From e317a207710be99818e2e50645f79c583f89a2fa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 13:24:14 +0200 Subject: [PATCH 0500/2430] Reduced cache to 10 sec --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 2ae280d2..69874e10 100644 --- a/lib/api.js +++ b/lib/api.js @@ -34,7 +34,7 @@ if(global.config.solo.enable === true){ pool_list.push('solo'); } -app.use(cache('30 seconds')); +app.use(cache('10 seconds')); app.use(cors({origin: true})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); From 5e6395e512a3682b9b891928654f9d5b4dfd5363 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 13:29:30 +0200 Subject: [PATCH 0501/2430] Added apicache --- lib/api.js | 5 ++++- package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 3203421f..69874e10 100644 --- a/lib/api.js +++ b/lib/api.js @@ -1,6 +1,8 @@ "use strict"; const express = require('express'); // call express +const apicache = require('apicache'); const app = express(); // define our app using express +const cache = apicache.middleware; const server = require('http').createServer(app); const cluster = require('cluster'); const async = require("async"); @@ -32,6 +34,7 @@ if(global.config.solo.enable === true){ pool_list.push('solo'); } +app.use(cache('10 seconds')); app.use(cors({origin: true})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); @@ -47,7 +50,7 @@ function getAllWorkerHashCharts(address, callback){ } let intCounter = 0; identifiers.forEach(function(identifier){ - returnData[identifier] = global.database.getCache("history:" + address + "_" + identifier)['hashHistory']; + returnData[identifier] = global.database.getCache("history:" + address+"_"+identifier)['hashHistory']; intCounter += 1; if (intCounter === identifiers.length){ return callback(null, returnData); diff --git a/package.json b/package.json index c68e06c7..2218f921 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "crypto": "0.0.3", "debug": "2.5.1", "express": "4.14.0", + "apicache": "1.2.1", "jsonwebtoken": "^7.2.1", "minimist": "1.2.0", "moment": "2.21.0", From a3792c4807fdb500643c12c5f38db1e2050243bb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 13:44:34 +0200 Subject: [PATCH 0502/2430] Added quote for malformed message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8f9dda19..b0b57337 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1774,7 +1774,7 @@ if (cluster.isMaster) { } } - console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + message); + console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + message.quote()); socket.destroy(); break; From 28ede5dedf486f4beaae7e30a6b949f773f06586 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 13:46:57 +0200 Subject: [PATCH 0503/2430] Fixed quote for malformed message --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b0b57337..01a90b67 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1774,7 +1774,7 @@ if (cluster.isMaster) { } } - console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + message.quote()); + console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + JSON.stringify(message)); socket.destroy(); break; From b9e0610227763e6ddfbf5787b72b98d49a91e5b0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 17:26:32 +0200 Subject: [PATCH 0504/2430] Fixed array ALGOS iteration --- lib/pool.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 01a90b67..2a4cb32a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -701,14 +701,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!this.algos) return ""; let best_algo = ""; let best_algo_hr = this.algos_hr[""]; - for (let algo in ALGOS) { - if (!(global.coinFuncs.algoTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) continue; - if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) continue; + ALGOS.forEach(function(algo) { + if (!(global.coinFuncs.algoTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) return; + if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) return; if (algo in this.algos_hr && this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)] > best_algo_hr) { best_algo = algo; best_algo_hr = this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)]; } - } + }); return best_algo; } @@ -1604,7 +1604,7 @@ if (cluster.isMaster) { global.config.daemon.activePort = global.config.daemon.port; } else { setInterval(updateActivePort, 3*1000, ""); - for (let algo in ALGOS) { + ALGOS.forEach(function(algo) { if (global.config.daemon[activePortAlgo(algo)]) { setInterval(updateActivePort, 5*1000, algo); templateUpdate(algo); @@ -1612,7 +1612,7 @@ if (cluster.isMaster) { } else { console.warn("global.config.daemon." + activePortAlgo(algo) + " is not defined, so ignoring its algo changes"); } - } + }); } templateUpdate(""); @@ -1621,7 +1621,7 @@ if (cluster.isMaster) { } else { templateUpdate(""); if (global.config.daemon.activePortHeavy && global.config.daemon.activePortLight) { - for (let algo in ALGOS) templateUpdate(algo); + ALGOS.forEach(function(algo) { templateUpdate(algo); }); } anchorBlockUpdate(); setInterval(anchorBlockUpdate, 3*1000); From eccd8da04b48efc3fe8f961072efca2f7fcd8552 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 17:29:10 +0200 Subject: [PATCH 0505/2430] Fixed this miner --- lib/pool.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2a4cb32a..39ada375 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -701,12 +701,13 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!this.algos) return ""; let best_algo = ""; let best_algo_hr = this.algos_hr[""]; + let miner = this; ALGOS.forEach(function(algo) { - if (!(global.coinFuncs.algoTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) return; - if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon[activePortAlgo(algo)]) in this.algos)) return; - if (algo in this.algos_hr && this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)] > best_algo_hr) { + if (!(global.coinFuncs.algoTypeStr(global.config.daemon[activePortAlgo(algo)]) in miner.algos)) return; + if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon[activePortAlgo(algo)]) in miner.algos)) return; + if (algo in miner.algos_hr && miner.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)] > best_algo_hr) { best_algo = algo; - best_algo_hr = this.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)]; + best_algo_hr = miner.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)]; } }); return best_algo; From b00db31f2c03fdebb6d50d87f27b6117801ab7ca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 17:44:47 +0200 Subject: [PATCH 0506/2430] Simplified helper functions --- lib/pool.js | 58 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 39ada375..c4a627b5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -80,8 +80,6 @@ global.database.thread_id = threadName; // algo can be "", "Heavy", "Light" const ALGOS = [ "Heavy", "Light" ]; -function algoHashFactor(algo) { return "algoHashFactor" + algo; } -function activePortAlgo(algo) { return "activePort" + algo; } function registerPool() { global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { @@ -254,40 +252,40 @@ function checkAliveMiners() { if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms"); } -// global.config.daemon[activePortAlgo(algo)] is only updated in master thread +// 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[activePortAlgo(algo)]; + const oldActivePort = global.config.daemon["activePort" + algo]; if (newActivePort === null) { if (algo === "" && 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 " + activePortAlgo(algo)); - global.config.daemon[algoHashFactor(algo)] = 0.0; + console.error("Error getting " + "activePort" + algo); + global.config.daemon["algoHashFactor" + algo] = 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; + console.error("Error getting " + "algoHashFactor" + algo); + global.config.daemon["algoHashFactor" + algo] = 0.0; } else { - if (newAlgoHashFactor == 0) debug("Got zero " + algoHashFactor(algo)); - global.config.daemon[algoHashFactor(algo)] = newAlgoHashFactor; + if (newAlgoHashFactor == 0) debug("Got zero " + "algoHashFactor" + algo); + global.config.daemon["algoHashFactor" + algo] = newAlgoHashFactor; if (oldActivePort !== newActivePort) { - console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); - global.config.daemon[activePortAlgo(algo)] = newActivePort; + console.log("Changing " + "activePort" + algo + " from " + oldActivePort + " to " + newActivePort); + global.config.daemon["activePort" + algo] = newActivePort; } } }); } else if (oldActivePort !== newActivePort) { if (newActivePort != 38081 || newActivePort != 18081) return; // !!! FOR DEBUGGING PURPOSES ONLY if (!(newActivePort in lastPortErrorTime) || Date.now() - lastPortErrorTime[newActivePort] > 30*60*1000) { - console.log("Changing " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); - global.config.daemon[activePortAlgo(algo)] = newActivePort; + console.log("Changing " + "activePort" + algo + " from " + oldActivePort + " to " + newActivePort); + global.config.daemon["activePort" + algo] = newActivePort; } else if ((Date.now() - lastPortErrorTime[newActivePort]) % 60*1000 < 6*1000) { // print every 10th message - console.warn("Avoiding changing recently problem " + activePortAlgo(algo) + " from " + oldActivePort + " to " + newActivePort); + console.warn("Avoiding changing recently problem " + "activePort" + algo + " from " + oldActivePort + " to " + newActivePort); } } } @@ -309,8 +307,8 @@ function setProblemPort(port) { // templateUpdateReal is only called in master thread (except the beginning of a worker thread) function templateUpdateReal(algo, activePort, algoHashFactor) { global.coinFuncs.getPortBlockTemplate(activePort, function (rpcResponse) { - if (activePort !== global.config.daemon[activePortAlgo(algo)]) { - console.log("Aborting " + activePort + " last block template request because " + activePortAlgo(algo) + " was already changed to " + global.config.daemon[activePortAlgo(algo)] + " port"); + 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"); return; } if (rpcResponse && typeof rpcResponse.result !== 'undefined') { @@ -350,15 +348,15 @@ function algoHashFactorUpdate(algo, algoHashFactor) { // templateUpdate is only called in master thread (except the beginning of a worker thread) function templateUpdate(algo, repeating) { - let activePort = global.config.daemon[activePortAlgo(algo)]; + let activePort = global.config.daemon["activePort" + algo]; global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { - if (activePort !== global.config.daemon[activePortAlgo(algo)]) { - console.log("Aborting " + activePort + " last block header request because " + activePortAlgo(algo) + " was already changed to " + global.config.daemon[activePortAlgo(algo)] + " port"); + 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); return; } if (err === null) { - const algoHashFactor = algo === "" ? 1.0 : global.config.daemon[algoHashFactor(algo)]; + 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; @@ -371,7 +369,7 @@ function templateUpdate(algo, repeating) { } if (repeating === true) setTimeout(templateUpdate, 50, algo, repeating); } else { - console.error("Last block header request for " + global.config.daemon[activePortAlgo(algo)] + " port failed!"); + console.error("Last block header request for " + global.config.daemon["activePort" + algo] + " port failed!"); if (algo === "") { if (activePort != global.config.daemon.port) setProblemPort(activePort); } else { @@ -408,7 +406,7 @@ function anchorBlockUpdate() { function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { const time_before = Date.now(); - if (algo !== "") global.config.daemon[algoHashFactor(algo)] = algoHashFactor; + if (algo !== "") global.config.daemon["algoHashFactor" + algo] = algoHashFactor; for (let minerId in activeSmartMiners) { if (activeSmartMiners.hasOwnProperty(minerId)) { @@ -703,11 +701,11 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_algo_hr = this.algos_hr[""]; let miner = this; ALGOS.forEach(function(algo) { - if (!(global.coinFuncs.algoTypeStr(global.config.daemon[activePortAlgo(algo)]) in miner.algos)) return; - if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon[activePortAlgo(algo)]) in miner.algos)) return; - if (algo in miner.algos_hr && miner.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)] > best_algo_hr) { + if (!(global.coinFuncs.algoTypeStr(global.config.daemon["activePort" + algo]) in miner.algos)) return; + if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon["activePort" + algo]) in miner.algos)) return; + if (algo in miner.algos_hr && miner.algos_hr[algo] * global.config.daemon["algoHashFactor" + algo] > best_algo_hr) { best_algo = algo; - best_algo_hr = miner.algos_hr[algo] * global.config.daemon[algoHashFactor(algo)]; + best_algo_hr = miner.algos_hr[algo] * global.config.daemon["algoHashFactor" + algo]; } }); return best_algo; @@ -811,7 +809,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.difficulty = this.newDiff; this.newDiff = null; } - const algoHashFactor = algo === "" ? 1.0 : global.config.daemon[algoHashFactor(algo)]; + const algoHashFactor = algo === "" ? 1.0 : global.config.daemon["algoHashFactor" + algo]; if (!this.proxy) { let blob = bt.nextBlob(); let target = this.getTargetHex(); @@ -1606,12 +1604,12 @@ if (cluster.isMaster) { } else { setInterval(updateActivePort, 3*1000, ""); ALGOS.forEach(function(algo) { - if (global.config.daemon[activePortAlgo(algo)]) { + if (global.config.daemon["activePort" + algo]) { setInterval(updateActivePort, 5*1000, algo); templateUpdate(algo); setTimeout(templateUpdate, 50, algo, true); } else { - console.warn("global.config.daemon." + activePortAlgo(algo) + " is not defined, so ignoring its algo changes"); + console.warn("global.config.daemon." + "activePort" + algo + " is not defined, so ignoring its algo changes"); } }); } From 55ec748e955263e8f79d554208d78be97cdc5f4b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 17:47:05 +0200 Subject: [PATCH 0507/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index c4a627b5..0c44143a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -433,7 +433,7 @@ function setNewBlockTemplate(template) { if (activeBlockTemplate[algo].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { - console.log('[*] New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); + console.log('[*] New ' + algo + ' block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } else { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } From b6f99a0297c0dbe7629d8f268dd3f077db396272 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 17:53:08 +0200 Subject: [PATCH 0508/2430] More debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 0c44143a..ef6ef086 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -433,7 +433,8 @@ function setNewBlockTemplate(template) { if (activeBlockTemplate[algo].port != template.port && global.config.pool.trustedMiners) isExtraCheck = true; } if (cluster.isMaster) { - console.log('[*] New ' + algo + ' block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); + 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'); } else { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } From 249c5fc111b0fa89b3ab4eeddd0b88bb7ddf1603 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 18:02:36 +0200 Subject: [PATCH 0509/2430] Removed NaN from stats --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ef6ef086..106d9d6a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -53,11 +53,11 @@ Buffer.prototype.toByteArray = function () { if (cluster.isMaster) { threadName = "(Master) "; setInterval(function () { - let trustedSharesPercent = (trustedShares / totalShares * 100).toFixed(2); - let normalSharesPercent = (normalShares / totalShares * 100).toFixed(2); - let invalidSharesPercent = (invalidShares / totalShares * 100).toFixed(2); - let outdatedSharesPercent = (outdatedShares / totalShares * 100).toFixed(2); - let throttledSharesPercent = (throttledShares / totalShares * 100).toFixed(2); + let trustedSharesPercent = (totalShares ? trustedShares / totalShares * 100 : 0).toFixed(2); + let normalSharesPercent = (totalShares ? normalShares / totalShares * 100 : 0).toFixed(2); + let invalidSharesPercent = (totalShares ? invalidShares / totalShares * 100 : 0).toFixed(2); + let outdatedSharesPercent = (totalShares ? outdatedShares / totalShares * 100 : 0).toFixed(2); + let throttledSharesPercent = (totalShares ? throttledShares / totalShares * 100 : 0).toFixed(2); console.log(`>>> Trusted=${trustedShares}(${trustedSharesPercent}%) / Validated=${normalShares}(${normalSharesPercent}%) / Invalid=${invalidShares}(${invalidSharesPercent}%) / Outdated=${outdatedShares}(${outdatedSharesPercent}%) / Throttled=${throttledShares}(${throttledSharesPercent}%) / Total=${totalShares} shares`); totalShares = 0; trustedShares = 0; From 109454f6e4ab1169c8f2f4064cf99196541411e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 18:16:03 +0200 Subject: [PATCH 0510/2430] More debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 106d9d6a..5bdca6e9 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -341,6 +341,7 @@ function algoHashFactorUpdate(algo, algoHashFactor) { 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); } else { setNewAlgoHashFactor(algo, algoHashFactor); } @@ -434,7 +435,7 @@ function setNewBlockTemplate(template) { } 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'); + 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 + ")"); } else { debug(threadName + 'New block to mine at ' + template.height + ' height with ' + template.difficulty + ' difficulty and ' + template.port + ' port'); } From 5b14ec247f66be3df7340bc1d3966502b8855dbd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 23:06:05 +0200 Subject: [PATCH 0511/2430] Fixed debug check --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5bdca6e9..795e8249 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,7 +280,7 @@ function updateActivePort(algo) { } }); } else if (oldActivePort !== newActivePort) { - if (newActivePort != 38081 || newActivePort != 18081) return; // !!! FOR DEBUGGING PURPOSES ONLY + if (newActivePort != 38081 && newActivePort != 18081) return; // !!! FOR DEBUGGING PURPOSES ONLY 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; From a1b80a7bde72c3f34fc8308625f20cee0a53acd8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 23:18:29 +0200 Subject: [PATCH 0512/2430] Fixed best algo selection --- lib/pool.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 795e8249..91474538 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -407,7 +407,7 @@ function anchorBlockUpdate() { function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { const time_before = Date.now(); - if (algo !== "") global.config.daemon["algoHashFactor" + algo] = algoHashFactor; + if (algo !== "") global.config.daemon["algoHashFactor" + algo] = algoHashFactor; // used in miner.selectBestAlgo for (let minerId in activeSmartMiners) { if (activeSmartMiners.hasOwnProperty(minerId)) { @@ -703,11 +703,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_algo_hr = this.algos_hr[""]; let miner = this; ALGOS.forEach(function(algo) { - if (!(global.coinFuncs.algoTypeStr(global.config.daemon["activePort" + algo]) in miner.algos)) return; - if (!(global.coinFuncs.algoShortTypeStr(global.config.daemon["activePort" + algo]) in miner.algos)) return; - if (algo in miner.algos_hr && miner.algos_hr[algo] * global.config.daemon["algoHashFactor" + algo] > best_algo_hr) { + if (!(algo in activeBlockTemplate)) return; + const port = activeBlockTemplate[algo].port; + if (!(global.coinFuncs.algoTypeStr(port) in miner.algos)) return; + if (!(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; + const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; + if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { best_algo = algo; - best_algo_hr = miner.algos_hr[algo] * global.config.daemon["algoHashFactor" + algo]; + best_algo_hr = miner.algos_hr[algo] * algoHashFactor; } }); return best_algo; From f3bafc9206c6689991a8af40b3827a5a6321deb2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 23:23:15 +0200 Subject: [PATCH 0513/2430] More debugging --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 91474538..29d5e428 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -703,6 +703,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_algo_hr = this.algos_hr[""]; let miner = this; ALGOS.forEach(function(algo) { + console.error(algo); // !!! FOR DEBUGGING PURPOSES if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; if (!(global.coinFuncs.algoTypeStr(port) in miner.algos)) return; @@ -711,6 +712,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { best_algo = algo; best_algo_hr = miner.algos_hr[algo] * algoHashFactor; + console.error("> " + best_algo + " " + best_algo_hr); // !!! FOR DEBUGGING PURPOSES } }); return best_algo; From fe2959443a2a479884d3e63ee8e824b5cb596fb3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 23:27:28 +0200 Subject: [PATCH 0514/2430] More debugging --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 29d5e428..2acc9265 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -703,16 +703,16 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_algo_hr = this.algos_hr[""]; let miner = this; ALGOS.forEach(function(algo) { - console.error(algo); // !!! FOR DEBUGGING PURPOSES + console.error("> " + best_algo + " " + best_algo_hr); // !!! FOR DEBUGGING PURPOSES if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; if (!(global.coinFuncs.algoTypeStr(port) in miner.algos)) return; if (!(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; + console.error("> " + miner.algos_hr + " " + (miner.algos_hr[algo] * algoHashFactor)); // !!! FOR DEBUGGING PURPOSES if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { best_algo = algo; best_algo_hr = miner.algos_hr[algo] * algoHashFactor; - console.error("> " + best_algo + " " + best_algo_hr); // !!! FOR DEBUGGING PURPOSES } }); return best_algo; From 4040405ec58ee4c2eec224e445e503e5724fc225 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 23:29:29 +0200 Subject: [PATCH 0515/2430] More debugging --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2acc9265..b4a4be1f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -709,7 +709,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!(global.coinFuncs.algoTypeStr(port) in miner.algos)) return; if (!(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; - console.error("> " + miner.algos_hr + " " + (miner.algos_hr[algo] * algoHashFactor)); // !!! FOR DEBUGGING PURPOSES + console.error(">> " + miner.algos_hr[algo] + " " + (miner.algos_hr[algo] * algoHashFactor)); // !!! FOR DEBUGGING PURPOSES if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { best_algo = algo; best_algo_hr = miner.algos_hr[algo] * algoHashFactor; From 4998902408d3e338daa47a11fcf73774542c8438 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 23:32:07 +0200 Subject: [PATCH 0516/2430] Fixed best algo condition --- lib/pool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b4a4be1f..5f0bcbec 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -706,8 +706,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer console.error("> " + best_algo + " " + best_algo_hr); // !!! FOR DEBUGGING PURPOSES if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; - if (!(global.coinFuncs.algoTypeStr(port) in miner.algos)) return; - if (!(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; + if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; console.error(">> " + miner.algos_hr[algo] + " " + (miner.algos_hr[algo] * algoHashFactor)); // !!! FOR DEBUGGING PURPOSES if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { From 909b0b90b591561b7d80d7c522baba58aaff849b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 17 May 2018 23:34:37 +0200 Subject: [PATCH 0517/2430] More debugging --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 5f0bcbec..9c7d04a5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -706,6 +706,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer console.error("> " + best_algo + " " + best_algo_hr); // !!! FOR DEBUGGING PURPOSES if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; + console.error(">X " + miner.algos + " " + port); // !!! FOR DEBUGGING PURPOSES if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; console.error(">> " + miner.algos_hr[algo] + " " + (miner.algos_hr[algo] * algoHashFactor)); // !!! FOR DEBUGGING PURPOSES From 7689df156ea48a87eaf0e52e5cd403a10146ef5a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 09:31:08 +0200 Subject: [PATCH 0518/2430] Optimized pool type handling --- lib/api.js | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/api.js b/lib/api.js index 69874e10..cc44f320 100644 --- a/lib/api.js +++ b/lib/api.js @@ -24,15 +24,9 @@ if (cluster.isMaster) { } let pool_list = []; -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'); -} +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(cache('10 seconds')); app.use(cors({origin: true})); @@ -327,22 +321,16 @@ app.get('/pool/payments/:pool_type', function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; switch (pool_type) { - case 'pplns': - break; - case 'pps': - break; - case 'solo': - break; - default: - return res.json({'error': 'Invalid pool type'}); + case 'pplns': break; + case 'pps': break; + case 'solo': break; + default: return res.json({'error': 'Invalid pool type'}); } let paymentIds = []; let query = "SELECT distinct(transaction_id) as txnID FROM payments WHERE pool_type = ? ORDER BY transaction_id DESC LIMIT ? OFFSET ?"; let response = []; global.mysql.query(query, [pool_type, limit, page * limit]).then(function (rows) { - if (rows.length === 0) { - return res.json([]); - } + if (rows.length === 0) return res.json([]); rows.forEach(function (row, index, array) { paymentIds.push(row.txnID); if (array.length === paymentIds.length) { @@ -379,12 +367,10 @@ app.get('/pool/payments', function (req, res) { let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; let query = "SELECT * FROM transactions ORDER BY id DESC LIMIT ? OFFSET ?"; global.mysql.query(query, [limit, page * limit]).then(function (rows) { - if (rows.length === 0) { - return res.json([]); - } + if (rows.length === 0) return res.json([]); let response = []; rows.forEach(function (row, index, array) { - if (row.id in tx_pool_types) { + if (row.id in tx_pool_types || pool_list.length === 1) { let ts = new Date(row.submitted_time); response.push({ id: row.id, @@ -394,13 +380,17 @@ app.get('/pool/payments', function (req, res) { fee: row.fees, value: row.xmr_amt, ts: ts.getTime(), - pool_type: tx_pool_types[row.id] + pool_type: (row.id in tx_pool_types ? tx_pool_types[row.id] : pool_list[0]) }); if (array.length === response.length) { res.json(response.sort(global.support.tsCompare)); } } else { global.mysql.query("SELECT pool_type FROM payments WHERE transaction_id = ? LIMIT 1", [row.id]).then(function (ptRows) { + if (ptRows.length === 0) { + console.error("Unknown pool_type for tx_id " + row.id); + ptRows = [ { "pool_type": "?" } ]; + } let ts = new Date(row.submitted_time); tx_pool_types[row.id] = ptRows[0].pool_type; response.push({ @@ -450,9 +440,7 @@ app.get('/miner/:address/payments', function (req, res) { } let response = []; global.mysql.query(query, [address, payment_id, limit, page * limit]).then(function (rows) { - if (rows.length === 0) { - return res.json(response); - } + if (rows.length === 0) return res.json(response); rows.forEach(function (row, index, array) { debug(threadName + "Got rows from initial SQL query: " + JSON.stringify(row)); global.mysql.query("SELECT transaction_hash, mixin FROM transactions WHERE id = ? ORDER BY id DESC", [row.transaction_id]).then(function (txnrows) { From c85d7e47bd1527dac3f7da8286f6ce0851190bbe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 09:33:23 +0200 Subject: [PATCH 0519/2430] Optimized pool type handling --- lib/api.js | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/api.js b/lib/api.js index 69874e10..cc44f320 100644 --- a/lib/api.js +++ b/lib/api.js @@ -24,15 +24,9 @@ if (cluster.isMaster) { } let pool_list = []; -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'); -} +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(cache('10 seconds')); app.use(cors({origin: true})); @@ -327,22 +321,16 @@ app.get('/pool/payments/:pool_type', function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; switch (pool_type) { - case 'pplns': - break; - case 'pps': - break; - case 'solo': - break; - default: - return res.json({'error': 'Invalid pool type'}); + case 'pplns': break; + case 'pps': break; + case 'solo': break; + default: return res.json({'error': 'Invalid pool type'}); } let paymentIds = []; let query = "SELECT distinct(transaction_id) as txnID FROM payments WHERE pool_type = ? ORDER BY transaction_id DESC LIMIT ? OFFSET ?"; let response = []; global.mysql.query(query, [pool_type, limit, page * limit]).then(function (rows) { - if (rows.length === 0) { - return res.json([]); - } + if (rows.length === 0) return res.json([]); rows.forEach(function (row, index, array) { paymentIds.push(row.txnID); if (array.length === paymentIds.length) { @@ -379,12 +367,10 @@ app.get('/pool/payments', function (req, res) { let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; let query = "SELECT * FROM transactions ORDER BY id DESC LIMIT ? OFFSET ?"; global.mysql.query(query, [limit, page * limit]).then(function (rows) { - if (rows.length === 0) { - return res.json([]); - } + if (rows.length === 0) return res.json([]); let response = []; rows.forEach(function (row, index, array) { - if (row.id in tx_pool_types) { + if (row.id in tx_pool_types || pool_list.length === 1) { let ts = new Date(row.submitted_time); response.push({ id: row.id, @@ -394,13 +380,17 @@ app.get('/pool/payments', function (req, res) { fee: row.fees, value: row.xmr_amt, ts: ts.getTime(), - pool_type: tx_pool_types[row.id] + pool_type: (row.id in tx_pool_types ? tx_pool_types[row.id] : pool_list[0]) }); if (array.length === response.length) { res.json(response.sort(global.support.tsCompare)); } } else { global.mysql.query("SELECT pool_type FROM payments WHERE transaction_id = ? LIMIT 1", [row.id]).then(function (ptRows) { + if (ptRows.length === 0) { + console.error("Unknown pool_type for tx_id " + row.id); + ptRows = [ { "pool_type": "?" } ]; + } let ts = new Date(row.submitted_time); tx_pool_types[row.id] = ptRows[0].pool_type; response.push({ @@ -450,9 +440,7 @@ app.get('/miner/:address/payments', function (req, res) { } let response = []; global.mysql.query(query, [address, payment_id, limit, page * limit]).then(function (rows) { - if (rows.length === 0) { - return res.json(response); - } + if (rows.length === 0) return res.json(response); rows.forEach(function (row, index, array) { debug(threadName + "Got rows from initial SQL query: " + JSON.stringify(row)); global.mysql.query("SELECT transaction_hash, mixin FROM transactions WHERE id = ? ORDER BY id DESC", [row.transaction_id]).then(function (txnrows) { From 430b04f6fdc63ca010d777f1174b2f43f36c1b54 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 09:36:09 +0200 Subject: [PATCH 0520/2430] More faster check first --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index cc44f320..192911b4 100644 --- a/lib/api.js +++ b/lib/api.js @@ -370,7 +370,7 @@ app.get('/pool/payments', function (req, res) { if (rows.length === 0) return res.json([]); let response = []; rows.forEach(function (row, index, array) { - if (row.id in tx_pool_types || pool_list.length === 1) { + if (pool_list.length === 1 || row.id in tx_pool_types) { let ts = new Date(row.submitted_time); response.push({ id: row.id, @@ -380,7 +380,7 @@ app.get('/pool/payments', function (req, res) { fee: row.fees, value: row.xmr_amt, ts: ts.getTime(), - pool_type: (row.id in tx_pool_types ? tx_pool_types[row.id] : pool_list[0]) + pool_type: (pool_list.length === 1 ? pool_list[0] : tx_pool_types[row.id]) }); if (array.length === response.length) { res.json(response.sort(global.support.tsCompare)); From 8645a89b1c07ad913ebff6e74e7c82ba4ee01de8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 10:00:45 +0200 Subject: [PATCH 0521/2430] Removed ? from tx pool type cache --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 192911b4..6ca67e0e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -370,7 +370,7 @@ app.get('/pool/payments', function (req, res) { if (rows.length === 0) return res.json([]); let response = []; rows.forEach(function (row, index, array) { - if (pool_list.length === 1 || row.id in tx_pool_types) { + if (pool_list.length === 1 || (row.id in tx_pool_types && tx_pool_types[row.id] != "?")) { let ts = new Date(row.submitted_time); response.push({ id: row.id, From 2cf4a5861b3365fba497041e0990ed57abf95e50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 10:01:39 +0200 Subject: [PATCH 0522/2430] Removed ? from tx pool type cache --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index cc44f320..6ca67e0e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -370,7 +370,7 @@ app.get('/pool/payments', function (req, res) { if (rows.length === 0) return res.json([]); let response = []; rows.forEach(function (row, index, array) { - if (row.id in tx_pool_types || pool_list.length === 1) { + if (pool_list.length === 1 || (row.id in tx_pool_types && tx_pool_types[row.id] != "?")) { let ts = new Date(row.submitted_time); response.push({ id: row.id, @@ -380,7 +380,7 @@ app.get('/pool/payments', function (req, res) { fee: row.fees, value: row.xmr_amt, ts: ts.getTime(), - pool_type: (row.id in tx_pool_types ? tx_pool_types[row.id] : pool_list[0]) + pool_type: (pool_list.length === 1 ? pool_list[0] : tx_pool_types[row.id]) }); if (array.length === response.length) { res.json(response.sort(global.support.tsCompare)); From df5577307401ed100c946a12634c231488a3dfb0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 10:26:43 +0200 Subject: [PATCH 0523/2430] More debugging --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9c7d04a5..16a31b7f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -706,7 +706,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer console.error("> " + best_algo + " " + best_algo_hr); // !!! FOR DEBUGGING PURPOSES if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; - console.error(">X " + miner.algos + " " + port); // !!! FOR DEBUGGING PURPOSES + console.error(">X " + JSON.stringify(miner.algos) + " " + port); // !!! FOR DEBUGGING PURPOSES if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; console.error(">> " + miner.algos_hr[algo] + " " + (miner.algos_hr[algo] * algoHashFactor)); // !!! FOR DEBUGGING PURPOSES From 761bd9264ea8d5c8e25ab7582167ac1bd1a6439a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 10:45:50 +0200 Subject: [PATCH 0524/2430] Fixed algos set --- lib/pool.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 16a31b7f..52dcf0d6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -568,7 +568,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.setAlgos = function(algos, algos_hr) { if (algos && (algos instanceof Array) && (algos.includes("cn/1") || algos.includes("cryptonight/1"))) { this.algos = {}; - for (let algo in algos) this.algos[algo] = 1; + for (let i in algos) this.algos[algos[i]] = 1; } else { return "algo array should include cn/1 or cryptonight/1"; } @@ -615,18 +615,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.port = port; this.portType = portType; switch (portType) { - case 'pplns': - this.poolTypeEnum = global.protos.POOLTYPE.PPLNS; - break; - case 'pps': - this.poolTypeEnum = global.protos.POOLTYPE.PPS; - break; - case 'solo': - this.poolTypeEnum = global.protos.POOLTYPE.SOLO; - break; - case 'prop': - this.poolTypeEnum = global.protos.POOLTYPE.PROP; - break; + case 'pplns': this.poolTypeEnum = global.protos.POOLTYPE.PPLNS; break; + case 'pps': this.poolTypeEnum = global.protos.POOLTYPE.PPS; break; + case 'solo': this.poolTypeEnum = global.protos.POOLTYPE.SOLO; break; + case 'prop': this.poolTypeEnum = global.protos.POOLTYPE.PROP; break; + default: console.error("Wrong portType " + portType); + this.poolTypeEnum = global.protos.POOLTYPE.PPLNS; } // 3c) diff stuff From afbf6776b89fca29a3f2e56a65aaa0f9a18f8ef0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 10:50:42 +0200 Subject: [PATCH 0525/2430] Removed debug info --- lib/pool.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 52dcf0d6..8056cdd1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -697,13 +697,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_algo_hr = this.algos_hr[""]; let miner = this; ALGOS.forEach(function(algo) { - console.error("> " + best_algo + " " + best_algo_hr); // !!! FOR DEBUGGING PURPOSES if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; - console.error(">X " + JSON.stringify(miner.algos) + " " + port); // !!! FOR DEBUGGING PURPOSES if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; - console.error(">> " + miner.algos_hr[algo] + " " + (miner.algos_hr[algo] * algoHashFactor)); // !!! FOR DEBUGGING PURPOSES if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { best_algo = algo; best_algo_hr = miner.algos_hr[algo] * algoHashFactor; From b715cdc9ab5e7a90d9571be0e1fc40c4fbac6f07 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 10:53:06 +0200 Subject: [PATCH 0526/2430] Added debug info --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 8056cdd1..234f0e83 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -702,6 +702,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { + console.error(miner.logString + ": " + algo + ": " + miner.algos_hr[algo] * algoHashFactor); best_algo = algo; best_algo_hr = miner.algos_hr[algo] * algoHashFactor; } From 39728254ff1247b058c6c9214c15d5adf37386e7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 16:47:18 +0200 Subject: [PATCH 0527/2430] Fixed threshold setting --- lib/api.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index 6ca67e0e..afc114ec 100644 --- a/lib/api.js +++ b/lib/api.js @@ -604,9 +604,8 @@ secureRoutes.post('/toggleEmail', function (req, res) { secureRoutes.post('/changePayoutThreshold', function (req, res) { let threshold = req.body.threshold; - if (threshold < global.config.payout.walletMin) { - threshold = global.config.payout.walletMin; - } + if (!threshold) return res.json({'msg': "Can't set threshold to 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.decoded.id]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); From 233a700ad05bb78b13ba27f74d077c193e08f6fc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 16:48:24 +0200 Subject: [PATCH 0528/2430] Fixed threshold setting --- lib/api.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index 6ca67e0e..afc114ec 100644 --- a/lib/api.js +++ b/lib/api.js @@ -604,9 +604,8 @@ secureRoutes.post('/toggleEmail', function (req, res) { secureRoutes.post('/changePayoutThreshold', function (req, res) { let threshold = req.body.threshold; - if (threshold < global.config.payout.walletMin) { - threshold = global.config.payout.walletMin; - } + if (!threshold) return res.json({'msg': "Can't set threshold to 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.decoded.id]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); From 171d2fcc3e1ad30cebc5369e655794aab53b6360 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 16:54:18 +0200 Subject: [PATCH 0529/2430] Added threshold set error --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index afc114ec..66914a1e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -604,7 +604,7 @@ secureRoutes.post('/toggleEmail', function (req, res) { secureRoutes.post('/changePayoutThreshold', function (req, res) { let threshold = req.body.threshold; - if (!threshold) return res.json({'msg': "Can't set threshold to wrong value"}); + 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.decoded.id]).then(function () { From eaea6651c42fe7fc54e684e049be31471eb141dd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 18 May 2018 17:14:09 +0200 Subject: [PATCH 0530/2430] Added threshold set error --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index afc114ec..66914a1e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -604,7 +604,7 @@ secureRoutes.post('/toggleEmail', function (req, res) { secureRoutes.post('/changePayoutThreshold', function (req, res) { let threshold = req.body.threshold; - if (!threshold) return res.json({'msg': "Can't set threshold to wrong value"}); + 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.decoded.id]).then(function () { From 5518088bf83777af7490ae3cada7d1ae08242866 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 20 May 2018 08:22:22 +0200 Subject: [PATCH 0531/2430] Removed debug code --- lib/coins/xmr.js | 1 - lib/pool.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3e5d9be5..09a770b7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -232,7 +232,6 @@ function Coin(data){ this.algoShortTypeStr = function(port) { switch (port) { - case 38081: return "cn-heavy"; // MSR // !!! FOR DEBUGGING PURPOSES ONLY default: return "cn/1"; } } diff --git a/lib/pool.js b/lib/pool.js index 234f0e83..7bee9ff7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -280,7 +280,6 @@ function updateActivePort(algo) { } }); } else if (oldActivePort !== newActivePort) { - if (newActivePort != 38081 && newActivePort != 18081) return; // !!! FOR DEBUGGING PURPOSES ONLY 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; @@ -562,9 +561,6 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return; } - algos = [ "cn/1", "cn-heavy" ]; // !!! FOR DEBUGGING PURPOSES ONLY - algos_hr = { "cn/1": 1000, "cn-heavy": 700 }; // !!! FOR DEBUGGING PURPOSES ONLY - this.setAlgos = function(algos, algos_hr) { if (algos && (algos instanceof Array) && (algos.includes("cn/1") || algos.includes("cryptonight/1"))) { this.algos = {}; From eacad7c9f2d0b0862712ac08148de4845d989299 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 20 May 2018 08:31:37 +0200 Subject: [PATCH 0532/2430] Disabled smart miners until their support will be finalized --- lib/pool.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7bee9ff7..103404cd 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -582,14 +582,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return ""; }; - if (algos && algos_hr) { - const status = this.setAlgos(algos, algos_hr); - if (status != "") { - this.error = status; - this.valid_miner = false; - return; - } - } + //if (algos && algos_hr) { + // const status = this.setAlgos(algos, algos_hr); + // if (status != "") { + // this.error = status; + // this.valid_miner = false; + // return; + // } + //} // 3) setup valid miner stuff From 769cf6511143de7736d34cc3ab0b5b8b6b6d15d2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 21 May 2018 19:39:09 +0200 Subject: [PATCH 0533/2430] Increased wallet timeout --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 26bfa3fa..63cedd04 100644 --- a/lib/support.js +++ b/lib/support.js @@ -167,7 +167,7 @@ function rpc_wallet(host, port, method, params, callback) { method: method, params: params }; - return jsonRequest(host, port, data, true, callback, 'json_rpc', 10*60*1000); + return jsonRequest(host, port, data, true, callback, 'json_rpc', 20*60*1000); } function getAlgoHashFactor(algo, callback) { From 8b89eb65c1ae823565b9c9c5637ef60c603e4461 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 21 May 2018 20:51:34 +0200 Subject: [PATCH 0534/2430] Increased damon timeout --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 63cedd04..aaa721dd 100644 --- a/lib/support.js +++ b/lib/support.js @@ -247,10 +247,10 @@ function tsCompare(a, b) { module.exports = function () { return { rpcDaemon: function (method, params, callback) { - rpc(global.config.daemon.address, global.config.daemon.port, method, params, callback, 2*1000); + rpc(global.config.daemon.address, global.config.daemon.port, method, params, callback, 10*1000); }, rpcPortDaemon: function (port, method, params, callback) { - rpc(global.config.daemon.address, port, method, params, callback, 2*1000); + rpc(global.config.daemon.address, port, method, params, callback, 10*1000); }, rpcWallet: function (method, params, callback) { rpc_wallet(global.config.wallet.address, global.config.wallet.port, method, params, callback); From d77b46820b18119a533a2186f1369335908acafd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 22 May 2018 12:45:05 +0200 Subject: [PATCH 0535/2430] Increased damon timeout --- lib/support.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/support.js b/lib/support.js index aaa721dd..3323a1a2 100644 --- a/lib/support.js +++ b/lib/support.js @@ -167,7 +167,7 @@ function rpc_wallet(host, port, method, params, callback) { method: method, params: params }; - return jsonRequest(host, port, data, true, callback, 'json_rpc', 20*60*1000); + return jsonRequest(host, port, data, true, callback, 'json_rpc', 30*60*1000); } function getAlgoHashFactor(algo, callback) { @@ -247,10 +247,10 @@ function tsCompare(a, b) { module.exports = function () { return { rpcDaemon: function (method, params, callback) { - rpc(global.config.daemon.address, global.config.daemon.port, method, params, callback, 10*1000); + rpc(global.config.daemon.address, global.config.daemon.port, method, params, callback, 30*1000); }, rpcPortDaemon: function (port, method, params, callback) { - rpc(global.config.daemon.address, port, method, params, callback, 10*1000); + 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); From 853789ec0d0c29ca938d84e7e9ad42ce7c344d99 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 22 May 2018 21:43:53 +0200 Subject: [PATCH 0536/2430] Fixed getActivePort --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 851145a1..7fd62cd5 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -357,7 +357,7 @@ function delayed_send_worker_stopped_hashing_email(miner, email, currentTime) { function updatePoolStats(poolType) { if (global.config.daemon.activePort) { - global.support.getActivePort(function (newActivePort) { + global.support.getActivePort("", function (newActivePort) { if (newActivePort) global.config.daemon.activePort = newActivePort; updatePoolStats2(poolType); }); From 072e0266bfd46ef4e16cf6da199013c4ae3b9e24 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 23 May 2018 22:23:20 +0200 Subject: [PATCH 0537/2430] Updated to v0.12.1.0 --- AEON-Notes.md | 9 ---- deployment/aeon.service | 13 ----- deployment/deploy.bash | 2 +- deployment/deploy_aeon.bash | 96 ---------------------------------- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 8 +-- 6 files changed, 7 insertions(+), 123 deletions(-) delete mode 100644 AEON-Notes.md delete mode 100644 deployment/aeon.service delete mode 100644 deployment/deploy_aeon.bash diff --git a/AEON-Notes.md b/AEON-Notes.md deleted file mode 100644 index 5952d6be..00000000 --- a/AEON-Notes.md +++ /dev/null @@ -1,9 +0,0 @@ -# Notes about AEON coin - -#### Special considerations for AEON - -NodeJS-Pool and PoolUI were built with monero in mind. While a recent update has made the pool compatible with Cryptonight-lite, the UI itself, by another developer, was hardcoded for Monero. Due to this there's a few things that need to be changed for the pool to successfully work. - - - aeond does not have a blockchain import function. So this makes downloading a blockchain.bin and importing it a bit difficult to do. I have included in my deploy.bash script a url i'm providing to keep the blockchain up to date within atleast a week delay, but it's unusable at the moment - - Until the PoolUI can be updated to allow for coins to be changed via a config, we're going to need to use a separate fork that I'll provide. I'll be working to try to include what I can to make the fork work for Monero AND aeon, but for the purpose here, my main goal will be for Aeon's compatibility. - - NodeJS-Pool is a bit more complex than CryptoNote Uni Pool, but it appears to be working just fine for our purpsoes. I highly recommend testing it for 1-2blocks if possible. \ No newline at end of file diff --git a/deployment/aeon.service b/deployment/aeon.service deleted file mode 100644 index c805bdad..00000000 --- a/deployment/aeon.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Aeon Daemon -After=network.target - -[Service] -Type=forking -GuessMainPID=no -ExecStart=/usr/local/src/aeon/build/release/bin/aeon --rpc-bind-ip 127.0.0.1 --detach --restricted-rpc -Restart=always -User=aeondaemon - -[Install] -WantedBy=multi-user.target diff --git a/deployment/deploy.bash b/deployment/deploy.bash index dab2d32e..747319c1 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,7 +26,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout release-v0.12 +sudo git checkout v0.12.1.0 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/deploy_aeon.bash b/deployment/deploy_aeon.bash deleted file mode 100644 index c4536692..00000000 --- a/deployment/deploy_aeon.bash +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -echo "This assumes that you are doing a green-field install. If you're not, please exit in the next 15 seconds." -sleep 15 -echo "Continuing install, this will prompt you for your password if you're not already running as root and you didn't enable passwordless sudo. Please do not run me as root!" -if [[ `whoami` == "root" ]]; then - echo "You ran me as root! Do not run me as root!" - exit 1 -fi -ROOT_SQL_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) -CURUSER=$(whoami) -echo "Etc/UTC" | sudo tee -a /etc/timezone -sudo rm -rf /etc/localtime -sudo ln -s /usr/share/zoneinfo/Zulu /etc/localtime -sudo dpkg-reconfigure -f noninteractive tzdata -sudo apt-get update -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 -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 https://github.com/aeonix/aeon.git -#cd aeon -#sudo git checkout v0.9.14.0 -#sudo make -j$(nproc) -#sudo cp ~/nodejs-pool/deployment/aeon.service /lib/systemd/system/ -#sudo useradd -m aeondaemon -d /home/aeondaemon -#sudo -u aeondaemon mkdir /home/aeondaemon/.aeon -#BLOCKCHAIN_DOWNLOAD_DIR=$(sudo -u aeondaemon mktemp -d) -#sudo -u aeondaemon wget --limit-rate=50m -O $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.bin http://74.208.156.45/blockchain.raw -#sudo -u aeondaemon mv $BLOCKCHAIN_DOWNLOAD_DIR/blockchain.bin /home/aeondaemon/.aeon/blockchain.bin -#sudo -u aeondaemon rm -rf $BLOCKCHAIN_DOWNLOAD_DIR -#sudo systemctl daemon-reload -#sudo systemctl enable aeon -#sudo systemctl start aeon -curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash -source ~/.nvm/nvm.sh -nvm install v6.9.2 -cd ~/nodejs-pool -npm install -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 -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 -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 -sudo mv caddy /usr/local/bin -sudo chown root:root /usr/local/bin/caddy -sudo chmod 755 /usr/local/bin/caddy -sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy -sudo groupadd -g 33 www-data -sudo useradd -g www-data --no-user-group --home-dir /var/www --no-create-home --shell /usr/sbin/nologin --system --uid 33 www-data -sudo mkdir /etc/caddy -sudo chown -R root:www-data /etc/caddy -sudo mkdir /etc/ssl/caddy -sudo chown -R www-data:root /etc/ssl/caddy -sudo chmod 0770 /etc/ssl/caddy -sudo cp ~/nodejs-pool/deployment/caddyfile /etc/caddy/Caddyfile -sudo chown www-data:www-data /etc/caddy/Caddyfile -sudo chmod 444 /etc/caddy/Caddyfile -sudo sh -c "sed 's/ProtectHome=true/ProtectHome=false/' init/linux-systemd/caddy.service > /etc/systemd/system/caddy.service" -sudo chown root:root /etc/systemd/system/caddy.service -sudo chmod 644 /etc/systemd/system/caddy.service -sudo systemctl daemon-reload -sudo systemctl enable caddy.service -sudo systemctl start caddy.service -rm -rf $CADDY_DOWNLOAD_DIR -cd ~ -sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin `pwd`/.nvm/versions/node/v6.9.2/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` -cd ~/nodejs-pool -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 -mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')" -mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" -pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api -bash ~/nodejs-pool/deployment/install_lmdb_tools.sh -cd ~/nodejs-pool/sql_sync/ -env PATH=$PATH:`pwd`/.nvm/versions/node/v6.9.2/bin node sql_sync.js -echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" diff --git a/deployment/leaf.bash b/deployment/leaf.bash index a86ddc22..40f54214 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -22,7 +22,7 @@ sudo systemctl enable ntp cd /usr/local/src sudo git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout release-v0.12 +sudo git checkout v0.12.1.0 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 b779f519..b1274a11 100644 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -2,12 +2,14 @@ echo "This assumes that you have a standard nodejs-pool install, and will patch and update it to the latest stable builds of Monero." sleep 15 echo "Continuing install, this will prompt you for your password if you didn't enable passwordless sudo. Please do not run me as root!" -cd /usr/local/src/monero + sudo git checkout . sudo git checkout master sudo git pull -sudo git checkout origin/release-v0.12 -curl -L https://raw.githubusercontent.com/Snipa22/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v +sudo git checkout v0.12.1.0 +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 make -j$(nproc) 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 b082693600888bf31ee9417a5baa354321f3df71 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 23 May 2018 22:25:40 +0200 Subject: [PATCH 0538/2430] Added nice build --- 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 b1274a11..489349b2 100644 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -11,5 +11,5 @@ curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deploym sudo git submodule init sudo git submodule update sudo rm -rf build -sudo make -j$(nproc) +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!" From 690a377e9d15bb50852e3f59a182b04fd1391818 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 23 May 2018 22:28:50 +0200 Subject: [PATCH 0539/2430] Added cd --- 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 489349b2..bec23268 100644 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -2,7 +2,7 @@ echo "This assumes that you have a standard nodejs-pool install, and will patch and update it to the latest stable builds of Monero." sleep 15 echo "Continuing install, this will prompt you for your password if you didn't enable passwordless sudo. Please do not run me as root!" - +cd /usr/local/src/monero sudo git checkout . sudo git checkout master sudo git pull From 43786993462643772b14546367c55068a0d02533 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 23 May 2018 22:30:36 +0200 Subject: [PATCH 0540/2430] Added && --- deployment/upgrade_monero.bash | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index bec23268..60e9145b 100644 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -2,14 +2,14 @@ echo "This assumes that you have a standard nodejs-pool install, and will patch and update it to the latest stable builds of Monero." sleep 15 echo "Continuing install, this will prompt you for your password if you didn't enable passwordless sudo. Please do not run me as root!" -cd /usr/local/src/monero -sudo git checkout . -sudo git checkout master -sudo git pull -sudo git checkout v0.12.1.0 -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 +cd /usr/local/src/monero &&\ +sudo git checkout . &&\ +sudo git checkout master &&\ +sudo git pull &&\ +sudo git checkout v0.12.1.0 &&\ +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!" From 4ad388a629e31157a1afb021c42ae0a458864d02 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 23 May 2018 22:40:55 +0200 Subject: [PATCH 0541/2430] Added +x --- deployment/upgrade_monero.bash | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 deployment/upgrade_monero.bash diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash old mode 100644 new mode 100755 From cdd54c012162ac715df528486e5bfa955e8e283d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 09:42:38 +0200 Subject: [PATCH 0542/2430] Increasing caching for address stats --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 66914a1e..92a8851c 100644 --- a/lib/api.js +++ b/lib/api.js @@ -510,7 +510,7 @@ app.get('/miner/:address/chart/hashrate/:identifier', function (req, res) { return res.json(global.database.getCache("history:" + req.params.address + "_" + req.params.identifier)['hashHistory']); }); -app.get('/miner/:address/stats', function (req, res) { +app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { getAddressStats(req.params.address, function(err, data){ return res.json(data); }); From fe129c4ed5b135bd539ca6d47b9c7835d509920e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 09:44:26 +0200 Subject: [PATCH 0543/2430] Returned caching for address stats --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 92a8851c..66914a1e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -510,7 +510,7 @@ app.get('/miner/:address/chart/hashrate/:identifier', function (req, res) { return res.json(global.database.getCache("history:" + req.params.address + "_" + req.params.identifier)['hashHistory']); }); -app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { +app.get('/miner/:address/stats', function (req, res) { getAddressStats(req.params.address, function(err, data){ return res.json(data); }); From 11f1f9eacc8dff33c3824d49a45048070cf823b1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 09:53:35 +0200 Subject: [PATCH 0544/2430] Increasing caching for address stats --- lib/api.js | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/lib/api.js b/lib/api.js index 66914a1e..0f5dec7d 100644 --- a/lib/api.js +++ b/lib/api.js @@ -28,7 +28,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(cache('10 seconds')); app.use(cors({origin: true})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); @@ -175,7 +174,7 @@ function getAddressStats(address, extCallback){ // test route to make sure everything is working (accessed at GET http://localhost:8080/api) // Config API -app.get('/config', function (req, res) { +app.get('/config', cache('5 minutes'), function (req, res) { res.json({ pplns_fee: global.config.payout.pplnsFee, pps_fee: global.config.payout.ppsFee, @@ -193,7 +192,7 @@ app.get('/config', function (req, res) { }); // Pool APIs -app.get('/pool/address_type/:address', function (req, res) { +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))) { res.json({valid: true, address_type: global.config.general.coinCode}); @@ -204,7 +203,7 @@ app.get('/pool/address_type/:address', function (req, res) { } }); -app.get('/pool/stats', function (req, res) { +app.get('/pool/stats', cache('10 seconds'), function (req, res) { let localCache = global.database.getCache('pool_stats_global'); delete(localCache.minerHistory); delete(localCache.hashHistory); @@ -212,15 +211,15 @@ app.get('/pool/stats', function (req, res) { res.json({pool_list: pool_list, pool_statistics: localCache, last_payment: !lastPayment ? 0 : lastPayment}); }); -app.get('/pool/chart/hashrate', function (req, res) { +app.get('/pool/chart/hashrate', cache('10 seconds'), function (req, res) { res.json(global.database.getCache('global_stats')['hashHistory']); }); -app.get('/pool/chart/miners', function (req, res) { +app.get('/pool/chart/miners', cache('10 seconds'), function (req, res) { res.json(global.database.getCache('global_stats')['minerHistory']); }); -app.get('/pool/chart/hashrate/:pool_type', function (req, res) { +app.get('/pool/chart/hashrate/:pool_type', cache('10 seconds'), function (req, res) { let pool_type = req.params.pool_type; let localCache; switch (pool_type) { @@ -239,7 +238,7 @@ app.get('/pool/chart/hashrate/:pool_type', function (req, res) { res.json(localCache['hashHistory']); }); -app.get('/pool/chart/miners/:pool_type', function (req, res) { +app.get('/pool/chart/miners/:pool_type', cache('10 seconds'), function (req, res) { let pool_type = req.params.pool_type; let localCache; switch (pool_type) { @@ -258,7 +257,7 @@ app.get('/pool/chart/miners/:pool_type', function (req, res) { res.json(localCache['minerHistory']); }); -app.get('/pool/stats/:pool_type', function (req, res) { +app.get('/pool/stats/:pool_type', cache('10 seconds'), function (req, res) { let pool_type = req.params.pool_type; let localCache; switch (pool_type) { @@ -282,41 +281,41 @@ app.get('/pool/stats/:pool_type', function (req, res) { res.json({pool_statistics: localCache}); }); -app.get('/pool/ports', function (req, res) { +app.get('/pool/ports', cache('10 seconds'), function (req, res) { res.json(global.database.getCache('poolPorts')); }); -app.get('/pool/blocks/:pool_type', 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)); }); -app.get('/pool/altblocks/:pool_type', function (req, res) { +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)); }); -app.get('/pool/blocks', function (req, res) { +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)); }); -app.get('/pool/altblocks', function (req, res) { +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)); }); -app.get('/pool/coin_altblocks/:coin_port', function (req, res) { +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)); }); -app.get('/pool/payments/:pool_type', function (req, res) { +app.get('/pool/payments/:pool_type', cache('10 seconds'), function (req, res) { let pool_type = req.params.pool_type; let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; @@ -362,7 +361,7 @@ app.get('/pool/payments/:pool_type', function (req, res) { // cache pool_type here just to avoid multiple SQL requests let tx_pool_types = {}; -app.get('/pool/payments', function (req, res) { +app.get('/pool/payments', cache('10 seconds'), function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; let query = "SELECT * FROM transactions ORDER BY id DESC LIMIT ? OFFSET ?"; @@ -416,17 +415,17 @@ app.get('/pool/payments', function (req, res) { }); // Network APIs -app.get('/network/stats', function (req, res) { +app.get('/network/stats', cache('10 seconds'), function (req, res) { res.json(global.database.getCache('networkBlockInfo')); }); // Miner APIs -app.get('/miner/:address/identifiers', function (req, res) { +app.get('/miner/:address/identifiers', cache('10 seconds'), function (req, res) { let address = req.params.address; return res.json(global.database.getCache(address + '_identifiers')); }); -app.get('/miner/:address/payments', function (req, res) { +app.get('/miner/:address/payments', 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; let address_parts = req.params.address.split('.'); @@ -465,13 +464,13 @@ app.get('/miner/:address/payments', function (req, res) { }); }); -app.get('/miner/:address/stats/allWorkers', function (req, res) { +app.get('/miner/:address/stats/allWorkers', cache('10 seconds'), function (req, res) { getAllWorkerStats(req.params.address, function(err, data){ return res.json(data); }); }); -app.get('/miner/:address/stats/:identifier', function (req, res) { +app.get('/miner/:address/stats/:identifier', cache('10 seconds'), function (req, res) { let address = req.params.address; let identifier = req.params.identifier; let memcKey = address + "_" + identifier; @@ -496,21 +495,21 @@ app.get('/miner/:address/stats/:identifier', function (req, res) { }); }); -app.get('/miner/:address/chart/hashrate', function (req, res) { +app.get('/miner/:address/chart/hashrate', cache('10 seconds'), function (req, res) { return res.json(global.database.getCache("history:" + req.params.address)['hashHistory']); }); -app.get('/miner/:address/chart/hashrate/allWorkers', function (req, res) { +app.get('/miner/:address/chart/hashrate/allWorkers', cache('10 seconds'), function (req, res) { getAllWorkerHashCharts(req.params.address, function(err, data){ return res.json(data); }); }); -app.get('/miner/:address/chart/hashrate/:identifier', function (req, res) { +app.get('/miner/:address/chart/hashrate/:identifier', cache('10 seconds'), function (req, res) { return res.json(global.database.getCache("history:" + req.params.address + "_" + req.params.identifier)['hashHistory']); }); -app.get('/miner/:address/stats', function (req, res) { +app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { getAddressStats(req.params.address, function(err, data){ return res.json(data); }); From 6b338665925530bcfb7ff5a2bf70caa55457502e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 09:59:48 +0200 Subject: [PATCH 0545/2430] Increasing caching for payment stuff --- lib/api.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index 0f5dec7d..b6217a7f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -315,7 +315,7 @@ app.get('/pool/coin_altblocks/:coin_port', cache('10 seconds'), function (req, r res.json(global.database.getAltBlockList(null, parseInt(req.params.coin_port)).slice(page*limit, (page + 1) * limit)); }); -app.get('/pool/payments/:pool_type', cache('10 seconds'), function (req, res) { +app.get('/pool/payments/:pool_type', cache('1 minute'), function (req, res) { let pool_type = req.params.pool_type; let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; @@ -361,7 +361,7 @@ app.get('/pool/payments/:pool_type', cache('10 seconds'), function (req, res) { // cache pool_type here just to avoid multiple SQL requests let tx_pool_types = {}; -app.get('/pool/payments', cache('10 seconds'), function (req, res) { +app.get('/pool/payments', cache('1 minute'), function (req, res) { let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; let query = "SELECT * FROM transactions ORDER BY id DESC LIMIT ? OFFSET ?"; @@ -425,7 +425,7 @@ app.get('/miner/:address/identifiers', cache('10 seconds'), function (req, res) return res.json(global.database.getCache(address + '_identifiers')); }); -app.get('/miner/:address/payments', cache('10 seconds'), function (req, res) { +app.get('/miner/:address/payments', cache('1 minute'), 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; let address_parts = req.params.address.split('.'); From 8a3c09c25f9e3da7f3ff85492eb46832f0459c03 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 12:49:11 +0200 Subject: [PATCH 0546/2430] Make use of last_edited --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 382ff34c..be0cfc7d 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -6,7 +6,7 @@ USE pool; ALTER DATABASE pool DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `balance` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `last_edited` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `last_edited` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `payment_address` varchar(128) DEFAULT NULL, `payment_id` varchar(128) DEFAULT NULL, `pool_type` varchar(64) DEFAULT NULL, From 6b75b28c2eb7e4ff21c58268494785944a46c168 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 13:19:07 +0200 Subject: [PATCH 0547/2430] More reliable PPLNS payments --- lib/blockManager.js | 76 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 9053da36..a9834221 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -43,7 +43,7 @@ let blockQueue = async.queue(function (task, callback) { }, 16); blockQueue.drain = function () { - console.log("Scan complete, unlocking remainder of blockManager functionality."); + console.log("blockQueue drained: unlocking remainder of blockManager functionality"); scanInProgress = false; if (typeof(blockScannerTask) === 'undefined'){ blockScannerTask = setInterval(blockScanner, 1000); @@ -125,6 +125,37 @@ let balanceQueue = async.queue(function (task, callback) { }, 24 ); +let block_unlock_callback; +let prev_balance_sum; + +balanceQueue.drain = function () { + console.log("balanceQueue drained"); + if (!block_unlock_callback) { + console.error("block_unlock_callback is not defined"); + return; + } + if (!prev_balance_sum) { + console.error("prev_balance_sum is not defined"); + return; + } + global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { + if (typeof(rows[0]) === 'undefined') { + console.error("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); + block_unlock_callback = null; + prev_balance_sum = null; + return; + } + let balance_sum = rows[0].amt; + if (balance_sum > prev_balance_sum) { + block_unlock_callback(); + } else { + console.error("Balance not changed from " + prev_balance_sum + " to " + balance_sum); + } + block_unlock_callback = null; + prev_balance_sum = null; + }); +}; + function calculatePPSPayments(blockHeader, callback) { if (global.config.pps.enable === true) { console.log("Performing PPS payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); @@ -216,11 +247,15 @@ function calculatePPSPayments(blockHeader, callback) { return callback(); } -function calculatePPLNSPayments(block_height, block_reward, block_difficulty, unlock_callback) { +function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { if (paymentInProgress) { debug("Skipping block payment run as there's a payment in progress"); return; } + if (balanceQueue.idle() === false) { + debug("Skipping block unlocker run a balanceQueue is not empty"); + return; + } paymentInProgress = true; console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward)); let rewardTotal = block_reward; @@ -355,7 +390,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un 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 + ")"); - unlock_callback(); paymentInProgress = false; if (totalPayments != block_reward) { global.support.sendEmail(global.config.general.adminEmail, @@ -457,6 +491,10 @@ function blockUnlocker() { debug("Skipping block unlocker run as there's a payment in progress"); return; } + if (balanceQueue.idle() === false) { + debug("Skipping block unlocker run a balanceQueue is not empty"); + return; + } debug("Running block unlocker"); let blockList = global.database.getValidLockedBlocks(); global.coinFuncs.getLastBlockHeader(function(err, body){ @@ -496,6 +534,10 @@ function altblockUnlocker() { debug("Skipping altblock unlocker run as there's a payment in progress"); return; } + if (balanceQueue.idle() === false) { + debug("Skipping block unlocker run a balanceQueue is not empty"); + return; + } debug("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); blockList.forEach(function (block) { @@ -528,9 +570,17 @@ function blockPayments(block) { 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){ - calculatePPLNSPayments(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); + global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { + if (typeof(rows[0]) === 'undefined') { + console.error("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); + return; + } + prev_balance_sum = rows[0].amt; + block_unlock_callback = function() { + console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); + global.database.unlockBlock(block.hash); + } + calculatePPLNSPayments(block.height, block.value, block.difficulty); }); } else { console.error("Can't get correct block header by hash " + block.hash.toString('hex')); @@ -559,9 +609,17 @@ function altblockPayments(block) { 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){ - 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); + global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { + if (typeof(rows[0]) === 'undefined') { + console.error("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); + return; + } + prev_balance_sum = rows[0].amt; + block_unlock_callback = function() { + console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); + global.database.unlockAltBlock(block.hash); + }; + calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty); }); } else { console.error("Can't get correct block header by height " + block.anchor_height.toString()); From 563bb93caaffe08154a6b6c36540618619ec2f2e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 13:20:44 +0200 Subject: [PATCH 0548/2430] Reduced amount of spam message --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index a9834221..74c4bc14 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -43,7 +43,7 @@ let blockQueue = async.queue(function (task, callback) { }, 16); blockQueue.drain = function () { - console.log("blockQueue drained: unlocking remainder of blockManager functionality"); + debug("blockQueue drained: unlocking remainder of blockManager functionality"); scanInProgress = false; if (typeof(blockScannerTask) === 'undefined'){ blockScannerTask = setInterval(blockScanner, 1000); From 34ea5b438a16bb3d2a6d37acedcbe783402c3a05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 13:27:16 +0200 Subject: [PATCH 0549/2430] Avoid possible race condition --- lib/blockManager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 74c4bc14..98efcfa1 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -252,7 +252,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { debug("Skipping block payment run as there's a payment in progress"); return; } - if (balanceQueue.idle() === false) { + if (balanceQueue.idle() === false || block_unlock_callback || prev_balance_sum) { debug("Skipping block unlocker run a balanceQueue is not empty"); return; } @@ -491,7 +491,7 @@ function blockUnlocker() { debug("Skipping block unlocker run as there's a payment in progress"); return; } - if (balanceQueue.idle() === false) { + if (balanceQueue.idle() === false || block_unlock_callback || prev_balance_sum) { debug("Skipping block unlocker run a balanceQueue is not empty"); return; } @@ -534,7 +534,7 @@ function altblockUnlocker() { debug("Skipping altblock unlocker run as there's a payment in progress"); return; } - if (balanceQueue.idle() === false) { + if (balanceQueue.idle() === false || block_unlock_callback || prev_balance_sum) { debug("Skipping block unlocker run a balanceQueue is not empty"); return; } @@ -695,7 +695,7 @@ function initial_sync() { setInterval(altblockUnlocker, 120000); 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."); + console.log("Boot-sync from SQL complete: pending completion of queued jobs to get back to work."); }); } From 1cecbf70ae889858b1b34956d4df5d9c68f9e438 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 13:28:50 +0200 Subject: [PATCH 0550/2430] Avoid possible race condition --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 98efcfa1..acacb5f4 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -129,15 +129,15 @@ let block_unlock_callback; let prev_balance_sum; balanceQueue.drain = function () { - console.log("balanceQueue drained"); if (!block_unlock_callback) { - console.error("block_unlock_callback is not defined"); + debug("block_unlock_callback is not defined"); return; } if (!prev_balance_sum) { - console.error("prev_balance_sum is not defined"); + debug("prev_balance_sum is not defined"); return; } + console.log("balanceQueue drained: performing block unlocking"); global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { if (typeof(rows[0]) === 'undefined') { console.error("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); From ee45fb07abec3e31afec96d9c5ddee38cc0574f4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 13:30:45 +0200 Subject: [PATCH 0551/2430] More logs --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index acacb5f4..79e3f64e 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -495,7 +495,7 @@ function blockUnlocker() { debug("Skipping block unlocker run a balanceQueue is not empty"); return; } - debug("Running block unlocker"); + console.log("Running block unlocker"); let blockList = global.database.getValidLockedBlocks(); global.coinFuncs.getLastBlockHeader(function(err, body){ if (err !== null) { @@ -690,9 +690,9 @@ function initial_sync() { // Enable block scanning for 1 seconds to update the block log. blockScanner(); // Scan every 120 seconds for invalidated blocks - setInterval(blockUnlocker, 120000); + setInterval(blockUnlocker, 2*60*1000); blockUnlocker(); - setInterval(altblockUnlocker, 120000); + 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 61769b6be48092dcd7d3243dffbde1360c03c259 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 13:37:38 +0200 Subject: [PATCH 0552/2430] More logs --- lib/blockManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 79e3f64e..56571fb3 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -147,9 +147,10 @@ balanceQueue.drain = function () { } let balance_sum = rows[0].amt; if (balance_sum > prev_balance_sum) { + console.log("Total balance increased from " + global.support.coinToDecimal(prev_balance_sum) + " to " + global.support.coinToDecimal(balance_sum)); block_unlock_callback(); } else { - console.error("Balance not changed from " + prev_balance_sum + " to " + balance_sum); + console.error("Total balance not changed from " + prev_balance_sum + " to " + balance_sum); } block_unlock_callback = null; prev_balance_sum = null; From 41e4fa4dc0e32b35582a30edf15644b19c7fa7e6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 13:45:49 +0200 Subject: [PATCH 0553/2430] Added panic mode --- lib/blockManager.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 56571fb3..b4a8d141 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -125,6 +125,18 @@ let balanceQueue = async.queue(function (task, callback) { }, 24 ); +let is_full_stop = false; + +function full_stop(err) { + is_full_stop = true; + console.error("Issue making balance increases: " + JSON.stringify(err)); + console.error("Will not make more balance increases until it is resolved!"); + //toAddress, subject, body + global.support.sendEmail(global.config.general.adminEmail, "blockManager unable to make balance increase", + "Hello,\r\nThe blockManager has hit an issue making a balance increase: " + JSON.stringify(err) + + ". Please investigate and restart blockManager as appropriate"); +} + let block_unlock_callback; let prev_balance_sum; @@ -140,7 +152,7 @@ balanceQueue.drain = function () { console.log("balanceQueue drained: performing block unlocking"); global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { if (typeof(rows[0]) === 'undefined') { - console.error("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); + full_stop("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); block_unlock_callback = null; prev_balance_sum = null; return; @@ -150,7 +162,7 @@ balanceQueue.drain = function () { console.log("Total balance increased from " + global.support.coinToDecimal(prev_balance_sum) + " to " + global.support.coinToDecimal(balance_sum)); block_unlock_callback(); } else { - console.error("Total balance not changed from " + prev_balance_sum + " to " + balance_sum); + full_stop("Total balance not changed from " + prev_balance_sum + " to " + balance_sum); } block_unlock_callback = null; prev_balance_sum = null; @@ -249,6 +261,10 @@ function calculatePPSPayments(blockHeader, callback) { } function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { + if (is_full_stop) { + debug("Dropping all PPLNS payments"); + return; + } if (paymentInProgress) { debug("Skipping block payment run as there's a payment in progress"); return; @@ -484,6 +500,10 @@ function calculateSoloPayments(blockHeader) { } 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; @@ -527,6 +547,10 @@ function blockUnlocker() { } function altblockUnlocker() { + if (is_full_stop) { + debug("Dropping all altblock unlocks"); + return; + } if (scanInProgress) { debug("Skipping altblock unlocker run as there's a scan in progress"); return; From 9869fa7cd5b3e29f496be5bb32f9b5acab1a5db3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 14:29:22 +0200 Subject: [PATCH 0554/2430] Disabled PPS more reliably --- lib/blockManager.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index b4a8d141..8d776bcf 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -170,9 +170,8 @@ balanceQueue.drain = function () { }; function calculatePPSPayments(blockHeader, callback) { - if (global.config.pps.enable === true) { - console.log("Performing PPS payout on block: " + blockHeader.height + " Block Value: " + global.support.coinToDecimal(blockHeader.reward)); - } + 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', @@ -254,9 +253,7 @@ function calculatePPSPayments(blockHeader, callback) { }); totalPayments += paymentData[key].amount; }); - if (global.config.pps.enable === true) { - 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 + "%"); - } + 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(); } @@ -560,7 +557,7 @@ function altblockUnlocker() { return; } if (balanceQueue.idle() === false || block_unlock_callback || prev_balance_sum) { - debug("Skipping block unlocker run a balanceQueue is not empty"); + debug("Skipping altblock unlocker run a balanceQueue is not empty"); return; } debug("Running altblock unlocker"); @@ -672,7 +669,7 @@ function blockScanner() { 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"); + //debug("No new work to be performed, block header matches last block"); scanInProgress = false; return; } From 7e13ff08d5925c8ce7d675a7449346ce2b24f644 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 14:47:14 +0200 Subject: [PATCH 0555/2430] Disabled queue idle test --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 8d776bcf..ea18b62f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -266,7 +266,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { debug("Skipping block payment run as there's a payment in progress"); return; } - if (balanceQueue.idle() === false || block_unlock_callback || prev_balance_sum) { + if (block_unlock_callback || prev_balance_sum) { debug("Skipping block unlocker run a balanceQueue is not empty"); return; } @@ -509,7 +509,7 @@ function blockUnlocker() { debug("Skipping block unlocker run as there's a payment in progress"); return; } - if (balanceQueue.idle() === false || block_unlock_callback || prev_balance_sum) { + if (block_unlock_callback || prev_balance_sum) { debug("Skipping block unlocker run a balanceQueue is not empty"); return; } @@ -556,7 +556,7 @@ function altblockUnlocker() { debug("Skipping altblock unlocker run as there's a payment in progress"); return; } - if (balanceQueue.idle() === false || block_unlock_callback || prev_balance_sum) { + if (block_unlock_callback || prev_balance_sum) { debug("Skipping altblock unlocker run a balanceQueue is not empty"); return; } From 3553d590951241c05212a0cb06aac6274617e45c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 15:05:22 +0200 Subject: [PATCH 0556/2430] Replaced undefined by null --- lib/blockManager.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index ea18b62f..24be0189 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -137,15 +137,15 @@ function full_stop(err) { ". Please investigate and restart blockManager as appropriate"); } -let block_unlock_callback; -let prev_balance_sum; +let block_unlock_callback = null; +let prev_balance_sum = null; balanceQueue.drain = function () { - if (!block_unlock_callback) { + if (block_unlock_callback === null) { debug("block_unlock_callback is not defined"); return; } - if (!prev_balance_sum) { + if (prev_balance_sum === null) { debug("prev_balance_sum is not defined"); return; } @@ -266,8 +266,8 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { debug("Skipping block payment run as there's a payment in progress"); return; } - if (block_unlock_callback || prev_balance_sum) { - debug("Skipping block unlocker run a balanceQueue is not empty"); + if (block_unlock_callback !== null || prev_balance_sum !== null) { + debug("Skipping block unlocker run since balanceQueue is not empty"); return; } paymentInProgress = true; @@ -509,8 +509,8 @@ function blockUnlocker() { debug("Skipping block unlocker run as there's a payment in progress"); return; } - if (block_unlock_callback || prev_balance_sum) { - debug("Skipping block unlocker run a balanceQueue is not empty"); + if (block_unlock_callback !== null || prev_balance_sum !== null) { + debug("Skipping block unlocker run since balanceQueue is not empty"); return; } console.log("Running block unlocker"); @@ -556,8 +556,8 @@ function altblockUnlocker() { debug("Skipping altblock unlocker run as there's a payment in progress"); return; } - if (block_unlock_callback || prev_balance_sum) { - debug("Skipping altblock unlocker run a balanceQueue is not empty"); + if (block_unlock_callback !== null || prev_balance_sum !== null) { + debug("Skipping altblock unlocker run since balanceQueue is not empty"); return; } debug("Running altblock unlocker"); From 23d246cf71d8a53bb2bb4b1b3e7339303d8a6d99 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 15:14:40 +0200 Subject: [PATCH 0557/2430] Fixed PPLNS payment --- lib/blockManager.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 24be0189..922c0bf9 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -141,12 +141,16 @@ let block_unlock_callback = null; let prev_balance_sum = null; balanceQueue.drain = function () { + if (!paymentInProgress) { + debug("balanceQueue.drain: paymentInProgress is false"); + return; + } if (block_unlock_callback === null) { - debug("block_unlock_callback is not defined"); + debug("balanceQueue.drain: block_unlock_callback is not defined"); return; } if (prev_balance_sum === null) { - debug("prev_balance_sum is not defined"); + debug("balanceQueue.drain: prev_balance_sum is not defined"); return; } console.log("balanceQueue drained: performing block unlocking"); @@ -155,6 +159,7 @@ balanceQueue.drain = function () { full_stop("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); block_unlock_callback = null; prev_balance_sum = null; + paymentInProgress = false; return; } let balance_sum = rows[0].amt; @@ -166,6 +171,7 @@ balanceQueue.drain = function () { } block_unlock_callback = null; prev_balance_sum = null; + paymentInProgress = false; }); }; @@ -266,10 +272,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { debug("Skipping block payment run as there's a payment in progress"); return; } - if (block_unlock_callback !== null || prev_balance_sum !== null) { - debug("Skipping block unlocker run since balanceQueue is not empty"); - return; - } paymentInProgress = true; console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward)); let rewardTotal = block_reward; @@ -404,7 +406,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { 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 + ")"); - paymentInProgress = false; if (totalPayments != block_reward) { global.support.sendEmail(global.config.general.adminEmail, "Block was not payed completely!", From f347f07dcd046a087b03241cb4f43d18c6193924 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 15:29:04 +0200 Subject: [PATCH 0558/2430] Fixed SQL query --- lib/blockManager.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 922c0bf9..3d502879 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -154,9 +154,9 @@ balanceQueue.drain = function () { return; } console.log("balanceQueue drained: performing block unlocking"); - global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { + global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { if (typeof(rows[0]) === 'undefined') { - full_stop("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); + full_stop("SELECT SUM(amount) as amt FROM balance query returned undefined result"); block_unlock_callback = null; prev_balance_sum = null; paymentInProgress = false; @@ -593,9 +593,9 @@ function blockPayments(block) { 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){ - global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { + global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { if (typeof(rows[0]) === 'undefined') { - console.error("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); + console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); return; } prev_balance_sum = rows[0].amt; @@ -632,9 +632,9 @@ function altblockPayments(block) { 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){ - global.mysql.query("SELECT SUM(amount) FROM pool.balance").then(function (rows) { + global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { if (typeof(rows[0]) === 'undefined') { - console.error("SELECT SUM(amount) as amt FROM pool.balance query returned undefined result"); + console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); return; } prev_balance_sum = rows[0].amt; From 24d3b085cc1236622d34485259b6810916484788 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 15:54:38 +0200 Subject: [PATCH 0559/2430] Joined some code --- lib/blockManager.js | 51 +++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 3d502879..f29f645b 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -264,15 +264,6 @@ function calculatePPSPayments(blockHeader, callback) { } function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { - if (is_full_stop) { - debug("Dropping all PPLNS payments"); - return; - } - if (paymentInProgress) { - debug("Skipping block payment run as there's a payment in progress"); - return; - } - paymentInProgress = true; console.log("Performing PPLNS payout on block: " + block_height + " Block Value: " + global.support.coinToDecimal(block_reward)); let rewardTotal = block_reward; let blockDiff = block_difficulty; @@ -584,6 +575,30 @@ function altblockUnlocker() { }); } +function prepareBlockPayment(callback) { + if (is_full_stop) { + debug("Dropping all payments"); + return; + } + if (paymentInProgress) { + debug("Skipping payment as there's a payment in progress"); + return; + } + if (block_unlock_callback !== null || prev_balance_sum !== null) { + debug("Skipping peyment since balanceQueue is not empty"); + return; + } + global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { + if (typeof(rows[0]) === 'undefined') { + console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); + return; + } + paymentInProgress = true; + prev_balance_sum = rows[0].amt; + callback(); + }); +} + function blockPayments(block) { switch (block.poolType) { case global.protos.POOLTYPE.PPS: @@ -593,12 +608,7 @@ function blockPayments(block) { 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){ - global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { - if (typeof(rows[0]) === 'undefined') { - console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); - return; - } - prev_balance_sum = rows[0].amt; + prepareBlockPayment(function() { block_unlock_callback = function() { console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockBlock(block.hash); @@ -632,17 +642,12 @@ function altblockPayments(block) { 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){ - global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { - if (typeof(rows[0]) === 'undefined') { - console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); - return; - } - prev_balance_sum = rows[0].amt; + prepareBlockPayment(function() { block_unlock_callback = function() { console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); global.database.unlockAltBlock(block.hash); - }; - calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty); + }; + calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty); }); } else { console.error("Can't get correct block header by height " + block.anchor_height.toString()); From bc473c69779737d99543a1ae967b569b3e9fe5a1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 16:10:00 +0200 Subject: [PATCH 0560/2430] Redisigned code to avoid queue drain race condition --- lib/blockManager.js | 98 +++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index f29f645b..5b295568 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -263,7 +263,7 @@ function calculatePPSPayments(blockHeader, callback) { return callback(); } -function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { +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; @@ -390,19 +390,31 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty) { console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); } let totalPayments = 0; - Object.keys(paymentData).forEach(function (key) { - paymentData[key].amount = Math.floor((paymentData[key].amount / (blockDiff*global.config.pplns.shareMulti)) * rewardTotal); - balanceQueue.push(paymentData[key], function () {}); - //console.log("[PAYMENT] " + key + ": " + global.support.coinToDecimal(paymentData[key].amount)); - totalPayments += paymentData[key].amount; + + global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { + if (typeof(rows[0]) === 'undefined') { + console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); + return; + } + paymentInProgress = true; + prev_balance_sum = rows[0].amt; + block_unlock_callback = unlock_callback; + + Object.keys(paymentData).forEach(function (key) { + paymentData[key].amount = Math.floor((paymentData[key].amount / (blockDiff*global.config.pplns.shareMulti)) * 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) { + 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 + ")" + ); + } }); - 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) { - 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 + ")" - ); - } }); }; @@ -501,10 +513,6 @@ function blockUnlocker() { debug("Skipping block unlocker run as there's a payment in progress"); return; } - if (block_unlock_callback !== null || prev_balance_sum !== null) { - debug("Skipping block unlocker run since balanceQueue is not empty"); - return; - } console.log("Running block unlocker"); let blockList = global.database.getValidLockedBlocks(); global.coinFuncs.getLastBlockHeader(function(err, body){ @@ -548,10 +556,6 @@ function altblockUnlocker() { debug("Skipping altblock unlocker run as there's a payment in progress"); return; } - if (block_unlock_callback !== null || prev_balance_sum !== null) { - debug("Skipping altblock unlocker run since balanceQueue is not empty"); - return; - } debug("Running altblock unlocker"); let blockList = global.database.getValidLockedAltBlocks(); blockList.forEach(function (block) { @@ -575,30 +579,6 @@ function altblockUnlocker() { }); } -function prepareBlockPayment(callback) { - if (is_full_stop) { - debug("Dropping all payments"); - return; - } - if (paymentInProgress) { - debug("Skipping payment as there's a payment in progress"); - return; - } - if (block_unlock_callback !== null || prev_balance_sum !== null) { - debug("Skipping peyment since balanceQueue is not empty"); - return; - } - global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { - if (typeof(rows[0]) === 'undefined') { - console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); - return; - } - paymentInProgress = true; - prev_balance_sum = rows[0].amt; - callback(); - }); -} - function blockPayments(block) { switch (block.poolType) { case global.protos.POOLTYPE.PPS: @@ -608,12 +588,14 @@ function blockPayments(block) { 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){ - prepareBlockPayment(function() { - block_unlock_callback = function() { - console.log("Unlocking main block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); - global.database.unlockBlock(block.hash); - } - calculatePPLNSPayments(block.height, block.value, block.difficulty); + if (paymentInProgress) { + debug("Skipping payment as there's a payment in progress"); + return; + } + paymentInProgress = true; + calculatePPLNSPayments(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); }); } else { console.error("Can't get correct block header by hash " + block.hash.toString('hex')); @@ -642,12 +624,14 @@ function altblockPayments(block) { 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){ - prepareBlockPayment(function() { - block_unlock_callback = function() { - console.log("Unlocking " + block.port + " port block on " + block.height + " height with " + block.hash.toString('hex') + " hash"); - global.database.unlockAltBlock(block.hash); - }; - calculatePPLNSPayments(block.anchor_height, block.pay_value, anchor_header.difficulty); + if (paymentInProgress) { + debug("Skipping payment as there's a payment in progress"); + return; + } + 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); }); } else { console.error("Can't get correct block header by height " + block.anchor_height.toString()); From e48ae1db9ed78450c0ccb95a06d4ed2e8f886b32 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 May 2018 17:34:51 +0200 Subject: [PATCH 0561/2430] Test for balance change, not plain increase --- lib/blockManager.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 5b295568..3a2d7acf 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -155,7 +155,7 @@ balanceQueue.drain = function () { } 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') { + if (typeof(rows[0]) === 'undefined' || typeof(rows[0].amt) === 'undefined') { full_stop("SELECT SUM(amount) as amt FROM balance query returned undefined result"); block_unlock_callback = null; prev_balance_sum = null; @@ -163,8 +163,8 @@ balanceQueue.drain = function () { return; } let balance_sum = rows[0].amt; - if (balance_sum > prev_balance_sum) { - console.log("Total balance increased from " + global.support.coinToDecimal(prev_balance_sum) + " to " + global.support.coinToDecimal(balance_sum)); + if (balance_sum !== prev_balance_sum) { + console.log("Total balance changed from " + global.support.coinToDecimal(prev_balance_sum) + " to " + global.support.coinToDecimal(balance_sum)); block_unlock_callback(); } else { full_stop("Total balance not changed from " + prev_balance_sum + " to " + balance_sum); @@ -392,11 +392,10 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un let totalPayments = 0; global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { - if (typeof(rows[0]) === 'undefined') { + if (typeof(rows[0]) === 'undefined' || typeof(rows[0].amt) === 'undefined') { console.error("SELECT SUM(amount) as amt FROM balance query returned undefined result"); return; } - paymentInProgress = true; prev_balance_sum = rows[0].amt; block_unlock_callback = unlock_callback; From b92747c2221a1c87dc7209accdebfecb5951a152 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 11:46:20 +0200 Subject: [PATCH 0562/2430] Added script to remove miner from the pool --- manage_scripts/common.js | 44 +++++++++++++++ manage_scripts/user_del.js | 113 +++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 manage_scripts/common.js create mode 100644 manage_scripts/user_del.js diff --git a/manage_scripts/common.js b/manage_scripts/common.js new file mode 100644 index 00000000..7f0ef3a9 --- /dev/null +++ b/manage_scripts/common.js @@ -0,0 +1,44 @@ +"use strict"; + +function init(callback) { + + let fs = require("fs"); + let mysql = require("promise-mysql"); + + let config = fs.readFileSync("../config.json"); + let coinConfig = fs.readFileSync("../coinConfig.json"); + let protobuf = require('protocol-buffers'); + + global.support = require("../lib/support.js")(); + global.config = JSON.parse(config); + global.mysql = mysql.createPool(global.config.mysql); + global.protos = protobuf(fs.readFileSync('../lib/data.proto')); + + global.mysql.query("SELECT * FROM config").then(function (rows) { + rows.forEach(function (row){ + if (!global.config.hasOwnProperty(row.module)) global.config[row.module] = {}; + if (global.config[row.module].hasOwnProperty(row.item)) return; + switch(row.item_type){ + case 'int': global.config[row.module][row.item] = parseInt(row.item_value); break; + case 'bool': global.config[row.module][row.item] = (row.item_value === "true"); break; + case 'string': global.config[row.module][row.item] = row.item_value; break; + case 'float': global.config[row.module][row.item] = parseFloat(row.item_value); break; + } + }); + + }).then(function(){ + global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; + let coinInc = require("." + global.config.coin.funcFile); + global.coinFuncs = new coinInc(); + let comms = require('../lib/local_comms'); + global.database = new comms(); + global.database.initEnv(); + + }).then(function(){ + callback(); + }); +} + +module.exports = { + init: init +}; \ No newline at end of file diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js new file mode 100644 index 00000000..7a77f31c --- /dev/null +++ b/manage_scripts/user_del.js @@ -0,0 +1,113 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); +const argv = require('minimist')(process.argv.slice(2)); + +const c = require("./common.js"); + +c.init(function() { + if (!argv.user) { + console.error("Please specify user address to delete"); + process.exit(1); + } + let parts = argv.user.split("."); + let address = parts.length === 1 ? argv.user : parts[0]; + let 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; + + let 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 = ?", [argv.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) { + let address = global.database.getCache(argv.user); + let stats = global.database.getCache("stats:" + argv.user); + let history = global.database.getCache("history:" + argv.user); + let identifiers = global.database.getCache(argv.user + '_identifiers'); + + if (address != false) console.log("Cache key is not empty: " + argv.user); + if (stats != false) console.log("Cache key is not empty: " + "stats:" + argv.user); + if (history != false) console.log("Cache key is not empty: " + "history:" + argv.user); + if (identifiers != false) console.log("Cache key is not empty: " + argv.user + '_identifiers'); + 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 = ?", [argv.user]).then(function (rows) { + console.log("DELETE FROM users WHERE username = " + argv.user); + callback(); + }); + }, + function (callback) { + global.mysql.query("DELETE FROM balance WHERE " + where_str, [argv.user]).then(function (rows) { + console.log("DELETE FROM balance WHERE " + where_str); + callback(); + }); + }, + function (callback) { + global.mysql.query("DELETE FROM payments WHERE " + where_str, [argv.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(argv.user)) txn.del(global.database.cacheDB, argv.user); + if (global.database.getCache("stats:" + argv.user)) txn.del(global.database.cacheDB, "stats:" + argv.user); + if (global.database.getCache("history:" + argv.user)) txn.del(global.database.cacheDB, "history:" + argv.user); + if (global.database.getCache(argv.user + '_identifiers')) txn.del(global.database.cacheDB, argv.user + '_identifiers'); + txn.commit(); + callback(); + }, + function (callback) { + console.log("DONE"); + process.exit(0); + } + ]); +}); From 96e5f08bcaab83f784233eff1698b58d6f0244b8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 13:37:56 +0200 Subject: [PATCH 0563/2430] Moved common tool part --- manage_scripts/user_del.js | 4 +--- manage_scripts/common.js => tool_init.js | 0 2 files changed, 1 insertion(+), 3 deletions(-) rename manage_scripts/common.js => tool_init.js (100%) diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index 7a77f31c..ad340591 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -3,9 +3,7 @@ const mysql = require("promise-mysql"); const async = require("async"); const argv = require('minimist')(process.argv.slice(2)); -const c = require("./common.js"); - -c.init(function() { +require("../tool_init.js").init(function() { if (!argv.user) { console.error("Please specify user address to delete"); process.exit(1); diff --git a/manage_scripts/common.js b/tool_init.js similarity index 100% rename from manage_scripts/common.js rename to tool_init.js From a6cff33e4eeba02f0a5fede8b79166be9c235dfd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 13:38:00 +0200 Subject: [PATCH 0564/2430] Moved common tool part --- tool_init.js => init_mini.js | 10 +++++----- manage_scripts/user_del.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) rename tool_init.js => init_mini.js (82%) diff --git a/tool_init.js b/init_mini.js similarity index 82% rename from tool_init.js rename to init_mini.js index 7f0ef3a9..053e7613 100644 --- a/tool_init.js +++ b/init_mini.js @@ -5,14 +5,14 @@ function init(callback) { let fs = require("fs"); let mysql = require("promise-mysql"); - let config = fs.readFileSync("../config.json"); - let coinConfig = fs.readFileSync("../coinConfig.json"); + let config = fs.readFileSync("./config.json"); + let coinConfig = fs.readFileSync("./coinConfig.json"); let protobuf = require('protocol-buffers'); - global.support = require("../lib/support.js")(); + global.support = require("./lib/support.js")(); global.config = JSON.parse(config); global.mysql = mysql.createPool(global.config.mysql); - global.protos = protobuf(fs.readFileSync('../lib/data.proto')); + global.protos = protobuf(fs.readFileSync('./lib/data.proto')); global.mysql.query("SELECT * FROM config").then(function (rows) { rows.forEach(function (row){ @@ -30,7 +30,7 @@ function init(callback) { global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; let coinInc = require("." + global.config.coin.funcFile); global.coinFuncs = new coinInc(); - let comms = require('../lib/local_comms'); + let comms = require('./lib/local_comms'); global.database = new comms(); global.database.initEnv(); diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index ad340591..e664b616 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -3,7 +3,7 @@ const mysql = require("promise-mysql"); const async = require("async"); const argv = require('minimist')(process.argv.slice(2)); -require("../tool_init.js").init(function() { +require("../init_mini.js").init(function() { if (!argv.user) { console.error("Please specify user address to delete"); process.exit(1); From 6310eaaa7d840e4d95d11aa9afb60c429648a0c5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 13:39:35 +0200 Subject: [PATCH 0565/2430] Fixed init --- init_mini.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/init_mini.js b/init_mini.js index 053e7613..7f0ef3a9 100644 --- a/init_mini.js +++ b/init_mini.js @@ -5,14 +5,14 @@ function init(callback) { let fs = require("fs"); let mysql = require("promise-mysql"); - let config = fs.readFileSync("./config.json"); - let coinConfig = fs.readFileSync("./coinConfig.json"); + let config = fs.readFileSync("../config.json"); + let coinConfig = fs.readFileSync("../coinConfig.json"); let protobuf = require('protocol-buffers'); - global.support = require("./lib/support.js")(); + global.support = require("../lib/support.js")(); global.config = JSON.parse(config); global.mysql = mysql.createPool(global.config.mysql); - global.protos = protobuf(fs.readFileSync('./lib/data.proto')); + global.protos = protobuf(fs.readFileSync('../lib/data.proto')); global.mysql.query("SELECT * FROM config").then(function (rows) { rows.forEach(function (row){ @@ -30,7 +30,7 @@ function init(callback) { global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; let coinInc = require("." + global.config.coin.funcFile); global.coinFuncs = new coinInc(); - let comms = require('./lib/local_comms'); + let comms = require('../lib/local_comms'); global.database = new comms(); global.database.initEnv(); From d222c525033a2d9944dbf6de6bb70c52e664e8db Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 13:40:43 +0200 Subject: [PATCH 0566/2430] Fixed init --- init_mini.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init_mini.js b/init_mini.js index 7f0ef3a9..7c1df25a 100644 --- a/init_mini.js +++ b/init_mini.js @@ -9,7 +9,7 @@ function init(callback) { let coinConfig = fs.readFileSync("../coinConfig.json"); let protobuf = require('protocol-buffers'); - global.support = require("../lib/support.js")(); + global.support = require("./lib/support.js")(); global.config = JSON.parse(config); global.mysql = mysql.createPool(global.config.mysql); global.protos = protobuf(fs.readFileSync('../lib/data.proto')); @@ -30,7 +30,7 @@ function init(callback) { global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; let coinInc = require("." + global.config.coin.funcFile); global.coinFuncs = new coinInc(); - let comms = require('../lib/local_comms'); + let comms = require('./lib/local_comms'); global.database = new comms(); global.database.initEnv(); From ed75e1c4eadef78c3e6891206eb11b49a1c6ce5c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 13:41:46 +0200 Subject: [PATCH 0567/2430] Fixed init --- init_mini.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init_mini.js b/init_mini.js index 7c1df25a..4cff8d68 100644 --- a/init_mini.js +++ b/init_mini.js @@ -28,7 +28,7 @@ function init(callback) { }).then(function(){ global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; - let coinInc = require("." + global.config.coin.funcFile); + let coinInc = require(global.config.coin.funcFile); global.coinFuncs = new coinInc(); let comms = require('./lib/local_comms'); global.database = new comms(); From a4cd3d6fef140e77c8c49ce94a30cd1dde2a2042 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 13:46:18 +0200 Subject: [PATCH 0568/2430] Added new script --- manage_scripts/dump_altblocks.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 manage_scripts/dump_altblocks.js diff --git a/manage_scripts/dump_altblocks.js b/manage_scripts/dump_altblocks.js new file mode 100644 index 00000000..9b42df24 --- /dev/null +++ b/manage_scripts/dump_altblocks.js @@ -0,0 +1,16 @@ +"use strict"; + +require("../init_mini.js").init(function() { + 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()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.AltBlock.decode(data); + console.log(key + ": " + JSON.stringify(blockData)) + }); + } + cursor.close(); + txn.commit(); + process.exit(0); +}); From 412d192ec38f991dd7a67b220b9befe71627dfb0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 13:47:44 +0200 Subject: [PATCH 0569/2430] Added new script --- manage_scripts/dump_blocks.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 manage_scripts/dump_blocks.js diff --git a/manage_scripts/dump_blocks.js b/manage_scripts/dump_blocks.js new file mode 100644 index 00000000..8f589712 --- /dev/null +++ b/manage_scripts/dump_blocks.js @@ -0,0 +1,16 @@ +"use strict"; + +require("../init_mini.js").init(function() { + 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()) { + cursor.getCurrentBinary(function(key, data){ // jshint ignore:line + let blockData = global.protos.Block.decode(data); + console.log(key + ": " + JSON.stringify(blockData)) + }); + } + cursor.close(); + txn.commit(); + process.exit(0); +}); From e914d6b69f09c2180f0dc62fa0c41d58dd8cb989 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:02:42 +0200 Subject: [PATCH 0570/2430] New scripts --- debug_scripts/altblock_dump.js | 32 ------ debug_scripts/block_dump.js | 32 ------ debug_scripts/block_migrator_from_old_sql.js | 105 ------------------- debug_scripts/share_dump.js | 42 -------- debug_scripts/socket_io.html | 22 ---- manage_scripts/dump_shares.js | 44 ++++++++ manage_scripts/user_del.js | 54 +++++----- 7 files changed, 72 insertions(+), 259 deletions(-) delete mode 100644 debug_scripts/altblock_dump.js delete mode 100644 debug_scripts/block_dump.js delete mode 100644 debug_scripts/block_migrator_from_old_sql.js delete mode 100644 debug_scripts/share_dump.js delete mode 100644 debug_scripts/socket_io.html create mode 100644 manage_scripts/dump_shares.js diff --git a/debug_scripts/altblock_dump.js b/debug_scripts/altblock_dump.js deleted file mode 100644 index 1566bddb..00000000 --- a/debug_scripts/altblock_dump.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -comms = require('../lib/local_comms'); -global.database = new comms(); -global.database.initEnv(); - - 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()) { - cursor.getCurrentBinary(function(key, data){ // jshint ignore:line - let blockData = global.protos.AltBlock.decode(data); - console.log(key + ": " + JSON.stringify(blockData)) - }); - } - cursor.close(); - } - - txn.commit(); - -process.exit(); \ No newline at end of file diff --git a/debug_scripts/block_dump.js b/debug_scripts/block_dump.js deleted file mode 100644 index f3b75111..00000000 --- a/debug_scripts/block_dump.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -comms = require('../lib/local_comms'); -global.database = new comms(); -global.database.initEnv(); - - 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()) { - cursor.getCurrentBinary(function(key, data){ // jshint ignore:line - let blockData = global.protos.Block.decode(data); - console.log(key + ": " + JSON.stringify(blockData)) - }); - } - cursor.close(); - } - - txn.commit(); - -process.exit(); \ No newline at end of file diff --git a/debug_scripts/block_migrator_from_old_sql.js b/debug_scripts/block_migrator_from_old_sql.js deleted file mode 100644 index b23db7c4..00000000 --- a/debug_scripts/block_migrator_from_old_sql.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); -const request = require('request'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -let coinInc; - - -// Config Table Layout -// . - -global.mysql.query("SELECT * FROM config").then(function (rows) { - rows.forEach(function (row){ - if (!global.config.hasOwnProperty(row.module)){ - global.config[row.module] = {}; - } - if (global.config[row.module].hasOwnProperty(row.item)){ - return; - } - switch(row.item_type){ - case 'int': - global.config[row.module][row.item] = parseInt(row.item_value); - break; - case 'bool': - global.config[row.module][row.item] = (row.item_value === "true"); - break; - case 'string': - global.config[row.module][row.item] = row.item_value; - break; - case 'float': - global.config[row.module][row.item] = parseFloat(row.item_value); - break; - } - }); -}).then(function(){ - global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; - coinInc = require("." + global.config.coin.funcFile); - global.coinFuncs = new coinInc(); - if (argv.module === 'pool'){ - comms = require('../lib/remote_comms'); - } else { - comms = require('../lib/local_comms'); - } - global.database = new comms(); - global.database.initEnv(); - global.coinFuncs.blockedAddresses.push(global.config.pool.address); - global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); -}).then(function(){ - /* - message Block { - 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; - optional int64 value = 8; - } - */ - global.mysql.query("SELECT * FROM blocks").then(function(rows){ - rows.forEach(function(row){ - let block = { - hash: row.hex, - difficulty: row.difficulty, - shares: row.shares, - timestamp: global.support.formatDateFromSQL(row.find_time)*1000, - poolType: null, - unlocked: row.unlocked === 1, - valid: row.valid === 1 - }; - switch(row.pool_type){ - case 'pplns': - block.poolType = global.protos.POOLTYPE.PPLNS; - break; - case 'solo': - block.poolType = global.protos.POOLTYPE.SOLO; - break; - case 'prop': - block.poolType = global.protos.POOLTYPE.PROP; - break; - case 'pps': - block.poolType = global.protos.POOLTYPE.PPS; - break; - default: - block.poolType = global.protos.POOLTYPE.PPLNS; - } - global.coinFuncs.getBlockHeaderByHash(block.hash, function(header){ - block.value = header.reward; - let txn = global.database.env.beginTxn(); - txn.putBinary(global.database.blockDB, row.height, global.protos.Block.encode(block)); - txn.commit(); - }); - }); - }); -}); \ No newline at end of file diff --git a/debug_scripts/share_dump.js b/debug_scripts/share_dump.js deleted file mode 100644 index 12c77613..00000000 --- a/debug_scripts/share_dump.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict"; -let range = require('range'); -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -comms = require('../lib/local_comms'); -global.database = new comms(); -global.database.initEnv(); - - let txn = global.database.env.beginTxn({readOnly: true}); - - { let cursor = new global.database.lmdb.Cursor(txn, global.database.shareDB); - let lastBlock = 1520747; - range.range(lastBlock-1, 1520747-100, -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.paymentAddress === "") { - var d = new Date(shareData.timestamp); - console.log(d.toString() + ": " + JSON.stringify(shareData)) - } - }); - } - }); - cursor.close(); - } - - txn.commit(); - -process.exit(); - -// 05:43 -// 07:51 \ No newline at end of file diff --git a/debug_scripts/socket_io.html b/debug_scripts/socket_io.html deleted file mode 100644 index bce2a717..00000000 --- a/debug_scripts/socket_io.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - \ No newline at end of file diff --git a/manage_scripts/dump_shares.js b/manage_scripts/dump_shares.js new file mode 100644 index 00000000..e7954553 --- /dev/null +++ b/manage_scripts/dump_shares.js @@ -0,0 +1,44 @@ +"use strict"; + +let range = require('range'); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.user) { + console.error("Please specify user address to dump"); + process.exit(1); +} +const user = argv.user; + +let worker; +if (argv.worker) worker = argv.worker; + +let depth = 100; +if (argv.depth) depth = argv.depth; + +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.paymentAddress === user && (!worker || shareData.identifier === worker)) { + var d = new Date(shareData.timestamp); + console.log(d.toString() + ": " + JSON.stringify(shareData)) + } + }); + } + }); + cursor.close(); + txn.commit(); + process.exit(0); + }); +}); \ No newline at end of file diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index e664b616..7efa9c53 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -3,26 +3,28 @@ 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() { - if (!argv.user) { - console.error("Please specify user address to delete"); - process.exit(1); - } - let parts = argv.user.split("."); - let address = parts.length === 1 ? argv.user : parts[0]; - let payment_id = parts.length === 2 ? parts[1] : null; + 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; - let where_str = payment_id === null ? "payment_address = '" + address + "' AND payment_id IS NULL" - : "payment_address = '" + address + "' AND payment_id = '" + payment_id + "'"; + 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 = ?", [argv.user]).then(function (rows) { + 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); @@ -55,15 +57,15 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - let address = global.database.getCache(argv.user); - let stats = global.database.getCache("stats:" + argv.user); - let history = global.database.getCache("history:" + argv.user); - let identifiers = global.database.getCache(argv.user + '_identifiers'); + 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(user + '_identifiers'); - if (address != false) console.log("Cache key is not empty: " + argv.user); - if (stats != false) console.log("Cache key is not empty: " + "stats:" + argv.user); - if (history != false) console.log("Cache key is not empty: " + "history:" + argv.user); - if (identifiers != false) console.log("Cache key is not empty: " + argv.user + '_identifiers'); + 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: " + user + '_identifiers'); callback(); }, @@ -76,19 +78,19 @@ require("../init_mini.js").init(function() { }, function (callback) { - global.mysql.query("DELETE FROM users WHERE username = ?", [argv.user]).then(function (rows) { - console.log("DELETE FROM users WHERE username = " + argv.user); + 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, [argv.user]).then(function (rows) { + 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, [argv.user]).then(function (rows) { + global.mysql.query("DELETE FROM payments WHERE " + where_str, [user]).then(function (rows) { console.log("DELETE FROM payments WHERE " + where_str); callback(); }); @@ -96,10 +98,10 @@ require("../init_mini.js").init(function() { function (callback) { console.log("Deleting LMDB cache keys"); let txn = global.database.env.beginTxn(); - if (global.database.getCache(argv.user)) txn.del(global.database.cacheDB, argv.user); - if (global.database.getCache("stats:" + argv.user)) txn.del(global.database.cacheDB, "stats:" + argv.user); - if (global.database.getCache("history:" + argv.user)) txn.del(global.database.cacheDB, "history:" + argv.user); - if (global.database.getCache(argv.user + '_identifiers')) txn.del(global.database.cacheDB, argv.user + '_identifiers'); + 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(user + '_identifiers')) txn.del(global.database.cacheDB, user + '_identifiers'); txn.commit(); callback(); }, From fee2f686b62e5606e0a92f0ca85f0e2738c1472e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:08:40 +0200 Subject: [PATCH 0571/2430] Reduced depth --- manage_scripts/dump_shares.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/dump_shares.js b/manage_scripts/dump_shares.js index e7954553..4dd45d68 100644 --- a/manage_scripts/dump_shares.js +++ b/manage_scripts/dump_shares.js @@ -12,7 +12,7 @@ const user = argv.user; let worker; if (argv.worker) worker = argv.worker; -let depth = 100; +let depth = 10; if (argv.depth) depth = argv.depth; require("../init_mini.js").init(function() { From e6592445436481ff3b9eedee1576e69a1c293e61 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:21:54 +0200 Subject: [PATCH 0572/2430] New scripts --- manage_scripts/dump_cache.js | 20 ++++++++++++++++ manage_scripts/dump_shares.js | 44 ----------------------------------- 2 files changed, 20 insertions(+), 44 deletions(-) create mode 100644 manage_scripts/dump_cache.js delete mode 100644 manage_scripts/dump_shares.js diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js new file mode 100644 index 00000000..502995e7 --- /dev/null +++ b/manage_scripts/dump_cache.js @@ -0,0 +1,20 @@ +"use strict"; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn({readOnly: true}); + let x = 0; + 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){ // jshint ignore:line + console.log(key + ": " + data); + if (++ x > 10) { + cursor.close(); + txn.commit(); + process.exit(0); + } + }); + } + cursor.close(); + txn.commit(); + process.exit(0); +}); diff --git a/manage_scripts/dump_shares.js b/manage_scripts/dump_shares.js deleted file mode 100644 index 4dd45d68..00000000 --- a/manage_scripts/dump_shares.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; - -let range = require('range'); -const argv = require('minimist')(process.argv.slice(2)); - -if (!argv.user) { - console.error("Please specify user address to dump"); - process.exit(1); -} -const user = argv.user; - -let worker; -if (argv.worker) worker = argv.worker; - -let depth = 10; -if (argv.depth) depth = argv.depth; - -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.paymentAddress === user && (!worker || shareData.identifier === worker)) { - var d = new Date(shareData.timestamp); - console.log(d.toString() + ": " + JSON.stringify(shareData)) - } - }); - } - }); - cursor.close(); - txn.commit(); - process.exit(0); - }); -}); \ No newline at end of file From 0336e4a6225de68f9dfd73dcf09ed593b77eb7cc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:24:09 +0200 Subject: [PATCH 0573/2430] New scripts --- manage_scripts/dump_shares.js | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 manage_scripts/dump_shares.js diff --git a/manage_scripts/dump_shares.js b/manage_scripts/dump_shares.js new file mode 100644 index 00000000..0f0cb4e5 --- /dev/null +++ b/manage_scripts/dump_shares.js @@ -0,0 +1,44 @@ +"use strict"; + +let range = require('range'); +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.user) { + console.error("Please specify user address to dump"); + process.exit(1); +} +const user = argv.user; + +let worker; +if (argv.worker) worker = argv.worker; + +let depth = 10; +if (argv.depth) depth = argv.depth; + +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.paymentAddress === user && (!worker || shareData.identifier === worker)) { + var d = new Date(shareData.timestamp); + console.log(d.toString() + ": " + JSON.stringify(shareData)) + } + }); + } + }); + cursor.close(); + txn.commit(); + process.exit(0); + }); +}); From 77cd0fbca08642258e5879375a691524c8f6a140 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:28:00 +0200 Subject: [PATCH 0574/2430] Changed string output --- manage_scripts/dump_cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js index 502995e7..c3409e29 100644 --- a/manage_scripts/dump_cache.js +++ b/manage_scripts/dump_cache.js @@ -6,7 +6,7 @@ require("../init_mini.js").init(function() { 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){ // jshint ignore:line - console.log(key + ": " + data); + console.log(key + ": " + JSON.strinfify(data)); if (++ x > 10) { cursor.close(); txn.commit(); From 218f0adc4056cf1db63057ce97223ac021379911 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:29:54 +0200 Subject: [PATCH 0575/2430] Changed string output --- manage_scripts/dump_cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js index c3409e29..9e212077 100644 --- a/manage_scripts/dump_cache.js +++ b/manage_scripts/dump_cache.js @@ -6,7 +6,7 @@ require("../init_mini.js").init(function() { 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){ // jshint ignore:line - console.log(key + ": " + JSON.strinfify(data)); + console.log(key + ": " + JSON.stringify(data)); if (++ x > 10) { cursor.close(); txn.commit(); From 4fb169e4a931fbc36f63935dffbe0df493ffd776 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:33:39 +0200 Subject: [PATCH 0576/2430] Changed string output --- manage_scripts/dump_cache.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js index 9e212077..5df1c3bc 100644 --- a/manage_scripts/dump_cache.js +++ b/manage_scripts/dump_cache.js @@ -6,7 +6,8 @@ require("../init_mini.js").init(function() { 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){ // jshint ignore:line - console.log(key + ": " + JSON.stringify(data)); + const data2 = JSON.parse(data); + console.log(key + ": " + JSON.stringify(data2)); if (++ x > 10) { cursor.close(); txn.commit(); From f9b55e2ed3c84189c1c32a97358c248f7cd3dbad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:35:46 +0200 Subject: [PATCH 0577/2430] Changed string output --- manage_scripts/dump_cache.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js index 5df1c3bc..edf6814e 100644 --- a/manage_scripts/dump_cache.js +++ b/manage_scripts/dump_cache.js @@ -5,9 +5,8 @@ require("../init_mini.js").init(function() { let x = 0; 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){ // jshint ignore:line - const data2 = JSON.parse(data); - console.log(key + ": " + JSON.stringify(data2)); + cursor.getCurrentString(function(key, data){ // jshint ignore:line + console.log(key + ": " + data); if (++ x > 10) { cursor.close(); txn.commit(); From 55e82b8174b45888315f0de0e66e76d7f1ed2745 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:40:43 +0200 Subject: [PATCH 0578/2430] Changed string output --- manage_scripts/dump_cache.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js index edf6814e..a125fb55 100644 --- a/manage_scripts/dump_cache.js +++ b/manage_scripts/dump_cache.js @@ -1,17 +1,15 @@ "use strict"; +const argv = require('minimist')(process.argv.slice(2)); +const user = argv.user ? argv.user : null; + require("../init_mini.js").init(function() { let txn = global.database.env.beginTxn({readOnly: true}); let x = 0; 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 - console.log(key + ": " + data); - if (++ x > 10) { - cursor.close(); - txn.commit(); - process.exit(0); - } + i (!user || key.includes(user)) console.log(key + ": " + data); }); } cursor.close(); From 288db01e0fa2985180cd28bfe072d015a29a6762 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 14:41:29 +0200 Subject: [PATCH 0579/2430] Changed string output --- manage_scripts/dump_cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js index a125fb55..ee10d946 100644 --- a/manage_scripts/dump_cache.js +++ b/manage_scripts/dump_cache.js @@ -9,7 +9,7 @@ require("../init_mini.js").init(function() { 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 - i (!user || key.includes(user)) console.log(key + ": " + data); + if (!user || key.includes(user)) console.log(key + ": " + data); }); } cursor.close(); From fda2c76e45e3713e8ab01d21453eb15d52048da4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 15:02:36 +0200 Subject: [PATCH 0580/2430] Fixed id bug --- lib/worker.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 7fd62cd5..89b47e83 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -67,19 +67,21 @@ function updateShareStats() { let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; + const identifier = share.identifier === "identifiers" ? "_identifiers" : share.identifier; + if (minerID in identifiers) { - if (identifiers[minerID].indexOf(share.identifier) < 0) { - identifiers[minerID].push(share.identifier); + if (identifiers[minerID].indexOf(identifier) < 0) { + identifiers[minerID].push(identifier); ++ minerCount; } } else { - identifiers[minerID] = [share.identifier]; + identifiers[minerID] = [identifier]; ++ minerCount; } if (share.timestamp <= locTime) return; - let minerIDWithIdentifier = minerID + "_" + share.identifier; + let minerIDWithIdentifier = minerID + "_" + identifier; localStats.global += share.shares; if (localTimes.global < share.timestamp) localTimes.global = share.timestamp; let minerType; From 2e0bb764828805df19737cdeb55e36ae0b25638c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 15:17:32 +0200 Subject: [PATCH 0581/2430] Fixed ids --- lib/api.js | 12 +++++++++--- lib/worker.js | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/api.js b/lib/api.js index b6217a7f..ac0e8bee 100644 --- a/lib/api.js +++ b/lib/api.js @@ -32,9 +32,15 @@ app.use(cors({origin: true})); app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); +function get_identifiers(address) { + let identifiers = global.database.getCache('identifiers:' + address); + if (identifiers === false) return global.database.getCache(address + '_identifiers'); + return identifiers; +} + // Support Functions that are reused now function getAllWorkerHashCharts(address, callback){ - let identifiers = global.database.getCache(address + '_identifiers'); + let identifiers = get_identifiers(address); let returnData = {global: global.database.getCache("history:" + address)['hashHistory']}; if (identifiers !== false){ identifiers.sort(); @@ -52,7 +58,7 @@ function getAllWorkerHashCharts(address, callback){ } function getAllWorkerStats(address, callback){ - let identifiers = global.database.getCache(address + '_identifiers'); + let identifiers = get_identifiers(address); let globalCache = global.database.getCache(address); let globalStatsCache = global.database.getCache("stats:" + address); if (globalStatsCache === false) { // for compatibility @@ -422,7 +428,7 @@ app.get('/network/stats', cache('10 seconds'), function (req, res) { // Miner APIs app.get('/miner/:address/identifiers', cache('10 seconds'), function (req, res) { let address = req.params.address; - return res.json(global.database.getCache(address + '_identifiers')); + return res.json(get_identifiers(address)); }); app.get('/miner/:address/payments', cache('1 minute'), function (req, res) { diff --git a/lib/worker.js b/lib/worker.js index 89b47e83..56181e60 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -67,7 +67,7 @@ function updateShareStats() { let minerID = typeof(share.paymentID) !== 'undefined' && share.paymentID.length > 10 ? share.paymentAddress + '.' + share.paymentID : share.paymentAddress; - const identifier = share.identifier === "identifiers" ? "_identifiers" : share.identifier; + const identifier = share.identifier; if (minerID in identifiers) { if (identifiers[minerID].indexOf(identifier) < 0) { @@ -250,7 +250,7 @@ function updateShareStats() { debug("New worker loop: " + ((Date.now() - currentTime) / 1000) + " seconds"); Object.keys(identifiers).forEach(function (key) { - cache_updates[key + '_identifiers'] = identifiers[key]; + cache_updates['identifiers:' + key] = identifiers[key]; }); cache_updates.minerSet = minerSet; global.database.bulkSetCache(cache_updates); From cc6b8ad3f4bf1e55ad3e34cbf11f0f4cd1b2e2f2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 15:54:59 +0200 Subject: [PATCH 0582/2430] Added new script --- manage_scripts/upgrade_cache.js | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 manage_scripts/upgrade_cache.js diff --git a/manage_scripts/upgrade_cache.js b/manage_scripts/upgrade_cache.js new file mode 100644 index 00000000..a73d066c --- /dev/null +++ b/manage_scripts/upgrade_cache.js @@ -0,0 +1,65 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); +const user = argv.user ? argv.user : null; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn(); + 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.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) return; + if (!user || key.includes(user)) { + if (key.includes("_identifiers")) { + let parts = key.split("_"); + let key2 = parts[0]; + if (global.database.getCache("identifiers:" + key2)) { + console.log(key2 + ": removing outdated _identifiers"); + txn.del(global.database.cacheDB, key); + } else { + console.log(key2 + ": moving _identifiers to identifiers:"); + txn.putString(global.database.cacheDB, "identifiers:" + key2, data); + txn.del(global.database.cacheDB, key); + } + } else { + try { + let data2 = JSON.parse(data); + if ("hash" in data2 && "lastHash" in data2) { + if (global.database.getCache("stats:" + key)) { + console.log(key + ": removing outdated stats"); + delete data2["hash"]; + delete data2["lastHash"]; + txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); + } else { + console.log(key + ": moving old stats to stats:"); + let data3 = { hash: data2.hash, lastHash: data2.lastHash }; + delete data2["hash"]; + delete data2["lastHash"]; + txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn.putString(global.database.cacheDB, "stats:" + key, JSON.stringify(data3)); + } + } + if ("hashHistory" in data2) { + if (global.database.getCache("history:" + key)) { + console.log(key + ": removing outdated history"); + delete data2["hashHistory"]; + txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); + } else { + console.log(key + ": moving old history to history:"); + let data3 = { hashHistory: data2.hashHistory }; + delete data2["hashHistory"]; + txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn.putString(global.database.cacheDB, "history:" + key, JSON.stringify(data3)); + } + } + } catch (e) { + console.error("Bad cache data with " + key + " key"); + } + } + } + }); + } + cursor.close(); + txn.commit(); + process.exit(0); +}); From c23f8eac6346fd1624d7aac62db7af3fd888d5e7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 16:06:30 +0200 Subject: [PATCH 0583/2430] Added new script --- manage_scripts/upgrade_cache.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manage_scripts/upgrade_cache.js b/manage_scripts/upgrade_cache.js index a73d066c..de8a823c 100644 --- a/manage_scripts/upgrade_cache.js +++ b/manage_scripts/upgrade_cache.js @@ -60,6 +60,8 @@ require("../init_mini.js").init(function() { }); } cursor.close(); + console.log("Starting write to LMDB"); txn.commit(); + console.log("Finishing write to LMDB"); process.exit(0); }); From 4aa5ff4a91a3644243de4bef3ce3becd7ecd26ef Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 16:18:18 +0200 Subject: [PATCH 0584/2430] Added new script --- manage_scripts/upgrade_cache.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/manage_scripts/upgrade_cache.js b/manage_scripts/upgrade_cache.js index de8a823c..0997d93c 100644 --- a/manage_scripts/upgrade_cache.js +++ b/manage_scripts/upgrade_cache.js @@ -4,22 +4,23 @@ const argv = require('minimist')(process.argv.slice(2)); const user = argv.user ? argv.user : null; require("../init_mini.js").init(function() { - let txn = global.database.env.beginTxn(); + let txn = global.database.env.beginTxn({readOnly: true}); 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.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) return; if (!user || key.includes(user)) { + let txn2 = global.database.env.beginTxn(); if (key.includes("_identifiers")) { let parts = key.split("_"); let key2 = parts[0]; if (global.database.getCache("identifiers:" + key2)) { console.log(key2 + ": removing outdated _identifiers"); - txn.del(global.database.cacheDB, key); + txn2.del(global.database.cacheDB, key); } else { console.log(key2 + ": moving _identifiers to identifiers:"); - txn.putString(global.database.cacheDB, "identifiers:" + key2, data); - txn.del(global.database.cacheDB, key); + txn2.putString(global.database.cacheDB, "identifiers:" + key2, data); + txn2.del(global.database.cacheDB, key); } } else { try { @@ -29,39 +30,38 @@ require("../init_mini.js").init(function() { console.log(key + ": removing outdated stats"); delete data2["hash"]; delete data2["lastHash"]; - txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); } else { console.log(key + ": moving old stats to stats:"); let data3 = { hash: data2.hash, lastHash: data2.lastHash }; delete data2["hash"]; delete data2["lastHash"]; - txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn.putString(global.database.cacheDB, "stats:" + key, JSON.stringify(data3)); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.putString(global.database.cacheDB, "stats:" + key, JSON.stringify(data3)); } } if ("hashHistory" in data2) { if (global.database.getCache("history:" + key)) { console.log(key + ": removing outdated history"); delete data2["hashHistory"]; - txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); } else { console.log(key + ": moving old history to history:"); let data3 = { hashHistory: data2.hashHistory }; delete data2["hashHistory"]; - txn.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn.putString(global.database.cacheDB, "history:" + key, JSON.stringify(data3)); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.putString(global.database.cacheDB, "history:" + key, JSON.stringify(data3)); } } } catch (e) { console.error("Bad cache data with " + key + " key"); } } + txn2.commit(); } }); } cursor.close(); - console.log("Starting write to LMDB"); txn.commit(); - console.log("Finishing write to LMDB"); process.exit(0); }); From 25eda382639f76a06c4800e704bd600a902e13dd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 16:21:20 +0200 Subject: [PATCH 0585/2430] Added new script --- manage_scripts/upgrade_cache.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manage_scripts/upgrade_cache.js b/manage_scripts/upgrade_cache.js index 0997d93c..167c9f9a 100644 --- a/manage_scripts/upgrade_cache.js +++ b/manage_scripts/upgrade_cache.js @@ -8,6 +8,11 @@ require("../init_mini.js").init(function() { 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) { + console.log("Skipping " + key + " key"); + return; + } + return; if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) return; if (!user || key.includes(user)) { let txn2 = global.database.env.beginTxn(); From 5b324ce357ec93f94eb370acb0a1038a847c86aa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 16:25:04 +0200 Subject: [PATCH 0586/2430] Added new script --- manage_scripts/upgrade_cache.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/manage_scripts/upgrade_cache.js b/manage_scripts/upgrade_cache.js index 167c9f9a..d4123855 100644 --- a/manage_scripts/upgrade_cache.js +++ b/manage_scripts/upgrade_cache.js @@ -9,6 +9,13 @@ require("../init_mini.js").init(function() { for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { cursor.getCurrentString(function(key, data){ // jshint ignore:line if (key.length < 95) { + if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) { + console.log(key + ": removing bad key"); + let txn2 = global.database.env.beginTxn(); + txn2.del(global.database.cacheDB, key); + txn2.commit(); + return; + } console.log("Skipping " + key + " key"); return; } From be1a113ba191db0b50ae297c5db7034950d91683 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 16:31:46 +0200 Subject: [PATCH 0587/2430] Added new script --- manage_scripts/upgrade_cache.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manage_scripts/upgrade_cache.js b/manage_scripts/upgrade_cache.js index d4123855..22e1ff07 100644 --- a/manage_scripts/upgrade_cache.js +++ b/manage_scripts/upgrade_cache.js @@ -8,7 +8,7 @@ require("../init_mini.js").init(function() { 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) { + if (key.length < 95) { // min XMR address length if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) { console.log(key + ": removing bad key"); let txn2 = global.database.env.beginTxn(); @@ -19,7 +19,6 @@ require("../init_mini.js").init(function() { console.log("Skipping " + key + " key"); return; } - return; if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) return; if (!user || key.includes(user)) { let txn2 = global.database.env.beginTxn(); From 33465060e873ed3903627e5c78add3f821894f4f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 16:42:35 +0200 Subject: [PATCH 0588/2430] Removed compatibility layer (ater executing upgrade_cache.js) --- lib/api.js | 16 ---------------- manage_scripts/dump_cache.js | 1 - manage_scripts/user_del.js | 6 +++--- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/lib/api.js b/lib/api.js index ac0e8bee..0bf183cb 100644 --- a/lib/api.js +++ b/lib/api.js @@ -61,10 +61,6 @@ function getAllWorkerStats(address, callback){ let identifiers = get_identifiers(address); let globalCache = global.database.getCache(address); let globalStatsCache = global.database.getCache("stats:" + address); - if (globalStatsCache === false) { // for compatibility - globalStatsCache = global.database.getCache("history:" + address); - if (globalStatsCache === false) globalStatsCache = globalCache; - } let returnData = {global: { lts: Math.floor(globalStatsCache.lastHash / 1000), identifer: 'global', @@ -79,10 +75,6 @@ function getAllWorkerStats(address, callback){ let id2 = address + "_" + identifier; let cachedData = global.database.getCache(id2); let cachedStatsData = global.database.getCache("stats:" + id2); - if (cachedStatsData === false) { // for compatibility - cachedStatsData = global.database.getCache("history:" + id2); - if (cachedStatsData === false) cachedStatsData = cachedData; - } returnData[identifier] = { lts: Math.floor(cachedStatsData.lastHash / 1000), identifer: identifier, @@ -102,10 +94,6 @@ function getAddressStats(address, extCallback){ let payment_id = address_parts[1]; let cachedData = global.database.getCache(address); let cachedStatsData = global.database.getCache("stats:" + address); - if (cachedStatsData === false) { // for compatibility - cachedStatsData = global.database.getCache("history:" + address); - if (cachedStatsData === false) cachedStatsData = cachedData; - } let paidQuery = "SELECT SUM(amount) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let txnQuery = "SELECT count(id) as amt FROM payments WHERE payment_address = ? AND payment_id = ?"; let unpaidQuery = "SELECT SUM(amount) as amt FROM balance WHERE payment_address = ? AND payment_id = ?"; @@ -487,10 +475,6 @@ app.get('/miner/:address/stats/:identifier', cache('10 seconds'), function (req, */ let cachedData = global.database.getCache(memcKey); let cachedStatsData = global.database.getCache("stats:" + memcKey); - if (cachedStatsData === false) { // for compatibility - cachedStatsData = global.database.getCache("history:" + memcKey); - if (cachedStatsData === false) cachedStatsData = cachedData; - } return res.json({ lts: Math.floor(cachedStatsData.lastHash / 1000), identifer: identifier, diff --git a/manage_scripts/dump_cache.js b/manage_scripts/dump_cache.js index ee10d946..eb2d2603 100644 --- a/manage_scripts/dump_cache.js +++ b/manage_scripts/dump_cache.js @@ -5,7 +5,6 @@ const user = argv.user ? argv.user : null; require("../init_mini.js").init(function() { let txn = global.database.env.beginTxn({readOnly: true}); - let x = 0; 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 diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index 7efa9c53..d2671310 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -60,12 +60,12 @@ require("../init_mini.js").init(function() { 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(user + '_identifiers'); + 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: " + user + '_identifiers'); + if (identifiers != false) console.log("Cache key is not empty: " + "identifiers:" + user); callback(); }, @@ -101,7 +101,7 @@ require("../init_mini.js").init(function() { 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(user + '_identifiers')) txn.del(global.database.cacheDB, user + '_identifiers'); + if (global.database.getCache("identifiers:" + user)) txn.del(global.database.cacheDB, "identifiers:" + user); txn.commit(); callback(); }, From 0c1a7f97ef6803cb3b852e835e0e3e5aed71b46d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 16:47:07 +0200 Subject: [PATCH 0589/2430] Removed compatibility layer (ater executing upgrade_cache.js) --- lib/api.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index 0bf183cb..8baec67a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -33,9 +33,7 @@ app.use(bodyParser.urlencoded({extended: false})); app.use(bodyParser.json()); function get_identifiers(address) { - let identifiers = global.database.getCache('identifiers:' + address); - if (identifiers === false) return global.database.getCache(address + '_identifiers'); - return identifiers; + return global.database.getCache('identifiers:' + address); } // Support Functions that are reused now From 5e45a2a82543b60cd9e87d6a6880718b90ab2b5b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 17:07:20 +0200 Subject: [PATCH 0590/2430] Fixed scripts --- manage_scripts/cache_clean.js | 51 +++++++++++++++++++++ manage_scripts/cache_upgrade.js | 78 +++++++++++++++++++++++++++++++++ manage_scripts/upgrade_cache.js | 78 --------------------------------- 3 files changed, 129 insertions(+), 78 deletions(-) create mode 100644 manage_scripts/cache_clean.js create mode 100644 manage_scripts/cache_upgrade.js delete mode 100644 manage_scripts/upgrade_cache.js diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js new file mode 100644 index 00000000..c366f2df --- /dev/null +++ b/manage_scripts/cache_clean.js @@ -0,0 +1,51 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); +const user = argv.user ? argv.user : null; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn({readOnly: true}); + 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) { // min XMR address length + console.log("Skipping " + key + " key"); + return; + } + if (key.includes("identifiers:") || !key.includes("_")) return; + if (user && !key.includes(user)) return; + + //let txn2 = global.database.env.beginTxn(); + if (key.includes("history:") || key.includes("stats:")) { + let parts = key.split(":"); + let key2 = parts[1]; + if (!global.database.getCache(key2)) { + console.log(key + ": found orphan key"); + //txn2.del(global.database.cacheDB, key); + return; + } + } else { + let stats = global.database.getCache("stats:" + key); + if (!stats) { + console.log(key + ": found key without stats"); + return; + } + if (!global.database.getCache("history:" + key)) { + console.log(key + ": found key without history"); + return; + } + if (Date.now() - stats.lastHash > 7*24*60*60*1000) { + console.log(key + ": found outdated key"); + //txn2.del(global.database.cacheDB, key); + //txn2.del(global.database.cacheDB, "history:" + key); + //txn2.del(global.database.cacheDB, "stats:" + key); + } + + } + //txn2.commit(); + }); + } + cursor.close(); + txn.commit(); + process.exit(0); +}); diff --git a/manage_scripts/cache_upgrade.js b/manage_scripts/cache_upgrade.js new file mode 100644 index 00000000..c2569c65 --- /dev/null +++ b/manage_scripts/cache_upgrade.js @@ -0,0 +1,78 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); +const user = argv.user ? argv.user : null; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn({readOnly: true}); + 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) { // min XMR address length + if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) { + console.log(key + ": removing bad key"); + let txn2 = global.database.env.beginTxn(); + txn2.del(global.database.cacheDB, key); + txn2.commit(); + return; + } + console.log("Skipping " + key + " key"); + return; + } + if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) return; + if (user && !key.includes(user)) return; + + let txn2 = global.database.env.beginTxn(); + if (key.includes("_identifiers")) { + let parts = key.split("_"); + let key2 = parts[0]; + if (global.database.getCache("identifiers:" + key2)) { + console.log(key2 + ": removing outdated _identifiers"); + txn2.del(global.database.cacheDB, key); + } else { + console.log(key2 + ": moving _identifiers to identifiers:"); + txn2.putString(global.database.cacheDB, "identifiers:" + key2, data); + txn2.del(global.database.cacheDB, key); + } + } else { + try { + let data2 = JSON.parse(data); + if ("hash" in data2 && "lastHash" in data2) { + if (global.database.getCache("stats:" + key)) { + console.log(key + ": removing outdated stats"); + delete data2["hash"]; + delete data2["lastHash"]; + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + } else { + console.log(key + ": moving old stats to stats:"); + let data3 = { hash: data2.hash, lastHash: data2.lastHash }; + delete data2["hash"]; + delete data2["lastHash"]; + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.putString(global.database.cacheDB, "stats:" + key, JSON.stringify(data3)); + } + } + if ("hashHistory" in data2) { + if (global.database.getCache("history:" + key)) { + console.log(key + ": removing outdated history"); + delete data2["hashHistory"]; + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + } else { + console.log(key + ": moving old history to history:"); + let data3 = { hashHistory: data2.hashHistory }; + delete data2["hashHistory"]; + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.putString(global.database.cacheDB, "history:" + key, JSON.stringify(data3)); + } + } + } catch (e) { + console.error("Bad cache data with " + key + " key"); + } + } + txn2.commit(); + }); + } + cursor.close(); + txn.commit(); + process.exit(0); +}); diff --git a/manage_scripts/upgrade_cache.js b/manage_scripts/upgrade_cache.js deleted file mode 100644 index 22e1ff07..00000000 --- a/manage_scripts/upgrade_cache.js +++ /dev/null @@ -1,78 +0,0 @@ -"use strict"; - -const argv = require('minimist')(process.argv.slice(2)); -const user = argv.user ? argv.user : null; - -require("../init_mini.js").init(function() { - let txn = global.database.env.beginTxn({readOnly: true}); - 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) { // min XMR address length - if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) { - console.log(key + ": removing bad key"); - let txn2 = global.database.env.beginTxn(); - txn2.del(global.database.cacheDB, key); - txn2.commit(); - return; - } - console.log("Skipping " + key + " key"); - return; - } - if (key.includes("history:") || key.includes("stats:") || key.includes("identifiers:")) return; - if (!user || key.includes(user)) { - let txn2 = global.database.env.beginTxn(); - if (key.includes("_identifiers")) { - let parts = key.split("_"); - let key2 = parts[0]; - if (global.database.getCache("identifiers:" + key2)) { - console.log(key2 + ": removing outdated _identifiers"); - txn2.del(global.database.cacheDB, key); - } else { - console.log(key2 + ": moving _identifiers to identifiers:"); - txn2.putString(global.database.cacheDB, "identifiers:" + key2, data); - txn2.del(global.database.cacheDB, key); - } - } else { - try { - let data2 = JSON.parse(data); - if ("hash" in data2 && "lastHash" in data2) { - if (global.database.getCache("stats:" + key)) { - console.log(key + ": removing outdated stats"); - delete data2["hash"]; - delete data2["lastHash"]; - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - } else { - console.log(key + ": moving old stats to stats:"); - let data3 = { hash: data2.hash, lastHash: data2.lastHash }; - delete data2["hash"]; - delete data2["lastHash"]; - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn2.putString(global.database.cacheDB, "stats:" + key, JSON.stringify(data3)); - } - } - if ("hashHistory" in data2) { - if (global.database.getCache("history:" + key)) { - console.log(key + ": removing outdated history"); - delete data2["hashHistory"]; - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - } else { - console.log(key + ": moving old history to history:"); - let data3 = { hashHistory: data2.hashHistory }; - delete data2["hashHistory"]; - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn2.putString(global.database.cacheDB, "history:" + key, JSON.stringify(data3)); - } - } - } catch (e) { - console.error("Bad cache data with " + key + " key"); - } - } - txn2.commit(); - } - }); - } - cursor.close(); - txn.commit(); - process.exit(0); -}); From 72781c9382bcbf2995535a5bfb27e9a70ffd470a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 17:17:14 +0200 Subject: [PATCH 0591/2430] Fixed scripts --- manage_scripts/cache_clean.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index c366f2df..e78fa6d9 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -17,7 +17,7 @@ require("../init_mini.js").init(function() { //let txn2 = global.database.env.beginTxn(); if (key.includes("history:") || key.includes("stats:")) { - let parts = key.split(":"); + let parts = key.split(/:(.+)/); let key2 = parts[1]; if (!global.database.getCache(key2)) { console.log(key + ": found orphan key"); From f6a0bcc8cf21a0da9632b7f0d18e256cf24854cd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 17:25:07 +0200 Subject: [PATCH 0592/2430] Fixed scripts --- manage_scripts/cache_clean.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index e78fa6d9..3ef869d5 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -3,6 +3,8 @@ const argv = require('minimist')(process.argv.slice(2)); const user = argv.user ? argv.user : null; +let count = 0; + require("../init_mini.js").init(function() { let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.cacheDB); @@ -22,7 +24,7 @@ require("../init_mini.js").init(function() { if (!global.database.getCache(key2)) { console.log(key + ": found orphan key"); //txn2.del(global.database.cacheDB, key); - return; + ++ count; } } else { let stats = global.database.getCache("stats:" + key); @@ -39,6 +41,7 @@ require("../init_mini.js").init(function() { //txn2.del(global.database.cacheDB, key); //txn2.del(global.database.cacheDB, "history:" + key); //txn2.del(global.database.cacheDB, "stats:" + key); + ++ count; } } @@ -47,5 +50,6 @@ require("../init_mini.js").init(function() { } cursor.close(); txn.commit(); + console.log("Deleted items: " + count); process.exit(0); }); From 35138c21da2ebd80d924f9807d41af1679af6742 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 19:44:31 +0200 Subject: [PATCH 0593/2430] Fixed scripts --- manage_scripts/cache_clean.js | 37 +++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index 3ef869d5..b95d9c0a 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -10,12 +10,12 @@ require("../init_mini.js").init(function() { 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 (user && !key.includes(user)) return; if (key.length < 95) { // min XMR address length console.log("Skipping " + key + " key"); return; } if (key.includes("identifiers:") || !key.includes("_")) return; - if (user && !key.includes(user)) return; //let txn2 = global.database.env.beginTxn(); if (key.includes("history:") || key.includes("stats:")) { @@ -48,8 +48,41 @@ require("../init_mini.js").init(function() { //txn2.commit(); }); } + + console.log("Deleted items: " + count); + + for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + cursor.getCurrentString(function(key, data){ // jshint ignore:line + if (user && !key.includes(user)) return; + if (key.length < 95) { // min XMR address length + console.log("Skipping " + key + " key"); + return; + } + if (!key.includes("identifiers:")) return; + + let parts = key.split(/:(.+)/); + let key2 = parts[1]; + + try { + let data2 = JSON.parse(data); + let isAlive = false; + for (let i in data2) { + let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); + if (stats && Date.now() - stats.lastHash > 24*60*60*1000) isAlive = true; + } + if (!isAlive) { + data2 = []; + console.log(key + ": found dead key"); + //let txn2 = global.database.env.beginTxn(); + //txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + //txn2.commit(); + } + } catch (e) { + console.error("Bad cache data with " + key + " key"); + } + }); + } cursor.close(); txn.commit(); - console.log("Deleted items: " + count); process.exit(0); }); From c56a62afdc0d92e94b26830a0644507cc9a4e42c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 19:52:26 +0200 Subject: [PATCH 0594/2430] Fixed scripts --- manage_scripts/cache_clean.js | 109 ++++++++++++++++------------------ 1 file changed, 50 insertions(+), 59 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index b95d9c0a..a1dbf726 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -15,74 +15,65 @@ require("../init_mini.js").init(function() { console.log("Skipping " + key + " key"); return; } - if (key.includes("identifiers:") || !key.includes("_")) return; - - //let txn2 = global.database.env.beginTxn(); - if (key.includes("history:") || key.includes("stats:")) { + if (key.includes("identifiers:")) { let parts = key.split(/:(.+)/); let key2 = parts[1]; - if (!global.database.getCache(key2)) { - console.log(key + ": found orphan key"); - //txn2.del(global.database.cacheDB, key); - ++ count; - } - } else { - let stats = global.database.getCache("stats:" + key); - if (!stats) { - console.log(key + ": found key without stats"); - return; - } - if (!global.database.getCache("history:" + key)) { - console.log(key + ": found key without history"); - return; - } - if (Date.now() - stats.lastHash > 7*24*60*60*1000) { - console.log(key + ": found outdated key"); - //txn2.del(global.database.cacheDB, key); - //txn2.del(global.database.cacheDB, "history:" + key); - //txn2.del(global.database.cacheDB, "stats:" + key); - ++ count; - } - - } - //txn2.commit(); - }); - } - - console.log("Deleted items: " + count); - - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { - cursor.getCurrentString(function(key, data){ // jshint ignore:line - if (user && !key.includes(user)) return; - if (key.length < 95) { // min XMR address length - console.log("Skipping " + key + " key"); - return; - } - if (!key.includes("identifiers:")) return; - - let parts = key.split(/:(.+)/); - let key2 = parts[1]; - try { - let data2 = JSON.parse(data); - let isAlive = false; - for (let i in data2) { - let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); - if (stats && Date.now() - stats.lastHash > 24*60*60*1000) isAlive = true; + try { + let data2 = JSON.parse(data); + let isAlive = false; + for (let i in data2) { + console.log("stats:" + key2 + "_" + data2[i]); + let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); + if (stats && Date.now() - stats.lastHash > 24*60*60*1000) isAlive = true; + } + if (!isAlive) { + data2 = []; + console.log(key + ": found dead key"); + //let txn2 = global.database.env.beginTxn(); + //txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + //txn2.commit(); + } + } catch (e) { + console.error("Bad cache data with " + key + " key"); } - if (!isAlive) { - data2 = []; - console.log(key + ": found dead key"); - //let txn2 = global.database.env.beginTxn(); - //txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - //txn2.commit(); + } else if (key.includes("_")) { + + //let txn2 = global.database.env.beginTxn(); + if (key.includes("history:") || key.includes("stats:")) { + let parts = key.split(/:(.+)/); + let key2 = parts[1]; + if (!global.database.getCache(key2)) { + console.log(key + ": found orphan key"); + //txn2.del(global.database.cacheDB, key); + ++ count; + } + } else { + let stats = global.database.getCache("stats:" + key); + if (!stats) { + console.log(key + ": found key without stats"); + return; + } + if (!global.database.getCache("history:" + key)) { + console.log(key + ": found key without history"); + return; + } + if (Date.now() - stats.lastHash > 7*24*60*60*1000) { + console.log(key + ": found outdated key"); + //txn2.del(global.database.cacheDB, key); + //txn2.del(global.database.cacheDB, "history:" + key); + //txn2.del(global.database.cacheDB, "stats:" + key); + ++ count; + } + } - } catch (e) { - console.error("Bad cache data with " + key + " key"); + //txn2.commit(); } }); } + cursor.close(); txn.commit(); + console.log("Deleted items: " + count); process.exit(0); }); From 60520ce5da26f972b08d3b2ce8969cfff6330fa7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 19:57:31 +0200 Subject: [PATCH 0595/2430] Fixed scripts --- manage_scripts/cache_clean.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index a1dbf726..0a5dbcf1 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -25,7 +25,7 @@ require("../init_mini.js").init(function() { for (let i in data2) { console.log("stats:" + key2 + "_" + data2[i]); let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); - if (stats && Date.now() - stats.lastHash > 24*60*60*1000) isAlive = true; + if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; } if (!isAlive) { data2 = []; From 383699c51af813004aaa4e91f367aa836f2e326c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 20:03:35 +0200 Subject: [PATCH 0596/2430] Fixed scripts --- manage_scripts/cache_clean.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index 0a5dbcf1..510c9348 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -23,23 +23,22 @@ require("../init_mini.js").init(function() { let data2 = JSON.parse(data); let isAlive = false; for (let i in data2) { - console.log("stats:" + key2 + "_" + data2[i]); let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; } if (!isAlive) { data2 = []; console.log(key + ": found dead key"); - //let txn2 = global.database.env.beginTxn(); - //txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - //txn2.commit(); + let txn2 = global.database.env.beginTxn(); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.commit(); } } catch (e) { console.error("Bad cache data with " + key + " key"); } } else if (key.includes("_")) { - //let txn2 = global.database.env.beginTxn(); + let txn2 = global.database.env.beginTxn(); if (key.includes("history:") || key.includes("stats:")) { let parts = key.split(/:(.+)/); let key2 = parts[1]; @@ -60,14 +59,14 @@ require("../init_mini.js").init(function() { } if (Date.now() - stats.lastHash > 7*24*60*60*1000) { console.log(key + ": found outdated key"); - //txn2.del(global.database.cacheDB, key); - //txn2.del(global.database.cacheDB, "history:" + key); - //txn2.del(global.database.cacheDB, "stats:" + key); + txn2.del(global.database.cacheDB, key); + txn2.del(global.database.cacheDB, "history:" + key); + txn2.del(global.database.cacheDB, "stats:" + key); ++ count; } } - //txn2.commit(); + txn2.commit(); } }); } From 85f799c8dddfd3282da9031df80d3baa79feaf9d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 20:19:50 +0200 Subject: [PATCH 0597/2430] Fixed scripts --- manage_scripts/cache_clean.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index 510c9348..987a9792 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -67,6 +67,21 @@ require("../init_mini.js").init(function() { } txn2.commit(); + + } else if (key.includes("stats:")) { + try { + let data2 = JSON.parse(data); + if ((data2.hash || data2.hash2) && Date.now() - data2.lastHash > 24*60*60*1000) { + console.log(key + ": found dead account"); + data2.hash = data2.hash2 = 0; + //let txn2 = global.database.env.beginTxn(); + //txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + //txn2.commit(); + } + } catch (e) { + console.error("Bad cache data with " + key + " key"); + } + } }); } From ce838d22f7da236075776975b63e44a3bca4005b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 20:21:00 +0200 Subject: [PATCH 0598/2430] Fixed scripts --- manage_scripts/cache_clean.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index 987a9792..a11425e0 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -21,17 +21,19 @@ require("../init_mini.js").init(function() { try { let data2 = JSON.parse(data); - let isAlive = false; - for (let i in data2) { - let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); - if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; - } - if (!isAlive) { - data2 = []; - console.log(key + ": found dead key"); - let txn2 = global.database.env.beginTxn(); - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn2.commit(); + if (data2.length) { + let isAlive = false; + for (let i in data2) { + let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); + if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; + } + if (!isAlive) { + data2 = []; + console.log(key + ": found dead key"); + let txn2 = global.database.env.beginTxn(); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.commit(); + } } } catch (e) { console.error("Bad cache data with " + key + " key"); From 31b37e396a9e6aa0f0e0fe5c92e72a2416e7c723 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 20:25:19 +0200 Subject: [PATCH 0599/2430] Fixed scripts --- manage_scripts/cache_clean.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index a11425e0..c1e549f2 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -76,9 +76,9 @@ require("../init_mini.js").init(function() { if ((data2.hash || data2.hash2) && Date.now() - data2.lastHash > 24*60*60*1000) { console.log(key + ": found dead account"); data2.hash = data2.hash2 = 0; - //let txn2 = global.database.env.beginTxn(); - //txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - //txn2.commit(); + let txn2 = global.database.env.beginTxn(); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.commit(); } } catch (e) { console.error("Bad cache data with " + key + " key"); From c85529f2737ee63ca4601cfb798f7a809dd66bcc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 20:40:39 +0200 Subject: [PATCH 0600/2430] New scripts --- manage_scripts/pass_reset.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 manage_scripts/pass_reset.js diff --git a/manage_scripts/pass_reset.js b/manage_scripts/pass_reset.js new file mode 100644 index 00000000..ae652bea --- /dev/null +++ b/manage_scripts/pass_reset.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 delete"); + 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 was not found!"); + process.exit(1); + } + console.log("Found rows in users table: " + rows.length); + rows2remove += rows.length; + 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) { + console.log("DONE"); + process.exit(0); + } + ]); +}); From eaba53b7cbc6a9993ff9c22f190f1006783203fd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 20:44:54 +0200 Subject: [PATCH 0601/2430] New scripts --- manage_scripts/cache_clean.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index c1e549f2..d3c6d191 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -40,14 +40,11 @@ require("../init_mini.js").init(function() { } } else if (key.includes("_")) { - let txn2 = global.database.env.beginTxn(); if (key.includes("history:") || key.includes("stats:")) { let parts = key.split(/:(.+)/); let key2 = parts[1]; if (!global.database.getCache(key2)) { console.log(key + ": found orphan key"); - //txn2.del(global.database.cacheDB, key); - ++ count; } } else { let stats = global.database.getCache("stats:" + key); @@ -61,14 +58,15 @@ require("../init_mini.js").init(function() { } if (Date.now() - stats.lastHash > 7*24*60*60*1000) { console.log(key + ": found outdated key"); + 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; } } - txn2.commit(); } else if (key.includes("stats:")) { try { From f3230709fe7209a29c4624080ff2d2fa0e40a96f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 21:10:08 +0200 Subject: [PATCH 0602/2430] New scripts --- manage_scripts/balance_move.js | 96 ++++++++++++++++++++++++++++++++++ manage_scripts/user_del.js | 5 ++ 2 files changed, 101 insertions(+) create mode 100644 manage_scripts/balance_move.js diff --git a/manage_scripts/balance_move.js b/manage_scripts/balance_move.js new file mode 100644 index 00000000..1d1913fa --- /dev/null +++ b/manage_scripts/balance_move.js @@ -0,0 +1,96 @@ +"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); + if (Date.now() - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { + console.error("There was recent amount update. Refusing to continue!"); + process.exit(1); + } + 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' FROM balance WHERE " + old_where_str).then(function (rows) { + console.log("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str); + callback(); + }); + }, + function (callback) { + global.mysql.query("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str).then(function (rows) { + console.log("UPDATE balance SET amount = amount + " + old_amount + " FROM balance 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); + } + ]); +}); diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index d2671310..84caf6ba 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -44,6 +44,11 @@ require("../init_mini.js").init(function() { console.error("Too big payment left: " + global.support.coinToDecimal(rows[0].amount)); process.exit(1); } + console.log("Balance last update time: " + rows[0].last_edited); + if (Date.now() - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { + console.error("There was recent amount update. Refusing to continue!"); + process.exit(1); + } console.log("Found rows in balance table: " + rows.length); rows2remove += rows.length; callback(); From 605e8db35c2b1bd15fcb0467f3c1c8db64c3d551 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 21:15:02 +0200 Subject: [PATCH 0603/2430] Fixed scripts --- manage_scripts/cache_clean.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index d3c6d191..6a7f3aec 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -49,11 +49,11 @@ require("../init_mini.js").init(function() { } else { let stats = global.database.getCache("stats:" + key); if (!stats) { - console.log(key + ": found key without stats"); + console.log(key + ": found key without stats: " + data); return; } if (!global.database.getCache("history:" + key)) { - console.log(key + ": found key without history"); + console.log(key + ": found key without history: " + data); return; } if (Date.now() - stats.lastHash > 7*24*60*60*1000) { From 2ce939df754677e468287f4e5868b4351e3ba942 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 21:42:47 +0200 Subject: [PATCH 0604/2430] Fixed scripts --- manage_scripts/cache_clean.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index 6a7f3aec..2c325ada 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -50,10 +50,18 @@ require("../init_mini.js").init(function() { let stats = global.database.getCache("stats:" + key); if (!stats) { console.log(key + ": found key without stats: " + data); + let txn2 = global.database.env.beginTxn(); + txn2.del(global.database.cacheDB, key); + if (global.database.getCache("history:" + key)) txn2.del(global.database.cacheDB, "history:" + key); + txn2.commit(); return; } if (!global.database.getCache("history:" + key)) { console.log(key + ": found key without history: " + data); + let txn2 = global.database.env.beginTxn(); + txn2.del(global.database.cacheDB, key); + txn2.del(global.database.cacheDB, "stats:" + key); + txn2.commit(); return; } if (Date.now() - stats.lastHash > 7*24*60*60*1000) { From 7b851f8cb68bed824815b818553d226e3cef7024 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 21:44:38 +0200 Subject: [PATCH 0605/2430] Fixed scripts --- manage_scripts/cache_clean.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index 2c325ada..ee6d75fd 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -54,6 +54,7 @@ require("../init_mini.js").init(function() { txn2.del(global.database.cacheDB, key); if (global.database.getCache("history:" + key)) txn2.del(global.database.cacheDB, "history:" + key); txn2.commit(); + ++ count; return; } if (!global.database.getCache("history:" + key)) { @@ -62,6 +63,7 @@ require("../init_mini.js").init(function() { txn2.del(global.database.cacheDB, key); txn2.del(global.database.cacheDB, "stats:" + key); txn2.commit(); + ++ count; return; } if (Date.now() - stats.lastHash > 7*24*60*60*1000) { From fb0c2ad09f71de2e4b7de0401d28e0c047882995 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 21:48:38 +0200 Subject: [PATCH 0606/2430] Fixed scripts --- manage_scripts/cache_clean.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index ee6d75fd..e6f3e844 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -44,7 +44,7 @@ require("../init_mini.js").init(function() { let parts = key.split(/:(.+)/); let key2 = parts[1]; if (!global.database.getCache(key2)) { - console.log(key + ": found orphan key"); + //console.log(key + ": found orphan key"); } } else { let stats = global.database.getCache("stats:" + key); From 0a00331ed90b126b32aa1d3e9864a2bc4a870bc5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 21:55:32 +0200 Subject: [PATCH 0607/2430] Fixed scripts --- manage_scripts/balance_move.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manage_scripts/balance_move.js b/manage_scripts/balance_move.js index 1d1913fa..a0226ccc 100644 --- a/manage_scripts/balance_move.js +++ b/manage_scripts/balance_move.js @@ -65,16 +65,16 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - global.mysql.query("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str).then(function (rows) { + //global.mysql.query("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str).then(function (rows) { console.log("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str); callback(); - }); + //}); }, function (callback) { - global.mysql.query("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str).then(function (rows) { + //global.mysql.query("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str).then(function (rows) { console.log("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str); callback(); - }); + //}); }, function (callback) { global.mysql.query("SELECT * FROM balance WHERE " + old_where_str).then(function (rows) { From 57dd1bac51d45c0ad13b55a5f9fa7543f7b46f3e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 21:59:52 +0200 Subject: [PATCH 0608/2430] New scripts --- manage_scripts/balance_move.js | 2 +- manage_scripts/user_del.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manage_scripts/balance_move.js b/manage_scripts/balance_move.js index a0226ccc..ee28213a 100644 --- a/manage_scripts/balance_move.js +++ b/manage_scripts/balance_move.js @@ -47,7 +47,7 @@ require("../init_mini.js").init(function() { 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); - if (Date.now() - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { + if (Date.now()/1000 - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { console.error("There was recent amount update. Refusing to continue!"); process.exit(1); } diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index 84caf6ba..22e08166 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -45,7 +45,7 @@ require("../init_mini.js").init(function() { process.exit(1); } console.log("Balance last update time: " + rows[0].last_edited); - if (Date.now() - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { + if (Date.now()/1000 - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { console.error("There was recent amount update. Refusing to continue!"); process.exit(1); } From 667df8355ac7178fd0f4fe092d95ae33a665ed05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 22:01:19 +0200 Subject: [PATCH 0609/2430] Fix scripts --- manage_scripts/balance_move.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manage_scripts/balance_move.js b/manage_scripts/balance_move.js index ee28213a..60a554ae 100644 --- a/manage_scripts/balance_move.js +++ b/manage_scripts/balance_move.js @@ -65,16 +65,16 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - //global.mysql.query("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str).then(function (rows) { + global.mysql.query("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str).then(function (rows) { console.log("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str); callback(); - //}); + }); }, function (callback) { - //global.mysql.query("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str).then(function (rows) { + global.mysql.query("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str).then(function (rows) { console.log("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str); callback(); - //}); + }); }, function (callback) { global.mysql.query("SELECT * FROM balance WHERE " + old_where_str).then(function (rows) { From e469eeba0da8ce1ca9cf8c41cc2a6182821f432e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 22:49:36 +0200 Subject: [PATCH 0610/2430] More scripts --- debug_scripts/altblock_validate.js | 66 ------------------- debug_scripts/block_locker.js | 19 ------ debug_scripts/block_share_fix.js | 59 ----------------- debug_scripts/block_unlocker.js | 19 ------ lib/local_comms.js | 51 +------------- manage_scripts/altblock_pay_manually.js | 40 +++++++++++ manage_scripts/altblock_revalidate.js | 40 +++++++++++ manage_scripts/altblock_unlock_without_pay.js | 15 +++++ manage_scripts/block_lock_to_pay.js | 22 +++++++ manage_scripts/block_unlock_without_pay.js | 15 +++++ manage_scripts/cache_get.js | 21 ++++++ manage_scripts/cache_set.js | 27 ++++++++ manage_scripts/pass_reset.js | 2 +- 13 files changed, 184 insertions(+), 212 deletions(-) delete mode 100644 debug_scripts/altblock_validate.js delete mode 100644 debug_scripts/block_locker.js delete mode 100644 debug_scripts/block_share_fix.js delete mode 100644 debug_scripts/block_unlocker.js create mode 100644 manage_scripts/altblock_pay_manually.js create mode 100644 manage_scripts/altblock_revalidate.js create mode 100644 manage_scripts/altblock_unlock_without_pay.js create mode 100644 manage_scripts/block_lock_to_pay.js create mode 100644 manage_scripts/block_unlock_without_pay.js create mode 100644 manage_scripts/cache_get.js create mode 100644 manage_scripts/cache_set.js diff --git a/debug_scripts/altblock_validate.js b/debug_scripts/altblock_validate.js deleted file mode 100644 index ec4a8f6d..00000000 --- a/debug_scripts/altblock_validate.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -let coinInc; - - -// Config Table Layout -// . - -global.mysql.query("SELECT * FROM config").then(function (rows) { - rows.forEach(function (row){ - if (!global.config.hasOwnProperty(row.module)){ - global.config[row.module] = {}; - } - if (global.config[row.module].hasOwnProperty(row.item)){ - return; - } - switch(row.item_type){ - case 'int': - global.config[row.module][row.item] = parseInt(row.item_value); - break; - case 'bool': - global.config[row.module][row.item] = (row.item_value === "true"); - break; - case 'string': - global.config[row.module][row.item] = row.item_value; - break; - case 'float': - global.config[row.module][row.item] = parseFloat(row.item_value); - break; - } - }); -}).then(function(){ - global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; - coinInc = require("." + global.config.coin.funcFile); - global.coinFuncs = new coinInc(); - comms = require('../lib/local_comms'); - global.database = new comms(); - global.database.initEnv(); - global.coinFuncs.blockedAddresses.push(global.config.pool.address); - global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); -}).then(function(){ - - global.coinFuncs.getPortBlockHeaderByHash(argv.blockPort, argv.blockHash, (err, body) => { - if (err !== null) { - console.log("Block "+argv.blockHash+" still has invalid hash for " + argv.blockPort + "! Exiting!"); - process.exit(); - } - global.database.validateAltBlock(argv.blockPort, argv.blockHash); - console.log("Block "+argv.blockHash+" was validated! Exiting!"); - process.exit(); - }); - -}); - - diff --git a/debug_scripts/block_locker.js b/debug_scripts/block_locker.js deleted file mode 100644 index e164eb0e..00000000 --- a/debug_scripts/block_locker.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -comms = require('../lib/local_comms'); -global.database = new comms(); -global.database.initEnv(); -global.database.lockBlock(argv.blockID); -console.log("Block "+argv.blockID+" re-locked! Exiting!"); -process.exit(); \ No newline at end of file diff --git a/debug_scripts/block_share_fix.js b/debug_scripts/block_share_fix.js deleted file mode 100644 index f2f3d715..00000000 --- a/debug_scripts/block_share_fix.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); -const request = require('request'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -let coinInc; - - -// Config Table Layout -// . - -global.mysql.query("SELECT * FROM config").then(function (rows) { - rows.forEach(function (row){ - if (!global.config.hasOwnProperty(row.module)){ - global.config[row.module] = {}; - } - if (global.config[row.module].hasOwnProperty(row.item)){ - return; - } - switch(row.item_type){ - case 'int': - global.config[row.module][row.item] = parseInt(row.item_value); - break; - case 'bool': - global.config[row.module][row.item] = (row.item_value === "true"); - break; - case 'string': - global.config[row.module][row.item] = row.item_value; - break; - case 'float': - global.config[row.module][row.item] = parseFloat(row.item_value); - break; - } - }); -}).then(function(){ - global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; - coinInc = require("." + global.config.coin.funcFile); - global.coinFuncs = new coinInc(); - if (argv.module === 'pool'){ - comms = require('../lib/remote_comms'); - } else { - comms = require('../lib/local_comms'); - } - global.database = new comms(); - global.database.initEnv(); - global.coinFuncs.blockedAddresses.push(global.config.pool.address); - global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); -}).then(function(){ - global.database.fixBlockShares(1241110); -}); \ No newline at end of file diff --git a/debug_scripts/block_unlocker.js b/debug_scripts/block_unlocker.js deleted file mode 100644 index ec80e588..00000000 --- a/debug_scripts/block_unlocker.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -comms = require('../lib/local_comms'); -global.database = new comms(); -global.database.initEnv(); -global.database.unlockBlock(argv.blockHash); -console.log("Block "+argv.blockHash+" un-locked! Exiting!"); -process.exit(); diff --git a/lib/local_comms.js b/lib/local_comms.js index e6f2477a..2682ec6d 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -5,12 +5,9 @@ let async = require('async'); function poolTypeStr(poolType) { switch (poolType) { - case global.protos.POOLTYPE.PPLNS: - return 'pplns'; - case global.protos.POOLTYPE.PPS: - return 'pps'; - case global.protos.POOLTYPE.SOLO: - return 'solo'; + case global.protos.POOLTYPE.PPLNS: return 'pplns'; + case global.protos.POOLTYPE.PPS: return 'pps'; + case global.protos.POOLTYPE.SOLO: return 'solo'; default: console.error("Unknown poolType: " + poolType.toString()); return 'pplns'; @@ -600,48 +597,6 @@ function Database(){ txn.commit(); }; - this.validateAltBlock = function(blockPort, 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.port === blockPort && blockData.hash === blockHex){ - blockData.valid = true; - blockData.unlocked = false; - txn.putBinary(altblockDB, key, global.protos.AltBlock.encode(blockData)); - } - }); - altblockDB = null; - } - cursor.close(); - txn.commit(); - }; - - this.lockBlock = function(blockId){ - let txn = this.env.beginTxn(); - let blockProto = txn.getBinary(this.blockDB, parseInt(blockId)); - if (blockProto !== null){ - let blockData = global.protos.Block.decode(blockProto); - blockData.unlocked = false; - txn.putBinary(this.blockDB, blockId, global.protos.Block.encode(blockData)); - } - txn.commit(); - }; - - this.lockAltBlock = function(blockId){ - let txn = this.env.beginTxn(); - let blockProto = txn.getBinary(this.altblockDB, blockId); - if (blockProto !== null){ - let blockData = global.protos.AltBlock.decode(blockProto); - blockData.unlocked = false; - txn.putBinary(this.altblockDB, blockId, global.protos.AltBlock.encode(blockData)); - } - txn.commit(); - }; - this.getCache = function(cacheKey){ debug("Getting Key: "+cacheKey); try { diff --git a/manage_scripts/altblock_pay_manually.js b/manage_scripts/altblock_pay_manually.js new file mode 100644 index 00000000..2b8e416c --- /dev/null +++ b/manage_scripts/altblock_pay_manually.js @@ -0,0 +1,40 @@ +"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.pay) { + console.error("Please specify pay value in main currency"); + process.exit(1); +} +const pay = argv.pay; + +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.pay_value = global.support.decimalToCoin(pay); + blockData.unlocked = false; + console.log("Put " + blockData.pay_value + " pay_value 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"); + process.exit(1); +}); diff --git a/manage_scripts/altblock_revalidate.js b/manage_scripts/altblock_revalidate.js new file mode 100644 index 00000000..69262f35 --- /dev/null +++ b/manage_scripts/altblock_revalidate.js @@ -0,0 +1,40 @@ +"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) { + global.coinFuncs.getPortBlockHeaderByHash(blockData.port, hash, (err, body) => { + if (err !== null) { + console.log("Block " + hash + " still has invalid hash for " + blockData.port + " port! Exiting!"); + cursor.close(); + txn.commit(); + process.exit(1); + } + blockData.valid = true; + blockData.unlocked = false; + txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + cursor.close(); + txn.commit(); + console.log("Block " + hash + " was validated! Exiting!"); + process.exit(0); + }); + } + }); + } + cursor.close(); + txn.commit(); + console.log("Not found altblock"); + process.exit(1); +}); diff --git a/manage_scripts/altblock_unlock_without_pay.js b/manage_scripts/altblock_unlock_without_pay.js new file mode 100644 index 00000000..3d7fb762 --- /dev/null +++ b/manage_scripts/altblock_unlock_without_pay.js @@ -0,0 +1,15 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.hash) { + console.error("Please specify altblock hash to unlock it (and avoid payment)"); + process.exit(1); +} +const hash = argv.hash; + +require("../init_mini.js").init(function() { + global.database.unlockAltBlock(hash); + console.log("Altblock " + hash + " un-locked! Exiting!"); + process.exit(0); +}); diff --git a/manage_scripts/block_lock_to_pay.js b/manage_scripts/block_lock_to_pay.js new file mode 100644 index 00000000..ec2143e0 --- /dev/null +++ b/manage_scripts/block_lock_to_pay.js @@ -0,0 +1,22 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.height) { + console.error("Please specify block height to lock again (to pay it again)"); + process.exit(1); +} +const height = argv.height; + +require("../init_mini.js").init(function() { + let txn = global.database.env.beginTxn(); + let blockProto = txn.getBinary(global.database.blockDB, parseInt(height)); + if (blockProto !== null) { + let blockData = global.protos.Block.decode(blockProto); + blockData.unlocked = false; + txn.putBinary(this.blockDB, height, global.protos.Block.encode(blockData)); + } + txn.commit(); + console.log("Block " + height + " re-locked! Exiting!"); + process.exit(0); +}); diff --git a/manage_scripts/block_unlock_without_pay.js b/manage_scripts/block_unlock_without_pay.js new file mode 100644 index 00000000..4b406681 --- /dev/null +++ b/manage_scripts/block_unlock_without_pay.js @@ -0,0 +1,15 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.hash) { + console.error("Please specify block hash to unlock it (and avoid payment)"); + process.exit(1); +} +const hash = argv.hash; + +require("../init_mini.js").init(function() { + global.database.unlockBlock(hash); + console.log("Block " + hash + " un-locked! Exiting!"); + process.exit(0); +}); diff --git a/manage_scripts/cache_get.js b/manage_scripts/cache_get.js new file mode 100644 index 00000000..1feb70f8 --- /dev/null +++ b/manage_scripts/cache_get.js @@ -0,0 +1,21 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.key) { + console.error("Please specify key"); + process.exit(1); +} +const key = argv.key; + +require("../init_mini.js").init(function() { + let value = global.database.getCache(key); + if (value !== false) { + console.log(JSON.stringify(value)); + process.exit(0); + } else { + console.error("Key is not found"); + process.exit(1); + } +}); + diff --git a/manage_scripts/cache_set.js b/manage_scripts/cache_set.js new file mode 100644 index 00000000..e1f1da05 --- /dev/null +++ b/manage_scripts/cache_set.js @@ -0,0 +1,27 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.key) { + console.error("Please specify key"); + process.exit(1); +} +const key = argv.key; + +if (!argv.value) { + console.error("Please specify value"); + process.exit(1); +} +const value = argv.value; + +require("../init_mini.js").init(function() { + try { + let value2 = JSON.parse(value); + global.database.setCache(key, value2); + process.exit(0); + } catch(e) { + console.error("Can't parse your value: " + value); + process.exit(1); + } +}); + diff --git a/manage_scripts/pass_reset.js b/manage_scripts/pass_reset.js index ae652bea..03f4ab2b 100644 --- a/manage_scripts/pass_reset.js +++ b/manage_scripts/pass_reset.js @@ -29,7 +29,7 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - console.log("DONE"); + console.log("DONE: Please do not forget to restart your miner to apply new password and set payment thresold since it was reset as well"); process.exit(0); } ]); From 46ec0cf8063e56fa0534391c97b1c261c0239eac Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 23:23:11 +0200 Subject: [PATCH 0611/2430] More scripts --- manage_scripts/altblock_add.js | 65 +++++++++++++++++++ manage_scripts/altblock_pay_manually.js | 2 +- manage_scripts/altblock_revalidate.js | 6 +- manage_scripts/altblock_unlock_without_pay.js | 2 +- manage_scripts/block_add.js | 51 +++++++++++++++ manage_scripts/block_lock_to_pay.js | 4 +- manage_scripts/block_unlock_without_pay.js | 2 +- 7 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 manage_scripts/altblock_add.js create mode 100644 manage_scripts/block_add.js diff --git a/manage_scripts/altblock_add.js b/manage_scripts/altblock_add.js new file mode 100644 index 00000000..3c8cae7f --- /dev/null +++ b/manage_scripts/altblock_add.js @@ -0,0 +1,65 @@ +"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; + +if (!argv.body) { + console.error("Please specify altblock body"); + process.exit(1); +} +const body = argv.body; +let body2; + +try { body2 = JSON.parse(body); } catch(e) { + console.error("Can't parse altblock body: " + body); + process.exit(1); +} + +1527369252: {,"pay_stage":"Unlocking wallet balance","pay_status":"OK"} + +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 + }; + if (typeof (body3.hash) === 'undefined' || + typeof (body3.difficulty) === 'undefined' || + typeof (body3.shares) === 'undefined' || + typeof (body3.timestamp) === 'undefined' || + typeof (body3.poolType) === 'undefined' || + typeof (body3.unlocked) === 'undefined' || + typeof (body3.valid) === 'undefined' || + typeof (body3.port) === 'undefined' || + typeof (body3.height) === 'undefined' || + typeof (body3.anchor_height) === 'undefined' || + typeof (body3.value) === 'undefined' || + typeof (body3.pay_value) === 'undefined' || + typeof (body3.pay_stage) === 'undefined' || + typeof (body3.pay_status) === 'undefined') { + console.error("Altblock body is invalid: " + JSON.stringify(body3)); + process.exit(1); + } + const body4 = global.protos.AltBlock.encode(body3); + let txn = global.database.env.beginTxn(); + txn.putBinary(global.database.altblockDB, timestamp, body4); + txn.commit(); + console.log("Altblock with " + timestamp + " timestamp added! Exiting!"); + process.exit(0); +}); diff --git a/manage_scripts/altblock_pay_manually.js b/manage_scripts/altblock_pay_manually.js index 2b8e416c..fdd3b8cd 100644 --- a/manage_scripts/altblock_pay_manually.js +++ b/manage_scripts/altblock_pay_manually.js @@ -35,6 +35,6 @@ require("../init_mini.js").init(function() { } cursor.close(); txn.commit(); - console.log("Not found altblock"); + 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 69262f35..42ec2f53 100644 --- a/manage_scripts/altblock_revalidate.js +++ b/manage_scripts/altblock_revalidate.js @@ -17,7 +17,7 @@ require("../init_mini.js").init(function() { if (blockData.hash === hash) { global.coinFuncs.getPortBlockHeaderByHash(blockData.port, hash, (err, body) => { if (err !== null) { - console.log("Block " + hash + " still has invalid hash for " + blockData.port + " port! Exiting!"); + console.log("Altblock with " + hash + " hash still has invalid hash for " + blockData.port + " port! Exiting!"); cursor.close(); txn.commit(); process.exit(1); @@ -27,7 +27,7 @@ require("../init_mini.js").init(function() { txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); cursor.close(); txn.commit(); - console.log("Block " + hash + " was validated! Exiting!"); + console.log("Altblock with " + hash + " hash was validated! Exiting!"); process.exit(0); }); } @@ -35,6 +35,6 @@ require("../init_mini.js").init(function() { } cursor.close(); txn.commit(); - console.log("Not found altblock"); + console.log("Not found altblock with " + hash + " hash"); process.exit(1); }); diff --git a/manage_scripts/altblock_unlock_without_pay.js b/manage_scripts/altblock_unlock_without_pay.js index 3d7fb762..adac654d 100644 --- a/manage_scripts/altblock_unlock_without_pay.js +++ b/manage_scripts/altblock_unlock_without_pay.js @@ -10,6 +10,6 @@ const hash = argv.hash; require("../init_mini.js").init(function() { global.database.unlockAltBlock(hash); - console.log("Altblock " + hash + " un-locked! Exiting!"); + console.log("Altblock with " + hash + " hash un-locked! Exiting!"); process.exit(0); }); diff --git a/manage_scripts/block_add.js b/manage_scripts/block_add.js new file mode 100644 index 00000000..04e71c2e --- /dev/null +++ b/manage_scripts/block_add.js @@ -0,0 +1,51 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2)); + +if (!argv.height) { + console.error("Please specify block height"); + process.exit(1); +} +const height = argv.height; + +if (!argv.body) { + console.error("Please specify block body"); + process.exit(1); +} +const body = argv.body; +let body2; + +try { body2 = JSON.parse(body); } catch(e) { + console.error("Can't parse block body: " + body); + process.exit(1); +} + +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, + "value": body2.value + }; + if (typeof (body3.hash) === 'undefined' || + typeof (body3.difficulty) === 'undefined' || + typeof (body3.shares) === 'undefined' || + typeof (body3.timestamp) === 'undefined' || + typeof (body3.poolType) === 'undefined' || + typeof (body3.unlocked) === 'undefined' || + typeof (body3.valid) === 'undefined' || + typeof (body3.value) === 'undefined') { + console.error("Block body is invalid: " + JSON.stringify(body3)); + process.exit(1); + } + const body4 = global.protos.AltBlock.encode(body3); + let txn = global.database.env.beginTxn(); + txn.putBinary(global.database.blockDB, height, body4); + txn.commit(); + console.log("Block on " + height + " height added! Exiting!"); + process.exit(0); +}); diff --git a/manage_scripts/block_lock_to_pay.js b/manage_scripts/block_lock_to_pay.js index ec2143e0..0d48b0c1 100644 --- a/manage_scripts/block_lock_to_pay.js +++ b/manage_scripts/block_lock_to_pay.js @@ -14,9 +14,9 @@ require("../init_mini.js").init(function() { if (blockProto !== null) { let blockData = global.protos.Block.decode(blockProto); blockData.unlocked = false; - txn.putBinary(this.blockDB, height, global.protos.Block.encode(blockData)); + txn.putBinary(global.database.blockDB, height, global.protos.Block.encode(blockData)); } txn.commit(); - console.log("Block " + height + " re-locked! Exiting!"); + console.log("Block on " + height + " height re-locked! Exiting!"); process.exit(0); }); diff --git a/manage_scripts/block_unlock_without_pay.js b/manage_scripts/block_unlock_without_pay.js index 4b406681..df740371 100644 --- a/manage_scripts/block_unlock_without_pay.js +++ b/manage_scripts/block_unlock_without_pay.js @@ -10,6 +10,6 @@ const hash = argv.hash; require("../init_mini.js").init(function() { global.database.unlockBlock(hash); - console.log("Block " + hash + " un-locked! Exiting!"); + console.log("Block on " + hash + " height un-locked! Exiting!"); process.exit(0); }); From bcda092855573144e8554550aa1286934ca8b935 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 23:24:44 +0200 Subject: [PATCH 0612/2430] More scripts --- debug_scripts/altblock_add.js | 68 -------------------------- debug_scripts/block_add.js | 92 ----------------------------------- debug_scripts/block_add2.js | 64 ------------------------ 3 files changed, 224 deletions(-) delete mode 100644 debug_scripts/altblock_add.js delete mode 100644 debug_scripts/block_add.js delete mode 100644 debug_scripts/block_add2.js diff --git a/debug_scripts/altblock_add.js b/debug_scripts/altblock_add.js deleted file mode 100644 index 3d5b0d40..00000000 --- a/debug_scripts/altblock_add.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); -const request = require('request'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -let coinInc; - - -// Config Table Layout -// . - -global.mysql.query("SELECT * FROM config").then(function (rows) { - rows.forEach(function (row){ - if (!global.config.hasOwnProperty(row.module)){ - global.config[row.module] = {}; - } - if (global.config[row.module].hasOwnProperty(row.item)){ - return; - } - switch(row.item_type){ - case 'int': - global.config[row.module][row.item] = parseInt(row.item_value); - break; - case 'bool': - global.config[row.module][row.item] = (row.item_value === "true"); - break; - case 'string': - global.config[row.module][row.item] = row.item_value; - break; - case 'float': - global.config[row.module][row.item] = parseFloat(row.item_value); - break; - } - }); -}).then(function(){ - global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; - coinInc = require("." + global.config.coin.funcFile); - global.coinFuncs = new coinInc(); - comms = require('../lib/local_comms'); - global.database = new comms(); - global.database.initEnv(); - global.coinFuncs.blockedAddresses.push(global.config.pool.address); - global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); -}).then(function(){ - let time_now = Date.now(); - /*global.database.storeAltBlock(Math.floor(time_now / 1000), global.protos.AltBlock.encode({ - hash: "517c5c49137d2a7b7c5c58297bea10940bbd5ba23d77d589069b16cadec95a03", - difficulty: 2149619256, - shares: 0, - timestamp: time_now, - poolType: global.protos.POOLTYPE.PPLNS, - unlocked: false, - valid: true, - port: 26968, - height: 157909, - anchor_height: 1509989 - }));*/ - -}); diff --git a/debug_scripts/block_add.js b/debug_scripts/block_add.js deleted file mode 100644 index 9fceec92..00000000 --- a/debug_scripts/block_add.js +++ /dev/null @@ -1,92 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); -const request = require('request'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -let coinInc; - - -// Config Table Layout -// . - -global.mysql.query("SELECT * FROM config").then(function (rows) { - rows.forEach(function (row){ - if (!global.config.hasOwnProperty(row.module)){ - global.config[row.module] = {}; - } - if (global.config[row.module].hasOwnProperty(row.item)){ - return; - } - switch(row.item_type){ - case 'int': - global.config[row.module][row.item] = parseInt(row.item_value); - break; - case 'bool': - global.config[row.module][row.item] = (row.item_value === "true"); - break; - case 'string': - global.config[row.module][row.item] = row.item_value; - break; - case 'float': - global.config[row.module][row.item] = parseFloat(row.item_value); - break; - } - }); -}).then(function(){ - global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; - coinInc = require("." + global.config.coin.funcFile); - global.coinFuncs = new coinInc(); - if (argv.module === 'pool'){ - comms = require('../lib/remote_comms'); - } else { - comms = require('../lib/local_comms'); - } - global.database = new comms(); - global.database.initEnv(); - global.coinFuncs.blockedAddresses.push(global.config.pool.address); - global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); -}).then(function(){ - /* - message Block { - 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; - optional int64 value = 8; - } - */ - /*let invalidBlockProto = global.protos.Block.encode({ - hash: "88cf2c37e1e4e8a273cbe3ec502b6975fd6c4ebe1e8889ad9d5e53a5e9cde007", - difficulty: 1002932, - shares: 0, - timestamp: Date.now(), - poolType: global.protos.POOLTYPE.PPS, - unlocked: false, - valid: true, - value:0 - }); - let wsData = global.protos.WSData.encode({ - msgType: global.protos.MESSAGETYPE.BLOCK, - key: global.config.api.authKey, - msg: invalidBlockProto, - exInt: 1 - }); - request.post({url: global.config.general.shareHost, body: wsData}, function (error, response, body) { - console.log(error); - console.log(JSON.stringify(response)); - console.log(JSON.stringify(body)); - });*/ -}); - diff --git a/debug_scripts/block_add2.js b/debug_scripts/block_add2.js deleted file mode 100644 index 43654517..00000000 --- a/debug_scripts/block_add2.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let argv = require('minimist')(process.argv.slice(2)); -let config = fs.readFileSync("../config.json"); -let coinConfig = fs.readFileSync("../coinConfig.json"); -let protobuf = require('protocol-buffers'); -const request = require('request'); - -global.support = require("../lib/support.js")(); -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.protos = protobuf(fs.readFileSync('../lib/data.proto')); -let comms; -let coinInc; - - -// Config Table Layout -// . - -global.mysql.query("SELECT * FROM config").then(function (rows) { - rows.forEach(function (row){ - if (!global.config.hasOwnProperty(row.module)){ - global.config[row.module] = {}; - } - if (global.config[row.module].hasOwnProperty(row.item)){ - return; - } - switch(row.item_type){ - case 'int': - global.config[row.module][row.item] = parseInt(row.item_value); - break; - case 'bool': - global.config[row.module][row.item] = (row.item_value === "true"); - break; - case 'string': - global.config[row.module][row.item] = row.item_value; - break; - case 'float': - global.config[row.module][row.item] = parseFloat(row.item_value); - break; - } - }); -}).then(function(){ - global.config['coin'] = JSON.parse(coinConfig)[global.config.coin]; - coinInc = require("." + global.config.coin.funcFile); - global.coinFuncs = new coinInc(); - comms = require('../lib/local_comms'); - global.database = new comms(); - global.database.initEnv(); - global.coinFuncs.blockedAddresses.push(global.config.pool.address); - global.coinFuncs.blockedAddresses.push(global.config.payout.feeAddress); -}).then(function(){ - /*global.database.storeBlock(1509990, global.protos.Block.encode({ - hash: "a677ed7fb05ecb82bdb02f0cbb0f3099914392991225704559616658d7661748", - difficulty: 115634200078, - shares: 0, - timestamp: 1518686098779, - poolType: global.protos.POOLTYPE.PPLNS, - unlocked: false, - valid: true - }));*/ - -}); From 3e2ed02f152e30329a3cffeee3addf1e202eb1ba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 23:40:51 +0200 Subject: [PATCH 0613/2430] Added cache clean to longRunner --- lib/longRunner.js | 73 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 7b19f870..a75df837 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -3,6 +3,75 @@ console.log("Cleaning up the share DB"); global.database.cleanShareDB(); setInterval(function(){ - console.log("Cleaning up the share DB"); - global.database.cleanShareDB(); + console.log("Cleaning up the share DB"); + global.database.cleanShareDB(); }, 4*60*60*1000); + + +// clean cache items +setInterval(function(){ + console.log("Cleaning up the cache DB"); + let count = 0; + let txn = global.database.env.beginTxn({readOnly: true}); + 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.includes("identifiers:")) { // remove frozen worker names after 24h + let parts = key.split(/:(.+)/); + let key2 = parts[1]; + + try { + let data2 = JSON.parse(data); + if (data2.length == 0) return; + let isAlive = false; + for (let i in data2) { + let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); + 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(); + } + + } catch (e) { + console.error("Bad cache data with " + key + " key"); + } + + } else if (key.includes("_") && !key.includes("history:") && !key.includes("stats:")) { // remove week old workers + let stats = global.database.getCache("stats:" + key); + 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; + } + + } else if (!key.includes("_") && key.includes("stats:")) { // zero frozen account hashrate after 24h + try { + 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(); + } + } catch (e) { + console.error("Bad cache data with " + key + " key"); + } + + } + }); + } + + cursor.close(); + txn.commit(); + console.log("Deleted cache items: " + count); +}, 24*60*60*1000); From 933df22086b86df86d52794f6bb1d4108875179f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 May 2018 23:45:58 +0200 Subject: [PATCH 0614/2430] Added cache clean to longRunner --- lib/longRunner.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index a75df837..1bbdb1fc 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -1,15 +1,6 @@ "use strict"; -console.log("Cleaning up the share DB"); -global.database.cleanShareDB(); -setInterval(function(){ - console.log("Cleaning up the share DB"); - global.database.cleanShareDB(); -}, 4*60*60*1000); - - -// clean cache items -setInterval(function(){ +function cleanCacheDB() { console.log("Cleaning up the cache DB"); let count = 0; let txn = global.database.env.beginTxn({readOnly: true}); @@ -74,4 +65,18 @@ setInterval(function(){ cursor.close(); txn.commit(); console.log("Deleted cache items: " + count); +} + +console.log("Cleaning up the share DB"); +global.database.cleanShareDB(); +cleanCacheDB(); + +setInterval(function(){ + console.log("Cleaning up the share DB"); + global.database.cleanShareDB(); +}, 4*60*60*1000); + +// clean cache items +setInterval(function(){ + cleanCacheDB(); }, 24*60*60*1000); From 7b6b8c224fa183a53112d09a335842b943d76ca3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 28 May 2018 16:35:16 +0200 Subject: [PATCH 0615/2430] Script minor change --- manage_scripts/cache_clean.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/manage_scripts/cache_clean.js b/manage_scripts/cache_clean.js index e6f3e844..3dd69f69 100644 --- a/manage_scripts/cache_clean.js +++ b/manage_scripts/cache_clean.js @@ -21,25 +21,25 @@ require("../init_mini.js").init(function() { try { let data2 = JSON.parse(data); - if (data2.length) { - let isAlive = false; - for (let i in data2) { - let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); - if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; - } - if (!isAlive) { - data2 = []; - console.log(key + ": found dead key"); - let txn2 = global.database.env.beginTxn(); - txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); - txn2.commit(); - } + if (data2.length == 0) return; + let isAlive = false; + for (let i in data2) { + let stats = global.database.getCache("stats:" + key2 + "_" + data2[i]); + if (stats && Date.now() - stats.lastHash <= 24*60*60*1000) isAlive = true; } + if (!isAlive) { + data2 = []; + console.log(key + ": found dead key"); + let txn2 = global.database.env.beginTxn(); + txn2.putString(global.database.cacheDB, key, JSON.stringify(data2)); + txn2.commit(); + } + } catch (e) { console.error("Bad cache data with " + key + " key"); } - } else if (key.includes("_")) { + } else if (key.includes("_")) { if (key.includes("history:") || key.includes("stats:")) { let parts = key.split(/:(.+)/); let key2 = parts[1]; From c4e3d49b2719a5a38007fc5cf3e5d9fea4d25eb8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 28 May 2018 21:11:08 +0200 Subject: [PATCH 0616/2430] Removed wrong chars --- manage_scripts/altblock_add.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/manage_scripts/altblock_add.js b/manage_scripts/altblock_add.js index 3c8cae7f..cb24f186 100644 --- a/manage_scripts/altblock_add.js +++ b/manage_scripts/altblock_add.js @@ -20,8 +20,6 @@ try { body2 = JSON.parse(body); } catch(e) { process.exit(1); } -1527369252: {,"pay_stage":"Unlocking wallet balance","pay_status":"OK"} - require("../init_mini.js").init(function() { const body3 = { "hash": body2.hash, From a2c7f4d0d98bcf87a57857db2bda5bd04974843d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 28 May 2018 21:19:24 +0200 Subject: [PATCH 0617/2430] Moved scripts --- {manage_scripts => user_scripts}/balance_move.js | 0 {manage_scripts => user_scripts}/pass_reset.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {manage_scripts => user_scripts}/balance_move.js (100%) rename {manage_scripts => user_scripts}/pass_reset.js (100%) diff --git a/manage_scripts/balance_move.js b/user_scripts/balance_move.js similarity index 100% rename from manage_scripts/balance_move.js rename to user_scripts/balance_move.js diff --git a/manage_scripts/pass_reset.js b/user_scripts/pass_reset.js similarity index 100% rename from manage_scripts/pass_reset.js rename to user_scripts/pass_reset.js From 1dcca75bc6ffca3ed997b0aded41073792e28b2d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 29 May 2018 15:53:01 +0200 Subject: [PATCH 0618/2430] Removed outdated script --- tools/blocks.js | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 tools/blocks.js diff --git a/tools/blocks.js b/tools/blocks.js deleted file mode 100644 index 1de41493..00000000 --- a/tools/blocks.js +++ /dev/null @@ -1,44 +0,0 @@ -const valid_actions = ['finder', 'stats', 'list']; -let error = 0; - -if (!global.argv.hasOwnProperty('action') || valid_actions.indexOf(global.argv.action) === -1) { - console.error("No action provided to block module."); - console.error("Valid actions: " + valid_actions.join(', ')); -} - -switch (global.argv.action) { - case 'finder': - if (!global.argv.hasOwnProperty('value')) { - console.error('No block provided in value field. Please use --value=blockID'); - error = 1; - break; - } - let blockID = parseInt(global.argv.value); - let block_data = global.database.getBlockByID(blockID); - /* - 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; - optional int64 value = 8; - */ - if (!block_data) { - console.error("Invalid blockID provided."); - error = 1; - break; - } - console.log("Data for block: " + blockID + '\n' + - 'Hash: ' + block_data.hash + '\n' + - 'Difficulty: ' + block_data.hash + '\n' + - 'Hashes Required: ' + block_data.hash + '\n' + - 'Find Time: ' + block_data.hash + '\n' + - 'Pool Type: ' + block_data.hash + '\n' + - 'Unlocked: ' + block_data.hash + '\n' + - 'Valid: ' + block_data.hash + '\n' + - 'Value: ' + block_data.hash + '\n'); -} - -process.exit(error); \ No newline at end of file From 69502d8723197cae1f5cb8fb439e1955fe9e28fa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 29 May 2018 15:54:03 +0200 Subject: [PATCH 0619/2430] Removed outdated script --- sql_sync/config_entries.json | 578 ----------------------------------- sql_sync/sql_sync.js | 31 -- 2 files changed, 609 deletions(-) delete mode 100644 sql_sync/config_entries.json delete mode 100644 sql_sync/sql_sync.js diff --git a/sql_sync/config_entries.json b/sql_sync/config_entries.json deleted file mode 100644 index 8d320da0..00000000 --- a/sql_sync/config_entries.json +++ /dev/null @@ -1,578 +0,0 @@ -[ - { - "id": 1, - "module": "pool", - "item": "address", - "item_value": "", - "item_type": "string", - "Item_desc": "Address to mine to, this should be the wallet-rpc address." - }, - { - "id": 2, - "module": "pool", - "item": "minerTimeout", - "item_value": "900", - "item_type": "int", - "Item_desc": "Length of time before a miner is flagged inactive." - }, - { - "id": 3, - "module": "pool", - "item": "banEnabled", - "item_value": "true", - "item_type": "bool", - "Item_desc": "Enables/disabled banning of \"bad\" miners." - }, - { - "id": 4, - "module": "pool", - "item": "banLength", - "item_value": "-15m", - "item_type": "string", - "Item_desc": "Ban duration except perma-bans" - }, - { - "id": 5, - "module": "pool", - "item": "targetTime", - "item_value": "30", - "item_type": "int", - "Item_desc": "Time in seconds between share finds" - }, - { - "id": 6, - "module": "pool", - "item": "trustThreshold", - "item_value": "30", - "item_type": "int", - "Item_desc": "Number of shares before miner trust can kick in." - }, - { - "id": 8, - "module": "pool", - "item": "banPercent", - "item_value": "25", - "item_type": "int", - "Item_desc": "Percentage of shares that need to be invalid to be banned." - }, - { - "id": 9, - "module": "pool", - "item": "banThreshold", - "item_value": "30", - "item_type": "int", - "Item_desc": "Number of shares before bans can begin" - }, - { - "id": 10, - "module": "pool", - "item": "trustedMiners", - "item_value": "true", - "item_type": "bool", - "Item_desc": "Enable the miner trust system" - }, - { - "id": 11, - "module": "pool", - "item": "trustChange", - "item_value": "1", - "item_type": "int", - "Item_desc": "Change in the miner trust in percent" - }, - { - "id": 12, - "module": "pool", - "item": "trustMin", - "item_value": "20", - "item_type": "int", - "Item_desc": "Minimum level of miner trust" - }, - { - "id": 13, - "module": "pool", - "item": "trustPenalty", - "item_value": "30", - "item_type": "int", - "Item_desc": "Number of shares that must be successful to be trusted, reset to this value if trust share is broken" - }, - { - "id": 14, - "module": "pool", - "item": "retargetTime", - "item_value": "60", - "item_type": "int", - "Item_desc": "Time between difficulty retargets" - }, - { - "id": 15, - "module": "daemon", - "item": "address", - "item_value": "127.0.0.1", - "item_type": "string", - "Item_desc": "Monero Daemon RPC IP" - }, - { - "id": 16, - "module": "daemon", - "item": "port", - "item_value": "18081", - "item_type": "int", - "Item_desc": "Monero Daemon RPC Port" - }, - { - "id": 17, - "module": "wallet", - "item": "address", - "item_value": "127.0.0.1", - "item_type": "string", - "Item_desc": "Monero Daemon RPC Wallet IP" - }, - { - "id": 18, - "module": "wallet", - "item": "port", - "item_value": "37458", - "item_type": "int", - "Item_desc": "Monero Daemon RPC Wallet Port" - }, - { - "id": 21, - "module": "rpc", - "item": "https", - "item_value": "false", - "item_type": "bool", - "Item_desc": "Enable RPC over SSL" - }, - { - "id": 22, - "module": "pool", - "item": "maxDifficulty", - "item_value": "500000", - "item_type": "int", - "Item_desc": "Maximum difficulty for VarDiff" - }, - { - "id": 23, - "module": "pool", - "item": "minDifficulty", - "item_value": "100", - "item_type": "int", - "Item_desc": "Minimum difficulty for VarDiff" - }, - { - "id": 24, - "module": "pool", - "item": "varDiffVariance", - "item_value": "20", - "item_type": "int", - "Item_desc": "Percentage out of the target time that difficulty changes" - }, - { - "id": 25, - "module": "pool", - "item": "varDiffMaxChange", - "item_value": "30", - "item_type": "int", - "Item_desc": "Percentage amount that the difficulty may change" - }, - { - "id": 27, - "module": "payout", - "item": "btcFee", - "item_value": "1.5", - "item_type": "float", - "Item_desc": "Fee charged for auto withdrawl via BTC" - }, - { - "id": 28, - "module": "payout", - "item": "ppsFee", - "item_value": "6.5", - "item_type": "float", - "Item_desc": "Fee charged for usage of the PPS pool" - }, - { - "id": 29, - "module": "payout", - "item": "pplnsFee", - "item_value": ".6", - "item_type": "float", - "Item_desc": "Fee charged for the usage of the PPLNS pool" - }, - { - "id": 30, - "module": "payout", - "item": "propFee", - "item_value": ".7", - "item_type": "float", - "Item_desc": "Fee charged for the usage of the proportial pool" - }, - { - "id": 31, - "module": "payout", - "item": "soloFee", - "item_value": ".4", - "item_type": "float", - "Item_desc": "Fee charged for usage of the solo mining pool" - }, - { - "id": 32, - "module": "payout", - "item": "exchangeMin", - "item_value": "5", - "item_type": "float", - "Item_desc": "Minimum XMR balance for payout to exchange/payment ID" - }, - { - "id": 33, - "module": "payout", - "item": "walletMin", - "item_value": ".3", - "item_type": "float", - "Item_desc": "Minimum XMR balance for payout to personal wallet" - }, - { - "id": 34, - "module": "payout", - "item": "devDonation", - "item_value": "5", - "item_type": "float", - "Item_desc": "Donation to XMR core development" - }, - { - "id": 35, - "module": "payout", - "item": "poolDevDonation", - "item_value": "0", - "item_type": "float", - "Item_desc": "Donation to pool developer" - }, - { - "id": 36, - "module": "payout", - "item": "denom", - "item_value": ".000001", - "item_type": "float", - "Item_desc": "Minimum balance that will be paid out to." - }, - { - "id": 37, - "module": "payout", - "item": "blocksRequired", - "item_value": "60", - "item_type": "int", - "Item_desc": "Blocks required to validate a payout before it's performed." - }, - { - "id": 38, - "module": "general", - "item": "sigDivisor", - "item_value": "1000000000000", - "item_type": "int", - "Item_desc": "Divisor for turning coin into human readable amounts " - }, - { - "id": 39, - "module": "payout", - "item": "feeAddress", - "item_value": "", - "item_type": "string", - "Item_desc": "Address that pool fees are sent to." - }, - { - "id": 40, - "module": "payout", - "item": "feesForTXN", - "item_value": "10", - "item_type": "int", - "Item_desc": "Amount of XMR that is left from the fees to pay miner fees." - }, - { - "id": 41, - "module": "payout", - "item": "maxTxnValue", - "item_value": "250", - "item_type": "int", - "Item_desc": "Maximum amount of XMR to send in a single transaction" - }, - { - "id": 42, - "module": "payout", - "item": "shapeshiftPair", - "item_value": "xmr_btc", - "item_type": "string", - "Item_desc": "Pair to use in all shapeshift lookups for auto BTC payout" - }, - { - "id": 43, - "module": "general", - "item": "coinCode", - "item_value": "XMR", - "item_type": "string", - "Item_desc": "Coincode to be loaded up w/ the shapeshift getcoins argument." - }, - { - "id": 44, - "module": "general", - "item": "allowBitcoin", - "item_value": "true", - "item_type": "bool", - "Item_desc": "Allow the pool to auto-payout to BTC via ShapeShift" - }, - { - "id": 45, - "module": "payout", - "item": "exchangeRate", - "item_value": "1217200", - "item_type": "float", - "Item_desc": "Current exchange rate" - }, - { - "id": 46, - "module": "payout", - "item": "bestExchange", - "item_value": "xmrto", - "item_type": "string", - "Item_desc": "Current best exchange" - }, - { - "id": 47, - "module": "payout", - "item": "mixIn", - "item_value": "4", - "item_type": "int", - "Item_desc": "Mixin count for coins that support such things." - }, - { - "id": 48, - "module": "pool", - "item": "geoDNS", - "item_value": "", - "item_type": "string", - "Item_desc": "geoDNS enabled address for the pool." - }, - { - "id": 49, - "module": "general", - "item": "statsBufferLength", - "item_value": "120", - "item_type": "int", - "Item_desc": "Number of items to be cached in the stats buffers." - }, - { - "id": 50, - "module": "api", - "item": "authKey", - "item_value": "", - "item_type": "string", - "Item_desc": "Auth key sent with all Websocket frames for validation" - }, - { - "id": 51, - "module": "general", - "item": "mailgunKey", - "item_value": "", - "item_type": "string", - "Item_desc": "MailGun API Key for notification" - }, - { - "id": 52, - "module": "general", - "item": "mailgunURL", - "item_value": "", - "item_type": "string", - "Item_desc": "MailGun URL for notifications" - }, - { - "id": 53, - "module": "general", - "item": "emailFrom", - "item_value": "", - "item_type": "string", - "Item_desc": "From address for the notification emails" - }, - { - "id": 54, - "module": "pps", - "item": "enable", - "item_value": "false", - "item_type": "bool", - "Item_desc": "Enable PPS or not" - }, - { - "id": 55, - "module": "pplns", - "item": "shareMulti", - "item_value": "2", - "item_type": "int", - "Item_desc": "Multiply this times difficulty to set the N in PPLNS" - }, - { - "id": 56, - "module": "pplns", - "item": "shareMultiLog", - "item_value": "3", - "item_type": "int", - "Item_desc": "How many times the difficulty of the current block do we keep in shares before clearing them out" - }, - { - "id": 57, - "module": "general", - "item": "blockCleaner", - "item_value": "true", - "item_type": "bool", - "Item_desc": "Enable the deletion of blocks or not." - }, - { - "id": 58, - "module": "api", - "item": "secKey", - "item_value": "", - "item_type": "string", - "Item_desc": "HMAC key for Passwords. JWT Secret Key" - }, - { - "id": 59, - "module": "payout", - "item": "feeSlewAmount", - "item_value": ".011", - "item_type": "float", - "Item_desc": "Amount to charge for the txn fee" - }, - { - "id": 60, - "module": "payout", - "item": "feeSlewEnd", - "item_value": "4", - "item_type": "float", - "Item_desc": "Value at which txn fee amount drops to 0" - }, - { - "id": 61, - "module": "general", - "item": "testnet", - "item_value": "false", - "item_type": "bool", - "Item_desc": "Does this pool use testnet?" - }, - { - "id": 62, - "module": "pplns", - "item": "enable", - "item_value": "true", - "item_type": "bool", - "Item_desc": "Enable PPLNS on the pool." - }, - { - "id": 63, - "module": "solo", - "item": "enable", - "item_value": "true", - "item_type": "bool", - "Item_desc": "Enable SOLO mining on the pool" - }, - { - "id": 64, - "module": "general", - "item": "adminEmail", - "item_value": "", - "item_type": "string", - "Item_desc": "Admin e-mail to send e-mails to when something isn't working right." - }, - { - "id": 65, - "module": "payout", - "item": "rpcPasswordEnabled", - "item_value": "false", - "item_type": "bool", - "Item_desc": "Does the wallet use a RPC password?" - }, - { - "id": 66, - "module": "payout", - "item": "rpcPasswordPath", - "item_value": "", - "item_type": "string", - "Item_desc": "Path and file for the RPC password file location" - }, - { - "id": 67, - "module": "payout", - "item": "maxPaymentTxns", - "item_value": "5", - "item_type": "int", - "Item_desc": "Maximum number of transactions in a single payment" - }, - { - "id": 68, - "module": "general", - "item": "shareHost", - "item_value": "", - "item_type": "string", - "Item_desc": "Host that receives share information" - }, - { - "id": 70, - "module": "email", - "item": "workerNotHashingBody", - "item_value": "Hello,\n\nYour worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n\nThank you,\n%(poolEmailSig)s", - "item_type": "string", - "Item_desc": "Email sent to the miner when their worker stops hashing" - }, - { - "id": 71, - "module": "email", - "item": "workerNotHashingSubject", - "item_value": "Worker %(worker)s stopped hashing", - "item_type": "string", - "Item_desc": "Subject of email sent to miner when worker stops hashing" - }, - { - "id": 72, - "module": "general", - "item": "emailSig", - "item_value": "NodeJS-Pool Administration Team", - "item_type": "string", - "Item_desc": "Signature line for the emails." - }, - { - "id": 73, - "module": "payout", - "item": "timer", - "item_value": "120", - "item_type": "int", - "Item_desc": "Number of minutes between main payment daemon cycles" - }, - { - "id": 74, - "module": "payout", - "item": "timerRetry", - "item_value": "25", - "item_type": "int", - "Item_desc": "Number of minutes between payment daemon retrying due to not enough funds" - }, - { - "id": 75, - "module": "payout", - "item": "priority", - "item_value": "0", - "item_type": "int", - "Item_desc": "Payout priority setting. 0 = use default (4x fee); 1 = low prio (1x fee)" - }, - { - "id": 76, - "module": "payout", - "item": "fee", - "item_value": "10000000000", - "item_type": "int", - "Item_desc": "Atomic units of coin to use ass a fee" - }, - { - "id": 77, - "module": "payout", - "item": "unlock_time", - "item_value": "0", - "item_type": "int", - "Item_desc": "Number of blocks assumed before the payout unlocks." - } -] diff --git a/sql_sync/sql_sync.js b/sql_sync/sql_sync.js deleted file mode 100644 index 72644bbd..00000000 --- a/sql_sync/sql_sync.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -let mysql = require("promise-mysql"); -let fs = require("fs"); -let config = fs.readFileSync("../config.json"); -let sql_schema = fs.readFileSync("config_entries.json"); -let async = require("async"); - -global.config = JSON.parse(config); -global.mysql = mysql.createPool(global.config.mysql); -global.schema = JSON.parse(sql_schema); - -// Config Table Layout -// . - -let loopCount = 0; -let updatedCount = 0; -async.eachSeries(global.schema, function(entry, callback){ - global.mysql.query("SELECT * FROM config WHERE module = ? AND item = ?", [entry.module, entry.item]).then(function(rows){ - loopCount += 1; - if (rows.length > 0){ - return callback(); - } - updatedCount += 1; - global.mysql.query("INSERT INTO config (module, item, item_value, item_type, Item_desc) VALUES (?, ?, ?, ?, ?)", [entry.module, entry.item, entry.item_value, entry.item_type, entry.Item_desc]).then(function(){ - return callback(); - }); - }); -}, function(){ - console.log("Updated SQL schema with "+updatedCount+" new rows! Exiting!"); - process.exit(); -}); \ No newline at end of file From fe0d7f1dc113bc358fa5080e0db11d37e4a805fa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 29 May 2018 15:56:10 +0200 Subject: [PATCH 0620/2430] Removed not used files --- SQL_MIGRATIONS.md | 35 ----------------------------------- coinConfig.json | 24 ------------------------ sample_config.sql | 6 ------ 3 files changed, 65 deletions(-) delete mode 100644 SQL_MIGRATIONS.md delete mode 100644 sample_config.sql diff --git a/SQL_MIGRATIONS.md b/SQL_MIGRATIONS.md deleted file mode 100644 index 355b13d8..00000000 --- a/SQL_MIGRATIONS.md +++ /dev/null @@ -1,35 +0,0 @@ -2/12/2017 ---------- -```sql -ALTER TABLE pool.config MODIFY item_value TEXT; -``` - -2/13/2017 ---------- -```sql -ALTER TABLE pool.payments ADD transfer_fee BIGINT(20) DEFAULT 0 NULL; -``` - -2/16/2017 ---------- -```sql -ALTER DATABASE pool DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.balance CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.bans CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.block_log CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.config CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.payments CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.pools CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.port_config CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.ports CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.shapeshiftTxn CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.transactions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.users CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -ALTER TABLE pool.xmrtoTxn CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; -``` - -2/25/2017 ---------- -```sql -ALTER TABLE pool.users ADD enable_email BOOL DEFAULT true NULL; -``` \ No newline at end of file diff --git a/coinConfig.json b/coinConfig.json index 2cbf1015..cdf6e355 100644 --- a/coinConfig.json +++ b/coinConfig.json @@ -8,29 +8,5 @@ "name": "Monero", "mixIn": 4, "shortCode": "XMR" - }, - "krb": { - "funcFile": "./lib/coins/krb.js", - "paymentFile": "./payment_systems/krb.js", - "sigDigits": 1000000000000, - "name": "Karbowanec", - "mixIn": 4, - "shortCode": "KRB" - }, - "aeon": { - "funcFile": "./lib/coins/aeon.js", - "paymentFile": "./payment_systems/aeon.js", - "sigDigits": 1000000000000, - "name": "Aeon Coin", - "mixIn": 4, - "shortCode": "AEON" - }, - "aeon-rebase": { - "funcFile": "./lib/coins/aeon-rebase.js", - "paymentFile": "./payment_systems/aeon-rebase.js", - "sigDigits": 1000000000000, - "name": "Aeon Coin", - "mixIn": 4, - "shortCode": "AEON" } } diff --git a/sample_config.sql b/sample_config.sql deleted file mode 100644 index dac267ec..00000000 --- a/sample_config.sql +++ /dev/null @@ -1,6 +0,0 @@ -UPDATE pool.config SET item_value = '' WHERE module = 'pool' and item = 'address'; -UPDATE pool.config SET item_value = '' WHERE module = 'payout' and item = 'feeAddress'; -UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'mailgunKey'; -UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'mailgunURL'; -UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'emailFrom'; -UPDATE pool.config SET item_value = '' WHERE module = 'general' and item = 'shareHost'; From 903a94b569458f3a2558b0aaa3c66d51fc3beda5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 30 May 2018 14:53:33 +0200 Subject: [PATCH 0621/2430] Removed wrong line --- user_scripts/pass_reset.js | 1 - 1 file changed, 1 deletion(-) diff --git a/user_scripts/pass_reset.js b/user_scripts/pass_reset.js index 03f4ab2b..74c83bd0 100644 --- a/user_scripts/pass_reset.js +++ b/user_scripts/pass_reset.js @@ -18,7 +18,6 @@ require("../init_mini.js").init(function() { process.exit(1); } console.log("Found rows in users table: " + rows.length); - rows2remove += rows.length; callback(); }); }, From 3d59d686ff3e0d80cd85f291a18913023093358b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 30 May 2018 14:57:00 +0200 Subject: [PATCH 0622/2430] Updated BKM --- user_scripts/pass_reset.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_scripts/pass_reset.js b/user_scripts/pass_reset.js index 74c83bd0..9c92ab71 100644 --- a/user_scripts/pass_reset.js +++ b/user_scripts/pass_reset.js @@ -14,7 +14,7 @@ require("../init_mini.js").init(function() { function (callback) { global.mysql.query("SELECT * FROM users WHERE username = ?", [user]).then(function (rows) { if (rows.length != 1) { - console.error("User was not found!"); + console.error("Your password is not yet set. To do that you need to set password field in your miner to \":\", where is any name (without : character) and is your password (depending on miner password can be in in command line, config.json or config.txt files). Optionally you can use your email as your password if you want notifications about miner downtimes from the pool. You need to make sure you restart your miner and your miner submits at least one valid share for password to be set."); process.exit(1); } console.log("Found rows in users table: " + rows.length); @@ -28,7 +28,7 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - console.log("DONE: Please do not forget to restart your miner to apply new password and set payment thresold since it was reset as well"); + console.log("Done. Please do not forget to restart your miner to apply new password and set payment threshold since it was reset as well"); process.exit(0); } ]); From 71688d041b58ed37f8a9b63d7b4ac4d553a5e30c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 1 Jun 2018 09:59:55 +0200 Subject: [PATCH 0623/2430] More intellegent block submit error notifier --- lib/pool.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 103404cd..882003f4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1164,12 +1164,25 @@ function processShare(miner, job, blockTemplate, params) { 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)); - if (isNotifyAdmin) 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 height " + job.height + " (active block template height: " + activeBlockTemplate[blockTemplate.algo].height + ") from " + miner.logString + ", share type: " + shareType + " 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) + ); else 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" + + threadName + "Error submitting block at height " + job.height + " height from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + "\n" + + "Because likely current height on this port already changed to " + (body.height + 1) + ); + }); + }, 5*1000); if (global.config.pool.trustedMiners) { debug(threadName + "Share trust broken by " + miner.logString); miner.trust.probability = 256; From 2a008b08deb1753b4d4ee2dea67a3fa854989930 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 1 Jun 2018 10:43:54 +0200 Subject: [PATCH 0624/2430] Removed debug email message --- lib/pool.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 882003f4..4d3664f0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1175,11 +1175,6 @@ function processShare(miner, job, blockTemplate, params) { "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) - ); else 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" + - threadName + "Error submitting block at height " + job.height + " height from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) + "\n" + - "Because likely current height on this port already changed to " + (body.height + 1) ); }); }, 5*1000); From 41f16be87b9bde1fab71241ffcdf2fa3b3f67dc3 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Fri, 1 Jun 2018 21:42:57 +0300 Subject: [PATCH 0625/2430] It is don't need to run. --- deployment/deploy.bash | 2 -- 1 file changed, 2 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 747319c1..bb0f7bc5 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -92,6 +92,4 @@ mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api bash ~/nodejs-pool/deployment/install_lmdb_tools.sh -cd ~/nodejs-pool/sql_sync/ -env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin node sql_sync.js echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" From 3b38e3373860064dec2cce211f3ed07b92013312 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 2 Jun 2018 07:02:13 +0200 Subject: [PATCH 0626/2430] Fixed SQL expression --- user_scripts/balance_move.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_scripts/balance_move.js b/user_scripts/balance_move.js index 60a554ae..9f4033a0 100644 --- a/user_scripts/balance_move.js +++ b/user_scripts/balance_move.js @@ -65,14 +65,14 @@ require("../init_mini.js").init(function() { }); }, function (callback) { - global.mysql.query("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str).then(function (rows) { - console.log("UPDATE balance SET amount = '0' FROM balance WHERE " + old_where_str); + 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 + " FROM balance WHERE " + new_where_str).then(function (rows) { - console.log("UPDATE balance SET amount = amount + " + old_amount + " FROM balance WHERE " + new_where_str); + 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(); }); }, From 82344fa77deae4c9da80721223a16a46f448c4b5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Jun 2018 09:52:54 +0200 Subject: [PATCH 0627/2430] Simulate accumulated shares as normal ones --- lib/api.js | 4 ++-- lib/blockManager.js | 4 ++-- lib/data.proto | 1 + lib/local_comms.js | 13 ++++++----- lib/payment_systems/xmr.js | 2 +- lib/pool.js | 46 ++++++++++++++++++++------------------ 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/lib/api.js b/lib/api.js index 8baec67a..a5e84b1a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -48,7 +48,7 @@ function getAllWorkerHashCharts(address, callback){ let intCounter = 0; identifiers.forEach(function(identifier){ returnData[identifier] = global.database.getCache("history:" + address+"_"+identifier)['hashHistory']; - intCounter += 1; + ++ intCounter; if (intCounter === identifiers.length){ return callback(null, returnData); } @@ -79,7 +79,7 @@ function getAllWorkerStats(address, callback){ hash: cachedStatsData.hash, totalHash: cachedData.totalHashes }; - intCounter += 1; + ++ intCounter; if (intCounter === identifiers.length){ return callback(null, returnData); } diff --git a/lib/blockManager.js b/lib/blockManager.js index 3a2d7acf..dfa98b0f 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -666,7 +666,7 @@ function blockScanner() { lastBlock = blockHeader.height; range.range(0, (blockHeader.height - Math.floor(global.config.payout.blocksRequired/2))).forEach(function (blockID) { if (!blockIDCache.hasOwnProperty(blockID)) { - inc_check += 1; + ++ inc_check; blockQueue.push({blockID: blockID}, function (err) { debug("Completed block scan on " + blockID); if (err) { @@ -693,7 +693,7 @@ function initial_sync() { global.mysql.query("SELECT id, hex FROM block_log WHERE orphan = 0").then(function (rows) { let intCount = 0; rows.forEach(function (row) { - intCount += 1; + ++ intCount; blockIDCache.push(row.id); blockHexCache[row.hex] = null; }); diff --git a/lib/data.proto b/lib/data.proto index 1eb65441..f2b6fba1 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -40,6 +40,7 @@ message Share { required string identifier = 12; optional int32 port = 13; optional int32 shares2 = 14; + optional int32 share_num = 15; } message Block { diff --git a/lib/local_comms.js b/lib/local_comms.js index 2682ec6d..60b02ee7 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -213,7 +213,7 @@ function Database(){ debug(shareObject.length + ' shares to process'); shareObject.forEach(function(share){ //Data is the share object at this point. - shareCount += 1; + ++ shareCount; if (typeof(share.shares) === "number") { if (!shares.hasOwnProperty(share.blockHeight)) { shares[share.blockHeight] = []; @@ -255,8 +255,9 @@ function Database(){ } cachedData[minerIDWithIdentifier].totalHashes += share.shares; cachedData[minerID].totalHashes += share.shares; - cachedData[minerIDWithIdentifier].goodShares += 1; - cachedData[minerID].goodShares += 1; + const share_num = typeof(share.share_num) !== 'undefined' ? share.share_num : 1; + cachedData[minerIDWithIdentifier].goodShares += share_num; + cachedData[minerID].goodShares += share_num; } else { console.error("Error in share parser: " + JSON.stringify(share)); } @@ -302,10 +303,10 @@ function Database(){ let blocksSeen = 0; for (let key in shares){ if (shares.hasOwnProperty(key)){ - blocksSeen += 1; + ++ blocksSeen; let sharesSeen = 0; shares[key].forEach(function(final_share){ // jshint ignore:line - sharesSeen += 1; + ++ sharesSeen; try { txn.putBinary(global.database.shareDB, parseInt(key), global.protos.Share.encode(final_share)); } catch (e) { @@ -809,7 +810,7 @@ function Database(){ console.log("Block cleaning started: removing " + data.length + " block share records"); let txn = global.database.env.beginTxn(); data.forEach(function(block){ - totalDeleted += 1; + ++ totalDeleted; txn.del(global.database.shareDB, parseInt(block)); debug("Deleted block: " + parseInt(block)); }); diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 061018a3..3373095a 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -707,7 +707,7 @@ function makePayments() { 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 += 1; + ++ roundCount; let threshold = global.support.decimalToCoin(0.3); let custom_threshold = false; if (userRow.length !== 0 && userRow[0].payout_threshold != 0) { diff --git a/lib/pool.js b/lib/pool.js index 4d3664f0..2dbca4eb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -126,14 +126,10 @@ function messageHandler(message) { setNewAlgoHashFactor(message.data.algo, message.data.algoHashFactor); break; case 'removeMiner': - if (cluster.isMaster) { - minerCount[message.data] -= 1; - } + if (cluster.isMaster) -- minerCount[message.data]; break; case 'newMiner': - if (cluster.isMaster) { - minerCount[message.data] += 1; - } + if (cluster.isMaster) ++ minerCount[message.data]; break; case 'sendRemote': if (cluster.isMaster) { @@ -141,24 +137,24 @@ function messageHandler(message) { } break; case 'trustedShare': - trustedShares += 1; - totalShares += 1; + ++ trustedShares; + ++ totalShares; break; case 'normalShare': - normalShares += 1; - totalShares += 1; + ++ normalShares; + ++ totalShares; break; case 'invalidShare': - invalidShares += 1; - totalShares += 1; + ++ invalidShares; + ++ totalShares; break; case 'outdatedShare': - outdatedShares += 1; + ++ outdatedShares; // total shares will be also increased separately as part of share type above break; case 'throttledShare': - throttledShares += 1; - totalShares += 1; + ++ throttledShares; + ++ totalShares; break; } } @@ -767,9 +763,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer // Valid stats are stored by the pool. if (validShare) { - this.validShares += 1; + ++ this.validShares; } else { - this.invalidShares += 1; + ++ this.invalidShares; } if (this.validShares + this.invalidShares >= global.config.pool.banThreshold) { if (this.invalidShares / this.validShares >= global.config.pool.banPercent / 100) { @@ -887,13 +883,12 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi let worker = wallet[worker_name]; if (time_now - worker.time > 60*1000) { let acc = worker.acc; - let acc2 = worker.acc2; 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: acc2, + shares2: worker.acc2, paymentAddress: miner_address, paymentID: miner_paymentID, foundBlock: false, @@ -905,7 +900,8 @@ function walletAccFinalizer(wallet_key, miner_address, miner_paymentID, miner_bi blockHeight: height, timestamp: time_now, identifier: worker_name, - port: miner_port + port: miner_port, + share_num: worker.share_num })); } debug("!!! " + wallet_key + ": removing old worker " + worker_name); @@ -955,7 +951,8 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy blockHeight: db_job_height, timestamp: time_now, identifier: miner.identifier, - port: blockTemplate.port + port: blockTemplate.port, + share_num: 1 })); } else { @@ -974,6 +971,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy worker.time = time_now; worker.acc = 0; worker.acc2 = 0; + worker.share_num = 0; } let worker = wallet[worker_name]; @@ -982,6 +980,7 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy 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 >= 1000000) { if (acc != 0) { @@ -1000,7 +999,8 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy blockHeight: height, timestamp: time_now, identifier: worker_name, - port: blockTemplate.port + port: blockTemplate.port, + share_num: share_num })); } @@ -1009,10 +1009,12 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy 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 + ")"); From f51f45a8ab5aba5aab5b574e804f0867c6a2f2cf Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Jun 2018 10:14:48 +0200 Subject: [PATCH 0628/2430] Fixed timeouts --- lib/api.js | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/lib/api.js b/lib/api.js index a5e84b1a..be9a21eb 100644 --- a/lib/api.js +++ b/lib/api.js @@ -39,19 +39,12 @@ function get_identifiers(address) { // Support Functions that are reused now function getAllWorkerHashCharts(address, callback){ let identifiers = get_identifiers(address); - let returnData = {global: global.database.getCache("history:" + address)['hashHistory']}; - if (identifiers !== false){ - identifiers.sort(); - } else { - return returnData; - } + let returnData = { global: global.database.getCache("history:" + address)['hashHistory'] }; + if (identifiers === false || identifiers.length == 0) return callback(null, returnData); let intCounter = 0; - identifiers.forEach(function(identifier){ - returnData[identifier] = global.database.getCache("history:" + address+"_"+identifier)['hashHistory']; - ++ intCounter; - if (intCounter === identifiers.length){ - return callback(null, returnData); - } + identifiers.sort().forEach(function(identifier){ + returnData[identifier] = global.database.getCache("history:" + address + "_" + identifier)['hashHistory']; + if (++ intCounter === identifiers.length) return callback(null, returnData); }); } @@ -59,30 +52,27 @@ function getAllWorkerStats(address, callback){ let identifiers = get_identifiers(address); let globalCache = global.database.getCache(address); let globalStatsCache = global.database.getCache("stats:" + address); - let returnData = {global: { - lts: Math.floor(globalStatsCache.lastHash / 1000), - identifer: 'global', - hash: globalStatsCache.hash, - totalHash: globalCache.totalHashes - }}; + let returnData = { + global: { + lts: globalStatsCache !== false ? Math.floor(globalStatsCache.lastHash / 1000) : false, + identifer: 'global', + hash: globalStatsCache !== false ? globalStatsCache.hash : false, + totalHash: globalCache !== false ? globalCache.totalHashes : false + } + }; + if (identifiers === false || identifiers.length == 0) return callback(null, returnData); let intCounter = 0; - if (identifiers === false){ - return callback(null, returnData); - } identifiers.sort().forEach(function(identifier){ let id2 = address + "_" + identifier; let cachedData = global.database.getCache(id2); let cachedStatsData = global.database.getCache("stats:" + id2); returnData[identifier] = { - lts: Math.floor(cachedStatsData.lastHash / 1000), + lts: globalStatsCache !== false ? Math.floor(cachedStatsData.lastHash / 1000) : false, identifer: identifier, - hash: cachedStatsData.hash, - totalHash: cachedData.totalHashes + hash: globalStatsCache !== false ? cachedStatsData.hash : false, + totalHash: globalCache !== false ? globalCache.totalHashes : false }; - ++ intCounter; - if (intCounter === identifiers.length){ - return callback(null, returnData); - } + if (++ intCounter === identifiers.length) return callback(null, returnData); }); } From 829f70db3c260e8fb3767e5f466a402d3a5ee25b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Jun 2018 17:25:04 +0200 Subject: [PATCH 0629/2430] Fixed stats bug --- lib/api.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/api.js b/lib/api.js index be9a21eb..c89a9b9d 100644 --- a/lib/api.js +++ b/lib/api.js @@ -67,10 +67,10 @@ function getAllWorkerStats(address, callback){ let cachedData = global.database.getCache(id2); let cachedStatsData = global.database.getCache("stats:" + id2); returnData[identifier] = { - lts: globalStatsCache !== false ? Math.floor(cachedStatsData.lastHash / 1000) : false, + lts: cachedStatsData !== false ? Math.floor(cachedStatsData.lastHash / 1000) : false, identifer: identifier, - hash: globalStatsCache !== false ? cachedStatsData.hash : false, - totalHash: globalCache !== false ? globalCache.totalHashes : false + hash: cachedStatsData !== false ? cachedStatsData.hash : false, + totalHash: cachedData !== false ? cachedData.totalHashes : false }; if (++ intCounter === identifiers.length) return callback(null, returnData); }); From e1d02cafaf75a0ec05481feacacd8b9805a953a8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Jun 2018 17:41:36 +0200 Subject: [PATCH 0630/2430] Fixed share count bug --- 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 60b02ee7..4ec5e1e1 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -255,7 +255,7 @@ function Database(){ } cachedData[minerIDWithIdentifier].totalHashes += share.shares; cachedData[minerID].totalHashes += share.shares; - const share_num = typeof(share.share_num) !== 'undefined' ? share.share_num : 1; + 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; } else { From ca9a8a4760b3b9131204f807899286bc047af9ba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Jun 2018 18:44:16 +0200 Subject: [PATCH 0631/2430] Added server side CMC query --- lib/support.js | 40 +++++++++++++++++++++++++++++++++++++++- lib/worker.js | 17 +++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/lib/support.js b/lib/support.js index 3323a1a2..4fe07f73 100644 --- a/lib/support.js +++ b/lib/support.js @@ -1,5 +1,6 @@ "use strict"; const CircularBuffer = require('circular-buffer'); +const https = require('https'); const request = require('request'); const requestJson = require('request-json'); const moment = require('moment'); @@ -170,6 +171,42 @@ function rpc_wallet(host, port, method, params, callback) { return jsonRequest(host, port, data, true, callback, 'json_rpc', 30*60*1000); } +function https_get(url, callback) { + let timer; + var req = https.get(url, function(res) { + if (res.statusCode != 200) { + console.error("URL " + url + ": Result code: " + res.statusCode); + return callback(null); + } + let str = ""; + res.on('data', function(d) { str += d; }); + res.on('end', function() { + if (timer) clearTimeout(timer); + let json; + try { + json = JSON.parse(str); + } catch (e) { + console.error("URL " + url + ": JSON parse exception: " + e); + return callback(str); + } + return callback(json); + }); + res.on('error', function() { + console.error("URL " + url + ": RESPONSE ERROR!"); + return callback(null); + }); + }); + req.on('error', function() { + console.error("URL " + url + ": REQUEST ERROR!"); + return callback(null); + }); + timer = setTimeout(function() { + console.error("URL " + url + ": TIMEOUT!"); + callback(null); + }, 30*1000); + req.end(); +} + function getAlgoHashFactor(algo, callback) { global.mysql.query("SELECT item_value FROM config WHERE module = 'daemon' and item = 'algoHashFactor" + algo + "'").then(function (rows) { if (rows.length != 1) { @@ -270,6 +307,7 @@ module.exports = function () { tsCompare: tsCompare, getAlgoHashFactor: getAlgoHashFactor, getActivePort: getActivePort, - setActivePort: setActivePort + setActivePort: setActivePort, + https_get: https_get, }; }; diff --git a/lib/worker.js b/lib/worker.js index 56181e60..446cc437 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -368,6 +368,9 @@ function updatePoolStats(poolType) { } } +let price_usd = 0; +let price_eur = 0; + 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() : ""; @@ -499,7 +502,16 @@ function updatePoolStats2(poolType) { //debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); let min_block_rewards = global.database.getCache('min_block_rewards'); return callback(null, min_block_rewards ? min_block_rewards : {}); - } + }, + function (callback) { + 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_usd = parseFloat(res[0].price_usd); + price_eur = parseFloat(res[0].price_eur); + } + return callback(null, { usd: price_usd, eur: price_eur }); + }); + }, ], function (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; @@ -520,7 +532,8 @@ function updatePoolStats2(poolType) { activePort: result[11] || 0, activePortProfit: result[12] || 0, activePortComment: result[13] || "", - minBlockRewards: result[14] || {} + minBlockRewards: result[14] || {}, + price: result[15] || {}, }); }); } From 11eaa60137e34d5490085625a808f8238027592a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Jun 2018 18:59:32 +0200 Subject: [PATCH 0632/2430] Added pending calc --- lib/worker.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 446cc437..55a5ee9c 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -370,6 +370,7 @@ function updatePoolStats(poolType) { let price_usd = 0; let price_eur = 0; +let min_block_rewards = {}; function updatePoolStats2(poolType) { let cache; @@ -402,6 +403,8 @@ function updatePoolStats2(poolType) { 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; async.series([ function (callback) { @@ -500,8 +503,19 @@ function updatePoolStats2(poolType) { }, function (callback) { //debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); - let min_block_rewards = global.database.getCache('min_block_rewards'); - return callback(null, min_block_rewards ? min_block_rewards : {}); + 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) { global.support.https_get("https://api.coinmarketcap.com/v1/ticker/" + global.config.coin.name + "/?convert=EUR", function (res) { @@ -533,7 +547,8 @@ function updatePoolStats2(poolType) { activePortProfit: result[12] || 0, activePortComment: result[13] || "", minBlockRewards: result[14] || {}, - price: result[15] || {}, + pending: result[15] || {}, + price: result[16] || {}, }); }); } From efcbbf381d9c3ef0f4ca8acc56cc3f6f682028d0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jun 2018 09:20:13 +0200 Subject: [PATCH 0633/2430] Current effort --- lib/worker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 55a5ee9c..7b2861d2 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -526,6 +526,14 @@ function updatePoolStats2(poolType) { return callback(null, { 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 (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; @@ -549,6 +557,7 @@ function updatePoolStats2(poolType) { minBlockRewards: result[14] || {}, pending: result[15] || {}, price: result[16] || {}, + currentEfforts: result[17] || {}, }); }); } @@ -753,7 +762,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 " + port + " port" ); } }); From 4cac21aaa9692a19aa23712d0eb74e03c9f75336 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jun 2018 09:37:49 +0200 Subject: [PATCH 0634/2430] Added extended network info --- lib/worker.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 7b2861d2..41f64f7b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -660,14 +660,22 @@ function updateBlockHeader() { if (body.hash !== lastBlockHash || main_body.height !== lastBlockHeight) { lastBlockHash = body.hash; lastBlockHeight = main_body.height; - global.database.setCache('networkBlockInfo', { - difficulty: body.difficulty, - hash: body.hash, - height: body.height, - main_height: main_body.height, - value: body.reward, - ts: body.timestamp - }); + let info = global.database.getCache('networkBlockInfo'); + if (info === false) info = {}; + info.difficulty = body.difficulty; + info.hash = body.hash; + info.height = body.height; + info.main_height = main_body.height; + info.value = body.reward; + info.ts = body.timestamp; + info[global.config.daemon.activePort] = { + difficulty = body.difficulty, + hash = body.hash, + height = body.height, + value = body.reward, + ts = body.timestamp, + }; + global.database.setCache('networkBlockInfo', info); } }); }); From 2957a98fa2cf583987f006fd2dbe36f7122acdd6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 8 Jun 2018 09:39:13 +0200 Subject: [PATCH 0635/2430] Added extended network info --- lib/worker.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 41f64f7b..776bf02d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -669,11 +669,11 @@ function updateBlockHeader() { info.value = body.reward; info.ts = body.timestamp; info[global.config.daemon.activePort] = { - difficulty = body.difficulty, - hash = body.hash, - height = body.height, - value = body.reward, - ts = body.timestamp, + difficulty: body.difficulty, + hash: body.hash, + height: body.height, + value: body.reward, + ts: body.timestamp, }; global.database.setCache('networkBlockInfo', info); } From e4544b7b6d5a45e410b62163af7138b330b6948f Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Fri, 8 Jun 2018 22:43:51 +0300 Subject: [PATCH 0636/2430] Price at bicoins --- lib/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 776bf02d..b24221db 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -520,10 +520,11 @@ function updatePoolStats2(poolType) { function (callback) { 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, { usd: price_usd, eur: price_eur }); + return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); }); }, function (callback) { From 531c08d5e3fb44820da443267d6daa4acec9b65c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 9 Jun 2018 12:28:50 +0200 Subject: [PATCH 0637/2430] Reduced block check wait time --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 2dbca4eb..0a5d5403 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1179,7 +1179,7 @@ function processShare(miner, job, blockTemplate, params) { threadName + "Error submitting block at " + job.height + " height from " + miner.logString + ", share type: " + shareType + " error: " + JSON.stringify(rpcResult.error) ); }); - }, 5*1000); + }, 2*1000); if (global.config.pool.trustedMiners) { debug(threadName + "Share trust broken by " + miner.logString); miner.trust.probability = 256; From 99329f163f6f87f6c5175286a5b99fc59c967dc6 Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sat, 9 Jun 2018 20:13:12 +0300 Subject: [PATCH 0638/2430] fix ReferenceError --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index b24221db..adeef298 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -368,6 +368,7 @@ function updatePoolStats(poolType) { } } +let price_btc = 0; let price_usd = 0; let price_eur = 0; let min_block_rewards = {}; From 74a98e9b1acd6d214524931b33ea0a246f86ce7e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 Jun 2018 09:09:20 +0200 Subject: [PATCH 0639/2430] Added case with missing user --- manage_scripts/user_del.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/manage_scripts/user_del.js b/manage_scripts/user_del.js index 22e08166..e72b0f48 100644 --- a/manage_scripts/user_del.js +++ b/manage_scripts/user_del.js @@ -44,10 +44,12 @@ require("../init_mini.js").init(function() { console.error("Too big payment left: " + global.support.coinToDecimal(rows[0].amount)); process.exit(1); } - console.log("Balance last update time: " + rows[0].last_edited); - if (Date.now()/1000 - global.support.formatDateFromSQL(rows[0].last_edited) < 24*60*60) { - console.error("There was recent amount update. Refusing to continue!"); - process.exit(1); + 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) { + console.error("There was recent amount update. Refusing to continue!"); + process.exit(1); + } } console.log("Found rows in balance table: " + rows.length); rows2remove += rows.length; From bd1733849e392bbc5869ed1cf8bb9e36323d53f4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 Jun 2018 16:00:08 +0200 Subject: [PATCH 0640/2430] Fixed timeout issue --- lib/support.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/support.js b/lib/support.js index 4fe07f73..59aca60f 100644 --- a/lib/support.js +++ b/lib/support.js @@ -175,6 +175,7 @@ function https_get(url, callback) { let timer; var req = https.get(url, function(res) { if (res.statusCode != 200) { + if (timer) clearTimeout(timer); console.error("URL " + url + ": Result code: " + res.statusCode); return callback(null); } @@ -192,11 +193,13 @@ function https_get(url, callback) { return callback(json); }); res.on('error', function() { + if (timer) clearTimeout(timer); console.error("URL " + url + ": RESPONSE ERROR!"); return callback(null); }); }); req.on('error', function() { + if (timer) clearTimeout(timer); console.error("URL " + url + ": REQUEST ERROR!"); return callback(null); }); From 757e5c7b517be7c2ec8d25920cd72c64400f839c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Jun 2018 08:44:19 +0200 Subject: [PATCH 0641/2430] Added ban helper scripts --- user_scripts/show_bans.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 user_scripts/show_bans.js diff --git a/user_scripts/show_bans.js b/user_scripts/show_bans.js new file mode 100644 index 00000000..f6ad7126 --- /dev/null +++ b/user_scripts/show_bans.js @@ -0,0 +1,21 @@ +"use strict"; +const mysql = require("promise-mysql"); +const async = require("async"); + +require("../init_mini.js").init(function() { + async.waterfall([ + 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."); + process.exit(0); + } + ]); +}); From c9355aac0fa7089e0a4715155399c8c2b909676e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Jun 2018 08:45:47 +0200 Subject: [PATCH 0642/2430] Added ban helper scripts --- user_scripts/ban_user.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 user_scripts/ban_user.js diff --git a/user_scripts/ban_user.js b/user_scripts/ban_user.js new file mode 100644 index 00000000..85baac26 --- /dev/null +++ b/user_scripts/ban_user.js @@ -0,0 +1,39 @@ +"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 ban"); + process.exit(1); +} +const user = argv.user; + +if (!argv.reason) { + console.error("Please specify reason to ban"); + process.exit(1); +} +const reason = argv.reson; + +require("../init_mini.js").init(function() { + async.waterfall([ + function (callback) { + global.mysql.query('INSERT INTO bans (mining_address, reason) VALUES (?, ?)', [user, reason]).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 banned."); + process.exit(0); + } + ]); +}); From 6490a150af655e198ad07c53d051dd41d033a00f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 12 Jun 2018 08:52:51 +0200 Subject: [PATCH 0643/2430] Fixed mistake --- user_scripts/ban_user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_scripts/ban_user.js b/user_scripts/ban_user.js index 85baac26..4b794353 100644 --- a/user_scripts/ban_user.js +++ b/user_scripts/ban_user.js @@ -13,7 +13,7 @@ if (!argv.reason) { console.error("Please specify reason to ban"); process.exit(1); } -const reason = argv.reson; +const reason = argv.reason; require("../init_mini.js").init(function() { async.waterfall([ From 24cb949b262995e7775ac0402224e1fa34adeed4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 23 Jun 2018 21:39:18 +0200 Subject: [PATCH 0644/2430] Fix for timeout requests --- lib/support.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/support.js b/lib/support.js index 59aca60f..f300d231 100644 --- a/lib/support.js +++ b/lib/support.js @@ -204,6 +204,7 @@ function https_get(url, callback) { return callback(null); }); timer = setTimeout(function() { + req.abort(); console.error("URL " + url + ": TIMEOUT!"); callback(null); }, 30*1000); From cfcc2c91016353b39157203bbe2b45a78f3d4b50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Jun 2018 10:58:35 +0200 Subject: [PATCH 0645/2430] More agile difficulty diff algo --- lib/pool.js | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0a5d5403..3c548bb4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -703,29 +703,44 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } this.calcNewDiff = function () { - let hashes; - let target; - let period; const proxyMinerName = this.payout + ":" + this.identifier; + let miner; + let target; + let min_diff = global.config.pool.minDifficulty; if (proxyMinerName in proxyMiners) { - hashes = proxyMiners[proxyMinerName].hashes; + miner = proxyMiners[proxyMinerName]; target = 5; - period = (Date.now() - proxyMiners[proxyMinerName].connectTime) / 1000; + min_diff *= 50; } else if (this.payout in minerWallets && minerWallets[this.payout].last_ver_shares >= MAX_VER_SHARES_PER_SEC * VER_SHARES_PERIOD) { - hashes = minerWallets[this.payout].hashes; + miner = minerWallets[this.payout]; target = 5; - period = (Date.now() - minerWallets[this.payout].connectTime) / 1000; + min_diff *= 50; } else { - hashes = this.hashes; + miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; - period = (Date.now() - this.connectTime) / 1000; } + if (miner.connectTimeShift) { + if (Date.now() - miner.connectTimeShift > 60*60*1000) { + miner.connectTime = miner.connectTimeShift; + miner.hashes -= miner.hashesShift; + miner.connectTimeShift = Date.now(); + miner.hashesShift = miner.hashes; + } + } else { + miner.connectTimeShift = Date.now(); + miner.hashesShift = miner.hashes; + } + + let hashes = miner.hashes; + let period = (Date.now() - miner.connectTime) / 1000; + if (hashes === 0) { hashes = this.difficulty; target = 2 * global.config.pool.retargetTime; if (period < target) period = target; } - return Math.floor(hashes * target / period); + const diff = Math.floor(hashes * target / period); + return diff < min_diff ? min_diff : diff; }; this.updateDifficulty = function () { From ef5e3e20d15943ec83ba8c71b0b3a5cd8e700ce3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Jun 2018 11:15:23 +0200 Subject: [PATCH 0646/2430] More agile difficulty diff algo --- lib/pool.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3c548bb4..bd0e725a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -706,18 +706,19 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer const proxyMinerName = this.payout + ":" + this.identifier; let miner; let target; - let min_diff = global.config.pool.minDifficulty; + let min_diff; if (proxyMinerName in proxyMiners) { miner = proxyMiners[proxyMinerName]; target = 5; - min_diff *= 50; + min_diff = 5000; } 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 *= 50; + min_diff = 5000; } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; + min_diff = global.config.pool.minDifficulty; } if (miner.connectTimeShift) { if (Date.now() - miner.connectTimeShift > 60*60*1000) { From 2c6592f8d41fb2bd424c532f1c90541fee6c3580 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 24 Jun 2018 11:17:49 +0200 Subject: [PATCH 0647/2430] Fixed min diff increase for proxy --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index bd0e725a..88510fcf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -710,15 +710,15 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (proxyMinerName in proxyMiners) { miner = proxyMiners[proxyMinerName]; target = 5; - min_diff = 5000; + min_diff = 10*global.config.pool.minDifficulty; } 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 = 5000; + min_diff = 10*global.config.pool.minDifficulty; } else { miner = this; target = this.proxy ? 5 : global.config.pool.targetTime; - min_diff = global.config.pool.minDifficulty; + min_diff = this.proxy ? 10*global.config.pool.minDifficulty : global.config.pool.minDifficulty; } if (miner.connectTimeShift) { if (Date.now() - miner.connectTimeShift > 60*60*1000) { From 15eee987e55dd8169dc24610e97054a46a43522a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Jun 2018 12:09:38 +0200 Subject: [PATCH 0648/2430] Add email retry --- lib/support.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/support.js b/lib/support.js index f300d231..11bf41e0 100644 --- a/lib/support.js +++ b/lib/support.js @@ -45,9 +45,9 @@ let emailAcc = {}; let emailLastSendTime = {}; let lastEmailSendTime; -function sendEmailReal(toAddress, subject, email_body){ +function sendEmailReal(toAddress, subject, email_body, retry) { if (lastEmailSendTime && Date.now() - lastEmailSendTime < 1000) { - setTimeout(sendEmailReal, 1000, toAddress, subject, email_body); + setTimeout(sendEmailReal, 1000, toAddress, subject, email_body, retry); return; } lastEmailSendTime = Date.now(); @@ -65,12 +65,16 @@ function sendEmailReal(toAddress, subject, email_body){ agentOptions: { rejectUnauthorized: global.config.general.mailgunNoCert === true ? false : true } - }, function(err, response, body){ - if (!err && response.statusCode === 200) { - debug(email_body); - console.log("Email to '" + toAddress + "' was sent successfully! Response: " + body); + }, function(err, response, body) { + if (retry) { + if (!err && response.statusCode === 200) { + debug(email_body); + console.log("Email to '" + toAddress + "' was sent successfully! Response: " + body); + } else { + console.error("Did not send e-mail to '" + toAddress + "' successfully! Response: " + body + " Response: "+JSON.stringify(response)); + } } else { - console.error("Did not send e-mail to '" + toAddress + "' successfully! Response: " + body + " Response: "+JSON.stringify(response)); + setTimeout(sendEmailReal, 5*1000, toAddress, subject, email_body, 1); } }); } From 42ad4cca207080da7e2fb0d711812f84bb9d51e3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Jul 2018 11:56:32 +0200 Subject: [PATCH 0649/2430] Added more strinc checking that payment id should go with simple address only --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 88510fcf..e817ce6c 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -495,7 +495,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer 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])) { + if (addressSplit[1].length === 64 && hexMatch.test(addressSplit[1]) && global.coinFuncs.validatePlainAddress(this.address)) { this.paymentID = addressSplit[1]; this.payout += "." + this.paymentID; if (typeof(addressSplit[2]) !== 'undefined' && this.identifier === 'x') { From ecfd0225f20a41260b86fdaefe549e9e9993e031 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Jul 2018 18:20:26 +0200 Subject: [PATCH 0650/2430] Fixed second email send --- lib/support.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/support.js b/lib/support.js index 11bf41e0..6978cab6 100644 --- a/lib/support.js +++ b/lib/support.js @@ -66,15 +66,15 @@ function sendEmailReal(toAddress, subject, email_body, retry) { rejectUnauthorized: global.config.general.mailgunNoCert === true ? false : true } }, function(err, response, body) { - if (retry) { - if (!err && response.statusCode === 200) { - debug(email_body); - console.log("Email to '" + toAddress + "' was sent successfully! Response: " + body); - } else { + if (!err && response.statusCode === 200) { + debug(email_body); + console.log("Email to '" + toAddress + "' was sent successfully! Response: " + body); + } else { + if (retry) { console.error("Did not send e-mail to '" + toAddress + "' successfully! Response: " + body + " Response: "+JSON.stringify(response)); + } else { + setTimeout(sendEmailReal, 50*1000, toAddress, subject, email_body, 1); } - } else { - setTimeout(sendEmailReal, 5*1000, toAddress, subject, email_body, 1); } }); } From b0baf15be44f2d464846cf770efd34fb8f120d81 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Jul 2018 12:26:01 +0200 Subject: [PATCH 0651/2430] Change for https://github.com/MoneroOcean/nodejs-pool/issues/43 --- lib/local_comms.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/local_comms.js b/lib/local_comms.js index 4ec5e1e1..d7ea169e 100644 --- a/lib/local_comms.js +++ b/lib/local_comms.js @@ -807,12 +807,19 @@ function Database(){ if(data.length > 0){ global.database.refreshEnv(); let totalDeleted = 0; + let totalDeleted2 = 0; console.log("Block cleaning started: removing " + data.length + " block share records"); let txn = global.database.env.beginTxn(); data.forEach(function(block){ ++ totalDeleted; - txn.del(global.database.shareDB, parseInt(block)); + ++ totalDeleted2; debug("Deleted block: " + parseInt(block)); + txn.del(global.database.shareDB, parseInt(block)); + if (totalDeleted2 > 100) { + txn.commit(); + txn = global.database.env.beginTxn(); + totalDeleted2 = 0; + } }); txn.commit(); console.log("Block cleaning finished: removed " + totalDeleted + " block share records"); From e800e688832506e8189094da82ab33b503117d9a Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Wed, 4 Jul 2018 17:50:20 +0300 Subject: [PATCH 0652/2430] don't double update --- lib/worker.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index adeef298..3ec6bc0f 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -519,14 +519,16 @@ function updatePoolStats2(poolType) { return callback(null, pending); }, function (callback) { - 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); - } + 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) { + 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 }); }); + } }, function (callback) { let currentEfforts = {}; From 0816ecc414529d68d23abd09581f165e915c430d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 4 Jul 2018 17:21:29 +0200 Subject: [PATCH 0653/2430] Returned more strict CMC result check --- lib/worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 3ec6bc0f..3ef5df0a 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -521,14 +521,14 @@ function updatePoolStats2(poolType) { 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) { + 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 }); - }); - } + return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); + }); + } }, function (callback) { let currentEfforts = {}; From b464097957a9dd8e97aacb18028020f83f14a693 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Jul 2018 07:25:55 +0200 Subject: [PATCH 0654/2430] Moving to the latest 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 bb0f7bc5..6dcfabe5 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -26,7 +26,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.12.1.0 +sudo git checkout v0.12.2.0 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 40f54214..2d72686c 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -22,7 +22,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.12.1.0 +sudo git checkout v0.12.2.0 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 60e9145b..73e60f40 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.12.1.0 &&\ +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 submodule init &&\ sudo git submodule update &&\ From a7a198b2521b6340ed857e1c45d26c3ef2f07dca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Jul 2018 07:40:50 +0200 Subject: [PATCH 0655/2430] Moved to patched nodejs LTS release --- deployment/deploy.bash | 5 +++-- deployment/deploy_test.bash | 7 ++++--- deployment/leaf.bash | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 6dcfabe5..4a7776ff 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -42,7 +42,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.9.3 +nvm install v8.11.3 +nvm alias default v8.11.3 cd ~/nodejs-pool npm install npm install -g pm2 @@ -82,7 +83,7 @@ sudo systemctl enable caddy.service sudo systemctl start caddy.service rm -rf $CADDY_DOWNLOAD_DIR cd ~ -sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin `pwd`/.nvm/versions/node/v8.9.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` +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 echo "Installing pm2-logrotate in the background!" diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index 7c180c6a..9d797b0f 100644 --- a/deployment/deploy_test.bash +++ b/deployment/deploy_test.bash @@ -36,7 +36,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.9.3 +nvm install v8.11.3 +nvm alias default v8.11.3 cd ~/nodejs-pool npm install npm install -g pm2 @@ -76,7 +77,7 @@ sudo systemctl enable caddy.service sudo systemctl start caddy.service rm -rf $CADDY_DOWNLOAD_DIR cd ~ -sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin `pwd`/.nvm/versions/node/v8.9.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` +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 echo "Installing pm2-logrotate in the background!" @@ -87,5 +88,5 @@ mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api bash ~/nodejs-pool/deployment/install_lmdb_tools.sh cd ~/nodejs-pool/sql_sync/ -env PATH=$PATH:`pwd`/.nvm/versions/node/v8.9.3/bin node sql_sync.js +env PATH=$PATH:`pwd`/.nvm/versions/node/v8.11.3/bin node sql_sync.js echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 2d72686c..f5572604 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -38,13 +38,14 @@ 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.9.3 +nvm install v8.11.3 +nvm alias default v8.11.3 cd ~/nodejs-pool npm install 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.9.3/bin `pwd`/.nvm/versions/node/v8.9.3/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` +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 echo "Installing pm2-logrotate in the background!" pm2 install pm2-logrotate From 1e81c8dd1c4f5fa32906385a3b1beea1f3002521 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 5 Jul 2018 16:18:38 +0200 Subject: [PATCH 0656/2430] Fixed Error: Callback was already called. --- lib/support.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/lib/support.js b/lib/support.js index 6978cab6..8b776d75 100644 --- a/lib/support.js +++ b/lib/support.js @@ -177,11 +177,16 @@ function rpc_wallet(host, port, method, params, callback) { function https_get(url, callback) { let timer; + let is_callback_called = false; var req = https.get(url, function(res) { if (res.statusCode != 200) { if (timer) clearTimeout(timer); console.error("URL " + url + ": Result code: " + res.statusCode); - return callback(null); + if (!is_callback_called) { + is_callback_called = true; + callback(null); + } + return; } let str = ""; res.on('data', function(d) { str += d; }); @@ -192,25 +197,42 @@ function https_get(url, callback) { json = JSON.parse(str); } catch (e) { console.error("URL " + url + ": JSON parse exception: " + e); - return callback(str); + if (!is_callback_called) { + is_callback_called = true; + callback(str); + } + return; + } + if (!is_callback_called) { + is_callback_called = true; + callback(json); } - return callback(json); + return; }); res.on('error', function() { if (timer) clearTimeout(timer); console.error("URL " + url + ": RESPONSE ERROR!"); - return callback(null); + if (!is_callback_called) { + is_callback_called = true; + callback(null); + } }); }); req.on('error', function() { if (timer) clearTimeout(timer); console.error("URL " + url + ": REQUEST ERROR!"); - return callback(null); + if (!is_callback_called) { + is_callback_called = true; + callback(null); + } }); timer = setTimeout(function() { req.abort(); console.error("URL " + url + ": TIMEOUT!"); - callback(null); + if (!is_callback_called) { + is_callback_called = true; + callback(null); + } }, 30*1000); req.end(); } From 63897ba3e6f6be571a38804bb4438d001263edee Mon Sep 17 00:00:00 2001 From: 1rV1N <34376228+1rV1N-git@users.noreply.github.com> Date: Sun, 8 Jul 2018 21:37:44 +0300 Subject: [PATCH 0657/2430] fix bug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 3ef5df0a..47d844cc 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -528,7 +528,7 @@ function updatePoolStats2(poolType) { } return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); }); - } + }else { return callback(null, {})} }, function (callback) { let currentEfforts = {}; From da6cc8aad0965d1bacc496ada112a8fea64c47d5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 9 Jul 2018 13:53:03 +0200 Subject: [PATCH 0658/2430] Fixed undefined error when other function try to access usd/eur/btc price. --- lib/worker.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 47d844cc..90d02196 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -528,7 +528,9 @@ function updatePoolStats2(poolType) { } return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); }); - }else { return callback(null, {})} + } else { + return callback(null, { btc: price_btc, usd: price_usd, eur: price_eur }); + } }, function (callback) { let currentEfforts = {}; From d441ef4305b374228a3a82ebd725bcac1f437c6a Mon Sep 17 00:00:00 2001 From: Learner Date: Tue, 10 Jul 2018 04:23:45 +0700 Subject: [PATCH 0659/2430] 150 Gb is minimum to run the bash 60Gb for blockchain download, 60Gb for importing blockchain, 30Gb reserved --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9155a77a..45b5fc6b 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Server Requirements ------------------- * 4 Gb Ram * 2 CPU Cores (with AES_NI) -* 60 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 24Gb 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! +* 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 24Gb 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! Pre-Deploy From 043d08e739a53602c8dea9a676d6031afee06939 Mon Sep 17 00:00:00 2001 From: Learner Date: Tue, 10 Jul 2018 04:24:41 +0700 Subject: [PATCH 0660/2430] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 45b5fc6b..842c0f5e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Server Requirements ------------------- * 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 24Gb 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! +* 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! Pre-Deploy From d234d18869d10d40f2e980f71a8a2e64a8d901a3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Jul 2018 11:11:34 +0200 Subject: [PATCH 0661/2430] Added fast support --- lib/pool.js | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e817ce6c..45854491 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -78,8 +78,8 @@ if (cluster.isMaster) { global.database.thread_id = threadName; -// algo can be "", "Heavy", "Light" -const ALGOS = [ "Heavy", "Light" ]; +// algo can be "", "Heavy", "Light", "Fast" +const ALGOS = [ "Heavy", "Light", "Fast" ]; function registerPool() { global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { @@ -470,7 +470,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_hr) { +function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent, algos, algos_perf) { // Username Layout -
. // Password Layout - .. // Default function is to use the password so they can login. Identifiers can be unique, payment ID is last. @@ -557,35 +557,36 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return; } - this.setAlgos = function(algos, algos_hr) { + 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; } else { return "algo array should include cn/1 or cryptonight/1"; } - if (algos_hr && (algos_hr instanceof Object)) { - this.algos_hr = {}; - for (let algo in algos_hr) { - if (algo.includes("heavy")) this.algos_hr["Heavy"] = algos_hr[algo]; - else if (algo.includes("lite")) this.algos_hr["Light"] = algos_hr[algo]; - else this.algos_hr[""] = algos_hr[algo]; + 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")) this.algos_perf["Fast"] = algos_perf[algo]; + else this.algos_perf[""] = algos_perf[algo]; } - if (!this.algos_hr[""]) return "algo_hr set should include non heavy and lite hashrate"; + if (!this.algos_perf[""]) return "algo_perf set should include non heavy/lite/fast hashrate"; } else { - return "algo_hr set should be present"; + return "algo_perf set should be present"; } return ""; }; - //if (algos && algos_hr) { - // const status = this.setAlgos(algos, algos_hr); - // if (status != "") { - // this.error = status; - // this.valid_miner = false; - // return; - // } - //} + if (algos && algos_perf) { + const status = this.setAlgos(algos, algos_perf); + if (status != "") { + this.error = status; + this.valid_miner = false; + return; + } + } // 3) setup valid miner stuff @@ -686,17 +687,17 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestAlgo = function() { if (!this.algos) return ""; let best_algo = ""; - let best_algo_hr = this.algos_hr[""]; + let best_algo_perf = this.algos_perf[""]; 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]; - if (algo in miner.algos_hr && miner.algos_hr[algo] * algoHashFactor > best_algo_hr) { - console.error(miner.logString + ": " + algo + ": " + miner.algos_hr[algo] * algoHashFactor); + if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { + console.error(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); best_algo = algo; - best_algo_hr = miner.algos_hr[algo] * algoHashFactor; + best_algo_perf = miner.algos_perf[algo] * algoHashFactor; } }); return best_algo; From d5af46ecef30a619a7202b6a08917702684bb6e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Jul 2018 13:12:21 +0200 Subject: [PATCH 0662/2430] Removed no longer supported --verify option --- deployment/base.sql | 2 ++ deployment/deploy.bash | 2 +- deployment/leaf.bash | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index be0cfc7d..e5b7135c 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -191,8 +191,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', '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', '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 ('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/deployment/deploy.bash b/deployment/deploy.bash index 4a7776ff..c4df0771 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -35,7 +35,7 @@ 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 --verify off --data-dir /home/monerodaemon/.bitmonero +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 diff --git a/deployment/leaf.bash b/deployment/leaf.bash index f5572604..523ec8a6 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -31,7 +31,7 @@ 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 --verify off --data-dir /home/monerodaemon/.bitmonero +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 From 97aa06e43f7c293a168943f35e03cd670bc33a9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Jul 2018 16:42:56 +0200 Subject: [PATCH 0663/2430] Updated algo-perf name --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 45854491..cbd32ba7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1275,7 +1275,7 @@ 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-hr"]); + miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent, params.algo, params["algo-perf"]); let time_now = Date.now(); if (!miner.valid_miner) { if (!(miner.payout in lastMinerLogTime) || time_now - lastMinerLogTime[miner.payout] > 10*60*1000) { From e8ebaa6ff6c3576cf5c2d11e23f8d1eff447f2a5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Jul 2018 16:46:55 +0200 Subject: [PATCH 0664/2430] Updated algo-perf name --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index cbd32ba7..2665890a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -18,7 +18,7 @@ let notifyAddresses = {}; let baseDiff = global.coinFuncs.baseDiff(); let activeMiners = {}; -let activeSmartMiners = {}; // miners with algos/algos-hr +let activeSmartMiners = {}; // miners with algos/algos-perf let lastBlockHash = {}; // algo key let lastAlgoHashFactor = {}; // algo key @@ -1352,8 +1352,8 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) { return; } miner.heartbeat(); - if (miner.algos && params.algo && params["algo-hr"]) { - const status = miner.setAlgos(params.algo, params["algo-hr"]); + if (miner.algos && params.algo && params["algo-perf"]) { + const status = miner.setAlgos(params.algo, params["algo-perf"]); if (status != "") { sendReply(status); return; From 544a86f7495cfcfafcece59bf3f90912c7f3f1c1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 16 Jul 2018 17:07:11 +0200 Subject: [PATCH 0665/2430] Added RYO/MSR support --- lib/coins/xmr.js | 12 ++++++++++-- lib/pool.js | 2 +- package.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 09a770b7..04f640c0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -213,8 +213,12 @@ function Coin(data){ }; }; - this.cryptoNight = function(convertedBlob) { - return multiHashing.cryptonight(convertedBlob, 1); + this.cryptoNight = function(convertedBlob, port) { + switch (port) { + case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO + case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR + default: return multiHashing.cryptonight(convertedBlob, 1); + } } this.blobTypeStr = function(port) { @@ -226,12 +230,16 @@ function Coin(data){ this.algoTypeStr = function(port) { switch (port) { + case 12211: return "cryptonight-heavy"; // RYO + case 38081: return "cryptonight/msr"; // MSR default: return "cryptonight/1"; } } this.algoShortTypeStr = function(port) { switch (port) { + case 12211: return "cn-heavy"; // RYO + case 38081: return "cn/msr"; // MSR default: return "cn/1"; } } diff --git a/lib/pool.js b/lib/pool.js index 2665890a..6b49c5d1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1145,7 +1145,7 @@ function processShare(miner, job, blockTemplate, params) { return false; } let convertedBlob = global.coinFuncs.convertBlob(shareBuffer, blockTemplate.port); - hash = global.coinFuncs.cryptoNight(convertedBlob); + hash = global.coinFuncs.cryptoNight(convertedBlob, blockTemplate.port); if (hash.toString('hex') !== resultHash) { let time_now = Date.now(); diff --git a/package.json b/package.json index 2218f921..94d10fb3 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#v1.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v2.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v2.2.0" } } From 1b5680ecfcad8b5009a44d56c07338b66d86bf82 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Jul 2018 03:43:41 +0200 Subject: [PATCH 0666/2430] Incrased job buffer to offset fact that blocks can be changed more often compared to vanilla XMR pools --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6b49c5d1..a7d46bc2 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -675,7 +675,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer } } - this.validJobs = global.support.circularBuffer(4); + this.validJobs = global.support.circularBuffer(10); this.cachedJob = null; this.invalidShareProto = global.protos.InvalidShare.encode({ From 084ae19d226eb4bd89b2911001231974aa1eff05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Jul 2018 16:54:08 +0200 Subject: [PATCH 0667/2430] Added RYO coin donation addresses --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 842c0f5e..7bbfb164 100644 --- a/README.md +++ b/README.md @@ -265,6 +265,7 @@ If you'd like to make a one time donation, the addresses are as follows: * ITNS - ```iz53aMEaKJ25zB8xku3FQK5VVvmu2v6DENnbGHRmn659jfrGWBH1beqAzEVYaKhTyMZcxLJAdaCW3Kof1DwTiTbp1DSqLae3e``` * WOW - ```Wo3yjV8UkwvbJDCB1Jy7vvXv3aaQu3K8YMG6tbY3Jo2KApfyf5RByZiBXy95bzmoR3AvPgNq6rHzm98LoHTkzjiA2dY7sqQMJ``` * XMV - ```4BDgQohRBqg2wFZ5ezYqCrNGjgECAttARdbh1fNkuAbd3HnNkSgas11QD9VFQMzbnvDD3Mfcky1LAFihkbEYph5oGAMLurw``` +* RYO - ```RYoLsi22qnoKYhnv1DwHBXcGe9QK6P9zmekwQnHdUAak7adFBK4i32wFTszivQ9wEPeugbXr2UD7tMd6ogf1dbHh76G5UszE7k1``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` From 4eb3ba99b763692a0045f9f8ce9f8264d9184aa5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 17 Jul 2018 18:15:38 +0200 Subject: [PATCH 0668/2430] Added more debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index a7d46bc2..7253b229 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -694,6 +694,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; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; + console.error(miner.logString + ": " + algo + "? " + miner.algos_perf[algo] * algoHashFactor); if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { console.error(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); best_algo = algo; From 2e4cbf11ee36e4110b128433480c8bd8ee0614ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Jul 2018 03:56:13 +0200 Subject: [PATCH 0669/2430] Added RYO --- deployment/base.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/base.sql b/deployment/base.sql index e5b7135c..4901e3a6 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -235,6 +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 ('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_12211', '', 'string', 'Address to mine to for 12211 (RYO) 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'); From a02cf6578a0b95dc1ddfed0477c9913f2055fc87 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Jul 2018 04:16:41 +0200 Subject: [PATCH 0670/2430] Added more debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 7253b229..6afb6270 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -690,8 +690,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_algo_perf = this.algos_perf[""]; let miner = this; ALGOS.forEach(function(algo) { + console.error(miner.logString + ": " + algo + "??"); if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; + console.error(miner.logString + ": " + algo + "???"); if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; console.error(miner.logString + ": " + algo + "? " + miner.algos_perf[algo] * algoHashFactor); From cdd2bd5a62cb28f6c77a2a6391a4115881aa057f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Jul 2018 05:00:16 +0200 Subject: [PATCH 0671/2430] Added more debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 6afb6270..24901036 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -580,6 +580,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (algos && algos_perf) { + console.error(JSON.stringify(algos)); + console.error(JSON.stringify(algos_perf)); const status = this.setAlgos(algos, algos_perf); if (status != "") { this.error = status; From 88f14eb6f737c7fabec03a2413bf6d1062770bdc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Jul 2018 07:53:04 +0200 Subject: [PATCH 0672/2430] Removed extra debug print --- lib/pool.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 24901036..f426d55f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -692,15 +692,12 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer let best_algo_perf = this.algos_perf[""]; let miner = this; ALGOS.forEach(function(algo) { - console.error(miner.logString + ": " + algo + "??"); if (!(algo in activeBlockTemplate)) return; const port = activeBlockTemplate[algo].port; - console.error(miner.logString + ": " + algo + "???"); if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; - console.error(miner.logString + ": " + algo + "? " + miner.algos_perf[algo] * algoHashFactor); if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { - console.error(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); + debug(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); best_algo = algo; best_algo_perf = miner.algos_perf[algo] * algoHashFactor; } From 315f15b5d513c45ab960b9fb625841e0a257b3ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Jul 2018 07:54:25 +0200 Subject: [PATCH 0673/2430] Removed extra debug print --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f426d55f..4c000aef 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -580,8 +580,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer }; if (algos && algos_perf) { - console.error(JSON.stringify(algos)); - console.error(JSON.stringify(algos_perf)); + //console.error(JSON.stringify(algos)); + //console.error(JSON.stringify(algos_perf)); const status = this.setAlgos(algos, algos_perf); if (status != "") { this.error = status; From 71a02b87c23565e0186889d20a33d180ec7d01d4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Jul 2018 09:30:40 +0200 Subject: [PATCH 0674/2430] Test change --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 4c000aef..e00a6658 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -697,7 +697,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { - debug(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); + console.error(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); best_algo = algo; best_algo_perf = miner.algos_perf[algo] * algoHashFactor; } From 51e601067cc617b1235bf09318b34b53fe47b9e6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 18 Jul 2018 09:39:13 +0200 Subject: [PATCH 0675/2430] Fixed variant for heavy --- 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 04f640c0..13f7b59f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -230,7 +230,7 @@ function Coin(data){ this.algoTypeStr = function(port) { switch (port) { - case 12211: return "cryptonight-heavy"; // RYO + case 12211: return "cryptonight-heavy/0"; // RYO case 38081: return "cryptonight/msr"; // MSR default: return "cryptonight/1"; } @@ -238,7 +238,7 @@ function Coin(data){ this.algoShortTypeStr = function(port) { switch (port) { - case 12211: return "cn-heavy"; // RYO + case 12211: return "cn-heavy/0"; // RYO case 38081: return "cn/msr"; // MSR default: return "cn/1"; } diff --git a/lib/pool.js b/lib/pool.js index e00a6658..4c000aef 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -697,7 +697,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer if (!(global.coinFuncs.algoTypeStr(port) in miner.algos) && !(global.coinFuncs.algoShortTypeStr(port) in miner.algos)) return; const algoHashFactor = global.config.daemon["algoHashFactor" + algo]; if (algo in miner.algos_perf && miner.algos_perf[algo] * algoHashFactor > best_algo_perf) { - console.error(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); + debug(miner.logString + ": " + algo + ": " + miner.algos_perf[algo] * algoHashFactor); best_algo = algo; best_algo_perf = miner.algos_perf[algo] * algoHashFactor; } From a7074fb73ec88b6359f9777f9913681a9bb2f63f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jul 2018 11:36:36 +0200 Subject: [PATCH 0676/2430] Added setAlgoHashFactor function --- lib/support.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/support.js b/lib/support.js index 8b776d75..f21cc108 100644 --- a/lib/support.js +++ b/lib/support.js @@ -257,6 +257,11 @@ function getActivePort(algo, callback) { }); } +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 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; @@ -337,6 +342,7 @@ module.exports = function () { tsCompare: tsCompare, getAlgoHashFactor: getAlgoHashFactor, getActivePort: getActivePort, + setAlgoHashFactor: setAlgoHashFactor, setActivePort: setActivePort, https_get: https_get, }; From c5034fae4e63ab08ce7900041ee52daab61f2618 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jul 2018 11:48:22 +0200 Subject: [PATCH 0677/2430] Ignore zero port --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4c000aef..7ba7840a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -345,7 +345,7 @@ function algoHashFactorUpdate(algo, algoHashFactor) { // 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]; - global.coinFuncs.getPortLastBlockHeader(activePort, function (err, body) { + 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); @@ -373,7 +373,7 @@ function templateUpdate(algo, repeating) { } setTimeout(templateUpdate, 1000, algo, repeating); } - }); + }); else setTimeout(templateUpdate, 1000, algo, repeating); } From f7f1ed19340e6e357b5ddb72f29b5754274c0f78 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jul 2018 12:57:05 +0200 Subject: [PATCH 0678/2430] Allow zero algo ports --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7ba7840a..b74e9e22 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1628,7 +1628,7 @@ if (cluster.isMaster) { } else { setInterval(updateActivePort, 3*1000, ""); ALGOS.forEach(function(algo) { - if (global.config.daemon["activePort" + algo]) { + if ("activePort" + algo in global.config.daemon) { setInterval(updateActivePort, 5*1000, algo); templateUpdate(algo); setTimeout(templateUpdate, 50, algo, true); From f3d461f37b13f4ba1536afe476dec57113549c3d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 21 Jul 2018 11:56:47 +0200 Subject: [PATCH 0679/2430] Return virtual hashrate in hash2 --- lib/api.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index c89a9b9d..d209aba5 100644 --- a/lib/api.js +++ b/lib/api.js @@ -57,6 +57,7 @@ function getAllWorkerStats(address, callback){ 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 } }; @@ -70,6 +71,7 @@ function getAllWorkerStats(address, callback){ 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 }; if (++ intCounter === identifiers.length) return callback(null, returnData); @@ -93,8 +95,15 @@ function getAddressStats(address, extCallback){ async.waterfall([ function (callback) { debug(threadName + "Checking Influx for last 10min avg for /miner/address/stats"); - return callback(null, {hash: cachedStatsData.hash, identifier: 'global', lastHash: Math.floor(cachedStatsData.lastHash / 1000), - totalHashes: cachedData.totalHashes, validShares: Number(cachedData.goodShares), invalidShares: Number(cachedData.badShares)}); + 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) + }); }, function (returnData, callback) { debug(threadName + "Checking MySQL total amount paid for /miner/address/stats"); @@ -467,6 +476,7 @@ app.get('/miner/:address/stats/:identifier', cache('10 seconds'), function (req, 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) From 05e22ec65010aa8b5479863ae4e72647088f92ed Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 04:32:18 +0200 Subject: [PATCH 0680/2430] Fixed 0 pending case --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 90d02196..fa709508 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -561,7 +561,7 @@ function updatePoolStats2(poolType) { activePortProfit: result[12] || 0, activePortComment: result[13] || "", minBlockRewards: result[14] || {}, - pending: result[15] || {}, + pending: result[15] || 0, price: result[16] || {}, currentEfforts: result[17] || {}, }); From 0c0c2e8d4868b2c283169440b59167c2e6f35c60 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 05:06:59 +0200 Subject: [PATCH 0681/2430] Added more coin info --- lib/worker.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index fa709508..0a0c99b6 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -494,13 +494,18 @@ function updatePoolStats2(poolType) { }, function (callback) { //debug(threadName + "Checking LMDB cache for xmr_profit value"); - let xmr_profit = global.database.getCache('xmr_profit'); + 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 xmr_profit_comment = global.database.getCache('xmr_profit_comment'); - return callback(null, xmr_profit_comment ? xmr_profit_comment.value : ""); + let coin_comment = global.database.getCache('coin_comment'); + return callback(null, coin_comment ? coin_comment.value : {}); }, function (callback) { //debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); @@ -559,11 +564,12 @@ function updatePoolStats2(poolType) { altBlocksFound: result[10] || {}, activePort: result[11] || 0, activePortProfit: result[12] || 0, - activePortComment: result[13] || "", - minBlockRewards: result[14] || {}, - pending: result[15] || 0, - price: result[16] || {}, - currentEfforts: result[17] || {}, + coinProfit: result[13] || {}, + coinComment: result[14] || {}, + minBlockRewards: result[15] || {}, + pending: result[16] || 0, + price: result[17] || {}, + currentEfforts: result[18] || {}, }); }); } From d14f6d574680108fab3e7774824add81bdbfec7c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 05:19:35 +0200 Subject: [PATCH 0682/2430] Fixed coin comment --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0a0c99b6..262cbb5d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -505,7 +505,7 @@ function updatePoolStats2(poolType) { 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.value : {}); + return callback(null, coin_comment ? coin_comment : {}); }, function (callback) { //debug(threadName + "Checking LMDB cache for min_block_rewards value to set minBlockRewards"); From 296a0068ee9d7d142adb510a919e3246a5e9b75b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 08:12:22 +0200 Subject: [PATCH 0683/2430] Update network info for all ports --- lib/worker.js | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 262cbb5d..ca6ec13e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -5,8 +5,6 @@ const sprintf = require("sprintf-js").sprintf; let threadName = "Worker Server "; let cycleCount = 0; -let lastBlockHash = null; -let lastBlockHeight = null; let hashrate_avg_min = 10; let stat_change_alert = 0.3; @@ -658,39 +656,44 @@ function updatePoolInformation() { }); } +let prev_network_info = {}; + function updateBlockHeader() { - global.coinFuncs.getLastBlockHeader(function(main_err, main_body){ - if (main_err !== null) { - console.error("Last block header request failed!"); - return; - } - global.coinFuncs.getPortLastBlockHeader(global.config.daemon.activePort, function(err, body){ + 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 !== null) { - console.error("Last block header request failed for " + global.config.daemon.activePort + " port!"); - return; + console.error("Last block header request failed for " + port + " port!"); + 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 (body.hash !== lastBlockHash || main_body.height !== lastBlockHeight) { - lastBlockHash = body.hash; - lastBlockHeight = main_body.height; - let info = global.database.getCache('networkBlockInfo'); - if (info === false) info = {}; + 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.main_height = main_body.height; info.value = body.reward; info.ts = body.timestamp; - info[global.config.daemon.activePort] = { - difficulty: body.difficulty, - hash: body.hash, - height: body.height, - value: body.reward, - ts: body.timestamp, - }; + } + if (-- left === 0) { + info.main_height = prev_network_info[18081].height; global.database.setCache('networkBlockInfo', info); } }); - }); + } } function updateWalletStats() { From 8d133911f2d44f8a10369eb9d20a56baa8b83729 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 11:21:35 +0200 Subject: [PATCH 0684/2430] Added active_ports stats --- lib/worker.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index ca6ec13e..22afd7c4 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -490,6 +490,11 @@ function updatePoolStats2(poolType) { //debug(threadName + "Checking MySQL for activePort value"); return callback(null, global.config.daemon.activePort ? global.config.daemon.activePort : global.config.daemon.port); }, + 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'); @@ -561,13 +566,14 @@ function updatePoolStats2(poolType) { totalAltBlocksFound: result[9] || 0, altBlocksFound: result[10] || {}, activePort: result[11] || 0, - activePortProfit: result[12] || 0, - coinProfit: result[13] || {}, - coinComment: result[14] || {}, - minBlockRewards: result[15] || {}, - pending: result[16] || 0, - price: result[17] || {}, - currentEfforts: result[18] || {}, + 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] || {}, }); }); } @@ -689,7 +695,7 @@ function updateBlockHeader() { info.ts = body.timestamp; } if (-- left === 0) { - info.main_height = prev_network_info[18081].height; + info.main_height = prev_network_info[global.config.daemon.port].height; global.database.setCache('networkBlockInfo', info); } }); From 2801810dacd308c1d89332ce791622218afe1dc0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 11:27:59 +0200 Subject: [PATCH 0685/2430] Added active_ports stats --- lib/worker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 22afd7c4..87645ede 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -493,7 +493,7 @@ function updatePoolStats2(poolType) { 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 : {}); + return callback(null, active_ports ? active_ports : []); }, function (callback) { //debug(threadName + "Checking LMDB cache for xmr_profit value"); @@ -566,7 +566,7 @@ function updatePoolStats2(poolType) { totalAltBlocksFound: result[9] || 0, altBlocksFound: result[10] || {}, activePort: result[11] || 0, - activePorts: result[12] || {}, + activePorts: result[12] || [], activePortProfit: result[13] || 0, coinProfit: result[14] || {}, coinComment: result[15] || {}, From 1f4580ad577fdc2650f84d107d3ea2413a3fbe7c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 13:23:08 +0200 Subject: [PATCH 0686/2430] Added PPLNS port shares info --- lib/blockManager.js | 6 +++++- lib/worker.js | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index dfa98b0f..456e3ff0 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -386,9 +386,13 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }, function (err) { let sumAllPorts = 0; for (let port in portShares) sumAllPorts += portShares[port]; + let pplns_port_shares = {}; for (let port in portShares) { - console.log("Port " + port + ": " + (100.0 * portShares[port] / sumAllPorts).toFixed(2) + "%"); + 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', port_shares); let totalPayments = 0; global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { diff --git a/lib/worker.js b/lib/worker.js index 87645ede..ab752472 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -548,6 +548,11 @@ function updatePoolStats2(poolType) { } 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 (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; @@ -574,6 +579,7 @@ function updatePoolStats2(poolType) { pending: result[17] || 0, price: result[18] || {}, currentEfforts: result[19] || {}, + pplnsPortShares: result[20] || {}, }); }); } From cf123c4e4b57ef45406b28d9672f455c30f64a66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 14:54:11 +0200 Subject: [PATCH 0687/2430] Added PPLNS port shares info --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 456e3ff0..ca83ed09 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -392,7 +392,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un pplns_port_shares[port] = port_share; console.log("Port " + port + ": " + (100.0 * port_share).toFixed(2) + "%"); } - global.database.setCache('pplns_port_shares', port_shares); + global.database.setCache('pplns_port_shares', pplns_port_shares); let totalPayments = 0; global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { From 6ea4e83dbcd64fe408142047ec28e4614138fa75 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 15:28:41 +0200 Subject: [PATCH 0688/2430] Added last PPLNS window time in seconds --- lib/blockManager.js | 6 ++++++ lib/worker.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index ca83ed09..69b1f165 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -319,6 +319,8 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un }; let portShares = {}; + let firstShareTime; + let lastShareTime; async.doWhilst(function (callback) { let txn = global.database.env.beginTxn({readOnly: true}); @@ -360,6 +362,9 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un addPayment(global.coinFuncs.poolDevAddress, poolDevDonation); addPayment(global.coinFuncs.coinDevAddress, devDonation); + if (!firstShareTime) firstShareTime = shareData.timestamp; + lastShareTime = shareData.timestamp; + if (typeof(shareData.port) !== 'undefined') { if (shareData.port in portShares) { portShares[shareData.port] += amountToPay; @@ -393,6 +398,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un 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', (lastShareTime - firstShareTime) / 1000); let totalPayments = 0; global.mysql.query("SELECT SUM(amount) as amt FROM balance").then(function (rows) { diff --git a/lib/worker.js b/lib/worker.js index ab752472..34de5ed9 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -553,6 +553,11 @@ function updatePoolStats2(poolType) { 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 (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; @@ -580,6 +585,7 @@ function updatePoolStats2(poolType) { price: result[18] || {}, currentEfforts: result[19] || {}, pplnsPortShares: result[20] || {}, + pplnsWindowTime: result[21] || 0, }); }); } From 4df016766d1bf444db9a0a812af495d57b5b37a9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 17:00:03 +0200 Subject: [PATCH 0689/2430] More precise PPLNS window calc --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 69b1f165..5cc32f10 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -351,6 +351,9 @@ 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 feesToPay = amountToPay * (global.config.payout.pplnsFee / 100) + (shareData.bitcoin === true ? amountToPay * (global.config.payout.btcFee / 100) : 0); @@ -362,9 +365,6 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un addPayment(global.coinFuncs.poolDevAddress, poolDevDonation); addPayment(global.coinFuncs.coinDevAddress, devDonation); - if (!firstShareTime) firstShareTime = shareData.timestamp; - lastShareTime = shareData.timestamp; - if (typeof(shareData.port) !== 'undefined') { if (shareData.port in portShares) { portShares[shareData.port] += amountToPay; From 970f7532d5bc94e0f0043d8475b10cc8acfa4a5c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 22 Jul 2018 17:14:17 +0200 Subject: [PATCH 0690/2430] Fixed PPLNS window time sign --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 5cc32f10..e6c36ab8 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -398,7 +398,7 @@ function calculatePPLNSPayments(block_height, block_reward, block_difficulty, un 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', (lastShareTime - firstShareTime) / 1000); + 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) { From 58c4abe9eec2ef90f623b612ba7ae2312ae551ca Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 29 Jul 2018 17:44:44 +0200 Subject: [PATCH 0691/2430] Show miner count in case of delays --- lib/pool.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b74e9e22..f44eec5d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -183,20 +183,23 @@ function retargetMiners() { } } + let miner_count = 0; const time_before = Date.now(); for (let minerId in activeSmartMiners) { if (activeSmartMiners.hasOwnProperty(minerId)) { retargetMiner(activeSmartMiners[minerId]); } + ++ miner_count; } for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { retargetMiner(activeMiners[minerId]); } + ++ miner_count; } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms"); + if (elapsed > 500) console.error("retargetMiners() consumed " + elapsed + " ms for " + miner_count + " miners"); } // wallet " " proxy miner name -> { connectTime, count (miner), hashes } @@ -232,20 +235,23 @@ 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 (let minerId in activeSmartMiners) { if (activeSmartMiners.hasOwnProperty(minerId)) { let miner = activeSmartMiners[minerId]; 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); } + ++ miner_count; } const elapsed = Date.now() - time_before; - if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms"); + if (elapsed > 500) console.error("checkAliveMiners() consumed " + elapsed + " ms for " + miner_count + " miners"); } // global.config.daemon["activePort" + algo] is only updated in master thread From 6cef56e5fbca99d93723ef4758249b96f36cf8f3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 31 Jul 2018 09:04:35 +0200 Subject: [PATCH 0692/2430] Fix for classic one coin pools --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 34de5ed9..8585a30e 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -404,6 +404,7 @@ function updatePoolStats2(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) { From ff66f389f35486a3041b0b4e340e5584681bdf11 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Aug 2018 11:22:37 +0200 Subject: [PATCH 0693/2430] Added 5 minute cooldown period for algo change if current algo is ok --- lib/pool.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index f44eec5d..15ee8295 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -694,6 +694,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestAlgo = function() { if (!this.algos) return ""; + if (this.curr_algo && this.curr_algo_time && this.algos_perf[curr_algo] && Date.now() - this.curr_algo_time < 5*60*1000) { + return this.curr_algo; + } let best_algo = ""; let best_algo_perf = this.algos_perf[""]; let miner = this; @@ -708,6 +711,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer best_algo_perf = miner.algos_perf[algo] * algoHashFactor; } }); + if (!this.curr_algo || this.curr_algo != best_algo) { + this.curr_algo = best_algo; + this.curr_algo_time = Date.now(); + } return best_algo; } From 432668669c90e765b62c41f8f02fed594c1cacb4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Aug 2018 11:23:13 +0200 Subject: [PATCH 0694/2430] Added --resursive to monero git clone --- 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 c4df0771..c26427bc 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -24,7 +24,7 @@ sudo mv libg* /usr/lib/ cd ~ 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 v0.12.2.0 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 523ec8a6..be240273 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -20,7 +20,7 @@ sudo mv libg* /usr/lib/ cd ~ 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 v0.12.2.0 curl https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/monero_daemon.patch | sudo git apply -v From 16ee96f9cfc0bc313d052cd5c33f09c4dded5a5d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Aug 2018 13:13:01 +0200 Subject: [PATCH 0695/2430] Added XTL/XHV/TUBE/AEON support --- README.md | 3 +++ deployment/base.sql | 6 ++++++ lib/coins/xmr.js | 23 ++++++++++++++++++----- lib/pool.js | 4 ++-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7bbfb164..0a35a3f3 100644 --- a/README.md +++ b/README.md @@ -266,6 +266,9 @@ If you'd like to make a one time donation, the addresses are as follows: * WOW - ```Wo3yjV8UkwvbJDCB1Jy7vvXv3aaQu3K8YMG6tbY3Jo2KApfyf5RByZiBXy95bzmoR3AvPgNq6rHzm98LoHTkzjiA2dY7sqQMJ``` * XMV - ```4BDgQohRBqg2wFZ5ezYqCrNGjgECAttARdbh1fNkuAbd3HnNkSgas11QD9VFQMzbnvDD3Mfcky1LAFihkbEYph5oGAMLurw``` * RYO - ```RYoLsi22qnoKYhnv1DwHBXcGe9QK6P9zmekwQnHdUAak7adFBK4i32wFTszivQ9wEPeugbXr2UD7tMd6ogf1dbHh76G5UszE7k1``` +* XTL - ```Se3Qr5s83AxjCtYrkkqg6QXJagCVi8dELbHb5Cnemw4rMk3xZzEX3kQfWrbTZPpdAJSP3enA6ri3DcvdkERkGKE518vyPQTyi``` +* XHV - ```hvxyEmtbqs5TEk9U2tCxyfGx2dyGD1g8EBspdr3GivhPchkvnMHtpCR2fGLc5oEY42UGHVBMBANPge5QJ7BDXSMu1Ga2KFspQR``` +* TUBE - ```bxcpZTr4C41NshmJM9Db7FBE5crarjaDXVUApRbsCxHHBf8Jkqjwjzz1zmWHhm9trWNhrY1m4RpcS7tmdG4ykdHG2kTgDcbKJ``` * BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` * BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` * ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` diff --git a/deployment/base.sql b/deployment/base.sql index 4901e3a6..5a3f7501 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -192,9 +192,11 @@ 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', '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 ('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'); @@ -236,6 +238,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 ('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_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_20189', '', 'string', 'Address to mine to for 12211 (Stellite) 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 13f7b59f..08c559dd 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -215,14 +215,19 @@ function Coin(data){ this.cryptoNight = function(convertedBlob, port) { switch (port) { + case 11181: return multiHashing.cryptonight_light(convertedBlob, 1); // Aeon case 12211: return multiHashing.cryptonight_heavy(convertedBlob, 0); // RYO - case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR + case 17750: return multiHashing.cryptonight_heavy(convertedBlob, 1); // Haven + case 20189: return multiHashing.cryptonight(convertedBlob, 3); // Stellite + case 24182: return multiHashing.cryptonight_heavy(convertedBlob, 2); // BitTube + case 38081: return multiHashing.cryptonight(convertedBlob, 4); // MSR default: return multiHashing.cryptonight(convertedBlob, 1); } } this.blobTypeStr = function(port) { switch (port) { + case 24182: return "forknote2"; // BitTube case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } @@ -230,16 +235,24 @@ function Coin(data){ this.algoTypeStr = function(port) { switch (port) { - case 12211: return "cryptonight-heavy/0"; // RYO - case 38081: return "cryptonight/msr"; // MSR + case 11181: return "cryptonight-lite/1"; // Aeon + case 12211: return "cryptonight-heavy/0"; // RYO + case 17750: return "cryptonight-heavy/xhv"; // Haven + case 20189: return "cryptonight/xtl"; // Stellite + case 24182: return "cryptonight-heavy/tube"; // BitTube + case 38081: return "cryptonight/msr"; // MSR default: return "cryptonight/1"; } } this.algoShortTypeStr = function(port) { switch (port) { - case 12211: return "cn-heavy/0"; // RYO - case 38081: return "cn/msr"; // MSR + case 11181: return "cn-lite/1"; // Aeon + case 12211: return "cn-heavy/0"; // RYO + case 17750: return "cn-heavy/xhv"; // Haven + case 20189: return "cn/xtl"; // Stellite + case 24182: return "cn-heavy/tube"; // BitTube + case 38081: return "cn/msr"; // MSR default: return "cn/1"; } } diff --git a/lib/pool.js b/lib/pool.js index 15ee8295..657435ac 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -79,7 +79,7 @@ if (cluster.isMaster) { global.database.thread_id = threadName; // algo can be "", "Heavy", "Light", "Fast" -const ALGOS = [ "Heavy", "Light", "Fast" ]; +const ALGOS = [ "Heavy", "Light", "Fast", "XTL" ]; function registerPool() { global.mysql.query("SELECT * FROM pools WHERE id = ?", [global.config.pool_id]).then(function (rows) { @@ -576,7 +576,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer 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 this.algos_perf[""] = 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 { From 11ebd1c0e7169c6a2b367b62924ed1206dcf5e5d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Aug 2018 14:30:40 +0200 Subject: [PATCH 0696/2430] Fixed tube blob type --- lib/coins/xmr.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 08c559dd..54bc1bf3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -227,7 +227,6 @@ function Coin(data){ this.blobTypeStr = function(port) { switch (port) { - case 24182: return "forknote2"; // BitTube case 38081: return "cryptonote2"; // MSR default: return "cryptonote"; } From acf4cf8ce1ebbee3a54427cafe0a819549dea805 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Aug 2018 14:36:07 +0200 Subject: [PATCH 0697/2430] Reduce number of malformed messages from the same IP --- lib/pool.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 657435ac..6e0ff23f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1727,6 +1727,8 @@ if (cluster.isMaster) { fs.writeFile(fn, str, function(err) { if (err) console.error("Error saving " + fn + " file"); }); }, 10*60*1000); + let lastGarbageFromIpTime = {}; + async.each(global.config.ports, function (portData) { if (global.config[portData.portType].enable !== true) { return; @@ -1810,7 +1812,11 @@ if (cluster.isMaster) { } } - console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + JSON.stringify(message)); + let time_now = Date.now(); + if (!(socket.remoteAddress in lastGarbageFromIpTime) || time_now - lastGarbageFromIpTime[socket.remoteAddress] > 60*1000) { + console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + JSON.stringify(message)); + lastGarbageFromIpTime[socket.remoteAddress] = time_now; + } socket.destroy(); break; From d8f2fe369481102924d90c49bd0b8d62d3a6854d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Aug 2018 17:33:44 +0200 Subject: [PATCH 0698/2430] Semantic error fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6e0ff23f..233f683f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -694,7 +694,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestAlgo = function() { if (!this.algos) return ""; - if (this.curr_algo && this.curr_algo_time && this.algos_perf[curr_algo] && Date.now() - this.curr_algo_time < 5*60*1000) { + if (this.curr_algo && this.curr_algo_time && this.algos_perf[this.curr_algo] && Date.now() - this.curr_algo_time < 5*60*1000) { return this.curr_algo; } let best_algo = ""; From 1864bedaa3a90bb8ad02e27ea68939a97d28a200 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 Aug 2018 17:49:31 +0200 Subject: [PATCH 0699/2430] Added more logs --- lib/pool.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 233f683f..54f1d952 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -406,6 +406,7 @@ 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 @@ -416,10 +417,11 @@ function setNewAlgoHashFactor(algo, algoHashFactor, check_height) { 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"); + if (elapsed > 500) console.error("setNewAlgoHashFactor() consumed " + elapsed + " ms for " + miner_count + " miners"); } function setNewBlockTemplate(template) { @@ -450,6 +452,7 @@ function setNewBlockTemplate(template) { setNewAlgoHashFactor(algo, template.algoHashFactor, isExtraCheck ? height : 0); + let miner_count = 0; const time_before = Date.now(); if (algo === "") for (let minerId in activeMiners) { @@ -458,10 +461,11 @@ function setNewBlockTemplate(template) { 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"); + if (elapsed > 500) console.error("setNewBlockTemplate() consumed " + elapsed + " ms for " + miner_count + " miners"); } // here we keep verified share number of a specific wallet (miner.payout) From 172604c535c82faa06402627608f2b3f27223571 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 4 Aug 2018 17:19:56 +0200 Subject: [PATCH 0700/2430] Added port hashrate --- deployment/base.sql | 2 +- lib/worker.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 5a3f7501..11d8cd23 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -241,7 +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 ('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 12211 (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 (Stellite) 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/worker.js b/lib/worker.js index 8585a30e..d9457eb1 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -43,6 +43,7 @@ function updateShareStats() { 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 localPortHahes = {}; let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; let loopBreakout = 0; @@ -100,6 +101,11 @@ function updateShareStats() { 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 localPortHahes) localPortHahes[port] += share.shares; + else localPortHahes[port] = share.shares; + if (minerID in minerSet) { localStats.miners[minerID] += share.shares; localStats.miners2[minerID] += share.shares2 ? share.shares2 : share.shares; @@ -174,6 +180,7 @@ function updateShareStats() { } cache_updates[key + "_stats"] = cachedData; }); + cache_updates["port_hash"] = localPortHahes; for (let miner in minerSet) { let stats; let keyStats = "stats:" + miner; @@ -400,6 +407,7 @@ function updatePoolStats2(poolType) { } } + 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'); @@ -559,6 +567,10 @@ function updatePoolStats2(poolType) { 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, cache.port_hash || {}); + }, ], function (err, result) { if (typeof(poolType) === 'undefined') { poolType = 'global'; @@ -587,6 +599,7 @@ function updatePoolStats2(poolType) { currentEfforts: result[19] || {}, pplnsPortShares: result[20] || {}, pplnsWindowTime: result[21] || 0, + portHash: result[22] || {}, }); }); } From c5d41e395be1c73d0f4f6c3f3b496411aba5a008 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 4 Aug 2018 17:23:30 +0200 Subject: [PATCH 0701/2430] Fixed port hashrate --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index d9457eb1..483a67af 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -569,7 +569,7 @@ function updatePoolStats2(poolType) { }, function (callback) { //debug(threadName + "Checking Influx for last 5min avg for pool stats (hashRate) per port"); - return callback(null, cache.port_hash || {}); + return callback(null, port_hash || {}); }, ], function (err, result) { if (typeof(poolType) === 'undefined') { From 93b7185743b6a9145352c70ca0bb20549a262e97 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 4 Aug 2018 17:25:32 +0200 Subject: [PATCH 0702/2430] Fixed port hashrate --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 483a67af..d416fc07 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -180,6 +180,7 @@ function updateShareStats() { } cache_updates[key + "_stats"] = cachedData; }); + for (port in localPortHashes) localPortHashes[port] = Math.floor(localPortHashes[port] / (hashrate_avg_min*60)) + 1; cache_updates["port_hash"] = localPortHahes; for (let miner in minerSet) { let stats; From 615096dea245e10e310067941f5e2a4062f18e06 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 4 Aug 2018 17:27:01 +0200 Subject: [PATCH 0703/2430] Fixed port hashrate --- lib/worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index d416fc07..e8adbdfd 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -43,7 +43,7 @@ function updateShareStats() { 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 localPortHahes = {}; + let localPortHashes = {}; let localTimes = { pplns: locTime, pps: locTime, solo: locTime, prop: locTime, global: locTime, miners: {} }; let loopBreakout = 0; @@ -103,8 +103,8 @@ function updateShareStats() { } const port = typeof(share.port) !== 'undefined' && share.port ? share.port : global.config.daemon.port; - if (port in localPortHahes) localPortHahes[port] += share.shares; - else localPortHahes[port] = share.shares; + if (port in localPortHashes) localPortHashes[port] += share.shares; + else localPortHashes[port] = share.shares; if (minerID in minerSet) { localStats.miners[minerID] += share.shares; @@ -181,7 +181,7 @@ function updateShareStats() { cache_updates[key + "_stats"] = cachedData; }); for (port in localPortHashes) localPortHashes[port] = Math.floor(localPortHashes[port] / (hashrate_avg_min*60)) + 1; - cache_updates["port_hash"] = localPortHahes; + cache_updates["port_hash"] = localPortHashes; for (let miner in minerSet) { let stats; let keyStats = "stats:" + miner; From e01bd6934d67e44e92f695a344d740e33e0c4f23 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 4 Aug 2018 17:28:02 +0200 Subject: [PATCH 0704/2430] Fixed port hashrate --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index e8adbdfd..9a013c2b 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -180,7 +180,7 @@ function updateShareStats() { } cache_updates[key + "_stats"] = cachedData; }); - for (port in localPortHashes) localPortHashes[port] = Math.floor(localPortHashes[port] / (hashrate_avg_min*60)) + 1; + for (let port in localPortHashes) localPortHashes[port] = Math.floor(localPortHashes[port] / (hashrate_avg_min*60)) + 1; cache_updates["port_hash"] = localPortHashes; for (let miner in minerSet) { let stats; From 9c720ce2333989f1d90af6d58115432d5c2abd7d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Aug 2018 13:58:00 +0200 Subject: [PATCH 0705/2430] Return short algo name --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 54f1d952..2c0bfe58 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -854,7 +854,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.validJobs.enq(newJob); this.cachedJob = { blob: blob, - algo: global.coinFuncs.algoTypeStr(bt.port), + algo: global.coinFuncs.algoShortTypeStr(bt.port), variant: global.coinFuncs.variantValue(bt.port), job_id: newJob.id, target: target, @@ -879,7 +879,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.cachedJob = { blocktemplate_blob: blob, blob_type: global.coinFuncs.blobTypeStr(bt.port), - algo: global.coinFuncs.algoTypeStr(bt.port), + algo: global.coinFuncs.algoShortTypeStr(bt.port), variant: global.coinFuncs.variantValue(bt.port), difficulty: bt.difficulty, height: bt.height, From 758adb1b71dcffa48cd3af6aecb1fab655c38f82 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 6 Aug 2018 14:35:31 +0200 Subject: [PATCH 0706/2430] Fix algo switch delay for cn algos --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2c0bfe58..5724321d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -698,7 +698,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer this.selectBestAlgo = function() { if (!this.algos) return ""; - if (this.curr_algo && 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 < 5*60*1000) { return this.curr_algo; } let best_algo = ""; @@ -715,7 +715,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer best_algo_perf = miner.algos_perf[algo] * algoHashFactor; } }); - if (!this.curr_algo || this.curr_algo != best_algo) { + if (typeof(this.curr_algo) === 'undefined' || this.curr_algo != best_algo) { this.curr_algo = best_algo; this.curr_algo_time = Date.now(); } From fa605899314609a3823c7173e87b52283cea8a14 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Aug 2018 15:41:38 +0200 Subject: [PATCH 0707/2430] Set variant so it will work with miners that override variant --- 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 54bc1bf3..f5de8218 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -257,7 +257,14 @@ function Coin(data){ } this.variantValue = function(port) { - return 1; + switch (port) { + case 12211: return "0"; // RYO + case 17750: return "xhv"; // Haven + case 20189: return "xtl"; // Stellite + case 24182: return "tube"; // BitTube + case 38081: return "msr"; // MSR + default: return "1"; + } } this.get_miner_agent_notification = function(agent) { From 01a52092797332286cac57db30306b64e5f993bb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Aug 2018 16:42:33 +0200 Subject: [PATCH 0708/2430] Allow cn/1 limited algo switching for miners that only report algo --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5724321d..3e416189 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -589,7 +589,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return ""; }; - if (algos && algos_perf) { + 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); From 5b49409de5ad4d48200ec20c2b246a5d62d64c8a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 10 Aug 2018 16:39:02 +0200 Subject: [PATCH 0709/2430] Added script to set password for lazy miners --- user_scripts/pass_set.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 user_scripts/pass_set.js diff --git a/user_scripts/pass_set.js b/user_scripts/pass_set.js new file mode 100644 index 00000000..b0bae4f6 --- /dev/null +++ b/user_scripts/pass_set.js @@ -0,0 +1,40 @@ +"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); +} +if (!argv.pass) { + console.error("Please specify user pass to set"); + process.exit(1); +} +const user = argv.user; +const pass = argv.pass; + +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) VALUES (?, ?)", [user, pass]).then(function (rows) { + console.log("INSERT INTO users (username, email) VALUES (" + user + ", " + pass + ")"); + callback(); + }); + }, + function (callback) { + console.log("Done."); + process.exit(0); + } + ]); +}); From e2a29c92e9de4643899487f2f4f5adc639e56dae Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Aug 2018 15:41:38 +0200 Subject: [PATCH 0710/2430] Set variant so it will work with miners that override variant --- 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 54bc1bf3..f5de8218 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -257,7 +257,14 @@ function Coin(data){ } this.variantValue = function(port) { - return 1; + switch (port) { + case 12211: return "0"; // RYO + case 17750: return "xhv"; // Haven + case 20189: return "xtl"; // Stellite + case 24182: return "tube"; // BitTube + case 38081: return "msr"; // MSR + default: return "1"; + } } this.get_miner_agent_notification = function(agent) { From 89bcb463b2f5ac1dce1c59a1a38b615b32d8e914 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Aug 2018 16:42:33 +0200 Subject: [PATCH 0711/2430] Allow cn/1 limited algo switching for miners that only report algo --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 5724321d..3e416189 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -589,7 +589,8 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer return ""; }; - if (algos && algos_perf) { + 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); From 0e0d259d2f58f6f48d51ce6adb6b74c570ef53a6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 10 Aug 2018 16:39:02 +0200 Subject: [PATCH 0712/2430] Added script to set password for lazy miners --- user_scripts/pass_set.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 user_scripts/pass_set.js diff --git a/user_scripts/pass_set.js b/user_scripts/pass_set.js new file mode 100644 index 00000000..b0bae4f6 --- /dev/null +++ b/user_scripts/pass_set.js @@ -0,0 +1,40 @@ +"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); +} +if (!argv.pass) { + console.error("Please specify user pass to set"); + process.exit(1); +} +const user = argv.user; +const pass = argv.pass; + +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) VALUES (?, ?)", [user, pass]).then(function (rows) { + console.log("INSERT INTO users (username, email) VALUES (" + user + ", " + pass + ")"); + callback(); + }); + }, + function (callback) { + console.log("Done."); + process.exit(0); + } + ]); +}); From db94117366d1e7f8c8f6f57192df9e7a3f98a601 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 11 Aug 2018 03:20:12 +0200 Subject: [PATCH 0713/2430] 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 0714/2430] 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 3e416189..34215a7b 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 0715/2430] Fixed typo --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 34215a7b..26b15427 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 0716/2430] 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 f5de8218..cd052e40 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 26b15427..5be290dc 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 0717/2430] 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 5be290dc..9015ff54 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 0718/2430] 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 11d8cd23..a3228e7d 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 cd052e40..1c31851c 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 0719/2430] 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 1c31851c..105df6d0 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 0720/2430] 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 105df6d0..be435e38 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 0721/2430] 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 9015ff54..23d1318f 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 0722/2430] 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 be435e38..937d3734 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 0723/2430] 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 937d3734..ef48c25d 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 0724/2430] 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 ef48c25d..b2b877e2 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 0725/2430] 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 23d1318f..adf812fb 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 0726/2430] 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 0a35a3f3..668175aa 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 b2b877e2..bfde96db 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 94d10fb3..79ffa972 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 0727/2430] Updated debug module --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79ffa972..63e02deb 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 0728/2430] 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 d7ea169e..4fd85cc8 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 0729/2430] 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 4fd85cc8..da1e969b 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 0730/2430] 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 f21cc108..2c1ddf38 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 0731/2430] 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 2c1ddf38..82d3b33c 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 0732/2430] 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 a3228e7d..ab8feb05 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 bfde96db..da6a8621 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 adf812fb..2a91c075 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 0733/2430] 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 da6a8621..31013b48 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 0734/2430] 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 da1e969b..7c49b4ba 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 0735/2430] Fixed sendEmailAdmin --- lib/support.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/support.js b/lib/support.js index 82d3b33c..31c3c9ef 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 0736/2430] 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 9a013c2b..2038b185 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 0737/2430] 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 2038b185..f5c6537a 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 0738/2430] 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 1bbdb1fc..47d93eec 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 0739/2430] 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 2a91c075..01296c39 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 0740/2430] 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 01296c39..928c2119 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 0741/2430] 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 928c2119..7317c5e5 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 0742/2430] "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 7c49b4ba..d4bd20bf 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 0743/2430] 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 7317c5e5..1258eb11 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 0744/2430] 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 d4bd20bf..e362d087 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 0745/2430] 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 1258eb11..d8dcca0a 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 0746/2430] 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 d8dcca0a..5c54652c 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 0747/2430] 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 5c54652c..f157ffb3 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 0748/2430] 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 f157ffb3..048f6fac 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 0749/2430] 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 048f6fac..60c02d26 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 0750/2430] Fixed fast case --- lib/pool.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 60c02d26..adcad3f3 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 0751/2430] Fixed fast case --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index adcad3f3..87cb3f86 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 0752/2430] 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 87cb3f86..8761660c 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 0753/2430] 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 8761660c..3936712f 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 0754/2430] 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 e6c36ab8..cf045851 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 0755/2430] 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 3936712f..a0bd829c 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 0756/2430] 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 a0bd829c..173e8f57 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 0757/2430] 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 173e8f57..01b6f9e4 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 0758/2430] 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 31013b48..91a5fadf 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 01b6f9e4..1bc5462b 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 63e02deb..c6231b6d 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 0759/2430] 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 91a5fadf..5da345ae 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 1bc5462b..d7560bd6 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 0760/2430] 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 5da345ae..ff4e0bad 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 d7560bd6..496ca671 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 0761/2430] 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 ff4e0bad..b0e76677 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 0762/2430] 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 cf045851..2f6303c1 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 0763/2430] 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 2f6303c1..d7b08c53 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 0764/2430] 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 d7b08c53..14081407 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 0765/2430] 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 14081407..e9029f37 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 0766/2430] 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 e9029f37..7d4b0cba 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 0767/2430] 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 496ca671..4e9cda07 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 0768/2430] 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 4e9cda07..a5e9255c 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 0769/2430] 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 ab8feb05..bf72a478 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 b0e76677..2330417e 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 a5e9255c..e7cb31d4 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 31c3c9ef..14f77cd2 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 f5c6537a..97945de5 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 0770/2430] 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 2330417e..7d4505f5 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 0771/2430] 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 7d4505f5..aeedd86e 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 0772/2430] 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 e7cb31d4..8f4f739b 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 0773/2430] 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 8f4f739b..c57e50fd 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 0774/2430] Added cn/2 tweak support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6231b6d..ef7943e1 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 0775/2430] 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 aeedd86e..6c088f2f 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 ef7943e1..117bb4fa 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 0776/2430] Updated hashing utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 117bb4fa..3101b1df 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 0777/2430] 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 c57e50fd..1bde34ef 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 0778/2430] Updated cn hash utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3101b1df..d0968ada 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 0779/2430] 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 6c088f2f..3b93a160 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 1bde34ef..bcad1cf4 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 0780/2430] 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 bcad1cf4..340a189d 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 0781/2430] 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 3b93a160..e5ea3d32 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 0782/2430] 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 340a189d..e787e843 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 0783/2430] 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 e787e843..859f1241 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 0784/2430] 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 859f1241..538438e1 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 0785/2430] 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 538438e1..986a3198 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 0786/2430] 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 986a3198..377146d6 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 0787/2430] 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 e5ea3d32..da504e36 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 0788/2430] trim spaces --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 377146d6..2b489515 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 0789/2430] 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 c26427bc..e4d9ff5c 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 be240273..5a053a03 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 73e60f40..7e13b772 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 0790/2430] 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 e4d9ff5c..c02203a5 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 5a053a03..308752c2 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 0791/2430] 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 c02203a5..2113095a 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 308752c2..aa29acf9 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 7e13b772..29dcf6a6 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 0792/2430] 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 29dcf6a6..9cbcbacc 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 0793/2430] 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 2113095a..b2db260b 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 aa29acf9..9e666e1f 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 0794/2430] 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 da504e36..a3a5bc45 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 0795/2430] 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 a3a5bc45..ad65a3a9 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 0796/2430] 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 377146d6..3d1c7442 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 0797/2430] Updated donate address --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 668175aa..64f20188 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 0798/2430] 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 3d1c7442..4313ed6b 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 0799/2430] 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 b2db260b..8e5871bc 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 9e666e1f..456cb362 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 9cbcbacc..c1fe833b 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 ad65a3a9..2fe7f5de 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 0800/2430] 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 8e5871bc..91a49bf9 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 456cb362..8bb9d8b7 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 c1fe833b..0b59e088 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 0801/2430] 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 91a49bf9..9bf29c74 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 8bb9d8b7..3393eb5f 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 0b59e088..483bda81 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 0802/2430] 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 9bf29c74..584c8497 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 0803/2430] 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 3393eb5f..6768662b 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 0804/2430] 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 584c8497..089ca6a8 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 0805/2430] 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 2fe7f5de..2171a2c0 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 0806/2430] 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 2171a2c0..7aed3d56 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 0807/2430] 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 7aed3d56..d756c4eb 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 0808/2430] 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 3373095a..1c56b406 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 0809/2430] 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 1c56b406..b92ca600 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 0810/2430] 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 d756c4eb..07bfc597 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 0811/2430] 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 bf72a478..b2be577e 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 07bfc597..ec4813c5 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 0812/2430] Added TRTL donate address --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 64f20188..d27566e5 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 0813/2430] 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 ec4813c5..2c0fde89 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 0814/2430] 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 2c0fde89..df01e661 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 0815/2430] 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 df01e661..ff5623b4 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 0816/2430] 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 ff5623b4..7d85faa0 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 0817/2430] 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 7d85faa0..85cb9d60 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 0818/2430] 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 e362d087..8d7b8315 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 0819/2430] 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 8e2139f7..d1cd09d7 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 0820/2430] 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 d1cd09d7..8f3d0dd8 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 0821/2430] 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 8f3d0dd8..8fd1e186 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 0822/2430] 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 8fd1e186..97c7a3e2 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 0823/2430] 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 97c7a3e2..16a32255 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 0824/2430] 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 85cb9d60..6cb17861 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 16a32255..afc9a273 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 0825/2430] 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 afc9a273..869514b8 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 0826/2430] Better debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 869514b8..3566fab4 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 0827/2430] 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 3566fab4..6e1db2b6 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 0828/2430] 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 6e1db2b6..fb42f80a 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 0829/2430] Error fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index fb42f80a..0afd2527 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 0830/2430] 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 0afd2527..804cfeb8 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 0831/2430] Error fix --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 804cfeb8..7e198bfa 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 0832/2430] More logs --- lib/pool.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7e198bfa..d0faaaf5 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 0833/2430] More debug --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d0faaaf5..5bce7618 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 0834/2430] More debug --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5bce7618..593f2f08 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 0835/2430] 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 593f2f08..db72f2e2 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 0836/2430] 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 6cb17861..70032ad7 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 0837/2430] 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 70032ad7..7741c76c 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 0838/2430] 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 97945de5..da802830 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 0839/2430] 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 7741c76c..562e1fdb 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 0840/2430] 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 da802830..5571c614 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 0841/2430] 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 5571c614..fb8adfb2 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 0842/2430] 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 562e1fdb..f37e56a7 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 0843/2430] 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 db72f2e2..1f999545 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 0844/2430] More algo switch debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 1f999545..a26fc99d 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 0845/2430] 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 a26fc99d..006232c7 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 0846/2430] 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 006232c7..3392414e 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 0847/2430] More debug --- lib/pool.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 3392414e..1941eea4 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 0848/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1941eea4..50c9a224 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 0849/2430] 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 50c9a224..b92f4287 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 0850/2430] 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 b92f4287..82b3d742 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 0851/2430] 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 82b3d742..005c9a86 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 0852/2430] Better debugging --- lib/pool.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 005c9a86..d12de452 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 0853/2430] 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 d12de452..c04367d4 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 0854/2430] 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 c04367d4..dc7f36b5 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 0855/2430] 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 dc7f36b5..f146f46e 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 0856/2430] 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 f146f46e..d4449cc4 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 0857/2430] 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 d4449cc4..a050a9a0 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 0858/2430] 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 a050a9a0..ae37e422 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 0859/2430] 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 ae37e422..f1e039af 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 0860/2430] Extended dump --- lib/pool.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f1e039af..70d42a95 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 0861/2430] Moved altblockManager to separate dir --- init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.js b/init.js index d4dc05d1..11e34c0e 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 0862/2430] 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 00000000..12e71b28 --- /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 0863/2430] 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 089ca6a8..2297ede2 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 6768662b..6c2854dd 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 483bda81..fcdd9db7 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 0864/2430] 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 b2be577e..c4fdeb13 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 f37e56a7..01c71e0a 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 0865/2430] 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 0866/2430] 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 70d42a95..ae0c5f53 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 0867/2430] 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 c4fdeb13..93cdcfd5 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 0868/2430] 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 01c71e0a..195f72df 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 ae0c5f53..8727c873 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 0869/2430] 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 b92ca600..e51c0d53 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 0870/2430] Addned new module support --- init.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.js b/init.js index 11e34c0e..5ad2cc44 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 0871/2430] 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 e51c0d53..9dc9dd64 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 0872/2430] 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 9dc9dd64..7287ce2d 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 0873/2430] 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 7d4b0cba..110e5dce 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 0874/2430] 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 110e5dce..40262959 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 0875/2430] 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 40262959..0080f054 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 0876/2430] 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 0080f054..ed6bbaa7 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 0877/2430] 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 ed6bbaa7..a8cef5f4 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 0878/2430] 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 a8cef5f4..842097d8 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 0879/2430] 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 195f72df..ccb9fd65 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 0880/2430] 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 8d7b8315..acc1a18c 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 0881/2430] 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 ccb9fd65..85c34890 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 0882/2430] 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 85c34890..70eb0b12 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 0883/2430] 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 70eb0b12..519b531f 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 0884/2430] 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 519b531f..fb58b47c 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 0885/2430] 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 fb58b47c..605c0ad8 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 0886/2430] 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 605c0ad8..5526c268 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 0887/2430] 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 5526c268..96b14ea0 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 0888/2430] 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 96b14ea0..c0bd95af 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 0889/2430] 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 c0bd95af..f8ff3d88 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 0890/2430] 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 f8ff3d88..919f48c2 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 0891/2430] 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 919f48c2..55562f37 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 0892/2430] 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 55562f37..1054d352 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 0893/2430] 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 1054d352..3623bf25 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 0894/2430] 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 3623bf25..5edf491c 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 0895/2430] 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 0f0cb4e5..401371d0 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 0896/2430] 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 8727c873..b8c82dc5 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 0897/2430] 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 842097d8..6009c4d1 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 0898/2430] 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 00000000..39d7ed27 --- /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 0899/2430] 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 5edf491c..e174184c 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 acc1a18c..893f57aa 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 0900/2430] 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 893f57aa..59bcf786 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 0901/2430] 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 59bcf786..ad9c9e80 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 0902/2430] 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 e174184c..46bbc3cb 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 ad9c9e80..2efae684 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 0903/2430] 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 2efae684..771e7823 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 0904/2430] 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 fb8adfb2..a5651370 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 0905/2430] 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 7287ce2d..d248b442 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 0906/2430] 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 d248b442..74c8d911 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 0907/2430] 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 a5651370..e1e270af 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 0908/2430] delete log --- lib/worker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index e1e270af..c0184ad6 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 0909/2430] 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 46bbc3cb..d07981d6 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 0910/2430] 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 74c8d911..5b3ce59b 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 0911/2430] 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 5b3ce59b..17e01902 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 0912/2430] 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 17e01902..72488545 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 0913/2430] 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 d07981d6..ae97a3b5 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 d0968ada..26a12021 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 0914/2430] 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 42ec2f53..576eac5b 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 0915/2430] 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 26a12021..4bdaa8f5 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 0916/2430] 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 ae97a3b5..93edbb5e 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 0917/2430] 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 93edbb5e..1891ee11 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 0918/2430] 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 1891ee11..4bfe3748 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 0919/2430] 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 b8c82dc5..56f2f837 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 0920/2430] 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 1891ee11..37196781 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 4bdaa8f5..d72d8fc0 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 0921/2430] 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 b230d231..d8bc1995 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 0922/2430] Updated utils for MSR --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d72d8fc0..e687ea74 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 0923/2430] 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 d8bc1995..3464f7ab 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 0924/2430] One more Masari fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e687ea74..59b9cb98 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 0925/2430] 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 6009c4d1..3a26102f 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 0926/2430] 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 3464f7ab..2c299c75 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 0927/2430] 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 2c299c75..6836e824 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 0928/2430] 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 6836e824..3b3ddce9 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 0929/2430] 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 3b3ddce9..ffd0ec63 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 59b9cb98..05d9e949 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 0930/2430] 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 ffd0ec63..65aab48e 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 05d9e949..8b6f036c 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 0931/2430] 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 65aab48e..c68c604e 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 0932/2430] 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 56f2f837..7932d2d9 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 0933/2430] 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 7932d2d9..b15fd7a3 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 0934/2430] 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 b15fd7a3..adf6e826 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 0935/2430] 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 adf6e826..38784c2a 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 0936/2430] 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 38784c2a..2965a8e4 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 0937/2430] 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 2965a8e4..a3a97098 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 0938/2430] 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 a3a97098..ed9d25db 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 0939/2430] 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 ed9d25db..4f92335d 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 0940/2430] Bug fixes for AVX CPUs --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b6f036c..63a31095 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 0941/2430] 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 c68c604e..ee9c3676 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 0942/2430] 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 ee9c3676..8cdcf048 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 0943/2430] 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 8cdcf048..33b40ab2 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 0944/2430] 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 33b40ab2..63a7f96c 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 ed9d25db..ace28331 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 63a31095..6cfa3b22 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 0945/2430] Updated version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6cfa3b22..9a4756e4 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 0946/2430] 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 ace28331..f158867a 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 0947/2430] 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 f158867a..1b7d6c77 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 0948/2430] 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 63a7f96c..d3cd6a40 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 0949/2430] 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 d3cd6a40..8eca8acb 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 1b7d6c77..4df8ad5a 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 0950/2430] 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 8eca8acb..9f3b4736 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 0951/2430] 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 4df8ad5a..77c1fe2d 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 0952/2430] 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 77c1fe2d..b517ad2a 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 0953/2430] 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 b517ad2a..00aa1282 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 0954/2430] 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 9f3b4736..8238070b 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 9a4756e4..1f9f2f71 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 0955/2430] 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 fcdd9db7..b7308359 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 0956/2430] 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 2297ede2..bec02219 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 6c2854dd..06a71e8a 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 0957/2430] 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 8238070b..e52a2430 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 0958/2430] 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 e52a2430..c2c2ce52 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 0959/2430] 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 00000000..49f4ee78 --- /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 0960/2430] 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 49f4ee78..3d7bb25f 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 0961/2430] 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 c2c2ce52..647fe0b1 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 0962/2430] 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 647fe0b1..261078e2 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 0963/2430] 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 261078e2..45b4dd4a 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 0964/2430] 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 261078e2..044fffb6 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 0965/2430] 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 91d31576..bbc542ee 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 0966/2430] 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 00aa1282..d3e91600 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 0967/2430] 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 bbc542ee..280ae822 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 1f9f2f71..8b4f7509 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 0968/2430] 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 280ae822..517f6d6e 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 0969/2430] 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 517f6d6e..5a4707c2 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 0970/2430] 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 517f6d6e..a3f895e3 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 0971/2430] 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 f2b6fba1..52d46327 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 0972/2430] 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 8df28348..04c9bc8e 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 0973/2430] 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 04c9bc8e..02269c91 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 0974/2430] 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 02269c91..86a9d511 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 0975/2430] 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 3a26102f..de4f4c4a 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 0976/2430] 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 d3e91600..15a0c8b5 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 0977/2430] remove condition --- lib/pool.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 15a0c8b5..c7da9823 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 0978/2430] 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 86a9d511..42e197d3 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 0979/2430] 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 42e197d3..788b61f7 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 0980/2430] 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 93cdcfd5..8558f09e 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 c0184ad6..25af96da 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 0981/2430] 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 25af96da..0f63e785 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 0982/2430] 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 0f63e785..9a6bc1ce 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 0983/2430] 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 9a6bc1ce..0ec2a554 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 0984/2430] Fixed rounding --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0ec2a554..0d40104c 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 0985/2430] 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 0d40104c..277ab86f 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 0986/2430] Improved history pow calc --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 277ab86f..470f4043 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 0987/2430] 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 470f4043..247ef964 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 0988/2430] Improved history pow calc --- lib/worker.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 247ef964..277ab86f 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 0989/2430] 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 277ab86f..dde21150 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 0990/2430] 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 dde21150..8f21c585 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 0991/2430] 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 8f21c585..841efa73 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 0992/2430] Moved to updated LOKI utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b4f7509..f78f202e 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 0993/2430] 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 788b61f7..731b6f3a 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 0994/2430] 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 731b6f3a..11f4eafe 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 0995/2430] 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 11f4eafe..7178ec61 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 e98f8163..6d50c67d 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 f78f202e..d3067c8b 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 0996/2430] 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 7178ec61..15cbaf65 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 6d50c67d..e1ef4053 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 0997/2430] 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 15cbaf65..27f40bd6 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 0998/2430] 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 27f40bd6..9a7179e7 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 0999/2430] 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 9a7179e7..4c61c82e 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 1000/2430] 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 4c61c82e..6b72e3b1 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 1001/2430] 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 6b72e3b1..59a92833 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 1002/2430] 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 59a92833..2126cb0a 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 1003/2430] 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 e1ef4053..445f3774 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 1004/2430] Added logs --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 445f3774..82fc2152 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 1005/2430] 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 2126cb0a..0c5acdf4 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 1006/2430] 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 0c5acdf4..0b65d4c4 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 82fc2152..d7182f7d 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 1007/2430] 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 0b65d4c4..0a812dcf 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 d7182f7d..baae9c77 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 1008/2430] 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 baae9c77..aa50875f 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 1009/2430] 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 aa50875f..ab747b00 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 1010/2430] 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 0a812dcf..636e6132 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 1011/2430] 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 636e6132..1e8228f1 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 1012/2430] Added log --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index ab747b00..d67735e1 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 1013/2430] 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 d67735e1..7546e570 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 1014/2430] 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 1e8228f1..f033f457 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 7546e570..c615edb6 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 1015/2430] Added logs --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index c615edb6..984ef724 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 1016/2430] 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 f033f457..3f910371 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 984ef724..9caf2fa3 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 1017/2430] 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 9caf2fa3..a8df137e 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 1018/2430] 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 3f910371..3f3cd659 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 1019/2430] 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 3f3cd659..52d07df8 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 1020/2430] 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 52d07df8..98d80f84 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 1021/2430] 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 a8df137e..d27ed02b 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 1022/2430] 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 98d80f84..2807c549 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 1023/2430] 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 2807c549..99a6398c 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 1024/2430] Less debug --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d27ed02b..3ff77f16 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 1025/2430] 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 3ff77f16..a228a862 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 1026/2430] 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 a228a862..86efa416 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 1027/2430] 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 86efa416..ea43e673 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 1028/2430] 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 99a6398c..f807ab68 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 ea43e673..0ba514fb 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 1029/2430] 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 0ba514fb..4cccb0d3 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 1030/2430] 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 4cccb0d3..2fcf4187 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 1031/2430] 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 f807ab68..05c884b0 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 1032/2430] 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 05c884b0..508a77c9 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 1033/2430] 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 508a77c9..9d59f3cf 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 1034/2430] 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 2fcf4187..74861233 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 1035/2430] 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 9d59f3cf..4e969352 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 1036/2430] 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 4e969352..c146b8ce 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 74861233..3420f3cb 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 1037/2430] 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 3420f3cb..dd8cb67b 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 1038/2430] 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 dd8cb67b..086074df 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 1039/2430] 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 c146b8ce..8f33e2ae 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 086074df..d6a2ef09 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 1040/2430] 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 8f33e2ae..b2b552bf 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 1041/2430] Extra debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index d6a2ef09..d7c15ed8 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 1042/2430] Extra debug --- lib/pool.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d7c15ed8..ab6a2057 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 1043/2430] 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 b2b552bf..e2bc8abd 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 1044/2430] Extra debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ab6a2057..545166fa 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 1045/2430] Extra debug --- lib/pool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 545166fa..03380562 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 1046/2430] Extra debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 03380562..c41cb4e7 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 1047/2430] Extra debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c41cb4e7..c83ca1fd 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 1048/2430] Extra debug --- lib/pool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c83ca1fd..95346b05 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 1049/2430] Extra debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 95346b05..dcdf3e31 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 1050/2430] 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 dcdf3e31..0181bbd3 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 1051/2430] 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 0181bbd3..3c8dbbbd 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 1052/2430] 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 3c8dbbbd..9e684519 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 1053/2430] Less debug --- lib/pool.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9e684519..61f25918 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 1054/2430] More debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 61f25918..cbed0974 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 1055/2430] More debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cbed0974..1da6ef9b 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 1056/2430] More debug --- lib/pool.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1da6ef9b..0ec905a2 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 1057/2430] More debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 0ec905a2..43c07372 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 1058/2430] 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 e2bc8abd..830fbfe5 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 1059/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 43c07372..b6a9cb55 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 1060/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index b6a9cb55..1ee77576 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 1061/2430] 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 830fbfe5..705c6fd7 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 1ee77576..68068ee0 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 1062/2430] 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 68068ee0..0d1910ff 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 1063/2430] 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 705c6fd7..ce1c13b4 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 1064/2430] 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 ce1c13b4..0cce4458 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 1065/2430] 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 0cce4458..7895b720 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 1066/2430] 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 7895b720..8eef889c 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 0d1910ff..9299f88c 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 1067/2430] More debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9299f88c..03bab51e 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 1068/2430] More debug --- lib/pool.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 03bab51e..04efc902 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 1069/2430] More debug --- lib/pool.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 04efc902..da7fb083 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 1070/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index da7fb083..465615b3 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 1071/2430] More debug --- lib/pool.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 465615b3..3b76ca76 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 1072/2430] More debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 3b76ca76..58e22f7f 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 1073/2430] 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 8eef889c..e9c4a1ed 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 58e22f7f..015e3aa4 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 1074/2430] Added debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 015e3aa4..1e643dfb 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 1075/2430] 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 e9c4a1ed..1fdeb2c2 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 1076/2430] 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 1fdeb2c2..8eef889c 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 1e643dfb..ea858940 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 1077/2430] More debug --- lib/pool.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ea858940..150d51c4 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 1078/2430] Less debug --- lib/pool.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 150d51c4..730add9b 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 1079/2430] 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 730add9b..281df0fd 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 1080/2430] More debug --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 281df0fd..7fe60be9 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 1081/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7fe60be9..54c7439f 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 1082/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 54c7439f..8fca6249 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 1083/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 8fca6249..3755675a 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 1084/2430] 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 3755675a..34218b99 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 1085/2430] 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 34218b99..6f207b18 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 1086/2430] 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 6f207b18..3402f234 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 1087/2430] 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 8eef889c..1bd30aca 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 3402f234..ee366e01 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 1088/2430] 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 1bd30aca..6d4231a1 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 ee366e01..77b932ca 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 1089/2430] 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 6d4231a1..6bb3e32b 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 1090/2430] 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 77b932ca..7bf9b6f1 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 1091/2430] 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 7bf9b6f1..f1e4c60d 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 1092/2430] 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 f1e4c60d..f8eeeabe 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 1093/2430] 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 f8eeeabe..2148e78d 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 1094/2430] 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 6bb3e32b..23dbf975 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 1095/2430] 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 23dbf975..404eeaab 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 1096/2430] 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 404eeaab..f001f5b0 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 1097/2430] 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 f001f5b0..d17ce662 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 1098/2430] 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 d17ce662..04f9fbed 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 1099/2430] 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 04f9fbed..c9518d49 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 1100/2430] 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 c9518d49..45f3a957 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 1101/2430] 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 45f3a957..54b1c2ac 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 1102/2430] 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 54b1c2ac..2b7e3514 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 1103/2430] 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 2b7e3514..1408562c 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 1104/2430] 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 1408562c..4e3dbbd5 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 1105/2430] 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 4e3dbbd5..2b007570 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 1106/2430] 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 2b007570..af8f7bc5 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 1107/2430] 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 2148e78d..3036b575 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 1108/2430] 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 3036b575..1b81591e 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 1109/2430] 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 1b81591e..ca9a2d3c 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 1110/2430] 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 ca9a2d3c..56540b96 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 1111/2430] 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 56540b96..d1f2d748 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 1112/2430] 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 d1f2d748..cf0e3409 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 1113/2430] 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 de4f4c4a..5a6a421c 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 cf0e3409..602315c9 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 1114/2430] Updated to tagged coin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3067c8b..7a48c4b4 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 1115/2430] 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 af8f7bc5..3f835883 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 1116/2430] Added UTF --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7a48c4b4..6c00bf7e 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 1117/2430] 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 841efa73..b1ba54a5 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 1118/2430] fix UTF --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c00bf7e..2c0d132b 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 1119/2430] 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 b1ba54a5..4c7862ce 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 1120/2430] 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 4c7862ce..10304e75 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 1121/2430] 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 10304e75..5b34298e 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 1122/2430] 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 3f835883..4317d343 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 1123/2430] 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 602315c9..9ba74f22 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 1124/2430] 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 4317d343..206bb63c 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 1125/2430] 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 206bb63c..d0517733 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 9ba74f22..096444b9 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 5b34298e..41668425 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 1126/2430] 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 d0517733..6348b8f3 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 1127/2430] 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 6348b8f3..25bb4f3b 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 1128/2430] 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 41668425..38bcd18b 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 1129/2430] 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 38bcd18b..cea7eb34 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 1130/2430] 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 cea7eb34..6a0d732d 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 1131/2430] 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 096444b9..a176db6d 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 1132/2430] Added some debug stuff --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index a176db6d..0cbe72d6 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 1133/2430] 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 0cbe72d6..bac0c1a6 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 1134/2430] 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 bac0c1a6..32378c90 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 1135/2430] 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 32378c90..8c2f9d74 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 1136/2430] 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 8c2f9d74..73bce333 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 1137/2430] 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 73bce333..e68dc98d 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 1138/2430] 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 e68dc98d..d5fa6ba9 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 1139/2430] 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 d5fa6ba9..41e5f737 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 1140/2430] 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 41e5f737..c1dbac8f 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 1141/2430] More debug --- lib/pool.js | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c1dbac8f..1eaccf07 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 1142/2430] Restored code --- lib/pool.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1eaccf07..83c6d79c 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 1143/2430] 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 83c6d79c..1eaccf07 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 1144/2430] 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 1eaccf07..c1dbac8f 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 1145/2430] Another attempt --- lib/pool.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c1dbac8f..f6e36f6c 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 1146/2430] 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 f6e36f6c..2598e838 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 1147/2430] 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 2598e838..c439611e 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 1148/2430] 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 c439611e..a353333c 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 1149/2430] Normalized coin jobs functions --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index a353333c..e057ab40 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 1150/2430] 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 e057ab40..c9b9e3a8 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 1151/2430] 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 72488545..2fcaea12 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 1152/2430] 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 c9b9e3a8..deb01c80 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 1153/2430] 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 deb01c80..2e49d4df 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 1154/2430] 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 2e49d4df..ea8a4ed5 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 1155/2430] Code simplify --- lib/pool.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ea8a4ed5..3357c8e7 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 1156/2430] Added extra wallet verify --- lib/pool.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 3357c8e7..a01ad6b2 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 1157/2430] 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 a01ad6b2..5219b4c9 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 1158/2430] 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 5219b4c9..f27c8bc7 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 1159/2430] Const adjustement --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f27c8bc7..8326bbf5 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 1160/2430] 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 8326bbf5..e2ea7717 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 1161/2430] 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 e2ea7717..3dca35ca 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 1162/2430] 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 3dca35ca..719bf710 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 1163/2430] More debug --- lib/pool.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 719bf710..cffbf8be 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 1164/2430] Removed debug --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index cffbf8be..3e339865 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 1165/2430] 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 25bb4f3b..1230d0a2 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 1166/2430] Added XTNC donate address --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d27566e5..9f33d1bf 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 1167/2430] Added XTNC support --- deployment/base.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 8558f09e..232d4779 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 1168/2430] Adjust constant --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 3e339865..7c844bc4 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 1169/2430] 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 232d4779..a9a0237c 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 5a6a421c..e18e19eb 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 52d46327..65370382 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 771e7823..a221c1db 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 1170/2430] Fixed rounding --- lib/blockManager.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e18e19eb..8c974fbc 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 1171/2430] Fixed rounding --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 8c974fbc..424a6599 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 1172/2430] 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 04e71c2e..08ae6820 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 1173/2430] Fixed callbacks --- lib/blockManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 424a6599..98abac60 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 1174/2430] Fixed callbacks --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 98abac60..c0f364f1 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 1175/2430] More debug --- lib/blockManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index c0f364f1..6649f8f4 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 1176/2430] More debug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 6649f8f4..53499c55 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 1177/2430] 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 53499c55..e05203d9 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 1178/2430] Fixed bug --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index e05203d9..5d0922a4 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 1179/2430] Fixed bug --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 5d0922a4..209860b7 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 1180/2430] Fixed bug --- lib/blockManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 209860b7..9b46819e 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 1181/2430] Fixed bug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 9b46819e..63909a60 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 1182/2430] Fixed bug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 63909a60..7415fc40 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 1183/2430] 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 7415fc40..b482db55 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 1184/2430] Fixed bug --- lib/blockManager.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index b482db55..3c98189c 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 1185/2430] 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 1230d0a2..2327dfd3 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 1186/2430] 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 3c98189c..6155cb0a 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 1187/2430] 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 a221c1db..5eda1f80 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 1188/2430] 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 5eda1f80..e3a1e98c 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 1189/2430] 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 a9a0237c..84744486 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 1190/2430] Added SUMO support --- deployment/base.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 84744486..e01520d5 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 1191/2430] 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 e01520d5..af99cb32 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 1192/2430] Updated hashing utils version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c0d132b..8053ef29 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 1193/2430] 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 e3a1e98c..b1543775 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 1194/2430] 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 b1543775..59364688 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 1195/2430] 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 6155cb0a..1d173492 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 1196/2430] 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 6a0d732d..f28b0d2f 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 1197/2430] 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 1d173492..19ca3c2e 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 1198/2430] 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 19ca3c2e..3a04482b 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 7c844bc4..b553404b 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 1199/2430] 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 2327dfd3..ceb8b644 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 1200/2430] 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 ceb8b644..94f5f4da 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 b553404b..0d99d4b1 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 8053ef29..ea4d7c6c 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 1201/2430] 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 0d99d4b1..9c0646a7 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 1202/2430] 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 94f5f4da..5d4b208b 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 1203/2430] Removed variant --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9c0646a7..82782997 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 1204/2430] 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 5d4b208b..d3efc3f4 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 1205/2430] 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 f28b0d2f..b3c61925 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 1206/2430] 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 47d93eec..d7b826c1 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 1207/2430] 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 d7b826c1..da4396cf 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 1208/2430] 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 da4396cf..df916d94 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 1209/2430] 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 df916d94..efb4279d 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 1210/2430] 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 efb4279d..7731733e 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 1211/2430] 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 7731733e..d1fd86ae 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 1212/2430] 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 d1fd86ae..d3630fdd 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 1213/2430] 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 e98c4b85..00000000 --- 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 1214/2430] 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 bec02219..0caec38c 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 9d797b0f..826d5217 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 06a71e8a..294ec678 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 a1ad70d6..86fcb369 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 d6a20b1e..e2f508f8 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 b7308359..bf87951d 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 82782997..9cebebda 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 1215/2430] 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 9cebebda..64517f4a 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 1216/2430] 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 64517f4a..579d9bda 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 1217/2430] 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 579d9bda..df7cd58f 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 1218/2430] 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 df7cd58f..023717f8 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 1219/2430] 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 023717f8..5af1ed27 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 1220/2430] 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 5af1ed27..7362e6bb 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 1221/2430] 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 7362e6bb..0b82c86d 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 1222/2430] 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 b3c61925..550014bf 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 1223/2430] 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 bf87951d..cf884b87 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 1224/2430] 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 0b82c86d..558f03c6 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 1225/2430] 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 d3efc3f4..a091efc6 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 ea4d7c6c..131e29c7 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 1226/2430] 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 558f03c6..43b2554b 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 1227/2430] 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 576eac5b..4c6bbee5 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 1228/2430] 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 550014bf..52ea3cb0 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 1229/2430] 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 a091efc6..c3253ccc 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 43b2554b..6d6573a5 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 131e29c7..048d0f2f 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 1230/2430] 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 00000000..a02732c0 --- /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 1231/2430] 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 a02732c0..4f576074 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 00000000..297877d2 --- /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 00000000..c2fc7f8f --- /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 1232/2430] 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 c3253ccc..5ba91cec 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 52ea3cb0..7852ccb7 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 1233/2430] 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 6d6573a5..da8388ab 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 1234/2430] 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 5ba91cec..c93b5e40 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 1235/2430] 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 da8388ab..6d6573a5 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 14f77cd2..44bf6d52 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 1236/2430] 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 44bf6d52..42b8f479 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 1237/2430] 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 6d6573a5..9790fb42 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 1238/2430] 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 9790fb42..5081f3e5 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 1239/2430] 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 c93b5e40..3bfd3752 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 42b8f479..44bf6d52 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 1240/2430] More debug --- lib/support.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 44bf6d52..9d36a6d3 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 1241/2430] 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 5081f3e5..d08bbbc9 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 1242/2430] 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 d08bbbc9..0238161a 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 1243/2430] 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 0238161a..fd84357f 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 1244/2430] 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 fd84357f..acd1c0e6 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 1245/2430] 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 acd1c0e6..fd407baa 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 1246/2430] 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 fd407baa..a1000923 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 1247/2430] 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 3bfd3752..f16e4503 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 1248/2430] 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 00000000..b323703b --- /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 1249/2430] 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 b323703b..84ef2e7c 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 1250/2430] 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 84ef2e7c..85f57261 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 1251/2430] 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 f16e4503..36ca4c57 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 1252/2430] 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 36ca4c57..2934325f 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 1253/2430] 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 2934325f..b372336f 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 1254/2430] 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 b372336f..0c990b3b 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 1255/2430] 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 0c990b3b..5f0a70d9 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 1256/2430] 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 5f0a70d9..ff1038b0 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 a1000923..b3c0d29d 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 048d0f2f..559fc102 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 1257/2430] 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 ff1038b0..8cde1c78 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 1258/2430] 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 b3c0d29d..ac64576d 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 1259/2430] 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 ac64576d..6eec1c3c 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 1260/2430] 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 6eec1c3c..1c0149bd 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 1261/2430] 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 1c0149bd..2880a580 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 1262/2430] 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 2880a580..881c6a0d 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 1263/2430] 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 881c6a0d..dd3ad4e8 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 1264/2430] 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 dd3ad4e8..2c87a5a1 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 1265/2430] 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 8cde1c78..d08f1607 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 1266/2430] 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 af99cb32..03e2d104 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 d08f1607..bf764fea 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 1267/2430] 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 2c87a5a1..6dc0cd84 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 1268/2430] 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 bf764fea..9c878ff2 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 1269/2430] 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 6dc0cd84..8d07bca4 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 1270/2430] 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 9c878ff2..6f0686ec 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 1271/2430] 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 6f0686ec..fb21047b 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 8d07bca4..bd7ddfea 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 1272/2430] 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 bd7ddfea..2b4f9e25 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 1273/2430] 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 b0bae4f6..dbfb7403 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 1274/2430] 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 2b4f9e25..291e75ec 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 1275/2430] 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 7852ccb7..77e526cc 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 1276/2430] 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 3a04482b..79be0860 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 1277/2430] 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 79be0860..22937d61 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 1278/2430] Removed extra callback --- lib/blockManager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 22937d61..955a7ad6 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 1279/2430] 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 291e75ec..3e441f27 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 1280/2430] 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 fb21047b..34eba13e 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 1281/2430] 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 34eba13e..d1e0ca5d 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 1282/2430] 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 d1e0ca5d..c4ec18d0 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 559fc102..bc680b54 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 1283/2430] 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 c4ec18d0..067d3c59 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 1284/2430] 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 00000000..d2e39624 --- /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 1285/2430] 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 d2e39624..9aac2136 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 1286/2430] 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 067d3c59..488931f2 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 1287/2430] 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 488931f2..ad2c2701 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 1288/2430] 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 59364688..4c0abfd0 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 1289/2430] 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 4c0abfd0..6ad9a4a0 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 1290/2430] 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 6ad9a4a0..376b13fd 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 1291/2430] 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 376b13fd..03eb8505 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 1292/2430] 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 ad2c2701..1577d33a 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 1293/2430] 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 3e441f27..481e1587 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 1294/2430] 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 1577d33a..1b495d87 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 1295/2430] 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 481e1587..c70e58f8 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 1296/2430] 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 1b495d87..03c6932e 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 1297/2430] 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 03c6932e..8d7e8881 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 1298/2430] 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 8d7e8881..92f0918f 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 c70e58f8..b40e4b87 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 bc680b54..2f6584e2 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 1299/2430] 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 92f0918f..f50d377c 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 1300/2430] Aeon support --- lib/pool.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index b40e4b87..67fe3196 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 1301/2430] 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 67fe3196..6aafa051 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 1302/2430] 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 f50d377c..8000921f 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 1303/2430] 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 8000921f..9d58c3b8 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 6aafa051..c1248177 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 1304/2430] 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 c1248177..13d5a3fb 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 1305/2430] 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 9d58c3b8..91a63e07 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 1306/2430] 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 91a63e07..339ad602 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 1307/2430] 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 13d5a3fb..993eb9b3 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 1308/2430] 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 993eb9b3..02aa3dd2 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 1309/2430] 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 02aa3dd2..70284b56 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 1310/2430] 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 70284b56..e0c04b44 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 1311/2430] More debug --- lib/pool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index e0c04b44..68e5e589 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 1312/2430] More debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 68e5e589..5a50e484 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 1313/2430] More debug --- lib/pool.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 5a50e484..211b7560 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 1314/2430] 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 211b7560..2789de34 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 1315/2430] 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 2789de34..9800ed2b 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 1316/2430] 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 9800ed2b..c277f148 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 1317/2430] 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 c277f148..675e25b2 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 1318/2430] 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 339ad602..f23425a0 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 1319/2430] 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 675e25b2..53723429 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 1320/2430] 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 f23425a0..7970a5f1 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 1321/2430] Added hash factor debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 53723429..c27fcc10 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 1322/2430] 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 c27fcc10..f4d9248d 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 1323/2430] 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 f4d9248d..d695f9ea 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 1324/2430] 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 d695f9ea..1abb1748 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 1325/2430] 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 1abb1748..d6a6dc6a 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 1326/2430] Added hash factor debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index d6a6dc6a..5bde7459 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 1327/2430] 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 5bde7459..5d0a15b6 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 1328/2430] 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 5d0a15b6..a29cd5a4 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 1329/2430] Removed debug info --- lib/pool.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a29cd5a4..13e23a3f 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 1330/2430] 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 7970a5f1..f5527c1a 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 1331/2430] 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 f5527c1a..9d711542 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 1332/2430] 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 0caec38c..90570926 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 826d5217..744695f0 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 294ec678..860dae81 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 1333/2430] 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 cf884b87..7bdd7514 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 1334/2430] 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 2fcaea12..388795d7 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 1335/2430] 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 9d711542..70cdc49e 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 13e23a3f..fe687b06 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 1336/2430] 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 70cdc49e..0128e16e 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 1337/2430] 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 0128e16e..cd0cfe0f 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 1338/2430] 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 cd0cfe0f..c5371f68 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 fe687b06..3a2194e3 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 1339/2430] 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 3a2194e3..129684ad 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 1340/2430] 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 129684ad..78b62b0f 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 1341/2430] 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 c5371f68..2442096c 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 78b62b0f..8987d9b3 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 1342/2430] 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 00000000..59c4fa73 --- /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 1343/2430] 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 8987d9b3..5ad1ef56 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 1344/2430] 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 5ad1ef56..8987d9b3 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 1345/2430] 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 8987d9b3..5ad1ef56 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 1346/2430] 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 5ad1ef56..9439dc69 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 1347/2430] 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 9439dc69..5ad1ef56 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 1348/2430] 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 5ad1ef56..d9a4fb5c 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 1349/2430] 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 00000000..4aefc243 --- /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 1350/2430] 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 d9a4fb5c..ce28f9d0 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 1351/2430] 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 ce28f9d0..e88d2013 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 1352/2430] 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 e88d2013..287c0a70 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 1353/2430] 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 287c0a70..1a0300a4 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 1354/2430] 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 1a0300a4..266ce92e 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 1355/2430] 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 266ce92e..c543d28c 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 1356/2430] 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 c543d28c..9d1fa365 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 1357/2430] 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 9d1fa365..9064cb2a 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 1358/2430] Disabled debug code --- lib/pool.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 9064cb2a..266ce92e 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 1359/2430] 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 2442096c..ceb53325 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 1360/2430] 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 ceb53325..546efa42 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 1361/2430] Remove CORS --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index d209aba5..907e0c1a 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 1362/2430] Remove CORS --- lib/api.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 907e0c1a..a1aa22bf 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 1363/2430] 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 a1aa22bf..907e0c1a 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 1364/2430] Remove CORS --- lib/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 907e0c1a..7a444045 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 1365/2430] 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 7a444045..907e0c1a 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 1366/2430] Remove CORS --- lib/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 907e0c1a..7a444045 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 1367/2430] 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 7a444045..907e0c1a 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 1368/2430] 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 907e0c1a..13ae8066 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 1369/2430] 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 13ae8066..1476701e 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 1370/2430] 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 1476701e..5aece722 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 1371/2430] 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 5aece722..7e445b51 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 1372/2430] Disabled CORS --- lib/api.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/api.js b/lib/api.js index 7e445b51..61aa8bb3 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 1373/2430] 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 61aa8bb3..609ee345 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 1374/2430] Disabled CORS --- lib/api.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/api.js b/lib/api.js index 609ee345..03e510c4 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 1375/2430] More debug --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 955a7ad6..abad5e69 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 1376/2430] 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 abad5e69..7467be7c 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 1377/2430] 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 7467be7c..abad5e69 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 1378/2430] 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 546efa42..7888eb58 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 1379/2430] 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 7888eb58..e5fa07d4 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 1380/2430] 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 e5fa07d4..4996a794 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 1381/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 266ce92e..7870f8ac 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 1382/2430] More debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7870f8ac..66a91e0c 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 1383/2430] 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 66a91e0c..43f0201b 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 1384/2430] Adjust --- lib/api.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/api.js b/lib/api.js index 03e510c4..675b6325 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 1385/2430] Adjust --- lib/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api.js b/lib/api.js index 675b6325..4c8aa9e3 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 1386/2430] Adjust --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 4c8aa9e3..2fd11d1e 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 1387/2430] Adjust --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index 2fd11d1e..1ad33779 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 1388/2430] Adjust --- lib/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api.js b/lib/api.js index 1ad33779..f9d26bc4 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 1389/2430] Adjust --- lib/api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api.js b/lib/api.js index f9d26bc4..4f3b9494 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 1390/2430] Adjust --- lib/api.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/api.js b/lib/api.js index 4f3b9494..7a084a72 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 1391/2430] Adjust --- lib/api.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/api.js b/lib/api.js index 7a084a72..9e83af60 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 1392/2430] Adjust --- lib/api.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/api.js b/lib/api.js index 9e83af60..8e451e71 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 1393/2430] Adjust --- lib/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 8e451e71..9e83af60 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 1394/2430] 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 43f0201b..bd63896e 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 1395/2430] Added IRD/ARQ addresses --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9f33d1bf..39d7e32d 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 1396/2430] 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 abad5e69..062e57cc 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 1397/2430] Added block share dumps --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 062e57cc..5a292505 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 1398/2430] 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 5a292505..bca330c0 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 4996a794..4b6ec081 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 1399/2430] Adjusted dumps --- lib/blockManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index bca330c0..f36852b2 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 1400/2430] Adjusted dumps --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index f36852b2..494c9272 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 1401/2430] Adjusted dumps --- lib/blockManager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 494c9272..f2dbe403 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 1402/2430] 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 f2dbe403..7a52205e 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 1403/2430] 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 7a52205e..d5e0e544 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 1404/2430] 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 00000000..405260ed --- /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 1405/2430] 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 405260ed..7d67e6b5 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 1406/2430] 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 4b6ec081..6f6f14cc 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 1407/2430] 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 6f6f14cc..d3a38f08 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 1408/2430] 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 39d7e32d..c5d6412a 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 03e2d104..952b388c 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 1409/2430] 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 d3a38f08..88277a35 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 bd63896e..4bb88015 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 1410/2430] 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 88277a35..9ae793b7 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 1411/2430] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f6584e2..4b98cefa 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 1412/2430] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b98cefa..55043da9 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 1413/2430] 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 d5e0e544..cce784f4 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 1414/2430] 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 cce784f4..1ade27c2 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 1415/2430] Reduce parallel block dumps --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1ade27c2..a5499e8c 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 1416/2430] Debug --- lib/blockManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index a5499e8c..1822d2da 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 1417/2430] Debug --- lib/blockManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1822d2da..4d93545c 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 1418/2430] Debug --- lib/blockManager.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 4d93545c..9029615e 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 1419/2430] 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 9029615e..a90a9ae0 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 1420/2430] 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 a90a9ae0..a00380f6 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 1421/2430] 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 9ae793b7..72511e45 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 9d36a6d3..fc7a9445 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 1422/2430] Removed debug --- lib/blockManager.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index a00380f6..192d162e 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 1423/2430] Removed debug --- lib/blockManager.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 192d162e..d48c0010 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 1424/2430] 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 e72b0f48..2c3f9af8 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 1425/2430] 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 d48c0010..1def3e10 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 1426/2430] 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 72511e45..58cbb649 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 4bb88015..7bc3a234 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 55043da9..de01a131 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 1427/2430] bug fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 7bc3a234..e4214351 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 1428/2430] 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 c5d6412a..0353cb9f 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 952b388c..1b025154 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 58cbb649..a21c3afa 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 1429/2430] 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 e4214351..babfe2ed 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 1430/2430] Bug fix --- lib/pool.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index babfe2ed..81725aa1 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 1431/2430] Bug fix --- lib/pool.js | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 81725aa1..d7a6c9e7 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 1432/2430] Bug fix --- lib/pool.js | 56 +++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d7a6c9e7..7dd5ac39 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 1433/2430] Bug fix --- lib/pool.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7dd5ac39..39bf9a4a 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 1434/2430] Bug fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 39bf9a4a..388cb5e8 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 1435/2430] Moved to master utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de01a131..a67dfd2c 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 1436/2430] 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 a21c3afa..14ff2db0 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 1437/2430] 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 14ff2db0..3fd2193b 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 a67dfd2c..2b8aba4d 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 1438/2430] 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 388cb5e8..79a582b8 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 1439/2430] 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 3fd2193b..14ff2db0 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 79a582b8..fa2bdeff 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 1440/2430] 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 fa2bdeff..5f61f9eb 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 1441/2430] 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 5f61f9eb..d5193cad 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 1442/2430] 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 d5193cad..c71d4e19 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 1443/2430] 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 c71d4e19..7fec6e5a 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 1444/2430] 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 14ff2db0..7364ddc5 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 2b8aba4d..6f144fff 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 1445/2430] Fixed XTNC support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f144fff..2b8aba4d 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 1446/2430] Fixed XTNC support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b8aba4d..6f144fff 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 1447/2430] 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 7364ddc5..c9bb97a5 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 7fec6e5a..a9357d20 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 1448/2430] 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 c9bb97a5..8e0fd2a4 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 6f144fff..6be72616 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 1449/2430] 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 0353cb9f..0668a461 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 1b025154..3350615e 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 8e0fd2a4..75277145 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 1450/2430] 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 03eb8505..17ef227d 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 1451/2430] 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 17ef227d..8a9887c3 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 1452/2430] 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 8a9887c3..6f7adf39 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 1453/2430] 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 6f7adf39..fd155b9f 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 1454/2430] 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 fd155b9f..ddaf68c0 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 1455/2430] 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 ddaf68c0..82cf1a86 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 1456/2430] 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 82cf1a86..dc6dedd1 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 1457/2430] 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 75277145..8b2b2ea6 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 1458/2430] 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 dc6dedd1..ceecedb8 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 1459/2430] 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 77e526cc..707f0406 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 1460/2430] 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 707f0406..7312da57 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 1461/2430] 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 8b2b2ea6..76ced1fd 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 1462/2430] 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 76ced1fd..cd7c58ae 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 1463/2430] Cache adjust --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 7312da57..d08ca9a1 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 1464/2430] Reverted --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index d08ca9a1..7312da57 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 1465/2430] 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 ceecedb8..3abae628 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 1466/2430] 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 80b95c51..219e206f 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 6be72616..f0df441d 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 1467/2430] 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 3abae628..8ca12b51 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 1468/2430] 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 8ca12b51..476a0a37 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 1469/2430] 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 476a0a37..7f15cdfa 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 1470/2430] 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 7312da57..a3a31a1e 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 1471/2430] 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 7f15cdfa..8ab52d75 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 1472/2430] Added GC --- lib/worker.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index a3a31a1e..2ff4e083 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 1473/2430] More debug --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 2ff4e083..c7f476d1 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 1474/2430] More debug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index c7f476d1..0c45d733 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 1475/2430] More debug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index 0c45d733..fe07cdb1 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 1476/2430] More debug --- lib/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/worker.js b/lib/worker.js index fe07cdb1..21ba9334 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 1477/2430] 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 0668a461..71955481 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 00000000..54335a8e --- /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 21ba9334..48ff7889 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 1478/2430] Separated worker module --- lib/worker.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/worker.js b/lib/worker.js index 48ff7889..e2567b21 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 1479/2430] Separated worker module --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71955481..ac3344c0 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 1480/2430] Separated worker module --- init.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.js b/init.js index 5ad2cc44..b1ec5a06 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 1481/2430] 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 54335a8e..57ac5e45 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 1482/2430] 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 57ac5e45..ab69f6fd 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 1483/2430] 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 ab69f6fd..75667ffb 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 1484/2430] 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 75667ffb..60ae0fb0 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 1485/2430] 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 60ae0fb0..6748ae17 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 1486/2430] 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 6748ae17..19398854 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 1487/2430] 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 19398854..ac293b25 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 1488/2430] 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 ac293b25..2f299e2e 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 1489/2430] 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 2f299e2e..af9c16c7 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 1490/2430] 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 af9c16c7..362a75b6 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 1491/2430] 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 362a75b6..7d6844cf 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 1492/2430] 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 7d6844cf..205faab0 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 1493/2430] 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 205faab0..426192a7 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 1494/2430] 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 426192a7..509d7391 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 1495/2430] Test --- lib/pool_stats.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 509d7391..2e38dcea 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 1496/2430] 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 2e38dcea..8205f4fc 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 1497/2430] Test --- lib/pool_stats.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 8205f4fc..d229af85 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 1498/2430] 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 d229af85..86cd4c94 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 1499/2430] 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 86cd4c94..d4513702 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 1500/2430] 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 d4513702..6e60878b 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 1501/2430] 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 6e60878b..580c708d 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 1502/2430] Fixed block unlocker stuck --- lib/blockManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 1def3e10..733037e3 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 1503/2430] 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 733037e3..0b67f3a8 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 1504/2430] 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 9aac2136..37f60461 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 1505/2430] 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 37f60461..df524725 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 1506/2430] 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 8ab52d75..f0f5090b 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 1507/2430] 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 9e83af60..a0a25ef0 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 f0f5090b..569e737b 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 580c708d..ea589992 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 1508/2430] 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 ea589992..98392f65 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 1509/2430] 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 98392f65..2a622f3b 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 1510/2430] 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 2a622f3b..1cbdac01 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 1511/2430] 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 569e737b..052345d9 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 1512/2430] 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 052345d9..87109bb9 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 1513/2430] 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 1cbdac01..15790b99 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 1514/2430] 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 15790b99..eb7708d5 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 1515/2430] 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 eb7708d5..3908ff30 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 1516/2430] 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 87109bb9..596d6c24 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 1517/2430] 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 596d6c24..06f7d9c4 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 1518/2430] 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 a9357d20..56edf145 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 1519/2430] 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 cd7c58ae..f08b7d01 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 1520/2430] Added XTA coin --- README.md | 1 + deployment/base.sql | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index ac3344c0..15ec0db3 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 3350615e..228ce83e 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 1521/2430] 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 f08b7d01..090f9b89 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 1522/2430] 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 0b67f3a8..59546c24 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 1523/2430] 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 00000000..d2671310 --- /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 1524/2430] 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 15ec0db3..89e120a9 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 228ce83e..360eb338 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 090f9b89..ec82fcd9 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 1525/2430] 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 ec82fcd9..1cc9c6ad 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 1526/2430] Dero support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0df441d..7a13eac4 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 1527/2430] 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 1cc9c6ad..2da44d87 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 1528/2430] 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 2da44d87..2fbc7c6f 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 56edf145..f553afe2 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 1529/2430] 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 2fbc7c6f..04fee261 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 1530/2430] Debug change --- lib/support.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/support.js b/lib/support.js index fc7a9445..0926f4b9 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 1531/2430] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 0926f4b9..8dc7e4b4 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 1532/2430] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 8dc7e4b4..0926f4b9 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 1533/2430] Debug change --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index f553afe2..ad2758e9 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 1534/2430] 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 ad2758e9..a2cb319a 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 0926f4b9..8dc7e4b4 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 1535/2430] Fixed AstroBWT --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a13eac4..1abe2873 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 1536/2430] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 8dc7e4b4..0926f4b9 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 1537/2430] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 0926f4b9..8dc7e4b4 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 1538/2430] Fixed AstroBWT --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1abe2873..2b1cfc7e 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 1539/2430] Debug change --- lib/support.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/support.js b/lib/support.js index 8dc7e4b4..0926f4b9 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 1540/2430] 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 a2cb319a..f553afe2 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 0926f4b9..fc7a9445 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 1541/2430] 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 04fee261..c6fd423f 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 1542/2430] 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 c6fd423f..b4ff6018 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 f553afe2..e261680d 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 1543/2430] 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 e261680d..ffd3bd6c 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 1544/2430] 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 b4ff6018..04fee261 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 1545/2430] 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 ffd3bd6c..2bfd41ff 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 1546/2430] Fixed DERO --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 2bfd41ff..a2ff9348 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 1547/2430] 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 a2ff9348..2bfd41ff 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 1548/2430] 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 2bfd41ff..a2ff9348 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 1549/2430] Fixed AstroBWT --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b1cfc7e..ad0742d3 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 1550/2430] Removed topoheight usage --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index a2ff9348..aa22c495 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 1551/2430] 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 59546c24..0dd34ee4 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 1552/2430] Async lists --- lib/blockManager.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 0dd34ee4..7964d150 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 1553/2430] 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 04fee261..0b84dd5c 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 1554/2430] More debug --- lib/blockManager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 7964d150..75e015a3 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 1555/2430] More debug --- lib/blockManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockManager.js b/lib/blockManager.js index 75e015a3..c5d99789 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 1556/2430] 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 0b84dd5c..623287d8 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 1557/2430] 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 360eb338..b24f25d5 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 3908ff30..d4d3f745 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 1558/2430] 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 d4d3f745..6e35440c 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 1559/2430] 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 6e35440c..f7d3c9f6 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 1560/2430] 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 f7d3c9f6..54db4f65 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 1561/2430] 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 54db4f65..e70af04b 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 1562/2430] 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 e70af04b..87f43469 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 1563/2430] 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 e70af04b..87f43469 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 1564/2430] 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 623287d8..53a81751 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 1565/2430] 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 b24f25d5..33ebaa19 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 53a81751..97638bc9 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 aa22c495..80340ee3 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 1566/2430] 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 97638bc9..ecb24ffa 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 1567/2430] Fix bug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 80340ee3..fa01e4d1 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 1568/2430] 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 ecb24ffa..23a3f3c6 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 1569/2430] 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 23a3f3c6..79304428 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 1570/2430] 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 79304428..23a3f3c6 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 1571/2430] 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 23a3f3c6..89cabab7 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 fa01e4d1..dade6a90 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 1572/2430] 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 89cabab7..dec833d4 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 1573/2430] 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 dec833d4..c1f5336a 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 1574/2430] 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 c1f5336a..441538bd 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 1575/2430] 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 441538bd..b405a533 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 dade6a90..9f0f7610 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 1576/2430] 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 b405a533..74b5da04 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 1577/2430] 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 74b5da04..34e18356 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 1578/2430] 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 34e18356..95b24f4d 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 1579/2430] 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 95b24f4d..4872fd89 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 1580/2430] 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 4872fd89..ee0b0989 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 1581/2430] Debug code --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 9f0f7610..b2b75dfd 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 1582/2430] 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 cf3ea8a5..74703db1 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 ee0b0989..db218494 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 1583/2430] 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 db218494..3a7c1751 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 e857034a..70c382b0 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 1584/2430] 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 3a7c1751..0b276446 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 1585/2430] 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 0b276446..61e00a8c 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 1586/2430] 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 61e00a8c..f551ab89 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 1587/2430] 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 b2b75dfd..75c54957 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 1588/2430] 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 f551ab89..3a8cb5d2 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 1589/2430] 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 3a8cb5d2..5be556fd 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 75c54957..7e745c09 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 1590/2430] 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 7e745c09..11fbde6d 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 1591/2430] 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 00000000..dce9fe99 --- /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 1592/2430] 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 86fcb369..5778a19e 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 1593/2430] 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 11fbde6d..0d3cc955 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 1594/2430] 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 5be556fd..ea17c8bf 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 1595/2430] 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 ea17c8bf..5784b0ce 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 1596/2430] 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 5784b0ce..068187b1 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 0d3cc955..fb7e1981 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 1597/2430] 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 068187b1..e66f6f0b 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 1598/2430] Upgraded async --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad0742d3..a829ab0a 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 1599/2430] 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 e66f6f0b..068187b1 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 1600/2430] 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 068187b1..ca3cba7d 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 1601/2430] 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 ca3cba7d..50d7fe25 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 1602/2430] 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 50d7fe25..9ee9c7fa 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 1603/2430] 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 9ee9c7fa..841459ba 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 1604/2430] 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 841459ba..48bf7bd5 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 1605/2430] Debug --- lib/remote_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 70c382b0..02e7627d 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 1606/2430] 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 02e7627d..172eb8a1 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 1607/2430] Debug --- lib/remote_comms.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/remote_comms.js b/lib/remote_comms.js index 172eb8a1..690b066c 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 1608/2430] 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 48bf7bd5..75b46c1d 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 690b066c..70c382b0 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 a829ab0a..ad0742d3 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 1609/2430] 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 c5d99789..961f34e2 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 75b46c1d..48bf7bd5 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 388795d7..add4d46d 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 70c382b0..c048e673 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 e2567b21..166fcffe 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 ad0742d3..a829ab0a 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 1610/2430] 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 961f34e2..7640a4b3 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 add4d46d..63ce59ae 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 c048e673..faf018bf 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 166fcffe..6d072cea 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 1611/2430] 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 7640a4b3..1d59a207 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 63ce59ae..8209a429 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 1612/2430] 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 1d59a207..6882122d 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 1613/2430] 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 00000000..c643f0c3 --- /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 1614/2430] 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 c643f0c3..485de4e6 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 1615/2430] 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 fb7e1981..aa11f9d1 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 1616/2430] 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 85f57261..97576513 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 1617/2430] 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 06f7d9c4..929dff9a 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 1618/2430] 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 97576513..79240549 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 1619/2430] 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 aa11f9d1..79aecc0d 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 1620/2430] 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 79aecc0d..e5fe0b27 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 1621/2430] 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 e5fe0b27..5d601aa7 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 1622/2430] 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 5d601aa7..4a976b2a 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 1623/2430] 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 4a976b2a..4a47d3ba 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 1624/2430] 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 6d072cea..60868b98 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 1625/2430] 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 60868b98..a9b53f7d 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 1626/2430] 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 a9b53f7d..3882fabe 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 1627/2430] 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 33ebaa19..2b792501 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 929dff9a..40a48b38 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 3882fabe..83ef7406 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 1628/2430] 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 4a47d3ba..6b2b7326 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 1629/2430] 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 40a48b38..ac905e49 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 1630/2430] 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 6882122d..82d492ae 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 1631/2430] Detect orphan DERO blocks --- lib/blockManager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/blockManager.js b/lib/blockManager.js index 82d492ae..d9621478 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 1632/2430] 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 87f43469..78a63604 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 1633/2430] 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 78a63604..f9a0944f 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 1634/2430] 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 f9a0944f..9e1cbc75 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 1635/2430] Updated minimist --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a829ab0a..b24c4400 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 1636/2430] 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 9e1cbc75..b1efa450 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 1637/2430] 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 2b792501..cc9853ec 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 a0a25ef0..57e3558c 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 8209a429..34ce0d1c 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 1638/2430] 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 57e3558c..ccefd314 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 1639/2430] 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 ccefd314..1620dc03 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 1640/2430] 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 00000000..2cc85aca --- /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 1641/2430] Updated API --- lib/api.js | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/lib/api.js b/lib/api.js index 1620dc03..fce8fc68 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 1642/2430] Updated API --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index fce8fc68..78723f55 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 1643/2430] Updated API --- lib/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 78723f55..bd8eb3d3 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 1644/2430] Updated API --- lib/api.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/api.js b/lib/api.js index bd8eb3d3..917282f2 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 1645/2430] Updated API --- lib/api.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/api.js b/lib/api.js index 917282f2..baf3354f 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 1646/2430] Updated API --- lib/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api.js b/lib/api.js index baf3354f..fb6de0ab 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 1647/2430] 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 6b2b7326..e9668af8 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 1648/2430] 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 7bdd7514..1fd1699b 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 1649/2430] 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 1fd1699b..e195ad33 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 00000000..fa4727e1 --- /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 1650/2430] 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 fa4727e1..82dfe2c8 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 1651/2430] Added news endpoint --- lib/api.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/api.js b/lib/api.js index fb6de0ab..48bd06c4 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 1652/2430] 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 82dfe2c8..c1fe4479 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 1653/2430] 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 90570926..1e3884b6 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 744695f0..95d6c3e6 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 860dae81..feed3d2a 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 e195ad33..5bdd156c 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 1654/2430] Update XMR address --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89e120a9..e9e25799 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 1655/2430] Typo fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b24c4400..4e4ebc9e 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 1656/2430] 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 1e3884b6..35620e13 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 95d6c3e6..346b28f4 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 feed3d2a..257410fd 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 5bdd156c..03e386d4 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 1657/2430] 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 e9e25799..8075a2b9 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 cc9853ec..7c332fd8 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 48bf7bd5..b63e8447 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 1658/2430] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e4ebc9e..0ff14b59 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 1659/2430] 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 b63e8447..fb4cac9f 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 1660/2430] 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 fb4cac9f..3dc832fb 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 1661/2430] 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 e9668af8..7e44c48a 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 1662/2430] 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 3dc832fb..5439ec64 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 7e44c48a..ff1f9b99 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 0ff14b59..84b1e963 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 1663/2430] 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 5439ec64..e3471f9f 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 84b1e963..042b920f 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 1664/2430] 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 e3471f9f..46fb1251 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 1665/2430] 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 46fb1251..e0cc77f3 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 1666/2430] Fixed Haven ringct --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 042b920f..2bd3ba72 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 1667/2430] 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 e0cc77f3..aa0a13a9 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 2bd3ba72..e08fecbf 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 1668/2430] 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 aa0a13a9..3cc7ca43 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 1669/2430] 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 3cc7ca43..bfc4544a 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 ff1f9b99..52180443 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 fc7a9445..0f022ad4 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 1670/2430] 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 8075a2b9..2ae7f60e 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 7c332fd8..6ee43ec4 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 bfc4544a..9a3a0562 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 1671/2430] 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 9a3a0562..5b438abe 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 52180443..c7bf99c1 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 1672/2430] 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 5b438abe..2f5aa70f 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 1673/2430] 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 2ae7f60e..ca3f754c 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 6ee43ec4..f86885c9 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 2f5aa70f..58f1333f 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 1674/2430] 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 58f1333f..dc0de8c1 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 1675/2430] 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 dc0de8c1..ec35b6ad 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 1676/2430] 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 c7bf99c1..353df407 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 1677/2430] 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 353df407..61c876d3 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 1678/2430] 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 61c876d3..1260dc6a 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 1679/2430] 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 1260dc6a..07de183c 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 1680/2430] 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 34ce0d1c..0bc20471 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 1681/2430] 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 ec35b6ad..476b9f50 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 e08fecbf..c744db57 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 1682/2430] 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 476b9f50..91ac824a 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 1683/2430] 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 35620e13..48f57cd6 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 346b28f4..44ce587a 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 257410fd..31e9d855 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 03e386d4..0de56b26 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 1684/2430] 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 48f57cd6..b86f78c9 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 44ce587a..c8fa336d 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 31e9d855..41852da4 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 0de56b26..1c2dc120 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 1685/2430] 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 b86f78c9..85254314 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 c8fa336d..00c69c8e 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 41852da4..93982a6c 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 1c2dc120..82db2dfd 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 1686/2430] 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 85254314..fd078ca8 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 00c69c8e..8021d37a 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 93982a6c..b4e585fc 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 82db2dfd..b892a9d4 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 1687/2430] 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 91ac824a..697bbb5f 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 1688/2430] 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 fd078ca8..daddc143 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 8021d37a..527b6be7 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 b4e585fc..b372def4 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 b892a9d4..0f5e1a2d 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 1689/2430] 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 f86885c9..e8c331ad 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 48bd06c4..256ce5eb 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 00000000..819e7bf8 --- /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 1690/2430] 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 697bbb5f..dbb380e5 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 c744db57..25857df9 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 1691/2430] 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 e8c331ad..7c60b839 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 dbb380e5..a3f79135 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 1692/2430] 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 305d8c18..5a5a7a84 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 1693/2430] 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 5a5a7a84..212d7684 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 1694/2430] 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 212d7684..7af22771 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 1695/2430] 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 7af22771..f92a09ed 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 1696/2430] 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 f92a09ed..e772b60b 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 1697/2430] 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 e772b60b..745d013b 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 1698/2430] 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 745d013b..dfd4862d 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 1699/2430] 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 d9621478..a70fb73d 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 1700/2430] 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 a70fb73d..07e628dd 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 1701/2430] 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 a3f79135..abd6c130 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 a5e0167d..fb163d07 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 c2fc7f8f..9e5e4d8d 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 1702/2430] 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 abd6c130..cee5c6d5 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 1703/2430] 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 cee5c6d5..0ddad32a 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 1704/2430] 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 0ddad32a..1f3b42a0 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 1705/2430] 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 1f3b42a0..245cc925 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 1706/2430] 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 245cc925..b1de5991 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 1707/2430] Restored timeout --- lib/support.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/support.js b/lib/support.js index dfd4862d..f2be0fd0 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 1708/2430] 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 fb163d07..27e3f4d4 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 f2be0fd0..537fd4e5 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 1709/2430] 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 27e3f4d4..09a92d25 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 1710/2430] 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 537fd4e5..bbd2cac0 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 1711/2430] 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 bbd2cac0..f0ac68a5 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 1712/2430] 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 256ce5eb..3d4d521e 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 1713/2430] 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 3d4d521e..9d143976 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 1714/2430] 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 b1de5991..635fa607 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 09a92d25..80ca8a39 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 f0ac68a5..b35a55d0 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 25857df9..b4266729 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 1715/2430] Draft implementation of Ravencoin --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 80ca8a39..8b87bcf0 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 1716/2430] 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 635fa607..69fd4626 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 8b87bcf0..9e374e0a 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 1717/2430] 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 9e374e0a..ffbbc4e9 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 1718/2430] 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 69fd4626..df85db69 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 1719/2430] 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 df85db69..5c528508 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 1720/2430] 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 5c528508..7be2d5cd 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 1721/2430] 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 7be2d5cd..1d57c3d8 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 1722/2430] 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 1d57c3d8..94be5478 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 1723/2430] 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 ca3f754c..ab073868 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 7c60b839..06db036d 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 94be5478..08430c61 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 ef665435..8cba5656 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 b35a55d0..119e5f2b 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 1724/2430] 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 119e5f2b..53f6a41f 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 1725/2430] 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 08430c61..564de405 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 1726/2430] 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 564de405..e27e7853 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 1727/2430] Draft implementation of Ravencoin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4266729..adea3dcb 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 1728/2430] 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 e27e7853..8f56e74e 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 1729/2430] 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 8f56e74e..f3fb3fb6 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 1730/2430] 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 f3fb3fb6..7f39d361 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 1731/2430] 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 7f39d361..3f02a874 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 1732/2430] 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 3f02a874..0f72ad5c 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 1733/2430] 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 0f72ad5c..6d4489e7 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 1734/2430] 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 6d4489e7..f91e8d50 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 1735/2430] 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 f91e8d50..d6373cd2 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 1736/2430] 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 d6373cd2..7f2b34da 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 1737/2430] 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 7f2b34da..2268244e 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 1738/2430] 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 2268244e..8c2855d8 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 ffbbc4e9..a73341ce 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 1739/2430] 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 8c2855d8..34a38027 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 a73341ce..504b764a 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 adea3dcb..88f41545 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 1740/2430] 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 504b764a..91416a76 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 1741/2430] 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 91416a76..0031cf7a 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 1742/2430] 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 0031cf7a..351754ae 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 1743/2430] 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 351754ae..7e5d30f0 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 1744/2430] 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 7e5d30f0..065904e9 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 1745/2430] 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 34a38027..b86d090b 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 065904e9..7dda0157 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 1746/2430] 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 7dda0157..9e5d80ac 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 1747/2430] 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 9e5d80ac..31e8dbc1 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 1748/2430] 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 31e8dbc1..6a97b635 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 1749/2430] 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 6a97b635..1ff4dde2 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 1750/2430] 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 1ff4dde2..b303751d 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 1751/2430] 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 b303751d..77358043 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 1752/2430] 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 77358043..bfff7fe8 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 1753/2430] 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 bfff7fe8..08428f17 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 1754/2430] 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 08428f17..bfff7fe8 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 1755/2430] 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 bfff7fe8..53b8b0a7 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 1756/2430] 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 53b8b0a7..b303751d 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 1757/2430] 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 b303751d..bfff7fe8 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 1758/2430] 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 bfff7fe8..ba4f4a3d 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 1759/2430] Diff debug --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index ba4f4a3d..d6c5654b 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 1760/2430] 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 d6c5654b..4c7d8342 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 1761/2430] 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 83ef7406..4e36bb37 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 1762/2430] 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 219e206f..f072ffed 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 ac905e49..1fd2759f 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 1763/2430] Update LMDB used --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88f41545..f5e20cb0 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 1764/2430] Update LMDB used --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5e20cb0..f10c345d 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 1765/2430] Update LMDB used --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f10c345d..82d1786b 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 1766/2430] 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 4c7d8342..1015a327 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 1767/2430] 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 b86d090b..0196e70d 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 1015a327..58045e38 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 1768/2430] 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 0196e70d..b86d090b 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 58045e38..69ba4308 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 1769/2430] 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 69ba4308..2abd4e3c 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 1770/2430] 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 2abd4e3c..69ba4308 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 1771/2430] 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 69ba4308..0e7d69b8 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 1772/2430] 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 0e7d69b8..949d3617 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 1773/2430] 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 949d3617..dc5a0aff 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 1774/2430] 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 dc5a0aff..83d640b4 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 1775/2430] 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 83d640b4..80a82aa8 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 1776/2430] 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 80a82aa8..83d640b4 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 1777/2430] 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 83d640b4..42bbb695 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 1778/2430] 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 42bbb695..6b300f50 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 1779/2430] 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 b86d090b..d830055f 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 1780/2430] 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 d830055f..882bdd73 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 6b300f50..d9f67d97 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 1781/2430] 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 882bdd73..92a5164b 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 1782/2430] 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 92a5164b..16a1945d 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 1783/2430] 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 16a1945d..882bdd73 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 82d1786b..9150cf45 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 1784/2430] 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 d9f67d97..e88175cb 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 1785/2430] 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 882bdd73..432dc71d 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 1786/2430] Draft implementation of Ravencoin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9150cf45..f2a8309b 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 1787/2430] 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 432dc71d..49f59e20 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 1788/2430] 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 49f59e20..17c7e348 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 1789/2430] 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 17c7e348..4ffcfc92 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 1790/2430] 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 e88175cb..8645e005 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 1791/2430] 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 8645e005..7ba79008 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 1792/2430] 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 4ffcfc92..760b9e6e 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 1793/2430] 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 7ba79008..d694b583 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 1794/2430] 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 d694b583..602f7c9a 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 1795/2430] 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 602f7c9a..f99827e1 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 1796/2430] 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 f99827e1..602f7c9a 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 1797/2430] 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 602f7c9a..f99827e1 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 1798/2430] Removed debug stuff --- lib/pool.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f99827e1..52943aba 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 1799/2430] 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 760b9e6e..b272cd8e 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 52943aba..d887e372 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 1800/2430] 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 d887e372..9cd0802a 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 1801/2430] Fixed for invalid shares --- lib/pool.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 9cd0802a..86408c7f 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 1802/2430] 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 b272cd8e..8c1efa7a 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 86408c7f..31bb8787 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 1803/2430] Draft implementation of Ravencoin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f2a8309b..5f0986cf 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 1804/2430] 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 8c1efa7a..69f56845 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 31bb8787..f0f0c0e9 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 1805/2430] 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 f0f0c0e9..f5d781f5 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 1806/2430] Added more miner debug --- lib/pool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index f5d781f5..5d0ef6fd 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 1807/2430] Fixed Raven TRM --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 5d0ef6fd..db9b8a4e 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 1808/2430] 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 db9b8a4e..6c58355d 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 1809/2430] Extra debug --- lib/pool.js | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6c58355d..1b76ccd8 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 1810/2430] Extra debug --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 1b76ccd8..0754e82d 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 1811/2430] Extra debug --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 0754e82d..82bd85c3 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 1812/2430] Fixed initial diff setup --- lib/pool.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 82bd85c3..69a83350 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 1813/2430] 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 daddc143..b62b4258 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 527b6be7..4efab595 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 b372def4..fe6ece80 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 0f5e1a2d..5de0c592 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 1814/2430] 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 69f56845..25749c7a 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 69a83350..7ce87634 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 1815/2430] Optimize stuff --- lib/pool.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7ce87634..b57c35f7 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 1816/2430] 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 b57c35f7..171e93f4 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 1817/2430] 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 171e93f4..f71dc00d 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 1818/2430] 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 f71dc00d..171e93f4 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 1819/2430] 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 171e93f4..3c0284a9 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 1820/2430] 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 3c0284a9..044e889c 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 1821/2430] 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 044e889c..fb3b1853 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 1822/2430] 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 fb3b1853..be26de55 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 1823/2430] 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 be26de55..7561215a 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 1824/2430] 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 65370382..f4079368 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 7561215a..9b7d7adf 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 1825/2430] 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 9d143976..7af69f90 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 f4079368..52e71e23 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 9b7d7adf..7dd8a8f1 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 1826/2430] 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 52e71e23..edca40a0 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 1827/2430] 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 07e628dd..bff4ddaa 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 1fd2759f..e5312723 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 e1efc970..69747fd4 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 4e36bb37..4ab04173 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 1828/2430] 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 4ab04173..8db41e8a 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 1829/2430] 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 edca40a0..7f5fbc6c 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 7dd8a8f1..07cc7b08 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 1830/2430] 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 7f5fbc6c..e72db63f 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 1831/2430] Fixed extranonce location --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f0986cf..363875e4 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 1832/2430] 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 07cc7b08..250403e8 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 1833/2430] 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 250403e8..3824f05e 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 1834/2430] 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 3824f05e..efdebb2c 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 1835/2430] 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 53f6a41f..ee506ff3 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 363875e4..7920aba9 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 1836/2430] 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 b62b4258..2f3f59fe 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 4efab595..4fe56050 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 fe6ece80..654553f5 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 5de0c592..1cac9b4f 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 1837/2430] constructNewRavenBlob fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7920aba9..00ddde71 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 1838/2430] 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 2f3f59fe..6d405254 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 4fe56050..d6447749 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 654553f5..692634cb 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 1cac9b4f..92b9b5e8 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 1839/2430] 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 efdebb2c..94e60e40 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 1840/2430] 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 25749c7a..87ca0940 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 00ddde71..baa238c5 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 1841/2430] 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 baa238c5..89387714 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 1842/2430] 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 89387714..e7a0b083 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 1843/2430] 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 e7a0b083..84083843 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 1844/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 84083843..b37d8106 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 1845/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b37d8106..472f364f 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 1846/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 472f364f..b57f2980 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 1847/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b57f2980..3bcf9335 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 1848/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3bcf9335..97e3e99f 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 1849/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 97e3e99f..11861804 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 1850/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 11861804..2f7b28bf 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 1851/2430] Fixed raven block processing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f7b28bf..9ea748b0 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 1852/2430] 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 6d405254..bcce4def 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 d6447749..645ff880 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 692634cb..55103875 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 92b9b5e8..18443b2e 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 1853/2430] 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 87ca0940..375110f9 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 1854/2430] 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 375110f9..afa6eaf1 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 94e60e40..4385edee 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 1855/2430] 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 cb24f186..e19b27fe 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 1856/2430] 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 bff4ddaa..d4478330 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 1857/2430] 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 4385edee..62e7e0ec 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 1858/2430] Removed extra debug output --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ea748b0..7209e79b 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 1859/2430] 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 bcce4def..812d5fbd 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 645ff880..90318cf2 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 55103875..bb220444 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 18443b2e..c58a8318 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 1860/2430] 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 62e7e0ec..12298171 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 1861/2430] 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 812d5fbd..962df87e 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 90318cf2..952fa809 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 bb220444..a4562d8a 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 c58a8318..e77085de 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 1862/2430] Typo fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 12298171..da57cd62 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 1863/2430] 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 d4478330..aca2833d 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 1864/2430] 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 00000000..d884296e --- /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 1865/2430] 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 7af69f90..a7bed18d 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 7209e79b..ede2f1ed 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 1866/2430] 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 a7bed18d..abf423e9 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 1867/2430] Ethash support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ede2f1ed..161c9419 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 1868/2430] 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 afa6eaf1..7fd631e4 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 1869/2430] 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 7fd631e4..48634cd8 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 1870/2430] 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 48634cd8..ee7e5ce4 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 1871/2430] 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 ee7e5ce4..00f1f275 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 1872/2430] 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 00f1f275..91858903 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 1873/2430] 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 91858903..afa75f1d 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 1874/2430] 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 afa75f1d..204e024d 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 1875/2430] 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 204e024d..ac394e38 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 1876/2430] 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 ac394e38..91a31c4b 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 1877/2430] 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 91a31c4b..ddab1e5b 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 1878/2430] 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 ddab1e5b..93115b88 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 1879/2430] 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 93115b88..697040eb 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 1880/2430] 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 697040eb..54efdfac 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 1881/2430] 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 54efdfac..e685cfc0 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 1882/2430] 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 e685cfc0..1adab2c0 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 1883/2430] 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 1adab2c0..fc5feb55 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 1884/2430] 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 fc5feb55..3cba55f0 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 1885/2430] 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 3cba55f0..ea782bc1 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 1886/2430] 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 ea782bc1..f88cc76d 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 da57cd62..d18d34fe 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 1887/2430] 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 d18d34fe..5a8e5ab7 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 1888/2430] 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 06db036d..866fad98 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 5a8e5ab7..e64672ab 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 1889/2430] 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 e64672ab..83226288 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 1890/2430] 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 83226288..48f81479 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 1891/2430] 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 48f81479..4fdfaff3 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 1892/2430] 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 f88cc76d..7193a2d4 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 4fdfaff3..56fd5fef 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 161c9419..b6955a30 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 1893/2430] Eth draft support --- deployment/base.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 866fad98..597046bd 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 1894/2430] 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 7193a2d4..32c6a6db 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 b6955a30..2214f650 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 1895/2430] Eth draft support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2214f650..2a77e70a 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 1896/2430] 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 d2671310..0901c87d 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 1897/2430] 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 2c3f9af8..19b8b57a 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 0901c87d..18cfe3a7 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 1898/2430] 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 32c6a6db..ed76fca5 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 56fd5fef..88943504 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 2a77e70a..b4700a85 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 1899/2430] 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 ed76fca5..77c02e3d 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 1900/2430] Eth draft support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b4700a85..98e6e8b1 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 1901/2430] 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 88943504..69a51ce7 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 1902/2430] 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 69a51ce7..b29fb0b4 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 1903/2430] 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 b29fb0b4..b8bf59c6 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 1904/2430] 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 b8bf59c6..7320f2c7 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 1905/2430] 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 7320f2c7..1f89c4fe 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 1906/2430] 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 1f89c4fe..19f3cd0f 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 1907/2430] 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 19f3cd0f..a44be744 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 1908/2430] 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 a44be744..e8d7037a 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 1909/2430] 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 e8d7037a..8bdd6549 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 1910/2430] 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 8bdd6549..fa991738 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 1911/2430] 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 fa991738..8091cb40 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 1912/2430] 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 8091cb40..9d35a959 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 8cba5656..917d9452 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 1913/2430] 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 597046bd..0f1f2e88 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 9d35a959..bbb754b3 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 1914/2430] 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 bbb754b3..fe72ccde 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 1915/2430] 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 fe72ccde..f9da872b 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 1916/2430] 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 f9da872b..4fd26dc6 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 1917/2430] 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 4fd26dc6..cc6b9776 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 1918/2430] 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 cc6b9776..4d5dd503 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 1919/2430] 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 4d5dd503..82f4b6c7 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 1920/2430] 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 82f4b6c7..13e36ad1 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 1921/2430] 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 13e36ad1..33c37189 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 1922/2430] 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 abf423e9..7af69f90 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 98e6e8b1..272b605a 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 1923/2430] 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 33c37189..4a12a93e 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 1924/2430] 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 4a12a93e..825c71e8 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 1925/2430] 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 825c71e8..87d1f9cb 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 1926/2430] 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 77c02e3d..af266654 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 87d1f9cb..738f05e8 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 1927/2430] 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 738f05e8..29472cd9 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 1928/2430] 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 29472cd9..41cf6936 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 1929/2430] 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 41cf6936..2ef47cc5 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 1930/2430] 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 2ef47cc5..de65e5dc 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 1931/2430] 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 de65e5dc..f8611a41 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 1932/2430] 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 f8611a41..c8a9a709 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 1933/2430] Removed =0 --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index 0f1f2e88..597046bd 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 1934/2430] Added extra wallet debug --- lib/pool.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index c8a9a709..a7b5733f 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 1935/2430] 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 a7b5733f..0fa5d875 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 1936/2430] 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 aca2833d..71237810 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 af266654..b00b21e5 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 1937/2430] 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 b00b21e5..ad926f28 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 1938/2430] 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 ad926f28..21dd448b 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 1939/2430] 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 21dd448b..132401c1 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 1940/2430] 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 132401c1..2183f1ea 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 1941/2430] 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 962df87e..857d3977 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 1942/2430] readme updates --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index ab073868..eb5e2b2f 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 1943/2430] 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 857d3977..1ff35f8f 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 1944/2430] 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 0fa5d875..aa6f707d 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 1945/2430] 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 597046bd..88aa41bd 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 917d9452..211c0709 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 1946/2430] 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 00000000..10cbbf61 --- /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 1947/2430] 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 10cbbf61..6fc04636 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 1948/2430] 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 6fc04636..c1162a20 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 1949/2430] 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 c1162a20..6be4a892 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 1950/2430] 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 aa6f707d..862bcc42 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 1951/2430] Improved ETH extranonce handling --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 862bcc42..ad5211cc 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 1952/2430] 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 ad5211cc..f308e34d 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 1953/2430] Improved ETH extranonce handling --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f308e34d..0687614c 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 1954/2430] 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 0687614c..b09f1dd4 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 1955/2430] 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 88aa41bd..26aa1ae3 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 b09f1dd4..fc1da174 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 1956/2430] 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 7af69f90..f2436463 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 1957/2430] 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 f2436463..a81ee334 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 1958/2430] 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 e5312723..419bee6d 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 1959/2430] 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 2183f1ea..b84a3eeb 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 1960/2430] 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 b84a3eeb..eaf4f359 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 1961/2430] 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 eaf4f359..53751f64 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 1962/2430] 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 26aa1ae3..6da30e9f 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 71237810..eb7db90e 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 1963/2430] 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 eb7db90e..4e51bad5 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 1964/2430] 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 6da30e9f..6b83fd4c 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 1965/2430] 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 6b83fd4c..59637df2 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 4e51bad5..24d7eef7 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 1966/2430] 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 d3630fdd..0498a4d5 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 1967/2430] 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 419bee6d..b4b052d1 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 1968/2430] 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 24d7eef7..a19a8e19 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 1969/2430] 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 a19a8e19..240cf11e 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 1970/2430] 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 240cf11e..e463418b 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 1971/2430] 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 e463418b..805b4b5d 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 1972/2430] 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 805b4b5d..be736c39 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 1973/2430] 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 be736c39..cc30867f 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 1974/2430] 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 cc30867f..e10b9360 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 1975/2430] 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 e10b9360..b646704a 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 1976/2430] 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 b646704a..c00dfdf1 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 1977/2430] Added block_payments api --- lib/api.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/api.js b/lib/api.js index a81ee334..8ce9315c 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 1978/2430] 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 8ce9315c..ae1118e6 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 1979/2430] 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 ae1118e6..e13aebbb 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 1980/2430] 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 e13aebbb..630524b2 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 1981/2430] 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 630524b2..ec55a528 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 1982/2430] 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 ec55a528..b5d406d2 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 1983/2430] 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 59637df2..67c71c9c 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 b5d406d2..4a6ee092 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 c00dfdf1..2d34f7c8 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 1984/2430] 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 67c71c9c..cdbbf153 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 2d34f7c8..5f9b960a 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 1985/2430] 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 5f9b960a..c4a4a1ba 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 1986/2430] 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 c4a4a1ba..4905079e 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 1987/2430] 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 4905079e..c5f0c920 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 1988/2430] 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 c5f0c920..0ec8faca 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 1989/2430] 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 0ec8faca..cf2c3013 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 1990/2430] 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 00000000..03173321 --- /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 4c6bbee5..e2f649b7 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 1991/2430] 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 cf2c3013..31af50ae 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 03173321..73bc1853 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 1992/2430] 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 b4b052d1..36f6cfd9 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 1993/2430] 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 36f6cfd9..4b03b1fb 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 1994/2430] 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 4b03b1fb..77cf3773 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 1995/2430] 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 77cf3773..1b31c37d 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 1996/2430] 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 4a6ee092..12cd18be 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 1997/2430] Fixed --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index cdbbf153..9169a483 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 1998/2430] 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 df524725..0beeb274 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 1999/2430] 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 0beeb274..85db21c1 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 2000/2430] 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 85db21c1..1c559cc8 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 2001/2430] 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 31af50ae..bbbeb2c6 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 fc1da174..4d109b41 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 2002/2430] 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 53751f64..ba58b2af 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 4d109b41..d4f767e0 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 2003/2430] 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 ba58b2af..6476dfcf 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 2004/2430] 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 6476dfcf..6be341fa 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 2005/2430] 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 6be341fa..ba58b2af 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 2006/2430] 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 ba58b2af..8af89ecf 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 2007/2430] 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 8af89ecf..ba58b2af 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 2008/2430] 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 ba58b2af..6863028a 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 2009/2430] 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 6863028a..294a4120 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 d4f767e0..9934eae1 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 2010/2430] 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 294a4120..19a2173e 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 2011/2430] 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 19a2173e..5f6991eb 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 2012/2430] 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 5f6991eb..294a4120 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 2013/2430] 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 294a4120..8314e4c4 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 2014/2430] 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 8314e4c4..2288a14f 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 2015/2430] 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 9934eae1..086f4259 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 2016/2430] 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 2288a14f..36662d4d 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 2017/2430] 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 36662d4d..db188e90 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 2018/2430] 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 db188e90..25b80bbb 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 2019/2430] 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 25b80bbb..61a2f66e 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 2020/2430] 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 61a2f66e..b61c6ffe 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 2021/2430] 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 b61c6ffe..eed9dc24 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 2022/2430] 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 eed9dc24..fce997e8 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 2023/2430] 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 fce997e8..c646c2cd 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 2024/2430] 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 e2f649b7..654d0074 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 2025/2430] 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 654d0074..ba295e0a 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 2026/2430] 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 c646c2cd..5a567999 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 2027/2430] 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 5a567999..9ddfa999 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 2028/2430] 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 9ddfa999..e6de4155 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 2029/2430] 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 e6de4155..5e928f01 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 2030/2430] 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 086f4259..d4e7fd6e 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 2031/2430] 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 d4e7fd6e..70e506a0 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 2032/2430] 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 70e506a0..3b77ed8e 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 2033/2430] 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 3b77ed8e..cf227692 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 2034/2430] 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 1ff35f8f..a3d81340 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 2035/2430] 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 952fa809..f90cfa26 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 2036/2430] 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 f90cfa26..fdb551d8 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 2037/2430] 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 fdb551d8..5d21be7a 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 2038/2430] 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 9169a483..1ce18cda 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 2039/2430] 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 bbbeb2c6..e7195170 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 2040/2430] 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 1ce18cda..f8b8b702 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 9352fcfe..5f075a99 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 a3d81340..429cdd68 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 2041/2430] Fixed XNP diff --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index cf227692..7dbd0ab3 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 2042/2430] 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 eb5e2b2f..f64df660 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 f8b8b702..7592b04a 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 7dbd0ab3..60d736f9 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 2043/2430] Fixed type --- deployment/base.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 7592b04a..b7a1906c 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 2044/2430] 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 b7a1906c..561a8707 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 60d736f9..b7ad8773 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 2045/2430] Adjusted diffs --- deployment/base.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 561a8707..bc2358ec 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 2046/2430] 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 00000000..7846e21b --- /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 2047/2430] 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 5e928f01..480e42be 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 2048/2430] 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 b7ad8773..560825e6 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 2049/2430] 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 560825e6..20068dbd 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 2050/2430] 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 69747fd4..ab9cafb6 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 2051/2430] 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 12cd18be..75913646 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 2052/2430] 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 f64df660..ede17ba8 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 429cdd68..904f3586 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 5d21be7a..c1d93847 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 a4562d8a..0a0503c1 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 e77085de..e4a3f83b 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 20068dbd..85cd1465 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 2053/2430] 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 480e42be..1f0d5554 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 2054/2430] 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 1f0d5554..05736496 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 2055/2430] 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 05736496..2f654851 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 2056/2430] 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 2f654851..aec9187e 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 2057/2430] 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 aec9187e..39fcf027 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 2058/2430] 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 39fcf027..51240a53 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 2059/2430] 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 8db41e8a..29beb534 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 2060/2430] 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 29beb534..de8a64c9 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 2061/2430] 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 51240a53..a07f82c9 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 85cd1465..af0b28ff 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 de8a64c9..2e971514 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 2062/2430] 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 bc2358ec..c4d4b797 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 af0b28ff..41c2d1ec 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 2063/2430] 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 2e971514..853a197d 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 2064/2430] 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 853a197d..56061d6e 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 2065/2430] 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 56061d6e..bafdb1d7 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 2066/2430] 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 bafdb1d7..faab83e7 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 2067/2430] 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 faab83e7..2fc7f65b 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 2068/2430] 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 2fc7f65b..f98e5a45 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 2069/2430] 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 f98e5a45..f6f24f09 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 2070/2430] 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 f6f24f09..78e0a2ab 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 2071/2430] 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 78e0a2ab..faf94908 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 2072/2430] 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 41c2d1ec..52d3b229 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 2073/2430] 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 c4d4b797..6f828687 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 52d3b229..c270648a 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 2074/2430] 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 c270648a..15fa8be1 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 2075/2430] Updated utils version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 272b605a..a44e32c1 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 2076/2430] 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 1b31c37d..f40c3232 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 faf94908..f76bf538 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 2077/2430] 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 f76bf538..d86104fa 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 2078/2430] 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 f40c3232..bc3003de 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 d86104fa..30460415 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 2079/2430] 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 30460415..a2c4614b 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 2080/2430] 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 a2c4614b..484db5f3 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 2081/2430] 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 484db5f3..f635247a 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 2082/2430] 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 f635247a..e7e24408 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 2083/2430] 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 e7e24408..adce01a0 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 2084/2430] 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 adce01a0..28283752 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 2085/2430] 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 28283752..cbb516e8 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 2086/2430] 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 cbb516e8..d22443ef 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 2087/2430] 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 d22443ef..1825565b 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 2088/2430] Worker script debug --- lib/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/worker.js b/lib/worker.js index 1825565b..a1e87658 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 2089/2430] 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 15fa8be1..bf16f0b5 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 a1e87658..fb4accdf 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 2090/2430] 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 fb4accdf..47385c08 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 2091/2430] 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 47385c08..14ddddaa 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 2092/2430] 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 e7195170..0fd1b6c7 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 bc3003de..6a96ca40 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 2093/2430] 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 6a96ca40..d4b21d09 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 2094/2430] 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 a07f82c9..72079244 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 2095/2430] 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 d4b21d09..143f1380 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 2096/2430] 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 00000000..49d690f2 --- /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 2097/2430] 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 49d690f2..a9968919 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 2098/2430] 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 a9968919..0e6dc6fc 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 2099/2430] 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 0e6dc6fc..d3b660f9 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 2100/2430] 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 d3b660f9..8294641e 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 2101/2430] 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 00000000..c34084c7 --- /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 2102/2430] 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 c34084c7..d10279d5 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 2103/2430] 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 d10279d5..072acf42 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 2104/2430] 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 74703db1..7c070264 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 bf16f0b5..b12f3823 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 2105/2430] Added extra verify host --- deployment/base.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/base.sql b/deployment/base.sql index 6f828687..2d7c5e03 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 2106/2430] 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 e72db63f..4accb175 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 2107/2430] 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 4accb175..e72db63f 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 2108/2430] 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 e72db63f..cc1c1ef5 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 2109/2430] 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 ede17ba8..2de8c2a4 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 2d7c5e03..5de34f49 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 72079244..3bbd1e5b 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 2110/2430] 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 3bbd1e5b..5e66e8e2 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 2111/2430] 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 0fd1b6c7..121079c8 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 2112/2430] Added block payment grouping --- deployment/base.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/base.sql b/deployment/base.sql index 5de34f49..142d87b8 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 2113/2430] 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 00000000..754f6cc3 --- /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 2114/2430] 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 754f6cc3..6607680a 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 2115/2430] 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 6607680a..9ab77bc6 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 2116/2430] 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 9ab77bc6..5a7ba72d 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 2117/2430] 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 5a7ba72d..64c12d3b 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 2118/2430] 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 121079c8..210c4ec5 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 2119/2430] 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 210c4ec5..9065f0a2 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 2120/2430] 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 9065f0a2..26c03087 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 2121/2430] 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 26c03087..77dbad0c 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 2122/2430] 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 77dbad0c..9c46a4a8 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 2123/2430] 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 9c46a4a8..26c03087 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 2124/2430] 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 5e66e8e2..112dc83c 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 143f1380..daa9bc24 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 2125/2430] 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 daa9bc24..b6f1f934 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 2126/2430] 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 b6f1f934..361d6181 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 2127/2430] 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 26c03087..9dfd77fe 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 2128/2430] 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 9dfd77fe..6473d671 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 2129/2430] 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 6473d671..9586d23a 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 2130/2430] 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 2de8c2a4..133a4b91 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 142d87b8..945811e7 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 904f3586..4de6a045 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 c1d93847..ed1d8501 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 0a0503c1..af87093f 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 75913646..b4e3c5d5 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 112dc83c..4b333c8c 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 b12f3823..105b31c9 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 a44e32c1..0390243c 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 2131/2430] 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 4b333c8c..87f8ccdb 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 2132/2430] 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 105b31c9..37b00c3a 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 2133/2430] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0390243c..6fafa76a 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 2134/2430] 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 ba295e0a..4bcba363 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 2135/2430] 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 cc1c1ef5..18f9b8e1 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 361d6181..3cce2376 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 37b00c3a..8d005e16 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 2136/2430] 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 3cce2376..5fb90ef7 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 2137/2430] 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 87f8ccdb..a2f499ee 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 2138/2430] 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 a2f499ee..e88c0bcb 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 2139/2430] Fixed install --- deployment/leaf.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index af87093f..1b6102a4 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 2140/2430] 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 e88c0bcb..4f918a58 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 8d005e16..94d19e5f 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 6fafa76a..0d93bc36 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 2141/2430] 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 94d19e5f..9e77e7a8 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 2142/2430] 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 9e77e7a8..c8b02cad 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 2143/2430] 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 c8b02cad..8435fdc8 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 2144/2430] 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 8435fdc8..d59110ab 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 2145/2430] 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 4f918a58..2e130bd4 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 d59110ab..1bfb2de6 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 2146/2430] 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 2e130bd4..fb24be31 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 2147/2430] 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 1bfb2de6..d3438287 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 2148/2430] 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 d3438287..f49a6c7e 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 2149/2430] 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 f49a6c7e..8a320c12 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 2150/2430] 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 8a320c12..86848e04 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 2151/2430] 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 fb24be31..9798dfac 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 86848e04..a17c0a79 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 ee506ff3..222c896f 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 2152/2430] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d93bc36..9eaca406 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 2153/2430] npm audit --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 9eaca406..f88b8747 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 2154/2430] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f88b8747..667af5ef 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 2155/2430] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 667af5ef..2a59013a 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 2156/2430] npm audit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2a59013a..11b523ff 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 2157/2430] 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 a17c0a79..86848e04 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 2158/2430] 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 86848e04..49d9a212 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 2159/2430] 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 3d7bb25f..bbd60b1f 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 2160/2430] 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 9798dfac..e1570503 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 2161/2430] 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 49d9a212..bbdbd48f 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 2162/2430] 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 bbdbd48f..8d41d30a 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 2163/2430] 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 8d41d30a..95fa6339 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 2164/2430] 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 8294641e..427877c5 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 2165/2430] 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 427877c5..108c96dc 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 2166/2430] More ERG debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index 95fa6339..0bc6e809 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 2167/2430] 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 0bc6e809..bbe18437 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 2168/2430] 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 e1570503..bec9db58 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 bbe18437..ff545f36 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 11b523ff..da02265e 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 2169/2430] 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 bec9db58..b28c2519 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 2170/2430] 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 b28c2519..c633807f 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 2171/2430] 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 c633807f..5e3f8114 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 2172/2430] 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 5e3f8114..6476a502 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 2173/2430] 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 6476a502..226ad75f 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 2174/2430] 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 226ad75f..1b3db740 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 2175/2430] 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 945811e7..d01ae6a0 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 222c896f..e6580547 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 2176/2430] 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 d01ae6a0..c9575956 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 5fb90ef7..43148f7d 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 2177/2430] Fixed typo --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index c9575956..9b4b7ecd 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 2178/2430] 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 4de6a045..99e5aadf 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 ed1d8501..0c55e701 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 1b6102a4..864e1bb2 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 e4a3f83b..2c6a1720 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 2179/2430] 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 99e5aadf..9bfa07da 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 0c55e701..98e6aaab 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 864e1bb2..792cf895 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 2c6a1720..5068725c 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 2180/2430] 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 0498a4d5..a4eb56bd 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 2181/2430] 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 a4eb56bd..43847f02 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 2182/2430] 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 43847f02..c8a2cb27 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 2183/2430] 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 c8a2cb27..c6bdcfb2 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 2184/2430] 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 ff545f36..9162ca83 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 2185/2430] Fixed N calc for ERG --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da02265e..fda03c0b 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 2186/2430] Fixed N calc for ERG --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fda03c0b..9dc9df36 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 2187/2430] Up utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9dc9df36..e54fe8cc 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 2188/2430] 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 1b3db740..a3984666 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 9162ca83..02713d9f 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 e54fe8cc..708a57ad 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 2189/2430] GR support --- deployment/base.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 9b4b7ecd..b48f0470 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 2190/2430] 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 133a4b91..5cc0712e 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 14ddddaa..f8c03058 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 2191/2430] 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 a3984666..8de1989d 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 2192/2430] 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 8de1989d..ee31e983 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 2193/2430] 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 ee31e983..4bd3f8df 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 2194/2430] 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 4bd3f8df..f1794ba6 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 2195/2430] 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 f1794ba6..72443de3 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 2196/2430] 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 72443de3..1e42ccf0 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 2197/2430] 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 1e42ccf0..3c88fd7c 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 2198/2430] 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 3c88fd7c..b15656c7 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 2199/2430] 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 b15656c7..d07fa06a 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 2200/2430] 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 d07fa06a..ad449adf 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 2201/2430] 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 ad449adf..d8e83977 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 2202/2430] 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 d8e83977..dae94b9d 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 2203/2430] Blob fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 708a57ad..c063d216 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 2204/2430] 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 dae94b9d..51dbd8b2 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 02713d9f..6ff58ab2 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 c063d216..05819584 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 2205/2430] 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 108c96dc..fafe2f9a 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 2206/2430] 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 6ff58ab2..0f1bbc0e 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 2207/2430] 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 51dbd8b2..48cc187a 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 0f1bbc0e..2599cc35 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 c48db0dd3fda536af3fc457e021d056208f79b2e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 11 Jan 2022 15:22:12 +0000 Subject: [PATCH 2208/2430] Corrected RVN block 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 48cc187a..55113f15 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -400,7 +400,7 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - body.result.reward = (port == 8766 ? 5000 : 3750) * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 + body.result.reward = (port == 8766 ? 2500 : 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); }); From a100cd90d3b7ad4afb5150b298a1124ce1479da4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 27 Jan 2022 23:01:43 +0000 Subject: [PATCH 2209/2430] Added worker limit --- config_example.json | 1 + lib/pool.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config_example.json b/config_example.json index 7c070264..78d1944c 100644 --- a/config_example.json +++ b/config_example.json @@ -1,6 +1,7 @@ { "pool_id": 0, "eth_pool_support": 1, + "worker_num": 0, "bind_ip": "127.0.0.1", "hostname": "testpool.com", "db_storage_path": "CHANGEME", diff --git a/lib/pool.js b/lib/pool.js index 2599cc35..f979b52d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2327,7 +2327,7 @@ function getUniqueWorkerID(cb) { } if (cluster.isMaster) { - const numWorkers = require('os').cpus().length; + const numWorkers = global.config.worker_num ? global.config.worker_num : require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { minerCount[i] = []; global.config.ports.forEach(function (portData) { From 2aee3164a1114326ad5aa2b9d09e84bbedc78a19 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 Feb 2022 04:04:34 +0000 Subject: [PATCH 2210/2430] Remove parity specific stuff --- lib/coins/xmr.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 55113f15..d607589c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -255,7 +255,7 @@ function calcEthReward(block, tx_reciepts) { }); let fee = 0; tx_reciepts.forEach(function(tx) { - fee += parseInt(tx.gasUsed) * gas_prices[tx.transactionHash]; + fee += parseInt(tx.result.gasUsed) * gas_prices[tx.result.transactionHash]; }); fee -= parseInt(block.baseFeePerGas) * parseInt(block.gasUsed); return (ETH_BASE_REWARD + ETH_BASE_REWARD * (block.uncles.length / 32)) * ETH_MULTIPLIER + fee; @@ -350,12 +350,16 @@ function Coin(data){ } 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) { + let batch_getBlockReceipts = []; + block.transactions.forEach(function(tx) { + batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); + }); + global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { + if (!body2 || !(body2 instanceof Array)) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body2)); return callback(true, body2); } - body.result.reward = calcEthReward(body.result, body2.result); + body.result.reward = calcEthReward(body.result, body2); return callback(null, body.result); }); }); @@ -414,12 +418,16 @@ function Coin(data){ 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) { - if (!body2 || !body2.result) { + let batch_getBlockReceipts = []; + block.transactions.forEach(function(tx) { + batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); + }); + global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { + if (!body2 || !(body2 instanceof Array)) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body2)); return callback(true, body2); } - body.result.reward = calcEthReward(body.result, body2.result); + body.result.reward = calcEthReward(body.result, body2); return callback(null, body.result); }); From 3f4d27b0732ec1432da08b8dfba117bff75d5c64 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 Feb 2022 04:05:17 +0000 Subject: [PATCH 2211/2430] Remove parity specific stuff --- 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 d607589c..81e4321f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -351,7 +351,7 @@ function Coin(data){ body.result.height = parseInt(body.result.number); if (blockId === "latest") return callback(null, body.result); // do not need rewards for the latest block let batch_getBlockReceipts = []; - block.transactions.forEach(function(tx) { + block.result.transactions.forEach(function(tx) { batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); }); global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { @@ -419,7 +419,7 @@ function Coin(data){ if (err) return callback(true, body); if (body.result.hash === body_height.hash) { let batch_getBlockReceipts = []; - block.transactions.forEach(function(tx) { + block.result.transactions.forEach(function(tx) { batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); }); global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { From 285497b016f44ea9a47b26d23628ad01e3f4439d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 4 Feb 2022 04:06:02 +0000 Subject: [PATCH 2212/2430] Remove parity specific stuff --- 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 81e4321f..07777bf1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -351,7 +351,7 @@ function Coin(data){ body.result.height = parseInt(body.result.number); if (blockId === "latest") return callback(null, body.result); // do not need rewards for the latest block let batch_getBlockReceipts = []; - block.result.transactions.forEach(function(tx) { + body.result.transactions.forEach(function(tx) { batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); }); global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { @@ -419,7 +419,7 @@ function Coin(data){ if (err) return callback(true, body); if (body.result.hash === body_height.hash) { let batch_getBlockReceipts = []; - block.result.transactions.forEach(function(tx) { + body.result.transactions.forEach(function(tx) { batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); }); global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { From f06be90b54c393445c8f6ec47c3f5de783b7a73a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 Feb 2022 18:57:47 +0000 Subject: [PATCH 2213/2430] Fixed gasUsed on 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 07777bf1..523011b9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -255,7 +255,7 @@ function calcEthReward(block, tx_reciepts) { }); let fee = 0; tx_reciepts.forEach(function(tx) { - fee += parseInt(tx.result.gasUsed) * gas_prices[tx.result.transactionHash]; + if (tx.result && tx.result.gasUsed) fee += parseInt(tx.result.gasUsed) * gas_prices[tx.result.transactionHash]; }); fee -= parseInt(block.baseFeePerGas) * parseInt(block.gasUsed); return (ETH_BASE_REWARD + ETH_BASE_REWARD * (block.uncles.length / 32)) * ETH_MULTIPLIER + fee; From 82ee69ae8272b15ab6a0a26c80f8943ba69be8fc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 Feb 2022 20:16:51 +0000 Subject: [PATCH 2214/2430] More diag --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index c6bdcfb2..17f0812e 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -118,7 +118,7 @@ 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 (" + Object.keys(locked_block_hashes).length + " locked)."); }); }); } From 41b69091dfb3f7f9f0c2e70096e9fc969d144f05 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 5 Feb 2022 20:55:36 +0000 Subject: [PATCH 2215/2430] LTHN algo update --- lib/coins/xmr.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 523011b9..f2cd6861 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -96,7 +96,7 @@ const port2algo = { "33124": "c29s", // XtendCash // "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR - "48782": "cn/r", // Lethean + "48782": "argon2/chukwav2", // Lethean "9231" : "cn/gpu", // XEQ "20206": "astrobwt", // DERO // "18181": "cn/0", // XMC @@ -907,7 +907,7 @@ function Coin(data){ 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/r" in algos_perf) coin_perf["SUMO"] = 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"]; @@ -946,8 +946,8 @@ function Coin(data){ //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"]; + if ("argon2/chukwav2" in algos_perf) coin_perf["TRTL"] = coin_perf["LTHN"] = algos_perf["argon2/chukwav2"]; + else if ("chukwav2" in algos_perf) coin_perf["TRTL"] = coin_perf["LTHN"] = algos_perf["chukwav2"]; return coin_perf; } @@ -992,7 +992,7 @@ function Coin(data){ 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 48782: return multiHashing.argon2(convertedBlob, 2); // Lethean default: console.error("Unknown " + blockTemplate.port + " port for Cryptonight PoW type"); return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); @@ -1018,7 +1018,6 @@ function Coin(data){ 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: From 9f05740a1f762cbea8a7379af553fc7e40834544 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 6 Feb 2022 21:00:48 +0000 Subject: [PATCH 2216/2430] Fix empty ETH block processing --- lib/coins/xmr.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f2cd6861..63608fca 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -354,6 +354,10 @@ function Coin(data){ body.result.transactions.forEach(function(tx) { batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); }); + if (!batch_getBlockReceipts.length) { + body.result.reward = calcEthReward(body.result, []); + return callback(null, body.result); + } global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { if (!body2 || !(body2 instanceof Array)) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body2)); @@ -422,6 +426,10 @@ function Coin(data){ body.result.transactions.forEach(function(tx) { batch_getBlockReceipts.push({ jsonrpc: "2.0", id: 1, method: 'eth_getTransactionReceipt', params: [ tx.hash ] }); }); + if (!batch_getBlockReceipts.length) { + body.result.reward = calcEthReward(body.result, []); + return callback(null, body.result); + } global.support.rpcPortDaemon2(port, '', batch_getBlockReceipts, function (body2) { if (!body2 || !(body2 instanceof Array)) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body2)); From af673d760fc7ffd103a49552efe3ded062180272 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 7 Feb 2022 17:24:41 +0000 Subject: [PATCH 2217/2430] Added more debug --- lib/longRunner.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 17f0812e..5b3b9480 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -97,6 +97,12 @@ let cleanBlockBalanceTableQueue = async.queue(function (task, callback) { global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [task.hex]).then(function () { return callback(true); }); }, 10); +setInterval(function(queue_obj){ + if (queue_obj.length()){ + console.log("Remove block balance queue length: " + queue_obj.length()); + } +}, 60*1000, this.cleanBlockBalanceTableQueue); + function cleanBlockBalanceTable() { console.log("Cleaning up the block balance table"); @@ -104,6 +110,7 @@ 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; }); + console.log("Starting cleaning the block balance table. Found " + Object.keys(locked_block_hashes).length + " locked blocks"); 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; @@ -118,7 +125,7 @@ function cleanBlockBalanceTable() { saw_block_hash_before[row.hex] = 1; } }); - console.log("Finished cleaning the block balance table. Removed " + deleted_row_count + " rows (" + Object.keys(locked_block_hashes).length + " locked)."); + console.log("Finished preparing the block balance table. Removing " + deleted_row_count + " rows (" + Object.keys(locked_block_hashes).length + " locked)."); }); }); } From 1b559cc19b7bc22da4b52a89b3aeb700a1333979 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 7 Feb 2022 17:31:14 +0000 Subject: [PATCH 2218/2430] Added more debug --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 5b3b9480..54007093 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -101,7 +101,7 @@ setInterval(function(queue_obj){ if (queue_obj.length()){ console.log("Remove block balance queue length: " + queue_obj.length()); } -}, 60*1000, this.cleanBlockBalanceTableQueue); +}, 60*1000, cleanBlockBalanceTableQueue); function cleanBlockBalanceTable() { console.log("Cleaning up the block balance table"); From cb4cf5e967cc7d00009c8249d55cd1db3ce0fb30 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 Feb 2022 18:04:08 +0000 Subject: [PATCH 2219/2430] Use updated XHV utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05819584..e0a64e77 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.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.1.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From 094f4dbfd32cb9c1f55668cfdf8e2070d13a9ab0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 Feb 2022 19:10:40 +0000 Subject: [PATCH 2220/2430] Improved pool handling --- lib/pool.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index f979b52d..c6ecaab0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2321,7 +2321,11 @@ function getUniqueWorkerID(cb) { console.error("Can't get max id from pool_workers table"); process.exit(1); } - return cb(rows[0].id, rows_max[0].maxId); + if (global.config.max_pool_worker_num && rows_max[0].maxId > global.config.max_pool_worker_num) { + console.error("Prease recreate pool_workers table"); + process.exit(1); + } + return cb(rows[0].id - 1, (global.config.max_pool_worker_num ? global.config.max_pool_worker_num : rows_max[0].maxId) - 1); }); }); } From ada3ae7ca41c51f1508c35b60b4730e770f0f318 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Feb 2022 07:44:01 +0000 Subject: [PATCH 2221/2430] Added more debug --- lib/longRunner.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/longRunner.js b/lib/longRunner.js index 54007093..b9649c66 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -112,6 +112,7 @@ function cleanBlockBalanceTable() { console.log("Starting cleaning the block balance table. Found " + Object.keys(locked_block_hashes).length + " locked blocks"); global.mysql.query("SELECT hex FROM paid_blocks WHERE paid_time > (NOW() - INTERVAL 7 DAY)").then(function (rows_keep) { + console.log("Got " + rows_keep.length + " recent blocks"); 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) { From 573771162803e6207be5b7aa7ca7798769eb6cbe Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Feb 2022 07:54:40 +0000 Subject: [PATCH 2222/2430] Added more debug --- lib/longRunner.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/longRunner.js b/lib/longRunner.js index b9649c66..d265ae02 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -116,6 +116,7 @@ function cleanBlockBalanceTable() { 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) { + console.log("Got " + rows.length + " block balance blocks"); rows.forEach(function (row) { if (row.hex in locked_block_hashes) return; if (row.hex in saw_block_hash_before) { From 17049a209ca485718d148f464960739e8462ae44 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Feb 2022 14:01:01 +0000 Subject: [PATCH 2223/2430] Deacreased 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 f8c03058..f6ea0bc9 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -341,7 +341,7 @@ function updateShareStats() { return setTimeout(updateShareStats, 10*1000); } updateShareStats2(body.height + 1, function() { - if (++cycleCount === 3) cycleCount = 0; + if (++cycleCount === 6) cycleCount = 0; setTimeout(updateShareStats, 10*1000); }); }); From b6263d5868318033da3861048eca04fb1b3355cd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Feb 2022 14:08:45 +0000 Subject: [PATCH 2224/2430] Deacreased 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 f6ea0bc9..a730b8db 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -338,7 +338,7 @@ function updateShareStats2(height, callback) { function updateShareStats() { global.coinFuncs.getLastBlockHeader(function (err, body) { if (err !== null){ - return setTimeout(updateShareStats, 10*1000); + return setTimeout(updateShareStats, 20*1000); } updateShareStats2(body.height + 1, function() { if (++cycleCount === 6) cycleCount = 0; From 5cf4c2b94670a30231f5e3b362a9ccc70ee37887 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Feb 2022 14:29:23 +0000 Subject: [PATCH 2225/2430] Improved block cleaning --- lib/longRunner.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index d265ae02..6eb2ec5f 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -91,7 +91,7 @@ function cleanCacheDB() { txn.commit(); } -let saw_block_hash_before = {}; +//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); }); @@ -119,13 +119,13 @@ function cleanBlockBalanceTable() { console.log("Got " + rows.length + " block balance blocks"); rows.forEach(function (row) { if (row.hex in locked_block_hashes) return; - if (row.hex in saw_block_hash_before) { + //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; - } + //} else { + // saw_block_hash_before[row.hex] = 1; + //} }); console.log("Finished preparing the block balance table. Removing " + deleted_row_count + " rows (" + Object.keys(locked_block_hashes).length + " locked)."); }); From bce0a0f961a1793d45a9f1b641b03c363b37e3d6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 9 Feb 2022 14:32:36 +0000 Subject: [PATCH 2226/2430] Deacreased 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 a730b8db..48b69ac5 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -342,7 +342,7 @@ function updateShareStats() { } updateShareStats2(body.height + 1, function() { if (++cycleCount === 6) cycleCount = 0; - setTimeout(updateShareStats, 10*1000); + setTimeout(updateShareStats, 20*1000); }); }); } From c111270f9217fb87c6dba8225cfcb8126dfd2b96 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Feb 2022 15:56:14 +0000 Subject: [PATCH 2227/2430] Updated monero daemon --- deployment/base.sql | 2 +- deployment/deploy.bash | 2 +- deployment/deploy_test.bash | 2 +- deployment/leaf.bash | 2 +- deployment/upgrade_monero.bash | 2 +- lib/coins/xmr.js | 11 ++++------- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index b48f0470..11687ae6 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', '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'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'address', '127.0.0.1', 'string', 'Default 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'); diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 9bfa07da..99e5aadf 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.3 +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 98e6aaab..0c55e701 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.3 +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 792cf895..864e1bb2 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.3 +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 5068725c..2c6a1720 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.3 &&\ +sudo git checkout v0.17.3.0 &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 63608fca..34febba9 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -33,7 +33,7 @@ const port2coin = { "48782": "LTHN", "19734": "SUMO", "13007": "IRD", - "13102": "XTA", +// "13102": "XTA", "19994": "ARQ", "33124": "XTNC", "19281": "XMV", @@ -62,7 +62,7 @@ const port2blob_num = { "48782": 0, // LTHN "19734": 0, // SUMO "13007": 2, // IRD - "13102": 12, // XTA +// "13102": 12, // XTA "19994": 0, // ARQ "19281": 8, // XMV "33124": 9, // XTNC @@ -83,7 +83,7 @@ const port2algo = { "11898": "argon2/chukwav2", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD - "13102": "c29i", // XTA +// "13102": "c29i", // XTA "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR "18981": "rx/graft", // Graft @@ -492,7 +492,7 @@ function Coin(data){ const blockJson = JSON.parse(body.result.json); const minerTx = blockJson.miner_tx; - if (port == 17750 || port == 33124 || port == 25182 || port == 13102 || port == 18181) { // XHV / XtendCash / TUBE / Italocoin / XMC has reward as zero transaction + if (port == 17750 || port == 33124 || port == 25182 || 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: Fri, 11 Feb 2022 15:59:04 +0000 Subject: [PATCH 2228/2430] Updated monero daemon --- deployment/upgrade_monero.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 2c6a1720..374aee2d 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -7,6 +7,7 @@ sudo git checkout . &&\ sudo git checkout master &&\ sudo git pull &&\ sudo git checkout v0.17.3.0 &&\ +sudo git submodule foreach git pull &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From d08d118161afaeaad4c0ff97ef097e0939a3fe1d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Feb 2022 16:01:26 +0000 Subject: [PATCH 2229/2430] Updated monero daemon --- deployment/upgrade_monero.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 374aee2d..0736c4fb 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -3,8 +3,8 @@ echo "This assumes that you have a standard nodejs-pool install, and will patch sleep 15 echo "Continuing install, this will prompt you for your password if you didn't enable passwordless sudo. Please do not run me as root!" cd /usr/local/src/monero &&\ -sudo git checkout . &&\ -sudo git checkout master &&\ +sudo git reset --hard origin/master &&\ +sudo git checkout &&\ sudo git pull &&\ sudo git checkout v0.17.3.0 &&\ sudo git submodule foreach git pull &&\ From 9e3f8b539153dc1227c35177102e4f9c1b0f7d0d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Feb 2022 16:03:17 +0000 Subject: [PATCH 2230/2430] Updated monero daemon --- 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 0736c4fb..03b3dcc1 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -4,7 +4,7 @@ sleep 15 echo "Continuing install, this will prompt you for your password if you didn't enable passwordless sudo. Please do not run me as root!" cd /usr/local/src/monero &&\ sudo git reset --hard origin/master &&\ -sudo git checkout &&\ +sudo git checkout master &&\ sudo git pull &&\ sudo git checkout v0.17.3.0 &&\ sudo git submodule foreach git pull &&\ From b30fa533ca114155a1b42d0ce40239f401af7c71 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Feb 2022 16:04:01 +0000 Subject: [PATCH 2231/2430] Updated monero daemon --- deployment/upgrade_monero.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 03b3dcc1..fa6fbdba 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -7,7 +7,6 @@ sudo git reset --hard origin/master &&\ sudo git checkout master &&\ sudo git pull &&\ sudo git checkout v0.17.3.0 &&\ -sudo git submodule foreach git pull &&\ sudo git submodule init &&\ sudo git submodule update &&\ sudo rm -rf build &&\ From d76c7a17fcdac1ebba875573454b01b713f0349d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Feb 2022 16:08:46 +0000 Subject: [PATCH 2232/2430] Updated monero daemon --- deployment/upgrade_monero.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index fa6fbdba..e23b8edd 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -7,8 +7,7 @@ sudo git reset --hard origin/master &&\ sudo git checkout master &&\ sudo git pull &&\ sudo git checkout v0.17.3.0 &&\ -sudo git submodule init &&\ -sudo git submodule update &&\ +sudo git submodule update --force --recursive --init --remote &&\ sudo rm -rf build &&\ 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 82e5e9b129085b50b67ab586eec76f6ab534e216 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Feb 2022 16:11:42 +0000 Subject: [PATCH 2233/2430] Updated monero daemon --- 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 e23b8edd..6e188c04 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -7,7 +7,7 @@ sudo git reset --hard origin/master &&\ sudo git checkout master &&\ sudo git pull &&\ sudo git checkout v0.17.3.0 &&\ -sudo git submodule update --force --recursive --init --remote &&\ +sudo git submodule update --force --recursive --init &&\ sudo rm -rf build &&\ 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 35884c51058c11ecb1c19a5f454493880296ec3f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 12 Feb 2022 19:20:16 +0000 Subject: [PATCH 2234/2430] Reduced loggin --- lib/pool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index c6ecaab0..283b9f14 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2602,7 +2602,7 @@ if (cluster.isMaster) { }); }, 5*60*1000); - let lastGarbageFromIpTime = {}; + //let lastGarbageFromIpTime = {}; async.each(global.config.ports, function (portData) { if (global.config[portData.portType].enable !== true) { @@ -2696,11 +2696,11 @@ if (cluster.isMaster) { } } - let time_now = Date.now(); - if (!(socket.remoteAddress in lastGarbageFromIpTime) || time_now - lastGarbageFromIpTime[socket.remoteAddress] > 60*1000) { - console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + JSON.stringify(message)); - lastGarbageFromIpTime[socket.remoteAddress] = time_now; - } + //let time_now = Date.now(); + //if (!(socket.remoteAddress in lastGarbageFromIpTime) || time_now - lastGarbageFromIpTime[socket.remoteAddress] > 60*1000) { + // console.warn(threadName + "Malformed message from " + socket.remoteAddress + " Message: " + JSON.stringify(message)); + // lastGarbageFromIpTime[socket.remoteAddress] = time_now; + //} socket.destroy(); break; From 639c94b314c93894a60c3310252ec9885b25975c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 12 Feb 2022 20:30:22 +0000 Subject: [PATCH 2235/2430] Fixed typo --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 6eb2ec5f..b7866bfd 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -121,7 +121,7 @@ function cleanBlockBalanceTable() { 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]; + //delete saw_block_hash_before[row.hex]; ++ deleted_row_count; //} else { // saw_block_hash_before[row.hex] = 1; From 30d3a8af1f455f9a5b4ede59fe62bf32a3c3ebfd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 12 Feb 2022 22:25:43 +0000 Subject: [PATCH 2236/2430] Disabled debug --- lib/pool.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 283b9f14..c7de8695 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -10,7 +10,7 @@ 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 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}$"); @@ -2685,16 +2685,16 @@ if (cluster.isMaster) { jsonData = JSON.parse(message); } catch (e) { - if (message.indexOf('GET /') === 0) { - if (message.indexOf('HTTP/1.1') !== -1) { - socket.end('HTTP/1.1' + httpResponse); - break; - } - else if (message.indexOf('HTTP/1.0') !== -1) { - socket.end('HTTP/1.0' + httpResponse); - break; - } - } + //if (message.indexOf('GET /') === 0) { + // if (message.indexOf('HTTP/1.1') !== -1) { + // socket.end('HTTP/1.1' + httpResponse); + // break; + // } + // else if (message.indexOf('HTTP/1.0') !== -1) { + // socket.end('HTTP/1.0' + httpResponse); + // break; + // } + //} //let time_now = Date.now(); //if (!(socket.remoteAddress in lastGarbageFromIpTime) || time_now - lastGarbageFromIpTime[socket.remoteAddress] > 60*1000) { From e30845416859438561d8c6a1fa4e1bb6130a4db9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 Feb 2022 01:54:59 +0000 Subject: [PATCH 2237/2430] Added SQL panic handling --- lib/pool_stats.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/pool_stats.js b/lib/pool_stats.js index 211c0709..eb692a11 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -127,10 +127,14 @@ function updatePoolStats(poolType) { 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); + }).catch(function (error) { + return callback(null, 0); }); } 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); + }).catch(function (error) { + return callback(null, 0); }); } }, @@ -139,6 +143,8 @@ function updatePoolStats(poolType) { 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); + }).catch(function (error) { + return callback(null, 0); }); } else { global.mysql.query("SELECT count(id) as txn_count FROM transactions").then(function (rows) { @@ -147,6 +153,8 @@ function updatePoolStats(poolType) { } else { return callback(null, 0); } + }).catch(function (error) { + return callback(null, 0); }); } }, @@ -342,6 +350,7 @@ function updatePoolPorts(poolServers) { } } }); + }).catch(function (error) { }); } @@ -361,6 +370,7 @@ function updatePoolInformation() { updatePoolPorts(local_cache); } }); + }).catch(function (error) { }); } @@ -452,6 +462,7 @@ function monitorNodes() { }); if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(block.height, top_height, global.config.daemon.port); }); + }).catch(function (error) { }); } From efe477f9212d700ff9152a2073d68c2915bb5d28 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 Feb 2022 02:09:55 +0000 Subject: [PATCH 2238/2430] Added SQL panic handling --- lib/api.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++ lib/pool_stats.js | 7 ++++++ 2 files changed, 61 insertions(+) diff --git a/lib/api.js b/lib/api.js index b4e3c5d5..16c62e31 100644 --- a/lib/api.js +++ b/lib/api.js @@ -126,6 +126,9 @@ function getAddressStats(address, extCallback){ } } return callback(null, returnData); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return callback(null, {}); }); }, function (returnData, callback) { @@ -140,6 +143,9 @@ function getAddressStats(address, extCallback){ } } return callback(null, returnData); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return callback(null, {}); }); }, function (returnData, callback) { @@ -154,6 +160,9 @@ function getAddressStats(address, extCallback){ } } return callback(true, returnData); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return callback(null, {}); }); } ], function (err, result) { @@ -354,6 +363,9 @@ app.get('/pool/payments/:pool_type', cache('1 minute'), function (req, res) { return res.json(response.sort(global.support.tsCompare)); } }); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); } }); @@ -410,6 +422,9 @@ app.get('/pool/payments', cache('1 minute'), function (req, res) { if (array.length === response.length) { res.json(response.sort(global.support.tsCompare)); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); } }); @@ -461,6 +476,9 @@ app.get('/miner/:address/payments', cache('1 minute'), function (req, res) { return res.json(response.sort(global.support.tsCompare)); } }); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); }).catch(function (err) { @@ -567,6 +585,9 @@ app.get('/user/:address', function (req, res) { } else { return res.json({payout_threshold: global.support.decimalToCoin(global.config.payout.defaultPay), email_enabled: 0}); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); @@ -586,6 +607,9 @@ app.post('/user/subscribeEmail', function (req, res) { } else { return res.json({'msg': 'Email preferences were updated'}); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); } 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) { @@ -599,6 +623,9 @@ app.post('/user/subscribeEmail', function (req, res) { } else { return res.json({'msg': 'Email preferences were updated'}); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); } else { global.mysql.query("UPDATE users SET enable_email = ?, email = ? WHERE username = ? AND email = ?", [enabled, to, username, from]).then(function (result) { @@ -607,6 +634,9 @@ app.post('/user/subscribeEmail', function (req, res) { } else { return res.json({'msg': 'Email preferences were updated'}); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); } }); @@ -618,6 +648,9 @@ app.get('/user/:address/unsubscribeEmail', function (req, res) { } else { return res.json({'msg': 'Your email was unsubscribed from further notifications'}); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); @@ -636,6 +669,9 @@ app.post('/user/updateThreshold', function (req, res) { } else { return res.status(401).send({'success': false, 'msg':"Can't update locked payment threshold"}); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); @@ -664,6 +700,9 @@ app.post('/authenticate', function (req, res) { let token = jwt.sign({id: rows[0].id, admin: rows[0].admin}, global.config.api.secKey, {expiresIn: '1d'}); return res.json({'success': true, 'msg': token}); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); @@ -703,6 +742,9 @@ secureRoutes.get('/tokenRefresh', function (req, res) { secureRoutes.get('/', function (req, res) { global.mysql.query("SELECT payout_threshold, enable_email, email FROM users WHERE id = ?", [req.decoded.id]).then(function(row){ return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email, email: row[0].email}}); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); @@ -710,18 +752,27 @@ secureRoutes.post('/changePassword', function (req, res) { let hmac = crypto.createHmac('sha256', global.config.api.secKey).update(req.body.password).digest('hex'); global.mysql.query("UPDATE users SET pass = ? WHERE id = ?", [hmac, req.decoded.id]).then(function () { return res.json({'msg': 'Password updated'}); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); secureRoutes.post('/changeEmail', function (req, res) { global.mysql.query("UPDATE users SET email = ? WHERE id = ?", [req.body.email, req.decoded.id]).then(function () { return res.json({'msg': 'Updated email was set to: ' + req.body.email}); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); secureRoutes.post('/toggleEmail', function (req, res) { global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE id = ?", [req.decoded.id]).then(function () { return res.json({'msg': 'Email toggled'}); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); @@ -732,6 +783,9 @@ secureRoutes.post('/changePayoutThreshold', function (req, res) { threshold = global.support.decimalToCoin(threshold); global.mysql.query("UPDATE users SET payout_threshold = ? WHERE id = ?", [threshold, req.decoded.id]).then(function () { return res.json({'msg': 'Threshold updated, set to: ' + global.support.coinToDecimal(threshold)}); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return res.json({}); }); }); diff --git a/lib/pool_stats.js b/lib/pool_stats.js index eb692a11..ff23bb20 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -128,12 +128,14 @@ function updatePoolStats(poolType) { 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); }).catch(function (error) { + console.error("SQL query failed: " + error); return callback(null, 0); }); } 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); }).catch(function (error) { + console.error("SQL query failed: " + error); return callback(null, 0); }); } @@ -144,6 +146,7 @@ function updatePoolStats(poolType) { global.mysql.query("SELECT distinct(transaction_id) from payments WHERE pool_type = ?", [poolType]).then(function (rows) { return callback(null, rows.length); }).catch(function (error) { + console.error("SQL query failed: " + error); return callback(null, 0); }); } else { @@ -154,6 +157,7 @@ function updatePoolStats(poolType) { return callback(null, 0); } }).catch(function (error) { + console.error("SQL query failed: " + error); return callback(null, 0); }); } @@ -351,6 +355,7 @@ function updatePoolPorts(poolServers) { } }); }).catch(function (error) { + console.error("SQL query failed: " + error); }); } @@ -371,6 +376,7 @@ function updatePoolInformation() { } }); }).catch(function (error) { + console.error("SQL query failed: " + error); }); } @@ -463,6 +469,7 @@ function monitorNodes() { if (is_master_daemon_issue) global.coinFuncs.fixDaemonIssue(block.height, top_height, global.config.daemon.port); }); }).catch(function (error) { + console.error("SQL query failed: " + error); }); } From 27aed916d24e20aee5082e44f28fdd740dff9d0c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 Feb 2022 02:51:01 +0000 Subject: [PATCH 2239/2430] Removed btc stuff and added sql checks --- deployment/base.sql | 1 - lib/api.js | 2 - lib/blockManager.js | 23 +- lib/data.proto | 1 - lib/longRunner.js | 13 +- lib/payment_systems/xmr.js | 539 +++++-------------------------------- lib/pool.js | 36 ++- lib/support.js | 17 +- package.json | 1 - 9 files changed, 113 insertions(+), 520 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 11687ae6..41dc6712 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -275,7 +275,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 ('payout', 'maxTxnValue', '250', 'int', 'Maximum amount of XMR to send in a single transaction'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'shapeshiftPair', 'xmr_btc', 'string', 'Pair to use in all shapeshift lookups for auto BTC payout'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'coinCode', 'XMR', 'string', 'Coincode to be loaded up w/ the shapeshift getcoins argument.'); -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', '10', 'int', 'Mixin count for coins that support such things.'); diff --git a/lib/api.js b/lib/api.js index 16c62e31..9e1f7af0 100644 --- a/lib/api.js +++ b/lib/api.js @@ -205,8 +205,6 @@ app.get('/pool/address_type/:address', cache('10 seconds'), function (req, res) let address = req.params.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'}); } else { res.json({valid: false}); } diff --git a/lib/blockManager.js b/lib/blockManager.js index 9586d23a..918e22ce 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -37,16 +37,15 @@ let createBalanceQueue = async.queue(function (task, callback) { let pool_type = task.pool_type; let payment_address = task.payment_address; let payment_id = task.payment_id; - let bitcoin = task.bitcoin; - let query = "SELECT id FROM balance WHERE payment_address = ? AND payment_id is ? AND pool_type = ? AND bitcoin = ?"; + let query = "SELECT id FROM balance WHERE payment_address = ? AND payment_id is ? AND pool_type = ?"; if (payment_id !== null) { - query = "SELECT id FROM balance WHERE payment_address = ? AND payment_id = ? AND pool_type = ? AND bitcoin = ?"; + query = "SELECT id FROM balance WHERE payment_address = ? AND payment_id = ? AND pool_type = ?"; } - let cacheKey = payment_address + pool_type + bitcoin + payment_id; + let cacheKey = payment_address + pool_type + payment_id; debug("Processing a account add/check for:" + JSON.stringify(task)); - global.mysql.query(query, [payment_address, payment_id, pool_type, bitcoin]).then(function (rows) { + global.mysql.query(query, [payment_address, payment_id, pool_type]).then(function (rows) { if (rows.length === 0) { - global.mysql.query("INSERT INTO balance (payment_address, payment_id, pool_type, bitcoin) VALUES (?, ?, ?, ?)", [payment_address, payment_id, pool_type, bitcoin]).then(function (result) { + global.mysql.query("INSERT INTO balance (payment_address, payment_id, pool_type) VALUES (?, ?, ?)", [payment_address, payment_id, pool_type]).then(function (result) { debug("Added to the SQL database: " + result.insertId); balanceIDCache[cacheKey] = result.insertId; return callback(); @@ -61,7 +60,6 @@ let createBalanceQueue = async.queue(function (task, callback) { 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; @@ -70,7 +68,7 @@ let balanceQueue = async.queue(function (task, callback) { debug("Processing balance increment task: " + JSON.stringify(task)); async.waterfall([ function (intCallback) { - let cacheKey = payment_address + pool_type + bitcoin + payment_id; + let cacheKey = payment_address + pool_type + payment_id; if (cacheKey in balanceIDCache) { return intCallback(null, balanceIDCache[cacheKey]); } else { @@ -166,21 +164,18 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, 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 }; @@ -225,7 +220,6 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, pool_type: 'pplns', payment_address: shareData.paymentAddress, payment_id: shareData.paymentID, - bitcoin: shareData.bitcoin, amount: 0 }; } @@ -234,8 +228,7 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, if (totalPaid < rewardTotal) lastShareTime = shareData.timestamp; const amountToPay = shareData.shares2; - const feesToPay = amountToPay * (global.config.payout.pplnsFee / 100) + - (shareData.bitcoin === true ? amountToPay * (global.config.payout.btcFee / 100) : 0); + const feesToPay = amountToPay * (global.config.payout.pplnsFee / 100); const devDonation = feesToPay * (global.config.payout.devDonation / 100); const poolDevDonation = feesToPay * (global.config.payout.poolDevDonation / 100); const amountToPay2 = amountToPay - feesToPay; @@ -348,7 +341,6 @@ function preCalculatePPLNSPayments(block_hexes, block_height, block_difficulty, pool_type: 'pplns', payment_address: payment.payment_address, payment_id: payment.payment_id, - bitcoin: 0, amount: payment.amount / pay_window, hexes: block_hexes, }; @@ -392,7 +384,6 @@ function doPPLNSPayments(block_hex, block_reward, block_port, block_timestamp, u 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) { diff --git a/lib/data.proto b/lib/data.proto index 18f9b8e1..030c2999 100644 --- a/lib/data.proto +++ b/lib/data.proto @@ -35,7 +35,6 @@ message Share { required POOLTYPE poolType = 6; required int32 poolID = 7; required int64 blockDiff = 8; - required bool bitcoin = 9; required int32 blockHeight = 10; required int64 timestamp = 11; required string identifier = 12; diff --git a/lib/longRunner.js b/lib/longRunner.js index b7866bfd..31584ae0 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -94,7 +94,12 @@ 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); }); + global.mysql.query("DELETE FROM block_balance WHERE hex = ?", [task.hex]).then(function () { + return callback(true); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return callback(false); + }); }, 10); setInterval(function(queue_obj){ @@ -127,8 +132,12 @@ function cleanBlockBalanceTable() { // saw_block_hash_before[row.hex] = 1; //} }); - console.log("Finished preparing the block balance table. Removing " + deleted_row_count + " rows (" + Object.keys(locked_block_hashes).length + " locked)."); + console.log("Finished preparing the block balance table. Removing " + deleted_row_count + " rows (" + Object.keys(locked_block_hashes).length + " locked)."); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); } diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index 0bc20471..78466766 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -1,5 +1,4 @@ "use strict"; -const shapeshift = require('shapeshift.io'); const async = require("async"); const debug = require("debug")("payments"); const request = require('request-json'); @@ -7,8 +6,6 @@ const range = require('range'); const sprintf = require("sprintf-js").sprintf; let hexChars = new RegExp("[0-9a-f]+"); -let bestExchange = global.config.payout.bestExchange; -let xmrAPIClient = request.createClient('https://xmr.to/api/v1/xmr2btc/'); let is_full_stop = false; @@ -22,295 +19,6 @@ function full_stop(err) { ". Please investigate and restart the payment daemon as appropriate"); } -let shapeshiftQueue = async.queue(function (task, callback) { - if (is_full_stop) { - debug("Dropping all pending shapeshift payments"); - return; - } - - // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. - let amount = task.amount - task.fee; - // Address is the destination address IN BTC. - let address = task.address; - // PaymentIDs are the paymentID's to flag as paid by this transaction. - // Should be a massive list of ID's so we can bulk-update them, by merging them with 's. - // Here we go! General process: Scan shapeshift for valid amounts of funds to xfer around. - // Once there's enough funds, then we active txn - // Do a wallet call to xfer. - // Setup a monitor on the transaction - async.waterfall([ - function (intCallback) { - // Verify if the coin is active in ShapeShift first. - shapeshift.coins(function (err, coinData) { - if (err) { - intCallback(err); - } else if (!coinData.hasOwnProperty(global.config.general.coinCode) || coinData[global.config.general.coinCode].status !== "available") { - intCallback("Coin " + global.config.general.coinCode + " Is not available at this time on shapeshift."); - } else { - intCallback(null); - } - }); - }, - function (intCallback) { - // Get the market information from shapeshift, which includes deposit limits, minimum deposits, rates, etc. - shapeshift.marketInfo(global.config.payout.shapeshiftPair, function (err, marketInfo) { - if (err) { - intCallback(err); - } else if (!marketInfo.hasOwnProperty("limit") || marketInfo.limit <= global.support.coinToDecimal(amount)) { - intCallback("Not enough coin in shapeshift to process at this time."); - } else if (!marketInfo.hasOwnProperty("min") || marketInfo.min >= global.support.coinToDecimal(amount)) { - intCallback("Not enough coin to hit the shapeshift minimum deposits."); - } else { - intCallback(null, marketInfo); - } - }); - }, - function (marketInfo, intCallback) { - // Validated there's enough coin. Time to make our dank txn. - // Return: - /* - { - "orderId": "cc49c556-e645-4c15-a943-d50a935274e4", - "sAddress": "46yzCCD3Mza9tRj7aqPSaxVbbePtuAeKzf8Ky2eRtcXGcEgCg1iTBio6N4sPmznfgGEUGDoBz5CLxZ2XPTyZu1yoCAG7zt6", - "deposit": "d8041668718e6e9d9d0fd335ee5ecd923e6fd074c41316d041cc18b779ade10e", - "depositType": "XMR", - "withdrawal": "1DbxcoCBSA9N7uZvkcvWxuLxSau9q9Pwiu", - "withdrawalType": "BTC", - "public": null, - "apiPubKey": "shapeshift", - "returnAddress": "46XWBqE1iwsVxSDP1qDrxhE1XvsZV6eALG5LwnoMdjbT4GPdy2bZTb99kagzxp2MMjUamTYZ4WgvZdFadvMimTjvR6Gv8hL", - "returnAddressType": "XMR" - } - Valid Statuses: - "received" - "complete" - "error" - "no_deposits" - Complete State Information: - { - "status": "complete", - "address": "d8041668718e6e9d9d0fd335ee5ecd923e6fd074c41316d041cc18b779ade10e", - "withdraw": "1DbxcoCBSA9N7uZvkcvWxuLxSau9q9Pwiu", - "incomingCoin": 3, - "incomingType": "XMR", - "outgoingCoin": "0.04186155", - "outgoingType": "BTC", - "transaction": "be9d97f6fc75262151f8f63e035c6ed638b9eb2a4e93fef43ea63124b045dbfb" - } - */ - shapeshift.shift(address, global.config.payout.shapeshiftPair, {returnAddress: global.config.pool.address}, function (err, returnData) { - if (err) { - intCallback(err); - } else { - global.mysql.query("INSERT INTO shapeshiftTxn (id, address, paymentID, depositType, withdrawl, withdrawlType, returnAddress, returnAddressType, txnStatus) VALUES (?,?,?,?,?,?,?,?,?)", - [returnData.orderId, returnData.sAddress, returnData.deposit, returnData.depositType, returnData.withdrawl, returnData.withdrawlType, returnData.returnAddress, returnData.returnAddressType, 'no_deposits']).then(function () { - intCallback(null, marketInfo, returnData); - }).catch(function (error) { - intCallback(error); - }); - } - }); - }, - function (marketInfo, shapeshiftTxnData, intCallback) { - // Make the payment to ShapeShift - let paymentDetails = { - destinations: [ - { - amount: amount, - address: shapeshiftTxnData.sAddress - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, - payment_id: shapeshiftTxnData.deposit - }; - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - intCallback(null, marketInfo, shapeshiftTxnData, body); - } else { - intCallback("Unknown error from the wallet."); - } - }); - }, - function (marketInfo, shapeshiftTxnData, body, intCallback) { - // body.tx_hash = XMR transaction hash. - // Need to add transaction. - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees, exchange_rate, exchange_name, exchange_txn_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - [1, address, null, task.amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, global.support.decimalToCoin(marketInfo.minerFee), 1, global.support.decimalToCoin(marketInfo.rate), 'shapeshift', shapeshiftTxnData.orderId]).then(function (result) { - intCallback(null, result.insertId); - }).catch(function (error) { - intCallback(error); - }); - } - ], function (err, result) { - if (err) { - console.error("Error processing shapeshift txn: " + JSON.stringify(err)); - callback(true); - } else { - // Need to fill out this data pronto! - console.log("Processed ShapeShift transaction for: " + address + " Paid out: " + result + " payments in the db"); - callback(null, result); - } - }); -}, 2); - -let xmrToQueue = async.queue(function (task, callback) { - if (is_full_stop) { - debug("Dropping all pending xmr.to payments"); - return; - } - - // http://xmrto-api.readthedocs.io/en/latest/introduction.html - // Documentation looks good! - // Amount needs to be shifted in as a non-completed value, as the wallet will only take non-complete values.. - let amount = task.amount - task.fee; - // Address is the destination address IN BTC. - let address = task.address; - // PaymentIDs are the paymentID's to flag as paid by this transaction. - // Should be a massive list of ID's so we can bulk-update them, by merging them with 's. - // Here we go! General process: Scan shapeshift for valid amounts of funds to xfer around. - // Once there's enough funds, then we active txn - // Do a wallet call to xfer. - // Setup a monitor on the transaction - async.waterfall([ - function (intCallback) { - // Verify if XMR.to is ready to get to work. - xmrAPIClient.get('order_parameter_query/', function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - let amtOfBTC = ((amount / global.config.general.sigDivisor) * body.price).toPrecision(5); - console.log("Attempting to pay: " + address + " Amount: " + amtOfBTC + " BTC or " + amount / global.config.general.sigDivisor + " XMR"); - console.log("Response from XMR.to: " + JSON.stringify(body)); - if (body.lower_limit >= amtOfBTC) { - return intCallback("Not enough XMR to hit the minimum deposit"); - } else if (body.upper_limit <= amtOfBTC) { - return intCallback("Too much XMR to pay out to xmr.to"); - } else { - return intCallback(null, amtOfBTC); - } - } - }); - }, - function (btcValue, intCallback) { - // Validated there's enough coin. Time to make our dank txn. - // Return: - /* - { - "state": "TO_BE_CREATED", - "btc_amount": , - "btc_dest_address": "", - "uuid": "" - } - Valid Statuses: - "TO_BE_CREATED" - "UNPAID" - "UNDERPAID" - "PAID_UNCONFIRMED" - "PAID" - "BTC_SENT" - "TIMED_OUT" - "NOT_FOUND" - // Create, then immediately update with the new information w/ a status call. - */ - console.log("Amount of BTC to pay: " + btcValue); - xmrAPIClient.post('order_create/', { - btc_amount: btcValue, - btc_dest_address: address - }, function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - return intCallback(null, body.uuid); - } - }); - }, - function (txnID, intCallback) { - // This function only exists because xmr.to is a pretty little fucking princess. - async.doUntil(function (xmrCallback) { - xmrAPIClient.post('order_status_query/', {uuid: txnID}, function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - xmrCallback(null, body.state); - } - }); - }, - function (xmrCallback, untilCB) { - return untilCB(null, xmrCallback !== "TO_BE_CREATED"); - }, - function () { - intCallback(null, txnID); - }); - }, - function (txnID, intCallback) { - xmrAPIClient.post('order_status_query/', {uuid: txnID}, function (err, res, body) { - if (err) { - return intCallback(err); - } else if (body.error_msg) { - return intCallback(body.error_msg); - } else { - console.log(JSON.stringify(body)); - global.mysql.query("INSERT INTO xmrtoTxn (id, address, paymentID, depositType, withdrawl, withdrawlType, returnAddress, returnAddressType, txnStatus, amountDeposited, amountSent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", - [txnID, body.xmr_receiving_address, body.xmr_required_payment_id_long, 'XMR', body.btc_dest_address, 'BTC', global.config.pool.address, 'XMR', body.state_str, global.support.decimalToCoin(body.xmr_amount_total), global.support.decimalToCoin(body.btc_amount)]).then(function () { - return intCallback(null, body, global.support.decimalToCoin(body.xmr_amount_total)); - }).catch(function (error) { - return intCallback(error); - }); - } - }); - }, - function (orderStatus, xmrDeposit, intCallback) { - // Make the payment to ShapeShift - let paymentDetails = { - destinations: [ - { - amount: xmrDeposit, - address: orderStatus.xmr_receiving_address - } - ], - priority: global.config.payout.priority, - mixin: global.config.payout.mixIn, - payment_id: orderStatus.xmr_required_payment_id_long - }; - debug("Payment Details: " + JSON.stringify(paymentDetails)); - paymentQueue.push(paymentDetails, function (body) { - if (body.fee && body.fee > 10) { - return intCallback(null, orderStatus, body); - } else { - return intCallback("Unknown error from the wallet."); - } - }); - }, - function (orderStatus, body, intCallback) { - // body.tx_hash = XMR transaction hash. - // Need to add transaction. - global.mysql.query("INSERT INTO transactions (bitcoin, address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees, exchange_rate, exchange_name, exchange_txn_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - [1, address, null, global.support.decimalToCoin(orderStatus.xmr_amount_total), body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1, global.support.decimalToCoin(orderStatus.xmr_price_btc), 'xmrto', orderStatus.uuid]).then(function (result) { - return intCallback(null, result.insertId); - }).catch(function (error) { - return intCallback(error); - }); - } - ], function (err, result) { - if (err) { - console.error("Error processing XMRTo txn: " + JSON.stringify(err)); - return callback("Error!"); - } else { - // Need to fill out this data pronto! - console.log("Processed XMRTo transaction for: " + address + " Paid out: " + result + " payments in the db"); - return callback(null, result); - } - }); -}, 2); - let paymentQueue = async.queue(function (paymentDetails, callback) { if (is_full_stop) { debug("Dropping all pending payments"); @@ -371,129 +79,10 @@ paymentQueue.drain(function(){ 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) { - rows.forEach(function (row) { - shapeshift.status(row.paymentID, function (err, status, returnData) { - if (err) { - return; - } - global.mysql.query("UPDATE shapeshiftTxn SET txnStatus = ? WHERE id = ?", [status, row.id]).then(function () { - if (status === 'complete') { - global.mysql.query("UPDATE shapeshiftTxn SET amountDeposited = ?, amountSent = ?, transactionHash = ? WHERE id = ?", - [global.support.decimalToCoin(returnData.incomingCoin), global.support.bitcoinDecimalToCoin(returnData.outgoingCoin), returnData.transaction, row.id]).then(function () { - global.mysql.query("UPDATE transactions SET confirmed = 1, confirmed_time = now(), btc_amt = ? WHERE exchange_txn_id = ?", [global.support.bitcoinDecimalToCoin(returnData.outgoingCoin), row.id]); - }); - } else if (status === 'error') { - // Failed txn. Need to rollback and delete all related data. Here we go! - global.mysql.query("DELETE FROM shapeshiftTxn WHERE id = ?", [row.id]); - global.mysql.query("SELECT id, xmr_amt, address FROM transactions WHERE exchange_txn_id = ?", [row.id]).then(function (rows) { - global.mysql.query("DELETE FROM transactions WHERE id = ?", [rows[0].id]); - global.mysql.query("DELETE payments WHERE transaction_id = ?", [rows[0].id]); - global.mysql.query("UPDATE balance SET amount = amount+? WHERE payment_address = ? limit 1", [rows[0].xmr_amt, rows[0].address]); - }); - console.error("Failed transaction from ShapeShift " + JSON.stringify(returnData)); - } - }); - }); - }); - }); -} - -function updateXMRToCompletion() { - global.mysql.query("SELECT * FROM xmrtoTxn WHERE txnStatus NOT IN ('PAID', 'TIMED_OUT', 'NOT_FOUND', 'BTC_SENT')").then(function (rows) { - rows.forEach(function (row) { - xmrAPIClient.post('order_status_query/', {uuid: row.id}, function (err, res, body) { - if (err) { - console.log("Error in getting order status: " + JSON.stringify(err)); - return; - } - if (body.error_msg) { - console.log("Error in getting order status: " + body.error_msg); - return; - } - global.mysql.query("UPDATE xmrtoTxn SET txnStatus = ? WHERE id = ?", [body.state, row.id]).then(function () { - if (body.status === 'BTC_SENT') { - global.mysql.query("UPDATE xmrtoTxn SET transactionHash = ? WHERE id = ?", [body.btc_transaction_id, row.id]).then(function () { - global.mysql.query("UPDATE transactions SET confirmed = 1, confirmed_time = now(), btc_amt = ? WHERE exchange_txn_id = ?", [global.support.bitcoinDecimalToCoin(body.btc_amount), row.id]); - }); - } else if (body.status === 'TIMED_OUT' || body.status === 'NOT_FOUND') { - global.mysql.query("DELETE FROM xmrtoTxn WHERE id = ?", [row.id]); - global.mysql.query("SELECT id, xmr_amt, address FROM transactions WHERE exchange_txn_id = ?", [row.id]).then(function (rows) { - global.mysql.query("DELETE FROM transactions WHERE id = ?", [rows[0].id]); - global.mysql.query("DELETE payments WHERE transaction_id = ?", [rows[0].id]); - global.mysql.query("UPDATE balance SET amount = amount+? WHERE payment_address = ? limit 1", [rows[0].xmr_amt, rows[0].address]); - }); - console.error("Failed transaction from XMRto " + JSON.stringify(body)); - } - }); - }); - }); - }); -} - -function determineBestExchange() { - async.waterfall([ - function (callback) { - // Verify if the coin is active in ShapeShift first. - shapeshift.coins(function (err, coinData) { - if (err) { - return callback(err); - } else if (!coinData.hasOwnProperty(global.config.general.coinCode) || coinData[global.config.general.coinCode].status !== "available") { - return callback("Coin " + global.config.general.coinCode + " Is not available at this time on shapeshift."); - } else { - return callback(null); - } - }); - }, - function (callback) { - // Get the market information from shapeshift, which includes deposit limits, minimum deposits, rates, etc. - shapeshift.marketInfo(global.config.payout.shapeshiftPair, function (err, marketInfo) { - if (err) { - return callback(err); - } else if (!marketInfo.hasOwnProperty("rate")) { - return callback("Shapeshift did not return the rate."); - } else { - return callback(null, global.support.bitcoinDecimalToCoin(marketInfo.rate)); - } - }); - }, - function (ssValue, callback) { - xmrAPIClient.get('order_parameter_query/', function (err, res, body) { - console.log("XMR.to pricing body: " + JSON.stringify(body)); - if (err) { - return callback(err); - } else if (body.error_msg) { - return callback(body.error_msg); - } else { - return callback(null, ssValue, global.support.bitcoinDecimalToCoin(body.price)); - } - }); - } - ], function (err, ssValue, xmrToValue) { - if (err) { - return console.error("Error processing exchange value: " + JSON.stringify(err)); - } - debug("ShapeShift Value: " + global.support.bitcoinCoinToDecimal(ssValue) + " XMR.to Value: " + global.support.bitcoinCoinToDecimal(xmrToValue)); - if (ssValue >= xmrToValue) { - console.log("ShapeShift is the better BTC exchange, current rate: " + global.support.bitcoinCoinToDecimal(ssValue)); - bestExchange = 'shapeshift'; - global.mysql.query("UPDATE config SET item_value = 'shapeshift' where item='bestExchange'"); - global.mysql.query("UPDATE config SET item_value = ? where item='exchangeRate'", [ssValue]); - } else { - console.log("XMR.to is the better BTC exchange, current rate: " + global.support.bitcoinCoinToDecimal(xmrToValue)); - bestExchange = 'xmrto'; - global.mysql.query("UPDATE config SET item_value = 'xmrto' where item='bestExchange'"); - global.mysql.query("UPDATE config SET item_value = ? where item='exchangeRate'", [xmrToValue]); - } - }); -} - -function Payee(amount, address, paymentID, bitcoin) { +function Payee(amount, address, paymentID) { this.amount = amount; this.address = address; this.paymentID = paymentID; - this.bitcoin = bitcoin; this.blockID = 0; this.poolType = ''; this.transactionID = 0; @@ -537,10 +126,10 @@ function Payee(amount, address, paymentID, bitcoin) { paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - 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, address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { + global.mysql.query("INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", + [address, paymentID, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).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, '" + console.error("Can't do: INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES ('" + address + "', '" + paymentID + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); payee.transactionID = 0; @@ -552,6 +141,15 @@ function Payee(amount, address, paymentID, bitcoin) { payee.tx_hash = body.tx_hash.match(hexChars)[0]; payee.tx_key = body.tx_key; payee.trackPayment(); + }).catch(function (error) { + console.error("SQL query failed: " + error); + console.error("Can't do: INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES ('" + + address + "', '" + paymentID + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" + ); + payee.transactionID = 0; + payee.manualPaymentShow(); + full_stop(result); + return; }); } else { console.error("Unknown error from the wallet: " + JSON.stringify(body)); @@ -580,10 +178,10 @@ function Payee(amount, address, paymentID, bitcoin) { paymentQueue.push(paymentDetails, function (body) { if (body.fee && body.fee > 10) { console.log("[*] Successful payment to " + identifier + " of " + global.support.coinToDecimal(amount) + " XMR (fee " + global.support.coinToDecimal(fee) + " - " + global.support.coinToDecimal(body.fee) + " = " + global.support.coinToDecimal(fee - 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, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", - [0, address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).then(function (result) { + global.mysql.query("INSERT INTO transactions (address, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?)", + [address, amount, body.tx_hash.match(hexChars)[0], global.config.payout.mixIn, body.fee, 1]).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, '" + console.error("Can't do: INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES ('" + address + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" ); payee.transactionID = 0; @@ -595,6 +193,15 @@ function Payee(amount, address, paymentID, bitcoin) { payee.tx_hash = body.tx_hash.match(hexChars)[0]; payee.tx_key = body.tx_key; payee.trackPayment(); + }).catch(function (error) { + console.error("SQL query failed: " + error); + console.error("Can't do: INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES ('" + + address + "', " + amount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", 1)" + ); + payee.transactionID = 0; + payee.manualPaymentShow(); + full_stop(result); + return; }); } else { console.error("Unknown error from the wallet: " + JSON.stringify(body)); @@ -602,33 +209,11 @@ function Payee(amount, address, paymentID, bitcoin) { }); }; - this.makeBitcoinPayment = function () { - let functionalData = {address: this.address, amount: this.amount, fee: this.fee}; - let payee = this; - if (bestExchange === 'xmrto') { - xmrToQueue.push(functionalData, function (err, transactionID) { - if (err) { - return console.error("Error processing payment for " + functionalData.address); - } - payee.transactionID = transactionID; - payee.trackPayment(); - }); - } else { - shapeshiftQueue.push(functionalData, function (err, transactionID) { - if (err) { - return console.error("Error processing payment for " + functionalData.address); - } - payee.transactionID = transactionID; - payee.trackPayment(); - }); - } - }; - this.manualPaymentShow = function () { console.error("Manual payment update:"); console.error(" UPDATE balance SET amount = amount - " + this.amount + " WHERE id = " + this.sqlID + ";"); - console.error(" INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee) VALUES (now(), now(), " - + this.poolType + ", " + this.address + ", " + this.transactionID + ", " + this.bitcoin + ", " + (this.amount - this.fee) + ", " + this.paymentID + ", " + this.fee + ");" + console.error(" INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, amount, payment_id, transfer_fee) VALUES (now(), now(), " + + this.poolType + ", " + this.address + ", " + this.transactionID + ", " + (this.amount - this.fee) + ", " + this.paymentID + ", " + this.fee + ");" ); }; @@ -639,14 +224,24 @@ function Payee(amount, address, paymentID, bitcoin) { this.manualPaymentShow(); full_stop(result); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + console.error("Can't do SQL balance update"); + this.manualPaymentShow(); + full_stop(result); }); - global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, bitcoin, amount, payment_id, transfer_fee)" + - " VALUES (now(), now(), ?, ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.bitcoin, this.amount - this.fee, this.paymentID, this.fee]).then(function (result) { + global.mysql.query("INSERT INTO payments (unlocked_time, paid_time, pool_type, payment_address, transaction_id, amount, payment_id, transfer_fee)" + + " VALUES (now(), now(), ?, ?, ?, ?, ?, ?)", [this.poolType, this.address, this.transactionID, this.amount - this.fee, this.paymentID, this.fee]).then(function (result) { if (!result.hasOwnProperty("affectedRows") || result.affectedRows != 1) { console.error("Can't do SQL payments update"); this.manualPaymentShow(); full_stop(result); } + }).catch(function (error) { + console.error("SQL query failed: " + error); + console.error("Can't do SQL payments update"); + this.manualPaymentShow(); + full_stop(result); }); let payee = this; @@ -678,6 +273,8 @@ function Payee(amount, address, paymentID, bitcoin) { ), payee.id ); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); }; } @@ -691,14 +288,6 @@ function makePayments() { debug("Payment queue is not empty so dropping all new payment creation"); return; } - if (shapeshiftQueue.idle() === false) { - debug("Shapeshift payment queue is not empty so dropping all new payment creation"); - return; - } - if (xmrToQueue.idle() === false) { - debug("xmr.to payment queue is not empty so dropping all new payment creation"); - return; - } debug("Starting makePayments"); global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { @@ -709,7 +298,7 @@ function makePayments() { 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 - let payee = new Payee(row.amount, row.payment_address, row.payment_id, row.bitcoin); + let payee = new Payee(row.amount, row.payment_address, row.payment_id); global.mysql.query("SELECT payout_threshold FROM users WHERE username = ?", [payee.id]).then(function (userRow) { let threshold = global.support.decimalToCoin(global.config.payout.defaultPay); let custom_threshold = false; @@ -732,28 +321,24 @@ function makePayments() { } if (payee.amount >= threshold) { payee.setFeeAmount(); - if (payee.bitcoin === 0 && payee.paymentID === null && payee.amount !== 0 && payee.amount > 0 && payee.address.length !== 106) { + if (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; - } 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))) { + } else if (ayee.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(); + } else { + console.error("Unsupported payment to " + payee.id + " was found"); } } return next(); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); }, function() { while (paymentDestinations.length > 0) { @@ -774,10 +359,10 @@ function makePayments() { 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) { + global.mysql.query("INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (?, ?, ?, ?, ?, ?, ?)", + [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, " + console.error("Can't do: INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (null, null, " + totalAmount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", " + paymentDetails.destinations.length + ")" ); paymentDetails.destinations.forEach(function (payeeItem) { @@ -795,6 +380,18 @@ function makePayments() { payee.tx_key = body.tx_key; payee.trackPayment(); }); + }).catch(function (error) { + console.error("SQL query failed: " + error); + console.error("Can't do: INSERT INTO transactions (address, payment_id, xmr_amt, transaction_hash, mixin, fees, payees) VALUES (null, null, " + + totalAmount + ", '" + body.tx_hash.match(hexChars)[0] + "', " + global.config.payout.mixIn + ", " + body.fee + ", " + paymentDetails.destinations.length + ")" + ); + paymentDetails.destinations.forEach(function (payeeItem) { + let payee = payeeObjects[payeeItem.address]; + payee.transactionID = 0; + payee.manualPaymentShow(); + }); + full_stop(result); + return; }); } else { console.error("Unknown error from the wallet: " + JSON.stringify(body)); @@ -803,24 +400,20 @@ function makePayments() { } debug("Finished processing payments for now"); }); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); debug("Finished makePayments"); } function init() { global.support.rpcWallet("store", [], function () {}); - if (global.config.allowBitcoin) { - determineBestExchange(); - setInterval(updateXMRToCompletion, 90000); - setInterval(updateShapeshiftCompletion, 90000); - setInterval(determineBestExchange, 60000); - } setInterval(function () { global.support.rpcWallet("store", [], function () {}); }, 60*1000); setInterval(function () { - console.log("Payment queue lengths: payment (" + (paymentQueue.running() + paymentQueue.length()) + ") / shapeshift (" + (shapeshiftQueue.running() + shapeshiftQueue.length()) + ") / xmr.to (" + (xmrToQueue.running() + xmrToQueue.length()) + ")"); + console.log("Payment queue lengths: payment (" + (paymentQueue.running() + paymentQueue.length()) + ")"); }, 10*60*1000); makePayments(); diff --git a/lib/pool.js b/lib/pool.js index c7de8695..9b860815 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -712,11 +712,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro return; } - if (global.coinFuncs.validateAddress(this.address)) { - this.bitcoin = 0; - } else if (global.config.general.allowBitcoin && global.coinFuncs.supportsAutoExchange && btcValidator.validate(this.address)) { - this.bitcoin = 1; - } else { + if (!global.coinFuncs.validateAddress(this.address)) { this.error = "Invalid payment address provided: " + this.address + ". Please use 95_char_long_monero_wallet_address format"; this.valid_miner = false; return; @@ -808,7 +804,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.poolTypeEnum = global.protos.POOLTYPE.PPLNS; } - this.wallet_key = this.payout + " " + this.bitcoin + " " + this.poolTypeEnum + " " + JSON.stringify(this.payout_div) + " "; + this.wallet_key = this.payout + " " + this.poolTypeEnum + " " + JSON.stringify(this.payout_div) + " "; // 3c) diff calc stuff @@ -841,8 +837,12 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro global.mysql.query("SELECT id FROM users WHERE username = ? LIMIT 1", [payoutAddress]).then(function (rows) { if (rows.length > 0) return; if (global.coinFuncs.blockedAddresses.indexOf(payoutAddress) !== -1) return; - global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, email]); + global.mysql.query("INSERT INTO users (username, email) VALUES (?, ?)", [payoutAddress, email]).catch(function (error) { + console.error("SQL query failed: " + error); + }); console.log("Setting password " + email + " for " + payoutAddress); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); walletLastCheckTime[payoutAddress] = time_now; } @@ -1244,7 +1244,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro } } -// store wallet_key (address, paymentID, bitcoin, poolTypeEnum, port) -> worker_name -> isTrustedShare -> (height, difficulty, time, acc, acc2) +// store wallet_key (address, paymentID, 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 = {}; @@ -1265,7 +1265,6 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam blockHeight: bt_height, blockDiff: bt_difficulty, poolType: miner.poolTypeEnum, - bitcoin: miner.bitcoin, foundBlock: isBlockCandidate, trustedShare: isTrustedShare, poolID: global.config.pool_id, @@ -1290,7 +1289,6 @@ function storeShareDiv(miner, share_reward, share_reward2, share_num, worker_nam blockHeight: bt_height, blockDiff: bt_difficulty, poolType: miner.poolTypeEnum, - bitcoin: miner.bitcoin, foundBlock: isBlockCandidate, trustedShare: isTrustedShare, poolID: global.config.pool_id, @@ -2342,14 +2340,20 @@ if (cluster.isMaster) { setInterval(function () { 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]); + 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]).catch(function (error) { + console.error("SQL query failed: " + error); + }); } else { - global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]); + global.mysql.query("UPDATE pools SET last_checkin = ?, active = ? WHERE id = ?", [global.support.formatDate(Date.now()), true, global.config.pool_id]).catch(function (error) { + console.error("SQL query failed: " + error); + }); } global.config.ports.forEach(function (portData) { let miner_count = 0; 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]); + global.mysql.query("UPDATE ports SET lastSeen = now(), miners = ? WHERE pool_id = ? AND network_port = ?", [miner_count, global.config.pool_id, portData.port]).catch(function (error) { + console.error("SQL query failed: " + error); + }); }); }, 30*1000); @@ -2400,6 +2404,8 @@ if (cluster.isMaster) { lastBlockFixTime[port] = Date.now(); lastBlockFixCount[port] = 0; } + }).catch(function (error) { + console.error("SQL query failed: " + error); }); }, 60*1000); @@ -2508,6 +2514,8 @@ if (cluster.isMaster) { bannedAddresses[row.mining_address] = row.reason; if (is_show) console.log("Added blocked address " + row.mining_address + ": " + row.reason); }); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); global.mysql.query("SELECT mining_address, message FROM notifications").then(function (rows) { notifyAddresses = {}; @@ -2515,6 +2523,8 @@ if (cluster.isMaster) { notifyAddresses[row.mining_address] = row.message; if (is_show) console.log("Added notify address " + row.mining_address + ": " + row.message); }); + }).catch(function (error) { + console.error("SQL query failed: " + error); }); } diff --git a/lib/support.js b/lib/support.js index e6580547..3a4bfade 100644 --- a/lib/support.js +++ b/lib/support.js @@ -237,11 +237,16 @@ function getCoinHashFactor(coin, callback) { return callback(null); } callback(parseFloat(rows[0].item_value)); + }).catch(function (error) { + console.error("SQL query failed: " + error); + return callback(0); }); } function setCoinHashFactor(coin, coinHashFactor) { - global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'coinHashFactor" + coin + "'", [coinHashFactor]); + global.mysql.query("UPDATE config SET item_value = ? WHERE module = 'daemon' and item = 'coinHashFactor" + coin + "'", [coinHashFactor]).catch(function (error) { + console.error("SQL query failed: " + error); + }); global.config.daemon["coinHashFactor" + coin] = coinHashFactor; } @@ -264,14 +269,6 @@ function decimalToCoin(amount) { return Math.round(amount * global.config.coin.sigDigits); } -function bitcoinDecimalToCoin(amount) { - return Math.round(amount * 100000000); -} - -function bitcoinCoinToDecimal(amount) { - return amount / 100000000; -} - function blockCompare(a, b) { if (a.height < b.height) { return 1; @@ -330,8 +327,6 @@ module.exports = function () { formatDate: formatDate, coinToDecimal: coinToDecimal, decimalToCoin: decimalToCoin, - bitcoinDecimalToCoin: bitcoinDecimalToCoin, - bitcoinCoinToDecimal: bitcoinCoinToDecimal, formatDateFromSQL: formatDateFromSQL, blockCompare: blockCompare, sendEmail: sendEmail, diff --git a/package.json b/package.json index e0a64e77..9cbaa452 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "range": "0.0.3", "request": "^2.79.0", "request-json": "0.6.5", - "shapeshift.io": "1.3.0", "sprintf-js": "^1.0.3", "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", From 19659d70f5f1ec2fcfebf115fb830f79d38bef18 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 Feb 2022 02:53:58 +0000 Subject: [PATCH 2240/2430] 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 78466766..f58c08b7 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -326,7 +326,7 @@ function makePayments() { 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; - } else if (ayee.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))) { + } else if (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; From 07d6d1dfe17f33ae30dd6f480d520b928d1eab3f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 Feb 2022 03:05:33 +0000 Subject: [PATCH 2241/2430] Fixed typo --- lib/payment_systems/xmr.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/payment_systems/xmr.js b/lib/payment_systems/xmr.js index f58c08b7..e8913479 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -321,19 +321,21 @@ function makePayments() { } if (payee.amount >= threshold) { payee.setFeeAmount(); - if (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; - } else if (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 { - console.error("Unsupported payment to " + payee.id + " was found"); + if (payee.paymentID === null && payee.amount !== 0 && payee.amount > 0) { + if (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; + } else if ( 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(); + } } } return next(); From 3a3ffffec7657d26e05d634f484b3401f69b0c0a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 13 Feb 2022 03:34:58 +0000 Subject: [PATCH 2242/2430] More debug --- lib/api.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lib/api.js b/lib/api.js index 9e1f7af0..1995a6a8 100644 --- a/lib/api.js +++ b/lib/api.js @@ -28,6 +28,13 @@ 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'); +let RPM = 0; + +setInterval(function () { + console.log(threadName + "RPM: " + RPM); + RPM = 0; +}, 60*1000); + //var whitelist = ['https://moneroocean.stream', 'https://test.moneroocean.stream']; //app.use(cors({ // origin: function (origin, callback) { return callback(null, whitelist.indexOf(origin) !== -1 || !origin); } @@ -184,6 +191,7 @@ function getAddressStats(address, extCallback){ // Config API app.get('/config', cache('5 minutes'), function (req, res) { + ++ RPM; res.json({ pplns_fee: global.config.payout.pplnsFee, pps_fee: global.config.payout.ppsFee, @@ -202,6 +210,7 @@ app.get('/config', cache('5 minutes'), function (req, res) { // Pool APIs app.get('/pool/address_type/:address', cache('10 seconds'), function (req, res) { + ++ RPM; let address = req.params.address; if (addressBase58Prefix === cnUtil.address_decode(Buffer.from(address))) { res.json({valid: true, address_type: global.config.general.coinCode}); @@ -211,11 +220,13 @@ app.get('/pool/address_type/:address', cache('10 seconds'), function (req, res) }); app.get('/pool/motd', cors(), cache('60 seconds'), function (req, res) { + ++ RPM; 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) { + ++ RPM; let localCache = global.database.getCache('pool_stats_global'); delete(localCache.minerHistory); delete(localCache.hashHistory); @@ -224,14 +235,17 @@ app.get('/pool/stats', cors(), cache('10 seconds'), function (req, res) { }); app.get('/pool/chart/hashrate', cache('10 seconds'), function (req, res) { + ++ RPM; res.json(global.database.getCache('global_stats')['hashHistory']); }); app.get('/pool/chart/miners', cache('10 seconds'), function (req, res) { + ++ RPM; res.json(global.database.getCache('global_stats')['minerHistory']); }); app.get('/pool/chart/hashrate/:pool_type', cache('10 seconds'), function (req, res) { + ++ RPM; let pool_type = req.params.pool_type; let localCache; switch (pool_type) { @@ -251,6 +265,7 @@ app.get('/pool/chart/hashrate/:pool_type', cache('10 seconds'), function (req, r }); app.get('/pool/chart/miners/:pool_type', cache('10 seconds'), function (req, res) { + ++ RPM; let pool_type = req.params.pool_type; let localCache; switch (pool_type) { @@ -270,6 +285,7 @@ app.get('/pool/chart/miners/:pool_type', cache('10 seconds'), function (req, res }); app.get('/pool/stats/:pool_type', cache('10 seconds'), function (req, res) { + ++ RPM; let pool_type = req.params.pool_type; let localCache; switch (pool_type) { @@ -294,40 +310,47 @@ app.get('/pool/stats/:pool_type', cache('10 seconds'), function (req, res) { }); app.get('/pool/ports', cache('10 seconds'), function (req, res) { + ++ RPM; res.json(global.database.getCache('poolPorts')); }); app.get('/pool/blocks/:pool_type', cache('10 seconds'), function (req, res) { + ++ RPM; 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, page*limit, (page + 1) * limit)); }); app.get('/pool/altblocks/:pool_type', cache('10 seconds'), function (req, res) { + ++ RPM; 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, null, page*limit, (page + 1) * limit)); }); app.get('/pool/blocks', cache('10 seconds'), function (req, res) { + ++ RPM; 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(null, page*limit, (page + 1) * limit)); }); app.get('/pool/altblocks', cache('10 seconds'), function (req, res) { + ++ RPM; 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, null, page*limit, (page + 1) * limit)); }); app.get('/pool/coin_altblocks/:coin_port', cache('10 seconds'), function (req, res) { + ++ RPM; 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), page*limit, (page + 1) * limit)); }); app.get('/pool/payments/:pool_type', cache('1 minute'), function (req, res) { + ++ RPM; let pool_type = req.params.pool_type; let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; @@ -377,6 +400,7 @@ app.get('/pool/payments/:pool_type', cache('1 minute'), function (req, res) { let tx_pool_types = {}; app.get('/pool/payments', cache('1 minute'), function (req, res) { + ++ RPM; let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 10; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; let query = "SELECT * FROM transactions ORDER BY id DESC LIMIT ? OFFSET ?"; @@ -434,16 +458,19 @@ app.get('/pool/payments', cache('1 minute'), function (req, res) { // Network APIs app.get('/network/stats', cache('10 seconds'), function (req, res) { + ++ RPM; res.json(global.database.getCache('networkBlockInfo')); }); // Miner APIs app.get('/miner/:address/identifiers', cache('10 seconds'), function (req, res) { + ++ RPM; let address = req.params.address; return res.json(get_identifiers(address)); }); app.get('/miner/:address/payments', cache('1 minute'), function (req, res) { + ++ RPM; let limit = typeof(req.query.limit) !== 'undefined' ? Number(req.query.limit) : 25; let page = typeof(req.query.page) !== 'undefined' ? Number(req.query.page) : 0; let address_parts = req.params.address.split('.'); @@ -486,6 +513,7 @@ app.get('/miner/:address/payments', cache('1 minute'), function (req, res) { }); app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) { + ++ RPM; 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; @@ -529,12 +557,14 @@ app.get('/miner/:address/block_payments', cache('1 minute'), function (req, res) }); app.get('/miner/:address/stats/allWorkers', cache('10 seconds'), function (req, res) { + ++ RPM; getAllWorkerStats(req.params.address, function(err, data){ return res.json(data); }); }); app.get('/miner/:address/stats/:identifier', cache('10 seconds'), function (req, res) { + ++ RPM; let address = req.params.address; let identifier = req.params.identifier; let memcKey = address + "_" + identifier; @@ -557,26 +587,31 @@ app.get('/miner/:address/stats/:identifier', cache('10 seconds'), function (req, }); app.get('/miner/:address/chart/hashrate', cache('10 seconds'), function (req, res) { + ++ RPM; return res.json(global.database.getCache("history:" + req.params.address)['hashHistory']); }); app.get('/miner/:address/chart/hashrate/allWorkers', cache('10 seconds'), function (req, res) { + ++ RPM; getAllWorkerHashCharts(req.params.address, function(err, data){ return res.json(data); }); }); app.get('/miner/:address/chart/hashrate/:identifier', cache('10 seconds'), function (req, res) { + ++ RPM; return res.json(global.database.getCache("history:" + req.params.address + "_" + req.params.identifier)['hashHistory']); }); app.get('/miner/:address/stats', cache('1 minute'), function (req, res) { + ++ RPM; getAddressStats(req.params.address, function(err, data){ return res.json(data); }); }); app.get('/user/:address', function (req, res) { + ++ RPM; 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({payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}); @@ -590,6 +625,7 @@ app.get('/user/:address', function (req, res) { }); app.post('/user/subscribeEmail', function (req, res) { + ++ RPM; const username = req.body.username; if (!username) return res.status(401).send({'success': false, 'msg': "No \"username\" parameter was found"}); if (!("enabled" in req.body)) return res.status(401).send({'success': false, 'msg': "No \"enabled\" parameter was found"}); @@ -640,6 +676,7 @@ app.post('/user/subscribeEmail', function (req, res) { }); app.get('/user/:address/unsubscribeEmail', function (req, res) { + ++ RPM; 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.status(401).json({'error': 'This XMR address does not have email subscription'}); @@ -653,6 +690,7 @@ app.get('/user/:address/unsubscribeEmail', function (req, res) { }); app.post('/user/updateThreshold', function (req, res) { + ++ RPM; 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; @@ -675,6 +713,7 @@ app.post('/user/updateThreshold', function (req, res) { // Authentication app.post('/authenticate', function (req, res) { + ++ RPM; let hmac; try{ hmac = crypto.createHmac('sha256', global.config.api.secKey).update(req.body.password).digest('hex'); @@ -733,11 +772,13 @@ secureRoutes.use(function (req, res, next) { // Secure/logged in routes. secureRoutes.get('/tokenRefresh', function (req, res) { + ++ RPM; let token = jwt.sign({id: req.decoded.id, admin: req.decoded.admin}, global.config.api.secKey, {expiresIn: '1d'}); return res.json({'msg': token}); }); secureRoutes.get('/', function (req, res) { + ++ RPM; global.mysql.query("SELECT payout_threshold, enable_email, email FROM users WHERE id = ?", [req.decoded.id]).then(function(row){ return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email, email: row[0].email}}); }).catch(function (error) { @@ -747,6 +788,7 @@ secureRoutes.get('/', function (req, res) { }); secureRoutes.post('/changePassword', function (req, res) { + ++ RPM; let hmac = crypto.createHmac('sha256', global.config.api.secKey).update(req.body.password).digest('hex'); global.mysql.query("UPDATE users SET pass = ? WHERE id = ?", [hmac, req.decoded.id]).then(function () { return res.json({'msg': 'Password updated'}); @@ -757,6 +799,7 @@ secureRoutes.post('/changePassword', function (req, res) { }); secureRoutes.post('/changeEmail', function (req, res) { + ++ RPM; global.mysql.query("UPDATE users SET email = ? WHERE id = ?", [req.body.email, req.decoded.id]).then(function () { return res.json({'msg': 'Updated email was set to: ' + req.body.email}); }).catch(function (error) { @@ -766,6 +809,7 @@ secureRoutes.post('/changeEmail', function (req, res) { }); secureRoutes.post('/toggleEmail', function (req, res) { + ++ RPM; global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE id = ?", [req.decoded.id]).then(function () { return res.json({'msg': 'Email toggled'}); }).catch(function (error) { @@ -775,6 +819,7 @@ secureRoutes.post('/toggleEmail', function (req, res) { }); secureRoutes.post('/changePayoutThreshold', function (req, res) { + ++ RPM; 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 56266a49ea219ca1d77ce838e51e7fa1c6cfc471 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Feb 2022 19:14:02 +0000 Subject: [PATCH 2243/2430] Use generic eth block submit method --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 9b860815..bb7e6a52 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1561,7 +1561,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste } 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); + global.support.rpcPortDaemon2(blockTemplate.port, "", { method: "eth_submitWork", 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)) { From 21ed12365fbe4421895d77f0a6b25694ae9aac3c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 Mar 2022 23:42:14 +0000 Subject: [PATCH 2244/2430] Skip unsupported RTM tx --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9cbaa452..dc53c41f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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.1.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From c4ba90ac8db662e48af275b07a4243f5e677548f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 8 Mar 2022 23:42:41 +0000 Subject: [PATCH 2245/2430] Fixed for ETH --- manage_scripts/altblock_add_auto.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manage_scripts/altblock_add_auto.js b/manage_scripts/altblock_add_auto.js index fafe2f9a..2df93b6e 100644 --- a/manage_scripts/altblock_add_auto.js +++ b/manage_scripts/altblock_add_auto.js @@ -42,7 +42,8 @@ require("../init_mini.js").init(function() { console.error("Can't get block height: " + JSON.stringify(body_header)); process.exit(0); } - + body_header.difficulty = parseInt(body_header.difficulty); + body_header.timestamp = parseInt(body_header.timestamp); global.database.storeAltBlock(body_header.timestamp, global.protos.AltBlock.encode({ hash: hash, difficulty: body_header.difficulty, From 8260b23e30cac6eae44cc1c34023a9fc6dabfa44 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 10 Mar 2022 01:51:48 +0000 Subject: [PATCH 2246/2430] Added ETH block submit debug --- lib/pool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index bb7e6a52..d7a66ada 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1493,7 +1493,9 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste return cb("0000000000000000000000000000000000000000000000000000000000000000"); }); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { - return cb(rpcResult.result.substr(2)); + //return cb(rpcResult.result.substr(2)); + console.log("submit ETH: " + JSON.stringify(blockData) + " -> " + JSON.stringify(rpcResult)); + return cb("0000000000000000000000000000000000000000000000000000000000000000"); } else { return cb(global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex')); } From 28d0978276fcb0340975658864c15ff5db67b7d0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Mar 2022 00:24:48 +0000 Subject: [PATCH 2247/2430] Fixed RTM tx parsing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc53c41f..c16b8b78 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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.2.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From 9da996a2783ee0d16d028f690d33e7c313918921 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Mar 2022 00:48:26 +0000 Subject: [PATCH 2248/2430] Fixed RTM tx parsing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c16b8b78..499f24ca 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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.2.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From ab49ac482764ecd6000a73c2e964374714e9cd50 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 11 Mar 2022 00:53:05 +0000 Subject: [PATCH 2249/2430] Fixed RTM tx parsing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 499f24ca..5ded14b5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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.2.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.3", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" } } From 0b941ad603de87bff7fcad6b774dec69c4226a41 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 12 Mar 2022 00:53:15 +0000 Subject: [PATCH 2250/2430] Detect block hash for geth' --- lib/coins/xmr.js | 46 +++++++++++++++++++++++++++++++++++++++++++--- lib/pool.js | 6 +++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 34febba9..00b3f178 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -444,14 +444,14 @@ function Coin(data){ 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(); + return next(null); } const uncleIndex = body_height.uncles.indexOf("0x" + blockHash); - if (uncleIndex === -1) return next(); + if (uncleIndex === -1) return next(null); 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_getUncleByBlockNumberAndIndex(0x" + block_height.toString(16) + ", 0x" + uncleIndex.toString(16) + "): " + JSON.stringify(body_uncle)); - return next(); + return next(null); } return next((ETH_BASE_REWARD * (8 - (parseInt(body_height.number) - parseInt(body_uncle.result.number))) / 8) * ETH_MULTIPLIER); }); @@ -640,6 +640,46 @@ function Coin(data){ return this.getPortBlockTemplate(global.config.daemon.port, callback); }; + + this.ethBlockCheck = function(miner_hex, nonce_hex, block_height_hex, callback) { + const port = 8545; + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByNumber', params: [ block_height_hex, true ] }, function (body) { + if (!body || !body.result) { + console.error("getPortBlockHeaderByID(" + port + ", " + block_height_hex + "): " + JSON.stringify(body)); + return callback(null, null); + } + if (body.result.miner === miner_hex && body.result.nonce == nonce_hex) return callback(body.result.hash); + block_height_hex = body.result.number; + async.eachSeries(Array(body.result.uncles.length).fill().map((element, index) => index), function(index, next) { + global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getUncleByBlockNumberAndIndex', params: [ block_height_hex, "0x" + index.toString(16) ] }, function (body_uncle) { + if (!body_uncle || !body_uncle.result) { + console.error("eth_getUncleByBlockNumberAndIndex(0x" + block_height_hex + ", 0x" + index.toString(16) + "): " + JSON.stringify(body_uncle)); + return next(null); + } + return next(body_uncle.result.miner === miner_hex && body_uncle.result.nonce == nonce_hex ? body_uncle.result.hash : null); + }); + }, function(block_hash) { + const block_height = parseInt(block_height_hex); + return callback(block_hash, block_height); + }); + }); + }; + + this.ethBlockFind = function(nonce_hex, callback) { + const miner_hex = global.config.pool["address_" + 8545]; + global.coinFuncs.ethBlockCheck(miner_hex, "latest", function(block_hash, block_height) { + if (block_hash) return callback(block_hash); + if (!block_height) return callback(null); + async.eachSeries(Array(32).fill().map((element, index) => block_height - index - 1), function(block_height, next) { + global.coinFuncs.ethBlockCheck(miner_hex, nonce_hex, "0x" + block_height.toString(16), function(block_hash) { + return next(block_hash); + }); + }, function(block_hash) { + return callback(block_hash); + }); + }); + }; + this.baseDiff = cnUtil.baseDiff; this.baseRavenDiff = cnUtil.baseRavenDiff; diff --git a/lib/pool.js b/lib/pool.js index d7a66ada..15ccd7b3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1493,9 +1493,9 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste return cb("0000000000000000000000000000000000000000000000000000000000000000"); }); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { - //return cb(rpcResult.result.substr(2)); - console.log("submit ETH: " + JSON.stringify(blockData) + " -> " + JSON.stringify(rpcResult)); - return cb("0000000000000000000000000000000000000000000000000000000000000000"); + setTimeout(global.coinFuncs.ethBlockFind, 30*1000, blockData[0], function(block_hash) { + return cb(block_hash ? block_hash.substr(2) : "0000000000000000000000000000000000000000000000000000000000000000"); + }); } else { return cb(global.coinFuncs.getBlockID(blockData, blockTemplate.port).toString('hex')); } From 45a145961aa04e099c176ff02b71743be78b40fa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 15 Mar 2022 15:14:30 +0000 Subject: [PATCH 2251/2430] 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 00b3f178..f19213a6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -667,7 +667,7 @@ function Coin(data){ this.ethBlockFind = function(nonce_hex, callback) { const miner_hex = global.config.pool["address_" + 8545]; - global.coinFuncs.ethBlockCheck(miner_hex, "latest", function(block_hash, block_height) { + global.coinFuncs.ethBlockCheck(miner_hex, nonce_hex, "latest", function(block_hash, block_height) { if (block_hash) return callback(block_hash); if (!block_height) return callback(null); async.eachSeries(Array(32).fill().map((element, index) => block_height - index - 1), function(block_height, next) { From eec256be2c177c0a345b8822f35b3b92d1090f12 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 25 Mar 2022 17:19:57 +0000 Subject: [PATCH 2252/2430] Reduced time to store paid block distribution in DB --- lib/longRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 31584ae0..777653d1 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -116,7 +116,7 @@ function cleanBlockBalanceTable() { global.database.getValidLockedAltBlocks().forEach(function (block) { locked_block_hashes[block.hash] = 1; }); console.log("Starting cleaning the block balance table. Found " + Object.keys(locked_block_hashes).length + " locked blocks"); - global.mysql.query("SELECT hex FROM paid_blocks WHERE paid_time > (NOW() - INTERVAL 7 DAY)").then(function (rows_keep) { + global.mysql.query("SELECT hex FROM paid_blocks WHERE paid_time > (NOW() - INTERVAL 2 DAY)").then(function (rows_keep) { console.log("Got " + rows_keep.length + " recent blocks"); rows_keep.forEach(function (row) { locked_block_hashes[row.hex] = 1; }); let deleted_row_count = 0; From 9cf3f557228926730f438a97cce53b04eeac0fba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 29 Mar 2022 01:47:45 +0000 Subject: [PATCH 2253/2430] DERO-HE support --- README.md | 2 +- lib/coins/xmr.js | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5cc0712e..16f1778b 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XWP - ```fh4MCJrakhWGoS6Meqp6UxGE1GNfAjKaRdPjW36rTffDiqvEq2HWEKZhrbYRw7XJb3CXxkjL3tcYGTT39m5qgjvk1ap4bVu1R``` * XEQ - ```Tvzp9tTmdGP9X8hCEw1Qzn18divQajJYTjR5HuUzHPKyLK5fzRt2X73FKBDzcnHMDJKdgsPhUDVrKHVcDJQVmLBg33NbkdjQb``` * XTA - ```ipN5cNhm7RXAGACP4ZXki4afT3iJ1A6Ka5U4cswE6fBPDcv8JpivurBj3vu1bXwPyb8KZEGsFUYMmToFG4N9V9G72X4WpAQ8L``` -* DERO - ```dERokvcrnuWH1ai1QmZQc9cgxrLwE3rX3TbhdrnLmi3BVZmf197qd5FaFqmPMp5dZ3igXfVQwUUMgTSjpVKDtUeb6DT2xp64XJ``` +* DERO - ```dero1qygrgnz9gea2rqgwhdtpfpa3mvagt5uyq0g92nurwrpk6wnn7hdnzqgudsv6t``` * CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` * BLOC - ```abLoc5iUG4a6oAb2dqygxkS5M2uHWx16zHb9fUWMzpSEDwm6T7PSq2MLdHonWZ16CGfnJKRomq75aZyviTo6ZjHeYQMzNAEkjMg``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index f19213a6..24eac921 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -98,7 +98,7 @@ const port2algo = { "38081": "cn/half", // MSR "48782": "argon2/chukwav2", // Lethean "9231" : "cn/gpu", // XEQ - "20206": "astrobwt", // DERO + "20206": "astrobwt/v2", // DERO // "18181": "cn/0", // XMC "16000": "cn/gpu", // CCX "8766" : "kawpow", // RVN @@ -378,6 +378,7 @@ function Coin(data){ } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { if (body && body.hasOwnProperty('result')) { + if (port == 20206) body.result.block_header.timestamp /= 1000; // DERO is special here return callback(null, body.result.block_header); } else { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); @@ -408,7 +409,7 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - body.result.reward = (port == 8766 ? 2500 : 3750) * 100000000; // TODO: Change to 2500 on (~January 2022) at block 2,100,000 + body.result.reward = (port == 8766 ? 2500 : 3750) * 100000000; if (port == 9998) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); @@ -487,6 +488,7 @@ function Coin(data){ } body.result.block_header.reward = 0; + if (port == 20206) body.result.block_header.timestamp /= 1000; // DERO is special here let reward_check = 0; const blockJson = JSON.parse(body.result.json); @@ -578,7 +580,8 @@ function Coin(data){ }); } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { - if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')){ + if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { + if (port == 20206) body.result.block_header.timestamp /= 1000; // DERO is special here return callback(null, body.result.block_header); } else { if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); @@ -989,7 +992,7 @@ function Coin(data){ 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"]; + if ("astrobwt/v2" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt/v2"]; //if ("cn/0" in algos_perf) coin_perf["XMC"] = algos_perf["cn/0"]; @@ -1036,7 +1039,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 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala - case 20206: return multiHashing.astrobwt(convertedBlob, 0); // Dero + case 20206: return multiHashing.astrobwt2(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.argon2(convertedBlob, 2); // Lethean From 89d26a0ad80fd2e19f0169949f2ff74c49644ce9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 1 Apr 2022 22:17:01 +0000 Subject: [PATCH 2254/2430] DERO HE support' --- lib/coins/xmr.js | 29 +++++++++++++++++++++++------ package.json | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 24eac921..b065fae2 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -378,7 +378,10 @@ function Coin(data){ } else { global.support.rpcPortDaemon(port, 'getblockheaderbyheight', {"height": blockId}, function (body) { if (body && body.hasOwnProperty('result')) { - if (port == 20206) body.result.block_header.timestamp /= 1000; // DERO is special here + if (port == 20206) { // DERO is special here + body.result.block_header.timestamp /= 1000; + body.result.block_header.difficulty *= 18; + } return callback(null, body.result.block_header); } else { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); @@ -488,7 +491,10 @@ function Coin(data){ } body.result.block_header.reward = 0; - if (port == 20206) body.result.block_header.timestamp /= 1000; // DERO is special here + if (port == 20206) { // DERO is special here + body.result.block_header.timestamp /= 1000; + body.result.block_header.difficulty *= 18; + } let reward_check = 0; const blockJson = JSON.parse(body.result.json); @@ -581,7 +587,10 @@ function Coin(data){ } else { global.support.rpcPortDaemon(port, 'getlastblockheader', [], function (body) { if (typeof(body) !== 'undefined' && body.hasOwnProperty('result')) { - if (port == 20206) body.result.block_header.timestamp /= 1000; // DERO is special here + if (port == 20206) { // DERO is special here + body.result.block_header.timestamp /= 1000; + body.result.block_header.difficulty *= 18; + } return callback(null, body.result.block_header); } else { if (!no_error_report) console.error("Last block header invalid: " + JSON.stringify(body)); @@ -634,6 +643,13 @@ 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){ + if (port == 20206) { // DERO is special here + body.result.timestamp /= 1000; + body.result.difficulty *= 18; + body.result.mbl_difficulty = body.result.blockhashing_blob.charAt(0) == '4' ? body.result.difficulty : body.result.difficulty * 9; + body.result.reserved_offset = 36; + body.result.prev_hash = body.result.blockhashing_blob; // need to keep prev_hash different for miniblocks or BT update will be ignored in pool.js + } return callback(body && body.result ? body.result : null); }); } @@ -815,7 +831,8 @@ function Coin(data){ // Overkill? Sure. But that's what we do here. Overkill. // Set these params equal to values we get from upstream (if they are set) - this.difficulty = template.difficulty; + // DERO-HE case, where mbl is miniblock + this.difficulty = template.mbl_difficulty ? template.mbl_difficulty : template.difficulty; this.height = template.height; this.bits = template.bits; this.seed_hash = template.seed_hash; @@ -862,7 +879,7 @@ function Coin(data){ 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; + this.reserved_offset = template.reserved_offset; } 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); @@ -1039,7 +1056,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 11812: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 3); // Scala - case 20206: return multiHashing.astrobwt2(convertedBlob, 0); // Dero + case 20206: return multiHashing.astrobwt(convertedBlob, 1); // 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.argon2(convertedBlob, 2); // Lethean diff --git a/package.json b/package.json index 5ded14b5..577fc3c2 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v26.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v27.0.0" } } From 8936f679a41307384fd630e8f079212a069f3732 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 10 Apr 2022 23:07:42 +0000 Subject: [PATCH 2255/2430] Fixed dero 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 b065fae2..edbe3dbb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -643,7 +643,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){ - if (port == 20206) { // DERO is special here + if (body && body.result && port == 20206) { // DERO is special here body.result.timestamp /= 1000; body.result.difficulty *= 18; body.result.mbl_difficulty = body.result.blockhashing_blob.charAt(0) == '4' ? body.result.difficulty : body.result.difficulty * 9; From cb023692142774af4d12793167c90ff5ce268528 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 4 Jul 2022 17:50:17 +0000 Subject: [PATCH 2256/2430] More debug --- 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 e8913479..564a1657 100644 --- a/lib/payment_systems/xmr.js +++ b/lib/payment_systems/xmr.js @@ -289,7 +289,7 @@ function makePayments() { return; } - debug("Starting makePayments"); + console.log("Starting makePayments"); global.mysql.query("SELECT * FROM balance WHERE amount >= ?", [global.support.decimalToCoin(global.config.payout.walletMin)]).then(function (rows) { console.log("Loaded all payees into the system for processing"); let paymentDestinations = []; From 5902aab5c283c4dbd7b7c241b87d0432bef08261 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Jul 2022 04:43:15 +0000 Subject: [PATCH 2257/2430] Added docker localhost ip --- deployment/base.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 41dc6712..c8c13501 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -1,7 +1,9 @@ CREATE DATABASE pool; CREATE USER pool@`127.0.0.1` IDENTIFIED WITH mysql_native_password BY '98erhfiuehw987fh23d'; +CREATE USER pool@`172.17.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@`172.17.0.1`; GRANT ALL ON pool.* TO pool@localhost; FLUSH PRIVILEGES; USE pool; From db7a0f5b74bd014fededb1f8fa347bc08bd8f92e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Jul 2022 18:00:09 +0000 Subject: [PATCH 2258/2430] Bug fix --- lib/pool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 15ccd7b3..2ee6c720 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2315,8 +2315,7 @@ function getUniqueWorkerID(cb) { } 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); - } - global.mysql.query("SELECT MAX(id) as maxId FROM pool_workers").then(function (rows_max) { + } else 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); From 6d471f1a62fb77000bdb96af9e93b0799ddba592 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Jul 2022 23:13:51 +0000 Subject: [PATCH 2259/2430] Improved remote share security --- lib/remoteShare.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/remoteShare.js b/lib/remoteShare.js index ab9cafb6..399e8e2d 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -31,7 +31,7 @@ function messageHandler(message) { process.on('message', messageHandler); -app.post('/leafApi', function (req, res) { +app.post('/leafApi', 'localhost', function (req, res) { try { let msgData = global.protos.WSData.decode(req.body); if (msgData.key !== global.config.api.authKey) { From c00b0af1fd054f8f8415ed039f35ed1fb2e77e22 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Jul 2022 23:16:32 +0000 Subject: [PATCH 2260/2430] Improved remote share security --- lib/remoteShare.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/remoteShare.js b/lib/remoteShare.js index 399e8e2d..f3cf604e 100644 --- a/lib/remoteShare.js +++ b/lib/remoteShare.js @@ -31,7 +31,7 @@ function messageHandler(message) { process.on('message', messageHandler); -app.post('/leafApi', 'localhost', function (req, res) { +app.post('/leafApi', function (req, res) { try { let msgData = global.protos.WSData.decode(req.body); if (msgData.key !== global.config.api.authKey) { @@ -112,7 +112,7 @@ if (cluster.isMaster) { workerList.push(worker); }); } else { - app.listen(8000, function () { + app.listen(8000, 'localhost', function () { console.log('Process ' + process.pid + ' is listening to all incoming requests'); }); } From 83068e475cb8d282db701af9ad0064f3784fd416 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 2 Aug 2022 03:41:01 +0000 Subject: [PATCH 2261/2430] ETC support --- README.md | 9 +++++---- deployment/base.sql | 3 +++ ex_keys.example.json | 2 ++ lib/blockManager.js | 2 +- lib/coins/xmr.js | 29 +++++++++++++++++------------ lib/pool.js | 4 ++-- package.json | 2 +- 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 16f1778b..6bb423d1 100644 --- a/README.md +++ b/README.md @@ -283,10 +283,11 @@ If you'd like to make a one time donation, the addresses are as follows: * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` * RTM - ```RUCyaEZxQu3Eure73XPQ57si813RYAMQKC``` * ERG - ```9fe533kUzAE57YfPP6o3nzsYMKN2W2uCxvg8KG8Vn5DDeJGetRw``` -* BTC - ```3BzvMuLStA388kYZ9nudfm8L22937dSPS3``` -* BCH - ```qrhww48p5s6zw9twhc7cujgwp7vym2k4vutem6f92p``` -* ETH - ```0xCF8BABC074C487Ae17F9Ce0394eab492E6A35658``` -* LTC - ```MCkjQo99VzoeZQ1piDzLDb4uqNSDRZpx55``` +* BTC - ```3HRbMgcvbqHVW7P34MNGvF2Gh3DE26iHdw``` +* BCH - ```18sKoDSjLCFW9kZrXuza1qzEERnKi7bx8S``` +* ETH - ```0xfE23a61548FCCE159a541FAe9e16cEB92Da650ed``` +* ETC - ```0x4480Ad73a113BEFf05B2079E38D90c9757Ecb063``` +* LTC - ```MGj8PU1PpTNDDqRHmuEqfDpH3gxp6cJrUU``` Credits ======= diff --git a/deployment/base.sql b/deployment/base.sql index c8c13501..e3e5a101 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', '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', 'coinHashFactorETC', '0', 'float', 'ETC 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'); @@ -251,6 +252,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 ('wallet', 'address', '127.0.0.1', 'string', 'Default 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_8645', '127.0.0.1', 'string', 'ETC 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'); @@ -314,6 +316,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_8645', '', 'string', 'Address to mine to for 8645 (Ethereum Classic) 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.'); diff --git a/ex_keys.example.json b/ex_keys.example.json index 12e71b28..8615ffd2 100644 --- a/ex_keys.example.json +++ b/ex_keys.example.json @@ -7,4 +7,6 @@ "QRYPTOS_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==", "LIVECOIN": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "LIVECOIN_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "COINEX": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "COINEX_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } \ No newline at end of file diff --git a/lib/blockManager.js b/lib/blockManager.js index 918e22ce..4c724dcf 100644 --- a/lib/blockManager.js +++ b/lib/blockManager.js @@ -490,7 +490,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 && block.port != 8545) { + } else if (err !== null && block.port != 8545 && block.port != 8645) { 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 edbe3dbb..123bf4e7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -44,6 +44,7 @@ const port2coin = { "16000": "CCX", "8766" : "RVN", "8545" : "ETH", + "8645" : "ETC", "2086" : "BLOC", "9053" : "ERG", "9998" : "RTM", @@ -73,6 +74,7 @@ const port2blob_num = { "20206": 100, // DERO "8766" : 101, // RVN "8545" : 102, // ETH + "8645" : 102, // ETC "2086" : 1, // BLOC "9053" : 103, // ERG "9998" : 104, // RTM @@ -103,6 +105,7 @@ const port2algo = { "16000": "cn/gpu", // CCX "8766" : "kawpow", // RVN "8545" : "ethash", // ETH + "8645" : "etchash", // ETC "2086" : "cn-heavy/xhv", // BLOC "9053" : "autolykos2", // ERG "9998" : "ghostrider", // RTM @@ -257,7 +260,7 @@ function calcEthReward(block, tx_reciepts) { tx_reciepts.forEach(function(tx) { if (tx.result && tx.result.gasUsed) fee += parseInt(tx.result.gasUsed) * gas_prices[tx.result.transactionHash]; }); - fee -= parseInt(block.baseFeePerGas) * parseInt(block.gasUsed); + if (block.baseFeePerGas) fee -= parseInt(block.baseFeePerGas) * parseInt(block.gasUsed); return (ETH_BASE_REWARD + ETH_BASE_REWARD * (block.uncles.length / 32)) * ETH_MULTIPLIER + fee; } @@ -341,7 +344,7 @@ function Coin(data){ } return global.coinFuncs.getPortAnyBlockHeaderByHash(port, body.result, false, callback); }); - } else if (port == 8545) { + } else if (port == 8545 || port == 8645) { 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) { @@ -416,7 +419,7 @@ function Coin(data){ if (port == 9998) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); - } else if (port == 8545) { + } else if (port == 8545 || port == 8645) { 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)); @@ -572,7 +575,7 @@ function Coin(data){ return callback(err, body2); }); }); - } else if (port == 8545) { + } else if (port == 8545 || port == 8645) { 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); @@ -627,7 +630,7 @@ function Coin(data){ } else return callback(null); }); - } else if (port == 8545) { + } else if (port == 8545 || port == 8645) { 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); }); @@ -660,8 +663,7 @@ function Coin(data){ }; - this.ethBlockCheck = function(miner_hex, nonce_hex, block_height_hex, callback) { - const port = 8545; + this.ethBlockCheck = function(port, miner_hex, nonce_hex, block_height_hex, callback) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByNumber', params: [ block_height_hex, true ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByID(" + port + ", " + block_height_hex + "): " + JSON.stringify(body)); @@ -684,13 +686,13 @@ function Coin(data){ }); }; - this.ethBlockFind = function(nonce_hex, callback) { - const miner_hex = global.config.pool["address_" + 8545]; - global.coinFuncs.ethBlockCheck(miner_hex, nonce_hex, "latest", function(block_hash, block_height) { + this.ethBlockFind = function(port, nonce_hex, callback) { + const miner_hex = global.config.pool["address_" + port]; + global.coinFuncs.ethBlockCheck(port, miner_hex, nonce_hex, "latest", function(block_hash, block_height) { if (block_hash) return callback(block_hash); if (!block_height) return callback(null); async.eachSeries(Array(32).fill().map((element, index) => block_height - index - 1), function(block_height, next) { - global.coinFuncs.ethBlockCheck(miner_hex, nonce_hex, "0x" + block_height.toString(16), function(block_hash) { + global.coinFuncs.ethBlockCheck(port, miner_hex, nonce_hex, "0x" + block_height.toString(16), function(block_hash) { return next(block_hash); }); }, function(block_hash) { @@ -990,7 +992,8 @@ function Coin(data){ if ("ghostrider" in algos_perf) coin_perf["RTM"] = algos_perf["ghostrider"]; - if ("ethash" in algos_perf) coin_perf["ETH"] = algos_perf["ethash"]; + if ("ethash" in algos_perf) coin_perf["ETH"] = coin_perf["ETC"] = algos_perf["ethash"]; + if ("etchash" in algos_perf) coin_perf["ETC"] = algos_perf["etchash"]; if ("autolykos2" in algos_perf) coin_perf["ERG"] = algos_perf["autolykos2"]; @@ -1042,6 +1045,7 @@ function Coin(data){ 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 8645: return multiHashing.etchash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETC 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 @@ -1143,6 +1147,7 @@ function Coin(data){ switch (port) { case 2086: return "forknote1"; // BLOC case 8545: return "eth"; // ETH + case 8645: return "eth"; // ETC case 8766: return "raven"; // RVN case 9053: return "erg"; // ERG case 9231: return "cryptonote_loki"; // XEQ diff --git a/lib/pool.js b/lib/pool.js index 2ee6c720..008c15e8 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -330,7 +330,7 @@ function templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt // 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) { + if (port == 8545 || port == 8645) { return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_header); } else global.coinFuncs.getPortBlockTemplate(port, function (body_bt) { if (!newCoinHashFactor[coin]) { @@ -1493,7 +1493,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste return cb("0000000000000000000000000000000000000000000000000000000000000000"); }); } else if (global.coinFuncs.blobTypeEth(blob_type_num)) { - setTimeout(global.coinFuncs.ethBlockFind, 30*1000, blockData[0], function(block_hash) { + setTimeout(global.coinFuncs.ethBlockFind, 30*1000, blockTemplate.port, blockData[0], function(block_hash) { return cb(block_hash ? block_hash.substr(2) : "0000000000000000000000000000000000000000000000000000000000000000"); }); } else { diff --git a/package.json b/package.json index 577fc3c2..745cb3bc 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v27.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.0" } } From e9a287c0bfca462d8df4db71a5de118feba4a16b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 05:12:03 +0000 Subject: [PATCH 2262/2430] ETC support fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 745cb3bc..60ba521f 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.0" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.1" } } From cfce4f72b71924c161ad3cbdeedbe978abe6238b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 05:17:16 +0000 Subject: [PATCH 2263/2430] Fixes --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 60ba521f..9721859e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "async": "3.2.0", - "bignum": "^0.13.1", + "bignum": "^0.13.2", "body-parser": "^1.16.0", "circular-buffer": "1.0.2", "cluster": "0.7.7", @@ -21,7 +21,7 @@ "express": "^4.17.1", "apicache": "1.2.1", "jsonwebtoken": "^8.5.1", - "minimist": ">=1.2.3", + "minimist": ">=1.2.6", "moment": "2.21.0", "mysql": "2.18.1", "node-lmdb": "git+https://github.com/Venemo/node-lmdb.git#5941c1e553de4ae1d57a67d355b7c2dd87feaea6", From 7b1fca2ecb4f792010e14af39b3370e9fcaf0b09 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 05:19:34 +0000 Subject: [PATCH 2264/2430] Fixes --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9721859e..977c1b57 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "author": "Multiple", "license": "MIT", "dependencies": { - "async": "3.2.0", - "bignum": "^0.13.2", + "async": "3.2.2", + "bignum": "^0.13.1", "body-parser": "^1.16.0", "circular-buffer": "1.0.2", "cluster": "0.7.7", From 80f09d4b9df8146de760ad2f4def3d0791bddbbd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 05:20:44 +0000 Subject: [PATCH 2265/2430] Fixes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 977c1b57..77203311 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "apicache": "1.2.1", "jsonwebtoken": "^8.5.1", "minimist": ">=1.2.6", - "moment": "2.21.0", + "moment": "2.29.4", "mysql": "2.18.1", "node-lmdb": "git+https://github.com/Venemo/node-lmdb.git#5941c1e553de4ae1d57a67d355b7c2dd87feaea6", "promise-mysql": "3.0.0", From ac2159837b174e1c4e496d57b314a39c5ca26058 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 05:43:04 +0000 Subject: [PATCH 2266/2430] Bug fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77203311..019ef883 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v11.2.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.1" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.2" } } From f6d7ef05473f701845225cce21d32b2c82ae0923 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 16:41:59 +0000 Subject: [PATCH 2267/2430] Updated XMR 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 99e5aadf..41e0a54e 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.18.0.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 0c55e701..e7ee247c 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.18.0.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 864e1bb2..25c7a272 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.18.0.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 6e188c04..f8551280 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git reset --hard origin/master &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.17.3.0 &&\ +sudo git checkout v0.18.0.0 &&\ sudo git submodule update --force --recursive --init &&\ sudo rm -rf build &&\ sudo USE_SINGLE_BUILDDIR=1 nice make release &&\ From ac6c59de66aa91dd90440b7a2fa0414fbbd0aa64 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 19:16:54 +0000 Subject: [PATCH 2268/2430] Improved wallet reward check --- lib/coins/xmr.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 123bf4e7..22889a19 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -524,13 +524,18 @@ function Coin(data){ 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 + if (reward !== reward_check) { + if (reward_check < reward) { + console.warn(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": using lesser block reward from block header " + reward_check + " instead of higher from incoming wallet tx " + reward); + reward = reward_check; } else { - console.error(port + ": block reward does not match wallet reward: " + JSON.stringify(body) + "\n" + JSON.stringify(body2)); - return callback(true, body); + console.warn(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": using lesser block reward from incoming tx " + check + " instead of higher from block header " + reward_check); } } + if (port != 38081 && reward == 0) { // MSR can have uncle block reward here + console.error(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": both block header and incoming wallet tx rewards are zero: " + 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 a8e50903c433604ec77868859448aa027375558a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 3 Aug 2022 19:17:59 +0000 Subject: [PATCH 2269/2430] 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 22889a19..08d1521e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -529,7 +529,7 @@ function Coin(data){ console.warn(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": using lesser block reward from block header " + reward_check + " instead of higher from incoming wallet tx " + reward); reward = reward_check; } else { - console.warn(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": using lesser block reward from incoming tx " + check + " instead of higher from block header " + reward_check); + console.warn(port + ": block hash: " + blockHash + ": txid " + miner_tx_hash + ": using lesser block reward from incoming tx " + reward + " instead of higher from block header " + reward_check); } } if (port != 38081 && reward == 0) { // MSR can have uncle block reward here From 896973f97a7cb001eb2860af6b6f80c08f02f2ce Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Aug 2022 05:11:57 +0000 Subject: [PATCH 2270/2430] Fixed ERG rewards --- lib/coins/xmr.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 08d1521e..bd8dbd71 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -268,6 +268,9 @@ function calcErgReward(height, block_tx) { let reward = 0; if (block_tx.length && block_tx[0].outputs.length == 2 && block_tx[0].outputs[1].creationHeight == height) { reward += block_tx[0].outputs[1].value; + // https://docs.ergoplatform.com/dev/protocol/eip27/ + if (block_tx[0].outputs[1].value >= 15000000000) reward -= 12000000000; + else reward -= 3000000000; } if (block_tx.length > 1) { const last_tx = block_tx[block_tx.length - 1]; From 00c2192d7d6505a291ad3fb2770d069b24a9cdd9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 5 Aug 2022 15:33:53 +0000 Subject: [PATCH 2271/2430] Monero v15 (view tags) hard-fork support --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 019ef883..637248e5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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.2.3", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.2" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v12.0.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.3" } } From 9812bcc7ba5f71ef0770fc591e842c61216c38ea Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 8 Aug 2022 20:52:33 +0000 Subject: [PATCH 2272/2430] Fixed ETC seeds after ecip-1099 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 637248e5..6ff24609 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "wallet-address-validator": "0.1.0", "utf8": "^3.0.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v12.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.3" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.4" } } From 62a6d09a1d542f3d31bfaba9495494707634e705 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 10 Aug 2022 15:46:08 +0000 Subject: [PATCH 2273/2430] More error reporting for bad shares --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 008c15e8..73d8b1da 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1612,7 +1612,7 @@ function ge(l, r) { 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); + console.error(threadName + "Bad " + job.coin + " coin share from miner (diff " + job.difficulty + ") " + miner.logString); lastMinerLogTime[miner.payout] = time_now; } } From bf3d69e9c1a405595e8941abf6d5db213125d65b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 1 Sep 2022 15:51:07 +0000 Subject: [PATCH 2274/2430] Fixed typo --- ex_keys.example.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ex_keys.example.json b/ex_keys.example.json index 8615ffd2..0cc47f9d 100644 --- a/ex_keys.example.json +++ b/ex_keys.example.json @@ -6,7 +6,7 @@ "QRYPTOS": "NNNNNN", "QRYPTOS_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==", "LIVECOIN": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - "LIVECOIN_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "LIVECOIN_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "COINEX": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "COINEX_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } \ No newline at end of file From b337669419dab6a3f24cbda0fddc51f3deda4393 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 6 Sep 2022 23:46:00 +0000 Subject: [PATCH 2275/2430] Add ability to specify XMR address in password for asic miners' --- lib/pool.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 73d8b1da..f895d64a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -563,11 +563,9 @@ function getRavenTargetHex(diff) { }; 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. - // 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. + // Username Layout: monero_address[.payment_id][(%N%monero_address_95char)+][+difficulty_number] + // Password Layout: worker_name[:email_or_pass[:monero_address]][~algo_name] + // If email_or_pass is email then miners will get email notifications about payments and offline workers const login_diff_split = login.split("+"); const login_div_split = login_diff_split[0].split("%"); @@ -584,7 +582,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro // 1) set payout, identifier, email and logString - this.payout = this.address = login_paymentid_split[0]; + this.payout = this.address = (pass_split.length === 3 ? pass_split[2] : login_paymentid_split[0]); this.paymentID = null; this.identifier = agent && agent.includes('MinerGate') ? "MinerGate" : (rigid ? rigid : pass_split[0]).substring(0, 64); @@ -601,20 +599,20 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro } this.debugMiner = this.payout in wallet_debug; - this.email = pass_split.length === 2 ? pass_split[1] : ""; + 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 if (login_diff_split.length > 2) { - this.error = "Please use monero_address[.payment_id][+difficulty_number] login/user format"; + this.error = "Please use monero_address[.payment_id][(%N%monero_address_95char)+][+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.error = "Please use monero_address[.payment_id][(%N%monero_address_95char)+][+difficulty_number] login/user format"; this.valid_miner = false; return; } @@ -681,8 +679,8 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.payout_div[this.payout] = payout_percent_left; } - if (pass_split.length > 2) { - this.error = "Please use worker_name[:email] password format"; + if (pass_split.length > 3) { + this.error = "Please use worker_name[:email_or_pass[:monero_address]][~algo_name] password format"; this.valid_miner = false; return; } From 5f03cf80563b60ad3e46192136e8b19a3fc47742 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Sep 2022 07:14:36 +0000 Subject: [PATCH 2276/2430] Fixed SQL overflow --- deployment/base.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/base.sql b/deployment/base.sql index e3e5a101..ac58f328 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -168,7 +168,7 @@ CREATE TABLE `transactions` ( KEY `transactions_shapeshiftTxn_id_fk` (`exchange_txn_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `users` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(256) NOT NULL, `pass` varchar(64) DEFAULT NULL, `email` varchar(256) DEFAULT NULL, From b3685ad3c902ece714452b05c98c0456bf431339 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 19 Oct 2022 17:11:28 +0000 Subject: [PATCH 2277/2430] Disabled double logins --- lib/pool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index f895d64a..d5378c68 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1855,6 +1855,10 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReplyFinal("No login specified"); return; } + if (socket.miner_ids && socket.miner_ids.length == 1) { + sendReplyFinal("No double login is allowed"); + return; + } if (!params.pass) params.pass = "x"; const difficulty = portData.difficulty; const minerId = get_new_id(); From ca7b179551aaa5c557ea1bb8cc9dd873e0f1de14 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 19 Oct 2022 17:29:20 +0000 Subject: [PATCH 2278/2430] Extra ip bans --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index d5378c68..fa768abf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1848,14 +1848,17 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se return; } if (!params) { + process.send({type: 'banIP', data: ip}); sendReplyFinal("No params specified"); return; } if (!params.login) { + process.send({type: 'banIP', data: ip}); sendReplyFinal("No login specified"); return; } if (socket.miner_ids && socket.miner_ids.length == 1) { + process.send({type: 'banIP', data: ip}); sendReplyFinal("No double login is allowed"); return; } From ce2bdbe7a1b41463bbe623fb38756b55b0ee5726 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 19 Oct 2022 18:00:10 +0000 Subject: [PATCH 2279/2430] Improved miner handling --- lib/pool.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index fa768abf..6b5974a1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1857,7 +1857,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReplyFinal("No login specified"); return; } - if (socket.miner_ids && socket.miner_ids.length == 1) { + if (socket.miner_id) { process.send({type: 'banIP', data: ip}); sendReplyFinal("No double login is allowed"); return; @@ -1901,15 +1901,11 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } } - if (!socket.miner_ids) socket.miner_ids = []; - socket.miner_ids.push(minerId); - activeMiners.set(minerId, miner); - if (!miner.proxy) { let proxyMinerName = miner.payout; // + ":" + miner.identifier; if ((params.agent && params.agent.includes('proxy')) || (proxyMinerName in proxyMiners)) { 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); + return sendReplyFinal("Temporary (one hour max) mining ban since you connected too many workers. Please use proxy (https://github.com/MoneroOcean/xmrig-proxy)", 600); } if (proxyMiners[proxyMinerName].hashes) adjustMinerDiff(miner); } else { @@ -1920,10 +1916,17 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se minerWallets[miner.payout].hashes = 0; minerWallets[miner.payout].last_ver_shares = 0; } else { - ++ minerWallets[miner.payout].count; + if (++ minerWallets[miner.payout].count > global.config.pool.workerMax) { + bannedBigTmpWallets[miner.payout] = 1; + return sendReplyFinal("Temporary (one hour max) ban on new miner connections since you connected too many workers. Please use proxy (https://github.com/MoneroOcean/xmrig-proxy)", 600); + } } } } + + socket.miner_id = minerId; + activeMiners.set(minerId, miner); + if (id === "Stratum") { // if grin miner is connected directly to the pool sendReply(null, "ok"); miner.protocol = "grin"; @@ -1979,7 +1982,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } case 'getjobtemplate': { // grin-mode miner only - const minerId = socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""; + const minerId = socket.miner_id; let miner = activeMiners.get(minerId); if (!miner) { sendReplyFinal("Unauthenticated"); @@ -2038,7 +2041,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReplyFinal("No params specified"); return; } - const minerId = params.id ? params.id : (socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""); + const minerId = params.id ? params.id : socket.miner_id; let miner = activeMiners.get(minerId); if (!miner) { sendReplyFinal("Unauthenticated"); @@ -2224,7 +2227,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReplyFinal("No params specified"); return; } - const minerId = params.id ? params.id : (socket.miner_ids && socket.miner_ids.length == 1 ? socket.miner_ids[0] : ""); + const minerId = params.id ? params.id : socket.miner_id; let miner = activeMiners.get(minerId); if (!miner) { sendReplyFinal("Unauthenticated"); @@ -2729,7 +2732,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 => removeMiner(activeMiners.get(miner_id))); + if (socket.miner_id) activeMiners.get(miner_id); if ("eth_extranonce_id" in socket) freeEthExtranonces.push(socket.eth_extranonce_id); }); } From df62c87c626bae764c41337124e4f5a035d93b9c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 19 Oct 2022 18:02:10 +0000 Subject: [PATCH 2280/2430] Improved miner handling --- lib/pool.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 6b5974a1..3dfdb9e4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1982,7 +1982,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se } case 'getjobtemplate': { // grin-mode miner only - const minerId = socket.miner_id; + const minerId = socket.miner_id ? socket.miner_id : ""; let miner = activeMiners.get(minerId); if (!miner) { sendReplyFinal("Unauthenticated"); @@ -2041,7 +2041,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReplyFinal("No params specified"); return; } - const minerId = params.id ? params.id : socket.miner_id; + const minerId = params.id ? params.id : (socket.miner_id ? socket.miner_id : ""); let miner = activeMiners.get(minerId); if (!miner) { sendReplyFinal("Unauthenticated"); @@ -2227,7 +2227,7 @@ function handleMinerData(socket, id, method, params, ip, portData, sendReply, se sendReplyFinal("No params specified"); return; } - const minerId = params.id ? params.id : socket.miner_id; + const minerId = params.id ? params.id : (socket.miner_id ? socket.miner_id : ""); let miner = activeMiners.get(minerId); if (!miner) { sendReplyFinal("Unauthenticated"); @@ -2732,7 +2732,7 @@ if (cluster.isMaster) { //debug(threadName + "Socket Error " + err.code + " from " + socket.remoteAddress + " Error: " + err); }).on('close', function () { pushMessage = function () {}; - if (socket.miner_id) activeMiners.get(miner_id); + if (socket.miner_id) activeMiners.get(socket.miner_id); if ("eth_extranonce_id" in socket) freeEthExtranonces.push(socket.eth_extranonce_id); }); } From f801232e9da55a047bfc485ea6888bc207897be2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 Nov 2022 21:12:15 +0000 Subject: [PATCH 2281/2430] Disabled 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 bd8dbd71..083dd7e7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -39,7 +39,7 @@ const port2coin = { "19281": "XMV", "19950": "XWP", "9231" : "XEQ", - "20206": "DERO", +// "20206": "DERO", // "18181": "XMC", "16000": "CCX", "8766" : "RVN", From e6dddedd86f3f7a56e6d9f67286db3eebdf7e297 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 24 Nov 2022 21:14:50 +0000 Subject: [PATCH 2282/2430] Disabled DERO --- 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 083dd7e7..e30cdffb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -43,7 +43,7 @@ const port2coin = { // "18181": "XMC", "16000": "CCX", "8766" : "RVN", - "8545" : "ETH", +// "8545" : "ETH", "8645" : "ETC", "2086" : "BLOC", "9053" : "ERG", @@ -1000,7 +1000,7 @@ function Coin(data){ if ("ghostrider" in algos_perf) coin_perf["RTM"] = algos_perf["ghostrider"]; - if ("ethash" in algos_perf) coin_perf["ETH"] = coin_perf["ETC"] = algos_perf["ethash"]; + if ("ethash" in algos_perf) coin_perf["ETC"] = algos_perf["ethash"]; if ("etchash" in algos_perf) coin_perf["ETC"] = algos_perf["etchash"]; if ("autolykos2" in algos_perf) coin_perf["ERG"] = algos_perf["autolykos2"]; @@ -1020,7 +1020,7 @@ function Coin(data){ if ("c29v" in algos_perf) coin_perf["XMV"] = algos_perf["c29v"]; if ("c29b" in algos_perf) coin_perf["TUBE"] = algos_perf["c29b"]; - if ("astrobwt/v2" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt/v2"]; + //if ("astrobwt/v2" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt/v2"]; //if ("cn/0" in algos_perf) coin_perf["XMC"] = algos_perf["cn/0"]; From c30ec7e8fbdb4cdce77548158e58a845840b2acb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Dec 2022 05:41:57 +0000 Subject: [PATCH 2283/2430] Haven 3.0 support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6ff24609..3d270be1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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#v12.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v13.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.4" } } From 686ea51d787d23f1bf8dc66264d922b0c8942e28 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Dec 2022 05:44:29 +0000 Subject: [PATCH 2284/2430] Haven 3.0 support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d270be1..5d965db5 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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#v13.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v13.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.4" } } From afa523758b88f2c0013a1ca4314d678009dc2e32 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 9 Jan 2023 15:52:25 +0000 Subject: [PATCH 2285/2430] XHV fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d965db5..82dd0a28 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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#v13.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v13.0.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.4" } } From aa616113fc11c2a4de8ecfc09ebec77e2c0ada0d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 9 Jan 2023 15:54:58 +0000 Subject: [PATCH 2286/2430] XHV fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82dd0a28..04a9b257 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,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#v13.0.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v13.0.3", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.4" } } From 11dd74f22b5b5b90d8b6ffb78c48bf6309ef9876 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 00:37:17 +0000 Subject: [PATCH 2287/2430] Added frequent main coin block template updates --- deployment/base.sql | 1 + lib/coins/xmr.js | 2 ++ lib/pool.js | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index ac58f328..c1f95afb 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', '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', 'highFeeBlock', '0.6', 'float', 'Main coin block reward that will lead to frequent block template updates'); 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'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index e30cdffb..34d50e59 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -931,6 +931,8 @@ function Coin(data){ 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 if (this.coin === "") { // For XMR (main coin) we allow frequent block template changes for the same height + this.prev_hash = this.idHash; } else { this.prev_hash = template.prev_hash; } diff --git a/lib/pool.js b/lib/pool.js index 3dfdb9e4..d7a5288a 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -340,7 +340,15 @@ function templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body_he if (!body_bt) { console.error("Block template request failed for " + port + " port"); coinHashFactorUpdate(coin, 0); - return setTimeout(templateUpdate2, 3000, coin, port, coinHashFactor, isHashFactorChange); + return; + } + // skip frequent updates of low fee block templates for miners + if (coin === "" && global.config.daemon.highFeeBlock) { + if (body_bt.prev_hash == lastBlockHash[coin]) { + if (body_bt.expected_reward < global.support.decimalToCoin(global.config.daemon.highFeeBlock)) return; + } else { + lastBlockHash[coin] = body_bt.prev_hash; + } } return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); }); @@ -361,7 +369,11 @@ function coinHashFactorUpdate(coin, coinHashFactor) { function templateUpdate(coin, repeating) { const port = global.coinFuncs.COIN2PORT(coin); const coinHashFactor = newCoinHashFactor[coin]; - if (coinHashFactor) global.coinFuncs.getPortLastBlockHeader(port, function (err, body) { + if (coinHashFactor) { + if (coin === "") { // separate logic for XMR (main coin) to allow several block tempaltes per height + templateUpdate2(coin, port, coinHashFactor, false, null); + if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); + } else 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); @@ -379,7 +391,8 @@ function templateUpdate(coin, repeating) { coinHashFactorUpdate(coin, 0); if (repeating !== false) setTimeout(templateUpdate, global.config.daemon.pollInterval, coin, repeating); } - }); else if (cluster.isMaster) { + }); + } else if (cluster.isMaster) { if (repeating !== false) setTimeout(templateUpdate, global.config.daemon.pollInterval, coin, repeating); } } From 78f88ea115f53b95f765c7d1280e9aa0d4d5776d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 00:56:48 +0000 Subject: [PATCH 2288/2430] Added frequent main coin block template updates --- lib/pool.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index d7a5288a..a111f551 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -66,6 +66,7 @@ let notifyAddresses = {}; // wallet notifications let activeMiners = new Map(); +let prevMainBlockBlob = null; let lastBlockHash = {}; // coin key let activeBlockTemplates = {}; // coin key let pastBlockTemplates = {}; // coin key -> global.support.circularBuffer -> activeBlockTemplates @@ -342,10 +343,16 @@ function templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body_he coinHashFactorUpdate(coin, 0); return; } - // skip frequent updates of low fee block templates for miners - if (coin === "" && global.config.daemon.highFeeBlock) { - if (body_bt.prev_hash == lastBlockHash[coin]) { - if (body_bt.expected_reward < global.support.decimalToCoin(global.config.daemon.highFeeBlock)) return; + + if (coin === "") { + if (body_bt.prev_hash === lastBlockHash[coin]) { + // replace body_header.hash (lastBlockHash) caching logic by body_bt.blockhashing_blob caching + if (body_bt.blockhashing_blob === prevMainBlockBlob) return; + prevMainBlockBlob = body_bt.blockhashing_blob; + // skip frequent updates of low fee block templates for miners + if ( global.config.daemon.highFeeBlock && body_bt.expected_reward && + body_bt.expected_reward < global.support.decimalToCoin(global.config.daemon.highFeeBlock) + ) return; } else { lastBlockHash[coin] = body_bt.prev_hash; } From a31f76d31d3c2d9395ea28020a86efc13f18fbb3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 01:11:21 +0000 Subject: [PATCH 2289/2430] Added frequent main coin block template updates --- deployment/base.sql | 1 + lib/pool.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index c1f95afb..14ebc8de 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', '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', 'highFeeBlock', '0.6', 'float', 'Main coin block reward that will lead to frequent block template updates'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'maxBlockTemplateKeepTime', '30', 'int', 'Mix block template update time in seconds on the same height'); 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'); diff --git a/lib/pool.js b/lib/pool.js index a111f551..a12a58a3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -66,7 +66,7 @@ let notifyAddresses = {}; // wallet notifications let activeMiners = new Map(); -let prevMainBlockBlob = null; +let prevMainBlockTime; let lastBlockHash = {}; // coin key let activeBlockTemplates = {}; // coin key let pastBlockTemplates = {}; // coin key -> global.support.circularBuffer -> activeBlockTemplates @@ -345,10 +345,12 @@ function templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body_he } if (coin === "") { + const time_now = Date.now(); if (body_bt.prev_hash === lastBlockHash[coin]) { - // replace body_header.hash (lastBlockHash) caching logic by body_bt.blockhashing_blob caching - if (body_bt.blockhashing_blob === prevMainBlockBlob) return; - prevMainBlockBlob = body_bt.blockhashing_blob; + // replace body_header.hash (lastBlockHash) caching logic by time caching + if ( global.config.daemon.maxBlockTemplateKeepTime && prevMainBlockTime && + time_now - prevMainBlockTime < global.config.daemon.maxBlockTemplateKeepTime * 1000 + ) return; // skip frequent updates of low fee block templates for miners if ( global.config.daemon.highFeeBlock && body_bt.expected_reward && body_bt.expected_reward < global.support.decimalToCoin(global.config.daemon.highFeeBlock) @@ -356,6 +358,7 @@ function templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body_he } else { lastBlockHash[coin] = body_bt.prev_hash; } + prevMainBlockTime = time_now; } return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); }); From 82634253330fa150f3e8adb505c3c9198e15fe9d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 02:06:01 +0000 Subject: [PATCH 2290/2430] Added frequent main coin block template updates --- deployment/base.sql | 3 ++- lib/pool.js | 44 ++++++++++++++++++++------------------------ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 14ebc8de..b601f4db 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -218,8 +218,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', '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', 'highFeeBlock', '0.6', 'float', 'Main coin block reward that will lead to frequent block template updates'); -INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'maxBlockTemplateKeepTime', '30', 'int', 'Mix block template update time in seconds on the same height'); 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', 'pollBlockInterval', '5000', 'int', 'Time in ms between pool daemon checks for block template updates'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'maxBlockKeepTime', '30', 'int', 'Mix block template update time in seconds on the same height'); 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 a12a58a3..4ba278f4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -66,8 +66,9 @@ let notifyAddresses = {}; // wallet notifications let activeMiners = new Map(); -let prevMainBlockTime; let lastBlockHash = {}; // coin key +let lastBlockTime = {}; // coin key +let lastBlockKeepTime = {}; // coin key let activeBlockTemplates = {}; // coin key let pastBlockTemplates = {}; // coin key -> global.support.circularBuffer -> activeBlockTemplates @@ -330,7 +331,7 @@ function templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt } // templateUpdate2 is only called in master thread (except the beginning of a worker thread) -function templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body_header) { +function templateUpdate2(coin, port, isHashChange, coinHashFactor, isHashFactorChange, body_header) { if (port == 8545 || port == 8645) { return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_header); } else global.coinFuncs.getPortBlockTemplate(port, function (body_bt) { @@ -344,23 +345,16 @@ function templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body_he return; } - if (coin === "") { - const time_now = Date.now(); - if (body_bt.prev_hash === lastBlockHash[coin]) { - // replace body_header.hash (lastBlockHash) caching logic by time caching - if ( global.config.daemon.maxBlockTemplateKeepTime && prevMainBlockTime && - time_now - prevMainBlockTime < global.config.daemon.maxBlockTemplateKeepTime * 1000 - ) return; - // skip frequent updates of low fee block templates for miners - if ( global.config.daemon.highFeeBlock && body_bt.expected_reward && - body_bt.expected_reward < global.support.decimalToCoin(global.config.daemon.highFeeBlock) - ) return; - } else { - lastBlockHash[coin] = body_bt.prev_hash; - } - prevMainBlockTime = time_now; + const highFeeBlock = global.support.decimalToCoin("highFeeBlock" + coin in global.config.daemon ? global.config.daemon["highFeeBlock" + coin] : 0); + const maxBlockKeepTime = ("maxBlockKeepTime" + coin in global.config.daemon ? global.config.daemon["maxBlockKeepTime" + coin] : 60*60) * 1000; + const time_now = Date.now(); + const isTimeChange = !(coin in lastBlockKeepTime) || time_now - lastBlockKeepTime[coin] > maxBlockKeepTime; + const isValueChange = highFeeBlock && body_bt.expected_reward && body_bt.expected_reward >= highFeeBlock; + + if ( isHashChange || isTimeChange || isValueChange) { + lastBlockKeepTime[coin] = time_now; + return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); } - return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); }); } @@ -380,18 +374,20 @@ function templateUpdate(coin, repeating) { const port = global.coinFuncs.COIN2PORT(coin); const coinHashFactor = newCoinHashFactor[coin]; if (coinHashFactor) { - if (coin === "") { // separate logic for XMR (main coin) to allow several block tempaltes per height - templateUpdate2(coin, port, coinHashFactor, false, null); - if (repeating === true) setTimeout(templateUpdate, DAEMON_POLL_MS, coin, repeating); - } else global.coinFuncs.getPortLastBlockHeader(port, function (err, body) { + 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 && body.hash) { const isHashFactorChange = Math.abs(lastCoinHashFactor[coin] - coinHashFactor) / coinHashFactor > 0.05; - if (!(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]) { + const pollBlockInterval = "pollBlockInterval" + coin in global.config.daemon ? global.config.daemon["pollBlockInterval" + coin] : 60*60*1000; + const time_now = Date.now(); + const isHashChange = !(coin in lastBlockHash) || body.hash !== lastBlockHash[coin]; + const isTimeChange = !(coin in lastBlockTime) || time_now - lastBlockTime[coin] > pollBlockInterval; + if ( isHashChange || isTimeChange) { lastBlockHash[coin] = body.hash; - templateUpdate2(coin, port, coinHashFactor, isHashFactorChange, body); + lastBlockTime[coin] = time_now; + templateUpdate2(coin, port, isHashChange, coinHashFactor, isHashFactorChange, body); } else if (isHashFactorChange) { coinHashFactorUpdate(coin, coinHashFactor); } From bfe90bc54e0d9889724ef48bd9c6ee46332f7c92 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 02:14:06 +0000 Subject: [PATCH 2291/2430] Added frequent main coin block template updates --- lib/coins/xmr.js | 14 +------------- lib/pool.js | 11 ----------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 34d50e59..fe1e6d19 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -659,7 +659,6 @@ function Coin(data){ body.result.difficulty *= 18; body.result.mbl_difficulty = body.result.blockhashing_blob.charAt(0) == '4' ? body.result.difficulty : body.result.difficulty * 9; body.result.reserved_offset = 36; - body.result.prev_hash = body.result.blockhashing_blob; // need to keep prev_hash different for miniblocks or BT update will be ignored in pool.js } return callback(body && body.result ? body.result : null); }); @@ -859,7 +858,7 @@ function Coin(data){ 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.hash = this.idHash = hash; this.hash2 = template.hash2; this.block_version = 0; this.nextBlobHex = function () { return hash; }; @@ -926,17 +925,6 @@ function Coin(data){ this.reserved_offset = 0; // to avoid hard crash } - if (!("prev_hash" in template)) { // Get prev_hash from blob - let prev_hash = Buffer.alloc(32); - 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 if (this.coin === "") { // For XMR (main coin) we allow frequent block template changes for the same height - this.prev_hash = this.idHash; - } else { - this.prev_hash = template.prev_hash; - } - // Copy the Instance ID to the reserve offset + 4 bytes deeper. Copy in 4 bytes. instanceId.copy(this.buffer, this.reserved_offset + 4, 0, 4); // Reset the Nonce - this is the per-miner/pool nonce diff --git a/lib/pool.js b/lib/pool.js index 4ba278f4..32d25568 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -518,17 +518,6 @@ function setNewBlockTemplate(template) { const coin = template.coin; let isExtraCheck = false; 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(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; - } - } if (coin in pastBlockTemplates) { pastBlockTemplates[coin].get(0).timeoutTime = Date.now() + 4*1000; } else { From 5792a32b9104e9d74c0819b042c2433e93620b02 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 02:25:28 +0000 Subject: [PATCH 2292/2430] Added frequent main coin block template updates --- deployment/base.sql | 1 - lib/pool.js | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index b601f4db..3ce65727 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -217,7 +217,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', 'highFeeBlock', '0.6', 'float', 'Main coin block reward that will lead to frequent block template updates'); 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', 'pollBlockInterval', '5000', 'int', 'Time in ms between pool daemon checks for block template updates'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'maxBlockKeepTime', '30', 'int', 'Mix block template update time in seconds on the same height'); diff --git a/lib/pool.js b/lib/pool.js index 32d25568..a13823b5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -69,6 +69,7 @@ let activeMiners = new Map(); let lastBlockHash = {}; // coin key let lastBlockTime = {}; // coin key let lastBlockKeepTime = {}; // coin key +let lastBlockReward = {}; // coin key let activeBlockTemplates = {}; // coin key let pastBlockTemplates = {}; // coin key -> global.support.circularBuffer -> activeBlockTemplates @@ -345,14 +346,14 @@ function templateUpdate2(coin, port, isHashChange, coinHashFactor, isHashFactorC return; } - const highFeeBlock = global.support.decimalToCoin("highFeeBlock" + coin in global.config.daemon ? global.config.daemon["highFeeBlock" + coin] : 0); const maxBlockKeepTime = ("maxBlockKeepTime" + coin in global.config.daemon ? global.config.daemon["maxBlockKeepTime" + coin] : 60*60) * 1000; const time_now = Date.now(); - const isTimeChange = !(coin in lastBlockKeepTime) || time_now - lastBlockKeepTime[coin] > maxBlockKeepTime; - const isValueChange = highFeeBlock && body_bt.expected_reward && body_bt.expected_reward >= highFeeBlock; + const isTimeChange = !(coin in lastBlockKeepTime) || time_now - lastBlockKeepTime[coin] > maxBlockKeepTime; + const isRewardChange = body_bt.expected_reward && (!(coin in lastBlockReward) || (lastBlockReward[coin] && body_bt.expected_reward / lastBlockReward[coin] > 1.01)); - if ( isHashChange || isTimeChange || isValueChange) { + if ( isHashChange || isTimeChange || isRewardChange) { lastBlockKeepTime[coin] = time_now; + lastBlockReward[coin] = body_bt.expected_reward; return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); } }); From 280b9fe8c00701c86eeab6a0fe0d64fca0eee9db Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 02:32:17 +0000 Subject: [PATCH 2293/2430] Debug --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index a13823b5..6cf583eb 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -352,6 +352,7 @@ function templateUpdate2(coin, port, isHashChange, coinHashFactor, isHashFactorC const isRewardChange = body_bt.expected_reward && (!(coin in lastBlockReward) || (lastBlockReward[coin] && body_bt.expected_reward / lastBlockReward[coin] > 1.01)); if ( isHashChange || isTimeChange || isRewardChange) { + console.log(port + ": " + isHashChange + " " + isTimeChange + " " + isRewardChange + " " + lastBlockReward[coin] + " " + body_bt.expected_reward); lastBlockKeepTime[coin] = time_now; lastBlockReward[coin] = body_bt.expected_reward; return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); From 8ae889ea58a27bdb2cd750b78d0e89cd612a12f9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 20 Jan 2023 02:44:27 +0000 Subject: [PATCH 2294/2430] Debug removed --- lib/pool.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6cf583eb..a13823b5 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -352,7 +352,6 @@ function templateUpdate2(coin, port, isHashChange, coinHashFactor, isHashFactorC const isRewardChange = body_bt.expected_reward && (!(coin in lastBlockReward) || (lastBlockReward[coin] && body_bt.expected_reward / lastBlockReward[coin] > 1.01)); if ( isHashChange || isTimeChange || isRewardChange) { - console.log(port + ": " + isHashChange + " " + isTimeChange + " " + isRewardChange + " " + lastBlockReward[coin] + " " + body_bt.expected_reward); lastBlockKeepTime[coin] = time_now; lastBlockReward[coin] = body_bt.expected_reward; return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); From 38f6944069bda64d1637408b529be5a410aad4a6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 21 Jan 2023 05:44:26 +0000 Subject: [PATCH 2295/2430] Do not update BT if there is no new transactions in it --- lib/pool.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index a13823b5..f3e48e89 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -346,12 +346,13 @@ function templateUpdate2(coin, port, isHashChange, coinHashFactor, isHashFactorC return; } - const maxBlockKeepTime = ("maxBlockKeepTime" + coin in global.config.daemon ? global.config.daemon["maxBlockKeepTime" + coin] : 60*60) * 1000; const time_now = Date.now(); - const isTimeChange = !(coin in lastBlockKeepTime) || time_now - lastBlockKeepTime[coin] > maxBlockKeepTime; - const isRewardChange = body_bt.expected_reward && (!(coin in lastBlockReward) || (lastBlockReward[coin] && body_bt.expected_reward / lastBlockReward[coin] > 1.01)); + const maxBlockKeepTime = ("maxBlockKeepTime" + coin in global.config.daemon ? global.config.daemon["maxBlockKeepTime" + coin] : 60*60) * 1000; + const isTimeChange = !(coin in lastBlockKeepTime) || time_now - lastBlockKeepTime[coin] > maxBlockKeepTime; + const isRewardCheckReady = body_bt.expected_reward && (coin in lastBlockReward) && lastBlockReward[coin]; + const isRewardChange = isRewardCheckReady && body_bt.expected_reward / lastBlockReward[coin] > 1.01; - if ( isHashChange || isTimeChange || isRewardChange) { + if (isHashChange || (isTimeChange && (!isRewardCheckReady || body_bt.expected_reward !== lastBlockReward[coin])) || isRewardChange) { lastBlockKeepTime[coin] = time_now; lastBlockReward[coin] = body_bt.expected_reward; return templateUpdate3(coin, port, coinHashFactor, isHashFactorChange, body_bt); From 9007785192e67e49b8bd4b05ab7e81dc9beff246 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 15 Mar 2023 23:35:25 +0000 Subject: [PATCH 2296/2430] Disabled TRTL --- 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 fe1e6d19..ea05815b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -21,7 +21,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", - "11898": "TRTL", +// "11898": "TRTL", "12211": "RYO", "17750": "XHV", "18081": "", @@ -51,7 +51,7 @@ const port2coin = { }; const port2blob_num = { // "11181": 7, // AEON - "11898": 2, // TRTL +// "11898": 2, // TRTL "12211": 4, // RYO "17750": 11, // XHV "18081": 0, // XMR @@ -82,7 +82,7 @@ const port2blob_num = { const port2algo = { // "11181": "k12", // Aeon - "11898": "argon2/chukwav2", // TRTL +// "11898": "argon2/chukwav2", // TRTL "12211": "cn/gpu", // RYO "13007": "cn-pico/trtl", // IRD // "13102": "c29i", // XTA From 1d29469c95e8957c0a8d0aa621002e2cf6aa5dcb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 16 Mar 2023 00:58:23 +0000 Subject: [PATCH 2297/2430] Improved thottling --- lib/coins/xmr.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ea05815b..74ac13ed 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -149,6 +149,7 @@ function get_algos() { const all_algos = get_algos(); const mm_child_port_set = get_mm_child_port_set(mm_port_set); +let miner_address_verify = {}; // store miner address and number of its shares currently in flight for verification let shareVerifyQueue = []; let shareVerifyQueueErrorTime = []; let shareVerifyQueueErrorCount = []; @@ -157,6 +158,7 @@ if (global.config.verify_shares_host) global.config.verify_shares_host.forEach(f shareVerifyQueueErrorTime[index] = 0; shareVerifyQueueErrorCount[index] = 0; shareVerifyQueue[index] = async.queue(function (task, queueCB) { + if (task.miner_address in miner_address_verify) -- miner_address_verify[task.miner_address]; const cb = task.cb; if (Date.now() - task.time > 1*60*1000) { cb(null); @@ -1076,6 +1078,10 @@ function Coin(data){ this.slowHashAsync = function(convertedBlob, blockTemplate, miner_address, cb) { if (!global.config.verify_shares_host) return cb(this.slowHash(convertedBlob, blockTemplate)); + if (miner_address in miner_address_verify) { + if (miner_address_verify[miner_address] > 100) return cb(null); + ++ miner_address_verify[miner_address]; + } else miner_address_verify[miner_address] = 1; let jsonInput; switch (blockTemplate.port) { case 18081: From 9a619975e1b62dac05c2079065774a7c8506e939 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 16:39:32 +0000 Subject: [PATCH 2298/2430] Reduced pool stats updates --- 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 ff23bb20..d6d07027 100644 --- a/lib/pool_stats.js +++ b/lib/pool_stats.js @@ -287,7 +287,7 @@ function updatePoolStats(poolType) { portMinerCount: result[23] || {}, portCoinAlgo: result[24] || {}, }); - setTimeout(updatePoolStats, 30*1000, poolType); + setTimeout(updatePoolStats, 60*1000, poolType); }); } From c3bd3519a48e7b49ce21436a4c275d65d3d853f6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 17:35:32 +0000 Subject: [PATCH 2299/2430] Clean old altblocks --- lib/longRunner.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/longRunner.js b/lib/longRunner.js index 777653d1..1de1d89d 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -91,6 +91,40 @@ function cleanCacheDB() { txn.commit(); } +function cleanAltBlockDB() { + console.log("Cleaning up the alt block DB. Searching for items to delete"); + let txn = global.database.env.beginTxn({readOnly: true}); + let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + let deleted = []; + 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 && Date.now() - blockData.timestamp > 365*24*60*60*1000) { + deleted.push(key); + console.log(JSON.stringify(blockData)); + } + }); + } + + cursor.close(); + txn.commit(); + + console.log("Deleting altblock items: " + deleted.length); + + let chunkSize = 0; + //txn = global.database.env.beginTxn(); + deleted.forEach(function(key) { + ++ chunkSize; + //txn.del(global.database.altblockDB, key); + if (chunkSize > 500) { + //txn.commit(); + //txn = global.database.env.beginTxn(); + chunkSize = 0; + } + }); + //txn.commit(); +} + //let saw_block_hash_before = {}; let cleanBlockBalanceTableQueue = async.queue(function (task, callback) { @@ -144,6 +178,7 @@ function cleanBlockBalanceTable() { console.log("Cleaning up the share DB"); global.database.cleanShareDB(); cleanCacheDB(); +cleanAltBlockDB(); cleanBlockBalanceTable(); setInterval(function(){ @@ -156,6 +191,11 @@ setInterval(function(){ cleanCacheDB(); }, 24*60*60*1000); +// clean altblock items +setInterval(function(){ + cleanAltBlockDB(); +}, 30*24*60*60*1000); + // clean block balance table setInterval(function(){ cleanBlockBalanceTable(); From 713a37a3aed42b06fe4ec8b56e7878391d77d52e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 17:49:24 +0000 Subject: [PATCH 2300/2430] Clean old altblocks --- lib/longRunner.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 1de1d89d..147b471f 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -102,6 +102,8 @@ function cleanAltBlockDB() { if (blockData.unlocked && Date.now() - blockData.timestamp > 365*24*60*60*1000) { deleted.push(key); console.log(JSON.stringify(blockData)); + } else { + console.log("SKIP: " + JSON.stringify(blockData)); } }); } @@ -194,7 +196,7 @@ setInterval(function(){ // clean altblock items setInterval(function(){ cleanAltBlockDB(); -}, 30*24*60*60*1000); +}, 7*24*60*60*1000); // clean block balance table setInterval(function(){ From efe3c18db8372cd23b65dd7d3ed7bc1480e18725 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:12:17 +0000 Subject: [PATCH 2301/2430] Clean old altblocks --- lib/longRunner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 147b471f..8555ceaf 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -92,7 +92,7 @@ function cleanCacheDB() { } function cleanAltBlockDB() { - console.log("Cleaning up the alt block DB. Searching for items to delete"); +/* console.log("Cleaning up the alt block DB. Searching for items to delete"); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); let deleted = []; @@ -124,7 +124,7 @@ function cleanAltBlockDB() { chunkSize = 0; } }); - //txn.commit(); + //txn.commit(); */ } //let saw_block_hash_before = {}; From 78abe60898974c0766cc43c2c684837607f9b197 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:12:39 +0000 Subject: [PATCH 2302/2430] Clean old altblocks --- manage_scripts/clean_altblocks.js | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 manage_scripts/clean_altblocks.js diff --git a/manage_scripts/clean_altblocks.js b/manage_scripts/clean_altblocks.js new file mode 100644 index 00000000..e93b3496 --- /dev/null +++ b/manage_scripts/clean_altblocks.js @@ -0,0 +1,37 @@ +"use strict"; + +require("../init_mini.js").init(function() { + console.log("Cleaning up the alt block DB. Searching for items to delete"); + let txn = global.database.env.beginTxn({readOnly: true}); + let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); + let deleted = []; + 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 && Date.now() - blockData.timestamp > 365*24*60*60*1000) { + deleted.push(key); + console.log(JSON.stringify(blockData)); + } else { + console.log("SKIP: " + JSON.stringify(blockData)); + } + }); + } + + cursor.close(); + txn.commit(); + + console.log("Deleting altblock items: " + deleted.length); + + let chunkSize = 0; + //txn = global.database.env.beginTxn(); + deleted.forEach(function(key) { + ++ chunkSize; + //txn.del(global.database.altblockDB, key); + if (chunkSize > 500) { + //txn.commit(); + //txn = global.database.env.beginTxn(); + chunkSize = 0; + } + }); + //txn.commit(); +}); From 9273be3874386f126d7351bc75050187c712d808 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:29:01 +0000 Subject: [PATCH 2303/2430] Clean old altblocks --- manage_scripts/clean_altblocks.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/manage_scripts/clean_altblocks.js b/manage_scripts/clean_altblocks.js index e93b3496..facf2c3f 100644 --- a/manage_scripts/clean_altblocks.js +++ b/manage_scripts/clean_altblocks.js @@ -5,10 +5,13 @@ require("../init_mini.js").init(function() { let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); let deleted = []; - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + let block_count = {}; + for (let found = cursor.goToLast(); found; found = cursor.goToPrev()) { cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); - if (blockData.unlocked && Date.now() - blockData.timestamp > 365*24*60*60*1000) { + if (!(blockData.port in block_count)) block_count[blockData.port] = 0; + ++ block_count[blockData.port]; + if (blockData.unlocked && (block_count[blockData.port] > 100000 || Date.now() - blockData.timestamp > 2*365*24*60*60*1000)) { deleted.push(key); console.log(JSON.stringify(blockData)); } else { From 17cc995d3690b3e77b0e57a7ad463529a12055de Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:29:46 +0000 Subject: [PATCH 2304/2430] Clean old altblocks --- manage_scripts/clean_altblocks.js | 1 + 1 file changed, 1 insertion(+) diff --git a/manage_scripts/clean_altblocks.js b/manage_scripts/clean_altblocks.js index facf2c3f..0f587de8 100644 --- a/manage_scripts/clean_altblocks.js +++ b/manage_scripts/clean_altblocks.js @@ -37,4 +37,5 @@ require("../init_mini.js").init(function() { } }); //txn.commit(); + process.exit(0); }); From 84e5591731be23fe917bc7c27167a2e04f55ba64 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:39:42 +0000 Subject: [PATCH 2305/2430] Clean old altblocks --- manage_scripts/clean_altblocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/clean_altblocks.js b/manage_scripts/clean_altblocks.js index 0f587de8..2ffc9420 100644 --- a/manage_scripts/clean_altblocks.js +++ b/manage_scripts/clean_altblocks.js @@ -11,7 +11,7 @@ require("../init_mini.js").init(function() { let blockData = global.protos.AltBlock.decode(data); if (!(blockData.port in block_count)) block_count[blockData.port] = 0; ++ block_count[blockData.port]; - if (blockData.unlocked && (block_count[blockData.port] > 100000 || Date.now() - blockData.timestamp > 2*365*24*60*60*1000)) { + if (blockData.unlocked && (block_count[blockData.port] > 20000 || Date.now() - blockData.timestamp > 2*365*24*60*60*1000)) { deleted.push(key); console.log(JSON.stringify(blockData)); } else { From 9d35ff7b409f7e623bc104f2daaf315fb9b97edd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:41:49 +0000 Subject: [PATCH 2306/2430] Clean old altblocks --- manage_scripts/clean_altblocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/clean_altblocks.js b/manage_scripts/clean_altblocks.js index 2ffc9420..994bc671 100644 --- a/manage_scripts/clean_altblocks.js +++ b/manage_scripts/clean_altblocks.js @@ -11,7 +11,7 @@ require("../init_mini.js").init(function() { let blockData = global.protos.AltBlock.decode(data); if (!(blockData.port in block_count)) block_count[blockData.port] = 0; ++ block_count[blockData.port]; - if (blockData.unlocked && (block_count[blockData.port] > 20000 || Date.now() - blockData.timestamp > 2*365*24*60*60*1000)) { + if (blockData.unlocked && (block_count[blockData.port] > 20000 || Date.now() - blockData.timestamp > 3*365*24*60*60*1000)) { deleted.push(key); console.log(JSON.stringify(blockData)); } else { From 3338d79c22971c8b5c111abfcc35b014d1fdb2a2 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:44:48 +0000 Subject: [PATCH 2307/2430] Clean old altblocks --- lib/longRunner.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 8555ceaf..3113357c 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -92,18 +92,19 @@ function cleanCacheDB() { } function cleanAltBlockDB() { -/* console.log("Cleaning up the alt block DB. Searching for items to delete"); + console.log("Cleaning up the alt block DB. Searching for items to delete"); let txn = global.database.env.beginTxn({readOnly: true}); let cursor = new global.database.lmdb.Cursor(txn, global.database.altblockDB); let deleted = []; - for (let found = cursor.goToFirst(); found; found = cursor.goToNext()) { + + let block_count = {}; + for (let found = cursor.goToLast(); found; found = cursor.goToPrev()) { cursor.getCurrentBinary(function(key, data){ // jshint ignore:line let blockData = global.protos.AltBlock.decode(data); - if (blockData.unlocked && Date.now() - blockData.timestamp > 365*24*60*60*1000) { + if (!(blockData.port in block_count)) block_count[blockData.port] = 0; + ++ block_count[blockData.port]; + if (blockData.unlocked && (block_count[blockData.port] > 20000 || Date.now() - blockData.timestamp > 3*365*24*60*60*1000)) { deleted.push(key); - console.log(JSON.stringify(blockData)); - } else { - console.log("SKIP: " + JSON.stringify(blockData)); } }); } @@ -124,7 +125,7 @@ function cleanAltBlockDB() { chunkSize = 0; } }); - //txn.commit(); */ + //txn.commit(); } //let saw_block_hash_before = {}; From 0f707b47238a22679c25d7477c6c1876bea4737c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 23 Mar 2023 18:52:15 +0000 Subject: [PATCH 2308/2430] Clean old altblocks --- lib/longRunner.js | 10 +++++----- manage_scripts/clean_altblocks.js | 13 +++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/longRunner.js b/lib/longRunner.js index 3113357c..97090eb6 100644 --- a/lib/longRunner.js +++ b/lib/longRunner.js @@ -115,17 +115,17 @@ function cleanAltBlockDB() { console.log("Deleting altblock items: " + deleted.length); let chunkSize = 0; - //txn = global.database.env.beginTxn(); + txn = global.database.env.beginTxn(); deleted.forEach(function(key) { ++ chunkSize; - //txn.del(global.database.altblockDB, key); + txn.del(global.database.altblockDB, key); if (chunkSize > 500) { - //txn.commit(); - //txn = global.database.env.beginTxn(); + txn.commit(); + txn = global.database.env.beginTxn(); chunkSize = 0; } }); - //txn.commit(); + txn.commit(); } //let saw_block_hash_before = {}; diff --git a/manage_scripts/clean_altblocks.js b/manage_scripts/clean_altblocks.js index 994bc671..21d36f5e 100644 --- a/manage_scripts/clean_altblocks.js +++ b/manage_scripts/clean_altblocks.js @@ -13,9 +13,6 @@ require("../init_mini.js").init(function() { ++ block_count[blockData.port]; if (blockData.unlocked && (block_count[blockData.port] > 20000 || Date.now() - blockData.timestamp > 3*365*24*60*60*1000)) { deleted.push(key); - console.log(JSON.stringify(blockData)); - } else { - console.log("SKIP: " + JSON.stringify(blockData)); } }); } @@ -26,16 +23,16 @@ require("../init_mini.js").init(function() { console.log("Deleting altblock items: " + deleted.length); let chunkSize = 0; - //txn = global.database.env.beginTxn(); + txn = global.database.env.beginTxn(); deleted.forEach(function(key) { ++ chunkSize; - //txn.del(global.database.altblockDB, key); + txn.del(global.database.altblockDB, key); if (chunkSize > 500) { - //txn.commit(); - //txn = global.database.env.beginTxn(); + txn.commit(); + txn = global.database.env.beginTxn(); chunkSize = 0; } }); - //txn.commit(); + txn.commit(); process.exit(0); }); From a7d6753148ab045919f792f28586aa8246c2b206 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 May 2023 03:08:10 +0000 Subject: [PATCH 2309/2430] Allow unlock many blocks at once --- manage_scripts/altblock_unlock_without_pay.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/manage_scripts/altblock_unlock_without_pay.js b/manage_scripts/altblock_unlock_without_pay.js index adac654d..f510982a 100644 --- a/manage_scripts/altblock_unlock_without_pay.js +++ b/manage_scripts/altblock_unlock_without_pay.js @@ -1,15 +1,16 @@ "use strict"; -const argv = require('minimist')(process.argv.slice(2)); +const argv = require('minimist')(process.argv.slice(2), { '--': true }); -if (!argv.hash) { - console.error("Please specify altblock hash to unlock it (and avoid payment)"); - process.exit(1); +let hashes = []; +for (const h of argv['--']) { + hashes.push(h); } -const hash = argv.hash; require("../init_mini.js").init(function() { - global.database.unlockAltBlock(hash); - console.log("Altblock with " + hash + " hash un-locked! Exiting!"); + hashes.forEach(function(hash) { + global.database.unlockAltBlock(hash); + console.log("Altblock with " + hash + " hash un-locked!"); + }) process.exit(0); }); From 2661438b1bdc03b6c105aeca1a964f28eeff3634 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 30 May 2023 04:24:56 +0000 Subject: [PATCH 2310/2430] Disabled tube --- 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 74ac13ed..551b5e53 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -27,7 +27,7 @@ const port2coin = { "18081": "", "18981": "GRFT", "11812": "XLA", - "25182": "TUBE", +// "25182": "TUBE", // "34568": "WOW", "38081": "MSR", "48782": "LTHN", @@ -57,7 +57,7 @@ const port2blob_num = { "18081": 0, // XMR "18981": 0, // GRFT "11812": 0, // XLA - "25182": 10, // TUBE +// "25182": 10, // TUBE // "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN @@ -94,7 +94,7 @@ const port2algo = { "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa "11812": "panthera", // Scala - "25182": "c29b", // BitTube +// "25182": "c29b", // BitTube "33124": "c29s", // XtendCash // "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR @@ -1010,7 +1010,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 ("c29b" in algos_perf) coin_perf["TUBE"] = algos_perf["c29b"]; //if ("astrobwt/v2" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt/v2"]; @@ -1131,7 +1131,7 @@ function Coin(data){ switch (port) { case 19281: return multiHashing.c29v(header, ring); // MoneroV case 19950: return multiHashing.c29s(header, ring); // Swap - case 25182: return multiHashing.c29b(header, ring); // TUBE +// case 25182: return multiHashing.c29b(header, ring); // TUBE case 33124: return multiHashing.c29s(header, ring); // XtendCash default: console.error("Unknown " + port + " port for Cuckaroo PoW type"); @@ -1165,7 +1165,7 @@ function Coin(data){ case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero case 22023: return "cryptonote_loki"; // LOKI - case 25182: return "cryptonote_tube"; // TUBE +// case 25182: return "cryptonote_tube"; // TUBE case 33124: return "cryptonote_xtnc"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; From d4c96a0e8c8d584a39c63c17a431971f4e44f419 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 18 Jun 2023 21:50:03 +0000 Subject: [PATCH 2311/2430] Revert "Disabled tube" This reverts commit 2661438b1bdc03b6c105aeca1a964f28eeff3634. --- 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 551b5e53..74ac13ed 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -27,7 +27,7 @@ const port2coin = { "18081": "", "18981": "GRFT", "11812": "XLA", -// "25182": "TUBE", + "25182": "TUBE", // "34568": "WOW", "38081": "MSR", "48782": "LTHN", @@ -57,7 +57,7 @@ const port2blob_num = { "18081": 0, // XMR "18981": 0, // GRFT "11812": 0, // XLA -// "25182": 10, // TUBE + "25182": 10, // TUBE // "34568": 0, // WOW "38081": 6, // MSR "48782": 0, // LTHN @@ -94,7 +94,7 @@ const port2algo = { "19950": "c29s", // Swap "19994": "rx/arq", // ArqMa "11812": "panthera", // Scala -// "25182": "c29b", // BitTube + "25182": "c29b", // BitTube "33124": "c29s", // XtendCash // "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR @@ -1010,7 +1010,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 ("c29b" in algos_perf) coin_perf["TUBE"] = algos_perf["c29b"]; //if ("astrobwt/v2" in algos_perf) coin_perf["DERO"] = algos_perf["astrobwt/v2"]; @@ -1131,7 +1131,7 @@ function Coin(data){ switch (port) { case 19281: return multiHashing.c29v(header, ring); // MoneroV case 19950: return multiHashing.c29s(header, ring); // Swap -// case 25182: return multiHashing.c29b(header, ring); // TUBE + case 25182: return multiHashing.c29b(header, ring); // TUBE case 33124: return multiHashing.c29s(header, ring); // XtendCash default: console.error("Unknown " + port + " port for Cuckaroo PoW type"); @@ -1165,7 +1165,7 @@ function Coin(data){ case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero case 22023: return "cryptonote_loki"; // LOKI -// case 25182: return "cryptonote_tube"; // TUBE + case 25182: return "cryptonote_tube"; // TUBE case 33124: return "cryptonote_xtnc"; // XtendCash case 38081: return "cryptonote3"; // MSR default: return "cryptonote"; From 5b0dd893d998e76a974f155a5801fd7f37d9de17 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jun 2023 04:22:47 +0000 Subject: [PATCH 2312/2430] Added new module --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 04a9b257..e7398944 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "body-parser": "^1.16.0", "circular-buffer": "1.0.2", "cluster": "0.7.7", + "crypto-js": "4.1.1", "concat-stream": "^1.6.0", "cors": "^2.8.1", "debug": "2.6.9", From 4e3fe0c82b72512004012637c1f8fb6e7d731a0e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 24 Jun 2023 19:54:44 +0000 Subject: [PATCH 2313/2430] ZEPH support --- deployment/base.sql | 2 ++ ex_keys.example.json | 4 +++- lib/coins/xmr.js | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 3ce65727..5c1bb605 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -249,6 +249,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', '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', 'coinHashFactorZEPH', '0', 'float', 'ZEPH 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', 'Default Daemon RPC Wallet IP'); @@ -322,6 +323,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_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 ('pool', 'address_17767', '', 'string', 'Address to mine to for 17767 (ZEPH) 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/ex_keys.example.json b/ex_keys.example.json index 0cc47f9d..34181689 100644 --- a/ex_keys.example.json +++ b/ex_keys.example.json @@ -8,5 +8,7 @@ "LIVECOIN": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "LIVECOIN_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "COINEX": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - "COINEX_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "COINEX_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "SEVENSEAS": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "SEVENSEAS_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } \ No newline at end of file diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 74ac13ed..694ec0b7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -48,6 +48,7 @@ const port2coin = { "2086" : "BLOC", "9053" : "ERG", "9998" : "RTM", + "17767" : "ZEPH", }; const port2blob_num = { // "11181": 7, // AEON @@ -55,6 +56,7 @@ const port2blob_num = { "12211": 4, // RYO "17750": 11, // XHV "18081": 0, // XMR + "17767": 0, // ZEPH "18981": 0, // GRFT "11812": 0, // XLA "25182": 10, // TUBE @@ -88,6 +90,7 @@ const port2algo = { // "13102": "c29i", // XTA "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR + "17767": "rx/0", // ZEPH "18981": "rx/graft", // Graft "19281": "c29v", // MoneroV "19734": "cn/r", // SUMO @@ -975,7 +978,7 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { 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["ZEPH"] = algos_perf["rx/0"]; if ("cn/r" in algos_perf) coin_perf["SUMO"] = algos_perf["cn/r"]; @@ -1055,6 +1058,7 @@ function Coin(data){ 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 17767: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // ZEPH //case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC case 18981: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 20); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO From f85be9bdecf3f283c19033e0bba23dfb78fa8da5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Jun 2023 00:28:25 +0000 Subject: [PATCH 2314/2430] ZEPH support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e7398944..b1342c94 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#v13.0.3", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v14.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.4" } } From 6e68a12483fd730315a38586cea54da0757a3e0c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Jun 2023 00:31:34 +0000 Subject: [PATCH 2315/2430] ZEPH support --- 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 694ec0b7..deea6ee1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -56,7 +56,7 @@ const port2blob_num = { "12211": 4, // RYO "17750": 11, // XHV "18081": 0, // XMR - "17767": 0, // ZEPH + "17767": 13, // ZEPH "18981": 0, // GRFT "11812": 0, // XLA "25182": 10, // TUBE @@ -1165,6 +1165,7 @@ function Coin(data){ case 13007: return "forknote2"; // Iridium case 12211: return "cryptonote_ryo"; // RYO case 17750: return "cryptonote_xhv"; // XHV + case 17767: return "cryptonote_zeph"; // ZEPH case 19281: return "cuckaroo"; // MoneroV case 19950: return "cuckaroo"; // Swap case 20206: return "cryptonote_dero"; // Dero From 2497cbd855c64469808526b1a4541e09154920ad Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Jun 2023 00:49:09 +0000 Subject: [PATCH 2316/2430] ZEPH support --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index deea6ee1..dc01a0a3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1088,6 +1088,7 @@ function Coin(data){ } else miner_address_verify[miner_address] = 1; let jsonInput; switch (blockTemplate.port) { + case 17767: case 18081: case 18981: case 19994: From 9de0fa147d62c463df67355c0d2c505838406499 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Jun 2023 02:05:40 +0000 Subject: [PATCH 2317/2430] Improved rx seed switch --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b1342c94..11a8c438 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#v14.0.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.4" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.9" } } From 9eeb66c1f5e696565182614d753371f298820542 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Jun 2023 04:00:20 +0000 Subject: [PATCH 2318/2430] Better ZEPH support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 11a8c438..edef3d96 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#v14.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v14.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.9" } } From 7a723cdce894e3a2179cf17d47238c3130ed29f1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 26 Jun 2023 14:13:39 +0000 Subject: [PATCH 2319/2430] Script for mass manual block payments --- manage_scripts/altblocks_pay_manually.js | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 manage_scripts/altblocks_pay_manually.js diff --git a/manage_scripts/altblocks_pay_manually.js b/manage_scripts/altblocks_pay_manually.js new file mode 100644 index 00000000..9870ef39 --- /dev/null +++ b/manage_scripts/altblocks_pay_manually.js @@ -0,0 +1,38 @@ +"use strict"; + +const argv = require('minimist')(process.argv.slice(2), { '--': true }); + +let hashes = {}; +for (const h of argv['--']) { + hashes[h] = 1; +} + +if (!argv.pay) { + console.error("Please specify pay value in main currency"); + process.exit(1); +} +const pay = argv.pay; + +require("../init_mini.js").init(function() { + 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 in hashes) { + console.log("Found altblock with " + blockData.hash + " hash"); + blockData.pay_value = global.support.decimalToCoin(pay); + blockData.unlocked = false; + console.log("Put " + blockData.pay_value + " pay_value to block"); + txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); + console.log("Changed altblock"); + changed = 1; + } + }); + } + cursor.close(); + txn.commit(); + if (!changed) console.log("Not found altblocks with specified hashes"); + process.exit(0); +}); \ No newline at end of file From a5c7e4a81e38ea576dceb01054b9ea9afbce10b4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Jun 2023 14:31:53 +0000 Subject: [PATCH 2320/2430] Count changed blocks --- manage_scripts/altblocks_pay_manually.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manage_scripts/altblocks_pay_manually.js b/manage_scripts/altblocks_pay_manually.js index 9870ef39..83e9dad4 100644 --- a/manage_scripts/altblocks_pay_manually.js +++ b/manage_scripts/altblocks_pay_manually.js @@ -27,12 +27,13 @@ require("../init_mini.js").init(function() { console.log("Put " + blockData.pay_value + " pay_value to block"); txn.putBinary(global.database.altblockDB, key, global.protos.AltBlock.encode(blockData)); console.log("Changed altblock"); - changed = 1; + changed += 1; } }); } cursor.close(); txn.commit(); if (!changed) console.log("Not found altblocks with specified hashes"); + else console.log("Changed " + changed + "blocks"); process.exit(0); }); \ No newline at end of file From 2d855deec4ead0fc50c28da28d3dc1f0b20a67b6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 27 Jun 2023 14:37:39 +0000 Subject: [PATCH 2321/2430] Count changed blocks --- manage_scripts/altblocks_pay_manually.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage_scripts/altblocks_pay_manually.js b/manage_scripts/altblocks_pay_manually.js index 83e9dad4..ebb2b648 100644 --- a/manage_scripts/altblocks_pay_manually.js +++ b/manage_scripts/altblocks_pay_manually.js @@ -34,6 +34,6 @@ require("../init_mini.js").init(function() { cursor.close(); txn.commit(); if (!changed) console.log("Not found altblocks with specified hashes"); - else console.log("Changed " + changed + "blocks"); + else console.log("Changed " + changed + " blocks"); process.exit(0); }); \ No newline at end of file From 25b7e59e33390154599f657fcb848b9188bd8472 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 28 Jun 2023 14:52:37 +0000 Subject: [PATCH 2322/2430] Delay non emergency coin switch for 60 secs --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index f3e48e89..ef4a3d13 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -752,7 +752,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro } else { return coin_perf; } - this.algo_min_time = algo_min_time ? algo_min_time : 0; + this.algo_min_time = algo_min_time ? algo_min_time : 60; return ""; }; @@ -761,7 +761,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro algos = [ algo_name ]; algos_perf = {}; algos_perf[algo_name] = 1; - algo_min_time = 0; + algo_min_time = 60; } else if (!(algos && algos instanceof Array && global.config.daemon.enableAlgoSwitching)) { const agent_algo = global.coinFuncs.get_miner_agent_not_supported_algo(agent); @@ -771,7 +771,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro algos = global.coinFuncs.getDefaultAlgos(); } algos_perf = global.coinFuncs.getDefaultAlgosPerf(); - algo_min_time = 0; + algo_min_time = 60; } const status = this.setAlgos(algos, algos_perf, algo_min_time); From 74674b6d4e273f2785c1644745df31d4140c1973 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 5 Jul 2023 22:53:50 +0000 Subject: [PATCH 2323/2430] Reduced memory usage --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index edef3d96..9c1aafdb 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#v14.0.1", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.9" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.10" } } From 6f79a8a90b1820f9c1363270f43aa99408da5b9a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 16 Jul 2023 00:04:55 +0000 Subject: [PATCH 2324/2430] Added BTRM --- README.md | 2 ++ deployment/base.sql | 2 ++ ex_keys.example.json | 6 +++++- lib/coins/xmr.js | 22 ++++++++++++++-------- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6bb423d1..2ed160e5 100644 --- a/README.md +++ b/README.md @@ -280,8 +280,10 @@ If you'd like to make a one time donation, the addresses are as follows: * DERO - ```dero1qygrgnz9gea2rqgwhdtpfpa3mvagt5uyq0g92nurwrpk6wnn7hdnzqgudsv6t``` * CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` * BLOC - ```abLoc5iUG4a6oAb2dqygxkS5M2uHWx16zHb9fUWMzpSEDwm6T7PSq2MLdHonWZ16CGfnJKRomq75aZyviTo6ZjHeYQMzNAEkjMg``` +* ZEPH - ```ZEPHYR2nic7ULkkmgZNX8a9i2tMbkxuCqjgWZYuee3awX7RhtmhoT98CwGEGrruWZVSKtA7Z7JC8m7oeYHtBD9cBEZzdEh9BSdq4q``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` * RTM - ```RUCyaEZxQu3Eure73XPQ57si813RYAMQKC``` +* BTRM - ```Bfhtr2g56tg73TNZBRCu6fJUD39Kur6SGG``` * ERG - ```9fe533kUzAE57YfPP6o3nzsYMKN2W2uCxvg8KG8Vn5DDeJGetRw``` * BTC - ```3HRbMgcvbqHVW7P34MNGvF2Gh3DE26iHdw``` * BCH - ```18sKoDSjLCFW9kZrXuza1qzEERnKi7bx8S``` diff --git a/deployment/base.sql b/deployment/base.sql index 5c1bb605..b8e034f0 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -249,6 +249,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', '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', 'coinHashFactorBTRM', '0', 'float', 'BTRM algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorZEPH', '0', 'float', 'ZEPH 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'); @@ -324,6 +325,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_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 ('pool', 'address_17767', '', 'string', 'Address to mine to for 17767 (ZEPH) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_10225', '', 'string', 'Address to mine to for 10225 (BTRM) 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/ex_keys.example.json b/ex_keys.example.json index 34181689..0e0c903b 100644 --- a/ex_keys.example.json +++ b/ex_keys.example.json @@ -10,5 +10,9 @@ "COINEX": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "COINEX_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "SEVENSEAS": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - "SEVENSEAS_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" + "SEVENSEAS_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "XEGGEX": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "XEGGEX_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "TXBIT": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "TXBIT_SECRET": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" } \ No newline at end of file diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index dc01a0a3..9bf249d7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -48,6 +48,7 @@ const port2coin = { "2086" : "BLOC", "9053" : "ERG", "9998" : "RTM", + "10225" : "BTRM", "17767" : "ZEPH", }; const port2blob_num = { @@ -80,6 +81,7 @@ const port2blob_num = { "2086" : 1, // BLOC "9053" : 103, // ERG "9998" : 104, // RTM + "10225": 104, // BTRM }; const port2algo = { @@ -112,6 +114,7 @@ const port2algo = { "2086" : "cn-heavy/xhv", // BLOC "9053" : "autolykos2", // ERG "9998" : "ghostrider", // RTM + "10225": "ghostrider", // BTRM }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -344,7 +347,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998) { + } else if (port == 8766 || port == 9998 || port == 10225) { global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); @@ -417,14 +420,14 @@ function Coin(data){ } return callback(null, body); }); - } else if (port == 8766 || port == 9998) { + } else if (port == 8766 || port == 9998 || port == 10225) { 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 = (port == 8766 ? 2500 : 3750) * 100000000; - if (port == 9998) body.result.difficulty *= 0xFFFFFFFF; + if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); } else if (port == 8545 || port == 8645) { @@ -573,7 +576,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998) { + } else if (port == 8766 || port == 9998 || port == 10225) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { console.error("getPortLastBlockHeader(" + port + "): " + JSON.stringify(body)); @@ -629,7 +632,7 @@ function Coin(data){ return callback(body ? body : null); }); - } else if (port == 8766 || port == 9998) { + } else if (port == 8766 || port == 9998 || port == 10225) { global.support.rpcPortDaemon2(port, '', { method: 'getblocktemplate', params: [{ @@ -638,8 +641,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 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 10225: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); } else return callback(null); }); @@ -993,7 +997,7 @@ 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 ("ghostrider" in algos_perf) coin_perf["RTM"] = coin_perf["BTRM"] = algos_perf["ghostrider"]; if ("ethash" in algos_perf) coin_perf["ETC"] = algos_perf["ethash"]; if ("etchash" in algos_perf) coin_perf["ETC"] = algos_perf["etchash"]; @@ -1047,6 +1051,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 9998: return multiHashing.cryptonight(convertedBlob, 18); // RTM + case 10225: return multiHashing.cryptonight(convertedBlob, 18); // BTRM case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH case 8645: return multiHashing.etchash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETC case 9053: return multiHashing.autolykos2_hashes(convertedBlob, blockTemplate.height); // ERG @@ -1161,6 +1166,7 @@ function Coin(data){ case 9053: return "erg"; // ERG case 9231: return "cryptonote_loki"; // XEQ case 9998: return "raptoreum"; // RTM + case 10225: return "raptoreum"; // BTRM //case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL case 13007: return "forknote2"; // Iridium From 493d84b2ed429dd6f188ce17916a0a4558bbeade Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Aug 2023 23:50:07 +0000 Subject: [PATCH 2325/2430] Added XNA --- deployment/base.sql | 2 ++ lib/coins/xmr.js | 35 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index b8e034f0..951cfdee 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -251,6 +251,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', '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', 'coinHashFactorBTRM', '0', 'float', 'BTRM algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorZEPH', '0', 'float', 'ZEPH algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXNA', '0', 'float', 'XNA 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', 'Default Daemon RPC Wallet IP'); @@ -326,6 +327,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_9998', '', 'string', 'Address to mine to for 9998 (RTM) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_17767', '', 'string', 'Address to mine to for 17767 (ZEPH) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_10225', '', 'string', 'Address to mine to for 10225 (BTRM) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19001', '', 'string', 'Address to mine to for 19001 (Neurai) 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 9bf249d7..5e53d60c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -50,6 +50,7 @@ const port2coin = { "9998" : "RTM", "10225" : "BTRM", "17767" : "ZEPH", + "19001" : "XNA", }; const port2blob_num = { // "11181": 7, // AEON @@ -82,6 +83,7 @@ const port2blob_num = { "9053" : 103, // ERG "9998" : 104, // RTM "10225": 104, // BTRM + "19001" : 101, // XNA }; const port2algo = { @@ -115,6 +117,7 @@ const port2algo = { "9053" : "autolykos2", // ERG "9998" : "ghostrider", // RTM "10225": "ghostrider", // BTRM + "19001": "kawpow", // XNA }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -347,7 +350,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998 || port == 10225) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); @@ -420,15 +423,26 @@ function Coin(data){ } return callback(null, body); }); - } else if (port == 8766 || port == 9998 || port == 10225) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash ] }, function (body) { - if (!body || !body.result) { + if (!body || !body.result || !(block.result.tx instanceof Array) || block.result.tx.length < 1) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - body.result.reward = (port == 8766 ? 2500 : 3750) * 100000000; - if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; - return callback(null, body.result); + global.support.rpcPortDaemon2(port, '', { method: 'getrawtransaction', params: [ block.result.tx[0], true ] }, function (body2) { + if (!body2 || !body2.result || !(body2.result.vout instanceof Array)) { + console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body2)); + return callback(true, body2); + } + const wallet_address = global.config.pool["address_" + port.toString()]; + body.result.reward = 0; + for (vout of body2.result.vout) { + if (vout.addresses && vout.addresses instanceof Array && vout.addresses.length == 1 && vout.addresses[0] == wallet_address) + body.result.reward += vout.valueSat; + } + if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; + return callback(null, body.result); + }); }); } else if (port == 8545 || port == 8645) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { @@ -576,7 +590,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998 || port == 10225) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { console.error("getPortLastBlockHeader(" + port + "): " + JSON.stringify(body)); @@ -632,7 +646,7 @@ function Coin(data){ return callback(body ? body : null); }); - } else if (port == 8766 || port == 9998 || port == 10225) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { global.support.rpcPortDaemon2(port, '', { method: 'getblocktemplate', params: [{ @@ -644,6 +658,7 @@ function Coin(data){ 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 10225: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); + case 19001: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); } else return callback(null); }); @@ -995,7 +1010,7 @@ function Coin(data){ // if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; - if ("kawpow" in algos_perf) coin_perf["RVN"] = algos_perf["kawpow"]; + if ("kawpow" in algos_perf) coin_perf["RVN"] = coin_perf["XNA"] = algos_perf["kawpow"]; if ("ghostrider" in algos_perf) coin_perf["RTM"] = coin_perf["BTRM"] = algos_perf["ghostrider"]; @@ -1050,6 +1065,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 19001: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // XNA case 9998: return multiHashing.cryptonight(convertedBlob, 18); // RTM case 10225: return multiHashing.cryptonight(convertedBlob, 18); // BTRM case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH @@ -1163,6 +1179,7 @@ function Coin(data){ case 8545: return "eth"; // ETH case 8645: return "eth"; // ETC case 8766: return "raven"; // RVN + case 19001: return "raven"; // XNA case 9053: return "erg"; // ERG case 9231: return "cryptonote_loki"; // XEQ case 9998: return "raptoreum"; // RTM From 7514adf2e2d583d389d3d5e87f0db5f3db29f994 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Aug 2023 23:51:49 +0000 Subject: [PATCH 2326/2430] Added XNA --- 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 5e53d60c..70cfd97b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -425,7 +425,7 @@ function Coin(data){ }); } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash ] }, function (body) { - if (!body || !body.result || !(block.result.tx instanceof Array) || block.result.tx.length < 1) { + if (!body || !body.result || !(body.result.tx instanceof Array) || body.result.tx.length < 1) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } From 87093a00420adbb924517249f93eb73cdcb55ed5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Aug 2023 23:52:26 +0000 Subject: [PATCH 2327/2430] Added XNA --- 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 70cfd97b..ed99825a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -429,7 +429,7 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { method: 'getrawtransaction', params: [ block.result.tx[0], true ] }, function (body2) { + global.support.rpcPortDaemon2(port, '', { method: 'getrawtransaction', params: [ body.result.tx[0], true ] }, function (body2) { if (!body2 || !body2.result || !(body2.result.vout instanceof Array)) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body2)); return callback(true, body2); From 331629291c3ea9ccad07fc2327658d5b5e089f0f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 26 Aug 2023 23:52:49 +0000 Subject: [PATCH 2328/2430] Added XNA --- 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 ed99825a..37ad229c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -436,7 +436,7 @@ function Coin(data){ } const wallet_address = global.config.pool["address_" + port.toString()]; body.result.reward = 0; - for (vout of body2.result.vout) { + for (const vout of body2.result.vout) { if (vout.addresses && vout.addresses instanceof Array && vout.addresses.length == 1 && vout.addresses[0] == wallet_address) body.result.reward += vout.valueSat; } From 2a7003bc9994d4528816c4414f38d42543d3e4a9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 27 Aug 2023 00:07:36 +0000 Subject: [PATCH 2329/2430] Added XNA --- lib/coins/xmr.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 37ad229c..525703cc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -434,12 +434,8 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body2)); return callback(true, body2); } - const wallet_address = global.config.pool["address_" + port.toString()]; body.result.reward = 0; - for (const vout of body2.result.vout) { - if (vout.addresses && vout.addresses instanceof Array && vout.addresses.length == 1 && vout.addresses[0] == wallet_address) - body.result.reward += vout.valueSat; - } + for (const vout of body2.result.vout) body.result.reward += vout.valueSat; if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); From 9c6b574d9e174c3c7376f9cd380bda8cbe8336f1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 27 Aug 2023 00:39:33 +0000 Subject: [PATCH 2330/2430] Added XNA --- lib/coins/xmr.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 525703cc..2f086a2a 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -424,21 +424,15 @@ function Coin(data){ return callback(null, body); }); } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { - global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash ] }, function (body) { + global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash, 2 ] }, function (body) { if (!body || !body.result || !(body.result.tx instanceof Array) || body.result.tx.length < 1) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - global.support.rpcPortDaemon2(port, '', { method: 'getrawtransaction', params: [ body.result.tx[0], true ] }, function (body2) { - if (!body2 || !body2.result || !(body2.result.vout instanceof Array)) { - console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body2)); - return callback(true, body2); - } - body.result.reward = 0; - for (const vout of body2.result.vout) body.result.reward += vout.valueSat; - if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; - return callback(null, body.result); - }); + body.result.reward = 0; + for (const vout of body.result.tx[0].vout) body.result.reward += vout.valueSat; + if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; + return callback(null, body.result); }); } else if (port == 8545 || port == 8645) { global.support.rpcPortDaemon2(port, '', { jsonrpc: "2.0", id: 1, method: 'eth_getBlockByHash', params: [ "0x" + blockHash, true ] }, function (body) { From 621fd7cbfc3552ff4dc124cb40e8905e99082276 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 27 Aug 2023 00:45:46 +0000 Subject: [PATCH 2331/2430] Added XNA --- 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 2f086a2a..5373e99c 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -430,7 +430,8 @@ function Coin(data){ return callback(true, body); } body.result.reward = 0; - for (const vout of body.result.tx[0].vout) body.result.reward += vout.valueSat; + for (const vout of body.result.tx[0].vout) body.result.reward += vout.value; + body.result.reward *= 100000000; if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); From 1944eae4b283da6b8c950df8f97a8073b8be60dd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 28 Aug 2023 03:41:02 +0000 Subject: [PATCH 2332/2430] Updated coin utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c1aafdb..c5cbc427 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#v14.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.0.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.10" } } From 7f110a460079b03c2ca5fd5418160d42e994760f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 1 Sep 2023 18:35:31 +0000 Subject: [PATCH 2333/2430] Fixed BTRM reward --- 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 5373e99c..2ccf3801 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -429,8 +429,11 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - body.result.reward = 0; - for (const vout of body.result.tx[0].vout) body.result.reward += vout.value; + body.result.reward = (port == 8766 ? 2500 : 3750) * 100000000; + if (port == 8766 || port == 19001) { // XNA, RVN + body.result.reward = 0; + for (const vout of body.result.tx[0].vout) body.result.reward += vout.value; + } else body.result.reward = 3750; // BTRM, RTM body.result.reward *= 100000000; if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); From bf445ea0e00470be96f4992ab6279b807c5b37bc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 1 Sep 2023 18:49:17 +0000 Subject: [PATCH 2334/2430] Fixed BTRM reward --- lib/coins/xmr.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 2ccf3801..9104c4ac 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -429,7 +429,6 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - body.result.reward = (port == 8766 ? 2500 : 3750) * 100000000; if (port == 8766 || port == 19001) { // XNA, RVN body.result.reward = 0; for (const vout of body.result.tx[0].vout) body.result.reward += vout.value; From 07c4b849e6bf3ebb135f8b5ca2a5fccb4ba45557 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 4 Sep 2023 16:42:40 +0000 Subject: [PATCH 2335/2430] Workaround for grft --- 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 9104c4ac..efd0f10d 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -530,9 +530,9 @@ function Coin(data){ } } } - const miner_tx_hash = body.result.miner_tx_hash == "" ? body.result.block_header.miner_tx_hash : body.result.miner_tx_hash; + const miner_tx_hash = port == 18981 ? "" : (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 && 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 8e70bbd123076692415b847f8270ab03293a9d7b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 4 Sep 2023 17:24:56 +0000 Subject: [PATCH 2336/2430] Removed graft --- README.md | 1 + lib/coins/xmr.js | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2ed160e5..4fa5a0d2 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,7 @@ If you'd like to make a one time donation, the addresses are as follows: * BLOC - ```abLoc5iUG4a6oAb2dqygxkS5M2uHWx16zHb9fUWMzpSEDwm6T7PSq2MLdHonWZ16CGfnJKRomq75aZyviTo6ZjHeYQMzNAEkjMg``` * ZEPH - ```ZEPHYR2nic7ULkkmgZNX8a9i2tMbkxuCqjgWZYuee3awX7RhtmhoT98CwGEGrruWZVSKtA7Z7JC8m7oeYHtBD9cBEZzdEh9BSdq4q``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` +* XNA - ```Nb931jkFtFN7QWpu4FqSThaoKajYjS5iFZ``` * RTM - ```RUCyaEZxQu3Eure73XPQ57si813RYAMQKC``` * BTRM - ```Bfhtr2g56tg73TNZBRCu6fJUD39Kur6SGG``` * ERG - ```9fe533kUzAE57YfPP6o3nzsYMKN2W2uCxvg8KG8Vn5DDeJGetRw``` diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index efd0f10d..2dfebe5f 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -25,7 +25,7 @@ const port2coin = { "12211": "RYO", "17750": "XHV", "18081": "", - "18981": "GRFT", +// "18981": "GRFT", "11812": "XLA", "25182": "TUBE", // "34568": "WOW", @@ -59,7 +59,7 @@ const port2blob_num = { "17750": 11, // XHV "18081": 0, // XMR "17767": 13, // ZEPH - "18981": 0, // GRFT +// "18981": 0, // GRFT "11812": 0, // XLA "25182": 10, // TUBE // "34568": 0, // WOW @@ -95,7 +95,7 @@ const port2algo = { "17750": "cn-heavy/xhv", // Haven "18081": "rx/0", // XMR "17767": "rx/0", // ZEPH - "18981": "rx/graft", // Graft +// "18981": "rx/graft", // Graft "19281": "c29v", // MoneroV "19734": "cn/r", // SUMO "19950": "c29s", // Swap @@ -530,7 +530,7 @@ function Coin(data){ } } } - const miner_tx_hash = port == 18981 ? "" : (body.result.miner_tx_hash == "" ? body.result.block_header.miner_tx_hash : body.result.miner_tx_hash); + 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 && 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')) { @@ -1012,7 +1012,7 @@ function Coin(data){ if ("autolykos2" in algos_perf) coin_perf["ERG"] = algos_perf["autolykos2"]; - if ("rx/graft" in algos_perf) coin_perf["GRFT"] = algos_perf["rx/graft"]; +// 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"]; @@ -1074,7 +1074,7 @@ function Coin(data){ case 18081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // XMR case 17767: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // ZEPH //case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC - case 18981: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 20); // 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 @@ -1104,7 +1104,7 @@ function Coin(data){ switch (blockTemplate.port) { case 17767: case 18081: - case 18981: +// case 18981: case 19994: case 11812: case 22023: From 94396ffb9e80a20bdc6da8ae3a45911912cb9996 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 5 Sep 2023 01:36:23 +0000 Subject: [PATCH 2337/2430] Added CLORE support --- README.md | 1 + deployment/base.sql | 2 ++ lib/coins/xmr.js | 30 +++++++++++++++++++----------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4fa5a0d2..009b2f8c 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,7 @@ If you'd like to make a one time donation, the addresses are as follows: * ZEPH - ```ZEPHYR2nic7ULkkmgZNX8a9i2tMbkxuCqjgWZYuee3awX7RhtmhoT98CwGEGrruWZVSKtA7Z7JC8m7oeYHtBD9cBEZzdEh9BSdq4q``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` * XNA - ```Nb931jkFtFN7QWpu4FqSThaoKajYjS5iFZ``` +* CLORE - ```AdXPHtV8yb86a8QKsbs8gmUpRpcxufRn8n``` * RTM - ```RUCyaEZxQu3Eure73XPQ57si813RYAMQKC``` * BTRM - ```Bfhtr2g56tg73TNZBRCu6fJUD39Kur6SGG``` * ERG - ```9fe533kUzAE57YfPP6o3nzsYMKN2W2uCxvg8KG8Vn5DDeJGetRw``` diff --git a/deployment/base.sql b/deployment/base.sql index 951cfdee..10346e10 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -252,6 +252,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', 'coinHashFactorBTRM', '0', 'float', 'BTRM algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorZEPH', '0', 'float', 'ZEPH algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXNA', '0', 'float', 'XNA algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorCLORE', '0', 'float', 'CLORE 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', 'Default Daemon RPC Wallet IP'); @@ -328,6 +329,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_17767', '', 'string', 'Address to mine to for 17767 (ZEPH) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_10225', '', 'string', 'Address to mine to for 10225 (BTRM) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19001', '', 'string', 'Address to mine to for 19001 (Neurai) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9766', '', 'string', 'Address to mine to for 9766 (CLORE) 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 2dfebe5f..b4592645 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -51,6 +51,7 @@ const port2coin = { "10225" : "BTRM", "17767" : "ZEPH", "19001" : "XNA", + "9766" : "CLORE", }; const port2blob_num = { // "11181": 7, // AEON @@ -83,7 +84,8 @@ const port2blob_num = { "9053" : 103, // ERG "9998" : 104, // RTM "10225": 104, // BTRM - "19001" : 101, // XNA + "19001": 101, // XNA + "9766" : 101, // CLORE }; const port2algo = { @@ -118,6 +120,7 @@ const port2algo = { "9998" : "ghostrider", // RTM "10225": "ghostrider", // BTRM "19001": "kawpow", // XNA + "9766": "kawpow", // CLORE }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -350,7 +353,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); @@ -423,13 +426,13 @@ function Coin(data){ } return callback(null, body); }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash, 2 ] }, function (body) { if (!body || !body.result || !(body.result.tx instanceof Array) || body.result.tx.length < 1) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - if (port == 8766 || port == 19001) { // XNA, RVN + if (port == 8766 || port == 19001 || port == 9766) { // XNA, RVN body.result.reward = 0; for (const vout of body.result.tx[0].vout) body.result.reward += vout.value; } else body.result.reward = 3750; // BTRM, RTM @@ -583,7 +586,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { console.error("getPortLastBlockHeader(" + port + "): " + JSON.stringify(body)); @@ -639,7 +642,7 @@ function Coin(data){ return callback(body ? body : null); }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001) { + } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getblocktemplate', params: [{ @@ -648,10 +651,13 @@ 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 10225: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); - case 19001: return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); + case 9998: + case 10225: + return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); + case 8766: + case 19001: + case 9766: + return callback(cnUtil.RavenBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); } else return callback(null); }); @@ -1003,7 +1009,7 @@ function Coin(data){ // if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; - if ("kawpow" in algos_perf) coin_perf["RVN"] = coin_perf["XNA"] = algos_perf["kawpow"]; + if ("kawpow" in algos_perf) coin_perf["RVN"] = coin_perf["XNA"] = coin_perf["CLORE"] = algos_perf["kawpow"]; if ("ghostrider" in algos_perf) coin_perf["RTM"] = coin_perf["BTRM"] = algos_perf["ghostrider"]; @@ -1059,6 +1065,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 19001: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // XNA + case 9766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // CLORE case 9998: return multiHashing.cryptonight(convertedBlob, 18); // RTM case 10225: return multiHashing.cryptonight(convertedBlob, 18); // BTRM case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH @@ -1173,6 +1180,7 @@ function Coin(data){ case 8645: return "eth"; // ETC case 8766: return "raven"; // RVN case 19001: return "raven"; // XNA + case 9766: return "raven"; // CLORE case 9053: return "erg"; // ERG case 9231: return "cryptonote_loki"; // XEQ case 9998: return "raptoreum"; // RTM From b742db4c00d33aefe337ce9509eab8b2617aef8d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Sep 2023 00:56:09 +0000 Subject: [PATCH 2338/2430] Added CLORE support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c5cbc427..35fce587 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#v15.0.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.0.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.10" } } From 132232cc760201fe9bd157baaa55e5fb79f02d34 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Sep 2023 06:07:12 +0000 Subject: [PATCH 2339/2430] Fixed CLORE reward --- 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 b4592645..dbeaedb7 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -432,9 +432,12 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - if (port == 8766 || port == 19001 || port == 9766) { // XNA, RVN + if (port == 8766 || port == 19001 || port == 9766) { // XNA, RVN, CLORE body.result.reward = 0; - for (const vout of body.result.tx[0].vout) body.result.reward += vout.value; + for (const vout of body.result.tx[0].vout) { + if (vout.scriptPubKey.addresses[0] != "AePr762UcuQrGoa3TRQpGMX6byRjuXw97A") // ignore CLORE common address + body.result.reward += vout.value; + } } else body.result.reward = 3750; // BTRM, RTM body.result.reward *= 100000000; if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; From 10cbff932aca07f9dc96d711a5dad09fb5c3c13b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 6 Sep 2023 06:10:16 +0000 Subject: [PATCH 2340/2430] Fixed CLORE reward --- 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 dbeaedb7..efb47c89 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -435,8 +435,8 @@ function Coin(data){ if (port == 8766 || port == 19001 || port == 9766) { // XNA, RVN, CLORE body.result.reward = 0; for (const vout of body.result.tx[0].vout) { - if (vout.scriptPubKey.addresses[0] != "AePr762UcuQrGoa3TRQpGMX6byRjuXw97A") // ignore CLORE common address - body.result.reward += vout.value; + if (vout.scriptPubKey.addresses && vout.scriptPubKey.addresses[0] === "AePr762UcuQrGoa3TRQpGMX6byRjuXw97A") continue; // ignore CLORE common address + body.result.reward += vout.value; } } else body.result.reward = 3750; // BTRM, RTM body.result.reward *= 100000000; From 92b548b7b30aaf58933291b66d0c0e283944e078 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 26 Sep 2023 16:55:55 +0000 Subject: [PATCH 2341/2430] XLA fork support --- lib/coins/xmr.js | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index efb47c89..1389e788 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -61,7 +61,7 @@ const port2blob_num = { "18081": 0, // XMR "17767": 13, // ZEPH // "18981": 0, // GRFT - "11812": 0, // XLA + "11812": 14, // XLA "25182": 10, // TUBE // "34568": 0, // WOW "38081": 6, // MSR @@ -1188,7 +1188,7 @@ function Coin(data){ case 9231: return "cryptonote_loki"; // XEQ case 9998: return "raptoreum"; // RTM case 10225: return "raptoreum"; // BTRM - //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 @@ -1201,6 +1201,7 @@ function Coin(data){ case 25182: return "cryptonote_tube"; // TUBE case 33124: return "cryptonote_xtnc"; // XtendCash case 38081: return "cryptonote3"; // MSR + case 11812: return "cryptonote_xla"; // XLA default: return "cryptonote"; } } diff --git a/package.json b/package.json index 35fce587..da8df9f2 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#v15.0.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.1.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.10" } } From b795a1f281a0371f727d80eeca38443c2eb93b54 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 1 Oct 2023 14:25:16 +0000 Subject: [PATCH 2342/2430] Added ZEPH fork support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da8df9f2..47c043ca 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#v15.1.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.2.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.10" } } From 8ed8430b8eb0ed6a8bf825bfaaa87613eae33faa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 17:06:44 +0000 Subject: [PATCH 2343/2430] Fixed rewards for RVN --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 1389e788..1f8f02ff 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -440,6 +440,7 @@ function Coin(data){ } } else body.result.reward = 3750; // BTRM, RTM body.result.reward *= 100000000; + body.result.reward = parseInt(body.result.reward); if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); From 9fb58e090a6ac83b3fcaee225962de2f6c2bf34f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 17:29:32 +0000 Subject: [PATCH 2344/2430] Debug RTM 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 1f8f02ff..db232c20 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -432,7 +432,7 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - if (port == 8766 || port == 19001 || port == 9766) { // XNA, RVN, CLORE + if (port == 8766 || port == 19001 || port == 9766 || port == 9998) { // XNA, RVN, CLORE body.result.reward = 0; for (const vout of body.result.tx[0].vout) { if (vout.scriptPubKey.addresses && vout.scriptPubKey.addresses[0] === "AePr762UcuQrGoa3TRQpGMX6byRjuXw97A") continue; // ignore CLORE common address From 68b8c80534006812562036230f8c0861d000533c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 17:33:43 +0000 Subject: [PATCH 2345/2430] Debug RTM reward --- 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 db232c20..3f4d1fb3 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -432,13 +432,19 @@ function Coin(data){ console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); return callback(true, body); } - if (port == 8766 || port == 19001 || port == 9766 || port == 9998) { // XNA, RVN, CLORE + if (port == 8766 || port == 19001 || port == 9766) { // XNA, RVN, CLORE body.result.reward = 0; for (const vout of body.result.tx[0].vout) { if (vout.scriptPubKey.addresses && vout.scriptPubKey.addresses[0] === "AePr762UcuQrGoa3TRQpGMX6byRjuXw97A") continue; // ignore CLORE common address body.result.reward += vout.value; } - } else body.result.reward = 3750; // BTRM, RTM + } else { // body.result.reward = 3750; // BTRM, RTM + body.result.reward = 0; + for (const vout of body.result.tx[0].vout) { + if (vout.scriptPubKey.addresses && vout.scriptPubKey.addresses[0] === global.config.pool["address_" + port.toString()]) + body.result.reward += vout.value; + } + } body.result.reward *= 100000000; body.result.reward = parseInt(body.result.reward); if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; From 423b4bc08c15283c7d4f0c8d4f50ac232fed211b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 17:38:07 +0000 Subject: [PATCH 2346/2430] Debug RTM reward --- 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 3f4d1fb3..deb2f622 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -441,8 +441,8 @@ function Coin(data){ } else { // body.result.reward = 3750; // BTRM, RTM body.result.reward = 0; for (const vout of body.result.tx[0].vout) { - if (vout.scriptPubKey.addresses && vout.scriptPubKey.addresses[0] === global.config.pool["address_" + port.toString()]) - body.result.reward += vout.value; + if (vout.scriptPubKey.addresses && vout.value > body.result.reward) + body.result.reward = vout.value; } } body.result.reward *= 100000000; From d9a05ad160a0bd75776f4a979c32573e775c1ca0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 17:46:15 +0000 Subject: [PATCH 2347/2430] Debug RTM reward --- lib/coins/xmr.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index deb2f622..88766b8e 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -439,11 +439,7 @@ function Coin(data){ body.result.reward += vout.value; } } else { // body.result.reward = 3750; // BTRM, RTM - body.result.reward = 0; - for (const vout of body.result.tx[0].vout) { - if (vout.scriptPubKey.addresses && vout.value > body.result.reward) - body.result.reward = vout.value; - } + body.result.reward = body.result.tx[0].vout[2].value; } body.result.reward *= 100000000; body.result.reward = parseInt(body.result.reward); From 1b24002fa1e517f01fec61646c155139dea5a001 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 17:59:59 +0000 Subject: [PATCH 2348/2430] Debug RTM reward --- 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 88766b8e..2395d4b5 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -439,7 +439,11 @@ function Coin(data){ body.result.reward += vout.value; } } else { // body.result.reward = 3750; // BTRM, RTM - body.result.reward = body.result.tx[0].vout[2].value; + body.result.reward = 0; + for (const vout of body.result.tx[0].vout) { + if (vout.value > body.result.reward && n <= 2) + body.result.reward = vout.value; + } } body.result.reward *= 100000000; body.result.reward = parseInt(body.result.reward); From 14c9b23c44364f912d4484baefcb5ecd39df52d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 18:00:46 +0000 Subject: [PATCH 2349/2430] Debug RTM 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 2395d4b5..208cda56 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -441,7 +441,7 @@ function Coin(data){ } else { // body.result.reward = 3750; // BTRM, RTM body.result.reward = 0; for (const vout of body.result.tx[0].vout) { - if (vout.value > body.result.reward && n <= 2) + if (vout.value > body.result.reward && vout.n <= 2) body.result.reward = vout.value; } } From aa62fba34d278246d0029903b58339ad3e758fe7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 Nov 2023 18:05:32 +0000 Subject: [PATCH 2350/2430] Debug RTM 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 208cda56..3437763b 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -441,7 +441,7 @@ function Coin(data){ } else { // body.result.reward = 3750; // BTRM, RTM body.result.reward = 0; for (const vout of body.result.tx[0].vout) { - if (vout.value > body.result.reward && vout.n <= 2) + if (vout.value > body.result.reward) body.result.reward = vout.value; } } From f92702819fd7bab49e6eb18e85eff8a92056a109 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 17 Dec 2023 07:33:35 +0000 Subject: [PATCH 2351/2430] Updated xmr 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 41e0a54e..a153da58 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.18.0.0 +sudo git checkout v0.18.3.1 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 e7ee247c..d772cbbf 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.18.0.0 +sudo git checkout v0.18.3.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 25c7a272..8550e946 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.18.0.0 +sudo git checkout v0.18.3.1 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 f8551280..7c339c30 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git reset --hard origin/master &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.18.0.0 &&\ +sudo git checkout v0.18.3.1 &&\ sudo git submodule update --force --recursive --init &&\ sudo rm -rf build &&\ sudo USE_SINGLE_BUILDDIR=1 nice make release &&\ From 5bf17b62d1b924ffba8717d74838315dcb332f09 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 31 Dec 2023 02:03:25 +0000 Subject: [PATCH 2352/2430] Invalidate too high share throttle --- lib/pool.js | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ef4a3d13..dcd22481 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1632,18 +1632,27 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (miner.payout in minerWallets) minerWallets[miner.payout].hashes += job.norm_diff; walletLastSeeTime[miner.payout] = Date.now(); - let shareThrottled = function() { - 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'}); - if (addProxyMiner(miner)) { - const proxyMinerName = miner.payout; // + ":" + miner.identifier; - proxyMiners[proxyMinerName].hashes += job.norm_diff; - adjustMinerDiff(miner); - } - return true; + let shareThrottled = function(processShareCB) { + if (miner.payout in minerWallets) { + const last_ver_shares = ++minerWallets[miner.payout].last_ver_shares; + const threshold = global.config.pool.minerThrottleSharePerSec * global.config.pool.minerThrottleShareWindow; + if (last_ver_shares > threshold) { + if (last_ver_shares == threshold) { + console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); + } else if (last_ver_shares > 10 * threshold) { // too much will invalidate share + invalid_share(miner); + processShareCB(false); // invalid share + return true; + } + process.send({type: 'throttledShare'}); + if (addProxyMiner(miner)) { + const proxyMinerName = miner.payout; // + ":" + miner.identifier; + proxyMiners[proxyMinerName].hashes += job.norm_diff; + adjustMinerDiff(miner); + } + processShareCB(null); // throttle share + return true; + } } return false; } @@ -1673,14 +1682,14 @@ 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); + if (shareThrottled(processShareCB)) return; 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') ]; return verifyShareCB(hashEthBuffDiff(resultBuff), resultBuff, blockData, false, true); } else if (global.coinFuncs.blobTypeErg(blob_type_num)) { - if (shareThrottled()) return processShareCB(null); + if (shareThrottled(processShareCB)) return; 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]), null, params.nonce, false, true); @@ -1726,7 +1735,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { } else { // verify share if (miner.debugMiner) console.log(threadName + miner.logString + " [WALLET DEBUG] verify share"); - if (shareThrottled()) return processShareCB(null); + if (shareThrottled(processShareCB)) return; const blockData = getShareBuffer(miner, job, blockTemplate, params); if (blockData === null) return processShareCB(invalid_share(miner)); const convertedBlob = global.coinFuncs.convertBlob(blockData, port); From fd5e21cbc4a225cb65aa06667177ab2ccc2e53da Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 31 Dec 2023 02:04:57 +0000 Subject: [PATCH 2353/2430] Invalidate too high share throttle --- lib/pool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pool.js b/lib/pool.js index dcd22481..ce0d40ab 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1640,6 +1640,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (last_ver_shares == threshold) { console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); } else if (last_ver_shares > 10 * threshold) { // too much will invalidate share + console.error(threadName + "Throttled down miner share as invalid (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); invalid_share(miner); processShareCB(false); // invalid share return true; From fe881889268671fd118dfe69e7da313e633c651a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 31 Dec 2023 02:08:23 +0000 Subject: [PATCH 2354/2430] Invalidate too high share throttle --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ce0d40ab..6f8d4c1e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1639,7 +1639,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (last_ver_shares > threshold) { if (last_ver_shares == threshold) { console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); - } else if (last_ver_shares > 10 * threshold) { // too much will invalidate share + } else if (last_ver_shares > 100 * threshold) { // too much will invalidate share console.error(threadName + "Throttled down miner share as invalid (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); invalid_share(miner); processShareCB(false); // invalid share From 804311e573826d6c28dc0657dc6dccce4e3a717a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 31 Dec 2023 02:26:09 +0000 Subject: [PATCH 2355/2430] Invalidate too high share throttle --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 6f8d4c1e..82772c7d 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1639,7 +1639,7 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { if (last_ver_shares > threshold) { if (last_ver_shares == threshold) { console.error(threadName + "Throttled down miner share (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); - } else if (last_ver_shares > 100 * threshold) { // too much will invalidate share + } else if (job.rewarded_difficulty2 >= 10000000 && last_ver_shares > 10 * threshold) { // too much will invalidate share console.error(threadName + "Throttled down miner share as invalid (diff " + job.rewarded_difficulty2 + ") submission from " + miner.logString); invalid_share(miner); processShareCB(false); // invalid share From 1347eada50051fbabfc5415b0403b6852cb45dea Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jan 2024 04:34:03 +0000 Subject: [PATCH 2356/2430] kawpow4 algo support for GPU with 4GB RAM --- lib/coins/xmr.js | 1 + lib/pool.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3437763b..8ad515d6 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1020,6 +1020,7 @@ function Coin(data){ // if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; if ("kawpow" in algos_perf) coin_perf["RVN"] = coin_perf["XNA"] = coin_perf["CLORE"] = algos_perf["kawpow"]; + if ("kawpow4" in algos_perf) coin_perf["XNA"] = coin_perf["CLORE"] = algos_perf["kawpow4"]; if ("ghostrider" in algos_perf) coin_perf["RTM"] = coin_perf["BTRM"] = algos_perf["ghostrider"]; diff --git a/lib/pool.js b/lib/pool.js index 82772c7d..848c6a6e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -736,6 +736,10 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro 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"]; + if (this.algos["kawpow4"]) { + this.algos["kawpow"] = 1; + delete this.algos["kawpow4"]; + } const check = global.coinFuncs.algoCheck(this.algos); if (check !== true) return check; if ("cn-pico" in this.algos) this.algos["cn-pico/trtl"] = 1; From 147c67492b96e47c8ae4c96587a42d98e40b630c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 3 Mar 2024 18:14:07 -0800 Subject: [PATCH 2357/2430] Updated hashing utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47c043ca..1449f74d 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#v15.2.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.10" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.11" } } From 8279300ade478d168d53f271b747dccfebf249d7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 11 Mar 2024 11:32:54 -0700 Subject: [PATCH 2358/2430] Reduced monmero usage by excluding not supported coins --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1449f74d..83e63290 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#v15.2.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.0.11" + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.1" } } From 0c70097c2ef88759810558d06f60e579b030f8c8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 May 2024 01:51:34 +0300 Subject: [PATCH 2359/2430] Updated software --- deployment/deploy.bash | 8 ++++---- deployment/deploy_test.bash | 10 +++++----- deployment/leaf.bash | 8 ++++---- deployment/upgrade_monero.bash | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index a153da58..47c33690 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.18.3.1 +sudo git checkout v0.18.3.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/ @@ -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.17.3 -nvm alias default v14.17.3 +nvm install v22.1.0 +nvm alias default v22.1.0 cd ~/nodejs-pool npm install npm install -g pm2 @@ -74,7 +74,7 @@ sudo systemctl enable caddy.service sudo systemctl start caddy.service 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` +sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v22.1.0/bin `pwd`/.nvm/versions/node/v22.1.0/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` cd ~/nodejs-pool sudo chown -R $CURUSER ~/.pm2 echo "Installing pm2-logrotate in the background!" diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash index d772cbbf..728305a0 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.18.3.1 +sudo git checkout v0.18.3.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 @@ -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 v14.17.3 -nvm alias default v14.17.3 +nvm install v22.1.0 +nvm alias default v22.1.0 cd ~/nodejs-pool npm install npm install -g pm2 @@ -71,7 +71,7 @@ sudo systemctl enable caddy.service sudo systemctl start caddy.service 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` +sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v22.1.0/bin `pwd`/.nvm/versions/node/v22.1.0/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` cd ~/nodejs-pool sudo chown -R $CURUSER ~/.pm2 echo "Installing pm2-logrotate in the background!" @@ -82,5 +82,5 @@ mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api bash ~/nodejs-pool/deployment/install_lmdb_tools.sh cd ~/nodejs-pool/sql_sync/ -env PATH=$PATH:`pwd`/.nvm/versions/node/v8.11.3/bin node sql_sync.js +env PATH=$PATH:`pwd`/.nvm/versions/node/v22.1.0/bin node sql_sync.js echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 8550e946..bc25a75f 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.18.3.1 +sudo git checkout v0.18.3.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/ @@ -27,14 +27,14 @@ 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.17.3 -nvm alias default v14.17.3 +nvm install v22.1.0 +nvm alias default v22.1.0 cd ~/nodejs-pool npm install 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 env PATH=$PATH:`pwd`/.nvm/versions/node/v22.1.0/bin `pwd`/.nvm/versions/node/v22.1.0/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` sudo chown -R $CURUSER ~/.pm2 echo "Installing pm2-logrotate in the background!" pm2 install pm2-logrotate diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 7c339c30..96ed31fd 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git reset --hard origin/master &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.18.3.1 &&\ +sudo git checkout v0.18.3.3 &&\ sudo git submodule update --force --recursive --init &&\ sudo rm -rf build &&\ sudo USE_SINGLE_BUILDDIR=1 nice make release &&\ From cca7ab5d60c4d761bde8c7d9492b0a948cce4c6f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 May 2024 20:15:08 +0300 Subject: [PATCH 2360/2430] Updated for Ubuntu 24.04 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 83e63290..d20d4ca8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "minimist": ">=1.2.6", "moment": "2.29.4", "mysql": "2.18.1", - "node-lmdb": "git+https://github.com/Venemo/node-lmdb.git#5941c1e553de4ae1d57a67d355b7c2dd87feaea6", + "node-lmdb": "git+https://github.com/Venemo/node-lmdb.git#c3135a3809da1d64ce1f0956b37b618711e33519", "promise-mysql": "3.0.0", "protocol-buffers": "^3.2.1", "range": "0.0.3", @@ -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#v15.2.0", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.1" + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.2.1", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.2" } } From 11f5ef29590f8c87bc6f271f9c303949186f0dc9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 May 2024 20:22:57 +0300 Subject: [PATCH 2361/2430] Updated for Ubuntu 24.04 --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d20d4ca8..aefefd07 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,20 @@ "author": "Multiple", "license": "MIT", "dependencies": { + "apicache": "1.2.1", "async": "3.2.2", "bignum": "^0.13.1", "body-parser": "^1.16.0", "circular-buffer": "1.0.2", "cluster": "0.7.7", - "crypto-js": "4.1.1", "concat-stream": "^1.6.0", "cors": "^2.8.1", + "crypto-js": "^4.2.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.2.1", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.2", "debug": "2.6.9", "express": "^4.17.1", - "apicache": "1.2.1", - "jsonwebtoken": "^8.5.1", + "jsonwebtoken": "^9.0.2", "minimist": ">=1.2.6", "moment": "2.29.4", "mysql": "2.18.1", @@ -30,11 +32,9 @@ "protocol-buffers": "^3.2.1", "range": "0.0.3", "request": "^2.79.0", - "request-json": "0.6.5", + "request-json": "^0.1.0", "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#v15.2.1", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.2" + "wallet-address-validator": "0.1.0" } } From 76c08d9133209c2d4d3ec7f5ce256b14f1438b87 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 May 2024 21:08:32 +0300 Subject: [PATCH 2362/2430] Updated tools --- deployment/install_lmdb_tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/install_lmdb_tools.sh b/deployment/install_lmdb_tools.sh index f072ffed..a8028315 100644 --- a/deployment/install_lmdb_tools.sh +++ b/deployment/install_lmdb_tools.sh @@ -3,7 +3,7 @@ cd ~ rm -rf node-lmdb git clone https://github.com/Venemo/node-lmdb.git cd node-lmdb -git checkout 5941c1e553de4ae1d57a67d355b7c2dd87feaea6 +git checkout c3135a3809da1d64ce1f0956b37b618711e33519 cd dependencies/lmdb/libraries/liblmdb make -j `nproc` mkdir ~/.bin From cb971466a0b5f7e1ff6e6463ebe4bc4b11eac801 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 3 May 2024 22:28:56 +0300 Subject: [PATCH 2363/2430] Better handle new pools --- lib/pool.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 848c6a6e..7c92ae06 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2568,9 +2568,8 @@ if (cluster.isMaster) { let numWorkers = require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { let fn = "wallet_trust_" + i.toString(); - let rs = fs.createReadStream(fn); - rs.on('error', function() { console.error("Can't open " + fn + " file"); }); - let lineReader = require('readline').createInterface({ input: rs }); + let lineReader = require('readline').createInterface({ input: fs.createReadStream(fn) }); + lineReader.on('error', function() { console.error("Can't read lines from " + fn + " file"); }); lineReader.on('line', function (line) { let parts = line.split(/\t/); if (parts.length != 3) { From 5904439b40292b7aef44453e5ee203f187501132 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 5 May 2024 18:59:14 +0300 Subject: [PATCH 2364/2430] Updated for Ubuntu 24.04 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index aefefd07..6815eb71 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.2.1", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.2.2", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.3", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From d1ec2b80a0aa0028729b62cb16c4d8a6452a4bbb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 5 May 2024 20:29:22 +0300 Subject: [PATCH 2365/2430] Removed old buffer usage --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6815eb71..bb7782a5 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "mysql": "2.18.1", "node-lmdb": "git+https://github.com/Venemo/node-lmdb.git#c3135a3809da1d64ce1f0956b37b618711e33519", "promise-mysql": "3.0.0", - "protocol-buffers": "^3.2.1", + "protocol-buffers": "5.0.0", "range": "0.0.3", "request": "^2.79.0", "request-json": "^0.1.0", From 3e6b3a9f075779b0cab39914f09419857dd5860e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 May 2024 02:30:43 +0300 Subject: [PATCH 2366/2430] Close connections by default --- lib/support.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/support.js b/lib/support.js index 3a4bfade..ce2dbc4c 100644 --- a/lib/support.js +++ b/lib/support.js @@ -119,7 +119,8 @@ function jsonRequest(host, port, data, callback, path, timeout) { timeout: timeout, headers: { "Content-Type": "application/json", - "Accept": "application/json" + "Accept": "application/json", + "Connection": "close", } }; if (global.config.daemon.basicAuth) { From ada0bc455d6559fb8eadbb917d4a9fe07ac3ed97 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 May 2024 03:37:29 +0300 Subject: [PATCH 2367/2430] Updated for Ubuntu 24.04 --- README.md | 157 ++++++---------- deployment/caddyfile | 17 -- deployment/deploy.bash | 304 +++++++++++++++++++++++-------- deployment/deploy_test.bash | 86 --------- deployment/install_lmdb_tools.sh | 13 -- deployment/leaf.bash | 128 +++++++++---- deployment/monero.service | 13 -- deployment/monero_test.service | 13 -- 8 files changed, 373 insertions(+), 358 deletions(-) delete mode 100644 deployment/caddyfile delete mode 100644 deployment/deploy_test.bash delete mode 100644 deployment/install_lmdb_tools.sh delete mode 100644 deployment/monero.service delete mode 100644 deployment/monero_test.service diff --git a/README.md b/README.md index 009b2f8c..18e194c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Pool Design/Theory ================== -The nodejs-pool is built around a small series of core daemons that share access to a single LMDB table for tracking of shares, with MySQL being used to centralize configurations and ensure simple access from local/remote nodes. The core daemons follow: +The nodejs-pool is built around a small series of core daemons that share access to a single LMDB table for tracking of shares, +with MySQL being used to centralize configurations and ensure simple access from local/remote nodes. The core daemons follow: + ```text api - Main API for the frontend to use and pull data from. Expects to be hosted at / remoteShare - Main API for consuming shares from remote/local pools. Expects to be hosted at /leafApi @@ -10,99 +12,75 @@ payments - Handles all payments to workers. blockManager - Unlocks blocks and distributes payments into MySQL worker - Does regular processing of statistics and sends status e-mails for non-active miners. ``` -API listens on port 8001, remoteShare listens on 8000 -moneroocean.stream (The reference implementation) uses the following setup: +API listens on port 8001, remoteShare listens on 8000. + +moneroocean.stream (The reference implementation) uses the following setup: * https://moneroocean.stream is hosted on its own server, as the main website is a static frontend * https://api.moneroocean.stream hosts api, remoteShare, longRunner, payments, blockManager, worker, as these must all be hosted with access to the same LMDB database. -Sample Caddyfile for API: -```text -https://api.moneroocean.stream { - proxy /leafApi 127.0.0.1:8000 - proxy / 127.0.0.1:8001 - cors - gzip -} -``` - -It is critically important that your webserver does not truncate the `/leafApi` portion of the URL for the remoteShare daemon, or it will not function! Local pool servers DO use the remoteShare daemon, as this provides a buffer in case of an error with LMDB or another bug within the system, allowing shares and blocks to queue for submission as soon as the leafApi/remoteShare daemons are back up and responding with 200's. - Setup Instructions ================== Server Requirements ------------------- -* Ubuntu 20.04, 18.04 (confirmed working) +* Ubuntu 24.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! +* 2 CPU Cores +* 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! Pre-Deploy ---------- -* If you're planning on using e-mail, you'll want to setup an account at https://mailgun.com (It's free for 10k e-mails/month!), so you can notify miners. This also serves as the backend for password reset emails, along with other sorts of e-mails from the pool, including pool startup, pool Monerod daemon lags, etc so it's highly suggested! -* Pre-Generate the wallets, or don't, it's up to you! You'll need the addresses after the install is complete, so I'd suggest making sure you have them available. Information on suggested setups are found below. -* If you're going to be offering PPS, PLEASE make sure you load the pool wallet with XMR before you get too far along. Your pool will trigger PPS payments on its own, and fairly readily, so you need some float in there! -* Make a non-root user, and run the installer from there! +* If you're planning on using e-mail, you'll want to setup an account at https://mailgun.com (It's free for 10k e-mails/month!), so you can notify miners. This also serves as the backend for password reset emails, along with other sorts of e-mails from the pool, including pool startup, pool Monerod daemon lags, etc so it's highly suggested! +* Pre-Generate the wallets, or don't, it's up to you! You'll need the addresses after the install is complete, so I'd suggest making sure you have them available. Information on suggested setups are found below. +* Run installer from root user and it will make new "user" for pool usage later. Deployment via Installer ------------------------ -1. Add your user to `/etc/sudoers`, this must be done so the script can sudo up and do it's job. We suggest passwordless sudo. Suggested line: ` ALL=(ALL) NOPASSWD:ALL`. Our sample builds use: `pooldaemon ALL=(ALL) NOPASSWD:ALL` -2. Run the [deploy script](https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/deploy.bash) as a **NON-ROOT USER**. This is very important! This script will install the pool to whatever user it's running under! Also. Go get a coffee, this sucker bootstraps the monero installation. -3. Once it's complete, change as `config.json` appropriate. It is pre-loaded for a local install of everything, running on 127.0.0.1. This will work perfectly fine if you're using a single node setup. You'll also want to set `bind_ip` to the external IP of the pool server, and `hostname` to the resolvable hostname for the pool server. `pool_id` is mostly used for multi-server installations to provide unique identifiers in the backend. You will also want to run: source ~/.bashrc This will activate NVM and get things working for the following pm2 steps. -4. You'll need to change the API endpoint for the frontend code in the `poolui/build/globals.js` and `poolui/build/globals.default.js` -- This will usually be `http(s):///api` unless you tweak caddy! -5. The default database directory `/home//pool_db/` is already been created during startup. If you change the `db_storage_path` just make sure your user has write permissions for new path. Run: `pm2 restart api` to reload the API for usage. -6. Hop into the web interface (Should be at `http:///admin.html`), then login with `Administrator/Password123`, **MAKE SURE TO CHANGE THIS PASSWORD ONCE YOU LOGIN**. *<- This step is currently not active, we're waiting for the frontend to catch up! Head down to the Manual SQL Configuration to take a look at what needs to be done by hand for now*. -7. From the admin panel, you can configure all of your pool's settings for addresses, payment thresholds, etc. -8. Once you're happy with the settings, go ahead and start all the pool daemons, commands follow. +2. Run the [deploy script](https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/deploy.bash) as a **ROOT USER**. This is very important! This script will install the pool to new user "user"! Also. Go get a coffee, this sucker bootstraps the monero installation. +3. Once it's complete, change as `config.json` appropriate. It is pre-loaded for a local install of everything, running on 127.0.0.1. This will work perfectly fine if you're using a single node setup. You'll also want to set `bind_ip` to the external IP of the pool server, and `hostname` to the resolvable hostname for the pool server. `pool_id` is mostly used for multi-server installations to provide unique identifiers in the backend. You will also want to run: source ~/.bashrc This will activate NVM and get things working for the following pm2 steps. +4. You'll need to change the API endpoint for the frontend code in the `moneroocean-gui/script.js` -- This will usually be `http(s)://api.` unless you tweak nginx! +5. The default database directory `/home/user/pool_db/` is already been created during startup. If you change the `db_storage_path` just make sure your user has write permissions for new path. Run: `pm2 restart api` to reload the API for usage. +8. Once you're happy with the settings, go ahead and add pool daemon on main/leaf pool node: ```shell cd ~/nodejs-pool/ -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 +pm2 save +pm2 startup ``` -Install Script: +Install Script that assumes you have free Cloudflare DNS setup for your web (moneroocean.stream) and API (api.moneroocean.stream) endpoints, CLoudflare API Token from +from https://dash.cloudflare.com/profile/api-tokens with "Zone.Zone (Read), Zone.DNS (Edit)" permissions and email for certbot updates: + ```bash -curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/deploy.bash | bash +curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/deploy.bash | bash -s -- -s moneroocean.stream api.moneroocean.stream "Cloudflare API Token" support@moneroocean.stream +``` + +Leaf server install script (only for pool module that you need to add/start as shown above after install and updating config.json to connect to your main pool DB server): +```bash +curl -L https://raw.githubusercontent.com/MoneroOcean/nodejs-pool/master/deployment/leaf.bash | bash ``` Assumptions for the installer ----------------------------- -The installer assumes that you will be running a single-node instance and using a clean Ubuntu 16.04 server install. The following system defaults are set: +The installer assumes that you will be running a single-node instance and using a clean Ubuntu 24.04 server install. The following system defaults are set: * MySQL Username: pool * MySQL Password: 98erhfiuehw987fh23d * MySQL Host: 127.0.0.1 -* MySQL root access is only permitted as the root user, the password is in `/root/.my.cnf` +* MySQL root access is only permitted as the root user, the password is in `/root/mysql_pass` * SSL Certificate is generated, self-signed, but is valid for Claymore Miners. * The server installs and deploys Caddy as it's choice of web server! -The following raw binaries **MUST BE AVAILABLE FOR IT TO BOOTSTRAP**: -* sudo - -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! +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. Wallet Setup ------------ -The pool is designed to have a dual-wallet design, one which is a fee wallet, one which is the live pool wallet. The fee wallet is the default target for all fees owed to the pool owner. PM2 can also manage your wallet daemon, and that is the suggested run state. - -1. Generate your wallets using `/usr/local/src/monero/build/release/bin/monero-wallet-cli` -2. Make sure to save your regeneration stuff! -3. For the pool wallet, store the password in a file, the suggestion is `~/wallet_pass` -4. Change the mode of the file with chmod to 0400: `chmod 0400 ~/wallet_pass` -5. Start the wallet using PM2: `pm2 start /usr/local/src/monero/build/release/bin/monero-wallet-rpc -- --rpc-bind-port 18082 --password-file ~/wallet_pass --wallet-file --disable-rpc-login --trusted-daemon` -6. If you don't use PM2, then throw the wallet into a screen and have fun. +The pool is designed to have a dual-wallet design, one which is a fee wallet, one which is the live pool wallet. +The fee wallet is the default target for all fees owed to the pool owner. PM2 can also manage your wallet daemon, and that is the suggested run state. Manual Setup ------------ @@ -110,47 +88,27 @@ Pretty similar to the above, you may wish to dig through a few other things for Manual SQL Configuration ------------------------ -Until the full frontend is released, the following SQL information needs to be updated by hand in order to bring your pool online, in module/item format. You can also edit the values in sample_config.sql, then import them into SQL directly via an update. +Until the full frontend is released, the following SQL information needs to be updated by hand in order to bring your pool online, in module/item format. You can also edit the values in sample_config.sql, then import them into SQL directly via an update. ``` -Critical/Must be done: -pool/address -pool/feeAddress -general/shareHost - Nice to have: general/mailgunKey general/mailgunURL general/emailFrom -SQL import command: sudo mysql pool < ~/nodejs-pool/sample_config.sql (Adjust name/path as needed!) +SQL import command: ```mysql -u root --password=$(sudo cat /root/mysql_pass)``` ``` -The shareHost configuration is designed to be pointed at wherever the leafApi endpoint exists. For moneroocean.stream, we use https://api.moneroocean.stream/leafApi. If you're using the automated setup script, you can use: `http:///leafApi`, as Caddy will proxy it. If you're just using localhost and a local pool serv, http://127.0.0.1:8000/leafApi will do you quite nicely +The shareHost configuration is designed to be pointed at wherever the leafApi endpoint exists. For moneroocean.stream, we use https://api.moneroocean.stream/leafApi. +If you're using the automated setup script, you can use: `http:///leafApi`, as Caddy will proxy it. If you're just using localhost and a local pool server, +http://localhost:8000/leafApi will do you quite nicely. -Additional ports can be added as desired, samples can be found at the end of base.sql. If you're not comfortable with the MySQL command line, I highly suggest MySQL Workbench or a similar piece of software (I use datagrip!). Your root MySQL password can be found in `/root/.my.cnf` - -Final Manual Steps ------------------- -Until the main frontend is done, we suggest running the following SQL line: -``` -DELETE FROM pool.users WHERE username = 'Administrator'; -``` -This will remove the administrator user until there's an easier way to change the password. Alternatively, you can change the password to something not known by the public: -``` -UPDATE pool.users SET email='your new password here' WHERE username='Administrator'; -``` -The email field is used as the default password field until the password is changed, at which point, it's hashed and dumped into the password field instead, and using the email field as a password is disabled. - -You should take a look at the [wiki](https://github.com/MoneroOcean/nodejs-pool/wiki/Configuration-Details) for specific configuration settings in the system. +Additional ports can be added as desired, samples can be found at the end of base.sql. If you're not comfortable with the MySQL command line, +I highly suggest MySQL Workbench or a similar piece of software (I use datagrip!). Your root MySQL password can be found in `/root/mysql_pass` Pool Update Procedures ====================== If upgrading the pool, please do a git pull to get the latest code within the pool's directory. -Once complete, please `cd` into `sql_sync`, then run `node sql_sync.js` - -This will update your pool with the latest config options with any defaults that the pools may set. - Pool Troubleshooting ==================== @@ -207,45 +165,36 @@ Status of shares Overflow pages: 0 Entries: 4379344 ``` -The important thing to verify here is that the "Number of pages used" value is less than the "Max Pages" value, and that there are "Free pages" under "Freelist Status". If this is the case, them look at the "Reader Table Status" and look for the PID listed. Run: +The important thing to verify here is that the "Number of pages used" value is less than the "Max Pages" value, and that there are "Free pages" under "Freelist Status". +If this is the case, them look at the "Reader Table Status" and look for the PID listed. Run: ```shell ps fuax | grep ex: ps fuax | grep 25763 ``` -If the output is not blank, then one of your node processes is reading, this is fine. If there is no output given on one of them, then proceed forwards. + +If the output is not blank, then one of your node processes is reading, this is fine. If there is no output given on one of them, then proceed forwards. The second step is to run: ```shell -pm2 stop blockManager worker payments remoteShare longRunner api -pm2 start blockManager worker payments remoteShare longRunner api +pm2 restart blockManager worker payments remoteShare longRunner api ``` This will restart all of your related daemons, and will clear any open reader connections, allowing LMDB to get back to a normal state. -If on the other hand, you have no "Free pages" and your Pages used is equal to the Max Pages, then you've run out of disk space for LMDB. You need to verify the cleaner is working. For reference, 4.3 million shares are stored within approximately 2-3 Gb of space, so if you're vastly exceeding this, then your cleaner (longRunner) is likely broken. - - -PPS Fee Thoughts -================ -If you're considering PPS, I've spoken with [Fireice_UK](https://github.com/fireice-uk/) whom kindly did some math about what you're looking at in terms of requirements to run a PPS pool without it self-imploding under particular risk factors, based on the work found [here](https://arxiv.org/pdf/1112.4980.pdf) - -```text -Also I calculated the amount of XMR needed to for a PPS pool to stay afloat. Perhaps you should put them up in the README to stop some spectacular clusterfucks :D: -For 1 in 1000000 chance that the pool will go bankrupt: 5% fee -> 1200 2% fee -> 3000 -For 1 in 1000000000 chance: 5% fee -> 1800 2% fee -> 4500 -``` - -The developers of the pool have not verified this, but based on usage on https://xmrpool.net/ this seems rather reasonable. You should be wary if you're considering PPS and take you fees into account appropriately! +If on the other hand, you have no "Free pages" and your Pages used is equal to the Max Pages, then you've run out of disk space for LMDB. +You need to verify the cleaner is working. For reference, 4.3 million shares are stored within approximately 2-3 Gb of space, +so if you're vastly exceeding this, then your cleaner (longRunner) is likely broken. Installation/Configuration Assistance ===================================== -If you need help installing the pool from scratch, please have your servers ready, which would be Ubuntu 16.04 servers, blank and clean, DNS records pointed. These need to be x86_64 boxes with AES-NI Available. +If you need help installing the pool from scratch, please have your servers ready, which would be Ubuntu 16.04 servers, blank and clean, DNS records pointed. +These need to be x86_64 boxes with AES-NI Available. Installation assistance is 3 XMR, with a 1 XMR deposit, with remainder to be paid on completion. Configuration assistance is 2 XMR with a 1 XMR deposit, and includes debugging your pool configurations, ensuring that everything is running, and tuning for your uses/needs. -altblockManager module source (that determines the most profitable coin to mine and trades them to main coin on exchanges, in particular -TradeOgre, Qryptos, Livecoin and Cryptopia integrations) price is 20 XMR. +altblockManager module source (that determines the most profitable coin to mine and trades them to main coin on exchanges, in particular Tradeogre, Xeggex, Binance, Coinex, Gate, Livecoin, Okex, Sevenseas) +price is 20 XMR. SSH access with a sudo-enabled user will be needed, preferably the user that is slated to run the pool. diff --git a/deployment/caddyfile b/deployment/caddyfile deleted file mode 100644 index 5f075a99..00000000 --- a/deployment/caddyfile +++ /dev/null @@ -1,17 +0,0 @@ -# Catch-all vhost -:80 { - root /var/www - proxy /leafApi 127.0.0.1:8000 - proxy /api 127.0.0.1:8001 { - without /api - } - proxy /socket.io 127.0.0.1:8001 { - header_upstream Connection {>Connection} - header_upstream Upgrade {>Upgrade} - } - header / { - Access-Control-Allow-Methods "GET, POST, OPTIONS" - Access-Control-Allow-Headers "Content-Type, x-access-token" - } - gzip -} diff --git a/deployment/deploy.bash b/deployment/deploy.bash index 47c33690..a80fd279 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -1,87 +1,237 @@ -#!/bin/bash -echo "This assumes that you are doing a green-field install. If you're not, please exit in the next 15 seconds." -sleep 15 -echo "Continuing install, this will prompt you for your password if you're not already running as root and you didn't enable passwordless sudo. Please do not run me as root!" -if [[ `whoami` == "root" ]]; then - echo "You ran me as root! Do not run me as root!" - exit 1 +#!/bin/bash -x + +NODEJS_VERSION=v20.12.2 + +WWW_DNS=$1 +API_DNS=$2 +CF_DNS_API_TOKEN=$3 +CERTBOT_EMAIL=$4 + +test -z $WWW_DNS && WWW_DNS="moneroocean.stream" +test -z $API_DNS && API_DNS="api.moneroocean.stream" +test -z $CF_DNS_API_TOKEN && CF_DNS_API_TOKEN="n/a" +test -z $CERTBOT_EMAIL && CERTBOT_EMAIL="support@moneroocean.stream" + +if [[ $(whoami) != "root" ]]; then + echo "Please run this script as root" + exit 1 fi -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 -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 -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 + +DEBIAN_FRONTEND=noninteractive apt-get update +DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y +timedatectl set-timezone Etc/UTC + +adduser --disabled-password --gecos "" user +grep -q "user ALL=(ALL) NOPASSWD:ALL" /etc/sudoers || echo "user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers +su user -c "mkdir /home/user/.ssh" +if [ -f "/root/.ssh/authorized_keys" ]; then + mv /root/.ssh/authorized_keys /home/user/.ssh/authorized_keys + chown user:user /home/user/.ssh/authorized_keys + chmod 600 /home/user/.ssh/authorized_keys + sed -i 's/#\?PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config + sed -i 's/#\?PermitRootLogin .\+/PermitRootLogin no/g' /etc/ssh/sshd_config + sed -i 's/#\?PermitEmptyPasswords .\+/PermitEmptyPasswords no/g' /etc/ssh/sshd_config + service ssh restart +fi + +ufw default deny incoming +ufw default allow outgoing +ufw allow ssh +ufw allow 443 +ufw --force enable + +cat >/root/.vimrc <<'EOF' +colorscheme desert +set fo-=ro +EOF + +cat >/home/user/.vimrc <<'EOF' +colorscheme desert +set fo-=ro +EOF +chown user:user /home/user/.vimrc + +DEBIAN_FRONTEND=noninteractive apt-get install -y nginx ntp sudo +snap install --classic certbot +snap set certbot trust-plugin-with-root=ok +snap install certbot-dns-cloudflare +find /snap/certbot -name options-ssl-nginx.conf | xargs -I{} cp {} /etc/letsencrypt/options-ssl-nginx.conf +echo "dns_cloudflare_api_token=$CF_DNS_API_TOKEN" >/root/dns_cloudflare_api_token.ini +chmod 600 /root/dns_cloudflare_api_token.ini +certbot certonly --non-interactive --agree-tos --email "$CERTBOT_EMAIL" --dns-cloudflare --dns-cloudflare-propagation-seconds 30 --dns-cloudflare-credentials /root/dns_cloudflare_api_token.ini -d $WWW_DNS +certbot certonly --non-interactive --agree-tos --email "$CERTBOT_EMAIL" --dns-cloudflare --dns-cloudflare-propagation-seconds 30 --dns-cloudflare-credentials /root/dns_cloudflare_api_token.ini -d $API_DNS +cat >/etc/nginx/sites-enabled/default <~/wallets/wallet_pass +echo 1 | /usr/local/src/monero/build/release/bin/monero-wallet-cli --offline --create-address-file --generate-new-wallet ~/wallets/wallet --password-file ~/wallets/wallet_pass --command address +echo 1 | /usr/local/src/monero/build/release/bin/monero-wallet-cli --offline --create-address-file --generate-new-wallet ~/wallets/wallet_fee --password-file ~/wallets/wallet_pass --command address +EOF +) | su user -l +echo; echo; echo +read -p "*** Write down your seeds for wallet and wallet_fee listed above and press ENTER to continue ***" + +cat >/lib/systemd/system/monero.service <<'EOF' +[Unit] +Description=Monero Daemon +After=network.target + +[Service] +ExecStart=/usr/local/src/monero/build/release/bin/monerod --hide-my-port --prune-blockchain --enable-dns-blocklist --no-zmq --out-peers 64 --non-interactive --restricted-rpc +Restart=always +User=monerodaemon +Nice=10 +CPUQuota=400% + +[Install] +WantedBy=multi-user.target +EOF + +useradd -m monerodaemon -d /home/monerodaemon +systemctl daemon-reload +systemctl enable monero +systemctl start monero + +sleep 30 +echo "Please wait until Monero daemon is fully synced" +tail -f /home/monerodaemon/.bitmonero/bitmonero.log 2>/dev/null | grep Synced & +( tail -F -n0 /home/monerodaemon/.bitmonero/bitmonero.log & ) | egrep -q "You are now synchronized with the network" +killall tail 2>/dev/null +echo "Monero daemon is synced" + +DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server +ROOT_SQL_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) +(cat </root/mysql_pass +chmod 600 /root/mysql_pass +grep max_connections /etc/mysql/my.cnf || cat >>/etc/mysql/my.cnf <<'EOF' +[mysqld] +max_connections = 10000 +EOF +systemctl restart mysql + +(cat <>/home/user/.bashrc + echo 'export PATH=/home/user/.bin:$PATH' >>/home/user/.bashrc + for i in mdb_copy mdb_dump mdb_load mdb_stat; do cp \$i /home/user/.bin/; done +) npm install -g pm2 +pm2 install pm2-logrotate 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 -mkdir ~/pool_db/ -sed -r "s/(\"db_storage_path\": ).*/\1\"\/home\/$CURUSER\/pool_db\/\",/" config_example.json > config.json -cd ~ +mkdir /home/user/pool_db +sed -r 's#("db_storage_path": ).*#\1"/home/user/pool_db/",#' config_example.json >config.json +mysql -u root --password=$ROOT_SQL_PASS /etc/systemd/system/caddy.service" -sudo chown root:root /etc/systemd/system/caddy.service -sudo chmod 644 /etc/systemd/system/caddy.service -sudo systemctl daemon-reload -sudo systemctl enable caddy.service -sudo systemctl start caddy.service -rm -rf $CADDY_DOWNLOAD_DIR -cd ~ -sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v22.1.0/bin `pwd`/.nvm/versions/node/v22.1.0/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` -cd ~/nodejs-pool -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 -mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')" -mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" -pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api -bash ~/nodejs-pool/deployment/install_lmdb_tools.sh -echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" +EOF +) | su user -l + +echo 'Now logout server, loging again under "user" account and run ~/moneroocean-gui/build.sh to build web site' diff --git a/deployment/deploy_test.bash b/deployment/deploy_test.bash deleted file mode 100644 index 728305a0..00000000 --- a/deployment/deploy_test.bash +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -echo "This assumes that you are doing a green-field install. If you're not, please exit in the next 15 seconds." -sleep 15 -echo "Continuing install, this will prompt you for your password if you're not already running as root and you didn't enable passwordless sudo. Please do not run me as root!" -if [[ `whoami` == "root" ]]; then - echo "You ran me as root! Do not run me as root!" - exit 1 -fi -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 -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 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 -cd /usr/local/src -sudo git clone --recursive https://github.com/monero-project/monero.git -cd monero -sudo git checkout v0.18.3.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 -sudo systemctl daemon-reload -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 v22.1.0 -nvm alias default v22.1.0 -cd ~/nodejs-pool -npm install -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 -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 -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 -sudo mv caddy /usr/local/bin -sudo chown root:root /usr/local/bin/caddy -sudo chmod 755 /usr/local/bin/caddy -sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy -sudo groupadd -g 33 www-data -sudo useradd -g www-data --no-user-group --home-dir /var/www --no-create-home --shell /usr/sbin/nologin --system --uid 33 www-data -sudo mkdir /etc/caddy -sudo chown -R root:www-data /etc/caddy -sudo mkdir /etc/ssl/caddy -sudo chown -R www-data:root /etc/ssl/caddy -sudo chmod 0770 /etc/ssl/caddy -sudo cp ~/nodejs-pool/deployment/caddyfile /etc/caddy/Caddyfile -sudo chown www-data:www-data /etc/caddy/Caddyfile -sudo chmod 444 /etc/caddy/Caddyfile -sudo sh -c "sed 's/ProtectHome=true/ProtectHome=false/' init/linux-systemd/caddy.service > /etc/systemd/system/caddy.service" -sudo chown root:root /etc/systemd/system/caddy.service -sudo chmod 644 /etc/systemd/system/caddy.service -sudo systemctl daemon-reload -sudo systemctl enable caddy.service -sudo systemctl start caddy.service -rm -rf $CADDY_DOWNLOAD_DIR -cd ~ -sudo env PATH=$PATH:`pwd`/.nvm/versions/node/v22.1.0/bin `pwd`/.nvm/versions/node/v22.1.0/lib/node_modules/pm2/bin/pm2 startup systemd -u $CURUSER --hp `pwd` -cd ~/nodejs-pool -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 -mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'authKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'Auth key sent with all Websocket frames for validation.')" -mysql -u root --password=$ROOT_SQL_PASS pool -e "INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('api', 'secKey', '`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`', 'string', 'HMAC key for Passwords. JWT Secret Key. Changing this will invalidate all current logins.')" -pm2 start init.js --name=api --log-date-format="YYYY-MM-DD HH:mm Z" -- --module=api -bash ~/nodejs-pool/deployment/install_lmdb_tools.sh -cd ~/nodejs-pool/sql_sync/ -env PATH=$PATH:`pwd`/.nvm/versions/node/v22.1.0/bin node sql_sync.js -echo "You're setup! Please read the rest of the readme for the remainder of your setup and configuration. These steps include: Setting your Fee Address, Pool Address, Global Domain, and the Mailgun setup!" diff --git a/deployment/install_lmdb_tools.sh b/deployment/install_lmdb_tools.sh deleted file mode 100644 index a8028315..00000000 --- a/deployment/install_lmdb_tools.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -cd ~ -rm -rf node-lmdb -git clone https://github.com/Venemo/node-lmdb.git -cd node-lmdb -git checkout c3135a3809da1d64ce1f0956b37b618711e33519 -cd dependencies/lmdb/libraries/liblmdb -make -j `nproc` -mkdir ~/.bin -echo ' ' >> ~/.bashrc -echo 'export PATH=~/.bin:$PATH' >> ~/.bashrc -for i in mdb_copy mdb_dump mdb_load mdb_stat; do cp $i ~/.bin/; done -echo "Please run source ~/.bashrc to initialize the new LMDB tools. Thanks for flying Snipa22 Patch Services." \ No newline at end of file diff --git a/deployment/leaf.bash b/deployment/leaf.bash index bc25a75f..9a88216d 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -1,41 +1,99 @@ -#!/bin/bash -echo "This assumes that you are doing a green-field install. If you're not, please exit in the next 15 seconds." -sleep 15 -echo "Continuing install, this will prompt you for your password if you're not already running as root and you didn't enable passwordless sudo. Please do not run me as root!" -if [[ `whoami` == "root" ]]; then - echo "You ran me as root! Do not run me as root!" - exit 1 +#!/bin/bash -x + +NODEJS_VERSION=v20.12.2 + +if [[ $(whoami) != "root" ]]; then + echo "Please run this script as root" + exit 1 fi -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 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 + +DEBIAN_FRONTEND=noninteractive apt-get update +DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y +timedatectl set-timezone Etc/UTC + +adduser --disabled-password --gecos "" user +grep -q "user ALL=(ALL) NOPASSWD:ALL" /etc/sudoers || echo "user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers +su user -c "mkdir /home/user/.ssh" +if [ -f "/root/.ssh/authorized_keys" ]; then + mv /root/.ssh/authorized_keys /home/user/.ssh/authorized_keys + chown user:user /home/user/.ssh/authorized_keys + chmod 600 /home/user/.ssh/authorized_keys + sed -i 's/#\?PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config + sed -i 's/#\?PermitRootLogin .\+/PermitRootLogin no/g' /etc/ssh/sshd_config + sed -i 's/#\?PermitEmptyPasswords .\+/PermitEmptyPasswords no/g' /etc/ssh/sshd_config + service ssh restart +fi + +ufw default deny incoming +ufw default allow outgoing +ufw allow ssh +ufw allow 3333 +ufw allow 5555 +ufw allow 7777 +ufw allow 9000 +ufw --force enable + +cat >/root/.vimrc <<'EOF' +colorscheme desert +set fo-=ro +EOF + +cat >/home/user/.vimrc <<'EOF' +colorscheme desert +set fo-=ro +EOF +chown user:user /home/user/.vimrc + +DEBIAN_FRONTEND=noninteractive apt-get install -y ntp sudo +DEBIAN_FRONTEND=noninteractive apt-get install -y git make g++ cmake libssl-dev libunbound-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev libboost-locale-dev libboost-regex-dev libboost-regex-dev libboost-program-options-dev libzmq3-dev cd /usr/local/src -sudo git clone https://github.com/monero-project/monero.git +git clone https://github.com/monero-project/monero.git cd monero -sudo git checkout v0.18.3.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/ -sudo useradd -m monerodaemon -d /home/monerodaemon -sudo systemctl daemon-reload -sudo systemctl enable monero -sudo systemctl start monero +git checkout v0.18.3.3 +git submodule update --init +USE_SINGLE_BUILDDIR=1 make -j$(nproc) release + +cat >/lib/systemd/system/monero.service <<'EOF' +[Unit] +Description=Monero Daemon +After=network.target + +[Service] +ExecStart=/usr/local/src/monero/build/release/bin/monerod --hide-my-port --prune-blockchain --enable-dns-blocklist --no-zmq --out-peers 64 --non-interactive --restricted-rpc --block-notify '/bin/bash /home/user/nodejs-pool/block_notify.sh' +Restart=always +User=monerodaemon +Nice=10 +CPUQuota=400% + +[Install] +WantedBy=multi-user.target +EOF + +useradd -m monerodaemon -d /home/monerodaemon +systemctl daemon-reload +systemctl enable monero +systemctl start monero + +sleep 30 +echo "Please wait until Monero daemon is fully synced" +tail -f /home/monerodaemon/.bitmonero/bitmonero.log 2>/dev/null | grep Synced & +( tail -F -n0 /home/monerodaemon/.bitmonero/bitmonero.log & ) | egrep -q "You are now synchronized with the network" +killall tail 2>/dev/null +echo "Monero daemon is synced" + +(cat < Date: Wed, 8 May 2024 03:40:15 +0300 Subject: [PATCH 2368/2430] Updated for Ubuntu 24.04 --- deployment/deploy.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/deploy.bash b/deployment/deploy.bash index a80fd279..151d1f81 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -141,7 +141,7 @@ Description=Monero Daemon After=network.target [Service] -ExecStart=/usr/local/src/monero/build/release/bin/monerod --hide-my-port --prune-blockchain --enable-dns-blocklist --no-zmq --out-peers 64 --non-interactive --restricted-rpc +ExecStart=/usr/local/src/monero/build/release/bin/monerod --hide-my-port --prune-blockchain --enable-dns-blocklist --no-zmq --out-peers 64 --non-interactive --restricted-rpc --block-notify '/bin/bash /home/user/nodejs-pool/block_notify.sh' Restart=always User=monerodaemon Nice=10 From 15a4927f944988a870a33f58c3fdf357dad07995 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 May 2024 18:49:08 +0300 Subject: [PATCH 2369/2430] Catch fs exception --- lib/pool.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7c92ae06..0af5c0e7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2568,23 +2568,27 @@ if (cluster.isMaster) { let numWorkers = require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { let fn = "wallet_trust_" + i.toString(); - let lineReader = require('readline').createInterface({ input: fs.createReadStream(fn) }); - lineReader.on('error', function() { console.error("Can't read lines from " + fn + " file"); }); - lineReader.on('line', function (line) { - let parts = line.split(/\t/); - if (parts.length != 3) { - console.error("Error line " + line + " ignored from " + fn + " file"); - return; - } - let wallet = parts[0]; - 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])) { - debug("Adding " + trust.toString() + " trust for " + wallet + " wallet"); - walletTrust[wallet] = trust; - walletLastSeeTime[wallet] = time; - } - }); + try { + let lineReader = require('readline').createInterface({ input: fs.createReadStream(fn) }); + lineReader.on('error', function() { console.error("Can't read lines from " + fn + " file"); }); + lineReader.on('line', function (line) { + let parts = line.split(/\t/); + if (parts.length != 3) { + console.error("Error line " + line + " ignored from " + fn + " file"); + return; + } + let wallet = parts[0]; + 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])) { + debug("Adding " + trust.toString() + " trust for " + wallet + " wallet"); + walletTrust[wallet] = trust; + walletLastSeeTime[wallet] = time; + } + }); + } catch(e) { + console.error("Can't open " + fn + " file"); + } } // dump wallet trust and miner agents to file From 41211e258a040316d1dc154eeebabb479db27c82 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 8 May 2024 18:57:04 +0300 Subject: [PATCH 2370/2430] Catch fs exception --- lib/pool.js | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 0af5c0e7..5a4d1e49 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -2568,27 +2568,25 @@ if (cluster.isMaster) { let numWorkers = require('os').cpus().length; for (let i = 1; i <= numWorkers; ++ i) { let fn = "wallet_trust_" + i.toString(); - try { - let lineReader = require('readline').createInterface({ input: fs.createReadStream(fn) }); - lineReader.on('error', function() { console.error("Can't read lines from " + fn + " file"); }); - lineReader.on('line', function (line) { - let parts = line.split(/\t/); - if (parts.length != 3) { - console.error("Error line " + line + " ignored from " + fn + " file"); - return; - } - let wallet = parts[0]; - 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])) { - debug("Adding " + trust.toString() + " trust for " + wallet + " wallet"); - walletTrust[wallet] = trust; - walletLastSeeTime[wallet] = time; - } - }); - } catch(e) { - console.error("Can't open " + fn + " file"); - } + let rs = fs.createReadStream(fn); + rs.on('error', function() { console.error("Can't open " + fn + " file"); }); + let lineReader = require('readline').createInterface({ input: rs }); + lineReader.on('error', function() { console.error("Can't read lines from " + fn + " file"); }); + lineReader.on('line', function (line) { + let parts = line.split(/\t/); + if (parts.length != 3) { + console.error("Error line " + line + " ignored from " + fn + " file"); + return; + } + let wallet = parts[0]; + 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])) { + debug("Adding " + trust.toString() + " trust for " + wallet + " wallet"); + walletTrust[wallet] = trust; + walletLastSeeTime[wallet] = time; + } + }); } // dump wallet trust and miner agents to file From 1a824bdd10915d63bfeb75c8be233c3aea53b61a Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 27 May 2024 22:20:54 +0300 Subject: [PATCH 2371/2430] Added KCN coin support --- deployment/base.sql | 2 ++ lib/coins/xmr.js | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/deployment/base.sql b/deployment/base.sql index 10346e10..7a5d0fa3 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -249,6 +249,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', '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', 'coinHashFactorKCN', '0', 'float', 'KCN algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorBTRM', '0', 'float', 'BTRM algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorZEPH', '0', 'float', 'ZEPH algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXNA', '0', 'float', 'XNA algo hash price factor relative to coinHashFactor'); @@ -326,6 +327,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_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 ('pool', 'address_5110', '', 'string', 'Address to mine to for 5110 (KCN) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_17767', '', 'string', 'Address to mine to for 17767 (ZEPH) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_10225', '', 'string', 'Address to mine to for 10225 (BTRM) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19001', '', 'string', 'Address to mine to for 19001 (Neurai) port.'); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 8ad515d6..fd88afa1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -48,6 +48,7 @@ const port2coin = { "2086" : "BLOC", "9053" : "ERG", "9998" : "RTM", + "5110" : "KCN", "10225" : "BTRM", "17767" : "ZEPH", "19001" : "XNA", @@ -83,6 +84,7 @@ const port2blob_num = { "2086" : 1, // BLOC "9053" : 103, // ERG "9998" : 104, // RTM + "5110" : 104, // KCN "10225": 104, // BTRM "19001": 101, // XNA "9766" : 101, // CLORE @@ -118,6 +120,7 @@ const port2algo = { "2086" : "cn-heavy/xhv", // BLOC "9053" : "autolykos2", // ERG "9998" : "ghostrider", // RTM + "5110" : "flex", // KCN "10225": "ghostrider", // BTRM "19001": "kawpow", // XNA "9766": "kawpow", // CLORE @@ -353,7 +356,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { + } else if (port == 8766 || port == 9998 || port == 5110 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getblockhash', params: [ blockId ] }, function (body) { if (!body || !body.result) { console.error("getPortBlockHeaderByID(" + port + ", " + blockId + "): " + JSON.stringify(body)); @@ -426,7 +429,7 @@ function Coin(data){ } return callback(null, body); }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { + } else if (port == 8766 || port == 9998 || port == 5110 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getblock', params: [ blockHash, 2 ] }, function (body) { if (!body || !body.result || !(body.result.tx instanceof Array) || body.result.tx.length < 1) { console.error("getPortBlockHeaderByHash(" + port + ", " + blockHash + "): " + JSON.stringify(body)); @@ -447,7 +450,7 @@ function Coin(data){ } body.result.reward *= 100000000; body.result.reward = parseInt(body.result.reward); - if (port == 9998 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; + if (port == 9998 || port == 5110 || port == 10225) body.result.difficulty *= 0xFFFFFFFF; return callback(null, body.result); }); } else if (port == 8545 || port == 8645) { @@ -596,7 +599,7 @@ function Coin(data){ return callback(true, body); } }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { + } else if (port == 8766 || port == 9998 || port == 5110 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getbestblockhash' }, function (body) { if (!body || !body.result) { console.error("getPortLastBlockHeader(" + port + "): " + JSON.stringify(body)); @@ -652,7 +655,7 @@ function Coin(data){ return callback(body ? body : null); }); - } else if (port == 8766 || port == 9998 || port == 10225 || port == 19001 || port == 9766) { + } else if (port == 8766 || port == 9998 || port == 5110 || port == 10225 || port == 19001 || port == 9766) { global.support.rpcPortDaemon2(port, '', { method: 'getblocktemplate', params: [{ @@ -661,6 +664,7 @@ function Coin(data){ }] }, function(body) { if (body && body.result) switch (parseInt(port)) { + case 5110: case 9998: case 10225: return callback(cnUtil.RtmBlockTemplate(body.result, global.config.pool["address_" + port.toString()])); @@ -1024,6 +1028,8 @@ function Coin(data){ if ("ghostrider" in algos_perf) coin_perf["RTM"] = coin_perf["BTRM"] = algos_perf["ghostrider"]; + if ("flex" in algos_perf) coin_perf["KCN"] = algos_perf["flex"]; + if ("ethash" in algos_perf) coin_perf["ETC"] = algos_perf["ethash"]; if ("etchash" in algos_perf) coin_perf["ETC"] = algos_perf["etchash"]; @@ -1078,6 +1084,7 @@ function Coin(data){ case 19001: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // XNA case 9766: return multiHashing.kawpow(convertedBlob, Buffer.from(nonce, 'hex'), Buffer.from(mixhash, 'hex')); // CLORE case 9998: return multiHashing.cryptonight(convertedBlob, 18); // RTM + case 5110: return multiHashing.cryptonight(convertedBlob, 19); // KCN case 10225: return multiHashing.cryptonight(convertedBlob, 18); // BTRM case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH case 8645: return multiHashing.etchash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETC @@ -1195,6 +1202,7 @@ function Coin(data){ case 9053: return "erg"; // ERG case 9231: return "cryptonote_loki"; // XEQ case 9998: return "raptoreum"; // RTM + case 5110: return "flex"; // KCN case 10225: return "raptoreum"; // BTRM //case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL From a43fd9eb3ad638ecce2fd42131e4ef3044507edb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 27 May 2024 22:21:19 +0300 Subject: [PATCH 2372/2430] Added KCN coin support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb7782a5..01993d5f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cors": "^2.8.1", "crypto-js": "^4.2.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.2.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v28.1.3", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.0", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From ed8268c1248ee6b5e25e2f3adbfb280cd17f9e4b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 28 May 2024 00:25:24 +0300 Subject: [PATCH 2373/2430] Added KCN coin support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 01993d5f..32fff491 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.2.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.0", "debug": "2.6.9", "express": "^4.17.1", From 9cd23f74362394c9f3e4ec70da88e9f8567ad911 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 28 May 2024 00:33:30 +0300 Subject: [PATCH 2374/2430] Added KCN coin support --- README.md | 1 + lib/coins/xmr.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18e194c9..2c09cb09 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,7 @@ If you'd like to make a one time donation, the addresses are as follows: * XNA - ```Nb931jkFtFN7QWpu4FqSThaoKajYjS5iFZ``` * CLORE - ```AdXPHtV8yb86a8QKsbs8gmUpRpcxufRn8n``` * RTM - ```RUCyaEZxQu3Eure73XPQ57si813RYAMQKC``` +* KCN - ```kc1qchtxq2gw9dc4r58hcegd6n4jspew6j9mu3yz8q``` * BTRM - ```Bfhtr2g56tg73TNZBRCu6fJUD39Kur6SGG``` * ERG - ```9fe533kUzAE57YfPP6o3nzsYMKN2W2uCxvg8KG8Vn5DDeJGetRw``` * BTC - ```3HRbMgcvbqHVW7P34MNGvF2Gh3DE26iHdw``` diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index fd88afa1..ed5fd6b1 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1202,7 +1202,7 @@ function Coin(data){ case 9053: return "erg"; // ERG case 9231: return "cryptonote_loki"; // XEQ case 9998: return "raptoreum"; // RTM - case 5110: return "flex"; // KCN + case 5110: return "raptoreum"; // KCN case 10225: return "raptoreum"; // BTRM //case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL From aa4b3fb59bfed04b709c88623d583e315b6d289e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 29 May 2024 03:26:16 +0300 Subject: [PATCH 2375/2430] Improved Flex algo speed --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32fff491..3bd28c4a 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cors": "^2.8.1", "crypto-js": "^4.2.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.0", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.1", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From 44d237821ca76525788fe5e921e671c7ba07abd0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 29 May 2024 22:48:38 +0300 Subject: [PATCH 2376/2430] XEQ algo update --- lib/coins/xmr.js | 8 +++++--- package.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index ed5fd6b1..3e296705 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -110,7 +110,7 @@ const port2algo = { // "34568": "rx/wow", // Wownero "38081": "cn/half", // MSR "48782": "argon2/chukwav2", // Lethean - "9231" : "cn/gpu", // XEQ + "9231" : "rx/xeq", // XEQ "20206": "astrobwt/v2", // DERO // "18181": "cn/0", // XMC "16000": "cn/gpu", // CCX @@ -1019,7 +1019,9 @@ 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["CCX"] = coin_perf["XEQ"] = algos_perf["cn/gpu"]; + if ("cn/gpu" in algos_perf) coin_perf["RYO"] = coin_perf["CCX"] = algos_perf["cn/gpu"]; + + if ("rx/xeq" in algos_perf) coin_perf["XEQ"] = algos_perf["rx/xeq"]; // if ("rx/wow" in algos_perf) coin_perf["WOW"] = algos_perf["rx/wow"]; @@ -1089,7 +1091,7 @@ function Coin(data){ case 8545: return multiHashing.ethash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETH case 8645: return multiHashing.etchash(convertedBlob, Buffer.from(nonce, 'hex'), blockTemplate.height); // ETC case 9053: return multiHashing.autolykos2_hashes(convertedBlob, blockTemplate.height); // ERG - case 9231 : return multiHashing.cryptonight(convertedBlob, 11); // XEQ + case 9231 : return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 22); // XEQ //case 11181: return multiHashing.k12(convertedBlob); // Aeon case 11898: return multiHashing.argon2(convertedBlob, 2); // TRTL case 12211: return multiHashing.cryptonight(convertedBlob, 11); // RYO diff --git a/package.json b/package.json index 3bd28c4a..0e42f4a9 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cors": "^2.8.1", "crypto-js": "^4.2.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.2", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.1", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From 8bb9c3d694330853d9a292a28f1c7e9517e4b2ba Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 30 May 2024 02:07:28 +0300 Subject: [PATCH 2377/2430] Fix for XEQ --- lib/coins/xmr.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 3e296705..697f12ac 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1129,6 +1129,7 @@ function Coin(data){ } else miner_address_verify[miner_address] = 1; let jsonInput; switch (blockTemplate.port) { + case 9231: case 17767: case 18081: // case 18981: From abce81aa3c617889a47bbc093a20590cafc7cd98 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 May 2024 18:18:17 +0300 Subject: [PATCH 2378/2430] Adds kcn dev reward to bt --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e42f4a9..9bc1b72b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.3", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From ee0b1dfa272c5081189861542afee18b6b95140b Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 May 2024 19:29:58 +0300 Subject: [PATCH 2379/2430] Adds kcn dev reward to bt --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bc1b72b..32e27b43 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.3", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.4", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 3e67dcc56f4305ed97ef3c88d25b7e80550a3dfc Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 May 2024 19:39:31 +0300 Subject: [PATCH 2380/2430] Adds kcn dev reward to bt --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32e27b43..57c5bd8e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.4", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.5", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From f8c28dbf5ce31ccfa90b6caea1f8689043bd30c4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 May 2024 20:22:47 +0300 Subject: [PATCH 2381/2430] KCN fix --- lib/coins/xmr.js | 12 ++++++++++-- lib/pool.js | 2 +- package.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 697f12ac..cc8aeea0 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -84,7 +84,7 @@ const port2blob_num = { "2086" : 1, // BLOC "9053" : 103, // ERG "9998" : 104, // RTM - "5110" : 104, // KCN + "5110" : 105, // KCN "10225": 104, // BTRM "19001": 101, // XNA "9766" : 101, // CLORE @@ -802,6 +802,8 @@ function Coin(data){ this.blobTypeRtm = function(blob_type_num) { return blob_type_num == 104; } + this.blobTypeKcn = function(blob_type_num) { return blob_type_num == 105; } + this.convertBlob = function(blobBuffer, port) { const blob_type_num = this.portBlobType(port, blobBuffer[0]); if (this.blobTypeDero(blob_type_num)) return blobBuffer; @@ -811,6 +813,8 @@ function Coin(data){ blob = cnUtil.convertRavenBlob(blobBuffer); } else if (this.blobTypeRtm(blob_type_num)) { blob = cnUtil.convertRtmBlob(blobBuffer); + } else if (this.blobTypeKcn(blob_type_num)) { + blob = cnUtil.convertKcnBlob(blobBuffer); } else { blob = cnUtil.convert_blob(blobBuffer, blob_type_num); } @@ -839,6 +843,8 @@ function Coin(data){ ); } else if (global.coinFuncs.blobTypeRtm(blob_type_num)) { return cnUtil.constructNewRtmBlob(blockTemplate, Buffer.from(params.nonce, 'hex')); + } else if (global.coinFuncs.blobTypeKcn(blob_type_num)) { + return cnUtil.constructNewKcnBlob(blockTemplate, Buffer.from(params.nonce, 'hex')); } else { return cnUtil.construct_block_blob(blockTemplate, Buffer.from(params.nonce, 'hex'), blob_type_num); } @@ -858,6 +864,8 @@ function Coin(data){ const blob_type_num = this.portBlobType(port, blockBuffer[0]); if (global.coinFuncs.blobTypeRtm(blob_type_num)) { return cnUtil.blockHashBuff(cnUtil.convertRtmBlob(blockBuffer)); + } else if (global.coinFuncs.blobTypeKcn(blob_type_num)) { + return cnUtil.blockHashBuff(cnUtil.convertKCnBlob(blockBuffer)); } else { return cnUtil.get_block_id(blockBuffer, blob_type_num); } @@ -922,7 +930,7 @@ function Coin(data){ this.buffer = Buffer.from(blob, 'hex'); this.block_version = this.buffer[0]; - if (global.coinFuncs.blobTypeRvn(port_blob_num) || global.coinFuncs.blobTypeRtm(port_blob_num)) { + if (global.coinFuncs.blobTypeRvn(port_blob_num) || global.coinFuncs.blobTypeRtm(port_blob_num) || global.coinFuncs.blobTypeKcn(port_blob_num)) { this.reserved_offset = template.reserved_offset; } else if (is_dero) { // exception for DERO this.reserved_offset = template.reserved_offset; diff --git a/lib/pool.js b/lib/pool.js index 5a4d1e49..db332e65 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1572,7 +1572,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) || global.coinFuncs.blobTypeRtm(job.blob_type_num)) { + } else if (global.coinFuncs.blobTypeRvn(job.blob_type_num) || global.coinFuncs.blobTypeRtm(job.blob_type_num) || global.coinFuncs.blobTypeKcn(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: "eth_submitWork", params: blockData, jsonrpc: "2.0", id: 0 }, reply_fn); diff --git a/package.json b/package.json index 57c5bd8e..6a6a9574 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.5", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.7", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From e3e2751188a4fce6cd927616dbcb0a50522bf14d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 May 2024 20:39:31 +0300 Subject: [PATCH 2382/2430] KCN 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 cc8aeea0..1ea99d56 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -1213,7 +1213,7 @@ function Coin(data){ case 9053: return "erg"; // ERG case 9231: return "cryptonote_loki"; // XEQ case 9998: return "raptoreum"; // RTM - case 5110: return "raptoreum"; // KCN + case 5110: return "raptoreum_kcn"; // KCN case 10225: return "raptoreum"; // BTRM //case 11181: return "aeon"; // Aeon case 11898: return "forknote2"; // TRTL From 7b5874c385b912001b63aa12ae309f0fba5ed9f0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 31 May 2024 23:30:33 +0300 Subject: [PATCH 2383/2430] KCN fix --- 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 1ea99d56..486c0b41 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -865,7 +865,7 @@ function Coin(data){ if (global.coinFuncs.blobTypeRtm(blob_type_num)) { return cnUtil.blockHashBuff(cnUtil.convertRtmBlob(blockBuffer)); } else if (global.coinFuncs.blobTypeKcn(blob_type_num)) { - return cnUtil.blockHashBuff(cnUtil.convertKCnBlob(blockBuffer)); + return cnUtil.blockHashBuff(cnUtil.convertKcnBlob(blockBuffer)); } else { return cnUtil.get_block_id(blockBuffer, blob_type_num); } diff --git a/package.json b/package.json index 6a6a9574..5b9b1f19 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.7", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.8", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From ac2fecdb47d705f16a9f6c7c1d625db0ea3c92df Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Jun 2024 08:57:38 +0300 Subject: [PATCH 2384/2430] KCN fix --- lib/coins/xmr.js | 2 +- lib/pool.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 486c0b41..daea4334 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -865,7 +865,7 @@ function Coin(data){ if (global.coinFuncs.blobTypeRtm(blob_type_num)) { return cnUtil.blockHashBuff(cnUtil.convertRtmBlob(blockBuffer)); } else if (global.coinFuncs.blobTypeKcn(blob_type_num)) { - return cnUtil.blockHashBuff(cnUtil.convertKcnBlob(blockBuffer)); + return cnUtil.blockHashBuff3(cnUtil.convertKcnBlob(blockBuffer)); } else { return cnUtil.get_block_id(blockBuffer, blob_type_num); } diff --git a/lib/pool.js b/lib/pool.js index db332e65..db50662e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1448,7 +1448,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste 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 + if (rpcResult && (rpcResult.error || rpcResult.result === "high-hash" || rpcResult.result === "bad-txnmrklroot")) { // did not manage to submit a block let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(blockData, blockTemplate.port); diff --git a/package.json b/package.json index 5b9b1f19..9980db9c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.8", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.9", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 2076c47ccaff4903a51989ab7a3e972f429f237d Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Jun 2024 09:36:02 +0300 Subject: [PATCH 2385/2430] KCN fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9980db9c..80fbec97 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.9", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.10", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 70df0f61ac19ab3d588d3f32a9a2d5d1d137c85c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Jun 2024 10:23:30 +0300 Subject: [PATCH 2386/2430] RTM fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 80fbec97..0f6d74db 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.10", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.11", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 89a513d787ef9047271ffdcbd29f5ab0e8e902e8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Jun 2024 16:58:26 +0300 Subject: [PATCH 2387/2430] Adjusted KCN reward --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f6d74db..99ea87a7 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.11", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.12", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 56782686f8a2b37814fe52ce171ee19a49c3c8c5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Jun 2024 19:21:37 +0300 Subject: [PATCH 2388/2430] Fixed KCN reward --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 99ea87a7..c3a13cd9 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.12", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.13", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 6265b14852a95feb2940fd3b2c324fb97a9ef276 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 1 Jun 2024 20:32:05 +0300 Subject: [PATCH 2389/2430] Fixed KCN blob contruction in all cases --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c3a13cd9..591acd7b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.13", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.14", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From fdeb0e15c2dbbbf4a9df13f841d8e644ccf55fc7 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 Jun 2024 01:12:55 +0300 Subject: [PATCH 2390/2430] Added 1 job daemon build in case of out of memory fail --- 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 151d1f81..5dcaf3fd 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -121,7 +121,7 @@ git clone https://github.com/monero-project/monero.git cd monero git checkout v0.18.3.3 git submodule update --init -USE_SINGLE_BUILDDIR=1 make -j$(nproc) release +USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || USE_SINGLE_BUILDDIR=1 make -j1 release (cat </lib/systemd/system/monero.service <<'EOF' [Unit] From 18ef68597e9ec7638c322a4f375e82dd57dfeb82 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 Jun 2024 02:58:43 +0300 Subject: [PATCH 2391/2430] Fixed KCN blob contruction in all cases --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 591acd7b..73c93299 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.14", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.15", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 16a1a482dd09f1e2498ae9315a31946dd3ec6ff8 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 Jun 2024 20:24:10 +0300 Subject: [PATCH 2392/2430] Fixed KCN blob contruction in all cases --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73c93299..c4cd9bb1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.15", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.16", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From ca51c40113160f63afd391cc0d9cbb0573c0b4ab Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 Jun 2024 20:33:35 +0300 Subject: [PATCH 2393/2430] Fixed KCN blob contruction in all cases --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c4cd9bb1..73c93299 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.16", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.15", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From b84c4cc2cf8635163130c5f6ba488dd68b9f74eb Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 Jun 2024 20:40:35 +0300 Subject: [PATCH 2394/2430] Fixed KCN blob contruction in all cases --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 73c93299..da78a516 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.15", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.17", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 2198c761b80d248d6055ba90216613b34ec4d07c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 Jun 2024 22:19:58 +0300 Subject: [PATCH 2395/2430] Fixed KCN blob contruction in all cases --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da78a516..26d8b0da 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.17", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.18", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 94139d2e256b2a7dee3b5cb5f838126b544f82a9 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 2 Jun 2024 23:58:42 +0300 Subject: [PATCH 2396/2430] Fixed RTM blob contruction --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 26d8b0da..2b6589ab 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.18", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.19", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From c664b001f0d8917d402fe6054285e8327ac2c9a0 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 4 Jun 2024 19:36:39 +0300 Subject: [PATCH 2397/2430] More strict block checks --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index db50662e..9199342f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1448,7 +1448,7 @@ function submit_block(miner, job, blockTemplate, blockData, resultBuff, isTruste 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" || rpcResult.result === "bad-txnmrklroot")) { // did not manage to submit a block + if (rpcResult && (rpcResult.error || rpcResult.result === "high-hash" || rpcResult.result === "bad-txnmrklroot" || rpcResult.result === "bad-cbtx-mnmerkleroot")) { // did not manage to submit a block let isNotifyAdmin = true; if (isParentBlock && isTrustedShare) { const convertedBlob = global.coinFuncs.convertBlob(blockData, blockTemplate.port); From bfc1cae2a8725e411727d97221b9b9a95bc0475c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 4 Jun 2024 23:36:08 +0300 Subject: [PATCH 2398/2430] Updated RTM utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b6589ab..79a87b04 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.19", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.20", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 8e0df18f7d0b3cb0f4ffd4a48674f69a04e5996c Mon Sep 17 00:00:00 2001 From: Tony Butler Date: Tue, 4 Jun 2024 23:12:45 -0600 Subject: [PATCH 2399/2430] Add "perf" option to set starting diff based on algo-perf * overrides default connection-port-based starting diff * append "+perf" to login/user (fixed-diff) * append "+perfauto" to login/user (auto-diff) * append "+123456" for existing fixed-diff support * anything else falls back to ignoring the "+" section (auto port-diff) --- lib/pool.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 9199342f..ba74ed52 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -972,6 +972,16 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro if (login_diff_split.length === 2) { this.fixed_diff = true; this.difficulty = Number(login_diff_split[1]); + if (login_diff_split[1].substring(0, 4) === 'perf') { + let perfDiff = 0; + if (this.coin_perf[""] > 2) { + perfDiff = Math.floor(this.coin_perf[""] * (global.config.pool.targetTime || 30)); + } + if (login_diff_split[1].substring(4, 8) === 'auto' || perfDiff === 0) { + this.fixed_diff = false; + } + this.difficulty = perfDiff || startingDiff; + } if (this.difficulty < global.config.pool.minDifficulty) { this.difficulty = global.config.pool.minDifficulty; } From e62c973364454162c53e96e73f8a7a0972632d1f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 7 Jun 2024 03:07:19 +0300 Subject: [PATCH 2400/2430] Adjusted PR --- lib/pool.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index ba74ed52..84d5166e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -971,7 +971,6 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro if (login_diff_split.length === 2) { this.fixed_diff = true; - this.difficulty = Number(login_diff_split[1]); if (login_diff_split[1].substring(0, 4) === 'perf') { let perfDiff = 0; if (this.coin_perf[""] > 2) { @@ -981,6 +980,8 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.fixed_diff = false; } this.difficulty = perfDiff || startingDiff; + } else { + this.difficulty = Number(login_diff_split[1]); } if (this.difficulty < global.config.pool.minDifficulty) { this.difficulty = global.config.pool.minDifficulty; From 797c6c48ec253143b6f4caaad888404629cc44d1 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 7 Jun 2024 03:28:31 +0300 Subject: [PATCH 2401/2430] Fixed /usr/bin/node link --- 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 5dcaf3fd..25e23612 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -183,7 +183,7 @@ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | b source /home/user/.nvm/nvm.sh nvm install $NODEJS_VERSION nvm alias default $NODEJS_VERSION -test -f /usr/bin/node || sudo ln -s $(which node) /usr/bin/node +test -f /usr/bin/node || sudo ln -s \$(which node) /usr/bin/node set -x git clone https://github.com/MoneroOcean/nodejs-pool.git cd /home/user/nodejs-pool diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 7440461a..15488d74 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -86,7 +86,7 @@ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | b source /home/user/.nvm/nvm.sh nvm install $NODEJS_VERSION nvm alias default $NODEJS_VERSION -test -f /usr/bin/node || sudo ln -s $(which node) /usr/bin/node +test -f /usr/bin/node || sudo ln -s \$(which node) /usr/bin/node set -x git clone https://github.com/MoneroOcean/nodejs-pool.git cd /home/user/nodejs-pool From 985b81699001a787a0098eee2ac6267a709a9095 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 14 Jul 2024 02:14:23 +0300 Subject: [PATCH 2402/2430] Added ZEPH update support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79a87b04..3d9e6f1d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.3.20", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.4.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 516017762d1c71409df1295014c13de2184154f3 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 07:26:29 +0300 Subject: [PATCH 2403/2430] Added SAL support --- README.md | 1 + deployment/base.sql | 2 ++ lib/coins/xmr.js | 8 +++++++- package.json | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c09cb09..eebddac8 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,7 @@ If you'd like to make a one time donation, the addresses are as follows: * CCX - ```ccx7dmnBBoRPuVcpKJSAVZKdSDo9rc7HVijFbhG34jsXL3qiqfRwu7A5ecem44s2rngDd8y8N4QnYK6WR3mXAcAZ5iXun9BQBx``` * BLOC - ```abLoc5iUG4a6oAb2dqygxkS5M2uHWx16zHb9fUWMzpSEDwm6T7PSq2MLdHonWZ16CGfnJKRomq75aZyviTo6ZjHeYQMzNAEkjMg``` * ZEPH - ```ZEPHYR2nic7ULkkmgZNX8a9i2tMbkxuCqjgWZYuee3awX7RhtmhoT98CwGEGrruWZVSKtA7Z7JC8m7oeYHtBD9cBEZzdEh9BSdq4q``` +* SAL - ```SaLvdWKnkz6MvVgxXr2TWSDSvESz6EBcz3wmMFch2sQuMYz2sUQGVNDYhkYaSuvkDr9GSYp5h6BeQHnGK8HzKhqGeZCZzG3AHS3``` * RVN - ```RLVJv9rQNHzXS3Zn4JH8hfAHmm1LfECMxy``` * XNA - ```Nb931jkFtFN7QWpu4FqSThaoKajYjS5iFZ``` * CLORE - ```AdXPHtV8yb86a8QKsbs8gmUpRpcxufRn8n``` diff --git a/deployment/base.sql b/deployment/base.sql index 7a5d0fa3..3d754c0e 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -254,6 +254,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', 'coinHashFactorZEPH', '0', 'float', 'ZEPH algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorXNA', '0', 'float', 'XNA algo hash price factor relative to coinHashFactor'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorCLORE', '0', 'float', 'CLORE algo hash price factor relative to coinHashFactor'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('daemon', 'coinHashFactorSAL', '0', 'float', 'SAL 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', 'Default Daemon RPC Wallet IP'); @@ -332,6 +333,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_10225', '', 'string', 'Address to mine to for 10225 (BTRM) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19001', '', 'string', 'Address to mine to for 19001 (Neurai) port.'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_9766', '', 'string', 'Address to mine to for 9766 (CLORE) port.'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'address_19081', '', 'string', 'Address to mine to for 19081 (SAL) 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 daea4334..428433fb 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -53,6 +53,7 @@ const port2coin = { "17767" : "ZEPH", "19001" : "XNA", "9766" : "CLORE", + "19081" : "SAL", }; const port2blob_num = { // "11181": 7, // AEON @@ -88,6 +89,7 @@ const port2blob_num = { "10225": 104, // BTRM "19001": 101, // XNA "9766" : 101, // CLORE + "19081": 15, // SAL }; const port2algo = { @@ -124,6 +126,7 @@ const port2algo = { "10225": "ghostrider", // BTRM "19001": "kawpow", // XNA "9766": "kawpow", // CLORE + "19081": "rx/0", // SAL }; const mm_nonce_size = cnUtil.get_merged_mining_nonce_size(); @@ -1018,7 +1021,7 @@ function Coin(data){ this.convertAlgosToCoinPerf = function(algos_perf) { let coin_perf = {}; - if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["ZEPH"] = algos_perf["rx/0"]; + if ("rx/0" in algos_perf) coin_perf[""] = coin_perf["ZEPH"] = coin_perf["SAL"] = algos_perf["rx/0"]; if ("cn/r" in algos_perf) coin_perf["SUMO"] = algos_perf["cn/r"]; @@ -1108,6 +1111,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 17767: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // ZEPH + case 19081: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 0); // SAL //case 18181: return multiHashing.cryptonight(convertedBlob, 0); // XMC // case 18981: return multiHashing.randomx(convertedBlob, Buffer.from(blockTemplate.seed_hash, 'hex'), 20); // Graft case 19734: return multiHashing.cryptonight(convertedBlob, 13, blockTemplate.height); // SUMO @@ -1140,6 +1144,7 @@ function Coin(data){ case 9231: case 17767: case 18081: + case 19081: // case 18981: case 19994: case 11812: @@ -1221,6 +1226,7 @@ function Coin(data){ case 12211: return "cryptonote_ryo"; // RYO case 17750: return "cryptonote_xhv"; // XHV case 17767: return "cryptonote_zeph"; // ZEPH + case 19081: return "cryptonote_sal"; // SAL 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 3d9e6f1d..9c2258cd 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.4.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From fa8d6d6a1e0cc5a182369fc4723a6b7a849c8053 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 10:14:58 +0300 Subject: [PATCH 2404/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c2258cd..9b4df306 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 9deacd9eeb2e0d7ab1d031457b65e129af84017f Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 19:32:13 +0300 Subject: [PATCH 2405/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9b4df306..6a475860 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 281bb222a0416a2fdefa97bc92364e9d05ed5692 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 19:39:12 +0300 Subject: [PATCH 2406/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6a475860..fdf756a8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.2", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.3", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From ac10e1af8ba3facaeca07e05a2310336378d72ee Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 20:30:31 +0300 Subject: [PATCH 2407/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fdf756a8..1d2d2bc4 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.3", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.4", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 6bd58b58dd62b50c4f1318a401e8bab37f1e8c88 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 20:52:33 +0300 Subject: [PATCH 2408/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d2d2bc4..c57f3c91 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.4", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.6", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 0bd00c871888bd1ba3d8514fd203a280593cb6f6 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 21:02:06 +0300 Subject: [PATCH 2409/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c57f3c91..b9cddba3 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.6", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.7", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From e1d8e2b5dfefedbd00c951bcda834c9e6ca7fb4c Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 21:06:37 +0300 Subject: [PATCH 2410/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9cddba3..492cd86d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.7", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.8", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 8ff2616c6fac9032824d8c5c7d8f69387bf7bb66 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 19 Jul 2024 21:44:28 +0300 Subject: [PATCH 2411/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 492cd86d..ba169d42 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.8", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.9", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 0f75cf008cc7db67e295496ff1b8886ee711eb10 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jul 2024 01:24:47 +0300 Subject: [PATCH 2412/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba169d42..ee57c39c 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.9", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.10", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 5a61e5b581f63f47e0222c3904f352cf1816bde5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jul 2024 04:42:06 +0300 Subject: [PATCH 2413/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ee57c39c..1f0a2690 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.10", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.11", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 249842cf8edd1109f87119370f4a3976358ce224 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jul 2024 04:49:43 +0300 Subject: [PATCH 2414/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f0a2690..28be499f 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.11", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.12", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 1b1736d3c377e273ec1f7a3c89e1b5c451583a41 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jul 2024 05:19:15 +0300 Subject: [PATCH 2415/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28be499f..9f45c1d1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.12", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.13", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From b36ff7d3c90714b6c15ffe379f38b44064a2c933 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jul 2024 19:13:22 +0300 Subject: [PATCH 2416/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f45c1d1..3a17bac1 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.13", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.15", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From e39a919eea3b23d2f3701cede13dd898b0228d9e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 20 Jul 2024 19:18:19 +0300 Subject: [PATCH 2417/2430] Added SAL support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3a17bac1..c86bfb44 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.15", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.16", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", "debug": "2.6.9", "express": "^4.17.1", From 6b9f84f726973672c854c56ff51ff10ff5a99529 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 21 Jul 2024 18:50:59 +0300 Subject: [PATCH 2418/2430] Updated email client code --- lib/support.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/support.js b/lib/support.js index ce2dbc4c..67d6a904 100644 --- a/lib/support.js +++ b/lib/support.js @@ -50,19 +50,22 @@ function sendEmailReal(toAddress, subject, email_body, retry) { return; } lastEmailSendTime = Date.now(); - request.post(global.config.general.mailgunURL + "/messages", { - auth: { - user: 'api', - pass: global.config.general.mailgunKey - }, - form: { - from: global.config.general.emailFrom, - to: toAddress, - subject: subject, - text: email_body - }, + const body = JSON.stringify({ + from: global.config.general.emailFrom, + to: toAddress, + subject: subject, + text: email_body + }) + "\n"; + request.post(global.config.general.mailgunURL, { + body: body, agentOptions: { rejectUnauthorized: global.config.general.mailgunNoCert === true ? false : true + }, + headers: { + "Content-Type": "application/json", + "Accept": "application/json", + "Content-Length": body.length, + "Connection": "close" } }, function(err, response, body) { if (!err && response.statusCode === 200) { From 778f1be31d309b54a441eda31360af7c9c3547bd Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sat, 27 Jul 2024 02:57:17 +0300 Subject: [PATCH 2419/2430] Added whitelist support --- lib/pool.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index 84d5166e..88716b42 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -562,7 +562,10 @@ var reEmail = /^\S+@\S+\.\S+$/; // wallet password last check time let walletLastCheckTime = {}; +// Print extra info for these wallets let wallet_debug = {}; +// Do not ban from these IPs +let ip_whitelist = {}; function getTargetHex(diff, size) { return pad_hex(baseDiff.div(diff).toBuffer({endian: 'little', size: size}).toString('hex'), size); @@ -609,6 +612,8 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro } this.debugMiner = this.payout in wallet_debug; + this.whiteList = ipAddress in ip_whitelist; + this.email = pass_split.length >= 2 ? pass_split[1] : ""; this.logString = this.payout.substr(this.payout.length - 10) + ":" + this.identifier + " (" + ipAddress + ")"; this.agent = agent; @@ -1072,6 +1077,7 @@ function Miner(id, login, pass, rigid, ipAddress, startingDiff, pushMessage, pro this.checkBan = function (validShare) { if (!global.config.pool.banEnabled) return; + if (this.whiteList) return; // Valid stats are stored by the pool. if (validShare) { @@ -2655,6 +2661,18 @@ if (cluster.isMaster) { wallet_debug[line] = 1; }); }); + const ip_whitelist_fn = "ip_whitelist.txt"; + ip_whitelist = {}; + fs.access(ip_whitelist_fn, fs.F_OK, function(err) { + if (err) return; + let rs = fs.createReadStream(ip_whitelist_fn); + rs.on('error', function() { console.error("Can't open " + ip_whitelist_fn + " file"); }); + let lineReader = require('readline').createInterface({ input: rs }); + lineReader.on('line', function (line) { + console.log(threadName + "[IP WHITELIST]: '" + line + "'"); + ip_whitelist[line] = 1; + }); + }); }, 5*60*1000); //let lastGarbageFromIpTime = {}; From 52486c9adb9d3260048cd67ff342bf245aa1e2e5 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Aug 2024 19:39:00 +0300 Subject: [PATCH 2420/2430] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c86bfb44..1d2681fc 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cors": "^2.8.1", "crypto-js": "^4.2.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.16", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.2", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.3", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From 789cfb54fa54302c0d0e67b6dc7afa69bd028c83 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Aug 2024 19:42:26 +0300 Subject: [PATCH 2421/2430] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d2681fc..61a2988f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cors": "^2.8.1", "crypto-js": "^4.2.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.16", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.3", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.4", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From 9a9d48fbccdd83d319b8d340074db8f54c83274e Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 11 Aug 2024 19:54:49 +0300 Subject: [PATCH 2422/2430] Updated utils --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61a2988f..1f037b84 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cors": "^2.8.1", "crypto-js": "^4.2.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.16", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.4", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.5", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From 5925dba576ca7511980d937774fdd83451de2511 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Wed, 25 Sep 2024 00:19:41 +0300 Subject: [PATCH 2423/2430] Disable local share reverify in case there is external verifier --- lib/coins/xmr.js | 8 ++++---- lib/pool.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index 428433fb..bcfeb1bc 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -195,7 +195,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); @@ -222,7 +222,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); @@ -235,7 +235,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); @@ -1165,7 +1165,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] > 10) return; + if (time_now - shareVerifyQueueErrorTime[index] < 1*60*1000 && shareVerifyQueueErrorCount[index] > 100 && global.config.verify_shares_host[index] !== "127.0.0.1") return; const qlength = queue_obj.length() + queue_obj.running(); if (min_queue_size === null || qlength < min_queue_size) { best_index = index; diff --git a/lib/pool.js b/lib/pool.js index 88716b42..4f0ca6b4 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1790,9 +1790,9 @@ function processShare(miner, job, blockTemplate, params, processShareCB) { global.coinFuncs.slowHashAsync(convertedBlob, blockTemplate, miner.payout, 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); + //} 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); From 3924fe8378f1a0f656c782b31d731f848f880028 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 7 Oct 2024 07:54:42 +0300 Subject: [PATCH 2424/2430] ZEPH 2.0 support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f037b84..2616e7f2 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.5.16", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.6.0", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.5", "debug": "2.6.9", "express": "^4.17.1", From bbbce828355ea914aa43ed6beb86d92f1b22d725 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 22 Oct 2024 02:57:49 +0300 Subject: [PATCH 2425/2430] Updated to monero 18.3.4 --- 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 25e23612..afd6e146 100644 --- a/deployment/deploy.bash +++ b/deployment/deploy.bash @@ -119,7 +119,7 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y git make g++ cmake libssl-dev cd /usr/local/src git clone https://github.com/monero-project/monero.git cd monero -git checkout v0.18.3.3 +git checkout v0.18.3.4 git submodule update --init USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || USE_SINGLE_BUILDDIR=1 make -j1 release diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 15488d74..9fddb945 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -49,7 +49,7 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y git make g++ cmake libssl-dev cd /usr/local/src git clone https://github.com/monero-project/monero.git cd monero -git checkout v0.18.3.3 +git checkout v0.18.3.4 git submodule update --init USE_SINGLE_BUILDDIR=1 make -j$(nproc) release || USE_SINGLE_BUILDDIR=1 make -j1 release diff --git a/deployment/upgrade_monero.bash b/deployment/upgrade_monero.bash index 96ed31fd..62981890 100755 --- a/deployment/upgrade_monero.bash +++ b/deployment/upgrade_monero.bash @@ -6,7 +6,7 @@ cd /usr/local/src/monero &&\ sudo git reset --hard origin/master &&\ sudo git checkout master &&\ sudo git pull &&\ -sudo git checkout v0.18.3.3 &&\ +sudo git checkout v0.18.3.4 &&\ sudo git submodule update --force --recursive --init &&\ sudo rm -rf build &&\ sudo USE_SINGLE_BUILDDIR=1 nice make release &&\ From f71d1a444b7004e84149f091419e44c268f14b44 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 5 Nov 2024 16:45:25 +0300 Subject: [PATCH 2426/2430] Fixed SAL parse after fork --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2616e7f2..f0149b82 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.6.0", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.6.1", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.5", "debug": "2.6.9", "express": "^4.17.1", From c3b24a56dc505d0b19a28d408334889ac18003aa Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Mon, 2 Dec 2024 22:35:02 +0300 Subject: [PATCH 2427/2430] Fixed missing ufw package --- deployment/leaf.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 9fddb945..030ffaba 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -9,6 +9,7 @@ fi DEBIAN_FRONTEND=noninteractive apt-get update DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y +DEBIAN_FRONTEND=noninteractive apt-get install -y ntp sudo ufw timedatectl set-timezone Etc/UTC adduser --disabled-password --gecos "" user @@ -44,7 +45,6 @@ set fo-=ro EOF chown user:user /home/user/.vimrc -DEBIAN_FRONTEND=noninteractive apt-get install -y ntp sudo DEBIAN_FRONTEND=noninteractive apt-get install -y git make g++ cmake libssl-dev libunbound-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev libboost-locale-dev libboost-regex-dev libboost-regex-dev libboost-program-options-dev libzmq3-dev cd /usr/local/src git clone https://github.com/monero-project/monero.git From b29b8935bcb92068caaa7fa5e75788e43cfc6136 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Tue, 3 Dec 2024 01:55:22 +0300 Subject: [PATCH 2428/2430] Added vim --- deployment/leaf.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/leaf.bash b/deployment/leaf.bash index 030ffaba..aa092883 100644 --- a/deployment/leaf.bash +++ b/deployment/leaf.bash @@ -21,7 +21,7 @@ if [ -f "/root/.ssh/authorized_keys" ]; then chmod 600 /home/user/.ssh/authorized_keys sed -i 's/#\?PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config sed -i 's/#\?PermitRootLogin .\+/PermitRootLogin no/g' /etc/ssh/sshd_config - sed -i 's/#\?PermitEmptyPasswords .\+/PermitEmptyPasswords no/g' /etc/ssh/sshd_config + sed -i 's/#\? .\+/PermitEmptyPasswords no/g' /etc/ssh/sshd_config service ssh restart fi @@ -45,7 +45,7 @@ set fo-=ro EOF chown user:user /home/user/.vimrc -DEBIAN_FRONTEND=noninteractive apt-get install -y git make g++ cmake libssl-dev libunbound-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev libboost-locale-dev libboost-regex-dev libboost-regex-dev libboost-program-options-dev libzmq3-dev +DEBIAN_FRONTEND=noninteractive apt-get install -y vim git make g++ cmake libssl-dev libunbound-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-dev libboost-system-dev libboost-date-time-dev libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev libboost-locale-dev libboost-regex-dev libboost-regex-dev libboost-program-options-dev libzmq3-dev cd /usr/local/src git clone https://github.com/monero-project/monero.git cd monero From 821afb36f9ae1e4a303629b7728fb902eb4e71a4 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Fri, 6 Dec 2024 03:44:18 +0300 Subject: [PATCH 2429/2430] Fixed buffer overflow --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f0149b82..6a98408e 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cors": "^2.8.1", "crypto-js": "^4.2.0", "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.6.1", - "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.5", + "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.6", "debug": "2.6.9", "express": "^4.17.1", "jsonwebtoken": "^9.0.2", From 518327d4d9dee003e71f879bc1a8f516cc9c8c08 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 19 Dec 2024 06:49:09 +0300 Subject: [PATCH 2430/2430] SAL v0.7 support and removed RingCT XHV support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6a98408e..a826220b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "concat-stream": "^1.6.0", "cors": "^2.8.1", "crypto-js": "^4.2.0", - "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.6.1", + "cryptoforknote-util": "git+https://github.com/MoneroOcean/node-cryptoforknote-util.git#v15.6.2", "cryptonight-hashing": "git+https://github.com/MoneroOcean/node-cryptonight-hashing.git#v29.0.6", "debug": "2.6.9", "express": "^4.17.1",