# On dual PoW, Graph rates, gps, and Difficulty

**URL:** https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144
**Category:** Mining
**Created:** [January 14, 2019, 4:16pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144 "2019-01-14T16:16:34Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)
#### Post date: [January 14, 2019, 4:16pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/1 "2019-01-14T16:16:35Z")

</div>

With two different PoWs, and a time varying balance of block rewards between the two, Grin is not your average blockchain. This post will try to relate the network difficulty to the various Graph rates, in units of graphs-per-second. For simplicity, we’ll pretend that the primary PoW is is just Cuckatoo31, i.e. no-one is mining Cuckatoo on graphs with more than 2^31 edges.

In order to solve a block, you pick either PoW, and you pick a nonce, which, together with the rest of the header, determines a graph.

In this graph you then look for a 42-cycle. You need some luck here, since the expected number of L-cycles in a random graph is 1/L. Once you find a 42-cycle, you compute the cyclehash, which is the hash of the (sorted) 42 edge indices.

Now, in the hashcash PoW of most other coins, you would test whether this hash, interpreted as a huge 256-bit number, is below a target, in which case you solved the block. The difficulty is inversely proportional to the target, so higher difficulty corresponds to lower targets (you can see that it’s harder for a random hash to fall below a lower target).

In Grin we use difficulties directly, and skip the notion of a target. We convert the cyclehash into a solution difficulty, and test whether this is at least the network difficulty. The conversion depends on the choice of PoW though.

For the primary Cuckatoo31, the solution difficulty is the weight of 2^31 edges, 7936, divided by the cyclehash interpreted as a fraction in the interval (0,1).

For the secondary Cuckaroo29, the solution difficulty is the secondary scale, divided by the cyclehash interpreted as a fraction in the interval (0,1).

Again we have that the smaller the cyclehash, the higher the solution difficulty, and the more likely we pass the difficulty test.

With Cuckaroo29, the likelihood is also proportional to the secondary scale. This variable acts like a control knob, that is used to either dial up or dial down the rate of blocks solved by the secondary PoW, in order to achieve the desired balance.

And now for some math. Denote

PR31 = Primary Rate = global rate of Cuckatoo31 graphs per second  
W31 = weight of a Cuckatoo31 graph = 31 \* 2^8 = 7936  
SR29 = Secondary Rate = global rate of Cukatoo29 graphs per second  
S29 = ar\_scale = secondary scale = variable scale of a Cukatoo29 graph  
BR31 = rate of primary blocks  
BR29 = rate of secondary blocks  
ND = Network Difficulty

We have BR31 = (PR31 / 42) \* (W31 / ND), BR29 = (SR29 / 42) \* (S29 / ND),  
for a combined block rate of BR31 + BR29 = (PR31 \* W31 + SR29 \* S29) / (42 \* ND) which should ideally equal 1/60. So assuming the system has achieved equilibrium, we have

ND = (60/42) \* (PR31 \* W31 + SR29 \* S29)

and at launch, when the secondary reward rate should be 90%, we have

(SR29 \* S29) / (PR31 \* W31) = 90% / 10%

This allows us to compute graph rates from network difficulty, secondary scale, and the current reward balance:

SR29 = ND \* (42 / 60) \* 90% / S29

PR31 = ND \* (42 / 60) \* 10% / W31

Also see the related post [https://forum.grin.mw/t/what-to-mine-choosing-between-cuckatoo31-and-cuckaroo29](https://forum.grin.mw/t/what-to-mine-choosing-between-cuckatoo31-and-cuckaroo29)

---

<div class="post-metadata">

### Author: ![xiaojay](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/xiaojay/32/858_2.png) [@xiaojay](https://forum.grin.mw/u/xiaojay)
#### Post date: [January 15, 2019, 4:00am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/2 "2019-01-15T04:00:54Z")

</div>

Great and clear explanation. Thank you, tromp.

and is the expected srs (the secondary reward rate) decreasing in the below way ?  
srs = max(0, 90 - int(height / NUM\_BLOCKS\_WEEK)), which NUM\_BLOCKS\_WEEK = 7 \* 60 \*24

---

<div class="post-metadata">

### Author: ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)
#### Post date: [January 15, 2019, 8:12am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/3 "2019-01-15T08:12:23Z")

</div>

No, the reward balance function is at

> <https://github.com/mimblewimble/grin/blob/ba994248ac7f4e4e9e24abb5c654051f81862779/core/src/consensus.rs#L61-L65>

---

<div class="post-metadata">

### Author: ![csga5000](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/csga5000/32/927_2.png) [@csga5000](https://forum.grin.mw/u/csga5000)
#### Post date: [January 16, 2019, 7:30am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/4 "2019-01-16T07:30:05Z")

</div>

@tromp Does the formula SR29 = ND \* (42 / 60) \* 90% / S29 get affected by the fact that AR29 is being awarded like 98% of blocks right now?

You say assuming the system has achieved equilibrium does that mean the hash formula is inaccurate right now?

---

<div class="post-metadata">

### Author: ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)
#### Post date: [January 16, 2019, 9:10am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/5 "2019-01-16T09:10:30Z")

</div>

The system has clearly not reached equilibrium yet, with ar\_scale on a downward trajectory to improve odds for Cuckatoo31 miners. So right now we have almost

SR29 = ND \* (42 / 60) \* 100% / S29

as the primary contribution is negligible…

---

<div class="post-metadata">

### Author: ![csga5000](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/csga5000/32/927_2.png) [@csga5000](https://forum.grin.mw/u/csga5000)
#### Post date: [January 16, 2019, 2:43pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/6 "2019-01-16T14:43:04Z")

</div>

Thanks tromp. That’s what I was thinking but my coworker seemed fairly certain you should still use the constant NOT the observed secondary award rate

---

<div class="post-metadata">

### Author: ![timolson](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/timolson/32/494_2.png) [@timolson](https://forum.grin.mw/u/timolson)
#### Post date: [January 16, 2019, 5:12pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/7 "2019-01-16T17:12:59Z")

</div>

Since there are no ASIC’s, the rewards should reach an equilibrium where the $/day for a GPU will be the same whether you mine Roo or Too. There might be a small premium on Too since fewer cards can mine it right now, which creates some friction. But I expect the 90/10 idea to disappear with GPU market dynamics. It will mostly level out on a $/day per GPU basis.

---

<div class="post-metadata">

### Author: ![csga5000](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/csga5000/32/927_2.png) [@csga5000](https://forum.grin.mw/u/csga5000)
#### Post date: [January 16, 2019, 5:53pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/8 "2019-01-16T17:53:58Z")

</div>

I don’t think that’s right, I agree the pheasbility will balance, but I do think 90/10 will still work because it will get harder to mine AR29 until the payout is the same. So you’re right except that we should still settle in at 9/10

---

<div class="post-metadata">

### Author: ![timolson](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/timolson/32/494_2.png) [@timolson](https://forum.grin.mw/u/timolson)
#### Post date: [January 16, 2019, 8:08pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/9 "2019-01-16T20:08:50Z")

</div>

I think we’re saying the same thing? The payout for any given GPU won’t be much different. If C31 is 10x slower, the difficulty will adjust until it has 10x the rewards. The 90/10 in the code simply means the “absolute” payouts will go to 90/10 based on the adjustment of network difficulty, but the market will adjust its hashrate until GPU profitability is the same for either PoW. Maybe C31 gets a little more like I said because not all GPU’s can mine it, therefore GPU’s that are good at C31 can get a premium on the payout.

---

<div class="post-metadata">

### Author: ![csga5000](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/csga5000/32/927_2.png) [@csga5000](https://forum.grin.mw/u/csga5000)
#### Post date: [January 16, 2019, 9:03pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/10 "2019-01-16T21:03:18Z")

</div>

Sounds like it. The thing that threw me off was when you said “the 90/10 idea will disappear with gpu market Dynamics”. I don’t think they ever expected that to represent profitability, just the intended number to be awarded. The profitability will in some sense go up when the 9:1 ratio approaches 0:10 but the miners will adjust by mining more AR31 so that profitability remains close.

---

<div class="post-metadata">

### Author: ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)
#### Post date: [January 16, 2019, 9:06pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/11 "2019-01-16T21:06:18Z")

</div>

> [@timolson](#):
>
> Maybe C31 gets a little more

It could get a lot more if for instance the 2080Ti hashpower is only 4% of the total. In order for them to take 10% of all rewards means that they enjoy a 2.5x premium. And the 1080ti, which is maybe 3x less efficient at C31 would still be better off sticking with C29.

---

<div class="post-metadata">

### Author: ![csga5000](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/csga5000/32/927_2.png) [@csga5000](https://forum.grin.mw/u/csga5000)
#### Post date: [January 16, 2019, 9:13pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/12 "2019-01-16T21:13:38Z")

</div>

I guess I speculate these giant farms might just upgrade (to 2080tis)- but a lot of them probably use exhisting infrastructure they have from mining other things

---

<div class="post-metadata">

### Author: ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)
#### Post date: [January 16, 2019, 9:15pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/13 "2019-01-16T21:15:29Z")

</div>

> [@csga5000](#):
>
> might just upgrade (to 2080tis)

Only after evaluating performance of the new 16 GB Vega…

---

<div class="post-metadata">

### Author: ![timolson](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/timolson/32/494_2.png) [@timolson](https://forum.grin.mw/u/timolson)
#### Post date: [January 16, 2019, 9:29pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/14 "2019-01-16T21:29:58Z")

</div>

> [@tromp](#):
>
> It could get a lot more if for instance the 2080Ti hashpower is only 4% of the total. In order for them to take 10% of all rewards means that they enjoy a 2.5x premium.

This would only be temporary. History shows that these discrepancies in the GPU market don’t last longer than 3 months, which is about the time for the GPU supply chain to react. The market for 1080Ti’s right now is ridiculous and constrained. If AMD releases that 16GB card in February…

I think the C31 premium could evaporate even faster as we see better C31 miners released that work on a wider variety of cards.

---

<div class="post-metadata">

### Author: ![timolson](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/timolson/32/494_2.png) [@timolson](https://forum.grin.mw/u/timolson)
#### Post date: [January 16, 2019, 9:37pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/15 "2019-01-16T21:37:18Z")

</div>

Nvidia cards are simply overpriced and I rarely hear of them being used in big farms. Nvidia targets the high-end gaming market, and AMD is the better value option. When you’re mining, margins are thin, and cheap is the way to go. From the current stats, the good ol’ 480’s and 580’s are currently the best $/H on capex, but I haven’t measured power.

---

<div class="post-metadata">

### Author: ![Neo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/neo/32/3365_2.png) [@Neo](https://forum.grin.mw/u/Neo)
#### Post date: [January 16, 2019, 9:38pm UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/16 "2019-01-16T21:38:16Z")

</div>

Re AMD’s Radeon VII

“[TweakTown](https://www.tweaktown.com/news/64501/amd-radeon-vii-less-5000-available-custom-cards/index.html) has reported that fewer than 5000 Radeon VII GPUs will be hitting the shelves come launch day, mid summer this year. According to its source, AMD will be making a net loss on each GPU sold to the consumer, as these are effectively just redeveloped M150 GPU accelerators originally designed for enterprise and data center use.”

---

<div class="post-metadata">

### Author: ![zphou](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@zphou](https://forum.grin.mw/u/zphou)
#### Post date: [January 17, 2019, 12:12am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/17 "2019-01-17T00:12:44Z")

</div>

I tried with 31 in the first 16 hours, results was not promising. I’m using Tesla-P40 with more than 12GB memory on the GPU. Due to the total blocks generated was very rare, so what I’ve got is also low.

---

<div class="post-metadata">

### Author: ![timolson](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/timolson/32/494_2.png) [@timolson](https://forum.grin.mw/u/timolson)
#### Post date: [January 17, 2019, 3:24am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/19 "2019-01-17T03:24:06Z")

</div>

To be clear, we’re talking about a theoretical premium on C31 that doesn’t exist yet. The two difficulties have not found market equilibrium yet…

---

<div class="post-metadata">

### Author: ![Rabinovitch](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/rabinovitch/32/1019_2.png) [@Rabinovitch](https://forum.grin.mw/u/Rabinovitch)
#### Post date: [January 17, 2019, 7:50am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/20 "2019-01-17T07:50:42Z")

</div>

So please make it clear for dummies: is there any reason to try mining on Cuckatoo 31 algo with GTX1070 GPUs? Will it be better for the network? Wil it be better in terms of miner’s profit?

---

<div class="post-metadata">

### Author: ![tromp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.grin.mw/tromp/32/22_2.png) [@tromp](https://forum.grin.mw/u/tromp)
#### Post date: [January 17, 2019, 7:53am UTC](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144/21 "2019-01-17T07:53:01Z")

</div>

> [@timolson](#):
>
> a theoretical premium on C31 that doesn’t exist yet.

The 2080Ti are already enjoying their premium on C31. As this post [https://forum.grin.mw/t/what-to-mine-choosing-between-cuckatoo31-and-cuckaroo29](https://forum.grin.mw/t/what-to-mine-choosing-between-cuckatoo31-and-cuckaroo29) explains, their premium amounts to

(GPS31 \* weight(31)) / (GPS29 \* ar\_scale)

and as long as ar\_scale is dropping, their premium is increasing further.

[Next page](https://forum.grin.mw/t/on-dual-pow-graph-rates-gps-and-difficulty/2144.md?page=2)
