Nervos CKB is a public permissionless blockchain, the common knowledge layer of Nervos network.
Clone or download
Latest commit 3eaf507 Feb 3, 2019
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.5.0-pre Jan 14, 2019
chain refactor: service interface Jan 30, 2019
core refactor: service interface Jan 30, 2019
db chore: clippy all-targets all-features Jan 15, 2019
devtools chore(ci): quick fail CI on first error Jan 26, 2019
docker/hub chore: bump rust-toolchain from 1.31.1 to 1.32.0 Jan 18, 2019
miner refactor: service interface Jan 30, 2019
network feat: manually shutdown Jan 30, 2019
nodes_template feat: refactor chain spec config (#224) Jan 25, 2019
notify refactor: service interface Jan 30, 2019
pool refactor: service interface Jan 30, 2019
pow chore(deps): bump byteorder from 1.2.7 to 1.3.0 Jan 21, 2019
protocol feat: use new merkle proof structure (#232) Jan 28, 2019
rpc feat: manually shutdown Jan 30, 2019
script chore(deps): bump byteorder from 1.2.7 to 1.3.0 Jan 21, 2019
shared feat: delay full block verification to fork switch (#158) Jan 30, 2019
spec refactor: service interface Jan 30, 2019
src refactor: service interface Jan 30, 2019
sync refactor: service interface Jan 30, 2019
util Change return type to tuple Feb 2, 2019
verification refactor: service interface Jan 30, 2019
.dockerignore chore: multi-stage docker Jan 16, 2019
.editorconfig feat(config): Simplify config and data dir parsing (#19) Nov 26, 2018
.gitignore chore: add project env ignore rule (#216) Jan 21, 2019
.gitmodules chore: Depend `ckb-vm` via Cargo (#25) Nov 28, 2018
.travis.yml chore(ci): quick fail CI on first error Jan 26, 2019
CHANGELOG.md chore: draft CHANGELOG for v0.4.0 Jan 14, 2019
CONTRIBUTING.md doc: add mailing list address to CONTRIBUTING Dec 26, 2018
COPYING doc: update COPYING Nov 19, 2018
Cargo.lock Upgrade secp256k1 Feb 2, 2019
Cargo.toml feat: service stop handler Jan 30, 2019
Makefile chore: clippy all-targets all-features Jan 15, 2019
README.md fix: cli arg matches Jan 23, 2019
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 chore: bump rust-toolchain from 1.31.1 to 1.32.0 Jan 18, 2019
rustfmt.toml feat(miner): Implement ethash Nov 19, 2018

README.md

Nervos CKB - The Common Knowledge Base

TravisCI 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 board 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.

How to Contribute

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.32.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.32.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 gcc libc6-dev pkg-config libssl-dev libclang-dev clang
  • Archlinux
sudo pacman -Sy git gcc pkgconf 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 run -c nodes/node2.json

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.