## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

- Auto
- Light
- Dark

# Algorand Specifications

Block commitment is the process by which a valid block is added to the Ledger.

> Important
> 
> **IMPLEMENTATION:**
> 
> Block commitment entry point in the [reference implementation](https://github.com/algorand/go-algorand/blob/b6e5bcadf0ad3861d4805c51cbf3f695c38a93b7/ledger/eval/eval.go#L2060).

To support block commitment, verification, and assembly, the node uses a structure called BlockEvaluatorBlockEvaluator.

A BlockEvaluatorBlockEvaluator can:

- Evaluate transactions in a block body one by one,
- Add transactions to an in-progress `payset`,
- Track state changes caused by each transaction, and
- Determine if a block is invalid due to a transaction failing validation in the block’s context.

During the block assembly phase, the BlockEvaluatorBlockEvaluator can also discard invalid transactions and continue assembling the block with valid ones.

> Important
> 
> **IMPLEMENTATION:**
> 
> Block Evaluator [reference implementation](https://github.com/algorand/go-algorand/blob/b6e5bcadf0ad3861d4805c51cbf3f695c38a93b7/ledger/eval/eval.go#L672).

Once a block has been certified, the Ledger is responsible for successfully adding it to the blockchain.

The process of adding a block follows this basic sequence:

```
ledger.AddValidatedBlockeval.Evalledger.AddBlockledger.AddValidatedBlockeval.Evalledger.AddBlockCalls Eval with Block and Agreement certificateState Delta updatesAdds the validated block with its certificate
```

Block evaluation takes place after its certificate has been computed. At this point, the Ledger validates the block, applies the resulting _State Deltas_ to its internal state, and adds the block to the blockchain. Once these changes are successfully applied, the block is finalized and officially committed to the Ledger.

```
EnsureBlock

ledger.addBlock

Execute Eval to process the Block with its certificate

StartEvaluator
Fetch previous block and protocol params

Initialize Evaluator and Base State

Calculate updates for new Block

Apply updates to Ledger state

Finalize and commit Block to the Ledger
```

The `StartEvaluator` function sets up and returns a pending BlockEvaluatorBlockEvaluator, which will handle processing the block and updating the Ledger state. As part of its initialization, the BlockEvaluatorBlockEvaluator retrieves the previous block and the relevant protocol parameters to guarantee that the evaluation is consistent with the current blockchain state.

> Important
> 
> **IMPLEMENTATION:**
> 
> Start Evaluator [reference implementation](https://github.com/algorand/go-algorand/blob/b6e5bcadf0ad3861d4805c51cbf3f695c38a93b7/ledger/eval/eval.go#L718).

The core interface of a BlockEvaluatorBlockEvaluator can be broken down into three primary functions:

- **Block Construction**:

This begins by calling `StartEvaluator` to create a new BlockEvaluatorBlockEvaluator instance. It then ingests a sequence of valid transactions from the transaction pool TxPoolrqTxPoolrq, tracking all resulting state changes. The block is finalized at the end of this process with the _block proposer_ setup deferred to this final stage.

- **Block Validation**:

This function checks the validity of a given block. Internally, it reuses the same logic as the evaluation process to ensure consistency.

- **Block Evaluation**:

This function processes the block to generate a _State Delta_, which captures all the changes the block makes to the Ledger and its associated [Trackers](https://specs.algorand.co/ledger/non-normative/ledger-nn-trackers).

> Important
> 
> **IMPLEMENTATION:**
> 
> Validate block [reference implementation](https://github.com/algorand/go-algorand/blob/b6e5bcadf0ad3861d4805c51cbf3f695c38a93b7/ledger/ledger.go#L978).
