Skip to content

fix: validator uses Subtensor.set_mechanism_weights() for CRv4#4

Merged
echobt merged 1 commit intomainfrom
dev
Dec 27, 2025
Merged

fix: validator uses Subtensor.set_mechanism_weights() for CRv4#4
echobt merged 1 commit intomainfrom
dev

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Dec 27, 2025

  • Subtensor handles CRv4/commit-reveal automatically based on chain config
  • Fetch weights from platform-server each epoch
  • Submit burn weights (UID 0) if no challenges available
  • Reveal pending commits in RevealWindowOpen (for non-CRv4)
  • Clean centralized architecture (no P2P)

Summary by CodeRabbit

Release Notes

  • New Features

    • Weight submission now integrates with Subtensor persistence layer for enhanced state management.
    • Automatic reveal handling for validator transactions replaces manual process.
    • Validator node operates in centralized validator mode.
  • Updates

    • Streamlined dependency footprint for reduced complexity.
    • Enhanced validator submission workflow with improved reliability.

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

- Subtensor handles CRv4/commit-reveal automatically based on chain config
- Fetch weights from platform-server each epoch
- Submit burn weights (UID 0) if no challenges available
- Reveal pending commits in RevealWindowOpen (for non-CRv4)
- Clean centralized architecture (no P2P)
@echobt echobt merged commit eda164e into main Dec 27, 2025
3 of 4 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Dec 27, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The validator-node crate undergoes dependency cleanup and major control-flow refactoring. Cargo.toml removes unused platform and utility crates while standardizing workspace dependencies. Main.rs integrates Subtensor persistence with CRv4-aware submission, updates CLI arguments, and modifies handle_block_event to wire in new signer and Subtensor parameters throughout the event loop.

Changes

Cohort / File(s) Summary
Dependency Cleanup
bins/validator-node/Cargo.toml
Removed platform crates (network, consensus, storage, challenge-runtime, etc.) and utility crates (futures, uuid, sha2, chrono, rand). Retained core platform dependencies and switched to workspace = true for shared crates (bittensor-rs, tokio, serde, reqwest, etc.).
Subtensor Integration & Function Signature Refactor
bins/validator-node/src/main.rs
Added version_key to Args; integrated Subtensor::with_persistence for state persistence; replaced BlockSync with Subtensor-backed weight submission. Updated handle_block_event signature to accept platform_client, subtensor, signer, netuid, version_key. Implemented CRv4-aware reveals and commit-window weight translation. Added Arc wrapping for platform_client and optional subsystems; adjusted logging to reflect centralized validator mode.

Sequence Diagram

sequenceDiagram
    participant EvtLoop as Event Loop
    participant Handler as handle_block_event
    participant PSClient as PlatformServerClient
    participant Subtensor
    participant Signer as BittensorSigner
    
    EvtLoop->>Handler: block_event + platform_client + subtensor + signer + netuid + version_key
    
    rect rgb(230, 245, 240)
        Note over Handler: COMMIT WINDOW
        Handler->>PSClient: fetch platform weights
        PSClient-->>Handler: weights
        Handler->>Handler: translate to mechanism weights
        Handler->>Signer: create signature
        Signer-->>Handler: signature
        Handler->>Subtensor: submit weights via ExtrinsicWait
        Subtensor-->>Handler: submission confirmed
    end
    
    rect rgb(245, 240, 230)
        Note over Handler: REVEAL WINDOW
        Handler->>Subtensor: trigger automatic reveal (CRv4)
        Subtensor-->>Handler: reveal complete
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Poem

🐰 A validator hops with glee,
Dependencies fall from the tree,
Subtensor's persistence takes the stage,
CRv4 reveals mark a brand new age,
With tighter bonds and cleaner code to see! 🌿✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66477bd and 3e0b1e5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • bins/validator-node/Cargo.toml
  • bins/validator-node/src/main.rs

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

echobt added a commit that referenced this pull request Feb 21, 2026
* fix(p2p-consensus): improve PBFT consensus security and reliability

- Add double-vote prevention in handle_prepare and handle_commit
- Validate ViewChange messages match NewView's view number
- Fix race conditions in consensus round handling
- Replace unwrap with proper error handling in finalize_evaluation
- Improve merkle proof generation with is_multiple_of check

* fix(storage): add size limits to bincode deserialization for security

- Add MAX_ENTRY_SIZE limits to prevent memory exhaustion attacks
- Use bincode::options().with_limit() for safe deserialization
- Ensure bincode compatibility with serialize defaults
- Fix ConflictResolution to use derive(Default)
- Apply clippy suggestions for improved code quality

* fix(secure-container-runtime): add container security hardening

- Add enhanced path traversal protection in policy validation
- Improve WebSocket transport security with better authentication
- Update container broker with improved error handling
- Add additional integration tests for security features

* fix(platform-server): secure API endpoints with signature verification

- Add signature verification to submit_evaluation endpoint
- Add signature verification to all validator API endpoints
- Secure CORS configuration and HTTP client error handling
- Fix broadcast authentication bypass vulnerability
- Add historical_weights pruning and JWT secret warning
- Implement Display trait instead of ToString for SubmissionStatus

* fix(validator): require authentication and improve security

- Require authentication for validator node operations
- Update container tests for security compliance
- Fix clippy warnings for iterator patterns

* chore: fix clippy warnings and apply code formatting

- Add allow attributes for await_holding_lock in p2p_client
- Apply cargo fmt formatting to all files
- Fix CORS configuration formatting in platform server
echobt added a commit that referenced this pull request Feb 21, 2026
…llenge storage validation (#4)

* feat(storage): add blockchain storage module for validator consensus

- Add BlockHeader struct with state roots, challenge roots, and signatures
- Add ValidatorSignature struct for attestations
- Add Block struct with transitions and computed hash
- Add StateTransition enum for state changes
- Add BlockchainStorage with full CRUD operations
- Support for historical state queries
- Implement 2f+1 signature verification
- Add comprehensive unit tests (23 tests)

* feat: add state root consensus protocol with fraud proofs

* feat(storage): add unified metadata registry module

Implements MetadataRegistry for centralized challenge storage validation:
- ChallengeMetadata: tracks schema version, merkle root, and config per challenge
- GlobalMetadata: tracks all challenges and combined state root
- Registry methods: register/unregister challenges, update state roots, validate
- Comprehensive unit tests (28 tests)

* feat(storage): add network-aware migration coordination

- Add NetworkMigrationStatus for tracking network-wide schema versions
- Add NetworkMigrationCoordinator for coordinating migrations across validators
- Add ChallengeMigration and ChallengeMigrationStatus for per-challenge migrations
- Add compute_migration_state_hash for migration verification
- Add ChallengeMigrationHandler trait for challenge-specific migrations
- Add comprehensive unit tests for all new functionality

* style: apply cargo fmt formatting
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