Smart Contract Release System
Smart Contract Source Code:
Describes a Turing-incomplete smart contract source code for a blockchain network that allows static analysis at release time.
The source code uses a non-compiled high-level language (such as a Lisp-like language), which helps avoid errors that may be introduced during the compilation process.
Data Maps:
The data map is a key component in a smart contract for storing and associating data, consisting of a key-tuple and a value-tuple.
Both the key-tuple and the value-tuple have known data types that determine their maximum possible size, making it possible to determine the output size during static analysis.
In the example, the data map is used to store and calculate factorials, showing how to implement recursive calculations in an iterative manner.
Static Analysis:
When a smart contract is released, nodes in the blockchain network perform static analysis to determine the runtime cost and storage requirements of the smart contract.
Static analysis is implemented by building a parse tree and traversing the tree nodes, each of which represents a function or parameter in the smart contract.
The analysis considers the function's input size, output size, and the use of data mappings to calculate the maximum possible runtime cost.
Smart Contract Execution:
The execution of smart contracts is done by virtual machine (VM) instances in the blockchain network, and each VM instance resets its context when executing a smart contract.
The VM calls the smart contract's initialization function, inserts the data mapping into the data store, and updates the data mapping when executing smart contract functions.
If the smart contract execution succeeds, the changes are reflected in the blockchain state; if the execution fails, the changes are reversed.
Contract Principals:
A contract principal is an entity that can prove ownership of something, such as a digital asset.
In smart contracts, contract principals can be used to perform ownership-based operations, such as transferring money or accessing protected resources.
The example shows how to use contract principals to simulate the partial unlocking function of a multi-signature wallet.
Technical Solution:
Provides a technical solution to the problem that gas costs cannot be determined before execution in Turing-complete smart contract languages (such as Ethereum).
By limiting the functions of smart contract language (such as recursion, anonymous functions, etc.), static analysis is possible, thereby improving the transparency and predictability of smart contracts.
Summary of short answer questions:
Main technical content:
Smart contract source code: Using Turing-incomplete smart contract source code allows static analysis at the time of release.
Data mapping: used to store and associate data in smart contracts, including key tuples and value tuples, with known data types and maximum possible sizes.
Static analysis: performed at release time to determine the runtime cost and storage requirements of smart contracts, implemented by parse tree traversal.
Smart contract execution: executed by virtual machine instances in the blockchain network, supporting the initialization and update of data mapping.
Contract principals:
Contract principals are entities that can prove ownership of digital assets, etc., and are used to perform ownership-based operations.
Advantages of technical solutions:
Solved the problem that Turing-complete smart contract language cannot determine the gas cost before execution.
By limiting the functions of smart contract language, the transparency and predictability of smart contracts are improved.