Skip to content

Commit c6137eb

Browse files
committed
fix(validator): use correct container name with validator suffix for challenge endpoints
The endpoint derivation must match the logic in challenge-orchestrator/docker.rs which includes a validator suffix (from VALIDATOR_NAME or HOSTNAME env vars). Without this fix, the validator would try to proxy to: http://challenge-term-challenge:8080 Instead of the actual container: http://challenge-term-challenge-ef1eb5119559:8080
1 parent c91e830 commit c6137eb

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

bins/validator-node/src/main.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,17 @@ async fn main() -> Result<()> {
498498
.rpc_handler()
499499
.register_challenge_routes(&challenge_id, routes);
500500

501-
// Store endpoint for this challenge (container name derived from challenge name)
502-
let container_name = config.name.to_lowercase().replace(' ', "-");
503-
let endpoint = format!("http://challenge-{}:8080", container_name);
501+
// Store endpoint for this challenge (container name derived from challenge name + validator suffix)
502+
// Must match logic in challenge-orchestrator/docker.rs
503+
let validator_suffix = std::env::var("VALIDATOR_NAME")
504+
.or_else(|_| std::env::var("HOSTNAME"))
505+
.unwrap_or_else(|_| format!("{:x}", std::process::id()));
506+
let container_name = format!(
507+
"challenge-{}-{}",
508+
config.name.to_lowercase().replace(' ', "-"),
509+
validator_suffix.to_lowercase().replace('-', "").replace(' ', "")
510+
);
511+
let endpoint = format!("http://{}:8080", container_name);
504512
challenge_endpoints.write().insert(challenge_id, endpoint);
505513
}
506514

@@ -538,8 +546,16 @@ async fn main() -> Result<()> {
538546

539547
match config {
540548
Some(cfg) => {
541-
let container_name = cfg.name.to_lowercase().replace(' ', "-");
542-
format!("http://challenge-{}:8080", container_name)
549+
// Must match logic in challenge-orchestrator/docker.rs
550+
let validator_suffix = std::env::var("VALIDATOR_NAME")
551+
.or_else(|_| std::env::var("HOSTNAME"))
552+
.unwrap_or_else(|_| format!("{:x}", std::process::id()));
553+
let container_name = format!(
554+
"challenge-{}-{}",
555+
cfg.name.to_lowercase().replace(' ', "-"),
556+
validator_suffix.to_lowercase().replace('-', "").replace(' ', "")
557+
);
558+
format!("http://{}:8080", container_name)
543559
}
544560
None => {
545561
return RouteResponse::new(

0 commit comments

Comments
 (0)