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

verrpc: add GetVersion endpoint #4163

Merged
merged 10 commits into from
Apr 13, 2020

Conversation

cfromknecht
Copy link
Contributor

@cfromknecht cfromknecht commented Apr 8, 2020

This PR adds a minimal verrpc subserver that is purely responsible for serving
version information about the running daemon. Though some of this information is
displayed via GetInfo, it is useful to have a single endpoint and service for this
purpose so that the chances of breaking changes are mitigated.

Third-party applications may not have the ability to be tightly synced with the
daemon, e.g. a mobile app connecting remotely via RPC. In order to support
proto version desynchronization, these apps typically come installed with several
historical versions of the proto files (especially when breaking changes have
been introduced). Apps can then determine the version of the daemon by trying
to decode various requests and looking for signals that indicate the version.

With verrpc, these headaches are largely eliminated. There may still be a need
to package multiple proto versions, but this makes it dead simple to map the
correct version. The intent (crosses fingers) is that this endpoint would never
undergo breaking changes so that app developers have a stable API they rely
on to determine versioning info.

In the future, we could consider separating the initialization of the verrpc
subserver to be active for wallet unlocking as well, but those protos don't
experience nearly as much churn as the others.

@cfromknecht cfromknecht added the rpc Related to the RPC interface label Apr 8, 2020
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Great to see this, we probably should have added this a long time ago.
Did a quick first pass, looks good!

I was wondering if now was the time to also start tackling the wallet unlocker state problem.
We could add a simple Unlocked boolean flag to this new version service.
Then we only need a way to signal that a sub server should also be registered when the WalletUnlocker service is spun up. I was thinking of a marker interface. If the subserver implements it, it's added/registered to the wallet unlocker, if not, it's skipped.
What do you think? It probably also depends on the release you were targeting with this. If this PR should go in with 0.10.0 then the whole unlocker thing is probably out of scope.

cmd/lncli/cmd_version.go Outdated Show resolved Hide resolved
lnrpc/rpc.proto Outdated Show resolved Hide resolved
lnrpc/verrpc/verrpc.proto Outdated Show resolved Hide resolved
Copy link
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

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

As you say, making sure the endpoint is always reachable (also if wallet is still locked) would be nice.

lnrpc/verrpc/verrpc.proto Outdated Show resolved Hide resolved
lnrpc/verrpc/verrpc.proto Show resolved Hide resolved
@cfromknecht
Copy link
Contributor Author

updated to compile build tags and go version into lnd and lncli, new output looks like this:

$ lncli version                 
{
    "lncli": {
        "commit": "v0.9.0-beta-551-ge89f4907f3a3d3ae034b400a44fd10c1567546c7-dirty",
        "commit_hash": "e89f4907f3a3d3ae034b400a44fd10c1567546c7",
        "version": "0.9.0-beta",
        "app_major": 0,
        "app_minor": 9,
        "app_patch": 0,
        "app_pre_release": "beta",
        "build_tags": [
            "routerrpc",
            "invoicesrpc"
        ],
        "go_version": "go1.14"
    },
    "lnd": {
        "commit": "v0.9.0-beta-551-ge89f4907f3a3d3ae034b400a44fd10c1567546c7-dirty",
        "commit_hash": "e89f4907f3a3d3ae034b400a44fd10c1567546c7",
        "version": "0.9.0-beta",
        "app_major": 0,
        "app_minor": 9,
        "app_patch": 0,
        "app_pre_release": "beta",
        "build_tags": [
            "routerrpc",
            "invoicesrpc"
        ],
        "go_version": "go1.14"
    }
}

Makefile Outdated Show resolved Hide resolved
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM, only nits at this point 🎉

lnrpc/verrpc/verrpc.proto Outdated Show resolved Hide resolved
cmd/lncli/cmd_version.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
cmd/lncli/cmd_version.go Outdated Show resolved Hide resolved
cmd/lncli/cmd_version.go Outdated Show resolved Hide resolved
@Roasbeef Roasbeef added this to the 0.10.0 milestone Apr 9, 2020
@Roasbeef Roasbeef added the v0.10 label Apr 9, 2020
@cfromknecht cfromknecht force-pushed the version-rpc branch 4 times, most recently from f8d161c to 38b2dea Compare April 10, 2020 00:11
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 💎

I think we should also tack on the "unlocked" status as that resolves existing issues users have with the current RPC lifecycle with a single field. However, we can do this in the rc phase, not enough to block this PR IMO.

// strings. In particular it MUST only contain characters in
// semanticAlphabet.
for _, r := range AppPreRelease {
if !strings.ContainsRune(semanticAlphabet, r) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice change to panic instead of silently omit characters.

var log btclog.Logger

// Subsystem defines the logging code for this subsystem.
const Subsystem = "VRPC"
Copy link
Member

Choose a reason for hiding this comment

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

Pretty cool that lnd will now ship with an integrated VR PC for the next major release 😎

@Roasbeef Roasbeef merged commit 786e278 into lightningnetwork:master Apr 13, 2020
@cfromknecht cfromknecht deleted the version-rpc branch April 13, 2020 23:04
@githorray
Copy link
Contributor

Building on Windows is no longer working.

go build -v -tags="dev" -o lnd-debug -ldflags \-X github.com/ligh
tningnetwork/lnd/build.Commit=v0.9.0-beta-595-ga53a6f160e25dac4696685d5b5edfb799
194e2d7 -X github.com/lightningnetwork/lnd/build.CommitHash=a53a6f160e25dac46966
85d5b5edfb799194e2d7 -X github.com/lightningnetwork/lnd/build.GoVersion=go1.14.2
 -X github.com/lightningnetwork/lnd/build.RawTags=dev" github.com/lightningnetwo
rk/lnd/cmd/lnd
/usr/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/usr/bin/sh: -c: line 1: syntax error: unexpected end of file
Makefile:107: recipe for target 'build' failed
make: *** [build] Error 258

@guggero
Copy link
Collaborator

guggero commented Apr 14, 2020

Thanks for the report, @githorray! Can you please try if #4190 fixes the problem?

string app_pre_release = 7;

/// The list of build tags that were supplied during comilation.
repeated string build_tags = 8;
Copy link
Contributor

@joostjager joostjager Apr 22, 2020

Choose a reason for hiding this comment

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

Looking at how this field is used in lightninglabs/loop#181 with the string matching and all, shouldn't we replace this with a compatibility flagged enum? It is a compilation symbol leaking into the runtime interface.

@joostjager
Copy link
Contributor

@guggero and I ran into the problem that go get -tags doesn't set the build tags compiler variable. So even though the subservers are enabled, they aren't reported. Maybe conditional compilation of boolean vars would have been better for that.

Worth mentioning in release notes @cfromknecht?

@cfromknecht
Copy link
Contributor Author

I don't think it's necessary. Our install docs are pretty clear that you should build with the makefile. There are a host of other things that you'd be missing if you install via go get like version, commit hash, etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rpc Related to the RPC interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants