Skip to content

feat/burn#687

Merged
joellidin merged 2 commits into
devfrom
feat/burn
Jan 21, 2026
Merged

feat/burn#687
joellidin merged 2 commits into
devfrom
feat/burn

Conversation

@joellidin
Copy link
Copy Markdown
Collaborator

@joellidin joellidin commented Jan 21, 2026

  • (neurons) Add burn-only validator for transition
  • Bump run version

Description

Related Issue(s)

  • Closes #[issue number]

Type of Change

  • Feature (adding new functionality)
  • Fix (resolving a bug or issue)
  • Docs (documentation updates)
  • Refactor (code changes that don't affect functionality)
  • Maintenance (dependency updates or other maintenance)
  • Tests (adding or improving tests)
  • Breaking change (fix or feature with incompatible API changes)
  • Other: _____

Branch Naming

  • My branch follows the project's naming convention (e.g., feature/add-new-capability)

Commit Messages

  • My commits are small, atomic, and have proper commit messages
  • Commit messages are in imperative mood with a capitalized summary under 50 chars

Code Quality

  • I've performed a self-review of my code
  • I've added appropriate docstrings following the project's conventions
  • I've added proper logging where necessary (without trailing periods)
  • I've applied linting and formatting with Ruff
  • My code generates no new warnings

Testing

  • I've added tests for new functionality or bug fixes
  • All tests pass locally with my changes
  • Test coverage has not decreased

Documentation

  • I've updated documentation to reflect my changes
  • I've updated comments in hard-to-understand areas

If this is a breaking change

Screenshots/Examples

Additional Notes

Summary by CodeRabbit

  • New Features

    • Introduced a burn validator that performs periodic weight allocation to a fixed burn destination.
  • Chores

    • Streamlined validator startup configuration and execution method.
    • Updated version to 2.1.28.

✏️ Tip: You can customize this high-level summary in your review settings.

Implement temporary burn validator for 100% burn period until Crusades
launches. Replaces normal validator behavior during transition phase.

- Add neurons/burn.py to set 100% weight to UID 1 every 360 blocks
- Update entrypoint.sh to run burn.py instead of full validator
- Remove torchrun and wandb dependencies for burn mode
- Add periodic status logging every 2 minutes
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 21, 2026

Walkthrough

A new burn validator script (burn.py) is introduced that periodically sets weight to a burn address every 360 blocks. The entrypoint is updated to execute this script directly instead of using torchrun, and the package version is incremented from 2.1.27 to 2.1.28.

Changes

Cohort / File(s) Summary
Burn Validator Implementation
neurons/burn.py
New script implementing burn-only validation: polls blockchain, initializes wallet and subtensor clients, resolves user UID from metagraph, and calls subtensor.set_weights() with fixed BURN_UID and weight 1.0 every 360 blocks, with periodic status logging and error handling.
Entrypoint Configuration
scripts/entrypoint.sh
Updated validator branch to execute burn.py directly instead of torchrun; removes per-rank logging setup, wandb integration, and device specification; simplifies passed arguments to wallet, netuid, and subtensor.network.
Version Bump
src/tplr/__init__.py
Package version incremented from 2.1.27 to 2.1.28.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🔥 A burn validator hops into place,
Setting weights at a measured pace,
Every 360 blocks, like clockwork true,
The burn address gets its due! 🐰✨

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides two bullet points but lacks substantive detail in the Description section; checkboxes remain unchecked and most template sections are empty, making review difficult. Complete the Description section with explanation of what and why; check relevant Type of Change boxes; and confirm Code Quality and Testing checks were performed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat/burn' is extremely vague and does not adequately describe the main changes; it only indicates the branch naming convention without conveying what the feature accomplishes. Expand the title to something like 'Add burn-only validator for transition' to clearly communicate the primary change and its purpose.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #687   +/-   ##
=======================================
  Coverage   57.69%   57.69%           
=======================================
  Files          27       27           
  Lines        4990     4990           
=======================================
  Hits         2879     2879           
  Misses       2111     2111           
Files with missing lines Coverage Δ
src/tplr/__init__.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
scripts/entrypoint.sh (2)

9-14: WANDB_API_KEY is still required but unused for burn validators.

The environment variable check still requires WANDB_API_KEY for all node types, but burn.py doesn't use wandb. This will cause burn validators to fail startup unnecessarily if WANDB_API_KEY is not set.

Suggested fix: make WANDB_API_KEY conditional
-for var in WALLET_NAME WALLET_HOTKEY NODE_TYPE WANDB_API_KEY NETUID; do
+# Base required variables for all node types
+for var in WALLET_NAME WALLET_HOTKEY NODE_TYPE NETUID; do
     if [ -z "${!var}" ]; then
         echo "Error: $var environment variable is required"
         exit 1
     fi
 done
+
+# WANDB_API_KEY only required for miner and evaluator
+if [ "$NODE_TYPE" != "validator" ] && [ -z "$WANDB_API_KEY" ]; then
+    echo "Error: WANDB_API_KEY environment variable is required for $NODE_TYPE"
+    exit 1
+fi

30-31: wandb login is called unconditionally.

If the WANDB_API_KEY check is made conditional (as suggested above), this line will also need to be conditional to avoid failures for burn validators.

Suggested fix
-# Login to wandb non-interactively
-wandb login ${WANDB_API_KEY} --relogin
+# Login to wandb non-interactively (not needed for burn validator)
+if [ "$NODE_TYPE" != "validator" ]; then
+    wandb login ${WANDB_API_KEY} --relogin
+fi
🤖 Fix all issues with AI agents
In `@neurons/burn.py`:
- Around line 32-34: The call to
metagraph.hotkeys.index(wallet.hotkey.ss58_address) can raise ValueError if the
hotkey isn't registered; wrap the lookup in a try/except around the metagraph =
subtensor.metagraph(config.netuid) / my_uid assignment and catch ValueError,
then use tplr.logger.error to log a clear message that the wallet hotkey
(wallet.hotkey.ss58_address) is not found on the subnet (include config.netuid
and optionally the returned metagraph.hotkeys list or length), and then either
raise a more descriptive exception or exit gracefully so subsequent code (e.g.,
tplr.logger.info that uses my_uid) does not run with an undefined my_uid.
🧹 Nitpick comments (1)
neurons/burn.py (1)

62-68: Consider adding backoff on repeated weight-setting failures.

When set_weights fails, last_set_block is not updated, causing the script to retry immediately on the next 12-second cycle. If failures persist (e.g., network issues, rate limiting), this could lead to rapid retries. Consider adding a simple backoff or failure counter.

Example approach
+    consecutive_failures = 0
+    max_backoff = 300  # 5 minutes max
+
     while True:
         try:
             current_block = subtensor.block
             blocks_since_last = current_block - last_set_block
             blocks_until_next = max(0, WEIGHT_INTERVAL - blocks_since_last)

             if blocks_since_last >= WEIGHT_INTERVAL:
                 tplr.logger.info(
                     f"Block {current_block}: Setting weights to burn UID {BURN_UID}"
                 )

                 success, msg = subtensor.set_weights(
                     wallet=wallet,
                     netuid=config.netuid,
                     uids=[BURN_UID],
                     weights=[1.0],
                     wait_for_inclusion=True,
                 )

                 if success:
                     tplr.logger.info(
                         f"Weights set successfully at block {current_block}"
                     )
                     last_set_block = current_block
+                    consecutive_failures = 0
                 else:
                     tplr.logger.warning(f"Failed to set weights: {msg}")
+                    consecutive_failures += 1
+                    backoff = min(12 * (2 ** consecutive_failures), max_backoff)
+                    time.sleep(backoff)
+                    continue

Comment thread neurons/burn.py
Comment on lines +32 to +34
metagraph = subtensor.metagraph(config.netuid)
my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Handle unregistered hotkey gracefully.

If the wallet's hotkey is not registered on the subnet, list.index() raises a ValueError with a generic message. Consider wrapping this in a try-except with a clear error message to improve debuggability.

Suggested improvement
     metagraph = subtensor.metagraph(config.netuid)
-    my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
+    try:
+        my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
+    except ValueError:
+        tplr.logger.error(
+            f"Hotkey {wallet.hotkey.ss58_address} not registered on netuid {config.netuid}"
+        )
+        return
     tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
metagraph = subtensor.metagraph(config.netuid)
my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}")
metagraph = subtensor.metagraph(config.netuid)
try:
my_uid = metagraph.hotkeys.index(wallet.hotkey.ss58_address)
except ValueError:
tplr.logger.error(
f"Hotkey {wallet.hotkey.ss58_address} not registered on netuid {config.netuid}"
)
return
tplr.logger.info(f"Running burn on UID {my_uid}, netuid {config.netuid}")
🤖 Prompt for AI Agents
In `@neurons/burn.py` around lines 32 - 34, The call to
metagraph.hotkeys.index(wallet.hotkey.ss58_address) can raise ValueError if the
hotkey isn't registered; wrap the lookup in a try/except around the metagraph =
subtensor.metagraph(config.netuid) / my_uid assignment and catch ValueError,
then use tplr.logger.error to log a clear message that the wallet hotkey
(wallet.hotkey.ss58_address) is not found on the subnet (include config.netuid
and optionally the returned metagraph.hotkeys list or length), and then either
raise a more descriptive exception or exit gracefully so subsequent code (e.g.,
tplr.logger.info that uses my_uid) does not run with an undefined my_uid.

@joellidin joellidin merged commit dc9a5f1 into dev Jan 21, 2026
7 of 8 checks passed
@joellidin joellidin deleted the feat/burn branch January 21, 2026 01:59
@coderabbitai coderabbitai Bot mentioned this pull request Jan 21, 2026
21 tasks
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