Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge mining with Hybrid POW/POS coins as main chain [$100] #6

Open
Infernoman opened this issue Feb 1, 2017 · 7 comments
Open

Merge mining with Hybrid POW/POS coins as main chain [$100] #6

Infernoman opened this issue Feb 1, 2017 · 7 comments

Comments

@Infernoman
Copy link
Member

Infernoman commented Feb 1, 2017

Currently shares from the POW/POS coins main chain when submitted to an auxpow coin as a block, it returns ReadCompactSize() : size too large. I'm guessing that block headers need to be adjusted for the hybrid coin, to be able to submit the block to the AUX network successfully.

--- There is a **[$100 open bounty](https://www.bountysource.com/issues/41537961-merge-mining-with-hybrid-pow-pos-coins-as-main-chain?utm_campaign=plugin&utm_content=tracker%2F8405108&utm_medium=issues&utm_source=github)** on this issue. Add to the bounty at [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F8405108&utm_medium=issues&utm_source=github).
@Infernoman Infernoman changed the title Merge mining with Hybrid POW/POS coins as main chain Merge mining with Hybrid POW/POS coins as main chain [$100] Feb 1, 2017
@Infernoman
Copy link
Member Author

Infernoman commented Feb 1, 2017

@ahmedbodi should be able to modify the block template for hybrid coin submission to auxpow networks. Looks to me like the transaction format is the issue. Peercoin can decode the rawtransaction it's trying to submit as auxpow on line 308 of lib/pool.js. but the auxcoin cannot.

JSON.stringify(shareData) ==

{"job":"1c",
"ip":"198.11.220.46",
"port":3032,
"worker":"PCcE1g9VXdYZKNAAb5TrtEP8gmGRE8pVeu",
"height":283196,
"blockReward":64840000,
"difficulty":50091.21019108,
"shareDiff":"97379103.65130197",
"blockDiff":565467873.9475175,
"blockDiffActual":565467873.9475175,
"coinbaseBuffer":[1,0,0,0,119,122,145,88,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,83,3,60,82,4,6,47,80,50,83,72,47,4,76,122,145,88,8,250,190,109,109,163,192,106,54,201,207,101,209,37,182,146,90,118,39,58,154,200,98,40,87,156,55,26,109,69,141,171,175,201,151,76,123,1,0,0,0,0,0,0,0,40,0,0,0,173,160,120,0,13,47,110,111,100,101,83,116,114,97,116,117,109,47,0,0,0,0,2,176,102,219,3,0,0,0,0,35,33,2,185,253,226,152,75,140,153,178,249,151,245,179,23,2,64,144,99,116,242,61,176,208,84,26,51,119,115,36,184,78,150,114,172,144,250,1,0,0,0,0,0,25,118,169,20,12,215,88,57,108,44,250,201,236,16,247,54,78,208,251,143,209,29,216,117,136,172,0,0,0,0],
"txHash":"fd8055df9b0253d9b998401d659a7cabdef512adbdea0b4217d658136e7b7609",
"headerHash":[123,119,216,32,195,199,102,196,142,14,146,247,12,61,84,132,204,97,92,79,81,218,222,26,44,0,0,0,0,0,0,0],
"blockBigNum":{},
"blockHashInvalid":"000000000000002c1adeda514f5c61cc84543d0cf7920e8ec466c7c320d8777b",
"time":1485929047}

[Failed to submit potential auxiliary block: {"code":-1,"message":"ReadCompactSize() : size too large"}]

JSON.stringify(_this.auxes[aux].rpcData) ==

{"hash":"a3c06a36c9cf65d125b6925a76273a9ac86228579c371a6d458dabafc9974c7b","chainid":20,"previousblockhash":"eb663e92c88c8e6eac8adcef34428d5ddbcc459b01b07975dce4d8e77fd4f506","coinbasevalue":1000000000,"bits":"1a0102bd","height":1235548,"target":{}}

auxpow.toString('hex') ==

01000000777a9158010000000000000000000000000000000000000000000000000000000000000000ffffffff53033c5204062f503253482f044c7a915808fabe6d6da3c06a36c9cf65d125b6925a76273a9ac86228579c371a6d458dabafc9974c7b010000000000000028000000ada078000d2f6e6f64655374726174756d2f0000000002b066db0300000000232102b9fde2984b8c99b2f997f5b3170240906374f23db0d0541a33777324b84e9672ac90fa0100000000001976a9140cd758396c2cfac9ec10f7364ed0fb8fd11dd87588ac000000007b77d820c3c766c48e0e92f70c3d5484cc615c4f51dade1a2c000000000000000000000000000000000001000000b1fe8e7fddf2ecfa351b2451942b68a4d0df27330ad154b3572bc77c4fd9b76dfd8055df9b0253d9b998401d659a7cabdef512adbdea0b4217d658136e7b7609777a915866980719a7096b80

Peercoin can decode this ^ Auxpow coin cannot. This is the serialized auxpow found.

@Infernoman
Copy link
Member Author

If all this needs is a bigger bounty that's no issue. It will provide a huge benefit to a few different communities. Make merge mining a bit more accessible to mid sized users that run their own pools. And provide a hashrate increase across the auxpow coins, from the hash being pointed toward peercoin/clones

@Infernoman
Copy link
Member Author

Infernoman commented Feb 17, 2017

auxpow.string can also be split into two parts,

01000000777a9158010000000000000000000000000000000000000000000000000000000000000000ffffffff53033c5204062f503253482f044c7a915808fabe6d6da3c06a36c9cf65d125b6925a76273a9ac86228579c371a6d458dabafc9974c7b010000000000000028000000ada078000d2f6e6f64655374726174756d2f0000000002b066db0300000000232102b9fde2984b8c99b2f997f5b3170240906374f23db0d0541a33777324b84e9672ac90fa0100000000001976a9140cd758396c2cfac9ec10f7364ed0fb8fd11dd87588ac000000007b77d820c3c766c48e0e92f70c3d5484cc615c4f51dade1a2c0000000000000000000000000000000000

is the peercoin transaction. and im guessing this is what needs some attention.

01000000b1fe8e7fddf2ecfa351b2451942b68a4d0df27330ad154b3572bc77c4fd9b76dfd8055df9b0253d9b998401d659a7cabdef512adbdea0b4217d658136e7b7609777a915866980719a7096b80

^ not quite sure which this is yet, either branchProof or headerBuffer

Could it be possible the header buffer needs some attention now? since I believe the coinbase buffer was already modified?

@Infernoman
Copy link
Member Author

After making the most recent changes on the peercoin-aux branch blocks are STILL failing to submit after stripping the timestamp from the hash.

2017-02-22 06:49:04 CBlock(hash=8f7561f50a8c8702854d9dad3e7fec996e5dbe032da8e3bdd6497224127116b2, ver=1310978, hashPrevBlock=b9bf02677ee4f1296af870b671720a432c417abee9d646636fe17e09299df29c, hashMerkleRoot=726d93bfb5d714fca45be4be3b3c2e2a70abbf804be854e0b5136bf18c9f7e1b, nTime=1487746054, nBits=1a011d6d, nNonce=0, vtx=1)
  CTransaction(hash=726d93bfb5, ver=1, vin.size=1, vout.size=2, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, 4294967295), coinbase 03434a130101)
    CTxOut(nValue=5.00000000, scriptPubKey=OP_DUP OP_HASH160 6c042008097d)
    CTxOut(nValue=5.00000000, scriptPubKey=OP_DUP OP_HASH160 0fa370766a94)

  vMerkleTree:  726d93bfb5d714fca45be4be3b3c2e2a70abbf804be854e0b5136bf18c9f7e1b

