Chia blockchain python implementation (full node, farmer, harvester, timelord, and wallet)
Go to file
2019-11-25 17:35:43 +09:00
.github/workflows Update pythonpackage.yml 2019-11-24 18:55:22 +09:00
config Improve header syncing process 2019-11-24 17:08:34 +09:00
db Small tweaks 2019-11-22 17:04:23 +09:00
docs More work on docs 2019-11-25 17:35:43 +09:00
lib Cherry pick pybind11 fix 2019-11-22 16:51:28 +09:00
plots Scripts (#14) 2019-11-08 16:51:01 -05:00
scripts Small tweaks 2019-11-22 17:04:23 +09:00
src Fix for self connections 2019-11-25 10:23:27 +09:00
tests Improve header syncing process 2019-11-24 17:08:34 +09:00
.flake8 New blockchain class implementation 2019-09-24 15:01:32 +09:00
.gitignore More work on docs 2019-11-25 17:35:43 +09:00
definitions.py Scripts (#14) 2019-11-08 16:51:01 -05:00
install.sh Merge, change names of scrips, change ports 2019-11-22 12:57:01 +09:00
LICENSE Initial commit 2019-07-16 17:32:40 +09:00
mypy.ini Changed to mypy from pyright, fix tests (full node still broken) 2019-10-22 16:44:01 +09:00
README.md New command to start mongo 2019-11-22 17:35:52 +09:00
requirements.txt Add motor requirement 2019-11-20 17:43:35 +09:00
setup.py Merge with latest master, bug fixes, cleanup 2019-11-20 16:28:26 +09:00

chia-blockchain

Python 3.7 is used for this project. Make sure your python version is >=3.7 by typing python3.

Install

# for Debian-based distros
sudo apt-get install build-essential cmake python3-dev python3-venv --no-install-recommends mongodb-org=4.2.1

# for MacOS
brew tap mongodb/brew
brew install cmake mongodb-community@4.2

git clone https://github.com/Chia-Network/chia-blockchain.git && cd chia-blockchain
sh install.sh

# Run mongo database
mongod --fork --dbpath ./db/ --logpath mongod.log

Generate keys

First, create some keys by running the following script:

python -m scripts.regenerate_keys

Run a full node

To run a full node on port 8002, and connect to the testnet, run the following command. This wil also start an ssh server in port 8222 for the UI, which you can connect to to see the state of the node.

python -m src.server.start_full_node "127.0.0.1" 8002 -id 1 -u 8222 &
ssh -p 8222 localhost

Run a farmer + full node

Farmers are entities in the network who use their hard drive space to try to create blocks (like Bitcoin's miners), and earn block rewards. First, you must generate some hard drive plots, which can take a long time depending on the size of the plots. Then, run the farmer + full node with the following script. A full node is also started on port 8002, which you can ssh into to view the node UI.

python -m scripts.create_plots -k 20 -n 10
sh ./scripts/simulate_farming.sh

Run a timelord + full node

Timelords execute sequential verifiable delay functions (proofs of time), that get added to blocks to make them valid. This requires fast CPUs and a lot of memory.

sh ./scripts/simulate_farming.sh

Tips

When running the servers on Mac OS, allow the application to accept incoming connections. Try running one of the full nodes a few minutes after the other ones, to test initial sync. Configuration of peers can be changed in config/config.yaml. You can also run the simulation, which runs all servers and multiple full nodes, at once.

sh ./scripts/simulate_network.sh

Run tests and linting

The first time the tests are run, BlockTools will create and persist many plots. These are used for creating proofs of space during testing. The next time tests are run, this won't be necessary. Make sure to run mongo before running the tests.

mongod --dbpath ./db/ &
black src tests
flake8 src
mypy src tests
py.test tests -s -v

Configure VS code

  1. Install Python extension
  2. Set the environment to ./.venv/bin/python
  3. Install mypy plugin
  4. Preferences > Settings > Python > Linting > flake8 enabled
  5. Preferences > Settings > Python > Linting > mypy enabled
  6. Preferences > Settings > Formatting > Python > Provider > black
  7. Preferences > Settings > mypy > Targets: set to ./src and ./tests