-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic energy model in TRON protocol #491
Comments
@daniel-cao-byte, no idea what you mean by above. Can you use an example with numbers so we can understand. |
@otakuinny Thanks for your comment. Here is an example, I believe it can help indicate how the mechanism works. Let's assume the parameters are as below:
and
And there exist two kinds of contract calls.
Maintenance N+1If Contract_A consumes more than
Direct trigger to each function will cost:
Maintenance N+2If Contract_A continues to consume more than
Maintenance N+3If Contract_A consumes less than
|
Thank you @daniel-cao-byte for taking the time to write-up the detailed example with numbers. Besides, the scam contracts that make millions of transactions can always rent more energy at a cheaper price even if the energy consumption is raised by a factor. A better system could be to charge TRX fees (just like 1 TRX for memo) when a contract exceeds a threshold in a cycle. This way we don't have to worry about complex calculations and max factors etc.. E.g. We can make the TRX fees configurable using SR proposals. Let's say it is 5 TRX and the threshold is 5 billion energy. So, to recap, charging trx fees instead of charging more energy might be the way to go as the contract can provide 100% of the energy by renting it cheaply. But we should be careful about setting the threshold value and the TRX fees so as to not hurt legitimate contracts. Also, when the contract call costs a trx fees, there should be a way for the caller to know ahead of time so a message can be shown on the dapp saying it'll cost the caller trx. Just my 2 cents. |
I think it's a very good advice to charge TRX fee instead of energy, we will carefully discuss and evaluate the suggestion. |
After our discussion, we think that adding a percentage of penalty energy is more reasonable than charging a fixed TRX fee for whatever the transaction is or how much energy it consumes. Also, charging for trigger to a specific contract can be easily bypassed by a 'bridge' contract. |
so, I just came here from the release notes of v4.7.0, and after I read the proposal I have come with the same conclusion as @otakuinny
Basically what this does is to turn USDT transfers more expensive for everyone, right? |
This might be one of the TIP's side effect, but not only USDT, any contracts consuming too much energy will consume extra penalty energy. |
USDT is 90% of the energy consumed on TRON (link), this TIP will just help turning TRON into Ethereum, where USDT payments for small value items (< 10 USDT) are unbearable pay via the TRON network, which will just push people to stop using TRON. So, basically, this TIP is kneecapping one of the biggest uses of the TRON network without providing any benefits whatsoever to anyone else, nor any meaningful spam prevention system. How was this TIP approved? |
Their aim is to make USDT transactions more expensive, but they can't admit that. So, they offer some bs explanation about other "mythical" contracts consuming a lot of energy. They know that we know they know they are wrong. They just don't care. This is very common among all centralized cryptos. |
Close this issue as it is implemented by GreatVoyage-v4.7.0.1. |
Simple Summary
This tip proposes a mechanism to perform dynamic regulation of energy in contracts to balance the distribution of energy among contracts.
Abstract
In this tip, we propose a mechanism to dynamically adjust the energy consumption of a contract according to its execution resource usage.
If a contract uses too much CPU resources in one cycle, the energy consumption of that contract will add a percentage as penalty in the next cycle; and when its use of resources is reasonable, the energy consumption of that contract will gradually return to normal. Through this mechanism, we hope to make the distribution of energy resources on the chain more reasonable, and combat low-value or fraudulent transactions while allowing more projects and contracts to have a chance for development.
Motivation
According to Tronscan, more than 85% of the current TRON network's CPU execution time is concentrated on a few contracts. And some of the transactions are low-value or even fraudulent ones.
If this situation persists,
Therefore, we propose to introduce a dynamic energy model to increase the transaction cost of low-value and fraudulent transactions without affecting other dApps, and also to guarantee the robustness, diversity and balanced development of the ecosystem.
Specification
Three main parameters controlled by the proposal are introduced in the scheme, and the meaning of each parameter is as follows,
threshold
: threshold value of base energy consumption for the contract hit rule, then the energy consumption factor will be adjusted.increase_factor
: the rate of the consumption factor increase when the base energy consumption of the contract exceeds the thresholdmax_factor
: the maximum value of the energy consumption factorAnd there is a derivative parameter for calculation:
decrease_factor
: a quarter ofincrease_factor
, the rate of the consumption factor decrease when the base energy consumption of the contract does not exceed the thresholdThe scheme mechanism is as follows.
During each maintenance period, the base energy consumed by the contract execution is recorded. If the contract's base energy consumption exceeds
threshold
during a maintenance period, then itsconsumption_factor
(1 +factor
) will be increased byincrease_factor
during the next maintenance period, the part that exceeds 1 is the penalty factor of the contract.Otherwise, it will be scaled down by a
decrease_factor
untilconsumption_factor
grows tomax_factor
+1 or drops back to 1. Each contract's instructions will be scaled up byconsumption_factor
when calculating energy consumption.When threshold is exceeded in the previous maintenance period:
Otherwise,
The energy consumption of a trigger_smart_contract will be:
Rationale
Cycle selection
We use a fixed cycle because dynamic cycle selection introduces additional complexity for the chain, and its increased flexibility can basically be supplemented by dynamic adjustment of the threshold. Too short a period tends to make some temporary popular contracts hit the rules and interfere with various dApps to carry out innovative activities; at the same time, the length of the period is best to have a record of the corresponding concept on the chain, reducing unnecessary development and maintenance costs. For all these reasons, we suggest the length of the maintenance period as the statistical cycle of this program.
Effective method
We choose a gradual scaling approach, and when the contract consumes base energy continuously exceeding the threshold, its scaling factor will also be continuously scaled up, which draws on the idea of dynamic adjustment of other mainstream public chains' resources by usage. At the same time, we add the limit of the maximum amplification factor in order to avoid infinite amplification.
Adjustment method
We introduce a factorized scaling of the energy consumed by the execution of a contract instruction. The method correlates with the actual execution of the contract.
Backward Compatibility
There are no backward compatibility issues.
API Changes
There are several API changes involved in this TIP.
contract_state
structure in/wallet/getcontractinfo
energy_usage
: the origin energy consumption of the contract in current maintenance period.energy_factor
: the penalty factor of the contract in current maintenance period, the precision is 10_000,energy_factor
= 1000 means the penalty percentage is 10%.update_cycle
: the current maintenance period number.energy_penalty
in contract trigger results, involving/wallet/triggerconstantcontract
andtriggersmartcontract
energy_penalty
: the total penalty energy in the transaction.energy_penalty_total
in transaction receipts, involving/wallet/gettransactioninfobyid
and/wallet/gettransactionreceiptbyid
/wallet/gettransactioninfobyid
receipt.energy_penalty_total
: the total penalty energy in the transaction./wallet/gettransactionreceiptbyid
Receipt.energy_penalty_total
: the total penalty energy in the transaction.Security Considerations
There are no security considerations.
The text was updated successfully, but these errors were encountered: