Chia farming for Truenas 13

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
The original chia wiki has the install instructions for freebsd 11 and 12. Those instructions no longer work for freebsd 13. Here are the steps I did to get chia farming working in a Truenas 13 jail. I suspect there is a better way to install things but this way works and skips having to compile the py cryptography package and you no longer need to make edits for the keyring as that's built in now. If you have done this also feel free to improve the process so we can keep freebsd as a supported os for chia.


Code:
Jail Version: 13.1-RELEASE
TrueNAS Version: 13.0-U1
pkg update; pkg upgrade -yf #pkg-1.18.3
pkg install bash git python screen bash gmake rust cmake gmp py39-sqlite3 py39-pybind11 pybind11
chsh -s /usr/local/bin/bash
bash #start the shell
git clone https://github.com/Chia-Network/chia-blockchain.git -b latest
cd chia-blockchain
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install clvm-tools-rs maturin #take note of the clvm-tools-rs version that gets installed(0.1.19 in this case)
*EDIT setup.py file for clvm-tools-rs version number
bash ./install.sh
chia init
chia version => 1.5.1.dev0


EDIT 12/20/2023 - I have 2.1.3 working but you have to build wheel for chia_rs 0.2.13 and build clvm-tools_rs. Make sure you're in your virtual environment when you do the build so it gets installed in the correct place.

Code:
(venv) [root@chia-farmer ~/chia-latest]# git clone -b 0.2.13 https://github.com/Chia-Network/chia_rs.git
*NOTE: you need to cd into the wheel directory here, that's different from the others.
(venv) [root@chia-farmer ~/chia-latest]# cd chia_rs/wheel
(venv)[root@chia-farmer ~/chia-latest/chia_rs/wheel]# pip install .

(venv) [root@chia-farmer ~/chia-latest]# git clone -b 0.1.39 https://github.com/Chia-Network/clvm_tools_rs.git
(venv) [root@chia-farmer ~/chia-latest]# cd clvm_tools_rs/
(venv) [root@chia-farmer ~/chia-latest/clvm_tools_rs]# pip install .

After building these things you should be able to do your bash install.sh command above.
 
Last edited:

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
hmm looks like upgrading to 1.5.1 isn't working
Code:
(venv) [root@chia-farmer ~/chia-1.5.1/chia-blockchain]# chia start farmer
Traceback (most recent call last):
  File "/root/chia-1.5.1/chia-blockchain/venv/bin/chia", line 8, in <module>
    sys.exit(main())
  File "/root/chia-1.5.1/chia-blockchain/chia/cmds/chia.py", line 147, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/root/chia-1.5.1/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/root/chia-1.5.1/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/root/chia-1.5.1/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/chia-1.5.1/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/chia-1.5.1/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/root/chia-1.5.1/chia-blockchain/venv/lib/python3.9/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/root/chia-1.5.1/chia-blockchain/chia/cmds/start.py", line 17, in start_cmd
    asyncio.run(async_start(root_path, config, group, restart, ctx.obj["force_legacy_keyring_migration"]))
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/root/chia-1.5.1/chia-blockchain/chia/cmds/start_funcs.py", line 68, in async_start
    if not await migrate_keys(root_path, True):
  File "/root/chia-1.5.1/chia-blockchain/chia/cmds/keys_funcs.py", line 221, in migrate_keys
    legacy_keyring = Keychain(force_legacy=True)
  File "/root/chia-1.5.1/chia-blockchain/chia/util/keychain.py", line 219, in __init__
    KeyringWrapper.get_legacy_instance() if force_legacy else KeyringWrapper.get_shared_instance()
  File "/root/chia-1.5.1/chia-blockchain/chia/util/keyring_wrapper.py", line 187, in get_legacy_instance
    return KeyringWrapper(force_legacy=True)
  File "/root/chia-1.5.1/chia-blockchain/chia/util/keyring_wrapper.py", line 115, in __init__
    if check_legacy_keyring_keys_present(legacy_keyring):
  File "/root/chia-1.5.1/chia-blockchain/chia/util/keyring_wrapper.py", line 58, in check_legacy_keyring_keys_present
    credential: Optional[Credential] = keyring.get_credential(keychain_service, current_user)
AttributeError: 'NoneType' object has no attribute 'get_credential'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x8047ce040>
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x8047def10>
(venv) [root@chia-farmer ~/chia-1.5.1/chia-blockchain]# Connection to tubby closed by remote host.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
the fix for the error above got merged into main yesterday. Not sure what release it will eventually make it into 1.6.1+ maybe?
 

EtienneB

Explorer
Joined
Feb 19, 2018
Messages
78
Highly appreciated this write up.
I went through all the steps and 1.6.2dev0 is installed now.
However I get an error when adding a key:

Code:
(venv) [root@chianew ~/chia-blockchain]# chia keys add
Traceback (most recent call last):
  File "/root/chia-blockchain/venv/bin/chia", line 8, in <module>
    sys.exit(main())
  File "/root/chia-blockchain/chia/cmds/chia.py", line 136, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1654, in invoke
    super().invoke(ctx)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/root/chia-blockchain/chia/cmds/keys.py", line 20, in keys_cmd
    if ctx.obj["force_legacy_keyring_migration"] and not asyncio.run(migrate_keys(root_path, True)):
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/root/chia-blockchain/chia/cmds/keys_funcs.py", line 279, in migrate_keys
    legacy_keyring = Keychain(force_legacy=True)
  File "/root/chia-blockchain/chia/util/keychain.py", line 265, in __init__
    KeyringWrapper.get_legacy_instance() if force_legacy else KeyringWrapper.get_shared_instance()
  File "/root/chia-blockchain/chia/util/keyring_wrapper.py", line 187, in get_legacy_instance
    return KeyringWrapper(force_legacy=True)
  File "/root/chia-blockchain/chia/util/keyring_wrapper.py", line 115, in __init__
    if check_legacy_keyring_keys_present(legacy_keyring):
  File "/root/chia-blockchain/chia/util/keyring_wrapper.py", line 58, in check_legacy_keyring_keys_present
    credential: Optional[Credential] = keyring.get_credential(keychain_service, current_user)
AttributeError: 'NoneType' object has no attribute 'get_credential'


Any thoughts are welcome.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Highly appreciated this write up.
I went through all the steps and 1.6.2dev0 is installed now.
However I get an error when adding a key:

Code:
(venv) [root@chianew ~/chia-blockchain]# chia keys add
Traceback (most recent call last):
  File "/root/chia-blockchain/venv/bin/chia", line 8, in <module>
    sys.exit(main())
  File "/root/chia-blockchain/chia/cmds/chia.py", line 136, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1654, in invoke
    super().invoke(ctx)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/root/chia-blockchain/venv/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/root/chia-blockchain/chia/cmds/keys.py", line 20, in keys_cmd
    if ctx.obj["force_legacy_keyring_migration"] and not asyncio.run(migrate_keys(root_path, True)):
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/root/chia-blockchain/chia/cmds/keys_funcs.py", line 279, in migrate_keys
    legacy_keyring = Keychain(force_legacy=True)
  File "/root/chia-blockchain/chia/util/keychain.py", line 265, in __init__
    KeyringWrapper.get_legacy_instance() if force_legacy else KeyringWrapper.get_shared_instance()
  File "/root/chia-blockchain/chia/util/keyring_wrapper.py", line 187, in get_legacy_instance
    return KeyringWrapper(force_legacy=True)
  File "/root/chia-blockchain/chia/util/keyring_wrapper.py", line 115, in __init__
    if check_legacy_keyring_keys_present(legacy_keyring):
  File "/root/chia-blockchain/chia/util/keyring_wrapper.py", line 58, in check_legacy_keyring_keys_present
    credential: Optional[Credential] = keyring.get_credential(keychain_service, current_user)
AttributeError: 'NoneType' object has no attribute 'get_credential'


