An Introduction To The Persistent Memory Concept

Gear Protocol
3 min readOct 27, 2022

--

In this article, we’re going to be evaluating a core component of the Gear Protocol that hasn’t been discussed in great detail before. We’re hoping that this will provide a great introduction to what is one of the most important and influential aspects of Gear’s tech stack. So, for the first time ever, let’s officially dive into the persistent memory concept.

The persistent memory concept enables us to work with memory, in a Web3 environment, in more of a traditional Web2 way. Typically, memory is saved in the storage of user spaces, which is how it operates in Ethereum for example. However, the issue with this approach is that programs are continuously connected to the storage layer, which is not in itself either particularly safe or cheap. Not only that, but the method also includes complex APIs and requires a special DSL language to find the memory itself.

When it comes to persistent memory, smart contracts (or programs) do not have storage within themselves, but rather their memory is persisted between calls, which enables users to drop many domain-specific features out of the development process and instead just code regular programs, lowering the barrier to entry by making development accessible to developers who aren’t so experienced with blockchain-specific programming.

By taking advantage of persistent memory, we can ensure complete preservation of state across instantiation of the programs on the network. This happens directly in the network’s runtime, making programming much more efficient & less complex than on your typical smart-contract platform.

In contrast, Gear programs have their own virtual memory and as a result are able to read and write operations within their own private space. With this, it is not necessary to declare storage. Individual isolated memory space per program enables the parallelization of message processing and each stream processes messages intended for a defined set of programs. Put simply, programs work with their own memory and they’re able to work on the blockchain without the developers needing to use any databases. Instead, they only need to work with their own memory space. What’s more, two programs can’t work with the same database at the same time, so they can never get crossed. Because of this we have a “lazy-pages” algorithm that only works with the parts of the memory that are needed.

Utilizing clever memory virtualization techniques, a feature unique to Substrate based protocols like Gear, memory allocation and deallocation are important syscalls of the protocol. This means that memory access is tracked and requires only accessed pages to be loaded/stored. This enables smart contracts stored in the blockchain’s state to be seamlessly persisted and invoked when needed, preserving their state upon execution, allowing for much more complex language constructs.

This is exactly why the Gear Protocol makes use of the persistent memory concept. Without it, we wouldn’t be able to facilitate the development of Web3 applications that need instantaneous dataset processing to be valuable. Thanks to the persistent memory concept, developers using the Gear Protocol can create networks that enable the most secure, accurate and innovative applications to be made to contribute to the advancement of the next generation of the internet. It helps those who develop on Gear to do so easier and it helps those applications to run faster, at greater levels of scale and security. Naturally, this contributes to Gear Protocol providing a foundational structure for building new types of interactive applications, products and services that can help disintermediate and improve a wide range of industries and business use cases.

We hope that this article has provided you a good overview & introduction to the persistent memory concept. To find out more about the technical workings behind the Gear Protocol, we recommend checking out our Whitepaper and our Wiki where there are more technical breakdowns of how the protocol works. In the meantime however, to stay up to day with the latest news and announcements surrounding the Gear Protocol then we recommend following us on Twitter.

--

--

Gear Protocol

A new advanced smart-contract engine allowing anyone to launch any dApp. Easiest and cost-effective way to run WebAssembly