From 8a84109c8831954eb81d19455b6e70b51138cbed Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Wed, 17 Oct 2018 12:04:13 +0200 Subject: [PATCH] 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. --- Cargo.toml | 4 ++-- src/broadcast/broadcast.rs | 8 ++++---- src/broadcast/message.rs | 4 ++-- src/subset.rs | 10 +++++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 35a7b82..27f2c0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ bincode = "1.0.0" byteorder = "1.2.3" env_logger = "0.5.10" failure = "0.1" -hex_fmt = "0.1" +hex_fmt = "0.2" init_with = "1.1.0" log = "0.4.1" rand = "0.4.2" @@ -30,7 +30,7 @@ rand_derive = "0.3.1" reed-solomon-erasure = "3.1.0" serde = "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" [dev-dependencies] diff --git a/src/broadcast/broadcast.rs b/src/broadcast/broadcast.rs index ebba349..4b90e68 100644 --- a/src/broadcast/broadcast.rs +++ b/src/broadcast/broadcast.rs @@ -133,14 +133,14 @@ impl Broadcast { // Convert the iterator over slices into a vector of slices. 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 self.coding .encode(&mut shards) .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. 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())) .collect(); - debug!("Reconstructed shards: {:?}", HexList(&shards)); + debug!("Reconstructed shards: {:0.10}", HexList(&shards)); // Construct the Merkle tree. let mtree = MerkleTree::from_vec(shards); @@ -459,6 +459,6 @@ fn glue_shards(m: MerkleTree>, n: usize) -> Option> { _ => return None, // The proposing node is faulty: no payload size. }; let payload: Vec = bytes.take(payload_len).collect(); - debug!("Glued data shards {:?}", HexFmt(&payload)); + debug!("Glued data shards {:0.10}", HexFmt(&payload)); Some(payload) } diff --git a/src/broadcast/message.rs b/src/broadcast/message.rs index 553d46c..bb210f0 100644 --- a/src/broadcast/message.rs +++ b/src/broadcast/message.rs @@ -42,7 +42,7 @@ impl Debug for Message { match *self { 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::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 { write!( f, - "Proof {{ #{}, root_hash: {:?}, value: {:?}, .. }}", + "Proof {{ #{}, root_hash: {:0.10}, value: {:0.10}, .. }}", &self.0.index(), HexFmt(self.0.root_hash()), HexFmt(self.0.value()) diff --git a/src/subset.rs b/src/subset.rs index 3d565e2..a3fa275 100644 --- a/src/subset.rs +++ b/src/subset.rs @@ -95,7 +95,11 @@ impl DistAlgorithm for Subset { type Error = Error; fn handle_input(&mut self, input: Self::Input) -> Result> { - debug!("{:?} Proposing {:?}", self.netinfo.our_id(), HexFmt(&input)); + debug!( + "{:?} Proposing {:0.10}", + self.netinfo.our_id(), + HexFmt(&input) + ); self.send_proposed_value(input) } @@ -225,7 +229,7 @@ impl Subset { }; 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 .extend(Some(SubsetOutput::Contribution(proposer_id.clone(), value))); None @@ -313,7 +317,7 @@ impl Subset { } } 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 .extend(Some(SubsetOutput::Contribution(proposer_id.clone(), value))); }