chia-blockchain/README.md

97 lines
3.3 KiB
Markdown
Raw Normal View History

# chia-blockchain
2019-11-03 19:24:49 +03:00
Python 3.7 is used for this project. Make sure your python version is >=3.7 by typing python3.
### Install on Debian/Ubuntu
```bash
sudo apt-get update
sudo apt-get install build-essential cmake python3-dev python3-venv --no-install-recommends mongodb-org=4.2.1
sh install.sh
# Run mongo database
mongod --fork --dbpath ./db/ --logpath mongod.log
. .venv/bin/activate
```
### Install on MacOS
Make sure [brew](https://brew.sh/) is available before starting the setup.
```bash
brew tap mongodb/brew
brew install cmake boost gmp mpir mpfr mongodb-community@4.2
2019-11-20 10:21:05 +03:00
git clone https://github.com/Chia-Network/chia-blockchain.git && cd chia-blockchain
git clone https://github.com/wbhart/flint2
2019-10-16 11:38:49 +03:00
sh install.sh
2019-11-22 09:53:04 +03:00
# Run mongo database
2019-11-22 11:35:52 +03:00
mongod --fork --dbpath ./db/ --logpath mongod.log
. .venv/bin/activate
```
2019-07-30 09:54:26 +03:00
### Generate keys
First, create some keys by running the following script:
2019-07-30 09:54:26 +03:00
```bash
python -m scripts.regenerate_keys
```
2019-09-20 07:57:22 +03:00
### 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.
```bash
2019-11-28 09:36:01 +03:00
python -m src.server.start_full_node "127.0.0.1" 8444 -id 1 -u 8222 &
ssh -p 8222 localhost
2019-08-05 09:16:08 +03:00
```
2019-09-20 07:57:22 +03:00
### 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.
2019-09-20 07:57:22 +03:00
```bash
python -m scripts.create_plots -k 20 -n 10
2019-11-27 19:39:03 +03:00
sh ./scripts/run_farming.sh
2019-09-20 07:57:22 +03:00
```
### 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.
2019-10-31 00:38:16 +03:00
```bash
2019-11-28 09:36:01 +03:00
sh ./scripts/run_timelord.sh
2019-10-31 00:38:16 +03:00
```
### Tips
When running the servers on Mac OS, allow the application to accept incoming connections.
2019-11-28 09:36:01 +03:00
UPnP is enabled by default, to open the port for incoming connections. If this causes issues, you can disable it in the configuration. Some routers may require port forwarding, or enabling UPnP in the router configuration.
You can also run the simulation, which runs all servers and multiple full nodes, locally, at once.
If you want to run the simulation, change the introducer ip in ./config/config.yaml so that the full node points to the local introducer (192.0.0.1:8445).
```bash
2019-11-27 19:39:03 +03:00
sh ./scripts/run_all_simulation.sh
```
2019-08-05 09:16:08 +03:00
### Run tests and linting
2019-10-09 10:36:58 +03:00
The first time the tests are run, BlockTools will create and persist many plots. These are used for creating
2019-10-25 13:25:26 +03:00
proofs of space during testing. The next time tests are run, this won't be necessary.
2019-11-22 09:53:04 +03:00
Make sure to run mongo before running the tests.
2019-08-05 09:16:08 +03:00
```bash
2019-11-22 09:53:04 +03:00
mongod --dbpath ./db/ &
black src tests && flake8 src && mypy src tests
py.test tests -s -v
2019-08-05 09:16:08 +03:00
```
### 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
7. Preferences > Settings > Formatting > Python > Provider > black
6. Preferences > Settings > mypy > Targets: set to ./src and ./tests