diff --git a/api/server.go b/api/server.go index 6654bea8..0379c6af 100644 --- a/api/server.go +++ b/api/server.go @@ -8,6 +8,7 @@ import ( "github.com/gorilla/mux" "github.com/rs/zerolog/log" "github.com/sprintertech/sprinter-signing/api/handlers" + "github.com/sprintertech/sprinter-signing/health" ) func Serve( @@ -23,6 +24,7 @@ func Serve( r.HandleFunc("/v1/chains/{chainId:[0-9]+}/signatures", signingHandler.HandleSigning).Methods("POST") r.HandleFunc("/v1/chains/{chainId:[0-9]+}/signatures/{depositId}", statusHandler.HandleRequest).Methods("GET") r.HandleFunc("/v1/chains/{chainId:[0-9]+}/confirmations", confirmationsHandler.HandleRequest).Methods("GET") + r.HandleFunc("/health", health.HealthHandler()).Methods("GET") server := &http.Server{ Addr: addr, diff --git a/app/app.go b/app/app.go index 85a39fa1..a654aed8 100644 --- a/app/app.go +++ b/app/app.go @@ -42,7 +42,6 @@ import ( "github.com/sprintertech/sprinter-signing/comm/elector" "github.com/sprintertech/sprinter-signing/comm/p2p" "github.com/sprintertech/sprinter-signing/config" - "github.com/sprintertech/sprinter-signing/health" "github.com/sprintertech/sprinter-signing/jobs" "github.com/sprintertech/sprinter-signing/keyshare" "github.com/sprintertech/sprinter-signing/metrics" @@ -110,8 +109,6 @@ func Run() error { panicOnError(err) log.Info().Str("peerID", host.ID().String()).Msg("Successfully created libp2p host") - go health.StartHealthEndpoint(configuration.RelayerConfig.HealthPort) - communication := p2p.NewCommunication(host, "p2p/sprinter") electorFactory := elector.NewCoordinatorElectorFactory(host, configuration.RelayerConfig.BullyConfig) coordinator := tss.NewCoordinator(host, communication, electorFactory) diff --git a/go.sum b/go.sum index b7d388e2..4318cbd1 100644 --- a/go.sum +++ b/go.sum @@ -950,14 +950,8 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk= github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4= -github.com/sprintertech/lifi-solver v0.0.0-20251106144931-4586926e1a4c h1:gt7WBOMG049RFW0E0tq7t5PuaU3utWDgbzzq98iMyug= -github.com/sprintertech/lifi-solver v0.0.0-20251106144931-4586926e1a4c/go.mod h1:3yuTgBKvA5WLCFsXXuBnOzk5nNS58phc881uXLGfD0o= -github.com/sprintertech/lifi-solver v0.0.0-20251107125259-138b58fd00bc h1:h/DY03o7cOez2Ilrwt9TO9BKWIYrAo3o/KvhvEwkziQ= -github.com/sprintertech/lifi-solver v0.0.0-20251107125259-138b58fd00bc/go.mod h1:d5/fytopwudQUE9ojF54XwtqLRFD3JbpBlri7ygb3ng= github.com/sprintertech/lifi-solver v0.0.0-20251107154632-5c22e7948a82 h1:Nq9wH4wU4W+3UXfeTqGwMBxr+yKDkz0wO6XzpSRkamg= github.com/sprintertech/lifi-solver v0.0.0-20251107154632-5c22e7948a82/go.mod h1:d5/fytopwudQUE9ojF54XwtqLRFD3JbpBlri7ygb3ng= -github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e h1:5sSP6GbqCT/ApxxZmUtav6GHy5Ke98zh5oqQxewhJd4= -github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ= github.com/sprintertech/solver-config/go v0.0.0-20251107123115-0ea5f862cab9 h1:oo4/4LvkYMVVl/u9+iqEY91iCDFJ05pGwUJNX+6APnA= github.com/sprintertech/solver-config/go v0.0.0-20251107123115-0ea5f862cab9/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= diff --git a/health/health.go b/health/health.go index 9f298624..2bb075eb 100644 --- a/health/health.go +++ b/health/health.go @@ -4,32 +4,12 @@ package health import ( - "fmt" "net/http" - "time" - - "github.com/rs/zerolog/log" ) -// StartHealthEndpoint starts /health endpoint on provided port that returns ok on invocation -func StartHealthEndpoint(port uint16) { - http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { +// HealthHandler returns a handler function for the /health endpoint +func HealthHandler() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { _, _ = w.Write([]byte("ok")) - }) - - srv := &http.Server{ - Addr: fmt.Sprintf(":%d", port), - ReadTimeout: 10 * time.Second, - WriteTimeout: 10 * time.Second, - IdleTimeout: 30 * time.Second, - ReadHeaderTimeout: 2 * time.Second, } - - err := srv.ListenAndServe() - if err != nil { - log.Err(err).Msgf("Failed starting health server") - return - } - - log.Info().Msgf("started /health endpoint on port %d", port) } diff --git a/tss/ecdsa/common/mock/tss.go b/tss/ecdsa/common/mock/tss.go index 0f4d5757..7f90c2f7 100644 --- a/tss/ecdsa/common/mock/tss.go +++ b/tss/ecdsa/common/mock/tss.go @@ -10,9 +10,9 @@ package mock_tss import ( - big "math/big" reflect "reflect" + int "github.com/binance-chain/tss-lib/common/int" tss "github.com/binance-chain/tss-lib/tss" gomock "go.uber.org/mock/gomock" ) @@ -56,10 +56,10 @@ func (mr *MockMessageMockRecorder) GetFrom() *gomock.Call { } // GetSessionId mocks base method. -func (m *MockMessage) GetSessionId() *big.Int { +func (m *MockMessage) GetSessionId() *int.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetSessionId") - ret0, _ := ret[0].(*big.Int) + ret0, _ := ret[0].(*int.Int) return ret0 } diff --git a/tss/mock/ecdsa.go b/tss/mock/ecdsa.go index bcad1f35..b35f0d94 100644 --- a/tss/mock/ecdsa.go +++ b/tss/mock/ecdsa.go @@ -68,17 +68,17 @@ func (mr *MockECDSAKeyshareStorerMockRecorder) LockKeyshare() *gomock.Call { } // StoreKeyshare mocks base method. -func (m *MockECDSAKeyshareStorer) StoreKeyshare(keyshare keyshare.ECDSAKeyshare) error { +func (m *MockECDSAKeyshareStorer) StoreKeyshare(arg0 keyshare.ECDSAKeyshare) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StoreKeyshare", keyshare) + ret := m.ctrl.Call(m, "StoreKeyshare", arg0) ret0, _ := ret[0].(error) return ret0 } // StoreKeyshare indicates an expected call of StoreKeyshare. -func (mr *MockECDSAKeyshareStorerMockRecorder) StoreKeyshare(keyshare any) *gomock.Call { +func (mr *MockECDSAKeyshareStorerMockRecorder) StoreKeyshare(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreKeyshare", reflect.TypeOf((*MockECDSAKeyshareStorer)(nil).StoreKeyshare), keyshare) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreKeyshare", reflect.TypeOf((*MockECDSAKeyshareStorer)(nil).StoreKeyshare), arg0) } // UnlockKeyshare mocks base method.