Clique POA in Ethereum

This article describes the Proof Of Authority (POA) consensus protocol in Ethereum.

The Clique is the POA implementation in Ethereum geth. Ethereum geth is the official software release of the Ethereum blockchain. The essence of POA is blocks may only be minted by trusted signers. The list of trusted signers is added in extra-data section in block headers. This addition extends the header field to 65 bytes, with secp256k1 miner signature. It also makes the miner field in headers obsolete. Note that changing the length of the header file is a non invasive operation.

To update a dynamic list of trusted signers, Clique uses the miner field and nonce field (both made obsolete by POA) to create a voting protocol.

  • during regular blocks, both fields are set to zero
  • if signer want to change the list of trusted signers, it will set miner to the signer it wants to vote out, and use the nonce filed for voting.

Then, the Ethereum nodes can vote during block processing. The epoch concept is used to prevent an infinite window to tally votes in. This epoch is a window of W blocks after which votes are considered stale. This way prevents malicious signer from injecting new vote proposals inside every block they mint.

To authorise a new block , the signer needs to sign the block’s hash containing everything except the signature itself. Each signer is allowed to sign 1 out of SIGNER_LIMIT consecutive blocks. This is to prevent malicious signer from creating trouble in the network.

Furthermore, to prevent racing for new blocks, every signer would add a small random offset to the time it releases a new block.

In Clique POA, signer number, block time and gas limit are the main parameters that we can tweak on. To consider a block as valid, it must be validated by at least 51% of the signers. However, increasing the number of signers, the network latency will increase. Gas limit is set as the maximum amount of gas that can be collected from transactions. Block time is the time required to validate an incoming transaction.

Clique POA is used in Rinkeby and Görli testnet. The reason is testnet lacks hash power, so attacker can disrupt the testnet cheaply. If testnet uses POA, attacker would face difficulty controlling the network.

Clique POA source code is in geth client. Go to the folder
consensus/clique, there are api.go, clique,go, and snapshot.go source files.

The clique.go contains the verify header, verify signature, create sealed block functions. The api.go contains get signers, get snapshot functions.

The snapshot.go contains the create new snapshot, load snapshot, cast new vote functions. Besides that, the is a function in the file that does creation of new authorisation snapshot by applying given headers to the original snapshot.

In the golang code, the Clique consensus engine is defined as “type Clique struct”.

It contains configuration parameters, database to store snapshot, recent blocks, recent signatures of blocks, ethereum address of signing key, and signer function, etc.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值