-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.yml
More file actions
247 lines (228 loc) · 9.69 KB
/
deploy.yml
File metadata and controls
247 lines (228 loc) · 9.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
---
- name: Deploy GenLayer Validator Node with LLM Config Update and Systemd Service
hosts: all
become: yes
vars:
genlayer_version: "v0.3.10"
node_password: "your_secret_password" # Set your validator account password here
backup_passphrase: "your_backup_encryption_passphrase" # Set your backup encryption passphrase here
backup_path: "/tmp/genlayer-validator-backup.key" # Path to store validator key backup
node_bin_url: "https://storage.googleapis.com/gh-af/genlayer-node/bin/amd64/{{ genlayer_version }}/genlayer-node-linux-amd64-{{ genlayer_version }}.tar.gz"
node_bin_tar: "/tmp/genlayer-node-linux-amd64-{{ genlayer_version }}.tar.gz"
node_bin_dir: "/opt/genlayer"
config_dir: "{{ node_bin_dir }}/configs/node"
data_dir: "{{ node_bin_dir }}/data/node"
# GenLayer chain URLs
zksync_rpc_url: ""
zksync_ws_url: ""
# LLM API keys, set to empty string if not used
heurist_key: ""
comput3_key: ""
ionet_key: ""
libertai_key: ""
openai_key: ""
anthropic_key: ""
xai_key: ""
google_key: ""
atoma_key: ""
tasks:
- name: Install OS dependencies
apt:
name:
- curl
- docker.io
- docker-compose
state: present
update_cache: yes
- name: Create GenLayer node directory
file:
path: "{{ node_bin_dir }}"
state: directory
mode: 0755
- name: Download GenLayer node tarball
get_url:
url: "{{ node_bin_url }}"
dest: "{{ node_bin_tar }}"
- name: Extract node tarball
unarchive:
src: "{{ node_bin_tar }}"
dest: "{{ node_bin_dir }}"
remote_src: yes
extra_opts: ['--strip-components=1', '--show-stored-names']
- name: Create config.yaml
copy:
dest: "{{ config_dir }}/config.yaml"
content: |
rollup:
zksyncurl: "{{ zksync_rpc_url }}"
zksyncwebsocketurl: "{{ zksync_ws_url }}"
consensus:
contractmainaddress: "0xe30293d600fF9B2C865d91307826F28006A458f4"
contractdataaddress: "0x2a50afD9d3E0ACC824aC4850d7B4c5561aB5D27a"
datadir: "{{ data_dir }}"
logging:
level: "INFO"
json: false
file:
enabled: true
level: "DEBUG"
folder: logs
maxsize: 10
maxage: 7
maxbackups: 100
localtime: false
compress: true
node:
mode: "validator"
admin:
port: 9155
rpc:
port: 9151
endpoints:
groups:
genlayer: true
genlayer_debug: true
ethereum: true
zksync: true
methods:
gen_call: true
gen_getContractSchema: true
gen_getTransactionStatus: true
gen_getTransactionReceipt: true
gen_dbg_ping: true
gen_dbg_load_test: true
eth_blockNumber: true
eth_getBlockByNumber: true
eth_getBlockByHash: true
eth_getBalance: true
eth_getTransactionCount: true
eth_getTransactionReceipt: true
eth_getLogs: true
eth_getCode: true
eth_sendRawTransaction: false
ops:
port: 9153
endpoints:
metrics: true
health: true
balance: true
dev:
disableSubscription: false
genvm:
bin_dir: {{ node_bin_dir }}/third_party/genvm/bin
manage_modules: true
merkleforest:
maxdepth: 16
dbpath: "{{ data_dir }}/merkle/forest/data.db"
indexdbpath: "{{ data_dir }}/merkle/index.db"
merkletree:
maxdepth: 16
dbpath: "{{ data_dir }}/merkle/tree/"
metrics:
interval: "15s"
- name: Run precompilation of WASM modules
shell: |
cd {{ node_bin_dir }}
./third_party/genvm/bin/genvm precompile
args:
executable: /bin/bash
- name: Generate validator key and address, store output
shell: |
cd {{ node_bin_dir }}
./bin/genlayernode account new -c $(pwd)/configs/node/config.yaml --setup --password "{{ node_password }}" 2>&1
args:
executable: /bin/bash
register: validator_account
- name: Extract validator address from key generation output
set_fact:
validator_address: "{{ (validator_account.stdout | regex_search('New address: (0x[a-fA-F0-9]{40})', '\\1')) | first | default('') }}"
- name: Backup validator account
shell: |
cd {{ node_bin_dir }}
./bin/genlayernode account export \
--password "{{ node_password }}" \
--address "{{ validator_address }}" \
--passphrase "{{ backup_passphrase }}" \
--path "{{ backup_path }}" \
-c $(pwd)/configs/node/config.yaml
args:
executable: /bin/bash
- name: Update genvm-module-llm.yaml to Enable backends based on LLM API key presence
block:
- name: Enable heurist backend
shell: "sed -i '/heurist:/, /enabled:/ s/enabled: (true|false)/enabled: true/' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: heurist_key is defined and heurist_key != ''
- name: Enable comput3 backend
shell: "sed -i -E 's|(comput3:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if comput3_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: comput3_key is defined and comput3_key != ''
- name: Enable ionet backend
shell: "sed -i -E 's|(ionet:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if ionet_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: ionet_key is defined and ionet_key != ''
- name: Enable libertai backend
shell: "sed -i -E 's|(libertai:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if libertai_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: libertai_key is defined and libertai_key != ''
- name: Enable openai backend
shell: "sed -i -E 's|(openai:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if openai_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: openai_key is defined and openai_key != ''
- name: Enable anthropic backend
shell: "sed -i -E 's|(anthropic:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if anthropic_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: anthropic_key is defined and anthropic_key != ''
- name: Enable xai backend
shell: "sed -i -E 's|(xai:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if xai_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: xai_key is defined and xai_key != ''
- name: Enable google backend
shell: "sed -i -E 's|(google:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if google_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: google_key is defined and google_key != ''
- name: Enable atoma backend
shell: "sed -i -E 's|(atoma:\\n\\s+enabled:)( true| false)|\\1 {{ \"true\" if atoma_key != \"\" else \"false\" }}|' '{{ node_bin_dir }}/third_party/genvm/config/genvm-module-llm.yaml'"
when: atoma_key is defined and atoma_key != ''
delegate_to: localhost
run_once: yes
- name: Run Docker Compose to start WebDriver container
shell: docker compose up -d
args:
chdir: "{{ node_bin_dir }}"
- name: Create systemd service for GenLayer validator node
copy:
dest: /etc/systemd/system/genlayer-node.service
content: |
[Unit]
Description=GenLayer Validator Node
After=network.target
[Service]
WorkingDirectory={{ node_bin_dir }}
ExecStart={{ node_bin_dir }}/bin/genlayernode run -c {{ config_dir }}/config.yaml --password '{{ node_password }}'
Restart=on-failure
RestartSec=10
User=root
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=genlayer-node
Environment=HEURISTKEY={{ heurist_key }}
Environment=COMPUT3KEY={{ comput3_key }}
Environment=IOINTELLIGENCEKEY={{ ionet_key }}
Environment=LIBERTAI_API_KEY={{ libertai_key }}
Environment=OPENAIKEY={{ openai_key }}
Environment=ANTHROPICKEY={{ anthropic_key }}
Environment=XAIKEY={{ xai_key }}
Environment=GEMINIKEY={{ google_key }}
Environment=ATOMAKEY={{ atoma_key }}
[Install]
WantedBy=multi-user.target
notify: Restart genlayer node
- name: Reload systemd to register new service
systemd:
daemon_reload: yes
- name: Enable and start genlayer-node service
systemd:
name: genlayer-node.service
enabled: yes
state: started
- name: Print validator address in a banner
debug:
msg: |
***********************************************
* Validator Address *
***********************************************
{{ validator_address }}
***********************************************