2017-02-22 06:49:04 generated 5.00
2017-02-22 06:49:04 ERROR: Aux POW merkle root incorrect
2017-02-22 06:49:04 ERROR: CheckProofOfWork : AUX POW is not valid
2017-02-22 06:49:04 ERROR: CheckBlockHeader() : proof of work failed
2017-02-22 06:49:04 ERROR: ProcessNewBlock : CheckBlock FAILED
2017-02-22 06:49:04 ERROR: CrownMiner : ProcessNewBlock, block not accepted

@Infernoman
Copy link
Member Author

Infernoman commented Feb 22, 2017

A regular block being submitted. that accepts. is around 12 characters shorter than the peercoin block with the timestamp stripped. So i'm still missing something. But what is it...

mazacoin block

01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff5303968b0b062f503253482f04204fad5808fabe6d6db423a8b409de38a3f713c39748a85aa5c656f558cdbabbbb3281758beea886ae010000000000000030000000bccc6a010d2f496e6665726e6f706f6f6c2f0000000002005441d1160000001976a914e903907c57a5fbb37fe409d2e270990c9e92597d88ac00943577000000001976a914b3a57b86fb02bc344c8a48426772d1f16bd1778b88ac000000001bbc8b056a35692e4c4b349ccec181550907d6b5660b8aff030100000000000000000000000000000000030000006d4d316322213311e9ed6629ee5b2c8579dc36ca583e98e24d000000000000009e85b3c0b1b03e75a441ae8ec320255b29107aebbc1156f95e06296d5a5790b0464fad58d3f6011ad542291a
01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff53033c5204062f503253482f044c7a915808fabe6d6da3c06a36c9cf65d125b6925a76273a9ac86228579c371a6d458dabafc9974c7b010000000000000028000000ada078000d2f6e6f64655374726174756d2f0000000002b066db0300000000232102b9fde2984b8c99b2f997f5b3170240906374f23db0d0541a33777324b84e9672ac90fa0100000000001976a9140cd758396c2cfac9ec10f7364ed0fb8fd11dd87588ac000000007b77d820c3c766c48e0e92f70c3d5484cc615c4f51dade1a2c000000000000000000000000000000000001000000b1fe8e7fddf2ecfa351b2451942b68a4d0df27330ad154b3572bc77c4fd9b76dfd8055df9b0253d9b998401d659a7cabdef512adbdea0b4217d658136e7b7609777a915866980719a7096b80

