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

[Feature] External Relay Chain Support #39

Merged
merged 6 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions roles/node/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ node_parachain_chainspec: ""
# It has to be a link to wasm runtime. It will be used by the "--wasm-runtime-overrides" CLI flag
node_parachain_wasm_runtime: ""

### Experimental Feature
# Remote Relay Chain via RPC
node_parachain_relay_chain_rpc_urls: []

### Keys
## p2p key
# If it's empty, the node will generate default key file
Expand Down
8 changes: 8 additions & 0 deletions roles/node/molecule/parachain_remote_rc/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Converge
hosts: all
gather_facts: true
tasks:
- name: "Include node"
ansible.builtin.include_role:
name: "node"
11 changes: 11 additions & 0 deletions roles/node/molecule/parachain_remote_rc/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Molecule
ansible_user: root

# Common
node_binary_version: v0.9.430
node_legacy_rpc_flags: false

node_binary: https://github.com/paritytech/cumulus/releases/download/{{ node_binary_version }}/polkadot-parachain
node_binary_signature: https://github.com/paritytech/cumulus/releases/download/{{ node_binary_version }}/polkadot-parachain.asc
node_app_name: "shell"
node_prometheus_file_exporter_path: "/tmp/substrate.prom"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Parachain
node_parachain_chain: "shell"
node_parachain_rpc_port: 9954
node_parachain_role: "collator"
node_parachain_chain_backup_restoring_type: "none"

