The easiest way to get set up for development is to install Python >=3.7
and pipenv
, then run the following:
make new_env_dev
pipenv shell
There are various makefile commands which are helpful during development. Some of the more prominent ones are listed below:
-
For linting:
make lint
-
For static analysis:
make mypy make pylint
-
For code security analysis:
make security
-
To run tests:
make test
This library uses python types which are generated (using Google's Protocol Buffers compiler) from protocol buffer schemas in the Cosmos SDK and WasmD.
When updating the Cosmos SDK version supported by this library (see the version currently used under COSMOS_SDK_VERSION
in Makefile), you will need to fetch its corresponding protobuf schemas and generate their associated python types, replacing the existing ones.
Note: This process has to be done only once when the Cosmos SDK version supported by this library is changed.
Note: To generate python types from Cosmos SDK protobuf schemas, you will need Google Protocol Buffers compiler. A guide on how to install it can be found here.
Below are the steps you need to take in order to achieve this:
-
Fetch the Cosmos SDK protobuf schema files:
make fetch_proto_schema_source
-
Generate python types:
make generate_proto_types
Note: For this library to be functional, only the python types generated from protobuf schemas are required, not the schema files themselves. The schema files are fetched on-demand only to enable the generation of python types. Therefore, the schema files are intentionally stored as local files and are NOT checked in to this repository to minimise its filesystem footprint.
The Makefile in this repo provides various useful commands that ease development. We will describe some of them here:
make lint
:- applies
black
: code formatter - applies
isort
: sorts imports - runs
flake8
: linter - runs
vulture
: detects unused code
- applies
make security
:- runs
bandit
: finds common security issues in Python code - runs
safety
: checks installed dependencies for known security vulnerabilities
- runs
make mypy
: runsmypy
, a static type checker for pythonmake pylint
: runspylint
, a static type checker and linter for python- tests:
make test
: runs all testsmake unit-test
: runs unit testsmake integration-test
: runs integration testsmake coverage-report
: produces the coverage report (you should run tests using one of the above commands first)
make clean
: removes temporary files and caches.make new_env
: creates a new environment (cleans and installs in normal mode)make new_env_dev
: creates a new development environment (cleans and installs in development mode)make liccheck
: checks dependencies and reports any license issuesmake copyright-check
: checks that files have the correct copyright headers- documentation:
make generate-docs
: generates documentation from the source codemake open-docs
: opensindex.html
page of the documentation (if on Linux or MacOS).
You require Go version 16.0 or higher for your platform (see here)
-
Setup FetchD
bash scripts/setup_fetchd.sh
The script will ask for root permissions while setting up a node.
-
Start the node
fetchd start
You require Docker for your platform.
-
Place the following entrypoint script somewhere in your system (e.g
~/fetchd_docker/fetchd_initialise.sh
):#!/usr/bin/env bash # variables export VALIDATOR_KEY_NAME=validator export BOB_KEY_NAME=bob export VALIDATOR_MNEMONIC="erase weekend bid boss knee vintage goat syrup use tumble device album fortune water sweet maple kind degree toss owner crane half useless sleep" export BOB_MNEMONIC="account snack twist chef razor sing gain birth check identify unable vendor model utility fragile stadium turtle sun sail enemy violin either keep fiction" export PASSWORD="12345678" export CHAIN_ID=testing export DENOM_1=stake export DENOM_2=atestfet # Add keys ( echo "$VALIDATOR_MNEMONIC"; echo "$PASSWORD"; echo "$PASSWORD"; ) |fetchd keys add $VALIDATOR_KEY_NAME --recover ( echo "$BOB_MNEMONIC"; echo "$PASSWORD"; ) |fetchd keys add $BOB_KEY_NAME --recover # Configure node fetchd init --chain-id=$CHAIN_ID $CHAIN_ID echo "$PASSWORD" |fetchd add-genesis-account $(fetchd keys show $VALIDATOR_KEY_NAME -a) 100000000000000000000000$DENOM_1 echo "$PASSWORD" |fetchd add-genesis-account $(fetchd keys show $BOB_KEY_NAME -a) 100000000000000000000000$DENOM_2 echo "$PASSWORD" |fetchd gentx $VALIDATOR_KEY_NAME 10000000000000000000000$DENOM_1 --chain-id $CHAIN_ID fetchd collect-gentxs # Enable rest-api sed -i '/^\[api\]$/,/^\[/ s/^enable = false/enable = true/' ~/.fetchd/config/app.toml sed -i '/^\[api\]$/,/^\[/ s/^swagger = false/swagger = true/' ~/.fetchd/config/app.toml fetchd start
-
Execute:
docker run -it --rm --entrypoint /scripts/<ENTRYPOINT_SCRIPT_NAME> -p 9090:9090 -p 1317:1317 -v <PATH_TO_ENTRYPOINT_SCRIPT>:/scripts/ fetchai/fetchd:0.9.0-rc4
where <ENTRYPOINT_SCRIPT_NAME>
is the name of the entrypoint script (e.g.fetchd_initialise.sh
) and <PATH_TO_ENTRYPOINT_SCRIPT>
is the path to the directory you placed the script (e.g.~/fetchd_docker/
).