From 70a6ad4b3a1b1ec4a547802c121962325f61d802 Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Mon, 10 Jul 2023 20:40:51 +0200 Subject: [PATCH 1/5] Add --relay-chain-rpc-urls feature --- roles/node/defaults/main.yml | 4 + roles/node/tasks/001-health-check.yml | 4 +- roles/node/tasks/100-tests.yml | 5 +- roles/node/tasks/1000-post-tasks.yml | 9 ++ roles/node/tasks/803-restore-chain-http.yml | 119 ++++++++++++++++++++ roles/node/templates/env.j2 | 8 ++ roles/node/templates/node.service.j2 | 6 +- 7 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 roles/node/tasks/1000-post-tasks.yml create mode 100644 roles/node/tasks/803-restore-chain-http.yml diff --git a/roles/node/defaults/main.yml b/roles/node/defaults/main.yml index e50e304..067953d 100644 --- a/roles/node/defaults/main.yml +++ b/roles/node/defaults/main.yml @@ -164,6 +164,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/tasks/001-health-check.yml b/roles/node/tasks/001-health-check.yml index 5df02d6..7d68588 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 bafb8aa..60113eb 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/tasks/1000-post-tasks.yml b/roles/node/tasks/1000-post-tasks.yml new file mode 100644 index 0000000..52e0142 --- /dev/null +++ b/roles/node/tasks/1000-post-tasks.yml @@ -0,0 +1,9 @@ +--- + +- name: Post tasks | Remove temporary directory + ansible.builtin.file: + path: "{{ _node_temp_dir.path }}" + state: absent + check_mode: false + changed_when: false + when: _node_temp_dir.path is defined diff --git a/roles/node/tasks/803-restore-chain-http.yml b/roles/node/tasks/803-restore-chain-http.yml new file mode 100644 index 0000000..a3d2392 --- /dev/null +++ b/roles/node/tasks/803-restore-chain-http.yml @@ -0,0 +1,119 @@ +--- + + +- name: Restore {{ item.part }} | HTTP restoring | Install rclone + ansible.builtin.apt: + deb: "{{ _node_chain_backup_http_rclone_deb }}" + when: node_chain_backup_http_install_rclone | bool + +- name: Restore {{ item.part }} | HTTP restoring | Check last version + ansible.builtin.uri: + url: "{{ item.http_url | trim | trim('/') }}/latest_version.meta.txt" + method: "GET" + return_content: yes + use_proxy: false + register: _node_chain_backup_last_version_register + until: _node_chain_backup_last_version_register.status is defined and + _node_chain_backup_last_version_register.status == 200 + retries: 3 + delay: 10 + check_mode: false + changed_when: false + when: item.custom_http_url == '' + +- name: Restore {{ item.part }} | HTTP restoring | Setup _node_chain_backup_http_full_url 1 + ansible.builtin.set_fact: + _node_chain_backup_http_full_url: "{% if item.custom_http_url == '' %} + {{ item.http_url }}/{{ _node_chain_backup_last_version_register.content }} + {% else %}{{ item.custom_http_url }}{% endif %}" + +- name: Restore {{ item.part }} | HTTP restoring | Setup _node_chain_backup_http_full_url 2 + ansible.builtin.set_fact: + _node_chain_backup_http_full_url: "{{ _node_chain_backup_http_full_url | regex_replace('[\\s]+','') | trim('/') }}" + +- name: Restore {{ item.part }} | HTTP restoring | Print backup url + ansible.builtin.debug: + msg: "{{ _node_chain_backup_http_full_url }}" + +- name: Restore {{ item.part }} | HTTP restoring | Print backup meta url + ansible.builtin.debug: + msg: "{{ _node_chain_backup_http_full_url }}.meta.txt" + +- name: Restore {{ item.part }} | HTTP restoring | Check the size of the backup + ansible.builtin.uri: + url: "{{ _node_chain_backup_http_full_url }}.meta.txt" + method: "GET" + return_content: yes + use_proxy: false + register: _node_chain_restore_backup_size_register + until: _node_chain_restore_backup_size_register.status is defined and + _node_chain_restore_backup_size_register.status == 200 + retries: 3 + delay: 10 + check_mode: false + changed_when: false + when: _node_run_check_size + +- name: Restore {{ item.part }} | HTTP restoring | Print backup size + ansible.builtin.debug: + msg: "Backup size = {{ (_node_chain_restore_backup_size_register.content | from_yaml).size | int | filesizeformat(true) }}" + when: _node_run_check_size + +- name: Restore {{ item.part }} | HTTP restoring | Fail if free space <500MB + ansible.builtin.fail: + msg: | + Not enough free space to perform the restore, you should set the node_data_root_path variable + to a path on a different drive with enough free space + when: + - _node_run_check_size + - _node_restore_free_space | int - (_node_chain_restore_backup_size_register.content | from_yaml).size | int < 500 * 1024 * 1024 + # Skipped during check mode because it doesn't actually delete the db, making the result of this task wrong + - not ansible_check_mode + +- name: Restore {{ item.part }} | HTTP restoring | Download the files.txt meta file + ansible.builtin.get_url: + url: "{{ _node_chain_backup_http_full_url }}/files.txt" + dest: "{{ _node_temp_dir.path }}/{{ item.part }}-files.txt" + mode: 0755 + owner: "root" + group: "root" + timeout: 30 + check_mode: false + changed_when: false + +- name: Restore {{ item.part }} | HTTP restoring | Stop service + ansible.builtin.systemd: + name: "{{ node_app_name }}" + state: stopped + notify: restart service {{ node_handler_id }} + ignore_errors: "{{ not _node_systemd_unit_file_stat.stat.exists }}" + when: not _node_use_tmp_restore_path + +- name: Restore {{ item.part }} | HTTP restoring | Download chain backup + ansible.builtin.command: | + rclone copy -v --contimeout=1m --retries 6 --retries-sleep 10 --disable-http2 --http-no-head --no-traverse + --transfers={{ ansible_processor_vcpus * 5 }} --http-url {{ _node_chain_backup_http_full_url }} :http: + {{ _node_backup_dl_path | quote }} --files-from-raw {{ _node_temp_dir.path }}/{{ item.part }}-files.txt + changed_when: true + notify: restart service {{ node_handler_id }} + +- name: Restore {{ item.part }} | HTTP restoring | Manage node_chain_backup_tmp_restore_path + block: + + - name: Restore {{ item.part }} | GCP restoring | Stop service and cleanup DB + ansible.builtin.include_tasks: includes/_delete_db_folder.yml + + - name: Restore {{ item.part }} | HTTP restoring | Copy backup from temporary folder + ansible.builtin.copy: + src: "{{ node_chain_backup_tmp_restore_path }}/" + dest: "{{ item.chain_path }}/{{ item.db_folder }}" + owner: "{{ node_user }}" + group: "{{ node_user }}" + remote_src: true + + - name: Restore {{ item.part }} | HTTP restoring | Delete temporary folder + ansible.builtin.file: + path: "{{ node_chain_backup_tmp_restore_path }}" + state: absent + + when: _node_use_tmp_restore_path diff --git a/roles/node/templates/env.j2 b/roles/node/templates/env.j2 index 89be792..ec78a18 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 == '' %} 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 != '' %} +--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..92ec7dd 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 }} From a7758b0912c4d841b8ee7d4eb3a421e3de3e4187 Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Tue, 11 Jul 2023 10:48:11 +0200 Subject: [PATCH 2/5] Rectify default value of node_parachain_relay_chain_rpc_urls Co-authored-by: Bulat Saifullin --- roles/node/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/node/defaults/main.yml b/roles/node/defaults/main.yml index b1b4ff1..b9c9d4d 100644 --- a/roles/node/defaults/main.yml +++ b/roles/node/defaults/main.yml @@ -172,7 +172,7 @@ node_parachain_wasm_runtime: "" ### Experimental Feature # Remote Relay Chain via RPC -node_parachain_relay_chain_rpc_urls: [""] +node_parachain_relay_chain_rpc_urls: [] ### Keys ## p2p key From 5ca117646ce42eddcaea8845710195edb0b2622a Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Wed, 12 Jul 2023 10:02:24 +0200 Subject: [PATCH 3/5] Add Molecule test --- .../molecule/parachain_remote_rc/converge.yml | 8 +++ .../parachain_remote_rc/group_vars/all.yml | 11 ++++ ...molecule-instance-node-parachain-remote-rc | 7 +++ ...cule-instance-node-parachain-remote-rc-rpc | 5 ++ .../molecule/parachain_remote_rc/molecule.yml | 36 ++++++++++++ .../molecule/parachain_remote_rc/prepare.yml | 13 +++++ .../molecule/parachain_remote_rc/verify.yml | 58 +++++++++++++++++++ roles/node/tasks/001-health-check.yml | 4 +- roles/node/templates/env.j2 | 4 +- roles/node/vars/main.yml | 1 - 10 files changed, 142 insertions(+), 5 deletions(-) create mode 100644 roles/node/molecule/parachain_remote_rc/converge.yml create mode 100644 roles/node/molecule/parachain_remote_rc/group_vars/all.yml create mode 100644 roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc create mode 100644 roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc create mode 100644 roles/node/molecule/parachain_remote_rc/molecule.yml create mode 100644 roles/node/molecule/parachain_remote_rc/prepare.yml create mode 100644 roles/node/molecule/parachain_remote_rc/verify.yml 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..9671f96 --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/converge.yml @@ -0,0 +1,8 @@ +--- +- name: Converge + hosts: all + gather_facts: true + tasks: + - name: "Include node" + ansible.builtin.include_role: + name: "node" 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..ea5e0e9 --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/group_vars/all.yml @@ -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" diff --git a/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc b/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc new file mode 100644 index 0000000..68b4969 --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc @@ -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"] \ No newline at end of file diff --git a/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc b/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc new file mode 100644 index 0000000..bc625fe --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc @@ -0,0 +1,5 @@ +# Relaychain +node_chain: "shell" +node_rpc_port: 9944 +node_chain_backup_restoring_type: "none" + 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..55c89f1 --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/molecule.yml @@ -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 \ 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..02d0dc1 --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/prepare.yml @@ -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 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..9c82c1b --- /dev/null +++ b/roles/node/molecule/parachain_remote_rc/verify.yml @@ -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 }}" diff --git a/roles/node/tasks/001-health-check.yml b/roles/node/tasks/001-health-check.yml index 7d68588..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_parachain_relay_chain_rpc_urls | length > 0) | ternary(node_parachain_rpc_port, 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_parachain_relay_chain_rpc_urls | length > 0) | ternary(node_parachain_rpc_port, 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/templates/env.j2 b/roles/node/templates/env.j2 index ec78a18..f9cb98a 100644 --- a/roles/node/templates/env.j2 +++ b/roles/node/templates/env.j2 @@ -6,7 +6,7 @@ COMMON="\ --detailed-log-output {%- endif %}" -{% if node_parachain_relay_chain_rpc_urls == '' %} +{% if ( node_parachain_relay_chain_rpc_urls | length ) == 0 %} RC_NAME="{% if node_parachain_has_name_fix %}--name {{ node_public_name }}{% endif %}" RC_KEY=" @@ -138,7 +138,7 @@ PC_CHAIN=" {%- endif %}" PC_REMOTE_RC_URLS=" -{%- if node_parachain_relay_chain_rpc_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 %}" 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 }}" - From 745039d1fcb1fda6b3f429ca75c1af07dec1c78e Mon Sep 17 00:00:00 2001 From: Anthony Lazam Date: Wed, 12 Jul 2023 21:50:17 +0200 Subject: [PATCH 4/5] Molecule test fixes --- .../molecule/parachain_remote_rc/converge.yml | 10 +++++++- .../parachain_remote_rc/group_vars/all.yml | 4 ++-- ...molecule-instance-node-parachain-remote-rc | 7 ------ ...cule-instance-node-parachain-remote-rc-rpc | 5 ---- .../molecule/parachain_remote_rc/molecule.yml | 9 +------- .../molecule/parachain_remote_rc/prepare.yml | 11 +++++++++ .../molecule/parachain_remote_rc/verify.yml | 23 +++---------------- roles/node/tasks/100-tests.yml | 2 +- roles/node/templates/node.service.j2 | 4 ++-- 9 files changed, 29 insertions(+), 46 deletions(-) delete mode 100644 roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc delete mode 100644 roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc diff --git a/roles/node/molecule/parachain_remote_rc/converge.yml b/roles/node/molecule/parachain_remote_rc/converge.yml index 9671f96..38534b0 100644 --- a/roles/node/molecule/parachain_remote_rc/converge.yml +++ b/roles/node/molecule/parachain_remote_rc/converge.yml @@ -3,6 +3,14 @@ hosts: all gather_facts: true tasks: - - name: "Include node" + - name: "parachain" ansible.builtin.include_role: name: "node" + vars: + node_app_name: "parachain-shell" + 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://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 index ea5e0e9..8b434ac 100644 --- a/roles/node/molecule/parachain_remote_rc/group_vars/all.yml +++ b/roles/node/molecule/parachain_remote_rc/group_vars/all.yml @@ -2,10 +2,10 @@ ansible_user: root # Common +node_app_name: "dummy" 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" +#node_binary_deployment: false diff --git a/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc b/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc deleted file mode 100644 index 68b4969..0000000 --- a/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc +++ /dev/null @@ -1,7 +0,0 @@ -# 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"] \ No newline at end of file diff --git a/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc b/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc deleted file mode 100644 index bc625fe..0000000 --- a/roles/node/molecule/parachain_remote_rc/host_vars/molecule-instance-node-parachain-remote-rc-rpc +++ /dev/null @@ -1,5 +0,0 @@ -# Relaychain -node_chain: "shell" -node_rpc_port: 9944 -node_chain_backup_restoring_type: "none" - diff --git a/roles/node/molecule/parachain_remote_rc/molecule.yml b/roles/node/molecule/parachain_remote_rc/molecule.yml index 55c89f1..6353fb8 100644 --- a/roles/node/molecule/parachain_remote_rc/molecule.yml +++ b/roles/node/molecule/parachain_remote_rc/molecule.yml @@ -4,17 +4,10 @@ dependency: 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 + # DOCKER image: "paritytech/debian11:latest" command: ${MOLECULE_DOCKER_COMMAND:-""} privileged: true diff --git a/roles/node/molecule/parachain_remote_rc/prepare.yml b/roles/node/molecule/parachain_remote_rc/prepare.yml index 02d0dc1..4b6b018 100644 --- a/roles/node/molecule/parachain_remote_rc/prepare.yml +++ b/roles/node/molecule/parachain_remote_rc/prepare.yml @@ -11,3 +11,14 @@ - 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: "shell" + 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 index 9c82c1b..da497d3 100644 --- a/roles/node/molecule/parachain_remote_rc/verify.yml +++ b/roles/node/molecule/parachain_remote_rc/verify.yml @@ -15,26 +15,11 @@ - name: Print service facts ansible.builtin.debug: - var: ansible_facts.services['shell.service'] + var: ansible_facts.services['parachain-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 + that: ansible_facts.services['parachain-shell.service'].state == 'running' - name: Get parachain system_health ansible.builtin.uri: @@ -53,6 +38,4 @@ - name: Print system_health ansible.builtin.debug: - msg: - - "Relaychain: {{ _relaychain_system_health_result.json }}" - - "Parachain: {{ _parachain_system_health_result.json }}" + msg: "Parachain: {{ _parachain_system_health_result.json }}" diff --git a/roles/node/tasks/100-tests.yml b/roles/node/tasks/100-tests.yml index 08f4337..3487e46 100644 --- a/roles/node/tasks/100-tests.yml +++ b/roles/node/tasks/100-tests.yml @@ -23,7 +23,7 @@ when: - node_chain == '' - node_chainspec == '' - - node_parachain_relay_chain_rpc_urls == '' + - node_parachain_relay_chain_rpc_urls == [] - name: Test | Check node_parachain_chain ansible.builtin.fail: diff --git a/roles/node/templates/node.service.j2 b/roles/node/templates/node.service.j2 index 92ec7dd..7e31eab 100644 --- a/roles/node/templates/node.service.j2 +++ b/roles/node/templates/node.service.j2 @@ -11,13 +11,13 @@ MemoryHigh={{ node_memory_high }} MemoryMax={{ node_memory_max }} ExecStart={{ _node_binary_file }} \ $COMMON \ -{% if node_parachain_role != '' and node_parachain_relay_chain_rpc_urls != '' %} +{% 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 == '' %} +{% 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 %} From 343d99087f18c44d1edb76e00c20f7dedfc74c79 Mon Sep 17 00:00:00 2001 From: BulatSaif Date: Thu, 13 Jul 2023 12:49:06 +0300 Subject: [PATCH 5/5] fix relaychain --- roles/node/molecule/parachain_remote_rc/converge.yml | 1 - .../node/molecule/parachain_remote_rc/group_vars/all.yml | 2 +- roles/node/molecule/parachain_remote_rc/prepare.yml | 9 +++++++-- roles/node/molecule/parachain_remote_rc/verify.yml | 7 ------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/roles/node/molecule/parachain_remote_rc/converge.yml b/roles/node/molecule/parachain_remote_rc/converge.yml index 38534b0..adf7050 100644 --- a/roles/node/molecule/parachain_remote_rc/converge.yml +++ b/roles/node/molecule/parachain_remote_rc/converge.yml @@ -9,7 +9,6 @@ vars: node_app_name: "parachain-shell" 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://127.0.0.1:9944"] diff --git a/roles/node/molecule/parachain_remote_rc/group_vars/all.yml b/roles/node/molecule/parachain_remote_rc/group_vars/all.yml index 8b434ac..4f0e17a 100644 --- a/roles/node/molecule/parachain_remote_rc/group_vars/all.yml +++ b/roles/node/molecule/parachain_remote_rc/group_vars/all.yml @@ -5,7 +5,7 @@ ansible_user: root 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/prepare.yml b/roles/node/molecule/parachain_remote_rc/prepare.yml index 4b6b018..ca8937d 100644 --- a/roles/node/molecule/parachain_remote_rc/prepare.yml +++ b/roles/node/molecule/parachain_remote_rc/prepare.yml @@ -17,8 +17,13 @@ name: "node" vars: node_app_name: "relaychain-shell" - node_data_root_path: "/opt/{{node_app_name}}" - node_chain: "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 index da497d3..a9cfb8d 100644 --- a/roles/node/molecule/parachain_remote_rc/verify.yml +++ b/roles/node/molecule/parachain_remote_rc/verify.yml @@ -3,13 +3,6 @@ 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: