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

Draft Proposal for Limit on bandwidth spend within Permission Model / for Resource Delegation/Reclaim transactions #6137

Open
corytam opened this issue Jan 3, 2025 · 4 comments

Comments

@corytam
Copy link

corytam commented Jan 3, 2025

Background

I was trying to understand about energy rental and the permission model , and thought that as a seller of energy , the permission model could be improved to enhance security of user's accounts when delegating resources to external accounts.

Simply , a feature within the permission model to prevent spending beyond available bandwidth/energy natively.

I see that some energy platforms give energy sellers an option to set a minimum energy/bandwidth limit to maintain and if this was native , it would be a great feature.

Rationale

I understand for multisig accounts , this issue can be avoided since all/enough parties (with the appropriate weightage) need to sign and approve transactions.
But in pursuit of efficiency and a solution for a non-multisig solution (in regards to energy selling/ resource delegation) which is more easily automated/executed due to simplicity , I believe these features will not only make delegation of resources fully trustless , but simplify and enhance the energy rental process . It could lead to lower overhead/ reduction in middle man costs on energy rental and hence may even lower energy costs for end-users as it becomes safer to delegate resources.

Scenario

Account A gives permission to Account B for delegating/reclaiming resource , Account B delegates Account A energy/bandwidth to Account C , spending bandwidth of Account A

The issue I see is that , correct me if I'm wrong , bandwidth spent to execute delegating /reclaiming resources is on the main account (Account A) when the external account (Account B) is the one executing the transaction.

From what I can see, this could lead to malicious draining of accounts through spam transactions at worse and at best unintentional burning of TRX.

*Note it seems like all permissions for transactions e.g transfer TRX, staking , voting will face this issue. Obviously "transfer TRX" permission gives basically control of the TRX assets in an address , but for other use cases for giving permission of staking or voting , these transactions would cost bandwidth and it is spent from Account A and you may not want to give permission away to "spend" TRX through transaction fees.

Important

This leads to a issue of trust when delegating resources and we should always aim for a trustless solution.

Right now , delegators (energy sellers) need to trust platforms that they will not burn TRX in order to execute delegation and reclaim transactions should the account run out of bandwidth.

What are the use-cases?

-Resource delegators/energy sellers providing resources to energy platforms/third parties without having to trust them that their TRX will not be burned without permissions / limits prevent accidental or nefarious attacks.

-End-users want to prevent accidental burn of TRX by accident when they run out of bandwidth/energy.

-Enabling Managed Staking service (permissions - stake , unstake , vote) without the risk of burning of TRX

Specification

Test Specification

Scope Of Impact

-Permission model
-Transaction payment overhaul

Implementation

One or more of the following options ( there may be alternatives as well)

Option 1) Transaction resource payer permission
A permission setting to make all accounts that have given away resource delegation permissions ( delegate and reclaim) will make the caller/transaction executor (external accounts given the permission) pay the bandwidth.

If permissioned tenant (Account B) is given this permission , Account B will pay for bandwidth ( technically could reverse the logic of this permission e.g pay for transaction cost if lacking the permission)
For backwards compatibility , maybe it will have to be Account B paying for bandwidth when given the permission.

Option 2) -TRX Burn for transaction resource permission
A permission / setting to prevent the account from burning tron for energy/bandwidth and only use bandwidth/energy from staked TRX

If an account does not have this permission e.g resourceBurnController , only available/staked energy and bandwidth can be used for transactions.

Option 3) Limit to minimum bandwidth/energy required in account
A setting to set a threshold on minimum bandwidth to maintain ( and no TRX will be burned for energy /bandwidth)
This option can be useful for even non energy-sellers, who either run out of bandwidth by accident after executing too many transactions and forget to check that they are out.
If limit is hit , error occurs when trying to sign transaction

For this, value of -1 could mean no minimum bandwidth and any number above will set the minimum bandwidth to maintain.

Disclaimer

Please excuse my misunderstandings if any and let me know how to improve this.

EDITTED: Updated some terms to clarify example cases ( in particular the naming of Account B as a tenant instead of delegatee) and added more comments

@lxcmyf
Copy link
Contributor

lxcmyf commented Jan 3, 2025

@corytam
In the Tron network, if the account initiating a transaction lacks its own resources, it will burn TRX to offset the transaction fee. This is a common feature of all transactions, and it is not limited to transactions involving delegating resources and undelegating resources. For option 1 you mentioned, when the delegator initiates or cancels a transaction involving delegating resources, the tenant pays the transaction fee. Why is this done? Who initiated the transaction and who pays the transaction fee. Regarding option 2, I understand that it is actually setting an optional parameter for the transaction to determine whether to burn trx when the account resources are insufficient. Does that mean that all types of transactions can have this optional parameter set, which may affect the efficiency of the transaction being uploaded to the chain? Finally, for option 3, resources are continuously restored over time, and setting this threshold may not be meaningful. Tron actually provides a getaccount or getaccountresource interface to query the available resources of the account, which can be used to customize the interception of transactions that may be burned with trx. This question is worth discussing and thinking about, and perhaps a better solution is on the way.

@corytam
Copy link
Author

corytam commented Jan 3, 2025

@lxcmyf Oh let me clarify after having a better understanding now with permissions which technically is multisig.

For option 1 , I assume the "tenant"/delegatee/tx caller is signing a transaction since the resource and tron belongs to the account (Account A), the account still pays the bandwidth and not the delegatee(Account B) (and Account B is delegating resource to Account C which gets the resources)

In this case i meant delegator and delegatee refers to permissions. Maybe I should be saying Owner and permission holder ?

Interestingly , the tx caller (Account B) should be the one signing the transaction to (delegate to account C) , I assume it is treated like Account B is signing a transaction on behalf of Account A and hence Account A has to pay for the bandwidth.

This would seem like option 1 is not feasible UNLESS a similar option /permission is given where when given , permission (Account B) will sponsor/ pay bandwidth on behalf of the owner ( Account A.)

P.S
Sorry i missed clicked closing the issue

@corytam corytam closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
@corytam corytam reopened this Jan 3, 2025
@corytam corytam closed this as completed Jan 3, 2025
@corytam corytam reopened this Jan 3, 2025
@lxcmyf
Copy link
Contributor

lxcmyf commented Jan 8, 2025

@corytam
Has the above reply answered your question? If you have any new confusion, please feel free to ask at any time.

@corytam corytam changed the title Concept/Draft Proposal for Limit on bandwidth spend for Resource Delegation/Reclaim transactions Draft Proposal for Limit on bandwidth spend within Permission Model / for Resource Delegation/Reclaim transactions Jan 9, 2025
@lxcmyf
Copy link
Contributor

lxcmyf commented Jan 9, 2025

@corytam
The current problem lies in the granting of multi signature permission to another account for delegating resource usage. For example, account A grants account B multi signature permission for delegating resource usage. However, when account A sets the multi signature threshold to 1, this means that either account A or B can control the resource usage of account A, and account B can initiate multi signature transactions without any hesitation, consuming a's resources. The core point is that this is actually a risk exposed by the A account itself when setting multiple signing authorization limits.

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

No branches or pull requests

2 participants