Skip to content

Commit 56d8ddb

Browse files
committed
feat: auto-rename challenge on WASM upload, add RemoveChallenge sudo action
1 parent cbf3166 commit 56d8ddb

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

bins/validator-node/src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,16 @@ async fn main() -> Result<()> {
946946
cid,
947947
route_infos.clone(),
948948
);
949+
// If challenge_id is a human-readable name (not UUID), ensure the
950+
// challenge config uses that name so HTTP name-based routing works.
951+
if uuid::Uuid::parse_str(challenge_id).is_err() {
952+
let needs_rename = state.wasm_challenge_configs.get(&cid)
953+
.map(|c| c.name != challenge_id)
954+
.unwrap_or(false);
955+
if needs_rename {
956+
state.rename_challenge(&cid, challenge_id.to_string());
957+
}
958+
}
949959
info!(
950960
challenge_id = challenge_id,
951961
routes_count = route_infos.len(),

crates/core/src/message.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ pub enum SudoAction {
326326
challenge_id: ChallengeId,
327327
new_name: String,
328328
},
329+
330+
/// Remove a challenge entirely
331+
RemoveChallenge {
332+
challenge_id: ChallengeId,
333+
},
329334
}
330335

331336
/// Configuration for how weights are distributed on a mechanism

crates/core/src/state.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,10 @@ impl ChainState {
498498
);
499499
self.rename_challenge(challenge_id, new_name.clone());
500500
}
501+
SudoAction::RemoveChallenge { challenge_id } => {
502+
tracing::info!(challenge_id = %challenge_id, "Sudo: removing challenge");
503+
self.remove_wasm_challenge(challenge_id);
504+
}
501505
}
502506
self.increment_mutation_sequence();
503507
Ok(())

0 commit comments

Comments
 (0)