Skip to content

[CRITICAL] referral_registry/src/lib.rs and tests.rs are empty on main — entire contract deleted by a bad merge #190

Description

@Dayz-tech-co

Summary

referral_registry/src/lib.rs and referral_registry/src/tests.rs are both 0 bytes on main right now — confirmed via the GitHub API directly against the default branch, independent of any local checkout:

$ gh api repos/SPulse-Org/SPulse-Contract/contents/referral_registry/src/lib.rs?ref=main -q '.size, .name'
0
lib.rs
$ gh api repos/SPulse-Org/SPulse-Contract/contents/referral_registry/src/tests.rs?ref=main -q '.size, .name'
0
tests.rs

The entire referral-registry contract — referrer registration, welcome bonuses, lifetime-earnings caps, admin-withdrawable surplus, pause circuit breaker, TTL lifecycle — is gone. Any contract that depends on referral_registry (e.g. prediction_market's test suite, which imports referral_registry::ReferralRegistryContract) cannot build.

Root cause

Commit 670ed9b ("Merge branch 'main' into fix/issue-77", 2026-08-22 15:15:28 +0100) deleted all 704 lines of lib.rs:

$ git show 670ed9b --stat -- referral_registry/src/lib.rs
 referral_registry/src/lib.rs | 704 -------------------------------------------

Both merge parents (947a306's descendant 28a3e95, and ef7e77b) had byte-for-byte identical, non-empty (689-line) content for this file — confirmed with a direct diff. There was no actual conflict on this file to resolve; the deletion was a pure mistake in how the merge was carried out (likely an ours/theirs/git rm misstep), not a judgment call between two diverging versions.

Why this isn't a simple git-revert

I attempted to restore the pre-deletion content (from 28a3e95/ef7e77b, 689 lines) as a fix. It doesn't compile either — the corruption predates the deletion:

  • require_not_paused has no closing brace and runs directly into an immediately-following pub fn is_paused, with no separation.
  • register_referral contains two overlapping, half-duplicated vec![...] blocks for the welcome-bonus cross-contract call — one calling add_bonus_pts via invoke_contract, another calling queue_bonus_reward via try_invoke_contract, tangled together.

Tracing further: the "pause / circuit breaker" feature was implemented independently in two separate efforts — issue #83 ("Add emergency pause/circuit-breaker to all four contracts") and issue #95 ("feat: add emergency pause / circuit breaker to market, registry and token") — and merged together badly, well before the later 670ed9b deletion compounded the damage.

What this needs

A real, careful manual reconciliation:

  1. Figure out the intended final behavior of the pause feature (likely: keep one clean is_paused/require_not_paused pair, drop the duplicate).
  2. Figure out which welcome-bonus call path (add_bonus_pts direct invoke vs. queue_bonus_reward queued) is the intended current design — they may both be legitimate at different points in history, only one should remain.
  3. Once a clean, compiling version is reconstructed, restore it, verify cargo test -p referral_registry passes, then verify cargo test --workspace (which currently cannot even attempt to compile past this).

This is a bigger, riskier task than a merge repair — it's real contract-logic reconciliation in a contract that handles referrer earnings and token minting, and deserves focused review rather than being rushed alongside an unrelated PR. I ran into this while working on #24 (PR #185) and am flagging it separately rather than trying to fix it there.

Impact

Every contract depending on referral_registry is currently unbuildable in its test form. This blocks verifying prediction_market, and by extension any change that needs the full workspace test suite to pass.

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