Skip to main content

Execution, Memory and Storage Management

JUG allows for multiple execution environments to run logic. The bytecode compiled for a specific execution environment target is persisted as a context and its execution is facilitated by the Storage, Memory, and Execution Manager of JUG.

The Storage Manager

Handles the reading of state objects and logic bytecode from the persistence layer and writing new state objects back to it. Storage Manager is also responsible for snapshotting the state of the account and using it to serve necessary data during the execution of a logic function.

Unlike traditional blockchain systems like Ethereum which manages the logic of an app and its account state in one unit, we have separated the logic and state associated with the app’s users. To understand how MOI manages the storage of account states, let us look at the following diagrams:

Storage Management in JUG

Figure: Storage Management in JUG

As you can see from the above diagram, the app-specific state variables are stored in their own account state. However, the account-specific state variables for each user are persisted in their own respective storage roots. The Merkle Tree 19 is simple and the data is managed by classifying the data for each app as a key-value entry.

By separating the account-specific state variables from the app’s account states, we have achieved the following advantages:

  • Privacy: We have given the control back to the user, by allowing them to store any of their appbased data in their own ecosystem
  • Security: Although the account-specific state variables have moved from app to the user account state, the PoXt algorithm ensures that users cannot corrupt or abuse the system
  • Performance: With the help of Modulated Trust, the app no longer suffers from bottleneck issues observed in traditional systems using linear state structures such as blockchain

The Memory Manager

Memory Manager handles memory allocation, deallocation, and the injection of state objects into the execution environment such as Stack memory in the case of Ethereum Virtual Machine (EVM) 20 and Linear Memory in the case of WebAssembly (Wasm) 21. It bridges the Execution Manager to the Storage Manager and keeps track of the length and addresses of all allocated spaces in the program memory.

The Execution Manager

Execution Manager instantiates the execution environment to run the logic based on the context.