Cointime

Download App
iOS & Android

Gear Protocol: building a decentralized app platform with infinite possibilities

Cointime Official

By Cointime.com 237

Gear Protocol is a smart contract platform built on Substrate that allows anyone to develop and run dApps in minutes. As the most development-friendly approach, Gear Protocol implements smart contracts with arbitrary logic and complexity. gear smart contracts run as WebAssembly programs, and thus can be compiled using Gear Smart Contracts run as WebAssembly programs and can therefore be compiled using a wide range of popular programming languages (e.g. Rust, C, C++, etc.).

The protocol provides a clean, intuitive and feature-rich API that makes it simple to implement and run programs on multiple networks. From a technical perspective, the Gear Protocol differentiates itself through unique features that allow developers to create new and previously unattainable user experiences, including the use of the Actor model for communication, the concept of persistent memory, and the WebAssembly execution environment. The protocol defines the characteristics that Actors have as communication entities.

By supporting innovative dApps, microservices, middleware, and open APIs, Gear Protocol will drive mass adoption of Web3 technologies.The Gear Network is available either as a stand-alone L1 network or as a parallel chain in the Polkadot and Kusama ecosystems. By deploying on Gear Protocol, developers can take full advantage of the various benefits Gear offers.

Vara Network, on the other hand, is the first Layer-1 decentralized network built and running independently on Gear Protocol.

Vara aims to provide developers with an environment to build decentralized applications and drive the Web3 industry to the next level. Without having to develop their own blockchain, anyone can build dApps and deploy them on the Vara network.

By building a bridge between Web2 and Web3, Vara opens up opportunities for developers to build the next generation of decentralized applications, accelerating the adoption of Web3 technologies and leading the way forward. As a local blockchain based on WebAssembly, developers can write and compile code using traditional programming languages.

Additionally, Vara Network offers features such as low transaction costs, pledges, participation in governance, validators, nominees, and ambassador programs (as well as future rebates on fuel costs).

Platform Features

Gear Protocol has a number of unique features that set it apart from other platforms:

1. Truly decentralized

Unlike other platforms, Gear smart contracts are able to trigger their functionality autonomously, without the need for external components or services to trigger on-chain transactions. Traditional smart contracts typically require the user to initiate a transaction in order to wake up the contract, but in many cases the contract needs to be triggered when specific conditions are met, such as a specific point in time being reached or a specific event occurring. In the past, this has limited the functionality of smart contracts or required developers to introduce centralized services to trigger the contract.

Gear Protocol, based on its support for asynchronous messaging, enables contract developers to implement arbitrary contract logic with delayed messaging that wakes up the contract after a specified period of time or upon the occurrence of a specific event. This brings a wider range of application scenarios for smart contracts, unleashes new decentralized features, and creates more value for users in the blockchain ecosystem.

2. Continuous Message Automation

The execution of every message in Gear (including system messages) consumes "gas", and the Gear Protocol introduces the concept of Gas Reservation, which allows for the creation of pools of gas that can be used by programs for further execution. Each pool is unique to the program that created it, and if the program does not have enough "gas_available", it can consume gas from that pool.

An important advantage of Gas Reservation is the ability to send delayed messages that are automatically triggered at a specific time in the future. These messages are similar to other messages in Gear, and can either call another smart contract in the network or appear in the user's mailbox.

Most interestingly, Gas Reservation allows a program to send a message to itself at a later time, allowing it to continue execution after a defined period of time. This allows a smart contract to implement itself for an unlimited number of executions (provided there is enough available gas).

This opens up a wide range of possibilities for implementing functional logic related to continuous message automation in smart contracts. Delayed messages are similar to cron jobs and cannot be implemented in smart contracts on other blockchain platforms unless external resources are used. The significant advantage of this solution is that it eliminates the need for centralized components in a dApp, ensures that they run entirely on-chain, and enables complete decentralization and autonomy.

Core Technology I: Substrate

Substrate is a modular framework that enables the ability to custom-build unique blockchains by combining custom or pre-built components with networks, consensus mechanisms, core functionality, security and governance features.

Using the Substrate framework simplifies the process of creating different blockchains for specific applications.Substrate provides a rich set of out-of-the-box features and allows developers to focus on creating custom engines on top of the protocol.

The main features of Substrate are as follows:

1, no fork updates

2, built-in coordination

