Nervos CKB is a public permissionless blockchain, the common knowledge layer of Nervos network.
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.cargo refactor: embrace Rust 2018 (#75) Dec 11, 2018
.github/ISSUE_TEMPLATE chore: Add contributing guidelines and issue templates Nov 19, 2018
benches chore: Bump to v0.3.0-pre Dec 12, 2018
chain feat: use crate faketime to fake time (#111) Dec 24, 2018
core chore: remove unused dependencies in Cargo.toml (#109) Dec 19, 2018
db chore: remove unused dependencies in Cargo.toml (#109) Dec 19, 2018
devtools chore: remove unused dependencies in Cargo.toml (#109) Dec 19, 2018
docker/hub fix(build): docker port Dec 12, 2018
miner feat: use crate faketime to fake time (#111) Dec 24, 2018
network Merge branch 'develop' into zhangsoledad/refc_jsonrpc Dec 24, 2018
nodes_template fix(config): boot_nodes -> bootnodes Dec 21, 2018
notify chore: remove unused dependencies in Cargo.toml (#109) Dec 19, 2018
pool feat: use crate faketime to fake time (#111) Dec 24, 2018
pow chore: Bump to v0.3.0-pre Dec 12, 2018
protocol chore: Bump to v0.3.0-pre Dec 12, 2018
rpc Merge branch 'develop' into zhangsoledad/refc_jsonrpc Dec 24, 2018
script fix: assign numeric numbers for syscall parameters Dec 21, 2018
shared chore: remove unused dependencies in Cargo.toml (#109) Dec 19, 2018
spec chore: add cellbase maturity (#112) Dec 24, 2018
src feat: jsonrpc API modules Dec 21, 2018
sync feat: use crate faketime to fake time (#111) Dec 24, 2018
util feat: use crate faketime to fake time (#111) Dec 24, 2018
verification feat: use crate faketime to fake time (#111) Dec 24, 2018
.dockerignore feat: dockerfile for hub (#48) Dec 4, 2018
.editorconfig feat(config): Simplify config and data dir parsing (#19) Nov 26, 2018
.gitignore feat(config): Simplify config and data dir parsing (#19) Nov 26, 2018
.gitmodules chore: Depend `ckb-vm` via Cargo (#25) Nov 28, 2018
.travis.yml chore: setup travis condition (#90) Dec 14, 2018
CONTRIBUTING.md doc: Refer to known issues in the wiki (#10) Nov 21, 2018
COPYING doc: update COPYING Nov 19, 2018
Cargo.lock Merge branch 'develop' into zhangsoledad/refc_jsonrpc Dec 24, 2018
Cargo.toml feat: jsonrpc API modules Dec 21, 2018
Makefile Merge branch 'develop' into zhangsoledad/refc_jsonrpc Dec 24, 2018
README.md feat: use crate faketime to fake time (#111) Dec 24, 2018
SECURITY.md doc: fix links in SECURITY.md (#3) Nov 19, 2018
build.rs refactor: embrace Rust 2018 (#75) Dec 11, 2018
clippy.toml feat: Uncle blocks Nov 19, 2018
rust-toolchain refactor: replace ethereum-types with numext Dec 10, 2018
rustfmt.toml feat(miner): Implement ethash Nov 19, 2018

README.md

Nervos CKB - The Common Knowledge Base

TravisCI dependency status Telegram Group


About Nervos CKB

Nervos CKB is the layer 1 of Nervos Network, a public blockchain with PoW and cell model.

Nervos project defines a suite of scalable and interoperable blockchain protocols. Nervos CKB uses those protocols to create a self-evolving distributed network with a novel economic model, data model and more.

License FOSSA Status

Nervos CKB is released under the terms of the MIT license. See COPYING for more information or see https://opensource.org/licenses/MIT.

Development Process

This project is still in development, and it's NOT in production-ready status. The wiki also lists some known issues that we are currently working on.

The master branch is regularly built and tested, however, it is not guaranteed to be completely stable; The develop branch is the work branch to merge new features, and it's not stable. The CHANGELOG is available in Releases and CHANGELOG.md in the master branch.

The contribution workflow is described in CONTRIBUTING.md, and security policy is described in SECURITY.md. To propose new protocol or standard for Nervos, see Nervos RFC.


Build dependencies

CKB is currently tested mainly with stable-1.31.0 on Linux and Mac OSX.

We recommend installing Rust through rustup

# Get rustup from rustup.rs, then in your `ckb` folder:
rustup override set 1.31.0
rustup component add rustfmt
rustup component add clippy

Report new breakage is welcome.

You also need to get the following packages:

  • Ubuntu and Debian:
sudo apt-get install git autoconf flex bison texinfo libtool pkg-config libssl-dev libclang-dev

If you are on Ubuntu 18.04, you might run into 'stdarg.h' file not found error, this is because librocksdb-sys fails to find the correct include path. A temporary fix until librocksdb-sys fixes this problem is as follows:

sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h /usr/include/stdarg.h
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h /usr/include/stddef.h
  • Archlinux
sudo pacman -Sy git autoconf flex bison texinfo libtool pkg-config openssl-1.0 clang

If you get openssl related errors in compiling, try the following environment variables to specify openssl-1.0:

OPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0 OPENSSL_LIB_DIR=/usr/lib/openssl-1.0 cargo build --release
  • OSX:
brew install autoconf libtool

Build from source & testing

# get ckb source code
git clone https://github.com/nervosnetwork/ckb.git
cd ckb

# build in release mode
make build

You can run the full test suite, or just run a specific package test:

# Run the full suite
cargo test --all
# Run a specific package test
cargo test -p ckb-chain

Quick Start

Start Node

Create the default runtime directory:

cp -r nodes_template/ nodes

Use the config file to start the node

target/release/ckb run

It searches config file ckb.json, nodes/default.json in the shell working directory in that order. Alternatively, the argument -c can specify the config file used to start the node.

The default config file saves data in nodes/default/.

Use RPC

Find RPC port in the log output, the following command assumes 8114 is used:

curl -d '{"id": 1, "jsonrpc": "2.0", "method":"get_tip_header","params": []}' \
  -H 'content-type:application/json' 'http://localhost:8114'

Run Miner

Run miner, gets a block template to mine.

target/release/ckb miner

Advanced

Run multiple nodes in different data directories.

Create the config file for new nodes, for example:

cp nodes/default.json nodes/node2.json

Update data_dir configuration in config file to a different directory.

"data_dir": "node2"

or using a simple shell command to modify the config file:

ex -sc '%s/"data_dir": "default"/"data_dir": "node2"/|x' nodes/node2.json

Then start the new node using the new config file

target/release/ckb -c nodes/node2.json run

The option ckb.chain configures the chain spec. It accepts a path to the spec JSON file. The directory nodes_template/spec has all the pre-defined specs. Please note that nodes with different chain specs may fail to connect with each other.

The chain spec can switch between different PoW engines. Wiki has the instructions about how to configure it.