How Does Solana (SOL) Work?

4 min

Solana is a high performance and high throughput Blockchain network. It uses Proof-of-History (PoH) for block generation and Proof-of-Stake (PoS) for block confirmation. Solana has two types of nodes: leader and validator. The leader processes all transactions and broadcasts them to the entire network. Validators confirm blocks using the Proof-of-Stake (PoS) mechanism. This verification process is faster than block generation and can be done in parallel by multiple validators.

Solana invented Proof-of-History (PoH) to generate time slots. Each slot contains one block, and the hash of the previous block is used as input for generating the next block. To understand PoH, you can think of it as a Verifiable Delay Function (VDF). Similar to the time-consuming nature of Proof-of-Work (PoW), PoH also uses SHA-256 for its computing cycles. Solana refers to each SHA-256 computation as a ‘tick,’ and a block must be ticked for 400ms. The pseudocode for the PoH algorithm is as follows:

function poh_generate()
    hash = prev_block_hash
    loop ticks
        hash = sha256(hash) //one tick
    return hash
end

The entire network has a primary leader that runs the PoH algorithm for its scheduled term. During the execution of the PoH algorithm, each transaction is inserted into the generating block, with the order of transactions determined by the queue order. Because a block represents a unit of time, Solana utilizes it for time synchronization and data consistency.

Every block is filled in a slot, and even if there are no transactions, the PoH still generates an empty block. The relationship between PoH and transactions is as follows:

function poh_generate()
    hash = prev_block_hash
    loop ticks
        tx = obtain_transaction_from(queue)
        if tx != nil
            hash = sha256(hash, tx)
        else
            hash = sha256(hash)
        end
    end
    return hash
end

Unlike other blockchain networks without an obvious structure, the Solana network is a tree structure. Solana transmits blocks over the GOSSIP protocol. Each block is split into shreds with additional loss erasure codes. The order of sending packets doesn’t need to be determined. Because the network is a top-down structure, each node just transmits packets to neighbors and lower-level nodes. The lower-level nodes don’t need to send packets back to upper-level nodes.

How Does Solana Process Transactions?

Solana has two types of nodes: Leaders and Validators. The Leader serves as both primary and secondary. A primary Leader runs for each elected epoch, and a secondary Leader receives backup blocks from the primary. When the primary Leader crashes, the secondary Leader is scheduled to become the primary Leader. The primary Leader receives all transactions, merges them into the PoH slot, and then transmits them to all Validators for confirmation voting.

When a user creates a transaction through a client (wallet), it first sends the data to a node (Validator) through HTTP. Next, the node sends the transaction through UDP to the Leader. After the Leader receives the transaction, the Leader’s TPU (Transaction Processing Unit) module processes the transaction and generates a block. The next stage is to broadcast the block to all validators. After a block has been verified by two-thirds of the Validators, the final stage is to store the block on the blockchain. 

Solana represents each slot as a period of time. When a transaction is processed (decreasing/increasing balance), it is sent into the PoH queue and merged into the block.

Why is Solana so fast with such high throughput?

  1. The single leader can determine the time order and sync the ordered block quickly.
  2. The network has a tree architecture, with package transmission going from top to bottom, eliminating the need for sending back.
  3. PoH is fast; the leader only takes 400ms to generate a block, and other validators can verify a block immediately.
  4. Block transmission is divided into packets with erasure codes, which can tolerate some degree of packet loss. Solana’s Turbine protocol further optimizes this process by breaking down data into smaller chunks, allowing for efficient and reliable data transmission across the network.

Proof-of-Stake (PoS) can guarantee data consensus if most nodes are honest. According to the Byzantine protocol, one-third of dishonest nodes will stop the network, while two-thirds of dishonest nodes will control the network. Solana is a centralized network. If a leader is attacked, the entire network needs time to resume.


References


Note: This post was originally published on liyafu.com (One of our makers' personal blog)


Nowadays, we spend most of my time building softwares. This means less time writing. Building softwares has become my default way of online expression. Currently, we are working on Slippod, a privacy-first desktop note-taking app and TextPixie, a tool to transform text including translation and extraction.