tronprotocol / tips

TRON Improvement Proposals
229 stars 203 forks source link

Proposal: Enable usage optimization for Stake 2.0 #567

Closed lxcmyf closed 1 year ago

lxcmyf commented 1 year ago

Simple Summary

In order to further improve the flexibility of Stake 2.0, it is proposed that after the mainnet is upgraded to the Periander version, the Stake 2.0 extension will be enabled, please refer to TIP-541 and TIP-542.

Motivation

Stake 2.0 is a new milestone of the TRON network, which has fully upgraded the staking mechanism. Compared with Stake 1.0, Stake 2.0 is more flexible, efficient and intelligent, it significantly improves the flexibility of TRON network resources and voting management.

Since Stake 2.0 was enabled on the mainnet for more than two months, the community has put forward some suggestions for improvement:

Therefore, GreatVoyage-v4.7.2(Periander) introduces TIP-541 and TIP-542. TIP-541 added a new governance proposal to allow users to cancel the unstaking that has been initiated but not yet completed, and TIP-542 added a new governance proposal to allow users to specify the resource delegating lockup time according to their needs.

Specification

Propose to modify the No.77 and No.78 TRON Network Parameters to enable the Stake 2.0 extension,

How to initiate the voting request

Enable the usage optimization for Stake 2.0,

Analysis

After it is enabled, the nodes will support a new transaction type, and users can use the wallet/cancelallunfreezev2 API to create an unstaking canceling transaction:

curl -X POST http://127.0.0.1:8090/wallet/cancelallunfreezev2 -d \
'{
  "owner_address": "TUoHaVjx7n5xz8LwPRDckgFrDWhMhuSuJM",
  "visible": true
}'

The return value in the above example is an unsigned transaction, it should be signed and broadcasted then.

After the above transaction is successfully on chain, you can use wallet/gettransactioninfobyid to query the amount of unstaking TRX that canceled and the amount of unstaked TRX withdrawn to the account:

curl -X POST http://127.0.0.1:8090/wallet/gettransactioninfobyid -d \
'{"value":"TUoHaVjx7n5xz8LwPRDckgFrDWhMhuSuJM",
  "visible":true
}'

{
    ...
    "cancel_unfreezeV2_amount":[
        {
            "key": "BANDWIDTH",
            "value": 2000000000
        },
        {
            "key": "ENERGY",
            "value": 3000000000
        },
        {
            "key": "TRON_POWER",
            "value": 0
        }
    ],
    "withdraw_expire_amount": 1000000000
}

When enabling the proposal, a time parameter needs to be specified, indicating the maximum value of the lock time that can be set. Once enabled, a new parameter, lock_period, will be added to wallet/delegateresource API:

curl -X POST http://127.0.0.1:8090/wallet/delegateresource -d \
'{
  "owner_address": "TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g",
  "receiver_address": "TPswDDCAWhJAZGdHPidFg5nEf8TkNToDX1",
  "balance": 1000000,
  "resource": "ENERGY",
  "lock": true,
  "lock_period": 86400,
  "visible": true
}'

The default value of lock_period is 86400, which is 3 days. That is, when lock is true, if lock_period is not specified or set to 0, lock_period will be set to 86400 by default, which will ensure the compatibility before and after TIP-542 takes effect.

In addition, the minimum value of lock_period cannot be lower than the remaining lock time of this type of resource that was previously delegated to the same recipient address,and the value will overwrite the remaining lock time of the previous delegating.

For example, user A delegates 100 energy shares to B, and lock_period is set to 57600 (2 days), and the remaining lock time after 1 day is 28800. At this time, when A delegates energy to B again, if choose to lock,lock_period should be set to at least 28800 (1 day), otherwise, an exception error will be thrown when creating the delegating transaction: The lock period for ENERGY this time cannot be less will be thrown when creating a proxy transaction than the remaining time[9600000ms] of the last lock period for ENERGY!. If A choose to lock 86400, this will overwrite the remaining lock time from 1 day to 3 days.

Compatibility

It will not influence the existed staking and unstaking related transactions.

Jamestepfoward commented 1 year ago

This is what we need, #542 will definitely make resource renting more easy. When will it be on mainnet, please leave some time for adopting these new features.

Jackmrshen commented 1 year ago

Good job, and TIP-541 will decrease the influence of 14 days waiting period, it provides with another option for users when they meets emergency during unstakings, that is cancel the unstaking, unstake it in just lend, and get the strx immediately.

hitlxy commented 1 year ago

Cancelling unstakes will indeed bring us a lot of convenience, users do not have to wait 14 days to reuse the unstaked funds. After re-stake the funds, voting for super representatives still needs to be re-voted manually, maybe that cannot be automated.

lxcmyf commented 1 year ago

@hitlxy Yes, this will make the functionality of the interface and voting function overly coupled, increasing complexity.

LauraYH commented 1 year ago

The 3-day lock setup impacts and limits the energy rental market so much, finally a solution is brought up. The unit of the parameter is bizarre, needs a little math.

