Concurrent linkage execution method for intelligent contracts among multiple fragments

By selecting gateway nodes, building MPTs and using broadcast encryption communication technology in the blockchain multi-slice environment in the edge computing scenario, the problem of concurrent linkage execution of smart contracts between multiple shards is solved, and efficient collaboration between nodes and support for complex business functions is achieved.

CN119645945APending Publication Date: 2025-03-18ZHONGYUAN ENGINEERING COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411643352.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In the edge computing scenario, concurrent linkage execution of smart contracts in a multi-slicing environment of blockchain is difficult to achieve, resulting in difficulty in efficient interaction and collaboration between nodes and the inability to effectively complete complex business functions.

Method used

By selecting gateway nodes based on the node state evaluation mechanism, Merkle Patricia Tree (MPT) is built to realize the storage and sharing of smart contract directories, and use broadcast encryption communication technology to securely share contract directories between multiple shards to realize the concurrent linkage execution of smart contracts between multiple shards.

Benefits of technology

It realizes dynamic perception and linkage execution of smart contracts between multi-shackles of blockchain, improves the collaboration capabilities between nodes of blockchain system and the business processing capabilities of smart contracts, and supports the implementation of complex functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645945A_ABST
    Figure CN119645945A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of intelligent contract execution in an edge computing scene, in particular to an intelligent contract concurrent linkage execution method among multiple fragments, which comprises the following steps: taking nodes existing in multiple block chain fragments as gateway nodes; the gateway node collects intelligent contract information deployed in the fragment where the gateway node is located and describes the contract information in a contract directory and key value pair form; the gateway node constructs, stores, queries and modifies a smart contract directory by using the MPT; the gateway node uses a broadcast communication technology to carry out security sharing of a contract directory between a plurality of other gateway nodes and the fragments; and a plurality of gateway nodes cooperate to jointly complete concurrent linkage execution of the intelligent contracts among the multiple fragments through contract calling. According to the invention, dynamic perception of the smart contract in the multiple fragments of the block chain by the block chain node is realized, contract service collaboration is allowed to be completed through smart contract linkage execution among the multiple fragments, and the collaboration capability of the multiple nodes of the block chain system and the business processing capability of the smart contract are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of smart contract execution technology in edge computing scenarios, and specifically to a method for concurrent linkage execution of smart contracts among multiple shards. Background Art

[0002] With the continuous development and popularization of digital technology and applications, edge computing is gradually becoming a key technology for processing and analyzing massive data. It greatly reduces latency and improves response speed by transferring data processing and storage tasks from the cloud to devices at the edge of the network, which is especially important for application scenarios that require real-time processing. However, edge computing still faces challenges in data security, privacy protection, mutual trust between devices, and data immutability. Blockchain, with its technical features such as distributed ledger, immutability, and transparency, provides a unique solution to these challenges. Combining edge computing with blockchain can provide a decentralized authentication mechanism for edge devices, enhance the security and reliability of edge computing networks, ensure the integrity and authenticity of data during transmission and processing between devices, and solve data privacy issues.

[0003] In addition, the introduction of blockchain smart contracts can automatically standardize the interaction process and business logic between edge devices, promote the seamless connection and efficient collaboration of complex business logic of edge computing, and thus achieve cost reduction and efficiency improvement. Edge computing scenarios usually involve the processing of large-scale data aggregation, processing, analysis and other issues. The data source may come from a wide range of different geographical regions or from different business systems. Since the computing, storage set and data transmission capabilities of each cloud-edge device vary greatly from each other, the functional expression capabilities of the blockchain smart contract itself are also limited. Obviously, it is unrealistic to implement the complex business logic described above by deploying a single smart contract. Considering that the data comes from a wide range of geographical regions or different business systems, the corresponding blockchain system may deploy multiple shards to meet its performance and scalability requirements. This requires a method for concurrent linkage execution of smart contracts between multiple shards to achieve efficient interaction and collaboration between nodes, and then realize the corresponding complex business functions. Summary of the invention

[0004] The embodiment of the present invention provides a method for concurrent linkage execution of smart contracts among multiple shards of a blockchain, which enables multiple nodes in an edge computing scenario to complete data interaction and business collaboration through the linkage execution of smart contracts deployed in multiple shards, and ultimately realize complex functions.

[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0006] S1: Based on the node status evaluation mechanism, nodes existing in multiple blockchain shards are selected as gateway nodes;

[0007] S2: The gateway node collects the smart contract information deployed in its shard and describes the above contract information in the form of contract directory and key-value pairs;

[0008] S3: Use MPT (Merkle Patricia Tree) to build, store, query and modify the smart contract directory, ensuring the storage security and operation efficiency of the contract directory;

[0009] S4: The gateway node uses broadcast communication technology to securely share the contract directory among multiple other gateway nodes and shards;

[0010] S5: Multiple gateway nodes cooperate to complete the concurrent linkage execution of smart contracts among multiple shards through contract calls.

[0011] Preferably, in S1, nodes existing in multiple blockchain shards are selected as gateway nodes based on the node status evaluation mechanism, and the following steps are performed:

[0012] Add blockchain nodes that are located in multiple shards to the gateway node candidate set;

[0013] Based on the node status evaluation mechanism, the number of partitions, resource remaining, past reputation, availability, etc. of the nodes in the quantified set are comprehensively quantified, and the node with the highest comprehensive quantification score is selected as the gateway node and added to the gateway node list, and then the node is deleted from the candidate set.

