Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit f58dead

Browse files
authored
disable orchestrator nodes migration (#517)
1 parent 53fa981 commit f58dead

File tree

2 files changed

+1
-124
lines changed

2 files changed

+1
-124
lines changed

crates/orchestrator/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ async fn main() -> Result<()> {
175175

176176
let store = Arc::new(RedisStore::new(&args.redis_store_url));
177177
let store_context = Arc::new(StoreContext::new(store.clone()));
178-
store_context.node_store.migrate_existing_nodes().await?;
179178

180179
let p2p_client = Arc::new(P2PClient::new(wallet.clone()).await.unwrap());
181180

crates/orchestrator/src/store/domains/node_store.rs

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -205,70 +205,6 @@ impl NodeStore {
205205
}
206206
Ok(())
207207
}
208-
pub async fn migrate_existing_nodes(&self) -> Result<()> {
209-
let mut con = self.redis.client.get_multiplexed_async_connection().await?;
210-
211-
let mut cursor = 0;
212-
loop {
213-
let (new_cursor, keys): (u64, Vec<String>) = redis::cmd("SCAN")
214-
.cursor_arg(cursor)
215-
.arg("MATCH")
216-
.arg(format!("{}:*", ORCHESTRATOR_BASE_KEY))
217-
.arg("COUNT")
218-
.arg(100)
219-
.query_async(&mut con)
220-
.await?;
221-
222-
for key in keys {
223-
if let Some(address) = key.strip_prefix(&format!("{}:", ORCHESTRATOR_BASE_KEY)) {
224-
let _: () = con.sadd(ORCHESTRATOR_NODE_INDEX, address).await?;
225-
}
226-
}
227-
228-
if new_cursor == 0 {
229-
break;
230-
}
231-
cursor = new_cursor;
232-
}
233-
234-
// Handle legacy keys with double colons (orchestrator:node::address)
235-
let mut cursor = 0;
236-
loop {
237-
let (new_cursor, keys): (u64, Vec<String>) = redis::cmd("SCAN")
238-
.cursor_arg(cursor)
239-
.arg("MATCH")
240-
.arg("orchestrator:node::*")
241-
.arg("COUNT")
242-
.arg(100)
243-
.query_async(&mut con)
244-
.await?;
245-
246-
for key in keys {
247-
if let Some(address) = key.strip_prefix("orchestrator:node::") {
248-
// Add to index
249-
let _: () = con.sadd(ORCHESTRATOR_NODE_INDEX, address).await?;
250-
251-
// Get the value from the old key
252-
let value: Option<String> = con.get(&key).await?;
253-
if let Some(value) = value {
254-
// Set the value with the correct key format
255-
let new_key = format!("{}:{}", ORCHESTRATOR_BASE_KEY, address);
256-
let _: () = con.set(&new_key, value).await?;
257-
258-
// Delete the old key with double colons
259-
let _: () = con.del(&key).await?;
260-
}
261-
}
262-
}
263-
264-
if new_cursor == 0 {
265-
break;
266-
}
267-
cursor = new_cursor;
268-
}
269-
270-
Ok(())
271-
}
272208
}
273209

274210
#[cfg(test)]
@@ -277,7 +213,7 @@ mod tests {
277213
use crate::models::node::NodeStatus;
278214
use crate::models::node::OrchestratorNode;
279215
use alloy::primitives::Address;
280-
use redis::AsyncCommands;
216+
281217
use std::str::FromStr;
282218

283219
#[tokio::test]
@@ -356,62 +292,4 @@ mod tests {
356292
Address::from_str("0x0000000000000000000000000000000000000003").unwrap()
357293
);
358294
}
359-
360-
#[tokio::test]
361-
async fn test_migration_handles_double_colon_keys() {
362-
let app_state = create_test_app_state().await;
363-
let node_store = &app_state.store_context.node_store;
364-
let mut con = app_state
365-
.store_context
366-
.node_store
367-
.redis
368-
.client
369-
.get_multiplexed_async_connection()
370-
.await
371-
.unwrap();
372-
373-
let test_address = "0x66295E2B4A78d1Cb57Db16Ac0260024900A5BA9B";
374-
let test_node = OrchestratorNode {
375-
address: Address::from_str(test_address).unwrap(),
376-
ip_address: "192.168.1.1".to_string(),
377-
port: 8080,
378-
status: NodeStatus::Healthy,
379-
..Default::default()
380-
};
381-
382-
// Manually create a legacy key with double colons
383-
let legacy_key = format!("orchestrator:node::{}", test_address);
384-
let _: () = con.set(&legacy_key, test_node.to_string()).await.unwrap();
385-
386-
// Verify the legacy key exists
387-
let exists: bool = con.exists(&legacy_key).await.unwrap();
388-
assert!(exists);
389-
390-
// Run migration
391-
node_store.migrate_existing_nodes().await.unwrap();
392-
393-
// Verify the legacy key is removed
394-
let legacy_exists: bool = con.exists(&legacy_key).await.unwrap();
395-
assert!(!legacy_exists);
396-
397-
// Verify the correct key exists
398-
let correct_key = format!("orchestrator:node:{}", test_address);
399-
let correct_exists: bool = con.exists(&correct_key).await.unwrap();
400-
assert!(correct_exists);
401-
402-
// Verify the node is in the index
403-
let in_index: bool = con
404-
.sismember("orchestrator:node_index", test_address)
405-
.await
406-
.unwrap();
407-
assert!(in_index);
408-
409-
// Verify we can retrieve the node correctly
410-
let retrieved_node = node_store
411-
.get_node(&Address::from_str(test_address).unwrap())
412-
.await
413-
.unwrap();
414-
assert!(retrieved_node.is_some());
415-
assert_eq!(retrieved_node.unwrap().address, test_node.address);
416-
}
417295
}

0 commit comments

Comments
 (0)