Skip to content

Commit 5811ea5

Browse files
authored
Merge pull request #543 from EspressoSystems/tw/rm-test
Remove `run_dkg_handover_decryption_phase_e2e`.
2 parents c5e76f7 + cceb60e commit 5811ea5

File tree

1 file changed

+9
-187
lines changed

1 file changed

+9
-187
lines changed

timeboost-sequencer/src/decrypt.rs

Lines changed: 9 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,15 @@ impl Drop for Decrypter {
427427
enum WorkerState {
428428
/// Obtains the threshold decryption key from DKG bundles.
429429
///
430-
/// A node can recover its threshold decryption key in two ways:
430+
/// A node can recover its threshold decryption key in two ways:
431431
/// 1. **Consensus**: by combining DKG bundles extracted directly from candidate lists produced
432432
/// by peers.
433433
/// 2. **Network**: by receiving and combining an agreed-upon subset of DKG bundles from a
434434
/// designated set of peers.
435435
///
436-
/// For the initial DKG, method (1) is used.
437-
/// For resharing, method (2) is used, with the source peers being the previous committee.
438-
/// When catching up—whether during the initial DKG or after resharing—the node also uses
436+
/// For the initial DKG, method (1) is used.
437+
/// For resharing, method (2) is used, with the source peers being the previous committee.
438+
/// When catching up—whether during the initial DKG or after resharing—the node also uses
439439
/// method (2), but obtains the bundles from the current committee.
440440
DkgPending(HashMap<PublicKey, DkgSubset>),
441441
/// Active mode with decryption key ready.
@@ -448,7 +448,7 @@ impl Default for WorkerState {
448448
}
449449
}
450450

451-
/// A `Worker` handles the production, exchange, and combination of decryption shares
451+
/// A `Worker` handles the production, exchange, and combination of decryption shares
452452
/// in coordination with other peers. See [`Decrypter`] for details.
453453
#[derive(Builder)]
454454
struct Worker {
@@ -1546,7 +1546,6 @@ mod tests {
15461546
time::Instant,
15471547
};
15481548
use test_utils::ports::alloc_port;
1549-
use timeboost_config::DECRYPTER_PORT_OFFSET;
15501549
use timeboost_utils::types::logging;
15511550

15521551
use cliquenet::AddressableCommittee;
@@ -1573,7 +1572,6 @@ mod tests {
15731572
const TEST_SEQNO: u64 = 10;
15741573
const RETAIN_ROUNDS: usize = 100;
15751574
const COM1: u64 = 1;
1576-
const COM2: u64 = 2;
15771575

15781576
// Pre-generated deterministic keys for consistent testing
15791577
// Generated via: `just mkconfig_local 5 --seed 42`
@@ -1585,14 +1583,6 @@ mod tests {
15851583
"6LMMEuoPRCkpDsnxnANCRCBC6JagdCHs2pjNicdmQpQE",
15861584
];
15871585

1588-
const COM2_SIGNATURE_PRIVATE_KEY_STRINGS: [&str; COMMITTEE_SIZE] = [
1589-
"6YJc9asDJQsFFHHg8iX23oL1sySx2EgTGM8CqDd71WMa",
1590-
"6NZdk8EGRSVS7sSjcjMiC8vL4KcSY41ELU6HaKyk1Drk",
1591-
"AMJEYXVhS4FfoqfD6VL5nZTNbzJQdtgdxBcVEAwZnLJ3",
1592-
"5mLCMSVT4f8HPqCqdKChxugpMcQ3x1C7hwfEnsTApFfp",
1593-
"4yhZYmNvAouKFpiYomrV9aH8kUZTLRH2hiCZtJzcAASa",
1594-
];
1595-
15961586
const COM1_DH_PRIVATE_KEY_STRINGS: [&str; COMMITTEE_SIZE] = [
15971587
"BB3zUfFQGfw3sL6bpp1JH1HozK6ehEDmRGoiCpQH62rZ",
15981588
"4hjtciEvuoFVT55nAzvdP9E76r18QwntWwFoeginCGnP",
@@ -1601,14 +1591,6 @@ mod tests {
16011591
"39wAn3bQzpn19oa8CiaNUFd8GekQAJMMuzrbp8Jt3FKz",
16021592
];
16031593

1604-
const COM2_DH_PRIVATE_KEY_STRINGS: [&str; COMMITTEE_SIZE] = [
1605-
"Ho9ZZCkP1i6f12fkWGUZucJxX2qbv9L3UbB56sqwjvkw",
1606-
"F5E9cp5qUe4z2wdaRYvEhFMYXaLy4sEX1rwCWRcTH69i",
1607-
"5zhwDWJ1ut6q871aHCHmH7QRCHDykXjUSEriGTLkwezL",
1608-
"2PojAT3g5iqGTrgLhTRKKHqwbeoFhRkzkYLM9AttFoKK",
1609-
"Bk2wY7o2YE9gpu6jxiRSbWiMU88H8s9D9MQGMaF2LJ7h",
1610-
];
1611-
16121594
const COM1_DKG_PRIVATE_KEY_STRINGS: [&str; COMMITTEE_SIZE] = [
16131595
"BW8gq8MARtDkSJL6daobPtGQm22TKkXdbLNrNGngNGTB",
16141596
"ARtqWGmRWrBqZUr4MmiLaPgzjsiKp5USsC9iQNRMZYy4",
@@ -1617,18 +1599,10 @@ mod tests {
16171599
"GFvv2wcQmiGpk5rFp1FGpeUjnVUyZmGM9k8VHb1Jn7EG",
16181600
];
16191601

1620-
const COM2_DKG_PRIVATE_KEY_STRINGS: [&str; COMMITTEE_SIZE] = [
1621-
"GLNPt6EYeFQbq8cCX5nKMA4LbCKdrUN5o5hmWTPJbkJZ",
1622-
"2n3Pz5NeUAVu5YaWgXN9CCrS6rC7NZwVZ48AG8m7JRqF",
1623-
"AGxRDhGvgovb1DZMjL3Y6Q4hF6UUpFCtpPD6sTJd827U",
1624-
"A3GUHxG3cPKvCch6XowztrHrrvaGS5JH3CuXQKCxQEnv",
1625-
"216zC1MgfV54cJJtt3AKdjJHhqfgZLZCmEyCkFN1bPoF",
1626-
];
1627-
1628-
#[test]
16291602
/// Tests the local DKG (Distributed Key Generation) end-to-end flow without networking.
16301603
/// Verifies that committee members can generate threshold decryption keys and perform
16311604
/// threshold encryption/decryption operations.
1605+
#[test]
16321606
fn test_local_dkg_e2e() {
16331607
logging::init_logging();
16341608
let mut rng = thread_rng();
@@ -1949,9 +1923,9 @@ mod tests {
19491923
);
19501924
}
19511925

1952-
#[tokio::test]
19531926
/// Tests integrated DKG to ensure it terminates with consistent public encryption keys
19541927
/// across all committee members in a networked environment.
1928+
#[tokio::test]
19551929
async fn test_dkg_termination() {
19561930
logging::init_logging();
19571931
let (mut decrypters, setup) = setup(
@@ -1985,174 +1959,22 @@ mod tests {
19851959
}
19861960
}
19871961

1988-
#[tokio::test]
19891962
/// Tests the complete DKG and decryption phase end-to-end flow in a networked environment.
19901963
/// Verifies that encrypted transactions can be properly decrypted after DKG completion.
1964+
#[tokio::test]
19911965
async fn test_dkg_and_decryption_phase_e2e() {
19921966
run_dkg_and_decryption_phase_e2e(false).await;
19931967
}
19941968

1995-
#[tokio::test]
19961969
/// Tests the complete DKG and decryption phase end-to-end flow in a networked environment.
19971970
/// Verifies that encrypted transactions can be properly decrypted after DKG completion.
19981971
/// The node that is catching up will not have the dealings locally enqueued but will instead
19991972
/// fetch the dealings from other nodes to obtain the DKG key material.
1973+
#[tokio::test]
20001974
async fn test_dkg_and_decryption_phase_e2e_with_catchup() {
20011975
run_dkg_and_decryption_phase_e2e(true).await;
20021976
}
20031977

2004-
#[tokio::test]
2005-
/// Tests the full spectrum of Decrypter states:
2006-
/// 1. Initial committee completes dkg and decrypts transactions.
2007-
/// 2. NextCommittee and UseCommittee events are triggered adding nodes to the network.
2008-
/// 3. Resharing is done in the background among new/old committee members.
2009-
/// 4. Old committee decrypts its last inclusion list triggering committee switch.
2010-
/// 5. New committee decrypts its first inclusion list using key from resharing.
2011-
async fn run_dkg_handover_decryption_phase_e2e() {
2012-
logging::init_logging();
2013-
2014-
let (mut com1_decrypters, com1_setup) = setup(
2015-
COM1,
2016-
&COM1_SIGNATURE_PRIVATE_KEY_STRINGS,
2017-
&COM1_DH_PRIVATE_KEY_STRINGS,
2018-
&COM1_DKG_PRIVATE_KEY_STRINGS,
2019-
None,
2020-
)
2021-
.await;
2022-
tracing::info!("COM1 decrypters and setup initialized");
2023-
2024-
let com1_round = RoundNumber::new(DECRYPTION_ROUND);
2025-
2026-
enqueue_all_dkg_bundles(&mut com1_decrypters, None).await;
2027-
tracing::info!("All DKG bundles enqueued for COM1");
2028-
2029-
for cell in com1_setup.dec_keys() {
2030-
cell.read().await;
2031-
}
2032-
tracing::info!("COM1 DKG keys generated and available");
2033-
2034-
let encryption_key = com1_setup.dec_keys()[0]
2035-
.get()
2036-
.expect("encryption key should be generated after DKG");
2037-
2038-
let com2_round = RoundNumber::new(DECRYPTION_ROUND + 1);
2039-
let (mut com2_decrypters, com2_setup) = setup(
2040-
COM2,
2041-
&COM2_SIGNATURE_PRIVATE_KEY_STRINGS,
2042-
&COM2_DH_PRIVATE_KEY_STRINGS,
2043-
&COM2_DKG_PRIVATE_KEY_STRINGS,
2044-
Some(com1_setup.clone()),
2045-
)
2046-
.await;
2047-
tracing::info!("COM2 decrypters and setup initialized with previous committee");
2048-
2049-
// trigger NextCommittee event at each decrypter in COM1
2050-
for decrypter in com1_decrypters.iter_mut() {
2051-
let mut sf_addr = com2_setup.addr_comm().clone();
2052-
sf_addr.update_addresses(|a| a.clone().with_port(a.port() - DECRYPTER_PORT_OFFSET));
2053-
decrypter
2054-
.next_committee(sf_addr, com2_setup.key_store().clone())
2055-
.await
2056-
.expect("next committee event succeeds");
2057-
}
2058-
tracing::info!("NextCommittee event triggered for all COM1 decrypters");
2059-
2060-
let priority_tx_message = b"Priority message for old committee";
2061-
let regular_tx_message = b"Non-priority message for old committee";
2062-
2063-
let encrypted_inclusion_list = create_encrypted_inclusion_list(
2064-
com1_round,
2065-
com1_setup.addr_comm().committee().clone(),
2066-
com1_setup.sig_keys(),
2067-
encryption_key.pubkey(),
2068-
priority_tx_message,
2069-
regular_tx_message,
2070-
);
2071-
tracing::info!("Encrypted inclusion list created for COM1 round");
2072-
2073-
// enqueues the same inclusion list to all nodes in COM1
2074-
for decrypter in com1_decrypters.iter_mut() {
2075-
decrypter
2076-
.enqueue(encrypted_inclusion_list.clone())
2077-
.await
2078-
.expect("Inclusion list should be enqueued successfully");
2079-
}
2080-
tracing::info!("Encrypted inclusion list enqueued to all COM1 decrypters");
2081-
2082-
let _ = collect_inclusion_lists(&mut com1_decrypters).await;
2083-
tracing::info!("Decrypted inclusion lists collected from COM1 decrypters");
2084-
2085-
// enqueue resharing bundles (for COM2) at each decrypter in COM1
2086-
enqueue_all_dkg_bundles(&mut com1_decrypters, Some(com2_setup.key_store().clone())).await;
2087-
tracing::info!("Resharing bundles enqueued for COM2 at all COM1 decrypters");
2088-
2089-
// trigger UseCommittee event for COM2
2090-
for decrypter in com2_decrypters.iter_mut() {
2091-
decrypter
2092-
.use_committee(Round::new(com2_round, COM2))
2093-
.await
2094-
.expect("use committee event succeeds");
2095-
}
2096-
tracing::info!("UseCommittee event triggered for COM2 decrypters");
2097-
2098-
let priority_tx_message = b"Priority message for new committee";
2099-
let regular_tx_message = b"Non-priority message for new committee";
2100-
2101-
let encrypted_inclusion_list = create_encrypted_inclusion_list(
2102-
com2_round,
2103-
com2_setup.addr_comm().committee().clone(),
2104-
com2_setup.sig_keys(),
2105-
encryption_key.pubkey(), // same encryption key
2106-
priority_tx_message,
2107-
regular_tx_message,
2108-
);
2109-
tracing::info!("Encrypted inclusion list created for COM2 round");
2110-
2111-
for new_decrypter in com2_decrypters.iter_mut() {
2112-
new_decrypter
2113-
.enqueue(encrypted_inclusion_list.clone())
2114-
.await
2115-
.expect("Inclusion list should be enqueued successfully");
2116-
}
2117-
tracing::info!("Encrypted inclusion list enqueued to all COM2 decrypters");
2118-
2119-
let decrypted_inclusion_lists = collect_inclusion_lists(&mut com2_decrypters).await;
2120-
tracing::info!("Decrypted inclusion lists collected from COM2 decrypters");
2121-
2122-
// Verify that all decrypted inclusion lists are correct
2123-
for decrypted_list in decrypted_inclusion_lists {
2124-
assert_eq!(
2125-
decrypted_list.round(),
2126-
com2_round,
2127-
"Decrypted list should have the expected round number"
2128-
);
2129-
assert_eq!(
2130-
decrypted_list.priority_bundles().len(),
2131-
1,
2132-
"Should have exactly one priority bundle"
2133-
);
2134-
assert_eq!(
2135-
decrypted_list.regular_bundles().len(),
2136-
1,
2137-
"Should have exactly one regular bundle"
2138-
);
2139-
2140-
let decrypted_priority_data = decrypted_list.priority_bundles()[0].bundle().data();
2141-
let decrypted_regular_data = decrypted_list.regular_bundles()[0].data();
2142-
2143-
assert_eq!(
2144-
decrypted_priority_data.to_vec(),
2145-
priority_tx_message.to_vec(),
2146-
"Decrypted priority transaction should match original"
2147-
);
2148-
assert_eq!(
2149-
decrypted_regular_data.to_vec(),
2150-
regular_tx_message.to_vec(),
2151-
"Decrypted regular transaction should match original"
2152-
);
2153-
}
2154-
}
2155-
21561978
/// Helper to run DKG and decryption phase E2E test.
21571979
async fn run_dkg_and_decryption_phase_e2e(catchup: bool) {
21581980
logging::init_logging();

0 commit comments

Comments
 (0)