TIP-944: Optimize TVM Voting Power Management

オープン
#944 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java
領域
blockchain

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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. With getAllTronPower() 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 L on 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.

主要言語
言語のデータがありません
スター
341
フォーク
347
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tronprotocol/tips のほかの issue

tronprotocol/tips の issue をすべて見る

似ている issue

Blockchain の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。