Skip to content

feat: CON-1445 Helper functions to create NiDkgConfigs from request contexts#9926

Merged
eichhorl merged 14 commits intomasterfrom
eichhorl/build-callback-id-config-map
Apr 22, 2026
Merged

feat: CON-1445 Helper functions to create NiDkgConfigs from request contexts#9926
eichhorl merged 14 commits intomasterfrom
eichhorl/build-callback-id-config-map

Conversation

@eichhorl
Copy link
Copy Markdown
Contributor

@eichhorl eichhorl commented Apr 17, 2026

Previously, configs for Remote DKG requests were only created and included as part of summary blocks. This implies that a request has to wait until the end of the current interval to even be started.

This PR introduces two new functions that will be used to start working on remote DKG requests as soon as they appear in the replicated state.

build_callback_id_config_map

This function iterates over all remote DKG request contexts and attempts to derive the corresponding DKG configs. This is done by using the start height of the most recent summary block. In case of malformed inputs, errors are returned instead.

One special aspect is the use of the initial_dkg_attempts map, which is maintained by the summary payload. Entries of this map are incremented whenever there is still an outstanding request context in the replicated state, when the summary block is created. If the number of attempts exceeds the maximum, the new function will generate a timeout error instead. Furthermore, we will use this map to track remote DKG requests that have been completed as part of the previous interval. Target IDs for such requests will be inserted into this map with a count of 0. This ensures that they will not be attempted again in the subsequent interval.

merge_configs

This function takes configs from the recent summary, and merges them with configs derived from the latest state using build_callback_id_config_map. The output represents the combined set of configs for currently ongoing DKGs.

Note that the new functions are still unused.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an (currently unused) internal module to derive remote NiDKG configs directly from replicated-state request contexts, enabling remote DKG work to begin before the next summary block is produced.

Changes:

  • Added build_callback_id_config_map to derive per-callback remote DKG config results from ReplicatedState and the latest DkgSummary, including timeout handling via initial_dkg_attempts.
  • Added merge_configs to combine summary-derived configs with context-derived configs (successes only).
  • Refactored create_remote_dkg_config_for_key_id to accept a transcript lookup function and widened visibility of a few helper functions for reuse.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
rs/consensus/dkg/src/remote.rs New module with remote-context→config derivation + merge helper and unit tests.
rs/consensus/dkg/src/payload_builder.rs Adjusted remote config creation API (closure-based transcript lookup) and made helper functions pub(crate) for reuse.
rs/consensus/dkg/src/lib.rs Added remote module to the crate with a module-level #[allow(dead_code)].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rs/consensus/dkg/src/payload_builder.rs Outdated
Comment thread rs/consensus/dkg/src/payload_builder.rs Outdated
Comment thread rs/consensus/dkg/src/lib.rs
Comment thread rs/consensus/dkg/src/remote.rs
@eichhorl eichhorl changed the title Draft: build_callback_id_config_map feat: CON-1445 Helper functions to create NiDkgConfigs from request contexts Apr 20, 2026
@github-actions github-actions Bot added the feat label Apr 20, 2026
@eichhorl eichhorl marked this pull request as ready for review April 20, 2026 12:49
@eichhorl eichhorl requested a review from a team as a code owner April 20, 2026 12:49
Comment thread rs/consensus/dkg/src/remote.rs Outdated
Comment thread rs/consensus/dkg/src/payload_builder.rs Outdated
Comment thread rs/consensus/dkg/src/remote.rs
Comment thread rs/consensus/dkg/src/remote.rs
Comment thread rs/consensus/dkg/src/remote.rs Outdated
Comment thread rs/consensus/dkg/src/remote.rs
Comment thread rs/consensus/dkg/src/remote.rs
Comment thread rs/consensus/dkg/src/remote.rs
Comment thread rs/consensus/dkg/src/remote.rs Outdated
Comment thread rs/consensus/dkg/src/remote.rs Outdated
@eichhorl eichhorl added this pull request to the merge queue Apr 22, 2026
Merged via the queue into master with commit 22853ca Apr 22, 2026
37 checks passed
@eichhorl eichhorl deleted the eichhorl/build-callback-id-config-map branch April 22, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants