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

Circular deps between btcutil and btcd, and tons of duplicated deps with different versions because the versions are inconsistent #2127

Open
benma opened this issue Feb 26, 2024 · 4 comments

Comments

@benma
Copy link
Contributor

benma commented Feb 26, 2024

Start a new project go mod init foo, then go get github.com/btcsuite/btcd, then add a main.go

package main

import (
	_ "github.com/btcsuite/btcd"
)

func main() {

}

```

then 
`go mod tidy`.

The resulting `go.sum` has tons of duplicate deps at different versions, for example

```
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=

The reason is that for example, [email protected] references [email protected]:

btcd/go.mod

Line 5 in d55c55a

github.com/btcsuite/btcd/btcutil v1.1.5

while btcutil in turn references [email protected]

https://github.com/btcsuite/btcd/blob/d55c55a81f8f9cf2b0fa3cbb83e820ea28173081/btcutil/go.mod#L7C1-L7C64

which in turn references an older btcutil, and so on.

Not sure if there are more such instances.

I am unsure why btcutil is a module of its own, can't it just be a package inside btcd and not a module?

If it has to be a module, btcutil and btcd should ideally not depend on each other.

Barring all of that, the two should point to the same versions.

@kcalvinalvin
Copy link
Collaborator

(All things aside) what was the thing you were trying to do? Maybe I could help out there. btcd's main package isn't really meant for outside usage, each of the individual packages are.

@guggero
Copy link
Collaborator

guggero commented Feb 26, 2024

We're aware of that. Still looking for reviewers of #1825.

@benma
Copy link
Contributor Author

benma commented Feb 26, 2024

@kcalvinalvin

(All things aside) what was the thing you were trying to do? Maybe I could help out there.

We are using it in a few projects and I noticed that I could not get rid of the many duplicated deps and wondered why.

btcd's main package isn't really meant for outside usage, each of the individual packages are.

Why not? It's a perfectly usable library. I make use of the wire package a lot to parse Bitcoin transactions, or use the txscript package for various things. These are not nested modules either - what is the benefit of having btcutil being a nested module?

Nested modules are kind of confusing and seem hard to maintain anyway, seems more natural to just make it a package - would there be a downside to that?

@kcalvinalvin
Copy link
Collaborator

Why not? It's a perfectly usable library. I make use of the wire package a lot to parse Bitcoin transactions, or use the txscript package for various things. These are not nested modules either - what is the benefit of having btcutil being a nested module?

Not much besides that it's just been like that.

Nested modules are kind of confusing and seem hard to maintain anyway, seems more natural to just make it a package - would there be a downside to that?

Not that I can think of.

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

No branches or pull requests

3 participants