Docker VM-based under-chain smart contract execution method

By deploying state management contracts and off-chain application contracts on the blockchain, and using DockerVM to execute off-chain application contracts, the scalability and privacy issues of the blockchain are solved, efficient and secure smart contract execution is achieved, and the system is improved. scalability and user privacy protection.

CN118627121APending Publication Date: 2024-09-10BEIHANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410827952.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

The global copy storage and execution model of the blockchain leads to poor scalability, and the transparency of smart contracts exposes privacy protection issues. There is an urgent need for a solution to transfer contract transactions on the chain to off-chain while meeting the business needs of privacy contracts.

Method used

Adopt an off-chain smart contract execution method based on DockerVM and go through four stages: deploying on-chain state management contracts, adding off-chain application contracts, calling off-chain application contracts and updating checkpoints, using DockerVM as the execution environment for off-chain application contracts. Achieve safe and efficient execution of off-chain smart contracts.

Benefits of technology

Significantly improve transaction processing speed, reduce contract execution costs, improve system scalability, enhance user privacy protection, promote interoperability of different blockchain platforms, reduce pressure on the main chain, maintain efficient operation of blockchain networks, and promote the development of DApps Innovation and diversified development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118627121A
    Figure CN118627121A
Patent Text Reader

Abstract

The invention discloses an under-chain intelligent contract execution method based on Docker VM, and belongs to the field of block chains, and the method comprises four stages: deploying an on-chain state management contract, adding an under-chain application contract, calling the under-chain application contract, and updating a check point. The participants comprise an on-chain state management contract, an off-chain operator node and an off-chain user. According to the under-chain intelligent contract execution method based on the Docker VM, the Docker VM is used as an execution environment of the under-chain application contract, a safe and efficient under-chain application contract execution mechanism is constructed, contract transactions on a chain are transferred to under-chain execution, and the pressure of the transactions on the chain is relieved while the execution effectiveness of the under-chain application contract is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of blockchain, and in particular to an off-chain smart contract execution method based on DockerVM. Background Art

[0002] Blockchain provides an environment where all parties can transparently and securely interact peer-to-peer without the need for a trusted third party. All parties can trust the integrity and correctness of transactions and the verifiable execution of binary code on the blockchain (smart contracts) within the system. However, in typical blockchains such as Ethereum, each node stores a copy of all smart contracts. In order to achieve global consensus, each node needs to redundantly execute all smart contract transactions. This globally replicated storage and execution model provides poor scalability, so Ethereum's smart contract platform strictly limits the computational complexity and size of contracts. On the other hand, due to the transparency of blockchain, the execution and transaction data of smart contracts are visible to all network participants, which may expose sensitive information in some cases and raise concerns about privacy protection.

[0003] In order to solve the scalability and privacy issues of blockchain, off-chain processing technology has been proposed. Off-chain processing refers to the technology of processing transactions or data outside the blockchain main network, aiming to reduce the burden of the main network, improve processing speed and reduce transaction costs. Now there is an urgent need for a solution that can meet the business needs of privacy contracts while transferring on-chain application contract transactions to off-chain. Summary of the invention

[0004] The purpose of the present invention is to provide an off-chain smart contract execution method based on DockerVM to solve the problems mentioned in the above background technology.

[0005] To achieve the above-mentioned purpose, the present invention provides an off-chain smart contract execution method based on DockerVM: comprising four stages, namely, deploying an on-chain state management contract, adding an off-chain application contract, calling an off-chain application contract and updating a checkpoint; the participating entities include an on-chain state management contract, an off-chain operator node and an off-chain user;

[0006] Deploy the on-chain state management contract. After deploying the on-chain state management contract on the blockchain platform, a contract address with an identifier is obtained. The on-chain state management contract initialization is applicable to all blockchain platforms with smart contract functions. For different blockchain platforms, different tool chains are used to deploy channel smart contracts.

