Skip to content

Fix: dpos doc and sr doc #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions docs/mechanism-algorithm/dpos.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Blockchain is a distributed accounting system. In a blockchain system, there can

There are several types of consensus, and the most commonly used are POW, POS, and DPoS. Definitely, different blockchain systems will have a unique way of implementation. This article will mainly introduce the DPoS consensus on which TRON based. We will also explain the basic components and mechanisms of DPoS.

The role of consensus is to select the SR(Super Representatives) in the blockchain system. The SR(Super Representatives) verify the transaction data and keep the account in order to broadcast new accounts to other nodes in the network and obtains the approval of the new accounts from other nodes. As a specific implementation of consensus, DPoS works in the following way:
The role of consensus is to select SRs(Super Representatives) in the blockchain system. SRs(Super Representatives) verify the transaction data and keep it in a leger, then broadcast the leger to other nodes in the network and obtain the approval of the leger from other nodes. As a specific implementation of consensus, DPoS works in the following way:

The DPoS consensus selects some nodes as SR(Super Representatives) in the blockchain system based on the number of votes they receive. First, when the blockchain system starts to operate, a certain number of tokens will be issued, and then the tokens will be given to nodes in the blockchain system. A node can apply to be a super representative candidate in the blockchain system with a portion of the tokens. Any token-holding node in the blockchain system can vote for these candidates. Every t period of time, the votes for all the candidates will be counted. Top N candidate nodes with the most votes will become SR(Super Representatives) for the next t period. After t period of time, the votes will be counted again to elect the new SR(Super Representatives), and the cycle continues.
The DPoS consensus selects some nodes as SRs(Super Representatives) in the blockchain system based on the number of votes they obtain. First, when the blockchain system starts to operate, a certain number of tokens will be issued, and then the tokens will be given to nodes in the blockchain system. A node can apply to be a super representative candidate in the blockchain system with a portion of the tokens. Any token-holding node in the blockchain system can vote for these candidates. Every t period of time, the votes for all the candidates will be counted. Top N candidate nodes with the most votes will become SR(Super Representatives) for the next t period. After t period of time, the votes will be counted again to elect the new SR(Super Representatives), and the cycle continues.

Let's see how it's realized in the context of TRON:
Let's see how it's implemented in the context of TRON:

## Definition
- TRON: refers to the TRON network. The document does not distinguish between TRON, TRON blockchain, TRON blockchain system, etc.
Expand All @@ -24,7 +24,7 @@ Let's see how it's realized in the context of TRON:

- Bookkeeping order: block generation order. The descending order of the 27 super representatives based on the number of votes they receive.

- Slot: In TRON, every three seconds is regarded as one slot. Under normal circumstances, each SR will produce a block within the corresponding slot time. Therefore, the average block interval of TRON is approximately three seconds. If an SR fails to produce a block for some reasons, the corresponding slot will be vacant and the next SR will produce a block in the following slot. During the maintenance period, block production will skip two slots.
- Slot: In TRON, every 3 seconds is regarded as one slot. Under normal circumstances, each SR will produce a block within the corresponding slot time. Therefore, the average block interval of TRON is approximately 3 seconds. If an SR fails to produce a block for some reasons, the corresponding slot will be vacant and the next SR will produce a block in the following slot. During the maintenance period, block production will skip two slots.

- Epoch: TRON sets an Epoch to be 6 hours. The last 2 block time of an Epoch is the maintenance period, during which block generating order for the next Epoch will be decided.

Expand All @@ -36,7 +36,7 @@ Let's see how it's realized in the context of TRON:
## Block Production Process
The SR(Super Representatives) of the blockchain network collect the newly generated transactions in the blockchain network and verify the legality of these transactions, then package the transactions in a block, record them as a new page on the ledger, and broadcast the page to the entire blockchain network. Other nodes will receive the new page and verify the legality of the transaction data on the page and add it to their own ledger. The SR(Super Representatives) will repeat this process so all new transaction data in the blockchain system can be recorded in the ledger.

## SR Election mechanism
## SR Election Mechanism
- Vote

