A consensus algorithm is a process in computer science used to achieve agreement on a single data value among distributed processes or systems. Consensus algorithms are designed to achieve reliability in a network involving multiple unreliable nodes. Solving that issue -- known as the consensus problem -- is important in distributed computing and multi-agent systems.
To accommodate this reality, consensus algorithms necessarily assume that some processes and systems will be unavailable and that some communications will be lost. As a result, consensus algorithms must be fault-tolerant. They typically assume, for example, that only a portion of nodes will respond but require a response from that portion, such as 51%, at a minimum.
Applications of consensus algorithms include:
- Deciding whether to commit a distributed transaction to a database.
- Designating node as a leader for some distributed task.
- Synchronizing state machine replicas and ensuring consistency among them.
Blockchain, the distributed ledger most commonly associated with Bitcoin, also relies on consensus algorithms to reach agreement among nodes. A blockchain can be thought of as a decentralized database that is managed by distributed computers on a peer-to-peer (P2P) network. Each peer maintains a copy of the ledger to prevent a single point of failure (SPOF). Updates and validations are reflected in all copies simultaneously.
Bitcoin uses the proof of work algorithm (PoW) to ensure security in a trustless network, by including mechanisms that ensure that the effort of mining is represented within the block submitted by the miner. Software on the computers of miners accesses their processing capacity to solve transaction-related algorithms. The block is an encrypted hash proof of work that is created in a compute-intensive process. Although any party can submit a chain of blocks to the ledger, the amount of computing resources required to fake consensus is too great to make it worthwhile to a dishonest party.
Other common consensus algorithms include the practical Byzantine fault tolerance algorithm (PBFT), the proof-of-stake algorithm (PoS) and the delegated proof-of-stake algorithm (DPoS).