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: cardano-node topology w/ bootstrap peers #125

Merged
merged 1 commit into from
Sep 7, 2024
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
14 changes: 9 additions & 5 deletions roles/cardano_node/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ cardano_node_config_file: '{{ cardano_node_config_container_dir }}/{{ cardano_no

# Topology
cardano_node_manage_topology: false
cardano_node_p2p_enabled: '{{ false if cardano_node_network == "mainnet" else true }}'
cardano_node_p2p_use_ledger_after: 116812831
cardano_node_topology_file: '{{ cardano_node_topology_container_dir }}/{{ cardano_node_network }}/topology.json'
cardano_node_topology_use_ledger_after_slot: 128908821
cardano_node_topology_localroots: []
cardano_node_topology_publicroots:
- address: 'relays-new.cardano-{{ cardano_node_network }}.iohk.io'
cardano_node_topology_publicroots: []
# Adjust for non-mainnet deployments
cardano_node_topology_bootstrap_peers:
- address: 'backbone.cardano.iog.io'
port: 3001
- address: 'backbone.mainnet.emurgornd.com'
port: 3001
- address: 'backbone.mainnet.cardanofoundation.org'
port: 3001
valency: 2 # this is only used for legacy topology

# Install chrony
chrony_enabled: true
Expand Down
14 changes: 2 additions & 12 deletions roles/cardano_node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,15 @@
- '{{ cardano_node_topology_dir }}'
when: cardano_node_manage_topology

- name: Generate custom topology config (legacy)
- name: Generate custom topology config
template:
dest: '{{ cardano_node_topology_file }}'
src: custom-topology.json.j2
owner: '{{ cardano_node_user | string }}'
group: '{{ cardano_node_group | string }}'
mode: 0644
register: cardano_topology
when: cardano_node_manage_topology and not cardano_node_p2p_enabled

- name: Generate custom topology config (P2P)
template:
dest: '{{ cardano_node_topology_file }}'
src: custom-p2p-topology.json.j2
owner: '{{ cardano_node_user | string }}'
group: '{{ cardano_node_group | string }}'
mode: 0644
register: cardano_topology_p2p
when: cardano_node_manage_topology and cardano_node_p2p_enabled
when: cardano_node_manage_topology

- name: Include docker-related tasks
ansible.builtin.include_tasks: docker.yml
Expand Down
40 changes: 0 additions & 40 deletions roles/cardano_node/templates/custom-p2p-topology.json.j2

This file was deleted.

51 changes: 45 additions & 6 deletions roles/cardano_node/templates/custom-topology.json.j2
Original file line number Diff line number Diff line change
@@ -1,16 +1,55 @@
{
"Producers": [
{% set peer_count = (cardano_node_topology_localroots + cardano_node_topology_publicroots) | length %}
{% for peer in (cardano_node_topology_localroots + cardano_node_topology_publicroots) %}
{% set peer_count = cardano_node_topology_bootstrap_peers | length %}
{% if peer_count > 0 %}
"bootstrapPeers": [
{% for peer in cardano_node_topology_bootstrap_peers %}
{
"address": "{{ peer.address }}",
"port": {{ peer.port }},
"valency": {{ peer.valency | default(1) }}
"port": {{ peer.port | int }}
{% if loop.index == peer_count %}
}
{% else %}
},
{% endif %}
],
{% endif %}
"localRoots": [
{
"accessPoints": [
{% set peer_count = cardano_node_topology_localroots | length %}
{% for peer in cardano_node_topology_localroots %}
{
"address": "{{ peer.address }}",
"port": {{ peer.port | int }}
{% if loop.index == peer_count %}
}
{% else %}
},
{% endif %}
{% endfor %}
],
"advertise": false,
"trustable": false,
"valency": 1
}
],
"publicRoots": [
{
"accessPoints": [
{% set peer_count = cardano_node_topology_publicroots | length %}
{% for peer in cardano_node_topology_publicroots %}
{
"address": "{{ peer.address }}",
"port": {{ peer.port | int }}
{% if loop.index == peer_count %}
}
{% else %}
},
{% endif %}
{% endfor %}
]
],
"advertise": false
}
],
"useLedgerAfterSlot": {{ cardano_node_topology_use_ledger_after_slot }}
}
Loading