In TRON, 1 TRX equals 1 vote.
Expand All @@ -49,7 +49,7 @@ In TRON, voting for candidates is a special transaction. Nodes can vote for cand

During each maintenance period, the votes for candidates will be counted. The top 27 candidates with the most votes will be the super representatives for the next Epoch.

## Block generation mechanism
## Block Generation Mechanism
During each Epoch, the 27 super representatives will take turns to generate blocks according to the bookkeeping order. Each super representative can only generate blocks when it is their turn. Super representatives package the data of multiple verified transactions into each block. The hash of the previous block will be included in each new block as the parentHash. The super representative will sign the data of this block with his/her private key and fill in witness_signature, along with the address of the super representative, the block height, and the time that block is generated, etc.

Through storing the hash of the previous block, blocks are logically connected. Eventually, they form a chain. A typical blockchain structure is shown in the following picture:
Expand All @@ -68,23 +68,20 @@ In ideal circumstances, the bookkeeping process in a DPoS consensus-based blockc

As mentioned above, the basis for the blockchain system to operate normally is that most of the nodes in the system are honest and reliable. Furthermore, the primary guarantee for the security of the blockchain system is the security of the ledger, meaning that illegal data cannot be written into the ledger maliciously and ledger copies saved on each node should be consistent as well. Based on the DPoS consensus, the bookkeeping process is carried out by super representatives. Therefore, the safety of TRON depends on the reliability of the majority of the super representatives. TRON has put confirmed blocks in the system which are irreversible. At the same time, in order to resist the malicious behaviors of a small number of super representatives nodes, TRON recognizes the longest chain as the main chain based on "the longest chain principle".

### The confirmed block principle
The newly produced blocks are in unconfirmed state, and only those blocks that are "approved" by more than 2/3 of the 27 super representatives(27 * 2/3 = 18, i.e., a minimum of 19) are considered to be irreversible blocks, commonly referred to as solidified blocks, and the transactions contained in the solidified blocks have been confirmed by the entire blockchain network. The way to "approve" the unconfirmed state block is that the SR producing subsequent blocks after it, as shown in Figure d, the SR C produces block 103, the SR E produces 104' on the basis of block 103, the block 105', 106', and 107' produced respectively by the SR G, A and B, are also subsequent blocks of the 103rd block, which means these four blocks approve the 103rd block. It can be seen that when the block of height 121 is produced, the 103rd block becomes a solidified block, since by this time the 103rd block has 19 subsequent blocks, and the point to be emphasized here is that the super representatives producing these 19 blocks must be different from each other and from the super representatives producing the 103rd block.
### The Confirmed Block Principle
The newly produced blocks are in unconfirmed state, and only those blocks that are "approved" by at least 70% of the 27 super representatives(i.e. 27 * 70% = 19, rounded up)) are considered to be irreversible blocks, commonly referred to as solidified blocks, and the transactions contained in the solidified blocks have been confirmed by the entire blockchain network. The way to "approve" the unconfirmed state block is that the SR producing subsequent blocks after it, as shown in Figure d, the SR C produces block 103, the SR E produces 104' on the basis of block 103, the block 105', 106', and 107' produced respectively by the SR G, A and B, are also subsequent blocks of the 103rd block, which means these four blocks approve the 103rd block. It can be seen that when the block of height 121 is produced, the 103rd block becomes a solidified block, since by this time the 103rd block has 19 subsequent blocks, and the point to be emphasized here is that the super representatives producing these 19 blocks must be different from each other and from the super representatives producing the 103rd block.

### The longest chain principle
### The Longest Chain Principle
When a fork occurs, an honest super representative would always choose to produce blocks on the longest chain.

## Incentive model
## Incentive Model

To ensure the safe and efficient operation of the blockchain system, TRON sets up an incentive model to encourage more nodes to join the network, thereby expanding the scale of the network. Every time a block is generated by the TRON network, a block reward of 16 TRX will be awarded to the super representative who produced the block, and a voting reward of 160 TRX will be awarded to all super representatives and super partners (super representative candidates who ranking 28th~ 127th are also called super partners), and they share the voting rewards proportionally according to the number of votes they get. At the same time, super representatives and partners will also deduct the rewards according to their commission ratio, and distribute the remaining part to voters according to the voter voting ratio.

