diff --git a/controls/roles/validator-fee-recipient-api/tasks/main.yml b/controls/roles/validator-fee-recipient-api/tasks/main.yml index cbb9ee31b..cdab9f799 100644 --- a/controls/roles/validator-fee-recipient-api/tasks/main.yml +++ b/controls/roles/validator-fee-recipient-api/tasks/main.yml @@ -16,47 +16,47 @@ ######## # fee recipient -# - block: -# - name: Prysm - Get validator service's api token -# slurp: -# src: "{{ stereum_service_configuration.volumes | select('match', '.*\/opt\/app\/data\/wallets') | first | split(':') | first }}/auth-token" -# register: stereum_service_configuration_raw -# become: yes -# - include_tasks: fee_recipient.yaml -# vars: -# validator_port: 7500 -# api_token: "{{ (stereum_service_configuration_raw.content | b64decode).splitlines() | last }}" -# loop: "{{ validator_keys }}" -# when: stereum_service_configuration.service == "PrysmValidatorService" +- block: + - name: Prysm - Get validator service's api token + slurp: + src: "{{ stereum_service_configuration.volumes | select('match', '.*\/opt\/app\/data\/wallets') | first | split(':') | first }}/auth-token" + register: stereum_service_configuration_raw + become: yes + - include_tasks: fee_recipient.yaml + vars: + validator_port: 7500 + api_token: "{{ (stereum_service_configuration_raw.content | b64decode).splitlines() | last }}" + loop: "{{ validator_keys }}" + when: stereum_service_configuration.service == "PrysmValidatorService" -# - block: -# - name: Lighthouse - Get validator service's api token -# command: "docker exec -u 0 -w /opt/app/validator/validators stereum-{{ validator_service }} cat api-token.txt" -# changed_when: false -# register: api_token_lh -# become: yes -# - name: print token -# debug: -# msg: "{{ api_token_lh.stdout }}" -# - include_tasks: fee_recipient.yaml -# vars: -# validator_port: 5062 -# api_token: "{{ api_token_lh.stdout }}" -# loop: "{{ validator_keys }}" -# when: stereum_service_configuration.service == "LighthouseValidatorService" +- block: + - name: Lighthouse - Get validator service's api token + command: "docker exec -u 0 -w /opt/app/validator/validators stereum-{{ validator_service }} cat api-token.txt" + changed_when: false + register: api_token_lh + become: yes + - name: print token + debug: + msg: "{{ api_token_lh.stdout }}" + - include_tasks: fee_recipient.yaml + vars: + validator_port: 5062 + api_token: "{{ api_token_lh.stdout }}" + loop: "{{ validator_keys }}" + when: stereum_service_configuration.service == "LighthouseValidatorService" -# - block: -# - name: Nimbus - Get validator service's api token -# command: "docker exec -u 0 -w /opt/app/validators stereum-{{ validator_service }} cat api-token.txt" -# changed_when: false -# register: api_token_n -# become: yes -# - include_tasks: fee_recipient.yaml -# vars: -# validator_port: 5052 -# api_token: "{{ api_token_n.stdout }}" -# loop: "{{ validator_keys }}" -# when: stereum_service_configuration.service == "NimbusBeaconService" +- block: + - name: Nimbus - Get validator service's api token + command: "docker exec -u 0 -w /opt/app/validators stereum-{{ validator_service }} cat api-token.txt" + changed_when: false + register: api_token_n + become: yes + - include_tasks: fee_recipient.yaml + vars: + validator_port: 5052 + api_token: "{{ api_token_n.stdout }}" + loop: "{{ validator_keys }}" + when: stereum_service_configuration.service == "NimbusBeaconService" - block: - name: Teku - Get validator service's api token diff --git a/launcher/src/backend/ValidatorAccountManager.js b/launcher/src/backend/ValidatorAccountManager.js index 6c9426f78..019120e0f 100644 --- a/launcher/src/backend/ValidatorAccountManager.js +++ b/launcher/src/backend/ValidatorAccountManager.js @@ -180,6 +180,29 @@ export class ValidatorAccountManager { }) } + + async addFeeRecipient(keys, address){ + if(keys && keys.length != 0 && address){ + const serviceID = keys[0].validatorID + const validatorKeys = keys.map(key => { + return { + pubkey: key.key, + recipient: address + } + }) + + try { + let run = await this.nodeConnection.runPlaybook('validator-fee-recipient-api', { stereum_role: 'validator-fee-recipient-api', validator_service: serviceID, validator_keys: validatorKeys }) + //let logs = new RegExp(/^DATA: ({"msg":.*)/, 'gm').exec(await this.nodeConnection.playbookStatus(run.playbookRunRef)) + //let result = (JSON.parse(logs[1])).msg + return run + } catch (err) { + log.error("Changing Fee Recipient Failed:\n", err) + return err + } + } + return 0 + } async getOperatorPageURL(pubKey){ const hash = crypto.createHash('sha256').update(pubKey).digest('hex') diff --git a/launcher/src/background.js b/launcher/src/background.js index ced167ebd..249251bc5 100644 --- a/launcher/src/background.js +++ b/launcher/src/background.js @@ -274,6 +274,11 @@ promiseIpc.on("refreshServiceInfos", async () => { return await monitoring.refreshServiceInfos(); }); + +promiseIpc.on("addFeeRecipient", async (args) => { + return await validatorAccountManager.addFeeRecipient(args.keys, args.address) +}) + promiseIpc.on("getOperatorPageURL", async (args) => { return await validatorAccountManager.getOperatorPageURL(args); }); diff --git a/launcher/src/store/ControlService.js b/launcher/src/store/ControlService.js index 5c2c6c9fd..fc8ef4576 100644 --- a/launcher/src/store/ControlService.js +++ b/launcher/src/store/ControlService.js @@ -202,6 +202,10 @@ class ControlService extends EventEmitter { return await this.promiseIpc.send("refreshServiceInfos"); // insert existing operator keys } + async addFeeRecipient(args){ + return await this.promiseIpc.send("addFeeRecipient", args) // + } + async getOperatorPageURL(args) { return await this.promiseIpc.send("getOperatorPageURL", args); // insert existing operator keys }