[Security] Bond module accounting discrepancy when node bond < cost

Resolve #2628

Summary

  • Cap the MsgMimir native tx fee cost to the node's actual bond before both the bond deduction and the SendFromModuleToModule transfer
  • Prevents bond module accounting discrepancy when cost > nodeAccount.Bond (e.g. after heavy slashing)
  • Follows the same defensive pattern used in handler_ban.go and handler_tss.go

Details

In handler_mimir.go, SafeSub(nodeAccount.Bond, cost) floors the bond to zero when cost exceeds bond, meaning only min(bond, cost) is actually deducted from individual accounting. However, SendFromModuleToModule transferred the full cost regardless, creating a discrepancy where the bond module's actual balance becomes less than the sum of all individual node bond amounts.

The fix adds a simple guard before the deduction:

if cost.GT(nodeAccount.Bond) {
    cost = nodeAccount.Bond
}

This ensures the module transfer amount always matches the actual bond deduction.

Test plan

  • Existing HandlerMimirSuite tests pass
  • make lint passes with no issues

Merge request reports

Loading
Loading