mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-08-24 10:05:29 -05:00
+6









Kyle Altendorf
GitHub
Adam Kelly
Earle Lowe
Evan Graham
wjblanke
Arvid Norberg
Mariano Sorgente
Jack Nelson
Mariano Sorgente
Jeff
dustinface
neurosis69
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Gene Hoffman
William Allen
7e3e18bdfd
* Resend transactions (#11167) * Resend transactions * Don't recheck transactions more frequently than timeout * Add wallet resend parameter to config, move timeout code out of tx store, but close to call site * Add a test for wallet transaction resend * Add test for wallet retry * isort new files for precommit and update workflows * Use correct fixture name * LGTM - remove unused import Co-authored-by: Earle Lowe <e.lowe@chia.net> * less except -> false (#10219) * less except -> false * establish_connection() and .perform_handshake() can just return None * remove more pointless, and no wrong, assertions * Write python version error to stderr (#11239) Co-authored-by: wjblanke <wjb98672@gmail.com> * simplify SizedBytes and StructStream (#11429) * simplify SizedBytes and StructStream * lint * super() !!! * do not pass parameter up to super().__init__() * Update chia/util/struct_stream.py Co-authored-by: Arvid Norberg <arvid@libtorrent.org> * parse fixed-width int data from class name * add int512 and uint128 .from_bytes(), test .parse() failures * test serialization against struct.pack() * use typing_extensions for final * override ignore * stop using struct for StructStream oh the irony * fixup .to_bytes() to accept parameters again for where we use that * bring back signed parameter * format * adjust tests for new exception * eliminate custom coding for uint128 and int512 * tidy * remove unused StructStream.PACK attribute * add direct tests for parse_metadata_from_name() * stricter hinting * remove no-longer-needed typeshed work-around * apply strict type checking to all touched files * remove StructStream override of .to_bytes() * tidy * types touchup * add unused parameter comments Co-authored-by: Arvid Norberg <arvid@libtorrent.org> Co-authored-by: wjblanke <wjb98672@gmail.com> * Allow services to set a non-default max request body size limit (#11516) * updated bls to 13 (#11529) * reduce the redundant computations of coin_ids in block_body_validation (#11530) * add test for streamable -> json conversion (#11527) * add test for streamable -> json conversion * fixup test * Uses the new `from_bytes_unchecked` method in blspy, to improve perfo… (#11463) * Uses the new `from_bytes_unchecked` method in blspy, to improve performance * Update test * Fix merge conflict * Use from_bytes_unchecked in post_init and from_json * More uniform code * rename test files that are missing test_ prefix (#10712) * rename test files that are missing test_ prefix * update mypy and isort excludes * skip test_get_host_addr6() in GitHub Actions under macOS * rebuild workflows * Coin Selection Refactor With CAT Coin Selection Refactor (#9975) * add exact match and best exact match algorithms * optimize algorithm further this might be good. * lint * fix bad logic * add final algorithms * delete lint * oops * Update coin_selection.py * simplify and fix knapsack algoritm * simplify code and correct logic * make it way better. * clarify comments and check for edge cases. * add comments and stuff * improve coin selection addressed comments Thanks! * add coin_selection rpc tests. * clean up and add new unit tests * undo test changes * add extra test cases * move coin_selection to its own function and switch to it for cat and main wallet. * add cat tests * lint * make function align with standards also removed test * make test better * add proper types * Improve code clarity * wallet: fix coin selection bugs * wallet: add an assert just in case * tests: add some sleeps to reduce flakiness * Isort Co-authored-by: Kyle Altendorf <sda@fstab.net> * fix bad merge * lint * fix tests * address aforementioned changes. * remove wallet test * isort * more tests and fixes * lint * rename to amount for coin selection rpc * fix incase we have no smaller coins * fix tests + lint * re add asserts * oops missed me. * lint * fix test * Squashed commit of the following: commit34a2235de5Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Apr 13 10:09:42 2022 -0400 clarify comment commitadbf7f4f94Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:27:05 2022 -0400 linty lint commit5ebc1ac9fdAuthor: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 20:17:19 2022 -0400 add failure test and final changes commit7e5a21b4c2Author: Jack Nelson <jack@jacknelson.xyz> Date: Tue Apr 12 19:35:18 2022 -0400 add descriptions and slim down code commit31c95b916dMerge:d7b91295bd9b0ef5f3Author: Jack Nelson <jack@jacknelson.xyz> Date: Mon Apr 11 10:12:05 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commitd7b91295b5Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:31:09 2022 -0400 lint commit30dc7c0ab4Author: Jack Nelson <jack@jacknelson.xyz> Date: Sun Apr 10 20:25:52 2022 -0400 fix tests commit6c8c2e4874Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:06:00 2022 -0400 remove duplicate code. commit9f79b6f304Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 15:01:10 2022 -0400 address more concerns commit67c1b3929fAuthor: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 12:59:05 2022 -0400 fix logic error commit2d19a53245Author: Jack Nelson <jack@jacknelson.xyz> Date: Thu Mar 31 11:47:52 2022 -0400 simplify and de duplicate code commit6ab1cc79bbAuthor: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:34:50 2022 -0400 add function and select individual coin commit582c17aa8dMerge:ce2165942618fbaebaAuthor: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 21:14:37 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commitce21659429Merge:16aabb3fd6daba28dbAuthor: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:53:21 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit16aabb3fd5Merge:0b9fc28452286fe426Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:49:02 2022 -0400 Merge branch 'jack-cat-coinselection' into jn_coinselection_dust commit0b9fc28455Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:38:12 2022 -0400 lint commit62e74c72f4Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 20:34:22 2022 -0400 fix logic and tests commite738f44320Author: Jack Nelson <jack@jacknelson.xyz> Date: Wed Mar 30 18:52:05 2022 -0400 deal with dust and add tests * make sure that we do not use any dust * minor change * address concerns * adjust comments * adjust comment Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net> * rebuild workflows (#11543) * remove the cache from CoinStore. It appears the cost of maintaining the cache outweighs the gains. (#11540) * Keep daemon websocket alive during keyring unlock (#11371) * When prompting to unlock the keyring during daemon launch, it's possible that the daemon websocket connection will timeout before the user has entered their passphrase. We can't quickly detect that the connection has timed-out, so instead we now reconnect after collecting the passphrase, unlock the keyring, and then close the old connection. * mypy fix * Switch to using asyncio.loop.run_in_executor to collect the passphrase on its own thread. * Use a new ThreadPoolExecutor configured with 1 worker thread. * Support searching derived addresses on testnet. (#11449) * Support searching derived addresses on testnet. * Added tests * Optimize code to not perform useless subgroup checks (#11546) * Optimize code to not perform useless subgroup checks * Revert less important optimizations * hints and strict type checking for test_wallet (#11541) * hints and strict type checking for test_wallet * fixup * flip flop * disable pytest-monitor by default (#11507) * disable pytest-monitor by default * take 2 * make recurse_jsonify() work directly on types (#11537) * make recurse_jsonify() work directly on types, circumventing the dataclasses.asdict() step. This enables simpler integration of non dataclasses into the Streamable and JSON protocols * add benchmark for Streamable.to_json_dict() * tests: Split up and improve `test_wallet_rpc.py` (#11552) This breaks up the one big test into ``` test_send_transaction test_create_signed_transaction test_create_signed_transaction_with_coin_announcement test_create_signed_transaction_with_puzzle_announcement test_send_transaction_multi test_get_transactions test_get_transaction_count test_cat_endpoints test_offer_endpoints test_key_and_address_endpoints ``` Note that there is still much more room for improvements. Also the following tests can still be split up more: ``` test_get_transactions test_cat_endpoints test_offer_endpoints test_key_and_address_endpoints ``` * Remove unneeded uint64() intermediate in CAT wallet (#11575) * Get get_args() and get_origin() from typing_extensions (#11571) * Get get_args() and get_origin() from typing_extensions * Update streamable.py * cleanup * Fix several flaky tests (#11576) * Increase some of the timeouts to reduce flakiness * Experiment with CI for flakiness * Force more runs * Add argument name * Fix flaky mempool test * Attempt to fix another flaky test * Fix wallet retry test * Missing arg * Lint * Increase benchmark test time * Debug * Debug * Simplify retry test * Lint * More lint * Return false instead of assert * No need to check disconnect twice (since we don't break, this was flaky) * Remove useless changes * Accidental changes revert * Accidental changes revert 2 * Accidental changes revert 3 * Revert fixture * Fix a few additional flaky tests (#11597) * Fix a few additional flaky tests * Lint * Update tests/core/full_node/stores/test_full_node_store.py Co-authored-by: Jeff <jeff@chia.net> * Fix merge conflict * Remove unnecessary function Co-authored-by: Jeff <jeff@chia.net> * Bind port 0 to fix race condition when grabbing available ports (#11578) * port 0 to fix flakiness * Try fixing setup_full_system * Try fixing setup_full_system, and lint * More attempts to fix * No more calls to get random ports in setup_nodes * Revert accidental changes * Timelord extra arg * Try with port 0 * Fix daemon test, and lint * Try without 0.0.0.0 * Back to 0.0.0.0 * Try a few timelord changes to get test running * Increase timeout again * Use the correct interface to get the port * INFO logging to debug issue * Revert "INFO logging to debug issue" This reverts commit7c379e5cca. * Fix advertised port log * Add extra log * Logging back * Rollback the timelord changes * Try port 0 timelord * Revert "Try port 0 timelord" This reverts commit4997faf3b2. * Try full green, change ordering * Remove unused var * speed up simulation and cleanup * Now try without the port config * Fix a flaky call to get_event_loop * Try getting the port dynamically * No dynamic port * Try changing the ordering * Try adding a sleep * Back to what works * Timelord before vdf clients * Dynamic port for 1st timelord * Revert "Dynamic port for 1st timelord" This reverts commit0f322a15b7. * Revert "Timelord before vdf clients" This reverts commit3286c34696. * Revert "Back to what works" This reverts commit30380dffb7. * Revert "Try adding a sleep" This reverts commit9212b665a6. * Revert "Try changing the ordering" This reverts commita62597d70d. * Revert "No dynamic port" This reverts commit5d2e15749b. * Revert "Try getting the port dynamically" This reverts commitef9cd75679. * Revert "Fix a flaky call to get_event_loop" This reverts commit01a000fdfb. * Try one to 0 * Just not 0 * Don't get port dynamically * Cleanup a bit * Fix * Some cleanup work * Some cleanup work * Fix daemon test * Cleanup * Remove arguments * restore missing hints being stored as None (instead of 0-length bytes) (#11568) * Coin simplification (#11567) * factor out as_list() from Coin into free function. Remove unused name_str() from Coin. Minor optimization of hash_coin_ids() for common case. * extend Coin unit test * test installer on fedora:36, drop 33 * add tests.util.misc.assert_maximum_duration for benchmark assertions (#11589) * add tests.util.misc.assert_maximum_duration for benchmark assertions * fix some imports * more * lint * correct duration * hint fixup * rename to caller_file_and_line() * set default timer to thread_time() * extract gc manager and default to disabling * self calibrate overhead * wrap none-ness behind .results() method * add messages * from __future__ import annotations * yield out self * final from typing_extensions * split it * just use Future * tweak * tweak * correction in loosely hint checked file * all future indexing in hints * union for the hints * rename * assert_runtime() * another rename... * message -> label * label all results with test names * oops * early return from _set_spent function (#11594) * check for removals before calling function * move condition to function * remove redundant condition (#11582) * fix built-in profiler to work for mac (#11590) * Bump actions/setup-python from 2 to 3 (#10949) * Bump actions/setup-python from 2 to 3 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 3. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Fixup templates for python@v3 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com> * avoid cancelling release/** and long_lived/** (#11519) * tests: Some adjustments in `test_offer_endpoints` (#11558) This is a follow up after #11552 which basically used the initial parts of `test_cat_endpoints` to make `test_offer_endpoints` working. Now this PR drops a lot of the stuff we can assume to be not needed in this test because its tested in `test_cat_endpoints` and it adds some general improvments to it. * async sleep and require connection reset error for DoS test (#11612) * fix jsonify bool * Remove is not None and length assertion in select_coins() (#11569) * Remove is not None and length assertion in select_coins() The `coins is not None` check seems unneeded since `select_coins()` is hinted to return `Set[Coin]`. The length requirement needlessly restricts from being able to request a zero amount. Either situation would either trigger an exception in the next assert, or trigger the assert itself for non-zero amounts requested. * also remove from cat_wallet.py * new port 0 stuff Co-authored-by: Adam Kelly <338792+aqk@users.noreply.github.com> Co-authored-by: Earle Lowe <e.lowe@chia.net> Co-authored-by: Evan Graham <me@luakt.net> Co-authored-by: wjblanke <wjb98672@gmail.com> Co-authored-by: Arvid Norberg <arvid@libtorrent.org> Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: Jack Nelson <jack@jacknelson.xyz> Co-authored-by: Mariano Sorgente <sorgente711@gmail.com> Co-authored-by: Jeff <jeff@chia.net> Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com> Co-authored-by: neurosis69 <83925572+neurosis69@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com> Co-authored-by: William Allen <wallentx@users.noreply.github.com>
311 lines
11 KiB
Bash
Executable File
311 lines
11 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -o errexit
|
|
|
|
USAGE_TEXT="\
|
|
Usage: $0 [-adh]
|
|
|
|
-a automated install, no questions
|
|
-d install development dependencies
|
|
-h display this help and exit
|
|
"
|
|
|
|
usage() {
|
|
echo "${USAGE_TEXT}"
|
|
}
|
|
|
|
PACMAN_AUTOMATED=
|
|
EXTRAS=
|
|
|
|
while getopts adh flag
|
|
do
|
|
case "${flag}" in
|
|
# automated
|
|
a) PACMAN_AUTOMATED=--noconfirm;;
|
|
# development
|
|
d) EXTRAS=${EXTRAS}dev,;;
|
|
h) usage; exit 0;;
|
|
*) echo; usage; exit 1;;
|
|
esac
|
|
done
|
|
|
|
UBUNTU=false
|
|
DEBIAN=false
|
|
if [ "$(uname)" = "Linux" ]; then
|
|
#LINUX=1
|
|
if command -v apt-get >/dev/null; then
|
|
OS_ID=$(lsb_release -is)
|
|
if [ "$OS_ID" = "Debian" ]; then
|
|
DEBIAN=true
|
|
else
|
|
UBUNTU=true
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# Check for non 64 bit ARM64/Raspberry Pi installs
|
|
if [ "$(uname -m)" = "armv7l" ]; then
|
|
echo ""
|
|
echo "WARNING:"
|
|
echo "The Chia Blockchain requires a 64 bit OS and this is 32 bit armv7l"
|
|
echo "For more information, see"
|
|
echo "https://github.com/Chia-Network/chia-blockchain/wiki/Raspberry-Pi"
|
|
echo "Exiting."
|
|
exit 1
|
|
fi
|
|
# Get submodules
|
|
git submodule update --init mozilla-ca
|
|
|
|
UBUNTU_PRE_20=0
|
|
UBUNTU_20=0
|
|
UBUNTU_21=0
|
|
UBUNTU_22=0
|
|
|
|
if $UBUNTU; then
|
|
LSB_RELEASE=$(lsb_release -rs)
|
|
# In case Ubuntu minimal does not come with bc
|
|
if ! command -v bc > /dev/null 2>&1; then
|
|
sudo apt install bc -y
|
|
fi
|
|
# Mint 20.04 responds with 20 here so 20 instead of 20.04
|
|
if [ "$(echo "$LSB_RELEASE<20" | bc)" = "1" ]; then
|
|
UBUNTU_PRE_20=1
|
|
elif [ "$(echo "$LSB_RELEASE<21" | bc)" = "1" ]; then
|
|
UBUNTU_20=1
|
|
elif [ "$(echo "$LSB_RELEASE<22" | bc)" = "1" ]; then
|
|
UBUNTU_21=1
|
|
else
|
|
UBUNTU_22=1
|
|
fi
|
|
fi
|
|
|
|
install_python3_and_sqlite3_from_source_with_yum() {
|
|
CURRENT_WD=$(pwd)
|
|
TMP_PATH=/tmp
|
|
|
|
# Preparing installing Python
|
|
echo 'yum groupinstall -y "Development Tools"'
|
|
sudo yum groupinstall -y "Development Tools"
|
|
echo "sudo yum install -y openssl-devel openssl libffi-devel bzip2-devel wget"
|
|
sudo yum install -y openssl-devel openssl libffi-devel bzip2-devel wget
|
|
|
|
echo "cd $TMP_PATH"
|
|
cd "$TMP_PATH"
|
|
# Install sqlite>=3.37
|
|
# yum install sqlite-devel brings sqlite3.7 which is not compatible with chia
|
|
echo "wget https://www.sqlite.org/2022/sqlite-autoconf-3370200.tar.gz"
|
|
wget https://www.sqlite.org/2022/sqlite-autoconf-3370200.tar.gz
|
|
tar xf sqlite-autoconf-3370200.tar.gz
|
|
echo "cd sqlite-autoconf-3370200"
|
|
cd sqlite-autoconf-3370200
|
|
echo "./configure --prefix=/usr/local"
|
|
# '| stdbuf ...' seems weird but this makes command outputs stay in single line.
|
|
./configure --prefix=/usr/local | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
|
echo "make -j$(nproc)"
|
|
make -j"$(nproc)" | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
|
echo "sudo make install"
|
|
sudo make install | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
|
# yum install python3 brings Python3.6 which is not supported by chia
|
|
cd ..
|
|
echo "wget https://www.python.org/ftp/python/3.9.11/Python-3.9.11.tgz"
|
|
wget https://www.python.org/ftp/python/3.9.11/Python-3.9.11.tgz
|
|
tar xf Python-3.9.11.tgz
|
|
echo "cd Python-3.9.11"
|
|
cd Python-3.9.11
|
|
echo "LD_RUN_PATH=/usr/local/lib ./configure --prefix=/usr/local"
|
|
# '| stdbuf ...' seems weird but this makes command outputs stay in single line.
|
|
LD_RUN_PATH=/usr/local/lib ./configure --prefix=/usr/local | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
|
echo "LD_RUN_PATH=/usr/local/lib make -j$(nproc)"
|
|
LD_RUN_PATH=/usr/local/lib make -j"$(nproc)" | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
|
echo "LD_RUN_PATH=/usr/local/lib sudo make altinstall"
|
|
LD_RUN_PATH=/usr/local/lib sudo make altinstall | stdbuf -o0 cut -b1-"$(tput cols)" | sed -u 'i\\o033[2K' | stdbuf -o0 tr '\n' '\r'; echo
|
|
cd "$CURRENT_WD"
|
|
}
|
|
|
|
# Manage npm and other install requirements on an OS specific basis
|
|
if [ "$(uname)" = "Linux" ]; then
|
|
#LINUX=1
|
|
if [ "$UBUNTU_PRE_20" = "1" ]; then
|
|
# Ubuntu
|
|
echo "Installing on Ubuntu pre 20.*."
|
|
sudo apt-get update
|
|
# distutils must be installed as well to avoid a complaint about ensurepip while
|
|
# creating the venv. This may be related to a mis-check while using or
|
|
# misconfiguration of the secondary Python version 3.7. The primary is Python 3.6.
|
|
sudo apt-get install -y python3.7-venv python3.7-distutils openssl
|
|
elif [ "$UBUNTU_20" = "1" ]; then
|
|
echo "Installing on Ubuntu 20.*."
|
|
sudo apt-get update
|
|
sudo apt-get install -y python3.8-venv openssl
|
|
elif [ "$UBUNTU_21" = "1" ]; then
|
|
echo "Installing on Ubuntu 21.*."
|
|
sudo apt-get update
|
|
sudo apt-get install -y python3.9-venv openssl
|
|
elif [ "$UBUNTU_22" = "1" ]; then
|
|
echo "Installing on Ubuntu 22.* or newer."
|
|
sudo apt-get update
|
|
sudo apt-get install -y python3.10-venv openssl
|
|
elif [ "$DEBIAN" = "true" ]; then
|
|
echo "Installing on Debian."
|
|
sudo apt-get update
|
|
sudo apt-get install -y python3-venv openssl
|
|
elif type pacman >/dev/null 2>&1 && [ -f "/etc/arch-release" ]; then
|
|
# Arch Linux
|
|
# Arch provides latest python version. User will need to manually install python 3.9 if it is not present
|
|
echo "Installing on Arch Linux."
|
|
case $(uname -m) in
|
|
x86_64|aarch64)
|
|
sudo pacman ${PACMAN_AUTOMATED} -S --needed git openssl
|
|
;;
|
|
*)
|
|
echo "Incompatible CPU architecture. Must be x86_64 or aarch64."
|
|
exit 1
|
|
;;
|
|
esac
|
|
elif type yum >/dev/null 2>&1 && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ] && [ ! -f "/etc/fedora-release" ]; then
|
|
# AMZN 2
|
|
echo "Installing on Amazon Linux 2."
|
|
if ! command -v python3.9 >/dev/null 2>&1; then
|
|
install_python3_and_sqlite3_from_source_with_yum
|
|
fi
|
|
elif type yum >/dev/null 2>&1 && [ -f "/etc/centos-release" ]; then
|
|
# CentOS
|
|
echo "Install on CentOS."
|
|
if ! command -v python3.9 >/dev/null 2>&1; then
|
|
install_python3_and_sqlite3_from_source_with_yum
|
|
fi
|
|
elif type yum >/dev/null 2>&1 && [ -f "/etc/redhat-release" ] && grep Rocky /etc/redhat-release; then
|
|
echo "Installing on Rocky."
|
|
# TODO: make this smarter about getting the latest version
|
|
sudo yum install --assumeyes python39 openssl
|
|
elif type yum >/dev/null 2>&1 && [ -f "/etc/redhat-release" ] || [ -f "/etc/fedora-release" ]; then
|
|
# Redhat or Fedora
|
|
echo "Installing on Redhat/Fedora."
|
|
if ! command -v python3.9 >/dev/null 2>&1; then
|
|
sudo yum install -y python39 openssl
|
|
fi
|
|
fi
|
|
elif [ "$(uname)" = "Darwin" ]; then
|
|
echo "Installing on macOS."
|
|
if ! type brew >/dev/null 2>&1; then
|
|
echo "Installation currently requires brew on macOS - https://brew.sh/"
|
|
exit 1
|
|
fi
|
|
echo "Installing OpenSSL"
|
|
brew install openssl
|
|
elif [ "$(uname)" = "OpenBSD" ]; then
|
|
export MAKE=${MAKE:-gmake}
|
|
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
|
|
elif [ "$(uname)" = "FreeBSD" ]; then
|
|
export MAKE=${MAKE:-gmake}
|
|
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
|
|
fi
|
|
|
|
find_python() {
|
|
set +e
|
|
unset BEST_VERSION
|
|
for V in 310 3.10 39 3.9 38 3.8 37 3.7 3; do
|
|
if command -v python$V >/dev/null; then
|
|
if [ "$BEST_VERSION" = "" ]; then
|
|
BEST_VERSION=$V
|
|
if [ "$BEST_VERSION" = "3" ]; then
|
|
PY3_VERSION=$(python$BEST_VERSION --version | cut -d ' ' -f2)
|
|
if [[ "$PY3_VERSION" =~ 3.11.* ]]; then
|
|
echo "Chia requires Python version < 3.11.0" >&2
|
|
echo "Current Python version = $PY3_VERSION" >&2
|
|
# If Arch, direct to Arch Wiki
|
|
if type pacman >/dev/null 2>&1 && [ -f "/etc/arch-release" ]; then
|
|
echo "Please see https://wiki.archlinux.org/title/python#Old_versions for support." >&2
|
|
fi
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
done
|
|
echo $BEST_VERSION
|
|
set -e
|
|
}
|
|
|
|
if [ "$INSTALL_PYTHON_VERSION" = "" ]; then
|
|
INSTALL_PYTHON_VERSION=$(find_python)
|
|
fi
|
|
|
|
# This fancy syntax sets INSTALL_PYTHON_PATH to "python3.7", unless
|
|
# INSTALL_PYTHON_VERSION is defined.
|
|
# If INSTALL_PYTHON_VERSION equals 3.8, then INSTALL_PYTHON_PATH becomes python3.8
|
|
|
|
INSTALL_PYTHON_PATH=python${INSTALL_PYTHON_VERSION:-3.7}
|
|
|
|
if ! command -v "$INSTALL_PYTHON_PATH" >/dev/null; then
|
|
echo "${INSTALL_PYTHON_PATH} was not found"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Python version is $INSTALL_PYTHON_VERSION"
|
|
|
|
# Check sqlite3 version bound to python
|
|
SQLITE_VERSION=$($INSTALL_PYTHON_PATH -c 'import sqlite3; print(sqlite3.sqlite_version)')
|
|
SQLITE_MAJOR_VER=$(echo "$SQLITE_VERSION" | cut -d'.' -f1)
|
|
SQLITE_MINOR_VER=$(echo "$SQLITE_VERSION" | cut -d'.' -f2)
|
|
echo "SQLite version for Python is ${SQLITE_VERSION}"
|
|
if [ "$SQLITE_MAJOR_VER" -lt "3" ] || [ "$SQLITE_MAJOR_VER" = "3" ] && [ "$SQLITE_MINOR_VER" -lt "8" ]; then
|
|
echo "Only sqlite>=3.8 is supported"
|
|
exit 1
|
|
fi
|
|
|
|
# Check openssl version python will use
|
|
OPENSSL_VERSION_STRING=$($INSTALL_PYTHON_PATH -c 'import ssl; print(ssl.OPENSSL_VERSION)')
|
|
OPENSSL_VERSION_INT=$($INSTALL_PYTHON_PATH -c 'import ssl; print(ssl.OPENSSL_VERSION_NUMBER)')
|
|
# There is also ssl.OPENSSL_VERSION_INFO returning a tuple
|
|
# 1.1.1n corresponds to 269488367 as an integer
|
|
echo "OpenSSL version for Python is ${OPENSSL_VERSION_STRING}"
|
|
if [ "$OPENSSL_VERSION_INT" -lt "269488367" ]; then
|
|
echo "WARNING: OpenSSL versions before 3.0.2, 1.1.1n, or 1.0.2zd are vulnerable to CVE-2022-0778"
|
|
echo "Your OS may have patched OpenSSL and not updated the version to 1.1.1n"
|
|
fi
|
|
|
|
# If version of `python` and "$INSTALL_PYTHON_VERSION" does not match, clear old version
|
|
VENV_CLEAR=""
|
|
if [ -e venv/bin/python ]; then
|
|
VENV_PYTHON_VER=$(venv/bin/python -V)
|
|
TARGET_PYTHON_VER=$($INSTALL_PYTHON_PATH -V)
|
|
if [ "$VENV_PYTHON_VER" != "$TARGET_PYTHON_VER" ]; then
|
|
echo "existing python version in venv is $VENV_PYTHON_VER while target python version is $TARGET_PYTHON_VER"
|
|
echo "Refreshing venv modules..."
|
|
VENV_CLEAR="--clear"
|
|
fi
|
|
fi
|
|
|
|
$INSTALL_PYTHON_PATH -m venv venv $VENV_CLEAR
|
|
if [ ! -f "activate" ]; then
|
|
ln -s venv/bin/activate .
|
|
fi
|
|
|
|
EXTRAS=${EXTRAS%,}
|
|
if [ -n "${EXTRAS}" ]; then
|
|
EXTRAS=[${EXTRAS}]
|
|
fi
|
|
|
|
# shellcheck disable=SC1091
|
|
. ./activate
|
|
# pip 20.x+ supports Linux binary wheels
|
|
python -m pip install --upgrade pip
|
|
python -m pip install wheel
|
|
#if [ "$INSTALL_PYTHON_VERSION" = "3.8" ]; then
|
|
# This remains in case there is a diversion of binary wheels
|
|
python -m pip install --extra-index-url https://pypi.chia.net/simple/ miniupnpc==2.2.2
|
|
python -m pip install -e ."${EXTRAS}" --extra-index-url https://pypi.chia.net/simple/
|
|
|
|
echo ""
|
|
echo "Chia blockchain install.sh complete."
|
|
echo "For assistance join us on Keybase in the #support chat channel:"
|
|
echo "https://keybase.io/team/chia_network.public"
|
|
echo ""
|
|
echo "Try the Quick Start Guide to running chia-blockchain:"
|
|
echo "https://github.com/Chia-Network/chia-blockchain/wiki/Quick-Start-Guide"
|
|
echo ""
|
|
echo "To install the GUI type 'sh install-gui.sh' after '. ./activate'."
|
|
echo ""
|
|
echo "Type '. ./activate' and then 'chia init' to begin."
|