Skip to content

Commit

Permalink
Alpha net deploy (#13)
Browse files Browse the repository at this point in the history
* update chain spec

* change code in spec

* remove useless code

* remove telemetryEndpoints

* add node key

* send im online and authority discovery

* change to two role

* 3 nodes

* add workload

* set workload 0

* muti bootnodes

* add setTimeWait

* fix

* remove install node and yarn

* fix cli help bug

* update readme
  • Loading branch information
LowEntropyBody authored Feb 28, 2020
1 parent b3e40a3 commit 182a64e
Show file tree
Hide file tree
Showing 5 changed files with 248 additions and 83 deletions.
147 changes: 94 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ On one hand, this project is used to install all crust related programs, includi
Unbantu 16.04

## Install crust-client
Step 0. Install curl, nodejs and yarn
```shell
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs
sudo apt install yarn
```

### Git mode
Step 1. Download crust-client
```shell
git clone https://github.com/crustio/crust-client.git
Expand All @@ -22,13 +31,39 @@ Step 3. Preparing the installation packages
```shell
mkdir resource # create resource directory
```
Then you need move installation packages into this directory ( resource ), include 'crust-api.tar' 'crust.tar' 'crust-tee.tar' ( for now, you can get those packages from crust organization ).
Then you need move installation packages into this directory ( resource ), include 'crust-api.tar' 'crust.tar' 'crust-tee.tar' ( for now, you can get those packages from crust organization and rename them ).

Step 4. Run install stcript
```shell
sudo ./install
```

### Package mode
Step 1. Download source code in release

[release page](https://github.com/crustio/crust-client/releases)

Step 2. Unzip crust-client-0.1.0-alpha.tar.gz
```shell
tar -zxf crust-client-0.1.0-alpha.tar.gz
```

Step 3. Into directory
```shell
cd crust-client-0.1.0-alpha
```

Step 4. Preparing the installation packages
```shell
mkdir resource # create resource directory
```
Then you need move installation packages into this directory ( resource ), include 'crust-api.tar' 'crust.tar' 'crust-tee.tar' ( for now, you can get those packages from crust organization and rename them ).

Step 5. Run install stcript
```shell
sudo ./install
```

## Configurations

### chain-launch.config
Expand All @@ -38,7 +73,8 @@ port=30333 # the port for p2p
ws_port=9944 # the port for ws
rpc_port=9933 # the port for rpc
name=node1 # the name of chain
bootnodes=/ip4/<ip>/tcp/<port>/p2p/<node-id> # the bootnodes for connect to the exist chain (if you are first node, you don't need this)
node_key= # only the genesis node need this:0000000000000000000000000000000000000000000000000000000000000001
bootnodes=(address1 address2 ...) # the bootnodes for connect to the exist chain (if you are first node, you don't need this)
external_rpc_ws=false # Whether to publicize the ws and rpc interface (if you are genesis node or validator node, this configuration must be false)
```

Expand All @@ -65,50 +101,51 @@ crust_chain_endpoint="ws://127.0.0.1:9944/" # the ws address of chain
### tee-launch.json
```json
{
"empty_path" : "crust_store/node1/tee/empty_path",
"empty_capacity" : 4,
"empty_path" : "crust_store/node1/tee/empty_path", # plot file will be stored in this directory
"empty_capacity" : 4, # empty disk storage in Gb

"ipfs_api_base_url" : "http://127.0.0.1:5001/api/v0",
"api_base_url": "http://127.0.0.1:12222/api/v0",
"validator_api_base_url": "http://127.0.0.1:12222/api/v0",
"ipfs_api_base_url" : "http://127.0.0.1:5001/api/v0", # for connect to ipfs
"api_base_url": "http://127.0.0.1:12222/api/v0", # your tee node api address
"validator_api_base_url": "http://127.0.0.1:12222/api/v0", # the tee validator address (**if you are genesis node, this url must equal to 'api_base_url'**)

"crust_api_base_url" : "http://127.0.0.1:56666/api/v1",
"crust_address" : "",
"crust_api_base_url" : "http://127.0.0.1:56666/api/v1", #the address of crust api
"crust_address" : "", # your crust chain identity
"crust_account_id" : "",
"crust_password" : "",
"crust_backup" : "",
......
}
```
empty_path -> plot file will be stored in this directory

empty_capacity -> empty disk storage in Gb

ipfs_api_base_url -> for connect to ipfs

api_base_url -> your tee node api address

validator_api_base_url -> the tee validator address (**if you are genesis node, this url must equal to 'api_base_url'**)

crust_api_base_url -> the address of crust api

crust_address, crust_account_id, crust_password, crust_backup -> your crust chain identity

## Run

### Run IPFS
Currently ipfs does not support customization.
### Run genesis node
The genesis node refers to the initial nodes of the chain written in the genesis spec. These nodes have a very important meaning as the core of the chain startup. They are also the initial validators. Generally genesis node's identity file is issued by crust organization.

#### Run IPFS
- Launch
```shell
crust-client ipfs-launch -b logs/ipfs.log
crust-client ipfs-launch genesis1_config/ipfs-launch.json -b logs/ipfs.log
```
- Monitor
```shell
tail -f logs/ipfs.log.pid
```

### Run genesis node
The genesis node refers to the initial nodes of the chain written in the genesis spec. These nodes have a very important meaning as the core of the chain startup. They are also the initial validators. Generally genesis node's identity file is issued by crust organization.
#### TEE
- Launch
```shell
crust-client tee-launch genesis1_config/tee-launch.json -b logs/genesis1-tee.log
```
- Monitor
```shell
tail -f logs/genesis1-api.log.pid
```

- Wait for plotting disk

Please use monitor to see infomation: "Waitting for chain to run..." before you launch chain.


#### Chain
- Launch
Expand All @@ -135,16 +172,6 @@ The genesis node refers to the initial nodes of the chain written in the genesis
curl --location --request GET 'http://localhost:56667/api/v1/block/header'
```

#### TEE
- Launch
```shell
crust-client tee-launch genesis1_config/tee-launch.json -b logs/genesis1-tee.log
```
- Monitor
```shell
tail -f logs/genesis1-api.log.pid
```

### Run normal node
Normal node cannot be a validator, it is only an access node of the chain, and it can be connected to the chain browser by setting external_rpc_ws=true

Expand All @@ -164,6 +191,36 @@ Connet to normal node ws like: ws://139.196.122.228:6013/ to see crust chian sta
### Run validator node
If you are not genesis node but want to apply to become a validator, please follow the instructions below. Of course you need a tee to report your workload

#### Run IPFS
- Launch
```shell
crust-client ipfs-launch validator1_config/ipfs-launch.json -b logs/ipfs.log
```
- Monitor
```shell
tail -f logs/ipfs.log.pid
```

#### TEE

- Configuration

Please select tee of a validator node on chain to validate your tee by fill 'validator_api_base_url' and use valdator account (not stash account ) to configure crust chain identity.

- Launch
```shell
crust-client tee-launch validator1_config/tee-launch.json -b logs/validator1-tee.log
```

- Monitor
```shell
tail -f logs/validator1-api.log.pid
```

- Wait for plotting disk

Please use monitor to see infomation: "Waitting for chain to run..." before you launch chain.

#### Chain
- Launch
```shell
Expand Down Expand Up @@ -205,22 +262,6 @@ you will see a warning like:
curl --location --request GET 'http://localhost:56669/api/v1/block/header'
```

#### TEE

- Configuration

Please select tee of a validator node on chain to validate your tee by fill 'validator_api_base_url' and use valdator account (not stash account ) to configure crust chain identity.

- Launch
```shell
crust-client tee-launch validator1_config/tee-launch.json -b logs/validator1-tee.log
```

- Monitor
```shell
tail -f logs/validator1-api.log.pid
```

#### Start validate

- Waiting TEE
Expand Down
3 changes: 2 additions & 1 deletion custom/chain-launch.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ port=30333 # the port for p2p
ws_port=9944 # the port for ws
rpc_port=9933 # the port for rpc
name=node1 # the name of chain
bootnodes=/ip4/<ip>/tcp/<port>/p2p/<node-id> # the bootnodes for connect to the exist chain (if you are first node, you don't need this)
node_key= # only the genesis node need this:0000000000000000000000000000000000000000000000000000000000000001
bootnodes=(address1 address2 ...) # the bootnodes for connect to the exist chain (if you are first node, you don't need this)
external_rpc_ws=false # Whether to publicize the ws and rpc interface (if you are genesis node or validator node, this configuration must be false)
104 changes: 90 additions & 14 deletions etc/crust_chain_spec.json

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ crust_client_aim="/usr/bin/crust-client"

trap '{ echo "\nHey, you pressed Ctrl-C. Time to quit." ; exit 1; }' INT

if [ $(id -u) -ne 0 ]; then
verbose ERROR "Please run with sudo!"
exit 1
fi

# Get crust resources
verbose INFO "---------- Getting resource ----------" n
crust_version=$1
Expand Down Expand Up @@ -96,13 +101,6 @@ chown -R $uid:$uid $crust_chain_main_install_dir
# Install crust API
verbose INFO "---------- Installing crust API ----------" n

verbose INFO "Install nodejs..." h
apt install nodejs &>/dev/null
verbose INFO "SUCCESS" t
verbose INFO "Install yarn..." h
apt install yarn &>/dev/null
verbose INFO "SUCCESS" t

if [ -d "$crust_api_resource_dir" ]; then
rm -rf $crust_api_resource_dir
fi
Expand Down
65 changes: 57 additions & 8 deletions stcript/crust-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,38 @@ curl http://localhost:$1 -H "Content-Type:application/json;charset=utf-8" -d \
}"
}

function send_im_online_key()
{
local secret_phrase=${@:3}
curl http://localhost:$1 -H "Content-Type:application/json;charset=utf-8" -d \
"{
\"jsonrpc\":\"2.0\",
\"id\":1,
\"method\":\"author_insertKey\",
\"params\": [
\"imon\",
\"$secret_phrase\",
\"$2\"
]
}"
}

function send_authority_discovery_key()
{
local secret_phrase=${@:3}
curl http://localhost:$1 -H "Content-Type:application/json;charset=utf-8" -d \
"{
\"jsonrpc\":\"2.0\",
\"id\":1,
\"method\":\"author_insertKey\",
\"params\": [
\"audi\",
\"$secret_phrase\",
\"$2\"
]
}"
}

# params are <base_path> <rpc_port> <name> <chain_start_stcript>
function get_rotate_keys()
{
Expand Down Expand Up @@ -182,12 +214,18 @@ function chainLaunchGenesis()

chain_start_stcript="$crust_chain_main_install_dir/bin/crust --base-path $base_path --chain /opt/crust/crust-client/etc/crust_chain_spec_raw.json --port $port --ws-port $ws_port --rpc-port $rpc_port --validator --name $name"
if [ ! -z $bootnodes ]; then
verbose INFO "Add bootnodes($bootnodes)" h
chain_start_stcript="$chain_start_stcript --bootnodes=$bootnodes"
verbose INFO "Add bootnodes(${bootnodes[*]})" h
chain_start_stcript="$chain_start_stcript --bootnodes ${bootnodes[*]}"
verbose INFO " SUCCESS" t
else
verbose WARN "No bootnodes in chain configuration, you must be the frist genesis node."
fi

if [ ! -z $node_key ]; then
verbose INFO "Add node key($node_key)" h
chain_start_stcript="$chain_start_stcript --node-key $node_key"
verbose INFO " SUCCESS" t
fi

verbose INFO "Try to kill old crust chain with same <chain-launch.json>" h
crust_chain_pid=$(ps -ef | grep "$chain_start_stcript" | grep -v grep | awk '{print $2}')
Expand Down Expand Up @@ -226,6 +264,14 @@ function chainLaunchGenesis()
send_babe_key $rpc_port $public_key_sr25519 $secret_phrase
verbose INFO " SUCCESS" t

verbose INFO "Send im_online key to your chain" h
send_im_online_key $rpc_port $public_key_sr25519 $secret_phrase
verbose INFO " SUCCESS" t

verbose INFO "Send authority_discovery key to your chain" h
send_authority_discovery_key $rpc_port $public_key_sr25519 $secret_phrase
verbose INFO " SUCCESS" t

verbose INFO "Try to kill old crust chain with same <chain-launch.json> again" h
crust_chain_pid=$(ps -ef | grep "$chain_start_stcript" | grep -v grep | awk '{print $2}')
if [ x"$crust_chain_pid" != x"" ]; then
Expand All @@ -238,7 +284,7 @@ function chainLaunchGenesis()
verbose INFO " SUCCESS" t
rm $rand_log_file &>/dev/null

verbose WARN "You need to open the port($port) in your device to Make extranet nodes discover your node."
verbose WARN "You need to open the port($port) in your device to make external nodes to discover your node."
sleep 1

if [ -z "$3" ]; then
Expand Down Expand Up @@ -280,8 +326,8 @@ chainLaunchNormal()
# Get chain start stcript
chain_start_stcript="$crust_chain_main_install_dir/bin/crust --base-path $base_path --chain /opt/crust/crust-client/etc/crust_chain_spec_raw.json --pruning=archive --port $port --ws-port $ws_port --rpc-port $rpc_port --name $name"
if [ ! -z $bootnodes ]; then
verbose INFO "Add bootnodes($bootnodes)" h
chain_start_stcript="$chain_start_stcript --bootnodes=$bootnodes"
verbose INFO "Add bootnodes(${bootnodes[*]})" h
chain_start_stcript="$chain_start_stcript --bootnodes ${bootnodes[*]}"
verbose INFO " SUCCESS" t
else
verbose ERROR "Please fill bootnodes in chain configuration!"
Expand Down Expand Up @@ -353,8 +399,8 @@ chainLaunchValidator()
# Get chain start stcript
chain_start_stcript="$crust_chain_main_install_dir/bin/crust --base-path $base_path --chain /opt/crust/crust-client/etc/crust_chain_spec_raw.json --pruning=archive --validator --port $port --ws-port $ws_port --rpc-port $rpc_port --name $name"
if [ ! -z $bootnodes ]; then
verbose INFO "Add bootnodes($bootnodes)" h
chain_start_stcript="$chain_start_stcript --bootnodes=$bootnodes"
verbose INFO "Add bootnodes(${bootnodes[*]})" h
chain_start_stcript="$chain_start_stcript --bootnodes ${bootnodes[*]}"
verbose INFO " SUCCESS" t
else
verbose ERROR "Please fill bootnodes in chain configuration!"
Expand Down Expand Up @@ -512,7 +558,7 @@ teeLaunch()
api_base_url=$(getJsonValuesByAwk "$tee_config" "api_base_url" "null")
validator_api_base_url=$(getJsonValuesByAwk "$tee_config" "validator_api_base_url" "null")
if [ $api_base_url = $validator_api_base_url ]; then
verbose WARN "TEE verifier address is the same as yourself, please confirm that you are one of genesisi nodes\n"
verbose WARN "TEE verifier address is the same as yourself, please confirm that you are one of genesis nodes\n"
fi

cmd_run="$crust_tee_main_install_dir/bin/crust-tee -c $1"
Expand Down Expand Up @@ -603,6 +649,9 @@ while true ; do
shift ;
break ;;
*)
if [ x"$cmd_run" = x"" ]; then
cmd_run="help"
fi
break;
;;
esac
Expand Down

0 comments on commit 182a64e

Please sign in to comment.