Conversation
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
WalkthroughA new burn validator script ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## dev #687 +/- ##
=======================================
Coverage 57.69% 57.69%
=======================================
Files 27 27
Lines 4990 4990
=======================================
Hits 2879 2879
Misses 2111 2111
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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_KEYfor all node types, butburn.pydoesn't use wandb. This will cause burn validators to fail startup unnecessarily ifWANDB_API_KEYis 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_weightsfails,last_set_blockis 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
| 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}") |
There was a problem hiding this comment.
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.
| 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.
Description
Related Issue(s)
Type of Change
Branch Naming
Commit Messages
Code Quality
Testing
Documentation
If this is a breaking change
Screenshots/Examples
Additional Notes
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.