[Security] Add defensive Coins length check in IsTradingHalt

Resolve #2582

This MR adds defense-in-depth against a potential index-out-of-bounds panic in IsTradingHalt when processing a MsgSwap with an empty Coins slice.

Summary

  • Add an early return to IsGlobalTradingHalted when MsgSwap.Tx.Coins is empty (first switch block, line 17)
  • Move the Coins[0].Asset access inside the existing len(m.Tx.Coins) > 0 guard in the second switch block, fixing dead-code where the length check occurred after the access
  • Add unit test verifying empty Coins does not panic and correctly falls back to global trading halt

Test plan

  • Existing KeeperHaltSuite.TestIsTradingHalt passes (84 tests in keeper/v1)
  • New test case verifies empty Coins returns false when no halt, and true when global halt is set
  • make build succeeds
  • make lint passes

Merge request reports

Loading