Released on October 18, Grin Testnet 4 is the latest and supposedly last Grin test network. Among the other features announced such as BIP32 integration, this new release introduces a dual proof-of-work system. But what is it exactly? How does it work? In this post, we explain the motivations for this new mechanism and its inner working in details.

A bit of vocabulary

In order to understand this post, we’ll need to clearly define some of terms that we’ll used.

AF: short for A SIC F riendly.

short for SIC riendly. AR: short for A SIC R esistant.

short for SIC esistant. Cuckoo Cycle: a graph-theoretic proof-of-work created by John Tromp.

a graph-theoretic proof-of-work created by John Tromp. Cuckatoo Cycle: a variation of Cuckoo Cycle that aims to simplify ASICs.

a variation of Cuckoo Cycle that aims to simplify ASICs. Cuckaroo Cycle: a variation of Cuckoo Cycle designed to be AR.

a variation of Cuckoo Cycle designed to be AR. Edge Bits: the size of the edge indices in the Cuckoo/Cuckatoo/Cuckaroo Cycle graph.

the size of the edge indices in the Cuckoo/Cuckatoo/Cuckaroo Cycle graph. Secondary Scaling: an integer committed in each block header.

an integer committed in each block header. Target difficulty: difference between current block total difficulty and previous block total difficulty.

difference between current block total difficulty and previous block total difficulty. Total difficulty: accumulated target difficulty of all blocks in history.

Now that we defined the minimal vocabulary, we will explain the two PoW in details.

Why two Proof-of-Work?

You might have heard that Grin uses a Proof-of-Work called Cuckoo Cycle created by John Tromp.

Grin started with the idea that it should be mineable by everyone with the adequate hardware. However, Grin is also vulnerable to “secret ASICs” meaning that a well-funded ASICs manufacturers can develop a specialized machine to mine Grin secretly with an unfair advantage over small GPU miners.

While long term ASICs are inevitable and should be encouraged, secret mining at launch is something that must be avoided at all cost. This would place a single entity in control of a large percentage of the hashrate thus market cap on the cryptocurrency.

That’s why Grin introduced two proof-of-work algorithms. The primary one is designed to be ASIC friendly and the secondary one ASIC resistant. At launch, the secondary one PoW will represent approximately 90% of the blocks found while the primary one will be roughly 10%. This percentage will evolve such that in two years 100% of the blocks are mined with the primary PoW, thus encouraging ASICs manufacturers to develop a machine for the primary algorithm.

In the next section, we will detail the primary and secondary PoW as in Grin Testnet4.

Primary Proof-of-Work

The primary proof-of-work is designed to be ASIC friendly and is not expected to change in the future. ASICs manufacturers are encouraged to design specialized machine to mine it.

This PoW is ASIC Friendly (AF) in the sense of allowing huge efficiency improvements over a GPU by using hundreds of MB of SRAM, while remaining bottlenecked by memory IO.

Cuckatoo30+ is the primary proof of work on Grin testnet4. The + stands for the fact that miners can submit a larger edge bits solution (which requires more memory and more time but have a higher chance of acceptance) but the minimum size is 30.

For Mainnet, Grin will use Cuckatoo31+.

Secondary Proof-of-Work

This proof-of-work is the ASIC resistant one. Since ASICs are unavoidable for a given algorithm, this PoW will be tweaked every 6 months discourage ASICs manufacturers from building specialized hardware for it.

Testnet4 uses a placeholder PoW called Cuckatoo 29. This proof-of-work is the same as the primary one except that the edge bits is 29. However, blocks mined with this PoW have their difficulty calculated differently than the one mined with the primary one.

To compute the effective difficulty achieved by a secondary PoW solution, you’ll need to scale the solution difficulty with the secondary scaling in the block header.

Putting it all together

Now that we have our two PoW algorithms, we can explain how Grin can guarantee a Primary/Secondary blocks ratio.

Each block mined with the primary Proof-of-Work tends to increase the secondary scaling factor, meaning that every time a “primary” block is found it gets easier and easier to mine with the secondary proof-of-work algorithm.

In contrast, when a “secondary” block is found the secondary scaling factor tend to reduce. Which means that it gets harder to mine with the secondary PoW (since you need a higher solution difficulty to reach to the target difficulty) and easier to mine with the primary proof-of-work.

What about Mainnet POW?

For Mainnet, Grin will have two different Proof-of-Work algorithms:

Primary one will be Cuckatoo31+.

Secondary one will be Cuckaroo29.

What’s next?

Grin is still a work in progress cryptocurrency and contributions are more than welcome. Feel free to talk with the team on the Grin Forum to learn more about the dual PoW and Grin in general.

You can also subscribe to the Grin newsletter.

Thanks to John Tromp.