Skip to main content
Version: latest

Consensus

BBA Chain consensus is a method for achieving reliable consensus among nodes in a distributed system, stemming from the Byzantine Generals Problem. It ensures the system operates correctly even if some nodes are malicious or unreliable.

Commitment Status

The commitment metric gives clients a standard measure of the network confirmation for the block. Clients can then use this information to derive their own measures of commitment.

There are three specific commitment statuses:

  • Processed
  • Confirmed
  • Finalized

Fork Generation

Overview

Nodes take turns being leader and generating the PoH that encodes state changes. The cluster can tolerate loss of connection to any leader by synthesizing what the leader would have generated had it been connected but not ingesting any state changes.

The possible number of forks is thereby limited to a "there/not-there" skip list of forks that may arise on leader rotation slot boundaries. At any given slot, only a single leader's transactions will be accepted.

Message Flow

  1. Transactions are ingested by the current leader.
  2. Leader filters valid transactions.
  3. Leader executes valid transactions updating its state.
  4. Leader packages transactions into entries based off its current PoH slot.
  5. Leader transmits the entries to validator nodes (in signed shreds)
    • The PoH stream includes ticks; empty entries that indicate liveness of the leader and the passage of time on the cluster.
    • A leader's stream begins with the tick entries necessary to complete PoH back to the leader's most recently observed prior leader slot.
  6. Validators retransmit entries to peers in their set and to further downstream nodes.
  7. Validators validate the transactions and execute them on their state.
  8. Validators compute the hash of the state.
  9. At specific times, i.e. specific PoH tick counts, validators transmit votes to the leader.
    • Votes are signatures of the hash of the computed state at that PoH tick count.
    • Votes are also propagated via gossip.
  10. Leader executes the votes, the same as any other transaction, and broadcasts them to the cluster.
  11. Validators observe their votes and all the votes from the cluster.

Leader Rotation

At any given moment, a cluster expects only one validator to produce ledger entries. By having only one leader at a time, all validators are able to replay identical copies of the ledger. The drawback of only one leader at a time, however, is that a malicious leader is capable of censoring votes and transactions. Since censoring cannot be distinguished from the network dropping packets, the cluster cannot simply elect a single node to hold the leader role indefinitely. Instead, the cluster minimizes the influence of a malicious leader by rotating which node takes the lead.

Each validator selects the expected leader using the same algorithm, described below. When the validator receives a new signed ledger entry, it can be certain that an entry was produced by the expected leader. The order of slots which each leader is assigned a slot is called a leader schedule.

Synchronization

Fast, reliable synchronization is the biggest reason BBA Chain is able to achieve such high throughput. Traditional blockchains synchronize on large chunks of transactions called blocks. By synchronizing on blocks, a transaction cannot be processed until a duration, called "block time", has passed. In Proof of Work consensus, these block times need to be very large (~10 minutes) to minimize the odds of multiple validators producing a new valid block at the same time. There's no such constraint in Proof of Stake consensus, but without reliable timestamps, a validator cannot determine the order of incoming blocks. The popular workaround is to tag each block with a wallclock timestamp. Because of clock drift and variance in network latencies, the timestamp is only accurate within an hour or two. To workaround the workaround, these systems lengthen block times to provide reasonable certainty that the median timestamp on each block is always increasing.

BBA Chain takes a very different approach, which it calls Proof of History or PoH. Leader nodes "timestamp" blocks with cryptographic proofs that some duration of time has passed since the last proof. All data hashed into the proof most certainly have occurred before the proof was generated. The node then shares the new block with validator nodes, which are able to verify those proofs. The blocks can arrive at validators in any order or even could be replayed years later. With such reliable synchronization guarantees, BBA Chain is able to break blocks into smaller batches of transactions called entries. Entries are streamed to validators in realtime, before any notion of block consensus.

BBA Chain technically never sends a block, but uses the term to describe the sequence of entries that validators vote on to achieve confirmation. In that way, BBA Chain's confirmation times can be compared apples to apples to block-based systems. The current implementation sets block time to 800ms.

What's happening under the hood is that entries are streamed to validators as quickly as a leader node can batch a set of valid transactions into an entry. Validators process those entries long before it is time to vote on their validity. By processing the transactions optimistically, there is effectively no delay between the time the last entry is received and the time when the node can vote. In the event consensus is not achieved, a node simply rolls back its state. This optimistic processing technique was introduced in 1981 and called Optimistic Concurrency Control. It can be applied to blockchain architecture where a cluster votes on a hash that represents the full ledger up to some block height. In BBA Chain, it is implemented trivially using the last entry's PoH hash.