Skip to content

Commit

Permalink
Allow any node to be a bootstrap node.
Browse files Browse the repository at this point in the history
  • Loading branch information
elric1 committed May 13, 2021
1 parent 4b6ca24 commit 320868d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 4 additions & 1 deletion charts/tezos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ accounts: {}
# https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/
#
# Params for for non-public chains:
# - `bake_using_account`: The name of the account that should be used for baking.
# - `bake_using_account`: The name of the account that should be used
# for baking.
# - `is_bootstrap_node`: Is this node a bootstrap peer.
#
# The `config` property should mimic the structure of a node's config.json.
# Run `tezos-node config --help` for more info.

nodes:
baking: {}
# tezos-baking-node-0:
Expand All @@ -101,6 +103,7 @@ nodes:
# Non-baking nodes
regular:
tezos-node-0:
is_bootstrap_node: false
config:
shell:
history_mode: rolling
Expand Down
13 changes: 8 additions & 5 deletions utils/config-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
MY_NODE = NODES[MY_NODE_TYPE][MY_POD_NAME]


ALL_NODES = { **NODES.get("baking", {}), **NODES.get("regular", {}) }
BAKING_NODES = NODES["baking"]
NETWORK_CONFIG = CHAIN_PARAMS["network"]

Expand Down Expand Up @@ -92,16 +93,18 @@ def main():
bootstrap_peers.extend(json.load(f)["p2p"]["bootstrap-peers"])
else:
local_bootstrap_peers = []
for baker_name, baker_settings in BAKING_NODES.items():
for name, settings in ALL_NODES.items():
print(" -- is " + name + " a bootstrap peer?\n");
my_pod_fqdn_with_port = f"{socket.getfqdn()}:9732"
if (
baker_settings.get("is_bootstrap_node", False)
and baker_name not in my_pod_fqdn_with_port
settings.get("is_bootstrap_node", False)
and name not in my_pod_fqdn_with_port
):
# Construct the FBN of the bootstrap node for all node's bootstrap_peers
bootstrap_peer_domain = sub(r"-\d+$", "", baker_name)
print(" -- YES!\n")
bootstrap_peer_domain = sub(r"-\d+$", "", name)
bootstrap_peer_fbn_with_port = (
f"{baker_name}.{bootstrap_peer_domain}:9732"
f"{name}.{bootstrap_peer_domain}:9732"
)
local_bootstrap_peers.append(bootstrap_peer_fbn_with_port)
bootstrap_peers.extend(local_bootstrap_peers)
Expand Down
4 changes: 2 additions & 2 deletions utils/wait-for-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ fi

BOOTSTRAP_NODES=$(
echo "$NODES" | \
jq -r '.baking|to_entries[]
jq -r '[.[]|to_entries]|flatten[]
|select(.value.is_bootstrap_node)
|.key+".tezos-baking-node"'
|.key + "." + (.key|sub("-[\\d]+$"; ""))'
)

if [ -z "$BOOTSTRAP_NODES" ]; then
Expand Down

0 comments on commit 320868d

Please sign in to comment.