State Management
All the state information of the participant in the MOI network is managed by the state manager using state objects. The state object is an in-memory structure that facilitates various operations on assets, logic, storage, and files owned by the participants. It is defined as follows:
type StateObject struct {
Balances BalanceObject
Approvals ApprovalObject
Logics LogicTrie
Files FileInfoTrie
Storage StorageTrie
Context ContextObject
}
Balances: All the assets owned by the participant are managed using a forward growing linked list, where each node in the list maintains a hash of the previous node, this node is called a balance object. This list improves the read time of preceding balances, by overcoming the need for retrieving the preceding tesseracts.
Figure: Balance objects
Approvals: Similar to balances, approvals are also managed using a front growing linked list, where each node in the list maintains a hash of the previous node, this node is called an approval object.
Figure: Approval Object
Logics: Logics deployed by the participants are managed using Krama Context Trie, where the key is the logicID, and value is the logicData, logicData is protocol buffers encoded byte code and metadata. Here, LogicID is a blake2b-256 hash of LogicData.
Files: All the meta-data of the files uploaded by the participant are also managed using krama-context trie, where the key is the absolute path of the file and value is the meta-data associated with the file.
Storage: Storage associated with logics is managed using krama-context trie, where the key is the logicID and value is the protocol buffers encoded mapping of slotID to the variable value.
Context: Participant's context data is managed using context Object, context Object is defined as follows:
type contextObject struct {
NetworkContextObject
UserPreferencesObject
}
NetworkContextObject: This object maintains a front growing linked list for behavior, random, and userspecific nodes, where every node maintains the hash of the previous node. The length of this node is set to 20.
UserPreferencesObject: This object maintains various context information like TDU Algo, MTQ, cryptographic context, etc.
Krama Context Trie
Krama Context Trie is a context-optimized sparse binary tree where every node is queryable across the network. Since the keyspace is very sparse, we store values at the highest subtree containing only one key. With this modification, in a tree of N keys, only log(N) hashes are required to update a key.