From f14470155808dfa89cdac7a3fa43406a3f842557 Mon Sep 17 00:00:00 2001 From: Timo Welde Date: Mon, 25 Feb 2019 16:47:17 +0100 Subject: [PATCH 1/3] feat: allow connecting to multiple bootnodes --- start-node.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/start-node.sh b/start-node.sh index dafd9a0cf..734c63869 100755 --- a/start-node.sh +++ b/start-node.sh @@ -14,14 +14,15 @@ TELEMETRY_URL=ws://telemetry-backend.kilt-prototype.tk:1024 ##### Functions lookup_boot_node() { - boot_node_domain="bootnode-${bootnode}.kilt-prototype.tk" + node=$1 + boot_node_domain="bootnode-${node}.kilt-prototype.tk" echo "Performing lookup for boot node ${boot_node_domain}" - if [[ "$bootnode" = "Alice" ]]; then + if [[ "$node" = "Alice" ]]; then alice_boot_node_ip=`dig ${boot_node_domain} A +short` - boot_node_ipfs=/ip4/${alice_boot_node_ip}/tcp/30333/p2p/${ALICE_BOOT_NODE_KEY_HASH} - elif [[ "$bootnode" = "Bob" ]]; then + boot_node_ipfs="$boot_node_ipfs /ip4/${alice_boot_node_ip}/tcp/30333/p2p/${ALICE_BOOT_NODE_KEY_HASH}" + elif [[ "$node" = "Bob" ]]; then bob_boot_node_ip=`dig ${boot_node_domain} A +short` - boot_node_ipfs=/ip4/${bob_boot_node_ip}/tcp/30333/p2p/${BOB_BOOT_NODE_KEY_HASH} + boot_node_ipfs="$boot_node_ipfs /ip4/${bob_boot_node_ip}/tcp/30333/p2p/${BOB_BOOT_NODE_KEY_HASH}" fi } @@ -118,14 +119,18 @@ fi if [[ ! -z "$bootnode" ]]; then - echo "Trying to connect to boot node '$bootnode'..." - lookup_boot_node + boot_node_ipfs= + echo "Trying to connect to boot node(s) '$bootnode'..." + for i in $(echo $bootnode | tr "," "\n") + do + lookup_boot_node $i + done if [[ -z "$boot_node_ipfs" ]]; then echo "Boot node address lookup failed for boot node named '$bootnode'" exit 1 else echo "Boot-node IPFS location: $boot_node_ipfs" - arg_boot_node_connect=" --bootnodes ${boot_node_ipfs}" + arg_boot_node_connect=" --bootnodes${boot_node_ipfs}" fi fi From a0768c95f1c940bc26c21b6b01e9d6d2f48b9762 Mon Sep 17 00:00:00 2001 From: Timo Welde Date: Mon, 25 Feb 2019 16:48:09 +0100 Subject: [PATCH 2/3] feat: promote Charlie to be a validator --- src/chain_spec.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chain_spec.rs b/src/chain_spec.rs index 3adb45eb1..9311b24bc 100644 --- a/src/chain_spec.rs +++ b/src/chain_spec.rs @@ -48,6 +48,7 @@ impl Alternative { || testnet_genesis(vec![ ed25519::Pair::from_seed(b"Alice ").public().into(), ed25519::Pair::from_seed(b"Bob ").public().into(), + ed25519::Pair::from_seed(b"Charlie ").public().into(), ], vec![ ed25519::Pair::from_seed(b"Alice ").public().0.into(), ed25519::Pair::from_seed(b"Bob ").public().0.into(), From 6eaa627300a15aac5b8027ec10c04aaac045b3d8 Mon Sep 17 00:00:00 2001 From: Timo Welde Date: Mon, 25 Feb 2019 17:04:40 +0100 Subject: [PATCH 3/3] feat: start node as charlie / connnect to charlie --- start-node.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/start-node.sh b/start-node.sh index 734c63869..9df5f255d 100755 --- a/start-node.sh +++ b/start-node.sh @@ -9,6 +9,8 @@ ALICE_BOOT_NODE_KEY=000000000000000000000000000000000000000000000000000000000000 ALICE_BOOT_NODE_KEY_HASH=QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN BOB_BOOT_NODE_KEY=0000000000000000000000000000000000000000000000000000000000000002 BOB_BOOT_NODE_KEY_HASH=QmXiB3jqqn2rpiKU7k1h7NJYeBg8WNSx9DiTRKz9ti2KSK +CHARLIE_BOOT_NODE_KEY=0000000000000000000000000000000000000000000000000000000000000003 +CHARLIE_BOOT_NODE_KEY_HASH=QmYcHeEWuqtr6Gb5EbK7zEhnaCm5p6vA2kWcVjFKbhApaC TELEMETRY_URL=ws://telemetry-backend.kilt-prototype.tk:1024 ##### Functions @@ -23,6 +25,9 @@ lookup_boot_node() { elif [[ "$node" = "Bob" ]]; then bob_boot_node_ip=`dig ${boot_node_domain} A +short` boot_node_ipfs="$boot_node_ipfs /ip4/${bob_boot_node_ip}/tcp/30333/p2p/${BOB_BOOT_NODE_KEY_HASH}" + elif [[ "$node" = "Charlie" ]]; then + charlie_boot_node_ip=`dig ${boot_node_domain} A +short` + boot_node_ipfs="$boot_node_ipfs /ip4/${charlie_boot_node_ip}/tcp/30333/p2p/${CHARLIE_BOOT_NODE_KEY_HASH}" fi } @@ -36,9 +41,9 @@ 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 ). + -a, --account-name ACCOUNT_NAME The name of the account to start the node with (Alice | Bob | Charlie). -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") + -c, --connect-to BOOT_NODE_NAME The names of the boot nodes to connect to, separated with a comma ("alice" | "bob" | "Charlie") -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, ...) @@ -52,15 +57,15 @@ Usage: Start Bob (boot node) that connects to Alice: ./start-node.sh -a Bob -c Alice - Start full node that connects to Alice and exposes an rpc endpoint: - ./start-node.sh -c Alice -n charly-node-123 --rpc + Start full node that connects to Alice and Bob and exposes an rpc endpoint: + ./start-node.sh -c Alice,Bob -n charly-node-123 --rpc HELP_USAGE } ##### Main -bootnode= +bootnodes= node_name= account_name= telemetry=0 @@ -77,7 +82,7 @@ while [[ "$1" != "" ]]; do node_name=$1 ;; -c | --connect-to ) shift - bootnode=$1 + bootnodes=$1 ;; -t | --telemetry ) telemetry=1 ;; @@ -108,6 +113,8 @@ 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}" +elif [[ "$account_name" = "Charlie" ]]; then + arg_node_key=" --node-key ${CHARLIE_BOOT_NODE_KEY}" fi if [[ ! -z "$account_name" ]]; then @@ -118,18 +125,18 @@ else fi -if [[ ! -z "$bootnode" ]]; then +if [[ ! -z "$bootnodes" ]]; then boot_node_ipfs= - echo "Trying to connect to boot node(s) '$bootnode'..." - for i in $(echo $bootnode | tr "," "\n") + echo "Trying to connect to boot node(s) '$bootnodes'..." + for i in $(echo $bootnodes | tr "," "\n") do lookup_boot_node $i done if [[ -z "$boot_node_ipfs" ]]; then - echo "Boot node address lookup failed for boot node named '$bootnode'" + echo "Boot node address lookup failed for boot nodes '$bootnodes'" exit 1 else - echo "Boot-node IPFS location: $boot_node_ipfs" + echo "Boot-node IPFS locations: $boot_node_ipfs" arg_boot_node_connect=" --bootnodes${boot_node_ipfs}" fi fi