Skip to content

Commit

Permalink
Merge pull request #63 from eclipsevortex/release/2.2.5
Browse files Browse the repository at this point in the history
Release/2.2.5
  • Loading branch information
eclipsevortex authored Jun 4, 2024
2 parents 2bbc76d + faa3f14 commit c30ec49
Show file tree
Hide file tree
Showing 22 changed files with 627 additions and 201 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2.2.5 / 2024-05-31

## What's Changed
* resyn metagraph for miner by @eclipsevortex in https://github.com/eclipsevortex/SubVortex/pull/62
* fix subtensor by @eclipsevortex in https://github.com/eclipsevortex/SubVortex/pull/65
* fix country api by @eclipsevortex in https://github.com/eclipsevortex/SubVortex/pull/64
* adjust weight for the scores by @eclipsevortex in https://github.com/eclipsevortex/SubVortex/pull/66


**Full Changelog**: https://github.com/eclipsevortex/SubVortex/compare/v2.2.4...v2.2.5

## 2.2.4 / 2024-05-20

## What's Changed
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Team responsabilities

- **EclipseVortex** - Development and technology
- **Ch3RNØbØG** - Operations and business development
- **tww9** - Strategy and public relations
- **CryptoMinedMind** - Strategy and public relations
- **HcL-CO** - QA Lead and support

Team timezone
Expand Down Expand Up @@ -182,6 +182,7 @@ Bittensor technology is still new and promising, and participants are eager to s

- **Bittensor**: for providing a subnet template that enabled us to quickly set up our subnet.
- **Subtensor**: for their local subtensor, scripts, and invaluable assistance.
- **andrewoflaherty**: for implementing the country api using MaxMind and IPInfo ([github](https://github.com/OFlahertyAndrew))
- **Subnet Storage (SN21)**: for their excellent subnet design, which adheres to best practices and simplifies the lives of developers.
- **Users**: YES!!! Without you, we are nothing, and our vision to advance this new technology would never have materialized.
- **Others**: undoubtedly, there are many other contributors deserving of recognition, and we look forward to acknowledging them in the future.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.4
2.2.5
8 changes: 4 additions & 4 deletions docs/features/incentive_mechanism.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ The final score is the score for the current challenge. It will be computed as t

The weight for each score will be as follows:

- Availability: Weight will be **3** if the miner's subtensor is synchronized, and **1** otherwise.
- Latency: Weight will be **1**.
- Reliability: Weight will be **1**.
- Distribution: Weight will be **1**.
- Availability: Weight will be **8** if the miner's subtensor is synchronized, and **3** otherwise.
- Latency: Weight will be **7**.
- Reliability: Weight will be **3**.
- Distribution: Weight will be **2**.

So, the final formula will be calculated using the following expression

Expand Down
18 changes: 18 additions & 0 deletions neurons/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def __init__(self):
self.thread: threading.Thread = None
self.lock = asyncio.Lock()
self.request_timestamps: typing.Dict = {}
self.previous_last_updates = []

self.step = 0

Expand Down Expand Up @@ -263,6 +264,23 @@ def __exit__(self, exc_type, exc_value, traceback):
"""
self.stop_run_thread()

def should_sync_metagraph(self):
"""
True if the metagraph has been resynced, False otherwise.
"""
last_updates = self.subtensor.substrate.query(
module="SubtensorModule",
storage_function="LastUpdate",
params=[self.config.netuid],
)
if self.previous_last_updates == last_updates:
return False

# Save the new updates
self.previous_last_updates = last_updates

return True


def run_miner():
"""
Expand Down
48 changes: 29 additions & 19 deletions neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from subnet import __version__ as THIS_VERSION

from subnet.monitor.monitor import Monitor
from subnet.country.country import CountryService

from subnet.shared.checks import check_registration
from subnet.shared.utils import get_redis_password, should_upgrade
Expand All @@ -36,7 +37,6 @@
from subnet.shared.mock import MockMetagraph, MockDendrite, MockSubtensor

from subnet.validator.config import config, check_config, add_args
from subnet.validator.localisation import get_country, get_localisation
from subnet.validator.forward import forward
from subnet.validator.models import Miner
from subnet.validator.version import VersionControl
Expand Down Expand Up @@ -168,19 +168,6 @@ def __init__(self, config=None):
self.dendrite = bt.dendrite(wallet=self.wallet)
bt.logging.debug(str(self.dendrite))

# Get the validator country
self.country = get_country(self.dendrite.external_ip)
country_localisation = get_localisation(self.country)
country_name = (
country_localisation["country"] if country_localisation else "None"
)
bt.logging.debug(f"Validator based in {country_name}")

# Init wandb.
if not self.config.wandb.off:
bt.logging.debug("loading wandb")
init_wandb(self)

# Init the event loop.
self.loop = asyncio.get_event_loop()

Expand All @@ -195,6 +182,7 @@ def __init__(self, config=None):
self.rebalance_queue = []
self.miners: List[Miner] = []
self.last_upgrade_check = 0
self.last_upgrade_country = None

async def run(self):
bt.logging.info("run()")
Expand All @@ -203,17 +191,31 @@ async def run(self):
dump_path = self.config.database.redis_dump_path
self.version_control = VersionControl(self.database, dump_path)

# Monitor miners
self.monitor = Monitor(self.config.netuid)
self.monitor.start()

# Country service
self.country_service = CountryService(self.config.netuid)
self.country_service.start()
self.country_service.wait()

# Get the validator country
self.country_code = self.country_service.get_country(self.dendrite.external_ip)
bt.logging.debug(f"Validator based in {self.country_code}")

# Init wandb.
if not self.config.wandb.off:
bt.logging.debug("loading wandb")
init_wandb(self)

# Init miners
self.miners = await get_all_miners(self)
bt.logging.debug(f"Miners loaded {len(self.miners)}")

# Load the state
load_state(self)

# Monitor miners
self.monitor = Monitor(self.config.netuid)
self.monitor.start()

try:
while 1:
# Start the upgrade process every 10 minutes
Expand All @@ -229,7 +231,12 @@ async def run(self):

start_epoch = time.time()

await resync_metagraph_and_miners(self)
# Check if the coutry changed
last_upgrade_country = self.country_service.get_last_modified()
has_country_changed = self.last_upgrade_country != last_upgrade_country
self.last_upgrade_country = last_upgrade_country

await resync_metagraph_and_miners(self, has_country_changed)
prev_set_weights_block = self.metagraph.last_update[self.uid].item()

# --- Wait until next step epoch.
Expand Down Expand Up @@ -308,6 +315,9 @@ async def run_forward():
if self.monitor:
self.monitor.stop()

if self.country_service:
self.country_service.stop()

if hasattr(self, "subtensor"):
bt.logging.debug("Closing subtensor connection")
self.subtensor.close()
Expand Down
152 changes: 152 additions & 0 deletions scripts/release/release-2.2.5/RELEASE-2.2.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
This guide provides step-by-step instructions for the release 2.2.5.

Previous Release: 2.2.4

<br />

---

- [Validator](#validators)
- [Rollout Process](#validator-rollout-process)
- [Rollback Process](#validator-rollback-process)
- [Miner](#miner)
- [Rollout Process](#miner-rollout-process)
- [Rollback Process](#miner-rollback-process)
- [Additional Resources](#additional-resources)
- [Troubleshooting](#troubleshooting)

---

<br />

# Validator

## Rollout Process <a id="validator-rollout-process"></a>

1. **Upgrade Subnet**: Fetch the remote tags

```bash
git fetch --tags --force
```

Then, checkout the new release tag

```bash
git checkout tags/v2.2.5
```

Finally, install the dependencies

```bash
pip install --upgrade SubVortex
pip install -e .
```

2. **Restart validator**: Restart your validator to take the new version

```bash
pm2 restart validator-7
```

3. **Check logs**: Check the validator logs to see if you see some `New Block`
```bash
pm2 logs validator-7
```

<br />

## Rollback Process <a id="validator-rollback-process"></a>

If any issues arise during or after the rollout, follow these steps to perform a rollback:

1. **Downgrade Subnet**: Checkout the previous release tag

```bash
git checkout tags/v2.2.4
```

Then, install the dependencies

```bash
pip install --upgrade SubVortex
pip install -e .
```

2. **Restart validator**: Restart your validator to take the old version

```bash
pm2 restart validator-7
```

3. **Check logs**: Check the validator logs to see if you see some `New Block`
```bash
pm2 logs validator-7
```

<br />

# Miner

## Rollout Process <a id="miner-rollout-process"></a>

1. **Upgrade Subnet**: Fetch the remote tags

```bash
git fetch --tags --force
```

Then, checkout the new release tag

```bash
git checkout tags/v2.2.5
```

Finally, install the dependencies

```bash
pip install --upgrade SubVortex
pip install -e .
```

2. **Restart miner**: Restart your miner to take the new version

```bash
pm2 restart miner-7
```

3. **Check logs**: Check the miner logs to see if you see some `New Block`
```bash
pm2 logs miner-7
```

## Rollback Process <a id="miner-rollback-process"></a>

1. **Downgrade Subnet**: Checkout the previous release tag

```bash
git checkout tags/v2.2.4
```

Then, install the dependencies

```bash
pip install --upgrade SubVortex
pip install -e .
```

2. **Restart miner**: Restart your miner to take the old version

```bash
pm2 restart miner-7
```

3. **Check logs**: Check the miner logs to see if you see some `New Block`
```bash
pm2 logs miner-7
```

<br />

# Additional Resources

For any further assistance or inquiries, please contact [**SubVortex Team**](https://discord.com/channels/799672011265015819/1215311984799653918)
Loading

0 comments on commit c30ec49

Please sign in to comment.