[0014] Repeat the second step above. If the shard of the node obtained this time has been covered by the shard of the previously selected gateway node, the node will not be used as a gateway node. Otherwise, the node will be added to the gateway node list. Then the node will be deleted from the candidate set.

[0015] When the shards where all gateway nodes in the gateway node list are located are consistent with the number of shards in the current blockchain system after deduplication, the third step above is terminated, and the gateway node list is output.

[0016] Preferably, in S1, nodes existing in multiple blockchain shards are selected as gateway nodes based on the node status evaluation mechanism, and further include:

[0017] Quantify the status indicators of blockchain nodes, such as the number of partitions t1, remaining resources t2, past reputation t3, availability t4, etc.; construct a status evaluation function when evaluating the status of the node:

[0018] ε=αt1+βt2+γt3+δt4

[0019] The variables in the function are the state indicators of the nodes, and the influencing factors before the variables are α, β, γ, and δ. The determination of these four factors can be achieved through the constrained optimization algorithm.

[0020] Preferably, in S2, the gateway node collects the smart contract information deployed in the shard where it is located, and describes the above contract information in the form of a contract directory and key-value pairs, and performs the following steps:

[0021] The gateway node list is denoted as N = {N1, N2, ... N i ...N k}, indicating that the list contains k nodes, where N i is its i-th node.

[0022] For any gateway node N in S1 i , the node first collects all smart contract information in its shard and describes it using key-value pairs, that is, for N i The jth smart contract C deployed on ij , N i use <k ij ,v ij >Describe it; where k ij N i The sharding deployment and functional description information of the j-th smart contract, v ij Indicates the construction and call related information of the smart contract.

[0023] Assume N i There are a total of t smart contracts deployed in the shard, N i Describe them one by one as in step 1, using the multi-tuple T i =< <k i1 ,v i1 >, <k i2 ,v i2 >,..., <k ij ,v ij >,..., <k it ,v it >>Formally express the t smart contracts, now called T i N i The contract directory of the shard.

[0024] When N i A new smart contract is deployed in the shard, N i Use the method described in the first step of S2 and add the key-value pair to T i .

[0025] When deleting an existing smart contract, N i Find the key-value pair corresponding to the smart contract and get it from Ti Delete it in.

[0026] When a deployed smart contract is updated, N i First, from T i Delete the key-value pairs corresponding to the old version of the smart contract, and then add the key-value pairs corresponding to the new version to T i middle.

[0027] Preferably, in S3, MPT (Merkle Patricia Tree) is used to implement the construction, storage, query and modification of the smart contract directory, ensuring the storage security and operation efficiency of the contract directory, and performing the following steps:

[0028] For gateway node N i And the contract directory it owns T i , N i To T i Any key-value pair <k ij ,v ij >The key value k in ij Use hexadecimal encoding, Value value v ij Use RLP encoding;

[0029] N i Contract directory T after re-encoding the data i Construct MPT according to the corresponding rules, that is, i Any <k ij ,v ij >, use the value field of the leaf node to store v ij , jointly use the key fields of the extension node and the branch node to store the query path k ij , T i The contract directory data structure generated according to the MPT construction rules is denoted as MT i ;

[0030] When you need to find the value corresponding to a specific key value, you need to convert the original code of the search key into a hexadecimal code. The resulting content is called the search path. Then, iThe root node starts searching for a path that is consistent with the content of the search path. Specifically, if the current node is a leaf node, the stored content is the content of the data item, and the content of the search path is consistent with the key of the leaf node, it means that the node is found, otherwise it means that the node does not exist in the tree; if the current node is an extension node, and the stored content is a hash index, the hash index is used to load the node from the database, and then the search path is used as a parameter to recursively call the search method for the newly parsed node; if the current node is an extension node, the stored content is a reference to another node, and the key of the current node is the prefix of the search path, then the search path is subtracted from the key of the current node, and the remaining search path is used as a parameter to recursively call the search method for its child nodes. If the key of the current node is not a prefix of the search path, it means that the node does not exist in the tree; if the current node is a branch node, if the search path is empty, the stored content of the branch node is returned, otherwise the child node of the branch node is selected using the first byte of the search path, and the search method is recursively called with the remaining search path as a parameter.

[0031] When it is necessary to i When inserting a node with a new key-value pair, first follow the steps in step 3 above to insert a new key-value pair into the MT. i Find the node with the longest identical path prefix as the key value of the newly inserted node, record it as node; if node is a branch node and the remaining search path is not empty, insert the new node as a leaf node into the corresponding child list. When the remaining search path is empty, store the content of the new node in the 17th child node item of the branch node (Value); if node is a leaf or extended node, when the remaining search path is consistent with the key of the current node, update the value of the current node. When the remaining search path is not completely consistent with the key of the current node, replace the child node of the leaf or extended node with the branch node, use the common prefix of the new node and the current node key as the key of the current node, insert the new node and the child node of the current node as two children into the child list of the branch node, and convert the current node into an extended node. If the new node and the current node do not have a common prefix, directly replace the current node with the generated branch node; if the insertion is successful, set the dirty flag of the modified node to true, set the hash flag to empty, and update the birth mark of the node to now.

[0032] When you need to i When deleting a node with a fixed key-value pair in the MT, first follow the steps in step 3 above to delete the node. iFind the node with the longest identical path prefix as the key value of the node to be deleted, record it as node; if node is a leaf or extension node, delete the entire node when the remaining search path is exactly the same as the key of node. When the remaining search path does not match the key of node, it means that the node to be deleted does not exist in the tree and the deletion fails. When the key of node is the prefix of the remaining search path, recursively call the deletion method of the node value. If node is a branch node, delete the node with the corresponding subscript mark in the child list, and the deletion ends. If the number of children of node is only one, replace the branch node with a leaf or extension node. If the deletion is successful, the dirty flag of the modified node is set to true, the hash flag is set to empty, and the birth mark of the node is updated to the present.

