Skip to content

[Governance] Separate flag records by content type to prevent ID collisions #411

Description

@3m1n3nc3

Description

Flag records and flag counts are keyed only by target_id, while giveaways and help requests have separate counters in the same numeric range. This allows flagging or suspension behavior to collide across content types that share the same ID.

User Story

As a Protocol User,
I want to flag the exact content item I intended,
so that moderation actions do not accidentally affect a giveaway and help request that happen to share the same numeric ID.

Requirements and Context

  • Files / refs: contracts/geev-core/src/governance.rs, contracts/geev-core/src/types.rs, contracts/geev-core/src/test.rs
  • Replace FlagRecord(u64, Address) and FlagCount(u64) with content-type-aware keys
  • Update flag_content, get_flag_count, has_flagged, and auto_suspend to resolve the correct content type explicitly
  • Add regression tests covering same-ID giveaway and help-request coexistence

Suggested Implementation

1. Add a content type enum for Giveaway vs HelpRequest
2. Use (content_type, target_id, user) and (content_type, target_id) in governance storage
3. Require callers to specify content type when flagging and querying
4. Add regression tests proving same numeric IDs no longer collide

Acceptance Criteria

  • Flagging a help request cannot affect a giveaway with the same numeric ID
  • Flag counts are isolated per content type
  • Auto-suspension resolves the intended content item only

Submission Guidelines

  • Branch: fix/governance-flag-namespacing
  • Depends on: None
  • PR: fix(governance): namespace flags by content type to prevent id collisions

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions