Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

update btcec dependency #245

Closed
wants to merge 13 commits into from
Closed

update btcec dependency #245

wants to merge 13 commits into from

Conversation

brianathere
Copy link
Contributor

, Proposing this specifically to update to btcec v2 and avoid ambiguous import of chainhash

@@ -3,34 +3,37 @@ module github.com/libp2p/go-libp2p-core
go 1.17

require (
github.com/btcsuite/btcd v0.20.1-beta
github.com/btcsuite/btcd/btcec/v2 v2.1.3
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we only update the btcec dependency in this PR please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I reverted the go.mod and go .sum changes, and then made the change to v2, ran go mod tidy it updated a lot of versions to the semantically compatible updated version. Are you suggesting I manually maintain the files instead of using the tools? Or is there a way of using the tools to only make very specific changes? (I'm reading the manuals, but if there's a pointer I'm happy to follow it)

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't reproduce this.

go get github.com/btcsuite/btcd/btcec/v2
go mod tidy

works perfectly fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm still seeing a bit more change than I expect following the same steps.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks fine now. Thanks.

@marten-seemann
Copy link
Contributor

Can you point us to the release notes for the v2? I didn't find anything in the repo.

@brianathere
Copy link
Contributor Author

Can you point us to the release notes for the v2? I didn't find anything in the repo.

I was unable to find it either when I started looking into how to avoid the ambiguous import that was coming into our project. This thread pointed me in this direction, and with minimal changes, it works.

btcsuite/btcd#1839 (comment)

@marten-seemann
Copy link
Contributor

Looks like there were quite a few changes between v0.22.0-beta and v2.1.3. Not really sure how to review this (or if this is even necessary). The lack of release notes is disturbing though.

 ~/src/go/src/github.com/btcsuite/btcd | @fc36cb25 >
❯ git diff --stat v0.22.0-beta -- btcec/**.go
 btcec/bench_test.go     |  169 ++++++++++++++++----------
 btcec/btcec.go          |  961 ++-----------------------------------------------------------------------------------------------------------------------------------------------
 btcec/btcec_test.go     |  256 +++++++++++++++++++--------------------
 btcec/ciphering.go      |  204 +------------------------------
 btcec/ciphering_test.go |  147 +----------------------
 btcec/curve.go          |   63 ++++++++++
 btcec/error.go          |   19 +++
 btcec/field.go          | 1395 +++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 btcec/field_test.go     | 1048 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------------------------------------------
 btcec/modnscalar.go     |   45 +++++++
 btcec/privkey.go        |   58 ++-------
 btcec/pubkey.go         |  173 +++------------------------
 btcec/pubkey_test.go    |    6 +-
 13 files changed, 906 insertions(+), 3638 deletions(-)

@brianathere
Copy link
Contributor Author

Looks like there were quite a few changes between v0.22.0-beta and v2.1.3. Not really sure how to review this (or if this is even necessary). The lack of release notes is disturbing though.

 ~/src/go/src/github.com/btcsuite/btcd | @fc36cb25 >
❯ git diff --stat v0.22.0-beta -- btcec/**.go
 btcec/bench_test.go     |  169 ++++++++++++++++----------
 btcec/btcec.go          |  961 ++-----------------------------------------------------------------------------------------------------------------------------------------------
 btcec/btcec_test.go     |  256 +++++++++++++++++++--------------------
 btcec/ciphering.go      |  204 +------------------------------
 btcec/ciphering_test.go |  147 +----------------------
 btcec/curve.go          |   63 ++++++++++
 btcec/error.go          |   19 +++
 btcec/field.go          | 1395 +++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 btcec/field_test.go     | 1048 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------------------------------------------
 btcec/modnscalar.go     |   45 +++++++
 btcec/privkey.go        |   58 ++-------
 btcec/pubkey.go         |  173 +++------------------------
 btcec/pubkey_test.go    |    6 +-
 13 files changed, 906 insertions(+), 3638 deletions(-)

Totally agree, I found the lack of documentation about V2 to be uncomfortable.

I believe the test cases in libp2p-core do cover this change, and that gave me confidence this is a working change.

Beyond that, I don't have any deeper insight into how to review this.

@brianathere
Copy link
Contributor Author

@marten-seemann Do you understand why the "API Compatibility" test is failing? I'm not familiar with this type of test, I will fix, but again, pointers would be appreciated if you can provide them.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Needs a rebase, but otherwise this looks fine. It's technically a breaking change because Secp246k1{Public,Private}Key is a newtype (and we're changing the underlying type). However, I don't personally consider that to be a part of the API.

@@ -6,7 +6,8 @@ import (

pb "github.com/libp2p/go-libp2p-core/crypto/pb"

"github.com/btcsuite/btcd/btcec"
btcec "github.com/btcsuite/btcd/btcec/v2"
ecdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa"
Copy link
Member

Choose a reason for hiding this comment

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

rename to btcecdsa (there's an ecdsa in the stdlib).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needs a rebase, but otherwise this looks fine. It's technically a breaking change because Secp246k1{Public,Private}Key is a newtype (and we're changing the underlying type). However, I don't personally consider that to be a part of the API.

I agree that this didn't feel like part of the public interface. I don't know how to reset this to be the new, accepted interface. Can you point me in the right direction to get that test to pass.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that this didn't feel like part of the public interface. I don't know how to reset this to be the new, accepted interface. Can you point me in the right direction to get that test to pass.

It won't pass, but that's fine. It's just a way to let us know very clearly that this is a breaking change. Ideally we'd have something fancier than a failing test... but it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I don't have the permissions to merge or release, how do I request that?

Copy link
Member

Choose a reason for hiding this comment

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

@marten-seemann has the final decision here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks.

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

Can you please clean up the commit history? Ideally, just rebase this on top of the current master and have a single commit.

@marten-seemann marten-seemann changed the title Update dependencies update btcec dependency Apr 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants