Skip to content

Commit 85647db

Browse files
authored
feat: cardano-node topology w/ bootstrap peers (#125)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 6b6217e commit 85647db

File tree

4 files changed

+56
-63
lines changed

4 files changed

+56
-63
lines changed

roles/cardano_node/defaults/main.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,18 @@ cardano_node_config_file: '{{ cardano_node_config_container_dir }}/{{ cardano_no
6464

6565
# Topology
6666
cardano_node_manage_topology: false
67-
cardano_node_p2p_enabled: '{{ false if cardano_node_network == "mainnet" else true }}'
68-
cardano_node_p2p_use_ledger_after: 116812831
6967
cardano_node_topology_file: '{{ cardano_node_topology_container_dir }}/{{ cardano_node_network }}/topology.json'
68+
cardano_node_topology_use_ledger_after_slot: 128908821
7069
cardano_node_topology_localroots: []
71-
cardano_node_topology_publicroots:
72-
- address: 'relays-new.cardano-{{ cardano_node_network }}.iohk.io'
70+
cardano_node_topology_publicroots: []
71+
# Adjust for non-mainnet deployments
72+
cardano_node_topology_bootstrap_peers:
73+
- address: 'backbone.cardano.iog.io'
74+
port: 3001
75+
- address: 'backbone.mainnet.emurgornd.com'
76+
port: 3001
77+
- address: 'backbone.mainnet.cardanofoundation.org'
7378
port: 3001
74-
valency: 2 # this is only used for legacy topology
7579

7680
# Install chrony
7781
chrony_enabled: true

roles/cardano_node/tasks/main.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,15 @@
3535
- '{{ cardano_node_topology_dir }}'
3636
when: cardano_node_manage_topology
3737

38-
- name: Generate custom topology config (legacy)
38+
- name: Generate custom topology config
3939
template:
4040
dest: '{{ cardano_node_topology_file }}'
4141
src: custom-topology.json.j2
4242
owner: '{{ cardano_node_user | string }}'
4343
group: '{{ cardano_node_group | string }}'
4444
mode: 0644
4545
register: cardano_topology
46-
when: cardano_node_manage_topology and not cardano_node_p2p_enabled
47-
48-
- name: Generate custom topology config (P2P)
49-
template:
50-
dest: '{{ cardano_node_topology_file }}'
51-
src: custom-p2p-topology.json.j2
52-
owner: '{{ cardano_node_user | string }}'
53-
group: '{{ cardano_node_group | string }}'
54-
mode: 0644
55-
register: cardano_topology_p2p
56-
when: cardano_node_manage_topology and cardano_node_p2p_enabled
46+
when: cardano_node_manage_topology
5747

5848
- name: Include docker-related tasks
5949
ansible.builtin.include_tasks: docker.yml

roles/cardano_node/templates/custom-p2p-topology.json.j2

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,55 @@
11
{
2-
"Producers": [
3-
{% set peer_count = (cardano_node_topology_localroots + cardano_node_topology_publicroots) | length %}
4-
{% for peer in (cardano_node_topology_localroots + cardano_node_topology_publicroots) %}
2+
{% set peer_count = cardano_node_topology_bootstrap_peers | length %}
3+
{% if peer_count > 0 %}
4+
"bootstrapPeers": [
5+
{% for peer in cardano_node_topology_bootstrap_peers %}
56
{
67
"address": "{{ peer.address }}",
7-
"port": {{ peer.port }},
8-
"valency": {{ peer.valency | default(1) }}
8+
"port": {{ peer.port | int }}
99
{% if loop.index == peer_count %}
1010
}
1111
{% else %}
1212
},
13+
{% endif %}
14+
],
15+
{% endif %}
16+
"localRoots": [
17+
{
18+
"accessPoints": [
19+
{% set peer_count = cardano_node_topology_localroots | length %}
20+
{% for peer in cardano_node_topology_localroots %}
21+
{
22+
"address": "{{ peer.address }}",
23+
"port": {{ peer.port | int }}
24+
{% if loop.index == peer_count %}
25+
}
26+
{% else %}
27+
},
28+
{% endif %}
29+
{% endfor %}
30+
],
31+
"advertise": false,
32+
"trustable": false,
33+
"valency": 1
34+
}
35+
],
36+
"publicRoots": [
37+
{
38+
"accessPoints": [
39+
{% set peer_count = cardano_node_topology_publicroots | length %}
40+
{% for peer in cardano_node_topology_publicroots %}
41+
{
42+
"address": "{{ peer.address }}",
43+
"port": {{ peer.port | int }}
44+
{% if loop.index == peer_count %}
45+
}
46+
{% else %}
47+
},
1348
{% endif %}
1449
{% endfor %}
15-
]
50+
],
51+
"advertise": false
52+
}
53+
],
54+
"useLedgerAfterSlot": {{ cardano_node_topology_use_ledger_after_slot }}
1655
}

0 commit comments

Comments
 (0)