Systems and methods for implementing a programming model for smart contracts within a decentralized computer network
Computer-implemented methods and systems for implementing smart contract modules on a decentralized network are disclosed.
1 . A computer-implemented method for implementing smart contracts on a decentralized network, the decentralized network configured to enable peer-to-peer connection amongst a plurality of nodes on the decentralized network, the computer-implemented method comprising:
executing, in a virtual machine execution environment of a first node of the plurality of nodes, a client-side functionality that (1) includes read access to storage of the first node and (2) excludes write access to the storage of the first node, based on client-side contract logic within a smart contract module of the first node;
in response to executing the client-side functionality, at the first node of the plurality of nodes:
retrieving a state of the first node from the storage of the first node, and
constructing an electronic message including commands that cause, when executed, execution of a server-side functionality of a second node to read from and write to a storage of a the second node of the plurality of nodes;
sending, to the second node of the plurality of nodes on the decentralized network, the electronic message to cause execution of the server-side functionality of the second node to modify a state of the second node;
receiving an electronic message (1) from a third node of the plurality of nodes and (2) including commands that cause, when executed, execution of a server-side functionality of the first node to read from and write to the storage of the first node, based on server-side logic within the smart contract module of the first node; and
in response to receiving the electronic message from the third node, executing, in the virtual machine execution environment of the first node, the server-side functionality of the first node to modify the state of the first node.
2 . The computer-implemented method of claim 1 , wherein:
execution of the server-side functionality of the first node further executes a heartbeat function at the first node, to cause the first node to return the state of the first node.
3 . The computer-implemented method of claim 1 , wherein:
the client-side functionality is implemented by client-side logic of a first smart contract; and
the server-side functionality of the second node is implemented by server-side logic of a second smart contract that is different from the first smart contract.
4 . The computer-implemented method of claim 1 , wherein:
the virtual machine execution environment of the first node includes a stateless virtual machine execution environment; and
the stateless virtual machine execution environment is isolated from any client-side execution function call not associated with the client-side functionality.
5 . The computer-implemented method of claim 1 , wherein:
the electronic message once sent to the second node is validated and executed independently of the execution of the client-side functionality.
6 . The computer-implemented method of claim 1 , wherein:
the retrieving the state of the first node excludes executing server-side functionality on any node on the decentralized network.
7 . The computer-implemented method of claim 1 , further comprising:
cryptographically signing the electronic message before sending the electronic message to the second node.
8 . The computer-implemented method of claim 1 , further comprising:
in response to sending the electronic message to the second node, executing the server-side functionality of the first node in the virtual machine execution environment of the first node to modify the state of the first node.
9 . The computer-implemented method of claim 1 , wherein at least a portion of the computer-implemented method utilizes Command Query Responsibility Segregation (CQRS).
10 . The computer-implemented method of claim 1 , further comprising:
broadcasting the electronic message to cause execution of the electronic message in an associated virtual machine of each node of the plurality of nodes in the decentralized network.
11 . A non-transitory, processor-readable medium storing instructions that, when executed by a processor, cause the processor to:
execute a client-side functionality of a smart contract module in a stateless virtual machine execution environment and in response to a request placed via an application programming interface (API), to perform a read-only query of a state stored in a persistent storage volume or a volatile system memory;
in response to executing the client-side functionality, construct an electronic message that represents a transaction, based on the state determined from executing the client-side functionality, the electronic message further encoding commands that, when executed, cause execution of server-side contract functionality on at least one first node of a decentralized network to read from and write to a storage of at least one additional smart contract module;
broadcast, on the decentralized network, the electronic message that includes an identifier associated with a server-side functionality to cause execution of the server-side functionality in at least one stateless virtual machine execution environment of the at least one first node of the decentralized network to modify a state of the at least one first node based on the transaction and a state of the storage of the at least one additional smart contract module;
receive an electronic message (1) from a second node of the decentralized network and (2) including commands that cause, when executed, execution of a server-side functionality of the smart contract module to read from and write to the persistent storage volume or the volatile system memory, based on server-side logic within the smart contract module; and
in response to receiving the electronic message from the second node of the decentralized network, execute, in the stateless virtual machine execution environment, the server-side functionality of the smart contract module to modify the state stored in the persistent storage volume or the volatile system memory.
12 . The non-transitory, processor-readable medium of claim 11 , wherein the transaction once broadcasted is validated and executed independently of the execution of the client-side functionality.
13 . The non-transitory, processor-readable medium of claim 11 , wherein:
the electronic message is cryptographically signed.
14 . The non-transitory, processor-readable medium of claim 11 , wherein:
the stateless virtual machine execution environment is isolated from any client-side execution function call not associated with the client-side functionality.
15 . The non-transitory, processor-readable medium of claim 11 , wherein:
the smart contract module is associated with a first smart contract; and
the at least one additional smart contract module is associated with at least one second smart contract that is different from the first smart contract.
16 . A method, comprising:
executing, via a processor, a client-side functionality of a smart contract module in a stateless virtual machine execution environment and in response to a request placed via an application programming interface (API), to perform a read-only query of a state stored in a persistent storage volume or volatile system memory;
in response to executing the client-side functionality, constructing, via the processor, an electronic message that represents a transaction, based on the state determined from executing the client-side functionality, the electronic message further encoding commands that, when executed, cause execution of server-side contract functionality on at least one first node of a decentralized network to read from and write to a storage of at least one additional smart contract module;
broadcasting, via the processor and on the decentralized network, the electronic message that include an identifier associated with a server-side functionality to cause execution of the server-side functionality in at least one stateless virtual machine execution environment of the at least one first node of the decentralized network to modify a state of the at least one first node based on the transaction and a state of the storage of the at least one additional smart contract module;
receiving, at the processor, an electronic message (1) from a second node of the decentralized network and (2) including commands that cause, when executed, execution of a server-side functionality of the smart contract module to read from and write to the persistent storage volume or the volatile system memory, based on server-side logic within the smart contract module; and
in response to receiving the electronic message from the second node of the decentralized network, executing, via the processor and in the stateless virtual machine execution environment, the server-side functionality of the smart contract module to modify the state stored in the persistent storage volume or the volatile system memory.
17 . The method of claim 16 , wherein the transaction once broadcasted is validated and executed independently of the execution of the client-side functionality.
18 . The method of claim 16 , wherein:
the electronic message is cryptographically signed.
19 . The method of claim 16 , wherein:
the stateless virtual machine execution environment is isolated from any client-side execution function call not associated with the client-side functionality.
20 . The method of claim 16 , wherein:
the smart contract module is associated with a first smart contract; and
the at least one additional smart contract module is associated with at least one second smart contract that is different from the first smart contract.