-
Notifications
You must be signed in to change notification settings - Fork 5
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
Implementing logic #7
Merged
grzegorz-leszczynski-reef
merged 32 commits into
bactensor:master
from
ggleszczynski:features/implementation
Jan 3, 2025
Merged
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
0dbf21f
feat: implement enabling shield
9648ecb
fix: fixes after code review
6f321c7
feat: shield logic finished
23fccc4
fix: code review fixes
290fc3d
feat: add serialization logic
1c69b99
feat: logic finished
6b4abe1
feat: encryption manager refactored
34a9cf7
feat: add memory implementation for some managers
168de86
feat: finish memory implementations for all managers along with full …
8f975a7
fix: finish tests for shield with needed fixes (there is still proble…
7f1873c
feat: back to EncryptionManager using ECIES library
4d7fba3
fix: added hash to manifest file to verify if content is the same
9802e2d
feat: implemented Route53AddressManager
16603b6
feat: implemented SQLAlchemyMinerShieldStateManager
6b24602
feat: implemented S3ManifestManager
82e330c
feat: added integration test
968f045
feat: filling AwsAddressManager, work in progress
935c2e6
feat: added possibility of specyfing IP in AwsAddressManager
6ba1675
feat: filling AwsAddressManager - creating ELB is working
2ac5dd7
feat: filling AwsAddressManager - creating HostedZone during ELB crea…
097b2de
feat: filling AwsAddressManager - creating alias DNS entry in Route53
dc62a30
feat: finished AwsAddressManager - added creating firewall
c9d3b75
feat: back to passing hosted_zone_id to AwsAddressManager
845ec8a
fix: tiny code review fixes
44ebe33
Add AWSClientFactory
grzegorz-leszczynski-reef 840941e
Use pytest fixture in TestAddressManager
grzegorz-leszczynski-reef 54de75f
Simplify code after CR
grzegorz-leszczynski-reef d2bc4a4
Upgrade handling AWS API errors
grzegorz-leszczynski-reef 030cba1
Add project dependencies
grzegorz-leszczynski-reef 5e27248
Apply ruff linter fixes
grzegorz-leszczynski-reef 78ad8f2
Add MinerShieldFactory
grzegorz-leszczynski-reef 4af7d75
Implement Validator
grzegorz-leszczynski-reef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,25 +30,27 @@ The goal of this project is to implement a distributed and decentralized system | |||||
- Validators can request the connection information of miners from the subtensor network. This information is validated and | ||||||
decrypted locally using the validator's private key. | ||||||
|
||||||
## Communication Flow | ||||||
## Basic Communication Flow | ||||||
|
||||||
<!-- | ||||||
@startuml ./assets/diagrams/CommunicationFlow | ||||||
participant Validator | ||||||
participant Miner | ||||||
participant GitHub | ||||||
participant AddressManager | ||||||
participant Storage | ||||||
participant Bittensor | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Validator -> Validator: Generate Validator key-pair | ||||||
Validator -> GitHub: Publish public key along with HotKey | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
GitHub -> Miner: Fetch Validator info | ||||||
Miner -> Miner: Encrypt Miner IP/Domain with Validator public key | ||||||
Miner -> Storage: Add/update file with encrypted IPs/Domains for Validators | ||||||
GitHub -> Miner: Fetch new Validator info | ||||||
Miner -> AddressManager: Generate new address | ||||||
Miner -> Miner: Encrypt generated address with Validator public key | ||||||
Miner -> Storage: Update file with encrypted addresses for Validators | ||||||
Miner -> Bittensor: Publish file location | ||||||
Bittensor -> Validator: Fetch file location | ||||||
Storage -> Validator: Fetch Miner file | ||||||
Validator -> Validator: Decrypt Miner file entry encrypted for given Validator | ||||||
Validator -> Miner: Send request using decrypted Miner IP/Domain | ||||||
Validator -> Miner: Send request using decrypted Miner address | ||||||
@enduml | ||||||
--> | ||||||
|
||||||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | ||||
---|---|---|---|---|---|---|
|
@@ -29,24 +29,27 @@ def __init__(self, address_id, address_type: AddressType, address: str, port: in | |||||
self.address = address | ||||||
self.port = port | ||||||
|
||||||
def __repr__(self): | ||||||
return f"Address(id={self.address_id}, type={self.address_type}, address={self.address}:{self.port})" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
@abstractmethod | ||||||
def encrypt(self) -> bytes: | ||||||
def serialize(self) -> bytes: | ||||||
""" | ||||||
Encrypts address data. | ||||||
Serialize address data. | ||||||
|
||||||
Returns: | ||||||
bytes: Encrypted address data. | ||||||
bytes: Serialized address data. | ||||||
""" | ||||||
pass | ||||||
|
||||||
@classmethod | ||||||
@abstractmethod | ||||||
def decrypt(cls, encrypted_data: bytes): | ||||||
def deserialize(cls, serialized_data: bytes) -> 'Address': | ||||||
""" | ||||||
Create address from encrypted address data. | ||||||
Deserialize address data. | ||||||
|
||||||
Args: | ||||||
encrypted_data: Encrypted address data. | ||||||
serialized_data: Data serialized before by serialize method. | ||||||
|
||||||
Returns: | ||||||
Address: Created address. | ||||||
|
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 |
---|---|---|
@@ -1,17 +1,33 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from bt_ddos_shield.utils import Hotkey | ||
|
||
|
||
class AbstractBlockchainManager(ABC): | ||
""" | ||
Abstract base class for manager handling publishing blocks to blockchain. | ||
""" | ||
|
||
@abstractmethod | ||
def publish(self, data: bytes): | ||
def put(self, hotkey: Hotkey, data: bytes): | ||
""" | ||
Puts data to blockchain. | ||
|
||
Args: | ||
hotkey: Hotkey of user for whom we are putting data. | ||
data: Data. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def get(self, hotkey: Hotkey) -> bytes: | ||
""" | ||
Gets data from blockchain. | ||
|
||
Args: | ||
hotkey: Hotkey of user to get data from. | ||
|
||
Returns: | ||
data: Last block of data put by user. | ||
""" | ||
pass |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.