## Proposal-based parameter adjustment
## Proposal-based Parameter Adjustment
An important characteristic of DPoS is that any parameter adjustment can be proposed on the chain, and super representatives will decide whether to approve the proposal by starting a vote. The advantage of this method is that it avoids hard fork upgrades when adding new features. For the current dynamic parameters and values ​​of the TRON network, as well as past proposals, please refer to [here](https://tronscan.org/#/sr/committee).


## Reference Documentations

- [Delegated Proof of Stake (DPoS) – Total Beginners Guide](https://www.coinbureau.com/education/delegated-proof-stake-dpos/)
- [Consensus Algorithms: Proof-of-Stake & Cryptoeconomics](https://www.nichanank.com/blog/2018/6/4/consensus-algorithms-pos-dpos)
- [Role of Delegates](http://docs.bitshares.org/en/master/technology/dpos.html#role-of-delegates)
- [What is Delegated Proof of Stake?](https://hackernoon.com/what-is-delegated-proof-of-stake-897a2f0558f9)
- [The Basics of TRON’s DPoS Consensus Algorithm](https://medium.com/tronnetwork/the-basics-of-trons-dpos-consensus-algorithm-db12c52f1e03)
46 changes: 27 additions & 19 deletions docs/mechanism-algorithm/sr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The votes will be counted every 6 hours, so super representatives and super repr

## Super Representative Election

To vote, you need to have TRON Power(TP). To get TRON Power, you need to stake TRX. Every 1 staked TRX accounts for one TRON Power(TP). Every account in TRON network has the right to vote for a super representative candidate. After you unstake your staked TRX, you will lose the responding TRON Power(TP), so your previous vote will be invalid.
To vote, you need to have TRON Power(TP). To get TRON Power, you need to stake TRX. Every 1 staked TRX accounts for one TRON Power(TP). Every account in TRON network has the right to vote for a super representative candidate. After you unstake your staked TRX, you will lose the corresponding TRON Power(TP), so your previous vote will be invalid.

Note: Only your latest vote will be counted in TRON network which means your previous vote will be over written by your latest vote.

Expand All @@ -28,47 +28,55 @@ The final output above is: Vote 3 votes for SR1, 7 votes for SR2.

The default ratio is 20%. Super representatives and super representative partners can query the brokerage ratio through the `wallet/getBrokerage` interface, and can also modify the brokerage ratio through the `wallet/updateBrokerage` interface.

If a SR(Super Representatives) get 20% of the reward, and the other 80% will be awarded to the voters. If the brokerage ratio is set to 100%, the rewards are all obtained by the SR; if set to 0, the rewards are all sent to the voters.
If a SR(Super Representatives) get 20% of the rewards, and the other 80% will be awarded to the voters. If the brokerage ratio is set to 100%, the rewards are all obtained by the SR; if set to 0, the rewards are all sent to the voters.

## Reward for SR(Super Representatives)
## Rewards for SR(Super Representatives)
The following calculations are all based on the situation where brokerage ratio is equal to 20%.

### Votes Reward
### Vote Rewards

Vote rewards are 160 TRX every block, with a block generated every 3 seconds, the total vote rewards per day is 4,608,000 TRX.
Vote rewards are 160 TRX for every block, with a block generated every 3 seconds, the total vote rewards per day is 4,608,000 TRX.

For each SR and Partner, the daily Vote Rewards = 4,608,000 * ( votes / total votes) x 20% TRX
For each SR and Partner, the daily vote rewards = 4,608,000 * ( votes / total votes) x 20% TRX

### Block Producing Reward
### Block Producing Rewards

Every time after a super representative produces a block, it will be reward 16 TRX. The 27 super representatives take turns to produce blocks every 3 seconds. The annual block producing reward is 168,192,000 TRX in total.
Every time after a super representative produces a block, it will be rewarded 16 TRX. The 27 super representatives take turns to produce blocks every 3 seconds. The annual block producing rewards is 168,192,000 TRX in total.

Every time after a super representative produces a block, the 16 TRX block producing reward will be sent to it's sub-account. The sub-account is a read-only account, it allows a withdraw action from sub-account to super representative account every 24 hours.
Every time after a super representative produces a block, the 16 TRX block producing rewards will be sent to it's sub-account. The sub-account is a read-only account, it allows a withdraw action from sub-account to super representative account every 24 hours.

$16 (\mathsf{TRX}/block) \times 28,800 (blocks/day) = 460,800 (\mathsf{TRX}/day)$
The daily total block producing rewards = 16 (TRX/block) * 28,800 (blocks/day) = 460,800 (TRX/day)

For each super representative, the daily block $Rewards_{sr} = (460,800 / 27) \times 20 \% \mathsf{TRX}$.
For each super representative, the daily block producing rewards = (460,800 / 27) * 20%TRX.

Reward may be less than the theoretical number due to missed blocks and maintenance period.

## Reward for Voters
Rewards may be less than the theoretical number due to missed blocks and maintenance period.

If you vote for a SR(Super Representative):
## Rewards for Voter

the daily Voter Rewards = (((the number of votes you vote to a SR) * 4,608,000 / total votes) * 80%) + ((460,800 / 27) * 80%) * (the number of votes you vote to a SR) / (the total number of votes a SR receives) TRX
If you vote for a SR(Super Representative), you will have both vote rewards and block producing rewards:

If you vote for a Partner:
vote rewards = ((the number of votes you vote to a SR / total votes) * 4,608,000 * 80%) TRX

the daily Voter Rewards = (((the number of votes you vote to a SR) * 4,608,000 / total votes) * 80%) TRX
block producing rewards = ((the number of votes you vote to a SR) / (the total number of votes a SR receives) * ((460,800 / 27) * 80%)) TRX

daily rewards for voter = vote rewards + block producing rewards

If you vote for a SR Partner, you will only have vote rewards:

daily rewards for voter = (((the number of votes you vote to a SR Partner) * 4,608,000 / total votes) * 80%) TRX

**Notice:** the above **total votes** refers to the combined votes of SRs and SR Partners, not including SR Candidates

## Committee

### What is Committee

Committee can modify the TRON network parameters, like transacton fees, block producing reward amount, etc. Committee is composed of the current 27 super representatives. Every super representative has the right to start a proposal. The proposal will be passed after it gets more than 18 approves from the super representatives and will become valid in the next maintenance period.
Committee can modify the TRON network parameters, like transacton fees, block producing reward amount, etc. Committee is composed of the current 27 super representatives. Every SR has the right to create and vote a proposal. The proposal will be passed after it gets at least 18 approves from the super representatives and will become valid in the next maintenance period.

### Create a Proposal

Only SRs, Partners and Candidates can create a proposal.
In addition to SR, SR Partner and SR Candidate also have the right to create a proposal, and only they have this right.

Please refer to [here](https://tronscan.org/#/sr/committee) for TRON network dynamic parameters and their values.

Expand Down
2 changes: 1 addition & 1 deletion docs/using_javatron/installing_javatron.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

java-tron nodes support to be deployed on `Linux` or `MacOS` operating systems, and rely on `Oracle JDK 1.8`, other versions of JDK are not supported.

The minimum hardware configuration required to run a java-tron node is `8-core CPU`, `16G memory`, `2T SDD`, the recommended configuration is: `16-core CPU`, `32G memory`, `2.5T+ SDD`. The fullnode running by super representative to produce block recommends `32-core CPU` and `64G memory`.
The minimum hardware configuration required to run a java-tron node is `8-core CPU`, `16G memory`, `3T SDD`, the recommended configuration is: `16-core CPU`, `32G memory`, `3.5T+ SDD`. The fullnode running by super representative to produce block recommends `32-core CPU` and `64G memory`.


## Compile the Source Code
Expand Down