tronprotocol / tronprotocol/tips
Discussion: Enable Energy Sponsorship for Contracts Deployed by Contracts
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 334
- Forks
- 339
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
Simple Summary
This is a discussion on enabling the energy sponsorship for contracts deployed by contracts.
Motivation
TRON network has a contract energy sharing mechanism that allows the contract deployer to share some of the energy consumption of contract execution, thus provides energy sponsorship for the contract users. But this mechanism currently cannot handle the case where a contract is created by a contract.
With the continuous enrichment of smart contract application scenarios on TRON network, there are more and more cases of deploying contracts (CREATE, CREATE2) through factory contracts. Some contract developers and projects have to deploy additional contracts as transaction entry points to provide energy sponsorship for these contracts, leading to additional costs and certain inconveniences.
Extending the contract energy sharing mechanism to contracts deployed by contracts will improve the flexibility of contracts, and make it easier for developers and projects to build more complex contract systems.
Specification
I can think of two approaches to enable the energy sponsorship for contracts deployed by contracts.
- Enable TVM to edit
consume_user_resource_percentandorigin_energy_limit
Because the consume_user_resource_percent and origin_energy_limit fields of a contract created by a contract are 100 and 0, indicating that 100% of the contract's execution energy consumption is borne by the user and that the contract deployer provides an upper limit of 0 energy for a single transaction.
Currently, TVM does not provide relevant commands for contracts to adjust this field.
By introducing opcodes to modify the consume_user_resource_percent and origin_energy_limit fields of a contract in TVM, factory contracts can modify these configs for child contracts, and provide energy sponsorship for child contracts.
This approach extends the TRON contract energy sharing mechanism to support the origin (deployer) of a contract is other contract, without changing the main energy share and consume logic.
- Allow TVM execution to use the energy of the contract itself.
Another approach is to change the energy sharing mechanism from using the energy of the origin (deployer) to the contract itself.
It also may require the TVM to support the contract to change some of the new share settings.
Both approaches require allowing delegating resource to contracts.
Discussion
Any opinion on energy sharing mechanism or improvement of the mechanism is welcome, thank you.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the specification, focusing on the two proposed approaches for energy sponsorship of contracts deployed by contracts and the requirement for delegating resources to contracts. No files, tests, or implementation entry points are named; the work is not ready for a newcomer until the discussion produces an agreed design and concrete completion criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- blockchain
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100