GMP and OpenSSL
brew install gmp brew install openssl sudo ln -sf /email@example.com /usr/local/opt/openssl
On Linux (Ubuntu)
sudo apt install libgmp-dev libssl-dev make gcc g++
On Linux (Cent OS / Amazon Linux 2)
sudo yum install glibc-static gmp-devel gmp-static openssl-libs openssl-static gcc-c++
Docker (for testing)
brew install --cask docker open /Applications/Docker.app
On Linux, reference official documentation here.
Clone and set up all of the repos with the following set of commands:
- Create the appropriate directories:
mkdir -p $(go env GOPATH)/src/github.com/harmony-one cd $(go env GOPATH)/src/github.com/harmony-one
If you get 'unknown command' or something along those lines, make sure to install golang first.
- Clone this repo & dependent repos.
git clone https://github.com/harmony-one/mcl.git git clone https://github.com/harmony-one/bls.git git clone https://github.com/harmony-one/harmony.git cd harmony
- Build the harmony binary & dependent libs
go mod tidy make
bash scripts/install_build_tools.shto ensure build tools are of correct versions. If you get 'missing go.sum entry for module providing package <package_name>', run
go mod tidy.
Dev Docker Image
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 (
mcl) set up correctly for you.
You can build the docker image for yourself with the following commands:
cd $(go env GOPATH)/src/github.com/harmony-one/harmony make clean docker build -t harmony .
Then you can start your docker container with the following command:
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.
If you need to open another shell, just do:
docker exec -it harmony /bin/bash
Learn more about docker here.
make command should automatically build the Harmony binary & all dependent libs.
However, if you wish to bypass the Makefile, first export the build flags:
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" export LD_LIBRARY_PATH=$GOPATH/src/github.com/harmony-one/bls/lib:$GOPATH/src/github.com/harmony-one/mcl/lib:/usr/local/opt/openssl/lib export LIBRARY_PATH=$LD_LIBRARY_PATH export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH export GO111MODULE=on
Then you can build all executables with the following command:
bash ./scripts/go_executable_build.sh -S
bash ./scripts/go_executable_build.sh -hfor more build options
One can start a local network (a.k.a localnet) with your current code using the following command:
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
You can view the localnet configuration at
/test/configs/local-resharding.txt. The fields for the config are (space-delimited & in order)
One can force kill the local network with the following command:
You can view all make commands with
To keep things consistent, we have a docker image to run all tests. These are the same tests ran on the pull request checks.
Note that all testing docker container binds a couple of ports to the host machine for your convince. The ports are:
9500- Shard 0 RPC for a validator
9501- Shard 1 RPC for a validator
9599- Shard 0 RPC for an explorer
9598- Shard 1 RPC for an explorer
9799- Shard 0 Rosetta (for an explorer)
9798- Shard 1 Rosetta (for an explorer)
9899- Shard 0 WS for an explorer
9898- Shard 1 WS for an explorer
This allows you to use curl, hmy CLI, postman, rosetta-cli, etc... on your host machine to play with or probe the localnet that was used for the test.
To run this test, do:
This test runs the go tests along with go lint, go fmt, go imports, go mod, and go generate checks.
To run this test, do:
This test starts a localnet (within the Docker container), ensures it reaches a consensus, and runs a series of tests to ensure correct RPC 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.
If you wish to debug further with the localnet after the tests are done, open a new shell and run:
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 on path, therefore you can use that to debug if needed. For example, one could do
hmy blockchain latest-headersto check the current block height of localnet. Reference the documentation for the CLI here for more details & commands.
To run this test, do:
This test starts a localnet (within the Docker container), ensures it reaches a consensus, and runs the Construction & Data API checks using the rosetta-cli. This test also acts as a preliminary integration test (more through tests are done on the testnets).
Similar to the RPC tests, if you wish to debug further with the localnet after the tests are done, open a new shell and run:
Harmony is licensed under GNU Lesser General Public License v3.0. See
LICENSE file for
the terms and conditions.
Harmony includes third-party open-source code. In general, a source subtree
COPYRIGHT file is from a third party, and our
modifications thereto are licensed under the same third-party open source
Also please see our Fiduciary License Agreement if you are contributing to the project. By your submission of your contribution to us, you and we mutually agree to the terms and conditions of the agreement.
Contributing To Harmony
CONTRIBUTING for details.
- Fully sharded network with beacon chain and shard chains
- Sharded P2P network and P2P gossiping
- FBFT (Fast Byzantine Fault Tolerance) Consensus with BLS multi-signature
- Consensus view-change protocol
- Account model and support for Solidity
- Cross-shard transaction
- VRF (Verifiable Random Function) and VDF (Verifiable Delay Function)
- EPoS staking mechanism
- Kademlia routing
- Integration with WASM
- Fast state synchronization
- Auditable privacy asset using ZK proof