Discussion: Enable Energy Sponsorship for Contracts Deployed by Contracts
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- blockchain
- Domain
- blockchain
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.
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.
- Dominant language
- No language data
- Stars
- 341
- Forks
- 347
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from tronprotocol/tips
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
tronprotocol/tips#950 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
tronprotocol/tips#945 · 8 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
tronprotocol/tips#944 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
tronprotocol/tips#941 · 5 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
tronprotocol/tips#938 · 15 comments ·
All issues in tronprotocol/tips
Similar issues
-
bug Medium security smart-contract Stellar Wave validation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Web3Novalabs/Nevo#1749 · 2 comments ·
Maintainers usually reply within 1 day
-
contract good first issue testing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Emmyt24/nova-launch#2436 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
status-im/nimbus-eth1#5181 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
erigontech/erigon#26523 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
lambdaclass/ethrex#7550 ·
Maintainers usually reply within 2 days