refactor(consensus): Refactor code in NiDkg to prepare VetKD implementation #3522
+49
−33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes changes to DKG in order to prepare the implementation of CON-1413.
In particular, it makes two changes:
Summary::current_transcript
now returns anOption
, rather than panicking.With the introduction of the
NiDkgTag::HighThresholdForKey(_)
, we can no longer enumerate all variants, and we should not assume that theSummary
contains all the tags we assume. In fact, when generating a vetkey, we will end up in situations wherenext_transcripts
contains tags thatcurrent_transctips
doesn't have. This PR simply adds unwraps at all call sites, since the code should not panic, if called withNiDkgTag::LowThreshold
orNiDkgTag::HighThreshold
.into_next_transcripts
and move it intodkg
crateThe current implementation is slightly wrong, since it enumerates the tags from the
current_transcripts
, which makes the assumption that the tags ofnext_transcripts
is a subset of the tags ofcurrent_transcripts
. This is not correct. When we add a new vetkey, we generate aConfig
for it at put it in theSummary
. This will generate aNiDkgTag::HighThresholdForKey(_)
transcript for it and put it intonext_transcripts
of the next block. So this transcript would never become acurrent_transcript
with the old code. The new code simply copiesnext_transcripts
over to the new summary ascurrent_transcripts
and then looks for oldcurrent_trascripts
whose tags are missing and copies them over too.Also the code was moved from
ic-types
into thedkg
crate, since it was only used there, and this way we can add some logging.