Skip to content

Commit

Permalink
release/3.5.0 (#1006)
Browse files Browse the repository at this point in the history
* [feature] external axon flags (#887)

* add external axon changes

* add defaults for new axon flags

* fix args to axon

* default to internal ip and port if not specified

* add new args and todefaults

* add axon unit tests

* add description for subtensor integration test

* move test to unit test

* create new test file
add/update copyright notices

* don't default to internal ip

* add tests for setting the full_address

* add tests for subtensor.serve w/external axon info

* allow external port config to be None

* switch to mock instead of patch

* fix test mocks

* change mock config create

* fix/add default config

* change asserts add mesage

* fix check call args

* fix mock config set

* only call once

* fix help wording

* should be True

* [fix] fixes unstake with max-stake flag (#905)

* add equality to None to the balance class

* add tests for the None case

* local train bug fix (#906)

* [feature] [CUDA solver] Add multi-GPU and ask for CUDA during btcli run (#893)

* added cuda solver

* boost versions to fix pip error

* allow choosing device id

* fix solution check to use keccak

* adds params for cuda and dev_id to register

* list devices by name during selection

* add block number logging

* fix calculation of hashrate

* fix update interval default

* add --TPB arg to register

* add update_interval flag

* switch back to old looping/work structure

* change typing

* device count is a function

* stop early if wallet registered

* add update interval and num proc flag

* add better number output

* optimize multiproc cpu reg
keeping proc until solution

* fix test

* change import to cubit

* fix import and default

* up default
should have default in CLI call

* add comments about params

* fix config var access

* add cubit as extra

* handle stale pow differently
check registration after failure

* restrict number of processes for integration test

* fix stale check

* use wallet.is_registered instead

* attempt to fix test issue

* fix my test

* oops typo

* typo again ugh

* remove print out

* fix partly reg test

* fix if solution None

* fix test?

* fix patch

* add args for cuda to subtensor

* add cuda args to reregister call

* add to wallet register the cuda args

* fix refs and tests

* add for val test also

* fix tests with rereg

* fix patch for tests

* add mock_register to subtensor passed instead

* move register under the check for isregistered

* use patch obj instead

* fit patch object

* fix prompt

* remove unneeded if

* modify POW submit to use rolling submit again

* add backoff to block get from network

* add test for backoff get block

* suppress the dev id flag if not set

* remove dest so it uses first arg

* fix pow submit loop

* move registration status with

* fix max attempts check

* remove status in subtensor.register

* add submit status

* change to neuron get instead

* fix count

* try to patch live display

* fix patch

* .

* separate test cases

* add POWNotStale and tests

* add more test cases for block get with retry

* fix return to None

* fix arg order

* fix indent

* add test to verify solution is submitted

* fix mock call

* patch hex bytes instead

* typo :/

* fix print out for unstake

* fix indexing into mock call

* call indexing

* access dict not with dot

* fix other indent

* add CUDAException for cubit

* up cubit version

* [Feature] ask cuda during btcli run (#890)

* add ask for cuda reg config in btcli run

* suppress unset arg

* [Feature] [cuda solver] multi gpu (#891)

* change diff display out

* remove logging

* check cubit support in the check config

* allow 1 or more devices in flag

* cuda flag should be suppress

* modify how cpu count is found

* make a solver base class

* add a solverbase for CUDA

* use mutli process kernel launching, one per GPU

* move check under dot get accessor

* Feature/cuda solver multi gpu (#892)

* change diff display out

* remove logging

* check cubit support in the check config

* allow 1 or more devices in flag

* cuda flag should be suppress

* modify how cpu count is found

* make a solver base class

* add a solverbase for CUDA

* use mutli process kernel launching, one per GPU

* move check under dot get accessor

* add All gpus specification

* continue trying reg after Stale

* catch for OSX

* dont use qsize

* add test for continue after being stale

* patch get_nowait instead of qsize

* [Docs] Update old docs link to new link. Change discord invite to custom link (#915)

* Update old docs link to new one

This change deletes the old gitbooks documentation link and replaces it with the new one.

* fix discord links

Co-authored-by: Mac Thrasher <95183714+quac88@users.noreply.github.com>

* Fix for test_neuron.py (#917)

prevents downloading from huggingface

* [feature] add --seed option to regen_hotkey (#916)

* add seed option to regen hotkey

* make seed optional and fix docstring

* add tests for both coldkey and hotkey regen w/seed

* oops, make seed optional

* fix old test, add config.seed

* circle ci version update and fix (#920)

* Add test_phrases_split unit test

Asserts that randomly instantiated compact_topk encodings can be correctly decoded to recover the original topk_tensor.

* Update unravel_topk_token_phrases with faster implementation

Replaces .tensor_split() with block indexing to avoid extra copy operations.

* Rename test_phrases_split to test_random_topk_token_phrases

* Unit tests cleanup (#922)

* circle ci version update and fix

* Test clean up

* uncomment test and remove specific test

* remove loguru and fix flaky tests

* fix syncing

* removing tokenizer equivalence + some bug fixes

* moving old dataset test

* Deactivate test_random_topk_token_phrases unit test

* Create topk_tensor on origin device

* Normalization Update (#909)

* local train bug fix

* normalization update

* fix tests

* remove test

* updated normalization

* Naming changes, bug fixes

* subtensor update for max clip

* max weight to a million

* Fixes for ordering and comments

* additional tests

* string fix

* numerical stability and testing updates

* minor update for division by zero

* Naming and spacing fixes

* epsilon update

* small fix

* Adding development workflow documentation and script for bumping the version (#918)

BIT-582 Adding development workflow documentation and script for bumping the version

* Revert "Normalization Update (#909)"

This reverts commit 3990a28.

* Parachain registration (#912)

* removed ws assumption

* removing check

* never registered

* Fixed sched_getaffinity for mac osx

* Started adding parachain support

* [hot-fix] fix indent again. add test (#907)

fix indent again. add test

* Fixed registration check and first time registration

* Removed old entrypoint list structure

* Fixed unit tests

Co-authored-by: Eugene <etesting007@gmail.com>
Co-authored-by: Ala Shaabana <ala@bittensor.com>
Co-authored-by: Cameron Fairchild <cameron.fairchild@mail.utoronto.ca>

* Bit 583 memory optimization v4 (#929)

* set allowed receptor to be 0 in validator to not store any receptor

* max_active receptro to 0

* fix

* feature/BIT-579/Adding Prometheus (#928)

* BIT-582 Adding development workflow documentation and script for bumping the version

* BIT-579 Adding prometheus_client==0.14.1 to requirements

* BIT-579 Removing wandb defaults from sample_configs

* Revert "BIT-579 Removing wandb defaults from sample_configs"

This reverts commit 2940cc7.

* BIT-579 Starting prometheus code. Adding metric_exporter concept/element and its MetricsExporterFactory

* BIT-579 Adding prometheus_client==0.14.1 to requirements

* BIT-579 Removing wandb defaults from sample_configs

* Revert "BIT-579 Removing wandb defaults from sample_configs"

This reverts commit 2940cc7.

* BIT-579 Starting prometheus code. Adding metric_exporter concept/element and its MetricsExporterFactory

* Revert "BIT-579 Starting prometheus code. Adding metric_exporter concept/element and its MetricsExporterFactory"

This reverts commit 8742d7f.

* BIT-579 Adding _prometheus to bittensor

* BIT-579 Adding prometheus code to bittensor/_neuron/text/core_*

* BIT-579 Adding prometheus code to bittensor/_config/config_impl.py. Sends the config to the inprocess prometheus server if it exists.

* BIT-579 Adding prometheus code to bittensor/_axon/*

* BIT-579 Adding prometheus code to bittensor/_dendrite/*

* BIT-579 Fixing syntax error

* BIT-579 Fixing missing import: time

* BIT-579 fixing typo

* BIT-579 fixing test: unit_tests/bittensor_tests/test_neuron.py

Co-authored-by: Unconst <32490803+unconst@users.noreply.github.com>

* Dendrite Text Generate (#941)

* adds generate to dendrite

* vune fixes

* extend readme

Co-authored-by: unconst <jake@bittensor.com>

* Subtensor and Normalization updates (#936)

* local train bug fix

* normalization update

* fix tests

* remove test

* updated normalization

* Naming changes, bug fixes

* subtensor update for max clip

* max weight to a million

* Fixes for ordering and comments

* additional tests

* string fix

* numerical stability and testing updates

* minor update for division by zero

* Naming and spacing fixes

* epsilon update

* small fix

* additional subtensor parameters

* remove print

* help string fixes

* Prometheus bug fix (#942)

* local train bug fix

* normalization update

* fix tests

* remove test

* updated normalization

* Naming changes, bug fixes

* subtensor update for max clip

* max weight to a million

* Fixes for ordering and comments

* additional tests

* string fix

* numerical stability and testing updates

* minor update for division by zero

* Naming and spacing fixes

* epsilon update

* small fix

* additional subtensor parameters

* remove print

* help string fixes

* small bug fix

* [Fix] only reregister if flag is set (#937)

* add test for expected reregister behaviour

* add fix

* pass passed args into earlier parse

* fix test by using args

* exit before actual register

* use strtobool

Co-authored-by: Unconst <32490803+unconst@users.noreply.github.com>

* [BIT 584] [feature] btcli register output stats not in place (#923)

* add flags for output_in_place during registration

* stop tracking best

* refactor registration logging output

* fix reregister from type bool

* change in_place and use_cuda to strtobool

* add param and defaults

* fix reference before assignment

* add new logger to cuda rege

* pass param to btcli register call

* oops

* fix init

* try slight timeout

* try fix

* oop

* ?

* fix use_cuda flag

* add test for new use_cuda flag setup

* use create pow to patch

* all no prompt dev id

* fix console.error

* use lower for str comparison

* call self register instead

* add test for wallet register call

* tests are for wallet reregister

* fix typo

* no self on top-level test

* fix tests?

* use reregister

* typo in test

* fix assert

* fix assert

* should be False

* fix time output to use timedelta

* add log verbose as option to reg output

* should be action

* fix typo

* add missing function arg

* fix spacing

* fix flags

* fix flags

* fix test

* should pass in args to config pre-parse

* use None instead of NA

Co-authored-by: isabella618033 <49876827+isabella618033@users.noreply.github.com>
Co-authored-by: Unconst <32490803+unconst@users.noreply.github.com>

* [Fix] multi cuda fix (#940)

* adjust none end calculation

* attempt to fix stop issue

* modify stop

* update nonce_start by correct amount

* fix nonce init to only random and update

* fix update amount

* add start values

* add test

* try different hashrate calc

* try EWMA for hash_rate

* oops bad import

* change name to worker

* extract helper and modify comment

* fix time now

* catch Full

* use a finished queue instead of times

* move constants to function params

* fix name of n

* fix verbose log

* allow --output_in_place

* fix n

* change to --no_ouput_in_place

* fix test

* Fix/pin wandb (#945)

pin below 0.13.4

* [Fix] change bellagene entrypoint string (#938)

dont add special case for network endpoint

Co-authored-by: Ala Shaabana <shaabana@gmail.com>

* Update dockerfile to current on dockerhub (#934)

* update dockerfile to current on dockerhub

* add netcat

* move nvm install up to take advantage of caching

* use pip

* add nvm install checksum

Co-authored-by: Ala Shaabana <shaabana@gmail.com>

* Minor fixes (#955)

minor fixes

Co-authored-by: unconst <jake@bittensor.com>

* Remove locals from cli and bittensor common (#947)

remove locals from cli and bittensor common

Co-authored-by: unconst <jake@bittensor.com>
Co-authored-by: Ala Shaabana <shaabana@gmail.com>

* [feature] Improve dataloader performance (#950)

* use threadpool and futures for dataloader

* add cli arg for max directories

Co-authored-by: Joey Legere <joey@opentensor.ai>
Co-authored-by: Ala Shaabana <shaabana@gmail.com>

* No set weights (#959)

* add no set weights

* add no_set_weights

* fix logging

* comments fix;

Co-authored-by: unconst <jake@bittensor.com>

* Bit 590 backward fix (#957)

* init

* no local forward and remote forward overlap

* clean up

* saving remote

* fix local size mismatch

* clean up

* fix

* hidden state and causalLM deterministicness

* rm backward

* default to have dendrite backward

* [Fix] add perpet hash rate and adjust alpha (#960)

* perpet hash rate and adjust alpha

* move reg code to registrationpy

* try different calc

* fix div by 0

* fix for cpu too

* fix race

* modify reg metrics output

* fix test mock

* oops

* [Fix] stake conversion issue (#958)

* modify balance arithm to cast to float first

* fix tests to model this behavior

* fix prompt spacing

* should be value error

* add test for eq balance other

* add comment to explain change

* fix tests

* .

* fix class

* balance fix

* try fix to staking

* fix comments

* add test for fix

* fix test

* fix impl

* add tests with bad types

* catch Typerror too and notimplerror

* catch typeerror

* .

* catch valueerror also

* initial commit

* fix manager server no return

* Dasyncio (#967)

* initial commit

* fix manager server no return

Co-authored-by: unconst <jake@bittensor.com>

* Update __init__.py

* Moving to release

* Release 3.4.2 (#969)

* initial commit

* fix manager server no return

* Moving to release

Co-authored-by: unconst <jake@bittensor.com>

* fix failing test_forward_priority_2nd_request_timeout

* Decrease validator moving average window

Decrease validator moving average window from 20 (alpha=0.05) to 10 (alpha=0.1) steps. This parameter could probably eventually be set to alpha=0.2.

The current 20-step window means that a server model change will take 20 steps * ~250 blocks/epoch * 12 sec = approx. 17 hours to reach full score in the validator neuron stats, because of the moving average slowly weighing in new model performance. 17 hours is probably too long, and it is also likely affecting registration immunity.

* Release 3.4.2 (#972)

* remove test_receptor test

* fix tests

Co-authored-by: unconst <jake@bittensor.com>

* No version checking (#974)

* no version checking

* fix integration tests

* remove print

Co-authored-by: Thebes <jake@bittensor.com>

* Promo suffix (#977)

* initial commit

* promo change to axon and dendrite

Co-authored-by: Thebes <jake@bittensor.com>

* Validator exit (#980)

* remove test_receptor test

* fix tests

* fix valdidator exit

Co-authored-by: unconst <jake@bittensor.com>

* Support arbitrary gRPC request metadata order (#976)

* Format AuthInterceptor using black

* Parse request metadata as key value pairs

* Use request method to black list calls

* Fix request type provided on backward

* Add type hints

* Refactor signature parsing

* [Fix] Dockerfile: clone the repo to install instead (#984)

* clone the repo to install instead

* no cd

Co-authored-by: Ala Shaabana <shaabana@gmail.com>

* Update bittensor version to 3.4.3

(cherry picked from commit 43110cf)

* Catch precision errors in synapse forward responses

Response serialization/deserialization introduces precision errors that may cause probability sums to exceed permissible boundaries. Now checks to see if precision errors are within established absolute tolerance (atol = 1e-6 currently).

(cherry picked from commit d96b625)

* Comment update for tensor size

(cherry picked from commit 6dd06f9)

* Fix/allow synapse all (#988)

* allow set synapse All using flag

* add test

* use dot get

* Mark registration threads as daemons (#998)

Make solver processes daemons

* Add response table to validator debugging

* Add return_ops to parameters

* Decode context and answer

* Add validation length parameter

* Itemize probabilities

* Add debug prints

* Change table formatting

* Add extra tasks to response table

* Debug add print

* Remove batch_size parameter

* Switch modulo order

* Modify table format

* Modify table format

* Modify table format

* Modify table format

* Try table print to catch rich errors

* Modify table title and caption

* Add shapley_values_nxt column

* Refactor response table functions

* Correct responsive count

* Format table caption

* [BIT-599] Validator weight setting improvements (#1000)

* Remove responsive prioritization from validator weight calculation

Weight setting limitation based on responsive prioritization is no longer needed, so has been removed. Part of the original intent of the limitation was a chain storage concern of setting too many weights, but since the network has gained very high > 90% response rate the concern is moot.

The downside of applying the limitation is that validators with longer step size artificially set fewer weights simply because they could not query the network in a single epoch. This introduced a counterproductive weight setting variability across validators.

Responsiveness is scored in any case via a Shapley EMA zero-push penalty, so setting weights on non-responsive nodes still relay an accurate scoring.

* Move metagraph_sync just before weight setting

The metagraph is one epoch (~250 blocks) outdated by the time weight setting is done. This means that newly registered keys will have weights set based on the stats of the key just previously registered on the same UID.

Weights will now be set more accurately when the metagraph is updated just before weight setting, which will reset stats of a UID that has changed ownership.

* Update neuron stats table caption

* Add metagraph register to validator

Tracks new hotkey registrations on UIDs, and records statistics of previous hotkey.

* Update validator epoch conditions

Epoch overrun beyond blocks_per_epoch no longer needed, since weight setting no longer restricted to epoch responsives.

Normal epoch duration is blocks_per_epoch if all UIDs have been queried try to query each UID at least once - assumes nucleus samples without replacement but keep minimum epoch duration at blocks_per_epoch * 12 sec block_period in case of subtensor outage causing invalid block readings to prevent fast repeated weight setting.

Also logs while conditions per step

* Cast phrase_cross_entropy tokens to int

* Assert self.metagraph.n == len(self.neuron_hotkeys)

* Round before casting to int in phrase_cross_entropy

* Log epoch while condition details

* Update validator weights console message

* Consume validator nucleus UID queue fully

Since epochs are now concluded at blocks_per_epoch many validators will have unqueried UIDs still in queue. It is better that these are retained and consumed in the next epoch, since this will ensure all UIDs are queried over a cycle that may involve successive epochs.

The inefficiency introduced is that if the queue has to be refilled in the same epoch, then a UID may be queried twice, although this is preferred over the risk of not querying a UID at all if the remaining queue is not fully consumed even if another epoch is required.

* No cache: metagraph.sync(cached=False)

Turns off metagraph cache, now requires ~10 minutes (on local) to update metagraph before weight setting, but typically provides more recent values that can catch UID ownership changes.

* Add validator --neuron.metagraph_cached

When flag --neuron.metagraph_cached is set the validator uses metagraph.sync(cached=True).

* Record block before validator neuron register entry

* Force validators without local subtensor to use cached metagraph

* Incorporate __blocktime__ and remove asserts

* Refactor neuron_register to neuron_changes and add flag

* Use cached metagraph.sync()

* Remove unused print_neuron_stats flag

* Strip lead 0. from table float displays

* Increase synergy table display precision

* Increase synergy table display precision

* Format validator query response table

* Improve release scripts and adding some labels to dockerfile #1004  (#1005)

* Pinning requirements versions in requirements/prod.txt

* Improve release scripts. Generating RELEASING.md document for release releasing guidelines. Adding more labels to dockerfile

Removing dockerfile label bittensor.packages

* Removing dockerfile label bittensor.dependencies.versions.cudnn

* Removing file that came from a wrong rebase

* Renaming RELEASING.md to RELEASE_GUIDELINES.md

* Modifying release scripts so versioning is independent of the relese process. Modifying RELEASE_GUIDELINES adding more information

* Modifying RELEASE_GUIDELINES adding more information

* Fixing the versioning script. Modifying RELEASE_GUIDELINES.md

* Version: 3.5.0. Applying ./scripts/release/versioning.sh --update minor -A

Co-authored-by: Cameron Fairchild <cameron.fairchild@mail.utoronto.ca>
Co-authored-by: Eugene <etesting007@gmail.com>
Co-authored-by: Eugene-hu <85906264+Eugene-hu@users.noreply.github.com>
Co-authored-by: Mac Thrasher <95183714+quac88@users.noreply.github.com>
Co-authored-by: opentaco <opentaco@protonmail.com>
Co-authored-by: opentaco <93473497+opentaco@users.noreply.github.com>
Co-authored-by: Ala Shaabana <shaabana@gmail.com>
Co-authored-by: Ala Shaabana <ala@bittensor.com>
Co-authored-by: isabella618033 <49876827+isabella618033@users.noreply.github.com>
Co-authored-by: Unconst <32490803+unconst@users.noreply.github.com>
Co-authored-by: unconst <jake@bittensor.com>
Co-authored-by: Cameron Fairchild <cameron@opentensor.ai>
Co-authored-by: joeylegere <joeylegere@gmail.com>
Co-authored-by: Joey Legere <joey@opentensor.ai>
Co-authored-by: Adrian-Stefan Mares <36161392+adriansmares@users.noreply.github.com>
  • Loading branch information
16 people committed Nov 24, 2022
1 parent 88ca9ed commit 5b31e73
Show file tree
Hide file tree
Showing 21 changed files with 874 additions and 321 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ LABEL bittensor.image.authors="bittensor.com" \
bittensor.image.revision="${VCS_REF}" \
bittensor.image.created="${BUILD_DATE}" \
bittensor.image.documentation="https://app.gitbook.com/@opentensor/s/bittensor/"
LABEL bittensor.dependencies.versions.torch="1.12.0"
LABEL bittensor.dependencies.versions.cuda="11.3"
ARG DEBIAN_FRONTEND=noninteractive

#nvidia key migration
Expand All @@ -34,9 +36,10 @@ RUN bash -c "source $HOME/.nvm/nvm.sh && \
# install pm2
npm install --location=global pm2"

RUN mkdir -p /root/.bittensor/bittensor
RUN cd ~/.bittensor/bittensor && \
python3 -m pip install bittensor
RUN mkdir -p /root/.bittensor/
RUN cd /root/.bittensor/ && \
git clone https://github.com/opentensor/bittensor.git bittensor && \
python3 -m pip install -e bittensor

# Increase ulimit to 1,000,000
RUN prlimit --pid=$PPID --nofile=1000000
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ At Bittensor, we are creating an open, decentralized, peer-to-peer network that
- [4.7. Finding and creating the endpoints for other nodes in the network](#47-finding-and-creating-the-endpoints-for-other-nodes-in-the-network)
- [4.8. Querying others in the network](#48-querying-others-in-the-network)
- [4.9. Creating a Priority Thread Pool for the axon](#49-creating-a-priority-thread-pool-for-the-axon)
- [5. License](#5-license)
- [6. Acknowledgments](#6-acknowledgments)
- [5. Release](#5-release)
- [6. License](#6-license)
- [7. Acknowledgments](#7-acknowledgments)

## 1. Documentation

Expand Down Expand Up @@ -338,7 +339,10 @@ representations, _, _ = den.forward_text (

```

## 5. License
## 5. Release
The release manager should follow the instructions of the [RELEASE_GUIDELINES.md](./RELEASE_GUIDELINES.md) document.

## 6. License
The MIT License (MIT)
Copyright © 2021 Yuma Rao

Expand All @@ -349,5 +353,5 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


## 6. Acknowledgments
## 7. Acknowledgments
**learning-at-home/hivemind**
80 changes: 80 additions & 0 deletions RELEASE_GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Release Guidelines

The release manager in charge can release a Bittensor version using two scripts:
- [./scripts/release/versioning.sh](./scripts/release/versioning.sh)
- [./scripts/release/release.sh](./scripts/release/release.sh)

The release manager will need the right permissions for:
- github.com
- pypi.org
- hub.docker.com

If you are new in this role, ask for the proper setup you need to run this process manually.

## Process of release

1. Create a branch called `release/VERSION`, having VERSION with the version to release.
1. Within the release branch; Update the version using the versioning script:
1. `./scripts/release/versioning.sh --update UPDATE_TYPE`, UPDATE_TYPE could be major, minor or patch.
1. Test the release branch and verify that it meets the requirements.
1. After merging the release branch; Run the release script

## Versioning script usage

Options:
- -U, --update: type of update. It could be major, minor, patch or rc (release candidate).
- -A, --apply: This specify to apply the release. Without this the versioning will just show a dry run with no changes.

## Release script usage

Options:
- -A, --apply: This specify to apply the release. Without this the release will just show a dry run with no changes.
- -T,--github-token: A github personal access token to interact with the Github API.

### Github token

Since you need to use a secret when releasing bittensor (github personal access token), I encourage you to use [pass](https://www.passwordstore.org/) or a similar tool that allows you to store the secret safely and not expose it in the history of the machine you use.

So you can have:
```
GITHUB_ACCESS_TOKEN=$(pass github/your_personal_token_with_permisions)
```

or
```
GITHUB_ACCESS_TOKEN=$(whatever you need to get the token safely)
```

### Executions

So, executing the script to release a minor version will be:

```
# For a dry run
./scripts/release/release.sh --version minor --github-token $GITHUB_ACCESS_TOKEN`
```

```
# Applying changes
./scripts/release/release.sh --apply --version minor --github-token $GITHUB_ACCESS_TOKEN`
```

## Checking release

After the execution of the release script we would have generated:
- A new git tag in [github.com](https://github.com/opentensor/bittensor/tags)
- A new github release in [github.com](https://github.com/opentensor/bittensor/releases)
- A new pip package in [pypi.org](https://pypi.org/project/bittensor/#history)
- A new docker image in [hub.docker.com](https://hub.docker.com/r/opentensorfdn/bittensor/tags)

## After release

After a Bittensor release we have to
- Update [cubit](https://github.com/opentensor/cubit).

### Updating cubit

1. Updating the [Dockerfile](https://github.com/opentensor/cubit/blob/master/docker/Dockerfile)
1. Building its docker image (follow its README instructions)
1. Push it to hub.docker.com
1. The generated name will be the same but with `-cubit` in its name
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.3
3.5.0
2 changes: 1 addition & 1 deletion bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
nest_asyncio.apply()

# Bittensor code and protocol version.
__version__ = '3.4.3'
__version__ = '3.5.0'
version_split = __version__.split(".")
__version_as_int__ = (100 * int(version_split[0])) + (10 * int(version_split[1])) + (1 * int(version_split[2]))

Expand Down
179 changes: 96 additions & 83 deletions bittensor/_axon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import inspect
import time
from concurrent import futures
from typing import List, Callable, Optional
from typing import Dict, List, Callable, Optional, Tuple, Union
from bittensor._threadpool import prioritythreadpool

import torch
Expand Down Expand Up @@ -339,101 +339,114 @@ def check_forward_callback( forward_callback:Callable, synapses:list = []):
forward_callback([sample_input], synapses, hotkey='')

class AuthInterceptor(grpc.ServerInterceptor):
""" Creates a new server interceptor that authenticates incoming messages from passed arguments.
"""
def __init__(self, key:str = 'Bittensor',blacklist:List = []):
r""" Creates a new server interceptor that authenticates incoming messages from passed arguments.
"""Creates a new server interceptor that authenticates incoming messages from passed arguments."""

def __init__(self, key: str = "Bittensor", blacklist: List = []):
r"""Creates a new server interceptor that authenticates incoming messages from passed arguments.
Args:
key (str, `optional`):
key for authentication header in the metadata (default= Bittensor)
black_list (Fucntion, `optional`):
key for authentication header in the metadata (default = Bittensor)
black_list (Function, `optional`):
black list function that prevents certain pubkeys from sending messages
"""
super().__init__()
self._valid_metadata = ('rpc-auth-header', key)
self.nounce_dic = {}
self.message = 'Invalid key'
self.auth_header_value = key
self.nonces = {}
self.blacklist = blacklist
def deny(_, context):
context.abort(grpc.StatusCode.UNAUTHENTICATED, self.message)

self._deny = grpc.unary_unary_rpc_method_handler(deny)

def intercept_service(self, continuation, handler_call_details):
r""" Authentication between bittensor nodes. Intercepts messages and checks them
"""
meta = handler_call_details.invocation_metadata
def parse_legacy_signature(
self, signature: str
) -> Union[Tuple[int, str, str, str], None]:
r"""Attempts to parse a signature using the legacy format, using `bitxx` as a separator"""
parts = signature.split("bitxx")
if len(parts) < 4:
return None
try:
nonce = int(parts[0])
parts = parts[1:]
except ValueError:
return None
receptor_uuid, parts = parts[-1], parts[:-1]
message, parts = parts[-1], parts[:-1]
pubkey = "".join(parts)
return (nonce, pubkey, message, receptor_uuid)

def parse_signature(self, metadata: Dict[str, str]) -> Tuple[int, str, str, str]:
r"""Attempts to parse a signature from the metadata"""
signature = metadata.get("bittensor-signature")
if signature is None:
raise Exception("Request signature missing")
parts = self.parse_legacy_signature(signature)
if parts is not None:
return parts
raise Exception("Unknown signature format")

def check_signature(
self, nonce: int, pubkey: str, signature: str, receptor_uuid: str
):
r"""verification of signature in metadata. Uses the pubkey and nonce"""
keypair = Keypair(ss58_address=pubkey)
# Build the expected message which was used to build the signature.
message = f"{nonce}{pubkey}{receptor_uuid}"
# Build the key which uniquely identifies the endpoint that has signed
# the message.
endpoint_key = f"{pubkey}:{receptor_uuid}"

if endpoint_key in self.nonces.keys():
previous_nonce = self.nonces[endpoint_key]
# Nonces must be strictly monotonic over time.
if nonce - previous_nonce <= -10:
raise Exception("Nonce is too small")
if not keypair.verify(message, signature):
raise Exception("Signature mismatch")
self.nonces[endpoint_key] = nonce
return

if not keypair.verify(message, signature):
raise Exception("Signature mismatch")
self.nonces[endpoint_key] = nonce

def version_checking(self, metadata: Dict[str, str]):
r"""Checks the header and version in the metadata"""
provided_value = metadata.get("rpc-auth-header")
if provided_value is None or provided_value != self.auth_header_value:
raise Exception("Unexpected caller metadata")

def black_list_checking(self, pubkey: str, method: str):
r"""Tries to call to blacklist function in the miner and checks if it should blacklist the pubkey"""
if self.blacklist == None:
return

try:
#version checking
self.version_checking(meta)
request_type = {
"/Bittensor/Forward": bittensor.proto.RequestType.FORWARD,
"/Bittensor/Backward": bittensor.proto.RequestType.BACKWARD,
}.get(method)
if request_type is None:
raise Exception("Unknown request type")

#signature checking
self.signature_checking(meta)
if self.blacklist(pubkey, request_type):
raise Exception("Request type is blacklisted")

#blacklist checking
self.black_list_checking(meta)
def intercept_service(self, continuation, handler_call_details):
r"""Authentication between bittensor nodes. Intercepts messages and checks them"""
method = handler_call_details.method
metadata = dict(handler_call_details.invocation_metadata)

return continuation(handler_call_details)
try:
# version checking
self.version_checking(metadata)

except Exception as e:
self.message = str(e)
return self._deny
(nonce, pubkey, signature, receptor_uuid) = self.parse_signature(metadata)

def vertification(self,meta):
r"""vertification of signature in metadata. Uses the pubkey and nounce
"""
variable_length_messages = meta[1].value.split('bitxx')
nounce = int(variable_length_messages[0])
pubkey = variable_length_messages[1]
message = variable_length_messages[2]
unique_receptor_uid = variable_length_messages[3]
_keypair = Keypair(ss58_address=pubkey)

# Unique key that specifies the endpoint.
endpoint_key = str(pubkey) + str(unique_receptor_uid)

#checking the time of creation, compared to previous messages
if endpoint_key in self.nounce_dic.keys():
prev_data_time = self.nounce_dic[ endpoint_key ]
if nounce - prev_data_time > -10:
self.nounce_dic[ endpoint_key ] = nounce

#decrypting the message and verify that message is correct
verification = _keypair.verify( str(nounce) + str(pubkey) + str(unique_receptor_uid), message)
else:
verification = False
else:
self.nounce_dic[ endpoint_key ] = nounce
verification = _keypair.verify( str( nounce ) + str(pubkey) + str(unique_receptor_uid), message)
# signature checking
self.check_signature(nonce, pubkey, signature, receptor_uuid)

return verification
# blacklist checking
self.black_list_checking(pubkey, method)

def signature_checking(self,meta):
r""" Calls the vertification of the signature and raises an error if failed
"""
if self.vertification(meta):
pass
else:
raise Exception('Incorrect Signature')

def version_checking(self,meta):
r""" Checks the header and version in the metadata
"""
if meta[0] == self._valid_metadata:
pass
else:
raise Exception('Incorrect Metadata format')
return continuation(handler_call_details)

def black_list_checking(self,meta):
r"""Tries to call to blacklist function in the miner and checks if it should blacklist the pubkey
"""
variable_length_messages = meta[1].value.split('bitxx')
pubkey = variable_length_messages[1]

if self.blacklist == None:
pass
elif self.blacklist(pubkey,int(meta[3].value)):
raise Exception('Black listed')
else:
pass
except Exception as e:
message = str(e)
abort = lambda _, ctx: ctx.abort(grpc.StatusCode.UNAUTHENTICATED, message)
return grpc.unary_unary_rpc_method_handler(abort)
6 changes: 3 additions & 3 deletions bittensor/_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def config(args: List[str]) -> 'bittensor.config':
run_parser.add_argument(
'--synapse',
type=str,
choices= list(bittensor.synapse.__synapses_types__),
choices= list(bittensor.synapse.__synapses_types__) + ['All'],
default='None',
help='''Synapses available through bittensor.synapse'''
)
Expand Down Expand Up @@ -993,8 +993,8 @@ def check_run_config( config: 'bittensor.Config' ):
model = Prompt.ask('Enter miner name', choices = list(bittensor.neurons.__text_neurons__.keys()), default = 'core_server')
config.model = model

if 'server' in config.model and not config.no_prompt:
synapse = Prompt.ask('Enter synapse', choices = list(bittensor.synapse.__synapses_types__), default = 'All')
if 'server' in config.model and config.get('synapse', 'None') == 'None' and not config.no_prompt:
synapse = Prompt.ask('Enter synapse', choices = list(bittensor.synapse.__synapses_types__) + ['All'], default = 'All')
config.synapse = synapse

# Don't need to ask about registration if they don't want to reregister the wallet.
Expand Down
Loading

0 comments on commit 5b31e73

Please sign in to comment.