Skip to content

feat: validator 30% of bonded tokens limit #1044

Open
danflo27 wants to merge 43 commits into
mainfrom
dan-val-30-limit
Open

feat: validator 30% of bonded tokens limit #1044
danflo27 wants to merge 43 commits into
mainfrom
dan-val-30-limit

Conversation

@danflo27

@danflo27 danflo27 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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

  • Bug fix
  • New feature
  • Documentation update
  • State Changes (please describe)"
  • Chain Changes (please describe):
  • Daemon Changes
  • Tests
  • Added Getter

Testing

unit/integration/e2e

Checklist

  • Code follows project style guidelines
  • I have added appropriate comments to my code
  • I have updated the documentation accordingly
  • I have added tests that prove my fix or feature works
  • go test ./... is passing locally
  • make e2e is passing locally

danflo27 added 7 commits June 25, 2026 09:30
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.
danflo27 added 11 commits June 25, 2026 12:21
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.
@danflo27 danflo27 requested a review from akremstudy June 25, 2026 20:23

@akremstudy akremstudy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@danflo27

danflo27 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

need to fix chasing redelegations for disputes

danflo27 added 9 commits July 9, 2026 17:54
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants