Skip to content

Latest commit

 

History

History
110 lines (83 loc) · 4.73 KB

tip-207.md

File metadata and controls

110 lines (83 loc) · 4.73 KB
tip:207
title: A proposal to improve network resources model 
author: sean Liu <[email protected]> 
discussions to: https://github.com/tronprotocol/TIPs/issues/207
status: Final
type: Standards Track
category: core
created: 2020-03-26

Simple Summary

This proposal proposes a new scheme to try to solve the problem of the low utilization rate of network frozen resources, reduce user usage costs, and improve resource models. This optimization may lead to more accounts freezing TRX to obtain resources and further increase the TVL of the TRON network.

The core idea is that freezing TRX only gets Bandwidth, Energy, or Tron Power.

In order to guarantee the stability of the network and the rights of users, the Tron Power and resources obtained before can be retained at the same time.

Motivation

Currently, freezing TRX can obtain Bandwidth or Energy, while obtaining Tron Power. Many accounts freeze a large amount of TRX for voting only but do not use resources. This results in accounts that really need resources only get a small part of resources and network resources are wasted.

Specification

There are two new parameters that will be added into account data structure: "old_tron_power" and "tron_power".

"old_tron_power" is used to record the Tron Power before the proposal, which is the sum of frozen TRX for the Bandwidth and Energy.

"tron_power" is used to record the Tron Power after the proposal.

message Account {
...
int64 old_tron_power = 46;
Frozen tron_power = 47;
}

In the FreezeBalanceContract and UnFreezeBalanceContract, TRON_POWER is added into ResourceCode.

enum ResourceCode {
BANDWIDTH = 0x00;
ENERGY = 0x01;
TRON_POWER = 0x02;
}

There is a new chain parameter called TOTAL_TRON_POWER_WEIGHT, which is used to record the new Tron Power in the whole network.

private static final byte[] TOTAL_TRON_POWER_WEIGHT = "TOTAL_TRON_POWER_WEIGHT".getBytes();

Tron Power info is added into AccountResourceMessage. Users could get Tron Power info using "GetAccountResource". In AccountResourceMessage, TotalTronPowerWeight is the total new Tron Power that users freeze for TRON_POWER in the whole network. TronPowerLimit is the total Tron Power the user has, include old Tron Power and new Tron Power. TronPowerUsed is the Tron Power the user already used for votes.

message AccountResourceMessage {
  int64 TotalTronPowerWeight = 9;
  int64 tronPowerUsed = 10;
  int64 tronPowerLimit = 11;
}

Implementation

After the proposal, when the account sends the first voting witness or freezing TRX transaction, the "old_tron_power" of the account will be calculated and initialized. The "old_tron_power" is the sum of frozen TRX for the Bandwidth and Energy before.

The "old_tron_power" will not increase even if the account freeze more TRX for the Bandwidth and Energy.

Pay attention, "old_tron_power" will be clear when the account sends an unfreeze operation, includes unfreezing Bandwidth、Energy or Tron Power, and will not set anymore.

If the account wants more Tron Power, the account could freeze TRX for Tron Power specifically.

When the account wants to vote a witness, Tron Power is the sum of "old_tron_power" and "tron_power" in the account.

In normal, the votes of an account will be clear when the account sent an unfreeze operation. But when the "old_tron_power" is equal to -1, the votes must come from the new "tron_power", unfreezing Bandwidth OR Energy should not affect the votes, so the votes are reserved.

In addition, the new Tron power is also not allowed to delegate to other accounts.

Comparison with present situation

In order to further classify the change after the proposal, we make a comparison on the key points.

First, before the proposal, the account could only freeze TRX for the Bandwidth and Energy to obtain Tron Power. After the proposal, the account should obtain Tron Power by freezing for Tron Power specifically.

Second, before the proposal, the Tron Power of an account is the sum of frozen TRX for the Bandwidth and Energy. After the proposal, all Tron Power of an account includes the "old_tron_power", and the new "tron_power" where the "old_tron_power" representative the past Tron Power value.

Later, before the proposal, the votes will be clear, when the account sends an unfreezing transaction. After the proposal, in most situation, the votes will be clear too, but when the "old_tron_power" is equal to -1, and the operation is unfreezing Bandwidth OR Energy, the votes will be reserved.

Backward Compatibility

There are no backward compatibility concerns.

Test Cases

  1. Check the "old_tron_power" is correct after a freezing operation.
  2. Check the "old_tron_power" is clear after an unfreeze operation.
  3. Check the Tron Power is the sum of "old_tron_power" and "tron_power".