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

make dependency secp256k1 optional, fix #391 #441

Merged
merged 1 commit into from Jul 13, 2020

Conversation

yihuang
Copy link
Contributor

@yihuang yihuang commented Jul 13, 2020

fix #391

@codecov-commenter
Copy link

Codecov Report

Merging #441 into master will decrease coverage by 0.0%.
The diff coverage is 0.0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #441     +/-   ##
========================================
- Coverage    30.9%   30.9%   -0.1%     
========================================
  Files         132     132             
  Lines        5502    5504      +2     
  Branches     1710    1711      +1     
========================================
  Hits         1701    1701             
- Misses       2605    2607      +2     
  Partials     1196    1196             
Impacted Files Coverage Δ
tendermint/src/account.rs 52.6% <ø> (ø)
tendermint/src/amino_types/ed25519.rs 36.0% <ø> (ø)
tendermint/src/config/node_key.rs 70.0% <ø> (ø)
tendermint/src/public_key.rs 43.4% <0.0%> (-1.1%) ⬇️
tendermint/src/validator.rs 50.4% <ø> (+0.4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82628f7...48d60e2. Read the comment docs.

@@ -3,7 +3,9 @@
use crate::error::{Error, Kind};
use anomaly::fail;
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};
use signatory::{ecdsa::curve::secp256k1, ed25519};
#[cfg(feature = "secp256k1")]
Copy link
Member

@liamsi liamsi Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we moved everything secp-related into a separate file/module, we can likely just annotate it on the mod level instead? Not blocking this PR but probably worth separating this out (if possible)?

Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untested ACK

@liamsi liamsi requested a review from romac July 13, 2020 15:01
Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

I think this is fine as an initial step towards not only improving the dependency tree for the main use case (ie. using only Ed25519 keys), but also towards improving the API in general for this main use case. Perhaps, as @liamsi suggested, by moving stuff around if possible, or by exposing a slightly different API when the secp256k1 feature is enabled.

As mentioned inline, another thing that we should imho look into is the presence of supposedly unreachable cases (_ => unreachable!()), which may not be when the secp256k1 feature is enabled. But since this PR improves on the previous behavior by making those actually unreachable when the feature is disabled, it's not a blocker.

👍 from me in the meantime, we can discuss further improvements in a follow-up issue.

@@ -49,6 +53,7 @@ impl PublicKey {

/// Get Ed25519 public key
pub fn ed25519(self) -> Option<ed25519::PublicKey> {
#[allow(unreachable_patterns)]
Copy link
Member

@romac romac Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that those _ => unreachable!() patterns were here previously to this PR, but just wanted to mention that those seem inherently unsafe to me (as in: may lead to panics). This PR improves the state of things by making them actually unreachable if the secp265k1 feature is not enabled (hence the need for the annotation), but we should perhaps take a closer look at them in a follow-up issue.

@liamsi liamsi merged commit 1218256 into informalsystems:master Jul 13, 2020
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.

Optional dependencies
4 participants