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

[fix] Use user home directory for wallet path #59

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

roman-opentensor
Copy link
Contributor

No description provided.

@roman-opentensor roman-opentensor self-assigned this Nov 7, 2024
@roman-opentensor roman-opentensor added the bug Something isn't working label Nov 7, 2024
@roman-opentensor roman-opentensor merged commit f420553 into staging Nov 7, 2024
6 of 10 checks passed
@roman-opentensor roman-opentensor deleted the fix/roman/home-path-for-wallet branch November 7, 2024 20:22
camfairchild added a commit that referenced this pull request Nov 12, 2024
* add PasswordError and bound to python

* formatter

* add `from bittensor_wallet.errors import PasswordError`

* return encrypted password, remove debug

* [fix] Use user home directory for wallet path (#59)

* Updates local -> environment vars in changelog

* closes GH #51 (#56)

* [fix] Use userhome for default wallet path ~ (#57)

* use userhome for default path ~

* bump ver

* expand path on init and use as _path

---------

Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: Cameron Fairchild <[email protected]>

* Fix ruff (#62)

* add rustup to CI (#63)

* add rustup to CI

* make rustup accept all

* add to path

* Update CHANGELOG.MD

* Update CHANGELOG.MD

---------

Co-authored-by: Roman <[email protected]>
Co-authored-by: Roman <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: Cameron Fairchild <[email protected]>
camfairchild added a commit that referenced this pull request Nov 12, 2024
* add PasswordError and bound to python

* formatter

* add `from bittensor_wallet.errors import PasswordError`

* return encrypted password, remove debug

* [fix] Use user home directory for wallet path (#59)

* Updates local -> environment vars in changelog

* closes GH #51 (#56)

* [fix] Use userhome for default wallet path ~ (#57)

* use userhome for default path ~

* bump ver

* expand path on init and use as _path

---------

Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: Cameron Fairchild <[email protected]>

* Fix ruff (#62)

* add rustup to CI (#63)

* add rustup to CI

* make rustup accept all

* add to path

* Update CHANGELOG.MD

* Update CHANGELOG.MD

* fix changelog

* bump ver

* bump cargo toml ver

* Update CHANGELOG.MD

---------

Co-authored-by: Roman <[email protected]>
Co-authored-by: Roman <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
@chad-u410
Copy link

I am having a problem that I think is related to this commit. Subnet 11, using this version, is failing to start with the following:

KeyFileError: Keyfile at: /root/~/.bittensor/wallets/redacted/hotkeys/redacted does not exist.

Note the ~ in the path.

If I set the environment variable BT_WALLET_PATH then it works.

@roman-opentensor
Copy link
Contributor Author

I am having a problem that I think is related to this commit. Subnet 11, using this version, is failing to start with the following:

KeyFileError: Keyfile at: /root/~/.bittensor/wallets/redacted/hotkeys/redacted does not exist.

Note the ~ in the path.

If I set the environment variable BT_WALLET_PATH then it works.

I was able to use the latest version bittensor-wallet 2.1.1.

In [1]: from bittensor_wallet import Wallet

In [2]: w = Wallet()

In [3]: w.create()

IMPORTANT: Store this mnemonic in a secure (preferable offline place), as anyone who has possession of this mnemonic can use it to regenerate the key and access your tokens.

The mnemonic to the new coldkey is: material birth crush tray awake session remove quit earth broom novel staff
You can use the mnemonic to recreate the key with `btcli` in case it gets lost.
Enter your password:
Retype your password:
Encrypting...

IMPORTANT: Store this mnemonic in a secure (preferable offline place), as anyone who has possession of this mnemonic can use it to regenerate the key and access your tokens.

The mnemonic to the new hotkey is: frag*** thi** combi** square pledge reopen gas nothing margin conduct tape square
You can use the mnemonic to recreate the key with `btcli` in case it gets lost.
Out[3]: name: 'default', hotkey: 'default', path: '~/.bittensor/wallets/'

In [4]: w.coldkey_file
Out[4]: Keyfile (Py(0x14360bce0) encrypted, /Users/roman/.bittensor/wallets/default/coldkey)>

In [5]: w.hotkey_file
Out[5]: keyfile (decrypted, /Users/roman/.bittensor/wallets/default/hotkeys/default)>

In [6]: w.coldkeypub_file
Out[6]: keyfile (decrypted, /Users/roman/.bittensor/wallets/default/coldkeypub.txt)>

Please provide more context to help me understand what I missed.
Thank you for your comment.

@chad-u410
Copy link

Thanks so much for the reply!

I encountered this while working on subnet 11, which was upgraded yesterday. This is happening in the Validator class, roughly here: https://github.com/impel-intelligence/dippy-bittensor-subnet/blob/main/neurons/validator.py#L228.

I think it's related to the Config method vs WalletConfig, specifically where the Config method prepends the ~ (https://github.com/opentensor/btwallet/blob/main/src/config.rs#L42).

In terms of reproducibility:

>>> from bittensor_wallet import Wallet
>>> w = Wallet()
>>> w.config()
Config(name: 'default', path: '~/~/.bittensor/wallets/', hotkey: 'default')

If the code from SN11 isn't correct let me know and I'll reach out to them.

Thanks!

@roman-opentensor
Copy link
Contributor Author

Thanks so much for the reply!

I encountered this while working on subnet 11, which was upgraded yesterday. This is happening in the Validator class, roughly here: https://github.com/impel-intelligence/dippy-bittensor-subnet/blob/main/neurons/validator.py#L228.

I think it's related to the Config method vs WalletConfig, specifically where the Config method prepends the ~ (https://github.com/opentensor/btwallet/blob/main/src/config.rs#L42).

In terms of reproducibility:

>>> from bittensor_wallet import Wallet
>>> w = Wallet()
>>> w.config()
Config(name: 'default', path: '~/~/.bittensor/wallets/', hotkey: 'default')

If the code from SN11 isn't correct let me know and I'll reach out to them.

Thanks!

For sure. Anytime you can ask any questions. Pls feel free to do it.

And, I got you. Yep, I found this bug and fixed it in this PR #67

This fix will be available in the next release.
Also, to be make sure it's working for now, pls see the next code snippet based on the code with that fix:

In [1]: from bittensor_wallet import Wallet

In [2]: w = Wallet()

In [3]: w.config()
Out[3]: Config(name: 'default', path: '~/.bittensor/wallets/', hotkey: 'default')

@chad-u410
Copy link

Looks great, thanks again!

unconst pushed a commit that referenced this pull request Nov 22, 2024
* add PasswordError and bound to python

* formatter

* add `from bittensor_wallet.errors import PasswordError`

* return encrypted password, remove debug

* [fix] Use user home directory for wallet path (#59)

* Updates local -> environment vars in changelog

* closes GH #51 (#56)

* [fix] Use userhome for default wallet path ~ (#57)

* use userhome for default path ~

* bump ver

* expand path on init and use as _path

---------

Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: Cameron Fairchild <[email protected]>

* Fix ruff (#62)

* add rustup to CI (#63)

* add rustup to CI

* make rustup accept all

* add to path

* Update CHANGELOG.MD

* Update CHANGELOG.MD

* fix changelog

* bump ver

* bump cargo toml ver

* Update CHANGELOG.MD

---------

Co-authored-by: Roman <[email protected]>
Co-authored-by: Roman <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Co-authored-by: ibraheem-opentensor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants