Skip to content

HPB Consensus Algorithm Election Mechanism

BlockGeek edited this page Apr 24, 2019 · 2 revisions

Introduction

In order to meet the requirements of BOE technology and improve security TPS as much as possible, HPB consensus algorithm adopts an efficient double-tier election mechanism, namely, outer election and inner election.

Outer Election: Selected by all users with BOE board. The period is 3 months and is selected by voting through HPB wallet.

Inner Election: The node contribution value evaluation index is used to select high contribution value node members among a great number of candidate nodes. Based on the Hash queue disclosed ballot mechanism, every time the block is generated, the priority of the high contribution node generation block is calculated, and high contribution nodes with higher priority has the priority to generate blocks.

In the design of consensus algorithm, the light message exchange mechanism of HPB consensus algorithm is more efficient in consensus than other consensus algorithms. It also made great improvement in security and privacy.

Outer Election

Since BOE board application has already considered other factors other than the amount of money held by the user, the outer election in the wallet voting nodes mainly consider such factors as the amount of money held and user recognition. The higher user recognition is, the more likely users would vote, otherwise it votes get fewer.

Note 1: If there are more users with BOE, there will be a certain number of users losing in outer voting. Alsorans can still gain access to the network, but are not regarded as candidate nodes or high performance nodes, neither will they receive rewards.

Inner Election

This article focuses on inner elections. The implementation and key factors of the inner election is described in detail.

The election consists of two parts, the first is voting node, the second is result declaration.

Key factors

The inner election phase occurs at a specific stage in the network operation, and each time a certain number of blocks at intervals are selected for election. They are ranked by key factors and excellent nodes are selected for voting.

Node bandwidth: During the node operation, the nodes will periodically test the bandwidth data with other nodes and saves them in the nodes for consensus to use. The bandwidth data of nodes is recorded in the block.

Amount of currency held by users: The amount of currency held by users when voting.

Number of vote: The number of vote user nodes receive in the outer election.

Voting rules

According to the node data obtained by the outer election, optimal nodes are selected and voted according to the weighted average of key factor ranking. In order to ensure the number of election result, randomization is used in the voting process. Instead of choosing optimal selection among all the outer election collection, a specific number of collections are randomly selected and then optimal nodes are voted in it. This is to ensure that the number of election results reaches a stable value, maintain network stability and eliminate nodes with low ranking.

Result declaration

When the basic data of the voting is available, the result declaration is carried out at a specific stage. All nodes declare result by reading block in this stage, and all the voting data in the block are extracted for statistics. The voting data will be written to voteIndex in voting.

Result declaration rule

All nodes with votes are regarded as a collection, from which a specific number of nodes are selected as high-performance nodes in the next round. Therefore, it is necessary to rank the nodes in the collection based on the mean value of voteIndex.

Final

In Note 2, you can see several fields that are closely related to the secondary text, namely candAddress, miner, and voteIndex.

Miner: The node that generates the block. candAddress is determined by miner based on three key factors in inner election. voteIndex is the weighted result value of factors corresponding to candAddress.

There is verification mechanism covering all nodes from voting to resulting declaration to ensure that node cannot make false voting and declaration. If voting is counterfeited, the block will be rejected by other nodes; if the result declaration is counterfeited, it will be kicked out of the network by other nodes.

Note 2: Part of the block.

{
**candAddress: “0x4a8111ecec1f9150d366ae319d0585303085748f”**,
comdAddress: “0x4a8111ecec1f9150d366ae319d0585303085748f”,
difficulty: 2,
extraData: “0x00000000000…”,
gasLimit: 100000000,
gasUsed: 0,
hardwareRandom: “0x2bce19ff44fbf1b05edfb93fcb7c7d3ab04c50fd7dc947e2fce65d66493d0dff”,
hash: “0x1fceb9c0d5a822fdddaa72bb9378f5ce24cd168b0281082a83d8f3a00c62d79a”,
logsBloom: “0x00000000000…”,
**miner: “0x4a8111ecec1f9150d366ae319d0585303085748f”**,
mixHash: “0x0000000000000000000000000000000000000000000000000000000000000000”,
nonce: “0x0000000000000000”,
number: 100,
parentHash: “0xab7299002317fecbfdd835b28bacb470e24a7933b41102f75cb76491957baa98”,
receiptsRoot: “0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421”,
sha3Uncles: “0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347”,
size: 683,
stateRoot: “0xc46fc99654813b2f92e9be58f7e69957499fa2c9b1c0ac31d1da86679f3b9a62”,
timestamp: 1541416798,
totalDifficulty: 201,
transactions: [],
transactionsRoot: “0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421”,
uncles: [],
**voteIndex: "0x0"**
}

The specific voting mechanism may be adjusted according to the latest requirements, please refer to the latest code

Clone this wiki locally