Skip to content

Tighten OutstandingAumFee validation and normalize legacy state #218

Description

@nullpointer0x00

Background

PerformVaultFeeTransfer previously added OutstandingAumFee with Coin.Add, which panics on a denom mismatch, so a malformed stored coin (e.g. {denom:"", amount:0}) could break fee reconciliation. That panic vector was eliminated in 2edbd03 (#210): the keeper now adds raw Ints with SafeAdd and rebuilds the coin from vault.PaymentDenom.

However, the malformed state itself is still representable — validation and state migration were never tightened to match.

Remaining work

  1. Tighten VaultAccount.Validate()types/vault.go:294-296 short-circuits the denom check for empty-denom coins:

    if (v.OutstandingAumFee.Denom != "" || (!v.OutstandingAumFee.Amount.IsNil() && !v.OutstandingAumFee.Amount.IsZero())) && v.OutstandingAumFee.Denom != v.PaymentDenom {

    A coin of {denom:"", amount:0} still passes validation. Tighten so the denom must match PaymentDenom (or the coin must be fully unset/nil).

  2. Migration normalization (optional) — no migration normalizes existing OutstandingAumFee state; MigrateVaultAccountPaymentDenomDefaults (keeper/migrations.go:40-59) normalizes only PaymentDenom. Consider normalizing empty-denom zero fees to sdk.NewCoin(PaymentDenom, 0).

  3. Regression test — add a test importing/validating a vault with OutstandingAumFee = {denom:"", amount:0} to lock in the chosen behavior.

Risk

Residual runtime risk is nil — the coin is rebuilt from PaymentDenom at the only use site — so this is defensive hardening and state hygiene, not a live bug.

Refs: #210

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsecurityThis issue/request improves or addresses the security of the system

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions