-
Notifications
You must be signed in to change notification settings - Fork 115
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
taprpc+multi: concert taprpc
into a versioned Go module
#1090
base: main
Are you sure you want to change the base?
Conversation
60fda5e
to
391c465
Compare
Pull Request Test Coverage Report for Build 10425996277Details
💛 - Coveralls |
4cc2f05
to
3371bdf
Compare
This commit transfers the marshal functions in marshal.go to a newly created rpcutils package. This preliminary change is necessary to facilitate the conversion of taprpc into a versioned Go module.
With this commit taprpc is converted to a separate go module.
3371bdf
to
596791e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncertain about this change, as it seems primarily targeted at Go developers. However, won't the users of those endpoints still require the marshal/unmarshal functions that this PR separates from the RPC endpoint definitions? I suspect they will still need to use them, which could undermine the intended benefits of this change.
I also appreciate the current scoping we have. For example, the existing oraclerpc.IsAssetBtc
is more contextually clear compared to something like rpcutils.IsAssetBtc
. Simply moving the code might not be sufficient, as we lose valuable context when shifting to a more generic scope like rpcutils
. I think we need to consider additional steps to preserve that context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see why we need to move out the marshal functions from the taprpc
sub package, since they depend on other packages in taproot-assets
, which would create a super awkward circular module dependency once we turn things into a module.
But maybe we don't need to move everything, just the stuff that does generic marshaling/unmarshaling? To address some of @ffranr's concerns?
@@ -207,3 +206,6 @@ require ( | |||
// We want to format raw bytes as hex instead of base64. The forked version | |||
// allows us to specify that as an option. | |||
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display | |||
|
|||
// Note this is a temproary replace and will be removd when taprpc is tagged. | |||
replace github.com/lightninglabs/taproot-assets/taprpc => ./taprpc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess a go.work
file wouldn't really help us here, at least not much. It would allow us to not have this replace
directive. But any external project depending on this one would still need to pull the git hash/version from here, so we still need to push a tag and update the go.mod
file regularly...
This makes everything quite cumbersome, especially in lightning-terminal
... But I don't really have a better solution...
out.ProofDeliveryComplete.WhenSome(func(complete bool) { | ||
if complete { | ||
proofDeliveryStatus = taprpc.ProofDeliveryStatusComplete | ||
proofDeliveryStatus = rpcutils.ProofDeliveryStatusComplete //nolint: lll |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add nolint comment before if
so it counts for both branches and doesn't make line even longer?
|
||
// IsAssetBtc is a helper function that returns true if the given asset | ||
// specifier represents BTC, and false otherwise. | ||
func IsAssetBtc(assetSpecifier *priceoraclerpc.AssetSpecifier) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this method doesn't actually pull in any other taproot-assets
packages, I think we can keep it where it is to address @ffranr's concerns re naming/context.
@@ -82,7 +83,7 @@ func newAddr(ctx *cli.Context) error { | |||
client, cleanUp := getClient(ctx) | |||
defer cleanUp() | |||
|
|||
assetVersion, err := taprpc.MarshalAssetVersion( | |||
assetVersion, err := rpcutils.MarshalAssetVersion( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can call this package rpcmarshal
instead, so it's more clear only marshaling functions (but from any sub RPC package) should go here.
My primary goal was to reduce dependencies in the lightning-terminal repository, ensuring we rely solely on protobuf-generated Go code. I believe this approach could benefit many projects. Additionally, this effort is part of a broader initiative aimed at ensuring the lightning-terminal repository only depends on versioned RPC modules.
I believe scoping could be addressed separately. Better naming of the functions might resolve the issue, or alternatively, we could add scoping within the rpcutils package. |
Yes, unfortunately
Would that address your concerns @ffranr ? |
I don't see the rationale for why litd should depend exclusively on protobuf-generated Go code. These are the questions I've asked myself, and I think the answer is negative on all counts:
Please help me see what I'm missing here. I would have thought that the compiler could drop any unused code, maybe not? Maybe it does simplify litd dev work somehow?
But doesn't litd also need to use the (un)marshalling functionality? |
I think these are all great questions and from I'd like to create an integration testing framework where I run |
modernc.org/strutil v1.2.0 // indirect | ||
modernc.org/token v1.1.0 // indirect | ||
sigs.k8s.io/yaml v1.2.0 // indirect | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need the existing replace
that was being used for the tap
project?
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we only need that in the main module where we actually use the code from the forked version.
Noting that this is also an issue that also affects users building in other languages. |
@bhandras, remember to re-request review from reviewers when ready |
With this PR,
taprpc
can now be used in other projects without also pulling in the entiretaproot-assets
repository as a dependency. This modularization is desirable because it reduces unnecessary dependencies, leading to cleaner and more efficient codebases. Additionally, it allows for more focused and manageable updates, improves build times, and enhances the reusability oftaprpc
in various contexts.