[0007] Add an off-chain application contract. The off-chain user first writes the corresponding application contract according to the contract template, obtains an application ID after deploying the application contract on the chain, and then adds the deployed application contract address to the application list of the on-chain state management contract through the on-chain state management contract. Finally, the off-chain operator node deploys the application contract to the local virtual machine environment (DockerVM);

[0008] Calling off-chain application contracts: Off-chain users request off-chain operator nodes to call off-chain application contracts. Off-chain operator nodes verify and execute transactions and return receipts. At the same time, they execute off-chain application contracts and update off-chain status databases based on the information of each transaction.

[0009] Update the checkpoint. If the off-chain user finds that the off-chain operator node does not execute the transaction correctly or does not update the off-chain database, the off-chain user will initiate a challenge in the on-chain state management contract according to the challenge mechanism. If the challenge is successful, the off-chain state will be rolled back.

[0010] Preferably, deploying the on-chain state management contract includes the following steps:

[0011] SA1. The off-chain operator node deploys the on-chain state management contract on the blockchain network and obtains the contract address after deployment;

[0012] SA2. The off-chain operator node registers its identity in the on-chain state management contract. After successful registration, the network address of the off-chain operator node is made public in the on-chain state management contract.

[0013] SA3. Off-chain operator nodes run off-chain services and receive off-chain application contract deployment and execution requests from off-chain users.

[0014] Preferably, adding an off-chain application contract specifically includes the following steps:

[0015] SB1. Off-chain users write application contract codes based on contract templates;

[0016] SB2. Off-chain users compile the application contract locally and deploy the application contract on the blockchain to obtain the on-chain address of the on-chain application contract. The contents of the on-chain application contract and the off-chain application contract are consistent.

[0017] SB3. The off-chain user sends an application contract add message to the on-chain state management contract, where the add message includes the hash of the application contract and the on-chain application contract address;

[0018] SB4. Off-chain users send files and hashes of off-chain application contracts to off-chain operator nodes;

[0019] SB5. The off-chain operator node checks whether the file and hash of the off-chain application contract are consistent with the on-chain application contract hash registered by the state management contract;

[0020] After SB6 and SB5 are verified, the off-chain operator node deploys the off-chain application contract in the local DockerVM.

[0021] Preferably, the steps of calling the off-chain application contract include:

[0022] SC1. Off-chain users initiate off-chain application contract execution requests to off-chain operator nodes. The execution request includes the contract ID to be executed and the operation to be executed.

[0023] SC2, the off-chain operator node checks the legitimacy of the execution request in SC1;

[0024] SC3. In DockerVM, execute the off-chain application contract according to the contract ID and input operation OP provided by the execution request, and realize the id i To State id i+1 Updates;

[0025] SC4. The off-chain operator node modifies the off-chain state database according to the execution results of the off-chain application contract. At the same time, the off-chain operator node generates a new execution state ES every time the off-chain application contract is executed. i :

[0026] ES i =H(State id i ||Tx i );

[0027] SC5. The off-chain operator node returns the execution result of the contract to the off-chain user;

[0028] SC6. Off-chain operators regularly submit checkpoints to the on-chain state management contract, where the checkpoints include the execution state sequence within a period;

[0029] SC7. If the checkpoint submitted by the off-chain operating node is correct, the checkpoint will take effect after a given challenge period, otherwise the off-chain user will initiate a challenge.

[0030] Preferably, the challenge mechanism steps are as follows:

[0031] SD1. Initial state of off-chain users id i-1 、The last executed transaction Tx i-1 , currently executing transaction Tx i , the state after execution id i And the application logo APP idSubmit to the on-chain state management contract;

[0032] SD2. Check the application APP of the specified on-chain application contract id exists;

[0033] SD3, according to the initial state State id i-1 And executed transactions Tx i-1 Generate execution status ES i-1 ', judge the generated execution status and the ES of the on-chain state management contract i-1 equal;

[0034] SD4. Call the specified on-chain application contract on the chain and set the initial state State id i-1 and execute transactions Tx i-1 , input into the on-chain application contract;

[0035] SD5. Determine the ES returned by the on-chain application contract i 'ES with on-chain state manager i Are they consistent? If not, the challenge is successful.

[0036] SD6. Delete ES on the on-chain state management contract i The subsequent execution status.

[0037] Therefore, the present invention adopts the above-mentioned off-chain smart contract execution method based on DockerVM, which has the following beneficial effects:

[0038] (1) Significantly improve transaction processing speed, significantly reduce the cost of contract execution, improve the scalability of the entire system, enhance user privacy protection, provide design flexibility, and promote interoperability between different blockchain platforms;

[0039] (2) Off-chain smart contracts can also reduce the pressure on the main chain, maintain the efficient operation and stability of the blockchain network, and promote the innovation of blockchain technology and the development of various blockchain applications;

[0040] (3) Off-chain smart contracts have become the core solution to the challenges facing blockchain, providing higher efficiency and lower costs for decentralized applications, and promoting the innovation and diversified development of DApps.

[0041] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 This is an overall framework diagram of the off-chain application contract execution method of an embodiment of the present invention;

[0043] Figure 2 This is a flow chart of adding an off-chain application contract in an embodiment of the present invention;

[0044] Figure 3 This is a flowchart of calling an off-chain application contract in an embodiment of the present invention;

[0045] Figure 4 Flow chart of the challenge mechanism of an embodiment of the present invention. DETAILED DESCRIPTION

[0046] Example

[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] Reference Figure 1 and Figure 2 , the present invention discloses an off-chain smart contract execution method based on DockerVM, which includes four stages, namely, deploying an on-chain state management contract, adding an off-chain application contract, calling an off-chain application contract, and updating a checkpoint; the participating entities include an on-chain state management contract, an off-chain operator node, and an off-chain user;

[0049] Deploy the on-chain state management contract. After deploying the on-chain state management contract on the blockchain platform, you will get a contract address with an identifier. The on-chain state management contract initialization is applicable to all blockchain platforms with smart contract functions. For different blockchain platforms, different tool chains are used to deploy channel smart contracts.

[0050] Deploying the on-chain state management contract consists of the following steps:

[0051] SA1. The off-chain operator node deploys the on-chain state management contract on the blockchain network and obtains the contract address after deployment;

[0052] SA2. The off-chain operator node registers its identity in the on-chain state management contract. After successful registration, the network address of the off-chain operator node is made public in the on-chain state management contract.

[0053] SA3. Off-chain operator nodes run off-chain services and receive off-chain application contract deployment and execution requests from off-chain users.

[0054] To add an off-chain application contract, the off-chain user first writes the corresponding application contract according to the contract template, obtains an application ID after deploying the application contract on the chain, and then adds the deployed application contract address to the application list of the on-chain state management contract through the on-chain state management contract. Finally, the off-chain operator node deploys the application contract to the local virtual machine environment.

[0055] Adding an off-chain application contract specifically includes the following steps:

[0056] SB1. Off-chain users write application contract codes based on contract templates;

[0057] SB2. Off-chain users compile the application contract locally and deploy the application contract on the blockchain to obtain the on-chain address of the on-chain application contract. The contents of the on-chain application contract and the off-chain application contract are consistent.

[0058] SB3. The off-chain user sends an application contract add message to the on-chain state management contract, where the add message includes the hash of the application contract and the on-chain application contract address;

[0059] SB4. Off-chain users send files and hashes of off-chain application contracts to off-chain operator nodes;

[0060] SB5. The off-chain operator node checks whether the file and hash of the off-chain application contract are consistent with the on-chain application contract hash registered by the state management contract;

[0061] After SB6 and SB5 are verified, the off-chain operator node deploys the off-chain application contract in the local DockerVM.

[0062] Call the off-chain application contract. The off-chain user requests the off-chain operator node to call the off-chain application contract. The off-chain operator node verifies and executes the transaction and returns the execution receipt. At the same time, it executes the off-chain application contract according to the information of each transaction and updates the off-chain status database.

[0063] The steps to call an off-chain application contract include:

[0064] SC1. Off-chain users initiate off-chain application contract execution requests to off-chain operator nodes. The execution request includes the contract ID to be executed and the operation to be executed.

[0065] SC2, the off-chain operator node checks the legitimacy of the execution request in SC1;

[0066] SC3. In DockerVM, execute the off-chain application contract according to the contract ID and input operation OP provided by the execution request, and realize the id i To State id i+1 Updates;

[0067] SC4. The off-chain operator node modifies the off-chain state database according to the execution results of the off-chain application contract. At the same time, the off-chain operator node generates a new execution state ES every time the off-chain application contract is executed. i :

[0068] ES i =H(State id i ||Tx i );

[0069] SC5. The off-chain operator node returns the execution result of the contract to the off-chain user;

[0070] SC6. Off-chain operators regularly submit checkpoints to the on-chain state management contract, where the checkpoints include the execution state sequence within a period;

[0071] SC7. If the checkpoint submitted by the off-chain operating node is correct, the checkpoint will take effect after a given challenge period, otherwise the off-chain user will initiate a challenge.

[0072] Update the checkpoint. If the off-chain user finds that the off-chain operator node does not execute the transaction correctly or does not update the off-chain database, the off-chain user will initiate a challenge in the on-chain state management contract according to the challenge mechanism. If the challenge is successful, the off-chain state will be rolled back.

[0073] The challenge mechanism steps are as follows:

[0074] SD1. Initial state of off-chain users id i-1 、The last executed transaction Tx i-1 , currently executing transaction Tx i , the state after execution id i And the application logo APP id Submit to the on-chain state management contract;

[0075] SD2. Check the application APP of the specified on-chain application contract id exists;

[0076] SD3, according to the initial state State id i-1 And executed transactions Tx i-1 Generate execution status ES i-1 ', judge the generated execution status and the ES of the on-chain state management contract i-1 equal;

[0077] SD4. Call the specified on-chain application contract on the chain and set the initial state Stateid i-1 and execute transactions Tx i-1 , input into the on-chain application contract;

[0078] SD5. Determine the ES returned by the on-chain application contract i 'ES with on-chain state manager i Are they consistent? If not, the challenge is successful.

[0079] SD6. Delete ES on the on-chain state management contract i The subsequent execution status.

[0080] On-chain state management contract: On-chain application contracts refer to smart contracts pre-deployed on the blockchain, which are used to add and delete the state of off-chain applications and off-chain nodes. Off-chain applications need to add applications and nodes through the on-chain manager.

[0081] Off-chain operator node: The off-chain operator node is used to run off-chain application contracts and maintain off-chain status. The off-chain operator node runs the off-chain application contract through the local virtual machine to update the off-chain status and update the off-chain status to the on-chain status management contract.

[0082] Off-chain users: Off-chain users do not need to participate in the maintenance of off-chain status. They can complete the execution requirements of smart contracts by deploying and requesting off-chain application contracts to execute.

[0083] Therefore, the present invention adopts the above-mentioned off-chain smart contract execution method based on DockerVM, uses DockerVM as the execution environment of the off-chain application contract, builds a safe and efficient off-chain application contract execution mechanism, and is committed to transferring on-chain contract transactions to off-chain execution, thereby alleviating the pressure of on-chain transactions while ensuring the effectiveness of off-chain application contract execution.

