Contract ordering execution method in multi-chain parallel architecture
By introducing a master election service and a contract orderer, the problem of state uncertainty during contract calls in a multi-chain parallel structure is solved, achieving efficient contract deployment and execution and ensuring the consistency of the final state.
Patent Information
- Application Number
- CN202310534557.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-12
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-05-12
AI Technical Summary
In a multi-chain parallel blockchain system, there is a problem that the final state cannot be confirmed when smart contracts are generated and invoked.
A master election service is introduced to assign contract orderers. Contract orderers are responsible for sorting contract transactions and querying the contract orderer through the master election service to ensure uniqueness and rationality. Contract orderers complete the deployment and execution of contracts in the account chain.
It achieves efficient contract transaction processing, avoids uncertainty in contract data state, and ensures the consistency of the final state when multiple chains are called in parallel.
Smart Images

Figure CN116566576B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain, specifically a method for ordering and executing contracts in a multi-chain parallel structure. Background Technology
[0002] Traditional blockchains are single chains composed of blocks, which can only be written synchronously and sequentially according to block production time. In contrast, blockchains based on the DAG structure are networks composed of transactions, supporting asynchronous concurrent accounting and mutual verification. Compared to traditional single-chain blockchain structures, they have significant advantages in scalability and transaction speed. For example, patent application number 202111086285.1 specifically discloses a DAG blockchain structure system based on an account chain and a guardian chain, including: a sender account chain, a receiver account chain, and a guardian chain; the sender account chain is used to create a transaction sending block when a transaction needs to be initiated, to sign the transaction sending block with a private key to obtain a signed transaction sending block, and to broadcast the signed transaction sending block; the receiver account chain is used to create a transaction receiving block after the signed transaction sending block is witnessed in the account chain witness network, and to establish a first block key between the transaction receiving block and the transaction sending block; the sender account chain is also used to send transfer transactions based on the transaction sending block; the receiver account chain is also used to receive the transfer transactions based on the transaction receiving block; the guardian chain is used to obtain the first current state information of the transaction sending block and the second current state information of the transaction receiving block, to package the first current state information and the second current state information, and to store the packaged first current state information and the second current state information to safeguard the transfer transaction. The sender account chain is further configured to create a contract deployment block when a contract needs to be deployed, and publish contract transactions through the contract deployment block; the guardian chain is further configured to deploy contracts according to the contract deployment block; the receiver account chain is further configured to create a contract execution block when a contract needs to be executed, establish a second block key between the contract deployment block and the contract execution block, and call the contract transaction through the contract execution block; the guardian chain is further configured to execute contracts according to the contract execution block, and obtain the third current state information of the contract deployment block and the fourth current state information of the contract execution block, package the third current state information and the fourth current state information, and store the packaged third current state information and the fourth current state information to complete the contract call process. Optionally, the guardian chain includes: a genesis block and a guardian block; the genesis block is used to start the guardian chain and store the configuration information of the guardian chain; the guardian block is used to obtain the third current state information of the contract deployment block and the fourth current state information of the contract execution block, package the third current state information and the fourth current state information, and store the packaged third current state information and the fourth current state information to complete the guardianship of the account chain.Optionally, the sender account chain is further configured to establish a first crosslink key pointing to the guardian block based on the transaction sending block when creating a transaction sending block, and to establish a second crosslink key pointing to the guardian block based on the contract deployment block when creating a contract deployment block; the receiver account chain is further configured to establish a third crosslink key pointing to the guardian block based on the transaction receiving block when creating a transaction receiving block, and to establish a fourth crosslink key pointing to the guardian block based on the contract execution block when creating a contract execution block; the guardian chain is further configured to obtain the first current state information based on the first crosslink key, the second current state information based on the second crosslink key, the third current state information based on the third crosslink key, and the fourth current state information based on the fourth crosslink key, so as to complete the consensus protection of the transaction sending block, the transaction receiving block, the contract deployment block, and the contract execution block. Optionally, the sender account chain, the receiver account chain, and the guardian chain form a directed acyclic graph chain structure based on the first block key, the second block key, the first crosslinking key, the second crosslinking key, the third crosslinking key, and the fourth crosslinking key.
[0003] In addition, patents with application numbers 2021111360890 and 2021114045559 also introduce blockchain systems with this DAG structure.
[0004] In DAG blockchains that support smart contracts, the generation and invocation of smart contracts are initiated by account nodes on the account chain, which is a multi-chain parallel transaction structure. When different account chains invoke a contract simultaneously, multiple chains may read or modify the data within the contract at the same time, making it impossible to confirm the final state.
[0005] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0006] The purpose of this invention is to solve the above-mentioned problems and provide a method for ordering and executing contracts in a multi-chain parallel structure.
[0007] To achieve the above objectives, the technical solution of the present invention is as follows: A contract ordering and execution method in a multi-chain parallel architecture includes a master election service, which is responsible for allocating contract orderers, and the contract orderers are responsible for ordering the transactions of the contracts assigned to them. The method includes the following steps: S1. The account chain node initiates a contract request, which includes a contract deployment request and a contract execution request; Step S2 is performed in two cases: For a contract deployment request, the following steps are executed: S21. Assign the contract orderer for the contract through the master election service; For a contract execution request, the execution steps are: S22. Query the contract orderer assigned by the contract orderer service during the deployment phase through the orderer service; S3. Send the contract request to the contract orderer of the contract; S4. After receiving a contract request, the contract sorter determines whether it is the contract sorter for that contract. If so, the contract request is added to the list to be sorted; otherwise, it is not added to the list to be sorted. S5. The contract sorter sorts the contract transactions in the current unsorted list according to time order, and then packages them into a contract transaction block and broadcasts it based on the actual deployment or execution of the contract transactions. S6. Other nodes receive the contract transaction block, verify its execution, and update the ledger.
[0008] Furthermore, only designated contract sorters can sort transactions for the corresponding contracts, and only witness nodes have the right to act as contract sorters.
[0009] In step S21, if the contract does not call other contracts, the master service selects the witness node with the least pressure to become the orderer of the contract; if other contracts are called, assuming that the orderers of the other contracts are the same, the same witness node is selected to become the orderer of the contract.
[0010] After the main service assigns the contract sorters, it uploads the assignment results to the blockchain.
[0011] Once a contract sorter is successfully assigned, the order of subsequent transactions for that contract will be determined by the assigned contract sorter.
[0012] After the main service assigns the contract orderers, the assignment results are uploaded to the blockchain and can be viewed on the blockchain.
[0013] In addition, the present invention also provides a contract ordering and execution system in a multi-chain parallel structure, including a master selection module. The master selection module provides a contract ordering service to assign a unique contract ordering for a certain contract. The master selection module also provides a contract ordering query service to provide a unique contract ordering for querying a contract externally or internally.
[0014] In addition, the present invention also provides a contract ordering and execution device in a multi-chain parallel structure, comprising: a memory, a processor, and a contract ordering and execution program in a multi-chain parallel structure stored in the memory and executable on the processor, wherein the contract ordering and execution program in the multi-chain parallel structure is configured to implement a contract ordering and execution method in the multi-chain parallel structure.
[0015] The present invention also provides a storage medium storing a contract sorting and execution program in a multi-chain parallel structure, wherein the contract sorting and execution program in the multi-chain parallel structure, when executed, implements a contract sorting and execution method in the multi-chain parallel structure.
[0016] By adopting the above technical solution, the present invention has the following advantages: 1. The smart contract transactions of this invention can be completed without the need for execution by a guardian chain, which is highly efficient.
[0017] 2. This invention solves the problem of not being able to confirm the final state when multiple chains call contracts in parallel or change contract data.
[0018] 3. This invention is also applicable to scenarios where contracts that read on-chain information and other contract data need to confirm the final state of a contract during multi-chain parallel calls. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the specific process of the present invention. Detailed Implementation
[0020] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0021] Example 1: In order to solve the problem that the final state cannot be confirmed due to multi-chain parallel call to contracts and changes in contract data, the present invention provides a contract ordering execution method in a multi-chain parallel structure.
[0022] This invention is equipped with a master selection service, which is located in the service interface layer of the blockchain structure. It is responsible for allocating appropriate contract orderers, and the contract orderers are responsible for ordering the contracts and deploying and executing related procedures.
[0023] If the contract does not call any other contracts, the witness node with the least pressure is selected as the contract sorter. If the contract calls other contracts, assuming the other contracts have the same contract sorter, that same witness node is selected as the contract sorter. Only the designated contract sorter can sort the transactions of the corresponding contract, and only witness nodes have the right to act as contract sorters.
[0024] After the main service assigns a suitable contract sorter, it records the assignment result on the blockchain, which is then verifiable on the blockchain, and notifies the contract sorter of the assignment result.
[0025] The contract sorter assigned by the main service is unique. Once the contract sorter is successfully assigned, the order of subsequent transactions for that contract will be sorted by the assigned contract sorter, and the contract sorter will not be changed.
[0026] The master selection service is also responsible for providing query services to external or internal entities to query the contract ordering entity assigned to a particular contract.
[0027] The deployment and execution of smart contracts in this invention are completed within the account chain. Therefore, the contract orderer and related nodes in this invention refer to nodes within the account chain.
[0028] The contract ordering and execution method in a multi-chain parallel structure of the present invention includes the following steps: S1. The account chain node initiates a contract request, which includes a contract deployment request and a contract execution request; Step S2 is performed in two cases: For a contract deployment request, the following steps are executed: S21. Assign the contract orderer for the contract through the master election service; For a contract execution request, the execution steps are: S22. Query the contract orderer assigned by the contract orderer service during the deployment phase through the orderer service; S3. Send the contract request to the contract orderer of the contract; S4. After receiving a contract request, the contract sorter determines whether it is the contract sorter for that contract. If so, the contract request is added to the list to be sorted; otherwise, it is not added to the list to be sorted. S5. The contract sorter sorts the contract transactions in the current unsorted list according to time order, and then packages them into a contract transaction block and broadcasts it based on the actual deployment or execution of the contract transactions. S6. Other nodes receive the contract transaction block, verify its execution, and update the ledger.
[0029] This invention initiates contract deployment and execution requests through account chain nodes and uses a master election service. Smart contract transactions can be completed without going through the guardian chain, which is highly efficient. Furthermore, when multiple chains call contracts in parallel and change contract data, the final state can still be well confirmed.
[0030] like Figure 1 As shown, the specific contract deployment process of this invention is as follows: D1.Node0: The account outkey initiates a contract deployment request and generates contract deployment block D; D2. The contract ordering witness node Node1 is selected by the main election service for D, and the result is notified to witness node Node1. D3.Node1 adds D to the unsorted list cArray; D4.Node1 generates and broadcasts the contract transaction block C1 based on the current list cArray; D5. Other nodes receive C1, verify and execute it, and update the ledger.
[0031] The contract execution process of this invention is as follows: E1. Node0: account_outkey initiates a contract execution request, calling D to generate contract execution block E1; at the same time, Node2: saintkey also initiates a contract execution request, calling D to generate contract execution block E2; E2. Query the contract ordering mechanism of D through the master election service and find that Node1 is the ordering mechanism, and send the contract execution request to Node1; E3.Node1 receives two transactions and determines that it is the one that sorts the contracts. Therefore, it adds E1 and E2 to the unsorted list cArray. E4.Node1 packages E1 and E2 into the contract transaction block C2 in order according to the current list cArray and broadcasts it. E5. Other nodes receive C2, verify and execute, and update the ledger.
[0032] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of this invention. In practical applications, those skilled in the art can select some or all of the workflow to achieve the purpose of the invention according to actual needs, and no restrictions are imposed here.
[0033] Example 2: In addition, this embodiment of the invention also proposes a contract ordering execution system in a multi-chain parallel structure, including a master selection module. The master selection module provides a contract ordering service to assign a unique contract ordering for a certain contract. The master selection module also provides a contract ordering query service to query the unique contract ordering for a contract externally or internally.
[0034] Furthermore, this embodiment is merely a basic description of the contract ordering and execution system in the multi-chain parallel structure of the present invention. For technical details not described in detail in this embodiment, please refer to the methods provided in any embodiment of the present invention, which will not be repeated here.
[0035] Example 3: Those skilled in the art will clearly understand that the systems and methods of the above embodiments can be implemented using software plus necessary general-purpose hardware platforms. Of course, they can also be implemented using hardware, but in many cases, the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory (ROM) / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, node packaging device, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0036] Therefore, the present invention also provides a contract ordering execution device in a multi-chain parallel structure, comprising: a memory, a processor, and a contract ordering execution program in a multi-chain parallel structure stored in the memory and executable on the processor, wherein the contract ordering execution program in the multi-chain parallel structure is configured to implement a contract ordering execution method in the multi-chain parallel structure.
[0037] In addition, the present invention also provides a storage medium on which a contract ordering execution program in a multi-chain parallel structure is stored.
[0038] In reality, when deploying equipment or programs, a program may execute all steps, or it may execute only one step, with multiple programs working together to achieve the full process. Therefore, when the contract ordering execution program in the multi-chain parallel structure is executed, it implements all or a certain process of the contract ordering execution method in the multi-chain parallel structure.
[0039] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are included within the patent protection scope of the present invention.
Claims
1. A contract ordering execution method in a multi-chain parallel structure, characterized in that, The method includes a master selection service, which is responsible for assigning contract orderers, and the contract orderers are responsible for ordering the transactions of the contracts assigned to them. The method includes the following steps: S1. The account chain node initiates a contract request, which includes a contract deployment request and a contract execution request; Step S2 is performed in two cases: For a contract deployment request, step S21 is executed. The contract orderer for the contract is assigned through the main election service; For a contract execution request, execute step S22. Query the contract orderer assigned by the contract orderer service during the deployment phase through the orderer service; S3. Send the contract request to the contract orderer of the contract; S4. After receiving a contract request, the contract sorter determines whether it is the contract sorter for that contract. If so, the contract request is added to the list to be sorted; otherwise, it is not added to the list to be sorted. S5. The contract sorter sorts the contract transactions in the current unsorted list according to time order, and then packages them into a contract transaction block and broadcasts it based on the actual deployment or execution of the contract transactions. S6. Other nodes receive the contract transaction block, verify its execution, and update the ledger; The contract sorter and other nodes refer to nodes in the account chain.
2. The contract ordering and execution method in a multi-chain parallel structure according to claim 1, characterized in that, Only designated contract sorters can sort transactions for the corresponding contracts, and only witness nodes have the right to act as contract sorters.
3. The contract ordering and execution method in a multi-chain parallel structure according to claim 1, characterized in that, In step S21, if the contract does not call other contracts, the master service selects the witness node with the least pressure to become the orderer of the contract; if other contracts are called, assuming that the orderers of the other contracts are the same, the same witness node is selected to become the orderer of the contract.
4. The contract ordering and execution method in a multi-chain parallel structure according to claim 1, characterized in that, Once a contract sorter is successfully assigned, the order of subsequent transactions for that contract will be determined by the assigned contract sorter.
5. The contract ordering and execution method in a multi-chain parallel structure according to claim 1, characterized in that, After the main service assigns the contract orderers, the assignment results are uploaded to the blockchain and can be viewed on the blockchain.
6. A contract ordering and execution device in a multi-chain parallel structure, characterized in that, The system includes a memory, a processor, and a contract ordering execution program in a multi-chain parallel structure stored in the memory and executable on the processor. The contract ordering execution program in the multi-chain parallel structure is configured to implement the contract ordering execution method in the multi-chain parallel structure as described in any one of claims 1 to 5.
7. A storage medium, characterized in that, The storage medium stores a contract ordering execution program in a multi-chain parallel structure. When executed, the contract ordering execution program in the multi-chain parallel structure implements the contract ordering execution method in the multi-chain parallel structure as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Systems and methods based on DAG blockchain structures of account chain and guardian chain
CN113837754B
Intelligent contract increment sorting execution method, system and device under DAG structure based on account chain and daemon chain, and storage medium
CN114119223A
