Each individual transaction is validated by every nodes which receives it. After validation the transactions propagates further to its connecting peers. The validation process involves several steps. In one of those steps the node verifies if the block points to the most recent block in the chain. The nodes also ensures that the transactions included in the blocks are valid. Now, coming on to your query. "you asked that what happens in the case when a node realizes that it was on the wrong chain and there is longer chain available, which forked some blocks before." How does it make the switch? I imagine that it should run all transactions in reverse till the fork happened to restore the state and than replay all transactions in the blocks from the longer chain? Forking is a rare situation that happens when a network receives two valid blocks. Suppose a node received two blocks at the same time, now it doesn't know which block os the right one. It adds one block to its main chain and the other block will be added to the forked chain. Now the node will wait for the next block to be found by the network, once this next block is found, the node will check for the longest chain available in the network, and will add this incoming block to the chain. and the blocks which are there in the shorter branches will go to the pool of unconfirmed transactions and are then picked up again later by the miners in the main chain.