paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

Perhaps two different versions of crate `schnorrkel` are being used #3245

Closed AurevoirXavier closed 5 years ago

AurevoirXavier commented 5 years ago

I wrote an erc20_demo which similar to substrate-erc20 and it works good.

I change pub trait Trait: system::Trait {} to pub trait Trait: assets::Trait {}, and add a function f() to do something with assets:

decl_module! {
    pub struct Module<T: Trait> for enum Call
        where
            origin: T::Origin
    {
        fn f() {
            let _ = <assets::Module<T>>::next_asset_id();
        }
    }
}

After that I got a compiling error:

   Compiling substrate-primitives v1.0.0 (https://github.com/paritytech/substrate.git?rev=a857f4f88722419a6781e8810028089112380466#a857f4f8)
error[E0308]: mismatched types
   --> /Users/xavier/.cargo/git/checkouts/substrate-7e08433d4c370a21/a857f4f/core/primitives/src/sr25519.rs:494:33
    |
494 |           let mini_key: MiniSecretKey = mini_secret_from_entropy(entropy, password.unwrap_or(""))
    |  _______________________________________^
495 | |             .expect("32 bytes can always build a key; qed");
    | |___________________________________________________________^ expected struct `schnorrkel::keys::MiniSecretKey`, found a different struct `schnorrkel::keys::MiniSecretKey`
    |
    = note: expected type `schnorrkel::keys::MiniSecretKey` (struct `schnorrkel::keys::MiniSecretKey`)
               found type `schnorrkel::keys::MiniSecretKey` (struct `schnorrkel::keys::MiniSecretKey`)
note: Perhaps two different versions of crate `schnorrkel` are being used?
   --> /Users/xavier/.cargo/git/checkouts/substrate-7e08433d4c370a21/a857f4f/core/primitives/src/sr25519.rs:494:33
    |
494 |           let mini_key: MiniSecretKey = mini_secret_from_entropy(entropy, password.unwrap_or(""))
    |  _______________________________________^
495 | |             .expect("32 bytes can always build a key; qed");
    | |___________________________________________________________^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `substrate-primitives`.

Here's cargo tree:

erc20-demo v1.0.0 (/Users/xavier/Documents/program/erc20-demo)
...
├── erc20-demo-runtime v1.0.0 (/Users/xavier/Documents/program/erc20-demo/runtime)
│   ...
│   ├── sr-io v1.0.0 (https://github.com/paritytech/substrate.git?rev=a857f4f88722419a6781e8810028089112380466#a857f4f8)
│   │   ...
│   │   ├── substrate-primitives v1.0.0 (https://github.com/paritytech/substrate.git?rev=a857f4f88722419a6781e8810028089112380466#a857f4f8)
│   │   │   ...
│   │   │   ├── schnorrkel v0.1.1
│   │   │   ...
│   │   │   ├── substrate-bip39 v0.2.2 (https://github.com/paritytech/substrate-bip39#c9cebebb)
│   │   │   │   ...
│   │   │   │   ├── schnorrkel v0.7.0
AurevoirXavier commented 5 years ago

According to stackoverflow, seems the only solution is updating the dependency?

kianenigma commented 5 years ago

@AurevoirXavier: I think you are right and this must be the reason. Good catch!

I remember someone updating this recently, are did you have this issue on master?

AurevoirXavier commented 5 years ago

@kianenigma Just with substrate-node-new xxx xxx, current version is rev = a857f4f88722419a6781e8810028089112380466.

I will try with master.

burdges commented 5 years ago

There is no compatibility between 0.1.1 and 0.7.0, but actually I only published 0.7.0 over the weekend so someone updated pretty fast. Actually transitioning form 0.1.1 to 0.7 will disrupt any testnets.

We're done with the audit and 0.7.0 has the final wire formal, so I'll love to yank 0.1.* shortly. I think yanking would not break any code currently using 0.1.1 but might make it impossible to register new crates as using 0.1.1.

wuminzhe commented 5 years ago

Branch v1.0 also has this problem.

kianenigma commented 5 years ago

closed via https://github.com/paritytech/substrate/pull/3283 and https://github.com/paritytech/substrate/pull/3270