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: allow fullnodes, make rpc optional #10

Merged
merged 2 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ There are master boot nodes running in the KILT testnet:
To start a node and connect to Alice you can use the shell script `start-node.sh`:

```
./start-node.sh --account-name Charly --connect-to Alice
./start-node.sh --connect-to Alice
```

You can use any of the accounts declared in the chain spec to connect (Alice, Bob, Charly, Dave, Eve, Ferdie).
If you want to connect to this node via RPC, add the `--rpc` flag:
```
./start-node.sh --connect-to Alice --rpc
```

Run `./start-node.sh --help` for more information.

Expand All @@ -41,7 +44,7 @@ docker pull 348099934012.dkr.ecr.eu-central-1.amazonaws.com/kilt/prototype-chain
a. To run a node and connect it to the KILT testnet: Run the image and pass the command to start a node:

```
docker run 348099934012.dkr.ecr.eu-central-1.amazonaws.com/kilt/prototype-chain ./start-node.sh --account-name Charly --connect-to Alice
docker run 348099934012.dkr.ecr.eu-central-1.amazonaws.com/kilt/prototype-chain ./start-node.sh --connect-to Alice
```
The node should be connected to the KILT testnet.

Expand Down
34 changes: 22 additions & 12 deletions start-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ Usage:

If you want to start a boot node, just use "Alice" or "Bob" as account name.

-a, --account-name ACCOUNT_NAME The name of the account to start the node with (Alice | Bob | Charly | Dave | Eve | Ferdie).
-a, --account-name ACCOUNT_NAME The name of the account to start the node with (Alice | Bob ).
-n, --node-name NODE_NAME The arbitrary name of the node (e.g. "charly-node-1234")
-c, --connect-to BOOT_NODE_NAME The name of the boot node to connect to ("alice" | "bob")
-d, --dry-run Flag indicating to only show the resulting command instead of executing it
-t, --telemetry Flag indicating whether or not to send data to the telemetry server
-p, --purge-userdata Purges all chain-dependend user data in auxiliary services (ctypes, contacts, messages, ...)
-r, --rpc Whether to activate rpc

Examples:

Expand All @@ -50,8 +51,8 @@ Usage:
Start Bob (boot node) that connects to Alice:
./start-node.sh -a Bob -c Alice

Start Charly (normal node) that connects to Alice:
./start-node.sh -a Charly -c Alice -n charly-node-123
Start full node that connects to Alice and exposes an rpc endpoint:
./start-node.sh -c Alice -n charly-node-123 --rpc
HELP_USAGE
}

Expand All @@ -64,6 +65,7 @@ account_name=
telemetry=0
purge_userdata=0
dry_run=0
rpc=0

while [[ "$1" != "" ]]; do
case $1 in
Expand All @@ -82,6 +84,8 @@ while [[ "$1" != "" ]]; do
;;
-d | --dry-run ) dry_run=1
;;
-r | --rpc ) rpc=1
;;
-h | --help ) usage
exit
;;
Expand All @@ -97,20 +101,22 @@ arg_node_key=
arg_node_name=
arg_telemetry=
arg_account_name=

if [[ -z "$account_name" ]]; then
usage
exit 1
fi
arg_rpc=

if [[ "$account_name" = "Alice" ]]; then
arg_node_key=" --node-key ${ALICE_BOOT_NODE_KEY}"
elif [[ "$account_name" = "Bob" ]]; then
arg_node_key=" --node-key ${BOB_BOOT_NODE_KEY}"
fi
arg_account_name=" --key ${account_name}"

echo "Starting KILT node with account '${account_name}'"
if [[ ! -z "$account_name" ]]; then
arg_account_name=" --key ${account_name} --validator"
echo "Starting KILT validator node with account '${account_name}'"
else
echo "Starting KILT full node"
fi


if [[ ! -z "$bootnode" ]]; then
echo "Trying to connect to boot node '$bootnode'..."
lookup_boot_node
Expand Down Expand Up @@ -140,7 +146,11 @@ if [[ "$purge_userdata" = "1" ]]; then
curl -X DELETE http://services.kilt-prototype.tk:3000/contacts
fi

command="./target/debug/node --chain ${CHAIN_NAME} --validator --port 30333 --ws-port 9944 --ws-external --rpc-external${arg_account_name}${arg_node_key}${arg_boot_node_connect}${arg_node_name}${arg_telemetry}"
if [[ "$rpc" = "1" ]]; then
arg_rpc=" --ws-port 9944 --ws-external --rpc-external"
fi

command="./target/debug/node --chain ${CHAIN_NAME} --port 30333${arg_rpc}${arg_account_name}${arg_node_key}${arg_boot_node_connect}${arg_node_name}${arg_telemetry}"

if [[ "$dry_run" = "1" ]]; then
echo "Dry run."
Expand All @@ -149,4 +159,4 @@ if [[ "$dry_run" = "1" ]]; then
fi

echo "Running: $command"
`${command}`
`${command}`