Update README.md

pull/3237/head
Daniel Van Der Maden 4 years ago
parent d5acb110e7
commit fc9c9ae48c
  1. 261
      README.md

@ -1,166 +1,109 @@
# Harmony
[![Build Status](https://travis-ci.com/harmony-one/harmony.svg?token=DnoYvYiTAk7pqTo9XsTi&branch=master)](https://travis-ci.com/harmony-one/harmony)
<a href='https://github.com/jpoles1/gopherbadger' target='_blank'>![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-45%25-brightgreen.svg?longCache=true&style=flat)</a>
<a href="https://discord.gg/kdf8a6T">![Discord](https://img.shields.io/discord/532383335348043777.svg)</a>
[![Coverage Status](https://coveralls.io/repos/github/harmony-one/harmony/badge.svg?branch=master)](https://coveralls.io/github/harmony-one/harmony?branch=master)
![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-45%25-brightgreen.svg?longCache=true&style=flat)
![Discord](https://img.shields.io/discord/532383335348043777.svg)
[![Coverage Status](https://coveralls.io/repos/github/harmony-one/harmony/badge.svg?branch=main)](https://coveralls.io/github/harmony-one/harmony?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/harmony-one/harmony)](https://goreportcard.com/report/github.com/harmony-one/harmony)
# Play with the blockchain
## General Documentation
## Running the harmony blockchain with docker
The easiest way to run our blockchain locally is to use docker.
If you are on `OS X`, then install docker via `brew`.
```
$ brew cask install docker
$ open /Applications/Docker.app
```
https://docs.harmony.one
then you can run
## API Guide
```
$ docker run -it harmonyone/main:stable /bin/bash
```
http://api.hmny.io/
You'll be in this current repository when the shell opens up, now let's catch up on any missing
commits (all the following commands assume you are in the running docker container)
## Requirements
### Bleeding edge master
1. **GMP and OpenSSL**
On macOS:
```bash
brew install gmp
brew install openssl
```
$ git fetch
$ git reset --hard origin/master
```
### Mainnet release intended branch
On Linux (Ubuntu)
```bash
sudo apt install glibc-static gmp-devel gmp-static openssl-libs openssl-static gcc-c++
```
$ git fetch
$ git checkout t3
$ git reset --hard origin/t3
On Linux (Cent OS / Amazon Linux 2)
```bash
sudo yum install glibc-static gmp-devel gmp-static openssl-libs openssl-static gcc-c++
```
2. **Docker** (for testing)
And now run the local blockchain
```
$ test/debug.sh
On macOS:
```bash
brew cask install docker
open /Applications/Docker.app
```
On Linux, reference official documentation [here](https://docs.docker.com/engine/install/).
3. **Go 1.14.1**
4. **Bash 4+**
## Using our hmy command line tool
For macOS, you can reference this [guide](http://tldrdevnotes.com/bash-upgrade-3-4-macos). For Linux, you can reference this [guide](https://fossbytes.com/installing-gnu-bash-4-4-linux-distros/).
Assuming that you got `test/debug.sh` running in your docker container, we can interact with
the running blockchain using our `hmy` command line tool. Its part of our
[go-sdk](https://github.com/harmony-one/go-sdk) repo, but our docker container already has it as
well and built.
## Dev Environment
Find your running container's ID, here's an example
**Most repos from [harmony-one](https://github.com/harmony-one) assumes the GOPATH convention. More information [here](https://github.com/golang/go/wiki/GOPATH).**
```
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62572a199bac harmonyone/main:stable "/bin/bash" 2 minutes ago Up 2 minutes awesome_cohen
```
now lets get our second shell in the running container:
```
$ docker exec -it 62572a199bac /bin/bash
```
The container already comes with a prebuilt `hmy` that you can invoke anywhere, but lets go ahead
and build the latest version.
### First Install
Clone and set up all of the repos with the following set of commands:
1. Create the appropriate directories:
```bash
mkdir -p $(go env GOPATH)/src/github.com/harmony-one
cd $(go env GOPATH)/src/github.com/harmony-one
```
$ cd ../go-sdk
$ git fetch
$ git reset --hard origin/master
$ make
$ ./hmy version
Harmony (C) 2020. hmy, version v211-698b282 (@harmony.one 2020-01-17T00:58:51+0000)
```
Then checkout `./hmy cookbook` for example usages. The majority of commands output legal `JSON`,
here is one example:
> If you get 'unknown command' or something along those lines, make sure to install [golang](https://golang.org/doc/install) first.
2. Clone this repo & dependent repos.
```bash
git clone git@github.com:harmony-one/mcl.git
git clone git@github.com:harmony-one/bls.git
git clone git@github.com:harmony-one/harmony.git
cd harmony
```
root@62572a199bac:~/go/src/github.com/harmony-one/go-sdk# ./hmy blockchain latest-header
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"blockHash": "0x34a8b155f90b8fc22342fc8b5d1c969ed836a2f666c506e4017b570dc337e88c",
"blockNumber": 0,
"epoch": 0,
"lastCommitBitmap": "",
"lastCommitSig": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"leader": "one1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqquzw7vz",
"shardID": 0,
"timestamp": "2019-06-28 15:00:00 +0000 UTC",
"unixtime": 1561734000,
"viewID": 0
}
}
```
## Developing in the container
The docker container is a full harmony development environment and comes with emacs, vim, ag, tig
and other creature comforts. Most importantly, it already has the go environment with our C/C++
based library dependencies (`libbls` and `mcl`) setup correctly for you. You can also change go
versions easily, an example:
3. Build the harmony binary & dependent libs
```
$ eval $(gimme 1.14.1)
make
```
> Run `bash scripts/install_build_tools.sh` to ensure build tools are of correct versions.
Note that changing the go version might mean that dependencies won't work out right when trying to
run `test/debug.sh` again, get the correct environment again easily by `exec bash`.
## Dev Docker Container
## Installation Requirements for directly on your MacOS X
GMP and OpenSSL
Included in this repo is a Dockerfile that has a full harmony development environment and
comes with emacs, vim, ag, tig and other creature comforts. Most importantly, it already has the go environment
with our C/C++ based library dependencies (`libbls` and `mcl`) set up correctly for you.
You can build the docker container for yourself with the following commands:
```bash
brew install gmp
brew install openssl
cd $(go env GOPATH)/src/github.com/harmony-one/harmony
make clean
docker build -t harmony .
```
## On Linux Box (assuming Amazon Linux 2 or Cent OS)
Then you can start your docker container with the following command:
```bash
sudo yum install glibc-static gmp-devel gmp-static openssl-libs openssl-static gcc-c++
docker rm harmony # Remove old docker container
docker run --name harmony -it -v "$(go env GOPATH)/src/github.com/harmony-one/harmony:/root/go/src/github.com/harmony-one/harmony" harmony /bin/bash
```
> Note that the harmony repo will be shared between your docker container and your host machine. However, everything else in the docker container will be ephemeral.
## Dev Environment Setup
The required go version is: **go1.14.1**
If you need to open another shell, just do:
```bash
export GOPATH=$HOME/<path_of_your_choice>
mkdir -p $HOME/<path_of_your_choice>/src/github.com/harmony-one
cd $HOME/<path_of_your_choice>/src/github.com/harmony-one
git clone git@github.com:harmony-one/mcl.git
git clone git@github.com:harmony-one/bls.git
git clone git@github.com:harmony-one/harmony.git
cd harmony
make
docker exec -it harmony /bin/bash
```
Note: make sure to run `scripts/install_build_tools.sh`to make sure build tools are of correct versions.
Learn more about docker [here](https://docker-curriculum.com/).
## Build
If you want to bypass the Makefile:
The `make` command should automatically build the Harmony binary & all dependent libs.
However, if you wish to bypass the Makefile, first export the build flags:
```bash
export CGO_CFLAGS="-I$GOPATH/src/github.com/harmony-one/bls/include -I$GOPATH/src/github.com/harmony-one/mcl/include -I/usr/local/opt/openssl/include"
export CGO_LDFLAGS="-L$GOPATH/src/github.com/harmony-one/bls/lib -L/usr/local/opt/openssl/lib"
@ -170,59 +113,67 @@ export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH
export GO111MODULE=on
```
Note : Some of our scripts require bash 4.x support, please [install bash 4.x](http://tldrdevnotes.com/bash-upgrade-3-4-macos) on MacOS X.
### Build all executables
You can run the script `./scripts/go_executable_build.sh` to build all the executables.
### Build individual executables
Harmony server / main node:
Then you can build all executables with the following command:
```bash
./scripts/go_executable_build.sh harmony
bash ./scripts/go_executable_build.sh -S
```
> Reference `bash ./scripts/go_executable_build.sh -h` for more build options
### Harmony docs and guides
https://docs.harmony.one
### API guides
https://docs.harmony.one/home/developers/api
### Running locally
The debug.sh script calls test/deploy.sh script to create a local environment of Harmony blockchain devnet based on the configuration file.
The configuration file configures number of nodes and their IP/Port.
The script starts 2 shards and 7 nodes in each shard.
## Debugging
One can start a local network (a.k.a localnet) with your current code using the following command:
```bash
./test/debug.sh
make debug
```
> This localnet has 2 shards, with 11 nodes on shard 0 (+1 explorer node) and 10 nodes on shard 0 (+1 explorer node).
>
> The shard 0 endpoint will be on the explorer at `http://localhost:9599`. The shard 1 endpoint will be on the explorer at `http://localhost:9598`.
>
> You can view the localnet configuration at `/test/configs/local-resharding.txt`. The fields for the config are (space-delimited & in order) `ip`, `port`, `mode`, `bls_pub_key`, and `shard` (optional).
### Terminate the local blockchain
One can force kill the local network with the following command:
```bash
./test/kill_nodes.sh
make debug-kill
```
> You can view all make commands with `make help`
## Testing
Make sure you use the following command and make sure everything passed before submitting your code.
To keep things consistent, we have a docker image to run all tests. **These are the same tests ran on the pull request checks**.
### Go tests
To run this test do:
```bash
make test-go
```
This test runs the go tests along with go lint, go fmt, go imports, go mod, and go generate checks.
### API tests
To run this test do:
```bash
make test-api
```
This test starts a localnet (within the Docker container), **ensures it reaches consensus**, and runs a series of tests to ensure correct Node API behavior.
This test also acts as a preliminary integration test (more through tests are done on the testnets).
> The tests ran by this command can be found [here](https://github.com/harmony-one/harmony-test/tree/master/localnet).
If you wish to debug further with the localnet after the tests are done, open a new shell and run:
```bash
./test/test_before_submit.sh
make test-api-attach
```
> This will open a shell in the docker container that is running the Node API tests.
>
> Note that the docker container has the [Harmony CLI](https://docs.harmony.one/home/wallets/harmony-cli) on path,
> therefore you can use that to debug if needed. For example, one could do `hmy blockchain latest-headers` to check
> the current block height of localnet. Reference the documentation for the CLI [here](https://docs.harmony.one/home/wallets/harmony-cli)
> for more details & commands.
## License
Harmony is licensed under the MIT License. See [`LICENSE`](LICENSE) file for
the terms and conditions.
Harmony includes third-party open source code. In general, a source subtree
Harmony includes third-party open-source code. In general, a source subtree
with a `LICENSE` or `COPYRIGHT` file is from a third party, and our
modifications thereto are licensed under the same third-party open source
license.
@ -237,7 +188,7 @@ See [`CONTRIBUTING`](CONTRIBUTING.md) for details.
## Development Status
### Features Done
### Finished Features
- Fully sharded network with beacon chain and shard chains
- Sharded P2P network and P2P gossiping
@ -250,9 +201,9 @@ See [`CONTRIBUTING`](CONTRIBUTING.md) for details.
- EPoS staking mechanism
- Kademlia routing
### Features Planned after Mainnet Open Staking
### Planned Features
- Resharding
- Integration with WASM
- Fast state synchronization
- Auditable privacy asset using ZK proof
- Auditable privacy asset using ZK proof
Loading…
Cancel
Save