tip: 653
title: Adjust energy cost of SUICIDE and VOTEWITNESS opcodes in TVM
author: yanghang8612@163.com
status: Review
type: Standards Track
category: VM
created: 2024-04-30
This TIP aims to adjust the energy cost of TVM opcodes based on actual resource consumption.
Adjust the energy cost for several opcodes (such as SUICIDE
and VOTEWITNESS
) in TVM to better reflect the actual resource consumption of opcode execution and to ensure that the costs are reasonable.
The SUICIDE
opcode is used to destroy smart contracts and release related resources. The VOTEWITNESS
opcode is a TRON-specific opcode that allows a contract account to perform voting operations on certain SRs just like an EOA account.
However, the current energy cost mechanism may have some deficiencies, failing to effectively reflect the resources and time costs required for the execution of SUICIDE
and VOTEWITNESS
opcodes, potentially leading to unreasonable costs.
-
Adjustment of Energy Cost: The current energy cost for the
SUICIDE
andVOTEWITNESS
opcodea may be comparatively low compared to other opcodes, failing to adequately consider the resources and time costs required for execution. It is proposed to adjust the energy cost for theSUICIDE
andVOTEWITNESS
opcodes appropriately to better reflect the actual costs. -
Consideration of Execution Time: The execution of the
SUICIDE
andVOTEWITNESS
opcodes may involve complex operations and require a certain amount of time to complete. Therefore, the impact of opcode execution time on energy cost should be considered to ensure that the cost is proportional to the execution time. -
Reasonability: When adjusting energy costs, it should be ensured that the costs reflect the consumption of resources by the opcodes to avoid the possibility of potential DDoS attacks.
After the getAllowEnergyAdjustment(81th)
proposal takes effect, the SUICIDE
opcode will charge an additional 25,000
energy cost, if the recipient does not exist. Also, the VOTEWITNESS
opcode will be charged a memory expansion energy cost of at least 32 bytes (array length) for its dynamic array parameters.
The rationale behind proposing an adjustment to the energy cost for the SUICIDE
and VOTEWITNESS
opcodes in TVM stems from several key considerations:
- Efficiency: Aligning the cost with actual resource consumption encourages developers to optimize contracts, leading to more efficient resource allocation.
- Security: A more accurate cost reduces the risk of abuse and network disruptions, enhancing overall security and stability.
- Community Involvement: Engaging the TRON community ensures support and alignment with network interests, promoting transparency and accountability.
These energy cost increases may potentially break contracts that depend on fixed energy costs.