souppopnix commented 1 year ago

I like these proposed features, cancel unstaking will allow us to reuse our resource/asset faster if needed. Being able to specify a custom locking period for delegations will give delegators and receivers more flexibility to agree on a lease time that suits their needs, sounds great to the energy market. I hope these features can be enabled soon to benefit the community.

lxcmyf commented 1 year ago

@souppopnix Yes, it's coming soon.

L-Reid commented 1 year ago

Custom locking period improves the resource allocation efficiency. But I think It is better that the unit of the lock-up period is the number of days, Because after the energy or bandwidth consumption, it needs almost one day to recover, so if the delegating period is very shot, a few blocks or minutes, even if the resources are recycled, they cannot be delegated again because they have been used.

lxcmyf commented 1 year ago

@L-Reid Some users have usage scenarios with lockdown periods of hours or even seconds. After resource consumption, it is dynamically restored, and can be restored even if it is less than a day, but cannot be fully restored. It is only a partial recovery of resources based on time.

ferdinand026 commented 1 year ago

It is more reasonable for lock period to have a larger range and small unit, expected this proposal takes into effect.

brooklynn1212 commented 1 year ago

What's the upper limit of getMaxDelegateLockPeriod, could it be as long as 30 days?

lxcmyf commented 1 year ago

@brooklynn1212 Yes, it is possible. The range of values for getMaxDelegateLockPeriod is (86400, 10512000], in blocks. The minimum is the number of blocks corresponding to 3 days, and the maximum is the number of blocks corresponding to 1 year. This will be determined through proposal voting.

Jamestepfoward commented 1 year ago

30 days is fine.

And a bit more suggestion, for the lock time, it needs some math, and it would be misleading for users cause the unit of block number is never seen in other field. And the parameter name lock_period will easily remind of time. Could it be made something like lock_block_intervals, otherwise some conspicuous remarks should be added somewhere to guide developers.

MannGates commented 1 year ago

I also noticed in #542 someone suggests to make the lock time 365 days. As it is only a limit parameter, why not make it larger? Maybe there is business involved in long-term resource delegating. It won't influence the short term delegating transactions right?

Jamestepfoward commented 1 year ago

I also noticed in #542 someone suggests to make the lock time 365 days. As it is only a limit parameter, why not make it larger? Maybe there is business involved in long-term resource delegating. It won't influence the short term delegating transactions right?

@MannGates There is an compatibility issue you should know that the upper limit parameter can only be adjusted larger in the future, it can not be smaller because otherwise the previous transactions of long lock time will be denied by nodes. That's why we should be cautious setting this value. I think 30 days meets the most requirement, if there is such situation that need lock time of 1 year, please name some, or we can discuss later.

MannGates commented 1 year ago

I also noticed in #542 someone suggests to make the lock time 365 days. As it is only a limit parameter, why not make it larger? Maybe there is business involved in long-term resource delegating. It won't influence the short term delegating transactions right?

@MannGates There is an compatibility issue you should know that the upper limit parameter can only be adjusted larger in the future, it can not be smaller because otherwise the previous transactions of long lock time will be denied by nodes. That's why we should be cautious setting this value. I think 30 days meets the most requirement, if there is such situation that need lock time of 1 year, please name some, or we can discuss later.

I see, then 30 days is fine. I never see long-term renting scenarios indeed for now.

Jackmrshen commented 1 year ago

It seems only nile network and wallet cli supports this proposal, when will tronweb includes this?

And a bit more suggestion, for the lock time, it needs some math, and it would be misleading for users cause the unit of block number is never seen in other field. And the parameter name lock_period will easily remind of time. Could it be made something like lock_block_intervals, otherwise some conspicuous remarks should be added somewhere to guide developers.

It would not be a serious problem, since dapps will not use this this unit, probably I will use unit of second on user interface, and input the corresponding block numbers calling the API, users won't be sensitive for several seconds.

brooklynn1212 commented 1 year ago

Good to know, and it provides users with more control over their staking process, they can more easily move their funds to other projects or save their funds without having to wait until their staking period has ended. This also helps to reduce the risk of a funds being locked up for too long if the user decides to switch projects or opt out of a project altogether.

KrisdiaPaul commented 1 year ago

Last time the implementation of Stake 2.0 makes resource delegating more easily and flexible, which also leads to increase of low-value transactions. If this is to make it more flexible, I'm afraid that the volume of low-value transactions will increase more.

Jackmrshen commented 1 year ago

Last time the implementation of Stake 2.0 makes resource delegating more easily and flexible, which also leads to increase of low-value transactions. If this is to make it more flexible, I'm afraid that the volume of low-value transactions will increase more.

Some low-value transactions utilize delegated resources indeed, but the main reason was free bandwidth. The modification in this proposal add no convenience for saving resources. I do not think these changes will promote the low-value transactions.

lxcmyf commented 1 year ago

Thanks to all your discussion on this proposal. This issue will be closed as it has already taken effect, please check it here: https://tronscan.org/#/proposal/88