Any thoughts are welcome.
Yeah this is the bug that got fixed. Right now things are kinda in a middle ground area where they are switching from the old key management to the new one.

i think you can make this change and i bet it will work.
 

EtienneB

Explorer
Joined
Feb 19, 2018
Messages
78
Thanks, that did the trick indeed!
Time to upgrade my db to v2 now and a new jail, as the plugin just fails to install.
 

EtienneB

Explorer
Joined
Feb 19, 2018
Messages
78
Did you manage to upgrade Chia to version 2?

I got an error:
Building editable for chia-blockchain (pyproject.toml) ... done
Created wheel for chia-blockchain: filename=chia_blockchain-2.1.1-0.editable-py3-none-any.whl size=10107 sha256=56ff79bb81ada91616f9f36fde22e259d0d4f09a659bc3dcd3e21490e1e928bd
Stored in directory: /tmp/pip-ephem-wheel-cache-eo1vg4_q/wheels/da/a4/cf/37bf78dde4ee7cf68952e463fb996b8339fe4389d183bcaa04
Building wheel for chiabip158 (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for chiabip158 (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [46 lines of output]
running bdist_wheel
running build
running build_ext
creating tmp
cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I/root/chia-blockchain/venv/include -I/usr/local/include/python3.9 -c /tmp/tmplvuutxxx.cpp -o tmp/tmplvuutxxx.o -std=c++17
cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I/root/chia-blockchain/venv/include -I/usr/local/include/python3.9 -c /tmp/tmpuobc6ca7.cpp -o tmp/tmpuobc6ca7.o -fvisibility=hidden
building 'chiabip158' extension
creating build
creating build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39
creating build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/python-bindings
creating build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/src
creating build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/src/crypto
creating build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/src/primitives
creating build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/src/script
creating build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/src/util
cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I/tmp/pip-build-env-b_fh104o/overlay/lib/python3.9/site-packages/pybind11/include -I/tmp/pip-build-env-b_fh104o/overlay/lib/python3.9/site-packages/pybind11/include -Isrc -I/root/chia-blockchain/venv/include -I/usr/local/include/python3.9 -c python-bindings/PyBIP158.cpp -o build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/python-bindings/PyBIP158.o -DVERSION_INFO=\"1.3\" -std=c++17 -fvisibility=hidden
python-bindings/PyBIP158.cpp:20:23: warning: comparison of integers of different signs: 'int' and 'std::vector<std::vector<unsigned char>>::size_type' (aka 'unsigned long') [-Wsign-compare]
for (int i = 0; i < hashes.size(); ++i)
~ ^ ~~~~~~~~~~~~~
python-bindings/PyBIP158.cpp:23:22: warning: comparison of integers of different signs: 'int' and 'std::vector<unsigned char>::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int j=0;j<hashes.size();j++)
~^~~~~~~~~~~~~~~~~
python-bindings/PyBIP158.cpp:50:18: warning: comparison of integers of different signs: 'int' and 'std::vector<unsigned char>::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int j=0;j<hash.size();j++)
~^~~~~~~~~~~~
python-bindings/PyBIP158.cpp:62:23: warning: comparison of integers of different signs: 'int' and 'std::vector<std::vector<unsigned char>>::size_type' (aka 'unsigned long') [-Wsign-compare]
for (int i = 0; i < hashes.size(); ++i)
~ ^ ~~~~~~~~~~~~~
python-bindings/PyBIP158.cpp:65:22: warning: comparison of integers of different signs: 'int' and 'std::vector<unsigned char>::size_type' (aka 'unsigned long') [-Wsign-compare]
for(int j=0;j<hashes.size();j++)
~^~~~~~~~~~~~~~~~~
5 warnings generated.
cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I/tmp/pip-build-env-b_fh104o/overlay/lib/python3.9/site-packages/pybind11/include -I/tmp/pip-build-env-b_fh104o/overlay/lib/python3.9/site-packages/pybind11/include -Isrc -I/root/chia-blockchain/venv/include -I/usr/local/include/python3.9 -c python-bindings/chiabip158.cpp -o build/temp.freebsd-13.1-RELEASE-p7-amd64-cpython-39/python-bindings/chiabip158.o -DVERSION_INFO=\"1.3\" -std=c++17 -fvisibility=hidden
In file included from python-bindings/chiabip158.cpp:19:
In file included from python-bindings/PyBIP158.h:18:
In file included from src/blockfilter.h:13:
In file included from src/primitives/block.h:9:
In file included from src/primitives/transaction.h:11:
In file included from src/script/script.h:9:
In file included from src/crypto/common.h:15:
src/compat/endian.h:17:10: error: 'endian.h' file not found with <angled> include; use "quotes" instead
#include <endian.h>
^~~~~~~~~~
"endian.h"
1 error generated.
error: command '/usr/bin/cc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for chiabip158
Successfully built chia-blockchain
Failed to build chiabip158
ERROR: Could not build wheels for chiabip158, which is required to install pyproject.toml-based projects
WARNING: There was an error checking the latest version of pip.

and then 'chia' does not exist as an app.

Any ideas?
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Did you manage to upgrade Chia to version 2?

I got an error:

and then 'chia' does not exist as an app.

Any ideas?
Yeah I got it upgraded but in the latest release there was an update that required them to make a change but lots of the repo's didn't get pushed so you will have to clone each repo that fails and manually build it. So clone chiabip158 and build that in your venv. After you make it past that I think there are 3 more. I also updated the requirements.txt to match the new versions.
 

Christopher_P

Dabbler
Joined
Nov 10, 2019
Messages
10
Might be worth me posting here vs. starting up a new thread. I am harvesting from within a jail got my full node running from a different machine. This has been working just fine. The issue I'm having is automatically restarting the harvester on system/jail reboot. The init script seems like it should be so basic but I haven't put the work in to understand the nuance associated with RC scripts.

Here's what I got and what I'm seeing:

Code:
#!/usr/local/bin/bash

set -x
exec >/tmp/chia.log 2>&1

source /chia-blockchain/venv/bin/activate
#added this as an attempt to force chia to use the correct config.yaml dir
#cd /root/.chia/mainnet/config
chia start harvester -r


Here's my error log. Basically, the 'chia start harvester -r' command looks to be attempting to load from / instead of root's home dir /root. I tried symlinking the config.yaml already but that introduced a whole bunch of other errors.

The error is telling me to re-run 'chia init' but that shouldn't be necessary. I can harvest from this setup just fine if I start the harvester manually. The correct config.yaml is located at /root/.chia/mainnet/config/config.yaml

+ source /chia-blockchain/venv/bin/activate
++ deactivate nondestructive
++ '[' -n '' ']'
++ '[' -n '' ']'
++ '[' -n /usr/local/bin/bash -o -n '' ']'
++ hash -r
++ '[' -n '' ']'
++ unset VIRTUAL_ENV
++ '[' '!' nondestructive = nondestructive ']'
++ VIRTUAL_ENV=/chia-blockchain/venv
++ export VIRTUAL_ENV
++ _OLD_VIRTUAL_PATH=/sbin:/bin:/usr/sbin:/usr/bin
++ PATH=/chia-blockchain/venv/bin:/sbin:/bin:/usr/sbin:/usr/bin
++ export PATH
++ '[' -n '' ']'
++ '[' -z '' ']'
++ _OLD_VIRTUAL_PS1=
++ PS1='(venv) '
++ export PS1
++ '[' -n /usr/local/bin/bash -o -n '' ']'
++ hash -r
+ cd /root
+ chia start harvester -r
can't find /.chia/mainnet/config/config.yaml
** please run `chia init` to migrate or create new config files **


EDIT:
Would help if I asked a question. Does anyone have a working RC script to share? Any thoughts on how I can go about making Chia use the correct config.yaml directory?
 
Last edited:
Top