Skip to content
John Tromp edited this page Feb 19, 2021 · 18 revisions

Block Header

General format of a Block Header in a MimbleWimble/Grin:

Field Description Size
version Version of the block 2 bytes
height Height of this block since the genesis block (height 0) 8 bytes
timestamp Timestamp at which the block was built 8 bytes
prev_hash Hash of the block previous to this in the chain 32 bytes
prev_root Root hash of the header MMR at the previous header 32 bytes
output_root Merkle root of all the commitments in the TxHashSet 32 bytes
range_proof_root Merkle root of all range proofs in the TxHashSet 32 bytes
kernel_root Merkle root of all transaction kernels in the TxHashSet 32 bytes
total_kernel_offset Total accumulated sum of kernel offsets since genesis block. 32 bytes
output_mmr_size Total size of the output MMR after applying this block. 8 bytes
kernel_mmr_size Total size of the kernel MMR after applying this block. 8 bytes
Sub-Total: 226 bytes
- - -
pow Proof of work data For cuck(AR)oo 29: 174 bytes.
For cuck(AT)oo 31: 184 bytes.
For cuck(AT)oo 32: 189 bytes.
Total:
400 bytes for C29
or 410 bytes for C31
or 415 bytes for C32

PoW

General format of a Proof Of Work in a MimbleWimble/Grin:

Field Description Size
total_difficulty Total accumulated difficulty since genesis block 8 bytes
secondary_scaling Variable difficulty scaling factor for secondary proof of work 4 bytes
nonce Nonce increment used to mine this block. 8 bytes
proof Proof of work data edge_bits: 1byte
cuckoo_solution of C29: 42∗29 bits=153 bytes
cuckoo_solution of C31: 42∗31 bits=163 bytes
cuckoo_solution of C32: 42∗32 bits=168 bytes
Sub-Total: 174 bytes for C29 and 184/189 bytes for C31/C32

Example

Here is a principle example of a MimbleWimble/Grin block header. The very first Cuckatoo32 block on mainnet chain block: 430112. https://grinscan.net/block/430112

Offset Field Hex Value
0 version 0002
2 height 0000000000069020
10 timestamp 000000005dc96cbf
18 prev_hash 00000129112e9b07770d2a14eab26006da0ecf2947dbfd20c522f45f3ac95e13
50 prev_root b211dedfb9a3644e5db0a1c2631d090e2bf33817002b76e442c242c2999eb090
82 output_root 54864c65172d55846c6a478aee8c3bb03047a4b768944eeb2e1f32a10a815523
114 range_proof_root 9022b292b308d104af54662643505c7ae80c182b41c2dc0c4bccd3de0bd39cc7
146 kernel_root 9300bccf4796b80e2feb509f08ea4817fcc1ce241a4e2e3287eee589f6855fef
178 total_kernel_offset cb1299bccfe1b99ce989a71b2ae8529931767f80269b1adbcbab5e6f1bee099c
210 output_mmr_size 0000000000465600
218 kernel_mmr_size 0000000000265e38
226 total_difficulty 00046c9f5c61a1e3
234 secondary_scaling 00000248
238 nonce b45e24f0d020cef8
246 edge_bits 20
247 edge_nonces 71030000df6d270503fa270adbf94a0b6034dd10608e0e13eb2fba17d1780b1fe881b729e5864b2c28f18538a084de39a77e313ccf6823471dca8d56b20d656b9b5f17827caaca8b4d0efd8efa203099e45136a17abbc3aa1d6c30ab4394dab3b01f28b516acc1b5868879b639d739b95adff3bf652844c235c081c927b38fca66393bd805b091d8aa40f2db7a408ddd4047e6df8531eedfcf80e4ea308bd0eee2b7ebf4b3c131fb
415

Description

To reproduce the proof of work for block 430112 with the reference cpu lean solver available as a grin-miner plugin, compile and run

$ time ./lean32x8 -x 00020000000000069020000000005dc96cbf00000129112e9b07770d2a14eab26006da0ecf2947dbfd20c522f45f3ac95e13b211dedfb9a3644e5db0a1c2631d090e2bf33817002b76e442c242c2999eb09054864c65172d55846c6a478aee8c3bb03047a4b768944eeb2e1f32a10a8155239022b292b308d104af54662643505c7ae80c182b41c2dc0c4bccd3de0bd39cc79300bccf4796b80e2feb509f08ea4817fcc1ce241a4e2e3287eee589f6855fefcb1299bccfe1b99ce989a71b2ae8529931767f80269b1adbcbab5e6f1bee099c00000000004656000000000000265e3800046c9f5c61a1e300000248b45e24f0d020cef8
Looking for 42-cycle on cuckatoo32("00020000000000069020000000005dc96cbf00000129112e9b07770d2a14eab26006da0ecf2947dbfd20c522f45f3ac95e13b211dedfb9a3644e5db0a1c2631d090e2bf33817002b76e442c242c2999eb09054864c65172d55846c6a478aee8c3bb03047a4b768944eeb2e1f32a10a8155239022b292b308d104af54662643505c7ae80c182b41c2dc0c4bccd3de0bd39cc79300bccf4796b80e2feb509f08ea4817fcc1ce241a4e2e3287eee589f6855fefcb1299bccfe1b99ce989a71b2ae8529931767f80269b1adbcbab5e6f1bee099c00000000004656000000000000265e3800046c9f5c61a1e300000248b45e24f0d020cef8",12996866191340392184) with trimming to 24 bits, 2 threads
Using 512MB edge and 512MB node memory, and 8-way siphash
cg.bytes 536870912 NEDGES/8 536870912
nonce -803156232 k0 k1 k2 k3 559a5c96c3567a41 54f8565e6e6f5cdb bcca9fedbbfe39ed f59465d6692f3047
95 trims completed  1753309 edges left
  2-cycle found
  42-cycle found
Time: 455187 ms
Solution 371 5276ddf a27fa03 b4af9db 10dd3460 130e8e60 17ba2feb 1f0b78d1 29b781e8 2c4b86e5 3885f128 39de84a0 3c317ea7 472368cf 568dca1d 6b650db2 82175f9b 8bcaaa7c 8efd0e4d 993020fa a13651e4 aac3bb7a ab306c1d b3da9443 b5281fb0 b5c1ac16 b6798886 b939d739 bff3df5a c2442865 c981c035 ca8fb327 d83b3966 d891b005 dbf240aa dd8d407a dfe64740 dfee3185 eae480cf eed08b30 f4ebb7e2 fb31c1b3
Verified with cyclehash 00004c782afccb4ea6dee4579e3e2a23e2e6379b2a34502856811a78c58c15f3
1 total solutions

real	7m15.781s
user	14m0.621s
sys	0m3.623s

We can check that the next block has that cyclehash as prev_hash.

Clone this wiki locally