Fix beta test issues

This commit is contained in:
poolman 2019-04-18 02:27:39 +03:00
parent 9a8a1b3a4a
commit 2ab4755066
4 changed files with 26 additions and 31 deletions

View file

@ -182,8 +182,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', 'Zano Daemon RPC Wallet IP');
INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('wallet', 'port', '11211', 'int', 'Zano 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', '500000000000', 'int', 'Maximum difficulty for VarDiff');
INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('pool', 'minDifficulty', '1000', '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');

View file

@ -73,10 +73,7 @@ function Coin(data){
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 (zanoUtil.address_decode(address) === this.prefix){
return true;
}
return zanoUtil.address_decode_integrated(address) === this.intPrefix;
return zanoUtil.is_address_valid(address);
};
this.convertBlob = function(blobBuffer){
@ -137,12 +134,9 @@ 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.nextBlob = function () {
// Write a 32 bit integer, big-endian style to the 0 byte of the reserve offset.
let extraNonceBuffer = Buffer.alloc(4);
extraNonceBuffer.writeUInt32BE(++this.extraNonce, 0);
this.nextBlob = function (id) {
// Convert the blob into something hashable.
return global.coinFuncs.getHashFromBlockTemplateWithExtra(this.buffer, extraNonceBuffer).toString('hex');
return '0x' + global.coinFuncs.getHashFromBlockTemplateWithExtra(this.buffer, id).toString('hex');
};
// Make it so you can get the raw block blob out.
this.nextBlobWithChildNonce = function () {

View file

@ -1,5 +1,6 @@
"use strict";
const debug = require('debug')('pool');
const crypto = require('crypto');
const bignum = require('bignum');
const cluster = require('cluster');
const btcValidator = require('wallet-address-validator');
@ -473,12 +474,15 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
}
if (!this.proxy) {
let blob = activeBlockTemplate.nextBlob();
let uniqueID = crypto.pseudoRandomBytes(8);
let blob = activeBlockTemplate.nextBlob(uniqueID);
let target = this.getTargetHex();
this.lastBlockHeight = activeBlockTemplate.height;
let newJob = {
id: blob,
unique_id: uniqueID,
extraNonce: activeBlockTemplate.extraNonce,
height: activeBlockTemplate.height,
difficulty: this.difficulty,
@ -492,7 +496,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
let heightBuffer = Buffer.alloc(8);
heightBuffer.writeUInt32BE(activeBlockTemplate.height, 4);
this.cachedJob = [
'0x'+ blob,
blob,
'0x'+ activeBlockTemplate.seed,
'0x'+ target,
'0x'+ heightBuffer.toString('hex'),
@ -600,13 +604,10 @@ function processShare(miner, job, blockTemplate, params, sendReply) {
let hashBuffer = new Buffer(resultHash, 'hex');
let extraNonceBuffer = Buffer.alloc(4);
extraNonceBuffer.writeUInt32BE(job.extraNonce, 0);
let heightBuffer = Buffer.alloc(8);
heightBuffer.writeUInt32LE(job.height, 0);
let shareBuffer = global.coinFuncs.getBlobFromBlockTemplate(blockTemplate.buffer, extraNonceBuffer, nonceBufferReversed);
let shareBuffer = global.coinFuncs.getBlobFromBlockTemplate(blockTemplate.buffer, job.unique_id, nonceBufferReversed);
let hash = global.coinFuncs.getPoWHash(hashBuffer, nonceBufferReversed, heightBuffer);
let hashDiff = bignum.fromBuffer(hash);
@ -651,8 +652,8 @@ function processShare(miner, job, blockTemplate, params, sendReply) {
return true;
}
function handleMinerData(method, params, ip, portData, sendReply, pushMessage) {
let miner = activeMiners[params.id];
function handleMinerData(method, params, ip, portData, sendReply, pushMessage, connID) {
let miner = activeMiners[connID];
// Check for ban here, so preconnected attackers can't continue to screw you
if (bannedIPs.indexOf(ip) !== -1) {
// Handle IP ban off clip.
@ -668,19 +669,19 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) {
}
difficulty = portData.difficulty;
miner = new Miner(ip, params[0], params[1], ip, difficulty, pushMessage, 1, portData.portType, portData.port, '');
miner = new Miner(connID, params[0], params[1], ip, difficulty, pushMessage, 1, portData.portType, portData.port, '');
if (!miner.valid_miner) {
console.log("Invalid miner, disconnecting due to: " + miner.error);
sendReply(miner.error);
return;
}
process.send({type: 'newMiner', data: miner.port});
activeMiners[ip] = miner;
activeMiners[connID] = miner;
sendReply(null, true);
break;
case 'eth_getWork':
if (!miner) {
miner = activeMiners[ip];
miner = activeMiners[connID];
}
if (!miner) {
sendReply('Unauthenticated');
@ -690,9 +691,6 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) {
miner.sendNewJob();
break;
case 'eth_submitWork':
if (!miner) {
miner = activeMiners[ip];
}
if (!miner) {
sendReply('Unauthenticated');
return;
@ -706,11 +704,12 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) {
miner.heartbeat();
job = miner.validJobs.toarray().filter(function (job) {
return '0x' + job.id === params[1];
return job.id === params[1];
})[0];
if (!job) {
sendReply('Invalid job id');
console.warn(threadName + 'Invalid job: ' + JSON.stringify(params) + ' from ' + miner.logString);
return;
}
@ -835,7 +834,7 @@ if (cluster.isMaster) {
if (global.config[portData.portType].enable !== true) {
return;
}
let handleMessage = function (socket, jsonData, pushMessage) {
let handleMessage = function (socket, jsonData, pushMessage, connID) {
if (!jsonData.id) {
console.warn('Miner RPC request missing RPC id');
return;
@ -861,7 +860,7 @@ if (cluster.isMaster) {
}) + "\n";
socket.write(sendData);
};
handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, pushMessage);
handleMinerData(jsonData.method, jsonData.params, socket.remoteAddress, portData, sendReply, pushMessage, connID);
};
function socketConn(socket) {
@ -870,6 +869,8 @@ if (cluster.isMaster) {
let dataBuffer = '';
let connID = crypto.pseudoRandomBytes(21).toString('base64');
let pushMessage = function (method, params, id) {
if (!socket.writable) {
return;
@ -926,7 +927,7 @@ if (cluster.isMaster) {
break;
}
handleMessage(socket, jsonData, pushMessage);
handleMessage(socket, jsonData, pushMessage, connID);
}
dataBuffer = incomplete;
}

View file

@ -147,7 +147,7 @@
"id": 22,
"module": "pool",
"item": "maxDifficulty",
"item_value": "500000",
"item_value": "50000000000",
"item_type": "int",
"Item_desc": "Maximum difficulty for VarDiff"
},
@ -155,7 +155,7 @@
"id": 23,
"module": "pool",
"item": "minDifficulty",
"item_value": "100",
"item_value": "1000",
"item_type": "int",
"Item_desc": "Minimum difficulty for VarDiff"
},