mirror of https://github.com/poanetwork/hbbft.git
skip InProgress state for non-KG changes, revert change to comment, push serialization inside epoch_state, skip threshold_decryption Step, use getter instead of pub(crate) for honey_badger.encryption_schedule
This commit is contained in:
parent
92a32d827d
commit
6b101ca3be
|
@ -300,7 +300,7 @@ where
|
|||
self.update_encryption_schedule(batch_epoch + 1, *schedule)?
|
||||
}
|
||||
});
|
||||
ChangeState::InProgress(change)
|
||||
ChangeState::Complete(change)
|
||||
} else {
|
||||
ChangeState::None
|
||||
};
|
||||
|
@ -380,7 +380,7 @@ where
|
|||
.encryption_schedule(if let Some(schedule) = encryption_schedule {
|
||||
schedule
|
||||
} else {
|
||||
self.honey_badger.encryption_schedule
|
||||
self.honey_badger.get_encryption_schedule()
|
||||
}).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ struct KeyGenState<N> {
|
|||
key_gen: SyncKeyGen<N>,
|
||||
/// The change for which key generation is performed.
|
||||
change: NodeChange<N>,
|
||||
/// The number of key generation messages received from the candidate. At most _N + 1_ are
|
||||
/// The number of key generation messages received from each peer. At most _N + 1_ are
|
||||
/// accepted.
|
||||
msg_count: BTreeMap<N, usize>,
|
||||
}
|
||||
|
|
|
@ -217,18 +217,20 @@ where
|
|||
/// If the instance hasn't terminated yet, inputs our encrypted contribution.
|
||||
pub fn propose(
|
||||
&mut self,
|
||||
proposal: Vec<u8>,
|
||||
proposal: &C,
|
||||
rng: &mut Box<dyn Rng + Send + Sync>,
|
||||
) -> Result<Step<C, N>> {
|
||||
let ser_prop =
|
||||
bincode::serialize(&proposal).map_err(|err| ErrorKind::ProposeBincode(*err))?;
|
||||
let cs_step = self.subset.handle_input(if self.require_decryption {
|
||||
let ciphertext = self
|
||||
.netinfo
|
||||
.public_key_set()
|
||||
.public_key()
|
||||
.encrypt_with_rng(rng, proposal);
|
||||
.encrypt_with_rng(rng, ser_prop);
|
||||
bincode::serialize(&ciphertext).map_err(|err| ErrorKind::ProposeBincode(*err))?
|
||||
} else {
|
||||
proposal
|
||||
ser_prop
|
||||
})?;
|
||||
self.process_subset(cs_step)
|
||||
}
|
||||
|
@ -326,7 +328,8 @@ where
|
|||
step.extend(if self.require_decryption {
|
||||
self.send_decryption_share(k.clone(), &v)?
|
||||
} else {
|
||||
self.process_decryption(k.clone(), td::Step::default().with_output(v))?
|
||||
self.decryption.insert(k.clone(), DecryptionState::Complete(v));
|
||||
Step::default()
|
||||
});
|
||||
self.accepted_proposers.insert(k);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ use std::collections::btree_map::Entry;
|
|||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use bincode;
|
||||
use rand::{Rand, Rng};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
|
@ -36,7 +35,7 @@ pub struct HoneyBadger<C, N: Rand> {
|
|||
/// Represents the optimization strategy to use for output of the `Subset` algorithm.
|
||||
pub(super) subset_handling_strategy: SubsetHandlingStrategy,
|
||||
/// The schedule for which rounds we should use threshold encryption.
|
||||
pub(crate) encryption_schedule: EncryptionSchedule,
|
||||
pub(super) encryption_schedule: EncryptionSchedule,
|
||||
}
|
||||
|
||||
pub type Step<C, N> = ::Step<HoneyBadger<C, N>>;
|
||||
|
@ -91,8 +90,6 @@ where
|
|||
return Ok(Step::default());
|
||||
}
|
||||
self.has_input = true;
|
||||
let ser_prop =
|
||||
bincode::serialize(&proposal).map_err(|err| ErrorKind::ProposeBincode(*err))?;
|
||||
let epoch = self.epoch;
|
||||
let mut step = {
|
||||
let epoch_state = {
|
||||
|
@ -102,7 +99,7 @@ where
|
|||
)
|
||||
};
|
||||
let rng = &mut self.rng;
|
||||
epoch_state.propose(ser_prop, rng)?
|
||||
epoch_state.propose(proposal, rng)?
|
||||
};
|
||||
step.extend(self.try_output_batches()?);
|
||||
Ok(step)
|
||||
|
@ -137,6 +134,10 @@ where
|
|||
!self.netinfo.is_validator() || self.has_input
|
||||
}
|
||||
|
||||
pub fn get_encryption_schedule(&self) -> EncryptionSchedule {
|
||||
self.encryption_schedule
|
||||
}
|
||||
|
||||
/// Returns the number of validators from which we have already received a proposal for the
|
||||
/// current epoch.
|
||||
pub(crate) fn received_proposals(&self) -> usize {
|
||||
|
|
Loading…
Reference in New Issue