From 0a0555eee276fd2bbbba55bbf9b6b4c63d1ce817 Mon Sep 17 00:00:00 2001 From: NeoPlays <80448387+NeoPlays@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:23:15 +0700 Subject: [PATCH] ADD: New Oracle Changes and activate CSM Mainnet (#2100) * ADD: New Oracle Changes * ADD: Mainnet Contract Addresses for csm monitor service * ADD: CSM * FIX: handle case when service is not in updates.json --------- Co-authored-by: Martin Wostal --- .../update-changes/molecule/224/converge.yml | 10 ++ .../update-changes/molecule/224/molecule.yml | 27 +++++ .../update-changes/molecule/224/playbook.yml | 7 ++ .../update-changes/molecule/224/prepare.yml | 105 ++++++++++++++++++ .../update-changes/molecule/224/verify.yml | 39 +++++++ .../tasks/2.2.4/ejector_changes.yaml | 20 ++++ .../tasks/2.2.4/updates-224.yaml | 11 ++ controls/roles/update-changes/tasks/main.yml | 4 + .../update-services/tasks/update-service.yml | 7 +- launcher/src/backend/Monitoring.js | 2 + .../backend/ethereum-services/LCOMService.js | 3 + .../ValidatorEjectorService.js | 2 +- launcher/src/composables/validators.js | 25 +++-- launcher/src/store/nodeManage.js | 2 +- 14 files changed, 246 insertions(+), 18 deletions(-) create mode 100644 controls/roles/update-changes/molecule/224/converge.yml create mode 100644 controls/roles/update-changes/molecule/224/molecule.yml create mode 100644 controls/roles/update-changes/molecule/224/playbook.yml create mode 100644 controls/roles/update-changes/molecule/224/prepare.yml create mode 100644 controls/roles/update-changes/molecule/224/verify.yml create mode 100644 controls/roles/update-changes/tasks/2.2.4/ejector_changes.yaml create mode 100644 controls/roles/update-changes/tasks/2.2.4/updates-224.yaml diff --git a/controls/roles/update-changes/molecule/224/converge.yml b/controls/roles/update-changes/molecule/224/converge.yml new file mode 100644 index 000000000..3f84cb4a2 --- /dev/null +++ b/controls/roles/update-changes/molecule/224/converge.yml @@ -0,0 +1,10 @@ +--- +- name: Converge + hosts: all + vars_files: + - ../../../../defaults/stereum_defaults.yaml + + tasks: + - name: "Include update-changes" + include_role: + name: "update-changes" diff --git a/controls/roles/update-changes/molecule/224/molecule.yml b/controls/roles/update-changes/molecule/224/molecule.yml new file mode 100644 index 000000000..c8e3775c9 --- /dev/null +++ b/controls/roles/update-changes/molecule/224/molecule.yml @@ -0,0 +1,27 @@ +--- +#dependency: +# name: galaxy +driver: + name: docker +platforms: + - name: "update-changes--2.2.4--ubuntu-23.04" + image: ubuntu:lunar + # - name: "configure-updates--default--centos-8" + # image: geerlingguy/docker-centos8-ansible +provisioner: + name: ansible + env: + ANSIBLE_PIPELINING: "True" +lint: | + set -e + yamllint . + ansible-lint . +scenario: + test_sequence: + - destroy + - create + - prepare + - converge + - idempotence + - verify + - destroy diff --git a/controls/roles/update-changes/molecule/224/playbook.yml b/controls/roles/update-changes/molecule/224/playbook.yml new file mode 100644 index 000000000..710c596cf --- /dev/null +++ b/controls/roles/update-changes/molecule/224/playbook.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "Include update-changes" + include_role: + name: "update-changes" diff --git a/controls/roles/update-changes/molecule/224/prepare.yml b/controls/roles/update-changes/molecule/224/prepare.yml new file mode 100644 index 000000000..07e1660f4 --- /dev/null +++ b/controls/roles/update-changes/molecule/224/prepare.yml @@ -0,0 +1,105 @@ +--- +- name: Prepare + hosts: all + tasks: + - name: Make sure Stereum's config path exists + file: + path: "/etc/stereum/services" + state: directory + owner: "root" + group: "root" + mode: 0644 + become: yes + + - name: Create ValidatorEjectorService config + copy: + dest: "/etc/stereum/services/15ce3684-4dbd-4657-8a21-b1243b72b1ca.yaml" + owner: "root" + group: "root" + mode: 0644 + content: | + service: ValidatorEjectorService + id: 15ce3684-4dbd-4657-8a21-b1243b72b1ca + configVersion: 1 + command: [] + entrypoint: [] + env: + EXECUTION_NODE: http://stereum-ce456ae0-64d6-4886-a53b-6b90984d4913:8545 + CONSENSUS_NODE: http://stereum-e7bd77d1-4d20-4a2e-85a6-1915f105a4c6:5052 + LOCATOR_ADDRESS: "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8" + STAKING_MODULE_ID: "123" + OPERATOR_ID: "123" + MESSAGES_LOCATION: /app/messages + ORACLE_ADDRESSES_ALLOWLIST: '["0x140Bd8FbDc884f48dA7cb1c09bE8A2fAdfea776E", + "0xA7410857ABbf75043d61ea54e07D57A6EB6EF186", + "0x404335BcE530400a5814375E7Ec1FB55fAff3eA2", + "0x946D3b081ed19173dC83Cd974fC69e1e760B7d78", + "0x007DE4a5F7bc37E2F26c0cb2E8A95006EE9B89b5", + "0xe57B3792aDCc5da47EF4fF588883F0ee0c9835C9", + "0x61c91ECd902EB56e314bB2D5c5C07785444Ea1c8", + "0x1Ca0fEC59b86F549e1F1184d97cb47794C8Af58d", + "0xc79F702202E3A6B0B6310B537E786B9ACAA19BAf"]' + HTTP_PORT: "8989" + RUN_METRICS: "true" + RUN_HEALTH_CHECK: "true" + DRY_RUN: "false" + image: lidofinance/validator-ejector:1.6.0 + ports: [] + volumes: + - /opt/stereum/validatorejector-15ce3684-4dbd-4657-8a21-b1243b72b1ca/messages:/app/messages + user: "2000" + autoupdate: true + network: mainnet + dependencies: + executionClients: + - service: GethService + id: ce456ae0-64d6-4886-a53b-6b90984d4913 + consensusClients: + - service: LighthouseBeaconService + id: e7bd77d1-4d20-4a2e-85a6-1915f105a4c6 + mevboost: [] + otherServices: [] + become: yes + + - name: Create ValidatorEjectorService config + copy: + dest: "/etc/stereum/services/41b15ea7-12d4-49f6-8448-8a6164edef36.yaml" + owner: "root" + group: "root" + mode: 0644 + content: | + service: ValidatorEjectorService + id: 41b15ea7-12d4-49f6-8448-8a6164edef36 + configVersion: 1 + command: [] + entrypoint: [] + env: + EXECUTION_NODE: http://stereum-cc1323ce-90a1-440f-8b78-f930a3300b38:8545 + CONSENSUS_NODE: http://stereum-62cb879b-b0f0-4ea2-bc13-f606b7f4cfb9:5052 + LOCATOR_ADDRESS: "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8" + STAKING_MODULE_ID: "123" + OPERATOR_ID: "123" + MESSAGES_LOCATION: /app/messages + ORACLE_ADDRESSES_ALLOWLIST: '["0x140Bd8FbDc884f48dA7cb1c09bE8A2fAdfea776E","0xA7410857ABbf75043d61ea54e07D57A6EB6EF186","0x404335BcE530400a5814375E7Ec1FB55fAff3eA2","0x946D3b081ed19173dC83Cd974fC69e1e760B7d78","0x007DE4a5F7bc37E2F26c0cb2E8A95006EE9B89b5","0xe57B3792aDCc5da47EF4fF588883F0ee0c9835C9","0x61c91ECd902EB56e314bB2D5c5C07785444Ea1c8","0x1Ca0fEC59b86F549e1F1184d97cb47794C8Af58d","0xc79F702202E3A6B0B6310B537E786B9ACAA19BAf"]' + HTTP_PORT: "8989" + RUN_METRICS: "true" + RUN_HEALTH_CHECK: "true" + DRY_RUN: "false" + image: lidofinance/validator-ejector:1.6.0 + ports: [] + volumes: + - /opt/stereum/validatorejector-41b15ea7-12d4-49f6-8448-8a6164edef36/messages:/app/messages + user: "2000" + autoupdate: true + network: mainnet + dependencies: + executionClients: + - service: GethService + id: cc1323ce-90a1-440f-8b78-f930a3300b38 + consensusClients: + - service: LighthouseBeaconService + id: 62cb879b-b0f0-4ea2-bc13-f606b7f4cfb9 + mevboost: [] + otherServices: [] + become: yes +#EOF diff --git a/controls/roles/update-changes/molecule/224/verify.yml b/controls/roles/update-changes/molecule/224/verify.yml new file mode 100644 index 000000000..54be09e3e --- /dev/null +++ b/controls/roles/update-changes/molecule/224/verify.yml @@ -0,0 +1,39 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + # ValidatorEjectorService + - name: Read ValidatorEjectorService file + slurp: + src: "/etc/stereum/services/15ce3684-4dbd-4657-8a21-b1243b72b1ca.yaml" + register: Ejector_service_configuration_raw + + # ValidatorEjectorService2 + - name: Read ValidatorEjectorService file + slurp: + src: "/etc/stereum/services/41b15ea7-12d4-49f6-8448-8a6164edef36.yaml" + register: Ejector_service_configuration2_raw + + - name: Parse Service configurations + set_fact: + Ejector_service_configuration: "{{ Ejector_service_configuration_raw['content'] | b64decode | from_yaml }}" + Ejector_service_configuration2: "{{ Ejector_service_configuration2_raw['content'] | b64decode | from_yaml }}" + + - debug: + msg: "{{ Ejector_service_configuration }}" + - debug: + msg: "{{ Ejector_service_configuration_raw['content'] | b64decode }}" + + - debug: + msg: "{{ Ejector_service_configuration2 }}" + - debug: + msg: "{{ Ejector_service_configuration2_raw['content'] | b64decode }}" + + - assert: + that: + - Ejector_service_configuration.env.ORACLE_ADDRESSES_ALLOWLIST | from_yaml | select('match', '0x73181107c8D9ED4ce0bbeF7A0b4ccf3320C41d12') | length == 1 + - Ejector_service_configuration.env.ORACLE_ADDRESSES_ALLOWLIST | from_yaml | select('match', '0x1Ca0fEC59b86F549e1F1184d97cb47794C8Af58d') | length == 0 + - Ejector_service_configuration2.env.ORACLE_ADDRESSES_ALLOWLIST | from_yaml | select('match', '0x73181107c8D9ED4ce0bbeF7A0b4ccf3320C41d12') | length == 1 + - Ejector_service_configuration2.env.ORACLE_ADDRESSES_ALLOWLIST | from_yaml | select('match', '0x1Ca0fEC59b86F549e1F1184d97cb47794C8Af58d') | length == 0 +# EOF diff --git a/controls/roles/update-changes/tasks/2.2.4/ejector_changes.yaml b/controls/roles/update-changes/tasks/2.2.4/ejector_changes.yaml new file mode 100644 index 000000000..e922def26 --- /dev/null +++ b/controls/roles/update-changes/tasks/2.2.4/ejector_changes.yaml @@ -0,0 +1,20 @@ +--- +- name: Read service file + slurp: + src: "{{ config_file.path }}" + register: service_configuration_raw + +- name: Parse service's configuration + set_fact: + service_configuration: "{{ service_configuration_raw['content'] | b64decode | from_yaml }}" + service_configuration_text: "{{ service_configuration_raw['content'] | b64decode }}" + +- name: Update Oracle Allow List + replace: + path: "{{ config_file.path }}" + regexp: '(?s)ORACLE_ADDRESSES_ALLOWLIST:.*?]["'']{1}' + replace: 'ORACLE_ADDRESSES_ALLOWLIST: ''["0x140Bd8FbDc884f48dA7cb1c09bE8A2fAdfea776E","0xA7410857ABbf75043d61ea54e07D57A6EB6EF186","0x404335BcE530400a5814375E7Ec1FB55fAff3eA2","0x946D3b081ed19173dC83Cd974fC69e1e760B7d78","0x007DE4a5F7bc37E2F26c0cb2E8A95006EE9B89b5","0xe57B3792aDCc5da47EF4fF588883F0ee0c9835C9","0x61c91ECd902EB56e314bB2D5c5C07785444Ea1c8","0x73181107c8D9ED4ce0bbeF7A0b4ccf3320C41d12","0xc79F702202E3A6B0B6310B537E786B9ACAA19BAf"]''' + when: + - service_configuration.service == "ValidatorEjectorService" + - service_configuration.network == "mainnet" + - service_configuration.env.ORACLE_ADDRESSES_ALLOWLIST | from_yaml | select('match', '0x1Ca0fEC59b86F549e1F1184d97cb47794C8Af58d') | length == 1 diff --git a/controls/roles/update-changes/tasks/2.2.4/updates-224.yaml b/controls/roles/update-changes/tasks/2.2.4/updates-224.yaml new file mode 100644 index 000000000..d3deab9df --- /dev/null +++ b/controls/roles/update-changes/tasks/2.2.4/updates-224.yaml @@ -0,0 +1,11 @@ +--- +- name: Find service configs + find: + paths: "/etc/stereum/services" + register: service_config_files + +- name: Include Ejector Changes + include_tasks: ejector_changes.yaml + loop: "{{ service_config_files.files }}" + loop_control: + loop_var: config_file diff --git a/controls/roles/update-changes/tasks/main.yml b/controls/roles/update-changes/tasks/main.yml index 1ce21eb21..3d2f786c7 100644 --- a/controls/roles/update-changes/tasks/main.yml +++ b/controls/roles/update-changes/tasks/main.yml @@ -13,4 +13,8 @@ - name: Include 2.2.3 Update Scripts include_tasks: "2.2.3/updates-223.yaml" ignore_errors: yes + +- name: Include 2.2.4 Update Scripts + include_tasks: "2.2.4/updates-224.yaml" + ignore_errors: yes # EOF diff --git a/controls/roles/update-services/tasks/update-service.yml b/controls/roles/update-services/tasks/update-service.yml index 1ea7d3a2d..b529077fd 100644 --- a/controls/roles/update-services/tasks/update-service.yml +++ b/controls/roles/update-services/tasks/update-service.yml @@ -17,13 +17,13 @@ - name: Get latest version for this service set_fact: - new_service_docker_image_tag: "{{ update_data.json[service_configuration.network][service_configuration.service] | default(update_data.json['mainnet'][service_configuration.service]) | last }}" + new_service_docker_image_tag: "{{ (update_data.json[service_configuration.network][service_configuration.service] | default(update_data.json['mainnet'][service_configuration.service] | default([]))) | last }}" when: service_configuration.autoupdate and service_configuration.service != 'CustomService' - name: Build new image tag set_fact: new_service_configuration_fraction: - image: "{{ service_docker_image }}:{{ new_service_docker_image_tag }}" + image: "{{ service_docker_image }}:{{ new_service_docker_image_tag | default(service_docker_image_tag) }}" when: service_configuration.autoupdate - name: Update configuration @@ -33,12 +33,11 @@ - name: Write configuration copy: - content: '{{ new_service_configuration | to_nice_yaml }}' + content: "{{ new_service_configuration | to_nice_yaml }}" dest: "/etc/stereum/services/{{ item }}.yaml" owner: "root" group: "root" mode: 0644 when: service_configuration.autoupdate and new_service_docker_image_tag != service_docker_image_tag become: yes - # EOF diff --git a/launcher/src/backend/Monitoring.js b/launcher/src/backend/Monitoring.js index 9f797a6dc..72380bd8c 100755 --- a/launcher/src/backend/Monitoring.js +++ b/launcher/src/backend/Monitoring.js @@ -1746,6 +1746,7 @@ export class Monitoring { // Get attestation rewards for given validators and epoch async getAttestationRewards(validators) { + if (validators.length === 0) return []; try { // Get local beacon port from first available consensus client const beaconResult = await this.findBeaconPort(); @@ -1808,6 +1809,7 @@ export class Monitoring { // Get Sync Committee for given validators and slot (count them together for whole epoch in frontend) async getSyncCommitteeRewards(validators, slot) { + if (validators.length === 0) return []; try { // Get local beacon port from first available consensus client const beaconResult = await this.findBeaconPort(); diff --git a/launcher/src/backend/ethereum-services/LCOMService.js b/launcher/src/backend/ethereum-services/LCOMService.js index 848aece27..dbf098ff0 100644 --- a/launcher/src/backend/ethereum-services/LCOMService.js +++ b/launcher/src/backend/ethereum-services/LCOMService.js @@ -32,6 +32,9 @@ export class LCOMService extends NodeService { // Mainnet smart-contract addresses: MAINNET_VALIDATORSEXITBUSORACLE_ADDRESS: "0x0De4Ea0184c2ad0BacA7183356Aea5B8d5Bf5c6e", + MAINNET_CSMODULE_ADDRESS: "0xdA7dE2ECdDfccC6c3AF10108Db212ACBBf9EA83F", + MAINNET_CSACCOUNTING_ADDRESS: "0x4d72BFF1BeaC69925F8Bd12526a39BAAb069e5Da", + MAINNET_CSFEEDISTRIBUTOR_ADDRESS: "0xD99CC66fEC647E68294C6477B40fC7E0F6F618D0", // Holesky Testnet smart-contract addresses: HOLESKY_VALIDATORSEXITBUSORACLE_ADDRESS: "0xffDDF7025410412deaa05E3E1cE68FE53208afcb", diff --git a/launcher/src/backend/ethereum-services/ValidatorEjectorService.js b/launcher/src/backend/ethereum-services/ValidatorEjectorService.js index 9432f190d..5b6661bc3 100755 --- a/launcher/src/backend/ethereum-services/ValidatorEjectorService.js +++ b/launcher/src/backend/ethereum-services/ValidatorEjectorService.js @@ -18,7 +18,7 @@ export class ValidatorEjectorService extends NodeService { case "mainnet": locatorAddress = "0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb"; //https://docs.lido.fi/deployed-contracts/#core-protocol oracleAllowList = - '["0x140Bd8FbDc884f48dA7cb1c09bE8A2fAdfea776E","0xA7410857ABbf75043d61ea54e07D57A6EB6EF186","0x404335BcE530400a5814375E7Ec1FB55fAff3eA2","0x946D3b081ed19173dC83Cd974fC69e1e760B7d78","0x007DE4a5F7bc37E2F26c0cb2E8A95006EE9B89b5","0xe57B3792aDCc5da47EF4fF588883F0ee0c9835C9","0x61c91ECd902EB56e314bB2D5c5C07785444Ea1c8","0x1Ca0fEC59b86F549e1F1184d97cb47794C8Af58d","0xc79F702202E3A6B0B6310B537E786B9ACAA19BAf"]'; + '["0x140Bd8FbDc884f48dA7cb1c09bE8A2fAdfea776E","0xA7410857ABbf75043d61ea54e07D57A6EB6EF186","0x404335BcE530400a5814375E7Ec1FB55fAff3eA2","0x946D3b081ed19173dC83Cd974fC69e1e760B7d78","0x007DE4a5F7bc37E2F26c0cb2E8A95006EE9B89b5","0xe57B3792aDCc5da47EF4fF588883F0ee0c9835C9","0x61c91ECd902EB56e314bB2D5c5C07785444Ea1c8","0x73181107c8D9ED4ce0bbeF7A0b4ccf3320C41d12","0xc79F702202E3A6B0B6310B537E786B9ACAA19BAf"]'; break; case "holesky": locatorAddress = "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8"; //https://docs.lido.fi/deployed-contracts/holesky#core-protocol diff --git a/launcher/src/composables/validators.js b/launcher/src/composables/validators.js index c72ade3ed..077a69ab0 100644 --- a/launcher/src/composables/validators.js +++ b/launcher/src/composables/validators.js @@ -19,7 +19,6 @@ export async function useListKeys(forceRefresh) { if ((client.config.keys === undefined || client.config.keys.length === 0 || forceRefresh) && client.state === "running") { //refresh validaotr list let result = await ControlService.listValidators(client.config.serviceID); - if (!client.service.includes("Web3Signer")) { let resultRemote = await ControlService.listRemoteKeys(client.config.serviceID); let remoteKeys = resultRemote.data @@ -102,6 +101,7 @@ export async function useListKeys(forceRefresh) { } export async function useUpdateValidatorStats() { + console.log("test"); const nodeManageStore = useNodeManage(); const stakingStore = useStakingStore(); let totalBalance = 0; @@ -119,18 +119,19 @@ export async function useUpdateValidatorStats() { }); var latestEpoch = latestEpochResponse.data.data.epoch; let buffer = stakingStore.keys.map((key) => key.key); + if (stakingStore.keys.length <= 100) { + const chunkSize = 50; + for (let i = 0; i < buffer.length; i += chunkSize) { + //split validator accounts into chunks of 50 (api url limit) + const chunk = buffer.slice(i, i + chunkSize); + let response = await axios.get(nodeManageStore.currentNetwork.dataEndpoint + "/validator/" + encodeURIComponent(chunk.join()), { + validateStatus: function (status) { + return status < 500; + }, + }); - const chunkSize = 50; - for (let i = 0; i < buffer.length; i += chunkSize) { - //split validator accounts into chunks of 50 (api url limit) - const chunk = buffer.slice(i, i + chunkSize); - let response = await axios.get(nodeManageStore.currentNetwork.dataEndpoint + "/validator/" + encodeURIComponent(chunk.join()), { - validateStatus: function (status) { - return status < 500; - }, - }); - - if (response.data.data) data = data.concat(response.data.data); //merge all gathered stats in one array + if (response.data.data) data = data.concat(response.data.data); //merge all gathered stats in one array + } } } } catch (err) { diff --git a/launcher/src/store/nodeManage.js b/launcher/src/store/nodeManage.js index 6db4c692c..f0c259005 100755 --- a/launcher/src/store/nodeManage.js +++ b/launcher/src/store/nodeManage.js @@ -195,7 +195,7 @@ export const useNodeManage = defineStore("nodeManage", { icon: "/img/icon/network-icons/ethereum-mainnet.png", currencyIcon: "/img/icon/control-page-icons/mainnet-currency-symbol.png", dataEndpoint: "https://mainnet.beaconcha.in/api/v1", - support: ["staking", "mev boost", "stereum on arm", "ssv.network", "obol", "archive", "lidoobol", "lidossv"], + support: ["staking", "mev boost", "stereum on arm", "ssv.network", "obol", "archive", "lidoobol", "lidossv", "lidocsm"], }, {