Skip to content

Contract migration sends invalid state to old contract, causing 'Invalid signature' error #127

@iduartgomez

Description

@iduartgomez

Problem

When a room contract is migrated to a new WASM version, the migration code sends an upgrade pointer UPDATE to the old contract. This UPDATE fails with:

UPDATE operation failed: invalid contract update, reason: State verification failed: Invalid signature: signature error

This was observed in the browser console while the UI migrated room XQTMFW5V from old contract oW3AFr9RE15sm9d1dZwEQVMjaNJKwsyNbGUP1ptekE6 to new contract GD238LC8mu6FHfp33w9DVATyKaCa9n5CNnKUzyANzodj.

Root Cause

In ui/src/components/app/freenet_api/room_synchronizer.rs around line 449-453, the upgrade state is constructed as:

let upgrade_state = ChatRoomStateV1 {
    upgrade: OptionalUpgradeV1(Some(authorized_upgrade)),
    ..Default::default()   // ← BUG: empty/invalid state for all other fields
};

The ..Default::default() produces an empty configuration (with zeroed owner_member_id), empty members, etc. The old contract's state verification checks the entire submitted state for consistency and rejects it because the configuration fields are invalid/empty.

Expected Behavior

The upgrade pointer should be sent as a delta (not a full state replacement), or the full current room state should be included alongside the upgrade pointer so the old contract's validation passes.

Steps to Reproduce

  1. Have a room created with an older contract version
  2. Connect with a new River UI that triggers contract migration
  3. Observe the console error: UPDATE operation failed: ... Invalid signature: signature error

Impact

  • The upgrade pointer is never set on the old contract
  • Other clients can't follow the migration pointer to the new contract
  • The new contract subscription eventually fails with repeated timeout errors

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions