Skip to main content

Logic and Manifest

Logic

Logic is executable with its storage that is deployed on MOI network. It has callable endpoints that can be called through interactions. While logic can contain its own data in its storage (logic state), MOI core concept is "participant context", meaning that participants of the interaction bring their own data related to the logic into interaction, so logics typically operate with the data of participants (actors) i.e. actor's state.

Manifest

Manifest is the file in which the logic is described. Logic is deployed on MOI network by an interaction that takes a manifest and permanently stores it on the blockchain. Once a logic is deployed, its endpoints can be called by invoking interactions.

Coco compiler produces manifests in YAML, JSON or POLO format: here's an example.

Show full flipper.yaml file
flipper.yaml
syntax: 1
engine:
kind: PISA
flags: []
version: 0.5.1
kind: logic
elements:
- ptr: 0
kind: typedef
data: map[identifier]bool
- ptr: 1
kind: state
data:
mode: logic
fields:
- slot: 0
label: values
type: map[identifier]bool
- ptr: 2
deps:
- 1
kind: callable
data:
name: Init
mode: dynamic
kind: deploy
accepts: []
returns: []
executes:
asm:
- LLOAD $0 &0
- PMAKE $1 &1
- NOT $1 $1
- ORIGIN $2
- SETKEY $0 $2 $1
- STORE $0
catches: []
- ptr: 3
deps:
- 1
kind: callable
data:
name: Flip
mode: dynamic
kind: invoke
accepts: []
returns: []
executes:
asm:
- LLOAD $0 &0
- ORIGIN $1
- GETKEY $1 $0 $1
- NOT $1 $1
- ORIGIN $2
- SETKEY $0 $2 $1
- STORE $0
catches: []
- ptr: 4
deps:
- 1
kind: callable
data:
name: Mode
mode: static
kind: invoke
accepts: []
returns:
- slot: 0
label: value
type: bool
executes:
asm:
- LLOAD $0 &0
- ORIGIN $1
- GETKEY $1 $0 $1
- YIELD $1 &0
- DUMP $0
catches: []
- ptr: 5
deps:
- 1
kind: callable
data:
name: Set
mode: dynamic
kind: invoke
accepts:
- slot: 0
label: value
type: bool
returns: []
executes:
asm:
- LLOAD $0 &0
- OBTAIN $1 &0
- ORIGIN $2
- SETKEY $0 $2 $1
- STORE $0
catches: []
- ptr: 6
kind: callable
data:
name: Invert
mode: pure
kind: invoke
accepts:
- slot: 0
label: value
type: bool
returns:
- slot: 0
label: out
type: bool
executes:
asm:
- OBTAIN $0 &0
- NOT $0 $0
- YIELD $0 &0
catches: []

Artifact

When the logic is deployed, it's stored on the network in an encoded format called artifact that's directly executable by PISA virtual machine (MOI's VM that executes logics). Similarly, when Coco runs logics through its test environment Cocolab, Coco programs are compiled to manifests and these manifests converted to artifacts that are executed in PISA.

Artifacts are largely invisible to developers, so we're not going into further details.

Coco Compiler & Cocolab

Coco Compiler is a compiler for Coco Programming Language that compiles .coco source code into manifests. It also contains Cocolab, a local test environment that enables executing logics locally without actual deployment on MOI network.