From ac4187fc2e7c4a3d95a636774c35ac55fe07925f Mon Sep 17 00:00:00 2001 From: NeoPlays <80448387+NeoPlays@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:47:50 +0200 Subject: [PATCH] ADD: Besu Update Changes (#1939) * ADD: Besu Update Changes * ADD: logging for debuging * FIX: Replace loop * ADD: logging * FIX: File not Found * FIX: Jest Test --- .github/workflows/test-molecule.yml | 1 + .../molecule/besu-lighthouse/converge.yml | 2 +- .../molecule/besu-lodestar/converge.yml | 2 +- .../molecule/besu-nimbus/converge.yml | 2 +- .../molecule/besu-prysm/converge.yml | 2 +- .../molecule/besu-teku/converge.yml | 2 +- .../mevboost-besu-lighthouse/converge.yml | 2 +- .../mevboost-besu-nimbus/converge.yml | 2 +- .../molecule/mevboost-besu-prysm/converge.yml | 2 +- .../molecule/mevboost-besu-teku/converge.yml | 2 +- .../molecule/monitor-besu/prepare.yml | 2 +- .../update-changes/molecule/221/converge.yml | 10 +++ .../update-changes/molecule/221/molecule.yml | 27 +++++++ .../update-changes/molecule/221/playbook.yml | 7 ++ .../update-changes/molecule/221/prepare.yml | 72 +++++++++++++++++++ .../update-changes/molecule/221/verify.yml | 26 +++++++ .../tasks/2.2.1/besu_changes.yaml | 22 ++++++ .../tasks/2.2.1/updates-221.yaml | 11 +++ controls/roles/update-changes/tasks/main.yml | 4 ++ launcher/src/backend/OneClickInstall.js | 2 +- .../backend/ethereum-services/BesuService.js | 2 +- .../backend/tests/unit/BesuService.test.js | 2 +- launcher/src/store/services.js | 11 +-- 23 files changed, 194 insertions(+), 23 deletions(-) create mode 100644 controls/roles/update-changes/molecule/221/converge.yml create mode 100644 controls/roles/update-changes/molecule/221/molecule.yml create mode 100644 controls/roles/update-changes/molecule/221/playbook.yml create mode 100644 controls/roles/update-changes/molecule/221/prepare.yml create mode 100644 controls/roles/update-changes/molecule/221/verify.yml create mode 100644 controls/roles/update-changes/tasks/2.2.1/besu_changes.yaml create mode 100644 controls/roles/update-changes/tasks/2.2.1/updates-221.yaml diff --git a/.github/workflows/test-molecule.yml b/.github/workflows/test-molecule.yml index 46942b81b..f48acd638 100644 --- a/.github/workflows/test-molecule.yml +++ b/.github/workflows/test-molecule.yml @@ -69,6 +69,7 @@ jobs: tests: [ { role: "update-changes", test: "215" }, + { role: "update-changes", test: "221" }, ] fail-fast: false concurrency: molecule-test-${{ matrix.tests.role }}-${{ matrix.tests.test }} diff --git a/controls/roles/manage-service/molecule/besu-lighthouse/converge.yml b/controls/roles/manage-service/molecule/besu-lighthouse/converge.yml index f966d6f78..afcf1fa8e 100644 --- a/controls/roles/manage-service/molecule/besu-lighthouse/converge.yml +++ b/controls/roles/manage-service/molecule/besu-lighthouse/converge.yml @@ -34,7 +34,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --p2p-port=30303 - --p2p-host=0.0.0.0 - --rpc-http-enabled=true diff --git a/controls/roles/manage-service/molecule/besu-lodestar/converge.yml b/controls/roles/manage-service/molecule/besu-lodestar/converge.yml index 0d703bdab..bfea405fa 100644 --- a/controls/roles/manage-service/molecule/besu-lodestar/converge.yml +++ b/controls/roles/manage-service/molecule/besu-lodestar/converge.yml @@ -35,7 +35,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --host-allowlist=* - --rpc-http-enabled=true - --rpc-http-host=0.0.0.0 diff --git a/controls/roles/manage-service/molecule/besu-nimbus/converge.yml b/controls/roles/manage-service/molecule/besu-nimbus/converge.yml index 76e6a8b91..9054d698b 100644 --- a/controls/roles/manage-service/molecule/besu-nimbus/converge.yml +++ b/controls/roles/manage-service/molecule/besu-nimbus/converge.yml @@ -34,7 +34,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --p2p-port=30303 - --p2p-host=0.0.0.0 - --rpc-http-enabled=true diff --git a/controls/roles/manage-service/molecule/besu-prysm/converge.yml b/controls/roles/manage-service/molecule/besu-prysm/converge.yml index bff997f9a..6e3de7e16 100644 --- a/controls/roles/manage-service/molecule/besu-prysm/converge.yml +++ b/controls/roles/manage-service/molecule/besu-prysm/converge.yml @@ -34,7 +34,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --p2p-port=30303 - --p2p-host=0.0.0.0 - --rpc-http-enabled=true diff --git a/controls/roles/manage-service/molecule/besu-teku/converge.yml b/controls/roles/manage-service/molecule/besu-teku/converge.yml index 99d9a47b1..b6bb955af 100644 --- a/controls/roles/manage-service/molecule/besu-teku/converge.yml +++ b/controls/roles/manage-service/molecule/besu-teku/converge.yml @@ -34,7 +34,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --p2p-port=30303 - --p2p-host=0.0.0.0 - --rpc-http-enabled=true diff --git a/controls/roles/manage-service/molecule/mevboost-besu-lighthouse/converge.yml b/controls/roles/manage-service/molecule/mevboost-besu-lighthouse/converge.yml index 5fc43129e..6238fbcbf 100644 --- a/controls/roles/manage-service/molecule/mevboost-besu-lighthouse/converge.yml +++ b/controls/roles/manage-service/molecule/mevboost-besu-lighthouse/converge.yml @@ -36,7 +36,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --host-allowlist=* - --rpc-http-enabled=true - --rpc-http-host=0.0.0.0 diff --git a/controls/roles/manage-service/molecule/mevboost-besu-nimbus/converge.yml b/controls/roles/manage-service/molecule/mevboost-besu-nimbus/converge.yml index 046b20617..7eeddeac8 100644 --- a/controls/roles/manage-service/molecule/mevboost-besu-nimbus/converge.yml +++ b/controls/roles/manage-service/molecule/mevboost-besu-nimbus/converge.yml @@ -35,7 +35,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --host-allowlist=* - --rpc-http-enabled=true - --rpc-http-host=0.0.0.0 diff --git a/controls/roles/manage-service/molecule/mevboost-besu-prysm/converge.yml b/controls/roles/manage-service/molecule/mevboost-besu-prysm/converge.yml index fd668035e..b2b0479f5 100644 --- a/controls/roles/manage-service/molecule/mevboost-besu-prysm/converge.yml +++ b/controls/roles/manage-service/molecule/mevboost-besu-prysm/converge.yml @@ -36,7 +36,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --host-allowlist=* - --rpc-http-enabled=true - --rpc-http-host=0.0.0.0 diff --git a/controls/roles/manage-service/molecule/mevboost-besu-teku/converge.yml b/controls/roles/manage-service/molecule/mevboost-besu-teku/converge.yml index 43b9b3452..265ac8b6d 100644 --- a/controls/roles/manage-service/molecule/mevboost-besu-teku/converge.yml +++ b/controls/roles/manage-service/molecule/mevboost-besu-teku/converge.yml @@ -35,7 +35,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --host-allowlist=* - --rpc-http-enabled=true - --rpc-http-host=0.0.0.0 diff --git a/controls/roles/manage-service/molecule/monitor-besu/prepare.yml b/controls/roles/manage-service/molecule/monitor-besu/prepare.yml index 94e475624..15f14e5f5 100644 --- a/controls/roles/manage-service/molecule/monitor-besu/prepare.yml +++ b/controls/roles/manage-service/molecule/monitor-besu/prepare.yml @@ -56,7 +56,7 @@ - --network=goerli - --data-path=/opt/app/data - --data-storage-format=BONSAI - - --sync-mode=X_SNAP + - --sync-mode=SNAP - --p2p-port=30303 - --p2p-host=0.0.0.0 - --rpc-http-enabled diff --git a/controls/roles/update-changes/molecule/221/converge.yml b/controls/roles/update-changes/molecule/221/converge.yml new file mode 100644 index 000000000..3f84cb4a2 --- /dev/null +++ b/controls/roles/update-changes/molecule/221/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/221/molecule.yml b/controls/roles/update-changes/molecule/221/molecule.yml new file mode 100644 index 000000000..10f644927 --- /dev/null +++ b/controls/roles/update-changes/molecule/221/molecule.yml @@ -0,0 +1,27 @@ +--- +#dependency: +# name: galaxy +driver: + name: docker +platforms: + - name: "update-changes--2.2.1--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/221/playbook.yml b/controls/roles/update-changes/molecule/221/playbook.yml new file mode 100644 index 000000000..710c596cf --- /dev/null +++ b/controls/roles/update-changes/molecule/221/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/221/prepare.yml b/controls/roles/update-changes/molecule/221/prepare.yml new file mode 100644 index 000000000..3d85f3858 --- /dev/null +++ b/controls/roles/update-changes/molecule/221/prepare.yml @@ -0,0 +1,72 @@ +--- +- 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 Besu config + copy: + dest: "/etc/stereum/services/9bf280d1-72ae-d8f3-f4da-3684727e06a0.yaml" + owner: "root" + group: "root" + mode: 0644 + content: | + service: BesuService + id: 9bf280d1-72ae-d8f3-f4da-3684727e06a0 + configVersion: 1 + command: + - --network=holesky + - --data-path=/opt/app/data + - --data-storage-format=BONSAI + - --sync-mode=SNAP + - --p2p-port=30303 + - --p2p-host=0.0.0.0 + - --rpc-http-enabled=true + - --rpc-http-host=0.0.0.0 + - --rpc-http-cors-origins=* + - --rpc-http-port=8545 + - --rpc-ws-enabled=true + - --rpc-ws-host=0.0.0.0 + - --rpc-ws-port=8546 + - --host-allowlist=* + - --metrics-enabled + - --metrics-host=0.0.0.0 + - --metrics-port=9545 + - --logging=INFO + - --engine-host-allowlist=* + - --engine-rpc-port=8551 + - --engine-jwt-secret=/engine.jwt + - --pruning-enabled=false + - --pruning-blocks-retained=0 + - --pruning-block-confirmations=0 + entrypoint: + - besu + env: + JAVA_OPTS: -Xmx4g + image: hyperledger/besu:24.3.3 + ports: + - 0.0.0.0:30303:30303/tcp + - 0.0.0.0:30303:30303/udp + - 127.0.0.1:8545:8545/tcp + - 127.0.0.1:8546:8546/tcp + volumes: + - /opt/stereum/besu-9bf280d1-72ae-d8f3-f4da-3684727e06a0/data:/opt/app/data + - /opt/stereum/besu-9bf280d1-72ae-d8f3-f4da-3684727e06a0/engine.jwt:/engine.jwt + user: "2000" + autoupdate: true + network: holesky + dependencies: + executionClients: [] + consensusClients: [] + mevboost: [] + otherServices: [] + become: yes + +#EOF \ No newline at end of file diff --git a/controls/roles/update-changes/molecule/221/verify.yml b/controls/roles/update-changes/molecule/221/verify.yml new file mode 100644 index 000000000..036ec1e15 --- /dev/null +++ b/controls/roles/update-changes/molecule/221/verify.yml @@ -0,0 +1,26 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + # Besu + - name: Read Besu file + slurp: + src: "/etc/stereum/services/9bf280d1-72ae-d8f3-f4da-3684727e06a0.yaml" + register: Besu_service_configuration_raw + + - name: Parse Service configurations + set_fact: + Besu_service_configuration: "{{ Besu_service_configuration_raw['content'] | b64decode | from_yaml }}" + + - debug: + msg: "{{ Besu_service_configuration }}" + - debug: + msg: "{{ Besu_service_configuration_raw['content'] | b64decode }}" + + - assert: + that: + - Besu_service_configuration.command | select('match', '--pruning-enabled=false') | length == 0 + - Besu_service_configuration.command | select('match', '--pruning-blocks-retained=0') | length == 0 + - Besu_service_configuration.command | select('match', '--pruning-block-confirmations=0') | length == 0 +# EOF diff --git a/controls/roles/update-changes/tasks/2.2.1/besu_changes.yaml b/controls/roles/update-changes/tasks/2.2.1/besu_changes.yaml new file mode 100644 index 000000000..9f0a8db81 --- /dev/null +++ b/controls/roles/update-changes/tasks/2.2.1/besu_changes.yaml @@ -0,0 +1,22 @@ +--- +- 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: Remove tags from Besu Config + lineinfile: + path: "{{ config_file.path }}" + regexp: "{{ item }}" + state: absent + loop: + - pruning-enabled + - pruning-blocks-retained + - pruning-block-confirmations + when: + - service_configuration.service == "BesuService" \ No newline at end of file diff --git a/controls/roles/update-changes/tasks/2.2.1/updates-221.yaml b/controls/roles/update-changes/tasks/2.2.1/updates-221.yaml new file mode 100644 index 000000000..f4c0a65ba --- /dev/null +++ b/controls/roles/update-changes/tasks/2.2.1/updates-221.yaml @@ -0,0 +1,11 @@ +--- +- name: Find service configs + find: + paths: "/etc/stereum/services" + register: service_config_files + +- name: Include Besu Changes + include_tasks: besu_changes.yaml + loop: "{{ service_config_files.files }}" + loop_control: + loop_var: config_file \ No newline at end of file diff --git a/controls/roles/update-changes/tasks/main.yml b/controls/roles/update-changes/tasks/main.yml index 6c1610374..3bb605dba 100644 --- a/controls/roles/update-changes/tasks/main.yml +++ b/controls/roles/update-changes/tasks/main.yml @@ -1,4 +1,8 @@ - name: Include 2.1.5 Update Scripts include_tasks: "2.1.5/updates-215.yaml" ignore_errors: yes + +- name: Include 2.2.1 Update Scripts + include_tasks: "2.2.1/updates-221.yaml" + ignore_errors: yes # EOF diff --git a/launcher/src/backend/OneClickInstall.js b/launcher/src/backend/OneClickInstall.js index 449c9b0de..96c2eca47 100755 --- a/launcher/src/backend/OneClickInstall.js +++ b/launcher/src/backend/OneClickInstall.js @@ -361,7 +361,7 @@ export class OneClickInstall { break; case "BesuService": this.executionClient.command[ - this.executionClient.command.findIndex((c) => c.includes("--sync-mode=X_SNAP")) + this.executionClient.command.findIndex((c) => c.includes("--sync-mode=SNAP")) ] = "--sync-mode=FULL"; break; case "NethermindService": diff --git a/launcher/src/backend/ethereum-services/BesuService.js b/launcher/src/backend/ethereum-services/BesuService.js index d0580aa2a..64d6333f6 100755 --- a/launcher/src/backend/ethereum-services/BesuService.js +++ b/launcher/src/backend/ethereum-services/BesuService.js @@ -43,7 +43,7 @@ export class BesuService extends NodeService { "--engine-jwt-secret=/engine.jwt", ], // command ["besu"], // entrypoint - { JAVA_OPTS: "-Xmx4g" }, // env + { JAVA_OPTS: "-Xmx6g" }, // env ports, // ports volumes, // volumes null, // user diff --git a/launcher/src/backend/tests/unit/BesuService.test.js b/launcher/src/backend/tests/unit/BesuService.test.js index 3704edca4..0b44540c9 100755 --- a/launcher/src/backend/tests/unit/BesuService.test.js +++ b/launcher/src/backend/tests/unit/BesuService.test.js @@ -13,7 +13,7 @@ test("buildByUserInput", () => { expect(besuService.command).toContain("--network=goerli"); expect(besuService.command).toContain("--data-path=/opt/app/data"); expect(besuService.entrypoint).toContain("besu"); - expect(besuService.env).toHaveProperty("JAVA_OPTS", "-Xmx4g"); + expect(besuService.env).toHaveProperty("JAVA_OPTS", "-Xmx6g"); expect(besuService.ports).toHaveLength(1); expect(besuService.ports).toContain("0.0.0.0:4040:4040/tcp"); expect(besuService.volumes).toContain("/opt/stereum/besu-" + besuService.id + "/data:/opt/app/data"); diff --git a/launcher/src/store/services.js b/launcher/src/store/services.js index 20ac9f7fe..fb4423534 100755 --- a/launcher/src/store/services.js +++ b/launcher/src/store/services.js @@ -645,16 +645,7 @@ export const useServices = defineStore("services", { sIcon: require("../../public/img/icon/service-icons/execution/HyperLedger-besu-s.png"), headerOption: false, expertOptionsModal: false, - expertOptions: [ - { - title: "Auto Pruning", - type: "toggle", - changeValue: true, - icon: "/img/icon/service-setting-icons/prunning.png", - pattern: ["(- --pruning-enabled=)(.*)(\\n)"], - commands: ["--pruning-enabled"], - }, - ], + expertOptions: [], drag: true, state: "exited", config: {