Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bundle app config #387

Closed
wants to merge 12 commits into from
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ tags
.vagrant

# runtime folder
/nodes/
/ckb.toml
/ckb-miner.toml
/data
/specs
115 changes: 13 additions & 102 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ toml = "0.5"
log = "0.4"
futures = "0.1"
crossbeam-channel = "0.3"
config-tool = { package= "config", version = "0.9" }
ckb-util = { path = "util" }
ckb-core = { path = "core" }
ckb-chain = { path = "chain" }
Expand All @@ -26,10 +25,10 @@ ckb-db = { path = "db" }
ckb-pow = { path = "pow" }
ckb-network = { path = "network"}
ckb-rpc = { path = "rpc"}
ckb-resource = { path = "resource"}
logger = { path = "util/logger" }
numext-fixed-hash = { version = "0.1", features = ["support_rand", "support_heapsize", "support_serde"] }
numext-fixed-uint = { version = "0.1", features = ["support_rand", "support_heapsize", "support_serde"] }
dir = { path = "util/dir" }
ctrlc = { version = "3.1", features = ["termination"] }
ckb-sync = { path = "sync"}
crypto = { path = "util/crypto"}
Expand All @@ -52,7 +51,6 @@ members = [
"util/merkle-tree",
"util/jsonrpc-types",
"util/crypto",
"util/dir",
"util/instrument",
"util/build-info",
"util/occupied-capacity",
Expand All @@ -72,7 +70,8 @@ members = [
"verification",
"script",
"pow",
"benches"
"benches",
"resource",
]

[profile.release]
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ gen-clean:
$(CFBC) -o $(shell dirname $@) $*.bfbs
rm -f $*.bfbs $*_builder.rs

.PHONY: build prod prod-test docker gen gen-clean
clean:
rm -rf ckb.toml ckb-miner.toml specs/

.PHONY: build prod prod-test docker gen gen-clean clean
.PHONY: fmt test clippy doc doc-deps check stats
.PHONY: ci info security-audit
127 changes: 5 additions & 122 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,126 +34,9 @@ The contribution workflow is described in [CONTRIBUTING.md](CONTRIBUTING.md), an

---

## Build dependencies
## Documentations

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

We recommend installing Rust through [rustup](https://www.rustup.rs/)

```bash
# Get rustup from rustup.rs, then in your `ckb` folder:
rustup override set 1.33.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:

```shell
sudo apt-get install git gcc libc6-dev pkg-config libssl-dev libclang-dev clang
```

* Arch Linux

```shell
sudo pacman -Sy git gcc pkgconf clang
```

* macOS:

```shell
brew install autoconf libtool
```

---

## Build from source & testing

```bash
# 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:

```bash
# 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:

```shell
cp -r nodes_template/ nodes
```

Use the config file to start the node

```shell
target/release/ckb run
```

It searches config file `ckb.toml`, `nodes/default.toml` 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:

```shell
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.

```shell
target/release/ckb miner
```

### Advanced

Run multiple nodes in different data directories.

Create the config file for new nodes, for example:

```shell
cp nodes/default.toml nodes/node2.toml
```

Update `data_dir` configuration in config file to a different directory.

```
data_dir = "node2"
```

Then start the new node using the new config file

```shell
target/release/ckb run -c nodes/node2.toml
```

The option `ckb.chain` configures the chain spec. It accepts a path to the spec toml 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](https://github.com/nervosnetwork/ckb/wiki/PoW-Engines) about how to configure it.
- [Build CKB](docs/build.md)
- [Quick Start](docs/quick-start.md)
- [Configure CKB](docs/configure.md)
- [CKB Core Development](docs/ckb-core-dev.md)
2 changes: 1 addition & 1 deletion core/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ mod tests {

#[test]
fn always_success_script_hash() {
let always_success = include_bytes!("../../nodes_template/spec/cells/always_success");
let always_success = include_bytes!("../../resource/specs/cells/always_success");
let always_success_hash: H256 = (&blake2b_256(&always_success[..])).into();

let script = Script::new(0, vec![], always_success_hash);
Expand Down
1 change: 1 addition & 0 deletions db/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::PathBuf;

#[derive(Clone, Debug, Deserialize, Default)]
pub struct DBConfig {
#[serde(default)]
pub path: PathBuf,
pub options: Option<HashMap<String, String>>,
}
19 changes: 13 additions & 6 deletions devtools/git/bors-changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
import subprocess
from collections import namedtuple, OrderedDict


def _str(s):
if sys.version_info >= (3, 0):
return s.decode('utf-8')
return s


if len(sys.argv) > 1:
since = sys.argv[1]
else:
tag_rev = subprocess.check_output(
['git', 'rev-list', '--tags', '--max-count=1']).strip()
since = subprocess.check_output(
['git', 'describe', '--tags', tag_rev]).strip()
tag_rev = _str(subprocess.check_output(
['git', 'rev-list', '--tags', '--max-count=1']).strip())
since = _str(subprocess.check_output(
['git', 'describe', '--tags', tag_rev]).strip())

logs = subprocess.check_output(
['git', 'log', '--merges', '{}...HEAD'.format(since)])
logs = _str(subprocess.check_output(
['git', 'log', '--merges', '{}...HEAD'.format(since)]))

START_RE = re.compile(r'\s+(\d+): (?:(\w+)(\([^\)]+\))?: )?(.*r=.*)')
END_RE = re.compile(r'\s+Co-authored-by:')
Expand Down
3 changes: 0 additions & 3 deletions docker/hub/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ COPY --from=ckb-builder /ckb/target/release/ckb /bin/ckb
RUN echo "#!/bin/bash \n ckb \$@" > ./entrypoint.sh
RUN chmod +x ./entrypoint.sh

# copy "nodes_template" to `WORKDIR`/nodes/
COPY --chown=ckb:ckb nodes_template/ nodes/

#switch use
USER ckb

Expand Down
54 changes: 54 additions & 0 deletions docs/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Build CKB

## Install Build Dependencies

CKB is currently tested mainly with `stable-1.33.0` on Linux and macOS.

We recommend installing Rust through [rustup](https://www.rustup.rs/)

```bash
# Get rustup from rustup.rs, then in your `ckb` folder:
rustup override set 1.33.0
```

Report new breakage is welcome.

You also need to get the following packages:

#### Ubuntu and Debian

```shell
sudo apt-get install git gcc libc6-dev pkg-config libssl-dev libclang-dev clang
```

#### Arch Linux

```shell
sudo pacman -Sy git gcc pkgconf clang
```

#### macOS

```shell
brew install autoconf libtool
```

## Build from Source

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

# build in release mode
make build
```

This will build the executable `target/release/ckb`. Please add the directory
to `PATH` or copy/link the file into a directory already in the `PATH`.

```base
export PATH="$(pwd)/target/release:$PATH"
# or
# ln -snf "$(pwd)/target/release/ckb" /usr/local/bin/ckb
```
31 changes: 31 additions & 0 deletions docs/ckb-core-dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# CKB Core Development

## Running Test

Install dependencies

```
rustup component add rustfmt
rustup component add clippy
```

Run tests

```
make ci
```

Run acceptance integration tests


```
cargo build
cd test && cargo run ../target/debug/ckb
```

## Chain Spec

The subcommand `ckb init` has an option `--export-spec` to export spec files
as well, which allows editing the chain spec for development.

The chain spec can switch between different PoW engines. Wiki has the [instructions](https://github.com/nervosnetwork/ckb/wiki/PoW-Engines) about how to configure it.-
Loading