Skip to content

Instantly share code, notes, and snippets.

@SippieCup
Last active June 7, 2021 00:07
Show Gist options
  • Save SippieCup/8420c831ffcd74f4c4c3c756d1bda912 to your computer and use it in GitHub Desktop.
Save SippieCup/8420c831ffcd74f4c4c3c756d1bda912 to your computer and use it in GitHub Desktop.
Safe way to install the multithreaded chiapos libary and rebuild chia-blockchain binaries
#!/bin/bash
# Note:
# I have not actually tested this installing into the
# chia-blockchain `install.sh` venv as I did not use it
# when I installed chia. I have only tested it in a
# test venv. YMMV!
if [ $# -eq 0 ]
then
echo "Usage: ./install_multithreaded_chiapos.sh /full/path/to/current/chia-blockchain"
exit 1
fi
WORK_DIR=/tmp/build-chia-stuff
# Clean up temporary files from previous attempts if they exist
rm -rf $WORK_DIR
cd $1
# activate the venv
# shellcheck disable=SC1091
if [ ! -f "activate" ]; then
echo "Error: Cannot find venv to activate"
exit 1
fi
. ./activate
# Create and move to temporary working directory
mkdir $WORK_DIR
cd $WORK_DIR
# Clone multithreaded library repo
git clone https://github.com/SippieCup/chiapos.git
cd chiapos
# We checkout a specific combined branch commit that I reviewed for security issues
# This ensures that any future potentially malicious commits, or modified history
# with malicious intent will not be included
# IF THIS COMMIT DOES NOT EXIST - DO NOT USE THE REPO
# UNTIL SOMEONE YOU TRUST HAS VALIDATED ITS SAFETY
git checkout 90f619bf2ff6739b2b0311e39e944015cd9f66d2
# Build chiapos library
python setup.py clean --all
python setup.py install
# Return to working directory and clone the official chia-blockchain repo
cd $WORK_DIR
git clone https://github.com/Chia-Network/chia-blockchain.git
cd chia-blockchain
# Update setup.py to accept the modified version of chiapos
sed -i.bak 's/chiapos\=\=[0-9]\+\.[0-9]\+\.[0-9]\+/chiapos==0.0.0/g' setup.py
# Build and install chia-blockchain binaries into the venv
python setup.py clean --all
python setup.py install
# Clean up temporary files after build
rm -rf $WORK_DIR
@SippieCup
Copy link
Author

SippieCup commented May 28, 2021

Here is a copy of the attached reddit post:

A lot of people have recently replied and PM'ed me about how to use the multi-threaded variant of chiapos with changes made by lukasstockner and pechy to improve plotting speeds. Going as far as to ask for unverified and potentially dangerous unverified binaries. Probably due to the fact I am constantly shilling its 30% gains (12 Hour plots to 8 hour plots when fully loaded.)

For the safety and betterment of the community, I thought I would provide a short script for anyone running Linux/MacOS to easily update their Chia binaries from source without editing the original chia-blockchain repo that was cloned by most when they installed Chia.

I think the only prerequisites for using the script is that you have the build-essential and cmake installed. Since my systems have these installed, and I'm too lazy to test on a fresh system/container, if there are more tools needed, hopefully someone else will post it. These can be installed with the following commands (also untested for non-arch, but should work).

on Arch based systems:

sudo pacman -S base-devel cmake

On Debian/Ubuntu based systems this is done by doing:

sudo apt install build-essential cmake python3-dev

On RHEL based, I believe this is done by doing:

sudo dnf group install "Development Tools"
sudo dnf install cmake

I don't know the "correct" way to do this on MacOS, but I'm sure its just a google search away.

That aside, here is the Install Script (LINK TO THIS GIST)

The script is quite easy to use. Just download it, make it executable, and pass your current chia-blockchain's path to it:

curl -o install_multithreaded_chiapos.sh https://gist.githubusercontent.com/SippieCup/8420c831ffcd74f4c4c3c756d1bda912/raw/d022b0fe9df26a1c4feea45b3bcff2a9baf503da/install_multithreaded_chiapos.sh
chmod a+x install_multithreaded_chiapos.sh
./install_multithreaded_chiapos.sh ~/chia-blockchain

This will not modify your original chia-blockchain install, and will leave no remnants of it's installation other than updated binaries & libary file in the venv, and it does not touch or work in any private files/folders.

To revert, simply reinstall from the original chia-blockchain repo you cloned.

If there are any mistakes in the script or instructions, let me know and I'll update them.

Thank you and stay safe, a.k.a don't install random binaries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment