Skip to content

Improve the performance of vote reward withdrawal #5354

Description

@lurais

Rationale

The reward calculation logic is divided into two parts: the old one and the new one. This is based on proposal No.82 which took effect on 2023-01-20 at 14:00:00. Due to the proposal, the vote rewards that occurred before that time (14:00:00, 2023-01-20) would still be calculated with the old reward algorithm when withdrawing, which has poor performance. For more details, please see TIP-465.

There are three types of transactions that trigger vote reward withdrawal: VoteWitnessContract, UnfreezeBalanceContract, and WithdrawBalanceContract.

Why should this feature exist?

To improve the performance of withdrawing vote rewards that occurred before 2023-01-20 14:00:00, reduce the execution time of the above three types of transactions.

Implementation

Do you have ideas regarding the implementation of this feature?

Option 1

Calculate the vote rewards (before 14:00:00, 2023-01-20) in advance by background task and cache them.

Previews

image

Problems&Shortcomings

  • DB Cache pollution due to bulk queries
  • how to mark the calculation progress
  • how to mark and clean outdated data(reward has been withdrawn)

Option 2

Execute the above three transactions asynchronously.

Previews

image

Problems&Shortcomings

  • transactions expire due to time-consuming reward calculations
  • the transactions are in disorder
  • how to callback for broadcastTransaction when executed asynchronously
  • transactions are not guaranteed to be broadcast over the entire network

Are you willing to implement this feature?
Yes.

statistic

As of Aug. 9, 2023, nearly 210k accounts(rewarding cumulative 2+ maintenances) still need old reward calculation logic , about 1k accounts/w declined online. There are 20k accounts rewarding cumulative 3k maintenances, 150k accounts rewarding cumulative 1k maintenances.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions