-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from backend-developers-ltd/faci-requests
Added fv_protocol package to compute_horde
- Loading branch information
Showing
10 changed files
with
145 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
compute_horde/compute_horde/fv_protocol/validator_requests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import Any, Self | ||
|
||
import bittensor | ||
from pydantic import BaseModel | ||
|
||
|
||
class V0Heartbeat(BaseModel, extra="forbid"): | ||
"""Message sent from validator to facilitator to keep connection alive""" | ||
|
||
message_type: str = "V0Heartbeat" | ||
|
||
|
||
class V0AuthenticationRequest(BaseModel, extra="forbid"): | ||
"""Message sent from validator to facilitator to authenticate itself""" | ||
|
||
message_type: str = "V0AuthenticationRequest" | ||
public_key: str | ||
signature: str | ||
|
||
@classmethod | ||
def from_keypair(cls, keypair: bittensor.Keypair) -> Self: | ||
return cls( | ||
public_key=keypair.public_key.hex(), | ||
signature=f"0x{keypair.sign(keypair.public_key).hex()}", | ||
) | ||
|
||
def verify_signature(self) -> bool: | ||
public_key_bytes = bytes.fromhex(self.public_key) | ||
keypair = bittensor.Keypair(public_key=public_key_bytes, ss58_format=42) | ||
# make mypy happy | ||
valid: bool = keypair.verify(public_key_bytes, self.signature) | ||
return valid | ||
|
||
@property | ||
def ss58_address(self) -> str: | ||
# make mypy happy | ||
address: str = bittensor.Keypair( | ||
public_key=bytes.fromhex(self.public_key), ss58_format=42 | ||
).ss58_address | ||
return address | ||
|
||
|
||
class V0MachineSpecsUpdate(BaseModel, extra="forbid"): | ||
"""Message sent from validator to facilitator to update miner specs""" | ||
|
||
message_type: str = "V0MachineSpecsUpdate" | ||
miner_hotkey: str | ||
validator_hotkey: str | ||
specs: dict[str, Any] | ||
batch_id: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.