Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(weights): implementation and testing #18

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

grantdfoster
Copy link
Contributor

@grantdfoster grantdfoster commented Feb 10, 2025

Summary of Changes

1. Makefile Enhancements

  • New Test Targets: Added test-weights-unit and test-weights-e2e targets to the Makefile for running unit and end-to-end tests related to weights management.

2. New Data Class in interfaces/types.py

  • NodeData Class: Introduced a new NodeData class with attributes hotkey, posts, uptime, and latency. This class is designed to encapsulate node-related data and is marked as JSONSerializable.

3. Version Update in neurons/__init__.py

  • Version Bump: Updated the version from 0.3.0 to 2.0.0, indicating significant changes or improvements in the codebase.

4. Validator Enhancements in neurons/validator.py

  • New Managers: Integrated WeightsManager and NodeDataScorer into the Validator class.
  • Background Task: Added a new asynchronous task set_weights_loop to periodically set weights using the WeightsManager.

5. New Tests for Weights Management

  • End-to-End Test (tests/test_weights_e2e.py): Created a test to verify the end-to-end functionality of the weights management system, including weight calculation and setting.
  • Unit Test (tests/test_weights_unit.py): Developed unit tests for the WeightsManager, focusing on weight calculation and setting logic with mocked dependencies.

6. Background Task in validator/background_tasks.py

  • Set Weights Loop: Implemented a new background task set_weights_loop to continuously update node weights based on data from NodeDataScorer.

7. Node Data Scoring in validator/scorer.py

  • NodeDataScorer Class: Introduced a class to score node data, currently using a stub for node data. This class is intended to be expanded to fetch real data in the future.

8. Weights Management in validator/weights.py

  • WeightsManager Class: Added a class to manage node weights, including methods to calculate and set weights on the blockchain.
    • Weight Calculation: Weights are calculated based on node post counts, normalized across the range of posts.
    • Blockchain Interaction: Ensures weights are set on the blockchain, respecting minimum intervals between updates and handling retries on failure.

Key Features and Improvements

  • Modular Design: The introduction of WeightsManager and NodeDataScorer promotes a modular approach, making the system more maintainable and extensible.
  • Automated Testing: New tests ensure the reliability of the weights management system, facilitating future development and refactoring.
  • Background Processing: The addition of background tasks for syncing and setting weights enhances the system's efficiency and responsiveness.

This pull request significantly enhances the functionality related to node weight management, providing a robust framework for future developments in this area.

@grantdfoster grantdfoster self-assigned this Feb 10, 2025
@grantdfoster grantdfoster linked an issue Feb 10, 2025 that may be closed by this pull request
3 tasks
@grantdfoster grantdfoster marked this pull request as ready for review February 10, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(core): setting weights
1 participant