Skip to content

fix(staking): reconcile active stake and thawing balances after slashing - #341

Open
juanmardefago wants to merge 1 commit into
masterfrom
juanmardefago/horizon-active-stake-accounting
Open

juanmardefago wants to merge 1 commit into
masterfrom
juanmardefago/horizon-active-stake-accounting

Conversation

@juanmardefago

Copy link
Copy Markdown
Contributor

Exclude idle stake from Horizon Indexer ratios and overdelegation dilution by using provisionedTokens minus thawingTokens. Preserve the existing stake basis explicitly for legacy metric calculations, including indexers that retain their legacy flag after migrating to Horizon.

Mirror the contracts' proportional reduction of thawing balances when provider stake or delegation is slashed, including integer rounding. Update the corresponding Indexer and network/service aggregates before recalculating metrics, and refresh the delegation exchange rates.

Network and service delegation totals already exclude thawing tokens, so subtract only the active portion of a delegation slash from those totals. Keep the full slash amount in gross balances and cumulative slashing totals.

Add 12 regression tests covering idle stake, deprovisioning, partial and full slashes, rounding, aggregate balances, exchange rates, and legacy metrics. Extend the existing deprovisioning test to check Indexer cuts.

Validation:

  • L1 and L2 codegen and builds passed.
  • All 144 tests passed under each configuration.
  • Targeted ESLint passed with four existing unused-variable warnings.
  • git diff --check passed.

Exclude idle stake from Horizon Indexer ratios and overdelegation dilution
by using provisionedTokens minus thawingTokens. Preserve the existing
stake basis explicitly for legacy metric calculations, including indexers
that retain their legacy flag after migrating to Horizon.

Mirror the contracts' proportional reduction of thawing balances when
provider stake or delegation is slashed, including integer rounding.
Update the corresponding Indexer and network/service aggregates before
recalculating metrics, and refresh the delegation exchange rates.

Network and service delegation totals already exclude thawing tokens, so
subtract only the active portion of a delegation slash from those totals.
Keep the full slash amount in gross balances and cumulative slashing totals.

Add 12 regression tests covering idle stake, deprovisioning, partial and
full slashes, rounding, aggregate balances, exchange rates, and legacy
metrics. Extend the existing deprovisioning test to check Indexer cuts.

Validation:
- L1 and L2 codegen and builds passed.
- All 144 tests passed under each configuration.
- Targeted ESLint passed with four existing unused-variable warnings.
- git diff --check passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant