Consensus Mechanisms
Last updated
Last updated
aelf delegates production nodes. starts with 8 and increases by 1 every year. These nodes in the aelf system enforce all of consensus rules of aelf.
The purpose of these delegated production nodes is to enable transaction relay, transaction confirmation, packaging blocks and data transfer. As aelf adopts multi-SideChain architecture, production nodes have to work as miners for some SideChains.
The nodes will go through a randomized order calculation each week. The randomization process is illustrated as follows:
aelf is running along the timeline within processing units we call a “round” (horizontal arrow in and ). In a round, one production node will produce one block each time, while one node will have one extra transaction at the end of the round (vertical arrow in Fig 7.1).
Each production node () has three main properties in a specific round ():
Private Key (): a value inputted from the production node and kept privately by the production node itself in round . It will become public after all block generations in round are completed.
Public Key (): the hash value of . Every node in the aelf network can look up this value at any time.
Signature (): a value generated by the production node itself in the first round. After the first round, it can only be calculated once the previous round is completed. It is used as the signature of this production node in this round and it is also opened to public at all times like the .
There are two main processes in DPoS: (1) Pre-verification; and (2) order calculation within each round.
Before a node starts its block generation in round , it has to have its status verified in round . In round , is already published as public, and can be queried at any time. So to verify the status of in round , other nodes can check .
Figure 7.0. Pre-verification
In Fig 7.1, we used 4 production nodes as an example to explain our order calculation strategy. In each round , production nodes have block generation. In the first round (Round 1 in Fig 7.1), the ordering of block generations as well as the signature for each node are totally arbitrary. In the second round (Round 2 in Fig 7.1), the block generations are again arbitrarily ordered.
However, from the second round, the signature will be calculated by
where here, means the node is processing the transaction in round . From round 3, the ordering within a round is generated from the ordering and the node signature from the previous round. In round we traverse the signature of nodes at round in order. The ordering of a node in is calculated by
For cases of conflict, i.e. results pointed to places which are not empty, we point the node to the next available place. If the node conflict is at the place, we will find the available place from the first place.
Figure 7.1. Order Calculation Details for First Three Rounds
The node that processes the one extra transaction is calculated from the signature of the node in first place of the previous round.
is decided by: (1) all the signatures from previous round ; (1) the value of itself in round ; (3) which node generate the extra block. So it can only be calculated after the previous round completed. Moreover, as it needs all the signatures from the previous round and the value is input by each node independently, there is no way to control the ordering. The extra block generation is used to increase the randomness. In general, we create a random system that relies on extra inputs from outside. Based on the assumption that no node can know all other nodes’ inputs in a specific round, no one node could control the ordering.
If one node cannot generate a block in round , it also cannot input its for this round. In such a case, the previous will be used. Since all production nodes are voted to be reliable nodes, such a situation should not happen often. Even if this situation does happen, the above-mentioned strategy is more than sufficient at dealing with it.
Every node only has a certain time seconds to process transactions. Under the present network condition, is a reasonable time consideration, meaning that every node only has 4 seconds to process transactions and submit the result to the network. Any delegate who fails to submit within 4 seconds is considered to be abandoning the block. If a delegate failed two times consecutively, there will be a window period calculated as hours (, stands for the number of failure) for that node.
In the systematic design, aelf defines that only one node generates blocks within a certain period. Therefore, it is unlikely for a fork to happen in an environment where production nodes are working under good connectivity. If multiple orphan node groups occur due to network problems, the system will adopt the longest chain since that is the chain that most likely comes from the orphan node group with largest number of production nodes. If a malicious node mines in two forked Blockchains simultaneously to attack the network, that node would be voted out of the entire network.
DPoS production nodes are elected in a way that resembles representative democracy. The elected nodes decide how to hand out bonuses to the other production nodes and stakeholders.