timezone |
---|
Asia/Shanghai |
- 智能合约开发者 想要学习协议层的知识
- 你认为你会完成本次残酷学习吗?会
笔记内容
We publish our code so that our fellow Cypherpunks may practice and play with it. Our code is free for all to use, worldwide. We don’t much care if you don’t approve of the software we write. We know that software can’t be destroyed and that a widely dispersed system can’t be shut down. 看了UNIX系统的档案 伟大的软件总是与开源文化息息相关。以太坊的开放、独立和协作开发文化深深植根于 FOSS, 这种文化是以太坊的基石,也是以太坊最大的不可替代性。 以太坊协议设计的基本哲学:简单性、通用性、模块化、无歧视性、敏捷性
Consensus Layer: process_execution_payload 验证执行层的区块是否合法,共识层和执行层通过Engine API进行通信,CL没有验证区块的能力,会将execution payloads通过notify_new_payload函数发送到EL,EL会执行状态转移的函数(STF) 代码 Excution layer (EL):
先验证区块头,再执行一遍交易,最后返回更新后的stateDB
- Environment: incl. Timestamps, block number, previous block, base fee, etc.
- Tx pool: Maintain the list of txns, ordered by their value
- StateDB
通过pool.Pop()方法获取当前内存池中gas费用最高的交易执行,重复这一过程直到达到gas limit。最后调用finalize方法产出最终的区块
engine_exchangeCapabilities: Used to exchange the Engine API methods supported by each client.
engine_forkchoiceUpdatedV2: Updates the fork choice of the Execution Layer Client. Also used to start a payload build process.
engine_getPayloadV2: Used to retrieve an execution_payload from a build process started in a past engine_forkchoiceUpdatedV2 call.
engine_newPayloadV2: Used by the consensus layer client to send an execution_payload to the execution layer client for it to validate it.
What's Byzantine fault tolerance (BFT)? • Byzantine fault tolerance (BFT) is the property of a system that is able to resist the class of failures derived from the Byzantine Generals' Problem. This means that a BFT system is able to continue operating even if some of the nodes fail or act maliciously.
Two-phase commit (2PC)
Make attestation: i.e. Validator makes cryptographic signature over the state of the chain Different types of attestations • LMD GHOST vote: Validator attests to the beacon chain head • Casper FFG vote: Validator attests to the checkpoint in its current epoch
Every 12 seconds there will be a new slot, and every slot will have a block. A slot is like the block time, but slots can be empty slot分为三个阶段 paradigm blog
Each epoch has 32 slots. The reason behind creating the epoch is to reduce the frequency of consensus processing, so that it doesn't need to happen in every slot
Allow block proposer to outsource block construction, so that validators can continue running on consumer-grade hardware without missing out MEV exposed
https://medium.com/@jamaltheatlantean/what-is-gasper-20f6697d3dc6
Gasper结合了**Casper FFG(Friendly Finality Gadget)和LMD-GHOST(Latest Message Driven - Greediest Heaviest Observed SubTree)
▪ Validators within the network will be randomly shuffled under different committees. ▪ Each validator will make one attestation per epoch. The exact slot the validator is assigned is determined by the protocol through RANDAO. 出于安全考虑,每个 slot 至少有 128 名验证者的委员会。攻击者控制委员会 2/3 的概率不到万亿分之一。
▪ Finality means that a tx is part of a block that can't change. ▪ Justification: When an epoch ends, if its checkpoint has gathered a 2/3 supermajority, the checkpoint gets justified. ▪ Finality: When a checkpoint is justified, the previous checkpoint that is already justified becomes finalized
A checkpoint is a block in the first slot of an epoch. If there is no such block, then the checkpoint is the preceding most recent block. There is always one checkpoint block per epoch. A block can be the checkpoint for multiple epochs.
When casting an LMD GHOST vote, a validator also votes for the checkpoint in its current epoch, called the target. This vote is called a Casper FFG vote, and also includes a prior checkpoint, called the source. In the diagram, a validator in Epoch 1 voted for a source checkpoint of the genesis block, and a target checkpoint of the block at Slot 64. In Epoch 2, the same validator voted for the same checkpoints. Only validators assigned to a slot cast an LMD GHOST vote for that slot. However, all validators cast FFG votes for each epoch checkpoint. Casper FFG 主要负责区块链的最终确定性(finality),确保一旦一个区块被认为是最终的,它就不会被更改。这通过在每个周期(称为epoch)结束时执行检查点来实现。
An attestation contains both an LMD GHOST vote and an FFG vote. Optimally, all validators submit one attestation per epoch. An attestation has 32 slot chances for inclusion on-chain. This means a validator may have two attestations included on-chain in a single epoch. Validators are rewarded the most when their attestation is included on-chain at their assigned slot; later inclusion is a decaying reward. To give validators time to prepare, they are assigned to committees one epoch in advance. Proposers are only assigned to slots once the epoch starts. Nonetheless, secret leader election research aims to mitigate attacks or bribing of proposers