Skip to content
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

Release/5.3.4 #1483

Merged
merged 22 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ jobs:
. env/bin/activate
python -m black --exclude '(env|venv|.eggs)' --check .

check_compatibility:
parameters:
python_version:
type: string
docker:
- image: cimg/python:3.10
steps:
- checkout
- run:
name: Install dependencies
command: |
sudo apt-get update
sudo apt-get install -y jq curl
- run:
name: Check compatibility
command: ./scripts/check_compatibility.sh << parameters.python_version >>

build-and-test:
resource_class: medium
parallelism: 2
Expand Down Expand Up @@ -203,6 +220,21 @@ jobs:


workflows:
compatibility_checks:
jobs:
- check_compatibility:
python_version: "3.8"
name: check-compatibility-3.8
- check_compatibility:
python_version: "3.9"
name: check-compatibility-3.9
- check_compatibility:
python_version: "3.10"
name: check-compatibility-3.10
- check_compatibility:
python_version: "3.11"
name: check-compatibility-3.11
ifrit98 marked this conversation as resolved.
Show resolved Hide resolved

pr-requirements:
jobs:
- black:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 5.3.4 / 2023-08-16

# What's Changed
* Removes miniupnpc by @ifrit98 (completely unused and requires a sudo install)
* Fixes blacklist vpermit_required by @inquinim e80d3d5
* Add try/except and timeout to version checking with exception handles by @ifrit98 a6a89fd
* Further updates CONTRIBUTING.md and DEVELOPMENT_WORKFLOW.md by @gitphantomman 3fefdbb


**Full Changelog**: https://github.com/opentensor/bittensor/compare/v5.3.3...v5.3.4


## 5.3.3 / 2023-07-26

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.3
5.3.4
2 changes: 1 addition & 1 deletion bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
nest_asyncio.apply()

