Max-Coin / maxcoin

The main source tree for the Max Coin cryptocurrency
MIT License
79 stars 62 forks source link

What did you guys do besides changing hash to keccak? #40

Closed zone117x closed 10 years ago

zone117x commented 10 years ago

I've been trying to implement maxcoin in NOMP and I've spend hours trying to get the daemon to accept a block on testnet.

It looks like instead of doing a double-sha256 on the coinbase transaction, you do a single-sha256 hash, for generating the merkle root. But I tried that and still the daemon won't accept the block.

What in the hell did you guys change in the block generation process that is preventing my code from generating a valid one? It works for sha256d, scrypt, scrypt-jane, scrypt-n, x11, quark... what the hell is different with maxcoin besides keccak hashing?

Apologies if I come off rude, I've spend hours on this and very frustrated.

lukem512 commented 10 years ago

Hi Zone117x,

here is a basic list of protocol diffences: https://github.com/Max-Coin/maxcoin/wiki/MaxCoin-Protocol-Differences. As you mentioned, we use Keccak for the proof-of-work, we use a single sha256 for generating transaction hashes and, additionally, we generate addresses using the Keccak algorithm.

We also changed the signing algorithm to use Schnorr, with the SECP256r1 curve for key generation. I don't know if this will affect your code - I somehow doubt it, but I haven't had time to fully examine what you're doing, so I've included this for completeness.

I hope this helps.

zone117x commented 10 years ago

Hi Luke, Thanks for the details response. I believe I may have found the cause to why my blocks are not valid.

Here is what I'm doing for keccak hashing: https://github.com/zone117x/node-multi-hashing/blob/master/keccak.c Even if that was incorrect, hashing should have no effect on the block being valid - but its used to validate share difficutly so can you please take a look and confirm that its correct?

Here you can see where I am using single-sha256 on the coinbase transaction when using keccak, can you confirm this is correct? https://github.com/zone117x/node-stratum-pool/blob/master/lib/jobManager.js#L68

Now looking over the wiki link you posted you said "The script addresses always begin with an n character (byte 112). Testnet addresses always begin with t (byte 127) and u (byte 130) respectively." Here is where I convert base58 encoded addresses to script which is used as the public key in the coinbase transaction: https://github.com/zone117x/node-stratum-pool/blob/master/lib/util.js#L261

That addressToScript function works with every other algo but does it need to be modified to work with Maxcoin?

lukem512 commented 10 years ago

Hi again,

I am putting together a piece of documentation with our hashing conventions. This is something I have meant to do for a while but, as you're in need of it now, it has spurred me on. It can be seen at https://github.com/Max-Coin/maxcoin/wiki/Hashing-Conventions.

You are correct that the transaction hash, to create the txid, uses a single sha256 hash.

Luke

starkers commented 10 years ago

nice one Luke :-)

On 02/04/14 14:49, Luke wrote:

Hi again,

I am putting together a piece of documentation with our hashing conventions. This is something I have meant to do for a while but, as you're in need of it now, it has spurred me on. It can be seen at https://github.com/Max-Coin/maxcoin/wiki/Hashing-Conventions.

You are correct that the transaction hash, to create the txid, uses a single sha256 hash.

Luke

— Reply to this email directly or view it on GitHub https://github.com/Max-Coin/maxcoin/issues/40#issuecomment-39331842.

zone117x commented 10 years ago

Hey Luke - thanks for the wiki but it doesn't give me any info I don't already know or need. I believe maxcoin code is borked and its impossible to generate a valid block on testnet. Go ahead, try it yourself. Setup a maxcoin testnet on your local network and use python-stratum maxcoin branch to try to generate a block. All rejected.

zone117x commented 10 years ago

This isn't a matter of how you guys changed hashing conventions. Its how you changed the block generation/submission process. So far the only difference I see is a single sha256 on coinbase. But that isn't enough to create a block that maxcoin testnet accepts. At this point I'm convinced you have a broken testnet.

lukem512 commented 10 years ago

@Prydie, I feel you might be more suited to answering this, if you could?

zone117x, I know that Prydie has used testnet in the past when developing RocketPool. I've asked him to specify what he did to get it up and running. To my knowledge we haven't broken the testnet, although I will of course perform some investigation into this myself.

lukem512 commented 10 years ago

zone, we also use a single sha256 hash for all transaction hashes, not just for coinbase.

prydie commented 10 years ago

@zone117x, I got up to several thousand blocks mined on testnet when we were building RocketPool using a modified version of the maxcoin stratum branch in Ahmed's stratum-mining repository. The modifications are shortly going to be pushed after I've written some unit tests to confirm everything is working as intended.

That said, the only modifications I've made are code structure rather than any core algorithmic changes so the code currently at the HEAD of the branch should suffice in demonstrating the differences.

These changes made to my knowledge (and this can be confirmed by grepping the stratum repo for "max") are address to pub-key and single sha256 hashing of the coinbase transaction. On top of changing the POW algorithm of course.

zone117x commented 10 years ago

Right, the algorithmic changes shouldn't have effect on the block hex being accepted by the daemon. I'm pretty sure I have the algo and share diff checking working fine. I get valid shares from cudaminer for keccak. Problem is daemon does not accept blocks. I did the changes that maxcoin requires which should only be using a single sha256 on the coinbase tx, here is where I do that.

Your max if statement in the address to pub-key is only related to validating an address - which I already have working. It doesn't actually change the address or pubkey any different from any other coin.

So other than changing the coinbase tx hashing to single-sha265 I don't know what else to do in order to generate valid blocks that the daemon accepts. I'm at a total loss of where to go from here. Luke, you or another dev that understands maxcoin's changes will have to look at my maxcoin related code and point out where its flawed otherwise it will not be supported because I have tried absolutely everything I can.

lukem512 commented 10 years ago

I'll have a look when I have an opportunity to do so - realistically this might be a week or more with current workload. Please leave your current changes in effect and I'll do my best.

zone117x commented 10 years ago

Hey Luke, lots of big pools switching to NOMP as the stratum server. There is demand for maxcoin support. Since all the research/work I put into supporting it failed - its up to you or some other dev to get it working, otherwise maxcoin stratum mining will be left behind to only work with antiquated pool server software.

uberadminer commented 10 years ago

I myself would love to see maxcoin work with NOMP.

zone117x commented 10 years ago

The NOMP community and I have got maxcoin and its clones working. Turns out my code was generating valid blocks but could not validate them due to Maxcoin changing the blockhash. For whatever reason you guys changes it from sha256d(block_header) to keccak(block_header + ntime).

I get excited when coin-devs implement new features in altcoins for the purpose of innovation. What irritates me is when they make arbitrary changes that break compatibility with existing cryptocurrency software while the change was neither innovative nor improved anything in anyway. Lots of people's productivity was wasted getting these maxcoin (or blakecoin or whoever initially implemented the "feature") arbitrary changes working, and I don't see how anything is better off because of it.

/end frustration

lukem512 commented 10 years ago

Brilliant, thanks for the update in getting this working. I apologise profusely for the amount of time this might have cost you - we're compiling some complete technical specifications to ease the development process in the future.