Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the minimum ecdsa version to v0.16.2 #1899

Merged
merged 3 commits into from
Oct 4, 2023

Conversation

DariuszDepta
Copy link
Member

cosmwasm-crypto crate does not compile with -Zminimal-versions option because of improper dependency to ecdsa in k256 crate. To reproduce the problem, run:

cargo clean && rm Cargo.lock && cargo +nightly build -Zminimal-versions -p cosmwasm-crypto

The result will be:

   Compiling elliptic-curve v0.13.0
   Compiling ecdsa v0.16.0 <-----------------------------------------|
   Compiling k256 v0.13.1
   Compiling ed25519-zebra v3.0.0
   Compiling cosmwasm-crypto v1.4.0 (/home/confio/Work/CosmWasm/cosmwasm/packages/crypto)
error[E0599]: no function or associated item named `from_bytes` found for struct `ecdsa::Signature` in the current scope
  --> packages/crypto/src/secp256k1.rs:53:36
   |
53 |     let mut signature = Signature::from_bytes(&signature.into())
   |                                    ^^^^^^^^^^
   |                                    |
   |                                    function or associated item not found in `Signature<Secp256k1>`
   |                                    help: there is a method with a similar name: `to_bytes`

error[E0599]: no function or associated item named `from_bytes` found for struct `ecdsa::Signature` in the current scope
   --> packages/crypto/src/secp256k1.rs:115:32
    |
115 |     let signature = Signature::from_bytes(&signature.into())
    |                                ^^^^^^^^^^
    |                                |
    |                                function or associated item not found in `Signature<Secp256k1>`
    |                                help: there is a method with a similar name: `to_bytes`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `cosmwasm-crypto` (lib) due to 2 previous errors

The newest version of ecdsa crate is 0.16.8 but is not compatible with version 0.16.0. So specifying -Zminimal-versions uses 0.16.0 version and our code does not compile anymore. The minimum ecdsa version needed to compile cosmwams-crypto is 0.16.2.

This change adds minimum ecdsa dependendency set to 0.16.2.
Now the compilation is successful:

cargo clean && rm Cargo.lock && cargo +nightly build -Zminimal-versions -p cosmwasm-crypto
   Compiling serde_derive v1.0.103
   Compiling elliptic-curve v0.13.2
   Compiling ecdsa v0.16.2 <-----------------------------------------|
   Compiling k256 v0.13.1
   Compiling ed25519-zebra v3.0.0
   Compiling cosmwasm-crypto v1.4.0 (/home/confio/Work/CosmWasm/cosmwasm/packages/crypto)
    Finished dev [unoptimized + debuginfo] target(s) in 8.21s

I hope that after this change, all our crates that use cosmwasm-crypto directly or indirectly via cosmwasm-std will not have to fix ecdsa dependency in Cargo.tomls.

@DariuszDepta DariuszDepta merged commit b3650df into main Oct 4, 2023
@DariuszDepta DariuszDepta deleted the fix-ecdsa-minimal-dependency branch October 4, 2023 07:30
@DariuszDepta DariuszDepta self-assigned this Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants