Skip to content

Commit

Permalink
Migrate to horcrux v3
Browse files Browse the repository at this point in the history
Signed-off-by: Dylan Schultz <[email protected]>
  • Loading branch information
dylanschultzie committed Aug 10, 2023
1 parent ecfdca0 commit c9b2116
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion roles/horcrux_configure/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ thresholdMode:
threshold: {{ threshold }}
cosigners:
{% for peer in horcrux_peers %}
- shardId: {{ peer.share_id }}
- shardID: {{ peer.share_id }}
p2pAddr: tcp://{{ peer.p2p_addr }}:2{{ signer_port }}
{% endfor %}
grpcTimeout: {{ rpc_timeout }}
Expand Down
33 changes: 3 additions & 30 deletions roles/horcrux_create_shares/tasks/create_multi_share.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
- name: Generate and move keys
block:
- name: Generate ECIES shards
- name: Generate key shards
become: false
delegate_to: localhost
run_once: true
shell: |
Expand All @@ -12,35 +13,7 @@
- "../hostbin/horcrux create-ed25519-shards --chain-id {{ chain_id }} --key-file ./priv_validator_key.json --threshold {{ threshold }} --shards {{ shares }}"

- name: Move keys to remote host
block:
- name: Find local key share
delegate_to: localhost
become: false
stat:
path: "{{ playbook_dir }}/keys/cosigner_{{ my_share}}/{{ item }}"
register: has_share

- name: Copy keys
copy:
src: "keys/cosigner_{{ my_share}}/{{ item }}"
dest: "{{ horcrux_dir }}/{{ item }}"
owner: "{{ horcrux_user }}"
group: "{{ horcrux_user }}"
mode: '0400'
when: has_share.stat.isreg is defined and has_share.stat.isreg

- name: Find remote key share
stat:
path: "{{ horcrux_dir }}/{{ item }}"
register: share_moved

- name: Delete local share
become: false
delegate_to: localhost
file:
path: "{{ playbook_dir }}/keys/cosigner_{{ my_share}}/{{ item }}"
state: absent
when: share_moved.stat.exists
include_tasks: move_multi_share.yml
loop:
- "{{ chain_id }}_shard.json"
- "ecies_keys.json"
Expand Down
29 changes: 29 additions & 0 deletions roles/horcrux_create_shares/tasks/move_multi_share.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Find local key share
delegate_to: localhost
become: false
stat:
path: "{{ playbook_dir }}/keys/cosigner_{{ my_share}}/{{ item }}"
register: has_share

- name: Copy key to remote host
copy:
src: "keys/cosigner_{{ my_share}}/{{ item }}"
dest: "{{ horcrux_dir }}/{{ item }}"
owner: "{{ horcrux_user }}"
group: "{{ horcrux_user }}"
mode: '0400'
when: has_share.stat.isreg is defined and has_share.stat.isreg

- name: Verify remote key share
stat:
path: "{{ horcrux_dir }}/{{ item }}"
register: share_moved

- name: Delete local share
become: false
delegate_to: localhost
file:
path: "{{ playbook_dir }}/keys/cosigner_{{ my_share }}/{{ item }}"
state: absent
when: share_moved.stat.exists
2 changes: 1 addition & 1 deletion roles/horcrux_install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
update: yes
register: horcrux

- name: Setup horcrux
- name: Install horcrux
when: horcrux.changed
block:
- name: Install horcrux
Expand Down

0 comments on commit c9b2116

Please sign in to comment.