Skip to content

Commit 5d4a1b4

Browse files
authored
feat(NNS): Parallelize dkg calls in recovery CUP creation (#4634)
This PR parallelises the calls to `create_initial_dkg_dealings` and `compute_initial_i_dkg_dealings` during subnet recovery. The rationale is that soon we will migrate the `compute_initial_i_dkg_dealings` call to the `reshare_chain_key` endpoint, which also supports resharing VetKD keys. Unlike existing IDKG reshares, a VetKD reshare can take up to two DKG intervals after the call has been made, since under the hood it uses the Remote NiDKG protocol, the same one that `create_initial_dkg_dealings` uses. If we didn't parallelizs these calls, creating a recovery CUP could potentially take more than 4 DKG intervals since we would do two rounds of Remote NiDKG. There is a similar situation in `create_subnet`, however, I decided not to parallelize this because: 1. The call sites of `ceate_initial_dkg_dealings` and `compute_initial_i_dkg_dealings` is further apart, which would require more code reshuffling 2. There is less time pressure when creating a Subnet than when recovering one, so the additional 2 DKG intervals are less of an issue. Nonetheless, if you think it makes sense to also parallelise `create_subnet`, let me know.
1 parent 4813af2 commit 5d4a1b4

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

rs/registry/canister/src/mutations/do_recover_subnet.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,6 @@ impl Registry {
9797
RegistryVersion::new(pre_call_registry_version),
9898
);
9999

100-
let response_bytes = call(
101-
CanisterId::ic_00(),
102-
"setup_initial_dkg",
103-
bytes,
104-
Encode!(&request).unwrap(),
105-
)
106-
.await
107-
.unwrap();
108-
109100
let initial_chain_key_config =
110101
payload
111102
.chain_key_config
@@ -115,9 +106,18 @@ impl Registry {
115106
.expect("Invalid InitialChainKeyConfig")
116107
});
117108

118-
let chain_key_initializations = self
119-
.get_all_initial_i_dkg_dealings_from_ic00(&initial_chain_key_config, dkg_nodes)
120-
.await;
109+
// Call setup_initial_dkg and compute_initial_i_dkg_dealings in parallel.
110+
// Since both calls may take up to 2 DKG intervals to complete, this speeds up generation of a recovery cup.
111+
let (response_bytes, chain_key_initializations) = futures::join!(
112+
call(
113+
CanisterId::ic_00(),
114+
"setup_initial_dkg",
115+
bytes,
116+
Encode!(&request).unwrap(),
117+
),
118+
self.get_all_initial_i_dkg_dealings_from_ic00(&initial_chain_key_config, dkg_nodes)
119+
);
120+
let response_bytes = response_bytes.unwrap();
121121

122122
if let Some(initial_chain_key_config) = initial_chain_key_config {
123123
// If chain key config is set, we must both update the subnet's chain_key_config

0 commit comments

Comments
 (0)