Skip to content

Add repos-v0 registry contract crate - #1665

Open
LandynDev wants to merge 1 commit into
feature/repo-registrationfrom
feat/2a-2-repos-v0-contract
Open

Add repos-v0 registry contract crate#1665
LandynDev wants to merge 1 commit into
feature/repo-registrationfrom
feat/2a-2-repos-v0-contract

Conversation

@LandynDev

Copy link
Copy Markdown
Collaborator

Part of repo-registration phase 2a (task 2a-2). Implements the repos-v0 ink! 5 contract per gt-utils spec specs/repo-registry-contract.md, mirroring the issues-v0 crate layout.

What it does

  • Repository registry keyed by GitHub numeric id: register / deregister / transfer_ownership / update_full_name (rate-limited rename follow)
  • Dynamic registration fee: Bittensor-style price curve (halvings by shift + Q32 fractional multiply, exact port of subtensor misc.rs), pulled from the caller's stake via CallerTransferStakeV1 and recycled via RecycleAlphaV1; delta-verified so a silent shortfall reverts
  • Count-based prune of the least-supported non-immune repo when full (all-immune registers reject before any fee is taken); select_victim is the single 2b swap point for stake-weighted selection
  • Per-repo hyperparams as key-value with owner-settable bounds (26 seeded keys), label multipliers, branch patterns
  • Whitelist-gated validator baskets (set_basket, weights sum 65535, entries validated against active registry)
  • Owner admin: pause, set_code_hash upgrade path, config with price_last re-clamp, force_deregister escape hatch
  • Launch constants per spec: MAX_REPOS=32, 30d immunity (216000 blocks), 500-alpha floor
  • Storage layout byte-offsets documented in lib.rs for the python childstate reader; all events carry github_id + full_name for the mirror reconciler

Spec deviations (flagging for review)

  1. register(github_id, full_name, fee_hotkey) — third param added; stake is keyed by hotkey so the contract cannot locate the caller's alpha without it
  2. Params/labels stored as Mapping<u64, Vec<(k, v)>> per repo instead of tuple-keyed cells — tuple keys are unenumerable for the pure-storage python reader
  3. Hard caps not in spec: MAX_REPOS_HARD=256, MAX_VOTERS=64, MAX_PARAM_KEYS=64
  4. Pruned/deregistered repos keep their Repo record with active=false; stale basket entries fail re-validation on next set_basket

Verification

  • 71/71 unit tests, clippy 0 warnings (cargo contract build not run — cargo-contract not installed locally)
  • Price-curve golden vectors (PRICE_GOLDEN, 14 cases + DECAY_FACTOR_GOLDEN) generated from an independent integer-exact python replica; these seed the 2a-3 python client port
  • Contract-security checklist reviewed: owner/repo-owner/voter authorization on every mutating message, saturating arithmetic throughout, chain-ext return values checked, bounded iteration (repos <= 256, voters <= 64), state cleanup on removal verified by tests

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant