Validation

In this section

Validation gives shape to your DNA’s data model. It defines the ‘rules of the game’ for a network — who can create, modify, or delete data, and what that data should and shouldn’t look like. It’s also the basis for Holochain’s peer-auditing security model.

You implement your validation logic in your application’s integrity zomes. A DNA uses validation logic in two ways:

  1. By an author of data, to protect them from publishing invalid data, and
  2. By an agent that’s received data to store and serve, to equip them to detect invalid data and take action against the author.

Because every peer has the DNA’s validation logic on their own machine and is expected to check the data they author before they publish it, invalid data is treated as an intentionally malicious act.

Info

Currently Holochain can inform agents about invalid data when asked. In the future it’ll also take automatic defensive action by putting a malicious author into an agent’s network block list when they see evidence of invalid data.

There are two callbacks that implement validation logic:

Design considerations

Validation is a broad topic, so we won’t go into detail here. There are a few basic things to keep in mind though:

Things you don’t need to worry about

Available host functions

As mentioned, any host functions that introduce non-determinism can’t be called from genesis_self_check or validate — Holochain will return an error. That includes functions that create data or check the current time or agent info, of course, but it also includes certain functions that retrieve DHT or source chain data. That’s because this data can change over time.

These functions are available to both validate and genesis_self_check:

validate can also call these deterministic DHT retrieval functions:

All of these functions cause a validate callback to terminate early with ValidateCallbackResult::UnresolvedDependencies(UnresolvedDependencies).

It looks like you are using Internet Explorer. While the basic content is available, this is no longer a supported browser by the manufacturer, and no attention is being given to having IE work well here.