Skip to content

Commit

Permalink
Merge branch 'main' into ench/abe/commented-info
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheem-opentensor committed Oct 9, 2024
2 parents e95b36a + 0c0c945 commit 632a9df
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
name: Black format check
command: |
. env/bin/activate
black --line-length 79 --exclude '(env|venv|.eggs)' --check .
black --line-length 79 --exclude '(env|venv|.eggs|.git)' --check .
pylint:
resource_class: small
Expand Down
2 changes: 1 addition & 1 deletion docs/running_on_staging.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ These steps initialize your local subtensor chain in development mode. These com
Build the binary with the faucet feature enabled:

```bash
cargo build --release --features pow-faucet
cargo build -p node-subtensor --profile production --features pow-faucet
```

**NOTE**: The `--features pow-faucet` option in the above is required if we want to use the command `btcli wallet faucet` [See the below Mint tokens step](#8-mint-tokens-from-faucet).
Expand Down
6 changes: 5 additions & 1 deletion docs/stream_tutorial/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def __init__(self, config=None, axon=None, wallet=None, subtensor=None):
bt.logging.set_config(config=self.config.logging)

# Wallet holds cryptographic information, ensuring secure transactions and communication.
self.wallet = wallet or bt.wallet(config=self.config)
self.wallet = wallet or bt.wallet(
name=self.config.wallet.name,
path=self.config.wallet.path,
hotkey=self.config.wallet.hotkey,
)
bt.logging.info(f"Wallet {self.wallet}")

# subtensor manages the blockchain connection, facilitating interaction with the Bittensor blockchain.
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bittensor>=7
starlette>=0.30.0
pydantic>=2
rich>=13
Expand Down
6 changes: 5 additions & 1 deletion template/base/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ def __init__(self, config=None):
self.config.netuid, subtensor=self.subtensor
)
else:
self.wallet = bt.wallet(config=self.config)
self.wallet = bt.wallet(
name=self.config.wallet.name,
path=self.config.wallet.path,
hotkey=self.config.wallet.hotkey,
)
self.subtensor = bt.subtensor(config=self.config)
self.metagraph = self.subtensor.metagraph(self.config.netuid)

Expand Down
3 changes: 2 additions & 1 deletion template/base/utils/weight_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def process_weights_for_netuid(
tuple[Any, ndarray],
]:
bittensor.logging.debug("process_weights_for_netuid()")
bittensor.logging.debug("weights", *weights)
bittensor.logging.debug("weights", weights)
bittensor.logging.debug("netuid", netuid)
bittensor.logging.debug("subtensor", subtensor)
bittensor.logging.debug("metagraph", metagraph)
Expand All @@ -174,6 +174,7 @@ def process_weights_for_netuid(

# Find all non zero weights.
non_zero_weight_idx = np.argwhere(weights > 0).squeeze()
non_zero_weight_idx = np.atleast_1d(non_zero_weight_idx)
non_zero_weight_uids = uids[non_zero_weight_idx]
non_zero_weights = weights[non_zero_weight_idx]
if non_zero_weights.size == 0 or metagraph.n < min_allowed_weights:
Expand Down
10 changes: 5 additions & 5 deletions template/base/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def set_weights(self):
# Compute raw_weights safely
raw_weights = self.scores / norm

bt.logging.debug("raw_weights", *raw_weights)
bt.logging.debug("raw_weights", raw_weights)
bt.logging.debug("raw_weight_uids", str(self.metagraph.uids.tolist()))
# Process the raw weights to final_weights via subtensor limitations.
(
Expand All @@ -255,8 +255,8 @@ def set_weights(self):
subtensor=self.subtensor,
metagraph=self.metagraph,
)
bt.logging.debug("processed_weights", *processed_weights)
bt.logging.debug("processed_weight_uids", *processed_weight_uids)
bt.logging.debug("processed_weights", processed_weights)
bt.logging.debug("processed_weight_uids", processed_weight_uids)

# Convert to uint16 weights and uids.
(
Expand All @@ -265,8 +265,8 @@ def set_weights(self):
) = convert_weights_and_uids_for_emit(
uids=processed_weight_uids, weights=processed_weights
)
bt.logging.debug("uint_weights", *uint_weights)
bt.logging.debug("uint_uids", *uint_uids)
bt.logging.debug("uint_weights", uint_weights)
bt.logging.debug("uint_uids", uint_uids)

# Set the weights on chain via our subtensor connection.
result, msg = self.subtensor.set_weights(
Expand Down
8 changes: 4 additions & 4 deletions verify/generate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from substrateinterface import Keypair
from os import getenv, environ
from datetime import datetime

import bittensor

# Hardcode or set the environment variable WALLET_PASS to the password for the wallet
Expand All @@ -14,14 +13,15 @@ def main(args):
timestamp = datetime.now()
timezone = timestamp.astimezone().tzname()

message = f"On {timestamp} {timezone} {args.message}"
# ensure compatiblity with polkadotjs messages, as polkadotjs always wraps message
message = "<Bytes>" + f"On {timestamp} {timezone} {args.message}" + "</Bytes>"
signature = keypair.sign(data=message)

file_contents = f"{message}\n\tSigned by: {keypair.ss58_address}\n\tSignature: {signature.hex()}"
print(file_contents)
open("message_and_signature.txt", "w").write(file_contents)

print(f"Signature generated and saved to message_and_signature.txt")
print("Signature generated and saved to message_and_signature.txt")


if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions verify/verify.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from substrateinterface import Keypair
from binascii import unhexlify

from substrateinterface import Keypair


def main(args):
file_data = open(args.file).read()
Expand All @@ -16,6 +17,8 @@ def main(args):
keypair = Keypair(ss58_address=address, ss58_format=42)

message = file_split[0]
if not message.startswith("<Bytes>") or not message.endswith("</Bytes>"):
raise ValueError("Message is not properly wrapped in <Bytes>.")

signature_line = file_split[2]
signature_prefix = "Signature: "
Expand All @@ -36,8 +39,6 @@ def main(args):
import argparse

parser = argparse.ArgumentParser(description="Verify a signature")
parser.add_argument(
"--file", help="The file containing the message and signature"
)
parser.add_argument("--file", help="The file containing the message and signature")
args = parser.parse_args()
main(args)

0 comments on commit 632a9df

Please sign in to comment.