
The term “message-passing communication” effectively describes the way that programs communicate. Message-passing has benefits over “shared memory communication” as message passing is easier to understand, it’s more robust and it has better performance capabilities.
The way that programs, or in this case Smart Contracts, communicate is very important because it’s a factor that contributes to the overall effectiveness of the program.
With Gear, for inter-process communication we use the Actor Model approach.
In a nutshell, this means that programs (smart contracts) never share any “state”, instead just exchanging messages between each other. The result of these messages may lead to other message sending, creation of a new actor or setting a designated behavior for the next message that an actor receives.
In this article, we’re going to explore what the Actor Model is, how it works and most importantly why Gear uses it.
What is the Actor Model?
The Actor Model is a conceptual model dealing with how programs communicate and it defines some general rules for how the system’s components should behave and interact with each other in a concurrent computational environment.
What makes the Actor Model so unique is that “actors” are completely isolated from each other and they never share memory. On top of that, actors maintain private states, which can only be changed by the program as a result of message processing from another actor.
How does the Actor Model Work?
Actors communicate with other actors by sending asynchronous messages to each other. With the Gear network specifically, messages are kept in the message queue that is maintained by Gear nodes. Messages that are dequeued or processed and transactions that are successful will appear in the block. Not processed messages will be processed in the next block. New messages appear at the end of the message queue.
Essentially, actors receive an input, send an output and perform functions. This is how programs, and more specifically smart contracts, can work automatically. It’s also worth noting that an actor can create another actor, extending the chain within a program and increasing its complexity.
What makes the Actor Model different from other communication methods?
The main difference between the Actor Model and other methods for program communication is that the Actor Model passes messages between actors instead of sharing a “network state. This contributes to greater program security and robustness. Because of this, each actor has its own individual mailbox and cannot change the state of another actor within the chain.
Why does Gear use the Actor Model?
The lack of normal support of asynchronous communication in typical smart contract code introduces a lot of problems for developers. But by using the Actor Model approach for message-passing communication, Gear has a way to enable concurrent communication inside smart contract logic, utilizing various language constructs or asynchronous programming.
This provides native arbitrary asynchronous communication for all programs, which greatly simplifies both development and testing while also reducing the likelihood of errors within the development process.
On top of that, the Actor Model is easy to scale, easy to implement, fault tolerant and does not have a shared state, which contributes to more robust programming.
To stay up to date with the latest news and announcements surrounding Gear, please follow us on Twitter. You can also tweet us with topics that you’d like us to cover next!
Thank You,
The Gear Team!