@@ -75,10 +75,6 @@ def modify_env_file(client, subspace_dir, release_version, genesis_hash=None, po
7575 logger .error (f"Failed to modify .env file: { e } " )
7676 raise
7777
78- except Exception as e :
79- logger .error (f"Failed to modify .env file: { e } " )
80- raise
81-
8278def docker_compose_down (client , subspace_dir ):
8379 """Run sudo docker compose down -v in the subspace directory."""
8480 try :
@@ -139,32 +135,9 @@ def docker_compose_up(client, subspace_dir):
139135 logger .error (f"Failed to run sudo docker compose up -d: { e } " )
140136 raise
141137
142- def grep_protocol_version (client , retries = 5 , interval = 30 ):
143- """Grep the logs to find the protocol version and extract the hash."""
144- logs_command = 'sudo docker logs --tail 100 subspace-archival-node-1 | grep "protocol_version="'
145-
146- for attempt in range (retries ):
147- try :
148- stdout , stderr = run_command (client , logs_command )
149- match = re .search (r'protocol_version=/subspace/2/([a-f0-9]+)' , stdout )
150- if match :
151- logger .info (f"Protocol version hash found: { match .group (1 )} " )
152- return match .group (1 )
153- else :
154- logger .warning (f"Protocol version hash not found. Attempt { attempt + 1 } of { retries } " )
155- except Exception as e :
156- logger .error (f"Error grepping protocol version: { e } " )
157-
158- if attempt < retries - 1 :
159- logger .info (f"Retrying in { interval } seconds..." )
160- sleep (interval )
161-
162- logger .error ("Failed to retrieve protocol version hash after retries." )
163- return None
164-
165138def handle_node (client , node , subspace_dir , release_version , pot_external_entropy = None ,
166139 plot_size = None , cache_percentage = None , network = None , prune = False , restart = False ,
167- update_genesis_hash = True , genesis_hash = None ):
140+ genesis_hash = None ):
168141 """Generic function to handle different node types with specified actions."""
169142 try :
170143 if prune :
@@ -180,7 +153,7 @@ def handle_node(client, node, subspace_dir, release_version, pot_external_entrop
180153 plot_size = plot_size ,
181154 cache_percentage = cache_percentage ,
182155 network = network ,
183- genesis_hash = genesis_hash if update_genesis_hash else None )
156+ genesis_hash = genesis_hash )
184157
185158 docker_compose_up (client , subspace_dir )
186159
@@ -197,6 +170,7 @@ def main():
197170 parser .add_argument ('--release_version' , required = True , help = 'Release version to update in the .env file' )
198171 parser .add_argument ('--subspace_dir' , default = '/home/ubuntu/subspace' , help = 'Path to the Subspace directory' )
199172 parser .add_argument ('--pot_external_entropy' , help = 'POT_EXTERNAL_ENTROPY value for all nodes' )
173+ parser .add_argument ('--genesis_hash' , help = 'GENESIS_HASH value for the Bootstrap nodes' )
200174 parser .add_argument ('--log_level' , default = 'INFO' , help = 'Set the logging level (DEBUG, INFO, WARNING, ERROR)' )
201175 parser .add_argument ('--no-timekeeper' , action = 'store_true' , help = 'Disable launching of the timekeeper node' )
202176 parser .add_argument ('--prune' , action = 'store_true' , help = 'Stop containers and destroy the Docker images' )
@@ -223,7 +197,9 @@ def main():
223197 try :
224198 logger .info (f"Connecting to timekeeper node { timekeeper_node ['host' ]} ..." )
225199 client = ssh_connect (timekeeper_node ['host' ], timekeeper_node ['user' ], timekeeper_node ['ssh_key' ])
226- handle_node (client , timekeeper_node , args .subspace_dir , args .release_version , pot_external_entropy = args .pot_external_entropy , network = args .network , prune = args .prune , restart = args .restart )
200+ handle_node (client , timekeeper_node , args .subspace_dir , args .release_version ,
201+ pot_external_entropy = args .pot_external_entropy , network = args .network ,
202+ prune = args .prune , restart = args .restart )
227203 except Exception as e :
228204 logger .error (f"Error handling timekeeper node: { e } " )
229205 finally :
@@ -237,72 +213,45 @@ def main():
237213 try :
238214 logger .info (f"Connecting to farmer node { node ['host' ]} ..." )
239215 client = ssh_connect (node ['host' ], node ['user' ], node ['ssh_key' ])
240- handle_node (client , node , args .subspace_dir , args .release_version , pot_external_entropy = args .pot_external_entropy , network = args .network , plot_size = args .plot_size , cache_percentage = args .cache_percentage , prune = args .prune , restart = args .restart )
216+ handle_node (client , node , args .subspace_dir , args .release_version ,
217+ pot_external_entropy = args .pot_external_entropy , network = args .network ,
218+ plot_size = args .plot_size , cache_percentage = args .cache_percentage ,
219+ prune = args .prune , restart = args .restart )
241220 except Exception as e :
242221 logger .error (f"Error handling farmer node { node ['host' ]} : { e } " )
243222 finally :
244223 if client :
245224 client .close ()
246225
247226 # Step 3: Handle RPC nodes
248- protocol_version_hash = None
249227 for node in rpc_nodes :
250228 try :
251229 logger .info (f"Connecting to RPC node { node ['host' ]} ..." )
252230 client = ssh_connect (node ['host' ], node ['user' ], node ['ssh_key' ])
253-
254- # Handle node operations (prune/restart will be managed here)
255231 handle_node (client , node , args .subspace_dir , args .release_version ,
256- pot_external_entropy = args .pot_external_entropy ,
257- network = args .network ,
258- prune = args .prune ,
259- restart = args .restart )
260-
261- # Skip protocol version extraction if prune or restart is specified
262- if args .prune or args .restart :
263- logger .info (f"Skipping protocol version extraction for RPC node { node ['host' ]} due to prune/restart." )
264- continue
265-
266- # If this is an RPC node, wait and then extract protocol version hash
267- logger .info (f"Waiting for RPC node { node ['host' ]} to start..." )
268- sleep (30 ) # Adjust sleep time as necessary
269-
270- # Attempt to grep the protocol version from logs
271- protocol_version_hash = grep_protocol_version (client )
272-
273- if not protocol_version_hash :
274- logger .error (f"Failed to retrieve protocol version hash on RPC node { node ['host' ]} " )
275- continue
232+ pot_external_entropy = args .pot_external_entropy , network = args .network ,
233+ prune = args .prune , restart = args .restart )
276234 except Exception as e :
277235 logger .error (f"Error handling RPC node { node ['host' ]} : { e } " )
278236 finally :
279237 if client :
280238 client .close ()
281239
282- # Step 4: Handle the bootstrap node, using the protocol version hash if available
240+ # Step 4: Handle the bootstrap node with genesis hash from arguments
283241 try :
284242 logger .info (f"Connecting to the bootstrap node { bootstrap_node ['host' ]} ..." )
285243 client = ssh_connect (bootstrap_node ['host' ], bootstrap_node ['user' ], bootstrap_node ['ssh_key' ])
286244
287- # Warn about missing protocol version hash before proceeding with the bootstrap node update
288- if not protocol_version_hash :
289- logger .warning ("Protocol version hash not found; proceeding with bootstrap node without genesis_hash update." )
290-
291- # Handle node operations with update_genesis_hash set to True
292245 handle_node (client , bootstrap_node , args .subspace_dir , args .release_version ,
293- pot_external_entropy = args .pot_external_entropy ,
294- network = args .network ,
295- prune = args .prune ,
296- restart = args .restart ,
297- update_genesis_hash = True , # Always update genesis hash
298- genesis_hash = protocol_version_hash )
246+ pot_external_entropy = args .pot_external_entropy , network = args .network ,
247+ prune = args .prune , restart = args .restart ,
248+ genesis_hash = args .genesis_hash )
299249
300250 except Exception as e :
301251 logger .error (f"Error handling bootstrap node: { e } " )
302252 finally :
303253 if client :
304- client .close ()
305-
254+ client .close ()
306255
307256if __name__ == '__main__' :
308257 main ()
0 commit comments