Support serde by default.

This removes the `serialization-serde` feature, since serde is already
used internally and therefore a dependency anyway.
This commit is contained in:
Andreas Fackler 2018-06-20 10:21:52 +02:00
parent c84c60d826
commit 83f8d61402
11 changed files with 16 additions and 32 deletions

View File

@ -12,18 +12,17 @@ error-chain = "0.11.0"
init_with = "1.1.0"
itertools = "0.7"
log = "0.4.1"
merkle = { git = "https://github.com/afck/merkle.rs", branch = "public-proof" }
merkle = { git = "https://github.com/afck/merkle.rs", branch = "public-proof", features = [ "serialization-serde" ] }
pairing = { version = "0.14.2", features = ["u128-support"] }
protobuf = { version = "2.0.0", optional = true }
rand = "0.4.2"
reed-solomon-erasure = "3.1.0"
ring = "^0.12"
serde = "1.0.55"
serde_derive = { version = "1.0.55", optional = true }
serde_derive = "1.0.55"
[features]
serialization-protobuf = [ "protobuf", "protobuf-codegen-pure" ]
serialization-serde = [ "merkle/serialization-serde", "serde_derive" ]
[build-dependencies]
protobuf-codegen-pure = { version = "2.0.0", optional = true }
@ -42,4 +41,3 @@ required-features = [ "serialization-protobuf" ]
[[example]]
name = "simulation"
required-features = [ "serialization-serde" ]

View File

@ -13,7 +13,7 @@ or incomplete.
An example is included to run a simulation of a network:
$ cargo run --example simulation --features=serialization-serde -- -h
$ cargo run --example simulation -- -h
# Building

View File

@ -3,8 +3,7 @@ use std::mem::replace;
/// A lattice-valued description of the state of `bin_values`, essentially the same as the set of
/// subsets of `bool`.
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum BinValues {
None,
False,

View File

@ -33,8 +33,7 @@ error_chain!{
}
}
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum AgreementContent {
/// `BVal` message.
BVal(bool),
@ -59,8 +58,7 @@ impl AgreementContent {
}
/// Messages sent during the binary Byzantine agreement stage.
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct AgreementMessage {
pub epoch: u32,
pub content: AgreementContent,

View File

@ -33,8 +33,7 @@ error_chain!{
/// The three kinds of message sent during the reliable broadcast stage of the
/// consensus algorithm.
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Clone, PartialEq)]
#[derive(Serialize, Deserialize, Clone, PartialEq)]
pub enum BroadcastMessage {
Value(Proof<Vec<u8>>),
Echo(Proof<Vec<u8>>),

View File

@ -25,8 +25,7 @@ error_chain! {
}
}
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct CommonCoinMessage(Signature<Bls12>);
impl CommonCoinMessage {

View File

@ -32,8 +32,7 @@ error_chain!{
type ProposedValue = Vec<u8>;
/// Message from Common Subset to remote nodes.
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum Message<NodeUid> {
/// A message for the broadcast algorithm concerning the set element proposed by the given node.
Broadcast(NodeUid, BroadcastMessage),

View File

@ -2,7 +2,6 @@ pub mod error;
pub mod poly;
#[cfg(feature = "serialization-protobuf")]
pub mod protobuf_impl;
#[cfg(feature = "serialization-serde")]
mod serde_impl;
use self::poly::{Commitment, Poly};
@ -179,8 +178,7 @@ impl<E: Engine> PartialEq for DecryptionShare<E> {
}
/// A public key and an associated set of public key shares.
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct PublicKeySet<E: Engine> {
/// The coefficients of a polynomial whose value at `0` is the "master key", and value at
/// `i + 1` is key share number `i`.
@ -526,7 +524,6 @@ mod tests {
assert_eq!(20, hash(g0, 20).len());
}
#[cfg(feature = "serialization-serde")]
#[test]
fn test_serde() {
use bincode;

View File

@ -248,11 +248,10 @@ impl<E: Engine> Poly<E> {
}
/// A commitment to a univariate polynomial.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Commitment<E: Engine> {
/// The coefficients of the polynomial.
#[cfg_attr(feature = "serialization-serde", serde(with = "super::serde_impl::projective_vec"))]
#[serde(with = "super::serde_impl::projective_vec")]
coeff: Vec<E::G1>,
}
@ -395,13 +394,12 @@ impl<E: Engine> BivarPoly<E> {
}
/// A commitment to a bivariate polynomial.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BivarCommitment<E: Engine> {
/// The polynomial's degree in each of the two variables.
degree: usize,
/// The commitments to the coefficients.
#[cfg_attr(feature = "serialization-serde", serde(with = "super::serde_impl::projective_vec"))]
#[serde(with = "super::serde_impl::projective_vec")]
coeff: Vec<E::G1>,
}

View File

@ -292,8 +292,7 @@ impl<Tx, NodeUid: Ord> Batch<Tx, NodeUid> {
}
/// A message sent to or received from another node's Honey Badger instance.
#[cfg_attr(feature = "serialization-serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum Message<NodeUid> {
/// A message belonging to the common subset algorithm in the given epoch.
CommonSubset(u64, common_subset::Message<NodeUid>),

View File

@ -82,8 +82,7 @@
//!
//! ## Serialization
//!
//! If the `serialization-serde` feature is enabled in the `Cargo.toml`, `hbbft` is compiled with
//! [serde](https://serde.rs/) support: All message types implement the `Serialize` and
//! `hbbft` supports [serde](https://serde.rs/): All message types implement the `Serialize` and
//! `Deserialize` traits so they can be easily serialized or included as part of other serializable
//! types.
//!
@ -112,7 +111,6 @@ extern crate rand;
extern crate reed_solomon_erasure;
extern crate ring;
extern crate serde;
#[cfg(feature = "serialization-serde")]
#[macro_use]
extern crate serde_derive;