Skip to content

Fix market visibility subscription bugs#365

Merged
crthpl merged 1 commit intomainfrom
worktree-fix-visibility-subscriptions
Mar 8, 2026
Merged

Fix market visibility subscription bugs#365
crthpl merged 1 commit intomainfrom
worktree-fix-visibility-subscriptions

Conversation

@crthpl
Copy link
Copy Markdown
Contributor

@crthpl crthpl commented Mar 7, 2026

Summary

  • Bug 1: Sudoed admins didn't receive real-time updates (Market, MarketSettled) for visibility-restricted markets. These were routed via send_private only to visible_to accounts, so admins with sudo who weren't in the list missed them entirely.
  • Bug 2: Non-admin users received broadcast updates (OrderCreated, OrdersCancelled, Redeemed) for markets they shouldn't see, because send_public had no visibility filtering on the receive side.
  • Fix: Always broadcast via send_public and add a should_filter_for_visibility check on the receive path that drops messages about markets the client can't see. Admin+sudo bypasses this filter.

Test plan

  • 9 new integration tests in websocket_visibility.rs covering:
    • Sudoed admin receives CreateMarket/SettleMarket/EditMarket for visible_to markets
    • Non-visible users don't receive OrderCreated/trade/settle broadcasts
    • Visible users still receive updates correctly (regression)
    • Initial data filtering still works for both admins and non-admins
  • All 57 existing tests pass (cargo test-all)
  • cargo clippy clean

Two bugs fixed:

1. Sudoed admins didn't receive real-time updates (CreateMarket,
   SettleMarket, EditMarket) for visibility-restricted markets because
   these were routed via send_private only to visible_to accounts.

2. Non-admin users received broadcast updates (OrderCreated,
   OrdersCancelled, Redeemed) for markets they shouldn't see because
   send_public had no visibility filtering.

Fix: always broadcast via send_public and filter on the receive side -
messages about markets the user can't see are dropped before sending
to the client. Admin+sudo bypasses this filter.
@crthpl crthpl requested a review from a team as a code owner March 7, 2026 16:48
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
platform Ready Ready Preview, Comment Mar 7, 2026 4:49pm

Request Review

@crthpl crthpl merged commit 296877c into main Mar 8, 2026
5 checks 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