Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
64e6091
WIP renaming dealings
Sawchord Nov 22, 2024
9ced08c
More renaming
Sawchord Nov 22, 2024
8a5e275
Some more renaming
Sawchord Nov 25, 2024
50b3a97
PB compatibility
Sawchord Nov 25, 2024
04d1bea
Fixes
Sawchord Nov 25, 2024
4f7b28a
Fixes
Sawchord Nov 25, 2024
5b4b664
Rename dkg::DataPayload to dkg::DkgDataPayload
Sawchord Nov 25, 2024
246ca4f
Fix
Sawchord Nov 25, 2024
f815b3e
Remove werid retry logic
Sawchord Nov 25, 2024
e30b8cf
UPdate comment
Sawchord Nov 25, 2024
db6d3c7
Add payload
Sawchord Nov 26, 2024
c3d430d
Deliver remote dkg transcripts from non-summary blocks as well
Sawchord Nov 27, 2024
d888927
Implement get_unused_dkg_dealings
Sawchord Nov 27, 2024
6d746dc
Small optimization
Sawchord Nov 27, 2024
32ba6a7
Merge branch 'master' into leon/dkg_acceleration_part3
Sawchord Nov 27, 2024
7d8edd4
Small refactoring
Sawchord Nov 27, 2024
4e6c8ef
More refactoring
Sawchord Nov 27, 2024
0b553aa
Refactor callback_id acquisition
Sawchord Nov 27, 2024
63fa101
WIP implement create_early_remote_transcripts
Sawchord Nov 27, 2024
26e0a2b
TODO
Sawchord Nov 27, 2024
07608f2
WIP implement PB
Sawchord Nov 28, 2024
4bbcb54
WIP early transcripts
Sawchord Nov 28, 2024
b4fe0ac
Improve payload builder code
Sawchord Nov 28, 2024
68fd82b
Remove some unused code
Sawchord Nov 28, 2024
5f5e8e5
Fix tests
Sawchord Nov 28, 2024
ec24eae
Revert "Small optimization"
Sawchord Nov 29, 2024
bbc49e1
Revert "Small optimization"
Sawchord Dec 2, 2024
bcdafe2
WIP implement validator
Sawchord Dec 2, 2024
d5c127e
Merge branch 'master' into leon/dkg_acceleration_part3
Sawchord Dec 3, 2024
4b08644
Merge branch 'master' into leon/dkg_acceleration_part3
Sawchord Dec 4, 2024
5ff9175
WIP testing
Sawchord Dec 5, 2024
aef6916
WIp implement early remote unit test
Sawchord Dec 5, 2024
9eb8092
WIP implementing test
Sawchord Dec 5, 2024
dde5035
Merge branch 'master' into leon/dkg_acceleration_part3
Sawchord Dec 11, 2024
1e03d03
WIP implement test
Sawchord Dec 11, 2024
7ed6d28
WIP improve test
Sawchord Dec 11, 2024
2fd1845
WIP working with tests
Sawchord Dec 11, 2024
6b857d4
init
eichhorl Jan 15, 2026
aee217a
compiling
eichhorl Jan 15, 2026
3004f2e
clippy
eichhorl Jan 15, 2026
6b501ae
clean
eichhorl Jan 15, 2026
00abdea
comment
eichhorl Jan 15, 2026
7864e1d
fix test
eichhorl Jan 15, 2026
bd97a32
fix
eichhorl Jan 15, 2026
1e126d7
clean
eichhorl Jan 16, 2026
5d1614d
Merge branch 'master' into eichhorl/early-remote-nidkg
eichhorl Jan 16, 2026
ae94556
update
eichhorl Jan 22, 2026
3c8f909
Merge branch 'master' into eichhorl/early-remote-nidkg-2
eichhorl Jan 22, 2026
e96cc22
progress
eichhorl Jan 23, 2026
b13a95e
Merge branch 'eichhorl/early-remote-nidkg-2' of github.com:dfinity/ic…
eichhorl Jan 23, 2026
a461ab6
errors
eichhorl Jan 23, 2026
b5d2d10
clean
eichhorl Jan 26, 2026
325b6b8
fix
eichhorl Jan 26, 2026
e2a4aab
Automatically updated Cargo*.lock
Jan 26, 2026
d250dbe
Automatically fixing code for linting and formatting issues
Jan 26, 2026
7e7dce4
use correct threshold
eichhorl Jan 27, 2026
35e6b00
include height
eichhorl Jan 27, 2026
ca29e9b
types
eichhorl Feb 2, 2026
e538cd0
test
eichhorl Feb 2, 2026
fdcc343
test
eichhorl Feb 2, 2026
f7c05f4
fix
eichhorl Feb 2, 2026
0e6d05e
fix tests
eichhorl Feb 2, 2026
f22f252
merge
eichhorl Feb 2, 2026
0654f21
docs
eichhorl Feb 3, 2026
3fec9d0
add vetkd test case
eichhorl Feb 3, 2026
c0bfd10
merge
eichhorl Feb 17, 2026
85ad8fd
test
eichhorl Feb 26, 2026
917d35c
test
eichhorl Feb 27, 2026
960c67a
target_ids
eichhorl Feb 27, 2026
ed0dce2
include errors
eichhorl Mar 2, 2026
cf2c455
include errors
eichhorl Mar 2, 2026
3b051ff
Revert "include errors"
eichhorl Mar 3, 2026
7a81bf3
assumption
eichhorl Mar 3, 2026
0c410fe
ignore completed test
eichhorl Mar 3, 2026
1294e62
Merge branch 'master' into eichhorl/early-remote-nidkg-2
eichhorl Mar 3, 2026
b688aea
test
eichhorl Mar 3, 2026
63ae5f1
Automatically updated Cargo*.lock
Mar 3, 2026
53e680e
prioritize remote dkg
eichhorl Mar 6, 2026
ea39195
clean up test utils
eichhorl Mar 9, 2026
c50c960
inferred return type
eichhorl Mar 9, 2026
a1e2c0d
build_target_id_callback_map docs
eichhorl Mar 9, 2026
00fb1e0
generalize comment
eichhorl Mar 9, 2026
b402350
remove number_of_contexts
eichhorl Mar 10, 2026
a9a4ad0
check against MAX_EARLY_REMOTE_TRANSCRIPTS early
eichhorl Mar 10, 2026
bfabda4
MAX_EARLY_REMOTE_TRANSCRIPTS test
eichhorl Mar 10, 2026
2697f4e
rename
eichhorl Mar 10, 2026
762f6ac
skip context with insufficient dealings test
eichhorl Mar 10, 2026
df49ee5
ensure retried transcripts are completed by the summary
eichhorl Mar 10, 2026
9bc0679
add log
eichhorl Mar 10, 2026
e8d49e5
Merge branch 'eichhorl/early-remote-nidkg-2' into eichhorl/prioritize…
eichhorl Mar 10, 2026
a66ee46
review
eichhorl Mar 10, 2026
ee78f6b
Merge branch 'eichhorl/early-remote-nidkg-2' into eichhorl/prioritize…
eichhorl Mar 10, 2026
68860fb
create configs early
eichhorl Mar 13, 2026
c5821b9
rename
eichhorl Mar 13, 2026
a149828
rm
eichhorl Mar 13, 2026
a59dd90
test
eichhorl Mar 26, 2026
3de6ab1
update
eichhorl Mar 31, 2026
1c227ad
update
eichhorl Mar 31, 2026
f6f2037
revert
eichhorl Mar 31, 2026
065c9e6
fix
eichhorl Mar 31, 2026
fcf1669
fix
eichhorl Mar 31, 2026
9f8de9d
fix
eichhorl Mar 31, 2026
8652441
Merge branch 'master' into eichhorl/early-remote-nidkg-2
eichhorl Mar 31, 2026
e618dad
Merge branch 'eichhorl/early-remote-nidkg-2' into eichhorl/prioritize…
eichhorl Mar 31, 2026
19ef286
fix
eichhorl Mar 31, 2026
f164c99
merge
eichhorl Mar 31, 2026
a9be68f
impl
eichhorl Apr 1, 2026
a1801b0
impl
eichhorl Apr 2, 2026
9281bd6
merge
eichhorl Apr 2, 2026
4713eb9
reader
eichhorl Apr 2, 2026
8d6fda2
review
eichhorl Apr 13, 2026
189ea78
clippy
eichhorl Apr 13, 2026
d365095
impl
eichhorl Apr 15, 2026
cf0fb8d
fix
eichhorl Apr 15, 2026
5097da3
fix
eichhorl Apr 16, 2026
3333cb9
fix
eichhorl Apr 16, 2026
306fd9a
merge
eichhorl Apr 16, 2026
899c3dc
fix
eichhorl Apr 16, 2026
2398fb8
merge
eichhorl Apr 16, 2026
11abd3d
fix
eichhorl Apr 16, 2026
15d51fb
merge
eichhorl Apr 23, 2026
429d301
merge
eichhorl Apr 23, 2026
7074dd4
Revert "Draft: create configs early"
eichhorl Apr 23, 2026
ecd3644
Reapply "Draft: create configs early"
eichhorl Apr 23, 2026
05fcb84
merge
eichhorl Apr 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
460 changes: 331 additions & 129 deletions rs/consensus/dkg/src/lib.rs

