z-classic / z-nomp

z-nomp is mining pool software for Zcash and Zclassic so you can create internet money in your home!
MIT License
290 stars 440 forks source link

TypeError: Cannot read property 'root' of undefined #155

Closed mckenzieja closed 7 years ago

mckenzieja commented 7 years ago
z-nomp/node_modules/stratum-pool/lib/merkleTree.js:8
   return result._65.root;
 TypeError: Cannot read property 'root' of undefined

I'm thinking it's because no workers are requesting shares?

Solutions attempted:

All other modules report running but whenever the poolspawner spawns a worker, it throws the above error.

mckenzieja commented 7 years ago

SOLVED

Ran znomp as root.

Dont do that.

mckenzieja commented 7 years ago

Actually still an issue.

howie50417 commented 7 years ago

I have the same error

howie50417 commented 7 years ago

I modify return result._65.root; to return result._1.root; then I can run up

mckenzieja commented 7 years ago

How viable is that solution?

jmprcx commented 7 years ago

I'm working on this now...

The cause of this is probably that Promise.denodeify is a non-standardized API. https://www.promisejs.org/api/

jmprcx commented 7 years ago

Could you all test this commit out? https://github.com/z-classic/node-stratum-pool/compare/test-hash-lookup?expand=1

You'll need to update this file node_modules/stratum-pool/lib/merkleTree.js with this:

var Promise = require('promise');
var merklebitcoin = Promise.denodeify(require('merkle-bitcoin'));
var util = require('./util.js');

function calcRoot(hashes) {
    var result = merklebitcoin(hashes);
    //console.log(Object.values(result)[2].root);
    return Object.values(result)[2].root;
}

exports.getRoot = function (rpcData, generateTxRaw) {
    hashes = [util.reverseBuffer(new Buffer(generateTxRaw, 'hex')).toString('hex')];
    rpcData.transactions.forEach(function (value) {
        hashes.push(value.hash);
    });
    if (hashes.length === 1) {
        return hashes[0];
    }
    var result = calcRoot(hashes);
    return result;
};
howie50417 commented 7 years ago

After patch this, I can run z-nomp without jump exception

jmprcx commented 7 years ago

Great to hear... I'll merge this in then.

For anybody else wanting to use this: rm -rf node_modules npm update npm install

mckenzieja commented 7 years ago

Seemed to do the trick. Spent hours pouring over stratum's dependencies.