node_parachain_relay_chain_rpc_urls: ["ws://molecule-instance-node-parachain-remote-rc-rpc:9944"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Relaychain
node_chain: "shell"
lazam marked this conversation as resolved.
Show resolved Hide resolved
node_rpc_port: 9944
node_chain_backup_restoring_type: "none"

36 changes: 36 additions & 0 deletions roles/node/molecule/parachain_remote_rc/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
dependency:
name: galaxy
driver:
name: ${DRIVER:-docker}
platforms:
- name: molecule-instance-node-parachain-remote-rc-rpc
source:
alias: debian/bullseye/amd64
# DOCKER
image: "paritytech/debian11:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
pre_build_image: true
- name: molecule-instance-node-parachain-remote-rc
source:
alias: debian/bullseye/amd64
image: "paritytech/debian11:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
pre_build_image: true
provisioner:
name: ansible
options:
D: True
config_options:
defaults:
callbacks_enabled: timer
verifier:
name: ansible
options:
D: True
lint: |
set -e
yamllint .
ansible-lint
13 changes: 13 additions & 0 deletions roles/node/molecule/parachain_remote_rc/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- name: Prepare
hosts: all
gather_facts: false
pre_tasks:
- name: Install Python
ansible.builtin.raw: apt -y update && apt install -y python3
changed_when: false
- name: Install required packages
ansible.builtin.apt:
name:
- gpg
update_cache: no
changed_when: false
58 changes: 58 additions & 0 deletions roles/node/molecule/parachain_remote_rc/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: re-deploy node with wipe
ansible.builtin.include_role:
name: "node"
vars:
node_database_wipe: true
node_parachain_database_wipe: true

- name: Collect service facts
ansible.builtin.service_facts:

- name: Print service facts
ansible.builtin.debug:
var: ansible_facts.services['shell.service']

- name: check service
ansible.builtin.assert:
that: ansible_facts.services['shell.service'].state == 'running'

- name: Get relaychain system_health
ansible.builtin.uri:
url: "http://127.0.0.1:{{ node_rpc_port }}"
method: POST
body:
{"id":1, "jsonrpc":"2.0", "method":"system_health", "params":[]}
body_format: json
headers:
Content-Type: 'application/json'
use_proxy: false
until: _relaychain_system_health_result.status is defined and _relaychain_system_health_result.status == 200
retries: 3
delay: 10
register: _relaychain_system_health_result

- name: Get parachain system_health
ansible.builtin.uri:
url: "http://127.0.0.1:{{ node_parachain_rpc_port }}"
method: POST
body:
{"id":1, "jsonrpc":"2.0", "method":"system_health", "params":[]}
body_format: json
headers:
Content-Type: 'application/json'
use_proxy: false
until: _parachain_system_health_result.status is defined and _parachain_system_health_result.status == 200
retries: 3
delay: 10
register: _parachain_system_health_result

- name: Print system_health
ansible.builtin.debug:
msg:
- "Relaychain: {{ _relaychain_system_health_result.json }}"
- "Parachain: {{ _parachain_system_health_result.json }}"
4 changes: 2 additions & 2 deletions roles/node/tasks/001-health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

- name: Health check | Run health check
ansible.builtin.uri:
url: "http://127.0.0.1:{{ node_rpc_port }}"
url: "http://127.0.0.1:{{ ( node_parachain_relay_chain_rpc_urls | length != 0 ) | ternary(node_parachain_rpc_port, node_rpc_port) }}"
method: "POST"
body_format: "json"
body:
Expand All @@ -46,7 +46,7 @@

- name: Health check | Check the current version using API
ansible.builtin.uri:
url: "http://127.0.0.1:{{ node_rpc_port }}"
url: "http://127.0.0.1:{{ ( node_parachain_relay_chain_rpc_urls | length != 0 ) | ternary(node_parachain_rpc_port, node_rpc_port) }}"
method: "POST"
body_format: "json"
body:
Expand Down
5 changes: 4 additions & 1 deletion roles/node/tasks/100-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
- name: Test | Check node_chain
ansible.builtin.fail:
msg: "The 'node_chain' variable can't be empty!"
when: node_chain == '' and node_chainspec == ''
when:
- node_chain == ''
- node_chainspec == ''
- node_parachain_relay_chain_rpc_urls == ''
lazam marked this conversation as resolved.
Show resolved Hide resolved

- name: Test | Check node_parachain_chain
ansible.builtin.fail:
Expand Down
8 changes: 8 additions & 0 deletions roles/node/templates/env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COMMON="\
--detailed-log-output
{%- endif %}"

{% if ( node_parachain_relay_chain_rpc_urls | length ) == 0 %}
RC_NAME="{% if node_parachain_has_name_fix %}--name {{ node_public_name }}{% endif %}"

RC_KEY="
Expand Down Expand Up @@ -99,6 +100,7 @@ RC_CUSTOM_OPTIONS="\
{{ option }}{% if not loop.last %} \
{% endif %}
{%- endfor %}"
{%- endif %}

{% if node_log_trace_enable or node_parachain_log_trace_enable %}
RUST_BACKTRACE=1
Expand Down Expand Up @@ -135,6 +137,12 @@ PC_CHAIN="
--chain {{ node_parachain_chain }}
{%- endif %}"

PC_REMOTE_RC_URLS="
{%- if ( node_parachain_relay_chain_rpc_urls | length ) != 0 %}
--relay-chain-rpc-urls {% for url in node_parachain_relay_chain_rpc_urls %}'{{ url }}'{% if not loop.last %} {% endif %}{% endfor %}
{%- endif %}"


PC_ADDR="\
--listen-addr=/ip4/{{ node_parachain_p2p_bind_addr }}/tcp/{{ node_parachain_p2p_port }}
{%- if node_enable_public_ip_detection %} \
Expand Down
6 changes: 5 additions & 1 deletion roles/node/templates/node.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ MemoryHigh={{ node_memory_high }}
MemoryMax={{ node_memory_max }}
ExecStart={{ _node_binary_file }} \
$COMMON \
{% if node_parachain_role != '' %}
{% if node_parachain_role != '' and node_parachain_relay_chain_rpc_urls != '' %}
lazam marked this conversation as resolved.
Show resolved Hide resolved
$PC_NAME $PC_ROLE_SPECIFIC $PC_KEY $PC_CHAIN $PC_REMOTE_RC_URLS $PC_ADDR $PC_CONNECTIONS $PC_DB $PC_TELEMETRY $PC_PRUNING $PC_LOGS $PC_METRICS $PC_WS $PC_RPC $PC_WASM_RUNTIME $PC_CUSTOM_OPTIONS
{% elif node_parachain_role != '' %}
$PC_NAME $PC_ROLE_SPECIFIC $PC_KEY $PC_CHAIN $PC_ADDR $PC_CONNECTIONS $PC_DB $PC_TELEMETRY $PC_PRUNING $PC_LOGS $PC_METRICS $PC_WS $PC_RPC $PC_WASM_RUNTIME $PC_CUSTOM_OPTIONS \
-- \
{% endif %}
{% if node_parachain_relay_chain_rpc_urls == '' %}
lazam marked this conversation as resolved.
Show resolved Hide resolved
$RC_NAME $RC_ROLE_SPECIFIC $RC_KEY $RC_CHAIN $RC_ADDR $RC_CONNECTIONS $RC_DB $RC_TELEMETRY $RC_PRUNING $RC_LOGS $RC_METRICS $RC_WS $RC_RPC $RC_WASM_RUNTIME $RC_CUSTOM_OPTIONS
{% endif %}

{% if node_syslog_labels != '' %}
SyslogIdentifier={{ node_syslog_labels }}
Expand Down
1 change: 0 additions & 1 deletion roles/node/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,3 @@ _node_parachain_chain_backup_data:
node_parachain_chain +
('-paritydb' if node_parachain_paritydb_enable else '-rocksdb') + ('-prune' if node_parachain_pruning > 0 else '-archive') }}"
custom_http_url: "{{ node_parachain_chain_backup_http_url }}"