Beta - zoobc/zoobc-core GitHub Wiki
ZOOBC CORE
Zoobc Core is the main node application to run the zoobc blockchain. This repository consist of the main node application and the command line interface tools to help with development.
Configuration
Configuration file config.toml
located in the root directory of zoobc-core contain many of variables that used as environtment. We use [viper][viper] as loader that loaded when start the node. Some point is:
dbPath
anddbName
for database connection needed.badgerDbPath
andbadgerDbName
for badger connection needed.snapshotPath
is path or directory of snapshot files.peerPort
is port that pointed for peer to peer connectionmyAddress
is address or IP for own node.wellknownPeers
is list of node addresses that you believe in.apiRPCPort
is port for RPC client connection supposted to be for wallet / explorermaxAPIRequestPerSecond
is request limit in secondapiHTTPPort
is port that use in proxy mode, set 0 to disable and only enable in develop mode.monitoringPort
is port for grafana and only enable in develop mode.cpuProfilingPort
is port for CPU profiling and only enable in develop mode.apiReqTimeoutSec
is request timeout in second for grpc streaming mode.ownerAccountAddress
is account address in slip10For more detail you can see on configuration
Getting Start
Download Binary
Download from release archive unzip the file and the result might contain some files and binary that you would need to runnng the application:
.zip
├── zoobc
├── cmd
├── Makefile
├── config.toml
└── resource
├── node_keys.json
└── templates
Check the config.toml
files and update several keys:
ownerAccountAddress
. You might need to run./cmd account ed25519 --seed "your mnemonic"
and copyaddress
part asownerAccountAddress
wellknownPeers
- And some ports if you need to change.
From Source
Clone the zoobc-core repo release tag into you machine, you might need to build binary manually, make sure your machine have make
:
-
Install some binary dependencies go-swagger and [protobuf][protobuf].
-
Install dependencies
go mod install
-
Make sure the
schema
pointing to a correct version withzoobc-core
version, otherwise you need to pull theschema
with the correct version and build that with:cd common/schema
./compile-go.sh
The result will update
*.pb.go
files insidecommon/model
andcommon/service
-
Update several keys from configuration files
config.toml
will need the following files configured:ownerAccountAddress
. You might need to run./cmd account ed25519 --seed "your mnemonic"
and copyaddress
part asownerAccountAddress
. For more information aboutzoobc cmd
you can see the detail herewellknownPeers
- And some ports if you need to change.
-
Build binary with
make build
and the result isrelease/zoobc
, you can check for more build version inMakefile
.
Dependencies
golang, currently using go.1.14 |
go-swagger |
[protobuf][protobuf] |
[protoc-gen-go][protoc-gen-go] |
[viper][viper] |
[cobra][cobra] |
[deep-copy][deep-copy] |
[sqlite3][sqlite3] |
[logrus][logrus] |
[go-grpc-middleware][go-grpc-middleware] |
[go-grpc-gateway][go-grpc-gateway] |
[badgerdb][badgerdb] |
[stats][stats] |
[btcd][btcd] |
[btcutil][btcutil] |
Run Binary file
The core node can be run by anyone that want to join the network, to run the core-node application need to following files configured update some keys from config.toml
and run with ./zoobc
.
In some reason you need to use web proxy to allowing browser access send and request with normal HTTP request (with Fetch or XHR) and it will expose functionality. You need to run
nohup grpcwebproxy --backend_addr=localhost:7000 --run_tls_server=false --allow_all_origins --server_http_debug_port=7001 --server_http_max_write_timeout 1h &
make sure you install binary [grpc-web-proxy][grpc-web-proxy]
To make sure the application is running open http://localhost:3031/v1/health/check in your browser. [note: 3031 is default of config.toml:apiHttpPort, adjust to your own configuration as needed].
Testing
- Unit tests
- Run all tests without cache
go test ./... -count=1
- Run all test with coverage report
go test ./... -coverprofile=cover.out && go tool cover -html=cover.out
- Run all tests without cache
- [GolangCI-Lint][golangci-lint]
- Install linter tools
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.20.0
- Run
golangci-lint run
to check any linting error in the changes.
- Install linter tools
Contributing
please refer to contribute.md and code of conduct.
[protobuf]: https://github.com/protocolbuffers/protobuf) [protoc-gen-go]: https://github.com/golang/protobuf [viper]: https://github.com/spf13/viper [cobra]: https://github.com/spf13/cobra [deep-copy]: github.com/mohae/deepcopy [sqlite3]: github.com/mattn/go-sqlite [logrus]: github.com/sirupsen/logrus [go-grpc-middleware]: github.com/grpc-ecosystem/go-grpc-middleware [go-grpc-gateway]: github.com/grpc-ecosystem/grpc-gateway [badgerdb]: github.com/dgraph-io/badger/v2 [stats]: github.com/montanaflynn/stats [btcd]: github.com/btcsuite/btcd [btcutil]: github.com/btcsuite/btcutil [golangci-lint]: https://github.com/golangci/golangci-lint [grpc-web-proxy]: https://github.com/improbable-eng/grpc-web/tree/master/go/grpcwebproxy