How much do you know about the cryptocurrency consensus algorithm?

本文详细介绍了区块链领域的三种共识算法:工作量证明(PoW)、权益证明(PoS)及委托权益证明(DPoS)。通过对比这些算法的优势与劣势,帮助读者理解它们如何确保交易的有效性和安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Today, we come together to understand the common consensus algorithms and what are the advantages and disadvantages of these algorithms.

1. PoW (Proof of Work)

Proof-of-Work (PoW) is an economic countermeasure against service and resource abuse. It usually requires the user to perform some time-consuming and appropriate complex calculations, and the answer can be quickly checked by the service provider, so as to use the time, equipment and energy as guarantee cost to ensure that the service and resources are used by the real demand.

The advantages of POW are:

(1) As the most secure public-chain consensus mechanism, Bitcoin uses this consensus algorithm

(2) The mechanism is simpler and easier to implement

(3) Relatively fair mining mechanism

The disadvantages of POW are:

(1) Consumption of large amounts of energy (mining of mines consumes huge amounts of electricity).

(2) The time for confirming the block is harder to shorten (the bitcoin network congestion problem is getting worse)

(3)mainchain possibly forkBCH was born with a hard fork

The digital currency using the POW consensus algorithm represents BTC, LTC, ETH, TRF, and so on.

2. PoS (Proof of Stake)

A POS is a person who has more cryptocurrency (equity), the easier it is to get the current block write right (dig mine). It is different from the POW and does not need to consume a lot of power, because there is no need for competition. The POS has generated all the currencies at the beginning, that is, the new block will not create new currency, but they can still get the transaction fee as a reward. Later versions of the POS also have designs for block mining incentives, especially if the POS is to be applied on the public chain.

 

How does the POS specifically select the writer of the current block? If you always choose the one with the highest equity, the member with the most money will always have exclusive write access, so the following two methods are usually implemented:

(1) Selection method for randomization:

Random numbers are generated, and writers are selected by random numbers with a specific formula, but those with higher equity still have a greater chance of being selected.

(2) Selection method based on currency age:

For example, if you hold a currency that is more than 30 days old, you can add a write-in competition. By multiplying the quantity of each currency by the number of days you hold, you can get a number. The higher the number, the higher the chance of being selected as a writer. Once the writing rights are obtained, the currency age of this batch of currency will be zeroed and it will take another 30 days to rejoin the calculation. With a currency age of more than 90 days, there is no way to further increase the odds. Holding a large amount of currency may also reach a maximum probability. This method can effectively improve the situation of centralization and greatly increase the difficulty of the attack.

The advantages of POS are:

(1) No need to compete for power, so low energy consumption

(2) Members who compete for writing rights must have money, so they prefer to guard the system in order to avoid evaporation

The disadvantages of POS are:

(1) A member who has an interest may not wish to participate in the accounting

(2) If the bad guys who get the write-in rights want to rewrite another fake chain, it only takes a small amount of calculation, which may lead to double spending

(3) The cost of doing bad things is very low and there is no penalty mechanism

(4) Based on (2) and (3) above, implementation of POS needs to be combined with other mechanisms to improve this situation and is therefore more complex than POW.

Digital currency using the POS consensus algorithm represents BLK, QTUM, and so on.

3. DPoS (Delegated Proof of Stake)

One of the downsides of POS is that the member who has the equity does not necessarily want to participate in the billing, and the DPOS can solve the problem. Similar to the democratic representative system, it first selects the billing participant (validation node) through the equity certificate, and then The operating mechanism allows these verification nodes to compete for block write rights. At the same time, due to the significant reduction in the number of verification nodes, consensus can be reached quickly.

In addition to the advantages of POS, DPOS includes:

(1) Reducing the number of participating nodes and significantly increasing consensus speed. This is one of the key reasons why EOS can support high-concurrency applications.

The disadvantages of DPOS are:

(1) Must rely on cryptocurrencies, but in many cases in today's alliance chain there is no cryptocurrency

Digital currency using the DPOS consensus algorithm represents BTS, EOS, TRON, etc.

There are other consensuses

PBFT: Practical Byzantine Fault Tolerance

PoSpace/PoC: Proof-of-space/Proof-of-Capacity

PoA:Proof of activity

PoB:Proof of burn

PoET: Proof of episodes

Interested people can understand these consensuses

### 关于共识跟随者无法执行当前操作的原因分析 当遇到“Consensus Follower Not Allowed to Perform Current Operation”的错误时,通常表明某个节点试图在其角色权限之外执行特定的操作。这种问题可能由多种原因引起,以下是常见的几个方面: #### 1. **节点配置不一致** 如果集群中的某些节点未被正确配置为领导者或追随者的角色,则可能导致此类错误。例如,在 Hyperledger Fabric 中,Orderer 节点的角色分配非常重要[^5]。如果 Orderer 的配置文件 `orderer.yaml` 或其环境变量设置不当,可能会导致非领导节点尝试执行仅限领导节点的任务。 #### 2. **Raft 协议下的选举机制异常** Hyperledger Fabric 使用 Raft 共识算法来管理分布式账本的状态同步。在正常情况下,只有领导者可以处理写入请求并广播给其他追随者节点。然而,如果网络延迟较高或者领导者频繁切换,部分追随者可能暂时失去与领导者的联系而误认为自己成为新的领导者[^5]。这种情况会引发冲突,从而抛出类似的错误消息。 #### 解决方案建议 针对以上提到的各种可能性,下面提供一些排查方法以及对应的解决措施: - **验证所有参与方的身份认证材料是否匹配** 确保每个 Peer 和 Orderer 所使用的 TLS 证书均来自同一个 CA 并保持最新版本[^3]。任何过期或伪造的安全凭证都可能干扰正常的通信流程。 ```bash openssl x509 -in /path/to/tls-cert.pem -text -noout | grep 'Not After' ``` - **重新初始化有问题的服务实例** 对于那些表现出不稳定行为的组件(比如疑似卡死的 Orderers),可以通过停止服务再重启的方式强制刷新内部状态缓存[^5]: ```bash kill $(ps aux | grep '[o]rderer' | awk '{print $2}') nohup ./orderer start > orderer-log.log 2>&1 & tail -f orderer-log.log ``` - **调整超时参数适应复杂场景需求** 有时简单的网络状况恶化就能触发不必要的重试逻辑,进而加重系统负担直至崩溃。适当延长等待响应的时间窗口有助于缓解这类压力[^4]: 修改 `core.yaml` 文件内的相关字段如下所示: ```yaml peer: deliveryclient: reconnectTotalTimeThreshold: 60s reConnectBackoffMax: 5s ``` 最后提醒一点,务必定期备份重要数据以防万一发生不可逆损坏事件! ### 提供一段示例代码用于调试目的 这里给出一小段 Python 脚本来帮助定位具体哪个环节出了差错: ```python import subprocess def test_orderer_status(orderer_name="orderer"): try: result = subprocess.run(["pgrep", "-fla", f"{orderer_name}"], capture_output=True, text=True) if result.returncode != 0 or not result.stdout.strip(): print(f"No active {orderer_name} process detected.") else: lines = result.stdout.splitlines() for line in lines: pid, cmdline = line.split(' ', maxsplit=1) print(f"Found {orderer_name}(PID={pid}) running with command-line arguments:\n{cmdline}") except Exception as e: print(e) if __name__ == "__main__": test_orderer_status() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值