Consensus method, device and blockchain system of blockchain system
By generating verifiable random numbers and calculating broadcast time in the blockchain system, the problems of high computing resource consumption and low transaction processing efficiency in the prior art are solved, and a more efficient consensus process is achieved.
Patent Information
- Application Number
- CN202411926925.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2044-12-25
AI Technical Summary
Existing blockchain consensus methods such as Proof of Work (PoW) require nodes to consume a large amount of computing resources to solve mathematical problems, resulting in high requirements for node computing power and low transaction processing efficiency.
By generating a verifiable random number based on the node private key and the latest overhead block hash value, and calculating the broadcast time of the block to be overhead based on the random number and time coefficient, the node consensus of the blockchain system is realized.
It greatly reduces the computing resources consumed by nodes in the consensus process and improves the consensus efficiency of the blockchain system.
Smart Images

Figure CN119363319B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to blockchain technology, and more particularly to a consensus method, device and blockchain system for a blockchain system. Background Art
[0002] Proof of Work (PoW) is a blockchain consensus method that requires nodes to prove their contribution to the blockchain network by performing computationally intensive tasks in order to obtain the right to create new blocks and obtain rewards. It reaches consensus by calculating the workload to ensure that all nodes agree on the state of the blockchain.
[0003] Although the PoW method has the advantages of high security, tamper-proof transactions and high network activity, the core of PoW is to solve mathematical problems, and the process of solving mathematical problems requires a lot of computing resources, resulting in high requirements on the computing power of nodes and a small amount of transactions processed per unit time in the blockchain network. Summary of the invention
[0004] The embodiments of the present disclosure provide a consensus method, device and blockchain system for a blockchain system to solve the above problems.
[0005] A first aspect of the embodiments of the present disclosure provides a consensus method for a blockchain system, including:
[0006] Get the hash value of the latest block on the blockchain system;
[0007] Based on the private key of each node in the blockchain system and the hash value of the latest on-chain block, a verifiable random number of each node is generated, and the verifiable random number of each node is added to each to-be-on-chain block generated by each node;
[0008] Based on the verifiable random number and time coefficient of each node, determine the waiting time of each to-be-chained block relative to the broadcast time of the latest chained block;
[0009] Determine the broadcast time of each to-be-uplinked block based on the broadcast time of the latest to-be-uplinked block and the waiting time of each to-be-uplinked block relative to the broadcast time of the latest to-be-uplinked block;
[0010] Based on the broadcast time of each block to be chained, each block to be chained is broadcasted.
[0011] In some embodiments of the present disclosure, generating a verifiable random number of each node based on the private key of each node in the blockchain system and the hash value of the latest on-chain block includes:
[0012] Using a preset signature method, the hash value of the latest on-chain block is signed based on the private key of each node in the blockchain system to obtain the signature result of each node;
[0013] The signature results of the nodes are numerically converted to obtain verifiable random numbers of the nodes.
[0014] In some embodiments of the present disclosure, broadcasting each to-be-linked block based on the broadcast time of each to-be-linked block includes:
[0015] For any of the blocks to be chained, perform the following steps:
[0016] In response to the system time reaching the broadcast time of the current block to be chained and no block to be chained broadcasted or forwarded by other nodes of the blockchain network is received, the current block to be chained is broadcasted.
[0017] In some embodiments of the present disclosure, broadcasting each to-be-linked block based on the broadcast time of each to-be-linked block includes:
[0018] For any of the blocks to be chained, perform the following steps:
[0019] In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the block to be chained of the same block height broadcast or forwarded by other nodes of the blockchain network is greater than the verifiable random number of the current block to be chained, the current block to be chained is broadcasted.
[0020] In some embodiments of the present disclosure, after determining the broadcast time of each to-be-uplinked block based on the broadcast time of the latest to-be-uplinked block and the waiting time of each to-be-uplinked block relative to the broadcast time of the latest to-be-uplinked block, the method further includes:
[0021] For any of the blocks to be chained, perform the following steps:
[0022] In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the target block to be chained with the same block height broadcast or forwarded by other nodes of the blockchain network is less than the verifiable random number of the current block to be chained, the target block to be chained is forwarded.
[0023] In some embodiments of the present disclosure, it further includes:
[0024] The time coefficient is adjusted based on the numerical relationship between the average block generation time of the most recent multiple on-chain blocks and a preset time threshold.
[0025] A second aspect of the embodiments of the present disclosure provides a consensus device of a blockchain system, including:
[0026] The acquisition module is used to obtain the hash value of the latest block on the blockchain system;
[0027] A block processing module, configured to generate a verifiable random number of each node based on the private key of each node in the blockchain system and the hash value of the latest on-chain block, and add the verifiable random number of each node to each to-be-on-chain block generated by each node;
[0028] A waiting time determination module, configured to determine the waiting time of each to-be-chained block relative to the broadcast time of the latest chained block based on the verifiable random number and time coefficient of each node;
[0029] A broadcast time determination module, configured to determine the broadcast time of each to-be-uplinked block based on the broadcast time of the latest to-be-uplinked block and the waiting time of each to-be-uplinked block relative to the broadcast time of the latest to-be-uplinked block;
[0030] The node communication module is used to broadcast each of the blocks to be chained based on the broadcast time of each of the blocks to be chained.
[0031] In some embodiments of the present disclosure, the block processing module includes:
[0032] A signature unit, used to preset a signature method, sign the hash value of the latest on-chain block based on the private key of each node in the blockchain system, and obtain the signature result of each node;
[0033] The numerical conversion unit is used to perform numerical conversion on the signature results of each node to obtain a verifiable random number of each node.
[0034] In some embodiments of the present disclosure, the node communication module is used to perform the following steps for any of the blocks to be chained:
[0035] In response to the system time reaching the broadcast time of the current block to be chained and no block to be chained broadcasted or forwarded by other nodes of the blockchain network is received, the current block to be chained is broadcasted.
[0036] In some embodiments of the present disclosure, the node communication module is used to perform the following steps for any of the blocks to be chained:
[0037] In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the block to be chained of the same block height broadcast or forwarded by other nodes of the blockchain network is greater than the verifiable random number of the current block to be chained, the current block to be chained is broadcasted.
[0038] In some embodiments of the present disclosure, the node communication module is used to perform the following steps for any of the blocks to be chained:
[0039] In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the target block to be chained with the same block height broadcast or forwarded by other nodes of the blockchain network is less than the verifiable random number of the current block to be chained, the target block to be chained is forwarded.
[0040] In some embodiments of the present disclosure, the device further includes:
[0041] The time coefficient adjustment module is used to adjust the time coefficient based on the numerical relationship between the average block generation time of the most recent multiple on-chain blocks and a preset time threshold.
[0042] A third aspect of the embodiments of the present disclosure provides a blockchain system, including:
[0043] Blockchain network;
[0044] The apparatus of the second aspect is used to execute the method of the first aspect.
[0045] The consensus method, device and blockchain system of the blockchain system of the embodiments of the present disclosure need to consume a large amount of computing resources of the nodes to reach a consensus by solving mathematical problems, resulting in high requirements on the computing power of the nodes and a small transaction volume processed per unit time of the blockchain network. Therefore, a verifiable random number is generated for each node according to the private key of each node in the blockchain system and the hash value of the latest block on the chain, and then the broadcast time of each block to be chained is calculated. The broadcast time of each block to be chained is used to broadcast the blocks to be chained to achieve node consensus of the blockchain system. Compared with the method of reaching consensus by solving complex mathematical problems and calculating the workload, the computing resources consumed by the nodes in the consensus process can be greatly reduced, thereby improving the consensus efficiency of the blockchain system.
[0046] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0048] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0049] Figure 1 A schematic diagram of a consensus method of a blockchain system in some embodiments of the present disclosure;
[0050] Figure 2 is a partial flow chart of step S2 in some embodiments of the present disclosure;
[0051] Figure 3 is a schematic diagram of the blockchain consensus process in some examples of the present disclosure;
[0052] Figure 4 is a working principle diagram of the blockchain system consensus method in some examples of the present disclosure;
[0053] Figure 5 It is a structural block diagram of a consensus device of a blockchain system in some embodiments of the present disclosure;
[0054] Figure 6 is a structural block diagram of a block processing module 200 in some embodiments of the present disclosure;
[0055] Figure 7 A structural block diagram of a consensus device of a blockchain system in some other embodiments of the present disclosure;
[0056] Figure 8 The structure block diagram of an electronic device in one embodiment of the present disclosure. DETAILED DESCRIPTION
[0057] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.
[0058] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.
[0059] It should also be understood that in the embodiments of the present disclosure, “plurality” may refer to two or more than two, and “at least one” may refer to one, two, or more than two.
[0060] It should also be understood that any component, data or structure mentioned in the embodiments of the present disclosure can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0061] In addition, the term "and / or" in the present disclosure is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present disclosure generally indicates that the associated objects before and after are in an "or" relationship.
[0062] It should also be understood that the description of the various embodiments in the present disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0063] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0064] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0065] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0066] The embodiments of the present disclosure can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0067] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0068] Figure 1Schematic diagram of the consensus method of the blockchain system in some embodiments of the present disclosure. Figure 1 As shown, the consensus method of the blockchain system includes the following steps:
[0069] S1: Get the hash value of the latest block on the blockchain system.
[0070] When each node in the blockchain system detects that a block has been uploaded to the chain, it obtains the hash value of the latest uploaded block.
[0071] The hash algorithm used by the blockchain system can be MD5, SHA-1 or SHA-2. Among them, the MD5 message digest algorithm is a cryptographic hash function used to generate a 128-bit (16-byte) hash value to ensure the integrity and consistency of information transmission. SHA-1 uses a cryptographic hash function to generate a 160-bit (20-byte) hash value called a message digest. SHA-2 is the successor of SHA-1, which can be further divided into six different algorithm standards, including: SHA-224, SHA-256, SHA-384, SHA-512, SHA-512 / 224, SHA-512 / 256.
[0072] S2: Based on the private key of each node in the blockchain system and the hash value of the latest chained block, a verifiable random number is generated for each node, and the verifiable random number of each node is added to each block to be chained generated by each node.
[0073] For each node in the blockchain system, a verifiable random number generation function can be used to generate a verifiable random number for each node based on its own private key and the hash value of the latest chained block. The verifiable random number generation function is vrfFunc(privKey, hash). Among them, privKey represents the private key of the node, hash represents the hash value of the latest chained block, and the generation function vrfFunc(privKey, hash) will generate a certain verifiable random number when given privKey and hash.
[0074] After each node in the blockchain system generates a block to be chained, the verifiable random number corresponding to each node is added to the block to be chained, so that other nodes in the blockchain system can verify the verifiable random number of each node according to the public key of each node.
[0075] S3: Based on the verifiable random number and time coefficient of each node, determine the waiting time of each block to be chained relative to the broadcast time of the latest chained block.
[0076] A time coefficient associated with the waiting time is obtained. The initial value of the time coefficient can be given by the genesis block of the blockchain system, and the initial value of the time coefficient can be adjusted.
[0077] Get the broadcast time of the latest on-chain block. According to the timestamp of the genesis block, the waiting time of each on-chain block from the genesis block to the latest on-chain block can be accumulated to obtain the broadcast time of the latest on-chain block. For example, the Unix timestamp of the genesis block is 1000s, the latest on-chain block is the 5th block in the blockchain, and the waiting time from the 1st block to the 5th block of the blockchain is 2s, 3s, 2s, 1s and 2s respectively. Then the broadcast time of the latest on-chain block is 1010S (1000s + 2s + 3s + 2s + 1s + 2s).
[0078] For each node in the blockchain system, the product of the verifiable random number of each node and the time coefficient is calculated, and the calculated product is determined as the waiting time of the to-be-chained block generated by each node relative to the broadcast time of the latest chained block.
[0079] S4: Based on the broadcast time of the latest on-chain block and the waiting time of each to-be-on-chain block relative to the broadcast time of the latest on-chain block, determine the broadcast time of each to-be-on-chain block.
[0080] For each to-be-chained block generated by each node in the blockchain system, the sum of the broadcast time of the new to-be-chained block and the waiting time of each to-be-chained block relative to the broadcast time of the latest to-be-chained block is calculated, and the calculated sum is used to determine the broadcast time of each to-be-chained block. For example, if the broadcast time of the latest to-be-chained block is 1010S, and the waiting time of a to-be-chained block is 2s, then the broadcast time of the to-be-chained block is 1012s.
[0081] S5: Broadcast each block to be chained based on the broadcast time of each block to be chained.
[0082] For each block to be chained generated by each node in the blockchain system, before the current system time reaches the broadcast time of each block to be chained, the node is not allowed to broadcast the block to be chained. If other nodes in the blockchain system directly discard the block to be chained before the current system time reaches the broadcast time of each block to be chained, each block to be chained can be broadcasted.
[0083] In this embodiment, since reaching a consensus by solving mathematical problems requires consuming a large amount of computing resources of the nodes, resulting in high requirements on the computing power of the nodes and a small amount of transactions processed per unit time of the blockchain network, a verifiable random number is generated for each node based on the private key of each node in the blockchain system and the hash value of the latest block on the chain, and then the broadcast time of each block to be chained is calculated, and the broadcast time of each block to be chained is used to broadcast the blocks to be chained to achieve node consensus of the blockchain system. Compared with reaching a consensus by solving complex mathematical problems and calculating the workload, the computing resources consumed by the nodes in the consensus process can be greatly reduced, thereby improving the consensus efficiency of the blockchain system.
[0084] Figure 2 FIG. 1 is a partial flow chart of step S2 in some embodiments of the present disclosure. Figure 2 As shown, step S2 includes the following steps:
[0085] S2-1: Use the preset signature method to sign the hash value of the latest block on the chain based on the private key of each node in the blockchain system to obtain the signature result of each node.
[0086] S2-2: Perform numerical conversion on the signature result of each node to obtain a verifiable random number for each node.
[0087] The Edwards-curve Digital Signature Algorithm (EdDSA) can be used in the function vrfFunc(privKey, hash) of verifiable random numbers. The vrfFunc function can be rewritten as toNumber(EdDSA(privKey, hash)). EdDSA(privKey, hash) means using the private key privKey to sign the data hash. The signature algorithm is EdDSA, and the signature result is a string. toNumber converts the string into a floating point number in the interval (0,1).
[0088] In an example of the present disclosure, the private key privKey is 9a1f8b…cbaf3f89, the hash value of the latest block on the chain is c0535e4…31f1b9d61, and the string generated by the EdDSA signature is rHXy7…Cw==. The string is forced to be converted into a decimal of 0.1764937649237, which can verify the random number.
[0089] In this embodiment, since the EdDSA signature method can improve the signing / verification speed while ensuring security, the EdDSA signature method is used to sign the hash value of the latest chain block according to the private key of each node to obtain a signature result in a string format. By converting the signature result into a numerical value, a verifiable random number for each node can be quickly generated while ensuring security.
[0090] In some embodiments of the present disclosure, in step S5, the following steps are performed for any of the blocks to be chained:
[0091] S5-A: In response to the system time reaching the broadcast time of the current block to be chained and no block to be chained with the same block height broadcast or forwarded by other nodes in the blockchain network is received, the current block to be chained is broadcasted.
[0092] For each block to be chained, from the broadcast time of the latest chained block to the time when the system time reaches the broadcast time of the block to be chained, if no blockchain node broadcasts or forwards the block to be chained with the same block height, that is, no other node competes for block generation within this time, then the block to be chained will be broadcasted in the blockchain network.
[0093] In this embodiment, since the blockchain network does not require pledged coins during the node consensus process, the block to be chained generated by the current node can be broadcasted when the system time reaches the broadcast time of the block to be chained generated by the current node and there are no other nodes competing for the block. This method is suitable for the alliance chain system.
[0094] In some embodiments of the present disclosure, in step S5, the following steps are performed for any of the blocks to be chained:
[0095] S5-B: In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the block to be chained with the same block height broadcast or forwarded by other nodes of the blockchain network is greater than the verifiable random number of the current block to be chained, the current block to be chained is broadcasted.
[0096] For each block to be chained, from the broadcast time of the latest chained block to the time when the system time reaches the broadcast time of the block to be chained, if the current node receives a block to be chained with the same block height broadcasted or forwarded by other nodes in the blockchain network, extract the verifiable random number in the block to be chained broadcasted or forwarded by other nodes, and compare the verifiable random number of the current block to be chained generated by the current node with the verifiable random number in the block to be chained broadcasted or forwarded by other nodes. If the verifiable random number of the current block to be chained generated by the current node is less than the verifiable random number in the block to be chained broadcasted or forwarded by other nodes, the current block to be chained generated by the current node is broadcasted in the blockchain network.
[0097] In this embodiment, since the blockchain network does not require pledged coins during the node consensus process, when the system time reaches the broadcast time of the current node generating the current block to be chained, and the verifiable random number of the current block to be chained is smaller than the verifiable random number of the block to be chained broadcasted or forwarded by other nodes, the block to be chained generated by the current node can be broadcasted. This consensus method of competing for blocks based on verifiable random numbers is suitable for alliance chain systems and compatible with decentralized peer-to-peer networks.
[0098] In some embodiments of the present disclosure, after step S4, the following steps are performed for any of the blocks to be chained:
[0099] S6: In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the target block to be chained broadcasted or forwarded by other nodes of the blockchain network is less than the verifiable random number of the current block to be chained, the target block to be chained is forwarded.
[0100] For each block to be chained, from the broadcast time of the latest chained block to the time when the system time reaches the broadcast time of the block to be chained, if the current node receives a block to be chained with the same block height broadcasted or forwarded by other nodes in the blockchain network, each block to be chained with the same block height broadcasted or forwarded by other nodes is used as the target block to be chained, and the verifiable random number in the target block to be chained broadcasted or forwarded by other nodes is extracted. The verifiable random number of the current block to be chained generated by the current node is compared with the verifiable random number in the target block to be chained. If the verifiable random number of the current block to be chained generated by the current node is greater than the verifiable random number in the target block to be chained, the target block to be chained is forwarded.
[0101] In this embodiment, since the blockchain network does not require pledged coins during the node consensus process, when the system time reaches the broadcast time of the current node generating the current block to be chained, and the verifiable random number of the target block to be chained is smaller than the verifiable random number of the current block to be chained, the target block to be chained is forwarded. This consensus method of competing for blocks based on verifiable random numbers is suitable for alliance chain systems and compatible with decentralized peer-to-peer networks.
[0102] In some embodiments of the present disclosure, the consensus method of the blockchain system may further include the following steps: adjusting the time coefficient based on the numerical relationship between the average block time of the most recent multiple on-chain blocks and a preset block time threshold.
[0103] Get the waiting time of the latest N on-chain blocks in the blockchain network, average the waiting time of the latest N on-chain blocks, and get the average block time of the latest N on-chain blocks. Where N is a positive integer greater than 1.
[0104] Using the preset time coefficient adjustment formula, the time coefficient is adjusted according to the numerical relationship between the average block time of the most recent N on-chain blocks and the preset time threshold, so that the adjusted time coefficient approaches or is equal to the preset time threshold.
[0105] In some examples of the present disclosure, let the average block time of the most recent N on-chain blocks be t1, the preset time threshold be t2, the time coefficient before adjustment be x1, and the time coefficient after adjustment be x2. If t1>t2, then , where c1 is a constant and 0<c1<1; if t1<t2, then , where c2 is a constant and c2>1.
[0106] In some other examples of the present disclosure, assuming that the average block time of the most recent N on-chain blocks is T1, the preset time threshold is T2, the time coefficient before adjustment is X1, and the time coefficient after adjustment is X2, then .
[0107] In this embodiment, since the blockchain system consensus method of the disclosed embodiment does not have a voting process, the failure of some nodes will affect the minimum value of the verifiable random number in the same block height, and thus affect the average block time. Therefore, the time coefficient is adjusted according to the numerical relationship between the average block time of the most recent multiple on-chain blocks and the preset time threshold. The average block time of the blockchain network can be close to the preset time coefficient, thereby controlling the average block time of the blockchain network. Even if a large number of nodes are down, consensus can still be performed normally.
[0108] Figure 3 is a schematic diagram of the blockchain consensus process in some examples of this disclosure. Figure 3As shown, the blockchain consensus process can include the following steps:
[0109] ① The blockchain node network obtains the block hash and time coefficient of the latest block on the blockchain. The blockchain node network may include node 1, node 2, node 3, and node 4. The blockchain node network may have downtime nodes, such as node 4 downtime. The following example will be explained with node 4 downtime.
[0110] ② After node 1, node 2, and node 3 obtain the block hash and time coefficient of the latest on-chain block, they use the EdDSA method to generate a verifiable random number for each node based on the block hash of the latest on-chain block and the private key of each node. That is, node 1 uses the EdDSA method to generate a verifiable random number for node 1 based on the block hash of the latest on-chain block and the private key of node 1. The way to generate the verifiable random number of node 2 and the verifiable random number of node 3 is similar to the way to generate the verifiable random number of node 1.
[0111] ③Node 1 generates the block to be chained of node 1, and packs the verifiable random number generated by node 1 into the block to be chained of node 1. In addition, node 1 determines the waiting time of the block to be chained of node 1 according to the verifiable random number and time coefficient of node 1, and then determines the broadcast time of the block to be chained of node 1 according to the broadcast time of the latest chained block and the verifiable random number of node 1. Using a similar processing method to node 1, node 2 packs the verifiable random number of node 2 into the block to be chained of node 2, and determines the broadcast time of the block to be chained of node 2. Also using a similar processing method to node 1, node 3 packs the verifiable random number of node 3 into the block to be chained of node 3, and determines the broadcast time of the block to be chained of node 3.
[0112] ④ In the time period from the broadcast time of the latest on-chain block to the broadcast time of the to-be-on-chain block of node i (i=1,2,3), if node i has not received the to-be-on-chain block of the same block height broadcast or forwarded by other nodes, or the verifiable random number in the to-be-on-chain block of the same block height broadcast or forwarded by other nodes received by node i is greater than the verifiable random number in the to-be-on-chain block of node i, then when the system time reaches the broadcast time of the to-be-on-chain block of node i, the to-be-on-chain block of node i will be broadcast in the blockchain node network.
[0113] In this example, even if node 4 goes down, nodes 1, 2, and 3 can still reach consensus normally.
[0114] Figure 4 This is a working principle diagram of the blockchain system consensus method in some examples of this disclosure. Figure 4As shown, the nodes competing for block generation in the blockchain network include node 1, node 2, and node 3. Node 1, node 2, and node 3 generate random numbers according to the previous block on the blockchain network (i.e., generate verifiable random numbers of the nodes according to the hash value of the latest on-chain block and the private key of the node), and add the generated random numbers to the to-be-on-chain blocks generated by the nodes themselves (add the verifiable random number generated by node i to the to-be-on-chain blocks generated by node i, i=1,2,3), and the to-be-on-chain blocks generated by node 1, node 2, and node 3 are respectively recorded as to-be-on-chain blocks 1, to-be-on-chain blocks 2, and to-be-on-chain blocks 3. Node 1, node 2, and node 3 generate the waiting time of their respective to-be-on-chain blocks according to the random numbers they generate, and then determine the broadcast time of to-be-on-chain blocks 1, to-be-on-chain blocks 2, and to-be-on-chain blocks 3. When the system time reaches the broadcast time of the block 1 to be chained, the system time has not reached the broadcast time of the block 2 to be chained and the block 3 to be chained. At this time, node 1 has not received the block 2 to be chained and the block 3 to be chained broadcasted or forwarded by node 2 and node 3, and broadcasts the block 1 to be chained in the blockchain network. After node 2 receives the block 1 to be chained broadcasted by node 1, since the system time has not reached the broadcast time of the block 2 to be chained, it compares the random number in the block 1 to be chained with the random number in the block 2 to be chained. Since the random number in the block 1 to be chained is less than the random number in the block 2 to be chained, node 2 forwards the block 1 to be chained in the blockchain network and discards the block 2 to be chained. The processing method of node 3 is similar to that of node 2. The processing result is that node 3 forwards the block 1 to be chained in the blockchain network and discards the block 3 to be chained. Afterwards, nodes 1, 2, and 3 continue to generate random numbers based on the most recently uploaded blocks and perform corresponding block broadcasting and block forwarding.
[0115] Figure 5 1 is a block diagram of the consensus device of the blockchain system in some embodiments of the present disclosure. Figure 5 As shown, the consensus device of the blockchain system includes:
[0116] The acquisition module 100 is used to obtain the hash value of the latest block on the blockchain system;
[0117] The block processing module 200 is used to generate a verifiable random number for each node based on the private key of each node in the blockchain system and the hash value of the latest on-chain block, and add the verifiable random number of each node to each to-be-on-chain block generated by each node;
[0118] The waiting time determination module 300 is used to determine the waiting time of each to-be-chained block relative to the broadcast time of the latest chained block based on the verifiable random number and time coefficient of each node;
[0119] The broadcast time determination module 400 is used to determine the broadcast time of each to-be-uplinked block based on the broadcast time of the latest to-be-uplinked block and the waiting time of each to-be-uplinked block relative to the broadcast time of the latest to-be-uplinked block;
[0120] The node communication module 500 is used to broadcast each block to be chained based on the broadcast time of each block to be chained.
[0121] Figure 6 FIG. 2 is a block diagram of a block processing module 200 in some embodiments of the present disclosure. Figure 6 As shown, the block processing module 200 includes:
[0122] The signature unit 210 is used to sign the hash value of the latest block on the blockchain based on the private key of each node in the blockchain system using a preset signature method to obtain the signature result of each node;
[0123] The numerical conversion unit 220 is used to perform numerical conversion on the signature result of each node to obtain a verifiable random number of each node.
[0124] In some embodiments of the present disclosure, the node communication module 500 is used to perform the following steps for any of the blocks to be chained:
[0125] In response to the system time reaching the broadcast time of the current block to be chained and no block to be chained broadcasted or forwarded by other nodes of the blockchain network is received, the current block to be chained is broadcasted.
[0126] In some embodiments of the present disclosure, the node communication module 500 is used to perform the following steps for any of the blocks to be chained:
[0127] In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the block to be chained with the same block height broadcast or forwarded by other nodes of the blockchain network is greater than the verifiable random number of the current block to be chained, the current block to be chained is broadcasted.
[0128] In some embodiments of the present disclosure, the node communication module 500 is used to perform the following steps for any of the blocks to be chained:
[0129] In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the target block to be chained with the same block height broadcast or forwarded by other nodes of the blockchain network is less than the verifiable random number of the current block to be chained, the target block to be chained is forwarded.
[0130] Figure 7 1 is a block diagram of the consensus device of the blockchain system in some other embodiments of the present disclosure. Figure 7As shown, the consensus device of the blockchain system also includes:
[0131] The time coefficient adjustment module 600 is used to adjust the time coefficient based on the numerical relationship between the average block generation time of the most recent multiple on-chain blocks and a preset time threshold.
[0132] It should be noted that the specific implementation of the consensus device of the blockchain system of the embodiment of the present disclosure is similar to the specific implementation of the consensus method of the blockchain system of the embodiment of the present disclosure, and the technical effect of the consensus device of the blockchain system of the embodiment of the present disclosure is similar to the technical effect of the consensus method of the blockchain system of the embodiment of the present disclosure. Please refer to the description of the consensus method of the blockchain system for details. In order to reduce redundancy, it will not be repeated here.
[0133] The present disclosure also provides a blockchain system, including:
[0134] Blockchain network;
[0135] The consensus device of the above-mentioned blockchain system is used to execute the consensus method of the above-mentioned blockchain system.
[0136] In addition, an embodiment of the present disclosure further provides an electronic device, including:
[0137] Memory for storing computer programs;
[0138] The processor is used to execute the computer program stored in the memory, and when the computer program is executed, the consensus method of the blockchain system described in any of the above embodiments of the present disclosure is implemented.
[0139] Below, reference Figure 8 To describe the electronic device according to the embodiment of the present disclosure. Figure 8 As shown, the electronic device includes one or more processors and memory.
[0140] The processor may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0141] The memory may store one or more computer program products, and the memory may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program products may be stored on the computer-readable storage medium, and the processor may run the computer program product to implement the consensus method of the blockchain system of each embodiment of the present disclosure described above and / or other desired functions.
[0142] In one example, the electronic device may further include: an input device and an output device, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0143] In addition, the input device may also include, for example, a keyboard, a mouse, and the like.
[0144] The output device can output various information to the outside, including determined distance information, direction information, etc. The output device can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0145] Of course, to simplify, Figure 8 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device may further include any other appropriate components.
[0146] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to perform the steps in the consensus method of the blockchain system according to various embodiments of the present disclosure described in the above part of this specification.
[0147] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0148] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, cause the processor to execute the steps of the consensus method of the blockchain system according to various embodiments of the present disclosure described in the above part of this specification.
[0149] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0150] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0151] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0152] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0153] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0154] It should also be noted that in the apparatus, device and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0155] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0156] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A consensus method for a blockchain system, characterized in that: include: Get the hash value of the latest block on the blockchain system; Based on the private key of each node in the blockchain system and the hash value of the latest on-chain block, a verifiable random number of each node is generated, and the verifiable random number of each node is added to each to-be-on-chain block generated by each node; Based on the verifiable random number and time coefficient of each node, determine the waiting time of each to-be-chained block relative to the broadcast time of the latest chained block; Determine the broadcast time of each to-be-uplinked block based on the broadcast time of the latest to-be-uplinked block and the waiting time of each to-be-uplinked block relative to the broadcast time of the latest to-be-uplinked block; Based on the broadcast time of each block to be chained, each block to be chained is broadcasted.
2. The method according to claim 1, characterized in that The generating of the verifiable random number of each node based on the private key of each node in the blockchain system and the hash value of the latest on-chain block includes: Using a preset signature method, the hash value of the latest on-chain block is signed based on the private key of each node in the blockchain system to obtain the signature result of each node; The signature results of the nodes are numerically converted to obtain verifiable random numbers of the nodes.
3. The method according to claim 1 or 2, characterized in that: The broadcasting of each to-be-linked block based on the broadcast time of each to-be-linked block includes: For any of the blocks to be chained, perform the following steps: In response to the system time reaching the broadcast time of the current block to be chained and no block to be chained broadcasted or forwarded by other nodes of the blockchain system is received, the current block to be chained is broadcasted.
4. The method according to claim 1 or 2, characterized in that: The broadcasting of each to-be-linked block based on the broadcast time of each to-be-linked block includes: For any of the blocks to be chained, perform the following steps: In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the block to be chained of the same block height broadcast or forwarded by other nodes of the blockchain system is greater than the verifiable random number of the current block to be chained, the current block to be chained is broadcasted.
5. The method according to claim 1 or 2, characterized in that: After determining the broadcast time of each to-be-linked block based on the broadcast time of the latest to-be-linked block and the waiting time of each to-be-linked block relative to the broadcast time of the latest to-be-linked block, the method further includes: For any of the blocks to be chained, perform the following steps: In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the target block to be chained with the same block height broadcast or forwarded by other nodes of the blockchain system is less than the verifiable random number of the current block to be chained, the target block to be chained is forwarded.
6. The method according to claim 1 or 2, characterized in that: Also includes: The time coefficient is adjusted based on the numerical relationship between the average block generation time of the most recent multiple on-chain blocks and a preset time threshold.
7. A consensus device for a blockchain system, characterized in that: include: The acquisition module is used to obtain the hash value of the latest block on the blockchain system; A block processing module, configured to generate a verifiable random number of each node based on the private key of each node in the blockchain system and the hash value of the latest on-chain block, and add the verifiable random number of each node to each to-be-on-chain block generated by each node; A waiting time determination module, configured to determine the waiting time of each to-be-chained block relative to the broadcast time of the latest chained block based on the verifiable random number and time coefficient of each node; A broadcast time determination module, configured to determine the broadcast time of each to-be-uplinked block based on the broadcast time of the latest to-be-uplinked block and the waiting time of each to-be-uplinked block relative to the broadcast time of the latest to-be-uplinked block; The node communication module is used to broadcast each of the blocks to be chained based on the broadcast time of each of the blocks to be chained.
8. The device according to claim 7, characterized in that The block processing module includes: A signature unit, used to sign the hash value of the latest on-chain block based on the private key of each node in the blockchain system using a preset signature method to obtain the signature result of each node; The numerical conversion unit is used to perform numerical conversion on the signature results of each node to obtain a verifiable random number of each node.
9. The device according to claim 7 or 8, characterized in that The node communication module is used to perform the following steps for any of the blocks to be chained: In response to the system time reaching the broadcast time of the current block to be chained and no block to be chained broadcasted or forwarded by other nodes of the blockchain system is received, the current block to be chained is broadcasted.
10. The device according to claim 7 or 8, characterized in that The node communication module is used to perform the following steps for any of the blocks to be chained: In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the block to be chained of the same block height broadcast or forwarded by other nodes of the blockchain system is greater than the verifiable random number of the current block to be chained, the current block to be chained is broadcasted.
11. The device according to claim 7 or 8, characterized in that The node communication module is used to perform the following steps for any of the blocks to be chained: In response to the system time reaching the broadcast time of the current block to be chained, and the verifiable random number in the target block to be chained with the same block height broadcast or forwarded by other nodes of the blockchain system is less than the verifiable random number of the current block to be chained, the target block to be chained is forwarded.
12. The device according to claim 7 or 8, characterized in that Also includes: The time coefficient adjustment module is used to adjust the time coefficient based on the numerical relationship between the average block generation time of the most recent multiple on-chain blocks and a preset time threshold.
13. A blockchain system, characterized in that: include: Blockchain network; The device according to any one of claims 7 to 12.
Citation Information
Patent Citations
Data processing method and device based on block chain, equipment and medium
CN117474676A
Computing power network block chain consensus method and system and storage medium
CN118802155A