mirror of https://github.com/poanetwork/hbbft.git
Use threshold_crypto 0.2.0-beta2 to fix overflow. (#273)
* Use threshold_crypto 0.2.0-beta1 to fix overflow. * Upgrade to hex_fmt 0.2. * Depend on threshold_crypto 0.2.0-beta2. This avoids depending on two different versions of hex_fmt.
This commit is contained in:
parent
26e659079a
commit
8a84109c88
|
@ -22,7 +22,7 @@ bincode = "1.0.0"
|
||||||
byteorder = "1.2.3"
|
byteorder = "1.2.3"
|
||||||
env_logger = "0.5.10"
|
env_logger = "0.5.10"
|
||||||
failure = "0.1"
|
failure = "0.1"
|
||||||
hex_fmt = "0.1"
|
hex_fmt = "0.2"
|
||||||
init_with = "1.1.0"
|
init_with = "1.1.0"
|
||||||
log = "0.4.1"
|
log = "0.4.1"
|
||||||
rand = "0.4.2"
|
rand = "0.4.2"
|
||||||
|
@ -30,7 +30,7 @@ rand_derive = "0.3.1"
|
||||||
reed-solomon-erasure = "3.1.0"
|
reed-solomon-erasure = "3.1.0"
|
||||||
serde = "1.0.55"
|
serde = "1.0.55"
|
||||||
serde_derive = "1.0.55"
|
serde_derive = "1.0.55"
|
||||||
threshold_crypto = { git = "https://github.com/poanetwork/threshold_crypto", tag = "0.2.0-beta" }
|
threshold_crypto = { git = "https://github.com/poanetwork/threshold_crypto", tag = "0.2.0-beta2" }
|
||||||
tiny-keccak = "1.4"
|
tiny-keccak = "1.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -133,14 +133,14 @@ impl<N: NodeIdT> Broadcast<N> {
|
||||||
// Convert the iterator over slices into a vector of slices.
|
// Convert the iterator over slices into a vector of slices.
|
||||||
let mut shards: Vec<&mut [u8]> = shards_iter.collect();
|
let mut shards: Vec<&mut [u8]> = shards_iter.collect();
|
||||||
|
|
||||||
debug!("Shards before encoding: {:?}", HexList(&shards));
|
debug!("Shards before encoding: {:0.10}", HexList(&shards));
|
||||||
|
|
||||||
// Construct the parity chunks/shards
|
// Construct the parity chunks/shards
|
||||||
self.coding
|
self.coding
|
||||||
.encode(&mut shards)
|
.encode(&mut shards)
|
||||||
.expect("the size and number of shards is correct");
|
.expect("the size and number of shards is correct");
|
||||||
|
|
||||||
debug!("Shards: {:?}", HexList(&shards));
|
debug!("Shards: {:0.10}", HexList(&shards));
|
||||||
|
|
||||||
// Create a Merkle tree from the shards.
|
// Create a Merkle tree from the shards.
|
||||||
let mtree = MerkleTree::from_vec(shards.into_iter().map(|shard| shard.to_vec()).collect());
|
let mtree = MerkleTree::from_vec(shards.into_iter().map(|shard| shard.to_vec()).collect());
|
||||||
|
@ -434,7 +434,7 @@ fn decode_from_shards(
|
||||||
.filter_map(|l| l.as_ref().map(|v| v.to_vec()))
|
.filter_map(|l| l.as_ref().map(|v| v.to_vec()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
debug!("Reconstructed shards: {:?}", HexList(&shards));
|
debug!("Reconstructed shards: {:0.10}", HexList(&shards));
|
||||||
|
|
||||||
// Construct the Merkle tree.
|
// Construct the Merkle tree.
|
||||||
let mtree = MerkleTree::from_vec(shards);
|
let mtree = MerkleTree::from_vec(shards);
|
||||||
|
@ -459,6 +459,6 @@ fn glue_shards(m: MerkleTree<Vec<u8>>, n: usize) -> Option<Vec<u8>> {
|
||||||
_ => return None, // The proposing node is faulty: no payload size.
|
_ => return None, // The proposing node is faulty: no payload size.
|
||||||
};
|
};
|
||||||
let payload: Vec<u8> = bytes.take(payload_len).collect();
|
let payload: Vec<u8> = bytes.take(payload_len).collect();
|
||||||
debug!("Glued data shards {:?}", HexFmt(&payload));
|
debug!("Glued data shards {:0.10}", HexFmt(&payload));
|
||||||
Some(payload)
|
Some(payload)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ impl Debug for Message {
|
||||||
match *self {
|
match *self {
|
||||||
Message::Value(ref v) => f.debug_tuple("Value").field(&HexProof(v)).finish(),
|
Message::Value(ref v) => f.debug_tuple("Value").field(&HexProof(v)).finish(),
|
||||||
Message::Echo(ref v) => f.debug_tuple("Echo").field(&HexProof(v)).finish(),
|
Message::Echo(ref v) => f.debug_tuple("Echo").field(&HexProof(v)).finish(),
|
||||||
Message::Ready(ref b) => f.debug_tuple("Ready").field(&HexFmt(b)).finish(),
|
Message::Ready(ref b) => write!(f, "Ready({:0.10})", HexFmt(b)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ impl<'a, T: AsRef<[u8]>> fmt::Debug for HexProof<'a, T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"Proof {{ #{}, root_hash: {:?}, value: {:?}, .. }}",
|
"Proof {{ #{}, root_hash: {:0.10}, value: {:0.10}, .. }}",
|
||||||
&self.0.index(),
|
&self.0.index(),
|
||||||
HexFmt(self.0.root_hash()),
|
HexFmt(self.0.root_hash()),
|
||||||
HexFmt(self.0.value())
|
HexFmt(self.0.value())
|
||||||
|
|
|
@ -95,7 +95,11 @@ impl<N: NodeIdT + Rand> DistAlgorithm for Subset<N> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn handle_input(&mut self, input: Self::Input) -> Result<Step<N>> {
|
fn handle_input(&mut self, input: Self::Input) -> Result<Step<N>> {
|
||||||
debug!("{:?} Proposing {:?}", self.netinfo.our_id(), HexFmt(&input));
|
debug!(
|
||||||
|
"{:?} Proposing {:0.10}",
|
||||||
|
self.netinfo.our_id(),
|
||||||
|
HexFmt(&input)
|
||||||
|
);
|
||||||
self.send_proposed_value(input)
|
self.send_proposed_value(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +229,7 @@ impl<N: NodeIdT + Rand> Subset<N> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let val_to_insert = if let Some(true) = self.ba_results.get(proposer_id) {
|
let val_to_insert = if let Some(true) = self.ba_results.get(proposer_id) {
|
||||||
debug!(" {:?} → {:?}", proposer_id, HexFmt(&value));
|
debug!(" {:?} → {:0.10}", proposer_id, HexFmt(&value));
|
||||||
step.output
|
step.output
|
||||||
.extend(Some(SubsetOutput::Contribution(proposer_id.clone(), value)));
|
.extend(Some(SubsetOutput::Contribution(proposer_id.clone(), value)));
|
||||||
None
|
None
|
||||||
|
@ -313,7 +317,7 @@ impl<N: NodeIdT + Rand> Subset<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(Some(value)) = self.broadcast_results.insert(proposer_id.clone(), None) {
|
if let Some(Some(value)) = self.broadcast_results.insert(proposer_id.clone(), None) {
|
||||||
debug!(" {:?} → {:?}", proposer_id, HexFmt(&value));
|
debug!(" {:?} → {:0.10}", proposer_id, HexFmt(&value));
|
||||||
step.output
|
step.output
|
||||||
.extend(Some(SubsetOutput::Contribution(proposer_id.clone(), value)));
|
.extend(Some(SubsetOutput::Contribution(proposer_id.clone(), value)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue