canopy

block.go - Block Processing and distribution

This file contains the high-level functionality for block processing, proposal creation, and consensus management in the Canopy blockchain. It handles how blocks are received, validated, proposed, and committed to the blockchain.

Overview

The block.go file implements important blockchain operations including:

Core Components

Block Listener

The block listener continuously monitors the network for incoming block messages. When a new block is received, it:

Block Proposal System

The proposal system is responsible for creating new blocks when a node is selected as a leader. It:

Block Validation

When a node receives a block proposal, it must validate it before accepting it. The validation process:

Block Commitment

Once a block has been validated by a quorum of validators (a supermajority of two-thirds of the network), it can be committed to the blockchain. The commitment process:

Certificate Management

Certificates are cryptographic proofs that a block has been validated by a quorum of validators. The system:

Processes

flowchart TD
    A[Receive Block] --> B{Validate Block}
    B -->|Valid| C[Apply Block to State]
    B -->|Invalid| D[Reject Block]
    C --> E[Commit Block]
    E --> F[Set Up for Next Height]

    G[Leader Selected] --> H[Create Block Proposal]
    H --> I[Include Transactions from Mempool]
    I --> J[Apply Block to State]
    J --> K[Create Certificate Results]
    K --> L[Send Proposal to Network]

Component Interactions

The block processing system interacts with several other components:

flowchart LR
    A[Block Processing] <--> B[FSM]
    A <--> C[Mempool]
    A <--> D[P2P Network]
    A <--> E[BFT Consensus]
    A <--> F[Store]

Security Features

The block processing system includes several security features: