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

Remove tx completion tracking #113

Merged
merged 12 commits into from
Sep 15, 2023
10 changes: 5 additions & 5 deletions .github/workflows/docker_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set build tag
id: build_tag_generator
Expand All @@ -25,16 +25,16 @@ jobs:
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
--tag ghcr.io/hyperledger/firefly-fabconnect:${{ steps.build_tag_generator.outputs.BUILD_TAG }} .

- name: Tag release
run: docker tag ghcr.io/hyperledger/firefly-fabconnect:${{ steps.build_tag_generator.outputs.BUILD_TAG }} ghcr.io/hyperledger/firefly-fabconnect:head

- name: Push docker image
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly-fabconnect:${{ steps.build_tag_generator.outputs.BUILD_TAG }}

- name: Push head tag
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly-fabconnect:head
docker push ghcr.io/hyperledger/firefly-fabconnect:head
6 changes: 2 additions & 4 deletions .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/checkout@v3

- name: Build
run: |
Expand All @@ -30,7 +28,7 @@ jobs:
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly-fabconnect:${GITHUB_REF##*/}

- name: Push head tag
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.17
go-version: "1.20"

- name: Build and Test
run: make
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17-alpine3.13 AS fabconnect-builder
FROM golang:1.20-alpine3.18 AS fabconnect-builder
RUN apk add make
WORKDIR /fabconnect
ADD go.mod go.sum ./
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ test: deps lint
coverage.html:
$(VGO) tool cover -html=coverage.txt
coverage: test coverage.html
lint:
GOGC=20 $(shell go list -f '{{.Target}}' github.com/golangci/golangci-lint/cmd/golangci-lint) run -v --timeout 5m
lint: ${LINT}
GOGC=20 $(LINT) run -v --timeout 5m
${LINT}:
$(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.3
firefly-nocgo: ${GOFILES}
CGO_ENABLED=0 $(VGO) build -o ${BINARY_NAME}-nocgo -ldflags "-X main.buildDate=`date -u +\"%Y-%m-%dT%H:%M:%SZ\"` -X main.buildVersion=$(BUILD_VERSION)" -tags=prod -tags=prod -v
firefly: ${GOFILES}
Expand All @@ -30,7 +32,7 @@ clean:
$(VGO) clean
rm -f *.so ${BINARY_NAME}
builddeps:
$(VGO) get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.2
$(VGO) get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
deps: builddeps
$(VGO) get
mockery: .ALWAYS
Expand Down
66 changes: 66 additions & 0 deletions cmd/debugrouter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package cmd

import (
"net/http"
"net/http/pprof"
runtimepprof "runtime/pprof"

"github.com/julienschmidt/httprouter"
"github.com/rs/cors"
log "github.com/sirupsen/logrus"
)

type debugRouter struct {
router *httprouter.Router
}

func NewDebugRouter() *debugRouter {
r := httprouter.New()
cors.Default().Handler(r)
return &debugRouter{
router: r,
}
}

func (d *debugRouter) addRoutes() {
d.router.GET("/debug/pprof/cmdline", d.cmdline)
d.router.GET("/debug/pprof/profile", d.profile)
d.router.GET("/debug/pprof/symbol", d.symbol)
d.router.GET("/debug/pprof/trace", d.trace)
d.router.GET("/debug/pprof/goroutines", d.goroutines)
d.router.GET("/debug/pprof/", d.index)
}

func (d *debugRouter) cmdline(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
log.Infof("--> %s %s", req.Method, req.URL)
pprof.Cmdline(res, req)
}

func (d *debugRouter) profile(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
log.Infof("--> %s %s", req.Method, req.URL)
pprof.Profile(res, req)
}

func (d *debugRouter) symbol(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
log.Infof("--> %s %s", req.Method, req.URL)

pprof.Symbol(res, req)
}

func (d *debugRouter) trace(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
log.Infof("--> %s %s", req.Method, req.URL)

pprof.Trace(res, req)
}

func (d *debugRouter) index(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
log.Infof("--> %s %s", req.Method, req.URL)

pprof.Index(res, req)
}

func (d *debugRouter) goroutines(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
log.Infof("--> %s %s", req.Method, req.URL)

_ = runtimepprof.Lookup("goroutine").WriteTo(res, 1)
}
21 changes: 15 additions & 6 deletions cmd/fabconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/http"
"strings"
"time"

"gopkg.in/yaml.v2"

Expand Down Expand Up @@ -94,15 +95,23 @@ func newRootCmd() (*cobra.Command, *conf.RESTGatewayConf) {

initLogging(rootConfig.DebugLevel)

return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
if rootConfig.DebugPort > 0 {
router := NewDebugRouter()
router.addRoutes()
debugServer := &http.Server{Addr: fmt.Sprintf("127.0.0.1:%d", rootConfig.DebugPort), Handler: router.router, ReadHeaderTimeout: 30 * time.Second}
go func() {
log.Debugf("Debug HTTP endpoint listening on localhost:%d: %s", rootConfig.DebugPort, http.ListenAndServe(fmt.Sprintf("localhost:%d", rootConfig.DebugPort), nil))
_ = debugServer.ListenAndServe()
}()
}
log.Infof("Debug HTTP endpoint listening on 127.0.0.1:%d", rootConfig.DebugPort)

return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
defer func() {
log.Infof("Shutting down the debug server")
_ = debugServer.Close()
}()
}
err := startServer(restGatewayConf, restGateway)
if err != nil {
return err
Expand All @@ -112,7 +121,7 @@ func newRootCmd() (*cobra.Command, *conf.RESTGatewayConf) {
}

rootCmd.Flags().IntVarP(&rootConfig.DebugLevel, "debug", "d", 1, "0=error, 1=info, 2=debug")
rootCmd.Flags().IntVarP(&rootConfig.DebugPort, "debugPort", "Z", 6060, "Port for pprof HTTP endpoints (localhost only)")
rootCmd.Flags().IntVarP(&rootConfig.DebugPort, "debugPort", "Z", 0, "Port for pprof HTTP endpoints (localhost only)")
rootCmd.Flags().BoolVarP(&rootConfig.PrintYAML, "print-yaml-confg", "Y", false, "Print YAML config snippet and exit")
rootCmd.Flags().StringVarP(&rootConfig.Filename, "configfile", "f", "", "Configuration file, must be one of .yml, .yaml, or .json")
conf.CobraInit(rootCmd, restGatewayConf)
Expand Down
18 changes: 18 additions & 0 deletions cmd/fabconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,21 @@ func TestKafkaSuccess(t *testing.T) {
assert.Equal([]string{"broker1", "broker2"}, restGatewayConf.Kafka.Brokers)
test.Teardown(tmpdir)
}

func TestDebugServer(t *testing.T) {
assert := assert.New(t)

tmpdir, _ := test.Setup()
rootCmd, _ := newRootCmd()
rootCmd.RunE = runNothing
args := []string{
"-f", path.Join(tmpdir, "config.json"),
"--debugPort", "6060",
}
rootCmd.SetArgs(args)
os.Unsetenv("FC_HTTP_PORT")
err := rootCmd.Execute()
assert.NoError(err)
assert.Equal(6060, rootConfig.DebugPort)
test.Teardown(tmpdir)
}
132 changes: 107 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,53 +1,135 @@
module github.com/hyperledger/firefly-fabconnect

go 1.16
go 1.20

require (
github.com/Shopify/sarama v1.29.1
github.com/frankban/quicktest v1.14.2 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
github.com/golang/protobuf v1.5.2
github.com/golangci/golangci-lint v1.44.2 // indirect
github.com/golang/protobuf v1.5.3
github.com/google/certificate-transparency-go v1.1.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/golang-lru v0.5.4
github.com/hyperledger/fabric-config v0.0.7 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.4
github.com/hyperledger/fabric-protos-go v0.0.0-20211118165945-23d738fc3553
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20220617091732-e170b98fa821
github.com/julienschmidt/httprouter v1.3.0
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/oklog/ulid/v2 v2.0.2
github.com/otiai10/copy v1.6.0
github.com/pkg/errors v0.9.1
github.com/rs/cors v1.8.2
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.8.4
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
github.com/x-cray/logrus-prefixed-formatter v0.5.2
github.com/xeipuuv/gojsonschema v1.2.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/cfssl v1.4.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/frankban/quicktest v1.14.4 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hyperledger/fabric-config v0.0.7 // indirect
github.com/hyperledger/fabric-lib-go v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jonboulle/clockwork v0.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.13.5 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/oklog/ulid/v2 v2.0.2
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/gomega v1.18.1 // indirect
github.com/otiai10/copy v1.6.0
github.com/onsi/ginkgo v1.16.4 // indirect
github.com/onsi/gomega v1.27.6 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.0 // indirect
github.com/pkg/errors v0.9.1
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rs/cors v1.8.2
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.11.0
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.7.1
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966 // indirect
github.com/urfave/cli v1.22.2 // indirect
github.com/x-cray/logrus-prefixed-formatter v0.5.2
github.com/xeipuuv/gojsonschema v1.2.0
github.com/weppos/publicsuffix-go v0.5.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/zmap/zcrypto v0.0.0-20190729165852-9051775e6a2e // indirect
github.com/zmap/zlint v0.0.0-20190806154020-fd021b4cfbeb // indirect
go.etcd.io/bbolt v1.3.5 // indirect
go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a // indirect
gopkg.in/yaml.v2 v2.4.0
golang.org/x/tools v0.9.3 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

Expand Down
Loading