mod: remove btcutil circular dependency with main module#1825
mod: remove btcutil circular dependency with main module#1825guggero wants to merge 13 commits intobtcsuite:masterfrom
btcutil circular dependency with main module#1825Conversation
dd5377c to
ad8be88
Compare
|
Rebased after dependent PR was merged. |
|
Thanks a ton for both #1823 and #1824. In this PR, I'm curious about the new submodules: Thanks again guys! I don't mean to overstep with my questions, just curious and wanting to help. |
ad8be88 to
915b225
Compare
|
Thanks for your input, @chappjc! |
Ahh, yes, Down in dcrd, @davecgh resolved this by introducing a Anyway, a |
915b225 to
0630734
Compare
|
Rebased on top of #1831. |
Pull Request Test Coverage Report for Build 1994552374Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
0630734 to
e7e4ac4
Compare
e7e4ac4 to
4309c27
Compare
|
From my point of view (a consumer), this is looking great. Looks like one of the last packages I import that will still come from the main Other than |
4309c27 to
b2c2e38
Compare
|
Given recent issues, txscript should really start at Combined with the "ambiguous import" issues with chainhash recently (#1839), I think all new modules should start at v2 to be safe (if packages of the same name had previously existed, so not btcutil/address), and existing ones that have those types in their API's (e.g. btcutil has in it's API types from chaincfg, chainhash, and wire) should be updated and have their module import path bumped as well. The order with which all these modules are created is obviously going to require care, but I think it needs to be done if these modules are going to be created. Lastly, I think the best move for the next btcd module tag should be a |
|
Care to rebase this? 😅 |
416b4f0 to
09aab7d
Compare
|
I rebased everything and created new |
| ) | ||
|
|
||
| // TODO(guggero): Remove once we have a tagged version of the chainhash package. | ||
| replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash |
There was a problem hiding this comment.
One question that comes to mind here: will we maintain a top level replace for development versions, and only go through the dance of tagging and updating all the modules for releases?
There was a problem hiding this comment.
Hmm, we've employed both strategies in different projects (replace directive for easier PRs vs. needing to do a PR for the submodule first, then tag, then second PR to use the new feature).
Not really sure which makes more sense for this project.
Since these packages are mainly used as library modules and there isn't a lot of new functionality added to the main daemon, I slightly lean toward the "no replace directive" approach.
|
Here're some diagrams to visualize the before/after, and why we had a circular dep issue in the first place: beforegraph TD
btcd[btcd<br/>main module]
btcutil[btcutil<br/>• Address types<br/>• Amount<br/>• Block utilities]
txscript[txscript<br/>• Script execution<br/>• Signature verification<br/>• Address validation]
wire[wire<br/>• Protocol messages<br/>• Serialization]
chaincfg[chaincfg<br/>• Network parameters<br/>• Genesis blocks]
chainhash[chainhash<br/>• Hash primitives<br/>• Block/Tx hashes]
%% Direct dependencies
btcd --> btcutil
btcd --> txscript
btcd --> wire
btcd --> chaincfg
btcutil --> chaincfg
btcutil --> chainhash
btcutil --> wire
btcutil -.->|CIRCULAR!| txscript
txscript --> wire
txscript --> chaincfg
txscript --> chainhash
txscript -.->|CIRCULAR!| btcutil
wire --> chainhash
chaincfg --> chainhash
%% Highlight the circular dependency with high contrast colors
style btcutil fill:#ff6b6b,stroke:#c92a2a,stroke-width:3px,color:#fff
style txscript fill:#ff6b6b,stroke:#c92a2a,stroke-width:3px,color:#fff
style btcd fill:#495057,stroke:#343a40,color:#fff
style wire fill:#868e96,stroke:#495057,color:#fff
style chaincfg fill:#868e96,stroke:#495057,color:#fff
style chainhash fill:#adb5bd,stroke:#495057,color:#000
%% Add annotation
btcutil -.- annotation[" ⚠️ Circular Dependency<br/>btcutil needs txscript for validation<br/>txscript needs btcutil for Address types"]
style annotation fill:#ffe066,stroke:#f08c00,stroke-dasharray: 5 5,color:#000
aftergraph TD
btcd_v2[btcd<br/>main module]
btcutil_v2[btcutil/v2<br/>• Amount<br/>• Block utilities<br/>• Focused scope]
address_v2[address/v2<br/>• Address types<br/>• Base58/Bech32<br/>• Encoding/Decoding<br/>✨ NEW MODULE]
txscript_v2[txscript/v2<br/>• Script execution<br/>• Signature verification<br/>• Uses address/v2]
wire_v2[wire/v2<br/>• Protocol messages<br/>• Serialization]
chaincfg_v2[chaincfg/v2<br/>• Network parameters<br/>• Genesis blocks]
chainhash_v2[chainhash/v2<br/>• Hash primitives<br/>• Block/Tx hashes]
%% Clean dependency flow - bottom to top
chainhash_v2 --> wire_v2
chainhash_v2 --> chaincfg_v2
wire_v2 --> address_v2
chaincfg_v2 --> address_v2
chainhash_v2 --> address_v2
address_v2 --> txscript_v2
wire_v2 --> txscript_v2
chaincfg_v2 --> txscript_v2
chainhash_v2 --> txscript_v2
txscript_v2 --> btcutil_v2
address_v2 --> btcutil_v2
wire_v2 --> btcutil_v2
chaincfg_v2 --> btcutil_v2
chainhash_v2 --> btcutil_v2
btcutil_v2 --> btcd_v2
txscript_v2 --> btcd_v2
wire_v2 --> btcd_v2
chaincfg_v2 --> btcd_v2
%% Highlight with high contrast colors
style address_v2 fill:#51cf66,stroke:#2f9e44,stroke-width:3px,color:#000
style btcutil_v2 fill:#4dabf7,stroke:#1971c2,stroke-width:2px,color:#000
style txscript_v2 fill:#4dabf7,stroke:#1971c2,stroke-width:2px,color:#000
style btcd_v2 fill:#495057,stroke:#343a40,color:#fff
style wire_v2 fill:#868e96,stroke:#495057,color:#fff
style chaincfg_v2 fill:#868e96,stroke:#495057,color:#fff
style chainhash_v2 fill:#adb5bd,stroke:#495057,color:#000
%% Add success annotation
address_v2 -.- success[" ✅ Problem Solved!<br/>Address types extracted to new module<br/>No more circular dependencies<br/>Clean dependency hierarchy"]
style success fill:#8ce99a,stroke:#51cf66,stroke-dasharray: 5 5,color:#000
|
5097f95 to
8bf72c6
Compare
8bf72c6 to
2888372
Compare
|
Rebased. |
|
Thank you for the hard work, this make sense, if it makes us closer to eliminating circular go module dependencies. |
|
Could this be merged? It looks like a great improvement to use btcd modularly. |
Depends on #1824.Removes the circular dependency between the main module and the
btcutilsub module by introducing a bunch of new sub modules.