# Bittensor code and protocol version.
__version__ = "5.3.3"
__version__ = "5.3.4"
version_split = __version__.split(".")
__version_as_int__ = (
(100 * int(version_split[0]))
Expand Down
5 changes: 4 additions & 1 deletion bittensor/_blacklist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def blacklist(
and is_registered
):
uid = metagraph.hotkeys.index(src_hotkey)
return metagraph.neurons[uid].validator_permit
# Return False (pass) if there is a permit, and True (fail) if there isn't.
if metagraph.neurons[uid].validator_permit:
return False, "has vpermit"
return True, "no vpermit"
ifrit98 marked this conversation as resolved.
Show resolved Hide resolved

# All checks passed.
return False, "passed blacklist"
29 changes: 1 addition & 28 deletions bittensor/_subtensor/extrinsics/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def serve_axon_extrinsic(
subtensor: "bittensor.Subtensor",
netuid: int,
axon: "bittensor.Axon",
use_upnpc: bool = False,
wait_for_inclusion: bool = False,
wait_for_finalization: bool = True,
prompt: bool = False,
Expand All @@ -170,9 +169,6 @@ def serve_axon_extrinsic(
The netuid being served on.
axon (bittensor.Axon):
Axon to serve.
use_upnpc (:type:bool, `optional`):
If true, the axon attempts port forward through your router before
subscribing.
wait_for_inclusion (bool):
If set, waits for the extrinsic to enter a block before returning true,
or returns false if the extrinsic fails to enter the block within the timeout.
Expand All @@ -188,30 +184,7 @@ def serve_axon_extrinsic(
"""
axon.wallet.hotkey
axon.wallet.coldkeypub

# ---- Setup UPNPC ----
if use_upnpc:
if prompt:
if not Confirm.ask("Attempt port forwarding with upnpc?"):
return False
try:
external_port = net.upnpc_create_port_map(port=axon.port)
bittensor.__console__.print(
":white_heavy_check_mark: [green]Forwarded port: {}[/green]".format(
axon.port
)
)
bittensor.logging.success(
prefix="Forwarded port", sufix="<blue>{}</blue>".format(axon.port)
)
except net.UPNPCException as upnpc_exception:
raise RuntimeError(
"Failed to hole-punch with upnpc with exception {}".format(
upnpc_exception
)
) from upnpc_exception
else:
external_port = axon.external_port
external_port = axon.external_port

# ---- Get external ip ----
if axon.external_ip == None:
Expand Down
34 changes: 20 additions & 14 deletions bittensor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,28 @@ def unbiased_topk(values, k, dim=0, sorted=True, largest=True):
return topk, permutation[indices]


def version_checking():
response = requests.get(bittensor.__pipaddress__)
latest_version = response.json()["info"]["version"]
version_split = latest_version.split(".")
latest_version_as_int = (
(100 * int(version_split[0]))
+ (10 * int(version_split[1]))
+ (1 * int(version_split[2]))
)
def version_checking(timeout: int = 15):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like this change; we should be more careful whenever we call external apis.

try:
response = requests.get(bittensor.__pipaddress__, timeout=timeout)
latest_version = response.json()["info"]["version"]
version_split = latest_version.split(".")
latest_version_as_int = (
(100 * int(version_split[0]))
+ (10 * int(version_split[1]))
+ (1 * int(version_split[2]))
)

if latest_version_as_int > bittensor.__version_as_int__:
print(
"\u001b[33mBittensor Version: Current {}/Latest {}\nPlease update to the latest version at your earliest convenience\u001b[0m".format(
bittensor.__version__, latest_version
if latest_version_as_int > bittensor.__version_as_int__:
print(
"\u001b[33mBittensor Version: Current {}/Latest {}\nPlease update to the latest version at your earliest convenience\u001b[0m".format(
bittensor.__version__, latest_version
)
)
)

except requests.exceptions.Timeout:
bittensor.logging.error("Version check failed due to timeout")
except requests.exceptions.RequestException as e:
bittensor.logging.error(f"Version check failed due to request failure: {e}")
ifrit98 marked this conversation as resolved.
Show resolved Hide resolved


def strtobool_with_default(
Expand Down
68 changes: 0 additions & 68 deletions bittensor/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import os
import urllib
import json
import miniupnpc
import netaddr
import requests

Expand Down Expand Up @@ -154,73 +153,6 @@ def get_external_ip() -> str:
raise ExternalIPNotFound


class UPNPCException(Exception):
"""Raised when trying to perform a port mapping on your router."""


def upnpc_create_port_map(port: int):
r"""Creates a upnpc port map on your router from passed external_port to local port.

Args:
port (int, `required`):
The local machine port to map from your external port.

Return:
external_port (int, `required`):
The external port mapped to the local port on your machine.

Raises:
UPNPCException (Exception):
Raised if UPNPC port mapping fails, for instance, if upnpc is not enabled on your router.
"""
try:
upnp = miniupnpc.UPnP()
upnp.discoverdelay = 200
logger.debug("UPNPC: Using UPnP to open a port on your router ...")
logger.debug("UPNPC: Discovering... delay={}ms", upnp.discoverdelay)
ndevices = upnp.discover()
upnp.selectigd()
logger.debug("UPNPC: " + str(ndevices) + " device(s) detected")

ip = upnp.lanaddr
external_ip = upnp.externalipaddress()

logger.debug("UPNPC: your local ip address: " + str(ip))
logger.debug("UPNPC: your external ip address: " + str(external_ip))
logger.debug(
"UPNPC: status = "
+ str(upnp.statusinfo())
+ " connection type = "
+ str(upnp.connectiontype())
)

# find a free port for the redirection
external_port = port
rc = upnp.getspecificportmapping(external_port, "TCP")
while rc != None and external_port < 65536:
external_port += 1
rc = upnp.getspecificportmapping(external_port, "TCP")
if rc != None:
raise UPNPCException("UPNPC: No available external ports for port mapping.")

logger.info(
"UPNPC: trying to redirect remote: {}:{} => local: {}:{} over TCP",
external_ip,
external_port,
ip,
port,
)
upnp.addportmapping(
external_port, "TCP", ip, port, "Bittensor: %u" % external_port, ""
)
logger.info("UPNPC: Create Success")

return external_port

except Exception as e:
raise UPNPCException(e) from e


def get_formatted_ws_endpoint_url(endpoint_url: str) -> str:
"""
Returns a formatted websocket endpoint url.
Expand Down
71 changes: 71 additions & 0 deletions contrib/CODE_REVIEW_DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Code Review
### Conceptual Review

A review can be a conceptual review, where the reviewer leaves a comment
* `Concept (N)ACK`, meaning "I do (not) agree with the general goal of this pull
request",
* `Approach (N)ACK`, meaning `Concept ACK`, but "I do (not) agree with the
approach of this change".

A `NACK` needs to include a rationale why the change is not worthwhile.
NACKs without accompanying reasoning may be disregarded.
After conceptual agreement on the change, code review can be provided. A review
begins with `ACK BRANCH_COMMIT`, where `BRANCH_COMMIT` is the top of the PR
branch, followed by a description of how the reviewer did the review. The
following language is used within pull request comments:

- "I have tested the code", involving change-specific manual testing in
addition to running the unit, functional, or fuzz tests, and in case it is
not obvious how the manual testing was done, it should be described;
- "I have not tested the code, but I have reviewed it and it looks
OK, I agree it can be merged";
- A "nit" refers to a trivial, often non-blocking issue.
### Code Review
ifrit98 marked this conversation as resolved.
Show resolved Hide resolved
Project maintainers reserve the right to weigh the opinions of peer reviewers
using common sense judgement and may also weigh based on merit. Reviewers that
have demonstrated a deeper commitment and understanding of the project over time
or who have clear domain expertise may naturally have more weight, as one would
expect in all walks of life.

Where a patch set affects consensus-critical code, the bar will be much
higher in terms of discussion and peer review requirements, keeping in mind that
mistakes could be very costly to the wider community. This includes refactoring
of consensus-critical code.

Where a patch set proposes to change the Bittensor consensus, it must have been
discussed extensively on the mailing list and IRC, be accompanied by a widely
discussed BIP and have a generally widely perceived technical consensus of being
ifrit98 marked this conversation as resolved.
Show resolved Hide resolved
a worthwhile change based on the judgement of the maintainers.

### Finding Reviewers

As most reviewers are themselves developers with their own projects, the review
process can be quite lengthy, and some amount of patience is required. If you find
that you've been waiting for a pull request to be given attention for several
months, there may be a number of reasons for this, some of which you can do something
about:

- It may be because of a feature freeze due to an upcoming release. During this time,
only bug fixes are taken into consideration. If your pull request is a new feature,
it will not be prioritized until after the release. Wait for the release.
- It may be because the changes you are suggesting do not appeal to people. Rather than
nits and critique, which require effort and means they care enough to spend time on your
contribution, thundering silence is a good sign of widespread (mild) dislike of a given change
(because people don't assume *others* won't actually like the proposal). Don't take
that personally, though! Instead, take another critical look at what you are suggesting
and see if it: changes too much, is too broad, doesn't adhere to the
[developer notes](DEVELOPMENT_WORKFLOW.md), is dangerous or insecure, is messily written, etc.
Identify and address any of the issues you find. Then ask e.g. on IRC if someone could give
their opinion on the concept itself.
- It may be because your code is too complex for all but a few people, and those people
may not have realized your pull request even exists. A great way to find people who
are qualified and care about the code you are touching is the
[Git Blame feature](https://docs.github.com/en/github/managing-files-in-a-repository/managing-files-on-github/tracking-changes-in-a-file). Simply
look up who last modified the code you are changing and see if you can find
them and give them a nudge. Don't be incessant about the nudging, though.
- Finally, if all else fails, ask on IRC or elsewhere for someone to give your pull request
a look. If you think you've been waiting for an unreasonably long time (say,
more than a month) for no particular reason (a few lines changed, etc.),
this is totally fine. Try to return the favor when someone else is asking
for feedback on their code, and the universe balances out.
- Remember that the best thing you can do while waiting is give review to others!
Loading