以太坊 PoS 共识机制的转变一直是路线图一个核心。PoW 相较于 PoS 更为简单粗暴,只要哈希的结果是正确的就代表出块成功。但对于 PoS 共识机制来说,由于需要区分网络中不同角色的责任和权限以进行奖励和惩罚,奖惩机制是很重要的。本课题旨在探究以太坊 PoS 节点可以获得的 6 种奖励和 4 种惩罚机制,拆解每一种机制背后的原理和细节。

一、Reward & Penalty

权益证明是一种证明「验证者在网络中投入了一些有价值的资产,如果他们不诚实,这些资产就会被摧毁」的方法。在以太坊的权益证明中,验证者以 ETH 的形式将资产质押到以太坊的智能合约中。随后,验证器参与负责验证网络中传播的新块是否有效,并偶尔自己创建和传播新块。如果他们试图欺骗网络(例如提出多个区块或是做出矛盾的断言),他们抵押的部分/全部 ETH 可能会被摧毁。

1、PoS 出块流程

在每个 slot(12s)中随机选择(RANDAO)一个出块者和委员会,出块者负责创建一个新的区块并将其发送到网络上的其他节点,committee 的投票用于确定所提议区块的有效性。其中 32 个 committees(不少于 128 个验证器) 是在每个 epoch(32 Slots, 6.4 mins)开始之前就随机生成好的了,每个 committee 中需要存在一个 aggregator 负责 BLS 签名聚合。

来源:https://www.ethereum.cn/Eth2/pos-ethereum

来源:https://www.ethereum.cn/Eth2/pos-ethereum

PoS 具体出块流程如下:

Untitled

  1. Intent is turned into tx through private/public RPC;
  2. Txs are sent to the execution client to verify its validity (signature & balance);
  3. In every slot (12 seconds), one validator and committee is randomly chosen. Once the validator is selected as proposer pseudo-randomly using RANDAO, the execution client bundles transactions from the local mempool into an "execution payload" and executes them locally to generate a state change;
  4. Execution client passes the execution payload to the consensus client through Eigen-API, so that the consensus layer can agree on the sequence of blocks at the head of the chain;
  5. Other nodes receive the new beacon block on the consensus layer gossip network. They pass it to their execution client where the transactions are re-executed locally to ensure the proposed state change is valid;
  6. The validator client then attests that the block is valid and is the logical next block in their view of the chain. The block is added to the local database in each node that attests to it.

2、奖励机制

2.1 基础知识

区块确认过程则经由区块证明(attestations),到被证明(justification),再到最终确定(finality)。