--- title: What's in a block description: Description of the construction of a block in the Mina Protocol tags: mina --- :::danger Work in progress ::: # What's in a block A block in Mina, is a transition from the existing blockchain state to a new state. A block in Mina is constituted of: * [Protocol state](https://hackmd.io/1eAeF2K1RaaL-tIe3lTqLg#Protocol-state) * [Protocol state proof](https://hackmd.io/1eAeF2K1RaaL-tIe3lTqLg#Protocol-state-proof) * [Staged ledger diff](https://hackmd.io/1eAeF2K1RaaL-tIe3lTqLg#Staged-ledger-diff) * [Delta transition chain proof](https://hackmd.io/1eAeF2K1RaaL-tIe3lTqLg#Delta-transition-chain-proof) :::info Blocks are also referred to as _transitions_. When this transition 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_. ::: 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 frontier. ## Protocol state The protocol state is comprised of the **previous protocol state hash** and a body that contains: * Genesis state hash * Blockchain state * Consensus state * Consensus constants 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. :::info Protocol state is defined in `src/lib/coda_state/protocol_state.ml` ::: ### 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](#) * Timestamp :::info Blockchain state is defined in `src/lib/coda_state/blockchain_state.ml` ::: ### Consensus state The consensus state is comprised of: * Blockchain length * Min window density * Last vrf output * Total currency * Current global slot * Staking epoch data (delegatee\_table) * Next epoch data :::info Consensus state is defined in `/src/lib/consensus/proof_of_stake.ml` ::: ### Consensus constants Constants](`src/lib/consensus/constants/#258`) 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)? * acceptable network delay * slot_duration_ms * epoch_duration * delta * genesis_state_timestamp :::info The constants are defined via `src/lib/consensus/proof_of_stake.ml#L77` ::: ## 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 proves the entire history of the chain is valid. ## Staged ledger diff When a [block producer](#) wins a slot to produce a block, the payments read from the transaction pool are sent to the staged ledger to create a diff. A diff consists of: * Payments included in the block * A list of [transaction proofs](#) that prove some of the transactions (payments, coinbase, and proof-fees) from previous blocks * Pending coinbase A staged ledger can be regarded as a _pending accounts database_ that has transactions(payments, coinbase, and proof-fees) applied for which there are no SNARKs available yet. A staged ledger consists of the accounts state (a ledger) and a data structure, which is the [scan state](https://hackmd.io/KNlBqIQXQXeaaCuW2_hfJQ) ## 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 slot duration. ## Example protocol state ```json { "protocol_state": { "previous_state_hash": "3NL5TAtjPgQL2eH1AWWugNhnvxh8VAmfme8vTXCHiJqrrZBeGf5b", "body": { "genesis_state_hash": "3NLVs8hfDhTvzEcjXurQdGKS1ykj6GcYKS1gXdHcNM1MorkbBEBX", "blockchain_state": { "staged_ledger_hash": { "non_snark": { "ledger_hash": "jxaj2pu82Jh38jGgkuQbSnbMn7R1F8n5wNHktBguPBSo9ebmLoP", "aux_hash": "VFccpmteNKbGRUGEYDVzt14P7f4E1LvKLz84UwrtJ9HR563oUR", "pending_coinbase_aux": "Xod79jkaSppeWc5P7rkCMdCjidKhqWUFscGnkvFCaVL68nhDdv" }, "pending_coinbase_hash": "2n1WAoAWnfxusjkmnR63xpUUJTEKN6jcZth4MmxzaLFvPUG3KRLQ" }, "snarked_ledger_hash": "jwHEKSFcm9dV8dk2xX3Mo59iHs5YXsTMGJw7WsVFQYnoh1K4uNd", "genesis_ledger_hash": "jxqupp5oGcqRuEFGaq9oTtJYBdMdtgHodLoxuMk7xt4m8gBUnNx", "snarked_next_available_token": "2", "timestamp": "1605723260000" }, "consensus_state": { "blockchain_length": "72", "epoch_count": "0", "min_window_density": "77", "sub_window_densities": ["0", "7", "7", "7", "7", "7", "7", "7", "7", "7", "7"], "last_vrf_output": "mTaARh9PaCplXDsmwTalBp8ACu4NE9rUB-EDjW9q2AA=", "total_currency": "99514684000001000", "curr_global_slot": { "slot_number": "221", "slots_per_epoch": "7140" }, "staking_epoch_data": { "ledger": { "hash": "jxqupp5oGcqRuEFGaq9oTtJYBdMdtgHodLoxuMk7xt4m8gBUnNx", "total_currency": "99505884000001000" }, "seed": "2va9BGv9JrLTtrzZttiEMDYw1Zj6a6EHzXjmP9evHDTG3oEquURA", "start_checkpoint": "3NK2tkzqqK5spR2sZ7tujjqPksL45M3UUrcA4WhCkeiPtnugyE2x", "lock_checkpoint": "3NK2tkzqqK5spR2sZ7tujjqPksL45M3UUrcA4WhCkeiPtnugyE2x", "epoch_length": "1" }, "next_epoch_data": { "ledger": { "hash": "jxqupp5oGcqRuEFGaq9oTtJYBdMdtgHodLoxuMk7xt4m8gBUnNx", "total_currency": "99505884000001000" }, "seed": "2vamyzPNNwfoWqt75Dtt8DttrGGmcgjKvA1s8KZQiTWyRJZkX9wj", "start_checkpoint": "3NK2tkzqqK5spR2sZ7tujjqPksL45M3UUrcA4WhCkeiPtnugyE2x", "lock_checkpoint": "3NL5TAtjPgQL2eH1AWWugNhnvxh8VAmfme8vTXCHiJqrrZBeGf5b", "epoch_length": "73" }, "has_ancestor_in_same_checkpoint_window": true }, "constants": { "k": "290", "slots_per_epoch": "7140", "slots_per_sub_window": "7", "delta": "0", "genesis_state_timestamp": "1605683480000" } } }, "state_hash": "3NLHauSN9PdmxJiQDdD4vZ1gQW86pi5wsf2hnJTbHZj42QcpE1MT" } ```