-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #425 from doitian/config-rework
feat: bundle app config
- Loading branch information
Showing
60 changed files
with
1,983 additions
and
1,223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,7 @@ tags | |
.vagrant | ||
|
||
# runtime folder | ||
/nodes/ | ||
/ckb.toml | ||
/ckb-miner.toml | ||
/data | ||
/specs |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Configure CKB | ||
|
||
## How CKB Locates Config File | ||
|
||
CKB looks for configuration files in `<config-dir>`, which is the current working directory by default. Different subcommands use different config file names: | ||
|
||
- `ckb run`: `ckb.toml` | ||
- `ckb miner`: `ckb-miner.toml` | ||
- `ckb import`: `ckb.toml` | ||
- `ckb export`: `ckb.toml` | ||
- `ckb cli`: no config file required yet | ||
|
||
Command line argument `-C <path>` sets the value of `<config-dir>` to `<path>`, which must come before subcommand. | ||
|
||
If configuration file is missing, the default config files bundled in the executable will be used. | ||
|
||
Some config file may refer to other files, for example, `chain.spec` in | ||
`ckb.toml` and `system_cells` in chain spec file. The file is referred via | ||
either absolute path, or a path relative to the directory containing the | ||
config file currently being parsed. Take following directory hierarchy as an | ||
example: | ||
|
||
``` | ||
ckb.toml | ||
specs/dev.toml | ||
specs/cells/always_success | ||
``` | ||
|
||
Then `ckb.toml` refers `dev.toml` as `specs/dev.toml`, while | ||
`specs/dev.toml` refers `always_success` as `cells/always_success`. | ||
|
||
For security reason, there is a limitation of the file reference. The bundled | ||
file can only refer to bundled files, while a file located in the file system | ||
can either refer to another file in the file system or a bundled one. | ||
|
||
## How to Change Config | ||
|
||
First export the bundled config files into current directory using subcommand `init`. | ||
|
||
``` | ||
ckb init | ||
``` | ||
|
||
Then edit the generated config files according to the in-line comments. | ||
|
||
## Chain Spec | ||
|
||
The option `ckb.chain` configures the chain spec, which controls which kind of chain to run. | ||
This option is set to a spec used for development by default. | ||
|
||
The subcommand `init` supports exporting the default options for different | ||
chain specs. The following command lists all supported chain specs. | ||
|
||
``` | ||
ckb init --list-specs | ||
``` | ||
|
||
Here is an example to export config files for testnet. | ||
|
||
``` | ||
ckb init --spec testnet | ||
``` | ||
|
||
Nodes running different chain specs cannot synchronize with each other, so be carefully when editing this option. | ||
|
||
## How to Run Multiple Nodes | ||
|
||
Each node requires its own `<config-dir>`. Since the default ports will conflict, please export the config files and edit the listen ports in the config files. | ||
|
||
``` | ||
mkdir node1 node2 | ||
ckb -C node1 init | ||
ckb -C node2 init | ||
# Change listen ports 8114/8115 to 8116/8117 in node2/ckb.toml. | ||
# Change `rpc_url` in node2/ckb.toml to use 8116. | ||
# You may also want to add each other as a boot node in the configuration file. | ||
# start node1 | ||
ckb -C node1 run | ||
# start node2 | ||
ckb -C node2 run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Get CKB | ||
|
||
## Download from Releases | ||
|
||
We will publish binaries for each release via [Github Releases](https://github.com/nervosnetwork/ckb/releases). If your system | ||
is listed there, you can download the package directory. | ||
|
||
|
||
## Build from Source | ||
|
||
### 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 | ||
|
||
```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 | ||
``` |
Oops, something went wrong.