Blockchain data consensus chaining method and device
By selecting the starting and ending nodes with the largest differences in consensus results from the blockchain node set, and the intermediate nodes on their optimal walk paths, a first node subset is formed for consensus. This solves the problem of low efficiency in blockchain data consensus and enables more efficient data uploading.
Patent Information
- Application Number
- CN202410656896.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-05-24
AI Technical Summary
The low efficiency of data consensus on the blockchain results in a very low number of transactions per second (TPS), which cannot meet the needs of scenarios with high real-time requirements and restricts the development of blockchain technology.
Consensus is achieved by using a subset of the first nodes in the blockchain node set. This subset includes the starting node, the ending node, and the intermediate nodes on the optimal walk path. Consensus is achieved by representing the whole through the local, thereby improving the efficiency of data consensus on the blockchain.
It improves the efficiency of data consensus on-chain, especially when there are many nodes, significantly improving the speed of data consensus and on-chain.
Smart Images

Figure CN118802944B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method and apparatus for blockchain data consensus on-chaining. Background Technology
[0002] Blockchain is essentially a decentralized database. Each block contains information about several transactions, and the blocks are linked together in chronological order to form a chain-like data structure. It can achieve data transparency, immutability, and traceability without the need for third-party endorsement. However, in related technologies, blockchain suffers from low data consensus efficiency, resulting in a very low number of transactions per second (TPS). This makes blockchain unsuitable for scenarios with high real-time requirements, hindering the development of blockchain technology. Summary of the Invention
[0003] This disclosure aims to at least partially address one of the technical problems in the related art.
[0004] Therefore, the first objective of this disclosure is to propose a blockchain data consensus on-chain method to improve the efficiency of data consensus on-chain.
[0005] The second objective of this disclosure is to propose a blockchain data consensus on-chain device.
[0006] The third objective of this disclosure is to propose an electronic device.
[0007] The fourth objective of this disclosure is to provide a computer-readable storage medium.
[0008] The fifth objective of this disclosure is to provide a computer program product.
[0009] To achieve the above objectives, the first aspect of this disclosure proposes a blockchain data consensus on-chain method, comprising:
[0010] In response to receiving a data upload request, a first subset of nodes is used to reach a consensus on the data upload request to obtain a first consensus result. The first subset of nodes includes a starting node, an ending node, and at least one intermediate node. The starting node and the ending node are the two nodes with the largest difference in consensus results in the blockchain node set. The intermediate node is a node on the optimal walk path between the starting node and the ending node in the blockchain node set.
[0011] If the first consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain.
[0012] Optionally, the method further includes:
[0013] If the first consensus result is that the consensus is not passed, then the first node subset and the second node subset in the blockchain node set are used to reach a consensus on the data upload request to obtain a second consensus result. In this case, the consensus result difference between any second node in the second node subset and the first node corresponding to any second node is less than the difference threshold, and the first node corresponding to any second node is the node with the smallest consensus result difference between the first node subset and any second node.
[0014] If the second consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain;
[0015] If the second consensus result is that the consensus is not passed, then all nodes in the blockchain node set will be used to reach a consensus on the data upload request to obtain a third consensus result;
[0016] If the third consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain.
[0017] Optionally, before reaching consensus on the data upload request using a subset of first nodes, the method further includes:
[0018] A spatial consensus vector set is constructed based on the historical consensus results corresponding to the blockchain node set, wherein the spatial consensus vector in the spatial consensus vector set corresponds one-to-one with the node in the blockchain node set;
[0019] Select the two nodes with the largest spatial consensus vector distance from the blockchain node set as the starting node and the ending node, respectively;
[0020] The optimal traversal route between the starting node and the ending node is determined from the blockchain node set, and the nodes in the optimal traversal route, the starting node, and the ending node are placed into the first node subset.
[0021] Optionally, determining the optimal traversal route between the starting node and the ending node from the blockchain node set includes:
[0022] Determine the direction of the first spatial consensus vector, the detection radius, and the first detection walk size between the starting node and the ending node;
[0023] The starting node is instructed to move to the target position according to the direction of the first spatial consensus vector and the first probe walking step size, and the node is scanned with the target position as the center according to the probe radius to obtain the scanning result;
[0024] If the scan result indicates that there is no node in the blockchain node set, then the starting node continues to move from the target position according to the vector direction and the first probe walking step size until the scan result indicates that there is a node in the blockchain node set.
[0025] The node corresponding to the scan result is used as the starting node to continue the journey until the ending node is reached, thus obtaining the optimal journey route.
[0026] Optionally, determining the detection radius between the starting node and the ending node and the first detection walk step size includes:
[0027] The direction of the first spatial consensus vector is normalized to obtain the normalized vector direction;
[0028] Determine the minimum spatial consensus vector distance corresponding to the set of spatial consensus vectors, and use the minimum spatial consensus vector distance as the detection radius;
[0029] The first detection walk step size is determined based on the normalized vector direction and the detection radius.
[0030] Optionally, before reaching consensus on the data upload request using the first subset of nodes and the second subset of nodes in the blockchain node set, the method further includes:
[0031] A second subset of nodes is determined from the set of blockchain nodes, wherein the distance between the spatial consensus vector of any second node in the second subset and the spatial consensus vector of the first node corresponding to any second node is less than a distance threshold, and the first node corresponding to any second node is the node with the smallest distance between the spatial consensus vector of the first subset and the spatial consensus vector of any second node.
[0032] Optionally, determining the second subset of nodes from the blockchain node set includes:
[0033] A third node is selected from the blockchain node set, and the node with the smallest distance between the spatial consensus vector of the first node subset and the spatial consensus vector of the third node is determined to obtain the first node corresponding to the third node. The third node is any node in the blockchain node set other than the first node subset and the second node subset.
[0034] Determine the direction of the second spatial consensus vector and the second probe walk step size between the third node and the first node corresponding to the third node;
[0035] The third node is instructed to walk in the direction of the second spatial consensus vector and the second probe walking step size until the distance between the spatial consensus vector and the spatial consensus vector of the first node corresponding to any node is less than the distance threshold. The third node after walking is then placed into the second node subset.
[0036] If the number of nodes corresponding to the second node subset meets the selection requirements, the selection of a third node from the blockchain node set is stopped, and the second node subset is obtained.
[0037] Optionally, adding the data corresponding to the data upload request to the blockchain includes:
[0038] The data corresponding to the data upload request is asynchronously uploaded to the blockchain using a state machine.
[0039] Optionally, the method further includes:
[0040] Determine the consensus result pass rate corresponding to the first consensus result, wherein the first consensus result includes the consensus result corresponding to any first node in the first node subset;
[0041] If the consensus result pass rate is greater than the consensus result pass rate threshold, then the first consensus result is considered a consensus pass;
[0042] If the consensus result pass rate is not greater than the consensus result pass rate threshold, then the first consensus result is a consensus failure.
[0043] To achieve the above objectives, a second aspect of this disclosure provides a blockchain data consensus on-chain device, comprising:
[0044] A data consensus unit is used to respond to a received data upload request by using a first subset of nodes to reach a consensus on the data upload request and obtain a first consensus result. The first subset of nodes includes a starting node, an ending node, and at least one intermediate node. The starting node and the ending node are the two nodes with the largest difference in consensus results in the blockchain node set. The intermediate node is a node on the optimal walk path between the starting node and the ending node in the blockchain node set.
[0045] The data upload unit is used to add the data corresponding to the data upload request to the blockchain if the first consensus result is that the consensus is passed.
[0046] To achieve the above objectives, a third aspect of this disclosure provides an electronic device, including: a processor and a memory communicatively connected to the processor;
[0047] The memory stores instructions that the computer executes;
[0048] The processor executes computer execution instructions stored in memory to implement the method shown in any of the first aspects above.
[0049] To achieve the above objectives, a fourth aspect of this disclosure provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, are used to implement the method shown in any of the first aspects above.
[0050] To achieve the above objectives, a fifth aspect of this disclosure provides a computer program product including a computer program that, when executed by a processor, implements the method shown in any of the first aspects above.
[0051] In summary, the method, apparatus, device, and storage medium provided in this disclosure achieve consensus on data upload requests by using a first subset of nodes in the blockchain node set. Since the first subset of nodes includes the two nodes with the largest differences in consensus results in the blockchain node set, as well as the nodes on the optimal walk path between these two nodes, the differences in consensus results among the nodes in the first subset of nodes are relatively large, which can include most cases of blockchain node consensus. Thus, it can achieve the effect of using the first subset of nodes to replace the blockchain node set for consensus, thereby improving the efficiency of data consensus upload.
[0052] Additional aspects and advantages of this disclosure will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this disclosure. Attached Figure Description
[0053] The above and / or additional aspects and advantages of this disclosure will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, in which:
[0054] Figure 1 This is an interactive schematic diagram of a blockchain data consensus on-chain method provided in an embodiment of this disclosure;
[0055] Figure 2 This is a flowchart illustrating a blockchain data consensus and on-chain method provided in an embodiment of the present disclosure.
[0056] Figure 3 A schematic diagram illustrating the determination of a first node subset provided in an embodiment of this disclosure;
[0057] Figure 4 A schematic flowchart illustrating a blockchain data consensus on-chain method provided in another embodiment of this disclosure;
[0058] Figure 5 This is a schematic diagram of the structure of a blockchain data consensus on-chain device provided in an embodiment of this disclosure. Detailed Implementation
[0059] Embodiments of this disclosure are described in detail below. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting this disclosure.
[0060] A blockchain is a distributed database system that allows multiple participants to collaboratively maintain a decentralized record of transactions. Each transaction is recorded in a block, and these blocks can be linked together to form a chain, hence the name "blockchain".
[0061] In a blockchain, all transactions are recorded on the blockchain, with each block including the hash value of the previous block, thus forming a chain-on-chain structure. Adding a new transaction to the blockchain is the act of adding that transaction to the blockchain.
[0062] To illustrate with an example, Bitcoin's Proof-of-Work (PoW) consensus algorithm requires "6 confirmations" and generates a new blockchain every 10 minutes. Hyperledger Fabric uses a Byzantine fault-tolerant blockchain data consensus method, which can provide (n-1) / 3 fault tolerance while ensuring availability and security, with a TPS of around 100 per second and high data read / write latency.
[0063] in, Figure 1 This is an interactive schematic diagram illustrating a blockchain data consensus on-chain method provided in an embodiment of this disclosure. Figure 1 As shown, the blockchain data consensus on-chain method specifically includes the following steps:
[0064] Step 1: Client C sends a request to blockchain node 0, requesting entry into the pre-prepare stage;
[0065] Step 2: Blockchain node 0 receives the request, verifies it, and then broadcasts the message to all consensus nodes (P, Q, R), thus entering the consensus phase.
[0066] Step 3: When a consensus node (P, Q, R) receives a broadcast message, it checks the message for correctness based on the signature field. If the verification is successful, it adds its own signature to form a prepare message and broadcasts it to other consensus nodes, waiting for verification by other consensus nodes.
[0067] Step 4: Other consensus nodes receive the prepare message, verify its correctness, and return the result to the prepare message initiator. If the prepare message initiator receives a message with more than two-thirds of the total number of consensus nodes that has passed verification, it considers the system to have reached a consensus and generates a prepare message to feed back to the consensus initiator node, i.e., blockchain node 0.
[0068] Step 5: When the consensus initiating node receives the commit message, if the number of verified commit messages exceeds one-third of all nodes, the data consensus is completed and the result is sent back to client C.
[0069] However, analysis of this Byzantine fault-tolerant-based blockchain data consensus method reveals that, due to the peer-to-peer decentralized storage employed by the blockchain, data upload requires the participation of all blockchain nodes, with each node frequently engaging in P2P consensus synchronization with other nodes. As the number of blockchain nodes increases, performance declines exponentially, resulting in low data consensus upload efficiency.
[0070] The present disclosure will now be described in detail with reference to specific embodiments.
[0071] In the first embodiment, such as Figure 2 As shown, Figure 2 This is a flowchart illustrating a blockchain data consensus and on-chain method provided in an embodiment of this disclosure. The method can be implemented using a computer program and can run on a device for performing blockchain data consensus and on-chain operations. This computer program can be integrated into an application or run as a standalone utility application.
[0072] Among them, the blockchain data consensus on-chain device can be an electronic device with blockchain data consensus on-chain function.
[0073] The blockchain data consensus on-chain method can be executed by electronic devices.
[0074] For example, this blockchain data consensus on-chain method includes the following steps:
[0075] S101, in response to receiving a data upload request, the first node subset is used to reach a consensus on the data upload request and obtain the first consensus result;
[0076] According to some embodiments, the first node subset refers to a set comprised of multiple first nodes. This first node subset includes a starting node, an ending node, and at least one intermediate node. The starting node and the ending node are the two nodes in the blockchain node set with the largest differences in consensus results, and the intermediate node is a node on the optimal walk path between the starting node and the ending node in the blockchain node set.
[0077] In some embodiments, a blockchain node set refers to a collection of all blockchain nodes in an electronic device.
[0078] In some embodiments, the optimal traversal route refers to the optimal route taken by the starting node to the ending node through other nodes in the blockchain node set.
[0079] According to some embodiments, the first consensus result includes the consensus result corresponding to any first node in the first node subset.
[0080] S102, if the first consensus result is that the consensus is passed, then the data corresponding to the data upload request is added to the blockchain.
[0081] In summary, the method provided in this embodiment uses a first subset of nodes in the blockchain node set to reach consensus on data upload requests. Since the first subset includes the two nodes with the largest differences in consensus results in the blockchain node set, as well as the nodes on the optimal walk path between these two nodes, the differences in consensus results among the nodes in the first subset are relatively large, which can include most cases of blockchain node consensus. Thus, it can achieve the effect of using the first subset of nodes to replace the entire blockchain node set for consensus, using the part to represent the whole for consensus, thereby improving the efficiency of data consensus upload. The more nodes in the blockchain node set, the more significant the improvement in data consensus upload efficiency.
[0082] This embodiment also provides another method for blockchain data consensus on-chain. This method can be executed by an electronic device.
[0083] For example, this blockchain data consensus on-chain method may include the following steps:
[0084] S201, Construct a spatial consensus vector set based on the historical consensus results corresponding to the blockchain node set;
[0085] For example, the historical consensus results are shown in Table (1). There are N nodes in the blockchain node set, and there are a total of M consensus results in history.
[0086] Table (1)
[0087] Consensus Result 1 Consensus Result 2 Consensus Result 3 Consensus Result 4 ...... Node 1 1 1 0 1 ...... Node 2 1 1 1 1 ...... Node 3 1 1 1 0 ...... Node 4 0 1 1 1 ...... ...... ...... ...... ...... ...... ......
[0088] "1" indicates that the consensus result is correct, and "0" indicates that the consensus result is incorrect.
[0089] According to some embodiments, the historical consensus results corresponding to this set of blockchain nodes can be updated, for example, on a weekly basis. For example, there may be a one-week interval between consensus result 1 and consensus result 2.
[0090] In some embodiments, the consensus results of all nodes in the blockchain node set at each iteration can be selected as the spatial consensus vector set. Each spatial consensus vector in the spatial consensus vector set corresponds one-to-one with a node in the blockchain node set.
[0091] For example, the spatial consensus vector of node i in a blockchain node set. in, This represents the m-th consensus result of node i.
[0092] S202: Select the two nodes with the largest spatial consensus vector distance from the blockchain node set as the starting node and the ending node, respectively.
[0093] It should be noted that the two nodes with the largest spatial consensus vector distance are the node with the highest consensus result accuracy and the node with the lowest consensus result accuracy, respectively.
[0094] For example, the starting node can be the node with the highest consensus accuracy, and the ending node can be the node with the lowest consensus accuracy. Alternatively, the starting node can be the node with the lowest consensus accuracy, and the ending node can be the node with the highest consensus accuracy.
[0095] According to some embodiments, the spatial consensus vector distance between any two nodes in a blockchain node set can be of types including but not limited to Euclidean distance, Manhattan distance, cosine distance, etc.
[0096] In some embodiments, the Euclidean distance between the spatial consensus vectors of any two nodes can be determined, for example, according to equation (1):
[0097]
[0098] Where, d ij A represents the Euclidean distance between the spatial consensus vectors of node i and node j; j Represents the spatial consensus vector of node j; a i a represents the h-th consensus result of node i; j This represents the h-th consensus result of node j.
[0099] It should be noted that the larger the Euclidean distance of the spatial consensus vector, the greater the consensus difference between the two nodes, and the more blockchain node scenarios can be included.
[0100] S203, determine the optimal traversal route between the starting node and the ending node from the blockchain node set, and put the nodes, starting node and ending node in the optimal traversal route into the first node subset;
[0101] According to some embodiments, the optimal walking route can be obtained by determining the direction of the first spatial consensus vector, the detection radius, and the first detection walking step size between the starting node and the ending node; instructing the starting node to walk to the target position according to the direction of the first spatial consensus vector and the first detection walking step size, and scanning nodes with the target position as the center according to the detection radius; if the scanning result is a node that does not exist in the blockchain node set, then instructing the starting node to continue walking from the target position according to the vector direction and the first detection walking step size until the scanning result is a node that exists in the blockchain node set; and taking the node corresponding to the scanning result as the starting node to continue walking until the ending node is reached.
[0102] In some embodiments, the direction of the first spatial consensus vector can be normalized to obtain a normalized vector direction; the minimum spatial consensus vector distance corresponding to the set of spatial consensus vectors can be determined, and the minimum spatial consensus vector distance can be used as the detection radius; the first detection walk size can be determined based on the normalized vector direction and the detection radius.
[0103] In some embodiments, the direction of the first spatial consensus vector between the starting node and the ending node can be as shown in equation (2):
[0104] t pq =A q -A p #(2)
[0105] Among them, A q A represents the spatial consensus vector of the endpoint node Q; p The spatial consensus vector representing the starting node P; t pq This represents the direction of the first spatial consensus vector between the endpoint node Q and the starting node P.
[0106] In some embodiments, the first probe walking step size can be, for example, as shown in equation (3):
[0107] λ pq =d min *t′ pq #(3)
[0108] Where, λ pq t′ represents the first probe walk step size between the starting node P and the ending node Q. pq Represents the normalized λ pq ;d min This represents the minimum spatial consensus vector distance corresponding to the set of spatial consensus vectors, d. min For example, it can be determined according to equation (1).
[0109] It should be noted that the determination of the first spatial consensus vector direction and the first probe walking step size can be adjusted according to the actual application scenario. It is not limited to using only one method, such as formula (2) and formula (3), as long as the optimal walking route can be obtained in the end.
[0110] To give an example from a scenario, Figure 3 This is a schematic diagram illustrating the determination of a first node subset provided in an embodiment of this disclosure. Figure 3 As shown, the specific steps are as follows:
[0111] Step S2031, let the starting node P be at t pq Directional wandering λ pq Reach position P1, at position P1 with d min Perform a node scan within the detection radius to check if any nodes exist.
[0112] Step S2032: Scanning reveals that node C is within the detection radius, and node C is placed into the first node subset;
[0113] Step S2033: Recalculate the spatial consensus vector direction t between node C and node Q. cq and the first probe walking step length λ cq Let node C be at t cq Directional wandering λ cq After the migration, the position is d min Perform a node scan within the detection radius to check if any nodes exist.
[0114] Step S2034: If no node is detected within the detection radius, then let node C continue scanning at t. cq Directional wandering λ cq Until a node is detected within the detection radius;
[0115] Step S2035: If a node is detected within the detection radius, the detected node is placed into the first node subset. Repeat the above steps until the Q node is reached, and obtain the optimal traversal route and the first node subset.
[0116] S204, determine the second subset of nodes from the blockchain node set;
[0117] According to some embodiments, if the difference in consensus results between any second node in the second node subset and the first node corresponding to any second node is less than a difference threshold, then the first node corresponding to any second node is the node with the smallest difference in consensus results between the first node subset and any second node.
[0118] In some embodiments, the difference in consensus results can be determined, for example, by the distance between spatial consensus vectors. In this case, the distance between the spatial consensus vector of any second node in the second node subset and the spatial consensus vector of the first node corresponding to any second node is less than a distance threshold, and the first node corresponding to any second node is the node with the smallest distance between the spatial consensus vector of the first node subset and the spatial consensus vector of any second node.
[0119] In some embodiments, the distance between spatial consensus vectors can be determined, for example, using Euclidean distance, with reference to formula (1).
[0120] According to some embodiments, a third node can be selected from the blockchain node set, and the node with the smallest distance between the spatial consensus vector of the third node and the spatial consensus vector of the first node subset can be determined to obtain the first node corresponding to the third node; the direction of the second spatial consensus vector and the second probe walk step size between the third node and the first node corresponding to the third node can be determined; the third node can walk according to the direction of the second spatial consensus vector and the second probe walk step size until it walks to the point where the distance between the spatial consensus vector and the spatial consensus vector of the first node corresponding to any node is less than the distance threshold, and the third node after walking is obtained and placed into the second node subset; if the number of nodes corresponding to the second node subset meets the selection requirements, the selection of the third node from the blockchain node set is stopped, and the second node subset is obtained.
[0121] In some embodiments, a third node refers to any node in the blockchain node set other than the first node subset and the second node subset.
[0122] In some embodiments, the node with the smallest distance between the spatial consensus vector of the first node subset and the spatial consensus vector of the third node can be determined according to formula (1).
[0123] In some embodiments, the direction of the second spatial consensus vector between the third node and the corresponding first node can be as shown in equation (4):
[0124] t ef =A f -A e #(4)
[0125] Among them, A e Indicates the third node E; A f This represents the first node F corresponding to the third node E; t ef This indicates the direction of the second spatial consensus vector between the third node E and the first node F.
[0126] In some embodiments, the second probe walking step size can be, for example, as shown in equation (5):
[0127] η ef =d min *t′ ef #(5)
[0128] Where, η ef t′ represents the second probe walk step size between the third node E and the first node F. ef Represents the normalized t ef .
[0129] According to some embodiments, the distance threshold can be, for example, the minimum spatial consensus vector distance d corresponding to the set of spatial consensus vectors. min For example, when the distance between the third node E and the spatial consensus vector of the first node F is less than d... min When the third node E after the walk is identified as the second node, the walk stops.
[0130] In some embodiments, the selection requirement may be, for example, that the number of nodes corresponding to the second node subset reaches half the number of nodes in the blockchain node set.
[0131] S205, in response to receiving a data upload request, the first subset of nodes is used to reach a consensus on the data upload request and obtain the first consensus result;
[0132] According to some embodiments, electronic devices may incorporate, for example, a blockchain system. In this case, the blockchain node set refers to the collection of all nodes in the blockchain system.
[0133] In some embodiments, a data upload request can be, for example, a data upload request sent by a business system to the blockchain.
[0134] In some embodiments, when a blockchain system receives a data upload request, it can first verify the rationality of the data upload request. After the data upload request is verified, it broadcasts it to neighboring nodes and continuously spreads it to the entire blockchain network.
[0135] According to some embodiments, the consensus result pass rate corresponding to the first consensus result can be determined; if the consensus result pass rate is greater than the consensus result pass rate threshold, then the first consensus result is a consensus passed; if the consensus result pass rate is not greater than the consensus result pass rate threshold, then the first consensus result is a consensus failed.
[0136] In some embodiments, the first consensus result includes the consensus result corresponding to any first node in the first node subset. That is, the consensus result pass rate corresponding to the first consensus result can be determined based on the consensus result corresponding to each first node in the first node subset. This consensus result pass rate is the proportion of nodes in the first node subset whose consensus result is a consensus pass.
[0137] In some embodiments, the pass rate threshold is not specifically a fixed threshold. The pass rate threshold can be adjusted according to the actual application scenario. For example, the pass rate threshold could be 50%.
[0138] S206 If the first consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain;
[0139] According to some embodiments, a state machine can be used to asynchronously upload the data corresponding to the data upload request to the blockchain.
[0140] In some embodiments, the state machine is a message queue. After consensus is reached, the data corresponding to the data upload request is stored in the state machine, packaged to generate a block, and the asynchronous upload operation is realized.
[0141] S207, if the first consensus result is that the consensus is not passed, then the first subset of nodes and the second subset of nodes in the blockchain node set are used to reach a consensus on the data upload request to obtain the second consensus result;
[0142] According to some embodiments, whether the second consensus result has passed consensus can be determined based on the consensus result pass rate and pass rate threshold corresponding to the second consensus result.
[0143] S208, if the second consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain;
[0144] S209, If the second consensus result is that the consensus is not passed, then all nodes in the blockchain node set shall be used to reach a consensus on the data upload request to obtain the third consensus result;
[0145] According to some embodiments, whether the second consensus result has passed consensus can be determined based on the consensus result pass rate corresponding to the third consensus result and the pass rate threshold.
[0146] S210, if the third consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain.
[0147] S211, if the third consensus result is that the consensus is not passed, then the data upload request will fail.
[0148] To give an example from a scenario, Figure 4 This is a schematic flowchart illustrating a blockchain data consensus and on-chain method provided in an embodiment of this disclosure. Figure 4As shown, the blockchain system is divided into three layers: the bus consensus layer, the probe-enhanced consensus layer, and other consensus layers. Among them, the bus nodes in the bus consensus layer are the nodes in the first node subset, the probe-enhanced consensus layer are the nodes in the second node subset, and the nodes in the other consensus layers are all nodes in the blockchain node set except for the first node subset and the second node subset.
[0149] In some embodiments, such as Figure 4 As shown, data upload requests are first reached through a bus consensus layer. Once consensus is reached, the data corresponding to the data upload request is asynchronously uploaded to the blockchain via a state machine. Secondly, if the bus consensus fails, nodes in the probe-enhanced consensus layer participate in the consensus process along with the bus consensus layer. Once consensus is reached, the data is asynchronously uploaded to the blockchain via a state machine. Finally, if the first two layers fail, all nodes—the bus consensus layer, the probe-enhanced consensus layer, and other consensus layers—participate in the consensus process. Therefore, an efficient consensus mechanism can be provided, enabling data to be uploaded to the blockchain quickly.
[0150] For example, the application product information in electronic signatures may include the name, version number, release date, and certificate information of the signing software or platform. By recording this information on the blockchain, the immutability and verifiability of the information can be achieved. This increases the credibility and security of electronic signatures and prevents tampering and forgery. Therefore, by utilizing the method provided in this embodiment, real-time updates and tracking of signature information can be achieved, improving the efficiency and convenience of the signing process, and providing support for evidence management and legal validity in electronic signatures. This provides users with a fast and convenient electronic signature service experience while improving the efficiency of data on-chain processing.
[0151] In summary, the method provided in this embodiment, by layering the blockchain node set, can improve data upload efficiency by reducing the consensus required by consensus nodes, thus significantly improving both node consensus and data upload efficiency. Specifically, when consensus fails with the first subset of nodes, consensus is achieved by combining consensus with the second subset of nodes. Since the distance between the spatial consensus vectors of the second node and its corresponding first node in the second subset is less than a distance threshold, consensus accuracy can be maintained while improving consensus and data upload efficiency. Furthermore, when consensus fails with both the first and second subsets of nodes, consensus is achieved using all nodes in the blockchain node set, which increases the consensus success rate. Moreover, by determining the first and second subsets of nodes from the blockchain node set based on historical consensus results, the accuracy of determining the first and second subsets can be improved.
[0152] To implement the above embodiments, this disclosure also proposes a blockchain data consensus on-chain device.
[0153] like Figure 5As shown, the blockchain data consensus on-chain device 500 includes:
[0154] The data consensus unit 501 is used to respond to the received data upload request, and to use a first node subset to reach consensus on the data upload request to obtain a first consensus result. The first node subset includes a starting node, an ending node and at least one intermediate node. The starting node and the ending node are the two nodes with the largest difference in consensus results in the blockchain node set, and the intermediate node is the node on the optimal walk path between the starting node and the ending node in the blockchain node set.
[0155] The data upload unit 502 is used to add the data corresponding to the data upload request to the blockchain if the first consensus result is that the consensus is passed.
[0156] Optionally, where,
[0157] The data consensus unit 501 is also used to, if the first consensus result is that the consensus has not been passed, use the first node subset and the second node subset in the blockchain node set to reach a consensus on the data upload request and obtain a second consensus result. In this case, the difference between the consensus result of any second node in the second node subset and the first node corresponding to any second node is less than the difference threshold, and the first node corresponding to any second node is the node with the smallest difference between the consensus result of the first node subset and any second node.
[0158] The data upload unit 502 is also used to add the data corresponding to the data upload request to the blockchain if the second consensus result is that the consensus is passed;
[0159] The data consensus unit 501 is also used to obtain a third consensus result if the second consensus result is that the consensus has not been passed, by using all nodes in the blockchain node set to reach a consensus on the data upload request.
[0160] The data upload unit 502 is also used to add the data corresponding to the data upload request to the blockchain if the third consensus result is that the consensus is passed.
[0161] Optionally, before reaching consensus on the data upload request using a subset of the first nodes, the data consensus unit 501 is also used for:
[0162] A spatial consensus vector set is constructed based on the historical consensus results corresponding to the blockchain node set, wherein the spatial consensus vector in the spatial consensus vector set corresponds one-to-one with the node in the blockchain node set;
[0163] Select the two nodes with the largest spatial consensus vector distance from the blockchain node set as the starting node and the ending node, respectively;
[0164] Determine the optimal traversal route between the starting node and the ending node from the blockchain node set, and put the nodes, starting node and ending node in the optimal traversal route into the first node subset.
[0165] Optionally, when the data consensus unit 501 is used to determine the optimal traversal route between the starting node and the ending node from the blockchain node set, it is specifically used for:
[0166] Determine the direction of the first spatial consensus vector, the detection radius, and the first detection walk size between the starting node and the ending node;
[0167] The starting node moves to the target position according to the direction of the first spatial consensus vector and the first probe walking step size, and then scans the node with the target position as the center according to the probe radius to obtain the scanning result;
[0168] If the scan result is that there is no node in the blockchain node set, then let the starting node continue to walk from the target position according to the vector direction and the first probe walking step size until the scan result is that there is a node in the blockchain node set;
[0169] The node corresponding to the scan result is used as the starting node to continue the journey until the ending node is reached, thus obtaining the optimal journey route.
[0170] Optionally, when the data consensus unit 501 is used to determine the detection radius between the starting node and the ending node and the first detection walk step size, it is specifically used for:
[0171] The direction of the consensus vector in the first space is normalized to obtain the normalized vector direction.
[0172] Determine the minimum spatial consensus vector distance corresponding to the set of spatial consensus vectors, and use the minimum spatial consensus vector distance as the detection radius;
[0173] The first detection walk step size is determined based on the normalized vector direction and the detection radius.
[0174] Optionally, before reaching consensus on the data upload request using the first subset of nodes and the second subset of nodes in the blockchain node set, the data consensus unit 501 is also used for:
[0175] A second subset of nodes is determined from the set of blockchain nodes, wherein the distance between the spatial consensus vector of any second node in the second subset and the spatial consensus vector of the first node corresponding to any second node is less than a distance threshold, and the first node corresponding to any second node is the node with the smallest distance between the spatial consensus vector of the first subset and the spatial consensus vector of any second node.
[0176] Optionally, when the data consensus unit 501 is used to determine the second subset of nodes from the blockchain node set, it is specifically used for:
[0177] Select the third node from the blockchain node set, and determine the node with the smallest distance between the spatial consensus vector of the first node subset and the spatial consensus vector of the third node, to obtain the first node corresponding to the third node. The third node is any node in the blockchain node set other than the first node subset and the second node subset.
[0178] Determine the direction of the second spatial consensus vector and the second probe walk step size between the third node and the first node corresponding to the third node;
[0179] The third node is instructed to walk in the direction of the second spatial consensus vector and the second probe walking step size until the distance between the spatial consensus vector and the spatial consensus vector of the first node corresponding to any node is less than the distance threshold. The third node after walking is then placed into the subset of the second node.
[0180] If the number of nodes corresponding to the second node subset meets the selection requirements, stop selecting a third node from the blockchain node set, thus obtaining the second node subset.
[0181] Optionally, the data upload unit 502 is used to add the data corresponding to the data upload request to the blockchain, specifically for:
[0182] The data corresponding to the data upload request is asynchronously uploaded to the blockchain using a state machine.
[0183] Optionally, the data consensus unit 501 is also used for:
[0184] Determine the consensus result pass rate corresponding to the first consensus result, wherein the first consensus result includes the consensus result corresponding to any first node in the first node subset;
[0185] If the consensus result pass rate is greater than the consensus result pass rate threshold, then the first consensus result is considered a consensus pass;
[0186] If the consensus result pass rate is not greater than the consensus result pass rate threshold, then the first consensus result is consensus failure.
[0187] It should be noted that the foregoing explanation of the blockchain data consensus on-chain method embodiment also applies to the blockchain data consensus on-chain device of this embodiment, and will not be repeated here.
[0188] In summary, the apparatus provided in this embodiment of the present disclosure achieves consensus on data upload requests by using a first subset of nodes in the blockchain node set. Since the first subset of nodes includes the two nodes with the largest differences in consensus results in the blockchain node set, as well as the nodes on the optimal walk path between these two nodes, the differences in consensus results among the nodes in the first subset of nodes are relatively large, which can include most cases of blockchain node consensus. Thus, the first subset of nodes can be used to replace the blockchain node set for consensus, thereby improving the efficiency of data consensus upload.
[0189] To implement the above embodiments, this disclosure also proposes an electronic device, including: a processor and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided in the foregoing embodiments.
[0190] To implement the above embodiments, this disclosure also proposes a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods provided in the foregoing embodiments.
[0191] To implement the above embodiments, this disclosure also proposes a computer program product, including a computer program that, when executed by a processor, implements the methods provided in the foregoing embodiments.
[0192] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in this disclosure all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0193] It should be noted that personal information collected from users should be used for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. Furthermore, such collection / sharing should only be conducted after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign an agreement / authorization that includes authorization of relevant user information before the user uses the function. In addition, any necessary steps must be taken to protect and safeguard access to such personal information data and ensure that others with access to personal information data comply with their privacy policies and procedures.
[0194] This disclosure is intended to provide implementation schemes for users to selectively prevent the use or access to their personal information data. Specifically, this disclosure is intended to provide hardware and / or software to prevent or block access to such personal information data. Once personal information data is no longer needed, risks can be minimized by restricting data collection and deleting data. Furthermore, where applicable, such personal information is de-identified to protect user privacy.
[0195] In the foregoing descriptions of the embodiments, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0196] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0197] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of this disclosure includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of this disclosure pertain.
[0198] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0199] It should be understood that various parts of this disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0200] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.
[0201] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0202] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.
Claims
1. A method for blockchain data consensus on-chaining, characterized in that, include: In response to a received data upload request, a first subset of nodes is used to reach a consensus on the data upload request, resulting in a first consensus result. This first subset of nodes includes a starting node, an ending node, and at least one intermediate node. The starting node and the ending node are the two nodes in the blockchain node set with the largest difference in their consensus results. The intermediate node is a node on the optimal walk path between the starting node and the ending node in the blockchain node set. Determining the optimal walk path between the starting node and the ending node from the blockchain node set includes: Determine the direction of the first spatial consensus vector, the detection radius, and the first detection walk size between the starting node and the ending node; The starting node is instructed to move to the target position according to the direction of the first spatial consensus vector and the first probe walking step size, and the node is scanned with the target position as the center according to the probe radius to obtain the scanning result; If the scan result indicates that there is no node in the blockchain node set, then the starting node continues to move from the target position according to the vector direction and the first probe walking step size until the scan result indicates that there is a node in the blockchain node set. The node corresponding to the scan result is used as the starting node to continue the journey until the ending node is reached, thus obtaining the optimal journey route. If the first consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain.
2. The method according to claim 1, characterized in that, The method further includes: If the first consensus result is that the consensus is not passed, then the first node subset and the second node subset in the blockchain node set are used to reach a consensus on the data upload request to obtain a second consensus result. In this case, the consensus result difference between any second node in the second node subset and the first node corresponding to any second node is less than the difference threshold, and the first node corresponding to any second node is the node with the smallest consensus result difference between the first node subset and any second node. If the second consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain; If the second consensus result is that the consensus is not passed, then all nodes in the blockchain node set will be used to reach a consensus on the data upload request to obtain a third consensus result; If the third consensus result is that the consensus is passed, then the data corresponding to the data upload request will be added to the blockchain.
3. The method according to claim 1, characterized in that, Before reaching consensus on the data upload request using a subset of first nodes, the method further includes: A spatial consensus vector set is constructed based on the historical consensus results corresponding to the blockchain node set, wherein the spatial consensus vector in the spatial consensus vector set corresponds one-to-one with the node in the blockchain node set; Select the two nodes with the largest spatial consensus vector distance from the blockchain node set as the starting node and the ending node, respectively; The optimal traversal route between the starting node and the ending node is determined from the blockchain node set, and the nodes in the optimal traversal route, the starting node, and the ending node are placed into the first node subset.
4. The method according to claim 3, characterized in that, Determining the detection radius between the starting node and the ending node and the first detection walk step length includes: The direction of the first spatial consensus vector is normalized to obtain the normalized vector direction; Determine the minimum spatial consensus vector distance corresponding to the set of spatial consensus vectors, and use the minimum spatial consensus vector distance as the detection radius; The first detection walk step size is determined based on the normalized vector direction and the detection radius.
5. The method according to claim 2, characterized in that, Before reaching consensus on the data upload request using the first subset of nodes and the second subset of nodes in the blockchain node set, the method further includes: A second subset of nodes is determined from the set of blockchain nodes, wherein the distance between the spatial consensus vector of any second node in the second subset and the spatial consensus vector of the first node corresponding to any second node is less than a distance threshold, and the first node corresponding to any second node is the node with the smallest distance between the spatial consensus vector of the first subset and the spatial consensus vector of any second node.
6. The method according to claim 5, characterized in that, Determining the second subset of nodes from the blockchain node set includes: A third node is selected from the blockchain node set, and the node with the smallest distance between the spatial consensus vector of the first node subset and the spatial consensus vector of the third node is determined to obtain the first node corresponding to the third node. The third node is any node in the blockchain node set other than the first node subset and the second node subset. Determine the direction of the second spatial consensus vector and the second probe walk step size between the third node and the first node corresponding to the third node; The third node is instructed to walk in the direction of the second spatial consensus vector and the second probe walking step size until the distance between the spatial consensus vector and the spatial consensus vector of the first node corresponding to any node is less than the distance threshold. The third node after walking is then placed into the second node subset. If the number of nodes corresponding to the second node subset meets the selection requirements, the selection of a third node from the blockchain node set is stopped, and the second node subset is obtained.
7. The method according to claim 1, characterized in that, Adding the data corresponding to the data upload request to the blockchain includes: The data corresponding to the data upload request is asynchronously uploaded to the blockchain using a state machine.
8. The method according to claim 1, characterized in that, The method further includes: Determine the consensus result pass rate corresponding to the first consensus result, wherein the first consensus result includes the consensus result corresponding to any first node in the first node subset; If the consensus result pass rate is greater than the consensus result pass rate threshold, then the first consensus result is considered a consensus pass; If the consensus result pass rate is not greater than the consensus result pass rate threshold, then the first consensus result is a consensus failure.
9. A blockchain data consensus on-chain device, characterized in that, include: A data consensus unit is configured to, in response to a received data upload request, use a first subset of nodes to reach a consensus on the data upload request and obtain a first consensus result. The first subset of nodes includes a starting node, an ending node, and at least one intermediate node. The starting node and the ending node are the two nodes in the blockchain node set with the largest difference in their consensus results. The intermediate node is a node on the optimal traversal path between the starting node and the ending node in the blockchain node set. Determining the optimal traversal path between the starting node and the ending node from the blockchain node set includes: Determine the direction of the first spatial consensus vector, the detection radius, and the first detection walk size between the starting node and the ending node; The starting node is instructed to move to the target position according to the direction of the first spatial consensus vector and the first probe walking step size, and the node is scanned with the target position as the center according to the probe radius to obtain the scanning result; If the scan result indicates that there is no node in the blockchain node set, then the starting node continues to move from the target position according to the vector direction and the first probe walking step size until the scan result indicates that there is a node in the blockchain node set. The node corresponding to the scan result is used as the starting node to continue the journey until the ending node is reached, thus obtaining the optimal journey route. The data upload unit is used to add the data corresponding to the data upload request to the blockchain if the first consensus result is that the consensus is passed.
Citation Information
Patent Citations
Data communication method and device between blockchain networks
CN109587131A
Block chain consensus method and device, computer equipment and block chain node
CN111522876A