CN111737358B - Method, device and equipment for determining main chain of block chain and storage medium - Google Patents

Method, device and equipment for determining main chain of block chain and storage medium Download PDF

Info

Publication number
CN111737358B
CN111737358B CN202010695567.0A CN202010695567A CN111737358B CN 111737358 B CN111737358 B CN 111737358B CN 202010695567 A CN202010695567 A CN 202010695567A CN 111737358 B CN111737358 B CN 111737358B
Authority
CN
China
Prior art keywords
block
chain
determining
historical
interval
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010695567.0A
Other languages
Chinese (zh)
Other versions
CN111737358A (en
Inventor
荆博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202010695567.0A priority Critical patent/CN111737358B/en
Publication of CN111737358A publication Critical patent/CN111737358A/en
Application granted granted Critical
Publication of CN111737358B publication Critical patent/CN111737358B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1441Countermeasures against malicious traffic

Abstract

The application discloses a method, a device, equipment and a storage medium for determining a block chain main chain, relates to the technical field of block chains, and can be applied to cloud computing and cloud services. The specific implementation scheme is as follows: determining the block output contribution degree of a block output node of a forked block in the forked chain in a block chain comprising a main chain and at least two forked chains, and taking the block output contribution degree as the block weight of the forked block; and selecting a target branched chain from the at least two branched chains according to the block weight of the branched block, and updating the main chain. The method and the device improve the accuracy of the determination result of the main chain determination in the block chain comprising the branch chain, further avoid the severe branch condition of the block chain caused by self-owned ore excavation, and provide guarantee for the stability and the safety of the block chain.

Description

Method, device and equipment for determining main chain of block chain and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for determining a blockchain main chain.
Background
The selfish mining attack is an attack mode aiming at a block chain network, an attacker can collect a large amount of computing power in a short time, is independent of a network backbone, and excavates a long branch without broadcasting to the outside. Finally, the forks are broadcast because their length is ahead of the backbone.
According to the current block chain network design, the longest chain is preferentially selected as a backbone, so that the block chain network switches the backbone to the error fork issued by an attacker. Therefore, the selfish mining attack will damage the interests of honest miners, and even a large number of invalid transactions or double-flower transactions can occur, which brings serious threats to the stability and the safety of the blockchain network.
Disclosure of Invention
The application discloses a method, a device, equipment and a storage medium for determining a block chain main chain with higher accuracy.
According to an aspect of the present application, there is provided a method for determining a blockchain main chain, which is applied to a blockchain including a main chain and at least two branch chains, the method including:
determining the block-out contribution degree of a block-out node of a forked block in the forked chain in the main chain, and taking the block-out contribution degree as the block weight of the forked block;
and selecting a target branched chain from the at least two branched chains according to the block weight of the branched block, wherein the target branched chain is used for updating the main chain.
According to another aspect of the present application, there is provided an apparatus for determining a blockchain main chain, applied to a blockchain including a main chain and at least two branch chains, the apparatus including:
a block weight determining module, configured to determine a block-out contribution degree of a block-out node of a forked block in the forked chain in the main chain, and use the block-out contribution degree as a block weight of the forked block;
and the main chain updating module is used for selecting a target branched chain from the at least two branched chains according to the block weight of the branched block and updating the main chain.
According to another aspect of the present application, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any one of the determination methods of the blockchain main chain provided by the embodiments of the present application.
According to another aspect of the present application, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute any one of the determination methods of a blockchain main chain provided by the embodiments of the present application.
According to the technique of the present application, the accuracy of the determination result of the main chain determination in the block chain including the branch chain is improved.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not intended to limit the present application. Wherein:
fig. 1A is a flowchart of a method for determining a blockchain main chain according to an embodiment of the present disclosure;
fig. 1B is a block chain diagram according to an embodiment of the present disclosure;
fig. 2 is a flowchart of another method for determining a blockchain main chain according to an embodiment of the present disclosure;
fig. 3 is a flowchart of another method for determining a blockchain main chain according to an embodiment of the present disclosure;
fig. 4 is a block chain main chain determining apparatus according to an embodiment of the present disclosure;
fig. 5 is a block diagram of an electronic device for implementing the method for determining a blockchain main chain according to the embodiment of the present application.
Detailed Description
The following description of the exemplary embodiments of the present application, taken in conjunction with the accompanying drawings, includes various details of the embodiments of the application for the understanding of the same, which are to be considered exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The method for determining the main chain of each block chain and the device for determining the main chain of the block chain provided by the embodiment of the application are suitable for the situation that the main chain is updated by rolling back branched chains in the block chain comprising the main chain and at least two branched chains. The method for determining each blockchain main chain in the embodiment of the present application is executed by a device for determining a blockchain main chain, where the device is implemented by software and/or hardware and is specifically configured in an electronic device carrying a blockchain node.
Fig. 1A is a flowchart of a method for determining a blockchain main chain according to an embodiment of the present disclosure, where the method includes:
s101, determining the block-out contribution degree of a block-out node of the branched block in the branched chain in the main chain, and taking the block-out contribution degree as the block weight of the branched block.
Illustratively, if it is detected that at least two forked chains exist in the block chain, determining the block-out contribution degree of the block-out node of the forked block in the forked chain in the main chain, and using the block-out contribution degree as the block weight of the forked block.
Because each block link point in the block chain network can almost observe the data of each block in the whole network, the supervision of all nodes on the network data is realized. Therefore, nodes with block chain storage authority in the block chain system can detect whether a branch chain exists in the block chain. If any node monitors that at least two branch chains exist in the block chain, the main chain in the block chain needs to be determined.
Illustratively, whether there are at least two bifurcating chains in a blockchain may be determined by: if the time difference of the timestamps in the at least two blocks is detected to be smaller than a certain time threshold, namely the generation time of the at least two blocks is very close, determining that at least two branch chains exist in the block chain; or, if it is detected that the last chunk header hash values of the at least two chunks are the same, it is determined that a branch chain occurs in the chunk chain. This application does not prescribe a limit to the detection mode of block chain branching phenomenon, and any detection mode that can detect block chain branching phenomenon can all refer to in this application. Any one of the above detection modes of the branch chain can be adopted, or according to the actual situation, the combination of at least two of the detection modes is adopted to realize the detection of the branch chain.
Here, a bifurcate block may be understood as a block included in a bifurcate chain. Specifically, refer to a block chain diagram shown in fig. 1B. The block chain includes a main chain 10, a branch chain 20 and a branch chain 30. Wherein, the block C, the block D, and the block E included in the branch chain 20 are branch blocks in the branch chain 20; the block c, the block d, the block e and the block f included in the branch chain 30 are branch blocks in the branch chain 30. The blocks a and B included in the main chain 10 may be referred to as main chain blocks.
The block output contribution degree can be understood as a block output node of the bifurcation block, and is a quantitative representation of the block output condition of at least one main trunk block in the main chain. Generally, if at least one main trunk block exists in the main chain and is generated by the block output node of the bifurcation block, it indicates that the block output node has a block output contribution degree to the main chain; if any trunk block does not exist in the main chain and is generated by the block output node of the bifurcation block, the block output node does not have the block output contribution degree to the main chain.
In general, it can be considered that a node with a higher block contribution degree has a stronger correlation between its own benefit and the whole blockchain network, and thus it can be considered that the cost of doing malicious work of the node in the blockchain network is also higher. Therefore, by mapping the node reliability according to the outgoing block contribution degree of the outgoing block node of the bifurcated block, whether the node is a rogue node can be judged, and whether the bifurcated chain to which the bifurcated block belongs is an erroneous block chain can be assisted to be judged.
S102, selecting a target branch chain from the at least two branch chains according to the block weight of the branch block, and updating the main chain.
Illustratively, according to the block weight of at least one branched block in the branched chain, selecting a target branched chain from at least two branched chains for updating the main chain; and rolling back other branch chains except the branch chain of the execution target.
In an optional implementation manner of the embodiment of the present application, the selecting a target branch chain from the at least two branch chains according to the block weight of the branch block may be: determining the chain weight of the branch chain according to the block weight; and selecting a target branched chain from at least two branched chains according to the chain weight.
The method can be understood that the determination of the chain weight of the branch chain is carried out through the block weight of the branch block, so that the block-out condition of the block-out node of each branch block in the branch chain in the main chain is mapped through the chain weight of the branch chain, and the chain weight is used as the selection basis of the target branch chain, so that the accuracy of the selection result of the target branch chain is guaranteed, the foundation is laid for the accuracy of the main chain determination result, and the safety and the stability of the block chain are further guaranteed.
Optionally, determining the chain weight of the branch chain according to the block weight may be: and taking the sum of the chain weights of at least one forked block contained in the forked chain as the chain weight of the forked chain, thereby mapping the chain weight of the forked chain through the block weight, and providing data support for the subsequent selection of the target forked chain.
It can be understood that, in order to further improve the accuracy of the result of determining the chain weight and further improve the accuracy of the result of selecting the target branch chain, and provide a guarantee for the stability and the security of the block chain, optionally, the sum of the chain weights of the branch blocks included in the branch chain is used as the chain weight of the branch chain.
Optionally, according to the chain weight, selecting a target branch chain from the at least two branch chains, which may be: and selecting one of the at least two forked chains with the largest chain weight as a target forked chain.
It can be understood that, by selecting the target forked chain according to the chain weight, the contribution degree of the out-block node of each forked block included in the selected target forked chain to the out-block of the main chain can be ensured to be higher than the contribution degree of the out-block node of each forked block included in other forked chains to the out-block of the main chain, that is, the reliability of the out-block node of each forked block included in the target forked chain is higher than the reliability of the out-block node of each forked block included in other forked chains, so that the accuracy of the selected target forked chain is improved, and further, the stability and the safety of the block chain are guaranteed.
Exemplarily, if the branch chain with the largest chain weight is one, directly taking the branch chain with the largest chain weight as the target branch chain; if the number of the branch chains with the largest chain weight is at least two, one of the branch chains with the largest chain weight can be randomly selected as a target branch chain from the at least two branch chains with the largest chain weight, or a branch chain with longer link time is selected as a target branch chain, or a branch chain with earlier block-out time of a first branch block contained in the target branch chain is selected as a target branch chain.
In the block chain comprising a main chain and at least two branched chains, determining the block-out contribution degree of a block-out node of a branched block in the branched chain in the main chain, and taking the block-out contribution degree as the block weight of the branched block; and selecting a target branched chain from the at least two branched chains according to the block weight of the branched block, and updating the main chain. According to the technical scheme, the block outgoing contribution degree of the block outgoing node of the branched block in the branched chain in the main chain is introduced to serve as the block weight of the branched block, and the credibility of each block outgoing node in the branched chain is mapped, so that when the target branched chain is determined according to the block weight of the branched block, the accuracy of the determination result of the target branched chain is improved, the accuracy of the finally determined main chain of the block chain is improved, the situation that the block chain is severely branched due to selfish mining is avoided, and the stability and the safety of the block chain are guaranteed.
Fig. 2 is a flowchart of another method for determining a block chain main chain according to an embodiment of the present application, where the method is optimized and improved based on the above technical solutions.
Further, the operation "determining the out-block contribution degree of the out-block node of the branch block in the branch chain in the main chain" is refined into "determining at least one history block interval associated with the branch chain to which the branch block belongs in the main chain; wherein, the different history block intervals are not overlapped; and determining the block contribution degree according to the block output number of the block output node of the forked block in at least one historical block interval so as to perfect the determination mechanism of the block output degree.
A method for determining a blockchain main chain as shown in fig. 2 includes:
s201, determining at least one history block interval associated in a main chain of a branch chain to which a branch block belongs; wherein, there is no overlap between different history block intervals.
For example, at least one of the section length of the history block section, the section left boundary block, and the section right boundary block may be specified in advance, and the determination of the history block section may be performed. At least one of the interval length of the historical block interval, the interval left boundary block and the block with the boundary block can be determined by a technician according to needs or experience values.
For example, a tail block of the main chain, that is, a main chain block connected with at least two branch chains, may be determined as an interval right boundary block, and an interval left boundary block may be determined according to a preset interval length, so that a part of the main chain blocks in the main chain may be selected as a history block interval according to the interval right boundary block and the interval left boundary block.
In order to avoid the situation that the block weight determination result of the forked blocks in forked chains with different lengths is unbalanced due to the fixed length of the section of the history block section, in an optional implementation manner of the embodiment of the present application, the following may also be performed: and determining the interval length of the historical block interval according to the branch length of the branch chain to which the branch block belongs.
For example, when the history chunk interval is one, the interval length of the history chunk interval may be determined by multiplying the bifurcation length by a preset interval length.
For example, when the number of the history block intervals is at least two, the number of the history block intervals may be determined according to the branch length of the branch chain to which the branch block belongs; and constructing a plurality of historical block intervals according to at least one historical main stem block in the main chain. For the construction of the single history block interval, the above contents can be referred to.
S202, determining the block contribution degree according to the block output number of the block output node of the forked block in at least one historical block interval.
For example, when the interval lengths of the history block intervals associated with the at least two forking chains are the same, the number of output blocks of the output block nodes of the forking chains in the history block interval may be directly used as the output block contribution degree, so as to reduce the data operation amount when the output block contribution degree is determined.
When the interval lengths of the history block intervals associated with at least two branch chains are different, in order to avoid the situation that the block output contribution degree determination results are unbalanced due to the different interval lengths of the history block intervals of different branch chains, the history block output frequency can be determined according to the block output number of the block output nodes of the branch chains in the history block intervals; and determining the block contribution degree according to at least one historical block output frequency of the branched block.
For example, determining the historical block output frequency according to the block output number of the block output node of the bifurcated block in the historical block interval may be: determining the ratio of the block output number of the block output nodes of the forked blocks in the historical block interval to the interval length of the historical block interval; and taking the determined ratio as historical block frequency.
For example, determining the block contribution degree according to at least one historical block frequency of the bifurcated block may be: and accumulating at least one historical block output frequency of each bifurcation block, and taking the accumulated sum as the block output contribution of the bifurcation block.
It is understood that, in order to improve the accuracy of the determination result of the block contribution degree, the historical block output frequencies of each bifurcated block are generally accumulated, and the accumulated sum is used as the block output contribution degree of the bifurcated block.
Generally, in a block chain, a block output node which has executed the block output operation most recently is less likely to be malicious, so that when the block contribution degree is determined, a time adjustment factor is introduced to update the block output contribution degree so as to improve the block output contribution degree of the block output node which has executed the block output operation most recently, and relatively reduce the block output contribution degree of the block output node which has not executed the block output operation most recently, thereby avoiding the occurrence of the missing recognition situation of the private mining of the node which has executed the block output operation in a main chain, improving the matching degree of the block output contribution degree and the block output node reliability, and further improving the accuracy of a target branched chain determination result.
In order to achieve the above object, in an optional implementation manner of the embodiment of the present application, the determining a block contribution degree according to at least one historical block output frequency of the bifurcated block may be: determining a time adjustment factor according to the relative block height of at least one historical trunk block contained in the historical block interval and the latest trunk block; updating the historical block output frequency according to the time adjustment factor; and determining the block contribution degree according to at least one updated historical block output frequency of the bifurcated block. The latest trunk block can be understood as a tail block in the main chain, that is, a trunk block to which at least two bifurcating chains are connected.
For example, the relative block height may be determined according to a block height difference between one of the historical stem blocks and the latest stem block in the historical block interval. The selected historical backbone block may be a backbone block arbitrarily selected from the historical block interval, or a backbone block selected according to a certain selection rule. For example, a main block at a given position in the history block interval, such as the first block, the last block, or the middle block, may be selected.
For example, in order to avoid that the interval lengths of different historical block intervals bring certain influence on the determination of the time adjustment factor and further influence the accuracy of the finally determined block output contribution degree, when determining the relative block height, the block height average value of at least two historical stem blocks in the historical block interval may be determined first, and the relative block height may be determined according to the block height difference value between the block height average value and the latest stem block.
In order to reduce the amount of data operation for performing the time adjustment factor determination process, the time adjustment factor is determined according to the relative block height between at least one historical stem block included in the historical block interval and the latest stem block, which may be: determining a time adjustment factor according to the interval serial number of the historical block interval; and each historical block interval is numbered in a reverse order according to the block-out time.
For example, the time adjustment factor may be determined according to the interval number of the history block interval by a preset time adjustment factor determination function. The preset time adjustment factor determining function is a decreasing function of the interval serial number of the historical block interval.
S203, the block contribution is used as the block weight of the bifurcated block.
S204, selecting a target branch chain from the at least two branch chains according to the block weight of the branch block for updating the main chain.
The method comprises the steps of refining a block output contribution degree determination operation into at least one historical block interval associated in a main chain by determining a branch chain to which a branch block belongs; wherein, the different history block intervals are not overlapped; and determining the block contribution degree according to the block output number of the block output node of the forked block in at least one historical block interval. By adopting the technical scheme, the determination mechanism of the block-out contribution degree is perfected, the block-out contribution degree is determined by limiting the partition in the main chain through the introduction of the historical block interval, and the controllability of the operation amount in the block-out contribution degree determination process is ensured. Meanwhile, by introducing at least one history block interval with different numerical intervals and no overlapping, the grading determination of the block contribution degree is realized, the accuracy of the result of the block contribution degree determination is improved, and a foundation is laid for the improvement of the accuracy of the target forked chain determination result.
Fig. 3 is a flowchart of another method for determining a block chain main chain according to an embodiment of the present application, and the method provides a preferred implementation manner based on the foregoing technical solutions.
A method for determining a block chain main chain as shown in fig. 3 is applied to a block chain including a main chain and at least two branch chains, and the method includes:
s301, determining the interval number of the historical block intervals according to the branch length of the branch chain where the branch blocks are located.
The number of the historical block intervals is equal to the branch length of the branch chain where the branch blocks are located.
S302, sequentially backward-pushing the backbone blocks with the set interval length from the backbone blocks with branches generated in the main chain, and constructing historical block intervals with the number of intervals.
Wherein the numerical value of the set interval length is determined by a skilled person as required or an empirical value.
S303, numbering the sequence of the historical block intervals according to the construction sequence of the historical block intervals.
S304, determining a time adjusting factor according to the interval number of the historical block interval.
For example, the determination of the time adjustment factor may be performed using the following equation:
Figure 436352DEST_PATH_IMAGE001
wherein z is the followingiA time adjustment factor corresponding to each historical block interval, d is the interval number of the historical block interval,aa constant greater than 0 can be determined by a skilled person as desired or empirical.
For example, the determination of the time adjustment factor may be performed using the following equation:
Figure 681388DEST_PATH_IMAGE002
wherein the content of the first and second substances,z i is as followsiThe time adjustment factor corresponding to each historical block interval,d i is as followsiThe section number of each history block section,athe non-negative number may be determined by a skilled person according to needs or empirical values, and may be set as the interval length of the history block interval, for example.
Wherein log b () Base number of (2)bFor constants greater than 1, the particular value can be determined by the skilled artisan as desired or empirically.
S305, determining historical block output frequency according to the block output number of the block output nodes of the bifurcation blocks in the historical block interval.
For example, the following formula may be used for the determination of the historical block frequency:
Figure 195546DEST_PATH_IMAGE003
wherein the content of the first and second substances,x i for the historical block-out frequency of the forked block in the first historical block interval,M i the node of the block is the firstiNumber of blocks in history block interval(ii) a N is the firstiThe interval length of each history block interval.
S304 and S305 may be executed sequentially or in parallel, and the execution order of the two is not limited in any way in the present application.
And S306, updating the historical block output frequency according to the time adjustment factor.
Illustratively, the historical block frequency may be updated using the following formula:
Figure 121914DEST_PATH_IMAGE004
wherein the content of the first and second substances,y i generating block frequency for the updated history;x i the block frequency is taken for the history before updating;z i is a time adjustment factor.
And S307, determining the block output contribution degree of the block output node of the forked block according to the updated historical block output frequency sum value of each historical block interval.
For example, the following formula may be used to determine the block contribution degree:
Figure 795341DEST_PATH_IMAGE005
wherein the content of the first and second substances,Qthe degree of out-block contribution of the out-block node for the bifurcated block,Wis the total number of history block intervals,y i the block frequency is derived for the updated history.
S308, the block output contribution of the block output node of the bifurcated block is used as the block weight of the bifurcated block.
S309, accumulating the block weights of the branch blocks in the branch chain, and using the accumulated sum as the chain weight of the branch chain.
S310, selecting one of the branch chains with the largest chain weight from all the branch chains as a target branch chain.
And S311, updating the main chain according to the target branched chain, and rolling back other branched chains except the target branched chain.
It can be understood that, an attacker generally temporarily samples computing resources to attack the blockchain network, so that the contribution degree of the block in the main chain is often insufficient, and the longer the bifurcation generated by the private excavation of the attacker, the more obvious the disadvantage of the contribution degree of the block is, so that the block weight is lower, the chain weight of the bifurcated chain is also obviously lower than that of a normal block node, so that the accuracy of the finally determined main chain is higher, the probability of severe bifurcation of the blockchain network is greatly reduced, and the security and stability of the blockchain network are further improved.
It should be noted that if too few blocks, for example, one or two blocks, are generated on the main chain before the bifurcation, the out-blocking node newly added to the network has a certain disadvantage compared with other out-blocking nodes making out-blocking contributions on the main chain. However, since an attacker generally does not make out block contributions on the main chain before forking, because the benefits of the out-block nodes which have already made blocks are closely related to the whole block chain network, malicious damage will cause credit collapse of the whole network, and is also disadvantageous to the out-block nodes themselves, the out-block nodes which newly join the network also have certain advantages for the attacker, and the basic benefits of the newly joining network can be ensured.
Fig. 4 is a block chain main chain determining apparatus 400 according to an embodiment of the present application, which is applied to a block chain including a main chain and at least two branch chains, and includes: a block weight determination module 401 and a backbone update module 402.
A block weight determining module 401, configured to determine a block exit contribution degree of a block exit node of a forked block in a forked chain in a main chain, and use the block exit contribution degree as a block weight of the forked block;
a main chain updating module 402, configured to select a target branch chain from the at least two branch chains according to the block weight of the branch block, and update the main chain.
In the block chain comprising a main chain and at least two branch chains, determining the block-out contribution degree of a block-out node of a branch block in the branch chain in the main chain through a block weight determination module, and taking the block-out contribution degree as the block weight of the branch block; and selecting a target branched chain from the at least two branched chains according to the block weight of the branched block through a main chain updating module for updating the main chain. According to the technical scheme, the block outgoing contribution degree of the block outgoing node of the branched block in the branched chain in the main chain is introduced to serve as the block weight of the branched block, and the credibility of each block outgoing node in the branched chain is mapped, so that when the target branched chain is determined according to the block weight of the branched block, the accuracy of the determination result of the target branched chain is improved, the accuracy of the finally determined main chain of the block chain is improved, the situation that the block chain is severely branched due to selfish mining is avoided, and the stability and the safety of the block chain are guaranteed.
Further, the block weight determining module 401 includes:
the history block interval determining unit is used for determining at least one history block interval associated with a branch chain to which the branch block belongs in a main chain; wherein, the different history block intervals are not overlapped;
and the block output contribution degree determining unit is used for determining the block contribution degree according to the block output number of the block output node of the forked block in at least one historical block interval.
Further, the block output contribution degree determining unit includes:
the history block output frequency determining subunit is used for determining the history block output frequency according to the block output number of the block output node of the bifurcation block in the history block interval;
and the block output contribution degree determining subunit is used for determining the block contribution degree according to at least one historical block output frequency of the bifurcation block.
Further, the determining subunit of the contribution degree of the block output includes:
a time adjustment factor determination slave unit, configured to determine a time adjustment factor according to a relative block height between at least one historical trunk block and a latest trunk block included in the historical block interval;
the historical block frequency updating slave unit is used for updating the historical block frequency according to the time adjustment factor;
and the slave unit for determining the block contribution degree is used for determining the block contribution degree according to at least one updated historical block output frequency of the bifurcation block.
Further, a time adjustment factor determining slave unit, comprising:
the time adjustment factor determining unit is used for determining a time adjustment factor according to the interval serial number of the historical block interval;
and each historical block interval is numbered in a reverse order according to the block-out time.
Further, the history block interval determination unit includes:
the interval number determining subunit is used for determining the interval number of the historical block intervals according to the branch length of the branch chain to which the branch blocks belong;
and the historical block interval constructing subunit is used for constructing the historical block intervals with the interval number according to at least one historical main trunk block in the main chain.
Further, a backbone update module, comprising:
a chain weight determining unit for determining a chain weight of the branch chain according to the block weight;
and the target branched chain selecting unit is used for selecting a target branched chain from the at least two branched chains according to the chain weight.
Further, the chain weight determination unit includes:
a chain weight determining subunit, configured to use a sum of chain weights of at least one forked block included in the forked chain as the chain weight of the forked chain.
Further, the target branch chain selecting unit comprises:
and the target branched chain selecting subunit is used for selecting one branched chain with the largest chain weight from the at least two branched chains as the target branched chain.
The device for determining the main chain of the block chain can execute any method for determining the main chain of the block chain provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects for executing the method for determining the main chain of the block chain.
According to an embodiment of the present application, an electronic device and a readable storage medium are also provided.
Fig. 5 is a block diagram of an electronic device implementing the method for determining a blockchain main chain according to the embodiment of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application that are described and/or claimed herein.
As shown in fig. 5, the electronic apparatus includes: one or more processors 501, memory 502, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions for execution within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input/output apparatus (such as a display device coupled to the interface). In other embodiments, multiple processors and/or multiple buses may be used, along with multiple memories and multiple memories, as desired. Also, multiple electronic devices may be connected, with each device providing portions of the necessary operations (e.g., as a server array, a group of blade servers, or a multi-processor system). In fig. 5, one processor 501 is taken as an example.
Memory 502 is a non-transitory computer readable storage medium as provided herein. The memory stores instructions executable by the at least one processor to cause the at least one processor to perform the method for determining a blockchain backbone provided herein. The non-transitory computer-readable storage medium of the present application stores computer instructions for causing a computer to execute the block chain backbone determination method provided herein.
The memory 502, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the block chain main chain determination method in the embodiment of the present application (for example, the block weight determination module 401 and the main chain update module 402 shown in fig. 4). The processor 501 executes various functional applications of the server and data processing by running non-transitory software programs, instructions and modules stored in the memory 502, that is, implements the method for determining the blockchain main chain in the above method embodiment.
The memory 502 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by use of the electronic device implementing the determination method of the blockchain main chain, and the like. Further, the memory 502 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 502 optionally includes memory located remotely from processor 501, which may be connected over a network to an electronic device implementing the determination of the blockchain backbone. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device implementing the method for determining a blockchain main chain may further include: an input device 503 and an output device 504. The processor 501, the memory 502, the input device 503 and the output device 504 may be connected by a bus or other means, and fig. 5 illustrates the connection by a bus as an example.
The input device 503 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the electronic apparatus implementing the determination method of the blockchain main chain, such as an input device of a touch screen, a keypad, a mouse, a track pad, a touch pad, a pointing stick, one or more mouse buttons, a track ball, a joystick, etc. The output devices 504 may include a display device, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibrating motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device can be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
These computer programs (also known as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented using high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, Programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
According to the technical scheme of the embodiment of the application, the out-block contribution degree of the out-block node of the bifurcation block in the bifurcation chain in the main chain is introduced and used as the block weight of the bifurcation block, and the credibility of each out-block node in the bifurcation chain is mapped, so that when the target bifurcation chain is determined according to the block weight of the bifurcation block, the accuracy of the determination result of the target bifurcation chain is improved, the accuracy of the main chain of the finally determined block chain is improved, the generation of the severe bifurcation condition of the block chain caused by self-owned mining is avoided, and the stability and the safety of the block chain are guaranteed.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present application may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present application can be achieved, and the present invention is not limited herein.
The above-described embodiments should not be construed as limiting the scope of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (20)

1. A method for determining a block chain main chain is applied to a block chain comprising a main chain and at least two branch chains, and the method comprises the following steps:
determining the block-out contribution degree of a block-out node of a forked block in the forked chain in the main chain, and taking the block-out contribution degree as the block weight of the forked block; the block output contribution degree is a block output node of the bifurcation block and is used for quantitatively representing the block output conditions of at least two main trunk blocks in the main chain;
and selecting a target branched chain from the at least two branched chains according to the block weight of the branched block, wherein the target branched chain is used for updating the main chain.
2. The method of claim 1, wherein the determining an out-blocking contribution degree of an out-blocking node of a bifurcated block in the bifurcated chain in the main chain comprises:
determining at least one historical block interval associated by a branch chain to which the branch block belongs in the main chain; wherein, there is no overlap between different history block intervals;
and determining the block output contribution degree according to the block output number of the block output node of the forked block in at least one historical block interval.
3. The method of claim 2, wherein the determining the out-block contribution according to the out-block number of the out-block node of the bifurcated block in at least one of the historical block intervals comprises:
determining historical block output frequency according to the block output number of the block output nodes of the forked blocks in the historical block interval;
and determining the block output contribution degree according to at least one historical block output frequency of the bifurcation block.
4. The method of claim 3, wherein said determining the out-of-block contribution based on at least one of the historical out-of-block frequencies for the bifurcated block comprises:
determining a time adjustment factor according to the relative block height of at least one historical trunk block and the latest trunk block contained in the historical block interval;
updating the historical block output frequency according to the time adjustment factor;
and determining the block output contribution degree according to at least one updated historical block output frequency of the bifurcation block.
5. The method of claim 4, wherein the determining a time adjustment factor according to the relative block heights of at least one historical stem block and the latest stem block included in the historical block interval comprises:
determining a time adjusting factor according to the interval serial number of the historical block interval;
and each historical block interval is numbered in a reverse order according to the block-out time.
6. The method according to any one of claims 2-5, wherein said determining at least one historical chunk interval to which a forking chain to which the forking chunk belongs is associated in the main chain comprises:
determining the interval number of the historical block intervals according to the branch length of the branch chain to which the branch block belongs;
and constructing the interval of the historical blocks with the interval number according to at least one historical main trunk block in the main chain.
7. The method according to any one of claims 1 to 5, wherein the selecting a target bifurcation chain from the at least two bifurcation chains according to the block weight of the bifurcation block comprises:
determining the chain weight of the branch chain according to the block weight;
and selecting a target branched chain from the at least two branched chains according to the chain weight.
8. The method of claim 7, wherein said determining chain weights for the forking chains based on the block weights comprises:
and taking the sum of the chain weights of at least one forked block contained in the forked chain as the chain weight of the forked chain.
9. The method of claim 7, wherein said selecting a target bifurcation chain from the at least two bifurcation chains according to the chain weight comprises:
and selecting one of the at least two forked chains with the largest chain weight as a target forked chain.
10. An apparatus for determining a block chain main chain, applied to a block chain including a main chain and at least two branch chains, the apparatus comprising:
a block weight determining module, configured to determine a block-out contribution degree of a block-out node of a forked block in the forked chain in the main chain, and use the block-out contribution degree as a block weight of the forked block; the block output contribution degree is a block output node of the bifurcation block and is used for quantitatively representing the block output conditions of at least two main trunk blocks in the main chain;
and the main chain updating module is used for selecting a target branched chain from the at least two branched chains according to the block weight of the branched block and updating the main chain.
11. The apparatus of claim 10, wherein the tile weight determination module comprises:
a history block interval determining unit, configured to determine at least one history block interval associated with a branch chain to which the branch block belongs in the main chain; wherein, there is no overlap between different history block intervals;
and the block output contribution degree determining unit is used for determining the block output contribution degree according to the block output number of the block output node of the forked block in at least one historical block interval.
12. The apparatus of claim 11, wherein the block contribution determining unit comprises:
a history block output frequency determining subunit, configured to determine a history block output frequency according to the block output number of the block output node of the bifurcated block in the history block interval;
and the block output contribution degree determining subunit is configured to determine the block output contribution degree according to at least one historical block output frequency of the bifurcated block.
13. The apparatus of claim 12, wherein the out-of-block contribution determination subunit includes:
a time adjustment factor determining slave unit, configured to determine a time adjustment factor according to a relative block height between at least one history trunk block and a latest trunk block included in the history block interval;
a historical block-out frequency updating slave unit, configured to update the historical block-out frequency according to the time adjustment factor;
and the secondary block output contribution degree determining unit is used for determining the block output contribution degree according to at least one updated historical block output frequency of the bifurcation block.
14. The apparatus of claim 13, wherein the time adjustment factor determines a slave unit comprising:
the time adjustment factor determining A slave unit is used for determining a time adjustment factor according to the interval serial number of the historical block interval;
and each historical block interval is numbered in a reverse order according to the block-out time.
15. The apparatus according to any one of claims 11-14, wherein the history zone block determining unit comprises:
the interval number determining subunit is configured to determine, according to a branch length of a branch chain to which the branch block belongs, the interval number of the history block intervals;
and the historical block interval constructing subunit is used for constructing the historical block intervals with the interval number according to at least one historical main trunk block in the main chain.
16. The apparatus of any of claims 10-14, wherein the backbone update module comprises:
a chain weight determining unit, configured to determine a chain weight of the branch chain according to the block weight;
and the target branched chain selecting unit is used for selecting a target branched chain from the at least two branched chains according to the chain weight.
17. The apparatus of claim 16, wherein the chain weight determination unit comprises:
a chain weight determining subunit, configured to use a sum of chain weights of at least one bifurcated block included in the bifurcated chain as the chain weight of the bifurcated chain.
18. The apparatus of claim 16, wherein the target-split-chain selecting unit comprises:
and the target branched chain selecting subunit is used for selecting one branched chain with the largest chain weight from the at least two branched chains as the target branched chain.
19. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of block chain backbone determination as claimed in any one of claims 1-9.
20. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform a method of determining a blockchain backbone as claimed in any one of claims 1 to 9.
CN202010695567.0A 2020-07-20 2020-07-20 Method, device and equipment for determining main chain of block chain and storage medium Active CN111737358B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010695567.0A CN111737358B (en) 2020-07-20 2020-07-20 Method, device and equipment for determining main chain of block chain and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010695567.0A CN111737358B (en) 2020-07-20 2020-07-20 Method, device and equipment for determining main chain of block chain and storage medium

Publications (2)

Publication Number Publication Date
CN111737358A CN111737358A (en) 2020-10-02
CN111737358B true CN111737358B (en) 2020-12-22

Family

ID=72654958

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010695567.0A Active CN111737358B (en) 2020-07-20 2020-07-20 Method, device and equipment for determining main chain of block chain and storage medium

Country Status (1)

Country Link
CN (1) CN111737358B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114401099B (en) * 2021-08-17 2023-05-09 同济大学 Block chain PoW selfish consensus resistance method based on network topology

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108647963A (en) * 2018-05-02 2018-10-12 百度在线网络技术(北京)有限公司 Determination method, apparatus, server and the storage medium of block chain main chain
CN109493062A (en) * 2018-12-29 2019-03-19 中国科学院合肥物质科学研究院 A kind of block chain common recognition method proved based on prestige equity
CN110490593A (en) * 2018-08-29 2019-11-22 华中科技大学 A kind of block chain common recognition method and system based on storage contribution margin
US20200192770A1 (en) * 2018-12-14 2020-06-18 Nokia Technologies Oy Hierarchical weighted consensus for permissioned blockchains

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108647963A (en) * 2018-05-02 2018-10-12 百度在线网络技术(北京)有限公司 Determination method, apparatus, server and the storage medium of block chain main chain
CN110490593A (en) * 2018-08-29 2019-11-22 华中科技大学 A kind of block chain common recognition method and system based on storage contribution margin
US20200192770A1 (en) * 2018-12-14 2020-06-18 Nokia Technologies Oy Hierarchical weighted consensus for permissioned blockchains
CN109493062A (en) * 2018-12-29 2019-03-19 中国科学院合肥物质科学研究院 A kind of block chain common recognition method proved based on prestige equity

Also Published As

Publication number Publication date
CN111737358A (en) 2020-10-02

Similar Documents

Publication Publication Date Title
CN111930852B (en) Data processing method, device and equipment based on block chain and storage medium
CN110705800B (en) Mixed travel route determination method, device, equipment and storage medium
CN111813828A (en) Entity relationship mining method and device, electronic equipment and storage medium
CN110808839B (en) Processing method, device, equipment and medium for block chain abnormal data
CN111737358B (en) Method, device and equipment for determining main chain of block chain and storage medium
CN114356547B (en) Low-priority blocking method and device based on processor virtualization environment
CN111212126A (en) Data transmission method, device, equipment and medium of block chain network
CN111652354B (en) Method, apparatus, device and storage medium for training super network
CN111860644A (en) Abnormal account identification method, device, equipment and storage medium
CN111565204A (en) Block chain operation method, device, equipment and storage medium
CN110796191B (en) Trajectory classification method and device
CN111147242A (en) Block generation method and device, electronic equipment and storage medium
CN112016524B (en) Model training method, face recognition device, equipment and medium
CN110750419B (en) Offline task processing method and device, electronic equipment and storage medium
CN111598571A (en) Transaction processing method, device, equipment and storage medium of block chain
CN115834229A (en) Message security detection method, device and storage medium
CN110933181A (en) Routing method, device and system and electronic equipment
CN111782633B (en) Data processing method and device and electronic equipment
CN111901254B (en) Bandwidth allocation method and device for all nodes, electronic equipment and storage medium
CN111400106B (en) Block chain account book synchronization method and device and electronic equipment
CN111475572B (en) Block generation method, device, equipment and medium
CN111858811A (en) Method and device for constructing interest point image, electronic equipment and storage medium
CN111292223A (en) Graph calculation processing method and device, electronic equipment and storage medium
CN113127512B (en) Multi-data stream data splicing triggering method and device, electronic equipment and medium
CN111371558A (en) Block chain data processing method and device, electronic equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant