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

chainkit: expose getblockheader #8111

Merged
merged 5 commits into from
Oct 27, 2023

Conversation

jharveyb
Copy link
Contributor

@jharveyb jharveyb commented Oct 24, 2023

Change Description

Description of change / link to associated issue.

Addresses lightninglabs/taproot-assets#315.

Expose the GetBlockHeader call from ChainKit. This was already available from each possible chain.Interface, but not available for users of ChainKit; a similar call was added to NeutrinoKit, but that would not work for users not running with a Neutrino backend.

Steps to Test

Steps for reviewers to follow to test the change.

Compile and run lncli chain getbestblock to get a block hash. Use that as an argument for lncli chain getblockheader and a hex block header should be returned.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@jharveyb
Copy link
Contributor Author

Not sure why so many protos were changed with this.

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.

Useful RPC call! Straight forward changes.

Comments mainly about getting the commits to build, and also seeing why you're generating diff protos.

lnrpc/chainrpc/chainkit.proto Show resolved Hide resolved
lnrpc/chainrpc/chainkit.proto Outdated Show resolved Hide resolved
lnrpc/signrpc/signer.swagger.json Outdated Show resolved Hide resolved
lnrpc/chainrpc/chain_server.go Show resolved Hide resolved
lnwallet/mock.go Outdated Show resolved Hide resolved
@Roasbeef
Copy link
Member

If I build using make rpc, then I get a pretty sizeable diff, similar to what CI shows, stuff like:

-               var err error
-               var annotatedContext context.Context
-               annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/lnrpc.Lightning/AddInvoice", runtime.WithHTTPPathPattern("/v1/invoices"))
+               rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/lnrpc.Lightning/AddInvoice", runtime.WithHTTPPathPattern("/v1/invoices"))
                if err != nil {
                        runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
                        return
                }
-               resp, md, err := local_request_Lightning_AddInvoice_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+               resp, md, err := local_request_Lightning_AddInvoice_0(rctx, inboundMarshaler, server, req, pathParams)
                md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
-               annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+               ctx = runtime.NewServerMetadataContext(ctx, md)
                if err != nil {
-                       runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+                       runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
                        return
                }

@jharveyb
Copy link
Contributor Author

If I build using make rpc, then I get a pretty sizeable diff, similar to what CI shows, stuff like:

-               var err error
-               var annotatedContext context.Context
-               annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/lnrpc.Lightning/AddInvoice", runtime.WithHTTPPathPattern("/v1/invoices"))
+               rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/lnrpc.Lightning/AddInvoice", runtime.WithHTTPPathPattern("/v1/invoices"))
                if err != nil {
                        runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
                        return
                }
-               resp, md, err := local_request_Lightning_AddInvoice_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+               resp, md, err := local_request_Lightning_AddInvoice_0(rctx, inboundMarshaler, server, req, pathParams)
                md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
-               annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+               ctx = runtime.NewServerMetadataContext(ctx, md)
                if err != nil {
-                       runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+                       runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
                        return
                }

Looks like the RPC build step is using a bookworm Docker image, with a newer protobuf compiler?

Swtich to bookworm:

Digest: sha256:445f34008a77b0b98bf1821bf7ef5e37bb63cc42d22ee7c21cc17041070d134f
Status: Downloaded newer image for golang:1.21.0-alpine
Building protobuf compiler docker image...
#0 building with "default" instance using docker driver

#1 [internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 1.26kB done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/golang:1.21.0-bookworm
#3 ...

#4 [auth] library/golang:pull token for registry-1.docker.io
#4 DONE 0.0s

#3 [internal] load metadata for docker.io/library/golang:1.21.0-bookworm
#3 DONE 1.0s

#5 [1/4] FROM docker.io/library/golang:1.21.0-bookworm@sha256:640f192f24852cd875514e18a01977ae87692dca466abed7705ad3c4670b6993

Compiler install:

 #6 3.259 After this operation, 252 MB of additional disk space will be used.
#6 3.259 Get:1 http://deb.debian.org/debian bookworm/main amd64 libicu72 amd64 72.1-3 [9376 kB]
#6 3.372 Get:2 http://deb.debian.org/debian bookworm/main amd64 libxml2 amd64 2.9.14+dfsg-1.3~deb12u1 [687 kB]
#6 3.372 Get:3 http://deb.debian.org/debian bookworm/main amd64 libz3-4 amd64 4.8.12-3.1 [7216 kB]
#6 3.425 Get:4 http://deb.debian.org/debian bookworm/main amd64 libllvm14 amd64 1:14.0.6-12 [21.8 MB]
#6 3.575 Get:5 http://deb.debian.org/debian bookworm/main amd64 libclang-cpp14 amd64 1:14.0.6-12 [11.1 MB]
#6 3.651 Get:6 http://deb.debian.org/debian bookworm/main amd64 clang-format-14 amd64 1:14.0.6-12 [75.0 kB]
#6 3.652 Get:7 http://deb.debian.org/debian bookworm/main amd64 clang-format amd64 1:14.0-55.7~deb12u1 [5256 B]
#6 3.652 Get:8 http://deb.debian.org/debian bookworm/main amd64 zlib1g-dev amd64 1:1.2.13.dfsg-1 [916 kB]
#6 3.659 Get:9 http://deb.debian.org/debian bookworm/main amd64 libprotobuf32 amd64 3.21.12-3 [932 kB]
#6 3.666 Get:10 http://deb.debian.org/debian bookworm/main amd64 libprotobuf-lite32 amd64 3.21.12-3 [261 kB]
#6 3.667 Get:11 http://deb.debian.org/debian bookworm/main amd64 libprotobuf-dev amd64 3.21.12-3 [1283 kB]
#6 3.676 Get:12 http://deb.debian.org/debian bookworm/main amd64 libprotoc32 amd64 3.21.12-3 [829 kB]
#6 3.682 Get:13 http://deb.debian.org/debian bookworm/main amd64 protobuf-compiler amd64 3.21.12-3 [83.9 kB]
#6 3.803 debconf: delaying package configuration, since apt-utils is not installed
#6 3.826 Fetched 54.6 MB in 0s (118 MB/s)
#6 3.840 Selecting previously unselected package libicu72:amd64.
#6 3.840 (Reading database ... 

rpc-check target detects incorrect compiler version:

 Verifying protos.
cd ./lnrpc; ../scripts/check-rest-annotations.sh
if test -n "$(git status --porcelain)"; then echo "Protos not properly formatted or not compiled with v3.4.0"; git status; git diff; exit 1; fi
Protos not properly formatted or not compiled with v3.4.0

@guggero
Copy link
Collaborator

guggero commented Oct 25, 2023

Ah, the error message in the rpc-check target is out of date. Just run make rpc, commit the changes and the make rpc-check shouldn't fail (it basically detects a dirty git working directory, so you can only run it after you committed the changes).

@jharveyb
Copy link
Contributor Author

Ah, the error message in the rpc-check target is out of date. Just run make rpc, commit the changes and the make rpc-check shouldn't fail (it basically detects a dirty git working directory, so you can only run it after you committed the changes).

This worked, and the issue with testing before is from not updating the protos and chainkit.yaml at the same time.

Added a CLI command and itest + release note change, should be ready now.

@jharveyb jharveyb requested a review from Roasbeef October 26, 2023 18:42
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.

utACK, LGTM (pending proper CI run with acceptable level of green).

lnrpc/chainrpc/chainkit.proto Outdated Show resolved Hide resolved
cmd/lncli/neutrino_active.go Show resolved Hide resolved
docs/release-notes/release-notes-0.17.1.md Outdated Show resolved Hide resolved
@jharveyb jharveyb force-pushed the chainkit_add_getblockheader branch from 3e8a50c to 3cc350b Compare October 26, 2023 20:19
@jharveyb
Copy link
Contributor Author

Addressed feedback; the latst windows itest failure looked unrelated.

The linter failures are for 3 81-char lines, which are similar to other 81-char lines in those files and IIUC can't cleanly be shortened according to our style guidelines.

@Roasbeef
Copy link
Member

The linter failures are for 3 81-char lines, which are similar to other 81-char lines in those files and IIUC can't cleanly be shortened according to our style guidelines.

Line ref?

@Roasbeef Roasbeef added this to the v0.17.1 milestone Oct 26, 2023
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 🌷

Pending CI (just approved again)

@jharveyb jharveyb force-pushed the chainkit_add_getblockheader branch from 3cc350b to 4ba332c Compare October 26, 2023 23:07
contractcourt/channel_arbitrator_test.go Outdated Show resolved Hide resolved
lnwallet/btcwallet/blockchain.go Outdated Show resolved Hide resolved
@jharveyb jharveyb force-pushed the chainkit_add_getblockheader branch from 4ba332c to 459a60e Compare October 27, 2023 15:07
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.

tACK, LGTM 🎉

@guggero guggero merged commit 3b7cda9 into lightningnetwork:master Oct 27, 2023
22 of 25 checks passed
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

Successfully merging this pull request may close these issues.

3 participants