Large diffs are not rendered by default.

197 changes: 106 additions & 91 deletions rs/consensus/dkg/src/payload_builder.rs

Large diffs are not rendered by default.

51 changes: 42 additions & 9 deletions rs/consensus/dkg/src/payload_validator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use self::payload_builder::create_early_remote_transcripts;
use super::{crypto_validate_dealing, payload_builder, utils};
use crate::remote::{build_callback_id_config_map, merge_configs};
use ic_consensus_utils::{crypto::ConsensusCrypto, pool_reader::PoolReader};
use ic_interfaces::{
dkg::{DkgPayloadValidationError, DkgPool},
Expand All @@ -15,7 +15,10 @@ use ic_types::{
batch::ValidationContext,
consensus::{
Block, BlockPayload,
dkg::{DkgDataPayload, DkgPayloadValidationFailure, DkgSummary, InvalidDkgPayloadReason},
dkg::{
DkgDataPayload, DkgPayloadCreationError, DkgPayloadValidationFailure, DkgSummary,
InvalidDkgPayloadReason,
},
},
};
use prometheus::IntCounterVec;
Expand Down Expand Up @@ -117,6 +120,8 @@ pub fn validate_payload(
});

validate_dealings_payload(
subnet_id,
registry_client,
crypto,
pool_reader,
dkg_pool,
Expand All @@ -134,8 +139,11 @@ pub fn validate_payload(
}

// Validates the payload containing dealings.
#[allow(clippy::too_many_arguments)]
#[allow(clippy::result_large_err)]
fn validate_dealings_payload(
subnet_id: SubnetId,
registry_client: &dyn RegistryClient,
crypto: &dyn ConsensusCrypto,
pool_reader: &PoolReader<'_>,
dkg_pool: &dyn DkgPool,
Expand Down Expand Up @@ -181,6 +189,20 @@ fn validate_dealings_payload(
return Err(InvalidDkgPayloadReason::DealerAlreadyDealt(dealer_id).into());
}

let state = state_reader
.get_state_at(validation_context.certified_height)
.map_err(DkgPayloadCreationError::StateManagerError)?;

let remote_config_results = build_callback_id_config_map(
subnet_id,
registry_client,
state.get_ref(),
validation_context.registry_version,
last_summary,
log,
)?;
let configs = merge_configs(&last_summary.configs, &remote_config_results);

// Check that all messages have a valid DKG config from the summary and the
// dealer is valid, then verify each dealing.
for message in &dealings.messages {
Expand All @@ -192,7 +214,7 @@ fn validate_dealings_payload(
continue;
}

let Some(config) = last_summary.configs.get(&message.content.dkg_id) else {
let Some(config) = configs.get(&message.content.dkg_id) else {
return Err(InvalidDkgPayloadReason::MissingDkgConfigForDealing.into());
};

Expand All @@ -202,14 +224,12 @@ fn validate_dealings_payload(

// If we have early transcripts, we compare them
if !dealings.transcripts_for_remote_subnets.is_empty() {
let expected_transcripts = create_early_remote_transcripts(
let expected_transcripts = payload_builder::create_early_remote_transcripts(
pool_reader,
crypto,
parent,
last_summary,
state_reader,
validation_context,
log.clone(),
remote_config_results,
log,
)?;

if dealings.transcripts_for_remote_subnets != expected_transcripts {
Expand Down Expand Up @@ -246,11 +266,13 @@ mod tests {
dkg::ChangeAction,
p2p::consensus::{MutablePool, PoolMutationsProducer},
};
use ic_interfaces_state_manager::Labeled;
use ic_logger::no_op_logger;
use ic_metrics::MetricsRegistry;
use ic_registry_keys::make_subnet_record_key;
use ic_test_utilities_consensus::fake::FakeContentSigner;
use ic_test_utilities_registry::SubnetRecordBuilder;
use ic_test_utilities_state::get_initial_state;
use ic_test_utilities_types::ids::{
NODE_1, NODE_2, NODE_3, SUBNET_1, SUBNET_2, node_test_id, subnet_test_id,
};
Expand Down Expand Up @@ -707,6 +729,13 @@ mod tests {
.build(),
)],
);
state_manager
.get_mut()
.expect_get_latest_certified_state()
.return_const(Some(Labeled::new(
Height::new(0),
Arc::new(get_initial_state(0, 0)),
)));

// Both summary registry versions should be 1 initially
let summary_block = pool.as_cache().summary_block();
Expand Down Expand Up @@ -758,6 +787,9 @@ mod tests {
let key_manager = Arc::new(Mutex::new(key_manager));
let dkg_impl = DkgImpl::new(
node_id,
subnet_id,
registry.clone(),
state_manager.clone(),
crypto.clone(),
pool.get_cache(),
key_manager,
Expand All @@ -778,9 +810,10 @@ mod tests {
};

// It should be possible to validate the dealing
let configs = dkg_summary.configs.iter().collect();
let result = dkg_impl.validate_dealings_for_dealer(
&dkg_pool,
&dkg_summary.configs,
&configs,
start_height,
vec![dealing],
);
Expand Down
61 changes: 59 additions & 2 deletions rs/consensus/dkg/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use ic_types::{
};
use std::{
collections::{BTreeMap, BTreeSet},
sync::Arc,
sync::{Arc, Mutex},
};

pub(super) fn make_setup_initial_dkg_context(
Expand Down Expand Up @@ -59,6 +59,23 @@ pub(super) fn make_reshare_chain_key_context(
})
}

fn clone_subnet_call_context(context: &SubnetCallContext) -> SubnetCallContext {
match context {
SubnetCallContext::SetupInitialDKG(c) => SubnetCallContext::SetupInitialDKG(c.clone()),
SubnetCallContext::CanisterHttpRequest(c) => {
SubnetCallContext::CanisterHttpRequest(c.clone())
}
SubnetCallContext::ReshareChainKey(c) => SubnetCallContext::ReshareChainKey(c.clone()),
SubnetCallContext::BitcoinGetSuccessors(c) => {
SubnetCallContext::BitcoinGetSuccessors(c.clone())
}
SubnetCallContext::BitcoinSendTransactionInternal(c) => {
SubnetCallContext::BitcoinSendTransactionInternal(c.clone())
}
SubnetCallContext::SignWithThreshold(c) => SubnetCallContext::SignWithThreshold(c.clone()),
}
}

/// Set up the state manager mock to return an initial state containing the
/// given subnet call contexts.
pub(super) fn complement_state_manager_with_dkg_contexts(
Expand All @@ -73,13 +90,53 @@ pub(super) fn complement_state_manager_with_dkg_contexts(
.subnet_call_context_manager
.push_context(context);
}
let state = Arc::new(state);
let mut mock = state_manager.get_mut();
let expectation = mock
.expect_get_state_at()
.return_const(Ok(Labeled::new(Height::new(0), Arc::new(state))));
.return_const(Ok(Labeled::new(Height::new(0), state.clone())));
if let Some(times) = times {
expectation.times(times);
}

mock.expect_get_latest_certified_state()
.return_const(Some(Labeled::new(Height::new(0), state.clone())));
}

/// Set up the state manager mock to return an initial state built from a
/// mutable context vector on every call.
pub(super) fn complement_state_manager_with_dkg_contexts_mut(
state_manager: Arc<RefMockStateManager>,
contexts: Arc<Mutex<Vec<SubnetCallContext>>>,
times: Option<usize>,
) {
let mut mock = state_manager.get_mut();
let state_for_get_state_at = contexts.clone();
let expectation = mock.expect_get_state_at().returning(move |_| {
let mut state = ic_test_utilities_state::get_initial_state(0, 0);
for context in state_for_get_state_at.lock().unwrap().iter() {
state
.metadata
.subnet_call_context_manager
.push_context(clone_subnet_call_context(context));
}
Ok(Labeled::new(Height::new(0), Arc::new(state)))
});
if let Some(times) = times {
expectation.times(times);
}

let state_for_latest_certified = contexts;
mock.expect_get_latest_certified_state().returning(move || {
let mut state = ic_test_utilities_state::get_initial_state(0, 0);
for context in state_for_latest_certified.lock().unwrap().iter() {
state
.metadata
.subnet_call_context_manager
.push_context(clone_subnet_call_context(context));
}
Some(Labeled::new(Height::new(0), Arc::new(state)))
});
}

pub(super) fn complement_state_manager_with_setup_initial_dkg_request(
Expand Down
3 changes: 3 additions & 0 deletions rs/consensus/tests/framework/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ impl<'a> ConsensusRunner<'a> {
);
let dkg = ic_consensus_dkg::DkgImpl::new(
deps.replica_config.node_id,
deps.replica_config.subnet_id,
Arc::clone(&deps.registry_client),
deps.state_manager.clone(),
Arc::clone(&consensus_crypto),
deps.consensus_pool.read().unwrap().get_cache(),
dkg_key_manager,
Expand Down
9 changes: 9 additions & 0 deletions rs/consensus/tests/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ fn consensus_produces_expected_batches() {
Height::new(0),
Arc::new(get_initial_state(0, 0)),
)));
state_manager
.expect_get_latest_certified_state()
.return_const(Some(Labeled::new(
Height::new(0),
Arc::new(get_initial_state(0, 0)),
)));
state_manager
.expect_get_certified_state_snapshot()
.returning(|| None);
Expand Down Expand Up @@ -185,6 +191,9 @@ fn consensus_produces_expected_batches() {
ic_consensus::consensus::ConsensusBouncer::new(&metrics_registry, router.clone());
let dkg = ic_consensus_dkg::DkgImpl::new(
replica_config.node_id,
replica_config.subnet_id,
Arc::clone(&registry_client) as Arc<_>,
Arc::clone(&state_manager) as Arc<_>,
Arc::clone(&fake_crypto) as Arc<_>,
Arc::clone(&consensus_cache),
dkg_key_manager,
Expand Down
3 changes: 3 additions & 0 deletions rs/replica/setup_ic_network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ fn start_consensus(
abortable_broadcast_channels.dkg,
ic_consensus_dkg::DkgImpl::new(
node_id,
subnet_id,
Arc::clone(&registry_client),
Arc::clone(&state_manager) as Arc<_>,
Arc::clone(&consensus_crypto),
Arc::clone(&consensus_pool_cache),
dkg_key_manager,
Expand Down
Loading