Closed yanghang8612 closed 2 months ago
The SUICIDE
opcode is executed when destroying a contract, hope the energy consumption of other opcodes remains the same, so that the cost of ordinary transactions would not increase.
Energy is designed to reflect the computing resource, this TIP indicates the resource should also take execution time into consideration, because time reflect the occupied resource. It seems reasonable, if it could control the influence to most existing contracts.
Better to estimate the amount of contracts that depend on fixed energy costs and find a way to help them adapt to this change, if necessary.
It is not very clear why the current energy cost of suicide
opcode is not reasonable compared to others. And specification part should be supplemented and discussed.
Hello,
Regarding to VOTEWITNESS
code
To be clear, this improvement doesn't mean that votewitnessaccount transactions will start to consume Energy. It's just about calls to vote from smart contracts?
@andreiRogov96
Yeah, that's for sure. The VOTEWITNESS
referred to in this TIP are opcode in TVM, not votewitnessaccount interface as you say.
Simple Summary
This TIP aims to adjust the energy cost of TVM opcodes based on actual resource consumption.
Abstract
Adjust the energy cost for several opcodes (such as
SUICIDE
andVOTEWITNESS
) in TVM to better reflect the actual resource consumption of opcode execution and to ensure that the costs are reasonable.Motivation
The
SUICIDE
opcode is used to destroy smart contracts and release related resources. TheVOTEWITNESS
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
andVOTEWITNESS
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.
Specification
After the
getAllowEnergyAdjustment(81th)
proposal takes effect, theSUICIDE
opcode will charge an additional25,000
energy cost, if the recipient does not exist. Also, theVOTEWITNESS
opcode will be charged a memory expansion energy cost of at least 32 bytes (array length) for its dynamic array parameters.Rationale
The rationale behind proposing an adjustment to the energy cost for the
SUICIDE
andVOTEWITNESS
opcodes in TVM stems from several key considerations:Backwards Compatibility
These energy cost increases may potentially break contracts that depend on fixed energy costs.