---
# System prepended metadata

title: Update 10

---

# Update on Understanding Block Processing


## Introduction

In the last update, I talked about my progress in understanding how blocks are processed. With guidance from Ethan at Status-IM, I was able to pinpoint the key function responsible for handling blocks: proc addResolvedHeadBlock in block_processor.nim. In this detailed update, we will delve deeper into this function and the components related to it.


## ChainDAG and Canonical Chains

The focus of our exploration is the dag parameter, which is of type ChainDAGRef. ChainDAG is a critical concept in our blockchain processing. It initially stores a linear history of blocks, starting from the genesis block and extending to a certain point. Beyond this point, it allows for branching, creating a Directed Acyclic Graph (DAG) structure. Among these branches, one is considered the "canonical chain." This canonical chain represents the official and accepted history of the blockchain network. Branching and the selection of a canonical chain can occur due to factors like consensus forks.


## BeaconChainDB and Its Role

Now, let's understand how everything fits together. One of the elements of type ChainDAGRef is BeaconChainDB, which is a vital part of our blockchain processing.

**block_clearance.nim** - Line 60

In the code, you'll see a line where `dag.putBlock(trustedBlock)` is used. To demystify this, let's break down the components involved:

    dag: This is a reference to ChainDAG, responsible for storing and handling the blocks in a database.
    putBlock: It is a procedure of dag, which is part of BeaconChainDB in ChainDAGRef. It is used to put a block into the database.

Understanding `trustedBlock`

    trustedBlock: This is of type ForkyTrustedSignedBeaconBlock. It represents a beacon block that has been signed, making it a reliable and valid block in the blockchain.


## Additional Details
**beacon_chain_db.nim** 
`putSnappySSZ` - line 745
`putSZSSZ` - line 762
**thoughts**
This is where the writes are added to an append-only log file.
    



## Language Server Update

The initial challenge I faced with the language server in VS Code has been resolved. I utilized the nimbus-build-system present in the nimbus-eth2 repository. This solution was explained in a video released by Codex Storage.


## A Fascinating Find

Lastly, I stumbled upon an intriguing book that I believe will be of interest to those looking to start their journey in computer programming with Nim. You can find it at the following link: [Nim Programming Book](https://ssalewski.de/nimprogramming.html). It's a valuable resource for anyone eager to dive into Nim programming.