# Block

# What Is Block?

Blocks contain the header and transactions in the form of their IDs. Each block in Zarb has a unique certificate that is signed by committee members. A block will be committed if it has a valid certificate. Blocks are immutable and any changes in the block will invalidate the certificate.

# Block Header

The header includes the main information about the block.

type Header struct {
   Version             int     `cbor:"1,keyasint"`
   UnixTime            int64   `cbor:"2,keyasint"`
   LastBlockHash       Hash    `cbor:"3,keyasint"`
   StateHash           Hash    `cbor:"4,keyasint"`
   TxIDsHash           Hash    `cbor:"5,keyasint"`
   LastCertificateHash Hash    `cbor:"6,keyasint"`
   SortitionSeed       Seed    `cbor:"7,keyasint"`
   ProposerAddress     Address `cbor:"8,keyasint"`
}
  • Version starts from 1 for the mainnet and starts from 1001 for the testnet
  • UnixTime is the time of block in unix format (seconds from Unix Epoch)
  • LastBlockHash is the hash of the previous block
  • StateHash is the state merkle root at the current height
  • TxIDsHash is the merkle root of the transaction IDs included in this block
  • LastCertificateHash is the hash of last block certificate. This ensures that the previous block has a valid certificate
  • SortitionSeed is the seed for the sortition algorithm and must be signed by the proposer
  • ProposerAddress is the address of block proposer

# Transaction IDs

TxIDs contain the list of transaction IDs in the block.

type TxIDs struct {
   IDs []tx.ID `cbor:"1,keyasint"`
}

Transactions in Zarb are stamped, therefore, there is no need to store the transaction body inside the block. Saving ID is fair enough.

# Example

Hers is an example of a block header data:

000000   A8 01 01 02 1A 60 6C F6  C8 03 58 20 B7 79 1C 69   ¨....`löÈ.X ·y.i
000010   19 7A 15 36 0D 20 AB A0  C8 22 DC 2B 83 EE A7 00   .z.6. « È"Ü+.î§.
000020   26 E3 30 A1 84 4A 32 02  0A 5D C3 03 04 58 20 DD   &ã0¡.J2..]Ã..X Ý
000030   C8 A4 B3 BF 95 E4 7E 68  55 DC D7 6D 67 90 E3 29   È¤³¿.ä~hUÜ×mg.ã)
000040   03 B8 9C E1 FB EA F8 F1  FC BD 51 89 BC D5 DA 05   .¸.áûêøñü½Q.¼ÕÚ.
000050   58 20 E8 55 44 E7 71 D1  AE 60 57 E9 99 A2 02 72   X èUDçqÑ®`Wé.¢.r
000060   5E 11 51 A1 5D 81 FE 96  81 07 5B B9 11 BE 7B 24   ^.Q¡].þ...[¹.¾{$
000070   6F CD 06 58 20 FA 52 7F  78 B7 88 25 DC A6 B9 77   oÍ.X úR.x·.%ܦ¹w
000080   27 86 D8 86 96 6A DF DE  66 C8 4E DB 67 A3 4F CF   '.Ø..jßÞfÈNÛg£OÏ
000090   AE 29 1D 0A 49 07 58 30  A8 37 49 6E EC 94 29 D0   ®)..I.X0¨7Inì.)Ð
0000A0   99 D0 75 93 02 30 03 47  CD 2E 0C 84 09 FC 5B 01   .Ðu..0.GÍ....ü[.
0000B0   38 15 99 F9 4B ED 93 37  B8 17 0E 6B 1E 0F 6A CD   8..ùKí.7¸..k..jÍ
0000C0   5A CB BF 0C 85 B7 1F 04  08 54 43 6D 9A 52 FD 0E   ZË¿..·...TCm.Rý.
0000D0   4C 60 CA 8D D8 9F 75 10  58 CF F4 0E DE E0         L`Ê.Ø.u.XÏô.Þà

Which can be interpreted in CBOR (opens new window) format:

{
  1: 1,
  2: 1617753800,
  3: h'B7791C69197A15360D20ABA0C822DC2B83EEA70026E330A1844A32020A5DC303',
  4: h'DDC8A4B3BF95E47E6855DCD76D6790E32903B89CE1FBEAF8F1FCBD5189BCD5DA',
  5: h'E85544E771D1AE6057E999A202725E1151A15D81FE9681075BB911BE7B246FCD',
  6: h'FA527F78B78825DCA6B9772786D886966ADFDE66C84EDB67A34FCFAE291D0A49',
  7: h'A837496EEC9429D099D0759302300347CD2E0C8409FC5B01381599F94BED9337B8170E6B1E0F6ACD5ACBBF0C85B71F04',
  8: h'436D9A52FD0E4C60CA8DD89F751058CFF40EDEE0'
}

Block hash is the hash of the header in binary format. For this example, the block hash is:

0x0ca12eee3c791ba4b78439448d59a4b817d1eaec10aa090ea40f9af3d43e6e2b