TIP-944: Optimize TVM Voting Power Management
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java
- Lĩnh vực
- blockchain
Hướng nghiên cứu
The proposal names AccountCapsule.java, FreezeBalanceActuator.java, and UnfreezeBalanceActuator.java as references, and says implementation will be in java-tron. Start by reading those files and the TVM voting and self-destruct paths, then trace the existing tests for voting, stake transfers, and account cleanup. Done means the new activation parameter gates the specified state transitions and the listed test cases cover activation combinations, rollback, and deletion.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
tip: 944
title: Optimize TVM Voting Power Management
author: [email protected]
discussions-to: https://github.com/tronprotocol/tips/issues/944
status: Draft
type: Standards Track
category: VM
created: 2026-10-27
Simple Summary
Improve voting-power state management in TVM operations, ensuring consistent account-state transitions under NewResourceModel.
Abstract
This proposal aligns voting-power state management in TVM with the conventions used by native transactions. It covers the applicable voting, stake-transfer, and account-cleanup operations under NewResourceModel.
Motivation
TVM and native transactions should follow consistent voting-power rules throughout the account lifecycle.
This proposal standardizes voting-power state management across TVM voting, stake transfers, and account cleanup.
Specification
This proposal introduces a new on-chain parameter, ALLOW_TVM_VOTE_POWER_OPTIMIZATION, to enable the changes described below.
State and voting-power definitions
Let L be oldTronPower, C the account's current resource-stake contribution returned by getTronPower(), and T its explicitly staked TRON_POWER balance across Stake 1.0 and Stake 2.0. C includes the account's own and delegated-out BANDWIDTH/ENERGY stake under those existing rules; acquired delegated resources are excluded.
All amounts are in sun. When the existing NewResourceModel voting-power calculation is selected:
| Legacy state | Stored value | Voting-power amount |
|---|---|---|
| Uninitialized | L = 0 |
C + T |
| Initialized | L > 0 |
L + T |
| Invalidated | L = -1 |
T |
The maximum total vote count is the integer quotient of the voting-power amount divided by TRX_PRECISION = 1,000,000.
These definitions follow AccountCapsule.getTronPower() and getAllTronPower(). The proposal does not change the existing selection condition: TVM uses getAllTronPower() when both NewResourceModel and unfreeze delay are enabled.
State transitions
After activation, when NewResourceModel is enabled:
| Operation | Required transition |
|---|---|
TVM voting with L = 0 |
Initialize before evaluating voting power: set L = C if C > 0; otherwise set L = -1. |
TVM voting with L > 0 or L = -1 |
Preserve L. |
Successful Stake 1.0 FREEZE for BANDWIDTH or ENERGY, including delegated-out stake |
If L = 0, initialize from the owner's state before increasing stake using the same rule. Preserve L > 0 or L = -1. |
Successful Stake 1.0 UNFREEZE for BANDWIDTH or ENERGY, including delegated-out stake, when getAllTronPower() is selected |
If L = 0, initialize from the owner's state before reducing stake. If the resulting legacy state is not invalidated, clear all account votes and pending new votes, preserve recorded old votes, then set L = -1. If already invalidated, preserve L = -1 and the existing votes. |
Successful Stake 1.0 UNFREEZE for BANDWIDTH or ENERGY, including delegated-out stake, when getTronPower() is selected |
If L = 0, initialize from the owner's state before reducing stake. Retain the existing over-vote cleanup against the post-unfreeze C, regardless of L: clear all account votes and pending new votes if their total exceeds C / TRX_PRECISION, preserving recorded old votes; otherwise preserve the votes. Set L = -1 before returning. |
| Receiving a positive Stake 2.0 transfer through self-destruct | If L = 0, initialize from the beneficiary's state before receipt using the same rule. Preserve an existing positive or invalidated value. |
| Self-destruct transfers a positive active Stake 2.0 balance or redeems a positive Stake 1.0 BANDWIDTH/ENERGY balance as part of source-account cleanup | Set the source's L = -1 before returning from SELFDESTRUCT, regardless of its previous legacy state or vote list and whether it is retained or scheduled for deletion. When getAllTronPower() is selected, its resulting voting-power amount is T_after. |
| Source account is scheduled for deletion | Apply any required source invalidation before SELFDESTRUCT returns. Its account state remains subject to these rules until physical deletion. |
| Source account is physically deleted at finalization | No voting-power state remains for that account. |
| Self-destruct performs neither a qualifying Stake 2.0 transfer nor a Stake 1.0 redemption | No transfer- or redemption-related state transition applies. |
Initialization follows AccountCapsule.initializeOldTronPower(): a computed zero is stored as -1, never as 0.
Stake 1.0 initialization and invalidation follow the native freeze and unfreeze conventions. Initialization and invalidation do not require TVM Stake 2.0 or unfreeze delay to be enabled. Vote cleanup follows the voting-power calculation actually selected; L = -1 alone does not bypass the getTronPower()-based over-vote check. Existing instruction availability and voting-power selection conditions still apply.
On successful Stake 1.0 UNFREEZE under this parameter and NewResourceModel, settle pending voting rewards using the existing reward rules before legacy initialization, stake reduction, and vote cleanup. This also applies when the legacy state is already invalidated or existing votes remain valid. Reward and account-state updates commit or roll back together.
For a beneficiary, receiving BANDWIDTH or ENERGY stake does not increase the resulting legacy snapshot; explicitly received TRON_POWER changes T under its existing rules. An invalidated state is not reopened by voting, receipt of stake, or vote cleanup.
The source invalidation rule above is part of this proposal's treatment of completed stake transfers and redemptions. A deletion marker does not make account state absent during the remaining transaction execution. Required invalidation must therefore be visible to subsequent execution in the same transaction; voting-power state ceases to exist only upon physical deletion at finalization.
Other native initialization and invalidation rules remain applicable. Vote cleanup preserves L unless an applicable lifecycle transition requires changing it; cleanup alone must not reset it to 0.
Use the actual beneficiary selected by the existing self-destruct semantics. Existing feature prerequisites and account-retention rules remain unchanged. All changes commit or roll back with the enclosing execution.
Account-field mapping and normative examples
The field paths below refer to Protocol.Account.
| Quantity | Account fields |
|---|---|
L |
old_tron_power |
Stake 1.0 part of C |
frozen[].frozen_balance, account_resource.frozen_balance_for_energy.frozen_balance, delegated_frozen_balance_for_bandwidth, and account_resource.delegated_frozen_balance_for_energy |
Stake 2.0 part of C |
frozenV2[].amount for BANDWIDTH/ENERGY, delegated_frozenV2_balance_for_bandwidth, and account_resource.delegated_frozenV2_balance_for_energy |
T |
tron_power.frozen_balance plus frozenV2[].amount for TRON_POWER |
For these examples, this parameter and NewResourceModel are active and getAllTronPower() is selected. Tuples are (L, C, T); positive amounts are in multiples of TRX_PRECISION, while -1 remains the stored sentinel. All existing operation prerequisites are satisfied.
| Operation | Before | Required result |
|---|---|---|
| Successful vote initialization | (0, 3, 2) |
(3, 3, 2); maximum total votes: 5. |
| Successful vote initialization with zero resource stake | (0, 0, 2) |
(-1, 0, 2); maximum total votes: 2. |
| Retained source transfers all active Stake 2.0 stake to a distinct beneficiary | Source (2, 2, 1), beneficiary (0, 1, 0); all current stake is Stake 2.0 |
Source (-1, 0, 0), beneficiary (1, 3, 1); maximum total votes: 0 and 2, respectively. |
| Same source repeats self-destruct without new stake | Previous row's resulting state | Both tuples remain unchanged; the invalidated source state is not reopened. |
| Enclosing call reverts the transfer | Transfer row's initial state | Both original tuples, account votes, pending vote records, and rewards are restored to their pre-call values. |
A source scheduled for deletion has the same required source tuple before finalization; after physical deletion, its account state is absent.
Independent activation
This proposal and TIP-945 are independently activated. Each applies only when its own parameter is active, while other independently activated protocol changes continue to apply. When both are active, TIP-945's oversized-count rejection occurs before this proposal's voting initialization and leaves L unchanged.
Rationale
Consistent state-management rules align TVM behavior with native transactions and simplify maintenance of the resource model.
Backwards Compatibility
This proposal changes consensus-relevant execution and requires coordinated activation.
Before activation, existing behavior is preserved. The changes apply to subsequent execution and do not introduce a historical account-state migration.
Test Cases
- All three legacy states, their voting-power amounts, and zero-contribution initialization.
- Stake 1.0 freezing and unfreezing of owned and delegated-out BANDWIDTH/ENERGY stake across all three legacy states; initialization before stake changes and vote cleanup under the selected calculation.
- With unfreeze delay disabled, post-unfreeze resource power below, equal to, or above the recorded vote total; account votes and pending new votes are cleared only when over-voted, irrespective of
L, and recorded old votes are preserved. WithgetAllTronPower()selected, preserve explicit TRON_POWER votes after invalidation. - Stake 1.0 availability with TVM Stake 2.0 disabled or enabled, unfreeze delay enabled or disabled, independent NewResourceModel/parameter gating, failed validation, and enclosing-call rollback.
- Reward settlement with invalidated legacy state and preserved valid votes, including allowance/reward-cycle updates and enclosing-call rollback.
- Beneficiary initialization before receipt, preservation of existing states, and explicit TRON_POWER treatment.
- Source cleanup with Stake 1.0 only, Stake 2.0 only, mixed balances, and zero qualifying balances; empty and non-empty vote lists.
- Source invalidation in retained and scheduled-for-deletion branches, including subsequent account execution before transaction finalization.
- Physical deletion, native lifecycle consistency, atomic updates, and rollback.
- All four activation combinations with TIP-945, including unchanged
Lon its early oversized-count rejection; preservation of pre-activation behavior.
Implementation
An implementation is available in java-tron PR #7068.
Copyright
Copyright and related rights waived via CC0.
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 341
- Fork
- 347
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tronprotocol/tips
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
tronprotocol/tips#950 · 2 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tronprotocol/tips#945 · 8 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
tronprotocol/tips#941 · 5 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tronprotocol/tips#938 · 15 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
tronprotocol/tips#937 · 7 bình luận ·
Tất cả issue của tronprotocol/tips
Issue tương tự
-
bug Medium security smart-contract Stellar Wave validation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Web3Novalabs/Nevo#1749 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
contract good first issue testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Emmyt24/nova-launch#2436 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
status-im/nimbus-eth1#5181 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
erigontech/erigon#26523 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
lambdaclass/ethrex#7550 ·
Maintainer thường phản hồi trong vòng 2 ngày