This documentation is for the prototype version of Holochain, written in Go.
There is a new version under development, for which there is new documentation and a Developer Preview pre-release.
View the future of Holochain here.
The documentation for the holochain-proto version will remain available online.

Validation in Holochain

We often describe Holochain as taking two standard technologies: Cryptographic Hash Chains, and Distributed Hash Tables, and mixing them up in the peculiar way of placing the creation of the chains in the hands of indivudual actors but adding validation to the DHT at the shared level to confirm the correctness of those chains according the rules of a given Holochain application.

This means that most of the important mechanichs of any application lie in the realm of the validation routines. This article serves as a collection point for a number of other sub-artciles from the documentation.

Articles from the API

The validation functions are the heart of ensuring distributed data integrity. Please consider them thoroughly and carefully as your systems data integrity is built from them.

Validation functions are called under two distinct conditions.

When data is about to be added to the local chain (validateCommit).

Whenever any node of the DHT receives a request to store or change data in some way, the request and the changes are validated against the source chain of the person making the request (validatePut,validateLink.) These are the validation functions that check permissions and enforce any other kind of data integrity you intend to preserve. For example, in a distributed Twitter, only Bob should be able to attach (link) a "post" to Bob as if it is his, and only Bob should be able to link Bob as a "follower" of Alice. Please keep in mind that system variables like App.Agent.Hash that return your own address will not return YOUR address when being executed by a remote DHT node. Code your functions as if anyone will be running them, because they will be.

Common parameters:

header the header for the entry, type Header-object

package the data package created by validateXPkg, type Package-object

sources an array of strings (hash-string) of agents that were involved in taking the action. This parameter will be useful for validation when you want to check if the content created relates in the proper way to the actor.

Each one of the validate commands has a corresponding package building command that will get called on the source node as part of the validation cycle so that the appropriate data can get sent back to the node trying to validate the action. Instead of having to compile all this information yourself, Holochain provides a simple way to configure the package, by creating a PkgReq object.

A JavaScript ribosome package request function that indicates that the entire chain should be sent in the validation package, would look like this:

Complexities of Validation

Holochain mixes together cryptographic hash-chains with a Distributed Hash Table (DHT) with the secret sauce of validation to create an agent-centric distributed application framework. This pattern has some interesting issues that arise. This article describes one of these: what happens in validation when the source node goes off line?

In the current (May 2018) version of our twitter clone clutter app, users experience a direct result of this issue in they will not see any users that they can follow that weren't simultaneously on, at least at one point. Why is this? You might think that when a node comes on line it should have published its identity to the DHT at some point, and so why can't it go offline, and then have another node pick it up later. Well, the answer lies in a couple issues of the current stated of development of Holochain. Mainly a combination of source validation and 100% redundancy (which is the only mode available with this version). Here's the explanation:

In Clutter, user handles get stored as links on App.DNA.Hash

Every node has at least one link entry for App.DNA.Hash: itself (since with 100% redundancy, every node is responsible for storing everything)

This has the consequence that a getLinks() call to retrieve handles always resolves locally, without triggering a DHT lookup

Through DHT gossip, we receive new entries from the DHT but since our node feels responsible (100% redundancy) it wants to validate the entry first by talking to the source before treating the entry as valid/existant

If the source has no (not yet) online overlap time with our node, the new handle link entry can't be validated and is not shown

In future versions we will implement allowing apps to activate proxy validation for certain data entries when appropriate, which would address this issue.