This script allows you to fetch and adjust validator weights within a Bittensor subnet. It connects to a specified subnet, fetches validators, and enables simulated weight modifications. The script iteratively adjusts weights for specified validators and redistributes remaining weights to maintain a consistent total of 1 across all validators.
- Python 3.7 or higher
bittensorlibrarynumpylibrarytorchlibrary
-
Clone this repository:
git clone https://github.com/yourusername/validator-weight-adjustment.git cd validator-weight-adjustment -
Create and activate a virtual environment (optional)
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install bittensor numpy torch
-
Run the script
python validator_weights.py
-
Specify the subnet
You’ll be prompted to enter a subnet ID (between1and52) to specify which subnet you want to examine. -
View and modify weights
- The script will fetch and display validators in the specified subnet.
- After displaying initial weights, you can enter a
UIDand specify a new weight value (in percent) for a particular validator in the emissions column. - The script will adjust other weights for the validator proportionally to ensure the total remains
1. - To exit the weight modification process, enter
Xwhen prompted.
- Review updated weights
After modifying weights, the script will display the updated weight distribution.
Enter the subnet ID (1-52): 5
Weight from UID[2] = 0.20%
Weight from UID[6] = 1.50%
...
Enter UID to simulate change weight (or 'X' to exit): 2
Enter new weight value for UID[2] in %: 1.5
Updated Weight from UID[2] = 1.5%
...
Enter UID to simulate change weight (or 'X' to exit): X
Exiting weight modification.This project is licensed under the MIT License - see the LICENSE file for details.