poanetwork / threshold_crypto

A pairing-based threshold cryptosystem for collaborative decryption and signatures used in HoneybadgerBFT implementation
Other
186 stars 71 forks source link

Reimport of Serialize and Deserialize #78

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi there,

The current master branch is broken because you are reimporting Serialize and Deserialize in the src/serde_impl.rs here.

Please fix.

vkomenda commented 5 years ago

Can you please describe your problem? The current master works and is not broken. The explanation for importing Deserialize and Serialize two times is that the line

use serde::{Deserialize, Deserializer, Serialize, Serializer};

imports the traits and the line

use serde_derive::{Deserialize, Serialize};

imports the derive macros. Therefore different constructs are imported and there is no reimport.

ghost commented 5 years ago

When trying to build my crate, I get the following error:

.cargo/registry/src/github.com-1ecc6299db9ec823/threshold_crypto-0.3.0/src/serde_impl.rs:10:20 9 use serde::{Deserialize, Deserializer, Serialize, Serializer}; ----------- previous import of the macro Deserialize here 10 use serde_derive::{Deserialize, Serialize}; ^^^^^^^^^^^--
Deserialize reimported here
help: remove unnecessary import

= note: Deserialize must be defined only once in the macro namespace of this module

and get the same for Serialize

vkomenda commented 5 years ago

Can I see your crate?

ghost commented 5 years ago

I forked threshold_crypto and upgraded to serde 1.0.89 and simply included the "derive" feature. I then removed all mentions of serde_derive and simply use the serde::Serialize and serde::Deserialize.

If you clone threshold_crypto and try cargo test, it will not work when using 1.33.0 nightly:

rustc 1.33.0-nightly (daa53a52a 2019-01-17)

I would suggest not to make use of serde and serde_derive in the same file.

Also, your code is causing troubles for rand 0.6.5... Overall this crate doesn't build in it's current form (at least on my laptop)

error[E0277]: the trait bound rand_hc::Hc128Rng: rand_core::SeedableRng is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/rngs/std.rs:55:6
|
55 | impl SeedableRng for StdRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng is not implemented for rand_hc::Hc128Rng

error[E0277]: the trait bound rand_isaac::IsaacRng: rand_core::SeedableRng is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:50:6
|
50 | impl SeedableRng for IsaacRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng is not implemented for rand_isaac::IsaacRng

error[E0277]: the trait bound rand_isaac::Isaac64Rng: rand_core::SeedableRng is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:96:6
|
96 | impl SeedableRng for Isaac64Rng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng is not implemented for rand_isaac::Isaac64Rng

error[E0277]: the trait bound rand_chacha::ChaChaRng: rand_core::SeedableRng is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:141:6
|
141 | impl SeedableRng for ChaChaRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng is not implemented for rand_chacha::ChaChaRng

error[E0277]: the trait bound rand_hc::Hc128Rng: rand_core::SeedableRng is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:198:6
|
198 | impl SeedableRng for Hc128Rng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng is not implemented for rand_hc::Hc128Rng

error[E0277]: the trait bound rand_xorshift::XorShiftRng: rand_core::SeedableRng is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:239:6
|
239 | impl SeedableRng for XorShiftRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng is not implemented for rand_xorshift::XorShiftRng

error[E0277]: the trait bound rand_hc::Hc128Rng: rand_core::SeedableRng is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/deprecated.rs:279:6
|
279 | impl SeedableRng for StdRng {
| ^^^^^^^^^^^ the trait rand_core::SeedableRng is not implemented for rand_hc::Hc128Rng

error[E0277]: the trait bound rand_hc::Hc128Core: rand_core::block::BlockRngCore is not satisfied
--> /Users/****/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/src/rngs/thread.rs:73:5
73 rng: *mut ReseedingRng<Hc128Core, EntropyRng>, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait rand_core::block::BlockRngCore is not implemented for rand_hc::Hc128Core

note: required by rngs::adapter::reseeding::ReseedingRng

vkomenda commented 5 years ago

Nightly is at 1.35.0 now. I tried cargo clippy with the current stable 1.33.0 and it compiled OK with no errors. Also I updated the versions of serde_derive to 0.6.5 and rand to 1.0.89 and it sill compiled with no errors.

Try stable 1.33 or the latest nightly. Do you have the same errors then?

vkomenda commented 5 years ago

Please try #79 to see if that fixes your issue.

ghost commented 5 years ago

@vkomenda, yes that is the same patch that applied locally to circumvent this issue.

afck commented 5 years ago

Thanks, I merged the fix! (But did you try cargo update? I imagine that would also have resolved the problems?)

afck commented 5 years ago

Fixed in #79. (Please reopen if I misread.)