2018-08-16 12:31:32 +02:00
<!-- -
2020-04-06 11:52:18 +02:00
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB software contributors.
2018-08-16 12:31:32 +02:00
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
Code is Apache-2.0 and docs are CC-BY-4.0
--->
2018-03-27 16:38:58 +02:00
# Notes on Running a Local Dev Node as Processes
2018-03-12 14:23:49 +01:00
The following doc describes how to run a local node for developing BigchainDB Tendermint version.
There are two crucial dependencies required to start a local node:
- MongoDB
- Tendermint
and of course you also need to install BigchainDB Sever from the local code you just developed.
2018-06-01 12:46:25 +02:00
## Install and Run MongoDB
2018-03-12 14:23:49 +01:00
2019-10-07 16:32:35 +02:00
MongoDB can be easily installed, just refer to their [installation documentation ](https://docs.mongodb.com/manual/installation/ ) for your distro.
2018-06-01 12:46:25 +02:00
We know MongoDB 3.4 and 3.6 work with BigchainDB.
2018-04-03 12:14:36 +02:00
After the installation of MongoDB is complete, run MongoDB using `sudo mongod`
2018-03-12 14:23:49 +01:00
2018-06-01 12:46:25 +02:00
## Install and Run Tendermint
### Installing a Tendermint Executable
2018-03-12 14:23:49 +01:00
2019-10-07 16:32:35 +02:00
The version of BigchainDB Server described in these docs only works well with Tendermint 0.31.5 (not a higher version number). Install that:
2018-06-01 12:46:25 +02:00
```bash
$ sudo apt install -y unzip
2019-10-07 16:32:35 +02:00
$ wget https://github.com/tendermint/tendermint/releases/download/v0.31.5/tendermint_v0.31.5_linux_amd64.zip
$ unzip tendermint_v0.31.5_linux_amd64.zip
$ rm tendermint_v0.31.5_linux_amd64.zip
2018-06-01 12:46:25 +02:00
$ sudo mv tendermint /usr/local/bin
```
2018-03-12 14:23:49 +01:00
### Installing Tendermint Using Docker
Tendermint can be run directly using the docker image. Refer [here ](https://hub.docker.com/r/tendermint/tendermint/ ) for more details.
### Installing Tendermint from Source
2018-06-01 12:46:25 +02:00
Before we can begin installing Tendermint one should ensure that the Golang is installed on system and `$GOPATH` should be set in the `.bashrc` or `.zshrc` . An example setup is shown below
2018-03-12 14:23:49 +01:00
```bash
$ echo $GOPATH
/home/user/Documents/go
$ go -h
Go is a tool for managing Go source code.
Usage:
go command [arguments]
The commands are:
build compile packages and dependencies
clean remove object files
...
```
- We can drop `GOPATH` in `PATH` so that installed Golang packages are directly available in the shell. To do that add the following to your `.bashrc`
```bash
export PATH=${PATH}:${GOPATH}/bin
```
2018-08-28 11:13:59 +02:00
Follow [the Tendermint docs ](https://tendermint.com/docs/introduction/install.html#from-source ) to install Tendermint from source.
2018-03-12 14:23:49 +01:00
2018-05-03 15:48:55 +02:00
If the installation is successful then Tendermint is installed at `$GOPATH/bin` . To ensure Tendermint's installed fine execute the following command,
2018-03-12 14:23:49 +01:00
```bash
$ tendermint -h
Tendermint Core (BFT Consensus) in Go
Usage:
tendermint [command]
Available Commands:
gen_validator Generate new validator keypair
help Help about any command
init Initialize Tendermint
...
```
### Running Tendermint
2018-06-01 12:46:25 +02:00
2018-03-12 14:23:49 +01:00
- We can initialize and run tendermint as follows,
```bash
$ tendermint init
...
$ tendermint node --consensus.create_empty_blocks=false
```
The argument `--consensus.create_empty_blocks=false` specifies that Tendermint should not commit empty blocks.
- To reset all the data stored in Tendermint execute the following command,
```bash
$ tendermint unsafe_reset_all
```
2018-06-01 12:46:25 +02:00
## Install BigchainDB
2018-03-12 14:23:49 +01:00
To install BigchainDB from source (for dev), clone the repo and execute the following command, (it is better that you create a virtual env for this)
```bash
$ git clone https://github.com/bigchaindb/bigchaindb.git
2018-06-01 12:46:25 +02:00
$ cd bigchaindb
2018-03-12 14:23:49 +01:00
$ pip install -e .[dev] # or pip install -e '.[dev]' # for zsh
```
2018-03-27 10:18:51 +02:00
## Running All Tests
2018-03-12 14:23:49 +01:00
To execute tests when developing a feature or fixing a bug one could use the following command,
```bash
2018-05-23 11:34:00 +02:00
$ pytest -v
2018-03-12 14:23:49 +01:00
```
NOTE: MongoDB and Tendermint should be running as discussed above.
One could mark a specific test and execute the same by appending `-m my_mark` to the above command.
Although the above should prove sufficient in most cases but in case tests are failing on Travis CI then the following command can be used to possibly replicate the failure locally,
```bash
2018-03-21 12:42:43 +01:00
$ docker-compose run --rm --no-deps bdb pytest -v --cov=bigchaindb
2018-03-12 14:23:49 +01:00
```
NOTE: before executing the above command the user must ensure that they reset the Tendermint container by executing `tendermint usafe_reset_all` command in the Tendermint container.