[0033] When you need to update the MT i When the value of a node with a specific key value is a new value, if the new value is not empty, the insertion method described in step 4 is called; if the new value is empty, the deletion method described in step 5 is called instead.

[0034] Preferably, in S4, the gateway node uses broadcast encryption communication technology to securely share the contract directory among multiple other gateway nodes and shards, and performs the following steps:

[0035] In the security sharing initialization phase, for the gateway node set N={N1,N2,...N i ...N k Any node N in i , the node will select a secret value s i , and we also need to select a high-order polynomial f i , and requires f i The order of N is not less than 5. i Calculate F i =(xs i )f i . Because N i It is a blockchain node whose identity has been authenticated and has public and private keys. You can use F i Signature, record the signature information as σ i , in order to ensure the freshness of the signature information, N i A timestamp t will be appended to the signature information i . N i Then the triple <F i ,σ i ,t i>Broadcast to the global blockchain network. For any node in the gateway node set, it will receive a total of k-1 triplets from other gateway nodes at this stage. The node will verify the validity of these triplets one by one and store them together with its own triplets, and then calculate F=F1*F2*...F k .

[0036] This step is mainly used to process F. Since F is a high-order polynomial, assuming that the highest order of the polynomial is q, based on the Lagrange interpolation method, q+1 coordinate points can be used to represent the polynomial. A simpler way is to directly use q+1 ordinate values, that is, use F(1), F(2)..., F(q+1). For ease of understanding, (F(1), F(2),..., F(q+1)) is used to represent this high-order polynomial.

[0037] In the encrypted sharing phase of the contract directory, for a MT that wants to share its contract directory j Gateway node N j , which first selects a 256-bit shared symmetric key w j And its corresponding symmetric key encryption algorithm AES-256. j Generate a binary ciphertext c by calculation j =(c j1 ,c j2 ), where c j1 =F+k j ,c j2 =ENC(String(MT j ),k j ), where String(MT j ) represents MT j The binary string representation of c j1 It is q+1 ordinate values ​​plus w j A binary string composed of j2 It is a ciphertext segment generated by the AES-256 encryption algorithm, where the algorithm input plaintext data is String (MT j ), the secret key is w j , N j c j =(c j1 ,c j2 ) is broadcasted to the blockchain network.

[0038] In the shared contract decryption phase, for any other gateway node N in the blockchain network i , when the node receives a tuple c j =(c j1 ,c j2); for c j1 ,N i Re-split it into q+1 coordinate points, namely (1,F(1)+w j ),(2,F(2)+w j ),...,(q+1,F(q+1)+w j ), then N i Reconstruct the q-order polynomial F+k using Lagrange interpolation j . From the above, we can know that:

[0039] F+k j =F1*F2*...F k +w j =(x-s1)f1(x-s2)f2....(xs k )f k +w j

[0040] According to the Abel-Ruffini theorem, since the order of the high-order polynomial F is much greater than 5, the polynomial equation based on F cannot have a radical general solution, which means that for the equation from c j1 Reconstructed high-order polynomial F+k j =(x-s1)f1(x-s2)f 2.... (xs k )f k +w j , any gateway node N i can be obtained by passing the secret value s i Substitute into w j , while for other non-gateway nodes, c j1 Get w j The probability of can be ignored. i Calculate p = DEC (c j2 ,w j ), that is, running the AES-256 decryption algorithm, the algorithm input is the key w j 、Ciphertext information c j2 , then the output p of the algorithm should be node N j Binary string description of the contract directory, followed by N i Parse the output to get MT j .

[0041] Preferably, in S5, multiple gateway nodes cooperate to jointly complete the concurrent linkage execution of smart contracts among multiple shards through contract calls, and perform the following steps:

[0042] For the gateway node set N = {N1, N2, ..., N i, ...,Nk Any node N in i , the node can share its smart contract directory information with other nodes through S5, and can also passively receive contract directory information sent by other gateway nodes. i It is found that it has not yet obtained a certain node N j When the contract directory information is sent, the node can send j Send request request N j Share the contract directory information with it according to the method described in S5.

[0043] For the gateway node set N = {N1, N2, ..., N i, ...,N n Any node N in i , the node can obtain the contract directory shared by all other gateway nodes through step 1, and then obtain the smart contract information deployed under all shards in the current blockchain network. i When some business logic needs to be executed and the functions provided by other shards are needed, the node queries the contract directory to find the key-value pair record of the smart contract corresponding to the function, assuming that <k pq ,v pq >, that is, the contract to be used is the qth contract deployed on the pth shard in the network, which is recorded as C pq , let the gateway node on this shard be N p .

[0044] In order to call the smart contract C deployed on the pth shard pq , complete the following sub-steps to complete C pq Indirect call:

[0045] N i According to the topological structure of all nodes in the gateway node set N, use the path selection algorithm to find the slave node N i To Node N p , here we can use the depth-first search algorithm or Dijkstra algorithm to get the shortest path between two nodes, denoted as PT ip .

[0046] Due to PT ip All nodes included in are gateway nodes. According to the definition of gateway nodes, these nodes must exist in multiple shards at the same time, so N i Construct a call C pq TX ipq , note that the transaction needs to include path information PT ip , and forwards the transaction to its adjacent gateway node.

[0047] When Ni The adjacent network management node receives the transaction TX ipq After that, the node will first check whether the calling contract contained in the transaction is in another shard. If so, the node will reconstruct the transaction format to make it conform to the transaction rules of the shard where the calling contract is located, and then forward the transaction in the shard. After the transaction is packaged, it will trigger the execution of the called smart contract.

[0048] If N i The node checks that the call contract contained in the transaction is not in its other shard, and the adjacent node will send TX ipq The next node on the forwarding path.

[0049] TX ipq The propagation between gateway nodes will repeat steps 3.3 and 3.4 until the transaction reaches the shard where the contained calling smart contract is located. After that, the transaction is processed, the contained contract call is triggered, and the corresponding calling smart contract is executed.

[0050] When the called smart contract is executed in the shard where it is deployed, its execution result will be constructed into a transaction, and this result transaction will also be forwarded to N in the same way as above. i The shard where it is located, and finally N i Receive Smart Contract C pq Execution result. Note here that although C pq It is executed in shard p, but its result will not be written to the shard. So far, the cross-shard collaborative execution of smart contracts among multiple shards is completed.

[0051] Compared with the prior art, the present invention has the following beneficial effects:

[0052] It can realize the dynamic perception of blockchain nodes on smart contracts in multiple shards of the blockchain, and then allow the completion of contract service collaboration through the linkage execution of smart contracts between multiple shards, thereby improving the collaboration capabilities of multiple nodes in the blockchain system and the business processing capabilities of smart contracts. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 This is an architectural diagram of the method for concurrent linkage execution of smart contracts among multiple blockchain shards of the present invention.

[0054] Figure 2 The present invention is a flowchart of a method for concurrent linkage execution of smart contracts among multiple blockchain shards. DETAILED DESCRIPTION

[0055] 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.

[0056] In order to ensure that multiple nodes in edge computing scenarios can complete data interaction and business collaboration through the linkage execution of smart contracts deployed in multiple shards, and ultimately achieve complex functions. This embodiment provides the following technical solutions:

[0057] A method for concurrent linkage execution of smart contracts among multiple shards based on contract service directory sharing includes the following steps:

[0058] S1: Based on the node status evaluation mechanism, nodes existing in multiple blockchain shards are selected as gateway nodes.

[0059] In this embodiment, as a preferred technical solution of the present invention, in S1, several nodes existing in multiple blockchain shards are selected as gateway nodes, and the following steps are performed:

[0060] Add blockchain nodes that are located in multiple shards to the gateway node candidate set;

[0061] Based on the node status evaluation mechanism, the number of partitions, resource remaining, past reputation, availability, etc. of the nodes in the quantified set are comprehensively quantified, and the node with the highest comprehensive quantification score is selected as the gateway node and added to the gateway node list, and then the node is deleted from the candidate set.

[0062] Repeat the above steps. If the shard of the node obtained this time is already covered by the shard of the previously selected gateway node, the node will not be used as a gateway node. Otherwise, the node will be added to the gateway node list. Then the node will be deleted from the candidate set.

[0063] When the shards where all gateway nodes in the gateway node list are located are consistent with the number of shards in the current blockchain system after deduplication, the above steps are terminated, and this step outputs the gateway node list.

[0064] Based on the node status evaluation mechanism, nodes existing in multiple blockchain shards are selected as gateway nodes, including:

[0065] Quantify the status indicators of blockchain nodes, such as the number of partitions t1, remaining resources t2, past reputation t3, availability t4, etc.; construct a status evaluation function when evaluating the status of the node:

[0066] ε=αt1+βt2+γt3+δt4

[0067] The variables in the function are the state indicators of the nodes, and the influencing factors before the variables are α, β, γ, and δ. The determination of these four factors can be achieved through the constrained optimization algorithm.

[0068] S2: The gateway node collects the smart contract information deployed in its shard and describes the above contract information in the form of contract directory and key-value pairs.

[0069] In this embodiment, as a preferred technical solution of the present invention, in S2, the smart contract deployed in the shard is stored in the form of a key-value pair, and the following steps are performed:

[0070] The gateway node list is denoted as N = {N1, N2, ..., N i, ...N k}, indicating that the list contains k nodes, where N i is its i-th node. For any gateway node N in step S1 i , the node first collects all smart contract information in its shard and describes it using key-value pairs, that is, for N i The jth smart contract C deployed on ij , N i use <k ij ,v ij >describe it. Among them, k ij N i The sharding deployment and functional description information of the j-th smart contract, v ij Indicates the construction and call related information of the smart contract.

[0071] Assume N i There are a total of t smart contracts deployed in the shard, N i Describe them one by one as in step 1, using the multi-tuple T i =< <k i1 ,v i1 >, <k i2 ,v i2 >,... <k ij ,v ij >,..., <k it ,v it >>Formally express the t smart contracts, now called T i N i The contract directory of the shard.

[0072] When N i A new smart contract is deployed in the shard, N i Describe it using the method shown in step 1 and add the key-value pair to T i; When deleting an existing smart contract, N i Find the key-value pair corresponding to the smart contract and get it from T i When a deployed smart contract is updated, N i First, from T i Delete the key-value pairs corresponding to the old version of the smart contract, and then add the key-value pairs corresponding to the new version to T i middle.

[0073] S3: Use MPT (Merkle Patricia Tree) to build, store, query and modify the smart contract directory, ensuring the storage security and operation efficiency of the contract directory.

[0074] In this embodiment, as a preferred technical solution of the present invention, in S3, MPT is used to store and operate the smart contract directory, and the following steps are performed:

[0075] For gateway node N i And the contract directory it owns T i , N i To T i Any key-value pair <k ij ,v ij >The key value k in ij Use hexadecimal encoding, Value value v ij Use RLP encoding;

[0076] N i Contract directory T after re-encoding the data i Construct MPT according to the corresponding rules, that is, i Any <k ij ,v ij >, use the value field of the leaf node to store v ij , jointly use the key fields of the extension node and the branch node to store the query path k ij , T i The contract directory data structure generated according to the MPT construction rules is denoted as MT i ;

[0077] When you need to find the value corresponding to a specific key value, you need to convert the original code of the search key into a hexadecimal code. The resulting content is called the search path. Then, from the MT iThe root node starts searching for a path that is consistent with the content of the search path. Specifically, if the current node is a leaf node, the stored content is the content of the data item, and the content of the search path is consistent with the key of the leaf node, it means that the node is found, otherwise it means that the node does not exist in the tree; if the current node is an extension node, and the stored content is a hash index, the hash index is used to load the node from the database, and then the search path is used as a parameter to recursively call the search method for the newly parsed node; if the current node is an extension node, the stored content is a reference to another node, and the key of the current node is the prefix of the search path, then the search path is subtracted from the key of the current node, and the remaining search path is used as a parameter to recursively call the search method for its child nodes. If the key of the current node is not a prefix of the search path, it means that the node does not exist in the tree; if the current node is a branch node, if the search path is empty, the stored content of the branch node is returned, otherwise the child node of the branch node is selected using the first byte of the search path, and the search method is recursively called with the remaining search path as a parameter.

[0078] When it is necessary to i When inserting a node with a new key-value pair, first follow the steps in step 3 above to insert a new key-value pair into the MT. i Find the node with the longest identical path prefix as the key value of the newly inserted node, record it as node; if node is a branch node and the remaining search path is not empty, insert the new node as a leaf node into the corresponding child list. When the remaining search path is empty, store the content of the new node in the 17th child node item of the branch node (Value); if node is a leaf or extended node, when the remaining search path is consistent with the key of the current node, update the value of the current node. When the remaining search path is not completely consistent with the key of the current node, replace the child node of the leaf or extended node with the branch node, use the common prefix of the new node and the current node key as the key of the current node, insert the new node and the child node of the current node as two children into the child list of the branch node, and convert the current node into an extended node. If the new node and the current node do not have a common prefix, directly replace the current node with the generated branch node; if the insertion is successful, set the dirty flag of the modified node to true, set the hash flag to empty, and update the node mark to the current mark.

[0079] When you need to i When deleting a node with a fixed key-value pair in the MT, first follow the steps in step 3 above to delete the node. iFind the node with the longest identical path prefix as the key value of the deleted node, record it as node; if node is a leaf or extension node, delete the entire node when the remaining search path is exactly the same as the node's key. When the remaining search path does not match the node's key, it means that the node to be deleted does not exist in the tree and the deletion fails. When the node's key is the prefix of the remaining search path, recursively call the deletion method for the node's value. If node is a branch node, delete the node with the corresponding subscript mark in the child list, and the deletion ends. If the number of children of node is only one, replace the branch node with a leaf or extension node. If the deletion is successful, set the dirty flag of the modified node to true, set the hash flag to empty, and update the node's mark to the current mark.

[0080] When you need to update the MT i When the value of a node with a specific key value in is a new value, if the new value is not empty, the insert method described in step 4 is called; if the new value is empty, the delete method described in step 5 is called instead. The specific details are not repeated here.

[0081] S4: The gateway node uses broadcast encrypted communication technology to securely share the contract directory among multiple other gateway nodes and shards.

[0082] In this embodiment, as a preferred technical solution of the present invention, in S4, the contract directories in multiple shards are broadcast and shared using broadcast encryption technology, and the following steps are performed:

[0083] In the security sharing initialization phase, for the gateway node set N={N1,N2,...,N i ,...,N k Any node N in i , the node will select a secret value s i , and we also need to select a high-order polynomial f i , and requires f i The order of N is not less than 5. i Calculate F i =(xs i )f i . Because N i N is a blockchain node whose identity has been authenticated and has public and private keys. i F i Signature, record the signature information as σ i , in order to ensure the freshness of the signature information, N i A timestamp t will be appended to the signature information i . N iThen the triple <F i ,σ i ,t i >Broadcast to the global blockchain network. For any node in the gateway node set, it will receive a total of k-1 triplets from other gateway nodes at this stage. The node will verify the validity of these triplets one by one and store them together with its own triplets, and then calculate F=F1*F2*...F k .

[0084] This step is mainly used to process F. Since F is a high-order polynomial, assuming that the highest order of the polynomial is q, based on the Lagrange interpolation method, q+1 coordinate points can be used to represent the polynomial. A simpler way is to directly use q+1 ordinate values, that is, use F(1), F(2), ..., F(q+1). For ease of understanding, we use (F(1), F(2), ..., F(q+1)) to represent this high-order polynomial.

[0085] In the encrypted sharing phase of the contract directory, for a MT that wants to share its contract directory j Gateway node N j , which first selects a 256-bit shared symmetric key w j And its corresponding symmetric key encryption algorithm AES-256. j Generate a binary ciphertext c by calculation j =(c j1 ,c j2 ), where c j1 =F+k j , c j2 =ENC(String(MT j ),k j ), where String(MT j ) represents MT j The binary string representation of c j1 It is q+1 ordinate values ​​plus w j A binary string composed of j2 It is a ciphertext segment generated by the AES-256 encryption algorithm, where the algorithm input plaintext data is String (MT j ), the secret key is w j . N j c j =(c j1 ,c j2 ) is broadcasted to the blockchain network.

[0086] In the shared contract decryption phase, for any other gateway node N in the blockchain network i, when the node receives a tuple c j =(c j1 ,c j2 ). For c j1、 N i Re-split it into q+1 coordinate points, namely (1,F(1)+w j ),(2,F(2)+w j ),...,(q+1,F(q+1)+w j ), then N i Reconstruct the q-order polynomial F+k using Lagrange interpolation j From the above, we can know

[0087] F+k j =F1*F2*...F k +w j =(x-s1)f1(x-s2)f 2.... (xs k )f k +w j

[0088] According to the Abel-Ruffini theorem, since the order of the high-order polynomial F is much greater than 5, the polynomial equation based on F cannot have a radical general solution, which means that for the equation from c j1 Reconstructed high-order polynomial F+k j =(x-s1)f1(x-s2)f2....(xs k )f k +w j , any gateway node N i can be obtained by passing the secret value s i Substitute into w j , while for other non-gateway nodes, c j1 Get w j The probability of can be ignored. i Calculate pt = DEC (c j2 ,w j ), that is, run the AES-256 decryption algorithm, and the algorithm input is the key w j 、Ciphertext information c j2 , then the output pt of the algorithm should be node N j Binary string description of the contract directory, followed by N i Parse the output to get MT j .

[0089] S5: Multiple gateway nodes cooperate to complete the concurrent linkage execution of smart contracts among multiple shards through contract calls.

[0090] In this embodiment, as a preferred technical solution of the present invention, in S5, multiple gateway nodes complete the concurrent linkage execution of cross-shard smart contracts through contract calls, and perform the following steps:

[0091] For the gateway node set N = {N1, N2, ..., N i, ...,N k Any node N in i , the node can share its smart contract directory information with other nodes through S5, and can also passively receive contract directory information sent by other gateway nodes. i It is found that it has not yet obtained a certain node N j When the contract directory information is sent, the node can send j Send request request N j Share the contract directory information with it according to the method described in S5.

[0092] For the gateway node set N = {N1, N2, ..., N i, ...,N n Any node N in i , the node can obtain the contract directory shared by all other gateway nodes through step 1, and then obtain the smart contract information deployed under all shards in the current blockchain network. i When some business logic needs to be executed and the functions provided by other shards are needed, the node queries the contract directory to find the key-value pair record of the smart contract corresponding to the function. Assume that <k pq ,v pq >, that is, the contract to be used is the qth contract deployed on the pth shard in the network, which is recorded as C pq , let the gateway node on this shard be N p .

[0093] In order to call the smart contract C deployed on the Pth shard pq , complete the following sub-steps to complete C pq Indirect call:

[0094] N i According to the topological structure of all nodes in the gateway node set N, use the path selection algorithm to find the slave node N i To Node N p , here we can use the depth-first search algorithm or Dijkstra algorithm to get the shortest path between two nodes, denoted as PT ip .

[0095] Due to PT ipAll nodes included in are gateway nodes. According to the definition of gateway nodes, these nodes must exist in multiple shards at the same time, so N i Construct a call C pq TX ipq , note that the transaction needs to include path information PT ip , and forwards the transaction to its adjacent gateway node.

[0096] When N i The adjacent network management node receives the transaction TX ipq After that, the node will first check whether the calling contract contained in the transaction is in another shard. If so, the node will reconstruct the transaction format to make it conform to the transaction rules of the shard where the calling contract is located, and then forward the transaction in the shard. After the transaction is packaged, it will trigger the execution of the called smart contract.

[0097] If N i The node checks that the call contract contained in the transaction is not in its other shard, and the adjacent node will send TX ipq The next node on the forwarding path.

[0098] TX ipq The propagation between gateway nodes will repeat steps 3.3 and 3.4 until the transaction reaches the shard where the contained calling smart contract is located. After that, the transaction is processed, the contained contract call is triggered, and the corresponding calling smart contract is executed.

[0099] When the called smart contract is executed on the shard where it is deployed, its execution result will be constructed into a transaction, and this result transaction will also be forwarded to N according to the method described in steps 3.2-3.4. i The shard where it is located, and finally N i Receive Smart Contract C pq Execution result. Note here that although C pq It is executed in shard p, but its result will not be written to the shard. So far, the cross-shard collaborative execution of smart contracts among multiple shards is completed.

[0100] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for concurrent linkage execution of smart contracts among multiple shards, characterized in that: The following steps are involved: S1. Select nodes existing in multiple blockchain shards as gateway nodes based on the node status evaluation mechanism; S2. The gateway node collects the smart contract information deployed in the shard where it is located, and describes the above contract information in the form of contract directory and key-value pairs; S3. Use MPT to build, store, query, and / or modify the smart contract directory; S4. The gateway node uses broadcast communication technology to securely share the contract directory among multiple other gateway nodes and shards; S5. Multiple gateway nodes cooperate to complete the concurrent linkage execution of smart contracts among multiple shards through contract calls.

2. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: The steps for selecting a gateway node are as follows: S11. List blockchain nodes located in multiple shards into the gateway node candidate set; S12. Based on the node status evaluation mechanism, comprehensively quantify the nodes in the set, select the node with the highest comprehensive quantification score as the gateway node and add it to the gateway node list, and then delete the node from the candidate set; S13. If the shard where the node obtained this time is located is already covered by the shard where the previously selected gateway node is located, the node is not used as a gateway node. Otherwise, the node is added to the gateway node list and then deleted from the candidate set. S14. When the number of shards where all gateway nodes in the gateway node list are located is consistent with the number of shards in the current blockchain system after deduplication, step S3 is terminated and step S4 outputs the gateway node list.

3. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: In step S1, nodes existing in multiple blockchain shards are selected as gateway nodes based on the node status evaluation mechanism, and the status indicators of blockchain nodes are quantified and evaluated. When constructing a status evaluation function for the node status: ε=αt1+βt2+γt3+δt4 The variables in the function are the status indicators of the node, including the number of partitions t1, the remaining resources t2, the previous reputation t3, and the availability t4. The influencing factors before the variables are α, β, γ, and δ. The determination of these four factors can be achieved through the constrained optimization algorithm.

4. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: In step S2, the gateway node executes the following: The gateway node list is denoted as N = {N1, N2, ... N i, ...,N k }, indicating that the list contains k nodes, where N i is its i-th node. For any gateway node N i First, collect all smart contract information in the shard where it is located and describe it using key-value pairs, that is, for N i The jth smart contract C deployed on ij , N i use <k ij ,v ij >Describe it; where k ij N i The sharding deployment and functional description information of the j-th smart contract, v ij Indicates the construction and call related information of the smart contract; Assume N i There are a total of t smart contracts deployed in the shard, using the multi-tuple T i =< <k i1 ,v i1 >, <k i2 ,v i2 >,..., <k ij ,v ij >,..., <k it ,v it >>Formally express the t smart contracts, now called T i N i The contract directory of the shard; When N i A new smart contract is deployed in the shard where it is located. All smart contract information in the shard is collected and described using key-value pairs, and the key-value pairs are added to T i ; When deleting an existing smart contract, N i Find the key-value pair corresponding to the smart contract and get it from T i When a deployed smart contract is updated, N i First, from T i Delete the key-value pairs corresponding to the old version of the smart contract, and then add the key-value pairs corresponding to the new version to T i middle.

5. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: In step S3: Construction of smart contract directory: for gateway node N i And the contract directory it owns T i , N i To T i Any key-value pair <k ij ,v ij >The key value k in ij Use hexadecimal encoding, Value value v ij Use RLP encoding; Storage of smart contract directory: N i Contract directory after re-encoding the data T i Construct MPT according to the corresponding rules, that is, i Any <k ij ,v ij >, use the value field of the leaf node to store v ij , jointly use the key fields of the extension node and the branch node to store the query path k ij。 T i The contract directory data structure generated according to the MPT construction rules is denoted as MT i .

6. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: The query method of the smart contract directory in step S3 is as follows: When you need to find the value corresponding to a specific key value, you need to convert the original code of the search key into a hexadecimal code. The resulting content is called the search path. Then, i The root node starts searching for a path that is consistent with the search path content; If the current node is a leaf node, the stored content is the content of the data item, and the content of the search path is consistent with the key of the leaf node, it means that the node is found, otherwise it means that the node does not exist in the tree; If the current node is an extended node and the stored content is a hash index, the node is loaded from the database using the hash index, and the search path is used as a parameter to recursively call the search method on the newly parsed node; If the current node is an extended node, the stored content is a reference to another node, and the key of the current node is a prefix of the search path, then the search path is subtracted from the key of the current node, and the remaining search path is used as a parameter to recursively call the search method on its child nodes; If the key of the current node is not a prefix of the search path, it means that the node does not exist in the tree; If the current node is a branch node and the search path is empty, the stored content of the branch node is returned. Otherwise, the child node of the branch node is selected using the first byte of the search path, and the search method is recursively called with the remaining search path as a parameter.

7. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: The modification of the smart contract directory in step S3 includes insertion and deletion; The insertion method is as follows: When you need to insert i When inserting a node with a new key-value pair, first i Find the node with the longest path prefix in common with the key value of the newly inserted node, and record it as node; If node is a branch node and the remaining search path is not empty, the new node is inserted into the corresponding child list as a leaf node. If the remaining search path is empty, the content of the new node is stored in the Value item of the 17th child node of the branch node. If the node is a leaf or extension node, when the remaining search path is consistent with the key of the current node, the current node value can be updated. When the remaining search path is not completely consistent with the key of the current node, the child node of the leaf or extension node is replaced with a branch node, and the common prefix of the new node and the current node key is used as the key of the current node. The new node and the child node of the current node are inserted into the child list of the branch node as two children. At the same time, the current node is converted into an extension node. If the new node and the current node do not have a common prefix, the current node is directly replaced with the generated branch node; if the insertion is successful, the dirty flag of the modified node is set to true, the hash flag is cleared, and the node mark is updated; The deletion method is as follows: When you need to delete i When deleting a node with a fixed key-value pair, first delete the node in the MT i Find the node with the longest path prefix that is the same as the key value of the deleted node, and record it as node; If the node is a leaf or extension node, if the remaining search path is exactly the same as the node's key, the entire node will be deleted. If the remaining search path does not match the node's key, it means that the node to be deleted does not exist in the tree and the deletion fails. If the node's key is the prefix of the remaining search path, a recursive deletion method call is made on the node's value. If node is a branch node, delete the node with the corresponding subscript in the child list, and the deletion ends. If node has only one child, replace the branch node with a leaf or expansion node. If the deletion is successful, set the dirty flag of the modified node to true, clear the hash flag, and update the node tag. When you need to update the MT i When the value of a node with a specific key value is a new value, if the new value is not empty, the insert method is called; if the new value is empty, the delete method is called instead.

8. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: The secure sharing in step S4 includes secure sharing initialization, contract directory encryption sharing, and shared contract decryption; secure sharing initialization phase: In the security sharing initialization phase, for the gateway node set N={N1,N2,...,N i ...,N k Any node N in i , the node will select a secret value s i , and we also need to select a high-order polynomial f i , and requires f i The order is not less than the threshold 5, N i Calculate F i =(xs i )f i ; N i The signature information is σ i , N i A timestamp t will be appended to the signature information i , N i Then the triple <F i ,σ i ,t i >Broadcast to the global blockchain network; for any node in the gateway node set, it will receive a total of k-1 triplets from other gateway nodes at this stage. The node will verify the validity of these triplets one by one and store them together with its own triplets, and then calculate F = F1*F2*...F k ; For the polynomial F, its highest order is q. Based on the Lagrange interpolation method, q+1 ordinate values ​​are used to represent it, that is, (F(1), F(2), ... F(q+1)) is used to represent this high-order polynomial; During the encrypted sharing phase of the contract directory: For a MT that wishes to share its contract directory j Gateway node N j , which first selects a 256-bit shared symmetric key w j and its corresponding symmetric key encryption algorithm AES-256; N j Generate a binary ciphertext c by calculation j =(c j1 ,c j2 ), where c j1 =F+k j , c j2 =ENC(String(MT j ),k j ), where String(MT j ) represents MT j The binary string representation of c j1 It is q+1 ordinate values ​​plus w j A binary string composed of j2 It is a ciphertext segment generated by the AES-256 encryption algorithm, where the algorithm input plaintext data is String (MT j ), the secret key is w j , N j c j =(c j1 ,c j2 )Broadcast to the blockchain network; During the shared contract decryption phase: For any other gateway node N in the blockchain network i , when the node receives a tuple c j =(c j1 ,c j2 ), for c j1 , N i Re-split it into q+1 coordinate points, namely (1,F(1)+w j ),(2,F(2)+w j ),...,(q+1,F(q+1)+w j ), then N i Reconstruct the q-order polynomial F+k using Lagrange interpolation j ; From the above, we can know: F+k j =F1*F2*...F k +w j =(x-s1)f1(x-s2)f 2.... (x-s k )f k +w j For from c j1 Reconstructed high-order polynomial F+k j =(x-s1)f1(x-s2)f 2.... (xs k )f k +w j , any gateway node N i can be obtained by passing the secret value s i Substitute into w j ; then N i Calculate pt = DEC (c j2 ,w j ), that is, running the AES-256 decryption algorithm, the algorithm input is the key w j 、Ciphertext information c j2 , then the output pt of the algorithm should be node N j Binary string description of the contract directory, followed by N i Parse the output to get MT j .

9. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 1, characterized in that: In S5, multiple gateway nodes cooperate to complete the concurrent linkage execution of smart contracts among multiple shards through contract calls, and perform the following steps: Step 1: For the gateway node set N = {N1, N2, ... N i ...N k Any node N in i , can share its smart contract directory information with other nodes, and can also passively receive contract directory information sent by other gateway nodes; In addition, when N i It is found that it has not yet obtained a certain node N j When the contract directory information is sent, the node can send j Send request request N j Share the contract directory information with them; Step 2: For the gateway node set N = {N1, N2, ..., N i, ...,N n Any node N in i , the node can obtain the contract directory shared by all other gateway nodes through step 1, and then obtain the smart contract information deployed under all shards in the current blockchain network; when N i When some business logic needs to be executed and the functions provided by other shards are needed, the node queries the contract directory to find the key-value pair record of the smart contract corresponding to the function, assuming that <k pq ,v pq >, that is, the contract to be used is the qth contract deployed on the pth shard in the network, which is recorded as C pq , let the gateway node on this shard be N p ; Step 3: When calling smart contract C deployed on the pth shard pq , N i According to the topological structure of all nodes in the gateway node set N, use the path selection algorithm to find the slave node N i To Node N p .

10. The method for concurrent linkage execution of smart contracts among multiple shards according to claim 9, characterized in that: C pq The indirect calling steps are as follows: Step 3.1: N i According to the topological structure of all nodes in the gateway node set N, use the path selection algorithm to find the slave node N i To Node N p , use the depth-first search algorithm or Dijkstra algorithm to get the shortest path between two nodes, denoted as PT i ; Step 3.2: N i Construct a call C pq TX ipq , the transaction needs to contain path information PT ip , and forward the transaction to its adjacent gateway node; Step 3.3: When N i The adjacent network management node receives the transaction TX ipq After that, the node will first check whether the calling contract contained in the transaction is in another shard. If so, the node will reconstruct the transaction format to make it conform to the transaction rules of the shard where the calling contract is located, and then forward the transaction in the shard. After the transaction is packaged, it will trigger the execution of the called smart contract; Step 3.4: If N i The node checks that the call contract contained in the transaction is not in its other shard, and the adjacent node will send TX ipq The next node in the forwarding path; Step 3.5: TX ipq The propagation between gateway nodes will repeat steps 3.3 and 3.4 until the transaction reaches the shard where the contained smart contract is located. After that, the transaction is processed, the contained contract call is triggered, and the corresponding called smart contract is executed; Step 3.6: When the called smart contract is executed on the shard where it is deployed, its execution result will be constructed into a transaction, and this result transaction will also be forwarded to N according to steps 3.2-3.

4. i The shard where it is located, and finally N i Receive Smart Contract C pq The execution result of .