diff --git a/roles/node/defaults/main.yml b/roles/node/defaults/main.yml index 82046f4..b9c9d4d 100644 --- a/roles/node/defaults/main.yml +++ b/roles/node/defaults/main.yml @@ -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 diff --git a/roles/node/molecule/parachain_remote_rc/converge.yml b/roles/node/molecule/parachain_remote_rc/converge.yml new file mode 100644 index 0000000..adf7050 --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/converge.yml @@ -0,0 +1,15 @@ +--- +- name: Converge + hosts: all + gather_facts: true + tasks: + - name: "parachain" + ansible.builtin.include_role: + name: "node" + vars: + node_app_name: "parachain-shell" + node_parachain_chain: "shell" + node_parachain_role: "collator" + node_parachain_chain_backup_restoring_type: "none" + node_parachain_relay_chain_rpc_urls: ["ws://127.0.0.1:9944"] + node_prometheus_file_exporter_path: "/tmp/substrate-pc.prom" diff --git a/roles/node/molecule/parachain_remote_rc/group_vars/all.yml b/roles/node/molecule/parachain_remote_rc/group_vars/all.yml new file mode 100644 index 0000000..4f0e17a --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/group_vars/all.yml @@ -0,0 +1,11 @@ +## Molecule +ansible_user: root + +# Common +node_app_name: "dummy" +node_binary_version: v0.9.430 +node_legacy_rpc_flags: false +node_parachain_rpc_port: 9954 +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_binary_deployment: false diff --git a/roles/node/molecule/parachain_remote_rc/molecule.yml b/roles/node/molecule/parachain_remote_rc/molecule.yml new file mode 100644 index 0000000..6353fb8 --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/molecule.yml @@ -0,0 +1,29 @@ +--- +dependency: + name: galaxy +driver: + name: ${DRIVER:-docker} +platforms: + - name: molecule-instance-node-parachain-remote-rc + source: + alias: debian/bullseye/amd64 + # DOCKER + 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 \ No newline at end of file diff --git a/roles/node/molecule/parachain_remote_rc/prepare.yml b/roles/node/molecule/parachain_remote_rc/prepare.yml new file mode 100644 index 0000000..ca8937d --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/prepare.yml @@ -0,0 +1,29 @@ +- 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 + tasks: + - name: "relaychain" + ansible.builtin.include_role: + name: "node" + vars: + node_app_name: "relaychain-shell" + node_data_root_path: "/opt/{{ node_app_name }}" + node_chain: "rococo-dev" + node_custom_options: [ '--alice' ] + node_binary_version: v0.9.43 + node_legacy_rpc_flags: false + node_binary: https://github.com/paritytech/polkadot/releases/download/{{ node_binary_version }}/polkadot + node_binary_signature: https://github.com/paritytech/polkadot/releases/download/{{ node_binary_version }}/polkadot.asc + node_rpc_port: 9944 + node_chain_backup_restoring_type: "none" + node_prometheus_file_exporter_path: "/tmp/substrate-rc.prom" diff --git a/roles/node/molecule/parachain_remote_rc/verify.yml b/roles/node/molecule/parachain_remote_rc/verify.yml new file mode 100644 index 0000000..a9cfb8d --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/verify.yml @@ -0,0 +1,34 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Collect service facts + ansible.builtin.service_facts: + + - name: Print service facts + ansible.builtin.debug: + var: ansible_facts.services['parachain-shell.service'] + + - name: check service + ansible.builtin.assert: + that: ansible_facts.services['parachain-shell.service'].state == 'running' + + - 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: "Parachain: {{ _parachain_system_health_result.json }}" diff --git a/roles/node/tasks/001-health-check.yml b/roles/node/tasks/001-health-check.yml index 5df02d6..0f8a340 100644 --- a/roles/node/tasks/001-health-check.yml +++ b/roles/node/tasks/001-health-check.yml @@ -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: @@ -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: diff --git a/roles/node/tasks/100-tests.yml b/roles/node/tasks/100-tests.yml index b0eee64..3487e46 100644 --- a/roles/node/tasks/100-tests.yml +++ b/roles/node/tasks/100-tests.yml @@ -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 == [] - name: Test | Check node_parachain_chain ansible.builtin.fail: diff --git a/roles/node/templates/env.j2 b/roles/node/templates/env.j2 index 89be792..f9cb98a 100644 --- a/roles/node/templates/env.j2 +++ b/roles/node/templates/env.j2 @@ -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=" @@ -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 @@ -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 %} \ diff --git a/roles/node/templates/node.service.j2 b/roles/node/templates/node.service.j2 index d92b045..7e31eab 100644 --- a/roles/node/templates/node.service.j2 +++ b/roles/node/templates/node.service.j2 @@ -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 != [] %} + $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 == [] %} $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 }} diff --git a/roles/node/vars/main.yml b/roles/node/vars/main.yml index 197afba..baa698c 100644 --- a/roles/node/vars/main.yml +++ b/roles/node/vars/main.yml @@ -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 }}" -