btcsuite / btcutil

Provides bitcoin-specific convenience functions and types
477 stars 410 forks source link

Please avoid circular dependencies with btcsuite/btcd #110

Closed aviau closed 2 years ago

aviau commented 6 years ago

It looks like this repository has circular dependencies with btcsuite/btcd.

Maybe the two repositories should be merged? Is there something we can do? This makes it hard for downstream projects like Debian to build them as separate packages.

Cheers,

stevenroose commented 6 years ago

Several subpackages of btcd (like btcec and btcwire f.e.) used to be separate repos as well, but got incorporated in btcd over time. It's usually those packages that btcutil depends on. I think it's fine to have them in btcd, it makes updates that cross multiple packages more convenient. Considering btcutil, I guess it's supposed to be a starting point to use Bitcoin functionality. btcd itself doesn't have a "developer-facing" package with utilities etc. I think that's why it makes sense to have btcutil still separate.

On Sun, Jan 7, 2018 at 8:33 PM, Alexandre Viau notifications@github.com wrote:

It looks like this repository has circular dependencies with btcsuite/btcd.

Maybe the two repositories should be merged? Is there something we can do? This makes it hard for downstream projects like Debian to build them as separate packages.

Cheers,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/btcsuite/btcutil/issues/110, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0F3K7YpQOGHmUKgc2d4HOCuIIZ26frks5tIRwEgaJpZM4RVwbV .

l0k18 commented 5 years ago

I just replicated btcd here: https://git.parallelcoin.io/loki/btcd with the goal, mainly, to remove the variable 'cfg' from the main (it's in btcd.go). It took me about 2 hours. It also required me to merge btclog and btcutil into the repository.

My first shot at it was quick and dirty, the easy solution was to move the config struct definition into its own package (otherwise it would have been a circular dependencies festival) and then peer and several other libraries I amended almost all of their functions to pass through the config structure.

It works perfectly, though I am not entirely happy with the mess of extra, messy additions of that variable. Tomorrow I am going to look at how I can inject it into the state variables of the other packages and remove the dirty parameters.

Of course, feel free to replicate all of the changes into the mainline, since as I can see this issue has been left open.

Just as a minor aside, the tight coupling of everything in this app is a real problem for any serious modification or integration into other packages. It's not just the example mentioned in this issue, I also discovered yesterday this codebase makes the linker integrate almost everything even when you only call a small thing, well, at least, anything within the main package of btcd.

I am building a client for parallelcoin currently, and the mess at the foundations of what I was working from became unbearable. So you can count on my repository above being updated a lot over the next few days as I cut everything up and move many properly speaking independent parts (especially several places there is more than a few types tangled together in one package that rightly should be separated.

l0k18 commented 5 years ago

I just wanted to update on my progress on breaking apart the main of btcd and this package (which I have merged)...

It is now mostly in some kind of sane order, all the separate types now live in their own files and I am steadily working on further splitting types out to live in their own folders, and I realised something: If I continue this process also with several of the components, specifically the parts that differ between different forks of the original bitcoin server (such as the one I am focused on, parallelcoin), I will be able to build an abstraction out of those parts and if I create an interface for this, it will be possible to write these parts for other coins' consensus modules and they would build out of this modified modularised version of btcd.

I will continue along this path and the repository I linked above will continue to have its btcd base main package, and in the parallelcoin main https://git.parallelcoin.io/dev/9 package it will only need to import this package and implement that consensus interface. And other projects will be able to easily do the same thing.

Note that I intend to later on, once I complete the parallelcoin hard fork, also add Cosmos IBC to this package which will allow easy interop with cosmos chain and other new cosmos subchains.

sammy007 commented 4 years ago

Playing with hdkeychain and I see that github.com/btcsuite/btcd/chaincfg brought whole btcd project along. Is there any agreement that such heavy stuff should be phased out? That hdwallet stuff is very useful thing.

Roasbeef commented 2 years ago

The repo now lives in the btcd repo. More sub-modules will eventually get rid of the hard circular dep.

alexeyneu commented 1 year ago

so why you closed it?