Crypto-Expert / stratum-mining

AIO Stratum mining server for various coins
Other
365 stars 348 forks source link

Feature Request - Merge mining for namecoin with Bitcoin #201

Closed educatedwarrior closed 9 years ago

educatedwarrior commented 10 years ago

Hi Ahmed, is there anyway you could currently use your stratum-mining for merged mining?

ahmedbodi commented 10 years ago

not possible atm

educatedwarrior commented 10 years ago

I talked with Luke-Jr (guy that wrote BFG Miner) at the Miami Bitcoin conference last weekend. .. He said all you have to do is take the solve hash for a Bitcoin block and submit it to the namecoin for example. Said it was pretty simple. If you would like me to get some more details I will. Let me know what I can do.

ahmedbodi commented 10 years ago

I asked him and he said it wasn't possible with stratum's existing code. rest assured its being worked on when I get the chance :D

a432511 commented 10 years ago

@ahmedbodi I forked someone's stratum-mining-nscrypt repo (just realized they didn't properly fork, so the relationship to your repository is lost) with the intent on getting merged mining working for Vertcoin. You say it isn't possible with stratum's existing code... do you mean the changes would need to occur within stratum or stratum-mining? My understanding is that stratum is just the network interface between the clients and server and stratum-mining does the work related to interfacing with the coind rpc. Thus, the changes would need to be made in stratum-mining... is that correct? Here is my fork btw: https://github.com/a432511/stratum-mining-nscrypt

a432511 commented 10 years ago

@ahmedbodi Also, it might be work merging my changes into your repo. I just refactored some coin specific vars, classes and config values to be more generic and less confusing. If you want to do that, I will re-fork from your merged master. I am unable to create a pull request because of the improper forking.

ahmedbodi commented 10 years ago

Hi. it is possible and it has been done to work with 1 merged mined coin. However it isnt an optimal solution. The best solution would be to clean up all the stratum code and to implement LukeJr's gotwork functionality so we can use the NMC mining proxy to do the merged mining. If you're willing to help out which it looks like you are. id be happy to help in doing so. I attempted to use a MPOS like BaseCoin configuration for algorithms on the dev1 branch. Im wondering if you'd be kind enough to test them for me?

Ahmed

a432511 commented 10 years ago

@ahmedbodi Ok. I also found an inefficiency in BlockTemplate.fill_from_rpc (https://github.com/a432511/stratum-mining-nscrypt/commit/38a54aa77457719f553a62be189498bd0a1ce158). It seems to iterate the transactions twice for no reason. Are you able to merge in from my fork so I can re-fork? I don't want to keep pushing commits to an unusable fork.

Regarding testing your changes, I can spin up a VM, but I don't know if I am familiar enough to perform a meaningful test for you. I am just diving in and still gathering the full picture on how this all fits together. If you have a guide or something I could give it a shot.

I was particularly interested in the BlockTemplate class because it appears that would be the insertion point for some of this merged mining stuff. I still need to review the standard for merged mining, but I gather BlockTemplate needs to take the additional 0 value transactions derived from the other merged coins as a param to add to the merkle tree. Additionally, the consumer of BlockTemplate needs to be aware of the other merged coins to assemble their blocks first to create the 0 VTC transactions that link to the merged coins. Am I thinking about that correctly?

What would be the advantage of making this change at the stratum level vs stratum-mining? I have not yet looked through the stratum code base.

Ultimately, I would like to maintain compatibility with MPOS. I know some changes will need to be made to MPOS, but I would hate to see it die after serving the community so well!

ahmedbodi commented 10 years ago

you are however that isnt the method that i'd like to go. i want to go the method where stratum wont need to know or care about merged mining. this would be using the namecoin proxy's gotwork interface where we submit hashes to the proxy to use in producing merged mining blocks and submitting to its appropriate coin';s

a432511 commented 10 years ago

Ok. Makes sense, however, I don't think such a proxy exists for VTC, MON and PLX. My goal is to get it working with those three coins. I suppose I could create a proxy based on namecoin's proxy..... eh. I'll take a peek. Feel free to pull from my fork for now if you are interested in some of the cleanup I am doing. I am not testing as I commit, so be aware of that risk.

ahmedbodi commented 10 years ago

it does. we just need to modify the difficulties inside the proxy to work with VTC based coins thats it :)

a432511 commented 10 years ago

@ahmedbodi Ok. Intruiging. Do you have a link to the source or a protocol?

a432511 commented 10 years ago

@ahmedbodi I saw your commit in the dev branch. MUCH better than what I did. So, I would just need to implement Coin for scryptn that inherits your base.

a432511 commented 10 years ago

@ahmedbodi Added scryptn and made some bugfixes to dev1 in my fork. Created pull request.

ahmedbodi commented 10 years ago

sweet thanks :+1:

a432511 commented 10 years ago

@ahmedbodi No problem. One thing... if you approve the changes, can you please pull from my fork? Then it preserves the commits and all that.

What is next as far as merged mining is concerned? Do you have a stratum branch that I can look at and an idea of what you want changed? I am more than willing to dive in to get it working.

Cheers

ahmedbodi commented 10 years ago

yep sure. i think let's re implement all the algorithm's we need inside stratum. go through the code and build text and documentation and then we can work on merged mining

a432511 commented 10 years ago

@ahmedbodi ok. I'll start on that. shouldnt be too hard. I'll do scrypt and scrypt-jane next.

ahmedbodi commented 10 years ago

sounds good :)

a432511 commented 10 years ago

@ahmedbodi All set, but I wasn't 100% sure what the import should be for scrypt-jane because I have never used that external lib before.

a432511 commented 10 years ago

@ahmedbodi I added a bit of cleanup to the pull request. Renamed some coin specific classes, vars, files. Please review this commit specifically: https://github.com/a432511/stratum-mining/commit/9b4eb64b72430036951838802444dbffa4400ee2

I think it is looping unnecessarily to clear old block templates. It looks like that loop just removes any indices that don't match the just added block template. I think the equivalent would be to clear the array by re-initializing and then adding the new block template - should be marginally more efficient.

a432511 commented 10 years ago

@ahmedbodi So I got around to throwing the dev1 branch on my server and was able to resolve numerous compile/runtime errors. It is running now, but the mining client throws a JSON authorization error. You can register and try for yourself @ https://vtc.sovereignshare.com

ahmedbodi commented 9 years ago

refactor done here: https://github.com/Multicoin-co/stratum-mining/pull/2 now you can specify your own diff1 and algo