Getting Set Up

If you’re on macOS, install Homebrew and run scripts/macos-setup.sh. Note that if you don’t have Homebrew or you’re not on macOS, the below information details what you’ll need. The script additionally sets up pre-commit hooks.

Building

Currently the easiest way to build is using the Dockerfile at the root of the repository. A simple docker build should get you a functioning container.

If you want to build natively, there are a few prereqs you’ll need to go through. In particular, you’ll need the protobuf compiler. You’ll also need to install the protoc-gen-gogoslick toolchain, which you can install using go get:

go get -u github.com/gogo/protobuf/protoc-gen-gogoslick

Run go generate ./.../ from keep-core and if everything is fine, start the Keep client with go run main.go.

Setting up local Keep network

For development purposes, it is convenient to set up local Ethereum client with a group of connected peers. A note-taken walkthrough covers the entire process including setting up local Ethereum client, deploying Keep contracts and configuring Keep peers.

Quick installation

To quickly install and start a client use the following scripts.

Install script

The install.sh script will:

  • migrate contracts

  • update client config files

  • build client

The script will ask you for the password to previously created ethereum accounts.

To start the installation execute:

./scripts/install.sh

Starting a client

To start a client execute:

./scripts/start.sh

The start.sh script will ask you to:

  • provide ethereum password

  • provide path to keep-core config files directory

  • select a config .toml file for your client

Development Guidelines

There are two primary languages in the Keep code right now:

Go

Go code largely adheres to community practices where they have been decided. Divergences and additional tidbits are listed in the Go Guidelines document.

Solidity

Solidity code generally adheres to the Solidity style guide. Contracts and their functions are documented using the Ethereum Natural Specification Format (NatSpec).

Relay States

There is a set of threshold relay state diagrams auto-generated from this repo’s docs available at https://docs.keep.network/relay-states.pdf. The images in the diagram, whose sources are at img-src/*.tikz, are also available at https://docs.keep.network/img/generated/*.png (the filenames are identical to their TikZ sources, with a .png suffix instead of .tikz). These URLs are for the main version of the repo; non-main branches are instead published to https://docs.keep.network/<branch name>/.

Common problems

  • Please avoid using ~ when defining $GOBIN location and use $HOME instead. We’ve been observing some issues with locating protoc-gen-gogoslick when running go generate and $GOBIN contained ~.

  • For Mojave, if you have a problem with missing include or missing library and you are sure that you have installed xcode with xcode-select --install. Then install the following package: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Working with Solidity contracts

The fastest and easiest way to have local Ethereum testent is to use Ganache app. https://truffleframework.com/ganache/

You can also use a demo script to help you deploy contracts to your local testnet and to have demo balances (token, staking and token grants) allocated between first two accounts.

Go to solidity directory and run:

npm install
npm run demo