simplecrypto / powerpool

A Python gevent driven stratum mining server
BSD 2-Clause "Simplified" License
48 stars 71 forks source link

[DRK] do not modify coinbasevalue in generate_job #124

Closed UdjinM6 closed 9 years ago

UdjinM6 commented 9 years ago

This addresses https://github.com/simplecrypto/powerpool/issues/123

crackfoo commented 9 years ago

@ahmedbodi can you please merge this properly with yours

crackfoo commented 9 years ago

With that change the block value is not inserted into the DB correctly. It is logged as full value not without the MN payment...

Found 1 hour, 33 minutes ago Currency Darkcoin (DRK) Algorithm X11 Coinbase Value 4.64 DRK (with 0.000000 in fees) Difficulty 4,184.51 Block Hash 00000000000aa5c3f0637c4dbbd43d97bba917b0941f5c0a31aa21bc986afdf5 Blockheight 222,155

crackfoo commented 9 years ago
    "address" : "XyLz1jG5mUy93hK1QDcPZ6DqDqLvWdEF4A",
    "category" : "immature",
    "amount" : 2.90178575,
    "confirmations" : 32,
    "generated" : true,
    "blockhash" : "00000000000aa5c3f0637c4dbbd43d97bba917b0941f5c0a31aa21bc986afdf5",
crackfoo commented 9 years ago
2015-02-18 05:53:48,340 [MonitorAuxNetwork_Unitus] [INFO] New UIS Aux block at height 60434
02000000d2d894532018d75e546a42d969c66c1a6b6a82e5d036528e4549040000000000ffcfc61e7578462288c994a7f4fd91594c093920efb44ae2ff2d53ff3727b728ef6ee4544da90f1b432911000102000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3903cb63032cfabe6d6dfd7c19392b3e698f9a76aa922da7972270e20b88ff1ebcdb24d8157a6f6881b90100000000000000d9baac00d7000000000000000204aa600a000000001976a9140fc3cf78f09ecea2b4cce2c74b56761f0bbf836e88ac0fc64b11000000001976a914f8896712b20f116f6b9548010043b05a8fc2930388ac0000000000
2015-02-18 05:53:48,501 [MonitorNetwork_DARKCOIN] [INFO] DRK BLOCK 00000000000aa5c3f0637c4dbbd43d97bba917b0941f5c0a31aa21bc986afdf5:222155 accepted by 127.0.0.1:5124
2015-02-18 05:53:48,501 [MonitorNetwork_DARKCOIN] [INFO] Recording block submission outcome True after 0.16185092926
2015-02-18 05:53:48,501 [MonitorNetwork_DARKCOIN] [Level 35] Valid network block identified!
2015-02-18 05:53:48,501 [MonitorNetwork_DARKCOIN] [INFO] New block at height 222155 with hash 00000000000aa5c3f0637c4dbbd43d97bba917b0941f5c0a31aa21bc986afdf5 and subsidy 464285715
2015-02-18 05:53:48,511 [PowerPool] [INFO] Recieved new command DARKCOIN getblocktemplate signal=1 __spawn=1

2015-02-18 05:53:48,525 [MonitorAuxNetwork_Unitus] [INFO] UIS BLOCK fd7c19392b3e698f9a76aa922da7972270e20b88ff1ebcdb24d8157a6f6881b9:60434 accepted after 0.185753107071
2015-02-18 05:53:48,557 [MonitorNetwork_DARKCOIN] [INFO] Push block signal notified us of a new block!
2015-02-18 05:53:48,557 [MonitorNetwork_DARKCOIN] [INFO] Paying out masternode at addr Xxs7GvaJXdyDjaydqgVACsZjAR8unjuRVz. Payout 174178390. Blockval 464475715
2015-02-18 05:53:48,558 [MonitorNetwork_DARKCOIN] [INFO] FLUSH: New block template with 5 trans. Diff 4,378.7147. Subsidy 4.64. Height 222,156. Merged: UIS
2015-02-18 05:53:48,558 [MonitorNetwork_DARKCOIN] [INFO] New main network block announced! Wiping previous jobs and pushing
2015-02-18 05:53:48,559 [MonitorNetwork_DARKCOIN] [INFO] Paying out masternode at addr Xxs7GvaJXdyDjaydqgVACsZjAR8unjuRVz. Payout 174178390. Blockval 464475715
UdjinM6 commented 9 years ago

@Fcases @crackfoo fixed block total_value calculation in latest commit so coinbase will stay unmodified now while block total_value will be decreased by MN payout. Please try it now.

UdjinM6 commented 9 years ago

@Fcases you are correct, it's 37.5% now. But it takes _payeeamount from getblocktemplate rpc data first which is calculated by darkcoind itself so you should never hit "coinbase/5". Anyway this PR is not about fixing 20%, it's about cases where coinbase value gets decreased many times leading to incorrect calculations of final coinbase tx. At least that's how I understood where @crackfoo problems came from.

UdjinM6 commented 9 years ago

Ahh.. I though I could modify it, oh well.. I'm not very familiar with the way this pool works (and python in general tbh), just trying to figure out and help. So there is another attempt to find a workaround, give it a try pls.

crackfoo commented 9 years ago

Hrmm ok. So only 2 changes then to the original file?

crackfoo commented 9 years ago

looks like the latest updates/changes are ok. Just found a block and was inserted properly and not orphaned.

Coinbase Value 3.48 DRK (with 0.000000 in fees) Difficulty 2,844.90 Block Hash 0000000000117cd4a2386dabc19ab8710afac961b1356c0a6b84350878deecc1 Blockheight 222,427

XsBnFfVrUiEEWwutDbKEHvEVLheyAwY96J: 2.08928568 (MN) XyLz1jG5mUy93hK1QDcPZ6DqDqLvWdEF4A: 3.4821429 (Pool Wallet)

crackfoo commented 9 years ago

Will let it roll for a few more blocks to know for sure.

ericecook commented 9 years ago

@UdjinM6 Good catch. I won't have time to play with this until the weekend, but it looks pretty much correct. A cleaner way to do it would be to set a new variable and use that, rather than modifying the coinbase again at the end.

crackfoo commented 9 years ago

So far so good testing the changes. Rewards are logged appropriately and blocks are not orphans. 5 good blocks since the changes.

Thanks @UdjinM6

icook commented 9 years ago

@ericecook To confirm, it looks like the change in darkcoin that occured was coinbasevalue from GBT now automatically removes the payee_amount? And in theory, payee_amount is probably always present? I guess I need to dig up the darkcoin stratum mining changes to confirm.

If that's the case the much cleaner solution would be to simply remove 369 I think.

If so I'll do that and merge.

ericecook commented 9 years ago

@icook I'm not sure if that is the case, but regardless we need something similar to 369 because as UdjinM6 pointed out it is quite possible for this code to be run multiple times in between GBT - which causes the coinbase value to be incorrectly decremented (monitor_network.py LN 370)

ericecook commented 9 years ago

@icook I looked it up, the stratum code still splits it out of the coinbase - so I went ahead and merged this w/ a few tweaks