Skip to content

Commit ae9250d

Browse files
committed
fix: use real container endpoints for P2P outbox polling
The outbox polling was using derived container names like 'challenge-term-challenge' but the actual container names have unique suffixes like 'challenge-term-challenge-4133b3431b1c'. Changes: - Use challenge_endpoints HashMap which has the real endpoints - Fix decrypt response URL to use actual endpoint - Add logging when messages are found in outbox This fixes the P2P proposal broadcast not being sent because the wrong URL was used.
1 parent 00ebeec commit ae9250d

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

bins/validator-node/src/main.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,7 @@ async fn run_validator() -> Result<()> {
16411641
let state_for_outbox = chain_state.clone();
16421642
let net_cmd_tx_for_outbox = net_cmd_tx.clone();
16431643
let keypair_for_outbox = keypair.clone();
1644+
let endpoints_for_outbox = challenge_endpoints.clone();
16441645

16451646
tokio::spawn(async move {
16461647
let client = reqwest::Client::new();
@@ -1649,22 +1650,36 @@ async fn run_validator() -> Result<()> {
16491650
loop {
16501651
tokio::time::sleep(poll_interval).await;
16511652

1652-
// Get all challenge containers
1653-
let configs: Vec<ChallengeContainerConfig> = {
1653+
// Get all challenge endpoints (these have the real container hostnames with suffixes)
1654+
let endpoints: Vec<(String, String)> = {
1655+
endpoints_for_outbox.read().iter().map(|(k, v)| (k.clone(), v.clone())).collect()
1656+
};
1657+
1658+
// Also get configs for challenge metadata
1659+
let configs: std::collections::HashMap<String, ChallengeContainerConfig> = {
16541660
let state = state_for_outbox.read();
1655-
state.challenge_configs.values().cloned().collect()
1661+
state.challenge_configs.iter().map(|(k, v)| (k.to_string(), v.clone())).collect()
16561662
};
16571663

1658-
for config in configs {
1659-
let container_name = config.name.to_lowercase().replace([' ', '_'], "-");
1660-
let outbox_url = format!("http://challenge-{}:8080/p2p/outbox", container_name);
1664+
for (challenge_id, endpoint) in endpoints {
1665+
// Use the real endpoint (includes suffix like challenge-term-challenge-4133b3431b1c)
1666+
let outbox_url = format!("{}/p2p/outbox", endpoint);
1667+
1668+
// Get config for this challenge
1669+
let config = match configs.get(&challenge_id) {
1670+
Some(c) => c.clone(),
1671+
None => continue, // Skip if no config found
1672+
};
16611673

16621674
match client.get(&outbox_url).send().await {
16631675
Ok(resp) if resp.status().is_success() => {
16641676
if let Ok(outbox) = resp.json::<serde_json::Value>().await {
16651677
if let Some(messages) =
16661678
outbox.get("messages").and_then(|m| m.as_array())
16671679
{
1680+
if !messages.is_empty() {
1681+
info!("Found {} messages in outbox for challenge {}", messages.len(), challenge_id);
1682+
}
16681683
for msg_value in messages {
16691684
// Parse the outbox message
16701685
if let (Some(message), target) = (
@@ -1706,7 +1721,7 @@ async fn run_validator() -> Result<()> {
17061721

17071722
// Send response back to container via P2P message endpoint
17081723
let p2p_response = platform_challenge_sdk::ChallengeP2PMessage::DecryptApiKeyResponse(response);
1709-
let p2p_endpoint = format!("http://challenge-{}:8080/p2p/message", container_name);
1724+
let p2p_endpoint = format!("{}/p2p/message", endpoint);
17101725
let req_body = serde_json::json!({
17111726
"from_hotkey": keypair_for_outbox.hotkey().to_hex(),
17121727
"message": p2p_response

0 commit comments

Comments
 (0)