README ¶
Feechain
This program was forked from https://github.com/harmony-one/harmony.git
Requirements
Go 1.16.3
GMP and OpenSSL
On macOS:
brew install gmp
brew install openssl
sudo ln -sf /usr/local/opt/openssl@1.1 /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)
On macOS:
brew install --cask docker
open /Applications/Docker.app
On Linux, reference official documentation here.
Bash 4+
For macOS, you can reference this guide. For Linux, you can reference this guide.
Dev Environment
Most repos assumes the GOPATH convention. More information here.
First Install
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/Timestopeofficial
cd $(go env GOPATH)/src/github.com/Timestopeofficial
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/Timestopeofficial/mcl.git
git clone https://github.com/Timestopeofficial/bls.git
git clone https://github.com/Timestopeofficial/feechain.git
cd feechain
- Build the feechain binary & dependent libs
go mod tidy
make
Run
bash scripts/install_build_tools.sh
to ensure build tools are of correct versions. If you get 'missing go.sum entry for module providing package <package_name>', rungo mod tidy
.
Dev Docker Image
Included in this repo is a Dockerfile that has a full feechain 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 image for yourself with the following commands:
cd $(go env GOPATH)/src/github.com/Timestopeofficial/feechain
make clean
docker build -t feechain .
If your build machine has an ARM-based chip, like Apple silicon (M1), the image is built for
linux/arm64
by default. To build forx86_64
, apply the--platform
arg like so:docker build --platform linux/amd64 -t feechain .
Learn more about the
--platform
arg and multi-CPU architecture support, here and here.
Then you can start your docker container with the following command:
docker run --rm --name feechain -it -v "$(go env GOPATH)/src/github.com/Timestopeofficial/feechain:/root/go/src/github.com/Timestopeofficial/feechain" feechain /bin/bash
Note that the feechain 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 feechain /bin/bash
Learn more about docker here.
Build
The make
command should automatically build the Feechain 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/Timestopeofficial/bls/include -I$GOPATH/src/github.com/Timestopeofficial/mcl/include -I/usr/local/opt/openssl/include"
export CGO_LDFLAGS="-L$GOPATH/src/github.com/Timestopeofficial/bls/lib -L/usr/local/opt/openssl/lib"
export LD_LIBRARY_PATH=$GOPATH/src/github.com/Timestopeofficial/bls/lib:$GOPATH/src/github.com/Timestopeofficial/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
Reference
bash ./scripts/go_executable_build.sh -h
for more build options
Debugging
One can start a local network (a.k.a localnet) with your current code using the following command:
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 athttp://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
, andshard
(optional).
One can force kill the local network with the following command:
make debug-kill
You can view all make commands with
make help
Testing
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 validator9501
- Shard 1 RPC for a validator9599
- Shard 0 RPC for an explorer9598
- Shard 1 RPC for an explorer9799
- Shard 0 Rosetta (for an explorer)9798
- Shard 1 Rosetta (for an explorer)9899
- Shard 0 WS for an explorer9898
- Shard 1 WS for an explorer
This allows you to use curl, fch CLI, postman, rosetta-cli, etc... on your host machine to play with or probe the localnet that was used for the test.
Go tests
To run this test, do:
make test-go
This test runs the go tests along with go lint, go fmt, go imports, go mod, and go generate checks.
License
This program was forked from https://github.com/harmony-one/harmony.git
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 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.
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.
Finished Features
- 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)
- Cross-links
- EPoS staking mechanism
- Kademlia routing
Directories ¶
Path | Synopsis |
---|---|
Package accounts implements high level Ethereum account management.
|
Package accounts implements high level Ethereum account management. |
abi
Package abi implements the Ethereum ABI (Application Binary Interface).
|
Package abi implements the Ethereum ABI (Application Binary Interface). |
abi/bind
Package bind generates Ethereum contract Go bindings.
|
Package bind generates Ethereum contract Go bindings. |
keystore
Package keystore implements encrypted storage of secp256k1 private keys.
|
Package keystore implements encrypted storage of secp256k1 private keys. |
api
|
|
service/explorer
TODO: refactor this whole module to v0 and v1
|
TODO: refactor this whole module to v0 and v1 |
service/prometheus
Package prometheus defines a service which is used for metrics collection and health of a node in Feechain.
|
Package prometheus defines a service which is used for metrics collection and health of a node in Feechain. |
cmd
|
|
common
|
|
math
Package math provides integer math utilities.
|
Package math provides integer math utilities. |
Package core implements the Ethereum consensus protocol.
|
Package core implements the Ethereum consensus protocol. |
rawdb
Package rawdb contains a collection of low level database accessors.
|
Package rawdb contains a collection of low level database accessors. |
state
Package state provides a caching layer atop the Ethereum state trie.
|
Package state provides a caching layer atop the Ethereum state trie. |
types
Package types contains data types related to Ethereum consensus.
|
Package types contains data types related to Ethereum consensus. |
vm
Package vm implements the Ethereum Virtual Machine.
|
Package vm implements the Ethereum Virtual Machine. |
vm/runtime
Package runtime provides a basic execution model for executing EVM code.
|
Package runtime provides a basic execution model for executing EVM code. |
crypto
|
|
vdf
Package vdf is a proof-of-concept implementation of a delay function and the security properties are not guaranteed.
|
Package vdf is a proof-of-concept implementation of a delay function and the security properties are not guaranteed. |
vrf
Package vrf defines the interface to a verifiable random function.
|
Package vrf defines the interface to a verifiable random function. |
vrf/p256
Package p256 implements a verifiable random function using curve p256.
|
Package p256 implements a verifiable random function using curve p256. |
eth
|
|
rpc
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports.
|
Package rpc implements bi-directional JSON-RPC 2.0 on multiple transports. |
tracers
Package tracers is a collection of JavaScript transaction tracers.
|
Package tracers is a collection of JavaScript transaction tracers. |
internal
|
|
package p2p
|
package p2p |
filters
Package filters implements an ethereum filtering system for block, transactions and log events.
|
Package filters implements an ethereum filtering system for block, transactions and log events. |
test
|
|