-
Notifications
You must be signed in to change notification settings - Fork 216
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
TIP-542: Resource delegating supports customizable lock period #542
Comments
I like it, just wonder whether it can be achieved. The first problem is that if you change the bool type to int256, it won't be backward compatible as said in the last section. The way I think it works is that add a new parameter in the API, for example "time", if the lock is true, then the lockup time is the value of "time". Please consider about it. |
You can be totally right. And probably that's how it's gonna be because it feels much more easy to addapt. It depends on how the logic is addapted and how the variable is stored. I purpose this way just in case it can be optimized directly to avoid that extra variable. Let's see what the dev team have to say. |
Thank you for the issue, I have read it and here are some words from my tech point of view:
So do you have any detailed requirement of delegation lockup time range based on the delegating scenarios ?so I will assess whether the extra work load is fine. |
I think the method you are discussing is to somehow follow Stake 1.0, meaning that when initiating a new delegation to the same address, you try to merge the transaction and refresh the lockup time. Well, how about this new approach: every delegating transaction accounts for one independent delegation. I mean even delegating to the same address, each delegating transaction has its own lockup time, and when undelegating, it's also each by each. I think it's more convenient and flexible for users in energy market. What would you say? |
I think the Stake2.0 should optimize the following points now:
|
It sounds achievable, but please consider the scenario about making multiple delegates to the same person in a short time. In this case, the system needs to maintain the lock period for each delegating seperately, which will complicate the resources management for the same person or address. The system needs to create multiple key-value pairs according to each lock periods of the delegatings to maintain, or the key remains unchanged, and the value data structure needs to be modified to store multiple resource delegatings. This seems feasible, but if the number of delegating to a particular address is not limited, the data stored will be inflated infinitely, therefore, the performance of the database will be severely degraded. |
thank you @lxcmyf for the info
Good summary, and somehow I think it can be refined:
|
I will add my pov here:
It's better to maintain 1 lock amount like it is now (or 2 counting the non-timed ones), allowing unlimited delegations increasing the timer than limit the amount of delegates which can be done to an address. That would add another complex layer to the way the resources are managed in the market right now. Answering @lxcmyf about this:
I'm not sure why it should be exactly a problem. The timer is just a passive variable (final timestamp) which doesn't need to have any load impact until someone tries to undelegate it, where the time is checked. I don't see the attack point here sincerely since the system doesn't need to do anything different that what it does right now with the 3 days which must be set internally. Maybe there must be some clarification of how timer is working currently that I'm not taking into account. Thank you in advance. |
I think it is really useful and necessary, because right now it's almost impossible for energy providers to hold multiple permissions at the same time for multiple platforms. Nowadays there are platforms undelegating orders that have not placed themselves but other platform, leaving a customer without the energy for the time he actually paid for. If we can lock the order for the entire period this problem would be considerably reduced. |
It seems there are two options,
I think I need more suggestions and discussion on these two options to evaluate the pros and cons of them. |
The big const I'm able to see is the freeze time which would maintain nearly the same essence of update the lock timer which is the reason why we are talking about version 1 to maintain those dates with their amounts. |
For Option 2, if there is no limit to the lock in period, it can become infinitely large. If the user temporarily regrets without taking any other measures to modify this period, it will remain locked in and such a lock in will become meaningless. Therefore, I think it is necessary to specify a maximum period that is also within the user's acceptable range. Do you think so? Also, the unit of the lock in period as an API parameter should be days, right? The unit of seconds or less will make user operations more complex, which means the minimum lock period is one day. Within the program, days are converted into seconds. Of course, further discussions will be held at TRON Developer Conference for both Option 1 and Option 2. |
Hi, thank you for your answer @lxcmyf :
Is this developer conference public? How can I participate? I would love to do it. |
I think it is necessary to add a new parameter for the locking period. I think the unit of the new parameter can be minutes or hours, because seconds don't make much sense and no one will lock a few seconds. Also for compatibility with old data, when lock is true and the new parameter is 0, it should be locked for 3 days by default, and use its value when it has a value. {
"owner_address": "Txxx1",
"receiver_address": "Txxx2",
"balance": 1000000,
"resource": "ENERGY",
"lock": true,
"visible": true
} It still means locked for 3 days. {
"owner_address": "Txxx1",
"receiver_address": "Txxx2",
"balance": 1000000,
"resource": "ENERGY",
"lock": true,
"lock_time": 1,
"visible": true
} It means locked for 1 hour. |
Keep it simple and don't complicate things. All changes should be backwards compatible, meaning if no change is made to the dapp code after the update of this api, it should still work exactly like before. While these changes are seen as improvements and are welcome, it looks pretty bad that these changes have to be made to a system so soon after its release. Makes whoever came up with the whole stake 2.0 model in the first place look like clown developers. |
Hour granularity is fine to me (and I think for most). Just trying to get advance in future situations with seconds since hourly doesn't seems to be a standard measure if you know what I mean.
For me personally I don't mind where the updates are done while they are done. It's true that there is a gap between core devs and what community is doing right now which makes some decisions seems to be incompleted or not well thought. |
Can't agree more, for every word. |
In the tron network, the concept of blocks is more deeply ingrained. A block generation takes 3 seconds, so the delegating lock period in blocks may be more in line with transaction rules and more acceptable to most people. Of course, blocks should have a maximum value limit, and it is recommended to set the number of blocks corresponding to 1 year or less time. /wallet/delegateresourceDescription: delegate resource Params:
Returns - unsigned transaction, data type is json string Example:
|
1 year? Are you crazy??? It should be no more than 30 days. 1 Year will open so many attack vectors on user accounts that give permissions to websites. The max value of lock_period should be 864,000 (30 days). When a value greater than 864,000 is passed, it should either throw an error or treat it as 0 which locks it for 3 days. |
Remember, you are the one that came up with the specs for Stake 2.0, and the fact that we are making changes so soon shows that you are not very good at your job. So, how about you listen to the community this time (something you should have done the first time). |
Thank you for these suggestions. Improving security awareness and identifying potential vulnerabilities are both valuable. Indeed, the one-year lock-period is too long, which leaves attackers too much time to launch other attacks. 30 days is a reasonable maximum, and this suggestion is worth adopting. |
Would it be better to set the |
It must be a parameter to allow updates in the future without having to update the node which is something all node sysadmin will appreciate 😄 |
yes, lock_period must be one of the chain parameters that can be updated through voting proposals with the initial default value as 864,000(30 days). |
If the maximum of delegate lock-period is set to a proposal and later reduced, it may cause users who have already been delegated to no longer be able to delegate. Therefore, is it better to set this value to a constant? |
What do you mean by 1 year opens too many attack vectors? This is a parameter-checking rule. You meant during that long time, pk has a better chance to be disclosed with a large amount of asset locking so that it leads to a higher chance to lose it?
|
I think a maximum value of 30 days is safe enough to start and it should be ok to only ever increase this value through proposals. Because we are talking about "maximum" value which allows any lower value as lock period, I don't think we have to worry too much about this. I can't think of a situation where we might want to lower the maximum value below 30 days. |
Yes, we have verified this proposal and future modifications can only increase it. |
Close this issue as it is implemented by GreatVoyage-v4.7.2. |
Simple Summary
Add a
lock_period
parameter in thewallet/delegateresource
API in Stake 2.0, to support delegating bandwidth or energy resource with a specified lockup time.Abstract
Besides the current API
wallet/delegateresource
that allows users to lockup a solid 3 days before the resouce could be undelegated, it is proposed to add a parameterlock_period
in this API to support customizable lock period in resource delegating, with the unit of blocks. And the new resource delegating to the same address of same type should have thislock_period
value larger than the lockup blocks left of the address.Motivation
Currently in Stake 2.0, the lock parameter in the
wallet/delegateresource
is abool
type. If it is set tofalse
, the delegated resources does not have a lockup time, it can be unstaked anytime after delegation. If it is set totrue
, the delegated resources cannot be undelegated within 3 days.The solid lockup time of 3 days can not meet all the scenarios and is not conducive to the two parties to agree on a lease time in advance. If it can not be defined in the transaction, there is risk that the owner may undelegate the resource before the appointed time. Making the lockup time a customizable time will enhance the flexibility and security in delegation transactions.
Specifications
Modify
wallet/delegateresource
API, the user can call this API to delegate bandwidth or energy resource with a customized lockup time to another address.Params:
owner_address
- Address of transaction initiator, data type is stringreceiver_address
- Receiver address of resource to be delegated to, data type is stringbalance
- Amount of TRX staked for resources to be delegated, unit is sun, data type is unit256resource
- Resource type, "BANDWIDTH" or "ENERGY", data type is stringlock
- Whether it is locked. If it is set tofalse
, there will not be any lockup time no matter what thelock_period
value is. If it is set totrue
, the delegating transaction will have a lockup time, and the time is decided by thelock_period
value.lock_period
- The lockup period, unit is blocks, data type is int256, It indicates how many blocks the resource delegating is locked before it can be undelegated. If the lock time is not over, and the owner delegates the same type of resource with a new lockup time to the same address, the lockup time of all the resource of the same type will be reset to the new lockup time.That new lockup time cannot be less than (old lockup time + old transaction timestamp) - current time.visible
- Whether the address is in base58 format, data type is boolReturns: unsigned transaction, data type is JSON string
Example:
Backward Compatibility
It will not influence the existed staking and unstaking related transactions.
If the
lock
is set totrue
, andlock_period
is set to 0, or left blank, it also have the same consequence with that thelock_period
is set to 86400.The text was updated successfully, but these errors were encountered: