What's in a Block?
A block is a set of transactions and consensus information that extend the state of the network. A block in Mina includes a proof that the current state of the network is fully valid.
A block in Mina is constituted of:
- Protocol state
- Protocol state proof
- Staged ledger diff
- Delta transition chain proof
- Current protocol version
- Proposed protocol version
When a node receives a block from a peer, it is first validated, applied to the existing state, and added to the node's transition frontier. If, according to the consensus rules, it results in increasing the length of the blockchain, the node's best tip is updated, and the root of the transition frontier is moved up to only maintain k
blocks in the transition frontier.
In Mina, blocks are synonymous with "transitions". When this transition (block) is received from a peer, it is referenced as an external transition, whereas one generated and applied locally is referred to as an internal transition.
Protocol State
The protocol state is comprised of the previous protocol state hash and a body that contains:
Each block contains the protocol state hash of the previous block, such that blocks may be linked together to form an immutable chain.
The protocol state hash is determined from the hash of hashes of the previous state and body and acts as a unique identifier for each block.
Genesis State Hash
The genesis state hash is the protocol state hash for the genesis protocol state.
Blockchain State
The blockchain state is comprised of:
- Staged ledger hash
- Snarked ledger hash
- Snarked next available token
- Genesis ledger hash
- Timestamp
Consensus State
The consensus state is comprised of:
- Blockchain length
- Epoch count
- Min window density
- Sub window density
- Last VRF output
- Total currency
- Current global slot
- Global slot since genesis
- Staking epoch data
- Next epoch data
- Has ancestor in same checkpoint window
- Block stake winner
- Block creator
- Coinbase receiver
- Supercharged coinbase
Consensus Constants
Constants define the consensus parameters:
- k
- delta
- slots_per_sub_window
- slots_per_window
- sub_windows_per_window
- slots_per_epoch
- epoch duration
- checkpoint_window_slots_per_year
- checkpoint_window_size_in_slots
- block_window_duration_ms
- acceptable network delay
- slot_duration_ms
- epoch_duration
- delta_duration
- genesis_state_timestamp
Protocol State Proof
The protocol state proof is a blockchain proof proving that the new protocol state generated by the block producer is valid. Due to the use of recursive SNARKs, this protocol state proof proves the entire history of the chain is valid.
Staged Ledger Diff
When a block producer wins a slot to produce a block, they select transactions and any SNARK work required from the transaction and SNARK pools. They create the proposed next state of the blockchain, which comprises creating a diff of the staged ledger. A diff consists of:
- Transactions included in the block
- A list of SNARK proofs generated by SNARK workers for prior transactions added
- Pending coinbase
A staged ledger can be regarded as a pending accounts database that has transactions(payments, coinbase, and proof fee payments) applied for which there are no SNARKs available yet. A staged ledger consists of the accounts state (a ledger) and a transaction queue for transactions without SNARK proofs, which is the scan state.
Delta Transition Chain Proof
There is an allowed network delay when broadcasting or gossiping newly produced blocks around the network to allow for adverse network conditions. The delta transition chain proof proves that the block was produced within the allotted slot time.
Example Block
{
"external_transition": {
"protocol_state": {
"previous_state_hash": "3NLKJLNbD7rBAbGdjZz3tfNBPYxUJJaLmwCP9jMKR65KSz4RKV6b",
"body": {
"genesis_state_hash": "3NLxYrjb7zmHdoFgBrubCN8ijM8v7eT8kvLiPLc9DHt3M8XrDDEG",
"blockchain_state": {
"staged_ledger_hash": {
"non_snark": {
"ledger_hash": "jxV4SS44wHUVrGEucCsfxLisZyUC5QddsiokGH3kz5xm2hJWZ25",
"aux_hash": "UmosfM82dH5xzqdckXgA1JoAvJ5tLxch2wsty4sXmiEPKnPTPq",
"pending_coinbase_aux": "WLo8mDN6oBUTSyBkFCy7Fky7Na5fN4R6oGq4HMf3YoHCAj4cwY"
},
"pending_coinbase_hash": "2mze7iXKwA9JAqVDC1MVvgWfJDgvbgSexKtuShdkgqMfv1tjATQQ"
},
"snarked_ledger_hash": "jx9171AbMApHNG1guAcKct1E6nyUFweA7M4ZPCjBZpgNNrE21Nj",
"genesis_ledger_hash": "jxX6VJ84HaafrKozFRA4qjnni4aPXqXC2H5vQLKSryNpKTXuz1R",
"snarked_next_available_token": "2",
"timestamp": "1611691710000"
},
"consensus_state": {
"blockchain_length": "3852",
"epoch_count": "1",
"min_window_density": "1",
"sub_window_densities": [
"3",
"1",
"3",
"1",
"4",
"2",
"1",
"2",
"2",
"4",
"5"
],
"last_vrf_output": "g_1vrXSXLhvn1e4Ap1Ey5e8yh3PFMJT0vZyhZLlTBAA=",
"total_currency": "167255800000001000",
"curr_global_slot": {
"slot_number": "12978",
"slots_per_epoch": "7140"
},
"global_slot_since_genesis": "12978",
"staking_epoch_data": {
"ledger": {
"hash": "jxX6VJ84HaafrKozFRA4qjnni4aPXqXC2H5vQLKSryNpKTXuz1R",
"total_currency": "165950000000001000"
},
"seed": "2vb1Mjvydod6sEwn7qpbejKCfRqugMgyG3MHXXRKcAkwQLRs9fj8",
"start_checkpoint": "3NK2tkzqqK5spR2sZ7tujjqPksL45M3UUrcA4WhCkeiPtnugyE2x",
"lock_checkpoint": "3NK5G8Xqn1Prh3XoTyZ2tqntJC6X2nVwruv5mEJCL3GaTk7jKUNo",
"epoch_length": "1769"
},
"next_epoch_data": {
"ledger": {
"hash": "jx7XXjRfJj2mGXmiHQmpm6ZgTxz14udpugyFtw4DefJFpie7apN",
"total_currency": "166537000000001000"
},
"seed": "2vavBR2GfJWvWkpC7yGJQFnts18nHaFjdVEr84r1Y9DQXvnJRhmd",
"start_checkpoint": "3NLdAqxtBRYxYbCWMXxGu6j1hGDrpQwGkBDF9QvGxmtpziXQDADu",
"lock_checkpoint": "3NL4Eis1pS1yrPdfCbiJcpCCYsHuXY3ZgEzHojPnFWfMK9gKmhZh",
"epoch_length": "2084"
},
"has_ancestor_in_same_checkpoint_window": true,
"block_stake_winner": "B62qpBrUYW8SHcKTFWLbHKD7d3FqYFvGRBaWRLQCgsr3V9pwsPSd7Ms",
"block_creator": "B62qpBrUYW8SHcKTFWLbHKD7d3FqYFvGRBaWRLQCgsr3V9pwsPSd7Ms",
"coinbase_receiver": "B62qpBrUYW8SHcKTFWLbHKD7d3FqYFvGRBaWRLQCgsr3V9pwsPSd7Ms",
"supercharge_coinbase": true
},
"constants": {
"k": "290",
"slots_per_epoch": "7140",
"slots_per_sub_window": "7",
"delta": "0",
"genesis_state_timestamp": "1609355670000"
}
}
},
"protocol_state_proof": "<opaque>",
"staged_ledger_diff": "<opaque>",
"delta_transition_chain_proof": "<opaque>",
"current_protocol_version": "1.1.0",
"proposed_protocol_version": "<None>"
}
}