<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>sjl623</title>
        <link>https://paragraph.com/@sjl623</link>
        <description>undefined</description>
        <lastBuildDate>Fri, 31 Jul 2026 15:37:48 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>sjl623</title>
            <url>https://storage.googleapis.com/papyrus_images/f85e257626be8906389a8be006d0f40c5d79892a917000de5367b97d92487e32.jpg</url>
            <link>https://paragraph.com/@sjl623</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[浅析以太坊2.0]]></title>
            <link>https://paragraph.com/@sjl623/2-0</link>
            <guid>eKFmq5j8CmxFk8mSsrQf</guid>
            <pubDate>Fri, 23 Sep 2022 07:03:17 GMT</pubDate>
            <description><![CDATA[What is ETH2.0The Merge!BlockBeats X 欧易 OKX 以太坊合并洞察联合播报，以太坊已于 2022 年 9 月 15 日 14 时 43 分完成主网和信标链的合并，标志着以太坊工作量证明（PoW）的淘汰以及向权益证明（PoS）的完全过渡The Merge!Before Merge在Merge之前，以太坊采用PoW(Proof of Work)共识机制，矿工通过寻找哈希碰撞解进行挖矿，其他节点通过验算找到的解是否满足条件即可确认区块是否有效。PoW机制After Merge在Merge之后，以太坊改用PoS(Proof of Stake)共识机制，新区块的构建不再需要寻找哈希碰撞解，而是改由质押了一定数量ETH的节点按照一定的规则轮流获取打包出块权。如果节点作恶，那么按照共识协议，其质押的ETH会被罚没(slashing) ，通过这种方式来促使节点遵守协议规则。What’s “Merge”Merge后的架构即原来eth1.0的链(PoW Main Chai)和新的信标链(Beacon Chain)合并，由信标链上存储的质押信息来决定出块节点的顺序。...]]></description>
            <content:encoded><![CDATA[<h1 id="h-what-is-eth20" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">What is ETH2.0</h1><h2 id="h-the-merge" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">The Merge!</h2><blockquote><p>BlockBeats X 欧易 OKX 以太坊合并洞察联合播报，以太坊已于 2022 年 9 月 15 日 14 时 43 分完成主网和信标链的合并，标志着以太坊工作量证明（PoW）的淘汰以及向权益证明（PoS）的完全过渡</p></blockquote><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/8d1a4a4cf5fc9b39a9a57d49b9ff8f5bec98728b0e80b8372af3bdea05f6ed7a.png" alt="The Merge!" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">The Merge!</figcaption></figure><h2 id="h-before-merge" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Before Merge</h2><p>在Merge之前，以太坊采用PoW(Proof of Work)共识机制，矿工通过<strong>寻找哈希碰撞解</strong>进行挖矿，其他节点通过验算找到的解是否满足条件即可确认区块是否有效。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5cbb208b3f9b297e42d653527bb00208a7ca451422cdb56ce2cb32ac3086c1f2.png" alt="PoW机制" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">PoW机制</figcaption></figure><h2 id="h-after-merge" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">After Merge</h2><p>在Merge之后，以太坊改用PoS(Proof of Stake)共识机制，新区块的构建不再需要寻找哈希碰撞解，而是改<strong>由质押了一定数量ETH的节点按照一定的规则轮流获取打包出块权</strong>。如果节点作恶，那么按照共识协议，其质押的ETH会被<strong>罚没(slashing)</strong> ，通过这种方式来促使节点遵守协议规则。</p><h3 id="h-whats-merge" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">What’s “Merge”</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ceb9cfeabe1f82d3a3e0f42c9e4575caad4ce9466f011bac410cb629953a1f09.png" alt="Merge后的架构" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Merge后的架构</figcaption></figure><p>即原来eth1.0的链(PoW Main Chai)和新的信标链(Beacon Chain)合并，由信标链上存储的质押信息来决定出块节点的顺序。而原eth1.0则抽象成一个execution layer，负责合约的执行和合约状态的维护。</p><h2 id="h-why-merge" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Why Merge</h2><ul><li><p><strong>能源消耗问题</strong> PoW共识机制的哈希碰撞运算消耗了大量的能源，不够环保。</p></li><li><p><strong>网络稳定性问题</strong> 质押促使节点需要一直维护来保证节点的正常运行直至退出质押，而PoW机制下矿工随时可以关机</p></li><li><p><strong>实现以太坊扩容(Scaling)⭐</strong> 即提高TPS，在PoW机制下，解决了puzzle的矿工就可以出块，出块的节点和时间间隔是不确定的，不利于分片等扩容技术的实现。在PoS机制下，可以通过信标链来统一协调出块节点的顺序、分片信息等。</p></li></ul><h1 id="h-how-to-eth20" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">How to ETH2.0</h1><h2 id="h-beacon-chain" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">信标链(beacon chain)</h2><p>信标链是一条独立于原有以太坊链而运行的新链，其与原eth1.0抽象出的execution layer相互配合，实现PoS共识机制</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">信标链结构</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e68c38f9488caaff3228ea80dedc799326c800ebbe634a0287a02e8819857fe5.png" alt="信标链结构" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">信标链结构</figcaption></figure><p>每一个epoch包含有32个slot，slot间隔周期为12s， 每个slot对应原eth1.0中的一个区块。(后续若启用多个分片链，则1个slot会对应多个分片链中的新区块)。</p><p>每一个slot可以理解为信标链中的一个block，其目前的内部结构体如下：</p><pre data-type="codeBlock" text="type BeaconBlock struct {
    version       int
    slot          types.Slot // slot号
    proposerIndex types.ValidatorIndex 
    parentRoot    [field_params.RootLength]byte
    stateRoot     [field_params.RootLength]byte
    body          *BeaconBlockBody
}
"><code><span class="hljs-keyword">type</span> BeaconBlock <span class="hljs-keyword">struct</span> {
    version       <span class="hljs-keyword">int</span>
    slot          types.Slot <span class="hljs-comment">// slot号</span>
    proposerIndex types.ValidatorIndex 
    parentRoot    [field_params.RootLength]<span class="hljs-keyword">byte</span>
    stateRoot     [field_params.RootLength]<span class="hljs-keyword">byte</span>
    body          <span class="hljs-operator">*</span>BeaconBlockBody
}
</code></pre><p>其中，BeaconBlockBody的结构如下：</p><pre data-type="codeBlock" text="type BeaconBlockBody struct {
    version                int
    isBlinded              bool
    randaoReveal           [field_params.BLSSignatureLength]byte
    eth1Data               *eth.Eth1Data
    graffiti               [field_params.RootLength]byte
    proposerSlashings      []*eth.ProposerSlashing
    attesterSlashings      []*eth.AttesterSlashing
    attestations           []*eth.Attestation
    deposits               []*eth.Deposit
    voluntaryExits         []*eth.SignedVoluntaryExit
    syncAggregate          *eth.SyncAggregate
    executionPayload       *engine.ExecutionPayload // 非盲区块，对应execution layer中的一个区块信息
    executionPayloadHeader *engine.ExecutionPayloadHeader //盲区块，对应execution layer中的一个区块信息
}
"><code><span class="hljs-keyword">type</span> BeaconBlockBody <span class="hljs-keyword">struct</span> {
    version                <span class="hljs-keyword">int</span>
    isBlinded              <span class="hljs-keyword">bool</span>
    randaoReveal           [field_params.BLSSignatureLength]<span class="hljs-keyword">byte</span>
    eth1Data               <span class="hljs-operator">*</span>eth.Eth1Data
    graffiti               [field_params.RootLength]<span class="hljs-keyword">byte</span>
    proposerSlashings      []<span class="hljs-operator">*</span>eth.ProposerSlashing
    attesterSlashings      []<span class="hljs-operator">*</span>eth.AttesterSlashing
    attestations           []<span class="hljs-operator">*</span>eth.Attestation
    deposits               []<span class="hljs-operator">*</span>eth.Deposit
    voluntaryExits         []<span class="hljs-operator">*</span>eth.SignedVoluntaryExit
    syncAggregate          <span class="hljs-operator">*</span>eth.SyncAggregate
    executionPayload       <span class="hljs-operator">*</span>engine.ExecutionPayload <span class="hljs-comment">// 非盲区块，对应execution layer中的一个区块信息</span>
    executionPayloadHeader <span class="hljs-operator">*</span>engine.ExecutionPayloadHeader <span class="hljs-comment">//盲区块，对应execution layer中的一个区块信息</span>
}
</code></pre><p>其中，<code>engine.ExecutionPayload</code>和<code>engine.ExecutionPayloadHeader</code>结构大体一致，区别在于是否为盲区块（后面讨论）， 以<code>engine.ExecutionPayload</code>为例，其结构体如下：</p><pre data-type="codeBlock" text="type ExecutionPayload struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    ParentHash    []byte   
    FeeRecipient  []byte   
    StateRoot     []byte   
    ReceiptsRoot  []byte   
    LogsBloom     []byte   
    PrevRandao    []byte   
    BlockNumber   uint64   
    GasLimit      uint64   
    GasUsed       uint64   
    Timestamp     uint64  
    ExtraData     []byte   
    BaseFeePerGas []byte   
    BlockHash     []byte   
    Transactions  [][]byte
}
"><code><span class="hljs-keyword">type</span> ExecutionPayload <span class="hljs-keyword">struct</span> {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    ParentHash    []<span class="hljs-keyword">byte</span>   
    FeeRecipient  []<span class="hljs-keyword">byte</span>   
    StateRoot     []<span class="hljs-keyword">byte</span>   
    ReceiptsRoot  []<span class="hljs-keyword">byte</span>   
    LogsBloom     []<span class="hljs-keyword">byte</span>   
    PrevRandao    []<span class="hljs-keyword">byte</span>   
    BlockNumber   <span class="hljs-keyword">uint64</span>   
    GasLimit      <span class="hljs-keyword">uint64</span>   
    GasUsed       <span class="hljs-keyword">uint64</span>   
    Timestamp     <span class="hljs-keyword">uint64</span>  
    ExtraData     []<span class="hljs-keyword">byte</span>   
    BaseFeePerGas []<span class="hljs-keyword">byte</span>   
    BlockHash     []<span class="hljs-keyword">byte</span>   
    Transactions  [][]<span class="hljs-keyword">byte</span>
}
</code></pre><p>可以发现，这实际上就是<strong>原以太坊中的区块头</strong>。 也就是说，通过将区块头打包进beacon chain<strong>实现了execution layer和beacon chain的merge</strong>。</p><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">信标链共识</h3><p>前面介绍了信标链上的结构，以及存了什么信息以实现和原链的&quot;merge“，下面介绍beacon chain如何实现共识，即不同的信标链节点间达成一致以持续出块。</p><h4 id="h-stacker-greatervalidator" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Stacker-&gt;Validator</h4><p>首先，如果一个节点想要参与beacon chain的共识，首先需要质押32个ETH，随后，经过一段时间的等待（出于安全考虑），质押者Stacker就会被激活成为Validator，即可参与beacon chain的共识，直至由于作恶被slash或主动退出。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/58139a1850e173732359b51b6df5b312f884a5a95580b81a19089e7fda4049b8.png" alt="validator生命周期" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">validator生命周期</figcaption></figure><h4 id="h-committees" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">委员会(committees)选举</h4><p>在每个epoch开始的时候，会将当前网络中注册的所有validator随机分配到某个slot中（随机确保恶意节点被分到同一个slot的概率足够小），如果启用了分片链，还会再进一步将validator分到指定的分片上，组成<strong>指定epoch、指定slot、指定分片</strong>上的委员会。委员会内又会再确定一个validator为<strong>Proposer</strong>，其他的为则为证明者<strong>Attester</strong>。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/731c69c60ce7296fe2940959a12497982226a35cae94677804cf1306ee6fa215.png" alt="委员会选举" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">委员会选举</figcaption></figure><h4 id="h-" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">委员会投票</h4><p>轮到指定slot出块时，Proposer会向网络中广播一个新的区块，然后其他的Attester进行校验投票（该类型的投票称为LMD GHOST投票），如果收集到的赞成票数超过2/3（根据质押数量加权），则新的块被加到beacon chain中。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/880556ed3d6e8921cc1b2e57a5cab31617c65c846123deeeb4b6dedb7a0b1d79.png" alt="委员会投票" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">委员会投票</figcaption></figure><h4 id="h-fork-choice" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">分叉选择(fork choice)</h4><p>如果出现分叉，则选择根据质押量加权后权重最高的节点</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/6627398d1404516385b41b2457b3eb58ae0c02ee33ee828534c04a7e67eb0431.png" alt="分叉选择" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">分叉选择</figcaption></figure><h4 id="h-checkpoints" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">信标链检查点(checkpoints)</h4><p>每个epoch中的第一个slot被称为checkpoints，也成为时段边界区块EBB (epoch boundary block)，每个validator在每个epoch中发起一次 LMD GHOST投票（对当前slot的块进行表决）同时还要对最近一个epoch的检查点发起一次投票，称为Casper FFG投票（对最近的检查点进行表决）。在提交Casper FFG投票时，需要包括两个检查点：当前epoch的checkpoint(称为target)和前一个checkpoint(称为source) 如果一个epoch的checkpoint表决通过（根据质押量加权后的2/3票数），则该epoch称为被&quot;<strong>证明(justified)</strong>&quot;了 更进一步，如果某个epoch的下一个epoch也被<strong>justified</strong>了，那么该epoch则称为被&quot;<strong>确定(finalized)</strong>&quot;了</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/68c0e4fbc9e0c780767c92226da99d3f32fc315e931b4c5976cc1945af0d33b4.png" alt="信标链检查点" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">信标链检查点</figcaption></figure><h4 id="h-slashing" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">罚没机制(slashing)</h4><p>如下的行为会被视作恶意行为：</p><ul><li><p><strong>双重提议(double proposer)</strong> 即proposer在一个slot中提议了两个不同的块</p></li><li><p><strong>双重投票(double vote)</strong> 即validator针对同一个target发了相对于不同source的两次FFG投票</p></li><li><p><strong>环绕投票(surround vote)</strong> 指一个FFG投票的区间包括了另一个FFG投票的区间</p></li></ul><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/39f71c08cf0cb43dfd3e7d801ae5bf123237de691550d0dbd4ab4acc1753f6dc.png" alt="环绕投票" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">环绕投票</figcaption></figure><h4 id="h-" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">激励机制</h4><p>validator的激励来源包括两部分：Attestation Reward 和 Proposer Reward</p><p>首先定义base_reward</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/024169b188ee8ad8fb4dd24ec8fa92db6953f7c6ea6a8545257b13b80b9bd082.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>其中, 64和4为可调节的协议参数，Average effective balance为平均质押量(没有被slash的validator时为32ETH，存在被slash的validator时将会小于32)，Total active balance staked为质押的ETH总数</p><p><strong>Attestation Reward</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0ddea0c9dd4b3adbf86d27ed2e6f5017841af5b4ed17b9872aa99bb7eba637f1.png" alt="Attestation Reward" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Attestation Reward</figcaption></figure><p>source和targe对应Casper FFG投票中的参数，head则为LMD GHOST投票对应的区块头</p><p><strong>Proposer Reward</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/96d7386d55f55814b61f630efc4806517c7c618c2614189b3bb356065e9ea8a7.png" alt="Proposer Reward" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Proposer Reward</figcaption></figure><p><strong>merge后的通胀率</strong></p><p>实际上，以上的激励机制里面起调节作用的主要是base reward，而base_reward在1. 节点越稳定时收入越高 2.质押总量越少收益越高，从而鼓励质押 以上两个指向都有利于以太坊的稳定性。在merge之前，挖矿的收益=固定收益(2ETH)+矿工费，merge之后，validator的收益=质押收益（当前每个块约0.1~0.2ETH不等）+矿工费(如果当选proposer)。 据估算，在新的激励模型下，merge后的通胀率将<strong>远低于</strong>merge前的通胀率</p><p><strong>论文</strong></p><p>beacon chain的基本内容就是这些，有一篇完整的论文专门讲beacon chain的共识，包括了安全性证明等内容。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b963e904629fc7a9e8fb36723c8110dc3ea89bec3316437d1e0fa0bd6632da94.png" alt="beacon chain共识论文" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">beacon chain共识论文</figcaption></figure><h2 id="h-beacon-chainexecution-layer" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">beacon chain和execution layer的交互实现</h2><h3 id="h-" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">总体架构</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/55ac83ac4ba8768130bbd47d8da6ab4b41e9ad26dc60f3181c182f9ca1089b58.png" alt="eth1+eth2" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">eth1+eth2</figcaption></figure><ul><li><p>eth1即原有的实现，现在作为执行层复用（如geth）</p></li><li><p>eth2为根据beacon chain的规范实现的beacon client，独立于原有实现（如prysm）</p></li><li><p>两者分别实现组成各自的p2p网络，并通过RPC调用通讯</p></li></ul><h3 id="h-eth2-client" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">eth2 client</h3><p>由社区根据规范实现，如prysm(<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/prysmaticlabs/prysm">https://github.com/prysmaticlabs/prysm</a>)</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d65125c9f08eb50f11719ac1ae4a2a0f48b0477d2d3c8eb9ccb74e41bd0da8c0.png" alt="eth2 client" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">eth2 client</figcaption></figure><ul><li><p>eth2 client 负责实现beacon chain的共识协议</p></li><li><p>eth2 client中维护了beacon chain的相关状态</p></li><li><p>通过RPC调用将收到的区块传递给eth1-engine</p></li></ul><h3 id="h-eth1-engine" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">eth1 engine</h3><p>复用原有的代码，抽象出执行层，主要负责EVM执行和合约的状态维护，如geth(<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/ethereumpow/go-ethereum">https://github.com/ethereumpow/go-ethereum</a>)</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0edaa4861d6101a8dedf4fbb63b5aefa81cead786c5bf2e6d0988b38cd58c050.png" alt="eth1 engine" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">eth1 engine</figcaption></figure><ul><li><p>接收并响应来自eth2-client的RPC请求</p></li><li><p>维护原eth链中的状态，如合约状态、账户余额等</p></li><li><p>交易广播、打包以及EVM虚拟机仍复用eth1 engine的原有实现</p></li></ul><h1 id="h-post-merge-ready-for-surge" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Post-Merge? Ready For Surge！</h1><p>以太坊Merge的目的是为了实现扩容(scaling，即提高tps)。 目前社区提出了新的扩容方案EIP4844，该提案是前一个提案的改进版本。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b696d73001bf7a9415cf25932c77a40139df542e697b3a015151657902bb39ff.png" alt="扩容提案" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">扩容提案</figcaption></figure><p>这两个提案的核心思想都是<strong>数据分片(Danksharding )</strong>。这是一个有别于原有的“网络分片-交易分片-状态分片”外的一种分片方案 这与之前区块链里面研究的状态分片不同，状态分片更多讨论如何将交易划分到不同的分片去执行，此外还要考虑跨片交易的实现。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/06c7230fabeba0ae3c47b880fe084a1151a2429c8dbbaf013a3eaba2205021a1.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>为了保证安全性，如果采取状态分片的方案，那么必须要在每个epoch对每个validator所属的分片进行重新随机分配，但这样会引入新的问题：<strong>数据同步问题</strong>，即validator在切换分片后需要使用相应分片的数据库</p><ul><li><p>如果validator在切换分片后重新同步新分片的数据，难以保证这项工作能够在切换分片的短时间内完成</p></li><li><p>如果validator保留完整的数据，在切换分片时使用相应分片的数据，那节点的数据库将会一直膨胀，与分片的初衷相违背。</p></li><li><p>此外，跨片交易的设计也很复杂，特别是针对以太坊EVM这种具备图灵完备特性的虚拟机，既<strong>难以预测合约执行过程中会访问哪些分片的数据</strong>，也<strong>难以保证合约执行过程访问的数据在同一分片上</strong>。</p></li></ul><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/62995b6430791cb3245c00a1cafa1f3cb00c5e873690e6fd7556e6fb34ec27ee.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>为此，目前主流的观点是放弃状态分片，改用数据分片。在介绍数据分片之前，需要先介绍目前主流的扩容方案，<strong>rollup</strong></p><h2 id="h-rollup" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">rollup</h2><p>目前主流的扩容方案是，以太坊链上<strong>不再执行EVM合约</strong>，而只<strong>存储有效性证明（即特定数据）</strong>，将执行EVM合约的任务转至链下中心化节点上执行，并将所有<strong>交易输入</strong>(经过压缩后的transacitons)和 <strong>执行结果的有效性证明</strong>(如state root)上链供校验，这样所有用户都可以校验中心化节点的执行结果是否正确，以这种方式保证了链下中心化节点正确的执行了用户交易。 即<strong>链下(off-chain)计算，链上(on-chain)校验</strong>， 这种扩容方案被称为<strong>rollup</strong>。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f6149973717d02bd9664ebdb0a1577168c05f0f96b3e90adcd19fc8b27389760.png" alt="rollup" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">rollup</figcaption></figure><h3 id="h-optimistic-rollup" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">optimistic-rollup</h3><p>optimistic--乐观的，这种rollup的基本思想就是乐观的假设链下的中心化节点不会作恶，但是每个区块都有一定时间的挑战期，任何一个人都可以在挑战期内根据链上保存的交易输入和有效性去校验中心化节点的计算结果是否正确，如果不正确则可以发起提交欺诈证明以获取中心化节点的质押保证金。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/96bfdf274a795dfb4d8110c5b6f13ba0e6067a0b8556abf241233c00702af8eb.png" alt="optimistic-rollup" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">optimistic-rollup</figcaption></figure><p>缺点： 挑战期内资金必须锁定在链上，流动能力不足</p><h3 id="h-zk-rollup" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">zk-rollup</h3><p>运用密码学中零知识证明(zero knowledge)相关的技术,将交易以及交易状态转移的相关证明提交到智能合约上，只有验证通过才能完成上链。 缺点： 目前基于zk-rollup的扩容方法仍尚未实现 对 图灵完备的EVM执行后的状态转移 生成零知识证明，只适用于一些特定的交易，如转账，代币兑换等。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ac374790fb33e7b4bdc49fa076e3a8a83ffa56f1f59d50e177808fe75eb9b8a8.png" alt="zk-rollup" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">zk-rollup</figcaption></figure><p>通过rollup，以太坊链的任务从<strong>执行合约，存储合约、账户状态</strong>变为了<strong>存储特定常量数据</strong>（如前面提到的有效性证明），为此，问题也就从“<strong>如何将不同交易划分到不同分片节点上执行</strong>”变成了“<strong>如何将数据划分到不同节点上存储”</strong>，即<strong>数据分片</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ef930d5f48f349c07a6773aa1b6c14d41cec85a97b5b8795bc200e02f0105074.png" alt="rollup主流方案" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">rollup主流方案</figcaption></figure><h2 id="h-danksharding" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">数据分片方案(Danksharding)</h2><p>数据分片方案是为了配合rollups而提出的一种分片方案，目的是降低验证节点(validator)验证区块有效性所需要的配置门槛，从而让更多验证节点能够参与进共识中，进而提高网络的去中心化和安全性。 其主要包括如下三个部分：</p><ul><li><p><strong>数据可用性抽样（DAS）</strong> 通过数学设计对区块数据进行分片，让验证节点只需要检查部分数据碎片就可以验证区块的完整性。主要通过<strong>Reed-Solomon（RS）编码</strong> + <strong>KZG多项式承诺</strong> 来实现。 RS编码用于实现数据分片，KZG多项式承诺确保编码人按照预先的编码规则进行了编码。</p></li><li><p><strong>出块者-打包者分离 (PBS Proposer-builder Separation)</strong> 为了进一步降低validator的门槛，validator作为proposer可以将打包区块的工作分离出去，交由专门的builder来进行，而validator只需要根据利益最大化的原则，采纳多个builder提交的区块中出价最高的那一个进行签名广播即可。此外，为了防止validator或其他builder窃取一个builder构建的区块，需要采用盲区块(blind block)机制，即builder在给validator发送的区块中并不包含具体的交易，只包括了区块头，只有等到validator将采纳的区块签名广播后，builder才会公布包括区块交易的完整区块。（待确认点：proposer看不到交易的内容，如何确保builder构造的区块是合法完整的）</p></li><li><p><strong>抗审查清单(crList)</strong> 为了防止打包者(builder)有意的忽略指定交易而造成中心化，validator可以通过提供crList指定builder打包的区块内必须包含指定交易，从而实现了validator和builder的分权制衡</p></li></ul><p>包含PBS和crList的完整架构如下所示：</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/33cbec37dc1bb1a998dcb7357ffc87c1e4b38837fb96228e429a69ba61f55089.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h3 id="h-das" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">数据可用性采样(DAS)</h3><h4 id="h-reed-solomonrs" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Reed-Solomon（RS）编码</h4><p>基本原理： 对于两个数m、n，设方程f(x)=ax+b, 令m=f(0)=b,n=f(1)=a+b，可得a=n-b,b=m 则有p=f(2)=2n-m,q=f(3)=3n-2m 则对于原数据m、n和冗余数据p、q，只有接收到这4个数中的任意两个，都可以还原出m、n 依此类推，将数据分成x个碎片，再生成x个冗余碎片，将这2x个数据进行分发，只要其中任意x个都可以还原完整数据。 以此为基础，validator可以不下载完整的数据，而是请求采样k个碎片，如果都能校验通过，则认为无法找到x个还原完整数据的碎片的概率为$0.5^k$</p><h4 id="h-kzg" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">KZG多项式承诺</h4><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://dankradfeist.de/ethereum/2021/10/13/kate-polynomial-commitments-mandarin.html">https://dankradfeist.de/ethereum/2021/10/13/kate-polynomial-commitments-mandarin.html</a> 该技术用于在validator请求数据分片校验时，数据节点生成相应的证明以证明数据完整性（类比默克尔证明）</p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">总结</h2><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1719c16d338f28d4eceebff941d660f00623a655c523f8aa47d1cd898dc979da.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>目前以太坊社区主流的观点都是<strong>放弃执行分片</strong>，<strong>改用数据分片</strong>，结合</p><ul><li><p>中心化出块 (rollup)</p></li><li><p>去中心化验证(DAS+PBS)</p></li><li><p>抗审查(crList)</p></li></ul><p>来实现以太坊扩容 我认为围绕这一个思想，确实有很大的想象空间，一方面，中心化出块可以让交易执行、确认的时间大幅缩短，另一方面，去中心化验证保证了这种方案仍然不违背区块链的基本原则。倘若能够将<strong>传统互联网应用中的分布式处理技术运用到中心化出块中</strong>，并<strong>保证去中心化验证的可行性和高效性</strong>，有可能能够将区块链的tps提高一个数量级。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/44d5438b3fddc75652331135f5a419f80ca30889f8e2257d33cd7a5d079e2bb8.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">参考资料</h1><ol><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://learnblockchain.cn/article/901">详解以太坊2.0信标链</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://arxiv.org/abs/2003.03052">Combining GHOST and Casper</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://learnblockchain.cn/article/4334">Danksharding解读</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.google.com/presentation/d/1-pe9TMF1ld185GL-5HSWMAsaZLbEqgfU1sYsHGdD0Vw/edit#slide=id.p2">Danksharding workshop</a></p></li></ol>]]></content:encoded>
            <author>sjl623@newsletter.paragraph.com (sjl623)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/2f8612fca7c27db40cf68f4771d5aac0595bcedd328f3b9999729772ea53f048.png" length="0" type="image/png"/>
        </item>
    </channel>
</rss>