Skip to content

Commit

Permalink
fix: CON-1313 Don't panic in make_registry_cup (#3980)
Browse files Browse the repository at this point in the history
This code is called by the orchestrator to create registry CUPs, so it
shouldn't panic.
  • Loading branch information
eichhorl authored Feb 18, 2025
1 parent a4e5d16 commit 4eec0b4
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions rs/consensus/src/cup_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,25 @@ pub fn make_registry_cup_from_cup_contents(
}
};

let low_dkg_id = dkg_summary
.current_transcript(&NiDkgTag::LowThreshold)
.expect("No current low threshold transcript available")
.dkg_id
.clone();
let high_dkg_id = dkg_summary
.current_transcript(&NiDkgTag::HighThreshold)
.expect("No current high threshold transcript available")
.dkg_id
.clone();
let Some(low_threshold_transcript) = dkg_summary.current_transcript(&NiDkgTag::LowThreshold)
else {
warn!(
logger,
"No current low threshold transcript in registry CUP contents"
);
return None;
};
let low_dkg_id = low_threshold_transcript.dkg_id.clone();

let Some(high_threshold_transcript) = dkg_summary.current_transcript(&NiDkgTag::HighThreshold)
else {
warn!(
logger,
"No current high threshold transcript in registry CUP contents"
);
return None;
};
let high_dkg_id = high_threshold_transcript.dkg_id.clone();

// In a NNS subnet recovery case the block validation context needs to reference a registry
// version of the NNS to be recovered. Otherwise the validation context points to a registry
Expand Down Expand Up @@ -164,7 +173,14 @@ pub fn make_registry_cup(
}
};

let cup_contents = versioned_record.value.expect("Missing CUP contents");
let Some(cup_contents) = versioned_record.value else {
warn!(
logger,
"Missing registry CUP contents at version {}", versioned_record.version
);
return None;
};

make_registry_cup_from_cup_contents(
registry,
subnet_id,
Expand Down

0 comments on commit 4eec0b4

Please sign in to comment.