Select Page

# Resources

## General parameters

• 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;
• Smallest amount: 0.00000001 RIC, or 1 riemann;
• 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).

Current projects, needs and discussions

## 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.

### Superblocks

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.

The Superblock system will be removed in the second fork. While records have indeed been broken this way, it also has significant drawbacks, like freezing the network during an hour every week and a complicated implementation that also confuses a lot of people, asking again and again why the rewards are lowered or why the miner suddenly mines much slower. After the fork, the possibility to look for longer tuples and break records this way will in some way replace this feature.

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 `getblockhash 1000000`.

### Example

Lets parse the block 1000000. Its hash is `0782988fb7c15f1254c2b76b34a3dfdf99620829bc757abc4e90e00800f79861` and with `getblockheader`, we get its raw block header:

`02000000e5f387ef33ae894a6e13ab37e1c3cd35d6e25db824f20bdf4a3f4952`
`e2c8c3e88a1d76d33c0279fb538765e3638572f65165ff9646d89d3b5a40879d`
`5cb653fd4ff3095c00000000003c05023335aac7c401c3ef938b0e0673b55573`
`50240d47cad658c0e478d8988843fa4e`

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 weird encoding and it is not trivial to decode it:
• Reverse the Endianness: `02053c00`;
• Make a bitwise and with the 0x007fffff mask: `00053c00`;
• Divide this by 256: `53c`, which is in decimal 1340.
• `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…

## PoW implementation

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.