^ peercoin block with timestamp removed ^

@Infernoman
Copy link
Member Author

@ahmedbodi let me know when you have some time in between work. I'll up the bounty on this. You probably have a better understanding than i do.

@M8BWNN
Copy link

M8BWNN commented Apr 7, 2017

i worked some days on this. i think it will not work.

as we all know, a miner builds the coinbase transaction ( with the help of extranonce ). this coinbase is different in POS-coins ( https://wiki.novaco.in/en/Transaction/ ): after the first 4 bytes there is a 4 byte timestamp ( and there is an additional script and the end, but this should be no problem ).

no NON-POS coin expects this timestamp - it can not read that coinbase and gives an error while submitting ( {"result":null,"error":{"code":-1,"message":"ReadCompactSize() : size too large: iostream error"} ). so unless the child coins care about this, there is no way to import this coinbase to another coin.

one workaround would be to remove the timestamp. now the daemons can read the auxblock ( {"result":false,"error":null} ). but it is not valid as a change in the string alters its hash and so the merkle root . difficulty und blockhash are no longer valid.

another idea was two create a second coinbase tx (with zero outputs? with a static extranonce..), which is valid for the child chain and sent like a normal tx to the miner. so it gets inculded in merkle tree. but two coinbases in one block is probably forbidden ( https://en.bitcoin.it/wiki/Protocol_rules#.22block.22_messages ). it is also not possible to remove it after computation - this would change merkle root again.

so this mining stuff is really robust and hardened against attacks.. so we can not cheat the system..

PS: the only combination i can think of: Peercoin as master and Emercoin as child. It has POS and is merge mined. But the diff is really high, i can not test that spontaneously ( and profit is very low for that coin! )

a2hill pushed a commit to a2hill/node-merged-pool that referenced this issue Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants