From b66e46b8729aa049c7c32852ad0f2765b4d652c2 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 23 Oct 2024 09:44:20 +0200 Subject: [PATCH 01/12] app: use git restore to re-create .gitkeep file This uses the more reliable way to restore the file in git after a build, preventing differences in line endings to cause the file to be seen as dirty in some situations. --- app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/package.json b/app/package.json index c3004bb6f..834ed71a4 100644 --- a/app/package.json +++ b/app/package.json @@ -8,7 +8,7 @@ "start": "BROWSER=none react-scripts start", "develop": "REACT_APP_USE_SAMPLE_DATA=true yarn start", "build": "react-scripts build", - "postbuild": "echo '# Keep directory in git.' > build/.gitkeep", + "postbuild": "git restore build/.gitkeep", "test": "react-scripts test --env=jest-environment-jsdom --transformIgnorePatterns \"node_modules/(?!d3)/\"", "test:ci": "cross-env CI=true yarn test --coverage", "eject": "react-scripts eject", From 65144f2c975fdf8afe900373da85690bcf3ae166 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 21 Oct 2024 14:39:10 +0200 Subject: [PATCH 02/12] GitHub+docker: update to Go 1.22.6 --- .github/workflows/main.yml | 2 +- .golangci.yml | 2 +- Dockerfile | 2 +- autopilotserverrpc/autopilotserver.pb.go | 36 ++++++++--------- dev.Dockerfile | 2 +- litrpc/Dockerfile | 6 +-- litrpc/firewall.pb.go | 16 ++++---- litrpc/firewall.pb.gw.go | 33 +++++----------- litrpc/lit-accounts.pb.go | 28 ++++++------- litrpc/lit-accounts.pb.gw.go | 35 +++++------------ litrpc/lit-accounts.swagger.json | 37 ++++++++++-------- litrpc/lit-autopilot.pb.go | 30 +++++++------- litrpc/lit-autopilot.pb.gw.go | 21 ++++------ litrpc/lit-sessions.pb.go | 50 ++++++++++++------------ litrpc/lit-sessions.pb.gw.go | 21 ++++------ litrpc/lit-status.pb.go | 12 +++--- litrpc/lit-status.pb.gw.go | 9 +++-- litrpc/proxy.pb.go | 18 ++++----- litrpc/proxy.pb.gw.go | 33 +++++----------- tools/Dockerfile | 2 +- 20 files changed, 170 insertions(+), 225 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcb46ffe9..cb4a33d7f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ env: # If you change this value, please change it in the following files as well: # /Dockerfile # /dev.Dockerfile - GO_VERSION: 1.22.3 + GO_VERSION: 1.22.6 jobs: ######################## diff --git a/.golangci.yml b/.golangci.yml index 7ff39caa1..92132a962 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,7 +31,7 @@ linters-settings: - G402 # Look for bad TLS connection settings. - G306 # Poor file permissions used when writing to a new file. staticcheck: - go: "1.18" + go: "1.22.6" checks: ["-SA1019"] linters: diff --git a/Dockerfile b/Dockerfile index 037068a83..6be7121c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,7 +35,7 @@ RUN apk add --no-cache --update alpine-sdk \ # If you change this value, please also update: # /dev.Dockerfile # /.github/workflows/main.yml -FROM golang:1.22.3-alpine as golangbuilder +FROM golang:1.22.6-alpine as golangbuilder # Instead of checking out from git again, we just copy the whole working # directory of the previous stage that includes the generated static assets. diff --git a/autopilotserverrpc/autopilotserver.pb.go b/autopilotserverrpc/autopilotserver.pb.go index dd9aece8e..7e4797dad 100644 --- a/autopilotserverrpc/autopilotserver.pb.go +++ b/autopilotserverrpc/autopilotserver.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc-gen-go v1.34.2 +// protoc v3.21.12 // source: autopilotserver.proto package autopilotserverrpc @@ -1081,7 +1081,7 @@ func file_autopilotserver_proto_rawDescGZIP() []byte { } var file_autopilotserver_proto_msgTypes = make([]protoimpl.MessageInfo, 18) -var file_autopilotserver_proto_goTypes = []interface{}{ +var file_autopilotserver_proto_goTypes = []any{ (*TermsRequest)(nil), // 0: autopilotserverrpc.TermsRequest (*TermsResponse)(nil), // 1: autopilotserverrpc.TermsResponse (*Version)(nil), // 2: autopilotserverrpc.Version @@ -1135,7 +1135,7 @@ func file_autopilotserver_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_autopilotserver_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*TermsRequest); i { case 0: return &v.state @@ -1147,7 +1147,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*TermsResponse); i { case 0: return &v.state @@ -1159,7 +1159,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Version); i { case 0: return &v.state @@ -1171,7 +1171,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ListFeaturesRequest); i { case 0: return &v.state @@ -1183,7 +1183,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*ActivateSessionRequest); i { case 0: return &v.state @@ -1195,7 +1195,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ActivateSessionResponse); i { case 0: return &v.state @@ -1207,7 +1207,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*ListFeaturesResponse); i { case 0: return &v.state @@ -1219,7 +1219,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*Feature); i { case 0: return &v.state @@ -1231,7 +1231,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*Rule); i { case 0: return &v.state @@ -1243,7 +1243,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*Permissions); i { case 0: return &v.state @@ -1255,7 +1255,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*Operation); i { case 0: return &v.state @@ -1267,7 +1267,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*RegisterSessionRequest); i { case 0: return &v.state @@ -1279,7 +1279,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*RegisterSessionResponse); i { case 0: return &v.state @@ -1291,7 +1291,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*RevokeSessionRequest); i { case 0: return &v.state @@ -1303,7 +1303,7 @@ func file_autopilotserver_proto_init() { return nil } } - file_autopilotserver_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_autopilotserver_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*RevokeSessionResponse); i { case 0: return &v.state diff --git a/dev.Dockerfile b/dev.Dockerfile index c8d7e5eaf..528b4f830 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -13,7 +13,7 @@ RUN cd /go/src/github.com/lightninglabs/lightning-terminal/app \ # If you change this value, please also update: # /Dockerfile # /.github/workflows/main.yml -FROM golang:1.22.3-alpine as golangbuilder +FROM golang:1.22.6-alpine as golangbuilder # Instead of checking out from git again, we just copy the whole working # directory of the previous stage that includes the generated static assets. diff --git a/litrpc/Dockerfile b/litrpc/Dockerfile index b2cf12b2e..e60a23ae9 100644 --- a/litrpc/Dockerfile +++ b/litrpc/Dockerfile @@ -1,9 +1,9 @@ -FROM golang:1.19.4-buster +FROM golang:1.22.6-bookworm RUN apt-get update && apt-get install -y \ git \ - protobuf-compiler='3.6*' \ - clang-format='1:7.0*' + protobuf-compiler='3.21.12*' \ + clang-format='1:14.0*' # We don't want any default values for these variables to make sure they're # explicitly provided by parsing the go.mod file. Otherwise we might forget to diff --git a/litrpc/firewall.pb.go b/litrpc/firewall.pb.go index 3f9ce5fa3..23a991ee9 100644 --- a/litrpc/firewall.pb.go +++ b/litrpc/firewall.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc-gen-go v1.34.2 +// protoc v3.21.12 // source: firewall.proto package litrpc @@ -691,7 +691,7 @@ func file_firewall_proto_rawDescGZIP() []byte { var file_firewall_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_firewall_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_firewall_proto_goTypes = []interface{}{ +var file_firewall_proto_goTypes = []any{ (ActionState)(0), // 0: litrpc.ActionState (*PrivacyMapConversionRequest)(nil), // 1: litrpc.PrivacyMapConversionRequest (*PrivacyMapConversionResponse)(nil), // 2: litrpc.PrivacyMapConversionResponse @@ -720,7 +720,7 @@ func file_firewall_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_firewall_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_firewall_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*PrivacyMapConversionRequest); i { case 0: return &v.state @@ -732,7 +732,7 @@ func file_firewall_proto_init() { return nil } } - file_firewall_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_firewall_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*PrivacyMapConversionResponse); i { case 0: return &v.state @@ -744,7 +744,7 @@ func file_firewall_proto_init() { return nil } } - file_firewall_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_firewall_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ListActionsRequest); i { case 0: return &v.state @@ -756,7 +756,7 @@ func file_firewall_proto_init() { return nil } } - file_firewall_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_firewall_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ListActionsResponse); i { case 0: return &v.state @@ -768,7 +768,7 @@ func file_firewall_proto_init() { return nil } } - file_firewall_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_firewall_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Action); i { case 0: return &v.state diff --git a/litrpc/firewall.pb.gw.go b/litrpc/firewall.pb.gw.go index 420e2a4ee..a24a94652 100644 --- a/litrpc/firewall.pb.gw.go +++ b/litrpc/firewall.pb.gw.go @@ -35,11 +35,7 @@ func request_Firewall_ListActions_0(ctx context.Context, marshaler runtime.Marsh var protoReq ListActionsRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -52,11 +48,7 @@ func local_request_Firewall_ListActions_0(ctx context.Context, marshaler runtime var protoReq ListActionsRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -69,11 +61,7 @@ func request_Firewall_PrivacyMapConversion_0(ctx context.Context, marshaler runt var protoReq PrivacyMapConversionRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -86,11 +74,7 @@ func local_request_Firewall_PrivacyMapConversion_0(ctx context.Context, marshale var protoReq PrivacyMapConversionRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -103,6 +87,7 @@ func local_request_Firewall_PrivacyMapConversion_0(ctx context.Context, marshale // UnaryRPC :call FirewallServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterFirewallHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterFirewallHandlerServer(ctx context.Context, mux *runtime.ServeMux, server FirewallServer) error { mux.Handle("POST", pattern_Firewall_ListActions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -161,21 +146,21 @@ func RegisterFirewallHandlerServer(ctx context.Context, mux *runtime.ServeMux, s // RegisterFirewallHandlerFromEndpoint is same as RegisterFirewallHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterFirewallHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -193,7 +178,7 @@ func RegisterFirewallHandler(ctx context.Context, mux *runtime.ServeMux, conn *g // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "FirewallClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "FirewallClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "FirewallClient" to call the correct interceptors. +// "FirewallClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterFirewallHandlerClient(ctx context.Context, mux *runtime.ServeMux, client FirewallClient) error { mux.Handle("POST", pattern_Firewall_ListActions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/litrpc/lit-accounts.pb.go b/litrpc/lit-accounts.pb.go index 753146419..903a8473e 100644 --- a/litrpc/lit-accounts.pb.go +++ b/litrpc/lit-accounts.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc-gen-go v1.34.2 +// protoc v3.21.12 // source: lit-accounts.proto package litrpc @@ -807,7 +807,7 @@ func file_lit_accounts_proto_rawDescGZIP() []byte { } var file_lit_accounts_proto_msgTypes = make([]protoimpl.MessageInfo, 11) -var file_lit_accounts_proto_goTypes = []interface{}{ +var file_lit_accounts_proto_goTypes = []any{ (*CreateAccountRequest)(nil), // 0: litrpc.CreateAccountRequest (*CreateAccountResponse)(nil), // 1: litrpc.CreateAccountResponse (*Account)(nil), // 2: litrpc.Account @@ -848,7 +848,7 @@ func file_lit_accounts_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_lit_accounts_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*CreateAccountRequest); i { case 0: return &v.state @@ -860,7 +860,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*CreateAccountResponse); i { case 0: return &v.state @@ -872,7 +872,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Account); i { case 0: return &v.state @@ -884,7 +884,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*AccountInvoice); i { case 0: return &v.state @@ -896,7 +896,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*AccountPayment); i { case 0: return &v.state @@ -908,7 +908,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*UpdateAccountRequest); i { case 0: return &v.state @@ -920,7 +920,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*ListAccountsRequest); i { case 0: return &v.state @@ -932,7 +932,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*ListAccountsResponse); i { case 0: return &v.state @@ -944,7 +944,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*AccountInfoRequest); i { case 0: return &v.state @@ -956,7 +956,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*RemoveAccountRequest); i { case 0: return &v.state @@ -968,7 +968,7 @@ func file_lit_accounts_proto_init() { return nil } } - file_lit_accounts_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_lit_accounts_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*RemoveAccountResponse); i { case 0: return &v.state diff --git a/litrpc/lit-accounts.pb.gw.go b/litrpc/lit-accounts.pb.gw.go index 4e095eea5..2c867c3be 100644 --- a/litrpc/lit-accounts.pb.gw.go +++ b/litrpc/lit-accounts.pb.gw.go @@ -35,11 +35,7 @@ func request_Accounts_CreateAccount_0(ctx context.Context, marshaler runtime.Mar var protoReq CreateAccountRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -52,11 +48,7 @@ func local_request_Accounts_CreateAccount_0(ctx context.Context, marshaler runti var protoReq CreateAccountRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -69,11 +61,7 @@ func request_Accounts_UpdateAccount_0(ctx context.Context, marshaler runtime.Mar var protoReq UpdateAccountRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -103,11 +91,7 @@ func local_request_Accounts_UpdateAccount_0(ctx context.Context, marshaler runti var protoReq UpdateAccountRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -152,7 +136,7 @@ func local_request_Accounts_ListAccounts_0(ctx context.Context, marshaler runtim } var ( - filter_Accounts_RemoveAccount_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}} + filter_Accounts_RemoveAccount_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_Accounts_RemoveAccount_0(ctx context.Context, marshaler runtime.Marshaler, client AccountsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -225,6 +209,7 @@ func local_request_Accounts_RemoveAccount_0(ctx context.Context, marshaler runti // UnaryRPC :call AccountsServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAccountsHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterAccountsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AccountsServer) error { mux.Handle("POST", pattern_Accounts_CreateAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -333,21 +318,21 @@ func RegisterAccountsHandlerServer(ctx context.Context, mux *runtime.ServeMux, s // RegisterAccountsHandlerFromEndpoint is same as RegisterAccountsHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterAccountsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -365,7 +350,7 @@ func RegisterAccountsHandler(ctx context.Context, mux *runtime.ServeMux, conn *g // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AccountsClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AccountsClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "AccountsClient" to call the correct interceptors. +// "AccountsClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterAccountsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AccountsClient) error { mux.Handle("POST", pattern_Accounts_CreateAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/litrpc/lit-accounts.swagger.json b/litrpc/lit-accounts.swagger.json index 4889c71ff..09a226165 100644 --- a/litrpc/lit-accounts.swagger.json +++ b/litrpc/lit-accounts.swagger.json @@ -139,23 +139,7 @@ "in": "body", "required": true, "schema": { - "type": "object", - "properties": { - "account_balance": { - "type": "string", - "format": "int64", - "description": "The new account balance to set. Set to -1 to not update the balance." - }, - "expiration_date": { - "type": "string", - "format": "int64", - "description": "The new account expiry to set. Set to -1 to not update the expiry. Set to 0\nto never expire." - }, - "label": { - "type": "string", - "description": "The label of the account to update. If an account has no label, then the ID\nmust be used instead." - } - } + "$ref": "#/definitions/AccountsUpdateAccountBody" } } ], @@ -166,6 +150,25 @@ } }, "definitions": { + "AccountsUpdateAccountBody": { + "type": "object", + "properties": { + "account_balance": { + "type": "string", + "format": "int64", + "description": "The new account balance to set. Set to -1 to not update the balance." + }, + "expiration_date": { + "type": "string", + "format": "int64", + "description": "The new account expiry to set. Set to -1 to not update the expiry. Set to 0\nto never expire." + }, + "label": { + "type": "string", + "description": "The label of the account to update. If an account has no label, then the ID\nmust be used instead." + } + } + }, "litrpcAccount": { "type": "object", "properties": { diff --git a/litrpc/lit-autopilot.pb.go b/litrpc/lit-autopilot.pb.go index 7da6f8cf4..796789278 100644 --- a/litrpc/lit-autopilot.pb.go +++ b/litrpc/lit-autopilot.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc-gen-go v1.34.2 +// protoc v3.21.12 // source: lit-autopilot.proto package litrpc @@ -924,7 +924,7 @@ func file_lit_autopilot_proto_rawDescGZIP() []byte { } var file_lit_autopilot_proto_msgTypes = make([]protoimpl.MessageInfo, 15) -var file_lit_autopilot_proto_goTypes = []interface{}{ +var file_lit_autopilot_proto_goTypes = []any{ (*AddAutopilotSessionRequest)(nil), // 0: litrpc.AddAutopilotSessionRequest (*FeatureConfig)(nil), // 1: litrpc.FeatureConfig (*ListAutopilotSessionsRequest)(nil), // 2: litrpc.ListAutopilotSessionsRequest @@ -983,7 +983,7 @@ func file_lit_autopilot_proto_init() { } file_lit_sessions_proto_init() if !protoimpl.UnsafeEnabled { - file_lit_autopilot_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*AddAutopilotSessionRequest); i { case 0: return &v.state @@ -995,7 +995,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*FeatureConfig); i { case 0: return &v.state @@ -1007,7 +1007,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ListAutopilotSessionsRequest); i { case 0: return &v.state @@ -1019,7 +1019,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ListAutopilotSessionsResponse); i { case 0: return &v.state @@ -1031,7 +1031,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*AddAutopilotSessionResponse); i { case 0: return &v.state @@ -1043,7 +1043,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ListAutopilotFeaturesRequest); i { case 0: return &v.state @@ -1055,7 +1055,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*ListAutopilotFeaturesResponse); i { case 0: return &v.state @@ -1067,7 +1067,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*RevokeAutopilotSessionRequest); i { case 0: return &v.state @@ -1079,7 +1079,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*RevokeAutopilotSessionResponse); i { case 0: return &v.state @@ -1091,7 +1091,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*Feature); i { case 0: return &v.state @@ -1103,7 +1103,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*RuleValues); i { case 0: return &v.state @@ -1115,7 +1115,7 @@ func file_lit_autopilot_proto_init() { return nil } } - file_lit_autopilot_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_lit_autopilot_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*Permissions); i { case 0: return &v.state diff --git a/litrpc/lit-autopilot.pb.gw.go b/litrpc/lit-autopilot.pb.gw.go index 20ce9efa1..7929c85c4 100644 --- a/litrpc/lit-autopilot.pb.gw.go +++ b/litrpc/lit-autopilot.pb.gw.go @@ -53,11 +53,7 @@ func request_Autopilot_AddAutopilotSession_0(ctx context.Context, marshaler runt var protoReq AddAutopilotSessionRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -70,11 +66,7 @@ func local_request_Autopilot_AddAutopilotSession_0(ctx context.Context, marshale var protoReq AddAutopilotSessionRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -157,6 +149,7 @@ func local_request_Autopilot_RevokeAutopilotSession_0(ctx context.Context, marsh // UnaryRPC :call AutopilotServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAutopilotHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterAutopilotHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AutopilotServer) error { mux.Handle("GET", pattern_Autopilot_ListAutopilotFeatures_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -265,21 +258,21 @@ func RegisterAutopilotHandlerServer(ctx context.Context, mux *runtime.ServeMux, // RegisterAutopilotHandlerFromEndpoint is same as RegisterAutopilotHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterAutopilotHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -297,7 +290,7 @@ func RegisterAutopilotHandler(ctx context.Context, mux *runtime.ServeMux, conn * // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AutopilotClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AutopilotClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "AutopilotClient" to call the correct interceptors. +// "AutopilotClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterAutopilotHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AutopilotClient) error { mux.Handle("GET", pattern_Autopilot_ListAutopilotFeatures_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/litrpc/lit-sessions.pb.go b/litrpc/lit-sessions.pb.go index 2fa4db7ad..f77393560 100644 --- a/litrpc/lit-sessions.pb.go +++ b/litrpc/lit-sessions.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc-gen-go v1.34.2 +// protoc v3.21.12 // source: lit-sessions.proto package litrpc @@ -1938,7 +1938,7 @@ func file_lit_sessions_proto_rawDescGZIP() []byte { var file_lit_sessions_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_lit_sessions_proto_msgTypes = make([]protoimpl.MessageInfo, 24) -var file_lit_sessions_proto_goTypes = []interface{}{ +var file_lit_sessions_proto_goTypes = []any{ (SessionType)(0), // 0: litrpc.SessionType (SessionState)(0), // 1: litrpc.SessionState (*AddSessionRequest)(nil), // 2: litrpc.AddSessionRequest @@ -2010,7 +2010,7 @@ func file_lit_sessions_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_lit_sessions_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*AddSessionRequest); i { case 0: return &v.state @@ -2022,7 +2022,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*MacaroonPermission); i { case 0: return &v.state @@ -2034,7 +2034,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*AddSessionResponse); i { case 0: return &v.state @@ -2046,7 +2046,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Session); i { case 0: return &v.state @@ -2058,7 +2058,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*MacaroonRecipe); i { case 0: return &v.state @@ -2070,7 +2070,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ListSessionsRequest); i { case 0: return &v.state @@ -2082,7 +2082,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*ListSessionsResponse); i { case 0: return &v.state @@ -2094,7 +2094,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*RevokeSessionRequest); i { case 0: return &v.state @@ -2106,7 +2106,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*RevokeSessionResponse); i { case 0: return &v.state @@ -2118,7 +2118,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*RulesMap); i { case 0: return &v.state @@ -2130,7 +2130,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*RuleValue); i { case 0: return &v.state @@ -2142,7 +2142,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*RateLimit); i { case 0: return &v.state @@ -2154,7 +2154,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*Rate); i { case 0: return &v.state @@ -2166,7 +2166,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*HistoryLimit); i { case 0: return &v.state @@ -2178,7 +2178,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*ChannelPolicyBounds); i { case 0: return &v.state @@ -2190,7 +2190,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[15].Exporter = func(v any, i int) any { switch v := v.(*OffChainBudget); i { case 0: return &v.state @@ -2202,7 +2202,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[16].Exporter = func(v any, i int) any { switch v := v.(*OnChainBudget); i { case 0: return &v.state @@ -2214,7 +2214,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[17].Exporter = func(v any, i int) any { switch v := v.(*SendToSelf); i { case 0: return &v.state @@ -2226,7 +2226,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[18].Exporter = func(v any, i int) any { switch v := v.(*ChannelRestrict); i { case 0: return &v.state @@ -2238,7 +2238,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[19].Exporter = func(v any, i int) any { switch v := v.(*PeerRestrict); i { case 0: return &v.state @@ -2250,7 +2250,7 @@ func file_lit_sessions_proto_init() { return nil } } - file_lit_sessions_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_lit_sessions_proto_msgTypes[20].Exporter = func(v any, i int) any { switch v := v.(*ChannelConstraint); i { case 0: return &v.state @@ -2263,7 +2263,7 @@ func file_lit_sessions_proto_init() { } } } - file_lit_sessions_proto_msgTypes[10].OneofWrappers = []interface{}{ + file_lit_sessions_proto_msgTypes[10].OneofWrappers = []any{ (*RuleValue_RateLimit)(nil), (*RuleValue_ChanPolicyBounds)(nil), (*RuleValue_HistoryLimit)(nil), diff --git a/litrpc/lit-sessions.pb.gw.go b/litrpc/lit-sessions.pb.gw.go index 3559339a6..ef0fa5cc5 100644 --- a/litrpc/lit-sessions.pb.gw.go +++ b/litrpc/lit-sessions.pb.gw.go @@ -35,11 +35,7 @@ func request_Sessions_AddSession_0(ctx context.Context, marshaler runtime.Marsha var protoReq AddSessionRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -52,11 +48,7 @@ func local_request_Sessions_AddSession_0(ctx context.Context, marshaler runtime. var protoReq AddSessionRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -139,6 +131,7 @@ func local_request_Sessions_RevokeSession_0(ctx context.Context, marshaler runti // UnaryRPC :call SessionsServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSessionsHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterSessionsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SessionsServer) error { mux.Handle("POST", pattern_Sessions_AddSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -222,21 +215,21 @@ func RegisterSessionsHandlerServer(ctx context.Context, mux *runtime.ServeMux, s // RegisterSessionsHandlerFromEndpoint is same as RegisterSessionsHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterSessionsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -254,7 +247,7 @@ func RegisterSessionsHandler(ctx context.Context, mux *runtime.ServeMux, conn *g // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SessionsClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SessionsClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "SessionsClient" to call the correct interceptors. +// "SessionsClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterSessionsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SessionsClient) error { mux.Handle("POST", pattern_Sessions_AddSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/litrpc/lit-status.pb.go b/litrpc/lit-status.pb.go index 435c27102..5ceaccf37 100644 --- a/litrpc/lit-status.pb.go +++ b/litrpc/lit-status.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc-gen-go v1.34.2 +// protoc v3.21.12 // source: lit-status.proto package litrpc @@ -236,7 +236,7 @@ func file_lit_status_proto_rawDescGZIP() []byte { } var file_lit_status_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_lit_status_proto_goTypes = []interface{}{ +var file_lit_status_proto_goTypes = []any{ (*SubServerStatusReq)(nil), // 0: litrpc.SubServerStatusReq (*SubServerStatusResp)(nil), // 1: litrpc.SubServerStatusResp (*SubServerStatus)(nil), // 2: litrpc.SubServerStatus @@ -260,7 +260,7 @@ func file_lit_status_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_lit_status_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_lit_status_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*SubServerStatusReq); i { case 0: return &v.state @@ -272,7 +272,7 @@ func file_lit_status_proto_init() { return nil } } - file_lit_status_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_lit_status_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*SubServerStatusResp); i { case 0: return &v.state @@ -284,7 +284,7 @@ func file_lit_status_proto_init() { return nil } } - file_lit_status_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_lit_status_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*SubServerStatus); i { case 0: return &v.state diff --git a/litrpc/lit-status.pb.gw.go b/litrpc/lit-status.pb.gw.go index 8edf5c1b9..a95ec5622 100644 --- a/litrpc/lit-status.pb.gw.go +++ b/litrpc/lit-status.pb.gw.go @@ -53,6 +53,7 @@ func local_request_Status_SubServerStatus_0(ctx context.Context, marshaler runti // UnaryRPC :call StatusServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterStatusHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterStatusHandlerServer(ctx context.Context, mux *runtime.ServeMux, server StatusServer) error { mux.Handle("GET", pattern_Status_SubServerStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -86,21 +87,21 @@ func RegisterStatusHandlerServer(ctx context.Context, mux *runtime.ServeMux, ser // RegisterStatusHandlerFromEndpoint is same as RegisterStatusHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterStatusHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -118,7 +119,7 @@ func RegisterStatusHandler(ctx context.Context, mux *runtime.ServeMux, conn *grp // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "StatusClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "StatusClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "StatusClient" to call the correct interceptors. +// "StatusClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterStatusHandlerClient(ctx context.Context, mux *runtime.ServeMux, client StatusClient) error { mux.Handle("GET", pattern_Status_SubServerStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/litrpc/proxy.pb.go b/litrpc/proxy.pb.go index d39203fdc..56aa65894 100644 --- a/litrpc/proxy.pb.go +++ b/litrpc/proxy.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc-gen-go v1.34.2 +// protoc v3.21.12 // source: proxy.proto package litrpc @@ -343,7 +343,7 @@ func file_proxy_proto_rawDescGZIP() []byte { } var file_proxy_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_proxy_proto_goTypes = []interface{}{ +var file_proxy_proto_goTypes = []any{ (*BakeSuperMacaroonRequest)(nil), // 0: litrpc.BakeSuperMacaroonRequest (*BakeSuperMacaroonResponse)(nil), // 1: litrpc.BakeSuperMacaroonResponse (*StopDaemonRequest)(nil), // 2: litrpc.StopDaemonRequest @@ -371,7 +371,7 @@ func file_proxy_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*BakeSuperMacaroonRequest); i { case 0: return &v.state @@ -383,7 +383,7 @@ func file_proxy_proto_init() { return nil } } - file_proxy_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*BakeSuperMacaroonResponse); i { case 0: return &v.state @@ -395,7 +395,7 @@ func file_proxy_proto_init() { return nil } } - file_proxy_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*StopDaemonRequest); i { case 0: return &v.state @@ -407,7 +407,7 @@ func file_proxy_proto_init() { return nil } } - file_proxy_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_proxy_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*StopDaemonResponse); i { case 0: return &v.state @@ -419,7 +419,7 @@ func file_proxy_proto_init() { return nil } } - file_proxy_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_proxy_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*GetInfoRequest); i { case 0: return &v.state @@ -431,7 +431,7 @@ func file_proxy_proto_init() { return nil } } - file_proxy_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_proxy_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*GetInfoResponse); i { case 0: return &v.state diff --git a/litrpc/proxy.pb.gw.go b/litrpc/proxy.pb.gw.go index c2e46dd90..7fecd1dc1 100644 --- a/litrpc/proxy.pb.gw.go +++ b/litrpc/proxy.pb.gw.go @@ -53,11 +53,7 @@ func request_Proxy_StopDaemon_0(ctx context.Context, marshaler runtime.Marshaler var protoReq StopDaemonRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -70,11 +66,7 @@ func local_request_Proxy_StopDaemon_0(ctx context.Context, marshaler runtime.Mar var protoReq StopDaemonRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -87,11 +79,7 @@ func request_Proxy_BakeSuperMacaroon_0(ctx context.Context, marshaler runtime.Ma var protoReq BakeSuperMacaroonRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -104,11 +92,7 @@ func local_request_Proxy_BakeSuperMacaroon_0(ctx context.Context, marshaler runt var protoReq BakeSuperMacaroonRequest var metadata runtime.ServerMetadata - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -121,6 +105,7 @@ func local_request_Proxy_BakeSuperMacaroon_0(ctx context.Context, marshaler runt // UnaryRPC :call ProxyServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterProxyHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterProxyHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ProxyServer) error { mux.Handle("GET", pattern_Proxy_GetInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -204,21 +189,21 @@ func RegisterProxyHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv // RegisterProxyHandlerFromEndpoint is same as RegisterProxyHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterProxyHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.DialContext(ctx, endpoint, opts...) + conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() @@ -236,7 +221,7 @@ func RegisterProxyHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ProxyClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ProxyClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "ProxyClient" to call the correct interceptors. +// "ProxyClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterProxyHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ProxyClient) error { mux.Handle("GET", pattern_Proxy_GetInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { diff --git a/tools/Dockerfile b/tools/Dockerfile index e9282d224..10283a84f 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.3-bookworm +FROM golang:1.22.6-bookworm RUN apt-get update && apt-get install -y git ENV GOCACHE=/tmp/build/.cache From d0d8f2aeb432cd779998f4dffb87cc28ebd8bd1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Thu, 26 Sep 2024 11:14:05 +0200 Subject: [PATCH 03/12] lightning-terminal: ensure reproducible releases This update modifies the release.sh script to ensure that release files are reproducible, generating identical hashes when rebuilt. Previously, the script did not set fixed timestamps for the files, resulting in different hashes across rebuilds. Additionally, the release.sh script has been updated to align more closely with the behavior of the lnd release script, ensuring consistency and coherence across repositories for users. --- release.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 12 deletions(-) diff --git a/release.sh b/release.sh index 5731149b7..8694fbb13 100755 --- a/release.sh +++ b/release.sh @@ -17,6 +17,61 @@ POOL_PKG="github.com/lightninglabs/pool" TAP_PKG="github.com/lightninglabs/taproot-assets" PACKAGE=lightning-terminal +# Needed for setting file timestamps to get reproducible archives. +BUILD_DATE="2020-01-01 00:00:00" +BUILD_DATE_STAMP="202001010000.00" + +# reproducible_tar_gzip creates a reproducible tar.gz file of a directory. This +# includes setting all file timestamps and ownership settings uniformly. +function reproducible_tar_gzip() { + local dir=$1 + local tar_cmd=tar + + # MacOS has a version of BSD tar which doesn't support setting the --mtime + # flag. We need gnu-tar, or gtar for short to be installed for this script to + # work properly. + tar_version=$(tar --version) + if [[ ! "$tar_version" =~ "GNU tar" ]]; then + if ! command -v "gtar"; then + echo "GNU tar is required but cannot be found!" + echo "On MacOS please run 'brew install gnu-tar' to install gtar." + exit 1 + fi + + # We have gtar installed, use that instead. + tar_cmd=gtar + fi + + # Pin down the timestamp time zone. + export TZ=UTC + + find "${dir}" -print0 | LC_ALL=C sort -r -z | $tar_cmd \ + "--mtime=${BUILD_DATE}" --no-recursion --null --mode=u+rw,go+r-w,a+X \ + --owner=0 --group=0 --numeric-owner -c -T - | gzip -9n > "${dir}.tar.gz" + + rm -r "${dir}" +} + +# reproducible_zip creates a reproducible zip file of a directory. This +# includes setting all file timestamps. +function reproducible_zip() { + local dir=$1 + + # Pin down file name encoding and timestamp time zone. + export TZ=UTC + + # Set the date of each file in the directory that's about to be packaged to + # the same timestamp and make sure the same permissions are used everywhere. + chmod -R 0755 "${dir}" + touch -t "${BUILD_DATE_STAMP}" "${dir}" + find "${dir}" -print0 | LC_ALL=C sort -r -z | xargs -0r touch \ + -t "${BUILD_DATE_STAMP}" + + find "${dir}" | LC_ALL=C sort -r | zip -o -X -r -@ "${dir}.zip" + + rm -r "${dir}" +} + # green prints one line of green text (if the terminal supports it). function green() { echo -e "\e[0;32m${1}\e[0m" @@ -37,20 +92,27 @@ function build_release() { green " - Packaging vendor" go mod vendor - tar -czf vendor.tar.gz vendor + reproducible_tar_gzip vendor maindir=$PACKAGE-$tag mkdir -p $maindir + mv vendor.tar.gz "${maindir}/" - cp vendor.tar.gz $maindir/ - rm vendor.tar.gz - rm -r vendor + # Don't use tag in source directory, otherwise our file names get too long and + # tar starts to package them non-deterministically. + package_source="${PACKAGE}-source" - package_source="${maindir}/${PACKAGE}-source-${tag}.tar" - git archive -o "${package_source}" HEAD - gzip -f "${package_source}" >"${package_source}.gz" + # The git archive command doesn't support setting timestamps and file + # permissions. That's why we unpack the tar again, then use our reproducible + # method to create the final archive. + git archive -o "${maindir}/${package_source}.tar" HEAD cd "${maindir}" + mkdir -p ${package_source} + tar -xf "${package_source}.tar" -C ${package_source} + rm "${package_source}.tar" + reproducible_tar_gzip ${package_source} + mv "${package_source}.tar.gz" "${package_source}-$tag.tar.gz" for i in $sys; do os=$(echo $i | cut -f1 -d-) @@ -79,16 +141,21 @@ function build_release() { env CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${TAP_PKG}/cmd/tapcli popd + # Add the hashes for the individual binaries as well for easy verification + # of a single installed binary. + shasum -a 256 "${dir}/"* >> "manifest-$tag.txt" + if [[ $os == "windows" ]]; then - zip -r "${dir}.zip" "${dir}" + reproducible_zip "${dir}" else - tar -cvzf "${dir}.tar.gz" "${dir}" + reproducible_tar_gzip "${dir}" fi - - rm -r "${dir}" done - shasum -a 256 * >manifest-$tag.txt + # Add the hash of the packages too, then sort by the second column (name). + shasum -a 256 lightning-terminal-* vendor* >> "manifest-$tag.txt" + LC_ALL=C sort -k2 -o "manifest-$tag.txt" "manifest-$tag.txt" + cat "manifest-$tag.txt" } # usage prints the usage of the whole script. From 81f44b7785511928fc513ef41cea686e11a6a2b5 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 23 Oct 2024 09:52:23 +0200 Subject: [PATCH 04/12] multi: add Docker release helper --- Makefile | 14 +++++++++++++- make/builder.Dockerfile | 28 ++++++++++++++++++++++++++++ make/release_flags.mk | 10 ++++++++++ release.sh | 5 ++++- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 make/builder.Dockerfile diff --git a/Makefile b/Makefile index 959083522..893348760 100644 --- a/Makefile +++ b/Makefile @@ -159,10 +159,22 @@ app-build: yarn-install @$(call print, "Building production app.") cd app; yarn build -release: app-build +release: app-build go-release + +go-release: @$(call print, "Creating release of lightning-terminal.") ./release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(LND_RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" +docker-release: app-build + @$(call print, "Building release helper docker image.") + if [ "$(tag)" = "" ]; then echo "Must specify tag=!"; exit 1; fi + + docker build -t litd-release-helper -f make/builder.Dockerfile make/ + + # Run the actual compilation inside the docker image. We pass in all flags + # that we might want to overwrite in manual tests. + $(DOCKER_RELEASE_HELPER) make go-release tag="$(tag)" sys="$(sys)" COMMIT="$(COMMIT)" + docker-tools: @$(call print, "Building tools docker image.") docker build -q -t litd-tools $(TOOLS_DIR) diff --git a/make/builder.Dockerfile b/make/builder.Dockerfile new file mode 100644 index 000000000..8d7f91c9f --- /dev/null +++ b/make/builder.Dockerfile @@ -0,0 +1,28 @@ +FROM golang:1.22.6-bookworm + +MAINTAINER Olaoluwa Osuntokun + +# Golang build related environment variables that are static and used for all +# architectures/OSes. +ENV GODEBUG netdns=cgo +ENV GO111MODULE=auto +ENV CGO_ENABLED=0 + +# Set up cache directories. Those will be mounted from the host system to speed +# up builds. If go isn't installed on the host system, those will fall back to +# temp directories during the build (see make/release_flags.mk). +ENV GOCACHE=/tmp/build/.cache +ENV GOMODCACHE=/tmp/build/.modcache + +RUN apt-get update && apt-get install -y \ + git \ + make \ + tar \ + zip \ + bash \ + && mkdir -p /tmp/build/litd \ + && mkdir -p /tmp/build/.cache \ + && mkdir -p /tmp/build/.modcache \ + && chmod -R 777 /tmp/build/ + +WORKDIR /tmp/build/litd diff --git a/make/release_flags.mk b/make/release_flags.mk index c0a369cd2..31116c274 100644 --- a/make/release_flags.mk +++ b/make/release_flags.mk @@ -2,6 +2,16 @@ VERSION_TAG = $(shell git describe --abbrev=40 --broken --tags --always) VERSION_CHECK = @$(call print, "Building master with date version tag") +DOCKER_RELEASE_HELPER = docker run \ + -it \ + --rm \ + --user $(shell id -u):$(shell id -g) \ + -v $(shell pwd):/tmp/build/litd \ + -v $(shell bash -c "go env GOCACHE || (mkdir -p /tmp/go-cache; echo /tmp/go-cache)"):/tmp/build/.cache \ + -v $(shell bash -c "go env GOMODCACHE || (mkdir -p /tmp/go-modcache; echo /tmp/go-modcache)"):/tmp/build/.modcache \ + -e SKIP_VERSION_CHECK \ + litd-release-helper + BUILD_SYSTEM = darwin-amd64 \ darwin-arm64 \ linux-386 \ diff --git a/release.sh b/release.sh index 8694fbb13..e5311387b 100755 --- a/release.sh +++ b/release.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Simple bash script to build basic lnd tools for all the platforms +# Simple bash script to build basic litd tools for all the platforms # we support with the golang cross-compiler. # # Copyright (c) 2016 Company 0, LLC. @@ -114,6 +114,9 @@ function build_release() { reproducible_tar_gzip ${package_source} mv "${package_source}.tar.gz" "${package_source}-$tag.tar.gz" + echo "Current git status before starting build: " + git status + for i in $sys; do os=$(echo $i | cut -f1 -d-) arch=$(echo $i | cut -f2 -d-) From 30eb7e4d2fa5c5b43fc85ebdc3313010da77d3ca Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 23 Oct 2024 11:16:25 +0200 Subject: [PATCH 05/12] make+release: move release script, fix make Because the "make release" command collided with the release.sh script, make thought it needed to do something with that file. We fix that problem in two ways: We move the file into the scripts sub folder and also tell make that all our defined goals don't correspond to folders or files. --- Makefile | 10 +++++++++- release.sh => scripts/release.sh | 0 2 files changed, 9 insertions(+), 1 deletion(-) rename release.sh => scripts/release.sh (100%) diff --git a/Makefile b/Makefile index 893348760..df7557aa4 100644 --- a/Makefile +++ b/Makefile @@ -163,7 +163,7 @@ release: app-build go-release go-release: @$(call print, "Creating release of lightning-terminal.") - ./release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(LND_RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" + ./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(LND_RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" docker-release: app-build @$(call print, "Building release helper docker image.") @@ -279,3 +279,11 @@ clean: clean-itest $(RM) ./litcli-debug $(RM) ./litd-debug $(RM) coverage.txt + +# Prevent make from interpreting any of the defined goals as folders or files to +# include in the build process. +.PHONY: default all yarn-install build install go-build go-build-noui \ + go-install go-install-noui go-install-cli app-build release go-release \ + docker-release docker-tools scratch check unit unit-cover unit-race \ + clean-itest build-itest itest-only itest flake-unit fmt lint mod mod-check \ + list rpc protos protos-check rpc-js-compile clean \ No newline at end of file diff --git a/release.sh b/scripts/release.sh similarity index 100% rename from release.sh rename to scripts/release.sh From 4485eae3644b8839cabfffd4ee852fb4a46d26e6 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 23 Oct 2024 11:42:35 +0200 Subject: [PATCH 06/12] .gitignore: add GoLand+VSCode files --- .gitignore | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 17833a841..3958b0234 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,16 @@ itest/litd-itest itest/lnd-itest itest/itest.test itest/.logs -itest/*.log \ No newline at end of file +itest/*.log + +vendor +*.idea +*.run +*.iml +profile.cov +profile.tmp + +.DS_Store + +.vscode +*.code-workspace From 1338cfad84b3573ab7bfed5d5772f641ed1cb926 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 23 Oct 2024 11:50:04 +0200 Subject: [PATCH 07/12] make+scripts: add lint check for Golang version To make sure we use the same Golang version everywhere, we add a new linter step with scripts copied from lnd. --- Makefile | 17 +++++- scripts/check-go-version-dockerfile.sh | 64 ++++++++++++++++++++++ scripts/check-go-version-yaml.sh | 75 ++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 1 deletion(-) create mode 100755 scripts/check-go-version-dockerfile.sh create mode 100755 scripts/check-go-version-yaml.sh diff --git a/Makefile b/Makefile index df7557aa4..7efc8d254 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,11 @@ COMMIT := $(shell git describe --abbrev=40 --dirty --tags) COMMIT_HASH := $(shell git rev-parse HEAD) PUBLIC_URL := +# GO_VERSION is the Go version used for the release build, docker files, and +# GitHub Actions. This is the reference version for the project. All other Go +# versions are checked against this version. +GO_VERSION = 1.22.6 + LOOP_COMMIT := $(shell cat go.mod | \ grep $(LOOP_PKG) | \ head -n1 | \ @@ -238,7 +243,17 @@ fmt: $(GOIMPORTS_BIN) @$(call print, "Formatting source.") gofmt -l -w -s $(GOFILES_NOVENDOR) -lint: docker-tools +check-go-version-yaml: + @$(call print, "Checking for target Go version (v$(GO_VERSION)) in YAML files (*.yaml, *.yml)") + ./scripts/check-go-version-yaml.sh $(GO_VERSION) + +check-go-version-dockerfile: + @$(call print, "Checking for target Go version (v$(GO_VERSION)) in Dockerfile files (*Dockerfile)") + ./scripts/check-go-version-dockerfile.sh $(GO_VERSION) + +check-go-version: check-go-version-dockerfile check-go-version-yaml + +lint: check-go-version docker-tools @$(call print, "Linting source.") $(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS) diff --git a/scripts/check-go-version-dockerfile.sh b/scripts/check-go-version-dockerfile.sh new file mode 100755 index 000000000..303ee42ed --- /dev/null +++ b/scripts/check-go-version-dockerfile.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Function to check if the Dockerfile contains only the specified Go version. +check_go_version() { + local dockerfile="$1" + local required_go_version="$2" + + # Use grep to find lines with 'FROM golang:' + local go_lines=$(grep -i '^FROM golang:' "$dockerfile") + + # Check if all lines have the required Go version. + if [ -z "$go_lines" ]; then + # No Go version found in the file. Skip the check. + return + elif echo "$go_lines" | grep -q -v "$required_go_version"; then + echo "$go_lines" + echo "Error: $dockerfile does not use Go version $required_go_version exclusively." + exit 1 + else + echo "$dockerfile is using Go version $required_go_version." + fi +} + +# Check if the target Go version argument is provided. +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +target_go_version="$1" + +# File paths to be excluded from the check. +exception_list=( + # Exclude the tools Dockerfile as otherwise the linter may need to be + # considered every time the Go version is updated. + "./tools/Dockerfile" +) + +# is_exception checks if a file is in the exception list. +is_exception() { + local file="$1" + for exception in "${exception_list[@]}"; do + if [ "$file" == "$exception" ]; then + return 0 + fi + done + return 1 +} + +# Search for Dockerfiles in the current directory and its subdirectories. +dockerfiles=$(find . -type f -name "*.Dockerfile" -o -name "Dockerfile") + +# Check each Dockerfile +for file in $dockerfiles; do + # Skip the file if it is in the exception list. + if is_exception "$file"; then + echo "Skipping $file" + continue + fi + + check_go_version "$file" "$target_go_version" +done + +echo "All Dockerfiles pass the Go version check for Go version $target_go_version." diff --git a/scripts/check-go-version-yaml.sh b/scripts/check-go-version-yaml.sh new file mode 100755 index 000000000..bd65ffa01 --- /dev/null +++ b/scripts/check-go-version-yaml.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +# Function to check if the YAML file contains the specified Go version after +# field 'go:'. +check_go_version_yaml() { + local yamlfile="$1" + local required_go_version="$2" + + # Use grep to find lines with 'go:'. The grep exist status is ignored. + local go_lines=$(grep -i '^\s*go:\s*"[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?"' "$yamlfile" || true) + + # Check if any lines specify the Go version. + if [ -n "$go_lines" ]; then + # Extract the Go version from the file's lines. Example matching strings: + # go: "1.21.0" + local extracted_go_version=$(echo "$go_lines" | sed -n 's/.*go: "\([^"]*\)".*/\1/p') + + # Check if the extracted Go version matches the required version. + if [ "$extracted_go_version" != "$required_go_version" ]; then + echo "Error finding pattern 'go:': $yamlfile specifies Go version '$extracted_go_version', but required version is '$required_go_version'." + exit 1 + else + echo "$yamlfile specifies Go version $required_go_version." + fi + fi +} + +# Function to check if the YAML file contains the specified Go version after +# environment variable 'GO_VERSION:'. +check_go_version_env_variable() { + local yamlfile="$1" + local required_go_version="$2" + + # Use grep to find lines with 'GO_VERSION:'. The grep exist status is + # ignored. + local go_lines=$(grep -i 'GO_VERSION:' "$yamlfile" || true) + + # Check if any lines specify the Go version. + if [ -n "$go_lines" ]; then + # Extract the Go version from the file's lines. Example matching strings: + # GO_VERSION: "1.21.0" + # GO_VERSION: '1.21.0' + # GO_VERSION: 1.21.0 + # GO_VERSION:1.21.0 + # GO_VERSION:1.21.0 + local extracted_go_version=$(echo "$go_lines" | sed -n 's/.*GO_VERSION[: ]*["'\'']*\([0-9.]*\).*/\1/p') + + # Check if the extracted Go version matches the required version. + if [ "$extracted_go_version" != "$required_go_version" ]; then + echo "Error finding pattern 'GO_VERSION:': $yamlfile specifies Go version '$extracted_go_version', but required version is '$required_go_version'." + exit 1 + else + echo "$yamlfile specifies Go version $required_go_version." + fi + fi +} + +# Check if the target Go version argument is provided. +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +target_go_version="$1" + +# Search for YAML files in the current directory and its subdirectories. +yaml_files=$(find . -type f \( -name "*.yaml" -o -name "*.yml" \)) + +# Check each YAML file. +for file in $yaml_files; do + check_go_version_yaml "$file" "$target_go_version" + check_go_version_env_variable "$file" "$target_go_version" +done + +echo "All YAML files pass the Go version check for Go version $target_go_version." From acf547ef3dd52a21426a46ec17dced972c0dd4fe Mon Sep 17 00:00:00 2001 From: ffranr Date: Wed, 23 Oct 2024 12:06:14 +0200 Subject: [PATCH 08/12] makefile+scripts: add Go version check to release command This commit updates `scripts/release.sh` to include a check for the correct Go version before executing the release build. This ensures that the release binaries are built with the specified Go version, maintaining consistency and integrity for developer signatures. --- Makefile | 2 +- scripts/release.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7efc8d254..bb5f03a3d 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,7 @@ release: app-build go-release go-release: @$(call print, "Creating release of lightning-terminal.") - ./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(LND_RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" + ./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(LND_RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)" docker-release: app-build @$(call print, "Building release helper docker image.") diff --git a/scripts/release.sh b/scripts/release.sh index e5311387b..26f41a4e7 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -84,11 +84,21 @@ function red() { # build_release builds the actual release binaries. # arguments: +# function build_release() { local tag=$1 local sys=$2 local buildtags=$3 local ldflags=$4 + local goversion=$5 + + # Check if the active Go version matches the specified Go version. + active_go_version=$(go version | awk '{print $3}' | sed 's/go//') + if [ "$active_go_version" != "$goversion" ]; then + echo "Error: active Go version ($active_go_version) does not match \ +required Go version ($goversion)." + exit 1 + fi green " - Packaging vendor" go mod vendor From c9e632e38dcea9c87214bd51157e5cb02d2690bd Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 23 Oct 2024 14:31:52 +0200 Subject: [PATCH 09/12] docker: pin all docker images with their hash --- Dockerfile | 9 +++------ dev.Dockerfile | 9 +++------ litrpc/Dockerfile | 2 +- make/builder.Dockerfile | 2 +- proto/Dockerfile | 2 +- tools/Dockerfile | 2 +- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6be7121c0..abe0af1cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Start with a NodeJS base image that also contains yarn. -FROM node:22.8.0-alpine as nodejsbuilder +FROM node:22.8.0-alpine@sha256:bec0ea49c2333c429b62e74e91f8ba1201b060110745c3a12ff957cd51b363c6 as nodejsbuilder # Pass a tag, branch or a commit using build-arg. This allows a docker image to # be built from a specified Git state. The default image will use the Git tip of @@ -32,10 +32,7 @@ RUN apk add --no-cache --update alpine-sdk \ # The first stage is already done and all static assets should now be generated # in the app/build sub directory. -# If you change this value, please also update: -# /dev.Dockerfile -# /.github/workflows/main.yml -FROM golang:1.22.6-alpine as golangbuilder +FROM golang:1.22.6-alpine@sha256:1a478681b671001b7f029f94b5016aed984a23ad99c707f6a0ab6563860ae2f3 as golangbuilder # Instead of checking out from git again, we just copy the whole working # directory of the previous stage that includes the generated static assets. @@ -53,7 +50,7 @@ RUN apk add --no-cache --update alpine-sdk \ && make go-install-cli # Start a new, final image to reduce size. -FROM alpine as final +FROM alpine:3.20.3@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d as final # Define a root volume for data persistence. VOLUME /root/.lnd diff --git a/dev.Dockerfile b/dev.Dockerfile index 528b4f830..fa61d30bb 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,5 +1,5 @@ # Start with a NodeJS base image that also contains yarn. -FROM node:22.8.0-alpine as nodejsbuilder +FROM node:22.8.0-alpine@sha256:bec0ea49c2333c429b62e74e91f8ba1201b060110745c3a12ff957cd51b363c6 as nodejsbuilder # Copy in the local repository to build from. COPY . /go/src/github.com/lightninglabs/lightning-terminal @@ -10,10 +10,7 @@ RUN cd /go/src/github.com/lightninglabs/lightning-terminal/app \ # The first stage is already done and all static assets should now be generated # in the app/build sub directory. -# If you change this value, please also update: -# /Dockerfile -# /.github/workflows/main.yml -FROM golang:1.22.6-alpine as golangbuilder +FROM golang:1.22.6-alpine@sha256:1a478681b671001b7f029f94b5016aed984a23ad99c707f6a0ab6563860ae2f3 as golangbuilder # Instead of checking out from git again, we just copy the whole working # directory of the previous stage that includes the generated static assets. @@ -31,7 +28,7 @@ RUN apk add --no-cache --update alpine-sdk \ && make go-install-cli # Start a new, final image to reduce size. -FROM alpine as final +FROM alpine:3.20.3@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d as final # Define a root volume for data persistence. VOLUME /root/.lnd diff --git a/litrpc/Dockerfile b/litrpc/Dockerfile index e60a23ae9..ea2bfdf0d 100644 --- a/litrpc/Dockerfile +++ b/litrpc/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.6-bookworm +FROM golang:1.22.6-bookworm@sha256:d31e093e3aeaee68ccee6c4c96e554ef0f192ea37ae684d91b206bec17377f19 RUN apt-get update && apt-get install -y \ git \ diff --git a/make/builder.Dockerfile b/make/builder.Dockerfile index 8d7f91c9f..62616561a 100644 --- a/make/builder.Dockerfile +++ b/make/builder.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.6-bookworm +FROM golang:1.22.6-bookworm@sha256:d31e093e3aeaee68ccee6c4c96e554ef0f192ea37ae684d91b206bec17377f19 MAINTAINER Olaoluwa Osuntokun diff --git a/proto/Dockerfile b/proto/Dockerfile index 69e146711..adc813a95 100644 --- a/proto/Dockerfile +++ b/proto/Dockerfile @@ -1,5 +1,5 @@ # Start with a NodeJS base image that also contains yarn. -FROM node:22.8.0-bookworm as nodejsbuilder +FROM node:22.8.0-bookworm@sha256:bd00c03095f7586432805dbf7989be10361d27987f93de904b1fc003949a4794 as nodejsbuilder RUN apt-get update && apt-get install -y \ git \ diff --git a/tools/Dockerfile b/tools/Dockerfile index 10283a84f..c57b15e00 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.6-bookworm +FROM golang:1.22.6-bookworm@sha256:d31e093e3aeaee68ccee6c4c96e554ef0f192ea37ae684d91b206bec17377f19 RUN apt-get update && apt-get install -y git ENV GOCACHE=/tmp/build/.cache From 321d93c285cc7d885531c3cb6060419091915ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Thu, 26 Sep 2024 13:01:12 +0200 Subject: [PATCH 10/12] docs: update release notes --- docs/release-notes/release-notes-0.13.5.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/release-notes-0.13.5.md b/docs/release-notes/release-notes-0.13.5.md index 2eac3d472..479468882 100644 --- a/docs/release-notes/release-notes-0.13.5.md +++ b/docs/release-notes/release-notes-0.13.5.md @@ -40,6 +40,11 @@ ## Integrated Binary Updates +- [Ensured reproducible + releases](https://github.com/lightninglabs/lightning-terminal/pull/881) by + setting a fixed timestamps for the files in the release script and by + providing a dockerized release build command `make docker-release` for MacOS. + ### LND ### Loop From fc778362047c28086b4f23c2493b2d3f6bdb5d11 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 23 Oct 2024 14:37:43 +0200 Subject: [PATCH 11/12] make+app: add dockerized builder for app We dockerize the app build and use that for both the docker build _AND_ the normal build to make sure the static content is fully reproducible across different systems. --- Makefile | 8 ++++++-- app/Dockerfile | 12 ++++++++++++ app/gen_app_docker.sh | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 app/Dockerfile create mode 100755 app/gen_app_docker.sh diff --git a/Makefile b/Makefile index bb5f03a3d..4a8d91e99 100644 --- a/Makefile +++ b/Makefile @@ -164,13 +164,17 @@ app-build: yarn-install @$(call print, "Building production app.") cd app; yarn build -release: app-build go-release +docker-app-build: + @$(call print, "Building production app in docker.") + cd app; ./gen_app_docker.sh + +release: docker-app-build go-release go-release: @$(call print, "Creating release of lightning-terminal.") ./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(LND_RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)" -docker-release: app-build +docker-release: docker-app-build @$(call print, "Building release helper docker image.") if [ "$(tag)" = "" ]; then echo "Must specify tag=!"; exit 1; fi diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 000000000..53a61fb93 --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,12 @@ +# Start with a NodeJS base image that also contains yarn. +FROM node:22.8.0-bookworm@sha256:bd00c03095f7586432805dbf7989be10361d27987f93de904b1fc003949a4794 as nodejsbuilder + +RUN apt-get update && apt-get install -y git + +ENV HOME=/tmp + +RUN mkdir /build + +WORKDIR /build + +CMD ["/bin/bash", "-c", "chown $(id -u):$(id -g) /build && cd app && rm -rf node_modules && yarn cache clean && yarn install && yarn build"] diff --git a/app/gen_app_docker.sh b/app/gen_app_docker.sh new file mode 100755 index 000000000..17aa6f3c5 --- /dev/null +++ b/app/gen_app_docker.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Directory of the script file, independent of where it's called from. +DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" + +echo "Building app compiler docker image..." +docker build -q -t lit-app-builder . + +echo "Compiling app files..." +docker run \ + --rm \ + --user $(id -u):$(id -g) \ + -v "$DIR/../:/build" \ + lit-app-builder From ea33903622e25898d084d931e891a963868e6958 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 24 Oct 2024 11:18:02 +0200 Subject: [PATCH 12/12] litrpc+proto: fix ownership in docker container This was discovered while debugging the reproducible build. We used the wrong group ID. And the environment variables aren't super portable so we use the correct command to get the numeric user and group IDs. --- litrpc/gen_protos_docker.sh | 3 +-- proto/gen_protos_docker.sh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/litrpc/gen_protos_docker.sh b/litrpc/gen_protos_docker.sh index 0f755c2fd..9d3c2230e 100755 --- a/litrpc/gen_protos_docker.sh +++ b/litrpc/gen_protos_docker.sh @@ -17,7 +17,6 @@ docker build -t lit-protobuf-builder \ echo "Compiling and formatting *.proto files..." docker run \ --rm \ - --user $UID:$UID \ - -e UID=$UID \ + --user $(id -u):$(id -g) \ -v "$DIR/../:/build" \ lit-protobuf-builder diff --git a/proto/gen_protos_docker.sh b/proto/gen_protos_docker.sh index 6f598c9ef..a3d4ed49c 100755 --- a/proto/gen_protos_docker.sh +++ b/proto/gen_protos_docker.sh @@ -11,7 +11,6 @@ docker build -q -t lit-protobuf-builder . echo "Compiling and formatting *.proto files..." docker run \ --rm \ - --user $UID:$UID \ - -e UID=$UID \ + --user $(id -u):$(id -g) \ -v "$DIR/../:/build" \ lit-protobuf-builder