How does Holochain manage consensus and data integrity?

Holochain maintains data integrity without the need for global consensus. It uses an agent-centric approach, combining ideas from BitTorrent and Git, along with cryptographic signatures, peer validation, and gossip.

An overview:

  • hApps have validation rules.
  • Agents have their own local, tamper-resistant hash-chains recording their actions, built upon hApp rules.
  • Each hash-chain entry is cryptographically signed (multi-party actions, like transactions, are mutually countersigned).
  • Data is shared to random peers who validate it.
  • Validators gossip to share good data, warn against bad data, and blacklist bad actors.

1. hApps have validation rules.

When people ask about consensus, what they really want to know is how users can agree on the “facts” of their interactions, technically known as data integrity. Holochain applications (hApps) maintain data integrity without the need for blockchain-style global consensus.

Things in the real world—atoms, cells, bodies—maintain the integrity of their individual and collective state just fine without consensus on a global ledger. In the same way, Holochain’s approach to data-integrity is agent-centric, rather than data-centric, with each node being like a cell that maintains its own state while remaining bound to the physical and biological constraints of the ecosystem in which it lives.

2. Agents have their own local, tamper-resistant hash-chains recording their actions, built upon hApp rules.

The “biological constraints” of a hApp are encoded in its validation rules—the DNA of the application. These rules are the only things nodes in a hApp need to maintain global consensus. With these rules as the foundation, each user keeps an immutable record of their own actions on a local hash-chain, DNA being the first entry on the chain. Each tweet, vote on a poll, or currency transaction (depending on the hApp) would be an additional entry on the agent’s chain for that application.

Keep in mind that Holochain is not a platform like Ethereum, where every dApp runs on the same network. Each hApp has its own validation rules and its own separate network. If an agent tries to cheat by tampering with their copy of the validation rules, they fork themselves off into a separate, lonely hApp just for them.

3. Each hash-chain entry is cryptographically signed (multi-party actions, like transactions, are mutually countersigned).

Each hash-chain entry is cryptographically signed to prove authorship and ensure accountability. Multi-party interactions (e.g., transactions) are mutually countersigned to each party’s chain, and peers are able to audit each other’s chains before agreeing to an interaction or transaction.

Nodes can then share data with each other via a distributed hash-table (DHT), the same technology underlying BitTorrent’s peer-to-peer file sharing protocol. What’s different about Holochain’s DHT is that it also ensures that the shared data follows validation rules.

4. Data is shared to random peers who validate it.

To share data, an agent’s device sends it to a subset of random peers (randomness defends against collusion) based on the similarity of their public key hashes to the hash of the data being shared. These random devices check that the shared data follows the rules of the application. The data is rejected if it breaks the rules. If it follows the rules, the validator marks it valid, signs that statement, and propagates the data by gossiping to the network.

5. Validators gossip to share good data, warn against bad data, and blacklist bad actors.

If a node is found to be propagating or validating bad data, that node is blocked and a warning is sent to others via gossip. This effectively blacklists bad actors from participating in the app.

Additional measures to defend against flooding the network with fake validators are customizable for each application. A messaging app may only need basic protections, such as using email verification, whereas a supply chain handling million-dollar transactions may require vouching from industry peers, an invitation code, and government ID verification to join the network.

It’s worth noting that consensus algorithms can be built on Holochain if desired, though they would have the same unnecessary wastefulness and inflexibility of blockchains. We have been able to map an alternate approach for every situation that seemed to need an absolute sequence of events or global consensus. We found solutions that do not have those requirements.

Join our community
to learn more

General discussion
in a fun environment

Telegram Chat

Tech-focused discussion
and help building apps

Developer Chat