Smart contract asynchronous execution storage based on private

Smart contract asynchronous execution storage based on private blockchain

Short answer questions

Please briefly describe the basic ideas and advantages of asynchronous execution of smart contracts.

What problems does Ethereum's smart contract execution model have? How does private blockchain solve these problems?

In the SCAM model, what tasks are blockchain nodes and transaction processors responsible for respectively?

Please explain what the five-tuple in the private blockchain execution state machine: (qnode, ∑mode, δnode, snode, Fnode) represent respectively?

What are the state transition functions (δexecutor) in the transaction processor execution state machine? Please give examples to illustrate their triggering conditions and executed operations.

Why is the storage structure of private blockchain suitable for using relational databases?

Why should the state storage of smart contracts adopt key-value format?

Please list and explain the three variables that need to be set in the kv database in the storage structure module that supports SCAM and their meanings.

What are the functions of the executor and the calculator in the smart contract module respectively?

Why should the contract code execution part be executed in Docker?

Answers to short-answer questions

The basic idea of ​​asynchronous execution of smart contracts is to extract the calculation of contracts from the calculation of blocks, and process transactions asynchronously without affecting the consistency of states. The advantage of doing so is that it can improve transaction processing efficiency and shorten block generation time.

The smart contract execution model of Ethereum includes contract calculations in the block production time, resulting in slow speed, and the possibility of rolling back historical data stored in the public chain makes it difficult to separate block calculations from transaction calculations. The blocks of private blockchains have instant finality, which can separate block calculations from transaction calculations and improve efficiency.

In the SCAM model, blockchain nodes are responsible for verifying the source of transactions, linking correct transactions into the blockchain, and providing the latest state value when calculating new blocks. The transaction processor is responsible for processing transactions in the blockchain in sequence and updating the latest state to the database.

The five-tuple represents: qnode is the state set of nodes in the private blockchain; ∑mode is the set of inputs (events); δnode is the set of state transition functions; snode is the initial state; Fnode is the set of terminal states. Together, they describe the behavior of the private blockchain execution state machine.

The state transition functions in the transaction processor execution state machine include: processing new transactions, querying status, verifying status, generating new blocks, etc. For example, when a new transaction is received, the transaction processor triggers the "process new transaction" function and puts the transaction into the queue to be processed.

Once the block data of the private blockchain is stored, it does not need to be modified, which is consistent with the characteristics of relational databases. Relational databases can ensure data consistency and integrity and are suitable for storing blockchain data.

The state of smart contracts needs to be updated frequently, and asynchronous execution requires the storage of a large amount of temporary data. Key-value databases can read and write data efficiently and are suitable for storing smart contract states.

For example: "State_root" represents the state tree root of the latest processed transaction; "State_height" represents the height of the block where the latest processed transaction is located; "block:i tran:j" records the state root and results of the transaction with block height i and transaction sequence number j after successful processing. These variables are used to record and track the progress and results of transaction processing.

The executor is responsible for communicating with the node, receiving transaction requests and forwarding them to the calculator. Compute is responsible for executing the smart contract code and returning the calculation results to the executor.

Placing the contract code execution part in a Docker container can improve security, isolate the contract code from the node environment, and prevent malicious code from attacking the node system.


Glossary

Term Definition Smart contract is a program code stored on the blockchain that can automatically execute the contract terms. Asynchronous execution is an execution method that disrupts the execution order of tasks without affecting the correctness of the results to improve efficiency. SCAM (Smart Contract Asynchronous Execution Model) is an execution model that separates smart contract calculations from block calculations to improve efficiency. Blockchain is a distributed ledger technology that connects data blocks in chronological order and uses cryptography to ensure data security and immutability. Private blockchain refers to a blockchain with restricted access, where only authorized nodes can participate. State machine is an abstract model used to describe the behavior of a system transitioning between different states. Transaction processor is responsible for executing smart contract code and updating the blockchain state. State tree is a data structure used to store and manage smart contract states, usually implemented as a Merkle tree. gRPC is a high-performance, open-source remote procedure call (RPC) framework for building distributed systems. Docker is a containerization platform that can package applications and their dependencies into a portable container and run them in any environment.