Skip to content

Commit

Permalink
ADD: Besu Update Changes (#1939)
Browse files Browse the repository at this point in the history
* ADD: Besu Update Changes

* ADD: logging for debuging

* FIX: Replace loop

* ADD: logging

* FIX: File not Found

* FIX: Jest Test
  • Loading branch information
NeoPlays authored Jul 10, 2024
1 parent 23a9ca3 commit ac4187f
Show file tree
Hide file tree
Showing 23 changed files with 194 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions controls/roles/update-changes/molecule/221/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Converge
hosts: all
vars_files:
- ../../../../defaults/stereum_defaults.yaml

tasks:
- name: "Include update-changes"
include_role:
name: "update-changes"
27 changes: 27 additions & 0 deletions controls/roles/update-changes/molecule/221/molecule.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions controls/roles/update-changes/molecule/221/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include update-changes"
include_role:
name: "update-changes"
72 changes: 72 additions & 0 deletions controls/roles/update-changes/molecule/221/prepare.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions controls/roles/update-changes/molecule/221/verify.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions controls/roles/update-changes/tasks/2.2.1/besu_changes.yaml
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 11 additions & 0 deletions controls/roles/update-changes/tasks/2.2.1/updates-221.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions controls/roles/update-changes/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion launcher/src/backend/OneClickInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion launcher/src/backend/ethereum-services/BesuService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion launcher/src/backend/tests/unit/BesuService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
11 changes: 1 addition & 10 deletions launcher/src/store/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit ac4187f

Please sign in to comment.