Skip to content
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

Proposal: Enable new reward calculation algorithm #496

Closed
bladehan1 opened this issue Jan 3, 2023 · 8 comments
Closed

Proposal: Enable new reward calculation algorithm #496

bladehan1 opened this issue Jan 3, 2023 · 8 comments

Comments

@bladehan1
Copy link
Contributor

bladehan1 commented Jan 3, 2023

Simple Summary

This proposal aims to activate the #67 network parameter to use a new reward calculation algorithm, speed up the execution of reward calculations related transactions, and improve the performance of the TRON network, for the new reward calculation algorithm, please refer to: TIP-465.

Motivation

The current reward algorithm time complexity is O (maintenance period * vote witness number), which increases linearly with the number of maintenance period rounds. As a result, it sometimes takes more than 1s to extract rewards-related transactions, which reduces the transaction volume of production blocks. The above problems can be resolved by recording the accumulated reward per ticket of each witness in the maintenance period, simplifying the cross-cycle calculation, and reducing the time complexity to O (number of vote witnesses).

Timeline

Any opinions or discussions about this proposal are welcomed.

The estimated timeline

  • Creation time of the voting request: January 17, 2023
  • The effective time of voting request: January 20, 2023

How to Initialize the Voting Request

  • Open the new reward calculation algorithm proposal.
    • createProposal 67 1

Performance Analyze

In order to quickly calculate the multi-maintenance period rewards, the cumulative per-ticket rewards are introduced to record the accumulated rewards per ticket during a maintenance period. The reward per ticket during the current maintenance period equals the witness reward during the maintenance period divided by the number of tickets, and the cumulative reward per ticket is the prefix sum of the reward per ticket during the maintenance period.

The interval per-ticket reward equals the sum of per-ticket rewards at the end of the maintenance period minus the sum of per-ticket rewards at the start of the maintenance period. The reward for a per witness equals the interval per ticket reward multiplied by the number of votes, so the calculation complexity of the reward is O (the number of voting witnesses).

@crayfishbang
Copy link

100% agree!

@txoh1603
Copy link

txoh1603 commented Jan 6, 2023

It is also helpful for explorer and DAPPs which provide stake and voting function. they need to query the voting reward more frequently, and this high efficient algorithm help to improve these product's performance.

@Jackmrshen
Copy link

With the increase of voters on TRON and the implementation of Stake 2.0, the calculation of workload during maintenance period is heavy. Optimization of algorithm is necessary to keep the maintenance period stable. Please go ahead and check more minor problems brought by Stake 2.0 to fix in advance.

@jernganl
Copy link

jernganl commented Jan 6, 2023

The new algorithm reduces the maintenance time, which is a great idea.

@Bellgin
Copy link

Bellgin commented Jan 6, 2023

It sometimes takes several secs to get it through when claiming my rewards, I was expecting failed transaction somehow. Hope this new method will help and make it fast and stable.

@SevenPie-R58zz
Copy link

So excited about the potential of reducing time complexity, can't wait to see how this will speed up the reward related transaction.

@ethan1844
Copy link
Collaborator

Thanks to everyone's contribution to this proposal.

This issue will be closed as it is already going to effect, check detail at: https://tronscan.org/#/proposal/82

@bladehan1
Copy link
Contributor Author

At present, this proposal has been effective for 10 days, comparison of average execution time of unstake related transaction before and after the proposal is shown as follows:

The Number of Maintenance Periods Average Execution Time Before the Proposal Takes Effect Average Execution Time After the Proposal Takes Effect
1000 1 - 1000 ms 0.08 ms
3000 1000 - 5000 ms 0.09 ms

The result meets expectation, and I will continue to follow up performance of this proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants