Skip to content

feat: Graceful room contract WASM upgrades #63

@sanity

Description

@sanity

Problem

When the room contract WASM is updated (e.g., to fix bugs like the StateSummary size issue), existing rooms cannot be upgraded in place. The contract key is derived from hash(WASM + parameters), so changing the WASM produces a different contract key, effectively creating a new room.

Currently, upgrading requires:

  1. Recreating the room with new WASM
  2. Users manually migrating to the new room
  3. Losing message history or manually migrating state

Proposed Solution

Implement a graceful upgrade mechanism using the existing upgrade: OptionalUpgradeV1 field in ChatRoomStateV1:

Phase 1: Basic Upgrade Pointer

  • Room owner can set the upgrade field to point to a new contract key
  • UI/CLI detects upgrade pointer and prompts users to migrate
  • Old room remains readable but new messages go to upgraded room

Phase 2: Automatic Migration (Future)

  • UI automatically follows upgrade pointers
  • State migration tooling to copy messages/members to new room
  • Invitation links could resolve through upgrade chain

Context

Discovered while investigating #StateSummary size issue - the Official Freenet room was created with old contract WASM that serializes full state instead of compact summaries (14KB vs ~500 bytes). The only current fix is room recreation.

Tasks

  • Add riverctl room upgrade <old-room> <new-room> command to set upgrade pointer
  • UI: Detect and display upgrade notifications
  • UI: "Follow upgrade" button to subscribe to new room
  • Documentation for room upgrade process
  • (Future) State migration tooling

[AI-assisted - Claude]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions