WO2021135934A1 - Blockchain accounting method and apparatus, node and storage medium - Google Patents

Blockchain accounting method and apparatus, node and storage medium Download PDF

Info

Publication number
WO2021135934A1
WO2021135934A1 PCT/CN2020/136600 CN2020136600W WO2021135934A1 WO 2021135934 A1 WO2021135934 A1 WO 2021135934A1 CN 2020136600 W CN2020136600 W CN 2020136600W WO 2021135934 A1 WO2021135934 A1 WO 2021135934A1
Authority
WO
WIPO (PCT)
Prior art keywords
chain
block
leader
proposal
application
Prior art date
Application number
PCT/CN2020/136600
Other languages
French (fr)
Chinese (zh)
Inventor
程强
Original Assignee
深圳市红砖坊技术有限公司
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 深圳市红砖坊技术有限公司 filed Critical 深圳市红砖坊技术有限公司
Publication of WO2021135934A1 publication Critical patent/WO2021135934A1/en

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
    • 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/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2219Large Object storage; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures

Definitions

  • the present disclosure relates to the field of blockchain technology, in particular to a blockchain accounting method, device, node, and storage medium.
  • the public blockchains led by Bitcoin in the industry generally have double waste: the first waste is the use of Proof of Work (PoW) algorithm, and a large number of meaningless calculations in the PoW algorithm lead to the mining process Excessive consumption of power resources, this problem can be solved by improving the consensus algorithm of the blockchain; the second waste is that the scarce mining machine resources only serve a single blockchain system, and the mining capacity of the mining machine has not been fully obtained.
  • the use of For example, in the existing Bitcoin system, there are millions of mining machines participating in mining, and the value of each mining machine may be as high as tens of thousands of RMB. However, due to the system implementation, it can only guarantee about 7 per second. The transaction capacity of the pen. As to how to improve the second waste of resources, no one has yet proposed a valuable solution.
  • the purpose of the present disclosure is to provide a blockchain accounting method, device, node and storage medium to improve the above technical problems.
  • the present disclosure provides a blockchain accounting method, which is applied to application chain miners, the method includes: participating in the selection of proposal group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miner Members of the proposal group who are elected as the block to be mined in the application chain will send a mining request for the block to be mined in the application chain to the base chain miners, and the proposal group is for the application chain miners who have the right to send mining requests Collection; Synchronize the base chain block information, and incorporate the base chain block information into the local base chain ledger, the base chain block information is derived from the application generated by the base chain miner according to the mining request
  • the base chain block of the leader of the proposal group of the chain to be mined, the base chain block information includes the election result indicating the leader of the proposal group; wherein, the leader of the proposal group has the application chain waiting Member of the proposal group for the right to mine the block; participate in the selection of the verification group member of the block to be mined in the application
  • the verification group is a collection of application chain miners who have the right to generate inspection reports.
  • the output block includes the application chain to-be-mined block packaged by the leader of the proposal group; the inspection report is received, and if it is determined according to the inspection report that the block generated by the leader of the proposal group is verified, the The block is included in the application chain ledger.
  • the present disclosure provides a blockchain accounting method, which is applied to base chain miners, and the method includes: according to a proposal sent by a member of the application chain to be mined block for the application chain to be mined block
  • the mining request is to elect the leader of the proposal group for the block to be mined in the application chain; the base chain block storing the election results and the basis for the election is included in the base chain ledger.
  • the application chain miners do not directly run the consensus algorithm to compete for the right to produce blocks, but send a mining request to the base chain miners after determining that they are members of the proposal group, and the base chain miners are elected by calculation
  • the leader of the proposal group that is, the application chain miner who has the right to produce blocks
  • the application chain miner can obtain the information of the proposal group leader by synchronizing the base chain block information , And then participate in the selection of the members of the verification group, and judge whether the block passes the verification by collecting the verification report issued by the members of the verification group for the block produced by the leader of the proposal group, and if it passes the verification, the account will be kept.
  • Miners provide computing power services for many application chains, and assist application chains to complete the mining process, which can effectively improve the waste of mining machine resources in the existing blockchain system and has good social benefits.
  • the newly developed blockchain system is vulnerable to attacks due to the lack of support from mining machine resources. If a proprietary consensus algorithm is designed for such a blockchain system, although its security can be improved, it is bound to As a result, the mining machine lacks versatility and is difficult to be recognized by the market, and ultimately cannot solve the dilemma of the new system. If the blockchain accounting method provided by the above two aspects is used, the base chain can provide sufficient mining machine resources for the newly developed blockchain system to ensure its safe and stable operation.
  • mining machines are not only used for mining, but can also be used to provide specific services to the outside world. It also requires a sufficient number of mining machines to ensure the stable operation of distributed services. If the blockchain accounting methods provided by the above two aspects are used, the base chain can provide sufficient mining machine resources for these blockchain systems to ensure the reliability of their services.
  • the present disclosure provides a blockchain accounting method, which is applied to a synchronization node set in the base chain, and the method includes: receiving a proposal group leader who determines the block to be mined in the application chain sent by the base chain miner Base chain block, or receiving the block header of the base chain block and the election result list in the block body of the base chain block sent by the base chain miner or other synchronization nodes set in the base chain; Wherein, each entry in the election result list corresponds to the election result of the leader of the proposal group of a block to be mined on an application chain, including the election result of the leader of the proposal group of the block to be mined in the application chain ; Send the base chain block information derived from the base chain block to the application chain miner, the form of the base chain block information includes one of the following: the base chain block itself; the base chain block The block header of the base chain block and the election result list in the block body of the base chain block; the block header of the base chain block and the fragment data for the application chain in
  • a synchronization node can be set on the base chain, and the synchronization node is used to synchronize block data including the results of the leader election of the proposal group from the base chain miners or other synchronization nodes, and the application chain miners can
  • the base chain block information is further synchronized from the synchronization node for block generation and verification.
  • the base chain block information can be a complete base chain block, or it can be simplified appropriately, and only the part required by the application chain miners in the base chain block is retained to reduce the bandwidth occupation during the data synchronization process.
  • multiple application chain miners are allowed to share a synchronization node, and in some scenarios, some application chain miners do not directly synchronize base chain block information from the synchronization node, but synchronize from other application chain miners.
  • the base chain does not need to set up independent synchronization nodes, and the application chain miners directly synchronize data from the base chain miners. These schemes can also be regarded as the base chain miners partially or fully implementing the function of the synchronization node. .
  • the present disclosure provides a blockchain accounting device, which is configured on a mining node set in the application chain, and the device includes: a proposal group selection module for application chain miners to participate in the application chain to be mined blocks Selection of proposal group members; wherein, if it is determined that the application chain miner is selected as the proposal group member of the application chain to be mined block, then a mining request for the application chain to be mined block is sent to the base chain miner, so
  • the proposal group is a collection of application chain miners who have the right to send mining requests; the block information synchronization module is used for the application chain miners to synchronize the base chain block information and incorporate the base chain block information into the local base chain.
  • the base chain block information comes from the base chain block generated by the base chain miner according to the mining request to determine the proposal group leader of the application chain to be mined.
  • the base chain block The information includes an election result indicating the leader of the proposal group; wherein, the leader of the proposal group is a member of the proposal group who has the right to produce blocks of the application chain to be mined; the verification group selection module is used for the application Chain miners participate in the selection of members of the verification group for the application chain to be mined; wherein, if it is determined that the application chain miner is selected as the verification group member of the application chain to be mined, the leader of the proposal group A block is generated for verification, and an inspection report is broadcast to other application chain miners.
  • the verification group is a collection of application chain miners who have the right to generate inspection reports.
  • the block produced by the proposal group leader includes the proposal group leader The packaged application chain block to be mined; the application chain accounting module, which is used by the application chain miner to receive the inspection report, and if it is determined according to the inspection report that the block produced by the leader of the proposal group has passed the verification, Then the block is included in the application chain ledger.
  • the present disclosure provides a block chain accounting device, which is configured on a mining node set in the base chain, and the device includes: an election module for the base chain miners according to the proposal group of the block to be mined in the application chain
  • the mining request sent by the member for the application chain to be mined block is the election proposal group leader of the application chain to be mined block;
  • the base chain accounting module is used for the base chain miners to save the election results and
  • the base chain block on which the election is based is included in the base chain ledger.
  • the present disclosure provides a blockchain accounting device, which is configured on a synchronization node set in a base chain, and the device includes: an information receiving module for the synchronization node to receive a certain application chain sent by a base chain miner The base chain block of the leader of the proposal group of the block to be mined, or receiving the block header of the base chain block and the base chain block sent by the base chain miner or other synchronization nodes set in the base chain
  • the election result list in the block body of the election result list; wherein, each entry in the election result list corresponds to the election result of the leader of the proposal group of a block to be mined on an application chain, including the application chain to be mined
  • the form includes one of the following: the base chain block itself; the block header of the base chain block and the
  • the present disclosure provides a blockchain node, which is set on an application chain, the node includes: a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are executed by the processor.
  • the node When reading and running, execute the method provided by the first aspect or any one of the possible implementations of the first aspect.
  • the present disclosure provides a blockchain node, which is set on a base chain.
  • the node includes a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are executed by the processor.
  • the present disclosure provides a blockchain node, which is set on a base chain, the node includes: a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are executed by the processor.
  • the node When reading and running, execute the method provided by the third aspect or any one of the possible implementations of the third aspect.
  • the present disclosure provides a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are read and run by a processor, the first aspect and the second aspect are executed. Aspect, the third aspect, or the method provided by any one of the above three aspects.
  • Figure 1 shows a structural diagram of a blockchain system provided by the present disclosure
  • Figure 2 shows a flowchart of a blockchain accounting method provided by the present disclosure
  • Figure 3 shows a functional module diagram of the first blockchain accounting device provided by the present disclosure
  • Figure 4 shows a functional module diagram of the second blockchain accounting device provided by the present disclosure
  • Figure 5 shows the functional module diagram of the third blockchain accounting device provided by the present disclosure
  • Fig. 6 shows a structural diagram of a blockchain node provided by the present disclosure.
  • the blockchain accounting method provided in this disclosure aims to build a new mechanism in which the base chain and the application chain participate in mining: a base chain can gather mining machine resources (embodied as base chain miners) to provide many application chains Computing power services, assisting application chain miners to complete the mining process, the main purpose is to improve the problem of mining machine resource waste in existing blockchain systems (such as the Bitcoin system); in addition, the application chain determines the proposal group and verification group
  • the random source of dependence is provided by the off-chain system (i.e. the base chain).
  • the leader of the proposal group members is changed to the off-chain system (i.e. the base chain), and the off-chain system (i.e. the base chain) is the application chain mining process.
  • Provide a clock source These measures help to strengthen the security of the application chain. The meaning of the concepts of proposal group, verification group, random source and clock source will be explained later.
  • Fig. 1 shows a structural diagram of a blockchain system provided by the present disclosure.
  • the blockchain system contains two kinds of blockchains, namely the base chain and the application chain.
  • the base chain In a typical scenario, there is one base chain and one or more application chains, which means that the base chain is allowed
  • it provides computing power services for multiple application chains, so as to fully dispatch the computing power of the mining machines in the base chain.
  • the process of providing computing power for each application chain by the base chain is similar, so in the following, the process of co-mining is mainly described in the case of one application chain.
  • Figure 1 also shows only one application chain. It should be pointed out that when the concept of base chain is mentioned in this disclosure, it should generally be understood as a block chain in an abstract sense.
  • the distributed ledger of the base chain it not only refers to the distributed ledger of the base chain, but also includes the nodes that constitute the base chain and the implementation of nodes. However, it does not rule out that the distributed ledger of the base chain is referred to as the base chain in some non-confusing positions in the following text; the concept of application chain should also be understood similarly.
  • the application chain should include at least mining nodes.
  • the application chain miners (for example, an application) are deployed on the mining nodes of the application chain, and the functions of the mining nodes are realized through the mining behavior of the application chain miners.
  • Figure 1 shows four application chain miners: application chain miner A, application chain miner B, application chain miner C, and application chain miner D.
  • the application chain miners do not directly run the consensus algorithm locally to compete for the accounting right when mining, but transfer the task of competing for the accounting right to the base chain for processing, and the application chain miners only need to start from the base chain. Synchronize the result of competing for accounting rights, and perform block generation and verification work based on the result.
  • the base chain should include at least mining nodes.
  • the base chain miners are deployed on the base chain mining nodes, and the functions of the mining nodes are realized through the mining behavior of the base chain miners.
  • the two concepts of chain mining nodes and base chain miners are considered to be one.
  • Figure 1 shows two base chain miners: base chain miner A and base chain miner B.
  • application chain miners send mining requests to inform the base chain miners to determine the holder of the accounting rights for them. After the base chain miners determine the application chain miners with accounting rights according to the mining request, the results are saved In the base chain block.
  • relevant data can be directly synchronized from the base chain miners (the data can be a base chain block or its simplified form), for example, the application chain miner in Figure 1 D synchronizes data directly from base chain miner B.
  • a dedicated synchronization node can also be set in the base chain, and application chain miners can synchronize related data from the synchronization node, and the data of the synchronization node is synchronized from the base chain miner or other synchronization nodes.
  • Figure 1 shows two synchronization nodes: synchronization node A and synchronization node B.
  • the data of synchronization node A is synchronized from synchronization node B, and the data of synchronization node B is synchronized from base chain miner A, application chain miner A and Application chain miners B can synchronize relevant data from the synchronization node B, so as to know the result of the competition for accounting rights.
  • base chain miners For the implementation of synchronizing related data directly from the base chain miners, it can also be considered that the base chain miners have realized part or all of the functions of the synchronization node at the same time.
  • the base chain block can also contain other content, which may not be of much value to the application chain. Therefore, in the optional scheme, the base chain block held by the base chain miner is the original data.
  • the original data can be simplified to a certain extent.
  • the application chain miner synchronizes the data from the synchronization node. From time to time, it is possible to further simplify the data, minimize the network bandwidth occupied by the data during the transmission process, and improve the operating efficiency of the blockchain system.
  • a dedicated synchronization node is set in the base chain for each application chain miner.
  • the synchronization node and the application chain mining node can be implemented as independent nodes.
  • the synchronization node and the application chain mining node can also be deployed in the same local area network; the synchronization node can also be implemented as the application chain mining node
  • the function of the application chain miner and the function of the synchronization node can be undertaken by two applications on the node respectively, or even merged into one application.
  • multiple application chain miners can also share a synchronization node.
  • the application chain miner A and application chain miner B in Figure 1 share the synchronization node B, and it is very likely that the application chain Miner A and application chain miner B originally belong to the same organization and can be trusted with each other. It is reasonable to share synchronization nodes.
  • application chain miners are allowed not to synchronize data from base chain miners or synchronization nodes, but to synchronize data from other application chain miners.
  • application chain miner C in Figure 1 synchronizes data from application chain miner B.
  • application chain miner C and application chain miner B belong to the same organization, and application chain miner C can trust application chain miner B's data.
  • Such an implementation method is completely reasonable.
  • the synchronization node mainly acts as an intermediary for the result of the application chain miners synchronizing and competing for the accounting rights from the base chain miners.
  • the information sent by the application chain miners to the base chain miners during mining Whether the mining request needs to be transferred through the synchronization node is not limited.
  • the synchronization node may also participate in base chain mining. At this time, the functions of the base chain miner and the synchronization node can be undertaken by two applications on the node respectively, or even merged into one application. .
  • the participation of synchronous nodes in base chain mining is also conducive to increasing the number of base chain miners.
  • a management node can also be set in the base chain.
  • the main role of the management node is twofold: one is to provide application chain registration services, and only the application chain base chain registered on the management node will provide computing for it. Strong support. In this process, the operator of the base chain may also charge a certain fee; the second is for the base chain miners to synchronize authorization and configuration information.
  • the authorization information is the registration status of the application chain, and the base chain miners need to judge based on this information Whether it should respond to the mining request of the application chain miners, the configuration information mainly includes some preset parameters used by the base chain miners in the joint mining process, and these parameters should be kept as consistent as possible among the base chain miners.
  • each application chain or base chain can be a parallel chain (for simplicity, a single chain is also regarded as a special case where the number of parallel chains is 1). From the perspective of providing computing power, it can be considered that the parallel chains that constitute the base chain are independent of each other, and each parallel chain of the base chain can provide computing power for one or more application chain parallel chains.
  • the application chain miners can be as follows The formula determines the parallel chain number of the base chain that provides computing power for the application chain in which you are located:
  • n (ChainNoOffet+k)%N
  • n represents the determined parallel chain chain number of the base chain
  • ChainNoOffet is the chain number offset of the application chain where the application chain miners are located
  • this parameter is a preset value
  • each application chain has its own ChainNoOffet
  • k is The chain number of the parallel chain of the application chain where the application chain miner is mining (if the application chain is a single chain, k can be 0), and% means the remainder operation.
  • the application chain miner can send a mining request to the base chain miner on the parallel chain number n of the base chain.
  • the corresponding base chain miner receives the request, it will also be based on the request.
  • the formula is verified (refer to the following content, the mining request includes information that can indicate which application chain and which parallel chain miner is sending the request, so that ChainNoOffet and k in the formula can be determined) whether you should respond It should be a mining request.
  • each parallel chain is implemented by an application, which is not limited.
  • the base chain and the application chain are often referred to in general, and it is not clear whether it is the entire base chain or a parallel chain of the base chain, or whether it is the entire application chain or a piece of the application chain.
  • Parallel chains can be specifically understood according to specific scenarios, and cannot be generalized.
  • the base chain/application chain structure in the present disclosure can also be nested.
  • one base chain at the first level provides computing power support for 4 application chains, and these 4 application chains can be used as the second level.
  • the base chains each provide computing power support for 16 application chains.
  • the solution of the present disclosure has no restriction on the specific type of blockchain used by the base chain or the application chain, as long as both the base chain and the application chain follow the longest chain rule.
  • the base chain can be a public chain
  • the application chain can be a public chain or a permission chain.
  • the base chain or the application chain directly adopts the existing blockchain system, it needs to be appropriately modified to meet the requirements of the common mining solution proposed in this disclosure.
  • FIG. 1 is only an example, and should not be regarded as a limitation on the protection scope of the present disclosure.
  • the above description of the common mining process is only a brief summary, and the specific implementation details will be given in the description of Figure 2.
  • FIG. 2 shows a flowchart of a blockchain accounting method provided by the present disclosure.
  • the method describes the process from generation to inclusion of a block on the application chain (application chain to be mined block) into the application chain ledger.
  • the process is roughly divided into two phases: the proposal phase and the verification phase.
  • the solution of this disclosure can be briefly summarized as follows: in the proposal stage, application chain miners elect members of the proposal group according to a preset algorithm, and only the members of the proposal group are eligible to be further elected as the leader of the proposal group and obtain the right to produce blocks (that is, the application chain is waiting to be mined). Block accounting rights), as to whether the right to produce blocks can be obtained depends on the result of the election of the leader of the proposal group by the base chain miners.
  • the method specifically includes:
  • Step S100 Application chain miners participate in the selection of proposal group members for the block to be mined in the application chain.
  • Step S101 If it is determined that the application chain miner is selected as a member of the proposal group of the application chain to be mined block, then a mining request for the application chain to be mined block is sent to the base chain miner.
  • the application chain to be mined block can be the next block in the application chain ledger that has been verified and accounted for.
  • the proposal group refers to a collection of application chain miners who are eligible to compete for the right to produce blocks of the application chain to be mined. , Since only the members of the proposal group will send mining requests for the application chain to be mined blocks to the base chain miners, the proposal group can also be defined as a collection of application chain miners who have the right to send mining requests.
  • the app chain miner who finally obtains the right to produce the block to be mined in the app chain is called the leader of the proposal group, and the leader of the proposal group is elected by the base chain miners. See step S102 for details.
  • Each application chain miner can independently determine whether to be a member of the proposal group according to a preset algorithm, and does not depend on other application chain miners.
  • the above-mentioned preset algorithm can use the Verifiable Random Function (VRF) algorithm.
  • the core content of the VRF algorithm is the verification function VRF_prove and the verification function VRF_verify: calling VRF_prove(PrivateKey, info ) Can get a provable string proof, the proof obtained by VRF_prove for certain input (PrivateKey and info) is certain (the value obtained by multiple operations is the same), where PrivateKey is the private key of a public-private key pair K Key, info is a known string; calling VRF_verify(PublicKey,info,proof) can verify whether the proof is forged, where PublicKey is the public key in the public-private key pair K.
  • VRF_verify returns True to indicate that the verification is passed, otherwise it returns False to indicate that the verification fails.
  • Application chain miners first call the proof function in the VRF algorithm based on their own private key (corresponding to the PrivateKey above) and the first election string determined by the preset rules (corresponding to the info above) to obtain the first provable string ( Corresponding to the proof above). After that, the application chain miner uses a preset rule to derive the first random value based on the first provable string, and determines whether the application chain miner is selected as a member of the proposal group for the block to be mined in the application chain based on the first random value.
  • the derivation rules are deterministic (but the specific rules are not limited), so for the same input, the deduced first random value is also deterministic, and then the members of the proposal group obtained on the basis of the first random value The results of the election are also deterministic.
  • the above-mentioned first election string is a known string, and its acquisition rule is determined.
  • the information of the leader of the proposal group elected by the base chain miners for the block to be mined in the application chain is recorded in a certain base chain block, which is said to be the base chain block of the proposal group leader who determines the block to be mined in the application chain ,
  • the base chain block is still in a state to be mined, but its height in the base chain can be determined (refer to the content below, the application chain also saves the base chain ledger ).
  • the first election string may be: to determine the information in the first L block of the base chain block of the leader of the proposal group of the block to be mined in the application chain; where L is a positive integer, the so-called block
  • the information in may be the hash value or random number recorded in the block header.
  • the first election string corresponds to the hash and nonce fields in the block header.
  • the leader information of the proposal group elected by the base chain miners for each block of the application chain is recorded in the base chain block, and the application chain miners are synchronized to the base chain area.
  • the information can be saved on the mining node where the application chain miner is located to form a local base chain ledger for the application chain miner, which may be simplified compared to the base chain ledger of the base chain miner, but still contains
  • the application chain miner can query the ledger to determine the content of the first election string.
  • the adversary which can refer to the malicious attacker on the blockchain system learns the first election string early, he will have sufficient time to perform some cracking actions.
  • the value of L is too small (for example, take 1).
  • the first election string determined by the application chain miners and the base chain miners at the block at the designated height of the base chain can be basically considered to be the same. That is to say, the influence of the soft fork of the base chain on the value of the first election string is basically eliminated.
  • the first 6 blocks of the base chain block of the proposal group leader who determine the block to be mined on the application chain have been earlier.
  • each application chain miner can calculate its own proposal group participation weight, and each application chain miner can determine whether he is an application chain based on the first random value and his own proposal group participation weight.
  • the members of the proposal group of the block to be mined are positively related to the value of the participation weight of the proposal group.
  • the weight of the proposal group participation weight of a certain application chain miner can be the number of times the miner was elected as the leader of the proposal group in a preset historical time period. According to this definition, the more times the miner was elected as the leader of the proposal group in the historical time period The probability that a miner will be elected as the leader of the proposal group again is also higher, in return for his repeated honest mining.
  • the application chain miner will also save a base chain ledger locally, and the application chain miner can query the ledger to obtain statistics to obtain the current application chain miner elected within the preset historical time period. The number of times the leader of the proposal group.
  • the application chain miners can also construct a query table based on the synchronized base chain block information.
  • the table can be stored in the database or resident memory, and its content can include applications.
  • the leader information of the proposal group of each block of the chain is convenient for the application chain miners to quickly query (no longer directly query from the local base chain ledger). The specific items of the inquiry form will be mentioned later.
  • the above-mentioned preset historical time period can be selected in different ways: for example, the continuous G2 (G2 is a positive integer) blocks of the base chain before the reciprocal G1 (for example, 36) blocks of the base chain are taken as the historical time period , Query the number of times that the miner of the application chain was elected as the leader of the proposal group in these blocks; for another example, take a difficulty adjustment period just past the base chain (the difficulty here refers to the difficulty of mining, for example, every 2016 block of Bitcoin is A difficulty adjustment period) before the consecutive G3 (G3 is a positive integer) difficulty adjustment period as the historical time period, query the number of times the application chain miners were elected as the leader of the proposal group in the base chain blocks generated during this period.
  • the historical time period does not take the latest period of time at the current moment.
  • the reason is that the communication delay and the soft fork of the base chain may affect the number of elections of the leader of the statistical proposal group.
  • the two influencing factors have been analyzed before the first election string was explained, and will not be repeated.
  • the first accounting weight parameter can also be preset on the application chain.
  • a value of 0 means that the newly added application chain miners are prohibited from participating in mining; otherwise, if the first accounting weight takes a non-zero value, it means Allow newly joined application chain miners to participate in mining.
  • their proposal group participation weight (the value is 0 at this time) can be set as the first accounting weight, so that they can be elected as a proposal group member with a lower probability.
  • the application chain can also preset the parameter of the proposal group’s maximum participation weight, that is, set an upper limit for the proposal group’s participation weight. If the calculated proposal group’s participation weight exceeds the upper limit (for example, application Chain miners have been elected as the leader of the proposal group for many times in the historical time period, and the proposal group’s participation weight is greater than the preset maximum participation weight of the proposal group), then the proposal group participation weight is set to the maximum participation weight of the proposal group . Avoid a certain application chain miner who is deeply involved in mining to have too much advantage in the selection of proposal group members, and deprive other application chain miners of the opportunity to be elected as members of the proposal group.
  • Application chain miners determine whether they are members of the proposal group of the block to be mined in the application chain according to the first random value and their own proposal group participation weight.
  • implementation methods There are also different implementation methods. In one implementation method, it can be implemented as follows:
  • RandValue1 is the first random value
  • ExpectedRange1 is the preset range value
  • priority1 is the weight of the proposal group participation
  • % represents the remainder operation.
  • the function of ExpectedRange1 is mainly to adjust the value of RandValue1 to a reasonable range, because the randomness of RandValue1 makes the value may be very large, which is not in the same order of magnitude as priority1. If RandValue1 is directly used for calculation, it may cause whether to add priority1 The final result has no effect.
  • M1 is the preset filtering ratio. For example, if M1 is 10, about 1/10 (in a probability sense) of all miners in the application chain will be selected as members of the proposal group.
  • priority1 is combined into the formula by product (currently by addition), or RandValue2 Less than a certain value is used as a condition for being elected as a member of the proposal group (currently greater than a certain value), and so on.
  • an application chain miner confirms that he is a member of the proposal group of the application chain to be mined, he will send a mining request for the application chain to be mined to the base chain miner.
  • the application chain miner may send a request directly to the mining node where the base chain miner is located, or may send a mining request to the synchronization node on the base chain.
  • the node that receives the mining request first in the base chain will send the mining request at Broadcast in the base chain, and eventually all base chain miners will receive it.
  • the base chain is composed of multiple parallel chains, before sending a mining request, the application chain miner needs to determine which base chain miner on the parallel chain to send the request to, otherwise the request will not be accepted. The determination method is shown in the illustration. It has been explained at 1 o'clock and will not be repeated here.
  • the mining request includes proposal candidate information.
  • the concept of proposal candidate information will be used in many places in this system. Its content includes: application chain identification, parallel chain chain number, height of the block to be mined in the application chain, and determination of the leader of the proposal group The height of the base chain block, the public key of the application chain miner, and the first provable string.
  • the application chain identifier refers to the identifier of the application chain where the member of the proposal group that sent the mining request is located (used to uniquely mark an application chain), and the parallel chain number refers to where the member of the proposal group in the parallel chain that constitutes the application chain mines.
  • the height of the base chain block that determines the leader of the proposal group refers to the base chain of the proposal group leader who determines the block to be mined in the application chain
  • the height of the block, the public key of the application chain miner refers to the public key of the proposal group member who sent the mining request, and the first provable string refers to the first provable string that the application chain miner relied on when elected as a member of the proposal group .
  • the proposal candidate information can also include other information items, such as the second random value that the application chain miners rely on when they are elected as members of the proposal group.
  • the second random value can also be derived using the first provable string, it needs to be For certain operations, in some occasions where the security requirements are not too high, the second random value can also be used directly for verification and other behaviors, without the need to derive it again.
  • the purpose of each information item in the proposal candidate information will be explained in the subsequent steps, and will not be expanded here.
  • Step S102 The base chain miners elect the leader of the proposal group according to the mining request for the application chain to be mined block sent by the proposal group members of the application chain to be mined block.
  • the base chain miner After the base chain miner receives a mining request sent by an application chain miner, it must first confirm whether to respond to the request. If it is confirmed to respond to the request, the request will be used as a proposal to elect the application chain to be mined. The basis of the group leader.
  • the content to be verified includes at least the following two:
  • the base chain miners determine whether the application chain corresponding to the identifier is supported by the base chain based on the application chain identifier in the mining request.
  • each base chain miner can locally maintain a set of application chain identifiers corresponding to the registered application chain. If the base chain miner finds the application chain in the current mining request If the identifier is in the set, it means that the application chain corresponding to the identifier has been registered, and the verification of this item is passed, otherwise it is not passed.
  • the identifier R is used to determine the value of the ChainNoOffet parameter in the formula, because this parameter is set for each application chain.
  • the base chain miner first determines the first election string that the application chain miner who sent the mining request depends on when it is elected as the member of the proposal group according to the height of the base chain block that determines the leader of the proposal group in the mining request; Then, based on the application chain miner’s public key in the mining request, the first proof string, and the first election string calculated by myself, the verification function in the VRF algorithm is called to verify whether the first provable string in the mining request is If forged, the verification function outputs True, indicating that the first provable string is not forged, and False indicates that the first provable string is forged.
  • the method of obtaining the first election string has been introduced in the previous article, but the calculation was performed by the application chain miners before, and here is the calculation by the base chain miners.
  • the source of the first election string The information in the base chain block is obviously easy to obtain for the base chain miners who have the base chain ledger locally, and the details will not be elaborated. If the output result of the verification function shows that the first provable string is not forged, the verification of this item is passed, otherwise the verification of this item is not passed.
  • the miner ID of the app chain miner who sent the mining request which is used to uniquely mark an app chain miner.
  • the base chain miner judges whether the calculated miner ID is in the blacklist configured by the base chain for the application chain.
  • the content of the blacklist can be a collection of a series of miner IDs. If the miner ID of the app chain miner who sends the mining request is In the blacklist, the base chain miners should refuse to provide services for them, that is, the verification fails, otherwise the verification is passed.
  • the base chain miner judges whether the calculated miner ID is in the real name list configured by the base chain for the application chain.
  • the content of the real name list can be a collection of a series of miner IDs. If the miner ID of the application chain miner who sends the mining request is In the real-name list, the base chain miners should agree to provide services for them, that is, the verification of this item is passed, otherwise the verification of this item is not passed. This verification is applicable to situations that require real-name mining by application chain miners.
  • the management node There are two main functions of the management node: The first function is authorization information management.
  • the management node provides external application chain registration services. If the manager of the application chain wants the operating application chain to be supported by the base chain’s computing power, it should initiate a registration with the management node. If the management node agrees to the application chain’s registration request, it can register with the base chain.
  • the miner issues authorization information (the issue here can be actively issued by the management node, or the base chain miner requests it to issue), and the content of the authorization information includes the information of the registered application chain (for example, the application of these application chains). Chain identification).
  • the second function of the management node is configuration information management.
  • the configuration information includes some preset parameters used by the base chain miners, such as the preset range values, preset filtering ratios, and first-time The accounting weight, the maximum weight of the proposal group and a number of parameters mentioned later. Although only the use of these parameters on the application chain has been introduced before, some or all of the parameters will also be used on the base chain. The same parameters should be as consistent as possible on the application chain and the base chain (because the parameters are applied in the base chain). The synchronization between the chain and the base chain takes time, so it is not ruled out that the value of the same parameter is different on the base chain and the application chain at some time, but the parameters can be designed with a certain margin), and the specific parameters are maintained. The method of consistent value is not limited in the present disclosure. Each base chain miner can synchronize configuration information from the management node, or it can be actively broadcast by the management node.
  • Authorization configuration information (abbreviation of authorization information and configuration information) is very important for the normal block generation of the application chain. Therefore, in some implementations, the management node can strictly number it to ensure the integrity of the data. For example, each modification operation of each parameter in the configuration information is recorded, and each operation behavior is sequentially numbered, so that all modification behaviors of the parameter can be traced back. For another example, for each parallel chain of the base chain, there are one or more parallel chains of its own service (these parallel chains can have their own set of configuration information), so the parallel chains of the base chain can also be Carry out the number, respectively carry on the configuration information management.
  • the authorized configuration information may be adjusted during the operation of the blockchain system.
  • the administrator of the application chain can submit the latest values of the parameters in the configuration information to the management node.
  • the authorization configuration information after the authorization configuration information is updated, it will not be synchronized from the management node to the base chain miners in real time, but will be synchronized at a specified time.
  • base chain miners can query the management node at the beginning of the difficulty adjustment period of the base chain whether the locally saved authorization and configuration information is the latest version, if not the latest version, synchronize the latest version of the authorization and configuration information from the management node; among them, Base chain miners make a query every preset number of difficulty adjustment cycles.
  • the management node sends authorization and configuration information to the base chain miners, it can also sign with its own private key to prevent the information from being tampered with.
  • the base chain miners continuously collect and cache the mining requests sent by the miners of each application chain. These mining requests may be for blocks of different heights in the application chain (specified by the height of the block to be mined in the application chain in the mining request) .
  • the base chain miners package the base chain blocks, they first determine the new height of the application chain to be mined according to the highest block of the application chain recorded in the base chain ledger and the leader of the proposal group has been selected (named as the new height is In order to distinguish it from the old height later, it has no special meaning), that is, to determine the election result of the application chain block of which height is to be recorded in the currently packaged base chain block.
  • Basechain miners can maintain a variable that is used to record the height of the highest block in the application chain that has selected the leader of the proposal group recorded in the basechain ledger. Of course, they can also query the basechain ledger every time a block is generated. Regarding the existence of empty blocks in the application chain, you can refer to the following text about the content of the base chain and the application chain generating blocks at the same frequency.
  • the base chain miners select the mining request that matches the new height from the cached mining requests and include them in the waiting set for the new height.
  • the so-called matching refers to the block to be mined in the application chain in the mining request.
  • the height item is consistent with the new height.
  • the base chain miners judge whether the number of requests in the set to be elected for the new height is not less than the preset minimum number of miners. If the minimum number of miners is not reached, then the leader of the proposal group will be elected for the block of the new height of the application chain. If a person fails, the processing method for failure is described in step S103. If the minimum number of miners is reached, the application chain is determined according to the first provable string in each mining request in the set to be elected for the new height The leader of the proposal group for the new height block. For different application chains, the minimum number of miners can take different values, such as a value between 10 and 50.
  • the parameter of setting the minimum number of miners is used to verify whether enough application chain miners agree with the current mining status, because honest application chain miners only pass the verification of the previous block of the application chain to be mined. Will request to mine the next block, and then it is possible to issue a mining request for the block to be mined in the application chain. If the number of requests in the waiting set for the new height is less than the minimum number of miners, it indicates that there are not enough Of application chain miners agree that currently mining blocks of new heights in the application chain are needed, and the elected leader of the proposal group is not effective.
  • the base chain miners elect the leader of the proposal group when they pack the base chain blocks.
  • the base chain miners pack the base chain blocks, it may be different according to the different mechanisms adopted by the base chain. This disclosure is about this. It is not limited. For example, there may be multiple base chain miners packing the base chain blocks at the same time. Of course, in the end, only the blocks packaged by the base chain miners who have obtained the bookkeeping right will be recognized; for another example, each base chain miner first competes for the bookkeeping right, only to obtain Only the base chain miners with bookkeeping rights will package the base chain blocks, and so on.
  • the base chain miners determine the leader of the proposal group for the block of the application chain at the new height.
  • the base chain miners can first calculate according to the first provable string in each mining request in the set to be elected for the new height
  • the specific process of the second random value corresponding to the mining request can be: first derive the first random value based on the first provable string using preset rules, and then according to the first random value and the application chain that sent the mining request
  • the second random value is calculated for the weight of the miner's proposal group participation (for the calculation formula, please refer to the previous article).
  • the weight of the proposal group participation can be determined based on the information in the base chain ledger, for example, it is defined as the number of times the application chain miners are elected as the proposal group leader in a preset historical time period.
  • the base chain miners store the base chain ledger locally, which can naturally count the number of elections of the application chain miners.
  • the base chain miner can also build a database or memory table based on the information in the base chain ledger. Convenient for inquiries.
  • the base chain miners After the base chain miners calculate the second random value corresponding to each mining request, they will further use a preset selection condition to filter out a second random value that meets the conditions, and then the second random value corresponding to the mining
  • the sender of the request is determined as the leader of the proposal group of the block to be mined in the application chain.
  • the selection condition can be the maximum or minimum calculated second random value, which is not limited, but for the sake of simplicity, the following is an example of selecting the largest second random value.
  • further information that can identify the identities of the members of the proposal group corresponding to these mining requests can be obtained (for example, The public key or the hash value of the public key of the members of the proposal group, where the miner’s public key is carried in the mining request), and use the obtained information to further compare according to certain rules, for example, let the public key or the public key hash The person with the greatest value is elected as the leader of the proposal group.
  • the base chain miners can further check whether the largest second random value is greater than the preset smallest random value. If it is greater than the smallest random value, the leader of the proposal group will be formally determined that the election is successful, otherwise The block election proposal group leader of the new height of the application chain fails, and the processing method for the failure is described in step S103.
  • the parameter of setting the minimum elected random value is used to increase the difficulty of the attack. Even if the adversary forges a large number of accounts to carry out witch attacks, the application chain miners corresponding to these accounts can only be elected as the leader of the proposal group with a low probability, especially for the proposal group participants.
  • the selection weight is based on the number of times the leader of the proposal group has been elected.
  • the new application chain miner has a small participation weight corresponding to the proposal group, and the final calculated second random value is also small, so It is likely to be excluded from the process of verifying the minimum random value of the election and will not be selected as the leader of the proposal group. Of course, there are other methods to prevent Sybil attacks.
  • a continuous mining flag parameter can be set for each application chain.
  • This parameter can take at least two values (such as True and False), which respectively indicate that miners of the same application chain are allowed to be successively elected leaders of the proposal group And the same application chain miner is not allowed to be continuously elected as the leader of the proposal group.
  • the continuous election here means that a certain application chain miner is selected as the leader of the proposal group in two consecutive blocks (empty blocks are not considered) of the application chain.
  • the base chain miner will determine whether the leader of the proposal group is the same after determining the leader of the proposal group according to the largest second random value.
  • the proposal group leader selected in the last proposal group leader election of the application chain, if yes, then re-determine the proposal group leader, and determine the application chain miner corresponding to the mining request with the second largest random value calculated as The leader of the proposal group of the block to be mined in the application chain.
  • Forbidding miners of the same application chain to be continuously elected as the leader of the proposal group is beneficial to improve the security of the blockchain system, because it is more difficult for adversaries to continuously obtain the right to keep accounts, combined with the longest chain rule, double-spending attacks will be more difficult to implement.
  • Step S103 The base chain miner incorporates the base chain block storing the election results of the application chain to be mined blocks and the basis of the election into the base chain ledger.
  • step S102 the leader of the proposal group for the block to be mined in the application chain is successfully selected, the base chain miners union will pack the election results and election basis into the base chain block, but it needs to be noted that some consensus is adopted in the base chain During the algorithm, multiple base chain miners will package the base chain blocks. These base chain blocks all record the election results of the blocks with the new height of the application chain.
  • Base chain miners are those who compete for the right to bookkeeping, not necessarily those who have obtained the right to bookkeeping.
  • the election results are mainly used to indicate the identity of the leader of the proposal group and which application chain area the leader of the proposal group is targeting.
  • the election basis is mainly used to record the credentials of the leader of the election proposal group, so that others can verify whether the election result is correct.
  • the election result includes the proposal candidate information obtained from the mining request sent by the leader of the proposal group of the application chain for the block to be mined in the application chain, and each base chain block has the maximum value for each application chain. Record an election result. In other words, the election results of two different blocks on the application chain must be recorded in two different base chain blocks.
  • the election result is stored in the block body of the base chain block as an entry in the election result list.
  • the election result list can include multiple entries, and each entry corresponds to a block to be mined on the application chain. Election results.
  • transactions are stored in the block body of a block, and a merkle tree can be constructed by performing multi-level hash operations on these transactions, and the merkle root (the root node of the merkle tree) is stored in the block header.
  • the structure of the base chain block can also be designed in a similar way, that is, the table items of the election result list are stored in the block body of the base chain block, and the merkle root calculated based on these table items is stored in the area.
  • it is recorded as merkle_root1 for the convenience of the following description.
  • the election basis includes a collection of proposal candidate information obtained from mining requests in the set to be elected for a new height, because the leader of the proposal group of the block to be mined in the application chain is selected based on the mining request in the set to be elected , So it is reasonable to use the proposal candidate information in these mining requests as the basis for election.
  • the proposal candidate information corresponding to the leader of the proposal group may not be included in the election basis, because the information is already included in the election result.
  • Election basis is stored in the block body of the base chain block as an entry in the election basis list. For each proposal candidate information in the same entry, due to the application chain identification, parallel chain chain number, and application chain waiting information.
  • the election basis list can include multiple entries, and each entry corresponds to the election basis of a block to be mined on an application chain.
  • the election result list and the election basis list have the same length, and each table item also has a one-to-one correspondence.
  • the block body of the base chain block stores the entries of the election basis list, and the merkle root calculated based on these entries is stored in the block header, which is recorded as merkle_root2 for the convenience of the following description.
  • the block header contains merkle_root1 and merkle_root2, it means that merkle_root1 and merkle_root2 will also be used as the source strings when calculating the hash value of the block. That is to say, once the content of the base chain block is determined, the list of election results and the basis for election The lists are all incorporated into the non-tamperable mechanism of the blockchain.
  • merkle_root1 and merkle_root2 are recorded in the block header of the base chain, indicating that the base chain adopts a double merkle tree structure.
  • the base chain is used to provide computing power for the application chain.
  • digital currency can be issued on the base chain, it is optional.
  • the block body of the base chain block It can also record transactions and mining information.
  • the mining information can be recorded in the first transaction of the block (also known as Coinbase), and its content includes the description of the block producer, mining rewards, etc.
  • the merkle tree can be organized, and the calculated merkle root is stored in the block header, which is recorded as merkle_root3.
  • the base chain adopts a three-merkle tree structure. The content of the transaction is already available in the current blockchain system and will not be described in detail.
  • the content can include: verifying the first provable word in the candidate information of each proposal in the election basis Whether the string is forged (the method is as described above); According to the election process of repeating the leader of the proposal group according to the election basis, verify whether the selected leader is consistent with the record in the election result; other regular verifications on the content of the block (such as verification area Block header content, verifying whether the transaction is legal when the transaction is included in the block, etc.). If all the verification items are passed, the base chain miners will perform accounting.
  • step S102 two possible reasons for failure are mentioned, neither Exclude other reasons for the election failure. If the leader of the election proposal group of the block to be mined of an application chain fails, the corresponding election results and election basis will not be recorded in the block generated this time on the base chain. If the base chain block adopts the election result list and election According to the form of the list, the entries in the two lists corresponding to the application chain are left blank. Of course, the election of the leader of the proposal group on each application chain is independent of each other, and the contents of other entries are not affected.
  • leader of the proposal group fails to be elected for the block at the new height of the application chain, a simple way is to postpone it until the next block generation of the base chain and try to elect the leader of the proposal group for the block of the new height of the application chain.
  • Another more complicated approach is to first try to reselect the leader of the proposal group at a number of old heights before the new height of the application chain. If the attempt is successful at an old height, then re-dig the application chain block at the old height. , If all are unsuccessful, it will be postponed until the next block generation of the base chain to try to elect the leader of the proposal group for the new height of the application chain.
  • the latter method is specifically introduced below:
  • the base chain miner fails to elect the leader of the proposal group for the new height block based on the mining request in the new height waiting to be elected set, first determine that the application chain adjacent to the application chain to be mined block in the application chain has been selected
  • the old height of the block of the leader of the proposal group, where the old height is lower than the new height in the application chain, and the above-mentioned adjacent meaning refers to adjacent in the sense of ignoring empty blocks in the application chain.
  • the base chain miners select the mining request matching the old height from the cached mining requests and include them in the waiting set for the old height.
  • the so-called matching refers to the block to be mined in the application chain in the mining request.
  • the height item is consistent with the old height. Note that since the application chain block of the old height has successfully elected the leader of the proposal group, some of the mining requests for the application chain block of the old height initiated by the application chain miners have been successfully elected before.
  • the base chain miners re-elect the proposal group leader of the block of the application chain at the old height according to the mining request in the waiting set for the old height, the election method and the previous election of the proposal group of the block of the application chain at the new height
  • the leaders are similar, so I won't elaborate on it. If the election is successful, the results of the election and the basis for the election will be saved in the base chain block.
  • the leader of the proposal group was successfully elected for a block at an old height of the application chain.
  • the election result and the basis of the election of the block of the old height are stored in the base chain block that was released this time. It is understandable that if the leader of the proposal group is successfully elected at an old height of the application chain, it may cause the block of the old height to be re-produced, and all the blocks connected after it in the application chain are also invalid and need to be re-mined. .
  • the leader of the proposal group will be elected for the block of the application chain at a new height when the base chain is next produced. If the election still fails, then Try to re-dig the old block and repeat.
  • the mining request for the new height used in the block generation of the base chain is in the base chain.
  • the mining request for the old height used in the current block generation of the base chain can be reused in the next block generation of the base chain, because the operation of re-mining old blocks is not tied to the height of the base chain block. That is, after the leader of the block election proposal group with the old height of the application chain succeeds, the election result and election basis are directly recorded in the latest block of the base chain, instead of recording the specified height in the mining request for election ( Refers to the base chain block that determines the height of the base chain block of the leader of the proposal group in the mining request.
  • the new block mining operation is tied to the height of the base chain block, that is, after the leader of the block election proposal group of the new height of the application chain is successful, the election result and election basis must be recorded in the specified height of the mining request for election (Refers to the base chain block height of the base chain block that determines the leader of the proposal group in the mining request).
  • the base chain miner can distinguish whether it is a mining request for a new height or a mining request for an old height based on the information of the height of the block to be mined in the application chain, and adopt different processing methods. .
  • the first election string at this time can be obtained according to this height (for example, take the first election string of the height).
  • the information in the L block) is further used for the verification of the first provable string in the request. After the verification is passed, the mining request can be used for the election of the leader of the proposal group for the block of the old height.
  • the reasons for the different processing methods for mining requests for mining new blocks and mining old blocks are:
  • application chain miners can verify the previous block in advance and issue a mining request for a new height in advance (see the following content for advance verification), so that the request has sufficient time to spread in the base chain, so Although the mining request for the new height is only valid during the block generation period of the base chain, the probability of selecting the leader of the proposal group for the block of the new height is also higher. However, the mining request for the old height may not be able to be fully disseminated (the ones that have been effectively disseminated, have been used before the leader of the proposal group at the old height, and cannot be reused), so it is allowed to publish multiple times on the base chain.
  • the base chain is responsible for selecting the leader of the proposal group for the application chain, but it does not presuppose whether the selected proposal group leader can play a role in the application chain (playing a role means successfully If it does not play a role, as a remedy, it is permissible to overturn and re-dig the old block, and re-dig the old block is a specific measure to achieve the derivation and re-start.
  • the leader of the proposal group fails to play a role in the application chain: For example, the base chain believes that a certain height block of the application chain has selected the proposal group leader, but the proposal group leader’s block has not been selected.
  • the block is not approved by the application chain;
  • both the base chain and the application chain follow the longest chain rule, they are not completely synchronized, that is, the longest chain of the base chain does not necessarily correspond to the longest chain of the application chain, so the base chain follows the longest chain
  • the rule switches to a new branch.
  • the recently selected leader of the proposal group on the new branch may correspond to the block at the old height of the longest chain of the application chain (rather than the highest block), and may also be the longest block of the application chain.
  • the chain has different leaders of the proposal group on the block of the old height; of course, it may also include other reasons, which will not be listed. In short, allowing the re-mining of old blocks in the application chain helps eliminate soft forks and exceptions in the application chain.
  • Step S104 The application chain miner synchronously determines the base chain block information of the base chain block of the proposal group leader of the block to be mined in the application chain from the base chain miner.
  • Application chain miners need to synchronize the base chain block information from the base chain miners in order to know the election results of the application chain to be mined blocks.
  • the base chain block information comes from the base of the leader of the proposal group that determines the application chain to be mined.
  • Chain block the base chain block information includes at least the election result of the leader of the proposal group specifying the block to be mined in the application chain.
  • the application chain miners directly synchronize related data from the base chain miners, and in another implementation mode, the application chain miners indirectly synchronize related data from the base chain miners.
  • Synchronization nodes can be set in the base chain, application chain miners can synchronize related data from the synchronization node, and the data of the synchronization node is synchronized from the base chain miners or other synchronization nodes, because the former implementation method can be regarded as the base chain miners.
  • the following mainly introduces the specific implementation of the latter method.
  • Base chain block information can take at least one of the following three forms:
  • the synchronization node obtains the base chain block from the base chain miner (it can be a block verified by the base chain miner, of course, it does not rule out the verification of the synchronization node itself), and then the application chain miner obtains the base chain block from the synchronization node, and finally
  • the base chain ledger is formed locally by the application chain miners (of course, simple verification can be done before the base chain block information is included in the ledger).
  • the above-mentioned acquisition can be either an active request or a passive receiving method.
  • the synchronization node obtains the block header and the election result list of the base chain block from the base chain miner or other synchronization nodes, and then the application chain miner obtains the area of the base chain block from the synchronization node.
  • the block header and the election result list, and finally the base chain ledger is formed locally by the application chain miners (of course, the base chain block information can be simply verified before being included in the ledger), and the block header of the block in the base chain ledger is the same as the base chain block ,
  • the block body only contains the list of election results in the base chain block, which is a simplified base chain ledger.
  • the fragment data includes the election result of the leader of the proposal group for the block to be mined in the application chain in the election result list, and the merkle root (that is, the merkle root calculated based on the election result list in the block header of the base chain block).
  • the election result list still contains the election results in each application chain. However, for the application chain where the block to be mined in the application chain is located, other application chains other than itself You do not need to care about the election results on the above.
  • the block header and the fragment data related to the application chain in the block body are retained in the base chain block information, this can further reduce the data synchronization overhead.
  • one base chain can serve hundreds of application chains. If the third type of base chain block information is adopted, the amount of data transmission can be saved considerable.
  • the merkle path is composed of a series of hash values, which can be used to verify that the election result of the leader of the proposal group for the block to be mined in the application chain in the fragment data has not been forged.
  • the merkle path can be used To verify whether a certain transaction has been forged, the verification principle here is similar and will not be elaborated.
  • the synchronization node obtains the block header and the election result list of the base chain block from the base chain miner or other synchronization nodes, and then the application chain miner obtains the area of the base chain block from the synchronization node.
  • the block header and the fragment data for the application chain where the miner is located, and finally the base chain ledger is formed locally in the application chain miner (of course, the base chain block information can be simply verified before being included in the ledger), and the block header of the block in the base chain ledger
  • the block body Like the base chain block, the block body only contains fragments of data for the application chain, which is a further simplified base chain ledger.
  • the base chain block information contains the election result of the leader of the proposal group of the application chain to be mined.
  • the content of the election result includes the information sent from the leader of the proposal group for the application chain to be mined
  • the proposal candidate information obtained in the mining request of the block includes at least the application chain identifier, the parallel chain chain number, the height of the block to be mined in the application chain, the height of the base chain block that determines the leader of the proposal group, and the application chain miner’s public The key and the first provable string of six pieces of information.
  • the election result can be further simplified to include only two pieces of information, the miner ID of the leader of the proposal group and the height of the block to be mined in the application chain.
  • the miner ID of the leader of the proposal group is based on the application chain ID, the parallel chain number and the public key of the application chain miner in the mining request sent by the leader of the proposal group.
  • the hash algorithm is used for calculation.
  • the identity of the mentioned application chain miners is the same (because the leader of the proposal group originally belongs to the application chain miner); the height of the block to be mined in the application chain can be directly copied from the application chain waiting in the mining request sent by the proposal group leader The height of the mining block.
  • the miner identification of the leader of the proposal group is a 32-byte hash value
  • the height of the block to be mined in the application chain is a 4-byte integer
  • the two occupy 36 bytes in total.
  • the election result list of 300 entries only occupies 10.8KB, plus the block header occupies about 11KB. Such a small amount of data is easy to synchronize with chain miners.
  • the election result when the base chain synchronizes the base chain block information with the synchronization node can adopt the above simplified form
  • the election result can also adopt the above simplified form.
  • the items in the election result list (each item corresponds to an election result) can also adopt the above simplified form. It is understandable that the items in the election result list After adopting the simplified form of the election results, it has no other impact on the structure of the base chain block.
  • the merkle root calculated based on the entries in the election result list is still stored in the block header.
  • the election basis list saves the backup of the election results (the mining request corresponding to the election result must also be one of the mining requests based on the election), any one can be restored at any time The original form of the election results.
  • data can be synchronized from the mining node in the base chain or other synchronization nodes, but the mining node in the base chain will not synchronize data from the synchronization node (because the mining node must ensure the integrity of the data , The simplified version of the data cannot be synchronized).
  • each node joins the base chain, it establishes a connection with other nodes and can inform each other of its own attributes (whether it is a mining node or a synchronization node), so that when the nodes synchronize data with each other, they will adopt different attributes according to each other’s attributes. operating.
  • a query table can be built on the application chain or the base chain to query the number of times that the application chain miners have been elected leaders of the proposal group in a preset historical time period (corresponding to several base chain blocks), as the application chain miners Proposal group participation weight.
  • the form includes three fields: the miner ID of the leader of the proposal group, the height of the base chain block of the elected leader of the proposal group (here refers to the block in the base). The actual height in the chain is not the height of the base chain specified in the mining request, because the existence of remining old blocks makes these two heights not necessarily the same) and the height of the block to be mined in the application chain.
  • the last One field is optional. Indexes can be set on the first two fields to speed up the query.
  • the table can be constructed based on the synchronized base chain block information.
  • the base chain block information includes at least the election results of the application chain to be mined blocks. If the election result is in the original form (that is, it contains proposal candidate information), the value of the first field in the form can be calculated based on the application chain identifier, parallel chain chain number, and application chain miner public key in the proposal candidate information. The value of this field is directly copied from the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, and the third field is directly copied from the height of the application chain block to be mined in the proposal candidate information.
  • the values of the first and third fields in the table can be directly copied from the election results, and because the application chain miners store the base chain ledger locally, according to the information in the base chain block Block header, the block formed by the block information of the base chain should be connected to which branch of the base chain which position is clear, and the value of the second field can also be determined.
  • Step S105 The application chain miners participate in the selection of the members of the verification group of the block to be mined in the application chain.
  • Step S106 If it is determined that the app chain miner is selected as a member of the verification group of the block to be mined in the app chain, the block produced by the leader of the proposal group is verified, the verification result is written into the inspection report and the inspection report is broadcast to other app chain miners .
  • full-staff verification that is, all application chain miners complete verification of any new block, and only after the verification is passed can it be included in the application chain ledger.
  • full-member verification is low.
  • full-member verification is restricted: only historical blocks (non-recently generated blocks) Simple verification, not complete verification, but full verification still has a great impact on the system TPS.
  • a compromise is considered between security and TPS, and a verification group is formed from all application chain miners for block verification.
  • the verification group is a collection of application chain miners meeting preset rules. , Only the members of the verification team have the right to fully verify the new block and issue an inspection report. Other application chain miners simply collect the inspection report and make appropriate statistics based on the inspection report to reach the final verification conclusion (of course, the members of the verification team will also Collect inspection reports).
  • the number of application chain miners in the verification group can only account for a small part of the total number of application chain miners, such as 1/10. In this way, without considering the communication bottleneck between nodes, the TPS of the blockchain system can also be approximately increased. 10 times.
  • this disclosure can also add the parameter of the full-member verification flag.
  • This parameter can take at least two values (such as True and False), which respectively indicate that the full-member verification is adopted and the full-member verification is not adopted, and the full-member verification is not adopted. That is, to adopt the method of forming a verification group to verify. If the all-member verification mark indicates that all-member verification is adopted, each application chain miner will complete the verification of the block produced by the leader of the proposal group (the blockchain database is being rebuilt, except for miners who are in a state of catching up with the progress of the block).
  • the verification group refers to the collection of application chain miners who have the right to verify the blocks produced by the leader of the proposal group and generate inspection reports.
  • the block produced by the leader of the proposal group is actually the application chain to be mined block packaged by the leader of the proposal group.
  • the selection of the verification group members of the application chain to be mined blocks can be divided into at least one round.
  • the application chain miners synchronize to the base chain block information of the leader of the proposal group that determines the application chain to be mined blocks, they participate in the first P round The selection of verification group members. After that, the application chain miners will participate in a new round of selection of verification group members every time they synchronize with the information of a base chain block. If one of the following cycle termination conditions is met, the application chain miners will no longer participate in the new round of verification. Selection of group members:
  • the application chain miners have determined that they are selected as members of the verification team in the selection rounds they have participated in; second, the application chain miners can conclude that the block produced by the proposal group leader has passed the verification based on the currently received inspection report Third, the selection rounds that the miners of the application chain have participated in have reached the preset maximum round MaxRounds (MaxRounds is a positive integer).
  • the selection of members of the verification group can be regarded as driven by the block generation of the base chain.
  • Each block of the base chain (application chain miners will also correspond to the synchronization of the base chain block information) will carry out a round of verification group member selection, and each round of verification group In the selection of members, several verification group members may be selected. If multiple rounds of selection are carried out, the verification group members selected in each round are superimposed, that is, as the round grows, there will be more and more members in the verification group.
  • Application chain miners who are selected as members of the verification group in a certain round do not need to participate in the selection of verification group members in subsequent rounds (the above cycle termination condition 1), and the identity of the verification group members can always be retained.
  • the application chain miners will verify the block produced by the leader of the proposal group, issue an inspection report and broadcast it in the application chain. Each verification group member will only generate one inspection report. The reporting process will be explained later. While participating in the selection of members of the verification team, the application chain miners are also receiving inspection reports sent by the members of the verification team. If the block verification by the leader of the proposal group can be confirmed based on the collected inspection reports, they do not need to continue to participate in the election. Verify the members of the group (the above loop termination condition two).
  • an AppChain miner who has not been selected as a member of the verification group can judge the proposal based on the inspection report issued by the AppChain miner selected as a member of the verification group in the previous two rounds of selection. Whether the block produced by the group leader has been verified.
  • Allowing to be divided into multiple rounds of selection of members of the verification group is conducive to adaptively eliminating soft forks in the base chain and the application chain. The specific principles are explained later.
  • each application chain miner independently determines whether to be a member of the verification group according to a preset algorithm, and does not depend on other application chain miners.
  • the above-mentioned preset algorithm can use the verifiable random function VRF algorithm, which has been introduced in the previous section when introducing the selection of the proposal group members.
  • Application chain miners first call the proof function in the VRF algorithm to obtain the second provable word based on their own private key (corresponding to the PrivateKey in the VRF algorithm) and the second election string determined by the preset rules (corresponding to the info in the VRF algorithm) String (corresponding to the proof in the VRF algorithm). After that, the application chain miner derives the third random value using preset rules based on the second provable string, and determines whether the application chain miner is selected as the verification group member of the application chain to be mined according to the third random value.
  • the derivation rules are deterministic (but the specific rules are not limited), so for the same input, the derived third random value is also deterministic, and then the verification group members obtained on the basis of the third random value The results of the election are also deterministic.
  • the above-mentioned second election string is a known string, and its acquisition rule is determined.
  • the second election string is calculated based on the following information: the miner ID of the leader of the proposal group, the height of the base chain block that determines the leader of the proposal group (here refers to the actual height of the block in the base chain Rather than the base chain height specified in the mining request, the two heights are not necessarily the same due to the existence of the re-mining of the old block), the height of the block to be mined in the application chain, and the round number of the selection verification group member.
  • the election result for the block to be mined in the application chain in the base chain block information is in the original form (that is, it contains proposal candidate information), it will be based on the application chain identification, parallel chain chain number, and application chain miner public key in the election result.
  • Information calculates the first item of information, plus the second and third items of information obtained from the election results, and calculates the second election string in combination with the round numbers of the members of the current selection verification group; if the election result is in a simplified form, then The first and third items of information are obtained from the election results.
  • the second item of information is the height of the base chain block storing the election results, and the second election string is calculated in combination with the round numbers of the members of the current selection verification group.
  • the rounds for selecting verification group members can be numbered starting from 0 and increasing in the order of natural numbers. When application chain miners participate in different rounds of verification group member selection, the value of the number will also change accordingly.
  • each application chain miner can calculate its own verification group participation weight, and each application chain miner can determine whether he is an application chain based on the third random value and its own verification group participation weight.
  • the members of the verification group of the block to be mined are positively related to the value of the weight of the verification group.
  • the verification group participation weight of an application chain miner can be calculated based on the amount of digital currency currently held by the miner (provided that digital currency is to be issued on the application chain), and it is stipulated that if the application chain miner does not currently hold digital currency Currency, the verification group participation weight is 0.
  • a typical implementation method is: application chain miners' verification group participation weight priority2 is proportional to their currency stake, namely:
  • C is a normal number.
  • the relationship between priority2 and stake can also be other relationships if the foregoing requirements are met.
  • the application chain miners who hold more coins have a higher weight for the verification group to participate in the election, so the probability of being selected as a member of the verification group is also higher, because the more coins they hold, the more the miner and the application The closer the chain of interest is, the less likely it is to cheat.
  • the minimum currency holding parameter can also be preset on the application chain. If the current number of digital currencies held by the application chain miners is less than the preset minimum currency holdings, the application chain miners cannot participate in the verification group members Selection. Typically, application chain miners who do not hold digital currencies cannot participate in the selection of members of the proposal group. This can prevent the sybil attack of forging a large number of new accounts to participate in mining. Of course, in some alternative solutions, the minimum value of the preset verification group participation weight can also have a similar effect.
  • the application chain can also preset the parameter of the verification group’s maximum participation weight, that is, set an upper limit for the verification group’s participation weight. If the calculated verification group’s participation weight exceeds the upper limit (for example, the application Because chain miners hold a large amount of digital currency, the verification group participation weight is greater than the preset verification group maximum participation weight), then the verification group participation weight is set to the verification group maximum participation weight. Avoid a large number of application chain miners holding coins in the selection of members of the verification group to have too much advantage, depriving other application chain miners of the opportunity to be elected members of the verification group.
  • Application chain miners determine whether they are members of the verification group of the application chain block to be mined according to the third random value and their own verification group participation weights.
  • implementation methods There are also different implementation methods. In one implementation method, it can be implemented as follows:
  • RandValue3 is the third random value
  • ExpectedRange2 is the preset range value
  • priority2 is the weight of the verification group participation
  • % represents the remainder operation.
  • M2 is the preset filtering ratio.
  • RandValue4 and RandValue2 are basically the same, except that the preset parameter ExpectedRange2 can take different values from ExpectedRange1, and M2 can take different values from M1.
  • the selection process of verification group members is similar to the selection of proposal group members, and the basis for election is recorded in the base chain block (because only proposal group members will send mining requests, it is equivalent to recording Proposal group members), so it is not ruled out that in some implementations, all proposal group members are directly used as verification group members, and the step of selecting verification group members is skipped.
  • the selection of verification group members and the selection of proposal group members are implemented as independent of each other (that is, whether an application chain miner is a member of the verification group and whether it is a member of the proposal group has nothing to do with the following aspects:
  • each application chain miner independently confirms whether he is a member of the verification group, which is more secure than the centralized confirmation of verification group members (referring to directly confirming the proposal group members as members of the verification group in batches);
  • the selection of members of the verification group mentioned above can be divided into multiple rounds, which provides an adaptive mechanism to eliminate soft forks (see below);
  • third, the members of the proposal group are listed in the base chain block election basis list for prevention The adversary's cheating allows all base chain miners to perform verification, not for the convenience of electing members of the verification group.
  • an application chain miner confirms that he is a member of the verification group of the application chain to be mined in a certain round of selection, he can verify the block produced by the leader of the proposal group of the application chain to be mined.
  • the timing of the proposal group leader to package the application chain to be mined may be different: for example, in the first method, any application chain miner will pack it after confirming that he is elected as a member of the proposal group
  • the application chain to be mined blocks, but in the end only the application chain to be mined blocks packaged by the leader of the proposal group will be spread in the application chain and will be booked after verification.
  • the application chain miners can synchronize the base chain block information.
  • the members of the proposal group after the members of the proposal group have packaged the application chain to be mined blocks, they can also broadcast the application chain to be mined blocks to other application chain miners in a local area around it.
  • the local scope here can be defined as the local scope in the sense of message forwarding.
  • the members of the proposal group specify a preset number of forwarding times in the broadcast message of the block to be mined in the application chain, and the block to be mined in the application chain passes every time For forwarding, the number of forwarding in the broadcast message is reduced by 1, and the block to be mined in the application chain will be stopped when the number of forwarding is reduced to 0.
  • the local scope adopts other definition methods, such as the scope in the geographical sense, the scope in the network topology sense, and so on.
  • directional corrosion refers to a certain malicious behavior of an adversary against a certain or certain specific application chain miners.
  • a network attack such as a distributed denial of service DDoS attack
  • a network attack causes it to fail to work normally due to message congestion and other reasons, so that the application chain miner cannot produce blocks normally, which is beneficial to the adversary's further progress.
  • Cracking behavior another example, bribing an application chain miner, instructing them to keep accounts according to their own requirements, etc.
  • the base chain uses a public chain, has a large number of miners, and combines the block chain data of the base chain to determine how the members of the proposal group are selected (for details, please refer to the method of obtaining the first election string in the previous section) ), that is, combined with the computing power factor of the base chain, it is difficult for the adversary to control the value of the first election string according to their expectations, so that they cannot select specific application chain miners as members of the proposal group according to their wishes.
  • the membership of the proposal group will be exposed (for example, the adversary can deploy a specific application to listen to the mining request, or deploy a dedicated miner of his own on the base chain. Receive the request), so that the adversary can directionally corrode the members of the proposal group.
  • miners of the application chain are required to immediately package the block to be mined in the application chain and spread the block in a limited range (the reason is limited to a partial range, mainly to avoid excessive consumption. Multiple bandwidth resources).
  • each application chain miner may receive multiple application chain blocks to be mined at the same height, which are packaged and produced by different proposal group members, but the application chain miners can determine after synchronizing the base chain block information
  • the leader of the proposal group the application chain miner will only keep the application chain to-be-mined block packaged by the proposal group leader (if the application chain miner has cached the block locally) and broadcast the block to other application chain miners (this time is Full chain broadcast), discarding the application chain to be mined blocks packaged by others.
  • the leader of the proposal group When the leader of the proposal group broadcasts the block, it also attaches the proposal candidate information in the mining request sent by the leader of the proposal group to the block in the broadcast message for block verification, and the follow-up proposal group leader issues When the block is spread in the application chain, the proposal information is always attached.
  • Application chain miners who are selected as members of the verification group of the application chain to be mined block verify the block produced by the leader of the proposal group, including at least the following verification items:
  • the base chain block determines the first election string that the proposal group leader relies on when he is elected as a member of the proposal group. Then, call the verification function in the VRF algorithm based on the first provable string in the proposal candidate information, the application chain miner's public key in the proposal candidate information, and the first election string to verify the first provable word in the proposal candidate information Whether the string is forged, if it is not forged, the verification of this item is passed, if it is forged, the verification of this item is not passed.
  • the verification content of this item can refer to the verification process of the first provable string in the mining request by the base chain miners, which has been explained above.
  • the public key information that characterizes the identity of the block creator is stored in the block header (for example, it can be the public key itself, the hash value of the public key, etc.), and the verification group members apply the chain miner public key in the proposal candidate information
  • the corresponding public key information can also be obtained, and the two can be compared. If they are consistent, it can be confirmed that the application chain miner corresponding to the application chain miner’s public key in the proposal candidate information is the creator of the block produced by the leader of the proposal group. If the verification is passed, otherwise it can be confirmed that the miner of the application chain is not the creator of the block produced by the leader of the proposal group, and the verification is not passed.
  • the leader of the proposal group broadcasts the block
  • the corresponding proposal candidate information is attached to the broadcast message.
  • it can also be accompanied by a proposal group leader who uses his own private key to pair the outgoing area.
  • the signature of the block (for example, it can be the signature of the entire block, it can be the signature of the block header, it can be the signature of some fields in the block header, etc.).
  • the members of the verification group use the public key of the application chain miner in the proposal candidate information to verify whether the signature of the block produced by the leader of the proposal group carried in the broadcast message is correct.
  • the public key of the application chain miner in the proposal candidate information can be confirmed
  • the corresponding application chain miner is the creator of the block produced by the leader of the proposal group, and this verification is passed, otherwise it can be confirmed that the application chain miner is not the creator of the block produced by the leader of the proposal group, and this verification fails.
  • the above implementation of storing the public key information of the block creator in the block header does not exclude the replacement of the public key information with the creator's miner identification, and the proposal candidate information can also be used to calculate a miner identification for verification.
  • the leader of the proposal group is queried from the local base chain ledger of the verification group member (of course, it is used to query the proposal group as mentioned above. It is also possible to inquire in the table of the number of leader elections), and then verify whether the inquired leader of the proposal group is consistent with the leader of the proposal group determined by the proposal candidate information.
  • the identity of the leader of the proposal group can be represented by a public key or a miner ID. For those represented by public keys, this verification is implemented as follows:
  • the base chain block that determines the leader of the proposal group in the proposal candidate information
  • query the public key of the proposal group leader from the local base chain ledger at this time, the election results in the base chain ledger are in the original form
  • the miner ID of the proposal group leader is verified.
  • miner IDs of the calculated proposal group leaders are the same, if they are the same, confirm that the queried proposal group leader is consistent with the proposal group leader determined by the proposal candidate information, this item is verified, otherwise the two proposal group leaders are confirmed Inconsistent, this verification failed.
  • the specific verification content includes verifying whether there is a forged transaction, implementing double spending, etc. This verification is similar to the verification of transactions in the existing blockchain system, and will not be specifically explained.
  • the first verification can be derived from the first provable string in the proposal candidate information. Random value, and then calculate the second random value based on the first random value and the proposal group leader’s participation weight of the proposal group determined by the proposal candidate information (see the previous section for the specific formula), and finally verify whether the second random value is consistent with the elected proposal group leader People’s basic requirements, for example, whether they meet the minimum random value requirement, if they are met, the verification of this item is passed, otherwise the verification of this item is not passed.
  • the proposal candidate information can also include the second random value that the miners of the application chain rely on when they are selected as members of the proposal group.
  • the second random value is obtained, it is also possible to verify whether the derived second random value is the same as the second random value in the proposal candidate information.
  • the verification team members If the verification results of all the above verification items are passed, the verification team members generate the inspection report that the inspection conclusion is passed. Otherwise, the verification team members generate the inspection report that the inspection report is not passed. After the verification team members generate the inspection report, they are in the application chain Broadcast the inspection report.
  • P 3 when the application chain miner synchronizes to the base chain block information of the leader of the proposal group that determines the block to be mined in the application chain (assuming it corresponds to a block with a height of H on the base chain), they can participate in the first Round (the round number is 0), the second round, and the third round of the selection of members of the verification group (of course, if you confirm that you are a member of the verification group in the first round, you don’t have to participate in the subsequent rounds of selection), no need to wait for the original Used to indicate the start of the second and third rounds of the base chain block information selected by the members of the verification group (the base chain block information corresponding to the base chain block at the height of H+1, H+2).
  • the inspection report can be regarded as advance Broadcast out. Broadcasting the inspection report in advance is conducive to the full dissemination of mining requests on the base chain, and the specific reasons will be analyzed in step S107.
  • the block verification information can also include the proposal group participation weight, the first random value, and the first random value. 2. Information such as random values.
  • the members of the proposal group can also save evidence that they are elected as members of the proposal group in the first transaction of the block (also known as Coinbase) when packaging the block to be mined in the application chain, for example, The information items in the proposal candidate information, the proposal group participation weight, the first random value, the second random value, etc., are used as block verification information for others to verify in the future. If a member of the proposal group is finally selected as the leader, the packaged block will be broadcast, and the information in Coinbase will naturally be spread along with the block. The effect is similar to that of sending the information separately.
  • Step S107 The application chain miner receives the inspection report, and judges whether the block produced by the leader of the proposal group is verified according to the inspection report.
  • Step S108 If the application chain miner determines that the block produced by the leader of the proposal group is verified, the block is included in the application chain ledger.
  • the inspection report may include the following information items: the miner identification of the leader of the proposal group, the height of the base chain block that determines the leader of the proposal group, the height of the block to be mined in the application chain, and the selection of the members of the verification group
  • the round number the public key of the verification group member who generated the inspection report, the second provable string that the app chain miner relied on when they were elected as the verification group member, the hash value of the block to be mined in the app chain, the verification conclusion, and the use verification
  • the private key of the group member signs the inspection report.
  • the first four items are used by application chain miners to calculate the second election string when participating in the selection of verification group members, and are attached to the inspection report for others to verify.
  • the round number of the selection verification group member is the final confirmation of the application chain miners. It is the number of the selection round of the members of the verification group;
  • the hash value of the block to be mined in the application chain is used to uniquely identify an application chain block, and the application chain miner can use the hash value when statistically verifying the conclusion of the report in step S107 Distinguish the reports for different application chain blocks;
  • the inspection conclusions are the two conclusions of passing and failing, as described above; using the private key of the verification team member to sign the inspection report can refer to the inspection report except the signature itself The signature of other information is used to prevent the inspection report from being tampered with.
  • the verification items can include:
  • the public key of the proposal group leader from the local base chain ledger according to the height of the base chain block of the leader of the proposal group in the inspection report, and then obtain the application chain identification and parallel chain chain where the miner of the application chain is mining. (These two contents can be obtained by each application chain miner), based on these three pieces of information, the hash algorithm is used to calculate the miner ID of the proposal group leader, and then the calculated miner ID and inspection report of the proposal group leader are verified Whether the miner identifications of the proposal group leaders in are the same. If they are the same, confirm that the inquired proposal group leader is consistent with the proposal group leader determined in the inspection report. This verification is passed, otherwise it is confirmed that the two proposal group leaders are inconsistent. This verification failed.
  • the base chain block that determines the leader of the proposal group in the inspection report query the miner ID of the proposal group leader from the local base chain ledger, and then verify the miner ID of the proposed group leader and the inspection report. If the miners’ identifications of the leaders of the proposal group are the same, confirm that the queried leader of the proposal group is consistent with the leader of the proposal group determined in the inspection report. This item is verified. Otherwise, it is confirmed that the leaders of the two proposal groups are inconsistent. Item verification failed.
  • the height of the base chain block of the leader of the proposal group, the height of the block to be mined in the application chain, and the round number of the members of the verification group are selected based on the four pieces of information.
  • the second provable character string calls the verification function in the VRF algorithm to verify whether the second provable character string in the inspection report is forged. If it is not forged, the verification of this item is passed, otherwise the verification of this item is not passed.
  • the application chain miner can first derive the third random value, and then calculate the fourth random value based on the third random value and its own verification group participation weight (see above for the specific formula), and finally based on the fourth random value Verify whether the miner of the application chain who generated the inspection report is a member of the verification team.
  • the application chain miner shall recognize the validity of the inspection report and perform the following steps. Otherwise, the inspection report is deemed invalid and can be discarded.
  • the application chain miners collect the received inspection reports for the blocks produced by the leader of the proposal group to perform statistics and obtain the verification results, which can be implemented as follows:
  • the block produced by the leader of the proposal group is determined Verification passed.
  • the number of reports that passed the inspection conclusion is less than the minimum number of successful verifications, and the number of reports that the inspection conclusion is not passed is not greater than the maximum number of failed verifications, continue to wait for a new inspection report, unless waiting After a preset period of time (this period will be explained later), if the verification conclusion is that the number of reports passed is still less than the minimum number of successful verifications, it is determined that the block verification by the leader of the proposal group has not passed.
  • the number of reports whose inspection conclusions are not passed is greater than the maximum number of failed verifications, it is determined that the block verification by the leader of the proposal group has not passed.
  • the minimum number of successful verifications and the maximum number of failed verifications may be preset values, or may also be calculated based on the number of application chain miners selected as the leader of the proposal group in a preset time period combined with a certain ratio.
  • the minimum number of successful verifications represents the degree of recognition of the block by the members of the verification group, and the maximum number of failed verifications represents a tolerance range. It is also possible to set the maximum number of failed verifications to 0, but setting it to a non-zero value is mainly to prevent a small number of verification group members Evil (intentionally issuing a report that the inspection conclusion is not passed) causes the application chain to fail to produce blocks normally.
  • Application chain miners can judge whether they can draw a verification conclusion according to the above rules every time they receive an inspection report, or application chain miners can cache the received inspection reports first and make judgments at appropriate times (for example, regular judgments) .
  • application chain miners can prioritize the inspection reports of the earlier rounds according to the round numbers of the members of the selected verification group, so as to prevent the adversary from broadcasting the reports of later rounds in advance and affecting the verification results.
  • the application chain miners determine that the block produced by the leader of the proposal group is verified according to the inspection report, the block will be included in the application chain ledger, and the selection of proposal group members for the next application chain to be mined can be started. If the application chain miner determines that the block produced by the leader of the proposal group fails to pass the verification according to the inspection report, the block produced by the leader of the proposal group will be discarded. If the block has been included in the application chain ledger and other blocks have been connected later They are discarded together, and the selection of members of the proposal group for the block to be mined in the application chain is restarted. Among them, the block after the block produced by the leader of the abandonment proposal group corresponds to the situation where the conclusion of the verification is overturned, which will be explained in detail later.
  • the application chain miner statistical inspection report can be regarded as a statistical voting process, and the voters are members of the verification group.
  • a more general description of the process is as follows:
  • Application chain miners first determine the number of votes in the verification process of the received inspection report, and then make a judgment: if the inspection conclusion in the received inspection report is that the total number of votes in the report is not less than the minimum number of successful verifications, and , The total number of votes in the report whose inspection conclusion is that the failure is not greater than the maximum number of failed verifications, then the block verification by the leader of the proposal group is determined to be passed.
  • the inspection conclusion in the received inspection report is that the total number of votes in the report is not less than the minimum number of successful verifications, and , The total number of votes in the report whose inspection conclusion is that the failure is not greater than the maximum number of failed verifications, then the block verification by the leader of the proposal group is determined to be passed.
  • one inspection report can correspond to one vote, as described above.
  • the number of votes occupied by each inspection report can be set to be positively correlated with the amount of digital currency currently held by the verification group member that generated the inspection report.
  • the reason why the inspection report issued by the members of the verification team with more currency has a certain advantage is that the more members of the proposal team who hold the currency are more closely related to the interests of the application chain, the less likely it is to cheat.
  • the number of votes occupied by the inspection report during the verification process can be calculated using the following formula:
  • vote_num is the number of votes occupied by the inspection report
  • stake is the number of digital currencies currently held by the members of the verification group that generated the inspection report
  • the currency holdings are recorded in the application chain ledger, which can be queried by any application chain miner
  • leverage is The preset vote adjustment ratio.
  • the method of one inspection report for one vote is used as an example. If the number of copies of the inspection report is not consistent with the number of votes, the relevant content can be adjusted adaptively.
  • the application chain miners cannot accurately conclude whether the block will pass the verification before receiving enough inspection reports for the block, which leads to a verification conclusion It may take a long time.
  • the application chain miner finds that in the received inspection report, the proportion of the number of reports that the inspection conclusion is passed to the minimum number of successful verifications is no less than the preset verified proportion (of course, it must also meet The inspection conclusion is that the number of failed reports is not greater than the maximum number of failed verifications), then the selection of the proposal group members of the block to be mined in the next application chain and the packaging of the block will be started in advance.
  • the verified ratio can be 50%, 60%, and so on.
  • the verification conclusion of the application chain block is passed, so the proposal group members selected in advance are reliable in most cases, and the probability of subsequent withdrawal of the membership of the proposal group is not high.
  • the above-mentioned measures are conducive to improving verification and verification.
  • the parallelism of the proposal work further enhances the TPS of the blockchain system.
  • the members of the verification group can verify the block produced by the leader of the proposal group in advance and broadcast the inspection report. Each application chain miner will check according to these inspections. The report may know the verification result of the block several rounds in advance. If the verification conclusion is passed, the application chain miners can determine at which height the application chain should mine next time, so that they can participate in the proposal of the next application chain to be mined in advance. The selection of the group members, and then send the mining request for the next application chain to be mined block to the base chain miners in advance, so the mining request has more time to spread in the base chain, which is conducive to the base chain miners to select the proposal group leader.
  • the application chain miners can receive the inspection report in advance, and can draw the conclusion that the block verification by the leader of the proposal group has passed based on these inspection reports, they still have to wait for the inspection report to take effect before it can be executed. Include the block in the application chain ledger, and participate in the selection of the members of the proposal group for the next application chain to be mined. Among them, the inspection report takes effect after the application chain miners synchronize to the base chain block information corresponding to the report generation round, and the report generation round refers to the selection round in which the application chain miners who generated the inspection report are elected as members of the verification group.
  • application chain miners received in advance the inspection report sent by the application chain miners selected as members of the verification group in the second round of verification group members, and based on the report, it can be determined that the block verification by the leader of the proposal group has passed.
  • the subsequent steps cannot be executed immediately, and it is necessary to wait for the application chain miners to synchronize to the base chain block information originally used to indicate the start of the second round of verification group member selection.
  • the application chain miner can immediately give a conclusion that the block verification by the leader of the proposal group has passed, so there is still an advance in time, at most one base chain can be produced in advance. time.
  • the so-called advance verification essentially only improves the degree of parallelization between the verification group member selection and subsequent steps, and does not destroy the synchronization relationship between the base chain block generation and the verification group member selection.
  • the application chain miners may be informed of the verification conclusion of the block produced by the leader of the proposal group in advance, they have time to cheat, such as changing the height of the block to be mined in the application chain, but because of the blockchain
  • the consensus mechanism requires the approval of multiple miners to confirm the result. Therefore, even if the individual application chain mining is cheating, other honest miners do not collude with it, and the cheating behavior is futile: for example, individual dishonest miners change the height of the application chain to be mined, and Most honest miners do not carry out the next round of mining at this height, and the cheating behavior of dishonest miners ultimately fails due to insufficient votes.
  • the application chain miners wait at most for a preset time. If the inspection conclusion received during this period is that the number of reports passed is always less than the minimum number of successful verifications (Of course, if the number of failed verification reports received during this period is greater than the maximum number of failed verifications, the waiting process ends early), it can be determined that the block verification by the leader of the proposal group has failed.
  • the above-mentioned preset duration is MaxRounds+Q base chain block generation time (Q takes 0 or a positive integer).
  • Q takes 0 or a positive integer
  • the interval is the block time of a base chain.
  • the preset duration starts from the synchronization of the application chain miners to the base chain block information of the leader of the proposal group that determines the block to be mined in the application chain (this time is also the starting time for the first round of verification group member selection).
  • MaxRounds base chain block generation time allows application chain miners to participate in the selection of verification group members (up to MaxRounds round selection) and broadcast the generated inspection report after confirming that they are selected, and apply chain miners within the next Q base chain block generation time
  • you can no longer participate in the selection of members of the verification team you can continue to receive inspection reports and determine whether the block produced by the leader of the proposal team has been verified based on the statistical results of the inspection reports.
  • an application chain miner is selected as a member of the verification team before the MaxRounds round of selection, it will take longer to receive the inspection report.
  • the block produced by the leader of the proposal group will be discarded, and because the block has been recognized as verified before, the mining of the subsequent high-level application chain block has been started, and even the follow-up area
  • the block has been included in the application chain ledger. Therefore, if the block has been included in the application chain ledger and other blocks are connected in series afterwards, the following blocks should also be discarded together.
  • the application chain can be restarted. Selection of members of the proposal group for mining blocks. Of course, it is a rare case that the verification conclusions have been overturned. In most cases, the application chain miners can still maintain the previous verification conclusions after receiving the new inspection report, and will not cause the existing blocks to be frequently invalidated.
  • the application chain miners are allowed to wait for the inspection report for at most MaxRounds+Q base chain block generation time, it means that the application chain miners allow at most Q+1 consecutive high application chain blocks to be in the verification state.
  • the block is in the verification state during the period from the selection of the verification group members of the block until the final verification conclusion (referring to the conclusion that can no longer be overturned) is reached.
  • the base chain and the application chain keep generating blocks at the same frequency (see below for details on the same frequency for block generation), so when the verification waiting time is more than Q base chain block generation time, the application chain in the simultaneous verification state is allowed
  • the number of blocks is Q+1. In special cases, Q can be set to 0, which means that only one application chain block is allowed to be in the verification state.
  • the working state of the application chain miners in the mining process will switch between the proposal state and the verification state of the block to be mined.
  • a block reaches a verification conclusion (not necessarily If it is the final verification conclusion)
  • the application chain miner will immediately enter the proposal group construction work of the next block. It will confirm whether the proposal group leader has been selected for the next block based on the latest synchronized base chain block information, and then decide whether Continue to form a proposal group. If the leader of the proposal group has been selected in the next block, the next block will enter the verification state directly.
  • the next block will enter the proposal state, and the application chain miners will start to be It selects members of the proposal group, sends mining requests and other operations. If the application chain miner determines that the leader of the proposal group for a block to be mined has not been selected, it will try to rebuild every time the base chain is produced (corresponding to the application chain miner, it is synchronized to the base chain block information) Proposal group, until the leader of the proposal group of the block to be mined is selected or re-mining a block of an old height is successful.
  • the application chain can avoid directional corrosion by ensuring the number of miners participating in complete verification and improve the security of the blockchain system. For example, if the total number of miners in the application chain is small, the full verification method can be adopted. If the total number of miners in the application chain is large, a verification group can be formed from them, and the minimum number of successful verifications cannot be set too small (for example, you can take tens to several A hundred). When a sufficient number of application chain miners participate in the complete verification of the block, it is very difficult to conduct a comprehensive directional corrosion (the verification result of the block is obtained by statistics, and the directional corrosion of individual verifiers is of little significance).
  • the application chain should maintain basically the same block generation frequency as the base chain (referred to as the same frequency block generation), which is specifically expressed as the largest block of the application chain Gao Chang is in a state of fast catching up with the largest block height of the base chain, usually only a few blocks away, and the reason for maintaining the same frequency for block generation will be analyzed later.
  • the inventor found that if the application chain only produces blocks in a conventional manner, the frequency of block generation must be less than that of the base chain. The reason is:
  • the establishment of a proposal group or a verification group on the application chain may fail, causing the application chain miners to fail to produce blocks, which reduces the frequency of application chain blocks.
  • Both the proposal group and the verification group have certain requirements for the number of members. For example, there is a minimum number of miners for the number of members of the proposal group, and the minimum number of successful verifications also implies a requirement for the number of members of the verification group.
  • the members of the proposal group or the verification group are selected using the VRF algorithm, there is bound to be insufficient. Because the result of the VRF algorithm is random, it can only be guaranteed from the probability sense that the number of members selected meets expectations, but it is specific to a certain time. In the process of forming a proposal group or a verification group, the number of members selected may not meet the requirements.
  • the block may still need to be determined after a few base chain block generations. This also makes the block generation time of the application chain slower than that of the base chain.
  • the expected rounds that the application chain conducts when selecting members of the verification group are related to the design intent of the application chain. For example, if the application chain pays more attention to the full dissemination of messages (such as inspection reports, etc.) between nodes (the more the message dissemination, the more the adversary commits crimes) The more difficult it is), you can conduct more rounds of selection of members of the verification group (try to reduce the proportion of each round being selected).
  • the frequency of block production on the base chain is very certain, which mainly depends on the mining power on the base chain, and is usually not interfered by other factors.
  • a proposal group leader cannot be selected for a block to be mined on a certain application chain. This time, the election result of the block to be mined is not recorded in the base chain block. That is, the base chain block is not applied Block chain impact.
  • the application chain miner packs the block to be mined in the application chain (the application chain miner may pack it after confirming that he is a member of the proposal group, or may pack it after confirming that he is the leader of the proposal group, such as As mentioned above), it will determine whether the difference between the height of the base chain block of the leader of the proposal group and the height of the block to be mined in the application chain is greater than the preset first difference threshold.
  • the difference threshold is to continuously pack the application chain to be mined blocks and a preset number (at least one) of empty blocks. If the difference between the two heights is not greater than the first difference threshold, only the application chain to be mined blocks are packed. For example, suppose it is determined that the height of the base chain block of the leader of the proposal group is X, the height of the block to be mined in the application chain is Y, and the first difference threshold is 4, if XY>4, the application chain to be mined can be continuously packaged Block and an empty block.
  • the former is the normal block generation, and the preset number of empty blocks play a filling role.
  • the purpose is to increase the block height of the application chain, thereby increasing the application chain.
  • the frequency of block generation the empty block does not contain any transaction content.
  • a mark may be added to the block header of the block to be mined in the application chain to indicate that it is the first block in the continuous block.
  • the base chain miners pack the base chain blocks, they will determine the application chain to be mined based on the highest block of the application chain recorded in the base chain ledger and the leader of the proposal group has been selected.
  • the height of the block, and the mining request matching the height is selected from the cached mining requests to be included in the waiting set for the block to be mined in the application chain.
  • the base chain miners can determine the height of the base chain block of the leader of the proposal group to determine the application chain to be mined block (this height can be changed from for the application chain to be mined block Is directly extracted from the mining request of the set to be elected) and whether the difference between the height of the block to be mined in the application chain is greater than the preset first difference threshold. If the difference between the two heights is greater than the first difference threshold, it will be marked in The application chain mining union will continuously produce blocks at the height where the block to be mined is located.
  • base chain miners when base chain miners subsequently determine the maximum block height of the application chain (for example, when collecting mining requests for the next application chain to be mined for the proposal group leader election), they should consider applications marked with continuous block generation The height of the chain. At these heights, the height increase caused by each block of the application chain will be greater than 1. For example, if the application chain miner is allowed to connect two blocks at a time (one of which is an empty block), then the application marked with continuous block generation At the chain height, the height of the application chain will increase by 2 after one block is produced.
  • the application chain still cannot catch up with the block generation speed of the base chain, it means that some configuration parameters of the application chain may be poorly selected and need to be adjusted, such as the minimum random value of the election, the minimum number of successful verifications, and the maximum number of failed verifications. Improper setting of other parameters may result in too few members in the selected proposal group or verification group, making it difficult to generate blocks in the application chain.
  • a second difference threshold can be preset for each application chain (the second difference threshold is greater than the first difference threshold), if the base chain miner determines that the difference between the above two heights is greater than the second difference
  • the threshold indicates that the application chain has been unable to catch up with the base chain to produce blocks.
  • the base chain can refuse to continue to provide computing power support for the application chain.
  • the base chain miner determines that the difference between the above two heights is not greater than the second difference threshold, the application chain should be allowed to continue to catch up with the base chain by generating empty blocks.
  • the base chain usually starts operation earlier than the application chain. Therefore, when the base chain computing power is connected to the newly started application chain, the base chain may have been running for a period of time, as long as the application
  • the initial block height specified by the chain in the genesis block is connected with the current maximum block height of the base chain, and subsequent mining can proceed normally. That is, the first block of the application chain is usually not numbered from 0, but the numbering starts with the block height of the base chain at the time of connection, which is equivalent to the default that the application chain and the base chain are completely synchronized before this.
  • the application chain is driven by the base chain to produce blocks (for application chain miners through the synchronization of the base chain block information to perceive the base chain to produce blocks) to carry out proposals and verification operations, which is equivalent to the base chain providing a definite clock system for the application chain , May as well call it a clock source, and the timing of various operations performed by the application chain is based on this clock source.
  • the application chain uses the base chain as the clock source to avoid security problems caused by the application chain’s self-defining clock: distributed systems often lack a unified time standard and are easily attacked by the adversary.
  • the adversary can control the calculation of the time on the chain, for example, 1 hour is counted as 1 minute to allow time for decryption, targeted attacks, etc.
  • the first election string used by application chain miners when selecting members of the proposal group and the second election string used when selecting members of the verification group are also from the base chain, and the opponents are the same. It is difficult to manipulate.
  • These two strings can be called random sources (because the election is random).
  • Clock source and random source are the two cornerstones of application chain security, because the clock source and random source are both outside the application chain. System (ie base chain) provided.
  • the frequency of block generation should be consistent with that of the base chain as much as possible. Otherwise, the fluctuation amplitude of the generation time interval of every two adjacent blocks in the application chain will increase, which is not good for the smooth block generation of the application chain. .
  • the block generation time of the application chain block is taken as the time node related to the business process or the basis for calculating these time nodes. The fluctuation of the block generation time will directly affect the business time The accuracy of judgment.
  • the application chain can produce blocks at the same frequency as the base chain, the cumulative effect of block generation time deviation can be avoided (the average block generation time of the application chain after inserting empty blocks in the application chain will converge to the base chain).
  • the empty block should avoid interference with the timing logic of the application chain itself. For example, the process of empty block generation can be logically understood as occupying 0 hours. If the upper-level application of the application chain wants to use the block generation time of the application chain block, the time span between the empty block and the previous non-empty block should be regarded as 0 duration.
  • each miner independently decides when to produce a block. For example, in the Bitcoin system, a miner randomly collides with a hash value that meets the difficulty factor requirement, and the computing power competition wins. The miners then broadcast the whole chain of the new blocks they have packaged. This approach will inevitably lead to multiple miners packing blocks of the same height at the same time, that is, soft forks in the ledger are inevitable.
  • the existing public chain system generally eliminates soft forks through the longest chain mechanism, which involves the longest chain switching operation. For details, please refer to the prior art, which will not be elaborated here.
  • the soft fork will not make the public chain system inoperable, if it occurs frequently, the longest chain switching operation must be performed frequently, resulting in frequent rollbacks of accounted transactions, thereby affecting the robustness of the system. Therefore, it is necessary to suppress soft forks or weaken the impact of soft forks as much as possible.
  • the base chain inherits the above-mentioned soft fork characteristics in the existing public chain system (but it does not mean that the base chain must be a public chain), and also adopts the most used in the existing public chain system. Long chain mechanism to eliminate soft forks.
  • the application chain relies on the computing power support of the base chain, its soft fork has two sources: First, the autonomous mining behavior of the application chain miners will lead to a soft fork (the above-mentioned soft fork characteristics in the existing public chain system) ); Second, the soft fork that appears in the base chain must be mapped to the application chain, making the application chain form a soft fork, because the application chain miners need to synchronize the base chain block information from the base chain to form a local base chain ledger, which is different Application chain miners connect to the base chain at different locations, so that the soft forks that appear in the base chain are also synchronized separately, causing each application chain miner to only recognize the leader of the proposal group indicated in the base chain block information that it has synchronized to.
  • the application chain also follows the longest chain mechanism.
  • the soft forks caused by the above two reasons are also eliminated by the longest chain mechanism, and the longest chain switch caused by these two reasons may not necessarily point to the same longest chain of the application chain. This makes the longest chain switching process used to eliminate soft forks on the application chain more complicated, which will be explained in detail later.
  • the mining request of the application chain miners will be broadcast in the base chain, and each base chain miner will receive the mining request, and based on these mining requests, the same proposal group leader will be selected for the same height block of the application chain.
  • the probability is higher.
  • the proposal stage is more restrictive than the verification stage (for example, in a common implementation, new miners who have never participated in mining will also give them the first accounting weight to allow them to mine, while holding Miners whose currency is less than the minimum currency holdings are not allowed to participate in the selection of members of the verification group), which is also conducive to the convergence of the election results of the leaders of the proposal group. Therefore, regardless of whether the base chain has a soft fork, it has little effect on the results of the election of the leader of the proposal group.
  • the first election string used by the application chain when selecting the members of the proposal group of the block to be mined in the application chain is based on the first L area of the base chain block of the leader of the proposal group to determine the block to be mined in the application chain
  • the information in the block is basically fixed (especially when L takes a larger value, such as 6). Therefore, if the base chain has a soft fork after the source block of the first election string, the application chain also has a soft fork. For the block to be mined at a certain height after the application chain, regardless of whether the block is located in the application chain.
  • the value of the first election string obtained is likely to be the same, and the final proposal group leader is also likely to be the same, because the proposal group leader election algorithm on each base chain miner is the same. Only the arrival of mining requests is inconsistent and there is interference (if the mining requests received by the base chain miners are inconsistent, there is a certain probability that different proposal group leaders will be selected).
  • the second election string used when the application chain selects the members of the verification group is calculated based on the following information: the miner identification of the proposal group leader, and the proposal is determined.
  • the reason is that the two information of the miner identification of the leader of the proposal group and the height of the block to be mined in the application chain are determined during the selection of multiple rounds of verification group members, and the base chain is selecting the proposal group of the block to be mined in the application chain.
  • the subsequent soft fork of the leader does not affect the value of determining the height of the base chain block of the leader of the proposal group, and the subsequent soft fork of the application chain due to the soft fork of the base chain does not affect the selection verification The value of the round number of the group members.
  • the administrator of the application chain can also adjust the two parameters of the minimum number of successful verifications and the maximum number of failed verifications configured on the application chain. Increase the minimum number of successful verifications and reduce the maximum number of failed verifications, so that the conditions for passing verification will be reduced. It is more demanding, and it is more difficult for the block to pass verification, especially the block produced by the leader of the proposal group approved by only a few verification group members will not be able to pass the verification.
  • the block generation speed of the application chain will slow down.
  • the number of rounds for selecting verification group members will increase (only more verification group members are selected to pass verification), and verification is time-consuming It will become longer.
  • the application chain miners can only continue mining at the original height, and the application chain height will not increase. After the mining progress of the application chain slows down, the degree of soft forks already generated on the application chain will not continue to deepen, which is conducive to the convergence of the forks.
  • the block frequency of the base chain will not be affected, and the soft fork generated on the base chain will be quickly eliminated.
  • the application chain After the soft fork of the base chain is eliminated, the application chain will return to the state of normal mining (but at this time the soft fork on the application chain may not have been eliminated), the side effect is that there will be vacancies on the application chain for a period of time. There will be more blocks in order to recover the block height difference with the base chain.
  • the probability that the block in the candidate branch maintained by the application chain miner in the active area (the meaning is explained below) (hereinafter referred to as the active branch) will pass through several rounds of verification is relative to the application chain miner in the inactive area.
  • the block in the candidate branch (hereinafter referred to as the inactive branch) is higher.
  • the active area is a community composed of nodes with smooth communication in the blockchain system.
  • the nodes in the active area are often distributed and concentrated, the information between the nodes is synchronized in time, and the number of nodes also accounts for the majority of the system.
  • the soft bifurcation of the application chain is not caused by the soft bifurcation of the base chain, it can be analyzed similarly and will not be elaborated. The following continues to introduce the longest chain switching process on the application chain.
  • the soft fork of the application chain there are two factors that lead to the soft fork of the application chain, one is caused by the independent mining of miners in the chain, and the other is caused by the soft fork of the base chain.
  • Two types of longest chain switching rules are correspondingly set in the application chain to eliminate soft forks caused by these two factors.
  • the first longest chain switch is triggered by the block synchronization between miners in the application chain
  • the second longest chain switch uses the longest chain switch of the base chain to trigger the longest chain switch of the application chain.
  • the successful accounting of each block on the candidate branch of the application chain as the switch target is used as the switch end sign.
  • a miner receives a new block and causes the longest chain switch.
  • the newly received block can be just a block header or a complete block, but it is required that it cannot be forged at will, because the longest chain Switching involves a transaction rollback operation, and the processing process is relatively heavy. If a block is easily forged and the candidate branch is switched, the blockchain system will become very fragile. Take the Bitcoin system as an example. Bitcoin only needs the block header to drive the longest chain switch, because hash collisions are restricted by the difficulty of mining, and forging the block header is as difficult as forging the block body. In the practice of the blockchain, the block header and the block body are mostly distributed separately.
  • the application chain block uses the method of separate propagation of the block header and the block body in the application chain. Among them, the block header can be propagated first, and the block body is taken to adjacent nodes. How to ask for it. If the application chain block is spread in other ways, similar analysis can also be done.
  • the application chain miner incorporates the block header of a certain application chain block into the application chain ledger, if it is found that the attachment of the block header causes a certain application chain candidate branch to become the highest among all candidate branches. If it is long, it triggers the first longest chain switch, and the block body of the application chain block can be requested from other application chain miners later.
  • the second longest chain switch is triggered after the longest chain switch is generated in the local base chain ledger.
  • base chain block information there are several forms of base chain block information, but no matter which form, at least it includes the block header of the base chain block and the block body of the base chain block.
  • the proposal for the block to be mined in the application chain The election result of the group leader cannot only include the block header of the base chain block, because if the information of the leader of the proposal group is missing, the application chain miners cannot perform subsequent verification and mining operations.
  • the branch of the application chain for mining is switched to the longest chain of the application chain indicated by the longest chain of the base chain through the second longest chain switch (referred to as the application chain waiting Switch branches).
  • the longest chain of the base chain and the longest chain of the application chain may not be exactly the same (because there are behaviors such as re-digging old blocks)
  • the branch to be switched of the application chain at this time is not necessarily the block height In the sense, the application chain is the longest chain, but it does not affect the application chain miners to switch the longest chain under the instructions of the base chain.
  • interleaving refers to the execution of one of the types of the longest chain switch Execute another type of longest chain switch at the same time.
  • the two types of longest chain switch can only be executed in time sharing or if they are executed at the same time, one of them must be terminated.
  • the specific execution rules are:
  • the application chain miner executes the triggered second longest chain switch, if a new second longest chain switch is triggered, the application chain miner terminates the second longest chain that is being executed Switch, and start to execute the newly triggered second longest chain switch.
  • the leader of the determined proposal group indicated by the longest chain of the base chain Whether the highest height of the human application chain block (that is, the height of the branch to be switched in the second longest chain switch) is less than the height of the candidate branch of the application chain that includes the block header that triggers the first longest chain switch . If the previous height is smaller than the latter height, it indicates that the application chain candidate branch corresponding to the first longest chain switch is higher.
  • the application chain miner terminates the second longest chain switch that is being executed, and starts to execute the newly triggered one
  • the first and longest chain switch if not, the application chain miner does not respond to the newly triggered first and longest chain switch, and continues to execute the current second and longest chain switch.
  • the processing method can refer to the implementation in existing blockchain systems such as Bitcoin or Ethereum, which will not be elaborated here.
  • the application chain miners may find that the block header of one or more recent blocks on the branch to be switched on the application chain is missing (the application chain is in the branch to be switched when the first longest chain is switched Block headers will not be missing), these blocks with missing headers may be saved by other miners in the application chain and have not yet been transmitted. This is a temporary loss, because since the second longest chain is switched to the longest chain of the base chain. The block before the maximum height of the branch to be switched in the application chain indicated by the longest chain of the base chain must have been successfully produced. Otherwise, the application chain miners will not initiate a target download if the previous block is not successfully produced. For a mining request for a block, the base chain will not select a leader of the proposal group for it.
  • Temporary missing and true missing of application chain blocks need to be distinguished. Temporary missing can still be compensated by data synchronization between application chain miners; true missing is that although the base chain has selected the leader of the proposal group, there is no miner in the application chain Knowing that the leader of the proposal group has been elected, no miners produce blocks, or the application chain miners who have been elected leaders of the proposal group have produced blocks, but failed to propagate new blocks due to abnormal communication. In short, they cannot pass the application chain miners. Synchronously replenish the data between them. Both of these two kinds of defects can be effectively dealt with in the second heavy and longest chain switching scheme of the present disclosure.
  • the application chain miner performs the second longest chain switch.
  • the overall process is: first determine the last confirmed block on the branch of the application chain to be switched.
  • the confirmed block means that the block header has been received by the application chain miner.
  • the application chain miner has determined the verified block according to the received inspection report (the block body can be obtained from other application chain miners later).
  • the block header is in a state that can be written to the application chain ledger, as to whether it will be written
  • the entry book is related to realization.
  • the application chain miner starts from the block after the confirmed block, traverses the application chain to be switched branches in the forward direction (in the direction of block height increase), and incorporates the blocks on the application chain to be switched branches into the application during the traversal process In the chain ledger.
  • the above-mentioned second heavy and longest chain switching process can be operated according to the following steps. Note that the empty blocks on the application chain are not involved in the following operations, and these empty blocks can be skipped and not processed.
  • application chain miners start from the last block of the longest base chain in the local base chain ledger, traverse the longest chain of the base chain in the reverse direction (the direction of block height reduction), and analyze the leaders of each selected proposal group. Whether the person's block has been confirmed on the pending branch of the application chain, the first confirmed block found is the last confirmed block on the pending branch of the application chain.
  • the first selected proposal group indicated by the base chain after the last confirmed block The leader's block is determined as the first block to be determined, and the first block to be determined is confirmed within the block time of at most Z base chains. If the first block to be determined has not been confirmed by the application chain miners after waiting for at most Z base chain block time, the second longest chain switch will be terminated, and the selection of the proposal group members of the first block to be determined will be restarted.
  • Z is a positive integer.
  • Z can be MaxRounds+Q, otherwise Z can be a value not less than MaxRounds+Q; MaxRounds is recommended and verified by application chain miners
  • the maximum round of group members, Q is the number of heights of additional blocks allowed by the application chain miners to be in the verification state at the same time. The meaning of these two parameters has been introduced above.
  • the next block of the last confirmed block is determined as the next block to be mined in the application chain and the block is started Selection of members of the proposal group.
  • the application chain miner judges whether the leader of the proposal group of the first block to be determined is himself. If the leader of the proposal group for the first block to be determined is the application chain miner, it is further judged whether the application chain miner has packaged the pending first block. If the pending first block has been packaged, the packaged pending first block is reused. If the first block to be determined has not been packaged, the first block to be determined is packaged. Regardless of whether the first block to be determined has been packaged or not, the application chain miners should broadcast the pending first block to other application chain miners and begin to participate in the selection of the verification group members of the pending first block.
  • the application chain mining tool has a caching mechanism, and the recently packaged blocks will be cached.
  • the first block to be determined needs to be packaged, it indicates that the block is not in the local cache.
  • the application chain miner did not know that he was the proposal group leader before , So we need to do the rebuild operation of the new block (if the rebuild fails, the application chain miners will restart the mining at the height of the first block to be determined after the Z base chain block generation time comes, see the description of the third step below), This situation corresponds to the actual lack of blocks described above. If the leader of the proposal group for the first block to be determined is not the application chain miners themselves, they can directly start the selection of members of the verification group for the first block to be determined.
  • application chain miners monitor the verification progress of the first block to be determined. If the first block to be determined is included in the application chain ledger within the Z base chain block generation time since the application chain miners start to select the proposal group members of the first block to be determined, the first block after the first block to be determined will be instructed by the base chain The block in which the leader of the proposal group has been selected is determined as the next first block to be determined. If the first block to be determined is not included in the application chain ledger within the Z base chain block generation time since the application chain miners started to select the proposal group members of the first block to be determined, the second longest chain switch will be terminated and the second longest chain switch will be restarted. Selection of the members of the proposal group for the first block.
  • the definition of Z is the same as in the previous step.
  • the inclusion of the first block to be determined into the application chain ledger means that the entire block of the first block to be determined is written into the application chain ledger, not just the block header, which is different from block confirmation.
  • the purpose of monitoring the application chain miners is mainly to avoid the mining node where the selected proposal group leader is abnormally offline, or has been shut down and exited. If such an abnormal situation is not dealt with, the application chain will easily hang up. live.
  • the application chain miners determine whether the next pending first block has been confirmed (because a period of time has passed since the last confirmed block of the branch to be switched in the application chain has been processed, and the next pending first block It may have been confirmed), if the next pending first block has been confirmed, or if it has not been confirmed at present but it is confirmed after waiting for at most Z base chain block time, then try to include the next pending first block into the application chain
  • the specific method of the ledger is similar to the processing of the first block to be determined in the above steps, that is, the processing of the first block to be determined is a cyclic process, and the description will not be repeated. If the next pending first block has not been confirmed by the application chain miners after waiting for at most Z base chain block time, the second longest chain switch will be terminated, and the proposal group members of the next pending first block will be restarted Selection.
  • the application chain miner continues to traverse the pending branch of the application chain forward to find the subsequent pending first block, until the block on the pending branch of the application chain is included in the application chain ledger, ending the second longest chain switch. If a new second and longest chain switch is triggered during the execution of the second and longest chain switch, the application chain miner terminates the second and longest chain switch that is being executed, and uses the new longest chain of the base chain. Based on the longest chain of the indicated application chain, go back to the first step above to execute the newly triggered second longest chain switch.
  • application chain miners only perform verification operations based on the block content (including block header and block body) when they confirm that they are members of the verification group. If the block content is found to be lacking (There is only a block header but no block body, corresponding to the temporary loss of the block mentioned above) first ask for the corresponding block body from the neighboring node, verify the block body and broadcast the inspection report, otherwise verify the members of the team Waiting for status: Or, waiting for the inspection report issued by other verification team members, and quitting when a conclusion of passing or failing the verification is reached based on the received inspection report, or waiting for exceeding the preset time limit (For example, Z base chain block time) then exit dead and so on.
  • the preset time limit For example, Z base chain block time
  • the application chain miner scans the cache area and selects the inspection report that matches the block to be inspected (the block miner and the block height match) autonomously decide whether to adopt the corresponding block according to the established rules. It may even happen that the current candidate branch is switched to another branch, but switched back after a period of time, because the branch that was cut has returned to the longest chain of the application chain, which has been used in history.
  • the inspection report may be reused repeatedly.
  • the double longest chain switching involves both the soft fork and branch switching caused by the application chain itself encountering the longest chain, and the soft fork and branch switching of the application chain caused by the base chain encountering the longest chain switching.
  • Branch switching these two kinds of switching have interactive effects, and the processing process is more complicated.
  • the soft fork of the base chain may cause two (or more) results in the election of the leader of the proposal group of the block of the specified height of the application chain. After the election results are recorded in the base chain block and synchronized by the application chain miners, the application chain For the same block height, two (or more) miners may be elected as the leaders of the proposal group.
  • the proposal group leader of the application chain block at the first height in its local application chain ledger (that is, the application chain miner who created the block) is called the old proposal group leader, that is, the current proposal group leader
  • the leader of the known, highest-level application chain block proposal group is not a specific height in the application chain, but generally refers to a certain height in the application chain.
  • the leader of the proposal group corresponding to the application chain block there may be the following ways to obtain:
  • the application chain miner can also broadcast the proposal candidate information corresponding to the leader of the proposal group that created the block, or the proposal candidate information corresponding to the leader of the proposal group It may be recorded in the Coinbase of the block.
  • the proposal candidate information includes the public key of the leader of the proposal group, so that the application chain miner can learn the identity information of the block creator after receiving the broadcast block.
  • the application chain mining union synchronizes the base chain block information from the base chain, and the election results of the proposal group leader in the base chain block information, so that the application chain miners can also learn the identity information of the block creator.
  • two (or more) blocks related to the same election on different branches may choose two (or more) different proposal group leaders for the same application chain with the same height block people.
  • the reason is probably due to poor communication.
  • the set of mining requests sent by miners in the application chain is not exactly the same for each miner node of the base chain. That is, some nodes of the base chain may miss messages. .
  • let’s take the example of two proposal group leaders selected by the base chain as the block of the application chain at the first height.
  • the two proposal group leaders, and the application chain miners who have already known their identities are called the old proposal group leaders.
  • the person, as mentioned above, who has not yet known his identity is called the leader of the new proposal group.
  • Application chain miners can learn through different channels that there are new proposal group leaders who are different from the old proposal group leaders for the first-level application chain block. For example, according to what has been mentioned above, when an application chain miner receives the first-highest application chain block broadcast by other application chain miners, it will be based on the proposal candidate information recorded in the block or the proposal that is broadcast with the block. Candidate information can determine that there is a new proposal group leader who is different from the old proposal group leader for the first-level application chain block. For another example, the application chain miner can also determine that there is a new proposal group leader different from the old proposal group leader for the first-level application chain block based on the synchronized base chain block information.
  • the application chain miner when the application chain miner receives the block created by the leader of the new proposal group, it can also verify whether the leader of the new proposal group is truly a member of the proposal group of the application chain block at the highest level. If not, Then the application chain block created by it will be ignored, and subsequent steps such as comparing priority will not be carried out.
  • the application chain mining union judges whether the priority of the new proposal group leader is higher than the priority of the old proposal group leader. If the priority of the new proposal group leader is higher than the priority of the old proposal group leader, it will proceed.
  • "Longest chain switch” that is, the application chain block of the first height created by the leader of the old proposal group on the current main branch of the application chain ledger is switched to the first height application created by the leader of the new proposal group
  • the first-highest application chain block created by the leader of the old proposal group was changed to be a block in a non-master branch.
  • the priority of the leader of the new proposal group is not higher than the priority of the leader of the old proposal group, the first-highest application chain block created by the leader of the new proposal group can be ignored, and the current main branch remains unchanged.
  • the application chain miners can continue to broadcast the first-highest application chain block created by the leader of the new proposal group to other application chain miners.
  • the first-highest application chain block created by the new proposal group leader may have just been received from other application chain miners (for example, new The leader of the proposal group originally confirmed it when the new block was received), or it may have been received before (for example, before the application chain miner synchronizes the base chain block information and confirms the existence of the new proposal group leader, the new proposal group leader People have already created and broadcast the block). In the latter case, you only need to find the first-highest application chain block created by the leader of the new proposal group from the locally cached application chain block.
  • the main branch switch triggered by the leader of the proposal group redetermined does not require that the soft fork that is newly cut into the main branch must be on the longest chain in the sense of block height, that is, the main branch after the switch.
  • the branch may not be the longest chain in the sense of block height, but for the convenience of description, this switch can still be called the "longest chain switch".
  • the longest chain switch is triggered by receiving a new block to form the longest chain on a non-master branch, the master branch after the switch must become the longest chain known to the current node.
  • the calculation of the second random value needs to rely on information, for example, the first provable string, the weight of the proposal group participation, etc. are attached to the broadcast message or directly recorded in the Coinbase of the block. Or, in some solutions, if the second random value is already carried in the Coinbase of the broadcast message or block, it can also be used directly without re-deriving it.
  • the second random value corresponding to the new proposal leader is greater than the second random value corresponding to the old proposal leader. If the second random value corresponding to the new proposal leader is greater than the second random value corresponding to the old proposal leader, then Determine that the priority of the leader of the new proposal group is higher than the priority of the leader of the old proposal group; otherwise, determine that the priority of the leader of the new proposal group is not higher than the priority of the leader of the old proposal group.
  • the second random value of the two are exactly the same, or it can be considered that the priority of the leader of the new proposal group is not higher than the priority of the leader of the old proposal group, it is the final priority comparison result (the “most Long chain switching”), or the priority of the two can be further compared through additional distinguishing information (for example, the public key of the miner corresponding to the leader of the proposal group).
  • the above-mentioned first height is also limited, and the application chain block of the first height cannot be a block too early, otherwise the stability of mining may be affected.
  • the difference between the first height and the maximum block height in the application chain ledger should be less than the preset height difference (for example, it can be 6).
  • the application chain miner performs the "longest chain switch"
  • it will further drive the tail of the newly switched terminal branch in the main branch (blocks with a height greater than the first height) to synchronize with adjacent miner nodes, including , Broadcast the blocks in the stub branch that you already own to neighboring miner nodes, and ask neighboring miner nodes for the data of subsequent blocks in the new stub branch.
  • the ledger can be compressed.
  • the following is an example of the compression of the base chain ledger stored locally by the base chain miners:
  • the base chain block can be stored as follows:
  • Blocks generated during the last D difficulty adjustment cycles of the base chain save the block header and the complete block body; blocks generated before the last D difficulty adjustment cycles of the base chain save the block header and elections in the block body
  • the result list does not save the election basis list.
  • D takes a positive integer, for example, the most recent D difficulty adjustment cycles may correspond to the most recent ten days, one or two months, etc.
  • the entries in the election result list are in a simplified form (only the miner identification of the leader of the proposal group), the candidate information of the proposal generated by the leader of the proposal group in the election basis list should also be saved (if the entries in the election result list are not included) In the simplified form, the required proposal candidate information is already included).
  • the base chain miners can first include it in the base chain ledger, and regularly clean the base chain ledger, that is, remove the election basis list in the block. Realize ledger compression.
  • the first election string can be obtained by using the item of the height of the base chain block of the leader of the proposal group in the proposal candidate information, and then based on the application chain miner’s public key and the first provable string in the proposal candidate information.
  • the item information and the obtained first election string call the verification function of the VRF algorithm to confirm that the first provable string is not forged.
  • the above-mentioned method can be used to confirm that the first provable string in the proposal candidate information is not forged; then, the proposal candidate needs to be confirmed according to the application chain miner public key in the proposal candidate information
  • the leader of the proposal group identified by the information is the block producer of the application chain block to be verified.
  • the block producer’s public key information can be stored in the block header of the application chain block, and the public key information obtained from the application chain miner can be confirmed
  • the public key information should be consistent with the public key information stored in the block header.
  • the first provable string can be further used to derive the first random value and the second random value ( See the above for the specific formula), and finally verify whether the second random value meets the conditions for being elected members of the proposal group and whether it meets the basic requirements of the elected proposal group leader.
  • the second random value is already included in the implementation of the proposal candidate information, and the application chain miners are eager to catch up with the block height when rebuilding the ledger, they can also directly use the second random value in the proposal candidate information for verification. Then derive it based on the first provable string.
  • the application chain miners do not directly run the consensus algorithm to compete for the block right, but send a mining request to the base chain miners after determining that they are members of the proposal group .
  • the base chain miners elect the leader of the proposal group through calculations and record the election results and election basis in the base chain block, and then the application chain miners can obtain the information of the proposal group leader by synchronizing the base chain block information, and then Participate in the selection of the members of the verification group, and judge whether the block has passed verification by collecting the verification reports made by the members of the verification group on the block produced by the leader of the proposal group. If the verification is passed, the account will be kept.
  • the base chain miners are responsible for the election of the proposal group leader.
  • the application chain miners elect the proposal group leader by themselves.
  • the election process still depends on the base chain. Synchronized information.
  • miners in these application chains can use the "random source" provided by the base chain to determine blocks of any height by the proposal group Which one of the members assumes the leadership role.
  • the so-called miner group within a certain range means that the list of proposal group members is fixed (can be pre-configured in the program), for example, proposal group members can be senior members of the application chain, board members, etc., depending on user needs Depends.
  • the concept of "random source” has already been introduced in the previous section.
  • the "random source” in this solution can include the first election string determined by preset rules. The content of the first election string is random and is based on the first election.
  • String, application chain miners can dynamically elect a proposal group leader from a certain range of proposal group members.
  • the first election string is still recorded as info, and the members of the proposal group are numbered from 0 to N-1.
  • the application chain miner can calculate the number of a proposal group member by calculating the value of info%N, that is, The number of the miner who is the leader of the proposal group, where N is the total number of members of the proposal group, and% represents the remainder operation.
  • info%N The number of the miner who is the leader of the proposal group, where N is the total number of members of the proposal group, and% represents the remainder operation.
  • the leader packs the application chain to be mined and submits it in this application chain, and the application chain subsequently forms a verification group to carry out verification and other operations similar to those introduced in the previous article, and will not be repeated.
  • the blockchain accounting method provided by the embodiments of this application actually provides a new mechanism for the base chain and the application chain to participate in mining.
  • One base chain can gather mining machine resources and provide computing power for many application chains. Service, assist the application chain to complete the mining process, which can effectively improve the waste of mining machine resources in the existing blockchain system, and has good social benefits.
  • the base chain and the application chain can be either a single chain or a parallel chain, and the block chain system composed of the base chain and the application chain can also be nested, which is very flexible.
  • the above first introduces the working principle of the base chain and the blockchain for joint mining, and then analyzes the difficult issues involved in the same frequency block, soft fork and longest chain, and ledger compression. Corresponding solutions have been developed to improve the joint mining mechanism.
  • Scenario 1 For the newly developed blockchain system, it will inevitably encounter the natural contradiction between growth and security. When the new system was launched, due to the lack of mining machine resources, the pooled computing power was insufficient and easy to be attacked. Real cases have confirmed this. There are already several blockchain systems from the Bitcoin hard fork. The premeditated computing power attack failed. The more insecure the blockchain system is, the harder it is to win the trust of the public, and the less people use it. The less people use it, the less mining machines participate, and the blockchain system tends to be more insecure. The entire system will fall into a vicious circle.
  • the base chain can provide sufficient mining machine resources for the newly developed blockchain system to ensure its safe and stable operation, which is conducive to the popularization of blockchain technology in various industries .
  • Scenario 2 In many blockchain systems, mining machines are not only used for mining, but also provide specific public services based on business specifics: for example, mining machines based on Proof of Capacity (PoC) will store hard disk storage capacity As computing power, computing power itself is a storage service; another example is a blockchain system that implements mining based on a Trusted Execution Environment (TEE), which can open TEE encryption, decryption, signature, and verification capabilities. Come out and provide security services to the outside world.
  • TEE Trusted Execution Environment
  • the base chain can provide sufficient mining machine resources for these blockchain systems to ensure the reliability of the services provided.
  • the application chain determines the random source that the proposal group and the verification group rely on is provided by the off-chain system (ie the base chain), and the leader of the proposal group is changed to the off-chain system ( That is, the base chain) is implemented, and the off-chain system (ie, the base chain) provides a clock source for the mining process of the application chain.
  • the current industry alliance chains generally use the Byzantine consensus algorithm, which limits the number of nodes participating in voting, and requires all nodes to establish connections before voting within a clear number range (for example, the number of nodes in a typical alliance chain Usually limited to about 100, all nodes that make up the alliance chain belong to the proposal group and the verification group, and the proposal group and the verification group are not dynamically formed).
  • the solution of the present disclosure improves on this, and realizes the dynamic selection mechanism of the proposal group and the verification group in the application chain.
  • the scope of the proposal group or the verification group is determined with the help of the VRF algorithm.
  • the random number (referring to the info in the VRF algorithm) is purely taken as the input of the VRF algorithm in the application chain, and the time factor involved in the process of forming a proposal group or verification group is only used in the application chain (for example, reporting from each node) Time is averaged, etc.) to determine, the security strength is not enough.
  • a random source and a clock source should be provided outside the application chain, which are provided by the base chain in the solution of the present disclosure.
  • FIG. 3 shows a functional module diagram of the blockchain accounting device 200 provided by the present disclosure.
  • the blockchain accounting device 200 includes:
  • the proposal group selection module 210 is used for application chain miners to participate in the selection of proposal group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miners are selected as the proposal group members of the application chain to be mined, then The base chain miner sends a mining request for the block to be mined in the application chain, and the proposal group is a collection of application chain miners who have the right to send the mining request;
  • the block information synchronization module 220 is used for the application chain miners to synchronize the base chain block information, and to incorporate the base chain block information into the local base chain ledger.
  • the base chain block information comes from the base chain miners
  • the base chain block of the leader of the proposal group that determines the block to be mined in the application chain is generated according to the mining request, and the base chain block information includes an election result indicating the leader of the proposal group; wherein, The leader of the proposal group is a member of the proposal group who has the right to produce blocks of the application chain to be mined;
  • the verification group selection module 230 is used for the application chain miners to participate in the selection of the verification group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miners are selected as the verification group of the application chain to be mined blocks Members, verify the blocks produced by the leader of the proposal group, and broadcast inspection reports to other application chain miners.
  • the verification group is a collection of application chain miners who have the right to generate inspection reports.
  • the proposal group leader The block produced includes the block to be mined in the application chain packaged by the leader of the proposal group;
  • the application chain accounting module 240 is used for the application chain miners to receive the inspection report, and if it is determined according to the inspection report that the block produced by the proposal group leader is verified, then the block is included in the application chain ledger .
  • FIG. 4 shows a functional module diagram of the blockchain accounting device 300 provided by the present disclosure.
  • the blockchain accounting device 300 includes:
  • the election module 310 is used for base chain miners to elect the leader of the proposal group for the application chain to be mined block according to the mining request sent by the proposal group members of the application chain to be mined block;
  • the base chain accounting module 320 is used for the base chain miners to incorporate the base chain block storing the election results and the election basis into the base chain ledger.
  • FIG. 5 shows a functional module diagram of the blockchain accounting device 400 provided by the present disclosure.
  • the blockchain accounting device 400 includes:
  • the information receiving module 410 is used for the synchronization node to receive the base chain block sent by the base chain miner to determine the proposal group leader of the application chain to be mined block, or to receive the base chain miner or other set in the base chain
  • the block header of the base chain block and the election result list in the block body of the base chain block sent by the synchronization node wherein, each entry in the election result list corresponds to an application chain
  • the election result of the leader of the proposal group of the block to be mined including the election result of the leader of the proposal group of the block to be mined in the application chain;
  • the information sending module 420 is used for the synchronization node to send the base chain block information derived from the base chain block to the application chain miners, and the form of the base chain block information includes one of the following: the base chain The block itself; the block header of the base chain block and the list of election results in the block body of the base chain block; the block header of the base chain block and the block body of the base chain block Fragment data for the application chain in the application chain; wherein the fragment data includes the election result of the leader of the proposal group for the block to be mined in the application chain in the election result list, and the election result and the The merkle path between merkle roots calculated based on the election result list in the block header of the base chain block.
  • Fig. 6 shows a schematic diagram of a blockchain node provided by the present disclosure.
  • the blockchain node 500 includes a processor 510, a memory 520, and a communication interface 530. These components are interconnected and communicate with each other through a communication bus 540 and/or other forms of connection mechanisms (not shown).
  • the memory 520 includes one or more (only one is shown in the figure), which may be, but not limited to, random access memory (Random Access Memory, RAM for short), Read Only Memory (ROM for short) , Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electric Erasable Programmable Read-Only Memory , EEPROM for short) and so on.
  • RAM Random Access Memory
  • ROM Read Only Memory
  • PROM Programmable Read-Only Memory
  • EPROM Erasable Programmable Read-Only Memory
  • EEPROM Electrical Erasable Programmable Read-Only Memory
  • the processor 510 and other possible components can access the memory 520, read and/or write data therein.
  • the processor 510 includes one or more (only one is shown in the figure), which may be an integrated circuit chip with signal processing capability.
  • the aforementioned processor 510 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a micro controller unit (Micro Controller Unit, MCU for short), a network processor (Network Processor, NP for short), or other conventional processing It can also be a dedicated processor, including Digital Signal Processor (DSP), Application Specific Integrated Circuits (ASIC), Field Programmable Gate Array (FPGA) Or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuits
  • FPGA Field Programmable Gate Array
  • the communication interface 530 includes one or more (only one is shown in the figure), which can be used to directly or indirectly communicate with other devices to exchange data.
  • the communication interface 530 can be an Ethernet interface; it can be a high-speed network interface (such as an Infiniband network); it can be a mobile communication network interface, such as a 3G, 4G, and 5G network interface; it can be a variety of bus interfaces, such as USB, CAN , I2C, SPI and other bus interfaces; it can also be other types of interfaces with data transceiver functions.
  • One or more computer program instructions can be stored in the memory 520, and the processor 510 can read and run these computer program instructions to implement the blockchain accounting method provided by the present disclosure and other desired functions.
  • the structure shown in FIG. 6 is only for illustration, and the blockchain node 500 may also include more or less components than those shown in FIG. 6, or have a different configuration from that shown in FIG. 6.
  • Each component shown in FIG. 6 can be implemented by hardware, software, or a combination thereof.
  • the blockchain node 500 when implemented by hardware, can be a personal computer, mobile phone, tablet computer, server, embedded device, dedicated hardware device for the blockchain system, etc.; when implemented by software, the blockchain node 500 can be a virtual machine, container, etc.
  • the blockchain node 500 is not limited to a single device, and may also be a combination of multiple devices or a cluster composed of a large number of devices.
  • the mining nodes on the base chain, the synchronization nodes on the base chain, the management nodes on the base chain, and the mining nodes on the application chain can all be implemented using the structure of the blockchain node 500 described above. And run their respective functions.
  • the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored.
  • the computer program instructions When the computer program instructions are read and run by a processor of the computer, the blockchain record provided by the present disclosure is executed. Accounting method.
  • the computer-readable storage medium may be implemented as the memory 520 in the blockchain node 500 in FIG. 6.
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation.
  • multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • the functional modules in the various embodiments of the present disclosure may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
  • the present disclosure provides a blockchain accounting method, device, node and storage medium.
  • the application chain miners do not directly run the consensus algorithm to compete for the right to produce blocks, but send a mining request to the base chain miners after determining that they are members of the proposal group, and the base chain miners elect the proposal group through calculation
  • the leader records the election results and the basis of the election in the base chain block, and then the application chain miners can obtain the information of the proposal group leader by synchronizing the base chain block information, and then participate in the selection of the verification group members, and pass the collection verification Group members judge whether the block passes the verification according to the inspection report issued by the leader of the proposal group, and if it passes the verification, the account will be kept.
  • this disclosure proposes a new mechanism for the base chain and the application chain to participate in mining.
  • a base chain can gather mining machine resources, provide computing power services for many application chains, and assist the application chain to complete mining. Process, which can effectively improve the waste of mining machine resources in the existing blockchain system, and has good social benefits.
  • the base chain can provide sufficient mining machine resources for the blockchain system to ensure the safe and stable operation of the newly developed blockchain system, and to ensure that the mining machines in the blockchain system can be externally Provide reliable specific services.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

A blockchain accounting method and apparatus, a node and a storage medium. The blockchain accounting method comprises: an application chain miner participating in the election of proposal group members of a block to be mined, and if the application chain miner is elected as a proposal group member, sending a mining request to base chain miners; the application chain miner synchronizing base chain block information, and including same in a local base chain ledger, wherein the base chain block information comprises a result of the base chain miners electing a proposal group leader according to the mining request; the application chain miner participating in the election of verification group members of the block to be mined, and if the application chain miner is elected as a verification group member, verifying a block provided by the proposal group leader and broadcasting a check report; and the application chain miner receiving the check report, and if it is determined, according to the check report, that the block provided by the proposal group leader passes the verification, including the block in an application chain ledger. In the method, a mechanism of a base chain and an application chain jointly participating in mining is proposed, which is conducive to solving the problem of a waste of mining machine resources.

Description

一种区块链记账方法、装置、节点及存储介质Block chain accounting method, device, node and storage medium
相关申请的交叉引用Cross-references to related applications
本公开要求于2019年12月31日提交的、申请号为201911410444.1、发明名称为“一种区块链记账方法、装置、节点及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。This disclosure claims the priority of a Chinese patent application filed on December 31, 2019 with an application number of 201911410444.1, and the title of the invention is "a blockchain accounting method, device, node, and storage medium", the entire content of which is approved Reference is incorporated in this disclosure.
技术领域Technical field
本公开涉及区块链技术领域,特别是涉及一种区块链记账方法、装置、节点及存储介质。The present disclosure relates to the field of blockchain technology, in particular to a blockchain accounting method, device, node, and storage medium.
背景技术Background technique
当前业界以比特币为首的区块链公有链,普遍存在双重浪费的现象:第一重浪费是采用工作量证明(Proofof Work,简称PoW)算法,PoW算法中大量无意义的计算导致挖矿过程过于消耗电力资源,这一问题可以通过改进区块链的共识算法来解决;第二重浪费是稀缺的矿机资源只服务于单一的区块链系统,矿机的挖矿能力未能得到充分的利用。例如,在现有的比特币系统中,有百万台级别的矿机参与挖矿,每台矿机的价值可能高达数万人民币,然而受限于系统实现,目前仅能保障约每秒7笔的交易能力。对于如何改善第二重资源浪费,目前尚未有人提出有价值的解决方案。At present, the public blockchains led by Bitcoin in the industry generally have double waste: the first waste is the use of Proof of Work (PoW) algorithm, and a large number of meaningless calculations in the PoW algorithm lead to the mining process Excessive consumption of power resources, this problem can be solved by improving the consensus algorithm of the blockchain; the second waste is that the scarce mining machine resources only serve a single blockchain system, and the mining capacity of the mining machine has not been fully obtained. The use of. For example, in the existing Bitcoin system, there are millions of mining machines participating in mining, and the value of each mining machine may be as high as tens of thousands of RMB. However, due to the system implementation, it can only guarantee about 7 per second. The transaction capacity of the pen. As to how to improve the second waste of resources, no one has yet proposed a valuable solution.
发明内容Summary of the invention
本公开的目的在于提供一种区块链记账方法、装置、节点及存储介质,以改善上述技术问题。The purpose of the present disclosure is to provide a blockchain accounting method, device, node and storage medium to improve the above technical problems.
为实现上述目的,本公开提供如下技术方案:In order to achieve the above objectives, the present disclosure provides the following technical solutions:
第一方面,本公开提供一种区块链记账方法,应用于应用链矿工,所述方法包括:参与应用链待挖区块的提案组成员的推选;其中,若确定所述应用链矿工被推选为应用链待挖区块的提案组成员,则向基链矿工发送针对所述应用链待挖区块的挖矿请求,所述提案组为有权发送挖矿请求的应用链矿工的集合;同步基链区块信息,并将所述基链区块信息纳入本地的基链账本中,所述基链区块信息来源于基链矿工根据所述挖矿请求生成的确定所述应用链待挖区块的提案组领导人的基链区块,所述基链区块信息中包括指示所述提案组领导人的选举结果;其中,所述提案组领导人为具有所述应用链待挖区块的出块权的提案组成员;参与应用链待挖区块的验证组成员的推选;其中,若确定所述应用链矿工被推选为所述应用链待挖区块的验证组成员,则对所述提案组领导人所出区块进行验证,并向其他应用链矿工广播检验报告,所述验证组为有权生成检验报告的应用链矿工的集合,所述提案组领导人所出区块包括所述提案组领导人打包的所述应用链待挖区块;接收所述检验报告,若根据所述检验报告确定所述提案组领导人所出区块验证通过,则将该区块纳入应用链账本中。In the first aspect, the present disclosure provides a blockchain accounting method, which is applied to application chain miners, the method includes: participating in the selection of proposal group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miner Members of the proposal group who are elected as the block to be mined in the application chain will send a mining request for the block to be mined in the application chain to the base chain miners, and the proposal group is for the application chain miners who have the right to send mining requests Collection; Synchronize the base chain block information, and incorporate the base chain block information into the local base chain ledger, the base chain block information is derived from the application generated by the base chain miner according to the mining request The base chain block of the leader of the proposal group of the chain to be mined, the base chain block information includes the election result indicating the leader of the proposal group; wherein, the leader of the proposal group has the application chain waiting Member of the proposal group for the right to mine the block; participate in the selection of the verification group member of the block to be mined in the application chain; wherein, if it is determined that the application chain miner is selected as the verification group member of the application chain to be mined block , Verify the block produced by the leader of the proposal group, and broadcast the inspection report to other application chain miners. The verification group is a collection of application chain miners who have the right to generate inspection reports. The output block includes the application chain to-be-mined block packaged by the leader of the proposal group; the inspection report is received, and if it is determined according to the inspection report that the block generated by the leader of the proposal group is verified, the The block is included in the application chain ledger.
第二方面,本公开提供一种区块链记账方法,应用于基链矿工,所述方法包括:根据应用链待挖区块的提案组成员发送的针对所述应用链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人;将保存有选举结果以及选举依据的基链区块纳入基链账本中。In a second aspect, the present disclosure provides a blockchain accounting method, which is applied to base chain miners, and the method includes: according to a proposal sent by a member of the application chain to be mined block for the application chain to be mined block The mining request is to elect the leader of the proposal group for the block to be mined in the application chain; the base chain block storing the election results and the basis for the election is included in the base chain ledger.
根据对上述两方面方法的描述,应用链矿工并不直接运行共识算法竞争出块权,而是在确定自身为提案组成员后向基链矿工发送挖矿请求,由基链矿工通过计算选举出提案组领导人(即具有出块权的应用链矿工)并将选举结果及选举依据记录在基链区块中,随后应用链矿工通过同步基链区块信息即可获知提案组领导人的信息,进而参与验证组成员的推选,并通过收集验证组成员针对提案组领导人所出区块出具的检验报告判断区块是否通过验证,若通过验证就进行记账。不难看出,上述两方面提供的区块链记账方法实际上提出了一套由基链和应用链共同参与挖矿的全新机制,即可由一条基链汇集矿机资源(体现为上述基链矿工),为众多应用链提供算力服务,协助应用链完成挖矿过程,从而可以有效改善现有区块链系统中矿机资源的浪费问题, 具有良好的社会效益。According to the description of the above two methods, the application chain miners do not directly run the consensus algorithm to compete for the right to produce blocks, but send a mining request to the base chain miners after determining that they are members of the proposal group, and the base chain miners are elected by calculation The leader of the proposal group (that is, the application chain miner who has the right to produce blocks) records the election results and election basis in the base chain block, and then the application chain miner can obtain the information of the proposal group leader by synchronizing the base chain block information , And then participate in the selection of the members of the verification group, and judge whether the block passes the verification by collecting the verification report issued by the members of the verification group for the block produced by the leader of the proposal group, and if it passes the verification, the account will be kept. It is not difficult to see that the blockchain accounting methods provided by the above two aspects actually propose a set of new mechanisms in which the base chain and the application chain participate in mining. Miners), provide computing power services for many application chains, and assist application chains to complete the mining process, which can effectively improve the waste of mining machine resources in the existing blockchain system and has good social benefits.
另一方面,对于新发展的区块链系统,由于缺乏矿机资源的支持,容易遭到攻击,若为这样的区块链系统设计专有的共识算法,虽然可以改善其安全性,但势必导致矿机缺乏通用性难以得到市场认可,最终还是无法解决新生系统的困境。若利用上述两方面提供的区块链记账方法,可由基链为新发展的区块链系统提供充足的矿机资源,保障其安全、稳定运行。On the other hand, the newly developed blockchain system is vulnerable to attacks due to the lack of support from mining machine resources. If a proprietary consensus algorithm is designed for such a blockchain system, although its security can be improved, it is bound to As a result, the mining machine lacks versatility and is difficult to be recognized by the market, and ultimately cannot solve the dilemma of the new system. If the blockchain accounting method provided by the above two aspects is used, the base chain can provide sufficient mining machine resources for the newly developed blockchain system to ensure its safe and stable operation.
此外,在很多区块链系统中,矿机不只用于挖矿,还可用于对外提供特定服务,同样需要足够数量的矿机才能够确保分布式服务的稳定运行。若利用上述两方面提供的区块链记账方法,可由基链为这些区块链系统提供充足的矿机资源,保障其提供服务的可靠性。In addition, in many blockchain systems, mining machines are not only used for mining, but can also be used to provide specific services to the outside world. It also requires a sufficient number of mining machines to ensure the stable operation of distributed services. If the blockchain accounting methods provided by the above two aspects are used, the base chain can provide sufficient mining machine resources for these blockchain systems to ensure the reliability of their services.
第三方面,本公开提供一种区块链记账方法,应用于基链中设置的同步节点,所述方法包括:接收基链矿工发送的确定应用链待挖区块的提案组领导人的基链区块,或者,接收所述基链矿工或基链中设置的其他同步节点发送的所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;其中,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的提案组领导人的选举结果,包括所述应用链待挖区块的提案组领导人的选举结果;向应用链矿工发送来源于所述基链区块的基链区块信息,所述基链区块信息采用的形式包括以下之一:所述基链区块本身;所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;所述基链区块的区块头以及所述基链区块的区块体中针对所述应用链的片断数据;其中,所述片断数据包括所述选举结果列表中针对所述应用链待挖区块的提案组领导人的选举结果,以及,所述选举结果与所述基链区块的区块头中基于所述选举结果列表计算出的merkle根之间的merkle路径。In the third aspect, the present disclosure provides a blockchain accounting method, which is applied to a synchronization node set in the base chain, and the method includes: receiving a proposal group leader who determines the block to be mined in the application chain sent by the base chain miner Base chain block, or receiving the block header of the base chain block and the election result list in the block body of the base chain block sent by the base chain miner or other synchronization nodes set in the base chain; Wherein, each entry in the election result list corresponds to the election result of the leader of the proposal group of a block to be mined on an application chain, including the election result of the leader of the proposal group of the block to be mined in the application chain ; Send the base chain block information derived from the base chain block to the application chain miner, the form of the base chain block information includes one of the following: the base chain block itself; the base chain block The block header of the base chain block and the election result list in the block body of the base chain block; the block header of the base chain block and the fragment data for the application chain in the block body of the base chain block; Wherein, the fragment data includes the election result of the leader of the proposal group for the block to be mined in the application chain in the election result list, and the election result and the block header of the base chain block are based on all the results. The merkle path between the merkle roots calculated from the election result list.
在第三方面提供的方法中,基链上可以设置同步节点,同步节点用于从基链矿工或其他同步节点处同步包含提案组领导人选举结果在内的区块数据,应用链矿工则可以进一步从同步节点处同步基链区块信息用于出块及验证。基链区块信息可以是完整的基链区块,也可以适当简化,只保留基链区块中应用链矿工所需部分,以减少数据同步过程中的带宽占用。In the method provided by the third aspect, a synchronization node can be set on the base chain, and the synchronization node is used to synchronize block data including the results of the leader election of the proposal group from the base chain miners or other synchronization nodes, and the application chain miners can The base chain block information is further synchronized from the synchronization node for block generation and verification. The base chain block information can be a complete base chain block, or it can be simplified appropriately, and only the part required by the application chain miners in the base chain block is retained to reduce the bandwidth occupation during the data synchronization process.
允许在一些方案中多个应用链矿工共享一个同步节点,也允许在一些方案中部分应用链矿工不直接从同步节点同步基链区块信息,而是从其他应用链矿工处同步。此外,在某些方案中,基链也可以不设置独立的同步节点,应用链矿工直接从基链矿工处同步数据,这些方案亦可视为基链矿工部分或全部地实现了同步节点的功能。In some scenarios, multiple application chain miners are allowed to share a synchronization node, and in some scenarios, some application chain miners do not directly synchronize base chain block information from the synchronization node, but synchronize from other application chain miners. In addition, in some schemes, the base chain does not need to set up independent synchronization nodes, and the application chain miners directly synchronize data from the base chain miners. These schemes can also be regarded as the base chain miners partially or fully implementing the function of the synchronization node. .
第四方面,本公开提供一种区块链记账装置,配置于应用链中设置的挖矿节点,所述装置包括:提案组推选模块,用于应用链矿工参与应用链待挖区块的提案组成员的推选;其中,若确定所述应用链矿工被推选为应用链待挖区块的提案组成员,则向基链矿工发送针对所述应用链待挖区块的挖矿请求,所述提案组为有权发送挖矿请求的应用链矿工的集合;区块信息同步模块,用于所述应用链矿工同步基链区块信息,并将所述基链区块信息纳入本地的基链账本中,所述基链区块信息来源于基链矿工根据所述挖矿请求生成的确定所述应用链待挖区块的提案组领导人的基链区块,所述基链区块信息中包括指示所述提案组领导人的选举结果;其中,所述提案组领导人为具有所述应用链待挖区块的出块权的提案组成员;验证组推选模块,用于所述应用链矿工参与应用链待挖区块的验证组成员的推选;其中,若确定所述应用链矿工被推选为所述应用链待挖区块的验证组成员,则对所述提案组领导人所出区块进行验证,并向其他应用链矿工广播检验报告,所述验证组为有权生成检验报告的应用链矿工的集合,所述提案组领导人所出区块包括所述提案组领导人打包的所述应用链待挖区块;应用链记账模块,用于所述应用链矿工接收所述检验报告,若根据所述检验报告确定所述提案组领导人所出区块验证通过,则将该区块纳入应用链账本中。In a fourth aspect, the present disclosure provides a blockchain accounting device, which is configured on a mining node set in the application chain, and the device includes: a proposal group selection module for application chain miners to participate in the application chain to be mined blocks Selection of proposal group members; wherein, if it is determined that the application chain miner is selected as the proposal group member of the application chain to be mined block, then a mining request for the application chain to be mined block is sent to the base chain miner, so The proposal group is a collection of application chain miners who have the right to send mining requests; the block information synchronization module is used for the application chain miners to synchronize the base chain block information and incorporate the base chain block information into the local base chain. In the chain ledger, the base chain block information comes from the base chain block generated by the base chain miner according to the mining request to determine the proposal group leader of the application chain to be mined. The base chain block The information includes an election result indicating the leader of the proposal group; wherein, the leader of the proposal group is a member of the proposal group who has the right to produce blocks of the application chain to be mined; the verification group selection module is used for the application Chain miners participate in the selection of members of the verification group for the application chain to be mined; wherein, if it is determined that the application chain miner is selected as the verification group member of the application chain to be mined, the leader of the proposal group A block is generated for verification, and an inspection report is broadcast to other application chain miners. The verification group is a collection of application chain miners who have the right to generate inspection reports. The block produced by the proposal group leader includes the proposal group leader The packaged application chain block to be mined; the application chain accounting module, which is used by the application chain miner to receive the inspection report, and if it is determined according to the inspection report that the block produced by the leader of the proposal group has passed the verification, Then the block is included in the application chain ledger.
第五方面,本公开提供一种区块链记账装置,配置于基链中设置的挖矿节点,所述装置包括:选举模块,用于基链矿工根据应用链待挖区块的提案组成员发送的针对所述应用链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人;基链记账模块,用于所述基链矿工将保存有选举结果以及选举依据的基链区块纳入基链账本中。In a fifth aspect, the present disclosure provides a block chain accounting device, which is configured on a mining node set in the base chain, and the device includes: an election module for the base chain miners according to the proposal group of the block to be mined in the application chain The mining request sent by the member for the application chain to be mined block is the election proposal group leader of the application chain to be mined block; the base chain accounting module is used for the base chain miners to save the election results and The base chain block on which the election is based is included in the base chain ledger.
第六方面,本公开提供一种区块链记账装置,配置于基链中设置的同步节点,所述装置包括:信息接收模块,用于所述同步节点接收基链矿工发送的确定应用链待挖区块的提案组领导人的基链区块,或者,接收所述基链矿工或基链中设置的其他同步节点发送的所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;其中,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的提案组领导人的选举结果,包括所述应用链待挖区块的提案组领导人的选举结果;信息发送模块,用于所述同步节点向应用链矿工发送来源于所述基链区块的基链区块信息,所述基链区块信息采用的形式包括以下之一:所述基链区块本身;所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;所述基链区块的区块头以及所述基链区块的区块体中针对所述应用链的片断数据;其中,所述片断数据包括所述选举结果列表中针对所述应用链待挖区块的提案组领导人的选举结果,以及,所述选举结果与所述基链区块的区块头中基于所述选举结果列表计算出的merkle根之间的merkle路径。In a sixth aspect, the present disclosure provides a blockchain accounting device, which is configured on a synchronization node set in a base chain, and the device includes: an information receiving module for the synchronization node to receive a certain application chain sent by a base chain miner The base chain block of the leader of the proposal group of the block to be mined, or receiving the block header of the base chain block and the base chain block sent by the base chain miner or other synchronization nodes set in the base chain The election result list in the block body of the election result list; wherein, each entry in the election result list corresponds to the election result of the leader of the proposal group of a block to be mined on an application chain, including the application chain to be mined The result of the election of the leader of the proposal group of the block; an information sending module for the synchronization node to send the base chain block information derived from the base chain block to the application chain miners, and the base chain block information uses The form includes one of the following: the base chain block itself; the block header of the base chain block and the election result list in the block body of the base chain block; the block header of the base chain block and Fragment data for the application chain in the block body of the base chain block; wherein, the fragment data includes the election result of the leader of the proposal group for the block to be mined of the application chain in the election result list And, the merkle path between the election result and the merkle root calculated based on the election result list in the block header of the base chain block.
第七方面,本公开提供一种区块链节点,设置在应用链上,所述节点包括:存储器以及处理器,所述存储器中存储有计算机程序指令,所述计算机程序指令被所述处理器读取并运行时,执行第一方面或第一方面的任意一种可能的实现方式提供的方法。In a seventh aspect, the present disclosure provides a blockchain node, which is set on an application chain, the node includes: a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are executed by the processor. When reading and running, execute the method provided by the first aspect or any one of the possible implementations of the first aspect.
第八方面,本公开提供一种区块链节点,设置在基链上,所述节点包括:存储器以及处理器,所述存储器中存储有计算机程序指令,所述计算机程序指令被所述处理器读取并运行时,执行第二方面或第二方面的任意一种可能的实现方式提供的方法。In an eighth aspect, the present disclosure provides a blockchain node, which is set on a base chain. The node includes a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are executed by the processor. When reading and running, execute the method provided by the second aspect or any one of the possible implementations of the second aspect.
第九方面,本公开提供一种区块链节点,设置在基链上,所述节点包括:存储器以及处理器,所述存储器中存储有计算机程序指令,所述计算机程序指令被所述处理器读取并运行时,执行第三方面或第三方面的任意一种可能的实现方式提供的方法。In a ninth aspect, the present disclosure provides a blockchain node, which is set on a base chain, the node includes: a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are executed by the processor. When reading and running, execute the method provided by the third aspect or any one of the possible implementations of the third aspect.
第十方面,本公开提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序指令,所述计算机程序指令被处理器读取并运行时,执行第一方面、第二方面、第三方面或以上三方面的任意一种可能的实现方式提供的方法。In a tenth aspect, the present disclosure provides a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are read and run by a processor, the first aspect and the second aspect are executed. Aspect, the third aspect, or the method provided by any one of the above three aspects.
附图说明Description of the drawings
为了更清楚地说明本公开的技术方案,下面将对本公开中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the present disclosure more clearly, the following will briefly introduce the accompanying drawings that need to be used in the present disclosure. It should be understood that the following drawings only show certain embodiments of the present disclosure, and therefore should not be viewed. The work is to limit the scope. For those of ordinary skill in the art, without creative work, other related drawings can be obtained from these drawings.
图1示出了本公开提供的一种区块链系统的结构图;Figure 1 shows a structural diagram of a blockchain system provided by the present disclosure;
图2示出了本公开提供的一种区块链记账方法的流程图;Figure 2 shows a flowchart of a blockchain accounting method provided by the present disclosure;
图3示出了本公开提供的第一种区块链记账装置的功能模块图;Figure 3 shows a functional module diagram of the first blockchain accounting device provided by the present disclosure;
图4示出了本公开提供的第二种区块链记账装置的功能模块图;Figure 4 shows a functional module diagram of the second blockchain accounting device provided by the present disclosure;
图5示出了本公开提供的第三种区块链记账装置的功能模块图;Figure 5 shows the functional module diagram of the third blockchain accounting device provided by the present disclosure;
图6示出了本公开提供的一种区块链节点的结构图。Fig. 6 shows a structural diagram of a blockchain node provided by the present disclosure.
具体实施方式Detailed ways
下面将结合本公开中的附图,对本公开实施例中的技术方案进行描述。应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。The technical solutions in the embodiments of the present disclosure will be described below in conjunction with the drawings in the present disclosure. It should be noted that similar reference numerals and letters indicate similar items in the following figures. Therefore, once a certain item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
需要指出,在本公开的描述中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be pointed out that in the description of the present disclosure, the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements , But also includes other elements that are not explicitly listed, or elements inherent to the process, method, article, or equipment. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, article, or equipment that includes the element.
同时,术语“第一”、“第二”等仅用于将一个实体或者操作与另一个实体或操作区分开来,而不能理解为指示或暗示相对重要性,也不能理解为要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。At the same time, the terms "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and cannot be understood as indicating or implying relative importance, nor as requiring or implying these. There is any such actual relationship or sequence between entities or operations.
本公开提供的区块链记账方法旨在构建一套由基链和应用链共同参与挖矿的全 新机制:可由一条基链汇集矿机资源(体现为基链矿工),为众多应用链提供算力服务,协助应用链矿工完成挖矿过程,其目的主要是为了改善现有区块链系统(如比特币系统)中矿机资源浪费的问题;另外,应用链确定提案组及验证组所依赖的随机源由链外系统(即基链)参与提供,提案组成员选举领导人改在链外系统(即基链)实施,并由链外系统(即基链)为应用链挖矿过程提供时钟源,这些措施有助于强化应用链的安全性,关于提案组、验证组、随机源和时钟源等概念的含义具体见后文阐述。The blockchain accounting method provided in this disclosure aims to build a new mechanism in which the base chain and the application chain participate in mining: a base chain can gather mining machine resources (embodied as base chain miners) to provide many application chains Computing power services, assisting application chain miners to complete the mining process, the main purpose is to improve the problem of mining machine resource waste in existing blockchain systems (such as the Bitcoin system); in addition, the application chain determines the proposal group and verification group The random source of dependence is provided by the off-chain system (i.e. the base chain). The leader of the proposal group members is changed to the off-chain system (i.e. the base chain), and the off-chain system (i.e. the base chain) is the application chain mining process. Provide a clock source. These measures help to strengthen the security of the application chain. The meaning of the concepts of proposal group, verification group, random source and clock source will be explained later.
图1示出了本公开提供的一种区块链系统的结构图。参照图1,该区块链系统中包含两种区块链,分别是基链和应用链,在一个典型的场景中,基链为一条,而应用链为一条或多条,即允许基链同时为多条应用链提供算力服务,从而充分调度基链中矿机的算力。当然,基链为每条应用链提供算力的过程是类似的,因此在后文中主要针对一条应用链的情况阐述共同挖矿的流程,图1中也仅示出了一条应用链。需要指出,在本公开中提到基链这一概念时,一般应理解为抽象意义上的区块链,不单单指代基链的分布式账本,还应包括构成基链的节点以及节点实现的功能,但也不排除在后文中某些不致混淆的位置将基链的分布式账本简称为基链;对于应用链这一概念,也应当作类似理解。Fig. 1 shows a structural diagram of a blockchain system provided by the present disclosure. Referring to Figure 1, the blockchain system contains two kinds of blockchains, namely the base chain and the application chain. In a typical scenario, there is one base chain and one or more application chains, which means that the base chain is allowed At the same time, it provides computing power services for multiple application chains, so as to fully dispatch the computing power of the mining machines in the base chain. Of course, the process of providing computing power for each application chain by the base chain is similar, so in the following, the process of co-mining is mainly described in the case of one application chain. Figure 1 also shows only one application chain. It should be pointed out that when the concept of base chain is mentioned in this disclosure, it should generally be understood as a block chain in an abstract sense. It not only refers to the distributed ledger of the base chain, but also includes the nodes that constitute the base chain and the implementation of nodes. However, it does not rule out that the distributed ledger of the base chain is referred to as the base chain in some non-confusing positions in the following text; the concept of application chain should also be understood similarly.
进一步参照图1,应用链至少应包括挖矿节点,应用链的挖矿节点上部署应用链矿工(例如,可以是一个应用程序),通过应用链矿工的挖矿行为实现挖矿节点的功能,在后文中为简单起见,一般不再专门区分应用链的挖矿节点和应用链矿工这两个概念,而认为二者是一体的。图1中示出了4个应用链矿工:应用链矿工A、应用链矿工B、应用链矿工C以及应用链矿工D。在本公开的方案中,应用链矿工在挖矿时并不直接在本地运行共识算法竞争记账权,而是将竞争记账权的任务转交给基链处理,应用链矿工只需从基链同步竞争记账权的结果,并依据该结果进行出块以及验证工作。With further reference to Figure 1, the application chain should include at least mining nodes. The application chain miners (for example, an application) are deployed on the mining nodes of the application chain, and the functions of the mining nodes are realized through the mining behavior of the application chain miners. In the following text, for the sake of simplicity, generally no longer specifically distinguish the two concepts of application chain mining nodes and application chain miners, but consider the two as one. Figure 1 shows four application chain miners: application chain miner A, application chain miner B, application chain miner C, and application chain miner D. In the solution of this disclosure, the application chain miners do not directly run the consensus algorithm locally to compete for the accounting right when mining, but transfer the task of competing for the accounting right to the base chain for processing, and the application chain miners only need to start from the base chain. Synchronize the result of competing for accounting rights, and perform block generation and verification work based on the result.
基链至少应包括挖矿节点,基链的挖矿节点上部署基链矿工,通过基链矿工的挖矿行为实现挖矿节点的功能,在后文中为简单起见,一般也不再专门区分基链的挖矿节点和基链矿工这两个概念,而认为二者是一体的。图1中示出了两个基链矿工:基链矿工A和基链矿工B。应用链矿工在挖矿时,以发送挖矿请求的方式通知基链矿工为其确定记账权获得者,基链矿工根据挖矿请求确定出具有记账权的应用链矿工后,将结果保存在基链区块中。The base chain should include at least mining nodes. The base chain miners are deployed on the base chain mining nodes, and the functions of the mining nodes are realized through the mining behavior of the base chain miners. The two concepts of chain mining nodes and base chain miners are considered to be one. Figure 1 shows two base chain miners: base chain miner A and base chain miner B. During mining, application chain miners send mining requests to inform the base chain miners to determine the holder of the accounting rights for them. After the base chain miners determine the application chain miners with accounting rights according to the mining request, the results are saved In the base chain block.
应用链矿工要获知竞争记账权的结果,在一些实现方式中,可以直接从基链矿工处同步相关数据(该数据可以为基链区块或者其简化形式),例如图1中应用链矿工D直接从基链矿工B处同步数据。在另一些实现方式中,基链中还可以设置专门的同步节点,应用链矿工可以从同步节点处同步相关数据,而同步节点的数据则同步自基链矿工或者其他同步节点。图1中示出了两个同步节点:同步节点A和同步节点B,其中同步节点A的数据同步自同步节点B,而同步节点B的数据则同步自基链矿工A,应用链矿工A和应用链矿工B都可以从同步节点B处同步相关数据,从而获知竞争记账权的结果。对于直接从基链矿工处同步相关数据的实现方式,也可以认为基链矿工同时实现了同步节点的部分或全部的功能。Application chain miners need to know the results of competing accounting rights. In some implementations, relevant data can be directly synchronized from the base chain miners (the data can be a base chain block or its simplified form), for example, the application chain miner in Figure 1 D synchronizes data directly from base chain miner B. In other implementations, a dedicated synchronization node can also be set in the base chain, and application chain miners can synchronize related data from the synchronization node, and the data of the synchronization node is synchronized from the base chain miner or other synchronization nodes. Figure 1 shows two synchronization nodes: synchronization node A and synchronization node B. The data of synchronization node A is synchronized from synchronization node B, and the data of synchronization node B is synchronized from base chain miner A, application chain miner A and Application chain miners B can synchronize relevant data from the synchronization node B, so as to know the result of the competition for accounting rights. For the implementation of synchronizing related data directly from the base chain miners, it can also be considered that the base chain miners have realized part or all of the functions of the synchronization node at the same time.
基链区块中除了记录应用链竞争记账权的结果外,还可以包含其他内容,这些内容对于应用链来说可能并没有什么价值。因此,在可选的方案中,基链矿工保有的基链区块为原始数据,同步节点从基链矿工处同步数据时可以对原始数据作一定的简化,应用链矿工从同步节点处同步数据时还有可能对数据作进一步简化,尽可能减少数据在传输过程中占用的网络带宽,提高区块链系统的运行效率。In addition to recording the results of the application chain's competition for accounting rights, the base chain block can also contain other content, which may not be of much value to the application chain. Therefore, in the optional scheme, the base chain block held by the base chain miner is the original data. When the synchronization node synchronizes the data from the base chain miner, the original data can be simplified to a certain extent. The application chain miner synchronizes the data from the synchronization node. From time to time, it is possible to further simplify the data, minimize the network bandwidth occupied by the data during the transmission process, and improve the operating efficiency of the blockchain system.
在一些常见的实现方式中,针对每个应用链矿工,都为其在基链中设置一个专属的同步节点。同步节点可以和应用链挖矿节点实现为相互独立的节点,为加快数据同步速度,同步节点和应用链挖矿节点还可以部署在同一局域网内;同步节点也可以和应用链挖矿节点实现为同一节点,此时应用链矿工的功能和同步节点的功能可以分别由该节点上的两个应用程序承担,甚至于合并到一个应用程序中实现。In some common implementations, a dedicated synchronization node is set in the base chain for each application chain miner. The synchronization node and the application chain mining node can be implemented as independent nodes. To speed up data synchronization, the synchronization node and the application chain mining node can also be deployed in the same local area network; the synchronization node can also be implemented as the application chain mining node At the same node, the function of the application chain miner and the function of the synchronization node can be undertaken by two applications on the node respectively, or even merged into one application.
在另一些实现方式中,若不存在信任问题,多个应用链矿工亦可以共享一个同步节点,例如图1中的应用链矿工A和应用链矿工B就共享了同步节点B,很可能应用链矿工A和应用链矿工B本来就归属于同一机构,相互之间可以信赖,进行同步 节点的共享是合理的。此外,还允许应用链矿工不从基链矿工或同步节点处同步数据,而是从其他应用链矿工处同步数据,例如图1中的应用链矿工C就是从应用链矿工B处同步数据的,比如应用链矿工C和应用链矿工B归属于同一机构,应用链矿工C可以信任应用链矿工B的数据,这样的实现方式是完全合理的。In other implementations, if there is no trust issue, multiple application chain miners can also share a synchronization node. For example, the application chain miner A and application chain miner B in Figure 1 share the synchronization node B, and it is very likely that the application chain Miner A and application chain miner B originally belong to the same organization and can be trusted with each other. It is reasonable to share synchronization nodes. In addition, application chain miners are allowed not to synchronize data from base chain miners or synchronization nodes, but to synchronize data from other application chain miners. For example, application chain miner C in Figure 1 synchronizes data from application chain miner B. For example, application chain miner C and application chain miner B belong to the same organization, and application chain miner C can trust application chain miner B's data. Such an implementation method is completely reasonable.
如上所述,在本公开的方案中,同步节点主要起中介作用,用于应用链矿工从基链矿工处同步竞争记账权的结果,至于应用链矿工在挖矿时向基链矿工发送的挖矿请求是否要通过同步节点中转,则不作限定。在一些实现方式中,同步节点也有可能参与基链挖矿,此时基链矿工的功能和同步节点的功能可以分别由该节点上的两个应用程序承担,甚至于合并到一个应用程序中实现。并且,同步节点参与基链挖矿还有利于增加基链矿工的数量,矿工数量越多,基链的安全性也就越高。对于不同的机构而言,在基链中设置自己专用的同步节点是常见的做法(确保同步的数据可信),若这些同步节点参与挖矿,将使得基链上的矿工被大量不同的机构所控制(而不是像现有的某些区块链系统矿机资源被少数几个机构控制),从而使得在基链上挖矿具有天然的去中心化特性,整个区块链系统的安全性大大改善。As mentioned above, in the solution of the present disclosure, the synchronization node mainly acts as an intermediary for the result of the application chain miners synchronizing and competing for the accounting rights from the base chain miners. As for the information sent by the application chain miners to the base chain miners during mining Whether the mining request needs to be transferred through the synchronization node is not limited. In some implementations, the synchronization node may also participate in base chain mining. At this time, the functions of the base chain miner and the synchronization node can be undertaken by two applications on the node respectively, or even merged into one application. . Moreover, the participation of synchronous nodes in base chain mining is also conducive to increasing the number of base chain miners. The greater the number of miners, the higher the security of the base chain. For different institutions, it is a common practice to set up their own dedicated synchronization nodes in the base chain (to ensure that the synchronized data is credible). If these synchronization nodes participate in mining, the miners on the base chain will be used by a large number of different institutions. Controlled (instead of being controlled by a few institutions like some existing blockchain system mining machine resources), so that mining on the base chain has natural decentralization characteristics, and the security of the entire blockchain system Greatly improved.
在一些实现方式中,基链中还可以设置管理节点,管理节点的主要作用有两项:其一是提供应用链注册服务,只有在管理节点上注册的应用链基链才会为其提供算力支持,在此过程中基链的运营方也有可能收取一定的费用;其二是用于基链矿工同步授权及配置信息,授权信息即应用链的注册情况,基链矿工需要根据该信息判断是否应该响应应用链矿工的挖矿请求,配置信息主要包括基链矿工在共同挖矿过程中用到的一些预设参数,这些参数在各基链矿工之间应当尽可能保持一致。In some implementations, a management node can also be set in the base chain. The main role of the management node is twofold: one is to provide application chain registration services, and only the application chain base chain registered on the management node will provide computing for it. Strong support. In this process, the operator of the base chain may also charge a certain fee; the second is for the base chain miners to synchronize authorization and configuration information. The authorization information is the registration status of the application chain, and the base chain miners need to judge based on this information Whether it should respond to the mining request of the application chain miners, the configuration information mainly includes some preset parameters used by the base chain miners in the joint mining process, and these parameters should be kept as consistent as possible among the base chain miners.
下面再对基链和应用链的具体构成作进一步说明。在现有技术中,比特币属于单链区块链系统,其每秒交易数(Transaction Per Second,简称TPS)非常有限,大约只能达到7。目前业界已提出不少采用并行链机制的方案来改善单链区块链系统的TPS瓶颈问题,其中比较著名的是以太坊中的分片(Sharding)技术。对于本公开中的区块链系统而言,每条应用链或基链都可以是并行链(为简单起见,这里将单链也视为并行链的链数为1的特殊情况)。就提供算力角度而言,可以认为构成基链的各并行链之间是相互独立的,基链的每条并行链都可以为一条或多条应用链并行链提供算力。The specific composition of the base chain and the application chain will be further explained below. In the prior art, Bitcoin belongs to a single-chain blockchain system, and its number of transactions per second (Transaction Per Second, TPS for short) is very limited, only about 7. At present, the industry has proposed many schemes using parallel chain mechanisms to improve the TPS bottleneck problem of single-chain blockchain systems. The more famous one is the Sharding technology in Ethereum. For the blockchain system in the present disclosure, each application chain or base chain can be a parallel chain (for simplicity, a single chain is also regarded as a special case where the number of parallel chains is 1). From the perspective of providing computing power, it can be considered that the parallel chains that constitute the base chain are independent of each other, and each parallel chain of the base chain can provide computing power for one or more application chain parallel chains.
应用链矿工在向基链发送挖矿请求时,应明确自己要向基链的哪条并行链上的基链矿工发送。在一种实现方式中,若假设N为基链的并行链的总数(N为正整数),并且基链的N条并行链按照从0至N-1依次编号,则应用链矿工可以按照如下公式确定为自己所在的应用链提供算力的基链的并行链链号:When an application chain miner sends a mining request to the base chain, it should be clear which parallel chain of the base chain to send to the base chain miner. In one implementation, if it is assumed that N is the total number of parallel chains of the base chain (N is a positive integer), and the N parallel chains of the base chain are numbered sequentially from 0 to N-1, the application chain miners can be as follows The formula determines the parallel chain number of the base chain that provides computing power for the application chain in which you are located:
n=(ChainNoOffet+k)%Nn=(ChainNoOffet+k)%N
其中,n表示确定出的基链的并行链链号,ChainNoOffet为应用链矿工所在的应用链的链号偏移,该参数为一个预设值,每条应用链都拥有自己的ChainNoOffet,k为应用链矿工挖矿所在的应用链并行链链号(若应用链为单链,k可取0),%表示取余数运算。计算出基链的并行链链号n后,应用链矿工可以向基链的编号为n的并行链上的基链矿工发送挖矿请求,相应的基链矿工接收到请求后,也会根据该公式进行验证(参考后文内容,挖矿请求中包括能够表明是哪条应用链的哪条并行链上的矿工在发送请求的信息,从而公式中的ChainNoOffet和k可以确定下来)自己是否应该响应该挖矿请求。Among them, n represents the determined parallel chain chain number of the base chain, ChainNoOffet is the chain number offset of the application chain where the application chain miners are located, this parameter is a preset value, each application chain has its own ChainNoOffet, and k is The chain number of the parallel chain of the application chain where the application chain miner is mining (if the application chain is a single chain, k can be 0), and% means the remainder operation. After calculating the parallel chain number n of the base chain, the application chain miner can send a mining request to the base chain miner on the parallel chain number n of the base chain. After the corresponding base chain miner receives the request, it will also be based on the request. The formula is verified (refer to the following content, the mining request includes information that can indicate which application chain and which parallel chain miner is sending the request, so that ChainNoOffet and k in the formula can be determined) whether you should respond It should be a mining request.
对于基链存在多条并行链的情况,虽然这些并行链在提供算力服务上相互独立,但在软件实现上则既可以在一个应用程序中实现,也可以在多个应用程序中实现(例如,每条并行链用一个应用程序实现),并不限定。For the case where there are multiple parallel chains in the base chain, although these parallel chains are independent of each other in providing computing power services, in terms of software implementation, they can be implemented in one application or in multiple applications (e.g. , Each parallel chain is implemented by an application), which is not limited.
需要指出,后文中为简单起见,也经常笼统地称呼基链和应用链,而并不明确区分到底是整个基链还是基链的一条并行链,或者,到底是整个应用链还是应用链的一条并行链,可以根据具体场景具体理解,不能一概而论。It needs to be pointed out that for the sake of simplicity in the following text, the base chain and the application chain are often referred to in general, and it is not clear whether it is the entire base chain or a parallel chain of the base chain, or whether it is the entire application chain or a piece of the application chain. Parallel chains can be specifically understood according to specific scenarios, and cannot be generalized.
进一步的,本公开中的基链/应用链结构还可以嵌套,例如,第一级的1条基链为4条应用链提供算力支持,这4条应用链又可作为第二级的基链各自为16条应用链提供算力支持。Further, the base chain/application chain structure in the present disclosure can also be nested. For example, one base chain at the first level provides computing power support for 4 application chains, and these 4 application chains can be used as the second level. The base chains each provide computing power support for 16 application chains.
本公开的方案对于基链或应用链具体采用何种类型的区块链没有限制,只要基链和应用链都遵循最长链规则就可以了。在一种典型的实现方式中,基链可以采用公链,应用链则可以采用公链或许可链。当然,若基链或应用链直接采用现有的区块链系统,需要进行适当改造,以符合本公开提出的共同挖矿方案的要求。The solution of the present disclosure has no restriction on the specific type of blockchain used by the base chain or the application chain, as long as both the base chain and the application chain follow the longest chain rule. In a typical implementation, the base chain can be a public chain, and the application chain can be a public chain or a permission chain. Of course, if the base chain or the application chain directly adopts the existing blockchain system, it needs to be appropriately modified to meet the requirements of the common mining solution proposed in this disclosure.
应当理解,图1中的系统结构仅为示例,不应当视为对本公开保护范围的限制。以上对共同挖矿过程的阐述,仅仅是简要的概括,具体的实现细节将在对图2的阐述中给出。It should be understood that the system structure in FIG. 1 is only an example, and should not be regarded as a limitation on the protection scope of the present disclosure. The above description of the common mining process is only a brief summary, and the specific implementation details will be given in the description of Figure 2.
图2示出了本公开提供的一种区块链记账方法的流程图,该方法描述了应用链上的一个区块(应用链待挖区块)从产生到纳入应用链账本的过程,该过程大致分为两个阶段:提案阶段和验证阶段。本公开的方案可以简单概括为:在提案阶段应用链矿工根据预设的算法选举提案组成员,只有提案组成员才有资格进一步当选提案组领导人并获得出块权(也即应用链待挖区块的记账权),至于能否获得出块权则取决于基链矿工对提案组领导人的选举结果,该结果记录在基链区块中,应用链矿工同步基链区块信息后便可获知,成为提案组领导人的应用链矿工所出区块将在应用链中广播;在验证阶段,应用链矿工根据预设的算法选举验证组成员,只有验证组成员才有资格进对提案组领导人所出区块进行验证并出具检验报告,检验报告在应用链中广播,若应用链矿工根据接收到的检验报告确认有足够多的验证组成员认可了提案组领导人所出区块的合法性,则将其纳入本地的应用链账本中。参照图2,该方法具体包括:Figure 2 shows a flowchart of a blockchain accounting method provided by the present disclosure. The method describes the process from generation to inclusion of a block on the application chain (application chain to be mined block) into the application chain ledger. The process is roughly divided into two phases: the proposal phase and the verification phase. The solution of this disclosure can be briefly summarized as follows: in the proposal stage, application chain miners elect members of the proposal group according to a preset algorithm, and only the members of the proposal group are eligible to be further elected as the leader of the proposal group and obtain the right to produce blocks (that is, the application chain is waiting to be mined). Block accounting rights), as to whether the right to produce blocks can be obtained depends on the result of the election of the leader of the proposal group by the base chain miners. The result is recorded in the base chain block. After the application chain miners synchronize the base chain block information It can be learned that the block produced by the application chain miner who becomes the leader of the proposal group will be broadcast in the application chain; in the verification phase, the application chain miner elects the members of the verification group according to the preset algorithm, and only the members of the verification group are eligible to enter. The block produced by the leader of the proposal group is verified and an inspection report is issued. The inspection report is broadcast in the application chain. If the application chain miners confirm that there are enough verification group members to approve the area where the leader of the proposal group has left the area according to the received inspection report The legality of the block is included in the local application chain ledger. Referring to Figure 2, the method specifically includes:
步骤S100:应用链矿工参与应用链待挖区块的提案组成员的推选。Step S100: Application chain miners participate in the selection of proposal group members for the block to be mined in the application chain.
步骤S101:若确定应用链矿工被推选为应用链待挖区块的提案组成员,则向基链矿工发送针对应用链待挖区块的挖矿请求。Step S101: If it is determined that the application chain miner is selected as a member of the proposal group of the application chain to be mined block, then a mining request for the application chain to be mined block is sent to the base chain miner.
以上两个步骤合并在一起阐述。应用链待挖区块可以是应用链账本中已通过验证并记账的区块的下一区块,提案组是指有资格竞争应用链待挖区块的出块权的应用链矿工的集合,由于只有提案组成员会向基链矿工发送针对应用链待挖区块的挖矿请求,所以提案组也可以定义为有权发送挖矿请求的应用链矿工的集合。提案组中最终获得应用链待挖区块的出块权的应用链矿工被称为提案组领导人,提案组领导人由基链矿工负责选举,具体见步骤S102。The above two steps are combined and explained together. The application chain to be mined block can be the next block in the application chain ledger that has been verified and accounted for. The proposal group refers to a collection of application chain miners who are eligible to compete for the right to produce blocks of the application chain to be mined. , Since only the members of the proposal group will send mining requests for the application chain to be mined blocks to the base chain miners, the proposal group can also be defined as a collection of application chain miners who have the right to send mining requests. In the proposal group, the app chain miner who finally obtains the right to produce the block to be mined in the app chain is called the leader of the proposal group, and the leader of the proposal group is elected by the base chain miners. See step S102 for details.
每个应用链矿工都可以根据预设的算法自主确定是否为提案组成员,不依赖于其他应用链矿工。在一种典型的实现方式中,上述预设的算法可采用可验证随机函数(Verifiable Random Function,简称VRF)算法,VRF算法的核心内容是证明函数VRF_prove以及验证函数VRF_verify:调用VRF_prove(PrivateKey,info)可以得到一个可证明字串proof,VRF_prove针对确定的输入(PrivateKey与info)所得到的proof是确定的(多次运算所得的值相同),其中,PrivateKey是某一公私钥对K中的私钥,info为一个已知字串;调用VRF_verify(PublicKey,info,proof)可以验证proof是否为伪造,其中,PublicKey为公私钥对K中的公钥,若proof未被伪造(即proof是由PublicKey对应的PrivateKey经VRF_prove调用产生的),VRF_verify返回True,表明验证通过,否则返回False表明验证不通过。本公开中主要介绍VRF算法在共同挖矿过程中的应用,关于算法的详细原理可以参考现有技术,不作具体说明。Each application chain miner can independently determine whether to be a member of the proposal group according to a preset algorithm, and does not depend on other application chain miners. In a typical implementation, the above-mentioned preset algorithm can use the Verifiable Random Function (VRF) algorithm. The core content of the VRF algorithm is the verification function VRF_prove and the verification function VRF_verify: calling VRF_prove(PrivateKey, info ) Can get a provable string proof, the proof obtained by VRF_prove for certain input (PrivateKey and info) is certain (the value obtained by multiple operations is the same), where PrivateKey is the private key of a public-private key pair K Key, info is a known string; calling VRF_verify(PublicKey,info,proof) can verify whether the proof is forged, where PublicKey is the public key in the public-private key pair K. If the proof is not forged (that is, the proof is made by PublicKey The corresponding PrivateKey is generated by calling VRF_prove), VRF_verify returns True to indicate that the verification is passed, otherwise it returns False to indicate that the verification fails. This disclosure mainly introduces the application of the VRF algorithm in the common mining process. For the detailed principle of the algorithm, reference may be made to the prior art, and no specific description will be given.
应用链矿工首先基于自身的私钥(对应上面的PrivateKey)以及利用预设规则确定的第一选举字串(对应上面的info)调用VRF算法中的证明函数,可以获得第一可证明字串(对应上面的proof)。之后,应用链矿工基于第一可证明字串利用预设的规则推导第一随机值,并根据第一随机值确定应用链矿工是否被推选为应用链待挖区块的提案组成员,上述预设的推导规则具有确定性(但具体是何种规则不限定),因此对于同样的输入,推导出的第一随机值也具有确定性,进而在第一随机值的基础上得到的提案组成员的推选结果也具有确定性。Application chain miners first call the proof function in the VRF algorithm based on their own private key (corresponding to the PrivateKey above) and the first election string determined by the preset rules (corresponding to the info above) to obtain the first provable string ( Corresponding to the proof above). After that, the application chain miner uses a preset rule to derive the first random value based on the first provable string, and determines whether the application chain miner is selected as a member of the proposal group for the block to be mined in the application chain based on the first random value. Suppose the derivation rules are deterministic (but the specific rules are not limited), so for the same input, the deduced first random value is also deterministic, and then the members of the proposal group obtained on the basis of the first random value The results of the election are also deterministic.
上述第一选举字串为一个已知字串,其获取规则是确定的。基链矿工为应用链待挖区块选举的提案组领导人的信息记录在某个基链区块中,称该区块为确定应用链待挖区块的提案组领导人的基链区块,在应用链矿工参选提案组领导人时,该基链区块还处于待挖状态,但其在基链中的高度可以确定(参考后文内容可知,应用链上也保存有基链账本)。在一种实现方式中,第一选举字串可取:确定应用链待挖区块的提 案组领导人的基链区块的前L区块中的信息;其中,L为正整数,所谓区块中的信息可以是区块头中记录的哈希值或者随机数,例如,参考比特币中的区块头实现,第一选举字串对应区块头中的hash和nonce两个字段。The above-mentioned first election string is a known string, and its acquisition rule is determined. The information of the leader of the proposal group elected by the base chain miners for the block to be mined in the application chain is recorded in a certain base chain block, which is said to be the base chain block of the proposal group leader who determines the block to be mined in the application chain , When the application chain miners participate in the proposal group leader, the base chain block is still in a state to be mined, but its height in the base chain can be determined (refer to the content below, the application chain also saves the base chain ledger ). In one implementation, the first election string may be: to determine the information in the first L block of the base chain block of the leader of the proposal group of the block to be mined in the application chain; where L is a positive integer, the so-called block The information in may be the hash value or random number recorded in the block header. For example, referring to the block header in Bitcoin, the first election string corresponds to the hash and nonce fields in the block header.
不难发现,第一选举字串的确定依赖于基链,基链矿工为应用链的每个区块选举的提案组领导人信息记录在基链区块中,应用链矿工同步到基链区块信息后,可以在应用链矿工所在的挖矿节点上保存该信息,形成一个应用链矿工本地的基链账本,该账本相对于基链矿工本地的基链账本可能有所简化,但仍然包含基链区块的区块头和选举结果等关键信息,应用链矿工查询该账本即可确定第一选举字串的内容。It is not difficult to find that the determination of the first election string depends on the base chain. The leader information of the proposal group elected by the base chain miners for each block of the application chain is recorded in the base chain block, and the application chain miners are synchronized to the base chain area. After the block information, the information can be saved on the mining node where the application chain miner is located to form a local base chain ledger for the application chain miner, which may be simplified compared to the base chain ledger of the base chain miner, but still contains For key information such as the block header and election results of the base chain block, the application chain miner can query the ledger to determine the content of the first election string.
第一选举字串当然也可以采用其他获取规则,但应尽可能保证应用链矿工和基链矿工都可以获取该字串并得到同样的结果(基链矿工使用该字串的步骤见后文),因此,基于基链账本中的信息确定第一选举字串是一种比较合理的选择,因为根据上面提到的,无论是在基链矿工本地还是应用链矿工本地都保存有基链账本(虽然应用链矿工本地保存的可能是简化版本)。Of course, other acquisition rules can also be used for the first election string, but as far as possible, it should be ensured that both application chain miners and base chain miners can obtain the string and get the same result (see below for the steps of base chain miners using this string) Therefore, it is a more reasonable choice to determine the first election string based on the information in the base chain ledger, because according to the above mentioned, both the base chain miners and the application chain miners store the base chain ledger ( Although the local save of the application chain miner may be a simplified version).
进一步的,发明人长期研究后发现,L取值不宜太大,L取值太大意味着第一选举字串来源于较早前的基链区块中的信息,从而第一选举字串的取值很早就可以确定下来,敌手(可以指对区块链系统存有恶意的攻击者)一旦提早获知第一选举字串,便有充足时间进行一些破解行为。当然L的取值太小(例如,取1)也有一些问题,应用链矿工同步基链区块信息也需要时间,因此在应用链矿工本地的基链账本中最近的数据可能还没有同步好,并且近期的区块链数据容易受到基链软分叉的影响,导致第一选举字串的取值受到影响(例如,当前应用链矿工和基链矿工或者其他应用链矿工针对同一应用链待挖区块获取到的字串值不同)。Further, after long-term research, the inventor found that the value of L should not be too large, which means that the first election string is derived from the information in the earlier base chain block, so that the value of the first election string The value can be determined very early. Once the adversary (which can refer to the malicious attacker on the blockchain system) learns the first election string early, he will have sufficient time to perform some cracking actions. Of course, the value of L is too small (for example, take 1). There are also some problems. It takes time for the application chain miners to synchronize the base chain block information. Therefore, the latest data in the local base chain ledger of the application chain miners may not be synchronized well. In addition, recent blockchain data is easily affected by the soft fork of the base chain, causing the value of the first election string to be affected (for example, current application chain miners and base chain miners or other application chain miners are waiting for the same application chain to be mined The string value obtained by the block is different).
由于区块链系统是一种分布式系统,软分叉是必然存在的现象,由于软分叉的存在,在不同的基链矿工看来,指定高度的基链区块未必都相同,但产生时间距离当前时刻越久远的区块越容易统一到同一内容,因为基链的最长链规则会消除软分叉,也就是说,L=2时作为第一选举字串来源的基链区块在内容上的同一性比L=1时要高得多,L=3时作为第一选举字串来源的基链区块在内容上的同一性又比L=2时要高得多(同一性概率以指数级别上升,例如在比特币中6次出块即视为不可逆转的确认,同一性概率接近于100%,而非同一性的概率小到可以忽略)。因此,综合考虑在确定第一选举字串时可取L=6,此时各应用链矿工、基链矿工在基链指定高度的区块处所确定出的第一选举字串基本可以认为是相同,即基本消除了基链软分叉对第一选举字串取值的影响,同时,由于确定应用链待挖区块的提案组领导人的基链区块的前6区块在较早之前已纳入基链账本,给应用链矿工同步该区块的基链区块信息预留了充足时间,即取L=6也充分考虑了通信时延的因素,取值比较合理,有利于增加系统的稳健性。Since the blockchain system is a distributed system, soft forks are an inevitable phenomenon. Due to the existence of soft forks, in the eyes of different base chain miners, the specified height of base chain blocks may not be the same, but Blocks that are farther away from the current time are easier to be unified into the same content, because the longest chain rule of the base chain will eliminate soft forks, that is, the base chain block that is the source of the first election string when L=2 The content identity is much higher than when L=1. When L=3, the identity of the base chain block as the source of the first election string is much higher than when L=2 (the same The probability of identity rises at an exponential level. For example, 6 blocks in Bitcoin are regarded as irreversible confirmation, the probability of identity is close to 100%, and the probability of non-identity is so small that it can be ignored). Therefore, comprehensive consideration can be taken when determining the first election string L=6. At this time, the first election string determined by the application chain miners and the base chain miners at the block at the designated height of the base chain can be basically considered to be the same. That is to say, the influence of the soft fork of the base chain on the value of the first election string is basically eliminated. At the same time, the first 6 blocks of the base chain block of the proposal group leader who determine the block to be mined on the application chain have been earlier. Included in the base chain ledger, sufficient time is reserved for the application chain miners to synchronize the base chain block information of the block, that is, taking L=6 also takes into account the communication delay factor, and the value is relatively reasonable, which is conducive to increasing the system. Robustness.
需要指出,上面的分析并不是要排除L=6之外的实现方式,例如采用L=1、L=2的实现方式也是可行的,因为随着时间的推移,软分叉最终会因最长链规则消除,通信时延也会消除,并不影响区块链系统的正常运作。It should be pointed out that the above analysis is not to exclude implementations other than L=6. For example, the implementation of L=1 and L=2 is also feasible, because as time goes by, the soft fork will eventually suffer the longest The chain rules are eliminated, and the communication delay will also be eliminated, which does not affect the normal operation of the blockchain system.
在一些实现方式中,可以直接根据第一随机值确定应用链矿工是否为应用链待挖区块的提案组成员。在另一些实现方式中,对于每个应用链矿工可以计算一个其专属的提案组参选权重,每个应用链矿工可以根据第一随机值以及自身的提案组参选权重确定自己是否为应用链待挖区块的提案组成员,其中,应用链矿工被选为提案组成员的概率与该提案组参选权重的取值正相关。In some implementation manners, it may be directly determined according to the first random value whether the application chain miner is a member of the proposal group of the block to be mined in the application chain. In other implementations, each application chain miner can calculate its own proposal group participation weight, and each application chain miner can determine whether he is an application chain based on the first random value and his own proposal group participation weight. The members of the proposal group of the block to be mined. Among them, the probability of the application chain miner being selected as a member of the proposal group is positively related to the value of the participation weight of the proposal group.
例如,某个应用链矿工的提案组参选权重可取该矿工在预设历史时间段内当选为提案组领导人的次数,按照该定义,在历史时间段内当选提案组领导人次数越多的矿工再次被选为提案组领导人的概率也越高,作为对其多次诚实挖矿的回报。之前在介绍第一选举字串的获取方法时已经提到,应用链矿工本地也会保存一个基链账本,应用链矿工查询该账本即可统计获得当前应用链矿工在预设历史时间段内当选为提案组领导人的次数。For example, the weight of the proposal group participation weight of a certain application chain miner can be the number of times the miner was elected as the leader of the proposal group in a preset historical time period. According to this definition, the more times the miner was elected as the leader of the proposal group in the historical time period The probability that a miner will be elected as the leader of the proposal group again is also higher, in return for his repeated honest mining. As mentioned in the introduction to the method of obtaining the first election string, the application chain miner will also save a base chain ledger locally, and the application chain miner can query the ledger to obtain statistics to obtain the current application chain miner elected within the preset historical time period. The number of times the leader of the proposal group.
作为一种可选方案,为提高当选次数的统计速度,应用链矿工还可以基于同步到的基链区块信息构建查询表格,该表格可以保存在数据库中或者常驻内存,其内容可 以包括应用链每个区块的提案组领导人信息,方便应用链矿工快速查询(不再直接从本地的基链账本中查询)。关于查询表格的具体表项,在后文还会提及。As an optional solution, in order to increase the statistical speed of the number of elections, the application chain miners can also construct a query table based on the synchronized base chain block information. The table can be stored in the database or resident memory, and its content can include applications. The leader information of the proposal group of each block of the chain is convenient for the application chain miners to quickly query (no longer directly query from the local base chain ledger). The specific items of the inquiry form will be mentioned later.
上述预设的历史时间段,可以有不同的选取方式:例如,从基链的倒数G1(比如36)个区块之前取基链的连续G2(G2为正整数)个区块作为历史时间段,查询应用链矿工在这些区块中当选为提案组领导人的次数;又例如,取基链刚过去的一个难度调整周期(这里的难度指挖矿难度,例如比特币每2016个区块为一个难度调整周期)之前的连续G3(G3为正整数)个难度调整周期作为历史时间段,查询应用链矿工在这段时间内产生的基链区块中当选为提案组领导人的次数。不难看出,在上面两个例子中,历史时间段并未取当前时刻的最近一段时间,其原因是通信时延和基链软分叉可能导致统计提案组领导人的当选次数受到影响,这两项影响因素之前阐述第一选举字串时已经分析,不再重复。The above-mentioned preset historical time period can be selected in different ways: for example, the continuous G2 (G2 is a positive integer) blocks of the base chain before the reciprocal G1 (for example, 36) blocks of the base chain are taken as the historical time period , Query the number of times that the miner of the application chain was elected as the leader of the proposal group in these blocks; for another example, take a difficulty adjustment period just past the base chain (the difficulty here refers to the difficulty of mining, for example, every 2016 block of Bitcoin is A difficulty adjustment period) before the consecutive G3 (G3 is a positive integer) difficulty adjustment period as the historical time period, query the number of times the application chain miners were elected as the leader of the proposal group in the base chain blocks generated during this period. It is not difficult to see that in the above two examples, the historical time period does not take the latest period of time at the current moment. The reason is that the communication delay and the soft fork of the base chain may affect the number of elections of the leader of the statistical proposal group. The two influencing factors have been analyzed before the first election string was explained, and will not be repeated.
提案组参选权重当然也可以采用其他定义,但应尽可能保证应用链矿工和基链矿工都可以计算该权重并获得同样的计算结果(基链矿工使用该权重的步骤见后文),因此,基于基链账本中的信息确定提案组参选权重是一种比较合理的选择,因为无论是在基链矿工本地还是应用链矿工本地都保存有基链账本。Of course, other definitions can also be used for the weight of the proposal group, but it should be ensured that both application chain miners and base chain miners can calculate the weight and obtain the same calculation result (see the following for the steps of base chain miners using this weight), so , It is a reasonable choice to determine the weight of the proposal group based on the information in the base chain ledger, because both the base chain miners and the application chain miners have the base chain ledger.
在一些实现方式中,应用链上还可以预设首次记账权重这一参数,其值为0表示禁止新加入的应用链矿工参与挖矿;否则,若首次记账权重取非0值,表示允许新加入的应用链矿工参与挖矿,当统计出应用链矿工在上述预设的历史时间段内未当选过提案组领导人时(对于新加入的应用链矿工,在该历史时段内可能还未参与挖矿),可将其提案组参选权重(此时值为0)设置为首次记账权重,使得其可以以较低的概率当选提案组成员。In some implementations, the first accounting weight parameter can also be preset on the application chain. A value of 0 means that the newly added application chain miners are prohibited from participating in mining; otherwise, if the first accounting weight takes a non-zero value, it means Allow newly joined application chain miners to participate in mining. When it is calculated that the application chain miners have not been elected as the leader of the proposal group within the above-mentioned preset historical time period (for newly joined application chain miners, they may still be If they are not involved in mining), their proposal group participation weight (the value is 0 at this time) can be set as the first accounting weight, so that they can be elected as a proposal group member with a lower probability.
在一些实现方式中,应用链上还可以预设提案组最大参选权重这一参数,即为提案组参选权重设置一个上限,若计算出的提案组参选权重超过该上限(例如,应用链矿工因在历史时间段内多次当选为提案组领导人而使得提案组参选权重大于预设的提案组最大参选权重),则将提案组参选权重设置为提案组最大参选权重。避免某一深度参与挖矿的应用链矿工在提案组成员的推选中优势过大,剥夺其他应用链矿工当选提案组成员的机会。In some implementations, the application chain can also preset the parameter of the proposal group’s maximum participation weight, that is, set an upper limit for the proposal group’s participation weight. If the calculated proposal group’s participation weight exceeds the upper limit (for example, application Chain miners have been elected as the leader of the proposal group for many times in the historical time period, and the proposal group’s participation weight is greater than the preset maximum participation weight of the proposal group), then the proposal group participation weight is set to the maximum participation weight of the proposal group . Avoid a certain application chain miner who is deeply involved in mining to have too much advantage in the selection of proposal group members, and deprive other application chain miners of the opportunity to be elected as members of the proposal group.
应用链矿工根据第一随机值以及自身的提案组参选权重确定自己是否为应用链待挖区块的提案组成员也可以有不同的实现方式,在一种实现方式中,可以这样实现:Application chain miners determine whether they are members of the proposal group of the block to be mined in the application chain according to the first random value and their own proposal group participation weight. There are also different implementation methods. In one implementation method, it can be implemented as follows:
首先,利用如下公式计算第二随机值RandValue2:First, use the following formula to calculate the second random value RandValue2:
RandValue2=(RandValue1%ExpectedRange1)+priority1RandValue2=(RandValue1%ExpectedRange1)+priority1
其中,RandValue1为第一随机值,ExpectedRange1为预设的范围值,priority1为提案组参选权重,%表示取余数运算。ExpectedRange1的作用主要是将RandValue1的值调整到一个合理的范围内,因为RandValue1的随机性使得该值可能很大,与priority1完全不在同一数量级,如果直接用RandValue1进行计算,可能导致是否加上priority1对最终结果没有影响。Among them, RandValue1 is the first random value, ExpectedRange1 is the preset range value, priority1 is the weight of the proposal group participation, and% represents the remainder operation. The function of ExpectedRange1 is mainly to adjust the value of RandValue1 to a reasonable range, because the randomness of RandValue1 makes the value may be very large, which is not in the same order of magnitude as priority1. If RandValue1 is directly used for calculation, it may cause whether to add priority1 The final result has no effect.
若计算出的RandValue2满足如下条件,则确定当前应用链矿工被推选为应用链待挖区块的提案组成员:If the calculated RandValue2 satisfies the following conditions, it is determined that the current application chain miner is selected as the proposal group member of the application chain to be mined block:
RandValue2>ExpectedRange1-(ExpectedRange1*1/M1)RandValue2>ExpectedRange1-(ExpectedRange1*1/M1)
其中,M1为预设过滤比例,例如,M1取10,则应用链所有的矿工中大约有1/10(概率意义上)会被选为提案组成员。Among them, M1 is the preset filtering ratio. For example, if M1 is 10, about 1/10 (in a probability sense) of all miners in the application chain will be selected as members of the proposal group.
应当理解,以上两个公式仅为举例,在不同的实现方式中,也可以采取其他的形式,例如,将priority1以乘积的方式结合到公式中(目前是以加法的方式),或者,将RandValue2小于某个值作为被推选为提案组成员的条件(目前是大于某个值),等等。It should be understood that the above two formulas are only examples. In different implementations, other forms can also be adopted. For example, priority1 is combined into the formula by product (currently by addition), or RandValue2 Less than a certain value is used as a condition for being elected as a member of the proposal group (currently greater than a certain value), and so on.
若一个应用链矿工确认了自己为应用链待挖区块的提案组成员,就会向基链矿工发送针对应用链待挖区块的挖矿请求,如前所述,在不同的实现方式中,应用链矿工可能直接向基链矿工所在的挖矿节点发送请求,也可能向基链上的同步节点发送挖矿请求,基链中最先收到挖矿请求的节点会将挖矿请求在基链中广播,最终各个基链矿工都会收到。若基链由多条并行链构成,应用链矿工在发送挖矿请求前,还需确定要 向哪条并行链上的基链矿工发送请求,否则其请求不会被受理,确定方式在阐述图1时已经说明,此处不再重复。If an application chain miner confirms that he is a member of the proposal group of the application chain to be mined, he will send a mining request for the application chain to be mined to the base chain miner. As mentioned above, in different implementations , The application chain miner may send a request directly to the mining node where the base chain miner is located, or may send a mining request to the synchronization node on the base chain. The node that receives the mining request first in the base chain will send the mining request at Broadcast in the base chain, and eventually all base chain miners will receive it. If the base chain is composed of multiple parallel chains, before sending a mining request, the application chain miner needs to determine which base chain miner on the parallel chain to send the request to, otherwise the request will not be accepted. The determination method is shown in the illustration. It has been explained at 1 o'clock and will not be repeated here.
挖矿请求中包括提案候选信息,提案候选信息的概念在本系统中多处会使用,其内容包括:应用链标识、并行链链号、应用链待挖区块的高度、确定提案组领导人的基链区块的高度、应用链矿工公钥以及第一可证明字串。The mining request includes proposal candidate information. The concept of proposal candidate information will be used in many places in this system. Its content includes: application chain identification, parallel chain chain number, height of the block to be mined in the application chain, and determination of the leader of the proposal group The height of the base chain block, the public key of the application chain miner, and the first provable string.
其中,应用链标识是指发送挖矿请求的提案组成员所在的应用链的标识(用于唯一标记一条应用链),并行链链号是指构成应用链的并行链中提案组成员挖矿所在的并行链的编号(若应用链为单链,该项可固定取0),确定提案组领导人的基链区块的高度是指确定应用链待挖区块的提案组领导人的基链区块的高度,应用链矿工公钥是指发送挖矿请求的提案组成员的公钥,第一可证明字串是指应用链矿工被推选为提案组成员时依赖的第一可证明字串。当然提案候选信息中还可以包括其他信息项,例如应用链矿工被推选为提案组成员时依赖的第二随机值,虽然利用第一可证明字串也可以推导出第二随机值,但需要进行一定的运算,在某些对安全性要求不太高的场合也可以直接使用第二随机值进行验证等行为,不必再推导一遍。关于提案候选信息中的各信息项的用途将在后续步骤中说明,此处暂不展开。Among them, the application chain identifier refers to the identifier of the application chain where the member of the proposal group that sent the mining request is located (used to uniquely mark an application chain), and the parallel chain number refers to where the member of the proposal group in the parallel chain that constitutes the application chain mines. The number of the parallel chain (if the application chain is a single chain, this item can be fixed to 0), the height of the base chain block that determines the leader of the proposal group refers to the base chain of the proposal group leader who determines the block to be mined in the application chain The height of the block, the public key of the application chain miner refers to the public key of the proposal group member who sent the mining request, and the first provable string refers to the first provable string that the application chain miner relied on when elected as a member of the proposal group . Of course, the proposal candidate information can also include other information items, such as the second random value that the application chain miners rely on when they are elected as members of the proposal group. Although the second random value can also be derived using the first provable string, it needs to be For certain operations, in some occasions where the security requirements are not too high, the second random value can also be used directly for verification and other behaviors, without the need to derive it again. The purpose of each information item in the proposal candidate information will be explained in the subsequent steps, and will not be expanded here.
步骤S102:基链矿工根据应用链待挖区块的提案组成员发送的针对应用链待挖区块的挖矿请求为应用链待挖区块选举提案组领导人。Step S102: The base chain miners elect the leader of the proposal group according to the mining request for the application chain to be mined block sent by the proposal group members of the application chain to be mined block.
基链矿工接收到某个应用链矿工发送的挖矿请求后,首先要确认是否要对该请求进行响应,若确认要响应该请求,才会将该请求作为选举应用链待挖区块的提案组领导人的依据。要验证的内容至少包括以下两项:After the base chain miner receives a mining request sent by an application chain miner, it must first confirm whether to respond to the request. If it is confirmed to respond to the request, the request will be used as a proposal to elect the application chain to be mined. The basis of the group leader. The content to be verified includes at least the following two:
其一,基链矿工根据挖矿请求中的应用链标识,确定该标识对应的应用链是否由基链提供算力支持。First, the base chain miners determine whether the application chain corresponding to the identifier is supported by the base chain based on the application chain identifier in the mining request.
在阐述图1时已经提到,在常见的实现方式中,某条应用链要在基链中的管理节点上注册后,基链才会为其提供服务。注册信息会被同步到各个基链矿工,例如,各基链矿工可以在本地维护一个由已注册的应用链对应的应用链标识构成的集合,若基链矿工发现当前挖矿请求中的应用链标识在该集合中,说明该标识对应的应用链已经注册,本项验证通过,否则不通过。As mentioned in the illustration of Figure 1, in common implementations, a certain application chain must be registered on the management node in the base chain before the base chain will provide services for it. The registration information will be synchronized to each base chain miner. For example, each base chain miner can locally maintain a set of application chain identifiers corresponding to the registered application chain. If the base chain miner finds the application chain in the current mining request If the identifier is in the set, it means that the application chain corresponding to the identifier has been registered, and the verification of this item is passed, otherwise it is not passed.
若考虑基链以及应用链为并行链的情况,情况可能会更复杂一些,基链矿工可能还需要根据挖矿请求中的应用链标识R以及并行链链号k计算基链并行链链号n=(ChainNoOffet+k)%N,若计算结果和自身真实的并行链链号一致,则确认自己可以向标识为R的应用链下的第k条并行链提供算力服务(仅指本项验证通过),否则确认自己不可以向标识为R的应用链下的第k条并行链提供算力服务。其中,标识R用于确定公式中的ChainNoOffet参数的取值,因为该参数针对每条应用链设置。If you consider the case where the base chain and the application chain are parallel chains, the situation may be more complicated. The base chain miners may also need to calculate the base chain parallel chain chain number n according to the application chain identifier R and the parallel chain chain number k in the mining request. =(ChainNoOffet+k)%N, if the calculation result is consistent with the real parallel chain number, confirm that you can provide computing power services to the kth parallel chain under the application chain identified as R (only refers to this verification Pass), otherwise confirm that you cannot provide computing power services to the kth parallel chain under the application chain identified as R. Among them, the identifier R is used to determine the value of the ChainNoOffet parameter in the formula, because this parameter is set for each application chain.
其二,基链矿工首先根据挖矿请求中的确定提案组领导人的基链区块的高度,确定发送挖矿请求的应用链矿工被推选为提案组成员时依赖的第一选举字串;然后,基于挖矿请求中的应用链矿工公钥、第一证明字串以及自己计算出的第一选举字串调用VRF算法中的验证函数,验证挖矿请求中的第一可证明字串是否被伪造,验证函数输出True,表明第一可证明字串未被伪造,输出False表明第一可证明字串被伪造。Second, the base chain miner first determines the first election string that the application chain miner who sent the mining request depends on when it is elected as the member of the proposal group according to the height of the base chain block that determines the leader of the proposal group in the mining request; Then, based on the application chain miner’s public key in the mining request, the first proof string, and the first election string calculated by myself, the verification function in the VRF algorithm is called to verify whether the first provable string in the mining request is If forged, the verification function outputs True, indicating that the first provable string is not forged, and False indicates that the first provable string is forged.
其中,第一选举字串的获取方式在前文已经介绍,只是之前是由应用链矿工进行计算,而此处是由基链矿工进行计算,在前文列举的实现方式中,第一选举字串来源于基链区块中的信息,显然对于本地保存有基链账本的基链矿工,这些信息是容易获得的,其细节不再阐述。若验证函数的输出结果表明第一可证明字串未被伪造,则本项验证通过,否则本项验证不通过。Among them, the method of obtaining the first election string has been introduced in the previous article, but the calculation was performed by the application chain miners before, and here is the calculation by the base chain miners. In the implementation methods listed above, the source of the first election string The information in the base chain block is obviously easy to obtain for the base chain miners who have the base chain ledger locally, and the details will not be elaborated. If the output result of the verification function shows that the first provable string is not forged, the verification of this item is passed, otherwise the verification of this item is not passed.
在一些可选的方案中,还可以增加第三项验证内容:基链矿工首先根据挖矿请求中的应用链标识、并行链链号以及应用链矿工公钥三项信息,利用哈希算法计算发送挖矿请求的应用链矿工的矿工标识,该标识用于唯一标记一个应用链矿工。然后,基链矿工判断计算出的矿工标识是否在基链针对应用链配置的黑名单中,该黑名单的内容可以是一系列矿工标识的集合,若发送挖矿请求的应用链矿工的矿工标识在黑名单中,则基链矿工应拒绝为其提供服务,即本项验证不通过,否则本项验证通过。In some optional schemes, you can also add a third verification content: the base chain miner first uses the hash algorithm to calculate according to the application chain identification, the parallel chain chain number, and the application chain miner’s public key in the mining request. The miner ID of the app chain miner who sent the mining request, which is used to uniquely mark an app chain miner. Then, the base chain miner judges whether the calculated miner ID is in the blacklist configured by the base chain for the application chain. The content of the blacklist can be a collection of a series of miner IDs. If the miner ID of the app chain miner who sends the mining request is In the blacklist, the base chain miners should refuse to provide services for them, that is, the verification fails, otherwise the verification is passed.
下面举例说明黑名单的一种典型应用场景,对于参与方比较明确的应用链(即大 致可以确定该应用链的矿工来源于哪些机构),可以先开放挖矿一段时间,然后通过配置禁止新加入的应用链矿工挖矿(例如,将之前提到的首次记账权重置0),再将已参与挖矿但来源于未知机构的应用链矿工纳入黑名单,以避免可能的安全风险。The following is an example of a typical application scenario of the blacklist. For application chains with clear participants (that is, it can be roughly determined from which institutions the miners of the application chain come from), mining can be opened for a period of time, and then new additions can be prohibited through configuration Miners of the application chain mining (for example, reset the first accounting right mentioned above to 0), and then include the application chain miners who have participated in mining but come from unknown institutions into the blacklist to avoid possible security risks.
在一些可选的方案中,还可以增加第四项验证内容:基链矿工首先根据挖矿请求中的应用链标识、并行链链号以及应用链矿工公钥三项信息,利用哈希算法计算发送挖矿请求的应用链矿工的矿工标识。然后,基链矿工判断计算出的矿工标识是否在基链针对应用链配置的实名制名单中,该实名制名单的内容可以是一系列矿工标识的集合,若发送挖矿请求的应用链矿工的矿工标识在实名制名单中,则基链矿工应同意为其提供服务,即本项验证通过,否则本项验证不通过。本项验证适用于要求应用链矿工实名挖矿的情形。In some optional schemes, you can also add a fourth verification content: the base chain miner first uses the hash algorithm to calculate according to the application chain identification, the parallel chain chain number and the application chain miner’s public key in the mining request. The miner ID of the app chain miner who sent the mining request. Then, the base chain miner judges whether the calculated miner ID is in the real name list configured by the base chain for the application chain. The content of the real name list can be a collection of a series of miner IDs. If the miner ID of the application chain miner who sends the mining request is In the real-name list, the base chain miners should agree to provide services for them, that is, the verification of this item is passed, otherwise the verification of this item is not passed. This verification is applicable to situations that require real-name mining by application chain miners.
若以上各项验证内容若均获得通过,则基链矿工接纳当前的挖矿请求并进行后续处理。在介绍后续步骤前,先对前面已经提到的基链中设置的管理节点作一些说明:If all the above verification contents are passed, the base chain miners accept the current mining request and perform subsequent processing. Before introducing the next steps, let's make some explanations on the management nodes set up in the base chain mentioned earlier:
管理节点的主要功能有两项:第一项功能是授权信息管理。管理节点对外提供应用链注册服务,应用链的管理者若希望运营的应用链得到基链的算力支持,应当向管理节点发起注册,管理节点若同意了应用链的注册请求,可以向基链矿工下发授权信息(这里的下发可以是管理节点主动下发,也可以是基链矿工请求其下发),授权信息的内容包括进行过注册的应用链的信息(例如这些应用链的应用链标识)。There are two main functions of the management node: The first function is authorization information management. The management node provides external application chain registration services. If the manager of the application chain wants the operating application chain to be supported by the base chain’s computing power, it should initiate a registration with the management node. If the management node agrees to the application chain’s registration request, it can register with the base chain. The miner issues authorization information (the issue here can be actively issued by the management node, or the base chain miner requests it to issue), and the content of the authorization information includes the information of the registered application chain (for example, the application of these application chains). Chain identification).
管理节点的第二项功能是配置信息管理,配置信息包括基链矿工所使用的一些预设参数,例如上面在选举提案组成员时提到的预设的范围值、预设的过滤比例、首次记账权重、提案组最大参选权重以及后文会提到的若干参数。虽然之前只介绍了在应用链上使用这些参数,但其中的部分或全部的参数在基链上也会使用,同一参数在应用链和基链上应当尽可能保持一致(因为参数在基链应用链和基链之间的同步需要时间,所以不排除在某些时刻同一参数的值在基链和应用链上是不同的,但参数在设计时可以预留一定余量),具体保持参数取值一致的方法本公开不限定。各基链矿工可以从管理节点同步配置信息,或者也可以由管理节点主动广播。The second function of the management node is configuration information management. The configuration information includes some preset parameters used by the base chain miners, such as the preset range values, preset filtering ratios, and first-time The accounting weight, the maximum weight of the proposal group and a number of parameters mentioned later. Although only the use of these parameters on the application chain has been introduced before, some or all of the parameters will also be used on the base chain. The same parameters should be as consistent as possible on the application chain and the base chain (because the parameters are applied in the base chain). The synchronization between the chain and the base chain takes time, so it is not ruled out that the value of the same parameter is different on the base chain and the application chain at some time, but the parameters can be designed with a certain margin), and the specific parameters are maintained. The method of consistent value is not limited in the present disclosure. Each base chain miner can synchronize configuration information from the management node, or it can be actively broadcast by the management node.
授权配置信息(授权信息和配置信息的简称)对于应用链正常出块十分重要,因此在一些实现方式中,管理节点可以对其进行严格编号,以保障数据的完整性。例如,对配置信息中的每个参数的每次修改操作都进行记录,并顺序编号每次操作行为,使得对于参数的所有修改行为都可以进行追溯。又例如,对于基链的每条并行链,都有自己服务的一条或多条应用链并行链(这些并行链都可以拥有自己专属的一套配置信息),因此可以对基链的并行链也进行编号,分别进行配置信息管理。Authorization configuration information (abbreviation of authorization information and configuration information) is very important for the normal block generation of the application chain. Therefore, in some implementations, the management node can strictly number it to ensure the integrity of the data. For example, each modification operation of each parameter in the configuration information is recorded, and each operation behavior is sequentially numbered, so that all modification behaviors of the parameter can be traced back. For another example, for each parallel chain of the base chain, there are one or more parallel chains of its own service (these parallel chains can have their own set of configuration information), so the parallel chains of the base chain can also be Carry out the number, respectively carry on the configuration information management.
授权配置信息在区块链系统的运行过程中可能会调整,例如可由应用链的管理者将配置信息中参数的最新取值提交到管理节点。在常见的实现方式中,出于数据传输开销及系统稳定性等方面的考虑,授权配置信息更新后并不会实时从管理节点同步到基链矿工,而是在指定的时刻才进行同步。例如,基链矿工可以在基链的难度调整周期开始时向管理节点查询本地保存的授权及配置信息是否是最新版本,若不是最新版本则从管理节点同步最新版本的授权及配置信息;其中,基链矿工每隔预设数量的难度调整周期进行一次查询。管理节点在向基链矿工发送授权及配置信息时,还可以用自身私钥进行签名,避免信息遭到篡改。The authorized configuration information may be adjusted during the operation of the blockchain system. For example, the administrator of the application chain can submit the latest values of the parameters in the configuration information to the management node. In a common implementation, due to data transmission overhead and system stability considerations, after the authorization configuration information is updated, it will not be synchronized from the management node to the base chain miners in real time, but will be synchronized at a specified time. For example, base chain miners can query the management node at the beginning of the difficulty adjustment period of the base chain whether the locally saved authorization and configuration information is the latest version, if not the latest version, synchronize the latest version of the authorization and configuration information from the management node; among them, Base chain miners make a query every preset number of difficulty adjustment cycles. When the management node sends authorization and configuration information to the base chain miners, it can also sign with its own private key to prevent the information from being tampered with.
基链矿工持续收集各应用链矿工发送的挖矿请求并缓存,这些挖矿请求可能针对于应用链不同的高度的区块(由挖矿请求中应用链待挖区块的高度一项指定)。基链矿工在打包基链区块时,首先根据基链账本中记录的、已经选出提案组领导人的应用链最高区块确定应用链待挖区块所在的新高度(命名为新高度是为了便于和后面的旧高度区分,并无特殊含义),也即是确定当前打包的基链区块中要记录的是哪个高度的应用链区块的选举结果。在多数情况下,由于区块链中的区块高度是依次增长的,基链账本中记录的、已经选出提案组领导人的应用链最高区块的高度加1就可以得到新高度,但在某些实现方式中,允许应用链中加入空块,则需要加2甚至更多才能得到新高度。基链矿工可以专门维护一个变量,用于记录基链账本中记录的、已经选出提案组领导人的应用链最高区块的高度,当然也可以每次出块时从基链账本中查询。关于应用链中存在空块的情况,可以参考后文关于基链和应用链同频出块的内容。The base chain miners continuously collect and cache the mining requests sent by the miners of each application chain. These mining requests may be for blocks of different heights in the application chain (specified by the height of the block to be mined in the application chain in the mining request) . When the base chain miners package the base chain blocks, they first determine the new height of the application chain to be mined according to the highest block of the application chain recorded in the base chain ledger and the leader of the proposal group has been selected (named as the new height is In order to distinguish it from the old height later, it has no special meaning), that is, to determine the election result of the application chain block of which height is to be recorded in the currently packaged base chain block. In most cases, since the block heights in the blockchain increase sequentially, the height of the highest block of the application chain recorded in the base chain ledger and the leader of the proposal group has been selected plus one to get the new height, but In some implementations, to allow empty blocks to be added to the application chain, you need to add 2 or more to get a new height. Basechain miners can maintain a variable that is used to record the height of the highest block in the application chain that has selected the leader of the proposal group recorded in the basechain ledger. Of course, they can also query the basechain ledger every time a block is generated. Regarding the existence of empty blocks in the application chain, you can refer to the following text about the content of the base chain and the application chain generating blocks at the same frequency.
确定好新高度后,基链矿工从缓存的挖矿请求中选择匹配于新高度的挖矿请求纳入针对新高度的待选举集合,所谓匹配是指挖矿请求中的应用链待挖区块的高度一项与新高度一致。After determining the new height, the base chain miners select the mining request that matches the new height from the cached mining requests and include them in the waiting set for the new height. The so-called matching refers to the block to be mined in the application chain in the mining request. The height item is consistent with the new height.
之后,基链矿工判断针对新高度的待选举集合中的请求个数是否不小于预设的最低矿工个数,若未达到最低矿工个数,则针对应用链新高度的区块选举提案组领导人失败,对于失败的处理方式在步骤S103中阐述,若达到最低矿工个数,则根据针对新高度的待选举集合中的每个挖矿请求中的第一可证明字串,确定应用链在新高度的区块的提案组领导人。对于不同的应用链,最低矿工个数可取不同的值,例如一个10至50之间的值。After that, the base chain miners judge whether the number of requests in the set to be elected for the new height is not less than the preset minimum number of miners. If the minimum number of miners is not reached, then the leader of the proposal group will be elected for the block of the new height of the application chain. If a person fails, the processing method for failure is described in step S103. If the minimum number of miners is reached, the application chain is determined according to the first provable string in each mining request in the set to be elected for the new height The leader of the proposal group for the new height block. For different application chains, the minimum number of miners can take different values, such as a value between 10 and 50.
其中,设置最低矿工个数这一参数用于验证是否有足够多的应用链矿工认同当前的挖矿状态,因为诚实的应用链矿工只有在应用链待挖区块的前一区块验证通过后才会请求挖下一区块,进而才有可能发出针对应用链待挖区块的挖矿请求,若针对新高度的待选举集合中的请求个数小于最低矿工个数,表明并没有足够多的应用链矿工认同当前要针对应用链新高度的区块进行挖矿,选举出的提案组领导人效力不足。Among them, the parameter of setting the minimum number of miners is used to verify whether enough application chain miners agree with the current mining status, because honest application chain miners only pass the verification of the previous block of the application chain to be mined. Will request to mine the next block, and then it is possible to issue a mining request for the block to be mined in the application chain. If the number of requests in the waiting set for the new height is less than the minimum number of miners, it indicates that there are not enough Of application chain miners agree that currently mining blocks of new heights in the application chain are needed, and the elected leader of the proposal group is not effective.
上面提到,基链矿工在打包基链区块时进行提案组领导人选举,但具体基链矿工何时打包基链区块,根据基链采用的不同机制可能有所不同,本公开对此并不作限定。例如,可能有多个基链矿工同时打包基链区块,当然最后只有获得记账权的基链矿工打包的区块会被认可;又例如,各基链矿工先竞争记账权,只有获得记账权的基链矿工才会打包基链区块,等等。As mentioned above, the base chain miners elect the leader of the proposal group when they pack the base chain blocks. However, when the base chain miners pack the base chain blocks, it may be different according to the different mechanisms adopted by the base chain. This disclosure is about this. It is not limited. For example, there may be multiple base chain miners packing the base chain blocks at the same time. Of course, in the end, only the blocks packaged by the base chain miners who have obtained the bookkeeping right will be recognized; for another example, each base chain miner first competes for the bookkeeping right, only to obtain Only the base chain miners with bookkeeping rights will package the base chain blocks, and so on.
基链矿工根据针对新高度的待选举集合中的每个挖矿请求中的第一可证明字串,确定应用链在新高度的区块的提案组领导人,可以有不同的实现方式:Based on the first provable string in each mining request in the set to be elected for the new height, the base chain miners determine the leader of the proposal group for the block of the application chain at the new height. There are different implementation methods:
例如,若之前应用链矿工在推选提案组成员时使用了第二随机值,则基链矿工首先可以根据针对新高度的待选举集合中的每个挖矿请求中的第一可证明字串计算该挖矿请求对应的第二随机值,其具体过程可以是:先基于第一可证明字串利用预设的规则推导第一随机值,然后根据第一随机值以及发送挖矿请求的应用链矿工的提案组参选权重计算第二随机值(计算公式可参考前文)。之前也提到,提案组参选权重可以基于基链账本中的信息确定,例如,定义为应用链矿工在预设历史时间段内当选为提案组领导人的次数。基链矿工本地保存有基链账本,自然可以统计出应用链矿工的当选次数,当然为提高当选次数的统计速度,在基链矿工处也可以基于基链账本中的信息构建数据库或内存表格,方便查询。For example, if the application chain miners used the second random value when selecting the members of the proposal group, the base chain miners can first calculate according to the first provable string in each mining request in the set to be elected for the new height The specific process of the second random value corresponding to the mining request can be: first derive the first random value based on the first provable string using preset rules, and then according to the first random value and the application chain that sent the mining request The second random value is calculated for the weight of the miner's proposal group participation (for the calculation formula, please refer to the previous article). As mentioned earlier, the weight of the proposal group participation can be determined based on the information in the base chain ledger, for example, it is defined as the number of times the application chain miners are elected as the proposal group leader in a preset historical time period. The base chain miners store the base chain ledger locally, which can naturally count the number of elections of the application chain miners. Of course, in order to increase the speed of counting the number of elections, the base chain miner can also build a database or memory table based on the information in the base chain ledger. Convenient for inquiries.
基链矿工计算出每个挖矿请求对应的第二随机值后,会进一步利用一个预设的当选条件从中筛选出一个满足条件的第二随机值,并将该第二随机值对应的挖矿请求的发送者确定为应用链待挖区块的提案组领导人。当选条件可以是计算出的第二随机值最大、最小等,不作限定,但下面为简单起见,以选择最大的第二随机值为例进行阐述。After the base chain miners calculate the second random value corresponding to each mining request, they will further use a preset selection condition to filter out a second random value that meets the conditions, and then the second random value corresponding to the mining The sender of the request is determined as the leader of the proposal group of the block to be mined in the application chain. The selection condition can be the maximum or minimum calculated second random value, which is not limited, but for the sake of simplicity, the following is an example of selecting the largest second random value.
在一种可选的方案中,如果遇到多个挖矿请求对应的第二随机值均为最大的情况,可进一步获取能够标识这些挖矿请求对应的提案组成员的身份的信息(例如,提案组成员的公钥或者公钥的哈希值,其中矿工公钥携带在挖矿请求中),并利用获取到的信息按照一定的规则进一步比较,例如,让公钥或公钥的哈希值最大者当选提案组领导人。In an optional solution, if the second random value corresponding to multiple mining requests is the largest, further information that can identify the identities of the members of the proposal group corresponding to these mining requests can be obtained (for example, The public key or the hash value of the public key of the members of the proposal group, where the miner’s public key is carried in the mining request), and use the obtained information to further compare according to certain rules, for example, let the public key or the public key hash The person with the greatest value is elected as the leader of the proposal group.
在一种可选方案中,基链矿工还可以进一步检验最大的第二随机值是否大于预设的最小当选随机值,若大于最小当选随机值,才正式确定提案组领导人选举成功,否则针对应用链新高度的区块选举提案组领导人失败,对于失败的处理方式在步骤S103中阐述。In an optional scheme, the base chain miners can further check whether the largest second random value is greater than the preset smallest random value. If it is greater than the smallest random value, the leader of the proposal group will be formally determined that the election is successful, otherwise The block election proposal group leader of the new height of the application chain fails, and the processing method for the failure is described in step S103.
其中,设置最小当选随机值这一参数用于提高攻击难度,即便敌手伪造大量账号实施女巫攻击,这些账号对应的应用链矿工也只能以低概率当选提案组领导人,特别是对于提案组参选权重取提案组领导人当选次数的情况,按照第二随机值的计算规则,新加入的应用链矿工对应的提案组参选权重很小,最终计算出的第二随机值也较小,从而很可能在验证最小当选随机值的过程中被排除在外,不会将其选为提案组领导人。当然,防范女巫攻击也有其他手段,例如,当基链矿工发现突然出现大量从未参与挖 矿的应用链矿工请求挖矿时,直接拒绝这些应用链矿工的挖矿请求。在一种可选方案中,针对每条应用链可以设置一个连续挖矿标记参数,该参数至少可以取两个值(如True和False),分别表示允许同一应用链矿工连续当选提案组领导人以及不允许同一应用链矿工连续当选提案组领导人,这里的连续当选是指某一应用链矿工在应用链的连续两次出块(不考虑空块)中都被选为提案组领导人。若连续挖矿标记指示不允许同一应用链矿工连续当选提案组领导人,则基链矿工在根据最大的第二随机值确定了提案组领导人后,还要判断该提案组领导人是否为同一应用链的上一次提案组领导人选举中选出的提案组领导人,若是,则重新确定提案组领导人,将计算出的第二随机值次大的挖矿请求对应的应用链矿工确定为应用链待挖区块的提案组领导人。禁止同一应用链矿工连续当选提案组领导人有利于提高区块链系统的安全性,因为敌手更难连续获得记账权,结合最长链规则,双花攻击将更难实施。Among them, the parameter of setting the minimum elected random value is used to increase the difficulty of the attack. Even if the adversary forges a large number of accounts to carry out witch attacks, the application chain miners corresponding to these accounts can only be elected as the leader of the proposal group with a low probability, especially for the proposal group participants. The selection weight is based on the number of times the leader of the proposal group has been elected. According to the calculation rule of the second random value, the new application chain miner has a small participation weight corresponding to the proposal group, and the final calculated second random value is also small, so It is likely to be excluded from the process of verifying the minimum random value of the election and will not be selected as the leader of the proposal group. Of course, there are other methods to prevent Sybil attacks. For example, when basechain miners discover that a large number of application chain miners who have never participated in mining suddenly request mining, they directly reject the mining request of these application chain miners. In an optional solution, a continuous mining flag parameter can be set for each application chain. This parameter can take at least two values (such as True and False), which respectively indicate that miners of the same application chain are allowed to be successively elected leaders of the proposal group And the same application chain miner is not allowed to be continuously elected as the leader of the proposal group. The continuous election here means that a certain application chain miner is selected as the leader of the proposal group in two consecutive blocks (empty blocks are not considered) of the application chain. If the continuous mining flag indicates that the same application chain miner is not allowed to be successively elected as the leader of the proposal group, the base chain miner will determine whether the leader of the proposal group is the same after determining the leader of the proposal group according to the largest second random value. The proposal group leader selected in the last proposal group leader election of the application chain, if yes, then re-determine the proposal group leader, and determine the application chain miner corresponding to the mining request with the second largest random value calculated as The leader of the proposal group of the block to be mined in the application chain. Forbidding miners of the same application chain to be continuously elected as the leader of the proposal group is beneficial to improve the security of the blockchain system, because it is more difficult for adversaries to continuously obtain the right to keep accounts, combined with the longest chain rule, double-spending attacks will be more difficult to implement.
步骤S103:基链矿工将保存有应用链待挖区块的选举结果以及选举依据的基链区块纳入基链账本中。Step S103: The base chain miner incorporates the base chain block storing the election results of the application chain to be mined blocks and the basis of the election into the base chain ledger.
若在步骤S102中成功选出了应用链待挖区块的提案组领导人,基链矿工会将选举结果及选举依据打包到基链区块中,但需要注意,在基链采取某些共识算法时,有多个基链矿工都会打包基链区块,这些基链区块都记录应用链新高度的区块的选举结果,但最终只有获得记账权的基链矿工所出区块会在基链中传播并纳入基链账本,也就是说步骤S103中所述的基链区块实际上是指获得记账权的基链矿工所出区块,而步骤S102中选举提案组成员的基链矿工则是竞争记账权的矿工,而不一定是已获得记账权的矿工。If in step S102, the leader of the proposal group for the block to be mined in the application chain is successfully selected, the base chain miners union will pack the election results and election basis into the base chain block, but it needs to be noted that some consensus is adopted in the base chain During the algorithm, multiple base chain miners will package the base chain blocks. These base chain blocks all record the election results of the blocks with the new height of the application chain. In the end, only the blocks produced by the base chain miners who have obtained the accounting rights will be It is transmitted in the base chain and incorporated into the base chain ledger, that is to say, the base chain block described in step S103 actually refers to the block produced by the base chain miner who has obtained the accounting right, and the member of the proposal group is elected in step S102 Base chain miners are those who compete for the right to bookkeeping, not necessarily those who have obtained the right to bookkeeping.
下面介绍基链区块中应用链待挖区块的选举结果以及选举依据的可能的形式,其中,选举结果主要用于指明提案组领导人的身份以及该提案组领导人是针对哪个应用链区块选举的,选举依据主要用于记录选举提案组领导人的凭证,从而可供他人验证选举结果是否正确。The following describes the election results of the application chain to be mined in the base chain block and the possible forms of the election basis. Among them, the election results are mainly used to indicate the identity of the leader of the proposal group and which application chain area the leader of the proposal group is targeting. For block elections, the election basis is mainly used to record the credentials of the leader of the election proposal group, so that others can verify whether the election result is correct.
在一种实现方式中,选举结果包括从应用链的提案组领导人发送的针对应用链待挖区块的挖矿请求中获取的提案候选信息,每个基链区块针对每条应用链最多记录一个选举结果,换句话说应用链上两个不同的区块的选举结果必然被记录在两个不同的基链区块中。选举结果作为选举结果列表中的一个表项保存在基链区块的区块体中,选举结果列表中可以包括多个表项,每个表项对应一条应用链上的一个待挖区块的选举结果。在一些现有区块链系统中,区块的区块体中保存交易,根据这些交易进行多级哈希运算可以构建merkle树,而merkle根(merkle树的根节点)保存在区块头中。在本公开中,也可以采取类似的方式设计基链区块的结构,即基链区块的区块体中保存选举结果列表的表项,而根据这些表项计算出的merkle根保存在区块头中,为方便后文描述,记作merkle_root1。In one implementation, the election result includes the proposal candidate information obtained from the mining request sent by the leader of the proposal group of the application chain for the block to be mined in the application chain, and each base chain block has the maximum value for each application chain. Record an election result. In other words, the election results of two different blocks on the application chain must be recorded in two different base chain blocks. The election result is stored in the block body of the base chain block as an entry in the election result list. The election result list can include multiple entries, and each entry corresponds to a block to be mined on the application chain. Election results. In some existing blockchain systems, transactions are stored in the block body of a block, and a merkle tree can be constructed by performing multi-level hash operations on these transactions, and the merkle root (the root node of the merkle tree) is stored in the block header. In this disclosure, the structure of the base chain block can also be designed in a similar way, that is, the table items of the election result list are stored in the block body of the base chain block, and the merkle root calculated based on these table items is stored in the area. In the block header, it is recorded as merkle_root1 for the convenience of the following description.
选举依据包括从针对新高度的待选举集合中的挖矿请求中获取的提案候选信息的集合,因为应用链待挖区块的提案组领导人就是根据待选举集合中的挖矿请求选出的,所以将这些挖矿请求中的提案候选信息作为选举依据是合理的。可选的,提案组领导人对应的提案候选信息也可以不包含在选举依据中,因为在选举结果中已经包含该信息。选举依据作为选举依据列表中的一个表项保存在基链区块的区块体中,对于同一个表项中的各个提案候选信息,由于其中的应用链标识、并行链链号以及应用链待挖区块的高度三项信息是相同的,因此在存储时也可以只存储一次以便节省存储空间。选举依据列表中可以包括多个表项,每个表项对应一条应用链上的一个待挖区块的选举依据。在同一基链区块中,选举结果列表和选举依据列表具有相同的长度,各表项之间也具有一一对应关系。基链区块的区块体中保存选举依据列表的表项,而根据这些表项计算出的merkle根保存在区块头中,为方便后文描述,记作merkle_root2。The election basis includes a collection of proposal candidate information obtained from mining requests in the set to be elected for a new height, because the leader of the proposal group of the block to be mined in the application chain is selected based on the mining request in the set to be elected , So it is reasonable to use the proposal candidate information in these mining requests as the basis for election. Optionally, the proposal candidate information corresponding to the leader of the proposal group may not be included in the election basis, because the information is already included in the election result. Election basis is stored in the block body of the base chain block as an entry in the election basis list. For each proposal candidate information in the same entry, due to the application chain identification, parallel chain chain number, and application chain waiting information. The three pieces of information about the height of the mining block are the same, so it can be stored only once to save storage space. The election basis list can include multiple entries, and each entry corresponds to the election basis of a block to be mined on an application chain. In the same base chain block, the election result list and the election basis list have the same length, and each table item also has a one-to-one correspondence. The block body of the base chain block stores the entries of the election basis list, and the merkle root calculated based on these entries is stored in the block header, which is recorded as merkle_root2 for the convenience of the following description.
既然区块头中包含了merkle_root1和merkle_root2,意味着计算区块的哈希值时merkle_root1和merkle_root2也会作为其来源字串,也就是说,一旦基链区块的内容确定,选举结果列表、选举依据列表均纳入区块链的不可篡改机制之中。这里,在基链区块头记录merkle_root1和merkle_root2,表明基链采用了双merkle树结构。Since the block header contains merkle_root1 and merkle_root2, it means that merkle_root1 and merkle_root2 will also be used as the source strings when calculating the hash value of the block. That is to say, once the content of the base chain block is determined, the list of election results and the basis for election The lists are all incorporated into the non-tamperable mechanism of the blockchain. Here, merkle_root1 and merkle_root2 are recorded in the block header of the base chain, indicating that the base chain adopts a double merkle tree structure.
在本公开的方案中,基链用于为应用链提供算力,至于基链上是否可以发行数字 货币是可选的,如果基链上也发行数字货币,则基链区块的区块体中还可以记录交易以及挖矿信息,挖矿信息可以记录在区块体的首个交易(也称Coinbase)中,其内容包括对出块者、挖矿奖励等的描述。根据区块体中的交易以及挖矿信息可以组织merkle树,计算出的merkle根保存在区块头中,记作merkle_root3,此时基链采用了三merkle树结构。关于交易的内容是目前的区块链系统中已有的,不再具体说明。In the solution of the present disclosure, the base chain is used to provide computing power for the application chain. As for whether digital currency can be issued on the base chain, it is optional. If digital currency is also issued on the base chain, the block body of the base chain block It can also record transactions and mining information. The mining information can be recorded in the first transaction of the block (also known as Coinbase), and its content includes the description of the block producer, mining rewards, etc. According to the transaction and mining information in the block body, the merkle tree can be organized, and the calculated merkle root is stored in the block header, which is recorded as merkle_root3. At this time, the base chain adopts a three-merkle tree structure. The content of the transaction is already available in the current blockchain system and will not be described in detail.
在每个基链矿工将接收到的区块纳入本地的基链账本之前,都会先执行区块内容的验证,其内容可以包括:验证选举依据中的各提案候选信息中的第一可证明字串是否伪造(方法如前文所述);根据选举依据重复提案组领导人的选举过程,验证选出的领导人与选举结果中记录的是否一致;其他关于区块内容的常规验证(比如验证区块头内容、在区块中还包含交易时验证交易是否合法等)。若验证项目全部通过,基链矿工才会进行记账。Before each base chain miner puts the received block into the local base chain ledger, the verification of the block content will be performed first. The content can include: verifying the first provable word in the candidate information of each proposal in the election basis Whether the string is forged (the method is as described above); According to the election process of repeating the leader of the proposal group according to the election basis, verify whether the selected leader is consistent with the record in the election result; other regular verifications on the content of the block (such as verification area Block header content, verifying whether the transaction is legal when the transaction is included in the block, etc.). If all the verification items are passed, the base chain miners will perform accounting.
上面阐述了应用链待挖区块选举提案组领导人成功的情况,实际中新高度的应用链待挖区块选举失败也是可能的,在步骤S102中提到了两种可能的失败原因,也不排除其他导致选举失败的原因。若某条应用链的待挖区块选举提案组领导人失败,则在基链本次产生的区块中不会记录相应的选举结果及选举依据,若基链区块采用选举结果列表、选举依据列表的形式实现,两个列表中与该应用链对应的表项中都置空,当然,每条应用链上的提案组领导人选举是相互独立的,其他表项的内容不受影响。The above describes the success of the election proposal group leader of the application chain to be mined block. In fact, it is also possible for the new height of the application chain to be mined block election to fail. In step S102, two possible reasons for failure are mentioned, neither Exclude other reasons for the election failure. If the leader of the election proposal group of the block to be mined of an application chain fails, the corresponding election results and election basis will not be recorded in the block generated this time on the base chain. If the base chain block adopts the election result list and election According to the form of the list, the entries in the two lists corresponding to the application chain are left blank. Of course, the election of the leader of the proposal group on each application chain is independent of each other, and the contents of other entries are not affected.
若针对应用链在新高度的区块选举提案组领导人失败,一种简单的处理方式是推迟到基链下次出块时再次尝试为应用链新高度的区块选举提案组领导人。另一种复杂一些的处理方式是先尝试在应用链新高度之前的若干旧高度重选提案组领导人,若在某一旧高度处尝试成功,则重挖该旧高度处的应用链区块,若全都不成功,才推迟到基链下次出块时再次尝试为应用链新高度的区块选举提案组领导人。下面具体介绍后一种方式:If the leader of the proposal group fails to be elected for the block at the new height of the application chain, a simple way is to postpone it until the next block generation of the base chain and try to elect the leader of the proposal group for the block of the new height of the application chain. Another more complicated approach is to first try to reselect the leader of the proposal group at a number of old heights before the new height of the application chain. If the attempt is successful at an old height, then re-dig the application chain block at the old height. , If all are unsuccessful, it will be postponed until the next block generation of the base chain to try to elect the leader of the proposal group for the new height of the application chain. The latter method is specifically introduced below:
若基链矿工根据针对新高度的待选举集合中的挖矿请求选举新高度的区块的提案组领导人失败,则首先确定应用链中与应用链待挖区块相邻的且已经选出提案组领导人的区块所在的旧高度,其中,旧高度在应用链中低于新高度,上述相邻的含义是指在忽略应用链中的空块意义上的相邻。If the base chain miner fails to elect the leader of the proposal group for the new height block based on the mining request in the new height waiting to be elected set, first determine that the application chain adjacent to the application chain to be mined block in the application chain has been selected The old height of the block of the leader of the proposal group, where the old height is lower than the new height in the application chain, and the above-mentioned adjacent meaning refers to adjacent in the sense of ignoring empty blocks in the application chain.
确定好旧高度后,基链矿工从缓存的挖矿请求中选择匹配于旧高度的挖矿请求纳入针对旧高度的待选举集合,所谓匹配是指挖矿请求中的应用链待挖区块的高度一项与旧高度一致。注意,由于旧高度的应用链区块之前已经成功选举出提案组领导人了,所以在应用链矿工发起的所有针对旧高度的应用链区块的挖矿请求中,有一部份在之前成功选举时已经使用过了,这部分挖矿请求不会再重用(否则可能导致在旧高度重选提案组领导人结果不变),即此时基链矿工收集的匹配于旧高度的挖矿请求是指那些尚未被使用过的且针对于旧高度的挖矿请求。After determining the old height, the base chain miners select the mining request matching the old height from the cached mining requests and include them in the waiting set for the old height. The so-called matching refers to the block to be mined in the application chain in the mining request. The height item is consistent with the old height. Note that since the application chain block of the old height has successfully elected the leader of the proposal group, some of the mining requests for the application chain block of the old height initiated by the application chain miners have been successfully elected before. Time has already been used, and this part of the mining request will not be reused (otherwise, the result of reselecting the leader of the proposal group at the old altitude may not change), that is, the mining requests that match the old altitude collected by the base chain miners at this time are Refers to those mining requests that have not been used and targeted at the old height.
之后,基链矿工根据针对旧高度的待选举集合中的挖矿请求重新选举应用链在旧高度的区块的提案组领导人,选举方式和之前选举应用链在新高度的区块的提案组领导人类似,不再展开阐述。若选举成功,则在本次所出基链区块中保存选举结果以及选举依据。若选举失败,则重复上面的过程,即先确定与当前选举提案组领导人的应用链高度的相邻的旧高度,然后针对该旧高度执行收集挖矿请求以及选举提案组领导人的操作(简称重挖旧块,相应的针对新高度选举提案组领导人的操作可以简称挖新块),直至满足以下两个条件之一,停止重挖旧块:After that, the base chain miners re-elect the proposal group leader of the block of the application chain at the old height according to the mining request in the waiting set for the old height, the election method and the previous election of the proposal group of the block of the application chain at the new height The leaders are similar, so I won't elaborate on it. If the election is successful, the results of the election and the basis for the election will be saved in the base chain block. If the election fails, repeat the above process, that is, first determine the old height adjacent to the application chain height of the current election proposal group leader, and then perform the operations of collecting mining requests and electing the proposal group leader for the old height ( Referred to as re-mining old blocks, the corresponding operations for the leaders of the new height election proposal group can be referred to as mining new blocks), until one of the following two conditions is met, stop re-mining old blocks:
其一,针对应用链的某一旧高度的区块选举提案组领导人成功。此时,在本次所出基链区块中保存该旧高度的区块的选举结果以及选举依据。可以理解的,若在应用链的某一旧高度选举提案组领导人成功,可能导致该旧高度的区块重新出块,应用链中串接在其后的区块也全部作废,需要重挖。First, the leader of the proposal group was successfully elected for a block at an old height of the application chain. At this time, the election result and the basis of the election of the block of the old height are stored in the base chain block that was released this time. It is understandable that if the leader of the proposal group is successfully elected at an old height of the application chain, it may cause the block of the old height to be re-produced, and all the blocks connected after it in the application chain are also invalid and need to be re-mined. .
其二,重挖旧块达到预设的次数限制。比如,以该次数限制取3为例,假设应用链的新高度为100,若选举新高度的区块的提案组领导人失败,则在基链本次出块期间,基链矿工最多可在应用链的旧高度99、98、97处尝试上述重挖旧块操作,若在上述三个旧高度处仍然不能成功选举提案组领导人,则不再继续尝试。Second, re-dig old blocks to reach the preset limit of times. For example, taking the number limit of 3 as an example, assuming that the new height of the application chain is 100, if the leader of the proposal group of the new height block fails, during the current block generation period of the base chain, the base chain miners can be at most At the old heights 99, 98, and 97 of the application chain, try the above-mentioned re-digging of old blocks. If the leader of the proposal group cannot be successfully elected at the above three old heights, no further attempts will be made.
最后,若是因为上面的第二种原因导致的停止重挖旧块,则在基链下次出块时再 针对应用链在新高度的区块选举提案组领导人,若还是不能选举成功,又尝试重挖旧块,如此重复下去。Finally, if the re-mining of old blocks is stopped due to the second reason above, the leader of the proposal group will be elected for the block of the application chain at a new height when the base chain is next produced. If the election still fails, then Try to re-dig the old block and repeat.
但需要注意的是,若基链本次出块选举提案组领导人未成功(不管是在新高度还是旧高度),在基链本次出块时使用的针对新高度的挖矿请求在基链下次出块时就不会再被用于选举新高度的区块的提案组领导人(但在之后可以被作为针对旧高度的挖矿请求用于重挖旧块),因为基链的出块导致基链账本的变化,挖矿请求中的第一可证明字串的值也会变化(因用于计算第一可证明字串的第一选举字串的值发生变化导致),挖矿请求中的确定提案组领导人的基链区块的高度也会变化,基链矿工需要重新汇集新的挖矿请求。However, it should be noted that if the leader of the proposal group for the block generation election of the base chain is unsuccessful (regardless of whether it is at the new height or the old height), the mining request for the new height used in the block generation of the base chain is in the base chain. The next time the chain is produced, it will no longer be used to elect the leader of the proposal group of the block of the new height (but it can be used as a mining request for the old height to re-mine the old block), because the base chain Block production leads to changes in the base chain ledger, and the value of the first provable string in the mining request will also change (due to the change in the value of the first election string used to calculate the first provable string), mining The height of the base chain block that determines the leader of the proposal group in the mining request will also change, and the base chain miners need to reassemble new mining requests.
相对应的,在基链本次出块时使用的针对旧高度的挖矿请求在基链下次出块时还可以重用,因为重挖旧块操作与基链区块的高度不绑定,即一个应用链旧高度的区块选举提案组领导人成功后,直接将选举结果和选举依据记录在基链最新的出块中,而不是记录在用于选举的挖矿请求中的指定高度(指挖矿请求中的确定提案组领导人的基链区块的高度一项)的基链区块中。而挖新块操作与基链区块的高度绑定,即应用链新高度的区块选举提案组领导人成功后,选举结果和选举依据必须记录在用于选举的挖矿请求中的指定高度(指挖矿请求中的确定提案组领导人的基链区块的高度一项)的基链区块中。Correspondingly, the mining request for the old height used in the current block generation of the base chain can be reused in the next block generation of the base chain, because the operation of re-mining old blocks is not tied to the height of the base chain block. That is, after the leader of the block election proposal group with the old height of the application chain succeeds, the election result and election basis are directly recorded in the latest block of the base chain, instead of recording the specified height in the mining request for election ( Refers to the base chain block that determines the height of the base chain block of the leader of the proposal group in the mining request. The new block mining operation is tied to the height of the base chain block, that is, after the leader of the block election proposal group of the new height of the application chain is successful, the election result and election basis must be recorded in the specified height of the mining request for election (Refers to the base chain block height of the base chain block that determines the leader of the proposal group in the mining request).
对于一个挖矿请求,基链矿工根据其中应用链待挖区块的高度这一项信息便可以区分其为针对新高度的挖矿请求还是针对旧高度的挖矿请求,从而采取不同的处理方式。对于针对旧高度的挖矿请求,由于挖矿请求中已经指定确定提案组领导人的基链区块的高度,根据该高度可获此时的第一选举字串(如,取该高度的前L区块中的信息),进而用于请求中第一可证明字串的验证,验证通过后该挖矿请求即可被用于针对旧高度的区块的提案组领导人选举。对于挖新块和挖旧块的挖矿请求采取不同处理方式的原因在于:For a mining request, the base chain miner can distinguish whether it is a mining request for a new height or a mining request for an old height based on the information of the height of the block to be mined in the application chain, and adopt different processing methods. . For the mining request for the old height, since the height of the base chain block to determine the leader of the proposal group has been specified in the mining request, the first election string at this time can be obtained according to this height (for example, take the first election string of the height). The information in the L block) is further used for the verification of the first provable string in the request. After the verification is passed, the mining request can be used for the election of the leader of the proposal group for the block of the old height. The reasons for the different processing methods for mining requests for mining new blocks and mining old blocks are:
在一些实现方式中,应用链矿工可以提前验证前一区块并提前发出针对新高度的挖矿请求(有关提前验证见后文内容),从而请求有较充分的时间在基链中传播,因此虽然针对新高度的挖矿请求只在本次基链出块期间有效,针对新高度的区块选出提案组领导人的概率也较高。但针对旧高度的挖矿请求则未必能充分传播(已经有效传播的,在之前选出旧高度处的提案组领导人时已经使用过了,不能重复使用),因此允许在基链多次出块的过程中,尽可能接收更多的针对旧高度的挖矿请求(这些请求之前可能未及时传播),再加上若重挖旧块未成功,针对旧高度的挖矿请求可以重用,有利于在旧高度重新选举提案组领导人成功。In some implementations, application chain miners can verify the previous block in advance and issue a mining request for a new height in advance (see the following content for advance verification), so that the request has sufficient time to spread in the base chain, so Although the mining request for the new height is only valid during the block generation period of the base chain, the probability of selecting the leader of the proposal group for the block of the new height is also higher. However, the mining request for the old height may not be able to be fully disseminated (the ones that have been effectively disseminated, have been used before the leader of the proposal group at the old height, and cannot be reused), so it is allowed to publish multiple times on the base chain. During the block process, as many mining requests for the old height as possible (these requests may not have been propagated in time), plus if the old block is unsuccessfully re-mined, the mining request for the old height can be reused. Conducive to the successful re-election of the leader of the proposal group at the old height.
下面简单分析允许旧块重挖的原因:基链负责为应用链选出提案组领导人,但并不预设选出的提案组领导人在应用链中能否发挥作用(发挥作用指成功出块并且所出区块被纳入应用链账本),若没有发挥作用,作为一种补救措施,推倒重来是允许的,重挖旧块就是实现推导重来的具体措施。导致提案组领导人在应用链中未能发挥作用的原因有多种:例如,基链认为应用链的某高度的区块已选出提案组领导人,但该提案组领导所出区块未通过验证组成员的验证,或者,验证组成员出具的检验报告因为通信原因未能有效传递导致该区块未通过验证(有关验证过程见后文内容),即该区块未获应用链认可;又例如,虽然基链和应用链都遵循最长链规则,但二者并不是完全同步的,即基链的最长链并不一定对应应用链的最长链,从而基链按照最长链规则切换到新分支,该新分支上最近选出的提案组领导人可能对应于应用链最长链的旧高度上的区块(而不是最高区块),并且还有可能和应用链最长链在该旧高度的区块上已确定的提案组领导人不同;当然还可能包括其他原因,不再列举。总之,允许在应用链上重挖旧块有利于消除应用链中的软分叉以及异常。The following is a simple analysis of the reasons for allowing the re-mining of old blocks: the base chain is responsible for selecting the leader of the proposal group for the application chain, but it does not presuppose whether the selected proposal group leader can play a role in the application chain (playing a role means successfully If it does not play a role, as a remedy, it is permissible to overturn and re-dig the old block, and re-dig the old block is a specific measure to achieve the derivation and re-start. There are many reasons why the leader of the proposal group fails to play a role in the application chain: For example, the base chain believes that a certain height block of the application chain has selected the proposal group leader, but the proposal group leader’s block has not been selected. Pass the verification of the members of the verification group, or the verification report issued by the members of the verification group fails to pass the verification due to communication reasons that cannot be effectively transmitted (see the following content for the verification process), that is, the block is not approved by the application chain; For another example, although both the base chain and the application chain follow the longest chain rule, they are not completely synchronized, that is, the longest chain of the base chain does not necessarily correspond to the longest chain of the application chain, so the base chain follows the longest chain The rule switches to a new branch. The recently selected leader of the proposal group on the new branch may correspond to the block at the old height of the longest chain of the application chain (rather than the highest block), and may also be the longest block of the application chain. The chain has different leaders of the proposal group on the block of the old height; of course, it may also include other reasons, which will not be listed. In short, allowing the re-mining of old blocks in the application chain helps eliminate soft forks and exceptions in the application chain.
上面介绍了有关旧块重挖的内容,但在后文阐述时,将仍然聚焦于位于新高度的应用链待挖区块,对于重挖产生的旧块,处理方式和新块是类似的。The above introduces the content of re-mining old blocks, but in the following description, we will still focus on the application chain blocks to be mined at new heights. For the old blocks generated by re-mining, the processing method is similar to the new block.
步骤S104:应用链矿工从基链矿工处同步确定应用链待挖区块的提案组领导人的基链区块的基链区块信息。Step S104: The application chain miner synchronously determines the base chain block information of the base chain block of the proposal group leader of the block to be mined in the application chain from the base chain miner.
应用链矿工要获知应用链待挖区块的选举结果,需从基链矿工处同步基链区块信 息,该基链区块信息来源于确定应用链待挖区块的提案组领导人的基链区块,基链区块信息中至少包括指明应用链待挖区块的提案组领导人的选举结果。根据在阐述图1时提到的,在一种实现方式中,应用链矿工直接从基链矿工处同步相关数据,在另一种实现方式中,应用链矿工间接从基链矿工处同步相关数据:基链中可以设置同步节点,应用链矿工可以从同步节点处同步相关数据,而同步节点的数据则同步自基链矿工或者其他同步节点,由于前一种实现方式可以视为基链矿工兼顾了同步节点的功能,因此下面主要介绍后一种方式的具体实现。Application chain miners need to synchronize the base chain block information from the base chain miners in order to know the election results of the application chain to be mined blocks. The base chain block information comes from the base of the leader of the proposal group that determines the application chain to be mined. Chain block, the base chain block information includes at least the election result of the leader of the proposal group specifying the block to be mined in the application chain. According to what was mentioned in the description of Figure 1, in one implementation, the application chain miners directly synchronize related data from the base chain miners, and in another implementation mode, the application chain miners indirectly synchronize related data from the base chain miners. : Synchronization nodes can be set in the base chain, application chain miners can synchronize related data from the synchronization node, and the data of the synchronization node is synchronized from the base chain miners or other synchronization nodes, because the former implementation method can be regarded as the base chain miners. In order to achieve the function of the synchronization node, the following mainly introduces the specific implementation of the latter method.
基链区块信息可以采用的形式至少包括以下三种之一:Base chain block information can take at least one of the following three forms:
其一,采用确定应用链待挖区块的提案组领导人的基链区块本身。同步节点从基链矿工处获取基链区块(可以是经过基链矿工验证的区块,当然也不排除同步节点自己验证),然后应用链矿工再从同步节点处获取基链区块,最后在应用链矿工本地形成基链账本(当然,基链区块信息纳入账本前可做简单验证)。以上所述的获取,既可以是主动请求也可以是被动接收的方式。One is to use the base chain block itself of the leader of the proposal group that determines the block to be mined in the application chain. The synchronization node obtains the base chain block from the base chain miner (it can be a block verified by the base chain miner, of course, it does not rule out the verification of the synchronization node itself), and then the application chain miner obtains the base chain block from the synchronization node, and finally The base chain ledger is formed locally by the application chain miners (of course, simple verification can be done before the base chain block information is included in the ledger). The above-mentioned acquisition can be either an active request or a passive receiving method.
其二,采用基链区块的区块头以及基链区块的区块体中的选举结果列表。选举结果列表的结构在上文已经介绍,该表中的每个表项对应一条应用链上的一个待挖区块的选举结果,其中也包括应用链待挖区块的提案组领导人的选举结果。相较于第一种形式,考虑到基链区块中的选举依据等内容应用链矿工未使用,因此可以不包含在基链区块信息中,以降低数据同步开销。Second, use the block header of the base chain block and the election result list in the block body of the base chain block. The structure of the election result list has been introduced above. Each entry in the table corresponds to the election result of a block to be mined on an application chain, which also includes the election of the leader of the proposal group of the block to be mined on the application chain. result. Compared with the first form, considering that the election basis in the base chain block is not used by the application chain miners, it may not be included in the base chain block information to reduce data synchronization overhead.
在一种可选的方案中,同步节点从基链矿工处或者其他同步节点处获取基链区块的区块头以及选举结果列表,然后应用链矿工再从同步节点处获取基链区块的区块头以及选举结果列表,最后在应用链矿工本地形成基链账本(当然,基链区块信息纳入账本前可做简单验证),该基链账本中的区块的区块头和基链区块相同,区块体中则只包含基链区块中的选举结果列表,即是一种简化的基链账本。In an optional scheme, the synchronization node obtains the block header and the election result list of the base chain block from the base chain miner or other synchronization nodes, and then the application chain miner obtains the area of the base chain block from the synchronization node. The block header and the election result list, and finally the base chain ledger is formed locally by the application chain miners (of course, the base chain block information can be simply verified before being included in the ledger), and the block header of the block in the base chain ledger is the same as the base chain block , The block body only contains the list of election results in the base chain block, which is a simplified base chain ledger.
其三,采用基链区块的区块头以及基链区块的区块体中针对应用链的片断数据。其中,片断数据包括选举结果列表中针对应用链待挖区块的提案组领导人的选举结果,以及,该选举结果与基链区块的区块头中基于选举结果列表计算出的merkle根(即前文的merkle_root1)之间的merkle路径。在基链区块信息的第二种形式中,选举结果列表中仍然包含各应用链中的选举结果,然而,对于应用链待挖区块所在的应用链,除它自身以外的其他应用链的上的选举结果并不需要关心,因此,只要在基链区块信息中保留区块头以及区块体中和该应用链有关的片断数据即可,这样可以进一步降低数据同步开销,在常见的应用场景中,一条基链可以服务于数百条应用链,若采取第三种基链区块信息的形式,数据传输量的节约相当可观。在片断数据中,merkle路径由一系列哈希值构成,可用于验证片断数据中针对应用链待挖区块的提案组领导人的选举结果未被伪造,在现有技术中,merkle路径可用于验证某个交易是否被伪造,这里的验证原理是类似的,不再具体阐述。Third, use the block header of the base chain block and the fragment data for the application chain in the block body of the base chain block. Among them, the fragment data includes the election result of the leader of the proposal group for the block to be mined in the application chain in the election result list, and the merkle root (that is, the merkle root calculated based on the election result list in the block header of the base chain block). The merkle path between merkle_root1) mentioned above. In the second form of base chain block information, the election result list still contains the election results in each application chain. However, for the application chain where the block to be mined in the application chain is located, other application chains other than itself You do not need to care about the election results on the above. Therefore, as long as the block header and the fragment data related to the application chain in the block body are retained in the base chain block information, this can further reduce the data synchronization overhead. In common applications In the scenario, one base chain can serve hundreds of application chains. If the third type of base chain block information is adopted, the amount of data transmission can be saved considerable. In the fragment data, the merkle path is composed of a series of hash values, which can be used to verify that the election result of the leader of the proposal group for the block to be mined in the application chain in the fragment data has not been forged. In the prior art, the merkle path can be used To verify whether a certain transaction has been forged, the verification principle here is similar and will not be elaborated.
在一种可选的方案中,同步节点从基链矿工处或者其他同步节点处获取基链区块的区块头以及选举结果列表,然后应用链矿工再从同步节点处获取基链区块的区块头以及针对该矿工所在应用链的片断数据,最后在应用链矿工本地形成基链账本(当然,基链区块信息纳入账本前可做简单验证),该基链账本中的区块的区块头和基链区块相同,区块体中则只包含针对本应用链的片断数据,即是一种进一步简化的基链账本。In an optional scheme, the synchronization node obtains the block header and the election result list of the base chain block from the base chain miner or other synchronization nodes, and then the application chain miner obtains the area of the base chain block from the synchronization node. The block header and the fragment data for the application chain where the miner is located, and finally the base chain ledger is formed locally in the application chain miner (of course, the base chain block information can be simply verified before being included in the ledger), and the block header of the block in the base chain ledger Like the base chain block, the block body only contains fragments of data for the application chain, which is a further simplified base chain ledger.
无论基链区块信息采用何种形式,其中都包含应用链待挖区块的提案组领导人的选举结果,根据前文,该选举结果的内容包括从提案组领导人发送的针对应用链待挖区块的挖矿请求中获取的提案候选信息,至少包括应用链标识、并行链链号、应用链待挖区块的高度、确定提案组领导人的基链区块的高度、应用链矿工公钥以及第一可证明字串六项信息。Regardless of the form of the base chain block information, it contains the election result of the leader of the proposal group of the application chain to be mined. According to the previous article, the content of the election result includes the information sent from the leader of the proposal group for the application chain to be mined The proposal candidate information obtained in the mining request of the block includes at least the application chain identifier, the parallel chain chain number, the height of the block to be mined in the application chain, the height of the base chain block that determines the leader of the proposal group, and the application chain miner’s public The key and the first provable string of six pieces of information.
进一步的,在一些实现方式中,可以进一步将选举结果简化为只包含两项信息,提案组领导人的矿工标识以及应用链待挖区块的高度。其中,提案组领导人的矿工标识基于提案组领导人发送的挖矿请求中的应用链标识、并行链链号以及应用链矿工公钥三项信息,利用哈希算法进行计算,其算法和前文提到的应用链矿工的标识相同(因为提案组领导人本来也属于应用链矿工);应用链待挖区块的高度则可以直接复制自 提案组领导人发送的挖矿请求中的应用链待挖区块的高度一项。例如,在一种具体实现中,提案组领导人的矿工标识为一个32字节的哈希值,应用链待挖区块的高度为4字节整数,二者总共占36字节。假设基链服务于300条应用链,以基链区块信息采用上述第二种实现方式为例,300个表项的选举结果列表总共只占10.8KB,再加上区块头大约占11KB,这样少的数据量应用链矿工同步起来很容易。Furthermore, in some implementations, the election result can be further simplified to include only two pieces of information, the miner ID of the leader of the proposal group and the height of the block to be mined in the application chain. Among them, the miner ID of the leader of the proposal group is based on the application chain ID, the parallel chain number and the public key of the application chain miner in the mining request sent by the leader of the proposal group. The hash algorithm is used for calculation. The identity of the mentioned application chain miners is the same (because the leader of the proposal group originally belongs to the application chain miner); the height of the block to be mined in the application chain can be directly copied from the application chain waiting in the mining request sent by the proposal group leader The height of the mining block. For example, in a specific implementation, the miner identification of the leader of the proposal group is a 32-byte hash value, and the height of the block to be mined in the application chain is a 4-byte integer, and the two occupy 36 bytes in total. Assuming that the base chain serves 300 application chains, taking the second implementation of the base chain block information as an example, the election result list of 300 entries only occupies 10.8KB, plus the block header occupies about 11KB. Such a small amount of data is easy to synchronize with chain miners.
不仅仅是基链向同步节点同步基链区块信息时其中的选举结果可以采用上述简化形式,同步节点向基链矿工或其他同步节点同步数据时,其中的选举结果也可以采用上述简化形式,甚至在基链矿工本地保存的基链区块中,选举结果列表中的表项(每个表项对应一选举结果)也可以采用上述简化形式,可以理解的,在选举结果列表中的表项采用选举结果的简化形式后,对基链区块的结构并无其他影响,区块头中仍然保存基于选举结果列表的表项计算出的merkle根。在基链矿工本地的基链区块中,由于选举依据列表中保存有选举结果的备份(选举结果对应的挖矿请求必然也是选举所依据的挖矿请求之一),因此可随时恢复任一选举结果的原始形式。Not only does the election result when the base chain synchronizes the base chain block information with the synchronization node can adopt the above simplified form, when the synchronization node synchronizes data with the base chain miner or other synchronization nodes, the election result can also adopt the above simplified form. Even in the base chain block stored locally by the base chain miners, the items in the election result list (each item corresponds to an election result) can also adopt the above simplified form. It is understandable that the items in the election result list After adopting the simplified form of the election results, it has no other impact on the structure of the base chain block. The merkle root calculated based on the entries in the election result list is still stored in the block header. In the local base chain block of the base chain miners, since the election basis list saves the backup of the election results (the mining request corresponding to the election result must also be one of the mining requests based on the election), any one can be restored at any time The original form of the election results.
对于基链中的同步节点,可以从基链中的挖矿节点或者其他同步节点同步数据,但是基链中的挖矿节点不会从同步节点同步数据(因为挖矿节点要保证数据的完整性,不能同步简化版本的数据)。每个节点在加入基链后,与其他节点之间建立连接,可以告知对方自己的属性(是挖矿节点还是同步节点),从而节点之间在相互同步数据时会根据对方的属性采取不同的操作。For the synchronization node in the base chain, data can be synchronized from the mining node in the base chain or other synchronization nodes, but the mining node in the base chain will not synchronize data from the synchronization node (because the mining node must ensure the integrity of the data , The simplified version of the data cannot be synchronized). After each node joins the base chain, it establishes a connection with other nodes and can inform each other of its own attributes (whether it is a mining node or a synchronization node), so that when the nodes synchronize data with each other, they will adopt different attributes according to each other’s attributes. operating.
之前提到,应用链或基链上可以构建查询表格,用于查询应用链矿工在预设的历史时间段(对应若干基链区块)内当选提案组领导人的次数,作为应用链矿工的提案组参选权重。在这里给出该表格的一种可能的实现方式,该表格中包括三个字段:提案组领导人的矿工标识、当选提案组领导人的基链区块的高度(此处指区块在基链中的实际高度而非挖矿请求中指定的基链高度,因为重挖旧块操作的存在致使这两个高度不一定相同)以及应用链待挖区块的高度,三个字段中,最后一个字段为可选字段,前两个字段上可以设置索引,加快查询速度。As mentioned earlier, a query table can be built on the application chain or the base chain to query the number of times that the application chain miners have been elected leaders of the proposal group in a preset historical time period (corresponding to several base chain blocks), as the application chain miners Proposal group participation weight. A possible implementation of the form is given here. The form includes three fields: the miner ID of the leader of the proposal group, the height of the base chain block of the elected leader of the proposal group (here refers to the block in the base The actual height in the chain is not the height of the base chain specified in the mining request, because the existence of remining old blocks makes these two heights not necessarily the same) and the height of the block to be mined in the application chain. In the three fields, the last One field is optional. Indexes can be set on the first two fields to speed up the query.
以应用链矿工为例,根据同步到的基链区块信息便可以构建该表格,基链区块信息中至少包括应用链待挖区块的选举结果。若该选举结果采用原始形式(即包含提案候选信息),表格中的第一个字段的值根据提案候选信息中的应用链标识、并行链链号、应用链矿工公钥即可计算,第二个字段的值直接复制自提案候选信息中的确定提案组领导人的基链区块的高度,第三个字段直接复制自提案候选信息中的应用链待挖区块的高度。若该选举结果采用简化形式,则表格中的第一、第三个字段的值可以直接从选举结果中复制,并且由于应用链矿工本地保存有基链账本,从而根据基链区块信息中的区块头,基链区块信息形成的区块要串接到基链的哪个分支的哪个位置是明确的,第二个字段的值也可以确定。Taking the application chain miner as an example, the table can be constructed based on the synchronized base chain block information. The base chain block information includes at least the election results of the application chain to be mined blocks. If the election result is in the original form (that is, it contains proposal candidate information), the value of the first field in the form can be calculated based on the application chain identifier, parallel chain chain number, and application chain miner public key in the proposal candidate information. The value of this field is directly copied from the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, and the third field is directly copied from the height of the application chain block to be mined in the proposal candidate information. If the election result is in a simplified form, the values of the first and third fields in the table can be directly copied from the election results, and because the application chain miners store the base chain ledger locally, according to the information in the base chain block Block header, the block formed by the block information of the base chain should be connected to which branch of the base chain which position is clear, and the value of the second field can also be determined.
步骤S105:应用链矿工参与应用链待挖区块的验证组成员的推选。Step S105: The application chain miners participate in the selection of the members of the verification group of the block to be mined in the application chain.
步骤S106:若确定应用链矿工被推选为应用链待挖区块的验证组成员,则对提案组领导人所出区块进行验证,验证结果写入检验报告并向其他应用链矿工广播检验报告。Step S106: If it is determined that the app chain miner is selected as a member of the verification group of the block to be mined in the app chain, the block produced by the leader of the proposal group is verified, the verification result is written into the inspection report and the inspection report is broadcast to other app chain miners .
以上两个步骤合并在一起阐述,在阐述之前,首先介绍一下全员验证的概念。在本公开的方案中,提供新区块(提案环节)与验证新区块(验证环节)是保障区块链系统安全性的最关键的两个环节,敌手控制这两项中任一项还无法直接达到破解目的,必须两项都控制才行。这两项中,验证环节对于安全性而言更重要,因为组织非法的区块内容从原理上分析难以完全抵御攻击,例如,敌手如果潜伏一个应用链矿工,只在它得知自己被推选为提案组领导人时才作恶,在提案环节中难以对其进行管控。但在验证环节中则可以管控,最严格的管控便是全员验证,即所有应用链矿工对任何新区块都做完整验证,验证通过才将其纳入应用链账本。然而,全员验证效率较低,虽然在一些现有的区块链系统(如比特币)中,对全员验证作了一定的限制:对历史区块(非最近产生的区块)只做简单验证,而非完整验证,但全员验证仍然对系统TPS影响很大。The above two steps are combined and explained. Before explaining, first introduce the concept of full-staff verification. In the solution of the present disclosure, providing a new block (proposal link) and verifying a new block (verification link) are the two most critical links to ensure the security of the blockchain system. The adversary cannot directly control either of these two links. To achieve the purpose of cracking, both must be controlled. Of these two, the verification link is more important for security, because the organization of illegal block content is difficult to completely defend against attacks from a theoretical analysis. For example, if an adversary lurks an application chain miner, only when it learns that it has been elected as a miner The leader of the proposal group only acts evil when it comes to the proposal, and it is difficult to control it during the proposal process. But in the verification process, it can be controlled. The most stringent control is full-staff verification, that is, all application chain miners complete verification of any new block, and only after the verification is passed can it be included in the application chain ledger. However, the efficiency of full-member verification is low. Although in some existing blockchain systems (such as Bitcoin), full-member verification is restricted: only historical blocks (non-recently generated blocks) Simple verification, not complete verification, but full verification still has a great impact on the system TPS.
在本公开的方案中,在安全性和TPS之间进行了折衷考虑,采用从全部的应用 链矿工中组建验证组的方式进行区块验证,验证组是满足预设规则的应用链矿工的集合,只有验证组成员有权对新出区块做完整验证并出具检验报告,其他应用链矿工只是简单地收集检验报告并根据检验报告适当统计后得出最终的验证结论(当然验证组成员也会收集检验报告)。验证组中的应用链矿工的数量可以只占应用链矿工总数量的一小部分,例如1/10,这样在不考虑节点间通信瓶颈的前提下,区块链系统的TPS也能够大约提升接近10倍。In the solution of the present disclosure, a compromise is considered between security and TPS, and a verification group is formed from all application chain miners for block verification. The verification group is a collection of application chain miners meeting preset rules. , Only the members of the verification team have the right to fully verify the new block and issue an inspection report. Other application chain miners simply collect the inspection report and make appropriate statistics based on the inspection report to reach the final verification conclusion (of course, the members of the verification team will also Collect inspection reports). The number of application chain miners in the verification group can only account for a small part of the total number of application chain miners, such as 1/10. In this way, without considering the communication bottleneck between nodes, the TPS of the blockchain system can also be approximately increased. 10 times.
当然,本公开中也可以增设全员验证标记这一参数,该参数至少可以取两个值(如True和False),分别表示采取全员验证和不采取全员验证,其中不采取全员验证即采取组建验证组的方式验证。若全员验证标记指示采取全员验证,则每个应用链矿工都会对提案组领导人所出区块进行完整验证(正在重建区块链数据库,处于追赶出块进度状态的矿工可以除外)。在后文中主要介绍采取组建验证组进行验证的方式。Of course, this disclosure can also add the parameter of the full-member verification flag. This parameter can take at least two values (such as True and False), which respectively indicate that the full-member verification is adopted and the full-member verification is not adopted, and the full-member verification is not adopted. That is, to adopt the method of forming a verification group to verify. If the all-member verification mark indicates that all-member verification is adopted, each application chain miner will complete the verification of the block produced by the leader of the proposal group (the blockchain database is being rebuilt, except for miners who are in a state of catching up with the progress of the block). In the following text, we mainly introduce the method of establishing a verification group for verification.
对于正在被挖矿的应用链待挖区块而言,验证组是指有权对提案组领导人所出区块进行验证并生成检验报告的应用链矿工的集合。提案组领导人所出区块其实就是提案组领导人打包的应用链待挖区块,但根据应用链不同的实现方式,可能有多个应用链矿工针对应用链同一高度打包应用链待挖区块,即可能产生多个应用链待挖区块,故此处在名称上稍加区分。For the application chain to be mined blocks that are being mined, the verification group refers to the collection of application chain miners who have the right to verify the blocks produced by the leader of the proposal group and generate inspection reports. The block produced by the leader of the proposal group is actually the application chain to be mined block packaged by the leader of the proposal group. However, according to different implementation methods of the application chain, there may be multiple application chain miners packing the application chain to be mined area for the same height of the application chain. Block, that is, multiple application chain blocks to be mined may be generated, so the name is slightly differentiated here.
推选应用链待挖区块的验证组成员可以分为至少一轮进行,当应用链矿工同步到确定应用链待挖区块的提案组领导人的基链区块信息后,就参与前P轮验证组成员的推选,之后应用链矿工每同步到一个基链区块信息,就参与新一轮验证组成员的推选,若满足以下循环终止条件之一,应用链矿工不再参与新一轮验证组成员的推选:The selection of the verification group members of the application chain to be mined blocks can be divided into at least one round. When the application chain miners synchronize to the base chain block information of the leader of the proposal group that determines the application chain to be mined blocks, they participate in the first P round The selection of verification group members. After that, the application chain miners will participate in a new round of selection of verification group members every time they synchronize with the information of a base chain block. If one of the following cycle termination conditions is met, the application chain miners will no longer participate in the new round of verification. Selection of group members:
其一,应用链矿工在已参与的推选轮次中确定自身被推选为验证组成员;其二,应用链矿工根据当前已接收到的检验报告能够得出提案组领导人所出区块验证通过的结论;其三,应用链矿工已参与的推选轮次已经达到预设的最大轮次MaxRounds(MaxRounds为正整数)。First, the application chain miners have determined that they are selected as members of the verification team in the selection rounds they have participated in; second, the application chain miners can conclude that the block produced by the proposal group leader has passed the verification based on the currently received inspection report Third, the selection rounds that the miners of the application chain have participated in have reached the preset maximum round MaxRounds (MaxRounds is a positive integer).
其中,1≤P≤MaxRounds,若应用链矿工在已参与的推选轮次中确定自身被推选为验证组成员,则对提案组领导人所出区块进行验证,向其他应用链矿工广播生成的检验报告(即执行步骤S106)。若P=1表明应用链矿工不可提前参与后续轮次的验证组成员的推选,若P>1表明应用链矿工可以提前参与后续轮次的验证组成员的推选。下面先介绍P=1的情况:Among them, 1≤P≤MaxRounds, if the application chain miner determines that he is elected as a member of the verification group in the selection rounds he has participated in, he will verify the block produced by the leader of the proposal group and broadcast the generated result to other application chain miners. Inspection report (that is, step S106 is executed). If P=1, it means that application chain miners cannot participate in the selection of verification group members in subsequent rounds in advance, and if P>1, it means that application chain miners can participate in the selection of verification group members in subsequent rounds in advance. The following first introduces the case of P=1:
验证组成员的推选可视为由基链出块驱动的,基链每出一块(应用链矿工也会对应同步基链区块信息)就进行一轮验证组成员的推选,每一轮验证组成员的推选,都可能选出若干验证组成员,若进行多轮推选,各轮次选出的验证组成员是叠加的,即随着轮次的增长验证组中的成员会越来越多,在某一轮次中被选为验证组成员的应用链矿工,在后续轮次中就不必参加验证组成员的推选了(上述循环终止条件一),验证组成员的身份可以一直保留。The selection of members of the verification group can be regarded as driven by the block generation of the base chain. Each block of the base chain (application chain miners will also correspond to the synchronization of the base chain block information) will carry out a round of verification group member selection, and each round of verification group In the selection of members, several verification group members may be selected. If multiple rounds of selection are carried out, the verification group members selected in each round are superimposed, that is, as the round grows, there will be more and more members in the verification group. Application chain miners who are selected as members of the verification group in a certain round do not need to participate in the selection of verification group members in subsequent rounds (the above cycle termination condition 1), and the identity of the verification group members can always be retained.
一旦被选为验证组成员,应用链矿工就会对提案组领导人所出区块进行验证、出具检验报告并在应用链中广播,每个验证组成员只生成一份检验报告,关于生成检验报告的过程稍后再进行阐述。应用链矿工在参选验证组成员的同时,同时也在接收验证组成员发送的检验报告,若根据已经收集到的检验报告能够确定提案组领导人所出区块验证通过,就不必继续参选验证组成员了(上述循环终止条件二)。例如,当前刚进入第三轮验证组成员推选,某个尚未被选为验证组成员的应用链矿工可以根据在前两轮推选中被选为验证组成员的应用链矿工出具的检验报告判断提案组领导人所出区块是否验证通过。Once selected as a member of the verification group, the application chain miners will verify the block produced by the leader of the proposal group, issue an inspection report and broadcast it in the application chain. Each verification group member will only generate one inspection report. The reporting process will be explained later. While participating in the selection of members of the verification team, the application chain miners are also receiving inspection reports sent by the members of the verification team. If the block verification by the leader of the proposal group can be confirmed based on the collected inspection reports, they do not need to continue to participate in the election. Verify the members of the group (the above loop termination condition two). For example, currently entering the third round of verification group member selection, an AppChain miner who has not been selected as a member of the verification group can judge the proposal based on the inspection report issued by the AppChain miner selected as a member of the verification group in the previous two rounds of selection. Whether the block produced by the group leader has been verified.
推选验证组成员的轮次有限制,最多不能超过预设的最大轮次(上述循环终止条件三),超过则当前应用链矿工结束对应用链待挖区块的验证组成员的推选。There are restrictions on the number of rounds for selecting members of the verification group, and the maximum number of rounds cannot exceed the preset maximum round (the above cycle termination condition 3). If it exceeds, the current application chain miners will end the selection of the verification group members of the application chain to be mined.
允许分成进行多轮验证组成员的推选有利于自适应消除基链和应用链中的软分叉,具体原理在后文阐述。Allowing to be divided into multiple rounds of selection of members of the verification group is conducive to adaptively eliminating soft forks in the base chain and the application chain. The specific principles are explained later.
在应用链待挖区块的任一轮验证组成员的推选过程中,每个应用链矿工根据预设的算法自主确定是否为验证组成员,不依赖于其他应用链矿工,在一种典型的实现方式中,上述预设的算法可采用可验证随机函数VRF算法,前文在介绍提案组成员推 选时已经介绍过该算法。In the selection process of any round of verification group members of the block to be mined in the application chain, each application chain miner independently determines whether to be a member of the verification group according to a preset algorithm, and does not depend on other application chain miners. In a typical In the implementation manner, the above-mentioned preset algorithm can use the verifiable random function VRF algorithm, which has been introduced in the previous section when introducing the selection of the proposal group members.
应用链矿工首先基于自身的私钥(对应VRF算法中的PrivateKey)以及利用预设规则确定的第二选举字串(对应VRF算法中的info)调用VRF算法中的证明函数获得第二可证明字串(对应VRF算法中的proof)。之后,应用链矿工基于第二可证明字串利用预设的规则推导第三随机值,并根据第三随机值确定应用链矿工是否被推选为应用链待挖区块的验证组成员,上述预设的推导规则具有确定性(但具体是何种规则不限定),因此对于同样的输入,推导出的第三随机值也具有确定性,进而在第三随机值的基础上得到的验证组成员的推选结果也具有确定性。Application chain miners first call the proof function in the VRF algorithm to obtain the second provable word based on their own private key (corresponding to the PrivateKey in the VRF algorithm) and the second election string determined by the preset rules (corresponding to the info in the VRF algorithm) String (corresponding to the proof in the VRF algorithm). After that, the application chain miner derives the third random value using preset rules based on the second provable string, and determines whether the application chain miner is selected as the verification group member of the application chain to be mined according to the third random value. Suppose the derivation rules are deterministic (but the specific rules are not limited), so for the same input, the derived third random value is also deterministic, and then the verification group members obtained on the basis of the third random value The results of the election are also deterministic.
上述第二选举字串为一个已知字串,其获取规则是确定的。在一种实现方式中,第二选举字串根据以下信息计算:提案组领导人的矿工标识、确定提案组领导人的基链区块的高度(此处指区块在基链中的实际高度而非挖矿请求中指定的基链高度,因为重挖旧块操作的存在致使这两个高度不一定相同)、应用链待挖区块的高度以及推选验证组成员的轮次编号。若基链区块信息中针对应用链待挖区块的选举结果为原始形式(即包含提案候选信息),则根据选举结果中的应用链标识、并行链链号、应用链矿工公钥三项信息计算上述第一项信息,再加上从选举结果中获取上述第二、三项信息,并结合当前推选验证组成员的轮次编号计算第二选举字串;若选举结果为简化形式,则从选举结果中获取上述第一、三项信息,上述第二项信息就是保存选举结果的基链区块的高度,再结合当前推选验证组成员的轮次编号计算第二选举字串。推选验证组成员的轮次可以从0开始编号,并按照自然数的顺序递增,应用链矿工在参与不同轮次的验证组成员推选时,该编号的取值也要随之变化。The above-mentioned second election string is a known string, and its acquisition rule is determined. In one implementation, the second election string is calculated based on the following information: the miner ID of the leader of the proposal group, the height of the base chain block that determines the leader of the proposal group (here refers to the actual height of the block in the base chain Rather than the base chain height specified in the mining request, the two heights are not necessarily the same due to the existence of the re-mining of the old block), the height of the block to be mined in the application chain, and the round number of the selection verification group member. If the election result for the block to be mined in the application chain in the base chain block information is in the original form (that is, it contains proposal candidate information), it will be based on the application chain identification, parallel chain chain number, and application chain miner public key in the election result. Information calculates the first item of information, plus the second and third items of information obtained from the election results, and calculates the second election string in combination with the round numbers of the members of the current selection verification group; if the election result is in a simplified form, then The first and third items of information are obtained from the election results. The second item of information is the height of the base chain block storing the election results, and the second election string is calculated in combination with the round numbers of the members of the current selection verification group. The rounds for selecting verification group members can be numbered starting from 0 and increasing in the order of natural numbers. When application chain miners participate in different rounds of verification group member selection, the value of the number will also change accordingly.
在一些实现方式中,可以直接根据第三随机值确定应用链矿工是否为应用链待挖区块的提案组成员。在另一些实现方式中,对于每个应用链矿工可以计算一个其专属的验证组参选权重,每个应用链矿工可以根据第三随机值以及自身的验证组参选权重确定自己是否为应用链待挖区块的验证组成员,其中,应用链矿工被选为验证组成员的概率与该验证组参选权重的取值正相关。In some implementations, it may be directly determined according to the third random value whether the application chain miner is a member of the proposal group of the block to be mined in the application chain. In other implementations, each application chain miner can calculate its own verification group participation weight, and each application chain miner can determine whether he is an application chain based on the third random value and its own verification group participation weight. The members of the verification group of the block to be mined. Among them, the probability of the application chain miner being selected as a member of the verification group is positively related to the value of the weight of the verification group.
例如,某个应用链矿工的验证组参选权重可根据该矿工当前持有数字货币的数量进行计算(前提是应用链上要发行数字货币),并规定:若应用链矿工当前未持有数字货币,则验证组参选权重取0。在这一规定下,一种典型的实现方式是:应用链矿工的验证组参选权重priority2和其持币量stake之间成正比,即:For example, the verification group participation weight of an application chain miner can be calculated based on the amount of digital currency currently held by the miner (provided that digital currency is to be issued on the application chain), and it is stipulated that if the application chain miner does not currently hold digital currency Currency, the verification group participation weight is 0. Under this regulation, a typical implementation method is: application chain miners' verification group participation weight priority2 is proportional to their currency stake, namely:
priority2=C×stakepriority2=C×stake
其中C为一正常数。当然在满足前述规定的情况下,priority2和stake之间的也可以为其他关系。在这种实现方式中,持币较多的应用链矿工计算出的验证组参选权重也较大,从而被选为验证组成员的概率也更高,因为持币越多表明该矿工与应用链利益关系越密切,其作弊可能性也越小。Where C is a normal number. Of course, the relationship between priority2 and stake can also be other relationships if the foregoing requirements are met. In this implementation method, the application chain miners who hold more coins have a higher weight for the verification group to participate in the election, so the probability of being selected as a member of the verification group is also higher, because the more coins they hold, the more the miner and the application The closer the chain of interest is, the less likely it is to cheat.
在一些实现方式中,应用链上还可以预设最小持币量这一参数,若应用链矿工当前持有数字货币的数量小于预设的最小持币量,则应用链矿工不能参与验证组成员的推选。典型的,未持有数字货币的应用链矿工不能参与提案组成员的推选,此举可以杜绝伪造大量新账号参与挖矿的女巫攻击。当然,在一些替代方案中,预设验证组参选权重的最小值也能够起到类似的效果。In some implementations, the minimum currency holding parameter can also be preset on the application chain. If the current number of digital currencies held by the application chain miners is less than the preset minimum currency holdings, the application chain miners cannot participate in the verification group members Selection. Typically, application chain miners who do not hold digital currencies cannot participate in the selection of members of the proposal group. This can prevent the sybil attack of forging a large number of new accounts to participate in mining. Of course, in some alternative solutions, the minimum value of the preset verification group participation weight can also have a similar effect.
在一些实现方式中,应用链上还可以预设验证组最大参选权重这一参数,即为验证组参选权重设置一个上限,若计算出的验证组参选权重超过该上限(例如,应用链矿工因持有大量数字货币而使得验证组参选权重大于预设的验证组最大参选权重),则将验证组参选权重设置为验证组最大参选权重。避免大量持币的应用链矿工在验证组成员的推选中优势过大,剥夺其他应用链矿工当选验证组成员的机会。In some implementations, the application chain can also preset the parameter of the verification group’s maximum participation weight, that is, set an upper limit for the verification group’s participation weight. If the calculated verification group’s participation weight exceeds the upper limit (for example, the application Because chain miners hold a large amount of digital currency, the verification group participation weight is greater than the preset verification group maximum participation weight), then the verification group participation weight is set to the verification group maximum participation weight. Avoid a large number of application chain miners holding coins in the selection of members of the verification group to have too much advantage, depriving other application chain miners of the opportunity to be elected members of the verification group.
验证组参选权重当然也可以采用其他定义,但根据应用链的持币数量进行计算是比较方便的,因为应用链账本记录本链所有账号的未花费的交易输出(Unspent Transaction Output,简称UTXO),从而所有应用链矿工都能查验他人的持币数量并计算相应的验证组参选权重,进而可对他人是否有资格当选验证组成员等进行验证。Of course, other definitions can also be used for the weight of the verification group participation, but it is more convenient to calculate based on the number of coins held by the application chain, because the application chain ledger records the unspent transaction output (UTXO) of all accounts in the chain. , So that all application chain miners can check the amount of coins held by others and calculate the corresponding verification group participation weight, and then can verify whether others are eligible to be elected members of the verification group.
应用链矿工根据第三随机值以及自身的验证组参选权重确定自己是否为应用链待挖区块的验证组成员也可以有不同的实现方式,在一种实现方式中,可以这样实现:Application chain miners determine whether they are members of the verification group of the application chain block to be mined according to the third random value and their own verification group participation weights. There are also different implementation methods. In one implementation method, it can be implemented as follows:
首先,利用如下公式计算第四随机值RandValue4:First, use the following formula to calculate the fourth random value RandValue4:
RandValue4=(RandValue3%ExpectedRange2)+priority2RandValue4=(RandValue3%ExpectedRange2)+priority2
其中,RandValue3为第三随机值,ExpectedRange2为预设的范围值,priority2为验证组参选权重,%表示取余数运算。Among them, RandValue3 is the third random value, ExpectedRange2 is the preset range value, priority2 is the weight of the verification group participation, and% represents the remainder operation.
若计算出的RandValue4满足如下条件,则确定当前应用链矿工被推选为应用链待挖区块的提案组成员:If the calculated RandValue4 satisfies the following conditions, it is determined that the current application chain miner is selected as the proposal group member of the application chain to be mined block:
RandValue4>ExpectedRange2-(ExpectedRange2*1/M2)RandValue4>ExpectedRange2-(ExpectedRange2*1/M2)
其中,M2为预设过滤比例。Among them, M2 is the preset filtering ratio.
不难看出,RandValue4和RandValue2的计算公式基本相同,只是其中的预设参数ExpectedRange2可以和ExpectedRange1取不同值,M2可以和M1取不同值。It is not difficult to see that the calculation formulas of RandValue4 and RandValue2 are basically the same, except that the preset parameter ExpectedRange2 can take different values from ExpectedRange1, and M2 can take different values from M1.
还可以看出,验证组成员的推选过程和提案组成员的推选有类似之处,并且基链区块中记录有选举依据(由于只有提案组成员才会发送挖矿请求,因此相当于记录了提案组成员),故不排除在一些实现方式中直接将全部提案组成员作为验证组成员,略过验证组成员推选的步骤。但在上面的方案中,将验证组成员的推选和提案组成员的推选实现为相互独立的(即一个应用链矿工是否为验证组成员和它是否为提案组成员无关),综合考虑如下方面:It can also be seen that the selection process of verification group members is similar to the selection of proposal group members, and the basis for election is recorded in the base chain block (because only proposal group members will send mining requests, it is equivalent to recording Proposal group members), so it is not ruled out that in some implementations, all proposal group members are directly used as verification group members, and the step of selecting verification group members is skipped. However, in the above scheme, the selection of verification group members and the selection of proposal group members are implemented as independent of each other (that is, whether an application chain miner is a member of the verification group and whether it is a member of the proposal group has nothing to do with the following aspects:
其一,每个应用链矿工独立地确认自己是否为验证组成员,相较于集中式地确认验证组成员(指直接将提案组成员批量确定为验证组成员)安全性更高;其二,上述验证组成员的推选可分多轮进行,为消除软分叉提供了自适应机制(见后文阐述);其三,基链区块的选举依据列表中列出提案组成员,是为了预防敌手作弊,使得各基链矿工都可以实施验证,并非为了选举验证组成员的方便。First, each application chain miner independently confirms whether he is a member of the verification group, which is more secure than the centralized confirmation of verification group members (referring to directly confirming the proposal group members as members of the verification group in batches); second, The selection of members of the verification group mentioned above can be divided into multiple rounds, which provides an adaptive mechanism to eliminate soft forks (see below); third, the members of the proposal group are listed in the base chain block election basis list for prevention The adversary's cheating allows all base chain miners to perform verification, not for the convenience of electing members of the verification group.
若一个应用链矿工在某一轮推选中确认了自己为应用链待挖区块的验证组成员,即可对应用链待挖区块的提案组领导人所出区块进行验证。在不同的实现方式中,提案组领导人打包应用链待挖区块的时机可能不同:例如,在第一种方式中,任一应用链矿工在确认自己被推选为提案组成员后,都会打包应用链待挖区块,但最终只有提案组领导人打包的应用链待挖区块会在应用链中传播并在验证通过后被记账,应用链矿工在同步基链区块信息后便可获知哪个应用链矿工当选提案组领导人,再结合区块的出块者信息便可以确定哪个是提案组领导人所出区块;在第二种方式中,只有提案组领导人才会打包应用链待挖区块,而应用链矿工在同步基链区块信息后便可获知自身是否为提案组领导人。If an application chain miner confirms that he is a member of the verification group of the application chain to be mined in a certain round of selection, he can verify the block produced by the leader of the proposal group of the application chain to be mined. In different implementations, the timing of the proposal group leader to package the application chain to be mined may be different: for example, in the first method, any application chain miner will pack it after confirming that he is elected as a member of the proposal group The application chain to be mined blocks, but in the end only the application chain to be mined blocks packaged by the leader of the proposal group will be spread in the application chain and will be booked after verification. The application chain miners can synchronize the base chain block information. Knowing which application chain miner was selected as the leader of the proposal group, combined with the block producer information can determine which is the block produced by the proposal group leader; in the second method, only the proposal group leader will package the application chain The block to be mined, and the application chain miner can know whether he is the leader of the proposal group after synchronizing the information of the base chain block.
可选的,对于第一种方式,提案组成员在打包好应用链待挖区块后,还可以将应用链待挖区块广播给它周边的局部范围内的其他应用链矿工。此处的局部范围可以定义为消息转发意义上的局部范围,例如,提案组成员在广播应用链待挖区块的广播消息中指定一个预设的转发次数,应用链待挖区块每经过一次转发,广播消息中的转发次数就减去1,在转发次数减少至0时停止广播应用链待挖区块。当然,也不排除局部范围采取其他定义方式,例如地理意义上的,网络拓扑意义上的范围,等等。Optionally, for the first method, after the members of the proposal group have packaged the application chain to be mined blocks, they can also broadcast the application chain to be mined blocks to other application chain miners in a local area around it. The local scope here can be defined as the local scope in the sense of message forwarding. For example, the members of the proposal group specify a preset number of forwarding times in the broadcast message of the block to be mined in the application chain, and the block to be mined in the application chain passes every time For forwarding, the number of forwarding in the broadcast message is reduced by 1, and the block to be mined in the application chain will be stopped when the number of forwarding is reduced to 0. Of course, it is not ruled out that the local scope adopts other definition methods, such as the scope in the geographical sense, the scope in the network topology sense, and so on.
对应用链待挖区块提前(指在确定出提案组领导人之前)进行局部扩散有利于改善区块链系统的安全性,具体分析如下:Local diffusion of the blocks to be mined in the application chain in advance (before the leader of the proposal group is determined) is beneficial to improve the security of the blockchain system. The specific analysis is as follows:
首先定义定向腐蚀的概念:定向腐蚀是指敌手对某个或某些特定的应用链矿工进行的某种恶意行为。例如,对某个应用链矿工所在挖矿节点进行网络攻击(例如分布式拒绝服务DDoS攻击),导致其因消息拥塞等原因无法正常工作,从而应用链矿工无法正常出块,有利于敌手进一步进行破解行为;又例如,对某个应用链矿工进行贿赂,指示其按照自己的要求进行记账等。First define the concept of directional corrosion: directional corrosion refers to a certain malicious behavior of an adversary against a certain or certain specific application chain miners. For example, a network attack (such as a distributed denial of service DDoS attack) on a mining node where an application chain miner is located causes it to fail to work normally due to message congestion and other reasons, so that the application chain miner cannot produce blocks normally, which is beneficial to the adversary's further progress. Cracking behavior; another example, bribing an application chain miner, instructing them to keep accounts according to their own requirements, etc.
在本公开方案常见的实现方式中,基链采用公链,拥有海量矿工,并且结合基链的区块链数据来决定提案组成员如何选出(具体可参考前文第一选举字串的获取方式),即结合了基链的算力因素,敌手难以控制第一选举字串按照其期望的方式去取值,从而无法按照其意愿将特定的应用链矿工选为提案组成员。并且,即使敌手可以在提前于出块的某一时间获知第一选举字串,由于应用链矿工在推导第一可证明字串时除了用到第一选举字串,还需结合自身私钥,因此敌手无法仅根据第一选举字串推导第一可证明字串,进而无法推导作为应用链矿工当选提案组成员的依据的第一随机 值或第二随机值,也就难以提前确定某个应用链矿工是否会当选提案组成员,从而无法对其进行定向腐蚀。In the common implementation of the disclosed scheme, the base chain uses a public chain, has a large number of miners, and combines the block chain data of the base chain to determine how the members of the proposal group are selected (for details, please refer to the method of obtaining the first election string in the previous section) ), that is, combined with the computing power factor of the base chain, it is difficult for the adversary to control the value of the first election string according to their expectations, so that they cannot select specific application chain miners as members of the proposal group according to their wishes. Moreover, even if the adversary can learn the first election string at a certain time before the block is produced, because the application chain miner needs to combine his own private key in addition to the first election string when deriving the first provable string, Therefore, the adversary cannot derive the first provable string based on the first election string alone, and thus cannot derive the first random value or the second random value that is the basis for the application chain miners to be elected members of the proposal group, and it is difficult to determine an application in advance. Will chain miners be elected as members of the proposal group so that they cannot be directionally corroded?
然而,一旦提案组成员向基链矿工发送挖矿请求,提案组成员身份就会暴露(例如,敌手可以部署特定应用程序监听挖矿请求,或者在基链上专门部署一个属于他自己的矿工来接收请求),从而敌手可以对提案组成员进行定向腐蚀。However, once a member of the proposal group sends a mining request to the base chain miner, the membership of the proposal group will be exposed (for example, the adversary can deploy a specific application to listen to the mining request, or deploy a dedicated miner of his own on the base chain. Receive the request), so that the adversary can directionally corrode the members of the proposal group.
为解决这一问题,要求应用链矿工在确定自身为提案组成员后,立即打包应用链待挖区块并在有限范围内扩散该区块(之所以限定为局部范围,主要是为了避免消耗过多带宽资源)。由于进行了提前扩散,每个应用链矿工可能收到多个同一高度的应用链待挖区块,由不同的提案组成员打包产生,但应用链矿工在同步基链区块信息后便可确定提案组领导人,应用链矿工将只保留提案组领导人打包的应用链待挖区块(如果应用链矿工本地有缓存该区块的话)并向其他应用链矿工广播该区块(此时是全链广播),丢弃其他人打包的应用链待挖区块。In order to solve this problem, after determining that they are members of the proposal group, miners of the application chain are required to immediately package the block to be mined in the application chain and spread the block in a limited range (the reason is limited to a partial range, mainly to avoid excessive consumption. Multiple bandwidth resources). Due to the advance diffusion, each application chain miner may receive multiple application chain blocks to be mined at the same height, which are packaged and produced by different proposal group members, but the application chain miners can determine after synchronizing the base chain block information The leader of the proposal group, the application chain miner will only keep the application chain to-be-mined block packaged by the proposal group leader (if the application chain miner has cached the block locally) and broadcast the block to other application chain miners (this time is Full chain broadcast), discarding the application chain to be mined blocks packaged by others.
这样,即使敌手在提案组成员请求挖矿时获知了其身份,由于应用链待挖区块已经在应用链中扩散,定向腐蚀达不到效果。比如,即使敌手通过某种方式确定了提案组领导人,对提案组领导人所在的挖矿节点进行DDoS攻击,虽然可能导该节点瘫痪,但其周边范围内的应用链矿工仍然可以扩散其所出区块,不受影响;同理,对提案组领导人进行贿赂也是徒劳。In this way, even if the adversary learns his identity when the members of the proposal group request mining, because the application chain to be mined blocks have already spread in the application chain, directional corrosion will not be effective. For example, even if the adversary determines the leader of the proposal group in some way, and launches a DDoS attack on the mining node where the leader of the proposal group is located, although the node may be paralyzed, the application chain miners in its surrounding area can still spread all of them. If you leave the block, it will not be affected; for the same reason, bribing the leader of the proposal group is futile.
提案组领导人在广播所出区块时,还在广播消息中附带提案组领导人发送的针对该区块的挖矿请求中的提案候选信息用于区块验证,后续提案组领导人所出区块在应用链中传播时,该提案信息也一直附带。被推选为应用链待挖区块的验证组成员的应用链矿工对提案组领导人所出区块进行验证,至少包括以下验证项目:When the leader of the proposal group broadcasts the block, it also attaches the proposal candidate information in the mining request sent by the leader of the proposal group to the block in the broadcast message for block verification, and the follow-up proposal group leader issues When the block is spread in the application chain, the proposal information is always attached. Application chain miners who are selected as members of the verification group of the application chain to be mined block verify the block produced by the leader of the proposal group, including at least the following verification items:
其一,首先根据上述提案候选信息中的确定提案组领导人的基链区块的高度,确定提案组领导人被推选为提案组成员时依赖的第一选举字串。然后,基于提案候选信息中的第一可证明字串、提案候选信息中的应用链矿工公钥以及第一选举字串调用VRF算法中的验证函数,验证提案候选信息中的第一可证明字串是否被伪造,若未被伪造,则本项验证通过,若被伪造,则本项验证不通过。本项验证内容可参考基链矿工对于挖矿请求中第一可证明字串的验证过程,上文已阐述。First, according to the height of the base chain block that determines the leader of the proposal group in the above proposal candidate information, determine the first election string that the proposal group leader relies on when he is elected as a member of the proposal group. Then, call the verification function in the VRF algorithm based on the first provable string in the proposal candidate information, the application chain miner's public key in the proposal candidate information, and the first election string to verify the first provable word in the proposal candidate information Whether the string is forged, if it is not forged, the verification of this item is passed, if it is forged, the verification of this item is not passed. The verification content of this item can refer to the verification process of the first provable string in the mining request by the base chain miners, which has been explained above.
其二,验证提案候选信息中的应用链矿工公钥对应的应用链矿工是否为提案组领导人所出区块的创建者。在本公开的方案中,可以设计一定的机制指明应用链区块的创建者:Second, verify whether the application chain miner corresponding to the application chain miner's public key in the proposal candidate information is the creator of the block produced by the leader of the proposal group. In the solution of the present disclosure, a certain mechanism can be designed to specify the creator of the application chain block:
例如,在区块头中保存表征区块创建者身份的公钥信息(如可以是公钥本身,可以是公钥的哈希值等),验证组成员根据提案候选信息中的应用链矿工公钥也可以获得相应的公钥信息,将二者进行对比,若一致,则可确认提案候选信息中的应用链矿工公钥对应的应用链矿工就是提案组领导人所出区块的创建者,本项验证通过,否则可确认该应用链矿工不是提案组领导人所出区块的创建者,本项验证不通过。For example, the public key information that characterizes the identity of the block creator is stored in the block header (for example, it can be the public key itself, the hash value of the public key, etc.), and the verification group members apply the chain miner public key in the proposal candidate information The corresponding public key information can also be obtained, and the two can be compared. If they are consistent, it can be confirmed that the application chain miner corresponding to the application chain miner’s public key in the proposal candidate information is the creator of the block produced by the leader of the proposal group. If the verification is passed, otherwise it can be confirmed that the miner of the application chain is not the creator of the block produced by the leader of the proposal group, and the verification is not passed.
又例如,上面提到,提案组领导人在广播所出区块时,在广播消息中附带相应的提案候选信息,此外还可以再附带一项提案组领导人利用自身的私钥对所出区块的签名(如可以是对整个区块的签名,可以是对区块头的签名,可以是对区块头中的某些字段的签名等)。验证组成员利用提案候选信息中的应用链矿工公钥验证广播消息中携带的对提案组领导人所出区块的签名是否正确,若正确,则可确认提案候选信息中的应用链矿工公钥对应的应用链矿工就是提案组领导人所出区块的创建者,本项验证通过,否则可确认该应用链矿工不是提案组领导人所出区块的创建者,本项验证不通过。For another example, as mentioned above, when the leader of the proposal group broadcasts the block, the corresponding proposal candidate information is attached to the broadcast message. In addition, it can also be accompanied by a proposal group leader who uses his own private key to pair the outgoing area. The signature of the block (for example, it can be the signature of the entire block, it can be the signature of the block header, it can be the signature of some fields in the block header, etc.). The members of the verification group use the public key of the application chain miner in the proposal candidate information to verify whether the signature of the block produced by the leader of the proposal group carried in the broadcast message is correct. If it is correct, the public key of the application chain miner in the proposal candidate information can be confirmed The corresponding application chain miner is the creator of the block produced by the leader of the proposal group, and this verification is passed, otherwise it can be confirmed that the application chain miner is not the creator of the block produced by the leader of the proposal group, and this verification fails.
此外,上述在区块头中保存区块创建者的公钥信息的实现方式,也不排除将公钥信息替换为创建者的矿工标识,利用提案候选信息也可以计算出一个矿工标识用于验证。In addition, the above implementation of storing the public key information of the block creator in the block header does not exclude the replacement of the public key information with the creator's miner identification, and the proposal candidate information can also be used to calculate a miner identification for verification.
其三,首先根据提案候选信息中的确定提案组领导人的基链区块的高度从验证组成员本地的基链账本中查询提案组领导人(当然,从前文提到的用于查询提案组领导人当选次数的表格中进行查询也是可以的),然后验证查询出的提案组领导人与提案候选信息确定的提案组领导人是否一致。Third, according to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, the leader of the proposal group is queried from the local base chain ledger of the verification group member (of course, it is used to query the proposal group as mentioned above. It is also possible to inquire in the table of the number of leader elections), and then verify whether the inquired leader of the proposal group is consistent with the leader of the proposal group determined by the proposal candidate information.
对于提案组领导人的身份,可以采用公钥或者矿工标识来表示。对于采用公钥表示的,本项验证这样实现:The identity of the leader of the proposal group can be represented by a public key or a miner ID. For those represented by public keys, this verification is implemented as follows:
首先根据提案候选信息中的确定提案组领导人的基链区块的高度从本地的基链账本中查询提案组领导人的公钥(此时基链账本中的选举结果采用原始形式),然后验证查询出的提案组领导人的公钥与提案候选信息中的应用链矿工公钥是否一致,若一致,则确认查询出的提案组领导人与提案候选信息确定的提案组领导人一致,本项验证通过,否则确认两个提案组领导人不一致,本项验证不通过。First, according to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, query the public key of the proposal group leader from the local base chain ledger (at this time, the election results in the base chain ledger are in the original form), and then Verify that the public key of the queried proposal group leader is consistent with the public key of the application chain miner in the proposal candidate information. If they are the same, confirm that the queried proposal group leader is consistent with the proposal group leader determined by the proposal candidate information. The verification is passed, otherwise it is confirmed that the leaders of the two proposal groups are inconsistent, and the verification fails.
对于采用矿工标识表示的,本项验证这样实现:For those represented by the miner's logo, this verification is implemented as follows:
首先根据提案候选信息中的确定提案组领导人的基链区块的高度从本地的基链账本中查询提案组领导人的矿工标识(此时基链账本中的选举结果采用简化形式),然后基于提案候选信息中的应用链矿工公钥、应用链标识以及并行链链号三项内容,利用哈希算法计算提案组领导人的矿工标识,最后验证查询出的提案组领导人的矿工标识与计算出的提案组领导人的矿工标识是否一致,若一致,则确认查询出的提案组领导人与提案候选信息确定的提案组领导人一致,本项验证通过,否则确认两个提案组领导人不一致,本项验证不通过。First, according to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, query the miner ID of the proposal group leader from the local base chain ledger (at this time, the election results in the base chain ledger are in a simplified form), and then Based on the application chain miner’s public key, application chain ID, and parallel chain chain number in the proposal candidate information, the hash algorithm is used to calculate the miner ID of the leader of the proposal group, and finally the miner ID of the queried proposal group leader is verified. Whether the miner IDs of the calculated proposal group leaders are the same, if they are the same, confirm that the queried proposal group leader is consistent with the proposal group leader determined by the proposal candidate information, this item is verified, otherwise the two proposal group leaders are confirmed Inconsistent, this verification failed.
其四,验证提案组领导人所出区块中的所有交易是否正确,若正确则本项验证通过,否则本项验证不通过。具体验证内容包括验证是否存在伪造交易、实施双花等,此项验证和现有的区块链系统中对交易的验证类似,不作具体说明。Fourth, verify whether all transactions in the block produced by the leader of the proposal group are correct. If they are correct, the verification is passed, otherwise the verification fails. The specific verification content includes verifying whether there is a forged transaction, implementing double spending, etc. This verification is similar to the verification of transactions in the existing blockchain system, and will not be specifically explained.
进一步的,在上述第一项验证通过后(注意以上验证没有必然的先后顺序,第一项验证未必是最先通过的),还可以根据提案候选信息中的第一可证明字串推导第一随机值,然后根据第一随机值以及提案候选信息所确定的提案组领导人的提案组参选权重计算第二随机值(具体公式见前文),最后验证第二随机值是否符合当选提案组领导人的基本要求,例如,是否满足最小当选随机值的要求,若满足则本项验证通过,否则本项验证不通过。在首次介绍提案候选信息的构成时曾经提到,在一些实现方式中,提案候选信息中还可以包括应用链矿工被选为提案组成员时依赖的第二随机值,对于这些实现方式,在推导出第二随机值后,还可以先验证一下推导出的第二随机值和提案候选信息中的第二随机值是否相同。Further, after the first verification is passed (note that there is no inevitable sequence for the verification above, the first verification may not be the first to pass), the first verification can be derived from the first provable string in the proposal candidate information. Random value, and then calculate the second random value based on the first random value and the proposal group leader’s participation weight of the proposal group determined by the proposal candidate information (see the previous section for the specific formula), and finally verify whether the second random value is consistent with the elected proposal group leader People’s basic requirements, for example, whether they meet the minimum random value requirement, if they are met, the verification of this item is passed, otherwise the verification of this item is not passed. When I first introduced the composition of the proposal candidate information, it was mentioned that in some implementations, the proposal candidate information can also include the second random value that the miners of the application chain rely on when they are selected as members of the proposal group. For these implementations, in derivation After the second random value is obtained, it is also possible to verify whether the derived second random value is the same as the second random value in the proposal candidate information.
若以上所有验证项目的验证结果均为通过,则验证组成员生成检验结论为检验通过的检验报告,否则生成检验结论为检验未通过的检验报告,验证组成员生成检验报告后,在应用链中广播该检验报告。If the verification results of all the above verification items are passed, the verification team members generate the inspection report that the inspection conclusion is passed. Otherwise, the verification team members generate the inspection report that the inspection report is not passed. After the verification team members generate the inspection report, they are in the application chain Broadcast the inspection report.
从上述验证组成员的推选过程可知,应用链矿工参与针对应用链待挖区块的每一轮验证组成员的推选时,导致其算出的作为当选与否的依据的第三随机值或第四随机值不同的原因在于计算第二选举字串时使用的推选验证组成员的轮次编号一项,其余各项在推选期间可视为固定值。从而,仅从原理上讲,应用链矿工参与验证组成员的推选并不受同步基链区块信息的限制,应用链矿工只需自行调整轮次编号值,就可以确定自己在某一轮次的推选中是否会被选为验证组成员,即使原本用于指示开始该轮次推选的基链区块信息尚未同步,简称为提前验证,对应于前文提到的P>1的情况。From the above selection process of verification group members, it can be seen that when application chain miners participate in the selection of each round of verification group members for the block to be mined in the application chain, the third random value or the fourth random value or fourth value calculated as the basis for the election is caused. The reason for the different random values is that the round numbers of the members of the selection verification group used in the calculation of the second election string are one item, and the remaining items can be regarded as fixed values during the selection period. Therefore, only in principle, the application chain miners participating in the selection of members of the verification group are not restricted by the synchronization base chain block information. The application chain miners only need to adjust the round number value by themselves to determine that they are in a certain round. Whether the selection of will be selected as a member of the verification group, even if the base chain block information originally used to indicate the start of this round of selection has not been synchronized, it is referred to as early verification for short, which corresponds to the situation of P>1 mentioned above.
比如,P=3,当应用链矿工同步到确定应用链待挖区块的提案组领导人的基链区块信息(假设对应基链上高度为H的区块)后,就可以参与第一轮(轮次编号为0)、第二轮、第三轮验证组成员的推选(当然,比如第一轮就确认自己是验证组成员,就不必参加后续轮次的推选了),不必等待原本用于指示开始第二轮、第三轮验证组成员推选的基链区块信息(H+1、H+2高度的基链区块对应的基链区块信息),若不提前参选,此时它只能参与第一轮验证组成员的推选;当应用链矿工同步到高度为H+1的基链区块对应的基链区块信息后,就可以参与第四轮验证组成员的推选,若不提前参选,此时它只能参与第二轮验证组成员的推选;以此类推。For example, P=3, when the application chain miner synchronizes to the base chain block information of the leader of the proposal group that determines the block to be mined in the application chain (assuming it corresponds to a block with a height of H on the base chain), they can participate in the first Round (the round number is 0), the second round, and the third round of the selection of members of the verification group (of course, if you confirm that you are a member of the verification group in the first round, you don’t have to participate in the subsequent rounds of selection), no need to wait for the original Used to indicate the start of the second and third rounds of the base chain block information selected by the members of the verification group (the base chain block information corresponding to the base chain block at the height of H+1, H+2). If you do not participate in advance, At this time, it can only participate in the first round of selection of members of the verification group; when the application chain miners synchronize to the base chain block information corresponding to the base chain block with a height of H+1, they can participate in the fourth round of verification group members. If it does not participate in the election in advance, it can only participate in the second round of selection of members of the verification team; and so on.
一旦应用链矿工在某轮推选中确定了自己为验证组成员,就对提案组领导所出区块进行验证并广播检验报告,相较于P=1的情况,这里的检验报告可视为提前广播出去的。提前广播检验报告有利于挖矿请求在基链的充分传播,具体原因在步骤S107中再进行分析。Once the application chain miner has determined that he is a member of the verification group in a certain round of selection, he will verify the block produced by the leader of the proposal group and broadcast the inspection report. Compared with the case of P=1, the inspection report here can be regarded as advance Broadcast out. Broadcasting the inspection report in advance is conducive to the full dissemination of mining requests on the base chain, and the specific reasons will be analyzed in step S107.
上面介绍了在提案组领导人发送的广播消息中额外携带区块验证信息的实现方 式,除了提案候选信息外,该区块验证信息中还可以包含提案组参选权重、第一随机值、第二随机值等信息。此外,在另一些实现方式中,提案组成员也可以在打包应用链待挖区块时,在区块的首个交易(也称Coinbase)中保存自身被推选为提案组成员的证据,例如,提案候选信息中的各信息项、提案组参选权重、第一随机值、第二随机值等,作为区块验证信息供他人日后实施验证。若提案组成员最终被选为领导人,其打包的区块将被广播,Coinbase中的信息自然也随区块一同被传播出去,其效果和单独发送这些信息类似。The above describes the implementation method of additionally carrying block verification information in the broadcast message sent by the leader of the proposal group. In addition to the proposal candidate information, the block verification information can also include the proposal group participation weight, the first random value, and the first random value. 2. Information such as random values. In addition, in other implementations, the members of the proposal group can also save evidence that they are elected as members of the proposal group in the first transaction of the block (also known as Coinbase) when packaging the block to be mined in the application chain, for example, The information items in the proposal candidate information, the proposal group participation weight, the first random value, the second random value, etc., are used as block verification information for others to verify in the future. If a member of the proposal group is finally selected as the leader, the packaged block will be broadcast, and the information in Coinbase will naturally be spread along with the block. The effect is similar to that of sending the information separately.
步骤S107:应用链矿工接收检验报告,若根据检验报告判断提案组领导人所出区块是否验证通过。Step S107: The application chain miner receives the inspection report, and judges whether the block produced by the leader of the proposal group is verified according to the inspection report.
步骤S108:若应用链矿工确定提案组领导人所出区块验证通过,则将该区块纳入应用链账本中。Step S108: If the application chain miner determines that the block produced by the leader of the proposal group is verified, the block is included in the application chain ledger.
以上两个步骤合并在一起进行阐述。在一种实现方式中,检验报告可以包括如下信息项:提案组领导人的矿工标识、确定提案组领导人的基链区块的高度、应用链待挖区块的高度、推选验证组成员的轮次编号、生成检验报告的验证组成员的公钥、应用链矿工被推选为验证组成员时依赖的第二可证明字串、应用链待挖区块的哈希值、检验结论以及利用验证组成员的私钥对检验报告的签名。The above two steps are combined together to explain. In one implementation, the inspection report may include the following information items: the miner identification of the leader of the proposal group, the height of the base chain block that determines the leader of the proposal group, the height of the block to be mined in the application chain, and the selection of the members of the verification group The round number, the public key of the verification group member who generated the inspection report, the second provable string that the app chain miner relied on when they were elected as the verification group member, the hash value of the block to be mined in the app chain, the verification conclusion, and the use verification The private key of the group member signs the inspection report.
其中,前四项为应用链矿工在参与验证组成员推选时计算第二选举字串时所用,附带在检验报告中供他人验证,推选验证组成员的轮次编号即为应用链矿工最终确认自己是验证组成员的推选轮次的编号;应用链待挖区块的哈希值用于唯一标识一个应用链区块,应用链矿工在步骤S107中统计检验报告的结论时可利用该哈希值区分针对不同的应用链区块的报告;检验结论即通过和不通过两种结论,上文已述;利用验证组成员的私钥对检验报告的签名可以指对检验报告中除签名本身以外的其他信息的签名,用于防止检验报告被篡改。Among them, the first four items are used by application chain miners to calculate the second election string when participating in the selection of verification group members, and are attached to the inspection report for others to verify. The round number of the selection verification group member is the final confirmation of the application chain miners. It is the number of the selection round of the members of the verification group; the hash value of the block to be mined in the application chain is used to uniquely identify an application chain block, and the application chain miner can use the hash value when statistically verifying the conclusion of the report in step S107 Distinguish the reports for different application chain blocks; the inspection conclusions are the two conclusions of passing and failing, as described above; using the private key of the verification team member to sign the inspection report can refer to the inspection report except the signature itself The signature of other information is used to prevent the inspection report from being tampered with.
应用链矿工在使用检验报告之前,可以先对检验报告的内容进行验证,验证的项目可以包括:Before the application chain miners use the inspection report, they can verify the content of the inspection report. The verification items can include:
其一,利用检验报告中的生成检验报告的验证组成员的公钥验证报告中的签名是否正确,若正确,则本项验证通过,否则本项验证不通过。First, use the public key of the verification team member who generated the inspection report in the inspection report to verify whether the signature in the report is correct. If it is correct, the verification of this item is passed, otherwise the verification of this item is not passed.
其二,首先根据检验报告中的确定提案组领导人的基链区块的高度从本地的基链账本中查询提案组领导人(当然,从前文提到的用于查询提案组领导人当选次数的表格中进行查询也是可以的),然后验证查询出的提案组领导人与检验报告所确定的提案组领导人是否一致。Second, first query the leader of the proposal group from the local basic chain ledger according to the height of the base chain block that determines the leader of the proposal group in the inspection report (of course, it is used to query the number of elections of the proposal group leader as mentioned above) It is also possible to inquire in the form), and then verify whether the inquired leader of the proposal group is consistent with the leader of the proposal group identified in the inspection report.
在应用链本地的基链账本中,若选举结果采用原始形式(即包含提案候选信息),本项验证这样实现:In the local base chain ledger of the application chain, if the election result is in the original form (that is, it contains proposal candidate information), this verification is implemented as follows:
首先根据检验报告中的确定提案组领导人的基链区块的高度从本地的基链账本中查询提案组领导人的公钥,然后获取应用链矿工挖矿所在的应用链标识以及并行链链号(这两项内容每个应用链矿工都可自行获得),基于这三项信息利用哈希算法计算提案组领导人的矿工标识,然后验证计算出的提案组领导人的矿工标识与检验报告中的提案组领导人的矿工标识是否一致,若一致,则确认查询出的提案组领导人与检验报告确定的提案组领导人一致,本项验证通过,否则确认两个提案组领导人不一致,本项验证不通过。Firstly, query the public key of the proposal group leader from the local base chain ledger according to the height of the base chain block of the leader of the proposal group in the inspection report, and then obtain the application chain identification and parallel chain chain where the miner of the application chain is mining. (These two contents can be obtained by each application chain miner), based on these three pieces of information, the hash algorithm is used to calculate the miner ID of the proposal group leader, and then the calculated miner ID and inspection report of the proposal group leader are verified Whether the miner identifications of the proposal group leaders in are the same. If they are the same, confirm that the inquired proposal group leader is consistent with the proposal group leader determined in the inspection report. This verification is passed, otherwise it is confirmed that the two proposal group leaders are inconsistent. This verification failed.
在应用链本地的基链账本中,若选举结果采用简化形式,本项验证这样实现:In the local base chain ledger of the application chain, if the election result is in a simplified form, this verification is implemented as follows:
首先根据检验报告中的确定提案组领导人的基链区块的高度从本地的基链账本中查询提案组领导人的矿工标识,然后验证查询出的提案组领导人的矿工标识与检验报告中的提案组领导人的矿工标识是否一致,若一致,则确认查询出的提案组领导人与检验报告确定的提案组领导人一致,本项验证通过,否则确认两个提案组领导人不一致,本项验证不通过。First, according to the height of the base chain block that determines the leader of the proposal group in the inspection report, query the miner ID of the proposal group leader from the local base chain ledger, and then verify the miner ID of the proposed group leader and the inspection report. If the miners’ identifications of the leaders of the proposal group are the same, confirm that the queried leader of the proposal group is consistent with the leader of the proposal group determined in the inspection report. This item is verified. Otherwise, it is confirmed that the leaders of the two proposal groups are inconsistent. Item verification failed.
其三,首先根据检验报告中的提案组领导人的矿工标识、确定提案组领导人的基链区块的高度、应用链待挖区块的高度以及推选验证组成员的轮次编号四项信息计算生成检验报告的应用链矿工被推选为验证组成员时依赖的第二选举字串,然后基于第二选举字串、检验报告中的生成检验报告的验证组成员的公钥以及检验报告中的第二 可证明字串调用VRF算法中的验证函数,验证检验报告中的第二可证明字串是否被伪造,若未被伪造,则本项验证通过,否则本项验证不通过。Third, according to the identification of the miner of the leader of the proposal group in the inspection report, the height of the base chain block of the leader of the proposal group, the height of the block to be mined in the application chain, and the round number of the members of the verification group are selected based on the four pieces of information. Calculate the second election string that the application chain miners who generated the inspection report are selected as members of the verification group rely on, and then based on the second election string, the public key of the verification group member who generated the inspection report in the inspection report, and the verification report The second provable character string calls the verification function in the VRF algorithm to verify whether the second provable character string in the inspection report is forged. If it is not forged, the verification of this item is passed, otherwise the verification of this item is not passed.
其四,基于检验报告中的第二可证明字串推导第三随机值,并根据第三随机值验证生成检验报告的应用链矿工是否为验证组成员,若是验证组成员,则本项验证通过,否则本项验证不通过。本项验证即重复验证组成员的推选操作,判断应用链矿工是否有确实有资格出具检验报告。Fourth, derive the third random value based on the second provable string in the inspection report, and verify whether the application chain miner who generated the inspection report is a member of the verification group based on the third random value. If it is a member of the verification group, the verification is passed. , Otherwise this verification fails. This verification is to repeat the selection of members of the verification team to determine whether the miners of the application chain are indeed qualified to issue an inspection report.
在一种实现方式中,应用链矿工可以先推导第三随机值,然后根据第三随机值以及自身的验证组参选权重计算第四随机值(具体公式见前文),最后根据第四随机值验证生成检验报告的应用链矿工是否为验证组成员。In one implementation, the application chain miner can first derive the third random value, and then calculate the fourth random value based on the third random value and its own verification group participation weight (see above for the specific formula), and finally based on the fourth random value Verify whether the miner of the application chain who generated the inspection report is a member of the verification team.
若以上所有验证项目的验证结果均为通过,则应用链矿工认可该检验报告的效力,并执行后续步骤,否则认为检验报告无效,可将其丢弃。If the verification results of all the above verification items are passed, the application chain miner shall recognize the validity of the inspection report and perform the following steps. Otherwise, the inspection report is deemed invalid and can be discarded.
应用链矿工汇总接收到的针对提案组领导人所出区块的检验报告进行统计并获得验证结果,具体可以这样实现:The application chain miners collect the received inspection reports for the blocks produced by the leader of the proposal group to perform statistics and obtain the verification results, which can be implemented as follows:
若收到的检验报告中检验结论为通过的报告份数不小于最小成功验证数,以及,检验结论为不通过的报告份数不大于最大失败验证数,则确定提案组领导人所出区块验证通过。If the inspection conclusion in the received inspection report is that the number of reports that pass is not less than the minimum number of successful verifications, and the number of reports that the inspection conclusion is that the number of failed verifications is not greater than the maximum number of failed verifications, the block produced by the leader of the proposal group is determined Verification passed.
若收到的检验报告中检验结论为通过的报告份数小于最小成功验证数,以及,检验结论为不通过的报告份数不大于最大失败验证数,则继续等待新的检验报告,除非等待了一段预设的时长(该时长后文有说明)后,检验结论为通过的报告份数仍然小于最小成功验证数,则确定提案组领导人所出区块验证未通过。If in the received inspection report, the number of reports that passed the inspection conclusion is less than the minimum number of successful verifications, and the number of reports that the inspection conclusion is not passed is not greater than the maximum number of failed verifications, continue to wait for a new inspection report, unless waiting After a preset period of time (this period will be explained later), if the verification conclusion is that the number of reports passed is still less than the minimum number of successful verifications, it is determined that the block verification by the leader of the proposal group has not passed.
若收到的检验报告中检验结论为不通过的报告份数大于最大失败验证数,则确定提案组领导人所出区块验证未通过。If in the received inspection report, the number of reports whose inspection conclusions are not passed is greater than the maximum number of failed verifications, it is determined that the block verification by the leader of the proposal group has not passed.
其中,最小成功验证数以及最大失败验证数可以为预设值,或者,也可以根据一预设时间段内被选为提案组领导人的应用链矿工的个数再结合一定的比例进行推算。最小成功验证数表征验证组成员对区块的认可程度,最大失败验证数表征一个容忍范围,若最大失败验证数设置为0也是可以的,但设置为非0值主要是为了防止少数验证组成员作恶(故意出具检验结论为不通过的报告)导致应用链无法正常出块。Among them, the minimum number of successful verifications and the maximum number of failed verifications may be preset values, or may also be calculated based on the number of application chain miners selected as the leader of the proposal group in a preset time period combined with a certain ratio. The minimum number of successful verifications represents the degree of recognition of the block by the members of the verification group, and the maximum number of failed verifications represents a tolerance range. It is also possible to set the maximum number of failed verifications to 0, but setting it to a non-zero value is mainly to prevent a small number of verification group members Evil (intentionally issuing a report that the inspection conclusion is not passed) causes the application chain to fail to produce blocks normally.
应用链矿工可以每收到一份检验报告就根据上面的规则判断能否得出验证结论,或者,应用链矿工也可以先缓存接收到的检验报告,在适当的时刻进行判断(例如定期判断)。对于接收到的检验报告,应用链矿工可以根据其中的推选验证组成员的轮次编号,优先处理靠前轮次的检验报告,避免敌手将后面轮次的报告提前广播而影响验证结果。Application chain miners can judge whether they can draw a verification conclusion according to the above rules every time they receive an inspection report, or application chain miners can cache the received inspection reports first and make judgments at appropriate times (for example, regular judgments) . For the received inspection reports, application chain miners can prioritize the inspection reports of the earlier rounds according to the round numbers of the members of the selected verification group, so as to prevent the adversary from broadcasting the reports of later rounds in advance and affecting the verification results.
若应用链矿工根据检验报告确定提案组领导人所出区块验证通过,则将该区块纳入应用链账本中,并可以开始下一应用链待挖区块的提案组成员的推选。若应用链矿工根据检验报告确定提案组领导人所出区块验证未通过,则弃用提案组领导人所出区块,若该区块已经纳入应用链账本并且之后还串接了其他区块则一同弃用,并重新开始应用链待挖区块的提案组成员的推选。其中,弃用提案组领导人所出区块之后的区块对应验证通过结论被推翻的情况,在后文有具体说明。If the application chain miners determine that the block produced by the leader of the proposal group is verified according to the inspection report, the block will be included in the application chain ledger, and the selection of proposal group members for the next application chain to be mined can be started. If the application chain miner determines that the block produced by the leader of the proposal group fails to pass the verification according to the inspection report, the block produced by the leader of the proposal group will be discarded. If the block has been included in the application chain ledger and other blocks have been connected later They are discarded together, and the selection of members of the proposal group for the block to be mined in the application chain is restarted. Among them, the block after the block produced by the leader of the abandonment proposal group corresponds to the situation where the conclusion of the verification is overturned, which will be explained in detail later.
应用链矿工统计检验报告可视为一个统计投票过程,投票者为验证组成员,对该过程更一般的描述如下:The application chain miner statistical inspection report can be regarded as a statistical voting process, and the voters are members of the verification group. A more general description of the process is as follows:
应用链矿工首先确定收到的检验报告的在验证过程中所占的票数,然后进行判断:若收到的检验报告中检验结论为通过的报告所占的总票数不小于最小成功验证数,以及,检验结论为不通过的报告所占的总票数不大于最大失败验证数,则确定提案组领导人所出区块验证通过。当然还有需要继续等待以及未通过的情况,和上文类似,这里省略不写。Application chain miners first determine the number of votes in the verification process of the received inspection report, and then make a judgment: if the inspection conclusion in the received inspection report is that the total number of votes in the report is not less than the minimum number of successful verifications, and , The total number of votes in the report whose inspection conclusion is that the failure is not greater than the maximum number of failed verifications, then the block verification by the leader of the proposal group is determined to be passed. Of course, there are still cases that need to wait and fail, which are similar to the above, and are omitted here.
在最常见的情形中,一份检验报告可以对应一票,在上文已经介绍。但在另一些实现方式中,每份检验报告所占的票数可以设置为与生成该检验报告的验证组成员当前持有的数字货币的数量正相关。让持币多的验证组成员出具的检验报告占据一定优势的原因在于:持币越的提案组成员与应用链利益关系越密切,其作弊可能性也越小。In the most common situation, one inspection report can correspond to one vote, as described above. However, in other implementations, the number of votes occupied by each inspection report can be set to be positively correlated with the amount of digital currency currently held by the verification group member that generated the inspection report. The reason why the inspection report issued by the members of the verification team with more currency has a certain advantage is that the more members of the proposal team who hold the currency are more closely related to the interests of the application chain, the less likely it is to cheat.
可选的,检验报告在验证过程中所占的票数可以利用如下公式计算:Optionally, the number of votes occupied by the inspection report during the verification process can be calculated using the following formula:
vote_num=1+stake/leveragevote_num=1+stake/leverage
其中,vote_num为检验报告所占的票数,stake为生成检验报告的验证组成员当前持有的数字货币的数量,持币量记录在应用链账本中,任一应用链矿工均可查询,leverage为预设的票数调节比例。Among them, vote_num is the number of votes occupied by the inspection report, stake is the number of digital currencies currently held by the members of the verification group that generated the inspection report, and the currency holdings are recorded in the application chain ledger, which can be queried by any application chain miner, and leverage is The preset vote adjustment ratio.
为简单起见,在后文阐述时,还是以一份检验报告一票的方式为例进行阐述,若检验报告的份数与票数并不一致,对相关内容进行适应性调整即可。For the sake of simplicity, in the following explanation, the method of one inspection report for one vote is used as an example. If the number of copies of the inspection report is not consistent with the number of votes, the relevant content can be adjusted adaptively.
对于应用链某一高度的区块,应用链矿工在未收到足够多的针对该区块的检验报告之前,并不能精确得出该区块是否会验证通过的结论,这导致得出验证结论可能会等上比较长的时间。在一种可选的方案中,若应用链矿工发现收到的检验报告中检验结论为通过的报告份数占最小成功验证数的比例已不小于预设的已验证比例(当然同时也要满足检验结论为不通过的报告份数不大于最大失败验证数),则提前开始下一应用链待挖区块的提案组成员的推选以及打包区块等工作。其中,已验证比例可以取50%、60%等等。大多数情况下,应用链区块的验证结论都是通过,因此提前推选出的提案组成员多数情况下是可靠的,后续被撤销提案组成员身份的概率不高,上述举措有利于提高验证和提案工作的并行性,进而提升区块链系统的TPS。For a block at a certain height of the application chain, the application chain miners cannot accurately conclude whether the block will pass the verification before receiving enough inspection reports for the block, which leads to a verification conclusion It may take a long time. In an optional scheme, if the application chain miner finds that in the received inspection report, the proportion of the number of reports that the inspection conclusion is passed to the minimum number of successful verifications is no less than the preset verified proportion (of course, it must also meet The inspection conclusion is that the number of failed reports is not greater than the maximum number of failed verifications), then the selection of the proposal group members of the block to be mined in the next application chain and the packaging of the block will be started in advance. Among them, the verified ratio can be 50%, 60%, and so on. In most cases, the verification conclusion of the application chain block is passed, so the proposal group members selected in advance are reliable in most cases, and the probability of subsequent withdrawal of the membership of the proposal group is not high. The above-mentioned measures are conducive to improving verification and verification. The parallelism of the proposal work further enhances the TPS of the blockchain system.
之前在阐述步骤S105和S106时,提到了提前验证的实现方式(P>1),验证组成员可以提前对提案组领导所出区块进行验证并广播检验报告,每个应用链矿工根据这些检验报告可能提前几轮就知道区块的验证结果,若验证结论为通过,应用链矿工即可明确下次应该在应用链哪个高度挖矿,从而可以提前参与下一应用链待挖区块的提案组成员的推选,进而提前向基链矿工发出针对下一应用链待挖区块的挖矿请求,因此挖矿请求有更多的时间在基链中传播,有利于基链矿工选出提案组领导人。In the previous description of steps S105 and S106, the implementation of advance verification was mentioned (P>1). The members of the verification group can verify the block produced by the leader of the proposal group in advance and broadcast the inspection report. Each application chain miner will check according to these inspections. The report may know the verification result of the block several rounds in advance. If the verification conclusion is passed, the application chain miners can determine at which height the application chain should mine next time, so that they can participate in the proposal of the next application chain to be mined in advance. The selection of the group members, and then send the mining request for the next application chain to be mined block to the base chain miners in advance, so the mining request has more time to spread in the base chain, which is conducive to the base chain miners to select the proposal group leader.
但需要注意的是,尽管应用链矿工可以提前收到检验报告,并且可以根据这些检验报告得出提案组领导人所出区块验证通过的结论,但还是要等待检验报告生效时刻到来,才能执行将区块纳入应用链账本、参与下一应用链待挖区块的提案组成员的推选等工作。其中,检验报告在应用链矿工同步到报告生成轮次对应的基链区块信息后生效,而报告生成轮次是指生成检验报告的应用链矿工被推选为验证组成员的推选轮次。However, it should be noted that although the application chain miners can receive the inspection report in advance, and can draw the conclusion that the block verification by the leader of the proposal group has passed based on these inspection reports, they still have to wait for the inspection report to take effect before it can be executed. Include the block in the application chain ledger, and participate in the selection of the members of the proposal group for the next application chain to be mined. Among them, the inspection report takes effect after the application chain miners synchronize to the base chain block information corresponding to the report generation round, and the report generation round refers to the selection round in which the application chain miners who generated the inspection report are elected as members of the verification group.
例如,应用链矿工提前收到了在第二轮验证组成员推选中被选为验证组成员的应用链矿工发送的检验报告,并且根据该份报告可以确定提案组领导人所出区块验证通过,也不能立刻执行后续步骤,而需要等待应用链矿工同步到原本用于指示开始第二轮验证组成员推选的基链区块信息。但是,一旦该同步到该基链区块信息,应用链矿工可立即给出提案组领导人所出区块验证通过的结论,所以在时间上还是有提前的,至多可以提前一个基链出块时间。For example, application chain miners received in advance the inspection report sent by the application chain miners selected as members of the verification group in the second round of verification group members, and based on the report, it can be determined that the block verification by the leader of the proposal group has passed. The subsequent steps cannot be executed immediately, and it is necessary to wait for the application chain miners to synchronize to the base chain block information originally used to indicate the start of the second round of verification group member selection. However, once it is time to synchronize to the base chain block information, the application chain miner can immediately give a conclusion that the block verification by the leader of the proposal group has passed, so there is still an advance in time, at most one base chain can be produced in advance. time.
因此,所谓提前验证本质上只是提高了验证组成员推选和后续步骤之间的并行化程度,并未破坏基链出块和验证组成员推选之间的同步关系。Therefore, the so-called advance verification essentially only improves the degree of parallelization between the verification group member selection and subsequent steps, and does not destroy the synchronization relationship between the base chain block generation and the verification group member selection.
在采用了提前验证机制后,虽然应用链矿工可能提前获知提案组领导人所出区块的验证结论,从而有时间进行作弊,例如更改一下应用链待挖区块的高度,但由于区块链的共识机制需要多个矿工认同才能确认结果,所以即使个别应用链矿工作弊,其他诚实矿工不与它串通,作弊行为也是徒劳:比如,个别不诚实矿工改变应用链待挖区块的高度,而多数诚实矿工并不在该高度上开展下一轮挖矿,不诚实矿工的作弊行为最终因投票不足而失败。After adopting the early verification mechanism, although the application chain miners may be informed of the verification conclusion of the block produced by the leader of the proposal group in advance, they have time to cheat, such as changing the height of the block to be mined in the application chain, but because of the blockchain The consensus mechanism requires the approval of multiple miners to confirm the result. Therefore, even if the individual application chain mining is cheating, other honest miners do not collude with it, and the cheating behavior is futile: for example, individual dishonest miners change the height of the application chain to be mined, and Most honest miners do not carry out the next round of mining at this height, and the cheating behavior of dishonest miners ultimately fails due to insufficient votes.
前文提到,在提案组领导人所出区块的验证阶段,应用链矿工至多等待预设的时长,若在这段时间内接收到的检验结论为通过的报告份数始终小于最小成功验证数(当然若这段时间内接收到的检验结论为不通过的报告份数大于最大失败验证数,则等待过程提前结束),则可确定提案组领导人所出区块验证未通过。As mentioned above, during the verification phase of the block produced by the leader of the proposal group, the application chain miners wait at most for a preset time. If the inspection conclusion received during this period is that the number of reports passed is always less than the minimum number of successful verifications (Of course, if the number of failed verification reports received during this period is greater than the maximum number of failed verifications, the waiting process ends early), it can be determined that the block verification by the leader of the proposal group has failed.
在一种实现方式中,上述预设的时长为MaxRounds+Q个基链出块时间(Q取0或正整数),对于应用链矿工来说,连续两次同步到基链区块信息之间的间隔就是一个基链出块时间。该预设的时长从应用链矿工同步到确定应用链待挖区块的提案组领导人的基链区块信息起开始计时(该时刻也是首轮验证组成员推选的起始时刻),在前MaxRounds个基链出块时间内允许应用链矿工参与验证组成员的推选(至多进行 MaxRounds轮推选)并在确认被选中后广播生成的检验报告,在后Q个基链出块时间内应用链矿工虽然不能再参选验证组成员的推选,但可以持续接收检验报告并根据对检验报告的统计结果确定提案组领导人所出区块是否验证通过。当然,若某个应用链矿工在第MaxRounds轮推选之前就被选为验证组成员,它用于接收检验报告的时间就会相对更长一些。In one implementation, the above-mentioned preset duration is MaxRounds+Q base chain block generation time (Q takes 0 or a positive integer). For application chain miners, it is synchronized twice to the base chain block information. The interval is the block time of a base chain. The preset duration starts from the synchronization of the application chain miners to the base chain block information of the leader of the proposal group that determines the block to be mined in the application chain (this time is also the starting time for the first round of verification group member selection). MaxRounds base chain block generation time allows application chain miners to participate in the selection of verification group members (up to MaxRounds round selection) and broadcast the generated inspection report after confirming that they are selected, and apply chain miners within the next Q base chain block generation time Although you can no longer participate in the selection of members of the verification team, you can continue to receive inspection reports and determine whether the block produced by the leader of the proposal team has been verified based on the statistical results of the inspection reports. Of course, if an application chain miner is selected as a member of the verification team before the MaxRounds round of selection, it will take longer to receive the inspection report.
重要的是,对于一个应用链矿工,即使它根据已经收到的针对提案组领导人所出区块的检验报告已经确认了该区块验证通过,也得继续接收检验报告,直至达到MaxRounds+Q个基链出块时间,在此期间,根据新接收到的检验报告,提案组领导人所出区块验证通过的结论可能被推翻,因为若新接收到的检验报告中的检验结论为不通过,可能导致检验结论为不通过的报告分数大于最大失败验证数。此时,提案组领导人所出区块将被弃用,并且,由于之前已经将该区块认定为验证通过,从而后续高度的应用链区块的挖矿工作已经随之启动,甚至后续区块已经纳入应用链账本,因此若该区块已经纳入应用链账本并且之后还串接了其他区块,串接在其后的区块也要一同弃用,处理完毕后可以重新开始应用链待挖区块的提案组成员的推选。当然,已得出验证结论被推翻是少数情况,大多数情况下应用链矿工收到新的检验报告后还是能维持之前得出的验证结论,并不会导致已出区块频繁作废。What is important is that for an application chain miner, even if it has confirmed that the block has been verified according to the inspection report for the block produced by the leader of the proposal group, it must continue to receive the inspection report until it reaches MaxRounds+Q The block generation time of each base chain. During this period, according to the newly received inspection report, the conclusion of the block verification passed by the leader of the proposal group may be overturned, because if the inspection conclusion in the newly received inspection report is not passed , The report score that may cause the inspection conclusion to be failed is greater than the maximum number of failed verifications. At this time, the block produced by the leader of the proposal group will be discarded, and because the block has been recognized as verified before, the mining of the subsequent high-level application chain block has been started, and even the follow-up area The block has been included in the application chain ledger. Therefore, if the block has been included in the application chain ledger and other blocks are connected in series afterwards, the following blocks should also be discarded together. After processing, the application chain can be restarted. Selection of members of the proposal group for mining blocks. Of course, it is a rare case that the verification conclusions have been overturned. In most cases, the application chain miners can still maintain the previous verification conclusions after receiving the new inspection report, and will not cause the existing blocks to be frequently invalidated.
需要指出,若应用链矿工在尚未到达MaxRounds+Q个基链出块时间的某个时间点根据已经收到的针对提案组领导人所出区块的检验报告已经确认了该区块验证未通过,则可直接重新开始应用链待挖区块的提案组成员的推选,不必再等待下去。因为报告的份数只会累加不会减少,一旦检验结论为不通过的检验报告分数大于最大失败验证数,后续再接收检验报告,也不会改变该结论,即,只有验证通过的情况才有可能出现结论反转。增设Q个基链出块时间专门用于继续接收检验报告的原因在于,检验报告在应用链中传播需要时间,因为通信等因素可能导致传播延迟,使得先期得出的验证结论不够准确。It should be pointed out that if the application chain miner has not reached the MaxRounds+Q base chain block generation time at a certain point in time, according to the inspection report that has been received for the block produced by the leader of the proposal group, it has confirmed that the block verification has not passed. , You can directly restart the selection of the members of the proposal group for the block to be mined in the application chain, without waiting any longer. Because the number of reports will only accumulate and will not decrease, once the test conclusion is that the score of the test report that fails is greater than the maximum number of failed verifications, subsequent inspection reports will be received, and the conclusion will not be changed, that is, only the cases where the verification is passed. The conclusion may be reversed. The reason for adding Q base chain block generation times to continue receiving inspection reports is that it takes time for inspection reports to propagate in the application chain, because communication and other factors may cause propagation delays, making the previous verification conclusions not accurate enough.
若允许应用链矿工在至多MaxRounds+Q个基链出块时间等待检验报告,意味着应用链矿工至多允许Q+1个连续高度的应用链区块处于验证状态。其中,从区块的验证组成员推选开始,直至得出最终的验证结论(指不可再被推翻的结论)这段时间内区块处于验证状态。例如,当应用链待挖区块开始验证时,至多允许包含它自身在内的最近Q+1个高度的区块同时处于验证状态,应用链待挖区块之前高度的区块虽已验证通过,但由于处于验证状态的时间尚未到达MaxRounds+Q个基链出块时间,因此还未得出最终的验证结论。在理想状态下,基链和应用链保持同频出块(同频出块具体见后文),所以当验证等待时间多出Q个基链出块时间时,允许处于同时验证状态的应用链区块是Q+1个。特别情况下,Q可取0,表示允许处于验证状态的应用链区块只有1个。If the application chain miners are allowed to wait for the inspection report for at most MaxRounds+Q base chain block generation time, it means that the application chain miners allow at most Q+1 consecutive high application chain blocks to be in the verification state. Among them, the block is in the verification state during the period from the selection of the verification group members of the block until the final verification conclusion (referring to the conclusion that can no longer be overturned) is reached. For example, when the application chain block to be mined starts to be verified, at most the blocks with the latest Q+1 height including itself are allowed to be in the verification state at the same time, although the block of the height before the block to be mined in the application chain has been verified and passed , But since the time in the verification state has not reached the time of MaxRounds+Q base chain block generation, the final verification conclusion has not yet been reached. In an ideal state, the base chain and the application chain keep generating blocks at the same frequency (see below for details on the same frequency for block generation), so when the verification waiting time is more than Q base chain block generation time, the application chain in the simultaneous verification state is allowed The number of blocks is Q+1. In special cases, Q can be set to 0, which means that only one application chain block is allowed to be in the verification state.
在基链出块的驱动下,处于挖矿进程中的应用链矿工的工作状态将在待挖区块的提案状态与验证状态之间循环切换,一旦某个区块得出验证结论(不一定要是最终的验证结论),应用链矿工随即进入下一区块的提案组构建工作,它将依据最新同步的基链区块信息确认下一区块是否已选出提案组领导人,进而决定是否继续组建提案组。若下一区块已选出提案组领导人,则下一区块直接进入验证状态,若下一区块未选出提案组领导人,则下一区块进入提案状态,应用链矿工开始为其推选提案组成员、发送挖矿请求等操作。若应用链矿工确定某个待挖区块的提案组领导人始终未选出,则会在每次基链出块时(对应于应用链矿工而言就是同步到基链区块信息)尝试重建提案组,直至该待挖区块的提案组领导人被选出或者在针对某一旧高度的区块重挖成功。Driven by the block production of the base chain, the working state of the application chain miners in the mining process will switch between the proposal state and the verification state of the block to be mined. Once a block reaches a verification conclusion (not necessarily If it is the final verification conclusion), the application chain miner will immediately enter the proposal group construction work of the next block. It will confirm whether the proposal group leader has been selected for the next block based on the latest synchronized base chain block information, and then decide whether Continue to form a proposal group. If the leader of the proposal group has been selected in the next block, the next block will enter the verification state directly. If the leader of the proposal group is not selected in the next block, the next block will enter the proposal state, and the application chain miners will start to be It selects members of the proposal group, sends mining requests and other operations. If the application chain miner determines that the leader of the proposal group for a block to be mined has not been selected, it will try to rebuild every time the base chain is produced (corresponding to the application chain miner, it is synchronized to the base chain block information) Proposal group, until the leader of the proposal group of the block to be mined is selected or re-mining a block of an old height is successful.
根据上面的阐述,若有多个高度的应用链区块同时处于验证状态(这些区块必然已选出提案组领导人),只有当其中高度最高的区块最终验证通过后,应用链矿工才会在该区块之后的高度展开新的提案组组建工作。对于非最高高度的区块,即使已得出最终的验证结论为通过,也不会导致应用链矿对针对该区块的下一高度展开新的提案组组建工作(因为此时下一高度的区块还处于验证状态)。According to the above explanation, if there are multiple high-level application chain blocks in the verification state at the same time (these blocks must have selected the leader of the proposal group), only when the highest block among them is finally verified, the application chain miners A new proposal group will be organized at a height after this block. For blocks with a non-highest height, even if the final verification conclusion is passed, it will not cause the application chain mine to launch a new proposal group for the next height of the block (because at this time the next height is The block is still in the verification state).
前文曾经提到提案阶段的定向腐蚀问题,对于验证阶段,也可能存在定向腐蚀问题。作为一种解决方案,在应用链中可以通过确保参与完整验证的矿工数量来避免定 向腐蚀,改善区块链系统的安全性。例如,若应用链矿工总数不多,可采用全员验证方式,若应用链矿工总数较多,可从中组建验证组,并且最小成功验证数不能设置得太小(比如,可取数十个至数百个)。当有足够多数量的应用链矿工参与区块的完整验证,要进行全面的定向腐蚀非常困难(区块的验证结果是统计得出的,对个别验证者定向腐蚀意义不大)。The issue of directional corrosion in the proposal stage has been mentioned in the previous article. For the verification stage, there may also be directional corrosion problems. As a solution, the application chain can avoid directional corrosion by ensuring the number of miners participating in complete verification and improve the security of the blockchain system. For example, if the total number of miners in the application chain is small, the full verification method can be adopted. If the total number of miners in the application chain is large, a verification group can be formed from them, and the minimum number of successful verifications cannot be set too small (for example, you can take tens to several A hundred). When a sufficient number of application chain miners participate in the complete verification of the block, it is very difficult to conduct a comprehensive directional corrosion (the verification result of the block is obtained by statistics, and the directional corrosion of individual verifiers is of little significance).
上面介绍了本公开提供的区块链系统进行共同挖矿的主要流程,下面再补充介绍该区块链系统在运行过程中涉及的一些关键问题:The main process of the blockchain system provided by the present disclosure for joint mining is described above, and some key issues involved in the operation of the blockchain system are supplemented below:
(1)同频出块问题(1) Block generation problem at the same frequency
为维持本公开中的区块链系统的正常工作,在常见的实现方式中,应用链应保持与基链基本相同的出块频率(简称同频出块),具体表现为应用链的最大块高常处于快追上基链最大块高的状态,通常只相差数块,需要保持同频出块的原因稍后再分析。然而发明人研究发现,如果应用链只按照常规方式出块,出块频率必然小于基链。其原因在于:In order to maintain the normal operation of the blockchain system in this disclosure, in common implementations, the application chain should maintain basically the same block generation frequency as the base chain (referred to as the same frequency block generation), which is specifically expressed as the largest block of the application chain Gao Chang is in a state of fast catching up with the largest block height of the base chain, usually only a few blocks away, and the reason for maintaining the same frequency for block generation will be analyzed later. However, the inventor found that if the application chain only produces blocks in a conventional manner, the frequency of block generation must be less than that of the base chain. The reason is:
第一,应用链上组建提案组或验证组可能失败,从而导致应用链矿工出块失败,使得应用链出块频率降低。无论是提案组还是验证组,都对成员的数量有一定的要求,例如,对于提案组成员的数量有最低矿工个数的要求,最小成功验证数也暗含对验证组成员的数量的要求。然而,若提案组或验证组成员采用VRF算法推选,必然存在数量不足的可能,因为VRF算法的结果具有随机性,只能从概率意义上保证选出的成员数量符合预期,但具体到某一次组建提案组或验证组的过程,则选出的成员数量未必符合要求。First, the establishment of a proposal group or a verification group on the application chain may fail, causing the application chain miners to fail to produce blocks, which reduces the frequency of application chain blocks. Both the proposal group and the verification group have certain requirements for the number of members. For example, there is a minimum number of miners for the number of members of the proposal group, and the minimum number of successful verifications also implies a requirement for the number of members of the verification group. However, if the members of the proposal group or the verification group are selected using the VRF algorithm, there is bound to be insufficient. Because the result of the VRF algorithm is random, it can only be guaranteed from the probability sense that the number of members selected meets expectations, but it is specific to a certain time. In the process of forming a proposal group or a verification group, the number of members selected may not meet the requirements.
第二,由于通信不畅,提案组领导人的选举结果或者检验报告未能及时送达导致应用链矿工出块失败,使得应用链出块频率降低。Second, due to poor communication, the election results or inspection reports of the leader of the proposal group were not delivered in time, resulting in the failure of application chain miners to produce blocks, which reduced the frequency of application chain blocks.
第三,即使基链已为应用链区块成功选出提案组领导人,由于组建验证组时存在多轮推选机制,该区块可能还需要隔上几个基链出块的时间才能确定全部的验证组成员,这也使得应用链的出块时间相较于基链偏慢。应用链在推选验证组成员时预期进行的轮次与应用链的设计意图有关,例如,若应用链更看重消息(比如,检验报告等)在节点间的充分传播(消息传播越充分敌手作案就越难),则可多进行几轮验证组成员推选(设法调低每轮被选中的比例)。Third, even if the base chain has successfully selected the leader of the proposal group for the application chain block, due to the multiple rounds of selection mechanism when forming the verification group, the block may still need to be determined after a few base chain block generations. This also makes the block generation time of the application chain slower than that of the base chain. The expected rounds that the application chain conducts when selecting members of the verification group are related to the design intent of the application chain. For example, if the application chain pays more attention to the full dissemination of messages (such as inspection reports, etc.) between nodes (the more the message dissemination, the more the adversary commits crimes) The more difficult it is), you can conduct more rounds of selection of members of the verification group (try to reduce the proportion of each round being selected).
作为对比的,基链出块频度很确定,主要取决于基链上的挖矿算力,通常不受其他因素干扰,特别地,根据前面的阐述,即使在某次基链出块时针对某条应用链上的待挖区块无法选出提案组领导人,本次不在所出的基链区块中记录该待挖区块的选举结果即可,即基链出块并不受应用链出块影响。In contrast, the frequency of block production on the base chain is very certain, which mainly depends on the mining power on the base chain, and is usually not interfered by other factors. In particular, according to the previous explanation, even when a block is produced on the base chain, it is A proposal group leader cannot be selected for a block to be mined on a certain application chain. This time, the election result of the block to be mined is not recorded in the base chain block. That is, the base chain block is not applied Block chain impact.
因此,保持同频出块实际上就是要提高应用链的出块频率,使其能够赶上基链的出块进度。在一种实现方式中,应用链矿工在打包应用链待挖区块时(应用链矿工可能在确定自身为提案组成员后就打包,或者可能在确定自身为提案组领导人后才打包,如前文所述),会判断确定提案组领导人的基链区块的高度与应用链待挖区块的高度之差是否大于预设的第一差值阈值,若两个高度之差大于第一差值阈值,则连续打包应用链待挖区块以及预设个数(至少一个)的空块,若两个高度之差不大于第一差值阈值,则只打包应用链待挖区块。例如,假设确定提案组领导人的基链区块的高度为X,应用链待挖区块的高度为Y,第一差值阈值取4,若X-Y>4,则可以连续打包应用链待挖区块以及一个空块。Therefore, maintaining the same frequency of block generation is actually to increase the block generation frequency of the application chain so that it can catch up with the block generation progress of the base chain. In one implementation, the application chain miner packs the block to be mined in the application chain (the application chain miner may pack it after confirming that he is a member of the proposal group, or may pack it after confirming that he is the leader of the proposal group, such as As mentioned above), it will determine whether the difference between the height of the base chain block of the leader of the proposal group and the height of the block to be mined in the application chain is greater than the preset first difference threshold. If the difference between the two heights is greater than the first The difference threshold is to continuously pack the application chain to be mined blocks and a preset number (at least one) of empty blocks. If the difference between the two heights is not greater than the first difference threshold, only the application chain to be mined blocks are packed. For example, suppose it is determined that the height of the base chain block of the leader of the proposal group is X, the height of the block to be mined in the application chain is Y, and the first difference threshold is 4, if XY>4, the application chain to be mined can be continuously packaged Block and an empty block.
对于连续打包的应用链待挖区块和空块,其中,前者就是正常出块,而预设个数的空块则起填充作用,其目的只是为了增加应用链的块高,从而提高应用链的出块频率,空块内不包含任何交易内容。可选的,应用链待挖区块的区块头中还可以增加一项标记,用于表明其为连续出块中的首块。在验证组成员对提案组领导人所出区块进行验证时,空块也要参与验证,不过可以直接在检验报告中给出检验通过的结论。For the continuously packaged application chain to-be-mined blocks and empty blocks, the former is the normal block generation, and the preset number of empty blocks play a filling role. The purpose is to increase the block height of the application chain, thereby increasing the application chain. The frequency of block generation, the empty block does not contain any transaction content. Optionally, a mark may be added to the block header of the block to be mined in the application chain to indicate that it is the first block in the continuous block. When the members of the verification group verify the block produced by the leader of the proposal group, the empty block also participates in the verification, but the conclusion that the verification has passed can be directly given in the verification report.
根据前文对提案组领导人选举过程的介绍,基链矿工在打包基链区块时,会根据基链账本中记录的、已经选出提案组领导人的应用链最高区块确定应用链待挖区块的高度,并从缓存的挖矿请求中选择匹配于该高度的挖矿请求纳入针对应用链待挖区块的待选举集合。对于应用链矿工可出空块的情况,相应地,基链矿工可以判断确定应 用链待挖区块的提案组领导人的基链区块的高度(该高度可以从针对应用链待挖区块的待选举集合的挖矿请求中直接提取)与应用链待挖区块的高度之差是否大于预设的第一差值阈值,若两个高度之差大于第一差值阈值,则标记在应用链待挖区块所在的高度处应用链矿工会进行连续出块。According to the previous introduction to the election process of the proposal group leader, when the base chain miners pack the base chain blocks, they will determine the application chain to be mined based on the highest block of the application chain recorded in the base chain ledger and the leader of the proposal group has been selected. The height of the block, and the mining request matching the height is selected from the cached mining requests to be included in the waiting set for the block to be mined in the application chain. For the case where application chain miners can produce empty blocks, correspondingly, the base chain miners can determine the height of the base chain block of the leader of the proposal group to determine the application chain to be mined block (this height can be changed from for the application chain to be mined block Is directly extracted from the mining request of the set to be elected) and whether the difference between the height of the block to be mined in the application chain is greater than the preset first difference threshold. If the difference between the two heights is greater than the first difference threshold, it will be marked in The application chain mining union will continuously produce blocks at the height where the block to be mined is located.
从而,基链矿工在后续确定应用链的最大块高时(例如,汇集针对下一应用链待挖区块的挖矿请求进行提案组领导人选举时),应考虑标记有连续出块的应用链高度,在这些高度处应用链每次出块引起的高度增长将大于1,比如,若允许应用链矿工一次连出两块(其中一块为空块),则在标记有连续出块的应用链高度处,应用链的高度在一次出块后将增长2。Therefore, when base chain miners subsequently determine the maximum block height of the application chain (for example, when collecting mining requests for the next application chain to be mined for the proposal group leader election), they should consider applications marked with continuous block generation The height of the chain. At these heights, the height increase caused by each block of the application chain will be greater than 1. For example, if the application chain miner is allowed to connect two blocks at a time (one of which is an empty block), then the application marked with continuous block generation At the chain height, the height of the application chain will increase by 2 after one block is produced.
如果按照上述方法,应用链还是无法追上基链的出块速度,则说明应用链的某些配置参数可能选择欠佳,需要调整,例如最小当选随机值、最小成功验证数、最大失败验证数等参数设置不当可能导致选出的提案组或验证组中成员过少,应用链出块困难。If according to the above method, the application chain still cannot catch up with the block generation speed of the base chain, it means that some configuration parameters of the application chain may be poorly selected and need to be adjusted, such as the minimum random value of the election, the minimum number of successful verifications, and the maximum number of failed verifications. Improper setting of other parameters may result in too few members in the selected proposal group or verification group, making it difficult to generate blocks in the application chain.
可选的,还可以针对每条应用链预设一个第二差值阈值(第二差值阈值大于第一差值阈值),若基链矿工判断出上述两个高度之差大于第二差值阈值,则表明应用链已经无法追赶基链出块,为避免对区块链系统的稳定运行产生负面影响,此时基链可以拒绝为应用链继续提供算力支持。反之,若基链矿工判断出上述两个高度之差不大于第二差值阈值,则应允许应用链继续通过出空块的方式追赶基链出块。Optionally, a second difference threshold can be preset for each application chain (the second difference threshold is greater than the first difference threshold), if the base chain miner determines that the difference between the above two heights is greater than the second difference The threshold indicates that the application chain has been unable to catch up with the base chain to produce blocks. In order to avoid a negative impact on the stable operation of the blockchain system, the base chain can refuse to continue to provide computing power support for the application chain. Conversely, if the base chain miner determines that the difference between the above two heights is not greater than the second difference threshold, the application chain should be allowed to continue to catch up with the base chain by generating empty blocks.
在本公开提供的区块链系统中,基链通常比应用链更早启动运行,因此将基链算力接入到新启动的应用链时,基链很可能已运行一段时间了,只要应用链在创世区块指定的初始块高,与基链当前最大块高能衔接上,后续挖矿就能正常推进。即应用链首个区块通常不从0开始编号,而改由衔接时刻基链已有块高开始编号,相当于默认在此之前应用链和基链出块完全同步。In the blockchain system provided by the present disclosure, the base chain usually starts operation earlier than the application chain. Therefore, when the base chain computing power is connected to the newly started application chain, the base chain may have been running for a period of time, as long as the application The initial block height specified by the chain in the genesis block is connected with the current maximum block height of the base chain, and subsequent mining can proceed normally. That is, the first block of the application chain is usually not numbered from 0, but the numbering starts with the block height of the base chain at the time of connection, which is equivalent to the default that the application chain and the base chain are completely synchronized before this.
前面提到,基链出块频度很确定,通常不受挖矿算力以外的因素干扰。应用链在基链出块(对于应用链矿工来说通过同步基链区块信息感知基链出块)的驱动下进行提案及验证等操作,相当于基链为应用链提供一个确定的时钟系统,不妨称之为时钟源,应用链执行各种操作的时机均以此时钟源为参照。应用链采用基链充当时钟源,可以避免应用链自行定义时钟导致的安全性问题:分布式系统常因缺少统一的时间标准,容易被敌手聚焦攻击,比方一应用链条链的矿工中敌手人数占优,敌手可以控制链上时间的计算,比方将1小时记作1分钟,给解密、定向攻击等留出时间。顺带一提,除了时钟源之外,应用链矿工在推选提案组成员时用到的第一选举字串、在推选验证组成员时用到的第二选举字串也来自于基链,敌手同样难以操纵,可将这两个字串称为随机源(因为选举具有随机性),时钟源与随机源是应用链安全保障的两大基石,因时钟源与随机源均由应用链的链外系统(即基链)提供。As mentioned earlier, the frequency of block generation on the base chain is very certain, and it is usually not interfered by factors other than mining power. The application chain is driven by the base chain to produce blocks (for application chain miners through the synchronization of the base chain block information to perceive the base chain to produce blocks) to carry out proposals and verification operations, which is equivalent to the base chain providing a definite clock system for the application chain , May as well call it a clock source, and the timing of various operations performed by the application chain is based on this clock source. The application chain uses the base chain as the clock source to avoid security problems caused by the application chain’s self-defining clock: distributed systems often lack a unified time standard and are easily attacked by the adversary. For example, the number of adversaries among the miners of the application chain chain Excellent, the adversary can control the calculation of the time on the chain, for example, 1 hour is counted as 1 minute to allow time for decryption, targeted attacks, etc. By the way, in addition to the clock source, the first election string used by application chain miners when selecting members of the proposal group and the second election string used when selecting members of the verification group are also from the base chain, and the opponents are the same. It is difficult to manipulate. These two strings can be called random sources (because the election is random). Clock source and random source are the two cornerstones of application chain security, because the clock source and random source are both outside the application chain. System (ie base chain) provided.
应用链将基链用作为时钟源后,因尽量维持与基链出块频率一致,否则将导致应用链中每两相邻区块生成时间间隔的波动幅变大,对应用链平稳出块不利。在应用链的一些上层应用(如交易转账)中,取应用链区块的出块时间作为与业务流程相关的时间节点或计算这些时间节点的依据,出块时间的波动将直接影响业务对时间判断的精确性。若应用链能够与基链保持同频出块,则可以避免出块时间偏差产生累积效应(应用链中插入空块后应用链平均出块时间将趋同于基链)。还需要指出,空块作为一种保持同频出块的特殊措施,应尽可能避免干扰应用链本身的计时逻辑,例如,空块出块的过程在逻辑上可理解为占用0时长,因此在应用链的上层应用中如果要取用应用链区块的出块时间,空块与它之前的非空块所跨越的时长应视作0时长。After the application chain uses the base chain as a clock source, the frequency of block generation should be consistent with that of the base chain as much as possible. Otherwise, the fluctuation amplitude of the generation time interval of every two adjacent blocks in the application chain will increase, which is not good for the smooth block generation of the application chain. . In some upper-level applications of the application chain (such as transaction transfer), the block generation time of the application chain block is taken as the time node related to the business process or the basis for calculating these time nodes. The fluctuation of the block generation time will directly affect the business time The accuracy of judgment. If the application chain can produce blocks at the same frequency as the base chain, the cumulative effect of block generation time deviation can be avoided (the average block generation time of the application chain after inserting empty blocks in the application chain will converge to the base chain). It should also be pointed out that, as a special measure to maintain the same frequency, the empty block should avoid interference with the timing logic of the application chain itself. For example, the process of empty block generation can be logically understood as occupying 0 hours. If the upper-level application of the application chain wants to use the block generation time of the application chain block, the time span between the empty block and the previous non-empty block should be regarded as 0 duration.
(2)软分叉及最长链问题(2) Soft fork and longest chain problem
在典型的区块链公链系统中,各矿工自主决定何时出块,例如在比特币系统中,某矿工随机碰撞到一个符合难度系数要求的哈希值,算力竞争就胜出了,该矿工随后将自己打包的新块全链广播。这种处理方式必然导致同一时间可能有多个矿工在打包同一高度的区块,即,账本中出现软分叉是必然的。现有的公链系统一般通过最长链机制来消除软分叉,其中涉及最长链切换操作,具体可参考现有技术,此处不展开阐述。软分叉虽不至于使公链系统无法运作,但如果其频繁发生,最长链切换操作也必 然频繁执行,导致已记账交易频繁发生回退,进而影响系统的稳健性。因此,有必要对软分叉进行抑制或者尽可能削弱软分叉产生的影响。In a typical blockchain public chain system, each miner independently decides when to produce a block. For example, in the Bitcoin system, a miner randomly collides with a hash value that meets the difficulty factor requirement, and the computing power competition wins. The miners then broadcast the whole chain of the new blocks they have packaged. This approach will inevitably lead to multiple miners packing blocks of the same height at the same time, that is, soft forks in the ledger are inevitable. The existing public chain system generally eliminates soft forks through the longest chain mechanism, which involves the longest chain switching operation. For details, please refer to the prior art, which will not be elaborated here. Although the soft fork will not make the public chain system inoperable, if it occurs frequently, the longest chain switching operation must be performed frequently, resulting in frequent rollbacks of accounted transactions, thereby affecting the robustness of the system. Therefore, it is necessary to suppress soft forks or weaken the impact of soft forks as much as possible.
本公开提供的区块链系统中,基链继承了现有公链系统中的上述软分叉特性(但并不表示基链一定为公链),也采用现有公链系统中使用的最长链机制来消除软分叉。In the blockchain system provided by the present disclosure, the base chain inherits the above-mentioned soft fork characteristics in the existing public chain system (but it does not mean that the base chain must be a public chain), and also adopts the most used in the existing public chain system. Long chain mechanism to eliminate soft forks.
应用链由于依赖基链的算力支持,因此其软分叉有两种来源:其一,应用链矿工自主的挖矿行为会导致软分叉(现有公链系统中的上述软分叉特性);其二,基链中出现的软分叉必然映射到应用链,使应用链形成软分叉,因为应用链矿工要从基链同步基链区块信息形成本地的基链账本,不同的应用链矿工在不同的位置接入基链,从而在基链出现的软分叉也分别被同步,导致应用链矿工各自只认可它已同步到的基链区块信息中指示的提案组领导人的信息,也只验证该提案组领导人产生的区块。应用链也遵循最长链机制,上述两种原因导致的软分叉也都通过最长链机制来消除,并且由于这两种原因引发的最长链切换未必指向相同的应用链最长链,使得应用链上用于消除软分叉的最长链切换过程变得复杂,具体在后文阐述。Since the application chain relies on the computing power support of the base chain, its soft fork has two sources: First, the autonomous mining behavior of the application chain miners will lead to a soft fork (the above-mentioned soft fork characteristics in the existing public chain system) ); Second, the soft fork that appears in the base chain must be mapped to the application chain, making the application chain form a soft fork, because the application chain miners need to synchronize the base chain block information from the base chain to form a local base chain ledger, which is different Application chain miners connect to the base chain at different locations, so that the soft forks that appear in the base chain are also synchronized separately, causing each application chain miner to only recognize the leader of the proposal group indicated in the base chain block information that it has synchronized to. Only the block generated by the leader of the proposal group is verified. The application chain also follows the longest chain mechanism. The soft forks caused by the above two reasons are also eliminated by the longest chain mechanism, and the longest chain switch caused by these two reasons may not necessarily point to the same longest chain of the application chain. This makes the longest chain switching process used to eliminate soft forks on the application chain more complicated, which will be explained in detail later.
本公开提供的区块链系统中的如下特性有助舒解因基链软分叉带来的干扰:The following features in the blockchain system provided by the present disclosure help to relieve the interference caused by the soft fork of the base chain:
其一,应用链矿工的挖矿请求会在基链中广播,每个基链矿工都会收到挖矿请求,从而基于这些挖矿请求针对应用链同一高度的区块选出同一提案组领导人的概率较高。并且,在本公开的方案中,提案阶段比验证阶段限制更宽松(比如,在常见的实现方式中,从未参与挖矿的新矿工也会赋予其首次记账权重允许其挖矿,而持币量小于最小持币量的矿工则不允许其参与验证组成员的推选),也有利于提案组领导人的选举结果趋于一致。从而,不管基链是否发生软分叉,对选举提案组领导人的结果影响不大。First, the mining request of the application chain miners will be broadcast in the base chain, and each base chain miner will receive the mining request, and based on these mining requests, the same proposal group leader will be selected for the same height block of the application chain. The probability is higher. Moreover, in the solution of the present disclosure, the proposal stage is more restrictive than the verification stage (for example, in a common implementation, new miners who have never participated in mining will also give them the first accounting weight to allow them to mine, while holding Miners whose currency is less than the minimum currency holdings are not allowed to participate in the selection of members of the verification group), which is also conducive to the convergence of the election results of the leaders of the proposal group. Therefore, regardless of whether the base chain has a soft fork, it has little effect on the results of the election of the leader of the proposal group.
其二,第一方面,应用链推选应用链待挖区块的提案组成员时采用的第一选举字串根据确定应用链待挖区块的提案组领导人的基链区块的前L区块中的信息,该信息基本已经固定下来(特别是在L取稍大一些的值,例如6的时候)。从而,基链若在该第一选举字串的来源区块之后出现软分叉导致应用链也出现软分叉,对应用链后续某高度的待挖区块来说,不管该区块位于应用链哪个候选分支上,获取到的第一选举字串的值大概率相同,进而最终确定出的提案组领导人也大概率一致,因为每个基链矿工上的提案组领导人选举算法相同,仅挖矿请求到达先后不一致有干扰(基链矿工若收到的挖矿请求不一致,存在一定概率选出不同的提案组领导人)。Second, the first aspect, the first election string used by the application chain when selecting the members of the proposal group of the block to be mined in the application chain is based on the first L area of the base chain block of the leader of the proposal group to determine the block to be mined in the application chain The information in the block is basically fixed (especially when L takes a larger value, such as 6). Therefore, if the base chain has a soft fork after the source block of the first election string, the application chain also has a soft fork. For the block to be mined at a certain height after the application chain, regardless of whether the block is located in the application chain. On which candidate branch of the chain, the value of the first election string obtained is likely to be the same, and the final proposal group leader is also likely to be the same, because the proposal group leader election algorithm on each base chain miner is the same. Only the arrival of mining requests is inconsistent and there is interference (if the mining requests received by the base chain miners are inconsistent, there is a certain probability that different proposal group leaders will be selected).
第二方面,在基链确定应用链待挖区块的提案组领导人后,应用链推选验证组成员时采用的第二选举字串根据以下信息计算:提案组领导人的矿工标识、确定提案组领导人的基链区块的高度、应用链待挖区块的高度以及推选验证组成员的轮次编号,该设计能够在验证组成员的推选过程中有效防止基链分叉的干扰。其原因在于:提案组领导人的矿工标识、应用链待挖区块的高度两项信息在多轮验证组成员推选期间是确定的,而基链在选出应用链待挖区块的提案组领导人后出现软分叉,亦不影响确定提案组领导人的基链区块的高度一项的取值,而其后由于基链软分叉导致的应用链软分叉并不影响推选验证组成员的轮次编号一项的取值。In the second aspect, after the base chain determines the leader of the proposal group for the block to be mined in the application chain, the second election string used when the application chain selects the members of the verification group is calculated based on the following information: the miner identification of the proposal group leader, and the proposal is determined The height of the group leader's base chain block, the height of the application chain to be mined and the round number of the selection verification group members, this design can effectively prevent the interference of the base chain bifurcation during the selection process of the verification group members. The reason is that the two information of the miner identification of the leader of the proposal group and the height of the block to be mined in the application chain are determined during the selection of multiple rounds of verification group members, and the base chain is selecting the proposal group of the block to be mined in the application chain. The subsequent soft fork of the leader does not affect the value of determining the height of the base chain block of the leader of the proposal group, and the subsequent soft fork of the application chain due to the soft fork of the base chain does not affect the selection verification The value of the round number of the group members.
综合以上两方面,基链与应用链存在软分叉大概率不会干扰提案组领导人选举及验证组成员推选,应用链出块及验证过程具有很高确定性。Based on the above two aspects, there is a high probability that the soft fork of the base chain and the application chain will not interfere with the election of the leader of the proposal group and the selection of the members of the verification group, and the application chain block generation and verification process has a high degree of certainty.
其三:若基链上的矿工针对同一应用链待挖区块选出两个或上的提案组领导人,将导致基链发生软分叉,进而应用链也随之发生软分叉,但分叉后应用链出块速度变慢,基链出块速度不变,软分叉将快速消除,这里存在一种基链、应用链出块速度差的自适应调整机制,具体介绍如下:Third: If the miners on the base chain select two or more proposal group leaders for the same application chain to be mined, it will cause the base chain to undergo a soft fork, and the application chain will also undergo a soft fork. After the fork, the block generation speed of the application chain slows down, the block generation speed of the base chain remains unchanged, and the soft fork will be quickly eliminated. There is an adaptive adjustment mechanism for the difference in block generation speed between the base chain and the application chain. The details are as follows:
若应用链的软分叉由上述原因导致,软分叉后应用链上将存在多个提案组领导人出块供验证,参与验证的矿工将被分流,客观上使得验证更难通过。此外,应用链的管理者还可以调整应用链上配置的最小成功验证数与最大失败验证数两个参数,将最小成功验证数调大,将最大失败验证数调小,这样验证通过的条件将更加苛刻,区块通过验证也更困难,特别是只有少数验证组成员认可的提案组领导人所出区块将无法通过验证。If the soft fork of the application chain is caused by the above reasons, after the soft fork, there will be multiple proposal group leaders on the application chain to produce blocks for verification, and the miners participating in the verification will be diverted, which objectively makes verification more difficult to pass. In addition, the administrator of the application chain can also adjust the two parameters of the minimum number of successful verifications and the maximum number of failed verifications configured on the application chain. Increase the minimum number of successful verifications and reduce the maximum number of failed verifications, so that the conditions for passing verification will be reduced. It is more demanding, and it is more difficult for the block to pass verification, especially the block produced by the leader of the proposal group approved by only a few verification group members will not be able to pass the verification.
随着验证通过难度的提高,应用链出块速度会变慢,一方面因为推选验证组成员 的轮次会变多(只有选出更多的验证组成员才有可能通过验证),验证耗时会变长,另一方面也因为一旦区块无法通过验证,应用链矿工只能在原高度继续挖矿,应用链高度不会增长。应用链挖矿进度变慢后,使得应用链上已经产生的软分叉程度不会继续加深,有利于分叉走向收敛。并且,应用链的区块高度增长变慢后,基链出块频率并不受影响,基链上产生的软分叉将很快消除。As the difficulty of passing verification increases, the block generation speed of the application chain will slow down. On the one hand, the number of rounds for selecting verification group members will increase (only more verification group members are selected to pass verification), and verification is time-consuming It will become longer. On the other hand, once the block fails to pass verification, the application chain miners can only continue mining at the original height, and the application chain height will not increase. After the mining progress of the application chain slows down, the degree of soft forks already generated on the application chain will not continue to deepen, which is conducive to the convergence of the forks. Moreover, after the block height growth of the application chain slows down, the block frequency of the base chain will not be affected, and the soft fork generated on the base chain will be quickly eliminated.
基链软分叉因素消除后,应用链将回归正常挖矿的状态(但此时应用链上的软分叉可能尚未消除),其附带效应是,之后的一段时间内应用链上所出空块将会变多,以便追回和基链的块高差。此时,处于活跃区域(含义在下面解释)内的应用链矿工维护的候选分支(下面简称活跃分支)中的区块经几轮验证通过的概率,相对处于不活跃区域内的应用链矿工维护的候选分支(下面简称非活跃分支)中的区块更高。从而,活跃分支上的区块高度增长更加容易,并且,由于应用链连续出块增多,活跃分支与非活跃分支之间的高度差将很快拉大,在较短时间内活跃分支将被确定为应用链最长链,进而应用链上的软分叉也得到消除。其中,活跃区域是区块链系统中由通信畅通的节点构成的群落,活跃区域内的节点往往分布集中、节点间信息同步及时并且节点数量也占系统的大多数。After the soft fork of the base chain is eliminated, the application chain will return to the state of normal mining (but at this time the soft fork on the application chain may not have been eliminated), the side effect is that there will be vacancies on the application chain for a period of time. There will be more blocks in order to recover the block height difference with the base chain. At this time, the probability that the block in the candidate branch maintained by the application chain miner in the active area (the meaning is explained below) (hereinafter referred to as the active branch) will pass through several rounds of verification is relative to the application chain miner in the inactive area. The block in the candidate branch (hereinafter referred to as the inactive branch) is higher. As a result, it is easier to increase the block height on the active branch, and because the application chain continuously produces more blocks, the height difference between the active branch and the inactive branch will quickly widen, and the active branch will be determined in a short period of time For the longest chain of the application chain, the soft fork on the application chain is also eliminated. Among them, the active area is a community composed of nodes with smooth communication in the blockchain system. The nodes in the active area are often distributed and concentrated, the information between the nodes is synchronized in time, and the number of nodes also accounts for the majority of the system.
若应用链软分叉并非由基链软分叉导致,也可类似分析,不再展开阐述。下面继续介绍应用链上的最长链切换过程。If the soft bifurcation of the application chain is not caused by the soft bifurcation of the base chain, it can be analyzed similarly and will not be elaborated. The following continues to introduce the longest chain switching process on the application chain.
A.双重最长链切换A. Double longest chain switching
如前所述,有两种导致应用链软分叉的因素,一种是链内各矿工自主挖矿引起,一种是基链软分叉引起。应用链中也相应地设置两种类型的最长链切换规则用于消除这两种因素导致的软分叉。其中,第一重最长链切换借助于应用链内各矿工之间的区块同步来触发,第二重最长链切换则利用基链的最长链切换来触发应用链的最长链切换。无论哪种类型的最长链切换,都将作为切换目标的应用链候选分支上的各区块记账成功作为切换结束标志。As mentioned earlier, there are two factors that lead to the soft fork of the application chain, one is caused by the independent mining of miners in the chain, and the other is caused by the soft fork of the base chain. Two types of longest chain switching rules are correspondingly set in the application chain to eliminate soft forks caused by these two factors. Among them, the first longest chain switch is triggered by the block synchronization between miners in the application chain, and the second longest chain switch uses the longest chain switch of the base chain to trigger the longest chain switch of the application chain. . No matter which type of the longest chain switch, the successful accounting of each block on the candidate branch of the application chain as the switch target is used as the switch end sign.
触发最长链切换存在可信的问题,某矿工收到新区块导致最长链切换,新收区块可以只是区块头,也可以是完整区块,但均要求无法随意伪造,因为最长链切换涉及交易回退操作,处理过程比较重,如果轻易伪造一个区块就导致候选分支切换,区块链系统会变得很脆弱。以比特币系统为例,比特币只需区块头就能驱动最长链切换,因为哈希碰撞受挖矿难度约束,伪造区块头与伪造区块体一样困难。在区块链的实践中,区块头和区块体多采用分开传播的方式,因区块头数据量较小易于快速传播以便执行后续操作,当然也不排除区块整体传播的方式。不过为简单起见,后文在介绍时仍假定应用链区块在应用链中采用区块头和区块体分开传播的方式,其中,区块头可以先传播,而区块体则采取向相邻节点索要的方式。如果应用链区块采用其他方式传播,亦可类似分析。There is a credibility problem in triggering the longest chain switch. A miner receives a new block and causes the longest chain switch. The newly received block can be just a block header or a complete block, but it is required that it cannot be forged at will, because the longest chain Switching involves a transaction rollback operation, and the processing process is relatively heavy. If a block is easily forged and the candidate branch is switched, the blockchain system will become very fragile. Take the Bitcoin system as an example. Bitcoin only needs the block header to drive the longest chain switch, because hash collisions are restricted by the difficulty of mining, and forging the block header is as difficult as forging the block body. In the practice of the blockchain, the block header and the block body are mostly distributed separately. Because the amount of data in the block header is small, it is easy to quickly propagate in order to perform subsequent operations. Of course, the method of block propagation as a whole is not ruled out. However, for the sake of simplicity, the following introduction still assumes that the application chain block uses the method of separate propagation of the block header and the block body in the application chain. Among them, the block header can be propagated first, and the block body is taken to adjacent nodes. How to ask for it. If the application chain block is spread in other ways, similar analysis can also be done.
在本公开的方案中,在应用链矿工将某个应用链区块的区块头纳入应用链账本后,若发现该区块头的挂入导致某个应用链候选分支在所有候选分支中变为最长,则触发第一重最长链切换,该应用链区块的区块体则可在后续向其他应用链矿工索要。In the solution of the present disclosure, after the application chain miner incorporates the block header of a certain application chain block into the application chain ledger, if it is found that the attachment of the block header causes a certain application chain candidate branch to become the highest among all candidate branches. If it is long, it triggers the first longest chain switch, and the block body of the application chain block can be requested from other application chain miners later.
在应用链矿工将同步到的基链区块信息纳入本地的基链账本、并使得本地的基链账本中产生最长链切换后触发第二重最长链切换。之前已经提到,基链区块信息有几种形式,但不管哪种形式,至少都包括基链区块的区块头以及基链区块的区块体中针对应用链待挖区块的提案组领导人的选举结果,而并不能只包含基链区块的区块头,因为如果缺少提案组领导人的信息,应用链矿工无法执行后续的验证及挖矿操作。在应用链矿工确认基链发生最长链切换后,通过第二重最长链切换将应用链中进行挖矿的分支切换到基链最长链指示的应用链最长链(简称应用链待切换分支)上去,然而,由于基链最长链和应用链最长链可能并不完全一致(因为有重挖旧块等行为的存在),所以此时应用链待切换分支并非一定是块高意义上应用链最长链,但并不影响应用链矿工在基链的指示下进行最长链切换。After the application chain miner incorporates the synchronized base chain block information into the local base chain ledger, the second longest chain switch is triggered after the longest chain switch is generated in the local base chain ledger. As mentioned before, there are several forms of base chain block information, but no matter which form, at least it includes the block header of the base chain block and the block body of the base chain block. The proposal for the block to be mined in the application chain The election result of the group leader cannot only include the block header of the base chain block, because if the information of the leader of the proposal group is missing, the application chain miners cannot perform subsequent verification and mining operations. After the application chain miner confirms that the longest chain switch of the base chain occurs, the branch of the application chain for mining is switched to the longest chain of the application chain indicated by the longest chain of the base chain through the second longest chain switch (referred to as the application chain waiting Switch branches). However, since the longest chain of the base chain and the longest chain of the application chain may not be exactly the same (because there are behaviors such as re-digging old blocks), the branch to be switched of the application chain at this time is not necessarily the block height In the sense, the application chain is the longest chain, but it does not affect the application chain miners to switch the longest chain under the instructions of the base chain.
由于最长链切换会涉及交易回退操作,因此在切换完成前不能进行其他交易相关操作,包括禁止两重最长链切换穿插进行,所谓穿插是指在执行其中一种类型的最长链切换的同时执行另一种类型的最长链切换,两种类型的最长链切换只能分时执行或 者若遇同时执行,必须将其中一种终止掉。其具体执行规则为:Since the longest chain switch involves transaction rollback operations, other transaction-related operations cannot be performed before the switch is completed, including prohibiting the interleaving of the two longest chain switches. The so-called interleaving refers to the execution of one of the types of the longest chain switch Execute another type of longest chain switch at the same time. The two types of longest chain switch can only be executed in time sharing or if they are executed at the same time, one of them must be terminated. The specific execution rules are:
其一,在应用链矿工执行已触发的第一重最长链切换的过程中,若有新触发的第一重最长链切换或第二重最长链切换,应用链矿工不进行响应,继续执行当前的第一重最长链切换。First, in the process of the application chain miner executing the triggered first and longest chain switch, if there is a newly triggered first or second longest chain switch, the application chain miner will not respond. Continue to perform the current first longest chain switch.
其二,在应用链矿工执行已触发的第二重最长链切换的过程中,若有新的第二重最长链切换被触发,则应用链矿工终止正在执行的第二重最长链切换,并开始执行新触发的第二重最长链切换。Second, when the application chain miner executes the triggered second longest chain switch, if a new second longest chain switch is triggered, the application chain miner terminates the second longest chain that is being executed Switch, and start to execute the newly triggered second longest chain switch.
其三,在应用链矿工执行已触发的第二重最长链切换的过程中,若有新的第一重最长链切换被触发,则判断基链最长链指示的已确定提案组领导人的应用链区块的最高高度(即第二重最长链切换中应用链待切换分支的高度),是否小于纳入触发该第一重最长链切换的区块头的应用链候选分支的高度。若前一高度小于后一高度,表明第一重最长链切换对应的应用链候选分支高度更高,此时应用链矿工终止正在执行的第二重最长链切换,并开始执行新触发的第一重最长链切换,若否,应用链矿工不响应新触发的第一重最长链切换,继续执行当前的第二重最长链切换。Third, in the process of the application chain miner executing the triggered second and longest chain switch, if a new first and longest chain switch is triggered, determine the leader of the determined proposal group indicated by the longest chain of the base chain Whether the highest height of the human application chain block (that is, the height of the branch to be switched in the second longest chain switch) is less than the height of the candidate branch of the application chain that includes the block header that triggers the first longest chain switch . If the previous height is smaller than the latter height, it indicates that the application chain candidate branch corresponding to the first longest chain switch is higher. At this time, the application chain miner terminates the second longest chain switch that is being executed, and starts to execute the newly triggered one The first and longest chain switch, if not, the application chain miner does not respond to the newly triggered first and longest chain switch, and continues to execute the current second and longest chain switch.
产生第一重最长链切换时,其处理方式可以参考比特币或以太坊等现有区块链系统中的实现,在此不作具体阐述。When the first and longest chain switch is generated, the processing method can refer to the implementation in existing blockchain systems such as Bitcoin or Ethereum, which will not be elaborated here.
产生第二重最长链切换时,应用链矿工则有可能发现应用链待切换分支上的一个或多个新近区块的区块头缺失(第一重最长链切换时应用链待切换分支中区块头不会缺失),这些区块头缺失的区块可能在应用链其他矿工处保存,还没传输过来,这属于临时缺失,因为既然第二重最长链切换在基链最长链的指示下进行,基链最长链指示的应用链待切换分支的最大高度之前的区块必然已经成功出块,否则应用链矿工不会在前一区块出块未成功的情况下就发起针对下一区块的挖矿请求,基链也不会为其选出提案组领导人。不过,这些区块头缺失的区块也可能在本链尚不存在,这属于真实缺失,由于应用链矿工接入的基链同步节点只在基链的局部区域维持数据同步,某些基链的候选分支可能未在当前应用链的任何矿工处同步过,或者虽然同步过但在同步时基链区块信息发生丢失等原因,导致应用链上未产生对应的应用链区块。When the second longest chain switch occurs, the application chain miners may find that the block header of one or more recent blocks on the branch to be switched on the application chain is missing (the application chain is in the branch to be switched when the first longest chain is switched Block headers will not be missing), these blocks with missing headers may be saved by other miners in the application chain and have not yet been transmitted. This is a temporary loss, because since the second longest chain is switched to the longest chain of the base chain. The block before the maximum height of the branch to be switched in the application chain indicated by the longest chain of the base chain must have been successfully produced. Otherwise, the application chain miners will not initiate a target download if the previous block is not successfully produced. For a mining request for a block, the base chain will not select a leader of the proposal group for it. However, these blocks with missing block headers may not yet exist in this chain. This is a true lack. Because the base chain synchronization node accessed by the application chain miners only maintains data synchronization in a local area of the base chain, some of the base chain’s The candidate branch may not have been synchronized with any miner in the current application chain, or although it has been synchronized, the base chain block information is lost at the time of synchronization, etc., resulting in no corresponding application chain block on the application chain.
应用链区块的临时缺失与真实缺失需要进行区分,临时缺失尚能通过应用链矿工之间的数据同步补回;真实缺失是基链虽然已选出提案组领导人,但应用链没有任何矿工知道该提案组领导人已当选,所以没矿工出块,或者已当选提案组领导人的应用链矿工虽已出块,但因通信异常未能传播新块,总之,并不能通过应用链矿工之间的数据同步补回。这两种缺失在本公开的第二重最长链切换方案中都能够有效得到处理。Temporary missing and true missing of application chain blocks need to be distinguished. Temporary missing can still be compensated by data synchronization between application chain miners; true missing is that although the base chain has selected the leader of the proposal group, there is no miner in the application chain Knowing that the leader of the proposal group has been elected, no miners produce blocks, or the application chain miners who have been elected leaders of the proposal group have produced blocks, but failed to propagate new blocks due to abnormal communication. In short, they cannot pass the application chain miners. Synchronously replenish the data between them. Both of these two kinds of defects can be effectively dealt with in the second heavy and longest chain switching scheme of the present disclosure.
应用链矿工进行第二重最长链切换,总体上的流程是:首先确定应用链待切换分支上的最后一个已确收区块,已确收区块是指区块头已被应用链矿工接收并且应用链矿工根据接收的检验报告已确定其验证通过的区块(区块体可后续从其他应用链矿工处索取),此时区块头处于可写入应用链账本的状态,至于是否会被写入账本则与实现有关。然后,应用链矿工从已确收区块之后的区块开始,正向(块高增大方向)遍历应用链待切换分支,并在遍历过程中将应用链待切换分支上的区块纳入应用链账本中。The application chain miner performs the second longest chain switch. The overall process is: first determine the last confirmed block on the branch of the application chain to be switched. The confirmed block means that the block header has been received by the application chain miner. And the application chain miner has determined the verified block according to the received inspection report (the block body can be obtained from other application chain miners later). At this time, the block header is in a state that can be written to the application chain ledger, as to whether it will be written The entry book is related to realization. Then, the application chain miner starts from the block after the confirmed block, traverses the application chain to be switched branches in the forward direction (in the direction of block height increase), and incorporates the blocks on the application chain to be switched branches into the application during the traversal process In the chain ledger.
在一种具体的实现方式中,上述第二重最长链切换的流程可以按照如下步骤操作,注意在下面的操作中未涉及应用链上的空块,对于这些空块可以跳过不处理。In a specific implementation manner, the above-mentioned second heavy and longest chain switching process can be operated according to the following steps. Note that the empty blocks on the application chain are not involved in the following operations, and these empty blocks can be skipped and not processed.
第一步,应用链矿工从本地的基链账本中的基链最长链的最后一个区块开始,逆向(块高减小方向)遍历基链最长链,分析各个已选出提案组领导人的区块在应用链待切换分支上是否已经确收,找到的第一个已确收区块就是应用链待切换分支上最后一个已确收区块。In the first step, application chain miners start from the last block of the longest base chain in the local base chain ledger, traverse the longest chain of the base chain in the reverse direction (the direction of block height reduction), and analyze the leaders of each selected proposal group. Whether the person's block has been confirmed on the pending branch of the application chain, the first confirmed block found is the last confirmed block on the pending branch of the application chain.
若应用链待切换分支上最后一个已确收区块不是应用链待切换分支上的最后一个区块,则将最后一个已确收区块之后的首个由基链指示的已选出提案组领导人的区块确定为待定首区块,并在至多Z个基链出块时间内等待待定首区块被确收。若待定首区块在等待了至多Z个基链出块时间后还未被应用链矿工确收,则终止第二重最长链切换,重新开始待定首区块的提案组成员的推选。其中,Z为正整数,若待定首区块是应用链待切换分支上的最后一个区块,则Z可取MaxRounds+Q,否则Z可取不 小于MaxRounds+Q的值;MaxRounds为应用链矿工推选验证组成员的最大轮次,Q为应用链矿工允许额外同时处于验证状态的区块的高度的数量,这两个参数的含义前文已经介绍过。If the last confirmed block on the branch to be switched on the application chain is not the last block on the branch to be switched on the application chain, the first selected proposal group indicated by the base chain after the last confirmed block The leader's block is determined as the first block to be determined, and the first block to be determined is confirmed within the block time of at most Z base chains. If the first block to be determined has not been confirmed by the application chain miners after waiting for at most Z base chain block time, the second longest chain switch will be terminated, and the selection of the proposal group members of the first block to be determined will be restarted. Among them, Z is a positive integer. If the first block to be determined is the last block on the branch to be switched on the application chain, Z can be MaxRounds+Q, otherwise Z can be a value not less than MaxRounds+Q; MaxRounds is recommended and verified by application chain miners The maximum round of group members, Q is the number of heights of additional blocks allowed by the application chain miners to be in the verification state at the same time. The meaning of these two parameters has been introduced above.
若最后一个已确收区块是应用链待切换分支上的最后一个区块,则将最后一个已确收区块的下一区块确定为下一应用链待挖区块并开始该区块的提案组成员的推选。If the last confirmed block is the last block on the branch of the application chain to be switched, the next block of the last confirmed block is determined as the next block to be mined in the application chain and the block is started Selection of members of the proposal group.
第二步,应用链矿工判断待定首区块的提案组领导人是否为其自身。若待定首区块的提案组领导人是应用链矿工自身,则进一步判断应用链矿工是否曾经打包过待定首区块,若曾经打包过待定首区块,则重用已打包的待定首区块,若未曾打包过待定首区块,则打包待定首区块。且不论是否打包过待定首区块,应用链矿工都应向其他应用链矿工广播待定首区块并开始参与待定首区块的验证组成员的推选。应用链矿工具有缓存机制,自己最近打包的区块都会缓存,若遇应用链最长链在候选分支之间来回切换数次,某个区块在之前已经打包过并缓存于应用链矿工本地是完全可能的,此时可直接重用之前组建好的区块。对于待定首区块需要打包的情况,表明本地缓存中没有该区块,例如虽然基链已为该区块选出提案组领导人,但应用链矿工之前并未得知自己是提案组领导人,所以要做新区块的补建操作(如果补建失败,应用链矿工将在Z个基链出块时间到来后,在待定首区块高度重启挖矿,参见下面第三步的描述),此种情形对应上文所述的区块真实缺失。若待定首区块的提案组领导人不是应用链矿工自身,直接开始待定首区块的验证组成员的推选即可。In the second step, the application chain miner judges whether the leader of the proposal group of the first block to be determined is himself. If the leader of the proposal group for the first block to be determined is the application chain miner, it is further judged whether the application chain miner has packaged the pending first block. If the pending first block has been packaged, the packaged pending first block is reused. If the first block to be determined has not been packaged, the first block to be determined is packaged. Regardless of whether the first block to be determined has been packaged or not, the application chain miners should broadcast the pending first block to other application chain miners and begin to participate in the selection of the verification group members of the pending first block. The application chain mining tool has a caching mechanism, and the recently packaged blocks will be cached. If the longest chain of the application chain switches back and forth between candidate branches several times, a certain block has been packaged and cached locally in the application chain miners. It is entirely possible that the previously constructed block can be reused directly at this time. For the case where the first block to be determined needs to be packaged, it indicates that the block is not in the local cache. For example, although the base chain has selected the proposal group leader for this block, the application chain miner did not know that he was the proposal group leader before , So we need to do the rebuild operation of the new block (if the rebuild fails, the application chain miners will restart the mining at the height of the first block to be determined after the Z base chain block generation time comes, see the description of the third step below), This situation corresponds to the actual lack of blocks described above. If the leader of the proposal group for the first block to be determined is not the application chain miners themselves, they can directly start the selection of members of the verification group for the first block to be determined.
第三步,应用链矿工对待定首区块的验证进度进行监控。若从应用链矿工开始推选待定首区块的提案组成员起的Z个基链出块时间内,待定首区块被纳入应用链账本,则将待定首区块之后的首个由基链指示的已选出提案组领导人的区块确定为下一待定首区块。若从应用链矿工开始推选待定首区块的提案组成员起的Z个基链出块时间内,待定首区块未被纳入应用链账本,则终止第二重最长链切换,重新开始待定首区块的提案组成员的推选。其中,Z的定义和前面的步骤中相同。需要注意的是,待定首区块被纳入应用链账本是指待定首区块的区块整体被写入应用链账本,不仅仅指区块头,这和区块确收是存在区别的。在本步骤中应用链矿工实施监视的目的主要是为了避免已选出的提案组领导人所在的挖矿节点异常离线,或已关机退出,若不处理这样的异常状况,应用链出块容易挂住。In the third step, application chain miners monitor the verification progress of the first block to be determined. If the first block to be determined is included in the application chain ledger within the Z base chain block generation time since the application chain miners start to select the proposal group members of the first block to be determined, the first block after the first block to be determined will be instructed by the base chain The block in which the leader of the proposal group has been selected is determined as the next first block to be determined. If the first block to be determined is not included in the application chain ledger within the Z base chain block generation time since the application chain miners started to select the proposal group members of the first block to be determined, the second longest chain switch will be terminated and the second longest chain switch will be restarted. Selection of the members of the proposal group for the first block. Among them, the definition of Z is the same as in the previous step. It should be noted that the inclusion of the first block to be determined into the application chain ledger means that the entire block of the first block to be determined is written into the application chain ledger, not just the block header, which is different from block confirmation. In this step, the purpose of monitoring the application chain miners is mainly to avoid the mining node where the selected proposal group leader is abnormally offline, or has been shut down and exited. If such an abnormal situation is not dealt with, the application chain will easily hang up. live.
第四步,应用链矿工判断确定出的下一待定首区块是否已经确收(因为从应用链待切换分支的最后一个已确收区块开始处理已经经过一段时间,下一待定首区块可能已经确收),若下一待定首区块已确收,或者目前虽未确收但在至多等待Z个基链出块时间后确收,则尝试将下一待定首区块纳入应用链账本,其具体方法和上面步骤中对待定首区块的处理类似,即对于待定首区块的处理是一个循环过程,不再重复说明。若下一待定首区块在等待了至多Z个基链出块时间后还未被应用链矿工确收,则终止第二重最长链切换,重新开始下一待定首区块的提案组成员的推选。In the fourth step, the application chain miners determine whether the next pending first block has been confirmed (because a period of time has passed since the last confirmed block of the branch to be switched in the application chain has been processed, and the next pending first block It may have been confirmed), if the next pending first block has been confirmed, or if it has not been confirmed at present but it is confirmed after waiting for at most Z base chain block time, then try to include the next pending first block into the application chain The specific method of the ledger is similar to the processing of the first block to be determined in the above steps, that is, the processing of the first block to be determined is a cyclic process, and the description will not be repeated. If the next pending first block has not been confirmed by the application chain miners after waiting for at most Z base chain block time, the second longest chain switch will be terminated, and the proposal group members of the next pending first block will be restarted Selection.
应用链矿工持续正向遍历应用链待切换分支查找后续的待定首区块,直至在将应用链待切换分支上的区块都纳入应用链账本后,结束第二重最长链切换。若在执行第二重最长链切换的过程中有新的第二重最长链切换被触发,则应用链矿工终止正在执行的第二重最长链切换,以新的基链最长链指示的应用链最长链为基础,回到上面的第一步执行新触发的第二重最长链切换。The application chain miner continues to traverse the pending branch of the application chain forward to find the subsequent pending first block, until the block on the pending branch of the application chain is included in the application chain ledger, ending the second longest chain switch. If a new second and longest chain switch is triggered during the execution of the second and longest chain switch, the application chain miner terminates the second and longest chain switch that is being executed, and uses the new longest chain of the base chain. Based on the longest chain of the indicated application chain, go back to the first step above to execute the newly triggered second longest chain switch.
单从最长链切换的角度来说,只需要区块头就可以驱动,但在应用链的第二重最长链切换的过程中,有两处必须依赖于区块体才能进行:其一是区块验证的时候,为验证交易的合法性,必须要使用区块体,因交易保存在区块体中;其二是应用链矿工要开始下一区块的挖矿工作前,由于要确定哪些交易可以纳入新区块,因此必须清楚之前已有哪些交易完成了记账,从而也需要使用区块体。From the perspective of the longest chain switch, only the block header can be driven, but in the process of the second and longest chain switch of the application chain, there are two things that must rely on the block body to proceed: one is When verifying a block, in order to verify the legitimacy of the transaction, the block body must be used, because the transaction is stored in the block body; the second is that the application chain miner needs to be sure before starting the mining work of the next block. Which transactions can be included in the new block, so it must be clear which transactions have been accounted for before, which also requires the use of block bodies.
对于第二重最长链切换中的验证过程,应用链矿工只有在确认自己为验证组成员时才依据区块内容(包括区块头和区块体)执行验证操作,如果发现区块内容尚缺(只有区块头而无区块体,对应上文所述的区块临时失)则先向邻近节点索要相应的区块体,索要到区块体后进行验证并广播检验报告,否则验证组成员处于死等状态:或者,等待其他验证组成员出具的检验报告,并在根据接收到的检验报告得出通过或不通过 验证的结论时退出死等,或者,在等待超过了预设的时间限制(如,Z个基链出块时间)后退出死等。对于非验证组成员的应用链矿工,只需凭验证组成员广播来的检验报告,自主按既定规则决定是否采纳相应区块,具体规则和前文普通挖矿(非最长链切换)时相同。For the verification process in the second longest chain switch, application chain miners only perform verification operations based on the block content (including block header and block body) when they confirm that they are members of the verification group. If the block content is found to be lacking (There is only a block header but no block body, corresponding to the temporary loss of the block mentioned above) first ask for the corresponding block body from the neighboring node, verify the block body and broadcast the inspection report, otherwise verify the members of the team Waiting for status: Or, waiting for the inspection report issued by other verification team members, and quitting when a conclusion of passing or failing the verification is reached based on the received inspection report, or waiting for exceeding the preset time limit (For example, Z base chain block time) then exit dead and so on. For application chain miners who are not members of the verification group, they only need to rely on the inspection report broadcasted by the verification group members to decide whether to adopt the corresponding block according to the established rules. The specific rules are the same as those in the previous ordinary mining (non-longest chain switching).
由于应用链存在软分叉,以及分布系统中的检验报告无法以确定时间、确定顺序的方式到达,因此可以要求各应用链矿工对收到检验报告都先缓存(过期则自动删除),在应用链出现最长链切换时,应用链矿工就扫描该缓存区,并选用与待验区块匹配的检验报告(出块矿工与出块高度均匹配)自主按既定规则决定是否采纳相应区块。甚至,还可能出现这种情况,当前候选分支被切换到另一分支,但过一段时间又切换回来,因为被切走的分支重回应用链最长链了,此时历史上已使用过的检验报告可能反复再用。Due to the soft fork of the application chain, and the inspection reports in the distributed system cannot arrive in a definite time and order, it is possible to require all application chain miners to cache the received inspection reports (automatically delete them when they expire). When the longest chain switch occurs in the chain, the application chain miner scans the cache area and selects the inspection report that matches the block to be inspected (the block miner and the block height match) autonomously decide whether to adopt the corresponding block according to the established rules. It may even happen that the current candidate branch is switched to another branch, but switched back after a period of time, because the branch that was cut has returned to the longest chain of the application chain, which has been used in history. The inspection report may be reused repeatedly.
对于第二重最长链切换中的提案过程,应用链矿工确认自己成为提案组成员后,在打包新区块之前,它需要保证此前各个区块内容已收全并已写入本地账本(如,可向邻近节点索要相应的区块体),如果没收全应先等待收全(如,至多等待Z个基链出块时间),若超时则在当前待定首区块高度重启挖矿工作。For the proposal process in the second longest chain switch, after the application chain miner confirms that he is a member of the proposal group, before packaging a new block, it needs to ensure that the contents of each block have been collected and written into the local ledger (e.g., You can ask for the corresponding block body from the neighboring node), if you have confiscated the whole, you should wait for it first (for example, wait for at most Z base chain block time), if it expires, restart the mining work at the height of the first block currently pending.
B.对双重最长链切换的优化B. Optimization of double longest chain switching
如前文所述,双重最长链切换既涉及因应用链自身遇到最长链产生的软分叉与分支切换,也涉及因基链遇到最长链切换而导致应用链产生软分叉与分支切换,这两种切换交互影响,处理过程比较复杂。基链出现软分叉可能导致应用链指定高度的区块的提案组领导人选举出现两个(或更多)的结果,选举结果记录到基链区块并被应用链矿工同步后,应用链中针对同一区块高度也会出现两个(或更多)矿工当选为提案组领导人的情况。在一种可选方案中,将从应用链矿工中选出多个针对同一区块高度的提案组领导人的情况视为正常现象(即允许多个应用链矿工在同一高度同时出块),进行最长链切换算法的优化,让应用链系统在同一区块高度遇到有多个矿工出块时,能最优选择分叉路径,从而降低最长链切换中的不确定性与处理复杂性。其具体方案如下:As mentioned above, the double longest chain switching involves both the soft fork and branch switching caused by the application chain itself encountering the longest chain, and the soft fork and branch switching of the application chain caused by the base chain encountering the longest chain switching. Branch switching, these two kinds of switching have interactive effects, and the processing process is more complicated. The soft fork of the base chain may cause two (or more) results in the election of the leader of the proposal group of the block of the specified height of the application chain. After the election results are recorded in the base chain block and synchronized by the application chain miners, the application chain For the same block height, two (or more) miners may be elected as the leaders of the proposal group. In an optional scheme, it is normal to select multiple proposal group leaders for the same block height from the application chain miners (that is, allowing multiple application chain miners to produce blocks at the same height at the same time), The optimization of the longest chain switching algorithm allows the application chain system to optimally select the bifurcation path when multiple miners produce blocks at the same block height, thereby reducing the uncertainty and processing complexity in the longest chain switching Sex. The specific plan is as follows:
对某个应用链矿工,将其本地的应用链账本中位于第一高度的应用链区块的提案组领导人(即创建该区块的应用链矿工)称为旧提案组领导人,即当前已知的、第一高度的应用链区块的提案组领导人。其中,第一高度并非应用链中的某个特定高度,而是泛指应用链中的某一高度。关于应用链区块对应的提案组领导人,可能有如下获取方式:For a certain application chain miner, the proposal group leader of the application chain block at the first height in its local application chain ledger (that is, the application chain miner who created the block) is called the old proposal group leader, that is, the current proposal group leader The leader of the known, highest-level application chain block proposal group. Among them, the first height is not a specific height in the application chain, but generally refers to a certain height in the application chain. Regarding the leader of the proposal group corresponding to the application chain block, there may be the following ways to obtain:
其一,前文提到,应用链矿工在广播应用链区块的同时,还可以附带广播创建该区块的提案组领导人对应的提案候选信息,或者,提案组领导人对应的提案候选信息也可能被记录在区块的Coinbase中,该提案候选信息中包括提案组领导人的公钥,从而应用链矿工在接收广播的区块后就能够获知区块创建者的身份信息。First, as mentioned above, while broadcasting the application chain block, the application chain miner can also broadcast the proposal candidate information corresponding to the leader of the proposal group that created the block, or the proposal candidate information corresponding to the leader of the proposal group It may be recorded in the Coinbase of the block. The proposal candidate information includes the public key of the leader of the proposal group, so that the application chain miner can learn the identity information of the block creator after receiving the broadcast block.
其二,应用链矿工会从基链同步基链区块信息,基链区块信息中提案组领导人的选举结果,从而应用链矿工也能够获知区块创建者的身份信息。Second, the application chain mining union synchronizes the base chain block information from the base chain, and the election results of the proposal group leader in the base chain block information, so that the application chain miners can also learn the identity information of the block creator.
由于第一高度的应用链区块已经纳入应用链矿工本地的应用链账本,所以旧提案组领导人的身份应用链矿工是已知的。Since the first-level application chain block has been incorporated into the application chain miner's local application chain ledger, the identity of the old proposal group leader's application chain miner is known.
在基链出现软分叉后,不同分支上与同一选举相关的两个(或更多)区块,为同一应用链同高区块可能选出两个(或更多)不同的提案组领导人。究其原因,很大可能是由于通信不畅,基链各矿工节点收到应用链各矿工发送的挖矿请求而构成的集合并不完全一样导致,即基链某些节点可能会漏收消息。这里,不妨以基链为应用链在第一高度处的区块选出了两个提案组领导人为例,这两个提案组领导人,应用链矿工已经获知其身份的称为旧提案组领导人,如上所述,尚未获知其身份的称为新提案组领导人。After the soft fork of the base chain, two (or more) blocks related to the same election on different branches may choose two (or more) different proposal group leaders for the same application chain with the same height block people. The reason is probably due to poor communication. The set of mining requests sent by miners in the application chain is not exactly the same for each miner node of the base chain. That is, some nodes of the base chain may miss messages. . Here, let’s take the example of two proposal group leaders selected by the base chain as the block of the application chain at the first height. The two proposal group leaders, and the application chain miners who have already known their identities are called the old proposal group leaders. The person, as mentioned above, who has not yet known his identity is called the leader of the new proposal group.
应用链矿工可通过不同的渠道获知针对第一高度的应用链区块还存在不同于旧提案组领导人的新提案组领导人。例如,根据上面已经提到的,应用链矿工在接收到其他应用链矿工广播的第一高度的应用链区块时,根据该区块中记录的提案候选信息或随该区块附带广播的提案候选信息,就可以确定针对第一高度的应用链区块存在不 同于旧提案组领导人的新提案组领导人。又例如,应用链矿工根据同步到的基链区块信息也可以确定针对第一高度的应用链区块存在不同于旧提案组领导人的新提案组领导人。特别地,如果新提案组领导人就是当前应用链矿工自身,则可通过后一种方式确认这一信息。当然,针对第一高度的应用链区块多数情况下并不存在不同于旧提案组领导人的新提案组领导人,此时不会触发后续的“最长链切换”。Application chain miners can learn through different channels that there are new proposal group leaders who are different from the old proposal group leaders for the first-level application chain block. For example, according to what has been mentioned above, when an application chain miner receives the first-highest application chain block broadcast by other application chain miners, it will be based on the proposal candidate information recorded in the block or the proposal that is broadcast with the block. Candidate information can determine that there is a new proposal group leader who is different from the old proposal group leader for the first-level application chain block. For another example, the application chain miner can also determine that there is a new proposal group leader different from the old proposal group leader for the first-level application chain block based on the synchronized base chain block information. In particular, if the leader of the new proposal group is the current application chain miner itself, this information can be confirmed in the latter way. Of course, in most cases, there is no new proposal group leader different from the old proposal group leader for the application chain block of the first height, and the subsequent "longest chain switch" will not be triggered at this time.
可选的,应用链矿工在收到新提案组领导人创建的区块时,还可以验证进一步新提案组领导人是否真正属于第一高度的应用链区块的提案组成员,若不属于,则其创建的应用链区块会被忽略,后续的比较优先级等步骤也不再进行。Optionally, when the application chain miner receives the block created by the leader of the new proposal group, it can also verify whether the leader of the new proposal group is truly a member of the proposal group of the application chain block at the highest level. If not, Then the application chain block created by it will be ignored, and subsequent steps such as comparing priority will not be carried out.
之后,应用链矿工会判断新提案组领导人的优先级是否高于旧提案组领导人的优先级,若新提案组领导人的优先级高于旧提案组领导人的优先级,则会进行“最长链切换”,即将应用链账本中位于当前主分支上的、由旧提案组领导人创建的第一高度的应用链区块切换为由新提案组领导人创建的第一高度的应用链区块,而由旧提案组领导人创建的第一高度的应用链区块则被改确定为非主分支中区块。若新提案组领导人的优先级不高于旧提案组领导人的优先级,则可忽略掉新提案组领导人创建的第一高度的应用链区块,维持当前主分支不变。切换完成后,应用链矿工可将新提案组领导人创建的第一高度的应用链区块继续广播给其他应用链矿工。After that, the application chain mining union judges whether the priority of the new proposal group leader is higher than the priority of the old proposal group leader. If the priority of the new proposal group leader is higher than the priority of the old proposal group leader, it will proceed. "Longest chain switch", that is, the application chain block of the first height created by the leader of the old proposal group on the current main branch of the application chain ledger is switched to the first height application created by the leader of the new proposal group The first-highest application chain block created by the leader of the old proposal group was changed to be a block in a non-master branch. If the priority of the leader of the new proposal group is not higher than the priority of the leader of the old proposal group, the first-highest application chain block created by the leader of the new proposal group can be ignored, and the current main branch remains unchanged. After the switch is completed, the application chain miners can continue to broadcast the first-highest application chain block created by the leader of the new proposal group to other application chain miners.
在应用链矿工重新确立第一高度的应用链区块的提案组领导人时,新提案组领导人创建的第一高度的应用链区块可能刚刚从其他应用链矿工处收到(例如,新提案组领导人本就是在收到新区块时才确认的),也可能之前已经收到了(例如,在应用链矿工同步基链区块信息并确认存在新提案组领导人之前,新提案组领导人已经创建并广播了该区块),对于后一种情况,只需从本地缓存的应用链区块中查找由新提案组领导人创建的第一高度的应用链区块即可。When the application chain miners re-establish the proposal group leader of the first-highest application chain block, the first-highest application chain block created by the new proposal group leader may have just been received from other application chain miners (for example, new The leader of the proposal group originally confirmed it when the new block was received), or it may have been received before (for example, before the application chain miner synchronizes the base chain block information and confirms the existence of the new proposal group leader, the new proposal group leader People have already created and broadcast the block). In the latter case, you only need to find the first-highest application chain block created by the leader of the new proposal group from the locally cached application chain block.
可以理解的是,由提案组领导人重新确定触发的主分支切换,并不要求新切入成为主分支的软分叉一定处在块高意义上的最长链上,也即,切换后的主分支可能不是块高意义上的最长链,但为描述方便,仍可将这一切换称为“最长链切换”。但是,如果由收到新区块在非主分支上构成最长链而触发的最长链切换,切换后的主分支一定成为当前节点已知的最长链。It is understandable that the main branch switch triggered by the leader of the proposal group redetermined does not require that the soft fork that is newly cut into the main branch must be on the longest chain in the sense of block height, that is, the main branch after the switch. The branch may not be the longest chain in the sense of block height, but for the convenience of description, this switch can still be called the "longest chain switch". However, if the longest chain switch is triggered by receiving a new block to form the longest chain on a non-master branch, the master branch after the switch must become the longest chain known to the current node.
下面说明一下如何利用第二随机值比较两个提案组领导人的优先级,当然也不排除通过其他方式定义提案组领导人的优先级:The following explains how to use the second random value to compare the priorities of two proposal group leaders. Of course, it does not rule out defining the priority of proposal group leaders in other ways:
首先,获取新提案领导人在被推选为提案组成员时使用的第二随机值,以及,旧提案领导人在被推选为提案组成员时使用的第二随机值。关于第二随机值的计算,在介绍推选提案组成员时已经说明,不再重复阐述。而根据前文阐述,计算第二随机值需要依赖的信息,例如,第一可证明字串、提案组参选权重等附带在广播消息中或者直接记录在区块的Coinbase中。或者,在某些方案中,若广播消息或区块的Coinbase中已经携带了第二随机值,也可以直接使用,无需再重新推导。First, obtain the second random value used by the new proposal leader when being selected as a member of the proposal group, and the second random value used by the old proposal leader when being selected as a member of the proposal group. Regarding the calculation of the second random value, it has been explained when introducing the members of the selection proposal group, and the explanation will not be repeated. According to the foregoing description, the calculation of the second random value needs to rely on information, for example, the first provable string, the weight of the proposal group participation, etc. are attached to the broadcast message or directly recorded in the Coinbase of the block. Or, in some solutions, if the second random value is already carried in the Coinbase of the broadcast message or block, it can also be used directly without re-deriving it.
然后,判断新提案领导人对应的第二随机值是否大于旧提案领导人对应的第二随机值,若新提案领导人对应的第二随机值大于旧提案领导人对应的第二随机值,则确定新提案组领导人的优先级高于旧提案组领导人的优先级,否则,确定新提案组领导人的优先级不高于旧提案组领导人的优先级。Then, determine whether the second random value corresponding to the new proposal leader is greater than the second random value corresponding to the old proposal leader. If the second random value corresponding to the new proposal leader is greater than the second random value corresponding to the old proposal leader, then Determine that the priority of the leader of the new proposal group is higher than the priority of the leader of the old proposal group; otherwise, determine that the priority of the leader of the new proposal group is not higher than the priority of the leader of the old proposal group.
特别地,若二者的第二随机值恰好相同,或者可以认为新提案组领导人的优先级不高于旧提案组领导人的优先级就是最终的优先级比较结果(此时不进行“最长链切换”),或者可以通过额外的区分信息(例如,提案组领导人对应的矿工公钥)进一步进行比较二者的优先级。In particular, if the second random value of the two are exactly the same, or it can be considered that the priority of the leader of the new proposal group is not higher than the priority of the leader of the old proposal group, it is the final priority comparison result (the “most Long chain switching”), or the priority of the two can be further compared through additional distinguishing information (for example, the public key of the miner corresponding to the leader of the proposal group).
在一些实现方式中,还对上述第一高度有所限定,第一高度的应用链区块不能是太早之前的区块,否则可能影响挖矿的稳定性。例如,可以限定第一高度与应用链账本中的最大块高之差应小于预设高度差(比如,可以取6)。换句话说,即使应用链矿工发现第一高度的应用链区块存在不同于旧提案组领导人的新提案组领导人,若判断出第一高度与应用链账本中的最大块高之差不小于预设高度差,也会忽略掉新提案组领导人创建的区块,不会进行优先级比较,也不会进行“最长链切换”,只有在判断出第一高度与应用链账本中的最大块高之差小于预设高度差时,才会进行优先级比较。In some implementations, the above-mentioned first height is also limited, and the application chain block of the first height cannot be a block too early, otherwise the stability of mining may be affected. For example, it can be defined that the difference between the first height and the maximum block height in the application chain ledger should be less than the preset height difference (for example, it can be 6). In other words, even if the application chain miners find that the first height of the application chain block has a new proposal group leader that is different from the old proposal group leader, if it is judged that the difference between the first height and the maximum block height in the application chain ledger is not If the height difference is smaller than the preset height, the block created by the leader of the new proposal group will be ignored, priority comparison will not be carried out, and the “longest chain switch” will not be carried out. Only when the first height is judged to be in the application chain ledger The priority comparison will only be performed when the difference between the maximum block height of is smaller than the preset height difference.
若应用链矿工进行了“最长链切换”,还将进一步驱动主分支中新切换进来的末梢分支中尾部若干区块(高度大于第一高度的区块)与相邻矿工节点进行同步,包括,将自己已持有的末梢分支中的区块广播给相邻矿工节点,以及,向相邻矿工节点索要新末梢分支中后续区块的数据。If the application chain miner performs the "longest chain switch", it will further drive the tail of the newly switched terminal branch in the main branch (blocks with a height greater than the first height) to synchronize with adjacent miner nodes, including , Broadcast the blocks in the stub branch that you already own to neighboring miner nodes, and ask neighboring miner nodes for the data of subsequent blocks in the new stub branch.
上面虽然只介绍了针对应用链同一高度的区块选出两个不同的提案组领导人的情况,单针对应用链同一高度的区块选出更多不同的提案组领导人的情况是类似的,在比较提案组领导人的优先级时仍可以采用两两比较的方式,不再重复阐述。Although the above only introduced the selection of two different proposal group leaders for the same height block of the application chain, the situation of selecting more different proposal group leaders for the same height block of the application chain is similar. , When comparing the priorities of the leaders of the proposal group, the method of pairwise comparison can still be used, and the explanation will not be repeated.
(3)账本压缩问题(3) Ledger compression problem
区块链系统在运行较长时间后,账本体积会越来越大,为节约区块链节点上的存储空间,可对账本进行压缩。下面以基链矿工本地保存的基链账本的压缩为例进行阐述:After the blockchain system runs for a long time, the volume of the ledger will become larger and larger. In order to save the storage space on the blockchain node, the ledger can be compressed. The following is an example of the compression of the base chain ledger stored locally by the base chain miners:
对于基链区块中的选举依据列表,只服务于新区块的开采,没有必要长期保存。例如,在一种实现方式中,基链区块可以按照如下方式保存:For the election basis list in the base chain block, it only serves the mining of new blocks, and there is no need to keep it for a long time. For example, in one implementation, the base chain block can be stored as follows:
在基链的最近D个难度调整周期内生成的区块保存区块头以及完整的区块体;在基链的最近D个难度调整周期之前生成的区块保存区块头以及区块体中的选举结果列表,但不保存选举依据列表。其中,D取正整数,比如最近D个难度调整周期可能对应最近的十几天、一两个月等。若选举结果列表的表项采用简化形式(只含提案组领导人的矿工标识),则还要保存选举依据列表中由提案组领导人自身产生的提案候选信息(若选举结果列表的表项未采用简化形式,则本已包含所需的提案候选信息)。若基链上有发行数字货币,则区块体中还要保存交易信息,以便确定账号余额。在具体实现时,基链矿工在新出的基链区块验证通过后,可先将其纳入基链账本,并定期对基链账本进行清理,即移除掉区块中的选举依据列表,实现账本压缩。Blocks generated during the last D difficulty adjustment cycles of the base chain save the block header and the complete block body; blocks generated before the last D difficulty adjustment cycles of the base chain save the block header and elections in the block body The result list, but does not save the election basis list. Among them, D takes a positive integer, for example, the most recent D difficulty adjustment cycles may correspond to the most recent ten days, one or two months, etc. If the entries in the election result list are in a simplified form (only the miner identification of the leader of the proposal group), the candidate information of the proposal generated by the leader of the proposal group in the election basis list should also be saved (if the entries in the election result list are not included) In the simplified form, the required proposal candidate information is already included). If digital currency is issued on the base chain, transaction information must be stored in the block body to determine the account balance. In the specific implementation, after the new base chain block is verified, the base chain miners can first include it in the base chain ledger, and regularly clean the base chain ledger, that is, remove the election basis list in the block. Realize ledger compression.
对于最近D个难度调整周期之前生成的基链区块,根据保留下来的信息亦足以进行验证,以区块中的选举结果列表的表项采用简化形式的情况为例:要证明表项中记录的提案组领导人的矿工标识未被伪造,只需推导merkle根,然后确认推导出的结果和区块头中记录的merkle_root1一致。要证明提案组领导人自身产生的提案候选信息中的内容真实可信,首先可根据提案候选信息推导提案组领导人的矿工标识,并确认推导结果与选举结果列表的表项中记录的一致;然后可利用提案候选信息中的确定提案组领导人的基链区块的高度一项可获取第一选举字串,进而基于提案候选信息中的应用链矿工公钥、第一可证明字串两项信息以及获取到的第一选举字串调用VRF算法的验证函数确认第一可证明字串未被伪造。For the base chain blocks generated before the most recent D difficulty adjustment period, it is sufficient to verify the information based on the retained information. Take the simplified form of the entries in the election result list in the block as an example: it is necessary to prove the records in the entries The miner ID of the leader of the proposal group has not been forged, just derive the merkle root, and then confirm that the deduced result is consistent with the merkle_root1 recorded in the block header. To prove that the content of the proposal candidate information generated by the leader of the proposal group is true and credible, firstly derive the miner ID of the proposal group leader based on the proposal candidate information, and confirm that the deduction result is consistent with the record in the list of election results; Then the first election string can be obtained by using the item of the height of the base chain block of the leader of the proposal group in the proposal candidate information, and then based on the application chain miner’s public key and the first provable string in the proposal candidate information. The item information and the obtained first election string call the verification function of the VRF algorithm to confirm that the first provable string is not forged.
应用链中有矿工需要重建应用链账本时(例如,矿工所在的挖矿节点故障后重启),必须要验证账本中的每一已出区块是否合法。对于任一待验证的应用链区块,应用链矿工至少需要从基链同步记录该区块的选举结果的基链区块的区块头以及区块体中为该区块选出的提案组领导人对应的提案候选信息(从上面的阐述可知,无论基链账本是否压缩,这两项内容都包含在每个基链区块内),并根据同步到的信息来确认应用链区块的是否得到基链认可,其具体过程包括:When a miner in the application chain needs to rebuild the application chain ledger (for example, the mining node where the miner is located is restarted after a failure), it is necessary to verify whether each block in the ledger is legal. For any application chain block to be verified, application chain miners at least need to synchronize the block header of the base chain block that records the election results of the block from the base chain and the leader of the proposal group selected for the block in the block body Person’s corresponding proposal candidate information (from the above description, these two contents are included in each base chain block regardless of whether the base chain ledger is compressed), and confirm whether the application chain block is correct according to the synchronized information Obtained by the base chain, the specific process includes:
应用链矿工同步上述信息后首先可用上面提到的方法确认提案候选信息中的第一可证明字串未被伪造;然后,还需要根据提案候选信息中的应用链矿工公钥一项确认提案候选信息所确定的提案组领导人就是待验证的应用链区块的出块者,例如,应用链区块的区块头中可以保存出块者的公钥信息,确认根据应用链矿工公钥获得的公钥信息与区块头中保存的公钥信息一致即可。After the application chain miner synchronizes the above information, the above-mentioned method can be used to confirm that the first provable string in the proposal candidate information is not forged; then, the proposal candidate needs to be confirmed according to the application chain miner public key in the proposal candidate information The leader of the proposal group identified by the information is the block producer of the application chain block to be verified. For example, the block producer’s public key information can be stored in the block header of the application chain block, and the public key information obtained from the application chain miner can be confirmed The public key information should be consistent with the public key information stored in the block header.
在一些可选的方案中,在应用链矿工确认了提案候选信息中的第一可证明字串未被伪造后,还可以进一步第一可证明字串推导第一随机值以及第二随机值(具体公式见前文),最后验证第二随机值是否满足当选提案组成员的条件、是否符合当选提案组领导人的基本要求等。当然,若提案候选信息的实现中已经包含第二随机值这一项,并且应用链矿工在重建账本时急于追赶块高,也可直接使用提案候选信息中的第二随机值用于验证,不必再根据第一可证明字串进行推导。In some optional solutions, after the application chain miner has confirmed that the first provable string in the proposal candidate information has not been forged, the first provable string can be further used to derive the first random value and the second random value ( See the above for the specific formula), and finally verify whether the second random value meets the conditions for being elected members of the proposal group and whether it meets the basic requirements of the elected proposal group leader. Of course, if the second random value is already included in the implementation of the proposal candidate information, and the application chain miners are eager to catch up with the block height when rebuilding the ledger, they can also directly use the second random value in the proposal candidate information for verification. Then derive it based on the first provable string.
应用链矿工在重建应用链账本时从基链同步信息确认账本中的区块被基链认可是十分重要的,因为应用链账本容易被人伪造,如果缺少基链为它背书,其真实性将 大打折扣。It is very important for application chain miners to synchronize information from the base chain when rebuilding the application chain ledger to confirm that the blocks in the ledger are recognized by the base chain, because the application chain ledger is easy to be forged. If the base chain is missing to endorse it, its authenticity will be Greatly discounted.
综上所述,在本公开提供的区块链记账方法中,应用链矿工并不直接运行共识算法竞争出块权,而是在确定自身为提案组成员后向基链矿工发送挖矿请求,由基链矿工通过计算选举出提案组领导人并将选举结果及选举依据记录在基链区块中,随后应用链矿工通过同步基链区块信息即可获知提案组领导人的信息,进而参与验证组成员的推选,并通过收集验证组成员对提案组领导人所出区块作出的检验报告判断区块是否通过验证,若通过验证就进行记账。To sum up, in the blockchain accounting method provided in this disclosure, the application chain miners do not directly run the consensus algorithm to compete for the block right, but send a mining request to the base chain miners after determining that they are members of the proposal group , The base chain miners elect the leader of the proposal group through calculations and record the election results and election basis in the base chain block, and then the application chain miners can obtain the information of the proposal group leader by synchronizing the base chain block information, and then Participate in the selection of the members of the verification group, and judge whether the block has passed verification by collecting the verification reports made by the members of the verification group on the block produced by the leader of the proposal group. If the verification is passed, the account will be kept.
实践中,该区块链记账方法还存在一些特殊情况,下面简单说明:In practice, there are some special circumstances in this blockchain accounting method, which are briefly explained below:
在前文介绍的方案中,均由基链矿工负责提案组领导人的选举,但在实践中也存在一些由应用链矿工自行选举提案组领导人的情况,当然选举过程仍然要依赖于从基链同步的信息。In the schemes introduced above, the base chain miners are responsible for the election of the proposal group leader. However, in practice, there are some cases where the application chain miners elect the proposal group leader by themselves. Of course, the election process still depends on the base chain. Synchronized information.
比如,某些应用链希望限定从确定范围内的矿工群体中选举提案组领导人,则这些应用链中的矿工可以借助基链提供的“随机源”来决定任一高度的区块由提案组中哪一位成员承担领导人角色。其中,所谓确定范围内的矿工群体,就是指提案组成员的名单是固定的(可以在程序中预先配置好),例如,提案组成员可以是应用链的资深成员、理事会员等,视用户需求而定。而“随机源”的概念前文已经介绍过,本方案中的“随机源”可以包括利用预设规则确定的第一选举字串,第一选举字串的内容具有随机性,从而基于第一选举字串,应用链矿工就可以动态地从确定范围的提案组成员中选举出一位提案组领导人。For example, some application chains want to limit the election of proposal group leaders from a certain range of miners, then miners in these application chains can use the "random source" provided by the base chain to determine blocks of any height by the proposal group Which one of the members assumes the leadership role. Among them, the so-called miner group within a certain range means that the list of proposal group members is fixed (can be pre-configured in the program), for example, proposal group members can be senior members of the application chain, board members, etc., depending on user needs Depends. The concept of "random source" has already been introduced in the previous section. The "random source" in this solution can include the first election string determined by preset rules. The content of the first election string is random and is based on the first election. String, application chain miners can dynamically elect a proposal group leader from a certain range of proposal group members.
例如,仍将第一选举字串记为info,将提案组成员先按照0至N-1编号,应用链矿工通过计算info%N的值就可以推算出一个提案组成员的编号,也就是要作为提案组领导人的矿工的编号,这里的N是提案组成员总数,%则表示取余数运算。应当指出,在这些特殊情况中,虽然基链矿工并未直接参与提案组领导人的选举过程,但应用链矿工在计算第一选举字串时仍需利用本地的基链账本(具体见前文关于第一选举字串的确定方式),因此应用链矿工同步基链区块信息的步骤仍然是必须的。For example, the first election string is still recorded as info, and the members of the proposal group are numbered from 0 to N-1. The application chain miner can calculate the number of a proposal group member by calculating the value of info%N, that is, The number of the miner who is the leader of the proposal group, where N is the total number of members of the proposal group, and% represents the remainder operation. It should be pointed out that in these special cases, although the base chain miners did not directly participate in the election process of the leader of the proposal group, the application chain miners still need to use the local base chain ledger when calculating the first election string (see the previous section for details) The method of determining the first election string), therefore, the step of applying chain miners to synchronize the block information of the base chain is still necessary.
提案组领导人选举完毕后,该领导人打包应用链待挖区块、并在本应用链提交,以及该应用链随后组建验证组,开展验证等操作与前文介绍的类似,不再重复阐述。After the election of the leader of the proposal group, the leader packs the application chain to be mined and submits it in this application chain, and the application chain subsequently forms a verification group to carry out verification and other operations similar to those introduced in the previous article, and will not be repeated.
总之,本申请实施例提供的区块链记账方法实际上提供了一套基链和应用链共同参与挖矿的全新机制,即可由一条基链汇集矿机资源,为众多应用链提供算力服务,协助应用链完成挖矿过程,从而可以有效改善现有区块链系统中矿机资源的浪费问题,具有良好的社会效益。其中,基链和应用链既可以是单链,也可以是并行链,并且基链和应用链构成的区块链系统还可以嵌套,其构成方式非常灵活。上文首先详细介绍了基链与区块链配合进行共同挖矿的工作原理,然后对其中涉及的同频出块、软分叉与最长链、账本压缩等难点问题进行了深入剖析并给出了对应的解决方案,使得共同挖矿机制得以完善。In short, the blockchain accounting method provided by the embodiments of this application actually provides a new mechanism for the base chain and the application chain to participate in mining. One base chain can gather mining machine resources and provide computing power for many application chains. Service, assist the application chain to complete the mining process, which can effectively improve the waste of mining machine resources in the existing blockchain system, and has good social benefits. Among them, the base chain and the application chain can be either a single chain or a parallel chain, and the block chain system composed of the base chain and the application chain can also be nested, which is very flexible. The above first introduces the working principle of the base chain and the blockchain for joint mining, and then analyzes the difficult issues involved in the same frequency block, soft fork and longest chain, and ledger compression. Corresponding solutions have been developed to improve the joint mining mechanism.
发明人研究后认为,该方法可以用于,但不限于以下的场景中:After research, the inventor believes that this method can be used in, but not limited to, the following scenarios:
场景一:对于新发展的区块链系统,必然会遭遇成长性与安全性的天然矛盾。新系统上线时由于缺少矿机资源的支持,导致汇集算力不足从而容易遭到攻击,现实案例已证实这一点,已有数个从比特币硬分叉而来的区块链系统,因遭受有预谋的算力攻击而夭折,区块链系统越不安全就越难赢得公众信任,也就越没人用,越少人用导致越少矿机参与,区块链系统更趋于不安全,整个体系将陷入恶性循环。Scenario 1: For the newly developed blockchain system, it will inevitably encounter the natural contradiction between growth and security. When the new system was launched, due to the lack of mining machine resources, the pooled computing power was insufficient and easy to be attacked. Real cases have confirmed this. There are already several blockchain systems from the Bitcoin hard fork. The premeditated computing power attack failed. The more insecure the blockchain system is, the harder it is to win the trust of the public, and the less people use it. The less people use it, the less mining machines participate, and the blockchain system tends to be more insecure. The entire system will fall into a vicious circle.
虽然为区块链系统设计专有的共识算法可以在一定程度上避免算力攻击,但势必导致矿机缺乏通用性难以得到市场认可,最终还是无法解决新生系统缺少算力支持的困境。Although the design of a proprietary consensus algorithm for the blockchain system can avoid computing power attacks to a certain extent, it will inevitably lead to the lack of versatility of the mining machine and it will be difficult for the market to recognize it. In the end, it will not be able to solve the plight of the new system lacking computing power support.
若利用本公开提供的区块链记账方法,则可由基链为新发展的区块链系统提供充足的矿机资源,保障其安全、稳定运行,有利于区块链技术在各行业的普及。If the blockchain accounting method provided in the present disclosure is used, the base chain can provide sufficient mining machine resources for the newly developed blockchain system to ensure its safe and stable operation, which is conducive to the popularization of blockchain technology in various industries .
场景二:在很多区块链系统中,矿机不只用于挖矿,还根据业务特定对外提供特定公共服务:例如,基于容量共识(Proof of Capacity,简称PoC)的矿机,将硬盘存储能力当作算力,算力本身就是存储服务;又例如,基于可信执行环境(Trusted Execution Environment,简称TEE)实施挖矿的区块链系统,可将TEE的 加解密、签名与验证等能力开放出来,对外提供安全服务。Scenario 2: In many blockchain systems, mining machines are not only used for mining, but also provide specific public services based on business specifics: for example, mining machines based on Proof of Capacity (PoC) will store hard disk storage capacity As computing power, computing power itself is a storage service; another example is a blockchain system that implements mining based on a Trusted Execution Environment (TEE), which can open TEE encryption, decryption, signature, and verification capabilities. Come out and provide security services to the outside world.
在这些区块链系统中,必须要足够数量的矿机才能够确相应服务的稳定运行。若利用本公开提供的区块链记账方法,可由基链为这些区块链系统提供充足的矿机资源,保障其提供服务的可靠性。In these blockchain systems, a sufficient number of mining machines must be able to ensure the stable operation of the corresponding services. If the blockchain accounting method provided in the present disclosure is used, the base chain can provide sufficient mining machine resources for these blockchain systems to ensure the reliability of the services provided.
此外,在本公开提供的区块链系统中,应用链确定提案组及验证组所依赖的随机源由链外系统(即基链)参与提供,提案组成员选举领导人改在链外系统(即基链)实施,并由链外系统(即基链)为应用链挖矿过程提供时钟源,这些措施有助于强化应用链的安全性,采取此种设计的简要分析如下:In addition, in the blockchain system provided by the present disclosure, the application chain determines the random source that the proposal group and the verification group rely on is provided by the off-chain system (ie the base chain), and the leader of the proposal group is changed to the off-chain system ( That is, the base chain) is implemented, and the off-chain system (ie, the base chain) provides a clock source for the mining process of the application chain. These measures help to strengthen the security of the application chain. A brief analysis of this design is as follows:
当前业界的联盟链普遍采用拜占庭共识算法,该算法限制了参与投票的节点数量,并要求在所有节点之间都建立连接后,才能在明确数量范围内进行投票(例如,典型联盟链的节点数量通常限制在100左右,组成联盟链的所有节点都属于提案组及验证组,不动态组建提案组及验证组)。本公开的方案对此进行了改进,在应用链内实现了提案组与验证组动态推选的机制,如上文所述的借助于VRF算法来确定提案组或验证组的范围,但发明人研究发现,纯粹在应用链内取随机数(指VRF算法中的info)作为VRF算法的输入,以及组建提案组或验证组过程中涉及的时间因素只在应用链内采用特定算法(比方从各节点上报时间取平均值等)来确定,安全强度不够。为了强化应用链的安全性,应在应用链的外部提供随机源与时钟源,在本公开的方案中由基链来提供。The current industry alliance chains generally use the Byzantine consensus algorithm, which limits the number of nodes participating in voting, and requires all nodes to establish connections before voting within a clear number range (for example, the number of nodes in a typical alliance chain Usually limited to about 100, all nodes that make up the alliance chain belong to the proposal group and the verification group, and the proposal group and the verification group are not dynamically formed). The solution of the present disclosure improves on this, and realizes the dynamic selection mechanism of the proposal group and the verification group in the application chain. As mentioned above, the scope of the proposal group or the verification group is determined with the help of the VRF algorithm. However, the inventor found that , The random number (referring to the info in the VRF algorithm) is purely taken as the input of the VRF algorithm in the application chain, and the time factor involved in the process of forming a proposal group or verification group is only used in the application chain (for example, reporting from each node) Time is averaged, etc.) to determine, the security strength is not enough. In order to strengthen the security of the application chain, a random source and a clock source should be provided outside the application chain, which are provided by the base chain in the solution of the present disclosure.
图3示出了本公开提供的区块链记账装置200的功能模块图。参照图3,区块链记账装置200包括:FIG. 3 shows a functional module diagram of the blockchain accounting device 200 provided by the present disclosure. 3, the blockchain accounting device 200 includes:
提案组推选模块210,用于应用链矿工参与应用链待挖区块的提案组成员的推选;其中,若确定所述应用链矿工被推选为应用链待挖区块的提案组成员,则向基链矿工发送针对所述应用链待挖区块的挖矿请求,所述提案组为有权发送挖矿请求的应用链矿工的集合;The proposal group selection module 210 is used for application chain miners to participate in the selection of proposal group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miners are selected as the proposal group members of the application chain to be mined, then The base chain miner sends a mining request for the block to be mined in the application chain, and the proposal group is a collection of application chain miners who have the right to send the mining request;
区块信息同步模块220,用于所述应用链矿工同步基链区块信息,并将所述基链区块信息纳入本地的基链账本中,所述基链区块信息来源于基链矿工根据所述挖矿请求生成的确定所述应用链待挖区块的提案组领导人的基链区块,所述基链区块信息中包括指示所述提案组领导人的选举结果;其中,所述提案组领导人为具有所述应用链待挖区块的出块权的提案组成员;The block information synchronization module 220 is used for the application chain miners to synchronize the base chain block information, and to incorporate the base chain block information into the local base chain ledger. The base chain block information comes from the base chain miners The base chain block of the leader of the proposal group that determines the block to be mined in the application chain is generated according to the mining request, and the base chain block information includes an election result indicating the leader of the proposal group; wherein, The leader of the proposal group is a member of the proposal group who has the right to produce blocks of the application chain to be mined;
验证组推选模块230,用于所述应用链矿工参与应用链待挖区块的验证组成员的推选;其中,若确定所述应用链矿工被推选为所述应用链待挖区块的验证组成员,则对所述提案组领导人所出区块进行验证,并向其他应用链矿工广播检验报告,所述验证组为有权生成检验报告的应用链矿工的集合,所述提案组领导人所出区块包括所述提案组领导人打包的所述应用链待挖区块;The verification group selection module 230 is used for the application chain miners to participate in the selection of the verification group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miners are selected as the verification group of the application chain to be mined blocks Members, verify the blocks produced by the leader of the proposal group, and broadcast inspection reports to other application chain miners. The verification group is a collection of application chain miners who have the right to generate inspection reports. The proposal group leader The block produced includes the block to be mined in the application chain packaged by the leader of the proposal group;
应用链记账模块240,用于所述应用链矿工接收所述检验报告,若根据所述检验报告确定所述提案组领导人所出区块验证通过,则将该区块纳入应用链账本中。The application chain accounting module 240 is used for the application chain miners to receive the inspection report, and if it is determined according to the inspection report that the block produced by the proposal group leader is verified, then the block is included in the application chain ledger .
本公开提供的区块链记账装置200,其实现原理及产生的技术效果在前述方法实施例中已经介绍,为简要描述,装置实施例部分未提及之处,可参考方法施例中相应内容。The implementation principles and technical effects of the blockchain accounting device 200 provided in the present disclosure have been introduced in the foregoing method embodiments. For a brief description, for the parts not mentioned in the device embodiments, please refer to the corresponding method embodiments. content.
图4示出了本公开提供的区块链记账装置300的功能模块图。参照图4,区块链记账装置300包括:FIG. 4 shows a functional module diagram of the blockchain accounting device 300 provided by the present disclosure. 4, the blockchain accounting device 300 includes:
选举模块310,用于基链矿工根据应用链待挖区块的提案组成员发送的针对所述应用链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人;The election module 310 is used for base chain miners to elect the leader of the proposal group for the application chain to be mined block according to the mining request sent by the proposal group members of the application chain to be mined block;
基链记账模块320,用于所述基链矿工将保存有选举结果以及选举依据的基链区块纳入基链账本中。The base chain accounting module 320 is used for the base chain miners to incorporate the base chain block storing the election results and the election basis into the base chain ledger.
本公开提供的区块链记账装置300,其实现原理及产生的技术效果在前述方法实施例中已经介绍,为简要描述,装置实施例部分未提及之处,可参考方法施例中相应内容。The implementation principles and technical effects of the blockchain accounting device 300 provided in the present disclosure have been introduced in the foregoing method embodiments. For a brief description, for the parts not mentioned in the device embodiments, please refer to the corresponding method embodiments. content.
图5示出了本公开提供的区块链记账装置400的功能模块图。参照图5,区块链记账装置400包括:FIG. 5 shows a functional module diagram of the blockchain accounting device 400 provided by the present disclosure. 5, the blockchain accounting device 400 includes:
信息接收模块410,用于所述同步节点接收基链矿工发送的确定应用链待挖区块的提案组领导人的基链区块,或者,接收所述基链矿工或基链中设置的其他同步节点发送的所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;其中,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的提案组领导人的选举结果,包括所述应用链待挖区块的提案组领导人的选举结果;The information receiving module 410 is used for the synchronization node to receive the base chain block sent by the base chain miner to determine the proposal group leader of the application chain to be mined block, or to receive the base chain miner or other set in the base chain The block header of the base chain block and the election result list in the block body of the base chain block sent by the synchronization node; wherein, each entry in the election result list corresponds to an application chain The election result of the leader of the proposal group of the block to be mined, including the election result of the leader of the proposal group of the block to be mined in the application chain;
信息发送模块420,用于所述同步节点向应用链矿工发送来源于所述基链区块的基链区块信息,所述基链区块信息采用的形式包括以下之一:所述基链区块本身;所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;所述基链区块的区块头以及所述基链区块的区块体中针对所述应用链的片断数据;其中,所述片断数据包括所述选举结果列表中针对所述应用链待挖区块的提案组领导人的选举结果,以及,所述选举结果与所述基链区块的区块头中基于所述选举结果列表计算出的merkle根之间的merkle路径。The information sending module 420 is used for the synchronization node to send the base chain block information derived from the base chain block to the application chain miners, and the form of the base chain block information includes one of the following: the base chain The block itself; the block header of the base chain block and the list of election results in the block body of the base chain block; the block header of the base chain block and the block body of the base chain block Fragment data for the application chain in the application chain; wherein the fragment data includes the election result of the leader of the proposal group for the block to be mined in the application chain in the election result list, and the election result and the The merkle path between merkle roots calculated based on the election result list in the block header of the base chain block.
本公开提供的区块链记账装置400,其实现原理及产生的技术效果在前述方法实施例中已经介绍,为简要描述,装置实施例部分未提及之处,可参考方法施例中相应内容。The implementation principles and technical effects of the blockchain accounting device 400 provided in the present disclosure have been introduced in the foregoing method embodiments. For a brief description, for the parts not mentioned in the device embodiments, please refer to the corresponding method embodiments. content.
图6示出了本公开提供的一种区块链节点的示意图。参照图6,区块链节点500包括:处理器510、存储器520以及通信接口530,这些组件通过通信总线540和/或其他形式的连接机构(未示出)互连并相互通讯。Fig. 6 shows a schematic diagram of a blockchain node provided by the present disclosure. 6, the blockchain node 500 includes a processor 510, a memory 520, and a communication interface 530. These components are interconnected and communicate with each other through a communication bus 540 and/or other forms of connection mechanisms (not shown).
其中,存储器520包括一个或多个(图中仅示出一个),其可以是,但不限于,随机存取存储器(Random Access Memory,简称RAM),只读存储器(Read Only Memory,简称ROM),可编程只读存储器(Programmable Read-Only Memory,简称PROM),可擦除只读存储器(Erasable Programmable Read-Only Memory,简称EPROM),电可擦除只读存储器(Electric Erasable Programmable Read-Only Memory,简称EEPROM)等。处理器510以及其他可能的组件可对存储器520进行访问,读和/或写其中的数据。Wherein, the memory 520 includes one or more (only one is shown in the figure), which may be, but not limited to, random access memory (Random Access Memory, RAM for short), Read Only Memory (ROM for short) , Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electric Erasable Programmable Read-Only Memory , EEPROM for short) and so on. The processor 510 and other possible components can access the memory 520, read and/or write data therein.
处理器510包括一个或多个(图中仅示出一个),其可以是一种集成电路芯片,具有信号的处理能力。上述的处理器510可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、微控制单元(Micro Controller Unit,简称MCU)、网络处理器(Network Processor,简称NP)或者其他常规处理器;还可以是专用处理器,包括数字信号处理器(Digital Signal Processor,简称DSP)、专用集成电路(Application Specific Integrated Circuits,简称ASIC)、现场可编程门阵列(Field Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The processor 510 includes one or more (only one is shown in the figure), which may be an integrated circuit chip with signal processing capability. The aforementioned processor 510 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a micro controller unit (Micro Controller Unit, MCU for short), a network processor (Network Processor, NP for short), or other conventional processing It can also be a dedicated processor, including Digital Signal Processor (DSP), Application Specific Integrated Circuits (ASIC), Field Programmable Gate Array (FPGA) Or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
通信接口530包括一个或多个(图中仅示出一个),可以用于和其他设备进行直接或间接地通信,以便进行数据的交互。例如,通信接口530可以是以太网接口;可以是高速网络接口(如Infiniband网络);可以是移动通信网络接口,例如3G、4G、5G网络的接口;可以是各类总线接口,例如USB、CAN、I2C、SPI等总线接口;还是可以是具有数据收发功能的其他类型的接口。The communication interface 530 includes one or more (only one is shown in the figure), which can be used to directly or indirectly communicate with other devices to exchange data. For example, the communication interface 530 can be an Ethernet interface; it can be a high-speed network interface (such as an Infiniband network); it can be a mobile communication network interface, such as a 3G, 4G, and 5G network interface; it can be a variety of bus interfaces, such as USB, CAN , I2C, SPI and other bus interfaces; it can also be other types of interfaces with data transceiver functions.
在存储器520中可以存储一条或多条计算机程序指令,处理器510可以读取并运行这些计算机程序指令,以实现本公开提供的区块链记账方法以及其他期望的功能。One or more computer program instructions can be stored in the memory 520, and the processor 510 can read and run these computer program instructions to implement the blockchain accounting method provided by the present disclosure and other desired functions.
可以理解,图6所示的结构仅为示意,区块链节点500还可以包括比图6中所示更多或者更少的组件,或者具有与图6所示不同的配置。图6中所示的各组件可以采用硬件、软件或其组合实现。例如,在采用硬件方式实现时,区块链节点500可以是个人计算机、手机、平板电脑、服务器、嵌入式设备、区块链系统专用硬件设备等;在采用软件方式实现时,区块链节点500可以是虚拟机、容器等。此外,区块链节点500也不限于单台设备,也可以是多台设备的组合或者大量设备构成的集群。于本公开的实施例中,基链上的挖矿节点、基链上的同步节点、基链上的管理节点、应用链上的挖矿节点都可以采用上述区块链节点500的结构实现,并运行各自的功能。It can be understood that the structure shown in FIG. 6 is only for illustration, and the blockchain node 500 may also include more or less components than those shown in FIG. 6, or have a different configuration from that shown in FIG. 6. Each component shown in FIG. 6 can be implemented by hardware, software, or a combination thereof. For example, when implemented by hardware, the blockchain node 500 can be a personal computer, mobile phone, tablet computer, server, embedded device, dedicated hardware device for the blockchain system, etc.; when implemented by software, the blockchain node 500 can be a virtual machine, container, etc. In addition, the blockchain node 500 is not limited to a single device, and may also be a combination of multiple devices or a cluster composed of a large number of devices. In the embodiments of the present disclosure, the mining nodes on the base chain, the synchronization nodes on the base chain, the management nodes on the base chain, and the mining nodes on the application chain can all be implemented using the structure of the blockchain node 500 described above. And run their respective functions.
本公开还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序指令,所述计算机程序指令被计算机的处理器读取并运行时,执行本公开提供的 区块链记账方法。例如,计算机可读存储介质可以实现为图6中区块链节点500中的存储器520。The present disclosure also provides a computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are read and run by a processor of the computer, the blockchain record provided by the present disclosure is executed. Accounting method. For example, the computer-readable storage medium may be implemented as the memory 520 in the blockchain node 500 in FIG. 6.
在本公开所提供的实施例中,应该理解到,所揭露装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the embodiments provided in the present disclosure, it should be understood that the disclosed device and method may be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other divisions in actual implementation. For example, multiple units or components may be combined or It can be integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
另外,作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。In addition, the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
再者,在本公开各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。Furthermore, the functional modules in the various embodiments of the present disclosure may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
以上所述仅为本公开的实施例而已,并不用于限制本公开的保护范围,对于本领域的技术人员来说,本公开可以有各种更改和变化。凡在本公开的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本公开的保护范围之内。The above are only the embodiments of the present disclosure, and are not used to limit the protection scope of the present disclosure. For those skilled in the art, the present disclosure may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
工业实用性Industrial applicability
本公开提供一种区块链记账方法、装置、节点及存储介质。在本公开的方案中,应用链矿工并不直接运行共识算法竞争出块权,而是在确定自身为提案组成员后向基链矿工发送挖矿请求,由基链矿工通过计算选举出提案组领导人并将选举结果及选举依据记录在基链区块中,随后应用链矿工通过同步基链区块信息即可获知提案组领导人的信息,进而参与验证组成员的推选,并通过收集验证组成员针对提案组领导人所出区块出具的检验报告判断区块是否通过验证,若通过验证就进行记账。The present disclosure provides a blockchain accounting method, device, node and storage medium. In the solution of the present disclosure, the application chain miners do not directly run the consensus algorithm to compete for the right to produce blocks, but send a mining request to the base chain miners after determining that they are members of the proposal group, and the base chain miners elect the proposal group through calculation The leader records the election results and the basis of the election in the base chain block, and then the application chain miners can obtain the information of the proposal group leader by synchronizing the base chain block information, and then participate in the selection of the verification group members, and pass the collection verification Group members judge whether the block passes the verification according to the inspection report issued by the leader of the proposal group, and if it passes the verification, the account will be kept.
即,本公开提出了一套由基链和应用链共同参与挖矿的全新机制,在该机制下可由一条基链汇集矿机资源,为众多应用链提供算力服务,协助应用链完成挖矿过程,从而可以有效改善现有区块链系统中矿机资源的浪费问题,具有良好的社会效益。此外,在本公开的方案中,可由基链为区块链系统提供充足的矿机资源,以保障新发展的区块链系统安全、稳定运行,以及保障区块链系统中的矿机能够对外提供可靠的特定服务。That is, this disclosure proposes a new mechanism for the base chain and the application chain to participate in mining. Under this mechanism, a base chain can gather mining machine resources, provide computing power services for many application chains, and assist the application chain to complete mining. Process, which can effectively improve the waste of mining machine resources in the existing blockchain system, and has good social benefits. In addition, in the solution of the present disclosure, the base chain can provide sufficient mining machine resources for the blockchain system to ensure the safe and stable operation of the newly developed blockchain system, and to ensure that the mining machines in the blockchain system can be externally Provide reliable specific services.

Claims (72)

  1. 一种区块链记账方法,其特征在于,应用于应用链矿工,所述方法包括:A blockchain accounting method, characterized in that it is applied to application chain miners, and the method includes:
    参与应用链待挖区块的提案组成员的推选;其中,若确定所述应用链矿工被推选为应用链待挖区块的提案组成员,则向基链矿工发送针对所述应用链待挖区块的挖矿请求,所述提案组为有权发送挖矿请求的应用链矿工的集合;Participate in the selection of the proposal group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miner is selected as the proposal group member of the application chain to be mined block, then send to the base chain miner that the application chain is to be mined Block mining request, the proposal group is a collection of application chain miners who have the right to send mining requests;
    同步基链区块信息,并将所述基链区块信息纳入本地的基链账本中,所述基链区块信息来源于基链矿工根据所述挖矿请求生成的确定所述应用链待挖区块的提案组领导人的基链区块,所述基链区块信息中包括指示所述提案组领导人的选举结果;其中,所述提案组领导人为具有所述应用链待挖区块的出块权的提案组成员;Synchronize the base chain block information, and incorporate the base chain block information into the local base chain ledger. The base chain block information is derived from the information generated by the base chain miners according to the mining request. The base chain block of the leader of the proposal group that mines the block, the base chain block information includes an election result indicating the leader of the proposal group; wherein, the leader of the proposal group has the area to be mined in the application chain Proposal group members with the right to produce blocks;
    参与应用链待挖区块的验证组成员的推选;其中,若确定所述应用链矿工被推选为所述应用链待挖区块的验证组成员,则对所述提案组领导人所出区块进行验证,并向其他应用链矿工广播检验报告,所述验证组为有权生成检验报告的应用链矿工的集合,所述提案组领导人所出区块包括所述提案组领导人打包的所述应用链待挖区块;Participate in the selection of members of the verification group for the block to be mined in the application chain; among them, if it is determined that the miner of the application chain is selected as the member of the verification group of the block to be mined in the application chain, the leader of the proposal group The block is verified, and the inspection report is broadcast to other application chain miners. The verification group is a collection of application chain miners who have the right to generate inspection reports. The block produced by the proposal group leader includes the package packaged by the proposal group leader. The block to be mined in the application chain;
    接收所述检验报告,若根据所述检验报告确定所述提案组领导人所出区块验证通过,则将该区块纳入应用链账本中。The inspection report is received, and if it is determined that the block produced by the leader of the proposal group is verified according to the inspection report, the block is included in the application chain ledger.
  2. 根据权利要求1所述的区块链记账方法,其特征在于,所述确定所述应用链矿工被推选为应用链待挖区块的提案组成员,包括:The blockchain accounting method according to claim 1, wherein the determining that the application chain miner is selected as a member of the proposal group of the application chain to be mined block comprises:
    基于所述应用链矿工的私钥以及利用预设规则确定的第一选举字串调用可验证随机函数VRF算法中的证明函数,获得第一可证明字串;Calling the verification function in the verifiable random function VRF algorithm based on the private key of the application chain miner and the first election string determined by the preset rule to obtain the first verifiable string;
    基于所述第一可证明字串推导第一随机值,并根据所述第一随机值确定所述应用链矿工被推选为应用链待挖区块的提案组成员。A first random value is derived based on the first provable character string, and according to the first random value, it is determined that the application chain miner is selected as a proposal group member of the application chain to be mined block.
  3. 根据权利要求2所述的区块链记账方法,其特征在于,所述第一选举字串取确定所述提案组领导人的基链区块的前L区块的区块头中记录的哈希值或随机数,L为正整数。The blockchain accounting method according to claim 2, characterized in that the first election string is the Harbin recorded in the block header of the first L block of the base chain block that determines the leader of the proposal group. Hope value or random number, L is a positive integer.
  4. 根据权利要求2所述的区块链记账方法,其特征在于,所述根据所述第一随机值确定所述应用链矿工被推选为应用链待挖区块的提案组成员,包括:The blockchain accounting method according to claim 2, wherein the determining that the application chain miner is elected as a proposal group member of the application chain to be mined block according to the first random value comprises:
    根据所述第一随机值以及所述应用链矿工的提案组参选权重确定所述应用链矿工被推选为应用链待挖区块的提案组成员;其中,所述应用链矿工被选为所述提案组成员的概率与所述提案组参选权重的取值正相关。According to the first random value and the weight of the application chain miner’s proposal group participation, it is determined that the application chain miner is selected as the proposal group member of the application chain to be mined; wherein, the application chain miner is selected as the candidate The probability of the members of the proposal group is positively related to the value of the participation weight of the proposal group.
  5. 根据权利要求4所述的区块链记账方法,其特征在于,所述根据所述第一随机值以及所述应用链矿工的提案组参选权重确定所述应用链矿工被推选为应用链待挖区块的提案组成员,包括:The blockchain accounting method according to claim 4, wherein the application chain miner is selected as the application chain based on the first random value and the proposal group participation weight of the application chain miner. The members of the proposal group of the block to be mined include:
    利用如下公式计算第二随机值RandValue2:Use the following formula to calculate the second random value RandValue2:
    RandValue2=((RandValue1%ExpectedRange1)+priority1)RandValue2=((RandValue1%ExpectedRange1)+priority1)
    其中,RandValue1为所述第一随机值,ExpectedRange1为预设的范围值,priority1为所述提案组参选权重,%表示取余数运算;Wherein, RandValue1 is the first random value, ExpectedRange1 is the preset range value, priority1 is the weight of the proposal group participation, and% represents the remainder operation;
    若满足如下条件,则确定所述应用链矿工被推选为应用链待挖区块的提案组成员:If the following conditions are met, it is determined that the application chain miner is selected as a member of the proposal group for the block to be mined in the application chain:
    RandValue2>(ExpectedRange1-(ExpectedRange1*1/M1))RandValue2>(ExpectedRange1-(ExpectedRange1*1/M1))
    其中,M1为预设过滤比例。Among them, M1 is the preset filtering ratio.
  6. 根据权利要求4所述的区块链记账方法,其特征在于,所述提案组参选权重取所述应用链矿工在预设历史时间段内当选为提案组领导人的次数。The blockchain accounting method according to claim 4, wherein the proposal group participation weight is taken as the number of times the application chain miner was elected as the proposal group leader in a preset historical time period.
  7. 根据权利要求6所述的区块链记账方法,其特征在于,所述应用链矿工在所述历史时间段内当选为提案组领导人的次数从基于所述基链区块信息构建的表格中查询获得。The blockchain accounting method according to claim 6, wherein the number of times that the application chain miner was elected as the leader of the proposal group in the historical time period is determined from a table constructed based on the base chain block information. Obtained in the query.
  8. 根据权利要求6所述的区块链记账方法,其特征在于,若所述应用链矿工因在所述历史时间段内未当选过提案组领导人而使得所述提案组参选权重为0,则所述提案组参选权重取首次记账权重,所述首次记账权重为预设的非0值。The blockchain accounting method according to claim 6, wherein if the application chain miner has not been elected as the leader of the proposal group within the historical time period, the weight of the proposal group participation is 0 , The weight of the proposal group participation is the first accounting weight, and the first accounting weight is a preset non-zero value.
  9. 根据权利要求6所述的区块链记账方法,其特征在于,若所述应用链矿工在所述历史时间段内当选提案组领导人的次数使得所述提案组参选权重大于预设的提案组最大参选权重,则所述提案组参选权重取所述提案组最大参选权重。The blockchain accounting method according to claim 6, wherein if the number of times that the application chain miner was elected as the leader of the proposal group in the historical period of time, the proposal group’s right to participate in the proposal group is greater than the preset If the proposal group has the largest participation weight, then the proposal group’s participation weight shall be the maximum participation weight of the proposal group.
  10. 根据权利要求2所述的区块链记账方法,其特征在于,所述挖矿请求中包括提案候选信息,所述提案候选信息包括:The blockchain accounting method according to claim 2, wherein the mining request includes proposal candidate information, and the proposal candidate information includes:
    应用链标识、并行链链号、应用链待挖区块的高度、确定提案组领导人的基链区块的高度、应用链矿工公钥以及第一可证明字串;Application chain identification, parallel chain chain number, height of the block to be mined in the application chain, height of the base chain block to determine the leader of the proposal group, public key of the application chain miner, and the first provable string;
    其中,所述应用链标识是指发送所述挖矿请求的所述提案组成员所在的应用链的标识,所述并行链链号是指构成所述应用链的并行链中所述提案组成员挖矿所在的并行链的编号,所述确定提案组领导人的基链区块的高度是指确定所述应用链待挖区块的提案组领导人的基链区块的高度,所述应用链矿工公钥是指所述提案组成员的公钥,所述第一可证明字串是指所述应用链矿工被推选为所述提案组成员时依赖的第一可证明字串。Wherein, the application chain identifier refers to the identifier of the application chain where the member of the proposal group that sent the mining request is located, and the parallel chain chain number refers to the member of the proposal group in the parallel chain constituting the application chain The number of the parallel chain where the mining is located, the height of the base chain block of the leader of the proposal group is determined to refer to the height of the base chain block of the leader of the proposal group that determines the block to be mined in the application chain. The chain miner's public key refers to the public key of the proposal group member, and the first provable string refers to the first provable string that the application chain miner relies on when it is elected as a member of the proposal group.
  11. 根据权利要求1所述的区块链记账方法,其特征在于,在所述确定所述应用链矿工被推选为应用链待挖区块的提案组成员之后,所述方法还包括:The blockchain accounting method according to claim 1, wherein after determining that the application chain miner is selected as a member of the proposal group of the application chain to be mined, the method further comprises:
    被推选为所述提案组成员的应用链矿工打包所述应用链待挖区块。The application chain miners selected as members of the proposal group pack the application chain to-be-mined blocks.
  12. 根据权利要求11所述的区块链记账方法,其特征在于,所述打包所述应用链待挖区块,包括:The blockchain accounting method according to claim 11, wherein said packaging the application chain to be mined blocks comprises:
    打包所述应用链待挖区块,并在所述应用链待挖区块的首个交易中保存所述应用链矿工被推选为所述提案组成员的证据。Pack the application chain to-be-mined block, and save the proof that the application-chain miner is selected as a member of the proposal group in the first transaction of the application-chain to-be-mined block.
  13. 根据权利要求11所述的区块链记账方法,其特征在于,所述打包所述应用链待挖区块,包括:The blockchain accounting method according to claim 11, wherein said packaging the application chain to be mined blocks comprises:
    判断确定所述提案组领导人的基链区块的高度与所述应用链待挖区块的高度之差是否大于预设的第一差值阈值;Determine whether the difference between the height of the base chain block of the leader of the proposal group and the height of the block to be mined in the application chain is greater than a preset first difference threshold;
    若两个高度之差大于所述第一差值阈值,则连续打包所述应用链待挖区块以及预设个数的空块;其中,所述预设个数不小于1。If the difference between the two heights is greater than the first difference threshold, the application chain to be mined blocks and a preset number of empty blocks are continuously packaged; wherein the preset number is not less than one.
  14. 根据权利要求11所述的区块链记账方法,其特征在于,在所述打包所述应用链待挖区块之后,所述方法还包括:The blockchain accounting method according to claim 11, wherein after the packaging of the application chain to be mined blocks, the method further comprises:
    将所述应用链待挖区块广播给周边局部范围内的其他应用链矿工。Broadcast the application chain to-be-mined block to other application chain miners in the surrounding area.
  15. 根据权利要求14所述的区块链记账方法,其特征在于,所述将所述应用链待挖区块广播给周边局部范围内的其他应用链矿工,包括:The blockchain accounting method according to claim 14, wherein the broadcasting the application chain to-be-mined block to other application chain miners in the surrounding area includes:
    在用于广播所述应用链待挖区块的广播消息中指定转发次数,所述应用链待挖区块每经过一次转发,所述广播消息中的转发次数减去1,在所述转发次数减少至0时停止广播所述应用链待挖区块。Specify the number of forwarding times in the broadcast message used to broadcast the block to be mined in the application chain. Each time the block to be mined in the application chain is forwarded, the number of forwarding in the broadcast message is reduced by 1, and the number of forwarding is When it is reduced to 0, stop broadcasting the application chain to-be-mined block.
  16. 根据权利要求1所述的区块链记账方法,其特征在于,所述基链由至少一条并行链构成,所述向基链矿工发送针对所述应用链待挖区块的挖矿请求,包括:The blockchain accounting method according to claim 1, wherein the base chain is composed of at least one parallel chain, and the base chain miner sends a mining request for the block to be mined in the application chain to the base chain miner, include:
    向所述基链的至少一条并行链中的一条并行链上的基链矿工发送针对所述应用链待挖区块的挖矿请求。Send a mining request for a block to be mined in the application chain to a base chain miner on one of the at least one parallel chain of the base chain.
  17. 根据权利要求16所述的区块链记账方法,其特征在于,所述向所述基链的至少一条并行链中的一条并行链上的基链矿工发送针对所述应用链待挖区块的挖矿请求,包括:The blockchain accounting method according to claim 16, characterized in that, said base chain miners on one of the at least one parallel chain of the base chain are sent to the base chain miners on the application chain to be mined. The mining request includes:
    根据如下公式从所述基链的至少一条并行链中确定一条并行链,并向该并行链上的基链矿工发送针对所述应用链待挖区块的挖矿请求:Determine a parallel chain from at least one parallel chain of the base chain according to the following formula, and send a mining request for the block to be mined in the application chain to the base chain miners on the parallel chain:
    n=(ChainNoOffet+k)%Nn=(ChainNoOffet+k)%N
    其中,N为所述基链的并行链的总数,N为正整数,并且所述基链的N条并行链按照从0至N-1依次编号,ChainNoOffet为所述应用链预设的链号偏移,k为构成所述应用链的并行链中所述提案组成员挖矿所在的并行链链号,%表示取余数运算,n表示确定出的所述基链的并行链链号。Wherein, N is the total number of parallel chains of the base chain, N is a positive integer, and the N parallel chains of the base chain are sequentially numbered from 0 to N-1, and ChainNoOffet is the chain number preset by the application chain Offset, k is the chain number of the parallel chain where the members of the proposal group mine in the parallel chain constituting the application chain,% represents the remainder operation, and n represents the determined parallel chain number of the base chain.
  18. 根据权利要求1所述的区块链记账方法,其特征在于,所述同步基链区块信息,包括:The blockchain accounting method according to claim 1, wherein the synchronization base chain block information includes:
    从所述基链中设置的同步节点同步基链区块信息。Synchronize the block information of the base chain from the synchronization node set in the base chain.
  19. 根据权利要求1所述的区块链记账方法,其特征在于,所述基链区块信息采用的形式包括以下之一:The blockchain accounting method according to claim 1, wherein the form of the base chain block information includes one of the following:
    确定所述提案组领导人的基链区块本身;Determine the base chain block itself of the leader of the proposal group;
    所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的选举结果,包括所述应用链待挖区块的提案组领导人的选举结果;The block header of the base chain block and the election result list in the block body of the base chain block, each entry in the election result list corresponds to the election of a block to be mined on an application chain The result includes the election result of the leader of the proposal group of the block to be mined in the application chain;
    所述基链区块的区块头以及所述基链区块的区块体中针对所述应用链的片断数据;其中,所述片断数据包括所述选举结果列表中针对所述应用链待挖区块的提案组领导人的选举结果,以及,所述选举结果与所述基链区块的区块头中基于所述选举结果列表计算出的merkle根之间的merkle路径。The block header of the base chain block and the fragment data for the application chain in the block body of the base chain block; wherein the fragment data includes the list of election results for the application chain to be mined The election result of the leader of the proposal group of the block, and the merkle path between the election result and the merkle root calculated based on the election result list in the block header of the base chain block.
  20. 根据权利要求1所述的区块链记账方法,其特征在于,推选所述应用链待挖区块的验证组成员分为至少一轮进行;The blockchain accounting method according to claim 1, wherein the selection of the verification group members of the application chain to be mined blocks is divided into at least one round;
    当所述应用链矿工同步到确定所述应用链待挖区块的提案组领导人的基链区块信息,就参与前P轮验证组成员的推选,之后所述应用链矿工每同步到一个基链区块信息,就参与新一轮验证组成员的推选,除非满足以下条件之一,不再参与新一轮验证组成员的推选:When the application chain miners synchronize to the base chain block information of the leader of the proposal group that determines the block to be mined in the application chain, they participate in the selection of the members of the previous P round verification group. After that, the application chain miners synchronize to one Base chain block information will participate in the new round of selection of members of the verification team. Unless one of the following conditions is met, it will no longer participate in the new round of selection of members of the verification team:
    所述应用链矿工在已参与的推选轮次中确定自身被推选为验证组成员;The application chain miner determines that he is elected as a member of the verification group in the selection rounds that he has participated in;
    所述应用链矿工根据当前已接收到的检验报告能够得出所述提案组领导人所出区块验证通过的结论;The application chain miner can draw a conclusion that the block verification passed by the leader of the proposal group according to the currently received inspection report;
    所述应用链矿工已参与的推选轮次已经达到预设的最大轮次;The selection rounds that the application chain miners have participated in have reached the preset maximum round;
    其中,1≤P≤MaxRounds,MaxRounds为所述最大轮次,若所述应用链矿工在已参与的推选轮次中确定自身被推选为验证组成员,则对所述提案组领导人所出区块进行验证,向其他应用链矿工广播检验报告。Among them, 1≤P≤MaxRounds, and MaxRounds is the maximum round. If the application chain miner determines that he is elected as a member of the verification group in the election rounds that he has participated in, the leader of the proposal group will be Block verification and broadcast inspection reports to other application chain miners.
  21. 根据权利要求1所述的区块链记账方法,其特征在于,所述确定所述应用链矿工被推选为所述应用链待挖区块的验证组成员,包括:The blockchain accounting method according to claim 1, wherein the determining that the application chain miner is selected as a verification group member of the application chain to be mined block comprises:
    基于所述应用链矿工的私钥以及利用预设规则确定的第二选举字串调用VRF算法中的证明函数,获得第二可证明字串;Call the proof function in the VRF algorithm based on the private key of the application chain miner and the second election string determined by the preset rules to obtain the second provable string;
    基于所述第二可证明字串推导第三随机值,并根据所述第三随机值以及所述应用链矿工的验证组参选权重确定所述应用链矿工被推选为所述应用链待挖区块的验证组成员;其中,所述应用链矿工被选为验证组成员的概率与所述验证组参选权重的取值正相关。Derive a third random value based on the second provable string, and determine that the application chain miner is selected as the application chain to be mined according to the third random value and the verification group participation weight of the application chain miner A member of the verification group of the block; wherein the probability of the application chain miner being selected as a member of the verification group is positively related to the value of the weight of the verification group participation.
  22. 根据权利要求21所述的区块链记账方法,其特征在于,所述验证组参选权重根据所述应用链矿工当前持有数字货币的数量进行计算,若所述应用链矿工当前未持有数字货币,则所述验证组参选权重取0。The blockchain accounting method according to claim 21, wherein the verification group participation weight is calculated according to the amount of digital currency currently held by the application chain miner, and if the application chain miner does not currently hold If there is digital currency, the weight of the verification group participation is 0.
  23. 根据权利要求22所述的区块链记账方法,其特征在于,若所述应用链矿工当前持有的数字货币数量使得所述验证组参选权重大于预设的验证组最大参选权重,则所述验证组参选权重取所述验证组最大参选权重。The blockchain accounting method according to claim 22, wherein if the amount of digital currency currently held by the application chain miners makes the verification group participation weight greater than the preset maximum verification group participation weight, Then the verification group participation weight takes the maximum verification group participation weight.
  24. 根据权利要求22所述的区块链记账方法,其特征在于,若所述应用链矿工当前持有数字货币的数量小于预设的最小持币量,则所述应用链矿工不参与验证组成员的推选。The blockchain accounting method according to claim 22, wherein if the amount of digital currency currently held by the application chain miners is less than the preset minimum amount of currency holdings, the application chain miners do not participate in the verification group Selection of members.
  25. 根据权利要求21所述的区块链记账方法,其特征在于,推选所述应用链待挖区块的验证组成员分为至少一轮进行,所述第二选举字串根据以下信息计算:The blockchain accounting method according to claim 21, wherein the selection of the verification group members of the application chain to be mined block is divided into at least one round, and the second election string is calculated according to the following information:
    所述提案组领导人的矿工标识、确定所述提案组领导人的基链区块的高度、所述应用链待挖区块的高度以及推选所述验证组成员的轮次编号。The miner identification of the leader of the proposal group, the height of the base chain block that determines the leader of the proposal group, the height of the block to be mined in the application chain, and the round number for selecting the members of the verification group.
  26. 根据权利要求1所述的区块链记账方法,其特征在于,所述提案组领导人在广播所出区块时,还附带广播所述提案组领导人发送的针对该区块的挖矿请求中的提案候选信息,被推选为所述应用链待挖区块的验证组成员的所述应用链矿工对所述提案组领导人所出区块进行验证,包括以下验证项目:The blockchain accounting method according to claim 1, wherein when the leader of the proposal group broadcasts the block, it also broadcasts the mining of the block sent by the leader of the proposal group. For the proposal candidate information in the request, the application chain miners who are selected as members of the verification group of the application chain to be mined block verify the block produced by the proposal group leader, including the following verification items:
    根据所述提案候选信息中的确定提案组领导人的基链区块的高度,确定所述提案组领导人被推选为提案组成员时依赖的第一选举字串,基于所述提案候选信息中的第一可证明字串、所述提案候选信息中的应用链矿工公钥以及所述第一选举字串调用VRF算法中的验证函数,验证所述提案候选信息中的第一可证明字串是否被伪造;According to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, the first election string that the proposal group leader relies on when elected as a member of the proposal group is determined, based on the proposal candidate information The first provable string in the proposal candidate information, the application chain miner public key in the proposal candidate information, and the first election string call the verification function in the VRF algorithm to verify the first provable string in the proposal candidate information Whether it has been forged;
    验证所述提案候选信息中的应用链矿工公钥对应的应用链矿工是否为所述提案组领导人所出区块的创建者;Verifying whether the application chain miner corresponding to the application chain miner public key in the proposal candidate information is the creator of the block produced by the proposal group leader;
    根据所述提案候选信息中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人,验证查询出的所述提案组领导人与所述提案候选信息确定的所述提案组领导人是否一致;According to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, query the proposal group leader from the local base chain ledger, and verify the inquired proposal group leader and the proposal candidate Whether the leaders of the proposal group determined by the information are consistent;
    验证所述提案组领导人所出区块中的所有交易是否正确;Verify that all transactions in the block produced by the leader of the proposal group are correct;
    若所有验证项目的验证结果均为“是”,则生成检验结论为验证通过的检验报告,否则生成检验结论为验证未通过的检验报告。If the verification results of all verification items are "Yes", the generated inspection conclusion is an inspection report that has passed the verification, otherwise, the generated inspection conclusion is an inspection report that has not passed the verification.
  27. 根据权利要求26所述的区块链记账方法,其特征在于,所述提案组领导人所出区块的区块头中保存有表征区块创建者身份的公钥信息,所述验证所述提案候选信息中的应用链矿工公钥对应的应用链矿工是否为所述提案组领导人所出区块的创建者,包括:The blockchain accounting method according to claim 26, wherein the block header of the block produced by the leader of the proposal group stores public key information that characterizes the identity of the block creator, and the verification of the Whether the application chain miner corresponding to the application chain miner public key in the proposal candidate information is the creator of the block produced by the proposal group leader includes:
    验证根据所述提案候选信息中的应用链矿工公钥获得的公钥信息与所述区块头中保存的公钥信息是否一致,若一致,则确认所述提案候选信息中的应用链矿工公钥对应的应用链矿工是所述提案组领导人所出区块的创建者,否则该应用链矿工四·不是所述提案组领导人所出区块的创建者。Verify whether the public key information obtained from the application chain miner public key in the proposal candidate information is consistent with the public key information stored in the block header, and if they are consistent, confirm the application chain miner public key in the proposal candidate information The corresponding application chain miner is the creator of the block produced by the proposal group leader, otherwise the application chain miner is not the creator of the block produced by the proposal group leader.
  28. 根据权利要求26所述的区块链记账方法,其特征在于,所述提案组领导人在广播所出区块时,还附带广播所述提案组领导人利用自身的私钥对所出区块的签名,所述验证所述提案候选信息中的应用链矿工公钥对应的应用链矿工是否为所述提案组领导人所出区块的创建者,包括:The blockchain accounting method according to claim 26, characterized in that, when the leader of the proposal group broadcasts the output block, the leader of the proposal group also broadcasts that the leader of the proposal group uses its own private key to verify the output of the block. The signature of the block to verify whether the application chain miner corresponding to the application chain miner public key in the proposal candidate information is the creator of the block produced by the proposal group leader includes:
    利用所述提案候选信息中的应用链矿工公钥验证广播消息中携带的对所述提案组领导人所出区块的签名是否正确,若正确,则确认所述提案候选信息中的应用链矿工公钥对应的应用链矿工是所述提案组领导人所出区块的创建者,否则该应用链矿工不是所述提案组领导人所出区块的创建者。Use the public key of the application chain miner in the proposal candidate information to verify whether the signature of the block produced by the leader of the proposal group carried in the broadcast message is correct, and if it is correct, confirm the application chain miner in the proposal candidate information The application chain miner corresponding to the public key is the creator of the block produced by the proposal group leader, otherwise the application chain miner is not the creator of the block produced by the proposal group leader.
  29. 根据权利要求26所述的区块链记账方法,其特征在于,所述根据所述提案候选信息中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人,验证查询出的所述提案组领导人与所述提案候选信息确定的所述提案组领导人是否一致,包括:The blockchain accounting method according to claim 26, characterized in that, according to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, the local base chain ledger is queried for the The leader of the proposal group, verifying whether the queried leader of the proposal group is consistent with the leader of the proposal group determined by the proposal candidate information, including:
    根据所述提案候选信息中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人的公钥,验证查询出的所述提案组领导人的公钥与所述提案候选信息中的应用链矿工公钥是否一致,若一致,则确认查询出的所述提案组领导人与所述提案候选信息确定的所述提案组领导人一致,否则两个提案组领导人不一致;According to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, the public key of the proposal group leader is queried from the local base chain ledger, and the public key of the queried proposal group leader is verified. Whether the key is consistent with the public key of the application chain miner in the proposal candidate information, if they are the same, confirm that the queried leader of the proposal group is consistent with the leader of the proposal group determined by the proposal candidate information, otherwise two Leaders of the proposal group are inconsistent;
    或者,or,
    根据所述提案候选信息中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人的矿工标识,基于所述提案候选信息中的应用链矿工公钥、所述提案候选信息中的应用链标识以及所述提案候选信息中的并行链链号,利用哈希算法计算所述提案组领导人的矿工标识,并验证查询出的所述提案组领导人的矿工标识与计算出的所述提案组领导人的矿工标识是否一致,若一致,则确认查询出的所述提案组领导人与所述提案候选信息确定的所述提案组领导人一致,否则两个提案组领导人不一致。According to the height of the base chain block that determines the leader of the proposal group in the proposal candidate information, the local base chain ledger is queried for the miner ID of the proposal group leader, and based on the application chain miner company in the proposal candidate information Key, the application chain identifier in the proposal candidate information and the parallel chain chain number in the proposal candidate information, the hash algorithm is used to calculate the miner ID of the leader of the proposal group, and the queried leader of the proposal group is verified Whether the human miner ID is consistent with the calculated miner ID of the proposal group leader, if they are the same, confirm that the queried proposal group leader is consistent with the proposal group leader determined by the proposal candidate information, Otherwise, the leaders of the two proposal groups are inconsistent.
  30. 根据权利要求1所述的区块链记账方法,其特征在于,所述根据所述检验报告确定所述提案组领导人所出区块验证通过,包括:The blockchain accounting method according to claim 1, wherein said determining, according to the inspection report, that the block produced by the leader of the proposal group has been verified, comprises:
    若收到的检验报告中检验通过的报告份数不小于最小成功验证数,以及,检验不通过的报告份数不大于最大失败验证数,则确定所述提案组领导人所出区块验证通过;If the number of passed inspection reports in the received inspection report is not less than the minimum number of successful verifications, and the number of failed inspection reports is not greater than the maximum number of failed verifications, it is determined that the block verification by the leader of the proposal group is passed ;
    其中,所述最小成功验证数以及所述最大失败验证数为预设值,或者,根据一预设时间段内被选为提案组领导人的应用链矿工的个数进行推算。Wherein, the minimum number of successful verifications and the maximum number of failed verifications are preset values, or calculated based on the number of application chain miners selected as the leader of the proposal group within a preset time period.
  31. 根据权利要求1所述的区块链记账方法,其特征在于,所述根据所述检验报告确定所述提案组领导人所出区块验证通过,包括:The blockchain accounting method according to claim 1, wherein said determining, according to the inspection report, that the block produced by the leader of the proposal group has been verified, comprises:
    确定收到的检验报告的在验证过程中所占的票数,每份检验报告所占的票数与生 成该检验报告的验证组成员当前持有的数字货币的数量正相关;Determine the number of votes of the received inspection report during the verification process. The number of votes for each inspection report is positively related to the amount of digital currency currently held by the verification team member who generated the inspection report;
    若收到的检验报告中检验通过的报告所占的总票数不小于最小成功验证数,以及,检验不通过的报告所占的总票数不大于最大失败验证数,则确定所述提案组领导人所出区块验证通过。If the total number of votes in the received inspection report is not less than the minimum number of successful verifications, and the total number of votes in the failed inspection reports is not greater than the maximum number of failed verifications, the leader of the proposal group is determined The block verification passed.
  32. 根据权利要求31所述的区块链记账方法,其特征在于,所述确定收到的检验报告的在验证过程中所占的票数,包括:The blockchain accounting method according to claim 31, wherein said determining the number of votes in the verification process of the received inspection report comprises:
    根据如下公式确定收到的检验报告的在验证过程中所占的票数:Determine the number of votes in the verification process of the received inspection report according to the following formula:
    vote_num=1+stake/leveragevote_num=1+stake/leverage
    其中,vote_num为所述检验报告所占的票数,stake为生成所述检验报告的验证组成员当前持有的数字货币的数量,leverage为预设的票数调节比例。Wherein, vote_num is the number of votes occupied by the inspection report, stake is the amount of digital currency currently held by the verification group members that generated the inspection report, and leverage is the preset vote adjustment ratio.
  33. 根据权利要求30所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method of claim 30, wherein the method further comprises:
    若收到的检验报告中检验通过的报告份数占所述最小成功验证数的比例不小于预设的已验证比例,则提前开始下一应用链待挖区块的提案组成员的推选。If the proportion of the number of reports passed in the received inspection report to the minimum number of successful verifications is not less than the preset verified proportion, the selection of the proposal group members for the next application chain block to be mined is started in advance.
  34. 根据权利要求1所述的区块链记账方法,其特征在于,所述检验报告包括以下信息:The blockchain accounting method according to claim 1, wherein the inspection report includes the following information:
    提案组领导人的矿工标识、确定提案组领导人的基链区块的高度、应用链待挖区块的高度、推选验证组成员的轮次编号、生成检验报告的验证组成员的公钥、应用链矿工被推选为验证组成员时依赖的第二可证明字串、应用链待挖区块的哈希值、检验结论以及利用验证组成员的私钥对检验报告的签名。The miner identification of the leader of the proposal group, the height of the base chain block that determines the leader of the proposal group, the height of the block to be mined in the application chain, the round number of the selection verification group member, the public key of the verification group member who generated the inspection report, The second provable string that the app chain miners rely on when they are selected as members of the verification group, the hash value of the block to be mined in the app chain, the verification conclusion, and the signature of the verification report using the private key of the verification group member.
  35. 根据权利要求34所述的区块链记账方法,其特征在于,在所述应用链矿工认可所述检验报告中的检验结论之前,所述方法还包括:The blockchain accounting method according to claim 34, characterized in that, before the application chain miner approves the inspection conclusion in the inspection report, the method further comprises:
    利用所述检验报告中的验证组成员的公钥确认报告中的签名正确;Use the public key of the verification group member in the inspection report to confirm that the signature in the report is correct;
    根据所述检验报告中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人,确认查询出的所述提案组领导人与所述检验报告所确定的所述提案组领导人一致;According to the height of the base chain block that determines the leader of the proposal group in the inspection report, query the leader of the proposal group from the local base chain ledger, and confirm that the inquired leader of the proposal group and the inspection report office The determined leaders of the proposal group are consistent;
    根据所述检验报告中的提案组领导人的矿工标识、确定提案组领导人的基链区块的高度、应用链待挖区块的高度以及推选验证组成员的轮次编号计算生成所述检验报告的应用链矿工被推选为所述验证组成员时依赖的第二选举字串,基于所述第二选举字串、所述检验报告中的生成检验报告的验证组成员的公钥以及所述检验报告中的第二可证明字串调用VRF算法中的验证函数,确认所述检验报告中的第二可证明字串未被伪造;The inspection is calculated and generated according to the miner identification of the leader of the proposal group in the inspection report, the height of the base chain block that determines the leader of the proposal group, the height of the block to be mined in the application chain, and the round number of the selected verification group member The second election string on which the reported application chain miners were elected as members of the verification group is based on the second election string, the public key of the verification group member who generated the verification report in the verification report, and the The second provable string in the inspection report calls the verification function in the VRF algorithm to confirm that the second provable string in the inspection report is not forged;
    基于所述检验报告中的第二可证明字串推导第三随机值,并根据所述第三随机值确认生成所述检验报告的应用链矿工为所述验证组成员。A third random value is derived based on the second provable character string in the inspection report, and the application chain miner who generated the inspection report is confirmed as a member of the verification group according to the third random value.
  36. 根据权利要求35所述的区块链记账方法,其特征在于,所述根据所述检验报告中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人,确认查询出的所述提案组领导人与所述检验报告确定的所述提案组领导人一致,包括:The block chain accounting method according to claim 35, wherein the proposal is inquired from the local base chain ledger according to the height of the base chain block that determines the leader of the proposal group in the inspection report The group leader, confirming that the inquired leader of the proposal group is consistent with the leader of the proposal group determined in the inspection report, including:
    根据所述检验报告中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人的公钥,基于查询出的所述提案组领导人的公钥、所述应用链矿工挖矿所在的应用链标识以及并行链链号,利用哈希算法计算所述提案组领导人的矿工标识,确认计算出的所述提案组领导人的矿工标识与所述检验报告中的提案组领导人的矿工标识一致;According to the height of the base chain block determining the leader of the proposal group in the inspection report, query the public key of the leader of the proposal group from the local base chain ledger, based on the public key of the leader of the proposal group found out , The application chain identifier and the parallel chain chain number where the application chain miner is mining, the hash algorithm is used to calculate the miner identifier of the proposal group leader, and the calculated miner identifier of the proposal group leader is confirmed with the The miner's identification of the leader of the proposal group in the inspection report is consistent;
    或者,or,
    根据所述检验报告中的确定提案组领导人的基链区块的高度从本地的基链账本中查询所述提案组领导人的矿工标识,确认查询出的所述提案组领导人的矿工标识与所述检验报告中的提案组领导人的矿工标识一致。According to the height of the base chain block determining the leader of the proposal group in the inspection report, query the local base chain ledger for the miner ID of the proposal group leader, and confirm the miner ID of the leader of the proposal group that was queried It is consistent with the miner identification of the leader of the proposal group in the inspection report.
  37. 根据权利要求1所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method according to claim 1, wherein the method further comprises:
    若根据所述检验报告确定所述提案组领导人所出区块验证通过,则开始下一应用链待挖区块的提案组成员的推选;If it is determined according to the inspection report that the block produced by the leader of the proposal group has passed the verification, the selection of the proposal group members of the block to be mined in the next application chain is started;
    若根据所述检验报告确定所述提案组领导人所出区块验证未通过,则弃用所述提 案组领导人所出区块,若该区块之后还串接了其他区块则一同弃用,并重新开始所述应用链待挖区块的提案组成员的推选。If it is determined according to the inspection report that the block produced by the leader of the proposal group is not verified, the block produced by the leader of the proposal group is discarded, and if other blocks are connected in series after the block, then discarded together And restart the selection of the members of the proposal group for the block to be mined in the application chain.
  38. 根据权利要求20所述的区块链记账方法,其特征在于,P>1,所述若根据所述检验报告确定所述提案组领导人所出区块验证通过,则将该区块纳入应用链账本中,包括:The blockchain accounting method according to claim 20, wherein P>1, if it is determined according to the inspection report that the block produced by the leader of the proposal group is verified, then the block is included The application chain ledger includes:
    若根据所述检验报告确定所述提案组领导人所出区块验证通过,且得出通过结论的所依赖的检验报告均已生效,则将该区块纳入应用链账本中;其中,所述检验报告在所述应用链矿工同步到报告生成轮次对应的基链区块信息后生效,所述报告生成轮次是指生成所述检验报告的应用链矿工被推选为验证组成员的推选轮次。If it is determined according to the inspection report that the block produced by the leader of the proposal group has been verified, and the inspection reports that have passed the conclusion are all valid, the block is included in the application chain ledger; The inspection report becomes effective after the application chain miner synchronizes to the base chain block information corresponding to the report generation round. The report generation round refers to the selection round in which the application chain miner who generated the inspection report is elected as a member of the verification group Times.
  39. 根据权利要求20所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method of claim 20, wherein the method further comprises:
    从所述应用链矿工同步到确定所述应用链待挖区块的提案组领导人的基链区块信息起的MaxRounds+Q个基链出块时间内,持续接收针对所述提案组领导人所出区的检验报告,并根据新接收到的检验报告维持或变更之前作出的所述提案组领导人所出区块验证通过的结论;From the time the miners of the application chain are synchronized to the base chain block information of the proposal group leader who determines the block to be mined in the application chain, MaxRounds+Q base chain block generation time, continue to receive the proposal group leader The inspection report of the exit zone, and maintain or change the previous conclusion that the leader of the proposal group has passed the verification based on the newly received inspection report;
    其中,所述应用链矿工至多允许包含所述应用链待挖区块在内的最近Q+1个高度的区块同时处于验证状态,Q取0或正整数。Wherein, the application chain miner allows at most the latest Q+1 blocks including the block to be mined in the application chain to be in the verification state at the same time, and Q takes 0 or a positive integer.
  40. 根据权利要求1所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method according to claim 1, wherein the method further comprises:
    在确定针对所述应用链账本中第一高度的应用链区块存在不同于旧提案组领导人的新提案组领导人时,判断所述新提案组领导人的优先级是否高于所述旧提案组领导人的优先级;When it is determined that there is a new proposal group leader different from the old proposal group leader for the application chain block with the highest height in the application chain ledger, it is determined whether the priority of the new proposal group leader is higher than the old proposal group leader. The priority of the leader of the proposal group;
    若所述新提案组领导人的优先级高于所述旧提案组领导人的优先级,则将所述应用链账本中位于当前主分支上的、由所述旧提案组领导人创建的所述第一高度的应用链区块切换为由所述新提案组领导人创建的所述第一高度的应用链区块。If the priority of the leader of the new proposal group is higher than the priority of the leader of the old proposal group, then the application chain ledger that is located on the current main branch and created by the old proposal group leader The application chain block of the first height is switched to the application chain block of the first height created by the leader of the new proposal group.
  41. 根据权利要求40所述的区块链记账方法,其特征在于,所述第一高度与所述应用链账本中的最大块高之差小于预设高度差。The blockchain accounting method of claim 40, wherein the difference between the first height and the maximum block height in the application chain ledger is less than a preset height difference.
  42. 根据权利要求40所述的区块链记账方法,其特征在于,确定针对所述应用链账本中第一高度的应用链区块存在不同于旧提案组领导人的新提案组领导人的方式包括以下至少一种:The blockchain accounting method according to claim 40, characterized in that it is determined that there is a new proposal group leader different from the old proposal group leader for the application chain block of the first height in the application chain ledger Including at least one of the following:
    在接收到其他应用链矿工广播的所述第一高度的应用链区块时,根据该区块中记录的提案候选信息或随该区块附带广播的提案候选信息,确定针对所述第一高度的应用链区块存在不同于旧提案组领导人的新提案组领导人;When receiving the application chain block of the first height broadcast by other application chain miners, according to the proposal candidate information recorded in the block or the proposal candidate information broadcasted with the block, it is determined that the first height is There is a new proposal group leader different from the old proposal group leader in the application chain block;
    根据同步到的所述基链区块信息确定针对所述第一高度的应用链区块存在不同于旧提案组领导人的新提案组领导人。According to the synchronized base chain block information, it is determined that there is a new proposal group leader different from the old proposal group leader for the application chain block of the first height.
  43. 根据权利要求40所述的区块链记账方法,其特征在于,在所述将所述应用链账本中位于当前主分支上的、由所述旧提案组领导人创建的所述第一高度的应用链区块切换为由所述新提案组领导人创建的所述第一高度的应用链区块之前,所述方法还包括:The blockchain accounting method according to claim 40, characterized in that, in the application chain ledger, the first height created by the leader of the old proposal group is located on the current main branch. Before the application chain block of is switched to the application chain block of the first height created by the leader of the new proposal group, the method further includes:
    接收其他应用链矿工广播的、由所述新提案组领导人创建的所述第一高度的应用链区块,或者,从本地缓存的应用链区块中查找由所述新提案组领导人创建的所述第一高度的应用链区块。Receive the first-level application chain block created by the leader of the new proposal group broadcasted by other application chain miners, or search locally cached application chain blocks created by the leader of the new proposal group The application chain block of the first height.
  44. 根据权利要求40-43中任一项所述的区块链记账方法,其特征在于,所述判断所述新提案组领导人的优先级是否高于所述旧提案组领导人的优先级,包括:The blockchain accounting method according to any one of claims 40-43, wherein the determining whether the priority of the leader of the new proposal group is higher than the priority of the leader of the old proposal group ,include:
    获取所述新提案领导人在被推选为提案组成员时使用的第二随机值,以及,所述旧提案领导人在被推选为提案组成员时使用的第二随机值;Acquiring the second random value used when the new proposal leader is selected as a member of the proposal group, and the second random value used when the old proposal leader is selected as a member of the proposal group;
    判断所述新提案领导人对应的第二随机值是否大于所述旧提案领导人对应的第二随机值;Judging whether the second random value corresponding to the new proposal leader is greater than the second random value corresponding to the old proposal leader;
    其中,若所述新提案领导人对应的第二随机值大于所述旧提案领导人对应的第二随机值,则确定所述新提案组领导人的优先级高于所述旧提案组领导人的优先级,否则,确定所述新提案组领导人的优先级不高于所述旧提案组领导人的优先级。Wherein, if the second random value corresponding to the new proposal leader is greater than the second random value corresponding to the old proposal leader, it is determined that the priority of the leader of the new proposal group is higher than the leader of the old proposal group Otherwise, it is determined that the priority of the leader of the new proposal group is not higher than the priority of the leader of the old proposal group.
  45. 一种区块链记账方法,其特征在于,应用于基链矿工,所述方法包括:A blockchain accounting method, characterized in that it is applied to base chain miners, and the method includes:
    根据应用链待挖区块的提案组成员发送的针对所述应用链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人;Electing the leader of the proposal group for the application chain to be mined block according to the mining request sent by the proposal group member of the application chain to be mined block;
    将保存有选举结果以及选举依据的基链区块纳入基链账本中。Incorporate the base chain block holding the election results and the basis of the election into the base chain ledger.
  46. 根据权利要求45所述的区块链记账方法,其特征在于,所述挖矿请求中包括提案候选信息,所述提案候选信息包括:The blockchain accounting method of claim 45, wherein the mining request includes proposal candidate information, and the proposal candidate information includes:
    应用链标识、并行链链号、应用链待挖区块的高度、确定提案组领导人的基链区块的高度、应用链矿工公钥以及第一可证明字串。Application chain identification, parallel chain chain number, height of the block to be mined in the application chain, height of the base chain block to determine the leader of the proposal group, public key of the application chain miner, and the first provable string.
  47. 根据权利要求46所述的区块链记账方法,其特征在于,在所述根据应用链待挖区块的提案组成员发送的针对所述应用链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人之前,所述方法还包括:The blockchain accounting method according to claim 46, wherein the mining request for the application chain to be mined block sent by the proposal group member according to the application chain to be mined block is the Before electing the leader of the proposal group for the block to be mined in the application chain, the method further includes:
    根据所述挖矿请求中的应用链标识确定该标识对应的应用链由所述基链提供算力支持;Determine, according to the application chain identifier in the mining request, that the application chain corresponding to the identifier is supported by the base chain with computing power;
    根据所述挖矿请求中的确定提案组领导人的基链区块的高度确定发送所述挖矿请求的应用链矿工被推选为提案组成员时依赖的第一选举字串,基于所述挖矿请求中的应用链矿工公钥、所述挖矿请求中的第一证明字串以及所述第一选举字串调用VRF算法中的验证函数,确定所述挖矿请求中的第一可证明字串未被伪造。According to the height of the base chain block that determines the leader of the proposal group in the mining request, it is determined that the application chain miner who sent the mining request is selected as the first election string that the proposal group member relies on, based on the mining The application chain miner's public key in the mining request, the first proof string in the mining request, and the first election string call the verification function in the VRF algorithm to determine the first provable in the mining request The string has not been forged.
  48. 根据权利要求46所述的区块链记账方法,其特征在于,在所述根据应用链待挖区块的提案组成员发送的针对所述应用链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人之前,所述方法还包括:The blockchain accounting method according to claim 46, wherein the mining request for the application chain to be mined block sent by the proposal group member according to the application chain to be mined block is the Before electing the leader of the proposal group for the block to be mined in the application chain, the method further includes:
    根据所述挖矿请求中的应用链标识、并行链链号以及应用链矿工公钥,利用哈希算法计算发送所述挖矿请求的提案组成员的矿工标识;According to the application chain identifier, the parallel chain chain number, and the application chain miner public key in the mining request, a hash algorithm is used to calculate the miner identifier of the proposal group member who sent the mining request;
    确定计算出的矿工标识不在所述基链针对所述应用链配置的黑名单中。It is determined that the calculated miner ID is not in the blacklist configured by the base chain for the application chain.
  49. 根据权利要求47所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method of claim 47, wherein the method further comprises:
    从所述基链中设置的管理节点获取授权及配置信息;其中,授权信息包括向所述管理节点进行过注册从而获得了所述基链的算力支持的应用链的信息,配置信息包括所述基链矿工所使用的预设参数。Obtain authorization and configuration information from the management node set in the base chain; wherein, the authorization information includes information about the application chain that has been registered with the management node to obtain the computing power support of the base chain, and the configuration information includes all The preset parameters used by the base chain miners are described.
  50. 根据权利要求49所述的区块链记账方法,其特征在于,所述从所述基链中设置的管理节点获取授权及配置信息,包括:The blockchain accounting method according to claim 49, wherein the obtaining authorization and configuration information from the management node set in the base chain comprises:
    在所述基链的难度调整周期开始时向所述基链中设置的管理节点查询本地保存的授权及配置信息是否是最新版本,若不是最新版本则从所述管理节点同步最新版本的授权及配置信息;其中,每隔预设数量的难度调整周期进行一次查询。At the beginning of the difficulty adjustment period of the base chain, the management node set in the base chain is inquired about whether the locally stored authorization and configuration information is the latest version. If it is not the latest version, the latest version of the authorization and configuration information will be synchronized from the management node. Configuration information; among them, a query is performed every preset number of difficulty adjustment cycles.
  51. 根据权利要求46所述的区块链记账方法,其特征在于,所述根据应用链待挖区块的提案组成员发送的针对所述应用链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人,包括:The blockchain accounting method according to claim 46, wherein the mining request for the application chain to be mined block sent according to the proposal group member of the application chain to be mined block is the application The leader of the proposal group for the block to be mined on the chain, including:
    根据基链账本中记录的、已经选出提案组领导人的应用链最高区块确定所述应用链待挖区块所在的新高度,并将其中包含的应用链待挖区块的高度与所述新高度一致的挖矿请求纳入针对所述新高度的待选举集合;Determine the new height of the application chain to be mined according to the highest block of the application chain recorded in the base chain ledger and the leader of the proposal group has been selected, and compare the height of the application chain to be mined block contained in it with the total The mining request consistent with the new height is included in the waiting set for the new height;
    若针对所述新高度的待选举集合中的请求个数不小于预设的最低矿工个数,则根据针对所述新高度的待选举集合中的每个挖矿请求中的第一可证明字串,确定所述应用链在所述新高度的区块的提案组领导人。If the number of requests in the set to be elected for the new height is not less than the preset minimum number of miners, then according to the first provable word in each mining request in the set to be elected for the new height String to determine the leader of the proposal group of the block at the new height of the application chain.
  52. 根据权利要求51所述的区块链记账方法,其特征在于,在所述根据基链账本中记录的、已经选出提案组领导人的应用链最高区块确定所述应用链待挖区块所在的新高度之后,所述方法还包括:The blockchain accounting method according to claim 51, characterized in that the highest block of the application chain recorded in the base chain ledger and the leader of the proposal group has been selected is used to determine the application chain to-be-mined area After the new height of the block, the method further includes:
    判断确定所述应用链待挖区块的提案组领导人的基链区块的高度与所述新高度之差是否大于预设的第一差值阈值;Judging whether the difference between the height of the base chain block of the leader of the proposal group of the block to be mined in the application chain and the new height is greater than a preset first difference threshold;
    若两个高度之差大于所述第一差值阈值,则标记所述应用链在所述新高度进行连续出块。If the difference between the two heights is greater than the first difference threshold, mark the application chain to continuously generate blocks at the new height.
  53. 根据权利要求52所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method according to claim 52, wherein the method further comprises:
    若两个高度之差大于预设的第二差值阈值,则拒绝为所述应用链继续提供算力支持;其中,所述第二差值阈值大于所述第一差值阈值。If the difference between the two heights is greater than the preset second difference threshold, refuse to continue to provide computing power support for the application chain; wherein the second difference threshold is greater than the first difference threshold.
  54. 根据权利要求51所述的区块链记账方法,其特征在于,所述根据针对所述新高度的待选举集合中的每个挖矿请求中的第一可证明字串,确定所述应用链在所述新高度的区块的提案组领导人,包括:The blockchain accounting method of claim 51, wherein the application is determined according to the first provable string in each mining request in the set to be elected for the new height The leader of the proposal group of the block with the chain at the new height, including:
    根据针对所述新高度的待选举集合中的每个挖矿请求中的第一可证明字串计算该挖矿请求对应的第二随机值,并将计算出的第二随机值满足预设的当选条件的挖矿请求对应的提案组成员确定为所述应用链在所述新高度的区块的提案组领导人。Calculate the second random value corresponding to the mining request according to the first provable string in each mining request in the set to be elected for the new height, and the calculated second random value meets the preset The proposal group member corresponding to the selected mining request is determined as the proposal group leader of the block of the application chain at the new height.
  55. 根据权利要求54所述的区块链记账方法,其特征在于,所述当选条件为计算出的第二随机值最大。The blockchain accounting method according to claim 54, characterized in that, the election condition is that the calculated second random value is the largest.
  56. 根据权利要求55所述的区块链记账方法,其特征在于,所述当选条件为计算出的第二随机值最大且所述第二随机值大于预设的最小当选随机值。The blockchain accounting method of claim 55, wherein the selection condition is that the calculated second random value is the largest and the second random value is greater than a preset minimum random value.
  57. 根据权利要求55所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method of claim 55, wherein the method further comprises:
    若所述应用链被配置为不允许同一矿工连续挖矿、且根据最大的第二随机值确定的提案组领导人在针对所述应用链的上一次提案组领导人选举中也被选为提案组领导人,则将计算出的第二随机值次大的挖矿请求对应的提案组成员确定为所述应用链在所述新高度的区块的提案组领导人。If the application chain is configured to disallow continuous mining by the same miner, and the proposal group leader determined according to the largest second random value is also selected as a proposal in the last proposal group leader election for the application chain The group leader determines the proposal group member corresponding to the mining request with the second largest random value calculated as the proposal group leader of the block of the application chain at the new height.
  58. 根据权利要求51或56所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method according to claim 51 or 56, wherein the method further comprises:
    若根据针对所述新高度的待选举集合中的挖矿请求选举所述新高度的区块的提案组领导人失败,则获取所述应用链中与所述应用链待挖区块相邻的且已经选出提案组领导人的区块所在的旧高度,并将其中包含的应用链待挖区块的高度与所述旧高度一致的挖矿请求纳入针对所述旧高度的待选举集合;If the leader of the proposal group that elects the block of the new height according to the mining request in the set of to-be-elected for the new height fails, obtain the block adjacent to the application chain to be mined in the application chain And the old height of the block of the leader of the proposal group has been selected, and the mining request whose height of the application chain to be mined block contained in it is consistent with the old height is included in the set to be elected for the old height;
    根据针对所述旧高度的待选举集合中的挖矿请求重新选举所述应用链在所述旧高度的区块的提案组领导人,若选举成功,则在所述基链本次所出区块中保存选举结果以及选举依据,若选举失败,则继续针对前一旧高度执行收集挖矿请求以及选举提案组领导人的重新挖矿操作,直至针对所述应用链的一旧高度选举提案组领导人成功或者针对所述应用链的旧高度的重新挖矿操作达到预设的次数限制;According to the mining request in the set to be elected for the old height, re-elect the leader of the proposal group of the application chain in the block of the old height. If the election is successful, then in the area where the base chain has exited this time The election result and election basis are stored in the block. If the election fails, continue to collect mining requests and elect the proposal group leader's re-mining operation for the previous old height, until the old height election proposal group for the application chain The leader succeeds or the re-mining operation for the old height of the application chain reaches the preset limit of times;
    若针对所述应用链的旧高度的重新挖矿操作已经达到预设的次数限制但仍未成功选出提案组领导人,则在基链下次出块时再针对所述应用链在所述新高度的区块选举提案组领导人。If the re-mining operation for the old height of the application chain has reached the preset number limit but the proposal group leader has not been successfully selected, the next time the base chain generates a block, the application chain will be re-mined in the A new level of block election proposal group leader.
  59. 根据权利要求51所述的区块链记账方法,其特征在于,所述选举结果包括从所述应用链的提案组领导人发送的挖矿请求中获取的提案候选信息;The blockchain accounting method according to claim 51, wherein the election result includes proposal candidate information obtained from a mining request sent by the leader of the proposal group of the application chain;
    所述选举结果作为选举结果列表中的一个表项保存在所述基链区块的区块体中,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的选举结果;The election result is stored in the block body of the base chain block as an entry in the election result list, and each entry in the election result list corresponds to a block to be mined on an application chain. Election result
    基于所述选举结果列表的表项计算出的merkle根保存在所述基链区块的区块头中。The merkle root calculated based on the entries of the election result list is stored in the block header of the base chain block.
  60. 根据权利要求51所述的区块链记账方法,其特征在于,所述选举结果包括所述提案组领导人的矿工标识以及所述应用链待挖区块的高度;The blockchain accounting method according to claim 51, wherein the election result includes the miner identification of the leader of the proposal group and the height of the block to be mined in the application chain;
    所述提案组领导人的矿工标识基于所述提案组领导人发送的挖矿请求中的应用链标识、并行链链号以及应用链矿工公钥,利用哈希算法进行计算,所述应用链待挖区块的高度复制自所述提案组领导人发送的挖矿请求中的对应信息项;The miner ID of the proposal group leader is calculated based on the application chain ID, the parallel chain chain number, and the application chain miner’s public key in the mining request sent by the proposal group leader, and the application chain is waiting The height of the mining block is copied from the corresponding information item in the mining request sent by the leader of the proposal group;
    所述选举结果作为选举结果列表中的一个表项保存在所述基链区块的区块体中,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的选举结果;The election result is stored in the block body of the base chain block as an entry in the election result list, and each entry in the election result list corresponds to a block to be mined on an application chain. Election result
    基于所述选举结果列表的表项计算出的merkle根保存在所述基链区块的区块头中。The merkle root calculated based on the entries of the election result list is stored in the block header of the base chain block.
  61. 根据权利要求59或60所述的区块链记账方法,其特征在于,所述选举依据包括从针对所述新高度的待选举集合中的挖矿请求中获取的提案候选信息的集合;The blockchain accounting method according to claim 59 or 60, wherein the election basis comprises a set of proposal candidate information obtained from mining requests in the set to be elected for the new height;
    所述选举依据作为选举依据列表中的一个表项保存在所述基链区块的区块体中,所述选举依据列表中的每个表项对应一条应用链上的一个待挖区块的选举依据;The election basis is stored in the block body of the base chain block as an entry in the election basis list, and each entry in the election basis list corresponds to a block to be mined on an application chain. Election basis
    基于所述选举依据列表的表项计算出的merkle根保存在所述基链区块的区块头中。The merkle root calculated based on the entries of the election basis list is stored in the block header of the base chain block.
  62. 根据权利要求61所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method according to claim 61, wherein the method further comprises:
    向所述基链中设置的同步节点发送所述基链区块;Sending the base chain block to a synchronization node set in the base chain;
    或者,向所述同步节点发送所述基链区块的区块头以及所述基链区块的区块体中的所述选举结果列表。Or, sending the block header of the base chain block and the election result list in the block body of the base chain block to the synchronization node.
  63. 根据权利要求61所述的区块链记账方法,其特征在于,在基链账本中区块按照如下方式保存:The blockchain accounting method according to claim 61, wherein the blocks in the base chain ledger are stored in the following manner:
    在所述基链的最近D个难度调整周期内生成的区块保存区块头以及区块体;其中,D为正整数;The blocks generated in the last D difficulty adjustment cycles of the base chain save the block header and the block body; where D is a positive integer;
    在所述基链的最近D个难度调整周期之前生成的区块保存区块头以及选举结果列表,若所述选举结果列表的表项中包含提案组领导人的矿工标识,则还要保存选举依据列表中由所述提案组领导人自身产生的提案候选信息。Blocks generated before the most recent D difficulty adjustment cycles of the base chain save the block header and the election result list. If the entry of the election result list contains the miner identification of the leader of the proposal group, the election basis shall also be saved Proposal candidate information generated by the leader of the proposal group in the list.
  64. 一种区块链记账方法,其特征在于,应用于基链中设置的同步节点,所述方法包括:A blockchain accounting method, characterized in that it is applied to a synchronization node set in a base chain, and the method includes:
    接收基链矿工发送的确定应用链待挖区块的提案组领导人的基链区块,或者,接收所述基链矿工或基链中设置的其他同步节点发送的所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;其中,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的提案组领导人的选举结果,包括所述应用链待挖区块的提案组领导人的选举结果;Receive the base chain block of the leader of the proposal group sent by the base chain miner to determine the block to be mined in the application chain, or receive the base chain block sent by the base chain miner or other synchronization nodes set in the base chain The block header and the election result list in the block body of the base chain block; wherein, each entry in the election result list corresponds to the election of the leader of the proposal group of a block to be mined on the application chain The result includes the election result of the leader of the proposal group of the block to be mined in the application chain;
    向应用链矿工发送来源于所述基链区块的基链区块信息,所述基链区块信息采用的形式包括以下之一:Send the base chain block information derived from the base chain block to the application chain miner, and the form of the base chain block information includes one of the following:
    所述基链区块本身;The base chain block itself;
    所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;The block header of the base chain block and the election result list in the block body of the base chain block;
    所述基链区块的区块头以及所述基链区块的区块体中针对所述应用链的片断数据;其中,所述片断数据包括所述选举结果列表中针对所述应用链待挖区块的提案组领导人的选举结果,以及,所述选举结果与所述基链区块的区块头中基于所述选举结果列表计算出的merkle根之间的merkle路径。The block header of the base chain block and the fragment data for the application chain in the block body of the base chain block; wherein the fragment data includes the list of election results for the application chain to be mined The election result of the leader of the proposal group of the block, and the merkle path between the election result and the merkle root calculated based on the election result list in the block header of the base chain block.
  65. 根据权利要求64所述的区块链记账方法,其特征在于,所述方法还包括:The blockchain accounting method according to claim 64, wherein the method further comprises:
    向基链中设置的其他同步节点发送所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表。Send the block header of the base chain block and the election result list in the block body of the base chain block to other synchronization nodes set in the base chain.
  66. 一种区块链记账装置,其特征在于,配置于应用链中设置的挖矿节点,所述装置包括:A blockchain accounting device, characterized in that it is configured on a mining node set in an application chain, and the device includes:
    提案组推选模块,用于应用链矿工参与应用链待挖区块的提案组成员的推选;其中,若确定所述应用链矿工被推选为应用链待挖区块的提案组成员,则向基链矿工发送针对所述应用链待挖区块的挖矿请求,所述提案组为有权发送挖矿请求的应用链矿工的集合;The proposal group selection module is used for application chain miners to participate in the selection of proposal group members of the application chain to be mined blocks; among them, if it is determined that the application chain miner is selected as the proposal group member of the application chain to be mined, then A chain miner sends a mining request for a block to be mined in the application chain, and the proposal group is a collection of application chain miners who have the right to send a mining request;
    区块信息同步模块,用于所述应用链矿工同步基链区块信息,并将所述基链区块信息纳入本地的基链账本中,所述基链区块信息来源于基链矿工根据所述挖矿请求生成的确定所述应用链待挖区块的提案组领导人的基链区块,所述基链区块信息中包括指示所述提案组领导人的选举结果;其中,所述提案组领导人为具有所述应用链待挖区块的出块权的提案组成员;The block information synchronization module is used for the application chain miners to synchronize the base chain block information and incorporate the base chain block information into the local base chain ledger. The base chain block information comes from the base chain miners according to The mining request generates the base chain block of the leader of the proposal group that determines the block to be mined in the application chain, and the base chain block information includes an election result indicating the leader of the proposal group; The leader of the proposal group is a member of the proposal group who has the right to produce blocks of the application chain to be mined;
    验证组推选模块,用于所述应用链矿工参与应用链待挖区块的验证组成员的推选;其中,若确定所述应用链矿工被推选为所述应用链待挖区块的验证组成员,则对所述提案组领导人所出区块进行验证,并向其他应用链矿工广播检验报告,所述验证组为有权生成检验报告的应用链矿工的集合,所述提案组领导人所出区块包括所述提案组领导人打包的所述应用链待挖区块;The verification group selection module is used for the application chain miners to participate in the selection of the verification group members of the application chain to be mined blocks; wherein, if it is determined that the application chain miners are selected as the verification group members of the application chain to be mined blocks , Verify the block produced by the leader of the proposal group, and broadcast the inspection report to other application chain miners. The verification group is a collection of application chain miners who have the right to generate inspection reports. The output block includes the block to be mined in the application chain packaged by the leader of the proposal group;
    应用链记账模块,用于所述应用链矿工接收所述检验报告,若根据所述检验报告确定所述提案组领导人所出区块验证通过,则将该区块纳入应用链账本中。The application chain accounting module is used for the application chain miner to receive the inspection report, and if it is determined according to the inspection report that the block produced by the proposal group leader is verified, the block is included in the application chain ledger.
  67. 一种区块链记账装置,其特征在于,配置于基链中设置的挖矿节点,所述装置包括:A blockchain accounting device, characterized in that it is configured on a mining node set in the base chain, and the device includes:
    选举模块,用于基链矿工根据应用链待挖区块的提案组成员发送的针对所述应用 链待挖区块的挖矿请求为所述应用链待挖区块选举提案组领导人;Election module, used for base chain miners to elect the leader of the proposal group for the application chain to be mined block according to the mining request sent by the proposal group members of the application chain to be mined block;
    基链记账模块,用于所述基链矿工将保存有选举结果以及选举依据的基链区块纳入基链账本中。The base chain accounting module is used for the base chain miners to incorporate the base chain block storing the election results and the election basis into the base chain ledger.
  68. 一种区块链记账装置,其特征在于,配置于基链中设置的同步节点,所述装置包括:A blockchain accounting device, characterized in that it is configured on a synchronization node set in a base chain, and the device includes:
    信息接收模块,用于所述同步节点接收基链矿工发送的确定应用链待挖区块的提案组领导人的基链区块,或者,接收所述基链矿工或基链中设置的其他同步节点发送的所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;其中,所述选举结果列表中的每个表项对应一条应用链上的一个待挖区块的提案组领导人的选举结果,包括所述应用链待挖区块的提案组领导人的选举结果;The information receiving module is used for the synchronization node to receive the base chain block sent by the base chain miner to determine the proposal group leader of the application chain to be mined block, or to receive the base chain miner or other synchronization set in the base chain The block header of the base chain block and the election result list in the block body of the base chain block sent by the node; wherein, each entry in the election result list corresponds to a waiting list on an application chain. The election result of the leader of the proposal group for mining the block, including the election result of the leader of the proposal group for the block to be mined in the application chain;
    信息发送模块,用于所述同步节点向应用链矿工发送来源于所述基链区块的基链区块信息,所述基链区块信息采用的形式包括以下之一:The information sending module is used for the synchronization node to send the base chain block information derived from the base chain block to the application chain miners, and the form of the base chain block information includes one of the following:
    所述基链区块本身;The base chain block itself;
    所述基链区块的区块头以及所述基链区块的区块体中的选举结果列表;The block header of the base chain block and the election result list in the block body of the base chain block;
    所述基链区块的区块头以及所述基链区块的区块体中针对所述应用链的片断数据;其中,所述片断数据包括所述选举结果列表中针对所述应用链待挖区块的提案组领导人的选举结果,以及,所述选举结果与所述基链区块的区块头中基于所述选举结果列表计算出的merkle根之间的merkle路径。The block header of the base chain block and the fragment data for the application chain in the block body of the base chain block; wherein the fragment data includes the list of election results for the application chain to be mined The election result of the leader of the proposal group of the block, and the merkle path between the election result and the merkle root calculated based on the election result list in the block header of the base chain block.
  69. 一种区块链节点,其特征在于,设置在应用链上,所述节点包括:存储器以及处理器,所述存储器中存储有计算机程序指令,所述计算机程序指令被所述处理器读取并运行时,执行如权利要求1-44中任一项所述的方法。A blockchain node, characterized in that it is set on an application chain, the node includes: a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are read and combined by the processor. When running, the method according to any one of claims 1-44 is executed.
  70. 一种区块链节点,其特征在于,设置在基链上,所述节点包括:存储器以及处理器,所述存储器中存储有计算机程序指令,所述计算机程序指令被所述处理器读取并运行时,执行如权利要求45-63中任一项所述的方法。A blockchain node, characterized in that it is set on a base chain, the node includes: a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are read and combined by the processor. At runtime, the method according to any one of claims 45-63 is executed.
  71. 一种区块链节点,其特征在于,设置在基链上,所述节点包括:存储器以及处理器,所述存储器中存储有计算机程序指令,所述计算机程序指令被所述处理器读取并运行时,执行如权利要求64或65所述的方法。A blockchain node, characterized in that it is set on a base chain, the node includes: a memory and a processor, and computer program instructions are stored in the memory, and the computer program instructions are read and combined by the processor. At runtime, the method according to claim 64 or 65 is executed.
  72. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序指令,所述计算机程序指令被计算机运行时,执行如权利要求1-65中任一项所述的方法。A computer-readable storage medium, characterized in that computer program instructions are stored on the computer-readable storage medium, and when the computer program instructions are run by a computer, the computer program instructions as described in any one of claims 1-65 are executed. method.
PCT/CN2020/136600 2019-12-31 2020-12-15 Blockchain accounting method and apparatus, node and storage medium WO2021135934A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911410444.1A CN111159297A (en) 2019-12-31 2019-12-31 Block chain accounting method, device, node and storage medium
CN201911410444.1 2019-12-31

Publications (1)

Publication Number Publication Date
WO2021135934A1 true WO2021135934A1 (en) 2021-07-08

Family

ID=70560001

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/136600 WO2021135934A1 (en) 2019-12-31 2020-12-15 Blockchain accounting method and apparatus, node and storage medium

Country Status (2)

Country Link
CN (1) CN111159297A (en)
WO (1) WO2021135934A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023043762A3 (en) * 2021-09-17 2023-04-20 The Regents Of The University Of California Collaborative transaction notarization in a byzantine computing environment

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111159297A (en) * 2019-12-31 2020-05-15 深圳市红砖坊技术有限公司 Block chain accounting method, device, node and storage medium
CN112968964A (en) * 2021-02-24 2021-06-15 曲阜师范大学 Intelligent bribery selfish mining attack algorithm for Ethernet workshop network
CN112948853A (en) * 2021-02-26 2021-06-11 安徽航天信息科技有限公司 Block chain-based medical data sharing method, device, equipment and storage medium
CN113157693B (en) * 2021-03-21 2023-05-19 贵州大学 Block chain storage optimization scheme for digital currency
US20230325813A1 (en) * 2022-03-28 2023-10-12 Daniel Joseph Lutz System and Method for Mining Crypto-Coins
CN113111392B (en) * 2021-04-12 2022-08-30 浙江永旗区块链科技有限公司 Block chain data synchronization system and control method thereof

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107171812A (en) * 2017-07-18 2017-09-15 光载无限(北京)科技有限公司 It is a kind of based on block chain without key signature infrastructure construction method
CN108074081A (en) * 2017-12-08 2018-05-25 上海策赢网络科技有限公司 The transfer method and device of a kind of virtual resource
CN108416593A (en) * 2018-03-20 2018-08-17 杨鉴 A kind of block chain common recognition method and system proved based on network dispersion degree
US20180300694A1 (en) * 2018-05-14 2018-10-18 Beijing Good Fortune Innovative Intelligence Technology Co.Ltd Method for intelligently selecting accounting node of blockchain
CN111159297A (en) * 2019-12-31 2020-05-15 深圳市红砖坊技术有限公司 Block chain accounting method, device, node and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107171812A (en) * 2017-07-18 2017-09-15 光载无限(北京)科技有限公司 It is a kind of based on block chain without key signature infrastructure construction method
CN108074081A (en) * 2017-12-08 2018-05-25 上海策赢网络科技有限公司 The transfer method and device of a kind of virtual resource
CN108416593A (en) * 2018-03-20 2018-08-17 杨鉴 A kind of block chain common recognition method and system proved based on network dispersion degree
US20180300694A1 (en) * 2018-05-14 2018-10-18 Beijing Good Fortune Innovative Intelligence Technology Co.Ltd Method for intelligently selecting accounting node of blockchain
CN111159297A (en) * 2019-12-31 2020-05-15 深圳市红砖坊技术有限公司 Block chain accounting method, device, node and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023043762A3 (en) * 2021-09-17 2023-04-20 The Regents Of The University Of California Collaborative transaction notarization in a byzantine computing environment

Also Published As

Publication number Publication date
CN111159297A (en) 2020-05-15

Similar Documents

Publication Publication Date Title
WO2021135934A1 (en) Blockchain accounting method and apparatus, node and storage medium
Li et al. Proof of vote: A high-performance consensus protocol based on vote mechanism & consortium blockchain
Yu et al. Repucoin: Your reputation is your power
US11907174B2 (en) Systems and methods for managing data generation, storage, and verification in a distributed system having a committee of validator nodes
Abraham et al. Solida: A blockchain protocol based on reconfigurable byzantine consensus
EP3399448B1 (en) Methods and apparatus for a distributed database within a network
CN111131209B (en) Improved efficient consensus method, system, computer device and storage medium
Pass et al. Hybrid consensus: Efficient consensus in the permissionless model
CN112541758A (en) Multi-round voting type fault-tolerant sequencing consensus mechanism and method based on block chain
CN110945548A (en) Computer-implemented system and method for managing large distributed storage pools in a blockchain network
CN113853578A (en) Method for generating random numbers in a blockchain intelligent contract
US20220158836A1 (en) Fork Processing Method And Blockchain Node
WO2021204181A1 (en) Method and device for preventing forking of blockchain
EP3659060B1 (en) Consensus protocol for permissioned ledgers
CN109347877B (en) Block chain structure storage controlling method
CN109685505A (en) Byzantine failure tolerance common recognition optimization method based on association ring signatures
CN114556864A (en) Method and device for safety symbiotic excavation
Yu et al. Low powered blockchain consensus protocols based on consistent hash
Lerner Decor+ hop: A scalable blockchain protocol
Zhang et al. FortunChain: EC-VRF-based scalable blockchain system for realizing state sharding
Yuan et al. AME Blockchain: An Architecture Design for Closed-Loop Fluid Economy Token System
Han Scaling permissionless blockchains via sharding
RU2776826C2 (en) Methods and device for a distributed database that makes it possible to delete events
Battagliola et al. Quadrans Blockchain
Xu et al. Frustum: achieving high throughput in blockchain systems through hierarchical and pipelined sharding

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20910525

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 291122)