Skip to content
Juvix imports

module arch.node.engines.storage;

import arch.node.engines.storage_messages open public;
import arch.node.engines.storage_config open public;
import arch.node.engines.storage_environment open public;
import arch.node.engines.storage_behaviour open public;
import arch.node.types.basics open;
import arch.node.types.engine open;
import arch.node.types.anoma as Anoma open;

open storage_config_example;
open storage_environment_example;
open storage_behaviour_example;

Storage Engine

Purpose

The Storage engine implements distributed object storage. Each stored object is encrypted using convergent encryption with a key derived from the hash of the content and a secret key, then the ciphertext is split into equal-sized parts, and organized in a Merkle-tree.

A Chunk is a Merkle-tree node that is stored by nodes in the network. An associated access control list may limit access to the chunk to a set of nodes, e.g. publisher or subscribers of a Topic.

Nodes may commit to store a Chunk via a ChunkCommitment sent to a pub/sub Topic or shared directly with certain nodes, and keep track of known commitments by other nodes. This allows nodes to respond to chunk requests with either the chunk itself if available locally, or with a ChunkCommitment by a node that stores the requested chunk.

Engine components

The type for a storage engine

StorageEngine : Type :=
Engine
StorageLocalCfg
StorageLocalState
StorageMailboxState
StorageTimerHandle
StorageActionArguments
Anoma.Msg
Anoma.Cfg
Anoma.Env;

Example of a storage engine

exStorageEngine : StorageEngine :=
mkEngine@{
cfg := exStorageCfg;
env := exStorageEnv;
behaviour := exStorageBehaviour;
};

Where exStorageCfg is defined as follows:

exStorageCfg : StorageCfg :=
mkEngineCfg@{
node := Curve25519PubKey "0xabcd1234";
name := "storage";
cfg := mkStorageLocalCfg;
};

exStorageEnv is defined as follows:

exStorageEnv : StorageEnv :=
mkEngineEnv@{
localState := mkStorageLocalState;
mailboxCluster := Map.empty;
acquaintances := Set.empty;
timers := [];
};

and exStorageBehaviour is defined as follows:

module storage_behaviour_example;
exStorageBehaviour : StorageBehaviour :=
mkEngineBehaviour@{
guards := First [exampleReplyGuard];
};
end;