[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.

Claims

1. A method for executing off-chain smart contracts based on DockerVM, characterized in that: It includes four stages, namely deploying the on-chain state management contract, adding the off-chain application contract, calling the off-chain application contract and updating the checkpoint; the participants include the on-chain state management contract, the off-chain operator node and the off-chain user; Deploy the on-chain state management contract. After deploying the on-chain state management contract on the blockchain platform, you will get a contract address with an identifier. For different blockchain platforms, different tool chains are used to deploy channel smart contracts. To add an off-chain application contract, the off-chain user first writes the corresponding application contract according to the contract template, obtains an application ID after deploying the application contract on the chain, and then adds the deployed on-chain application contract address to the application list of the on-chain state management contract through the on-chain state management contract. Finally, the off-chain operator node deploys the off-chain application contract to the local virtual machine environment; Calling off-chain application contracts: Off-chain users request off-chain operator nodes to call off-chain application contracts. Off-chain operator nodes verify and execute transactions and return receipts. At the same time, they execute off-chain application contracts and update off-chain status databases based on the information of each transaction. Update the checkpoint. If the off-chain user finds that the off-chain operator node does not execute the transaction correctly or does not update the off-chain database, the off-chain user will initiate a challenge in the on-chain state management contract according to the challenge mechanism. If the challenge is successful, the off-chain state will be rolled back.

2. According to the DockerVM-based off-chain smart contract execution method of claim 1, it is characterized in that: Deploying the on-chain state management contract consists of the following steps: SA1. The off-chain operator node deploys the on-chain state management contract on the blockchain network and obtains the on-chain state management contract address after deployment; SA2. The off-chain operator node registers its identity in the on-chain state management contract. After successful registration, the network address of the off-chain operator node is made public in the on-chain state management contract. SA3. Off-chain operator nodes run off-chain services and receive off-chain application contract deployment and execution requests from off-chain users.

3. According to the DockerVM-based off-chain smart contract execution method of claim 2, it is characterized in that: Adding an off-chain application contract specifically includes the following steps: SB1. Off-chain users write application contract codes based on contract templates; SB2. Off-chain users compile the application contract locally and deploy the application contract on the blockchain to obtain the on-chain address of the on-chain application contract. The contents of the on-chain application contract and the off-chain application contract are consistent. SB3. The off-chain user sends an on-chain application contract add message to the on-chain state management contract, where the add message includes the hash of the on-chain application contract and the on-chain application contract address; SB4. Off-chain users send files and hashes of off-chain application contracts to off-chain operator nodes; SB5. The off-chain operator node checks whether the file and hash of the off-chain application contract are consistent with the on-chain application contract hash registered by the state management contract; After the verification of SB6 and SB5 is passed, the off-chain operator node deploys the off-chain application contract in the local virtual machine environment.

4. According to claim 3, a method for executing an off-chain smart contract based on DockerVM is characterized in that: The steps to call an off-chain application contract include: SC1. Off-chain users initiate off-chain application contract execution requests to off-chain operator nodes. The execution request includes the contract ID to be executed and the operation to be executed. SC2, the off-chain operator node checks the legitimacy of the execution request in SC1; SC3. In DockerVM, execute the off-chain application contract according to the off-chain application contract ID and input operation OP provided by the execution request, and realize the id i To State id i+1 Updates; SC4. The off-chain operator node modifies the off-chain state database according to the execution results of the off-chain application contract. At the same time, the off-chain operator node generates a new execution state ES every time the off-chain application contract is executed. i : ES i =H(State id i ||Tx i ); SC5. The off-chain operator node returns the execution result of the contract to the off-chain user; SC6. Off-chain operators regularly submit checkpoints to the on-chain state management contract, where the checkpoints include the execution state sequence within a period; SC7. If the checkpoint submitted by the off-chain operating node is correct, the checkpoint will take effect after a given challenge period, otherwise the off-chain user will initiate a challenge.

5. According to the DockerVM-based off-chain smart contract execution method of claim 4, it is characterized in that: The challenge mechanism in SC7 works as follows: SD1. Initial state of off-chain users id i-1 、The last executed transaction Tx i-1 , currently executing transaction Tx i , the state after execution id i And the application logo APP id Submit to the on-chain state management contract; SD2. Check the application APP of the specified on-chain application contract id exists; SD3, according to the initial state State id i-1 And executed transactions Tx i-1 Generate execution status ES i-1 ', judge the generated execution status and the ES of the on-chain state management contract i-1 equal; SD4. Call the specified on-chain application contract on the chain and set the initial state State id i-1 and execute transactions Tx i-1 , input into the on-chain application contract; SD5. Determine the ES returned by the on-chain application contract i 'ES with on-chain state manager i Are they consistent? If not, the challenge is successful. SD6. Delete ES on the on-chain state management contract i The subsequent execution status.