Discussion: Enable Energy Sponsorship for Contracts Deployed by Contracts

未关闭
#782 28 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
活跃
技术栈
blockchain
领域
blockchain

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

enhancement

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.

  1. Enable TVM to edit consume_user_resource_percent and origin_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.

  1. 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.

主要语言
没有语言数据
星标
341
派生
347
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

tronprotocol/tips 的其他 Issue

查看 tronprotocol/tips 的全部 Issue

相似的 Issue

更多 Blockchain Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。