mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 13:09:24 +00:00
Restore key gen message match from develop
It was modified in response to the handover completion bug, which has now been resolved.
This commit is contained in:
@@ -10,6 +10,7 @@ use ciphersuite::{
|
||||
group::{ff::Field, GroupEncoding},
|
||||
Ciphersuite, Ristretto, Secp256k1,
|
||||
};
|
||||
use dkg::ThresholdParams;
|
||||
|
||||
use serai_client::{
|
||||
primitives::NetworkId,
|
||||
@@ -31,30 +32,31 @@ pub async fn key_gen<C: Ciphersuite>(
|
||||
let id = KeyGenId { session: set.session, attempt: 0 };
|
||||
|
||||
for (i, processor) in processors.iter_mut().enumerate() {
|
||||
loop {
|
||||
let msg = processor.recv_message().await;
|
||||
match &msg {
|
||||
CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::GenerateKey {
|
||||
id: this_id,
|
||||
params,
|
||||
shares,
|
||||
}) => {
|
||||
assert_eq!(id, *this_id);
|
||||
assert_eq!(params.t(), u16::try_from(((coordinators * 2) / 3) + 1).unwrap());
|
||||
assert_eq!(params.n(), u16::try_from(coordinators).unwrap());
|
||||
assert_eq!(*shares, 1);
|
||||
participant_is.push(params.i());
|
||||
break;
|
||||
}
|
||||
CoordinatorMessage::Substrate(
|
||||
messages::substrate::CoordinatorMessage::ConfirmKeyPair { .. },
|
||||
) => {
|
||||
continue;
|
||||
}
|
||||
_ => panic!("unexpected message: {msg:?}"),
|
||||
let msg = processor.recv_message().await;
|
||||
match &msg {
|
||||
CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::GenerateKey {
|
||||
params,
|
||||
..
|
||||
}) => {
|
||||
participant_is.push(params.i());
|
||||
}
|
||||
_ => panic!("unexpected message: {msg:?}"),
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
msg,
|
||||
CoordinatorMessage::KeyGen(messages::key_gen::CoordinatorMessage::GenerateKey {
|
||||
id,
|
||||
params: ThresholdParams::new(
|
||||
u16::try_from(((coordinators * 2) / 3) + 1).unwrap(),
|
||||
u16::try_from(coordinators).unwrap(),
|
||||
participant_is[i],
|
||||
)
|
||||
.unwrap(),
|
||||
shares: 1,
|
||||
})
|
||||
);
|
||||
|
||||
processor
|
||||
.send_message(messages::key_gen::ProcessorMessage::Commitments {
|
||||
id,
|
||||
|
||||
@@ -129,7 +129,7 @@ async fn set_rotation_test() {
|
||||
new_test(
|
||||
|mut processors: Vec<Processor>| async move {
|
||||
// exclude the last processor from keygen since we will add him later
|
||||
let excluded = processors.pop().unwrap();
|
||||
let mut excluded = processors.pop().unwrap();
|
||||
assert_eq!(processors.len(), COORDINATORS);
|
||||
|
||||
let pair5 = insecure_pair_from_name("Eve");
|
||||
@@ -142,6 +142,13 @@ async fn set_rotation_test() {
|
||||
|
||||
// genesis keygen
|
||||
let _ = key_gen::<Secp256k1>(&mut processors, Session(0)).await;
|
||||
// Even the excluded processor should receive the key pair confirmation
|
||||
match excluded.recv_message().await {
|
||||
CoordinatorMessage::Substrate(
|
||||
messages::substrate::CoordinatorMessage::ConfirmKeyPair { session, .. },
|
||||
) => assert_eq!(session, Session(0)),
|
||||
_ => panic!("excluded got message other than ConfirmKeyPair"),
|
||||
}
|
||||
|
||||
// wait until next session to see the effect on coordinator
|
||||
wait_till_next_epoch(&serai).await;
|
||||
|
||||
Reference in New Issue
Block a user