gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
898 stars 374 forks source link

[META] r/boards"2" #3137

Open salmad3 opened 5 days ago

salmad3 commented 5 days ago

Context:

[!warning] Criteria is a WIP and subject to change

"boards" serves as a demo and reference implementation for social media-like boards with posts and interactions. The goal is to fully realize the previous r/demo/boards initiative and use it as the foundation for a social interaction dApp on gno.land. For mainnet, "boards" will provide immediate functionality and connect users from day one to drive user enablement and acquisition. "boards" is also an opportunity to test Gno and gno.land as both a dogfooding exercise and a stress test to strengthen the chain's elements.

This META issue maps out the development plan for boards2, including creation, management, moderation, governance, and forking.

To-Do

[!Important] Current conceptual model:

  • Board creation and management are controlled by a flexible permissions system.
  • A boards realm AdminDAO oversees realm-level operations like board creation, renaming, and freezing.
  • The system supports multiple roles: admins, moderators, and members, each with distinct permission levels.
  • A flagging system is implemented for content moderation with configurable thresholds.
  • Forking is allowed at the board level, with clear guidelines for managing duplicate content.
  • The implementation allows for future policy changes without significant code restructuring.
  • Boards can have configurable default visibility settings for posts.
  • Spam prevention measures are in place to maintain board quality.
  • GovDAO has ultimate control over the boards realm AdminDAO.
  • A mechanism exists for setting notification messages and freezing boards or the entire realm.
  • An upgrade path is provided for future versions of the boards realm without forcing immediate migration.
  • The system implements a multi-tiered governance structure:
    • GovDAO (top level)
    • Boards realm AdminDAO (realm level)
    • AdminDAO (board level)

System Relationships:

classDiagram
    class Board {
        <<realm>>
        +String name
        +Permissions permissions
        +UserDirectory userDirectory
        +Thread[] threads
    }

    class Thread {
        <<struct>>
        +String id
        +String title
        +Address author
        +Post[] posts
        +Flag[] flags
        +bool isLocked
    }

    class Post {
        <<struct>>
        +String id
        +String content
        +Address author
        +DateTime timestamp
        +Flag[] flags
    }

    class Flag {
        <<struct>>
        +Address user
        +String action
        +String reason
    }

    class Permissions {
        <<interface>>
        +WithPermission(user, action, args)
        +HasPermission(user, action, args)
        +GetRoles()
        +GetUsers(role)
    }

    class DefaultPermissions {
        +AdminDAO adminDAO
        +Map~Address, bool~ memberSet
    }

    class AdminDAO {
        <<package>>
        +Address[] admins
        +int threshold
        +ReviewProposal()
        +FreezeBoard()
        +SetNotificationMessage()
    }

    class BoardsRealmAdminDAO {
        <<realm>>
        +Address[] admins
        +int threshold
        +ReviewProposal()
        +FreezeRealm()
        +SetUpgradeNotification()
    }

    class UserDirectory {
        <<interface>>
        +Lookup(addr)
    }

    class UsersRealm {
        <<realm>>
        +LookupUser(name)
        +ValidateName(name)
    }

    class GovDAO {
        <<realm>>
        +ManageBoardsRealm()
    }

    Permissions <|.. DefaultPermissions : implements
    Board *-- Thread : contains
    Thread *-- Post : contains
    Post *-- Flag : has
    Thread *-- Flag : has
    Board *-- UserDirectory : has
    Board *-- Permissions : has
    DefaultPermissions --> AdminDAO : uses
    UserDirectory --> UsersRealm : interacts with
    BoardsRealmAdminDAO --> Board : manages
    GovDAO --> BoardsRealmAdminDAO : controls

Control Flow:

sequenceDiagram
    participant User
    participant Board
    participant Permissions
    participant AdminDAO
    participant UsersRealm
    participant BoardsRealmAdminDAO
    participant GovDAO

    User->>Board: Request Action (create/rename/fork)
    Board->>Permissions: WithPermission(user, action, args)
    alt Permission Denied
        Permissions-->>Board: Deny Action
        Board-->>User: Action Denied Message
    else Requires AdminDAO Approval
        Permissions->>Permissions: Check basic rules
        Permissions->>UsersRealm: Validate Name (if needed)
        UsersRealm-->>Permissions: Validation Result
        Permissions->>AdminDAO: Create Proposal
        Note over AdminDAO: Review Process
        AdminDAO-->>Permissions: Approve/Reject
        alt Approved
            Permissions-->>Board: Execute Action
            Board-->>User: Action Successful
        else Rejected
            Permissions-->>Board: Deny Action
            Board-->>User: Action Denied Message
        end
    end

    Note over BoardsRealmAdminDAO: Manages realm-level actions
    BoardsRealmAdminDAO->>Board: Freeze/Unfreeze Board
    BoardsRealmAdminDAO->>Board: Set Upgrade Notification

    GovDAO->>BoardsRealmAdminDAO: Control realm-level governance

Dependency Hierarchy:

graph TD
    A[GovDAO] -->|Controls| B[BoardsRealmAdminDAO]
    B -->|Manages| C[Board Creation]
    B -->|Manages| D[Board Forking]
    B -->|Manages| E[Board Renaming]
    B -->|Can| F[Freeze Realm]
    B -->|Can| G[Set Upgrade Notification]

    H[AdminDAO] -->|Manages| I[Individual Board]
    I -->|Has| J[Permissions]
    I -->|Contains| K[Posts]
    I -->|Contains| L[Threads]

    J -->|Enforces| M[Access Control]
    J -->|Manages| N[Role-based Permissions]

    O[DefaultPermissions] -->|Uses| H
    O -->|Implements| J

    P[UsersRealm] -->|Validates| Q[Board Names]
    P -->|Provides| R[User Directory]

    S[Permissions Interface] -->|Defines| T[WithPermission]
    S -->|Defines| U[HasPermission]
    S -->|Defines| V[GetRoles]
    S -->|Defines| W[GetUsers]

Acceptance Criteria:

Creation & Management:

Includes:

Permissions:

Includes:

Moderation:

Includes:

Forking:

Includes:

Considerations:

Current State of Related Components:

Underlying Components Enables Already in Gno? Implementation Required? In Progress? Related Issues
Copy-on-Write Can enables efficient data management without data duplication for forking No Yes Yes (#3126) N/A
AVL Tree Structure Will be used for handling of boards; can be used for ordered data like board names; quick lookups and uniqueness checks Yes (/p/demo/avl) No N/A N/A
Linked Lists Can manages sequences with frequent insertions/deletions, such as comment threads No Yes (custom implementation) No N/A
Hash Maps (Maps) Enables fast lookups for user roles, permissions, and other mappings Yes No N/A #1374 (Proposal for ordered tree-structured maps)
Validation Functions Can ensure uniqueness and correctness of board names and usernames To update To update To update N/A
Binary Search Algorithms Can provide fast retrieval of data in ordered collections To update To update To update N/A
Sorting Algorithms Ordering posts, comments, or boards based on criteria To update To update To update N/A
Serialization Utilities Can be used for data storage and transmission To update To update N/A N/A
Concurrency Primitives Ensures data consistency during concurrent access To update To update N/A N/A
salmad3 commented 1 day ago

[20-11-24]:

Criteria continues to evolve.