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/7.3.0 #2122

Merged
merged 17 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
26 changes: 26 additions & 0 deletions .circleci/check_pr_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Extract the repository owner
REPO_OWNER=$(echo $CIRCLE_PULL_REQUEST | awk -F'/' '{print $(NF-3)}')

# Extract the repository name
REPO_NAME=$(echo $CIRCLE_PULL_REQUEST | awk -F'/' '{print $(NF-2)}')

# Extract the pull request number
PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | awk -F'/' '{print $NF}')


PR_DETAILS=$(curl -s \
"https://github.com/gitapi/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER")


IS_DRAFT=$(echo "$PR_DETAILS" | jq -r .draft)
echo $IS_DRAFT

if [ "$IS_DRAFT" == "true" ]; then
echo "This PR is a draft. Skipping the workflow."
exit 1
else
echo "This PR is not a draft. Proceeding with the workflow."
exit 0
fi
23 changes: 20 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ version: 2.1
orbs:
python: circleci/python@2.1.1
python-lib: dialogue/python-lib@0.1.55
# coveralls: coveralls/coveralls@1.0.6

jobs:
check-if-pr-is-draft:
docker:
- image: cimg/python:3.10
steps:
- checkout
- run:
name: Install jq
command: sudo apt-get update && sudo apt-get install -y jq
- run:
name: Check if PR is a draft
command: .circleci/check_pr_status.sh

ruff:
resource_class: small
parameters:
Expand Down Expand Up @@ -137,6 +148,7 @@ jobs:
- store_artifacts:
path: test-results


#- when:
#condition:
#equal: ["3.10.5", << parameters.python-version >> ]
Expand All @@ -153,6 +165,7 @@ jobs:
#CI_JOB_ID: $CIRCLE_NODE_INDEX
#COVERALLS_PARALLEL: true


lint-and-type-check:
resource_class: medium
parallelism: 2
Expand Down Expand Up @@ -275,7 +288,6 @@ jobs:
command: |
./scripts/release/release.sh --github-token ${GH_API_ACCESS_TOKEN}


workflows:
compatibility_checks:
jobs:
Expand All @@ -291,12 +303,17 @@ workflows:

pr-requirements:
jobs:
- check-if-pr-is-draft
- ruff:
python-version: "3.9.13"
requires:
- check-if-pr-is-draft
- build-and-test:
matrix:
parameters:
python-version: ["3.9.13", "3.10.6", "3.11.4"]
requires:
- check-if-pr-is-draft
- unit-tests-all-python-versions:
requires:
- build-and-test
Expand All @@ -305,7 +322,7 @@ workflows:
parameters:
python-version: ["3.9.13", "3.10.6", "3.11.4"]
requires:
- build-and-test
- check-if-pr-is-draft
#- coveralls:
#requires:
#- build-and-test
Expand Down
46 changes: 33 additions & 13 deletions .github/workflows/e2e-subtensor-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ concurrency:
cancel-in-progress: true

on:
## Run automatically for all PRs against main, regardless of what the changes are
## to be safe and so we can more easily force re-run the CI when github is being
## weird by using a blank commit
push:
branches: [main, development, staging]

##
# Run automatically for PRs against default/main branch if Rust files change
pull_request:
branches: [main, development, staging]
types: [ opened, synchronize, reopened, ready_for_review ]

## Allow running workflow manually from the Actions tab
workflow_dispatch:
inputs:
verbose:
Expand All @@ -26,24 +21,42 @@ on:

env:
CARGO_TERM_COLOR: always
VERBOSE: ${{ github.events.input.verbose }}
VERBOSE: ${{ github.event.inputs.verbose }}

# job to run tests in parallel
jobs:
# Job to find all test files
find-tests:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
outputs:
test-files: ${{ steps.get-tests.outputs.test-files }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v2

- name: Find test files
id: get-tests
run: |
test_files=$(find tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
echo "::set-output name=test-files::$test_files"
shell: bash

# Job to run tests in parallel
run:
needs: find-tests
runs-on: SubtensorCI
strategy:
fail-fast: false # Allow other matrix jobs to run even if this job fails
max-parallel: 8 # Set the maximum number of parallel jobs
matrix:
rust-branch:
- nightly-2024-03-05
rust-target:
- x86_64-unknown-linux-gnu
# - x86_64-apple-darwin
os:
- ubuntu-latest
# - macos-latest
include:
- os: ubuntu-latest
# - os: macos-latest
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
env:
RELEASE_NAME: development
RUSTV: ${{ matrix.rust-branch }}
Expand Down Expand Up @@ -81,4 +94,11 @@ jobs:
- name: Run tests
run: |
python3 -m pip install -e .[dev] pytest
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest tests/e2e_tests/ -s
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest ${{ matrix.test-file }} -s

- name: Retry failed tests
if: failure()
run: |
sleep 10
python3 -m pip install -e .[dev] pytest
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" pytest ${{ matrix.test-file }} -s
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 7.3.0 / 2024-07-12

## What's Changed
* Liquid Alpha by @opendansor & @gus-opentensor in https://github.com/opentensor/bittensor/pull/2012
* check_coldkey_swap by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2126

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v7.2.0...v7.3.0


## 7.2.0 / 2024-06-12

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.2.0
7.3.0
33 changes: 32 additions & 1 deletion bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@


# Bittensor code and protocol version.
__version__ = "7.2.0"
__version__ = "7.3.0"

_version_split = __version__.split(".")
__version_info__ = tuple(int(part) for part in _version_split)
Expand Down Expand Up @@ -229,6 +229,37 @@ def debug(on: bool = True):
"SubnetRegistrationRuntimeApi": {
"methods": {"get_network_registration_cost": {"params": [], "type": "u64"}}
},
"ColdkeySwapRuntimeApi": {
"methods": {
"get_scheduled_coldkey_swap": {
"params": [
{
"name": "coldkey_account_vec",
"type": "Vec<u8>",
},
],
"type": "Vec<u8>",
},
"get_remaining_arbitration_period": {
"params": [
{
"name": "coldkey_account_vec",
"type": "Vec<u8>",
},
],
"type": "Vec<u8>",
},
"get_coldkey_swap_destinations": {
"params": [
{
"name": "coldkey_account_vec",
"type": "Vec<u8>",
},
],
"type": "Vec<u8>",
},
}
},
},
}

Expand Down
69 changes: 69 additions & 0 deletions bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@
["difficulty", "Compact<u64>"],
["commit_reveal_weights_interval", "Compact<u64>"],
["commit_reveal_weights_enabled", "bool"],
["alpha_high", "Compact<u16>"],
["alpha_low", "Compact<u16>"],
["liquid_alpha_enabled", "bool"],
],
},
"ScheduledColdkeySwapInfo": {
"type": "struct",
"type_mapping": [
["old_coldkey", "AccountId"],
["new_coldkey", "AccountId"],
["arbitration_block", "Compact<u64>"],
],
},
}
Expand Down Expand Up @@ -321,6 +332,7 @@ class ChainDataType(Enum):
StakeInfo = 6
IPInfo = 7
SubnetHyperparameters = 8
ScheduledColdkeySwapInfo = 9


def from_scale_encoding(
Expand Down Expand Up @@ -981,6 +993,9 @@ class SubnetHyperparameters:
difficulty: int
commit_reveal_weights_interval: int
commit_reveal_weights_enabled: bool
alpha_high: int
alpha_low: int
liquid_alpha_enabled: bool

@classmethod
def from_vec_u8(cls, vec_u8: List[int]) -> Optional["SubnetHyperparameters"]:
Expand Down Expand Up @@ -1033,6 +1048,9 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetHyperparameters":
difficulty=decoded["difficulty"],
commit_reveal_weights_interval=decoded["commit_reveal_weights_interval"],
commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"],
alpha_high=decoded["alpha_high"],
alpha_low=decoded["alpha_low"],
liquid_alpha_enabled=decoded["liquid_alpha_enabled"],
)

def to_parameter_dict(
Expand Down Expand Up @@ -1131,3 +1149,54 @@ class ProposalVoteData(TypedDict):


ProposalCallData = GenericCall


@dataclass
class ScheduledColdkeySwapInfo:
"""Dataclass for scheduled coldkey swap information."""

old_coldkey: str
new_coldkey: str
arbitration_block: int

@classmethod
def fix_decoded_values(cls, decoded: Any) -> "ScheduledColdkeySwapInfo":
"""Fixes the decoded values."""
return cls(
old_coldkey=ss58_encode(decoded["old_coldkey"], bittensor.__ss58_format__),
new_coldkey=ss58_encode(decoded["new_coldkey"], bittensor.__ss58_format__),
arbitration_block=decoded["arbitration_block"],
)

@classmethod
def from_vec_u8(cls, vec_u8: List[int]) -> Optional["ScheduledColdkeySwapInfo"]:
"""Returns a ScheduledColdkeySwapInfo object from a ``vec_u8``."""
if len(vec_u8) == 0:
return None

decoded = from_scale_encoding(vec_u8, ChainDataType.ScheduledColdkeySwapInfo)
if decoded is None:
return None

return ScheduledColdkeySwapInfo.fix_decoded_values(decoded)

@classmethod
def list_from_vec_u8(cls, vec_u8: List[int]) -> List["ScheduledColdkeySwapInfo"]:
"""Returns a list of ScheduledColdkeySwapInfo objects from a ``vec_u8``."""
decoded = from_scale_encoding(
vec_u8, ChainDataType.ScheduledColdkeySwapInfo, is_vec=True
)
if decoded is None:
return []

return [ScheduledColdkeySwapInfo.fix_decoded_values(d) for d in decoded]

@classmethod
def decode_account_id_list(cls, vec_u8: List[int]) -> Optional[List[str]]:
"""Decodes a list of AccountIds from vec_u8."""
decoded = from_scale_encoding(vec_u8, ChainDataType.AccountId, is_vec=True)
if decoded is None:
return None
return [
ss58_encode(account_id, bittensor.__ss58_format__) for account_id in decoded
]
2 changes: 2 additions & 0 deletions bittensor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
WalletCreateCommand,
CommitWeightCommand,
RevealWeightCommand,
CheckColdKeySwapCommand,
)

# Create a console instance for CLI display.
Expand Down Expand Up @@ -157,6 +158,7 @@
"set_identity": SetIdentityCommand,
"get_identity": GetIdentityCommand,
"history": GetWalletHistoryCommand,
"check_coldkey_swap": CheckColdKeySwapCommand,
},
},
"stake": {
Expand Down
1 change: 1 addition & 0 deletions bittensor/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@
RootSetSlashCommand,
)
from .identity import GetIdentityCommand, SetIdentityCommand
from .check_coldkey_swap import CheckColdKeySwapCommand
Loading
Loading