(deprecated) RSpace 0.2 Specification
Introduction
Purpose
This document is intended to specify the 0.2 release of the RChain storage layer (Storage.02)
References
Call out any related documents, pre-requisite documents, and documents that provide context or background.
Previous version (Storage.01)
The version of the storage layer envisioned for Storage.02 is a simplified version of the layer described in this document.
Storage.02 will not include distributed operation. Storage.02 will not operate in a distributed setting. Storage.02 is designed to work in the context of a single Rholang interpreter running alone on a single node which does not communicate with other nodes. Later releases of the RChain storage layer will work with multiple instances of the Rholang interpreter or RhoVM running on a single node which will be networked with other such nodes.
There are also some important differences from the storage layer described the architecture document:
The underlying key-value store: Instead of MongoDB, the current design of the storage layer uses LMDB. See Software Dependencies for more information.
The query mechanism: Originally, SpecialK used a Prolog/Datalog-based query mechanism, which was included in the original design for the RChain storage layer . However, this feature will not be available in the Storage.02 release. It will be replaced with a different approach to matching on keys.
This document contains relevant information about LMDB.
Old, somewhat weird solution to each key having multiple pieces of data
Definitions:
a term that has a definition
a
termthat is part of the interfacea
termthat has a definition and is part of the interface
JAR: Java ARchive
"A package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution." (Wikipedia)
COMM Event
From RChain Architecture Docs: Execution Model
RhoVM operates against a key-value data store. A state change of RhoVM is realized by an operation that modifies which key maps to what value. Since, like Rholang, RhoVM is derived from the rho-calculus model of computation, that operation is the low-level rho-calculus reduction rule. Effectively, the reduction rule, known as the “COMM” rule, is a substitution that defines a computation
Pto be performed if a new value is observed at a key. A key is analogous to a name in that it references a location in memory which holds the value being substituted.
A COMM Event is a consume that matched at least one produce.
IO Event
consume or produce.
Consume
A consume is an action that can be issued on RSpace and is aligned with the Rholang conceptual model of using the tupelspace.
The consume represents a waiting continuation which can be matched in RSpace with a relevant produce.
Produce
A produce is an action that can be issued on RSpace and is aligned with the Rholang conceptual model of using the tupelspace.
The produce represents data that can be matched in RSpace with a relevant consume.
BlockDAG
A variant on a blockchain, where each block is a node in a Directed Acyclic Graph (DAG). In order to accommodate the CASPER consensus model, RChain's Blockchain is a BlockDAG. The storage layer stores the history of states and has means for rolling back to them to support the consensus model.
Merkle Patricia Trie
From https://github.com/ethereum/wiki/wiki/Patricia-Tree
Merkle Patricia tries provide a cryptographically authenticated data structure that can be used to store all (key, value) bindings
Type class
From the Cats Documentation
Type classes are a powerful tool used in functional programming to enable ad-hoc polymorphism, more commonly known as overloading. Where many object-oriented languages leverage subtyping for polymorphic code, functional programming tends towards a combination of parametric polymorphism (think type parameters, like Java generics) and ad-hoc polymorphism.
Original paper demonstrating how to encode type classes in Scala: https://ropas.snu.ac.kr/~bruno/papers/TypeClasses.pdf
LMDB
From http://www.lmdb.tech/doc/
LMDB is a Btree-based database management library modeled loosely on the BerkeleyDB API, but much simplified.
RSpace
RSpace is the "RChain storage layer" implementation. It has an abstract interface IStore that holds the"RChain storage layer" contract.
RSpace[C, P, A, K]
C - a type representing a channel
P - a type representing a pattern
A - a type representing an arbitrary piece of data
K - a type representing a continuationCheckpoint
A Checkpoint is a stable (once created it does not change over time) reference to a particular state of RSpace. It is implemented as a BLAKE2b256 hash.
A checkpoint is also an action of creating a Checkpoint.
Rollback
A rollback is an action that can be performed on RSpace. It requires a valid Checkpoint and results in RSpace pointing to the state that the passed Checkpoint referenced.
Branch
A Branch represents a named context in RSpace. Any data that found it's way into RSpace on one Branch will not be visible on a different Branch.
This allows RSpace to share the data store (different data spaces on different Branches) which in turns allow to run a replay (via rigged mode).
Log (Trace Log)
Every action (IO Event, COMM Event) that affects the state in RSpace is stored in the log.
Rigged mode
Puts RSpace in a mode that allows to replay results that were produced by a different RSpace based on log and incoming produce and consume events.
Network
The RChain's Blockchain network composed of multiple nodes.
Validator
A validator is a node role responsible for the consensus algorithm (http://architecture-docs.readthedocs.io/execution_model/consensus_protocol.html).
Scope
RSpace 0.2 includes the features needed to support the RChain blockchain.
As stated above, this document is only intended to describe the minimal initial version of the storage layer, known as Storage.02.
Storage.02 will implement the basic tuplespace functionality described below for use in the Rholang Interpreter.
Storage.02
will not operate in a distributed mode
will not implement the "system processes" feature which allow a client to run arbitrary Scala code keyed to a particular channel.
- 1 Introduction
- 1.1 Purpose
- 1.2 References
- 1.3 Definitions:
- 1.3.1 JAR: Java ARchive
- 1.3.2 COMM Event
- 1.3.3 IO Event
- 1.3.4 Consume
- 1.3.5 Produce
- 1.3.6 BlockDAG
- 1.3.7 Merkle Patricia Trie
- 1.3.8 Type class
- 1.3.9 LMDB
- 1.3.10 RSpace
- 1.3.11 Checkpoint
- 1.3.12 Rollback
- 1.3.13 Branch
- 1.3.14 Log (Trace Log)
- 1.3.15 Rigged mode
- 1.3.16 Network
- 1.3.17 Validator
- 2 Scope
- 3 Use Cases
- 3.1 History & Rollback
- 3.2 COMM Event Traces
- 3.3 Storage Layer
- 4 Interfaces
- 4.1 System Interface
- 4.1.1 Overview
- 4.1.1.1 ISpace interface
- 4.1.1.2 RSpace signature
- 4.1.1.3 Prerequisites
- 4.1.1.4 ITrieStore
- 4.1.1.5 LMDBStore
- 4.1.2 RSpace creation
- 4.1.2.1 RSpace create
- 4.1.3 Consume
- 4.1.4 Install
- 4.1.4.1 install
- 4.1.5 Produce
- 4.1.5.1 produce
- 4.1.6 Rollback
- 4.1.6.1 rollback
- 4.1.6.2 rollback usage
- 4.1.7 Replay mode
- 4.1.7.1 ReplayRSpace
- 4.1.7.2 How trace log is recorded
- 4.1.7.3 Trace log
- 4.1.7.4 Trace log recording
- 4.1.7.5 COMM event recording
- 4.1.7.6 Rig point creation
- 4.1.7.7 How the log is used to create replay data
- 4.1.7.8 Replay table creation
- 4.1.7.9 How deterministic playback works
- 4.1.7.10 Rigged mode replay
- 4.1.1 Overview
- 4.2 Hardware Interface
- 4.3 Software Interface
- 4.4 User Interface
- 4.5 Communications Interface
- 4.1 System Interface
- 5 System Overview
- 6 Limitations
- 7 Assumptions and Dependencies
- 7.1 Software Dependencies
- 7.1.1 Lightning Memory-mapped Database
- 7.1.1.1 General Information:
- 7.1.1.2 JNR-FFI Wrapper Library for use from Scala
- 7.1.2 Protocol Buffers (serialization format)
- 7.1.2.1 ScalaPB
- 7.1.1 Lightning Memory-mapped Database
- 7.1 Software Dependencies
- 8 Metrics
- 9 Architectural Strategies
- 10 System Architecture
- 11 Not Use Cases: