feat: validator 30% of bonded tokens limit #1044
Open
danflo27 wants to merge 43 commits into
Open
Conversation
Introduce the ADR 1013 module parameter with proto, generated bindings, validation, and a dedicated sentinel error for cap violations.
Add cap checks for direct delegations and cap-aware refund routing in ReturnSlashedTokens, FeeRefund, and WithdrawTip with fallback scanning.
Project validator active-set changes and MsgUnjail re-entry so staking and authz messages are rejected when they would exceed the cap.
Set the 0.30 default during upgrade so existing chains enable the validator power cap alongside the reporter power cap.
Split bonded and unbonded refund amounts from the reporter keeper and move truncation dust to the bonded pool so mixed-origin slashes settle correctly.
Cover ante enforcement, keeper refund paths, and cap-enabled genesis fixtures; extend stake projection helpers and ICQ genesis stripping.
Small-validator devnets and shared test setup exceed 30% bonded stake, so default genesis and setup disable the cap unless tests opt back in.
Extract ValidatePowerShareParam, PowerShareEnabled, and ExceedsPowerShare so reporter and validator cap sites share one param/enforcement definition.
Replace validatorPowerCapState with explicit maxShare and projectedBondedDelta arguments and reuse shared types helpers for cap checks.
Move active-set projection and validator power share checks into a dedicated ante file and simplify unjail tracking for M2 isolation.
…uting Extract delegateToStakeAndEmit, route truncation dust in ReturnSlashedTokens, and move dust policy out of the dispute caller.
Document max_validator_power_share enforcement sites, design decisions, and module readme param coverage.
akremstudy
reviewed
Jul 3, 2026
akremstudy
left a comment
Contributor
There was a problem hiding this comment.
ReturnSlashedTokens gets called by BeginBlocker during ExecuteVote, and it now checks the bonded cap. if it scans the top 32 bonded validators for one under cap, and can't find one it errors when none of them can take the amount without going over, and that error could halt the chain.
Contributor
Author
|
need to fix chasing redelegations for disputes |
Move the hardcoded 30% delegator bonded-stake cap into types so keeper and ante paths share one definition.
Rename wasActive/unjailOccurred to preTxActive/jailCleared so MsgUnjail re-entry projects validator-cap stake without folding into 5%/delegator paths.
Key FeePaidFromStake by payer, refund against actual collected amounts, chase redelegation paths, and return stake via explicit bonded/unbonded policy.
Thread payer into FeeRefund, clamp stake-fee refunds to measured totals, and use DisputedDelegationTotal for bond rewards and claim queries.
Local agent contract, session handoff, and a helper to run e2e tests one at a time.
Ban combining WithdrawTip/WithdrawFeeRefund with ante-projected power acquisition in one tx so independently cap-safe legs cannot stack above the validator power share limit.
Use largest-remainder proportional shares for dispute escrow, validate snapshot totals, and walk redelegations via a delegator-scoped iterator with explicit per-record gas instead of hop-capped src-validator lookups.
Lock in that ReporterStake snapshots the reporter's selected stake, not network-wide total reporter power, so escrow math stays against the right denominator.
Keep agent session state local; these files should not live in the repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Validator power concentration: Adds max_validator_power_share (default 0.30) so bonded-to-bonded redelegation cannot push a validator over 30% while leaving total bonded and per-delegator bonded unchanged (the existing 5% tracker and delegator cap miss this). Enforced in ante and on keeper paths that call Delegate directly (WithdrawTip, dispute returns, fee refunds, tip staking). Cap overflow restores via unbonding instead of over-bonding or failing execution.
Escrow / refund drift: Escrow and fee trackers now record actual Unbond amounts (not share-derived theory), stake-fee snapshots are payer-scoped, and dispute refunds/rewards/queries use measured collected totals so they cannot promise more than the module holds. Dispute BeginBlock execution runs in CacheContext, defers retryable stake-return failures, and no longer risks halting the chain on execution errors.
Related Issue
Fixes #
Type of Change
Testing
unit/integration/e2e
Checklist