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: Fee Recipient via API #622

Merged
merged 5 commits into from
Sep 1, 2022
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
78 changes: 39 additions & 39 deletions controls/roles/validator-fee-recipient-api/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions launcher/src/backend/ValidatorAccountManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 5 additions & 0 deletions launcher/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
4 changes: 4 additions & 0 deletions launcher/src/store/ControlService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down