3, cross-language support for WebAssembly

4, light client friendly

5, deterministic finality

6. Seamless integration

Substrate enabled the Gear team to significantly reduce development time and focus on developing key Gear protocol components, while the Rust language ensured security and high performance.

Gear's unique asynchronous messaging architecture enables efficient communication between networks built on Substrate technology. This seamless integration helps to increase the interoperability of network functionality and participation.

Core Technology II: Actor Model

The Actor model is a key and unique feature of the Gear Protocol for message-passing communications. In concurrent computing systems, "message-passing communication" means that programs communicate by exchanging messages. Message passing is easier to understand and has better performance characteristics than "shared memory communication".

The Actor model framework supports asynchronous messaging and parallel computation, which greatly improves speed and makes it easier to build complex dApps. In general, the normal Actor model does not guarantee message order, but the Gear Protocol provides some additional guarantees to ensure that the order of messages is preserved between two specific programs.

In this context, Actor refers to the atomic computation unit in the Actor model that can send and receive messages. In Gear, any instance of the Gear Protocol is an Actor, either a program (smart contract) or a user that sends messages to a program. Each Actor has its own internal private state and the user has a mailbox. Communication is asynchronous; messages are taken from the mailbox and assigned to a message processing stream in which they are processed according to a cycle.

Core Technology III: WebAssembly

WebAssembly is a way to run non-JavaScript programming language applications in web pages. In reality, Wasm is just a virtual machine that runs on modern browsers, but unlike in the past when JavaScript had to be used to run code in web pages, Wasm makes it possible to run code in browsers using non-JavaScript programming languages.

The WebAssembly virtual machine (or Wasm for short) proved to be faster than any alternative virtual machine due to its technical features. Using WebAssembly it is possible to compile Gear's smart contracts directly into machine code and run them at near-native speeds. Higher speed means lower transaction costs and greater efficiency.

All Gear programs and smart contracts run as WebAssembly programs. This means that developers can take their applications to the Web and achieve full performance and the full feature set of the application in a Web browser, just as if it were running natively on Windows or Mac. Instead of writing Wasm code directly, developers actually use Wasm as a compilation target for programs written in other languages.

The main problem WebAssembly solves is the inability to use programming languages other than JavaScript on the Web. Although JavaScript is a great programming language, it is not suitable for ultra-fast execution of large applications.Wasm is revolutionary in that it brings the performance of native applications written in other programming languages to the Web in a completely safe manner.

Wasm can significantly increase speed in two main areas.

First, it should dramatically increase the speed at which applications are launched. In fact, applications already using Wasm have been able to cut application startup times in half, and startup speeds will only increase further as more optimizations are made. This will allow huge applications to load very quickly.

Secondly, Wasm also significantly improves throughput, which means that once the code is compiled, it will run faster, making the application more efficient and responsive, which significantly improves the user experience.

Core Technology IV: Persistent Memory

Another important feature of Gear Protocol is its persistent memory technology. This technology makes development simpler, reduces complexity, and matches the memory management of the actual hardware and operating system.

Instead of using traditional storage, programs running in the Gear network persist their complete state. Doing so greatly reduces the API surface on the blockchain. At the same time, this approach avoids the constraints of a domain-specific language and allows the use of more complex language constructs such as persistent closures and futures combinators.

Gear Protocol employs a clever memory virtualization technique that treats memory allocation and release as first-class system calls. It also tracks memory accesses and loads/stores only the pages needed. This way heap allocations in smart contracts (typically found in futures and their combinators) can be seamlessly persisted and called when needed to preserve their state.

Program code is stored as immutable Wasm blocks with a certain amount of memory space that is persisted between message processing (called static regions). Each program has a separate memory space and is reserved for it during the initialization phase at no additional cost. Programs can only read and write in their own memory space and cannot access the memory space of other programs.

Programs can allocate the memory they need in 64KB blocks. Each memory block allocation consumes gas. Each page (64KB) of these memory blocks is stored separately on the distributed database backend. However, at runtime, Gear nodes build contiguous runtime memory and allow programs to run on it without reloading.

Persistent memory technology also supports memory parallelism. Each program has a separate, isolated memory space, which allows multiple message streams to be processed in parallel on Gear nodes. The number of streams processed in parallel is equal to the number of CPU cores. Each flow is responsible for processing a set of program-specific messages, which can come from other programs or externally (user transactions).

With persistent memory technology, Gear Protocol enables efficient parallelization of message processing, which improves system performance. This technology ensures persistence of program state and provides developers with more flexible and powerful programming capabilities.

Core Technology V: Gear Network State

The Gear network maintains distributed state through a series of state components. Similar to other blockchain systems, runtime code compiled as WebAssembly becomes part of the state stored on the blockchain.

Gear employs an important feature - forkless runtime upgrades. Determinism of the state can be ensured through the use of finality tools.

The stored state consists of the following components:

1. program and memory

This includes the program's code and private memory. The program code is stored in immutable Wasm blocks. Each program has a certain amount of memory that is persisted between message processing (i.e., static regions). A program can allocate more memory from the memory pool provided by the Gear instance, and can only read and write in the memory specifically allocated to it.

2. Message Queues

The global message queue is used to receive message transactions sent by the user to a particular program. These messages populate the message queue, are queued out and routed to the appropriate program during block building.

3、Accounts

Network accounts and their balances are stored in the Accounts component.Gear provides a Balances module to manage user and program balances and to pay for transactions. For public networks, defending against DOS attacks usually requires payment of gas/fees. In the case of a license, the balance module may not be required.

The Gear network may be a licensed or unlicensed public blockchain. In the case of licensing, the balance module may not be needed, but it is necessary for public networks.

In summary, Gear Network state technology enables efficient distributed state management through components such as programs, memory, message queues, and accounts, and provides developers with powerful tools to build blockchain solutions for a variety of application scenarios.

Core Technology VI: State Transition

Each system performs state transitions according to certain rules and updates the state according to the state transition rules when the network processes new input data. This input data is packaged into fine-grained information called transactions.

In Gear network, nodes maintain and synchronize a transaction pool which contains all new transactions. When a transaction is received by any node (validating or non-validating), that node propagates it to all connected nodes.

When a Gear validation node is ready to generate a new block, it selects some or all of the transactions from the transaction pool and merges them into a block through which state transitions are performed. Transactions not included in the previous block are kept in the pool until the next block is generated.

The Gear network supports the following types of transactions:

1. Uploading a program: Users can upload a new program (smart contract) and associate an initial balance with it.

2、Upload Code: You can upload uninitialized Wasm code for subsequent creation of programs.

3、Create Program: Users and programs can use the uploaded code to create new programs.

4、Send Message: End users interact with the program by sending messages to the Gear network. Sent messages populate a global message queue that acts as a runtime-driven transaction queue, ensuring that all messages are eventually processed.

5. Sending replies: Similar to messages, replies can only be sent as a response to a received message. Users can send replies to messages contained in their mailboxes.

6、Claim value from mailbox: When a message associated with a value is received, the user must claim the value and transfer it from the message to the user. Unclaimed values will be returned to the sender when the gas limit is exhausted.

7. out-of-queue messages: validators choose which messages to out-of-queue when it is their turn to generate the next block. This eliminates the need for each validator to maintain full memory state. The queuing process occurs only at the end of each block.

8. Balance transfers: Conventional balance transfers can be performed in two ways, either using the extrinsics provided by the Substrate Balances module (e.g., transfer, setBalance, etc.), or by sending a transfer request with the relevant values to other users via messages.

The lifecycle of message processing, block building and events in the Gear network is shown below. According to the Actor model of communication, there is no sharing, only messages. It ends up in the form of an event log for inspection by the user space.

Conclusion

Gear Protocol and Vara Network provide developers with powerful tools and environments that enable them to build innovative decentralized applications in the Web3 industry. By supporting multiple programming languages and the flexibility of smart contracts, these platforms bring great convenience and freedom to developers.

Unique features of Gear Protocol, such as asynchronous messaging support and the Gas Reservation mechanism, bring greater functionality and automation capabilities to smart contracts. This allows developers to achieve previously unattainable persistent message automation and decentralized logic, further expanding the boundaries of blockchain applications.

As Web3 technology continues to evolve and adoption accelerates, we can expect Gear Protocol and Vara Network to continue to push the boundaries of the space. These platforms provide a strong foundation for the creation and innovation of next-generation decentralized applications, facilitating a thriving Web3 ecosystem. As an important technology support, these platforms are likely to lead the way in the future development of Web3 technology and create more value and rich user experience for users.

Comments

All Comments

Recommended for you