@@ -44,7 +44,7 @@ def run_command(client, command):
4444
4545 # Treat Docker status updates as INFO instead of ERROR
4646 if error :
47- if any (keyword in error for keyword in ["Stopping" , "Stopped" , "Creating" , "Started" , "Removing" , "Removed" ]):
47+ if any (keyword in error for keyword in ["Stopping" , "Stopped" , "Creating" , "Started" , "Removing" , "Removed" ]):
4848 logger .info (f"Command output: { error .strip ()} " )
4949 else :
5050 logger .error (f"Error running command: { error .strip ()} " )
@@ -138,8 +138,9 @@ def main():
138138 parser .add_argument ('--config' , required = True , help = 'Path to the TOML config file' )
139139 parser .add_argument ('--release_version' , required = True , help = 'Release version to update in the .env file' )
140140 parser .add_argument ('--subspace_dir' , default = '/home/ubuntu/subspace' , help = 'Path to the Subspace directory (default: /home/ubuntu/subspace)' )
141- parser .add_argument ('--pot_external_entropy' , help = 'POT_EXTERNAL_ENTROPY value for the timekeeper node ' )
141+ parser .add_argument ('--pot_external_entropy' , help = 'POT_EXTERNAL_ENTROPY value for all nodes ' )
142142 parser .add_argument ('--log_level' , default = 'INFO' , help = 'Set the logging level (DEBUG, INFO, WARNING, ERROR)' )
143+ parser .add_argument ('--no-timekeeper' , action = 'store_true' , help = 'Disable launching of the timekeeper node' )
143144 args = parser .parse_args ()
144145
145146 # Set logging level based on user input
@@ -159,35 +160,48 @@ def main():
159160 release_version = args .release_version
160161 subspace_dir = args .subspace_dir
161162
162- # Step 1: sudo docker compose down -v on all farmer and RPC nodes
163- for node in farmer_rpc_nodes :
163+ # Step 1: Handle the timekeeper node first, if present and --no-timekeeper is not set
164+ if not args . no_timekeeper and timekeeper_node :
164165 client = None # Initialize the client variable
165166 try :
166- logger .info (f"Connecting to { node ['host' ]} for sudo docker compose down -v ..." )
167- client = ssh_connect (node ['host' ], node ['user' ], node ['ssh_key' ])
167+ logger .info (f"Connecting to the timekeeper node { timekeeper_node ['host' ]} ..." )
168+ client = ssh_connect (timekeeper_node ['host' ], timekeeper_node ['user' ], timekeeper_node ['ssh_key' ])
168169
169- # Run sudo docker compose down -v
170+ # Run sudo docker compose down -v for the timekeeper node
170171 docker_compose_down (client , subspace_dir )
171172
172- # Close connection after shutdown
173- client .close ()
173+ # Modify the .env file with the POT_EXTERNAL_ENTROPY value
174+ logger .debug (f"Modifying .env file for timekeeper with POT_EXTERNAL_ENTROPY={ args .pot_external_entropy } " )
175+ modify_env_file (client , subspace_dir , release_version , pot_external_entropy = args .pot_external_entropy )
176+
177+ # Start the timekeeper node
178+ docker_compose_up (client , subspace_dir )
179+
180+ logger .info ("Timekeeper node started with the updated POT_EXTERNAL_ENTROPY value." )
174181 except Exception as e :
175- logger .error (f"Error during sudo docker compose down -v on { node [ 'host' ] } : { e } " )
182+ logger .error (f"Error during timekeeper node update : { e } " )
176183 finally :
177184 if client :
178185 client .close ()
179- logger .debug (f"Closed connection for node { node ['host' ]} " )
186+ logger .debug (f"Closed connection to timekeeper node { timekeeper_node ['host' ]} " )
187+ elif args .no_timekeeper :
188+ logger .info ("Skipping timekeeper node as --no-timekeeper flag is set." )
189+ else :
190+ logger .warning ("Timekeeper node not found, proceeding with other nodes." )
180191
181- # Step 2: Update .env and start sudo docker compose for RPC and Farmer nodes
192+ # Step 2: Start the other farmer and RPC nodes after the timekeeper node
182193 protocol_version_hash = None
183194 for node in farmer_rpc_nodes :
184195 client = None # Initialize the client variable
185196 try :
186- logger .info (f"Connecting to { node ['host' ]} ..." )
197+ logger .info (f"Connecting to { node ['host' ]} for sudo docker compose down -v ..." )
187198 client = ssh_connect (node ['host' ], node ['user' ], node ['ssh_key' ])
188199
189- # Modify the .env file
190- modify_env_file (client , subspace_dir , release_version )
200+ # Run sudo docker compose down -v
201+ docker_compose_down (client , subspace_dir )
202+
203+ # Modify the .env file for farmer and RPC nodes
204+ modify_env_file (client , subspace_dir , release_version , pot_external_entropy = args .pot_external_entropy )
191205
192206 # Start sudo docker compose up -d
193207 docker_compose_up (client , subspace_dir )
@@ -212,34 +226,7 @@ def main():
212226 client .close ()
213227 logger .debug (f"Closed connection for node { node ['host' ]} " )
214228
215- if timekeeper_node :
216- client = None # Initialize the client variable
217- if args .pot_external_entropy :
218- try :
219- logger .info (f"Connecting to the timekeeper node { timekeeper_node ['host' ]} ..." )
220- client = ssh_connect (timekeeper_node ['host' ], timekeeper_node ['user' ], timekeeper_node ['ssh_key' ])
221-
222- # Run sudo docker compose down -v
223- docker_compose_down (client , subspace_dir )
224-
225- # Modify the .env file with the POT_EXTERNAL_ENTROPY value
226- logger .debug (f"Modifying .env file with POT_EXTERNAL_ENTROPY={ args .pot_external_entropy } " )
227- modify_env_file (client , subspace_dir , release_version , pot_external_entropy = args .pot_external_entropy )
228-
229- # Start the timekeeper node
230- docker_compose_up (client , subspace_dir )
231-
232- logger .info ("Timekeeper node started with the updated POT_EXTERNAL_ENTROPY value." )
233- except Exception as e :
234- logger .error (f"Error during timekeeper node update: { e } " )
235- finally :
236- if client :
237- client .close ()
238- logger .debug (f"Closed connection to timekeeper node { timekeeper_node ['host' ]} " )
239- else :
240- logger .warning (f"POT_EXTERNAL_ENTROPY not provided for the timekeeper node, skipping update." )
241-
242- # Step 3: SSH into the bootstrap node and update GENESIS_HASH, then start it
229+ # Step 3: SSH into the bootstrap node and update GENESIS_HASH and POT_EXTERNAL_ENTROPY, then start it
243230 if protocol_version_hash :
244231 client = None # Initialize the client variable
245232 try :
@@ -249,14 +236,14 @@ def main():
249236 # Run sudo docker compose down -v for the bootstrap node
250237 docker_compose_down (client , subspace_dir )
251238
252- # Modify .env with the new GENESIS_HASH
253- modify_env_file (client , subspace_dir , release_version , genesis_hash = protocol_version_hash )
239+ # Modify .env with the new GENESIS_HASH and POT_EXTERNAL_ENTROPY
240+ modify_env_file (client , subspace_dir , release_version , genesis_hash = protocol_version_hash , pot_external_entropy = args . pot_external_entropy )
254241
255242 # Start the bootstrap node
256243 docker_compose_up (client , subspace_dir )
257244
258245 client .close ()
259- logger .info ("Bootstrap node started with the updated Genesis Hash." )
246+ logger .info ("Bootstrap node started with the updated Genesis Hash and POT_EXTERNAL_ENTROPY ." )
260247 except Exception as e :
261248 logger .error (f"Error during bootstrap node update: { e } " )
262249 finally :
0 commit comments