Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: Prysm Update Scripts #1947

Merged
merged 6 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions controls/roles/update-changes/molecule/221/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,48 @@
otherServices: []
become: yes

- name: Create Prysm config
copy:
dest: "/etc/stereum/services/192ffe7a-dd48-3ff1-b221-6a5fe3765e3c.yaml"
owner: "root"
group: "root"
mode: 0644
content: |
service: PrysmValidatorService
id: 192ffe7a-dd48-3ff1-b221-6a5fe3765e3c
configVersion: 1
command: /app/cmd/validator/validator --accept-terms-of-use=true
--beacon-rpc-provider="stereum-e021e341-d3cc-003a-7ba4-8d062ea218e4:4000"
--beacon-rpc-gateway-provider="stereum-e021e341-d3cc-003a-7ba4-8d062ea218e4:3500"
--web --holesky=true --datadir=/opt/app/data/db
--wallet-dir=/opt/app/data/wallets
--wallet-password-file=/opt/app/data/passwords/wallet-password
--monitoring-host=0.0.0.0 --grpc-gateway-port=7500 --grpc-gateway-host=0.0.0.0
--grpc-gateway-corsdomain="*" --monitoring-host=0.0.0.0
--monitoring-port=8081
--suggested-fee-recipient=0x0000000000000000000000000000000000000000
--graffiti-file=/opt/app/graffitis/graffitis.yaml --enable-builder=true
--enable-doppelganger=true
entrypoint: []
env: {}
image: prysmaticlabs/prysm-validator:v5.0.4
ports:
- 127.0.0.1:7500:7500/tcp
volumes:
- /opt/stereum/prysm-192ffe7a-dd48-3ff1-b221-6a5fe3765e3c/data/db:/opt/app/data/db
- /opt/stereum/prysm-192ffe7a-dd48-3ff1-b221-6a5fe3765e3c/data/wallets:/opt/app/data/wallets
- /opt/stereum/prysm-192ffe7a-dd48-3ff1-b221-6a5fe3765e3c/data/passwords:/opt/app/data/passwords
- /opt/stereum/prysm-192ffe7a-dd48-3ff1-b221-6a5fe3765e3c/graffitis:/opt/app/graffitis
user: "2000"
autoupdate: true
network: holesky
dependencies:
executionClients: []
consensusClients:
- service: PrysmBeaconService
id: e021e341-d3cc-003a-7ba4-8d062ea218e4
mevboost: []
otherServices: []


#EOF
13 changes: 13 additions & 0 deletions controls/roles/update-changes/molecule/221/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,31 @@
src: "/etc/stereum/services/9bf280d1-72ae-d8f3-f4da-3684727e06a0.yaml"
register: Besu_service_configuration_raw

# Prysm
- name: Read Prysm file
slurp:
src: "/etc/stereum/services/192ffe7a-dd48-3ff1-b221-6a5fe3765e3c.yaml"
register: Prysm_service_configuration_raw

- name: Parse Service configurations
set_fact:
Besu_service_configuration: "{{ Besu_service_configuration_raw['content'] | b64decode | from_yaml }}"
Prysm_service_configuration: "{{ Prysm_service_configuration_raw['content'] | b64decode | from_yaml }}"

- debug:
msg: "{{ Besu_service_configuration }}"
- debug:
msg: "{{ Besu_service_configuration_raw['content'] | b64decode }}"

- debug:
msg: "{{ Prysm_service_configuration }}"
- debug:
msg: "{{ Prysm_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
- "'--keymanager-token-file=/opt/app/data/wallets/auth-token' in Prysm_service_configuration.command"
# EOF
37 changes: 37 additions & 0 deletions controls/roles/update-changes/tasks/2.2.1/prysm_changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- 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 }}"

- name: set new config
ansible.utils.update_fact:
updates:
- path: service_configuration.command
value: "{{ service_configuration.command + ' --keymanager-token-file=/opt/app/data/wallets/auth-token' }}"
register: updated
when:
- service_configuration.service == "PrysmValidatorService"
- "'--keymanager-token-file=/opt/app/data/wallets/auth-token' not in service_configuration.command"

- name: update config
set_fact:
service_configuration: "{{ updated.service_configuration }}"
when:
- service_configuration.service == "PrysmValidatorService"
- "'--keymanager-token-file=/opt/app/data/wallets/auth-token' not in service_configuration.command"

- name: Write Config
copy:
dest: "{{ config_file.path }}"
content: "{{ service_configuration | to_nice_yaml(indent=2) }}"
owner: "root"
group: "root"
mode: 0644
when:
- service_configuration.service == "PrysmValidatorService"
- updated.changed
6 changes: 6 additions & 0 deletions controls/roles/update-changes/tasks/2.2.1/updates-221.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
- name: Include Besu Changes
include_tasks: besu_changes.yaml
loop: "{{ service_config_files.files }}"
loop_control:
loop_var: config_file

- name: Include Prysm Changes
include_tasks: prysm_changes.yaml
loop: "{{ service_config_files.files }}"
loop_control:
loop_var: config_file
10 changes: 6 additions & 4 deletions launcher/src/backend/ValidatorAccountManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export class ValidatorAccountManager {
.volumes.find((volume) => volume.includes("passwords"))
.split(":")[0];

if ((await this.nodeConnection.sshService.exec(`cat ${passwords_path}/wallet-password`)).rc === 1) {
const walletPassword = await this.nodeConnection.sshService.exec(`cat ${passwords_path}/wallet-password`)
const walletDir = await this.nodeConnection.sshService.exec(`ls ${wallet_path}/direct/accounts`)

if (walletPassword.rc != 0 || walletDir.rc != 0) {
log.error("No Wallet found");
log.info("Generating one");
this.nodeConnection.taskManager.otherTasksHandler(
Expand All @@ -115,7 +118,7 @@ export class ValidatorAccountManager {
await this.nodeConnection.sshService.exec(`chown 2000:2000 ${passwords_path}/wallet-password`);
//Prysm - Create wallet for account(s)
await this.nodeConnection.sshService.exec(
`docker exec stereum-${client.id} /app/cmd/validator/validator wallet create --wallet-dir=/opt/app/data/wallets --wallet-password-file=/opt/app/data/passwords/wallet-password --accept-terms-of-use --keymanager-kind=direct --prater`
`docker exec stereum-${client.id} /app/cmd/validator/validator wallet create --wallet-dir=/opt/app/data/wallets --wallet-password-file=/opt/app/data/passwords/wallet-password --accept-terms-of-use --keymanager-kind=direct --${client.network}`
);

await this.nodeConnection.sshService.exec(`chown -R 2000:2000 ${wallet_path}`);
Expand Down Expand Up @@ -324,8 +327,7 @@ export class ValidatorAccountManager {
const curlTag = await this.nodeConnection.ensureCurlImage();
let command = [
"docker run --rm --network=stereum curlimages/curl:" + curlTag,
`curl ${service.service.includes("Teku") ? "--insecure https" : "http"}://stereum-${service.id}:${
validatorPorts[service.service]
`curl ${service.service.includes("Teku") ? "--insecure https" : "http"}://stereum-${service.id}:${validatorPorts[service.service]
}${apiPath}`,
`-X ${method.toUpperCase()}`,
`-H 'Content-Type: application/json'`,
Expand Down