- Blocks every 2.5 minutes (150 seconds);
- Difficulty adjustment every 288 blocks (~12 h);
- Base block reward of 50 RIC, halving every 840000 blocks (~4 years);
- Maximum supply: 84 million RIC;
- Proof of Work: prime constellations (sextuplets);
- Addresses prefixes: with R (60, P2PKH), T (65, P2SH), ric (Bech32). For Testnet it is respectively r (122), t (127) and tric.
- RPC port 28332 (38332 for Testnet);
- P2P port 28333 (38333 for Testnet);
- Protocol version 10070001 and, magic number 0xdbb2bcfc (0x0511090d for Testnet).
See also other useful links below.
Proof of Work in detail
To be a good proof of work, it should be something which solutions are much harder to find than verify.
If the proof of work were just to “find a prime number of length n”, checking whether a number is actually prime is not much easier, so this would not be a good PoW. Validating blocks would be almost as hard as finding them…
A way to make finding (or, in our case, mining) much harder than verifying is to not just look for prime numbers, but prime constellations of length k: these are sequence of k prime numbers such that the difference between the first and last is the least possible. Indeed, increasing the length basically makes finding constellations exponentially harder, while verifying that the k numbers are part of a prime constellation will not be much more difficult. This is the PoW that Riecoin uses.
Ideally, we would want to have the biggest k possible, as it would make verification much easier compared to finding. However, too much would make mining too hard and force to find much smaller prime numbers, which is something that would also make GPU mining possible.
Gatra has chosen k = 6, because the known algorithms at this time were too slow for k = 7.
In summary, the Riecoin PoW is to find a prime constellation of length 6 with numbers having a certain size, and that size is the difficulty. A prime constellation of length 6 is a 6-tuple with the pattern (n, n + 4, n + 6, n + 10, n + 12, n + 16) such that all 6 numbers are prime.
Riecoin proposes a Superblock system, in which each week (or 4032 blocks), a block will be much harder (about 27.78 times) to solve than usual. Its aim is to beat more easily 6-tuple world records. The 144 blocks before and 143 blocks after it are in the other hand a bit easier to compensate. The superblock and the 287 surrounding have rewards adjusted, and currently have rewards of respectively 694.66666666 RIC and 22.66666666 RIC instead of 25 RIC.
The Riecoin network hardforked years ago at Block 160704 as this idea was not initially present. The first Superblock is Block 160848 and then the subsequent ones have a number of the form 160848 + 4032n.
While records have indeed been broken this way, it has been proposed to replace this system by the usage of a better constellation patterns for Riecoin. Indeed,
- The 6-tuples found will never be a part of a 7-tuple or longer. It would be better to accept a 4 or 5-tuple pattern which is compatible with constellations up to length 15. The mining difficulty (prime number sizes) will be much higher and occasionally we would find 5/6-tuples and rarely 6/7-tuples or longer (which should easily beat the current world records and increase a lot the Riecoin’s purpose). Longer tuples may be rewarded better and would in this case act as Superblocks;
- Each week the network gets stuck during in average 69.47 minutes in order to find the Superblock;
- The Superblock implementation confuses a lot of people as regularly, people ask “Why in some blocks there is 22,66666666, and not 25 ric?”…
Discussion opened here.
Block header in detail
A Riecoin block header has the following structure:
- 32 bits – stores the block version (this includes bits for softfork support signaling);
- 256 bits – stores the hash of the previous block;
- 256 bits – stores the Merkle Root of the block’s transactions;
- 64 bits – stores the block’s timestamp;
- 32 bits – stores the Difficulty;
- 256 bits – stores the PoW solution, see below (this field is often called nOffset or Nonce);
- Total: 896 bits/112 bytes
With Riecoin Core, you can get the raw header of a block using
getblockheader <block hash> false. To get the block hash knowing its number, use for example
Lets parse the block 1000000. Its hash is
0782988fb7c15f1254c2b76b34a3dfdf99620829bc757abc4e90e00800f79861 and with
getblockheader, we get its raw block header:
Let’s decompose it and parse it in detail:
02000000: it is the block version, in Little Endian. The value is 2 (or, 0x00000002);
e5f387ef33ae894a6e13ab37e1c3cd35d6e25db824f20bdf4a3f4952e2c8c3e8: the previous block hash (try to get the hash of the block 999999 and compare; beware the endianness!);
8a1d76d33c0279fb538765e3638572f65165ff9646d89d3b5a40879d5cb653fd: the Merkle Root of the block’s transactions (you can easily find literature on how to compute it);
4ff3095c00000000: the 64 bits timestamp, in Little Endian. The value is 1544155983 (or 0x000000005c09f34f). This corresponds to 2018-12-07, 04:13:03;
003c0502: the difficulty. For some reason, it uses a really weird encoding and it is not that easy to decode it:
- Reverse the Endianness:
- Make a bitwise and with the 0x007fffff mask:
- Divide this by 256:
53c, which is in decimal 1340.
- Reverse the Endianness:
3335aac7c401c3ef938b0e0673b5557350240d47cad658c0e478d8988843fa4e: the PoW solution, in an offset form.
In general, parsing such data is easy, but the endiannesses will often cause a lot of headaches…
The work is determined by the block header. Here is the mining process (see also the rieMiner source for details/actual implementation):
- The miner gets and parses the data (difficulty D, transactions,…) for the next block from a Riecoin node. With that, the miner creates a block header;
- It computes the sha256^2 hash (length of 256 bits) of the first 80 bytes of this block header (so without the offset, which is still not used anyway until a solution is found). Let’s call that hash S (an Endianness or similar operation may be applied to S to use it properly);
- The binary concatenation 1 . 00000000 . S . <D – 265 zeroes> (or equivalent arithmetic operations) is made, and this is the target T;
- The miner must now find X < 2^(D – 265) such that T + X is the first prime number of a prime constellation of the required pattern;
- If X is found, the Offset field of the block header is filled and the full block is submitted to the Riecoin node, which will verify that T + X is actually the first prime number of a prime constellation.
- The rieTools can help to understand better technical aspects with concrete code;
- Also see the Riecoin Core and rieMiner source code;
- The FAQ in the older website;
- Possible constellation patterns;
- Prime constellation world records, maintained by Tony Forbes;
- Our own records;
- Fast prime cluster search – or building a fast Riecoin miner (part 1), by David Andersen (dga): explains how (an algorithm) we can solve the Riecoin’s PoW. Unfortunately, he never published Part 2…