From 206207b530c30aca13d705db259c6cf738cae533 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 9 Jan 2024 12:34:33 +0300 Subject: [PATCH 01/39] http resolver --- validator/client/BUILD.bazel | 1 + .../multiple_endpoints_http_resolver.go | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 validator/client/multiple_endpoints_http_resolver.go diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 223a3f16a99f..a0deebea9c42 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -10,6 +10,7 @@ go_library( "log.go", "metrics.go", "multiple_endpoints_grpc_resolver.go", + "multiple_endpoints_http_resolver.go", "propose.go", "propose_protect.go", "registration.go", diff --git a/validator/client/multiple_endpoints_http_resolver.go b/validator/client/multiple_endpoints_http_resolver.go new file mode 100644 index 000000000000..77dbb0fe1311 --- /dev/null +++ b/validator/client/multiple_endpoints_http_resolver.go @@ -0,0 +1,70 @@ +package client + +import ( + "fmt" + "net/http" + + "github.com/prysmaticlabs/prysm/v4/network/httputil" +) + +// MultipleEndpointsHTTPResolver is a custom resolver for HTTP clients that supports multiple addresses. +type MultipleEndpointsHTTPResolver struct { + addresses []string + currentIdx int + client *http.Client +} + +// NewMultipleEndpointsHTTPResolver creates a new instance of MultipleEndpointsHTTPResolver. +func NewMultipleEndpointsHTTPResolver(addresses []string) *MultipleEndpointsHTTPResolver { + return &MultipleEndpointsHTTPResolver{ + addresses: addresses, + currentIdx: 0, + client: &http.Client{}, + } +} + +func (r *MultipleEndpointsHTTPResolver) HttpMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + // Attempt to send the request to the current endpoint + err := r.sendRequest(req, w) + + // Switch to the next endpoint and retry if there is an error + for i := 0; i < len(r.addresses)-1 && err != nil; i++ { + r.switchEndpoint() + err = r.sendRequest(req, w) + } + + if err != nil { + httputil.HandleError(w, fmt.Sprintf("failed to send request: %v", err), http.StatusInternalServerError) + return + } + + next.ServeHTTP(w, req) + }) +} + +// sendRequest sends the HTTP request to the current endpoint. +func (r *MultipleEndpointsHTTPResolver) sendRequest(req *http.Request, w http.ResponseWriter) error { + // Update the request URL with the current endpoint + req.URL.Host = r.resolveEndpoint() + + // Send the HTTP request using the client + resp, err := r.client.Do(req) + if err != nil { + // Optionally handle specific errors or log them + httputil.HandleError(w, fmt.Sprintf("error sending request to %s: %v\n", r.resolveEndpoint(), err), http.StatusInternalServerError) + return err + } + defer resp.Body.Close() + return nil +} + +// resolveEndpoint returns the current endpoint based on the resolver's state. +func (r *MultipleEndpointsHTTPResolver) resolveEndpoint() string { + return r.addresses[r.currentIdx] +} + +// switchToNextEndpoint switches to the next available endpoint, this is circular. +func (r *MultipleEndpointsHTTPResolver) switchEndpoint() { + r.currentIdx = (r.currentIdx + 1) % len(r.addresses) +} From 5437c44ac26e48c041f5c16f399446c5f72c31a2 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Mon, 22 Jan 2024 16:03:21 -0800 Subject: [PATCH 02/39] Redo --- validator/client/BUILD.bazel | 1 - .../beacon_api_beacon_chain_client.go | 6 +- .../beacon-api/beacon_api_node_client.go | 2 +- .../beacon-api/beacon_api_validator_client.go | 2 +- .../client/beacon-api/json_rest_handler.go | 40 +++++++++-- .../beacon-api/json_rest_handler_test.go | 4 +- .../beacon-api/prysm_beacon_chain_client.go | 2 +- .../beacon_chain_client_factory.go | 15 ++-- validator/client/iface/beacon_chain_client.go | 1 + .../multiple_endpoints_http_resolver.go | 70 ------------------- validator/client/service.go | 2 +- validator/rpc/beacon.go | 2 +- 12 files changed, 59 insertions(+), 88 deletions(-) delete mode 100644 validator/client/multiple_endpoints_http_resolver.go diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index a0deebea9c42..223a3f16a99f 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -10,7 +10,6 @@ go_library( "log.go", "metrics.go", "multiple_endpoints_grpc_resolver.go", - "multiple_endpoints_http_resolver.go", "propose.go", "propose_protect.go", "registration.go", diff --git a/validator/client/beacon-api/beacon_api_beacon_chain_client.go b/validator/client/beacon-api/beacon_api_beacon_chain_client.go index 08805224deba..c80a7ed1dd91 100644 --- a/validator/client/beacon-api/beacon_api_beacon_chain_client.go +++ b/validator/client/beacon-api/beacon_api_beacon_chain_client.go @@ -357,10 +357,14 @@ func (c beaconApiBeaconChainClient) GetValidatorParticipation(ctx context.Contex panic("beaconApiBeaconChainClient.GetValidatorParticipation is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiBeaconChainClientWithFallback.") } +func (c beaconApiBeaconChainClient) MultipleEndpointResolver(ctx context.Context, beaconApiUrls []string) { + c.jsonRestHandler.SwitchBeaconEndpoint(ctx, beaconApiUrls) +} + func NewBeaconApiBeaconChainClientWithFallback(host string, timeout time.Duration, fallbackClient iface.BeaconChainClient) iface.BeaconChainClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: host, + host: func() string { return host }, } return &beaconApiBeaconChainClient{ diff --git a/validator/client/beacon-api/beacon_api_node_client.go b/validator/client/beacon-api/beacon_api_node_client.go index adc3ff6bf766..bd60d2ce7def 100644 --- a/validator/client/beacon-api/beacon_api_node_client.go +++ b/validator/client/beacon-api/beacon_api_node_client.go @@ -103,7 +103,7 @@ func (c *beaconApiNodeClient) ListPeers(ctx context.Context, in *empty.Empty) (* func NewNodeClientWithFallback(host string, timeout time.Duration, fallbackClient iface.NodeClient) iface.NodeClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: host, + host: func() string { return host }, } return &beaconApiNodeClient{ diff --git a/validator/client/beacon-api/beacon_api_validator_client.go b/validator/client/beacon-api/beacon_api_validator_client.go index 67da2d6ebefe..48c9e9bfd6d1 100644 --- a/validator/client/beacon-api/beacon_api_validator_client.go +++ b/validator/client/beacon-api/beacon_api_validator_client.go @@ -26,7 +26,7 @@ type beaconApiValidatorClient struct { func NewBeaconApiValidatorClient(host string, timeout time.Duration) iface.ValidatorClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: host, + host: func() string { return host }, } return &beaconApiValidatorClient{ diff --git a/validator/client/beacon-api/json_rest_handler.go b/validator/client/beacon-api/json_rest_handler.go index 9a7c30e3e312..b938437effac 100644 --- a/validator/client/beacon-api/json_rest_handler.go +++ b/validator/client/beacon-api/json_rest_handler.go @@ -6,6 +6,7 @@ import ( "encoding/json" "io" "net/http" + "time" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api" @@ -15,11 +16,12 @@ import ( type JsonRestHandler interface { Get(ctx context.Context, query string, resp interface{}) error Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp interface{}) error + SwitchBeaconEndpoint(ctx context.Context, beaconApiUrls []string) } type beaconApiJsonRestHandler struct { httpClient http.Client - host string + host func() string } // Get sends a GET request and decodes the response body as a JSON object into the passed in object. @@ -29,7 +31,7 @@ func (c beaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp return errors.New("resp is nil") } - url := c.host + endpoint + url := c.host() + endpoint req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -60,8 +62,7 @@ func (c beaconApiJsonRestHandler) Post( if data == nil { return errors.New("data is nil") } - - url := c.host + apiEndpoint + url := c.host() + apiEndpoint req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, data) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -115,3 +116,34 @@ func decodeResp(httpResp *http.Response, resp interface{}) error { return nil } + +// SwitchBeaconEndpoint switches to the next available endpoint, this is circular. +func (c beaconApiJsonRestHandler) SwitchBeaconEndpoint(ctx context.Context, beaconApiUrls []string) { + const endpoint = "/eth/v1/node/health" + ticker := time.NewTicker(5 * time.Second) // Check every 5 seconds + go func() { + for { + select { + case <-ticker.C: + // GET request to the health endpoint using the current host + err := c.Get(ctx, endpoint, nil) + if err != nil { + for i, url := range beaconApiUrls { + if url == c.host() { + next := (i + 1) % len(beaconApiUrls) + c.changeHost(beaconApiUrls[next]) + break + } + } + } + } + } + }() + defer ticker.Stop() + select {} +} + +// changeHost updates the host function in beaconApiJsonRestHandler +func (c beaconApiJsonRestHandler) changeHost(newHost string) { + c.host = func() string { return newHost } +} diff --git a/validator/client/beacon-api/json_rest_handler_test.go b/validator/client/beacon-api/json_rest_handler_test.go index b9652a6d6f90..4015c8289c99 100644 --- a/validator/client/beacon-api/json_rest_handler_test.go +++ b/validator/client/beacon-api/json_rest_handler_test.go @@ -42,7 +42,7 @@ func TestGet(t *testing.T) { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: time.Second * 5}, - host: server.URL, + host: func() string { return server.URL }, } resp := &beacon.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Get(ctx, endpoint+"?arg1=abc&arg2=def", resp)) @@ -88,7 +88,7 @@ func TestPost(t *testing.T) { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: time.Second * 5}, - host: server.URL, + host: func() string { return server.URL }, } resp := &beacon.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Post(ctx, endpoint, headers, bytes.NewBuffer(dataBytes), resp)) diff --git a/validator/client/beacon-api/prysm_beacon_chain_client.go b/validator/client/beacon-api/prysm_beacon_chain_client.go index 6a9876ac7042..7b5cb8b6b109 100644 --- a/validator/client/beacon-api/prysm_beacon_chain_client.go +++ b/validator/client/beacon-api/prysm_beacon_chain_client.go @@ -19,7 +19,7 @@ import ( func NewPrysmBeaconChainClient(host string, timeout time.Duration, nodeClient iface.NodeClient) iface.PrysmBeaconChainClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: host, + host: func() string { return host }, } return prysmBeaconChainClient{ diff --git a/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go b/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go index 0cc5d888584e..d803f63b0c9d 100644 --- a/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go +++ b/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go @@ -1,6 +1,9 @@ package validator_client_factory import ( + "context" + "strings" + "github.com/prysmaticlabs/prysm/v4/config/features" beaconApi "github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api" grpcApi "github.com/prysmaticlabs/prysm/v4/validator/client/grpc-api" @@ -9,19 +12,21 @@ import ( validatorHelpers "github.com/prysmaticlabs/prysm/v4/validator/helpers" ) -func NewBeaconChainClient(validatorConn validatorHelpers.NodeConnection) iface.BeaconChainClient { +func NewBeaconChainClient(ctx context.Context, validatorConn validatorHelpers.NodeConnection) iface.BeaconChainClient { grpcClient := grpcApi.NewGrpcBeaconChainClient(validatorConn.GetGrpcClientConn()) featureFlags := features.Get() if featureFlags.EnableBeaconRESTApi { - return beaconApi.NewBeaconApiBeaconChainClientWithFallback( - validatorConn.GetBeaconApiUrl(), + urls := strings.Split(validatorConn.GetBeaconApiUrl(), ",") + bc := beaconApi.NewBeaconApiBeaconChainClientWithFallback( + urls[0], validatorConn.GetBeaconApiTimeout(), grpcClient, ) - } else { - return grpcClient + bc.MultipleEndpointResolver(ctx) + return bc } + return grpcClient } func NewPrysmBeaconClient(validatorConn validatorHelpers.NodeConnection) iface.PrysmBeaconChainClient { diff --git a/validator/client/iface/beacon_chain_client.go b/validator/client/iface/beacon_chain_client.go index cbff1c5d6c5f..40639e481566 100644 --- a/validator/client/iface/beacon_chain_client.go +++ b/validator/client/iface/beacon_chain_client.go @@ -14,4 +14,5 @@ type BeaconChainClient interface { GetValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error) GetValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error) GetValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error) + MultipleEndpointResolver(ctx context.Context, beaconApiUrls []string) } diff --git a/validator/client/multiple_endpoints_http_resolver.go b/validator/client/multiple_endpoints_http_resolver.go deleted file mode 100644 index 77dbb0fe1311..000000000000 --- a/validator/client/multiple_endpoints_http_resolver.go +++ /dev/null @@ -1,70 +0,0 @@ -package client - -import ( - "fmt" - "net/http" - - "github.com/prysmaticlabs/prysm/v4/network/httputil" -) - -// MultipleEndpointsHTTPResolver is a custom resolver for HTTP clients that supports multiple addresses. -type MultipleEndpointsHTTPResolver struct { - addresses []string - currentIdx int - client *http.Client -} - -// NewMultipleEndpointsHTTPResolver creates a new instance of MultipleEndpointsHTTPResolver. -func NewMultipleEndpointsHTTPResolver(addresses []string) *MultipleEndpointsHTTPResolver { - return &MultipleEndpointsHTTPResolver{ - addresses: addresses, - currentIdx: 0, - client: &http.Client{}, - } -} - -func (r *MultipleEndpointsHTTPResolver) HttpMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - // Attempt to send the request to the current endpoint - err := r.sendRequest(req, w) - - // Switch to the next endpoint and retry if there is an error - for i := 0; i < len(r.addresses)-1 && err != nil; i++ { - r.switchEndpoint() - err = r.sendRequest(req, w) - } - - if err != nil { - httputil.HandleError(w, fmt.Sprintf("failed to send request: %v", err), http.StatusInternalServerError) - return - } - - next.ServeHTTP(w, req) - }) -} - -// sendRequest sends the HTTP request to the current endpoint. -func (r *MultipleEndpointsHTTPResolver) sendRequest(req *http.Request, w http.ResponseWriter) error { - // Update the request URL with the current endpoint - req.URL.Host = r.resolveEndpoint() - - // Send the HTTP request using the client - resp, err := r.client.Do(req) - if err != nil { - // Optionally handle specific errors or log them - httputil.HandleError(w, fmt.Sprintf("error sending request to %s: %v\n", r.resolveEndpoint(), err), http.StatusInternalServerError) - return err - } - defer resp.Body.Close() - return nil -} - -// resolveEndpoint returns the current endpoint based on the resolver's state. -func (r *MultipleEndpointsHTTPResolver) resolveEndpoint() string { - return r.addresses[r.currentIdx] -} - -// switchToNextEndpoint switches to the next available endpoint, this is circular. -func (r *MultipleEndpointsHTTPResolver) switchEndpoint() { - r.currentIdx = (r.currentIdx + 1) % len(r.addresses) -} diff --git a/validator/client/service.go b/validator/client/service.go index 566ed0515319..076778498201 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -190,7 +190,7 @@ func (v *ValidatorService) Start() { } validatorClient := validatorClientFactory.NewValidatorClient(v.conn) - beaconClient := beaconChainClientFactory.NewBeaconChainClient(v.conn) + beaconClient := beaconChainClientFactory.NewBeaconChainClient(v.ctx, v.conn) prysmBeaconClient := beaconChainClientFactory.NewPrysmBeaconClient(v.conn) valStruct := &validator{ diff --git a/validator/rpc/beacon.go b/validator/rpc/beacon.go index d79bb44e0e55..acba73bb7388 100644 --- a/validator/rpc/beacon.go +++ b/validator/rpc/beacon.go @@ -51,7 +51,7 @@ func (s *Server) registerBeaconClient() error { s.beaconApiTimeout, ) - s.beaconChainClient = beaconChainClientFactory.NewBeaconChainClient(conn) + s.beaconChainClient = beaconChainClientFactory.NewBeaconChainClient(s.ctx, conn) s.beaconNodeClient = nodeClientFactory.NewNodeClient(conn) s.beaconNodeValidatorClient = validatorClientFactory.NewValidatorClient(conn) return nil From a3eda2dca98e07006345caebfdb11c3c436099e0 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Fri, 16 Feb 2024 18:21:42 -0800 Subject: [PATCH 03/39] Revert "Redo" This reverts commit 5437c44ac26e48c041f5c16f399446c5f72c31a2. --- validator/client/BUILD.bazel | 1 + .../beacon_api_beacon_chain_client.go | 6 +- .../beacon-api/beacon_api_node_client.go | 2 +- .../beacon-api/beacon_api_validator_client.go | 2 +- .../client/beacon-api/json_rest_handler.go | 40 ++--------- .../beacon-api/json_rest_handler_test.go | 4 +- .../beacon-api/prysm_beacon_chain_client.go | 2 +- .../beacon_chain_client_factory.go | 15 ++-- validator/client/iface/beacon_chain_client.go | 1 - .../multiple_endpoints_http_resolver.go | 70 +++++++++++++++++++ validator/client/service.go | 2 +- validator/rpc/beacon.go | 2 +- 12 files changed, 88 insertions(+), 59 deletions(-) create mode 100644 validator/client/multiple_endpoints_http_resolver.go diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 223a3f16a99f..a0deebea9c42 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -10,6 +10,7 @@ go_library( "log.go", "metrics.go", "multiple_endpoints_grpc_resolver.go", + "multiple_endpoints_http_resolver.go", "propose.go", "propose_protect.go", "registration.go", diff --git a/validator/client/beacon-api/beacon_api_beacon_chain_client.go b/validator/client/beacon-api/beacon_api_beacon_chain_client.go index c80a7ed1dd91..08805224deba 100644 --- a/validator/client/beacon-api/beacon_api_beacon_chain_client.go +++ b/validator/client/beacon-api/beacon_api_beacon_chain_client.go @@ -357,14 +357,10 @@ func (c beaconApiBeaconChainClient) GetValidatorParticipation(ctx context.Contex panic("beaconApiBeaconChainClient.GetValidatorParticipation is not implemented. To use a fallback client, pass a fallback client as the last argument of NewBeaconApiBeaconChainClientWithFallback.") } -func (c beaconApiBeaconChainClient) MultipleEndpointResolver(ctx context.Context, beaconApiUrls []string) { - c.jsonRestHandler.SwitchBeaconEndpoint(ctx, beaconApiUrls) -} - func NewBeaconApiBeaconChainClientWithFallback(host string, timeout time.Duration, fallbackClient iface.BeaconChainClient) iface.BeaconChainClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: func() string { return host }, + host: host, } return &beaconApiBeaconChainClient{ diff --git a/validator/client/beacon-api/beacon_api_node_client.go b/validator/client/beacon-api/beacon_api_node_client.go index bd60d2ce7def..adc3ff6bf766 100644 --- a/validator/client/beacon-api/beacon_api_node_client.go +++ b/validator/client/beacon-api/beacon_api_node_client.go @@ -103,7 +103,7 @@ func (c *beaconApiNodeClient) ListPeers(ctx context.Context, in *empty.Empty) (* func NewNodeClientWithFallback(host string, timeout time.Duration, fallbackClient iface.NodeClient) iface.NodeClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: func() string { return host }, + host: host, } return &beaconApiNodeClient{ diff --git a/validator/client/beacon-api/beacon_api_validator_client.go b/validator/client/beacon-api/beacon_api_validator_client.go index 48c9e9bfd6d1..67da2d6ebefe 100644 --- a/validator/client/beacon-api/beacon_api_validator_client.go +++ b/validator/client/beacon-api/beacon_api_validator_client.go @@ -26,7 +26,7 @@ type beaconApiValidatorClient struct { func NewBeaconApiValidatorClient(host string, timeout time.Duration) iface.ValidatorClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: func() string { return host }, + host: host, } return &beaconApiValidatorClient{ diff --git a/validator/client/beacon-api/json_rest_handler.go b/validator/client/beacon-api/json_rest_handler.go index b938437effac..9a7c30e3e312 100644 --- a/validator/client/beacon-api/json_rest_handler.go +++ b/validator/client/beacon-api/json_rest_handler.go @@ -6,7 +6,6 @@ import ( "encoding/json" "io" "net/http" - "time" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v4/api" @@ -16,12 +15,11 @@ import ( type JsonRestHandler interface { Get(ctx context.Context, query string, resp interface{}) error Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp interface{}) error - SwitchBeaconEndpoint(ctx context.Context, beaconApiUrls []string) } type beaconApiJsonRestHandler struct { httpClient http.Client - host func() string + host string } // Get sends a GET request and decodes the response body as a JSON object into the passed in object. @@ -31,7 +29,7 @@ func (c beaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp return errors.New("resp is nil") } - url := c.host() + endpoint + url := c.host + endpoint req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -62,7 +60,8 @@ func (c beaconApiJsonRestHandler) Post( if data == nil { return errors.New("data is nil") } - url := c.host() + apiEndpoint + + url := c.host + apiEndpoint req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, data) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -116,34 +115,3 @@ func decodeResp(httpResp *http.Response, resp interface{}) error { return nil } - -// SwitchBeaconEndpoint switches to the next available endpoint, this is circular. -func (c beaconApiJsonRestHandler) SwitchBeaconEndpoint(ctx context.Context, beaconApiUrls []string) { - const endpoint = "/eth/v1/node/health" - ticker := time.NewTicker(5 * time.Second) // Check every 5 seconds - go func() { - for { - select { - case <-ticker.C: - // GET request to the health endpoint using the current host - err := c.Get(ctx, endpoint, nil) - if err != nil { - for i, url := range beaconApiUrls { - if url == c.host() { - next := (i + 1) % len(beaconApiUrls) - c.changeHost(beaconApiUrls[next]) - break - } - } - } - } - } - }() - defer ticker.Stop() - select {} -} - -// changeHost updates the host function in beaconApiJsonRestHandler -func (c beaconApiJsonRestHandler) changeHost(newHost string) { - c.host = func() string { return newHost } -} diff --git a/validator/client/beacon-api/json_rest_handler_test.go b/validator/client/beacon-api/json_rest_handler_test.go index 4015c8289c99..b9652a6d6f90 100644 --- a/validator/client/beacon-api/json_rest_handler_test.go +++ b/validator/client/beacon-api/json_rest_handler_test.go @@ -42,7 +42,7 @@ func TestGet(t *testing.T) { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: time.Second * 5}, - host: func() string { return server.URL }, + host: server.URL, } resp := &beacon.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Get(ctx, endpoint+"?arg1=abc&arg2=def", resp)) @@ -88,7 +88,7 @@ func TestPost(t *testing.T) { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: time.Second * 5}, - host: func() string { return server.URL }, + host: server.URL, } resp := &beacon.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Post(ctx, endpoint, headers, bytes.NewBuffer(dataBytes), resp)) diff --git a/validator/client/beacon-api/prysm_beacon_chain_client.go b/validator/client/beacon-api/prysm_beacon_chain_client.go index 7b5cb8b6b109..6a9876ac7042 100644 --- a/validator/client/beacon-api/prysm_beacon_chain_client.go +++ b/validator/client/beacon-api/prysm_beacon_chain_client.go @@ -19,7 +19,7 @@ import ( func NewPrysmBeaconChainClient(host string, timeout time.Duration, nodeClient iface.NodeClient) iface.PrysmBeaconChainClient { jsonRestHandler := beaconApiJsonRestHandler{ httpClient: http.Client{Timeout: timeout}, - host: func() string { return host }, + host: host, } return prysmBeaconChainClient{ diff --git a/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go b/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go index d803f63b0c9d..0cc5d888584e 100644 --- a/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go +++ b/validator/client/beacon-chain-client-factory/beacon_chain_client_factory.go @@ -1,9 +1,6 @@ package validator_client_factory import ( - "context" - "strings" - "github.com/prysmaticlabs/prysm/v4/config/features" beaconApi "github.com/prysmaticlabs/prysm/v4/validator/client/beacon-api" grpcApi "github.com/prysmaticlabs/prysm/v4/validator/client/grpc-api" @@ -12,21 +9,19 @@ import ( validatorHelpers "github.com/prysmaticlabs/prysm/v4/validator/helpers" ) -func NewBeaconChainClient(ctx context.Context, validatorConn validatorHelpers.NodeConnection) iface.BeaconChainClient { +func NewBeaconChainClient(validatorConn validatorHelpers.NodeConnection) iface.BeaconChainClient { grpcClient := grpcApi.NewGrpcBeaconChainClient(validatorConn.GetGrpcClientConn()) featureFlags := features.Get() if featureFlags.EnableBeaconRESTApi { - urls := strings.Split(validatorConn.GetBeaconApiUrl(), ",") - bc := beaconApi.NewBeaconApiBeaconChainClientWithFallback( - urls[0], + return beaconApi.NewBeaconApiBeaconChainClientWithFallback( + validatorConn.GetBeaconApiUrl(), validatorConn.GetBeaconApiTimeout(), grpcClient, ) - bc.MultipleEndpointResolver(ctx) - return bc + } else { + return grpcClient } - return grpcClient } func NewPrysmBeaconClient(validatorConn validatorHelpers.NodeConnection) iface.PrysmBeaconChainClient { diff --git a/validator/client/iface/beacon_chain_client.go b/validator/client/iface/beacon_chain_client.go index 40639e481566..cbff1c5d6c5f 100644 --- a/validator/client/iface/beacon_chain_client.go +++ b/validator/client/iface/beacon_chain_client.go @@ -14,5 +14,4 @@ type BeaconChainClient interface { GetValidatorQueue(ctx context.Context, in *empty.Empty) (*ethpb.ValidatorQueue, error) GetValidatorPerformance(ctx context.Context, in *ethpb.ValidatorPerformanceRequest) (*ethpb.ValidatorPerformanceResponse, error) GetValidatorParticipation(ctx context.Context, in *ethpb.GetValidatorParticipationRequest) (*ethpb.ValidatorParticipationResponse, error) - MultipleEndpointResolver(ctx context.Context, beaconApiUrls []string) } diff --git a/validator/client/multiple_endpoints_http_resolver.go b/validator/client/multiple_endpoints_http_resolver.go new file mode 100644 index 000000000000..77dbb0fe1311 --- /dev/null +++ b/validator/client/multiple_endpoints_http_resolver.go @@ -0,0 +1,70 @@ +package client + +import ( + "fmt" + "net/http" + + "github.com/prysmaticlabs/prysm/v4/network/httputil" +) + +// MultipleEndpointsHTTPResolver is a custom resolver for HTTP clients that supports multiple addresses. +type MultipleEndpointsHTTPResolver struct { + addresses []string + currentIdx int + client *http.Client +} + +// NewMultipleEndpointsHTTPResolver creates a new instance of MultipleEndpointsHTTPResolver. +func NewMultipleEndpointsHTTPResolver(addresses []string) *MultipleEndpointsHTTPResolver { + return &MultipleEndpointsHTTPResolver{ + addresses: addresses, + currentIdx: 0, + client: &http.Client{}, + } +} + +func (r *MultipleEndpointsHTTPResolver) HttpMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + // Attempt to send the request to the current endpoint + err := r.sendRequest(req, w) + + // Switch to the next endpoint and retry if there is an error + for i := 0; i < len(r.addresses)-1 && err != nil; i++ { + r.switchEndpoint() + err = r.sendRequest(req, w) + } + + if err != nil { + httputil.HandleError(w, fmt.Sprintf("failed to send request: %v", err), http.StatusInternalServerError) + return + } + + next.ServeHTTP(w, req) + }) +} + +// sendRequest sends the HTTP request to the current endpoint. +func (r *MultipleEndpointsHTTPResolver) sendRequest(req *http.Request, w http.ResponseWriter) error { + // Update the request URL with the current endpoint + req.URL.Host = r.resolveEndpoint() + + // Send the HTTP request using the client + resp, err := r.client.Do(req) + if err != nil { + // Optionally handle specific errors or log them + httputil.HandleError(w, fmt.Sprintf("error sending request to %s: %v\n", r.resolveEndpoint(), err), http.StatusInternalServerError) + return err + } + defer resp.Body.Close() + return nil +} + +// resolveEndpoint returns the current endpoint based on the resolver's state. +func (r *MultipleEndpointsHTTPResolver) resolveEndpoint() string { + return r.addresses[r.currentIdx] +} + +// switchToNextEndpoint switches to the next available endpoint, this is circular. +func (r *MultipleEndpointsHTTPResolver) switchEndpoint() { + r.currentIdx = (r.currentIdx + 1) % len(r.addresses) +} diff --git a/validator/client/service.go b/validator/client/service.go index 076778498201..566ed0515319 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -190,7 +190,7 @@ func (v *ValidatorService) Start() { } validatorClient := validatorClientFactory.NewValidatorClient(v.conn) - beaconClient := beaconChainClientFactory.NewBeaconChainClient(v.ctx, v.conn) + beaconClient := beaconChainClientFactory.NewBeaconChainClient(v.conn) prysmBeaconClient := beaconChainClientFactory.NewPrysmBeaconClient(v.conn) valStruct := &validator{ diff --git a/validator/rpc/beacon.go b/validator/rpc/beacon.go index acba73bb7388..d79bb44e0e55 100644 --- a/validator/rpc/beacon.go +++ b/validator/rpc/beacon.go @@ -51,7 +51,7 @@ func (s *Server) registerBeaconClient() error { s.beaconApiTimeout, ) - s.beaconChainClient = beaconChainClientFactory.NewBeaconChainClient(s.ctx, conn) + s.beaconChainClient = beaconChainClientFactory.NewBeaconChainClient(conn) s.beaconNodeClient = nodeClientFactory.NewNodeClient(conn) s.beaconNodeValidatorClient = validatorClientFactory.NewValidatorClient(conn) return nil From d337580485750d0eeadffcbcafea1949781a09b1 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Fri, 16 Feb 2024 18:22:19 -0800 Subject: [PATCH 04/39] Revert "http resolver" This reverts commit 206207b530c30aca13d705db259c6cf738cae533. --- validator/client/BUILD.bazel | 1 - .../multiple_endpoints_http_resolver.go | 70 ------------------- 2 files changed, 71 deletions(-) delete mode 100644 validator/client/multiple_endpoints_http_resolver.go diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index a0deebea9c42..223a3f16a99f 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -10,7 +10,6 @@ go_library( "log.go", "metrics.go", "multiple_endpoints_grpc_resolver.go", - "multiple_endpoints_http_resolver.go", "propose.go", "propose_protect.go", "registration.go", diff --git a/validator/client/multiple_endpoints_http_resolver.go b/validator/client/multiple_endpoints_http_resolver.go deleted file mode 100644 index 77dbb0fe1311..000000000000 --- a/validator/client/multiple_endpoints_http_resolver.go +++ /dev/null @@ -1,70 +0,0 @@ -package client - -import ( - "fmt" - "net/http" - - "github.com/prysmaticlabs/prysm/v4/network/httputil" -) - -// MultipleEndpointsHTTPResolver is a custom resolver for HTTP clients that supports multiple addresses. -type MultipleEndpointsHTTPResolver struct { - addresses []string - currentIdx int - client *http.Client -} - -// NewMultipleEndpointsHTTPResolver creates a new instance of MultipleEndpointsHTTPResolver. -func NewMultipleEndpointsHTTPResolver(addresses []string) *MultipleEndpointsHTTPResolver { - return &MultipleEndpointsHTTPResolver{ - addresses: addresses, - currentIdx: 0, - client: &http.Client{}, - } -} - -func (r *MultipleEndpointsHTTPResolver) HttpMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - // Attempt to send the request to the current endpoint - err := r.sendRequest(req, w) - - // Switch to the next endpoint and retry if there is an error - for i := 0; i < len(r.addresses)-1 && err != nil; i++ { - r.switchEndpoint() - err = r.sendRequest(req, w) - } - - if err != nil { - httputil.HandleError(w, fmt.Sprintf("failed to send request: %v", err), http.StatusInternalServerError) - return - } - - next.ServeHTTP(w, req) - }) -} - -// sendRequest sends the HTTP request to the current endpoint. -func (r *MultipleEndpointsHTTPResolver) sendRequest(req *http.Request, w http.ResponseWriter) error { - // Update the request URL with the current endpoint - req.URL.Host = r.resolveEndpoint() - - // Send the HTTP request using the client - resp, err := r.client.Do(req) - if err != nil { - // Optionally handle specific errors or log them - httputil.HandleError(w, fmt.Sprintf("error sending request to %s: %v\n", r.resolveEndpoint(), err), http.StatusInternalServerError) - return err - } - defer resp.Body.Close() - return nil -} - -// resolveEndpoint returns the current endpoint based on the resolver's state. -func (r *MultipleEndpointsHTTPResolver) resolveEndpoint() string { - return r.addresses[r.currentIdx] -} - -// switchToNextEndpoint switches to the next available endpoint, this is circular. -func (r *MultipleEndpointsHTTPResolver) switchEndpoint() { - r.currentIdx = (r.currentIdx + 1) % len(r.addresses) -} From 1c7211242a72baec11363c25f75872448a0b3f05 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Fri, 16 Feb 2024 18:37:30 -0800 Subject: [PATCH 05/39] Add host change to ValidatorClient + Validator --- .../beacon-api/beacon_api_validator_client.go | 8 ++++ .../client/beacon-api/json_rest_handler.go | 20 ++++++++-- validator/client/iface/validator.go | 2 + validator/client/iface/validator_client.go | 2 + validator/client/service.go | 37 ++++++++++++++++++- validator/client/validator.go | 8 ++++ validator/rpc/beacon.go | 2 +- 7 files changed, 73 insertions(+), 6 deletions(-) diff --git a/validator/client/beacon-api/beacon_api_validator_client.go b/validator/client/beacon-api/beacon_api_validator_client.go index f1a46438dd99..7ca48483bd9b 100644 --- a/validator/client/beacon-api/beacon_api_validator_client.go +++ b/validator/client/beacon-api/beacon_api_validator_client.go @@ -179,3 +179,11 @@ func (c *beaconApiValidatorClient) EventStreamIsRunning() bool { func (c *beaconApiValidatorClient) GetAggregatedSelections(ctx context.Context, selections []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) { return c.getAggregatedSelection(ctx, selections) } + +func (c *beaconApiValidatorClient) RetrieveHost() string { + return c.jsonRestHandler.GetHost() +} + +func (c *beaconApiValidatorClient) UpdateHost(host string) { + c.jsonRestHandler.SetHost(host) +} diff --git a/validator/client/beacon-api/json_rest_handler.go b/validator/client/beacon-api/json_rest_handler.go index 923d4842b2f7..cd9e8e663c3d 100644 --- a/validator/client/beacon-api/json_rest_handler.go +++ b/validator/client/beacon-api/json_rest_handler.go @@ -16,17 +16,20 @@ import ( type JsonRestHandler interface { Get(ctx context.Context, endpoint string, resp interface{}) error Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp interface{}) error + GetHost() string + SetHost(newHost string) } type BeaconApiJsonRestHandler struct { HttpClient http.Client - Host string + Host func() string } // Get sends a GET request and decodes the response body as a JSON object into the passed in object. // If an HTTP error is returned, the body is decoded as a DefaultJsonError JSON object and returned as the first return value. func (c BeaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp interface{}) error { - url := c.Host + endpoint + url := c.Host() + endpoint + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -58,7 +61,8 @@ func (c BeaconApiJsonRestHandler) Post( return errors.New("data is nil") } - url := c.Host + apiEndpoint + url := c.Host() + apiEndpoint + req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, data) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -114,3 +118,13 @@ func decodeResp(httpResp *http.Response, resp interface{}) error { return nil } + +func (c BeaconApiJsonRestHandler) GetHost() string { + return c.Host() +} + +func (c BeaconApiJsonRestHandler) SetHost(newHost string) { + c.Host = func() string { + return newHost + } +} diff --git a/validator/client/iface/validator.go b/validator/client/iface/validator.go index 18ebfb512c17..ab93ee795f55 100644 --- a/validator/client/iface/validator.go +++ b/validator/client/iface/validator.go @@ -67,6 +67,8 @@ type Validator interface { StartEventStream(ctx context.Context) error EventStreamIsRunning() bool NodeIsHealthy(ctx context.Context) bool + RetrieveHost() string + UpdateHost(host string) } // SigningFunc interface defines a type for the a function that signs a message diff --git a/validator/client/iface/validator_client.go b/validator/client/iface/validator_client.go index 24956e881a29..03520aea68e5 100644 --- a/validator/client/iface/validator_client.go +++ b/validator/client/iface/validator_client.go @@ -91,4 +91,6 @@ type ValidatorClient interface { StartEventStream(ctx context.Context) error EventStreamIsRunning() bool GetAggregatedSelections(ctx context.Context, selections []BeaconCommitteeSelection) ([]BeaconCommitteeSelection, error) + RetrieveHost() string + UpdateHost(host string) } diff --git a/validator/client/service.go b/validator/client/service.go index 2da49d8ea013..9389ea559bd7 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -15,6 +15,7 @@ import ( grpcutil "github.com/prysmaticlabs/prysm/v5/api/grpc" "github.com/prysmaticlabs/prysm/v5/async/event" lruwrpr "github.com/prysmaticlabs/prysm/v5/cache/lru" + "github.com/prysmaticlabs/prysm/v5/config/features" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" validatorserviceconfig "github.com/prysmaticlabs/prysm/v5/config/validator/service" @@ -194,15 +195,22 @@ func (v *ValidatorService) Start() { return } + urls := strings.Split(v.conn.GetBeaconApiUrl(), ",") restHandler := &beaconApi.BeaconApiJsonRestHandler{ HttpClient: http.Client{Timeout: v.conn.GetBeaconApiTimeout()}, - Host: v.conn.GetBeaconApiUrl(), + Host: func() string { + return urls[0] + }, } - evHandler := beaconApi.NewEventHandler(http.DefaultClient, v.conn.GetBeaconApiUrl()) + evHandler := beaconApi.NewEventHandler(http.DefaultClient, urls[0]) opts := []beaconApi.ValidatorClientOpt{beaconApi.WithEventHandler(evHandler)} validatorClient := validatorClientFactory.NewValidatorClient(v.conn, restHandler, opts...) + if len(urls) > 1 && features.Get().EnableBeaconRESTApi { + runNodeSwitcherRoutine(v.ctx, v.validator, urls) + } + valStruct := &validator{ validatorClient: validatorClient, beaconClient: beaconChainClientFactory.NewBeaconChainClient(v.conn, restHandler), @@ -360,3 +368,28 @@ func (v *ValidatorService) GenesisInfo(ctx context.Context) (*ethpb.Genesis, err nc := ethpb.NewNodeClient(v.conn.GetGrpcClientConn()) return nc.GetGenesis(ctx, &emptypb.Empty{}) } + +func runNodeSwitcherRoutine(ctx context.Context, v iface.Validator, endpoints []string) { + healthCheckTicker := time.NewTicker(time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second) + go func() { + for { + select { + case <-healthCheckTicker.C: + if !v.NodeIsHealthy(ctx) { + for i, url := range endpoints { + if url == v.RetrieveHost() { + next := (i + 1) % len(endpoints) + v.UpdateHost(endpoints[next]) + } + } + } + case <-ctx.Done(): + if ctx.Err() != nil { + log.WithError(ctx.Err()).Error("Context cancelled") + } + log.Error("Context cancelled") + return + } + } + }() +} diff --git a/validator/client/validator.go b/validator/client/validator.go index 93b3ef6ba4f3..94318ae8ddbf 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -1085,6 +1085,14 @@ func (v *validator) NodeIsHealthy(ctx context.Context) bool { return v.nodeClient.IsHealthy(ctx) } +func (v *validator) RetrieveHost() string { + return v.validatorClient.RetrieveHost() +} + +func (v *validator) UpdateHost(host string) { + v.validatorClient.UpdateHost(host) +} + func (v *validator) filterAndCacheActiveKeys(ctx context.Context, pubkeys [][fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([][fieldparams.BLSPubkeyLength]byte, error) { filteredKeys := make([][fieldparams.BLSPubkeyLength]byte, 0) statusRequestKeys := make([][]byte, 0) diff --git a/validator/rpc/beacon.go b/validator/rpc/beacon.go index c165e1a92f30..44e291606351 100644 --- a/validator/rpc/beacon.go +++ b/validator/rpc/beacon.go @@ -56,7 +56,7 @@ func (s *Server) registerBeaconClient() error { restHandler := &beaconApi.BeaconApiJsonRestHandler{ HttpClient: http.Client{Timeout: s.beaconApiTimeout}, - Host: s.beaconApiEndpoint, + Host: func() string { return s.beaconApiEndpoint }, } s.beaconChainClient = beaconChainClientFactory.NewBeaconChainClient(conn, restHandler) s.beaconNodeClient = nodeClientFactory.NewNodeClient(conn, restHandler) From b7e0af5aca4b5545edce49d0c3a3215fed684846 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 11:39:52 -0800 Subject: [PATCH 06/39] Update mockgen --- crypto/bls/common/mock/interface_mock.go | 21 +- hack/update-mockgen.sh | 1 + testing/mock/beacon_service_mock.go | 115 +++++----- testing/mock/beacon_validator_client_mock.go | 199 +++++++++--------- testing/mock/beacon_validator_server_mock.go | 111 +++++----- testing/mock/node_service_mock.go | 55 ++--- .../beacon_chain_client_mock.go | 19 +- testing/validator-mock/node_client_mock.go | 17 +- .../prysm_beacon_chain_client_mock.go | 9 +- .../validator-mock/validator_client_mock.go | 87 +++++--- .../beacon-api/json_rest_handler_test.go | 19 +- .../mock/beacon_block_converter_mock.go | 15 +- .../client/beacon-api/mock/duties_mock.go | 15 +- .../client/beacon-api/mock/genesis_mock.go | 9 +- .../beacon-api/mock/json_rest_handler_mock.go | 41 +++- .../beacon-api/mock/state_validators_mock.go | 13 +- 16 files changed, 442 insertions(+), 304 deletions(-) diff --git a/crypto/bls/common/mock/interface_mock.go b/crypto/bls/common/mock/interface_mock.go index d8c93097d29e..c7a0c27040d0 100644 --- a/crypto/bls/common/mock/interface_mock.go +++ b/crypto/bls/common/mock/interface_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: crypto/bls/common/interface.go +// +// Generated by this command: +// +// mockgen -package=mock -source=crypto/bls/common/interface.go -destination=crypto/bls/common/mock/interface_mock.go +// // Package mock is a generated GoMock package. package mock @@ -7,8 +12,8 @@ package mock import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" common "github.com/prysmaticlabs/prysm/v5/crypto/bls/common" + gomock "go.uber.org/mock/gomock" ) // MockSecretKey is a mock of SecretKey interface. @@ -71,7 +76,7 @@ func (m *MockSecretKey) Sign(msg []byte) common.Signature { } // Sign indicates an expected call of Sign. -func (mr *MockSecretKeyMockRecorder) Sign(msg interface{}) *gomock.Call { +func (mr *MockSecretKeyMockRecorder) Sign(msg any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sign", reflect.TypeOf((*MockSecretKey)(nil).Sign), msg) } @@ -108,7 +113,7 @@ func (m *MockPublicKey) Aggregate(p2 common.PublicKey) common.PublicKey { } // Aggregate indicates an expected call of Aggregate. -func (mr *MockPublicKeyMockRecorder) Aggregate(p2 interface{}) *gomock.Call { +func (mr *MockPublicKeyMockRecorder) Aggregate(p2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Aggregate", reflect.TypeOf((*MockPublicKey)(nil).Aggregate), p2) } @@ -136,7 +141,7 @@ func (m *MockPublicKey) Equals(p2 common.PublicKey) bool { } // Equals indicates an expected call of Equals. -func (mr *MockPublicKeyMockRecorder) Equals(p2 interface{}) *gomock.Call { +func (mr *MockPublicKeyMockRecorder) Equals(p2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Equals", reflect.TypeOf((*MockPublicKey)(nil).Equals), p2) } @@ -201,7 +206,7 @@ func (m *MockSignature) AggregateVerify(pubKeys []common.PublicKey, msgs [][32]b } // AggregateVerify indicates an expected call of AggregateVerify. -func (mr *MockSignatureMockRecorder) AggregateVerify(pubKeys, msgs interface{}) *gomock.Call { +func (mr *MockSignatureMockRecorder) AggregateVerify(pubKeys, msgs any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AggregateVerify", reflect.TypeOf((*MockSignature)(nil).AggregateVerify), pubKeys, msgs) } @@ -229,7 +234,7 @@ func (m *MockSignature) Eth2FastAggregateVerify(pubKeys []common.PublicKey, msg } // Eth2FastAggregateVerify indicates an expected call of Eth2FastAggregateVerify. -func (mr *MockSignatureMockRecorder) Eth2FastAggregateVerify(pubKeys, msg interface{}) *gomock.Call { +func (mr *MockSignatureMockRecorder) Eth2FastAggregateVerify(pubKeys, msg any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eth2FastAggregateVerify", reflect.TypeOf((*MockSignature)(nil).Eth2FastAggregateVerify), pubKeys, msg) } @@ -243,7 +248,7 @@ func (m *MockSignature) FastAggregateVerify(pubKeys []common.PublicKey, msg [32] } // FastAggregateVerify indicates an expected call of FastAggregateVerify. -func (mr *MockSignatureMockRecorder) FastAggregateVerify(pubKeys, msg interface{}) *gomock.Call { +func (mr *MockSignatureMockRecorder) FastAggregateVerify(pubKeys, msg any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FastAggregateVerify", reflect.TypeOf((*MockSignature)(nil).FastAggregateVerify), pubKeys, msg) } @@ -271,7 +276,7 @@ func (m *MockSignature) Verify(pubKey common.PublicKey, msg []byte) bool { } // Verify indicates an expected call of Verify. -func (mr *MockSignatureMockRecorder) Verify(pubKey, msg interface{}) *gomock.Call { +func (mr *MockSignatureMockRecorder) Verify(pubKey, msg any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockSignature)(nil).Verify), pubKey, msg) } diff --git a/hack/update-mockgen.sh b/hack/update-mockgen.sh index 9c579b3c8cb1..c5fdd493c268 100755 --- a/hack/update-mockgen.sh +++ b/hack/update-mockgen.sh @@ -2,6 +2,7 @@ # Script to update mock files after proto/prysm/v1alpha1/services.proto changes. # Use a space to separate mock destination from its interfaces. +# Be sure to install mockgen before use: https://github.com/uber-go/mock mock_path="testing/mock" iface_mock_path="testing/validator-mock" diff --git a/testing/mock/beacon_service_mock.go b/testing/mock/beacon_service_mock.go index ee724db57109..78bf69ec1165 100644 --- a/testing/mock/beacon_service_mock.go +++ b/testing/mock/beacon_service_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 (interfaces: BeaconChainClient) +// +// Generated by this command: +// +// mockgen -package=mock -destination=testing/mock/beacon_service_mock.go github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 BeaconChainClient +// // Package mock is a generated GoMock package. package mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" grpc "google.golang.org/grpc" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -40,7 +45,7 @@ func (m *MockBeaconChainClient) EXPECT() *MockBeaconChainClientMockRecorder { // AttestationPool mocks base method. func (m *MockBeaconChainClient) AttestationPool(arg0 context.Context, arg1 *eth.AttestationPoolRequest, arg2 ...grpc.CallOption) (*eth.AttestationPoolResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -51,16 +56,16 @@ func (m *MockBeaconChainClient) AttestationPool(arg0 context.Context, arg1 *eth. } // AttestationPool indicates an expected call of AttestationPool. -func (mr *MockBeaconChainClientMockRecorder) AttestationPool(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) AttestationPool(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AttestationPool", reflect.TypeOf((*MockBeaconChainClient)(nil).AttestationPool), varargs...) } // GetBeaconConfig mocks base method. func (m *MockBeaconChainClient) GetBeaconConfig(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.BeaconConfig, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -71,16 +76,16 @@ func (m *MockBeaconChainClient) GetBeaconConfig(arg0 context.Context, arg1 *empt } // GetBeaconConfig indicates an expected call of GetBeaconConfig. -func (mr *MockBeaconChainClientMockRecorder) GetBeaconConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetBeaconConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBeaconConfig", reflect.TypeOf((*MockBeaconChainClient)(nil).GetBeaconConfig), varargs...) } // GetChainHead mocks base method. func (m *MockBeaconChainClient) GetChainHead(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.ChainHead, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -91,16 +96,16 @@ func (m *MockBeaconChainClient) GetChainHead(arg0 context.Context, arg1 *emptypb } // GetChainHead indicates an expected call of GetChainHead. -func (mr *MockBeaconChainClientMockRecorder) GetChainHead(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetChainHead(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChainHead", reflect.TypeOf((*MockBeaconChainClient)(nil).GetChainHead), varargs...) } // GetIndividualVotes mocks base method. func (m *MockBeaconChainClient) GetIndividualVotes(arg0 context.Context, arg1 *eth.IndividualVotesRequest, arg2 ...grpc.CallOption) (*eth.IndividualVotesRespond, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -111,16 +116,16 @@ func (m *MockBeaconChainClient) GetIndividualVotes(arg0 context.Context, arg1 *e } // GetIndividualVotes indicates an expected call of GetIndividualVotes. -func (mr *MockBeaconChainClientMockRecorder) GetIndividualVotes(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetIndividualVotes(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIndividualVotes", reflect.TypeOf((*MockBeaconChainClient)(nil).GetIndividualVotes), varargs...) } // GetValidator mocks base method. func (m *MockBeaconChainClient) GetValidator(arg0 context.Context, arg1 *eth.GetValidatorRequest, arg2 ...grpc.CallOption) (*eth.Validator, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -131,16 +136,16 @@ func (m *MockBeaconChainClient) GetValidator(arg0 context.Context, arg1 *eth.Get } // GetValidator indicates an expected call of GetValidator. -func (mr *MockBeaconChainClientMockRecorder) GetValidator(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidator(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidator", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidator), varargs...) } // GetValidatorActiveSetChanges mocks base method. func (m *MockBeaconChainClient) GetValidatorActiveSetChanges(arg0 context.Context, arg1 *eth.GetValidatorActiveSetChangesRequest, arg2 ...grpc.CallOption) (*eth.ActiveSetChanges, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -151,16 +156,16 @@ func (m *MockBeaconChainClient) GetValidatorActiveSetChanges(arg0 context.Contex } // GetValidatorActiveSetChanges indicates an expected call of GetValidatorActiveSetChanges. -func (mr *MockBeaconChainClientMockRecorder) GetValidatorActiveSetChanges(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidatorActiveSetChanges(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorActiveSetChanges", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidatorActiveSetChanges), varargs...) } // GetValidatorParticipation mocks base method. func (m *MockBeaconChainClient) GetValidatorParticipation(arg0 context.Context, arg1 *eth.GetValidatorParticipationRequest, arg2 ...grpc.CallOption) (*eth.ValidatorParticipationResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -171,16 +176,16 @@ func (m *MockBeaconChainClient) GetValidatorParticipation(arg0 context.Context, } // GetValidatorParticipation indicates an expected call of GetValidatorParticipation. -func (mr *MockBeaconChainClientMockRecorder) GetValidatorParticipation(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidatorParticipation(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorParticipation", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidatorParticipation), varargs...) } // GetValidatorPerformance mocks base method. func (m *MockBeaconChainClient) GetValidatorPerformance(arg0 context.Context, arg1 *eth.ValidatorPerformanceRequest, arg2 ...grpc.CallOption) (*eth.ValidatorPerformanceResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -191,16 +196,16 @@ func (m *MockBeaconChainClient) GetValidatorPerformance(arg0 context.Context, ar } // GetValidatorPerformance indicates an expected call of GetValidatorPerformance. -func (mr *MockBeaconChainClientMockRecorder) GetValidatorPerformance(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidatorPerformance(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorPerformance", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidatorPerformance), varargs...) } // GetValidatorQueue mocks base method. func (m *MockBeaconChainClient) GetValidatorQueue(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.ValidatorQueue, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -211,16 +216,16 @@ func (m *MockBeaconChainClient) GetValidatorQueue(arg0 context.Context, arg1 *em } // GetValidatorQueue indicates an expected call of GetValidatorQueue. -func (mr *MockBeaconChainClientMockRecorder) GetValidatorQueue(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidatorQueue(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorQueue", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidatorQueue), varargs...) } // ListAttestations mocks base method. func (m *MockBeaconChainClient) ListAttestations(arg0 context.Context, arg1 *eth.ListAttestationsRequest, arg2 ...grpc.CallOption) (*eth.ListAttestationsResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -231,16 +236,16 @@ func (m *MockBeaconChainClient) ListAttestations(arg0 context.Context, arg1 *eth } // ListAttestations indicates an expected call of ListAttestations. -func (mr *MockBeaconChainClientMockRecorder) ListAttestations(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListAttestations(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAttestations", reflect.TypeOf((*MockBeaconChainClient)(nil).ListAttestations), varargs...) } // ListBeaconBlocks mocks base method. func (m *MockBeaconChainClient) ListBeaconBlocks(arg0 context.Context, arg1 *eth.ListBlocksRequest, arg2 ...grpc.CallOption) (*eth.ListBeaconBlocksResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -251,16 +256,16 @@ func (m *MockBeaconChainClient) ListBeaconBlocks(arg0 context.Context, arg1 *eth } // ListBeaconBlocks indicates an expected call of ListBeaconBlocks. -func (mr *MockBeaconChainClientMockRecorder) ListBeaconBlocks(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListBeaconBlocks(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListBeaconBlocks", reflect.TypeOf((*MockBeaconChainClient)(nil).ListBeaconBlocks), varargs...) } // ListBeaconCommittees mocks base method. func (m *MockBeaconChainClient) ListBeaconCommittees(arg0 context.Context, arg1 *eth.ListCommitteesRequest, arg2 ...grpc.CallOption) (*eth.BeaconCommittees, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -271,16 +276,16 @@ func (m *MockBeaconChainClient) ListBeaconCommittees(arg0 context.Context, arg1 } // ListBeaconCommittees indicates an expected call of ListBeaconCommittees. -func (mr *MockBeaconChainClientMockRecorder) ListBeaconCommittees(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListBeaconCommittees(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListBeaconCommittees", reflect.TypeOf((*MockBeaconChainClient)(nil).ListBeaconCommittees), varargs...) } // ListIndexedAttestations mocks base method. func (m *MockBeaconChainClient) ListIndexedAttestations(arg0 context.Context, arg1 *eth.ListIndexedAttestationsRequest, arg2 ...grpc.CallOption) (*eth.ListIndexedAttestationsResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -291,16 +296,16 @@ func (m *MockBeaconChainClient) ListIndexedAttestations(arg0 context.Context, ar } // ListIndexedAttestations indicates an expected call of ListIndexedAttestations. -func (mr *MockBeaconChainClientMockRecorder) ListIndexedAttestations(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListIndexedAttestations(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListIndexedAttestations", reflect.TypeOf((*MockBeaconChainClient)(nil).ListIndexedAttestations), varargs...) } // ListValidatorAssignments mocks base method. func (m *MockBeaconChainClient) ListValidatorAssignments(arg0 context.Context, arg1 *eth.ListValidatorAssignmentsRequest, arg2 ...grpc.CallOption) (*eth.ValidatorAssignments, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -311,16 +316,16 @@ func (m *MockBeaconChainClient) ListValidatorAssignments(arg0 context.Context, a } // ListValidatorAssignments indicates an expected call of ListValidatorAssignments. -func (mr *MockBeaconChainClientMockRecorder) ListValidatorAssignments(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListValidatorAssignments(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListValidatorAssignments", reflect.TypeOf((*MockBeaconChainClient)(nil).ListValidatorAssignments), varargs...) } // ListValidatorBalances mocks base method. func (m *MockBeaconChainClient) ListValidatorBalances(arg0 context.Context, arg1 *eth.ListValidatorBalancesRequest, arg2 ...grpc.CallOption) (*eth.ValidatorBalances, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -331,16 +336,16 @@ func (m *MockBeaconChainClient) ListValidatorBalances(arg0 context.Context, arg1 } // ListValidatorBalances indicates an expected call of ListValidatorBalances. -func (mr *MockBeaconChainClientMockRecorder) ListValidatorBalances(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListValidatorBalances(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListValidatorBalances", reflect.TypeOf((*MockBeaconChainClient)(nil).ListValidatorBalances), varargs...) } // ListValidators mocks base method. func (m *MockBeaconChainClient) ListValidators(arg0 context.Context, arg1 *eth.ListValidatorsRequest, arg2 ...grpc.CallOption) (*eth.Validators, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -351,16 +356,16 @@ func (m *MockBeaconChainClient) ListValidators(arg0 context.Context, arg1 *eth.L } // ListValidators indicates an expected call of ListValidators. -func (mr *MockBeaconChainClientMockRecorder) ListValidators(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListValidators(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListValidators", reflect.TypeOf((*MockBeaconChainClient)(nil).ListValidators), varargs...) } // SubmitAttesterSlashing mocks base method. func (m *MockBeaconChainClient) SubmitAttesterSlashing(arg0 context.Context, arg1 *eth.AttesterSlashing, arg2 ...grpc.CallOption) (*eth.SubmitSlashingResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -371,16 +376,16 @@ func (m *MockBeaconChainClient) SubmitAttesterSlashing(arg0 context.Context, arg } // SubmitAttesterSlashing indicates an expected call of SubmitAttesterSlashing. -func (mr *MockBeaconChainClientMockRecorder) SubmitAttesterSlashing(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) SubmitAttesterSlashing(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitAttesterSlashing", reflect.TypeOf((*MockBeaconChainClient)(nil).SubmitAttesterSlashing), varargs...) } // SubmitProposerSlashing mocks base method. func (m *MockBeaconChainClient) SubmitProposerSlashing(arg0 context.Context, arg1 *eth.ProposerSlashing, arg2 ...grpc.CallOption) (*eth.SubmitSlashingResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -391,8 +396,8 @@ func (m *MockBeaconChainClient) SubmitProposerSlashing(arg0 context.Context, arg } // SubmitProposerSlashing indicates an expected call of SubmitProposerSlashing. -func (mr *MockBeaconChainClientMockRecorder) SubmitProposerSlashing(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) SubmitProposerSlashing(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitProposerSlashing", reflect.TypeOf((*MockBeaconChainClient)(nil).SubmitProposerSlashing), varargs...) } diff --git a/testing/mock/beacon_validator_client_mock.go b/testing/mock/beacon_validator_client_mock.go index 097a09e62316..bed03fb8f49c 100644 --- a/testing/mock/beacon_validator_client_mock.go +++ b/testing/mock/beacon_validator_client_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 (interfaces: BeaconNodeValidatorClient,BeaconNodeValidator_WaitForChainStartClient,BeaconNodeValidator_WaitForActivationClient,BeaconNodeValidator_StreamSlotsClient) +// +// Generated by this command: +// +// mockgen -package=mock -destination=testing/mock/beacon_validator_client_mock.go github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 BeaconNodeValidatorClient,BeaconNodeValidator_WaitForChainStartClient,BeaconNodeValidator_WaitForActivationClient,BeaconNodeValidator_StreamSlotsClient +// // Package mock is a generated GoMock package. package mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" grpc "google.golang.org/grpc" metadata "google.golang.org/grpc/metadata" emptypb "google.golang.org/protobuf/types/known/emptypb" @@ -41,7 +46,7 @@ func (m *MockBeaconNodeValidatorClient) EXPECT() *MockBeaconNodeValidatorClientM // AggregatedSigAndAggregationBits mocks base method. func (m *MockBeaconNodeValidatorClient) AggregatedSigAndAggregationBits(arg0 context.Context, arg1 *eth.AggregatedSigAndAggregationBitsRequest, arg2 ...grpc.CallOption) (*eth.AggregatedSigAndAggregationBitsResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -52,16 +57,16 @@ func (m *MockBeaconNodeValidatorClient) AggregatedSigAndAggregationBits(arg0 con } // AggregatedSigAndAggregationBits indicates an expected call of AggregatedSigAndAggregationBits. -func (mr *MockBeaconNodeValidatorClientMockRecorder) AggregatedSigAndAggregationBits(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) AggregatedSigAndAggregationBits(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AggregatedSigAndAggregationBits", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).AggregatedSigAndAggregationBits), varargs...) } // AssignValidatorToSubnet mocks base method. func (m *MockBeaconNodeValidatorClient) AssignValidatorToSubnet(arg0 context.Context, arg1 *eth.AssignValidatorToSubnetRequest, arg2 ...grpc.CallOption) (*emptypb.Empty, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -72,16 +77,16 @@ func (m *MockBeaconNodeValidatorClient) AssignValidatorToSubnet(arg0 context.Con } // AssignValidatorToSubnet indicates an expected call of AssignValidatorToSubnet. -func (mr *MockBeaconNodeValidatorClientMockRecorder) AssignValidatorToSubnet(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) AssignValidatorToSubnet(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignValidatorToSubnet", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).AssignValidatorToSubnet), varargs...) } // CheckDoppelGanger mocks base method. func (m *MockBeaconNodeValidatorClient) CheckDoppelGanger(arg0 context.Context, arg1 *eth.DoppelGangerRequest, arg2 ...grpc.CallOption) (*eth.DoppelGangerResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -92,16 +97,16 @@ func (m *MockBeaconNodeValidatorClient) CheckDoppelGanger(arg0 context.Context, } // CheckDoppelGanger indicates an expected call of CheckDoppelGanger. -func (mr *MockBeaconNodeValidatorClientMockRecorder) CheckDoppelGanger(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) CheckDoppelGanger(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckDoppelGanger", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).CheckDoppelGanger), varargs...) } // DomainData mocks base method. func (m *MockBeaconNodeValidatorClient) DomainData(arg0 context.Context, arg1 *eth.DomainRequest, arg2 ...grpc.CallOption) (*eth.DomainResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -112,16 +117,16 @@ func (m *MockBeaconNodeValidatorClient) DomainData(arg0 context.Context, arg1 *e } // DomainData indicates an expected call of DomainData. -func (mr *MockBeaconNodeValidatorClientMockRecorder) DomainData(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) DomainData(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DomainData", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).DomainData), varargs...) } // GetAttestationData mocks base method. func (m *MockBeaconNodeValidatorClient) GetAttestationData(arg0 context.Context, arg1 *eth.AttestationDataRequest, arg2 ...grpc.CallOption) (*eth.AttestationData, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -132,16 +137,16 @@ func (m *MockBeaconNodeValidatorClient) GetAttestationData(arg0 context.Context, } // GetAttestationData indicates an expected call of GetAttestationData. -func (mr *MockBeaconNodeValidatorClientMockRecorder) GetAttestationData(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) GetAttestationData(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttestationData", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).GetAttestationData), varargs...) } // GetBeaconBlock mocks base method. func (m *MockBeaconNodeValidatorClient) GetBeaconBlock(arg0 context.Context, arg1 *eth.BlockRequest, arg2 ...grpc.CallOption) (*eth.GenericBeaconBlock, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -152,16 +157,16 @@ func (m *MockBeaconNodeValidatorClient) GetBeaconBlock(arg0 context.Context, arg } // GetBeaconBlock indicates an expected call of GetBeaconBlock. -func (mr *MockBeaconNodeValidatorClientMockRecorder) GetBeaconBlock(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) GetBeaconBlock(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBeaconBlock", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).GetBeaconBlock), varargs...) } // GetDuties mocks base method. func (m *MockBeaconNodeValidatorClient) GetDuties(arg0 context.Context, arg1 *eth.DutiesRequest, arg2 ...grpc.CallOption) (*eth.DutiesResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -172,16 +177,16 @@ func (m *MockBeaconNodeValidatorClient) GetDuties(arg0 context.Context, arg1 *et } // GetDuties indicates an expected call of GetDuties. -func (mr *MockBeaconNodeValidatorClientMockRecorder) GetDuties(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) GetDuties(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDuties", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).GetDuties), varargs...) } // GetFeeRecipientByPubKey mocks base method. func (m *MockBeaconNodeValidatorClient) GetFeeRecipientByPubKey(arg0 context.Context, arg1 *eth.FeeRecipientByPubKeyRequest, arg2 ...grpc.CallOption) (*eth.FeeRecipientByPubKeyResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -192,16 +197,16 @@ func (m *MockBeaconNodeValidatorClient) GetFeeRecipientByPubKey(arg0 context.Con } // GetFeeRecipientByPubKey indicates an expected call of GetFeeRecipientByPubKey. -func (mr *MockBeaconNodeValidatorClientMockRecorder) GetFeeRecipientByPubKey(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) GetFeeRecipientByPubKey(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFeeRecipientByPubKey", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).GetFeeRecipientByPubKey), varargs...) } // GetSyncCommitteeContribution mocks base method. func (m *MockBeaconNodeValidatorClient) GetSyncCommitteeContribution(arg0 context.Context, arg1 *eth.SyncCommitteeContributionRequest, arg2 ...grpc.CallOption) (*eth.SyncCommitteeContribution, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -212,16 +217,16 @@ func (m *MockBeaconNodeValidatorClient) GetSyncCommitteeContribution(arg0 contex } // GetSyncCommitteeContribution indicates an expected call of GetSyncCommitteeContribution. -func (mr *MockBeaconNodeValidatorClientMockRecorder) GetSyncCommitteeContribution(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) GetSyncCommitteeContribution(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncCommitteeContribution", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).GetSyncCommitteeContribution), varargs...) } // GetSyncMessageBlockRoot mocks base method. func (m *MockBeaconNodeValidatorClient) GetSyncMessageBlockRoot(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.SyncMessageBlockRootResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -232,16 +237,16 @@ func (m *MockBeaconNodeValidatorClient) GetSyncMessageBlockRoot(arg0 context.Con } // GetSyncMessageBlockRoot indicates an expected call of GetSyncMessageBlockRoot. -func (mr *MockBeaconNodeValidatorClientMockRecorder) GetSyncMessageBlockRoot(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) GetSyncMessageBlockRoot(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncMessageBlockRoot", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).GetSyncMessageBlockRoot), varargs...) } // GetSyncSubcommitteeIndex mocks base method. func (m *MockBeaconNodeValidatorClient) GetSyncSubcommitteeIndex(arg0 context.Context, arg1 *eth.SyncSubcommitteeIndexRequest, arg2 ...grpc.CallOption) (*eth.SyncSubcommitteeIndexResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -252,16 +257,16 @@ func (m *MockBeaconNodeValidatorClient) GetSyncSubcommitteeIndex(arg0 context.Co } // GetSyncSubcommitteeIndex indicates an expected call of GetSyncSubcommitteeIndex. -func (mr *MockBeaconNodeValidatorClientMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncSubcommitteeIndex", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).GetSyncSubcommitteeIndex), varargs...) } // MultipleValidatorStatus mocks base method. func (m *MockBeaconNodeValidatorClient) MultipleValidatorStatus(arg0 context.Context, arg1 *eth.MultipleValidatorStatusRequest, arg2 ...grpc.CallOption) (*eth.MultipleValidatorStatusResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -272,16 +277,16 @@ func (m *MockBeaconNodeValidatorClient) MultipleValidatorStatus(arg0 context.Con } // MultipleValidatorStatus indicates an expected call of MultipleValidatorStatus. -func (mr *MockBeaconNodeValidatorClientMockRecorder) MultipleValidatorStatus(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) MultipleValidatorStatus(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MultipleValidatorStatus", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).MultipleValidatorStatus), varargs...) } // PrepareBeaconProposer mocks base method. func (m *MockBeaconNodeValidatorClient) PrepareBeaconProposer(arg0 context.Context, arg1 *eth.PrepareBeaconProposerRequest, arg2 ...grpc.CallOption) (*emptypb.Empty, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -292,16 +297,16 @@ func (m *MockBeaconNodeValidatorClient) PrepareBeaconProposer(arg0 context.Conte } // PrepareBeaconProposer indicates an expected call of PrepareBeaconProposer. -func (mr *MockBeaconNodeValidatorClientMockRecorder) PrepareBeaconProposer(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) PrepareBeaconProposer(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareBeaconProposer", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).PrepareBeaconProposer), varargs...) } // ProposeAttestation mocks base method. func (m *MockBeaconNodeValidatorClient) ProposeAttestation(arg0 context.Context, arg1 *eth.Attestation, arg2 ...grpc.CallOption) (*eth.AttestResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -312,16 +317,16 @@ func (m *MockBeaconNodeValidatorClient) ProposeAttestation(arg0 context.Context, } // ProposeAttestation indicates an expected call of ProposeAttestation. -func (mr *MockBeaconNodeValidatorClientMockRecorder) ProposeAttestation(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) ProposeAttestation(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeAttestation", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).ProposeAttestation), varargs...) } // ProposeBeaconBlock mocks base method. func (m *MockBeaconNodeValidatorClient) ProposeBeaconBlock(arg0 context.Context, arg1 *eth.GenericSignedBeaconBlock, arg2 ...grpc.CallOption) (*eth.ProposeResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -332,16 +337,16 @@ func (m *MockBeaconNodeValidatorClient) ProposeBeaconBlock(arg0 context.Context, } // ProposeBeaconBlock indicates an expected call of ProposeBeaconBlock. -func (mr *MockBeaconNodeValidatorClientMockRecorder) ProposeBeaconBlock(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) ProposeBeaconBlock(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeBeaconBlock", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).ProposeBeaconBlock), varargs...) } // ProposeExit mocks base method. func (m *MockBeaconNodeValidatorClient) ProposeExit(arg0 context.Context, arg1 *eth.SignedVoluntaryExit, arg2 ...grpc.CallOption) (*eth.ProposeExitResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -352,16 +357,16 @@ func (m *MockBeaconNodeValidatorClient) ProposeExit(arg0 context.Context, arg1 * } // ProposeExit indicates an expected call of ProposeExit. -func (mr *MockBeaconNodeValidatorClientMockRecorder) ProposeExit(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) ProposeExit(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeExit", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).ProposeExit), varargs...) } // StreamBlocksAltair mocks base method. func (m *MockBeaconNodeValidatorClient) StreamBlocksAltair(arg0 context.Context, arg1 *eth.StreamBlocksRequest, arg2 ...grpc.CallOption) (eth.BeaconNodeValidator_StreamBlocksAltairClient, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -372,16 +377,16 @@ func (m *MockBeaconNodeValidatorClient) StreamBlocksAltair(arg0 context.Context, } // StreamBlocksAltair indicates an expected call of StreamBlocksAltair. -func (mr *MockBeaconNodeValidatorClientMockRecorder) StreamBlocksAltair(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) StreamBlocksAltair(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamBlocksAltair", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).StreamBlocksAltair), varargs...) } // StreamSlots mocks base method. func (m *MockBeaconNodeValidatorClient) StreamSlots(arg0 context.Context, arg1 *eth.StreamSlotsRequest, arg2 ...grpc.CallOption) (eth.BeaconNodeValidator_StreamSlotsClient, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -392,16 +397,16 @@ func (m *MockBeaconNodeValidatorClient) StreamSlots(arg0 context.Context, arg1 * } // StreamSlots indicates an expected call of StreamSlots. -func (mr *MockBeaconNodeValidatorClientMockRecorder) StreamSlots(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) StreamSlots(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamSlots", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).StreamSlots), varargs...) } // SubmitAggregateSelectionProof mocks base method. func (m *MockBeaconNodeValidatorClient) SubmitAggregateSelectionProof(arg0 context.Context, arg1 *eth.AggregateSelectionRequest, arg2 ...grpc.CallOption) (*eth.AggregateSelectionResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -412,16 +417,16 @@ func (m *MockBeaconNodeValidatorClient) SubmitAggregateSelectionProof(arg0 conte } // SubmitAggregateSelectionProof indicates an expected call of SubmitAggregateSelectionProof. -func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitAggregateSelectionProof(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitAggregateSelectionProof(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitAggregateSelectionProof", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).SubmitAggregateSelectionProof), varargs...) } // SubmitSignedAggregateSelectionProof mocks base method. func (m *MockBeaconNodeValidatorClient) SubmitSignedAggregateSelectionProof(arg0 context.Context, arg1 *eth.SignedAggregateSubmitRequest, arg2 ...grpc.CallOption) (*eth.SignedAggregateSubmitResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -432,16 +437,16 @@ func (m *MockBeaconNodeValidatorClient) SubmitSignedAggregateSelectionProof(arg0 } // SubmitSignedAggregateSelectionProof indicates an expected call of SubmitSignedAggregateSelectionProof. -func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitSignedAggregateSelectionProof(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitSignedAggregateSelectionProof(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSignedAggregateSelectionProof", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).SubmitSignedAggregateSelectionProof), varargs...) } // SubmitSignedContributionAndProof mocks base method. func (m *MockBeaconNodeValidatorClient) SubmitSignedContributionAndProof(arg0 context.Context, arg1 *eth.SignedContributionAndProof, arg2 ...grpc.CallOption) (*emptypb.Empty, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -452,16 +457,16 @@ func (m *MockBeaconNodeValidatorClient) SubmitSignedContributionAndProof(arg0 co } // SubmitSignedContributionAndProof indicates an expected call of SubmitSignedContributionAndProof. -func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitSignedContributionAndProof(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitSignedContributionAndProof(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSignedContributionAndProof", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).SubmitSignedContributionAndProof), varargs...) } // SubmitSyncMessage mocks base method. func (m *MockBeaconNodeValidatorClient) SubmitSyncMessage(arg0 context.Context, arg1 *eth.SyncCommitteeMessage, arg2 ...grpc.CallOption) (*emptypb.Empty, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -472,16 +477,16 @@ func (m *MockBeaconNodeValidatorClient) SubmitSyncMessage(arg0 context.Context, } // SubmitSyncMessage indicates an expected call of SubmitSyncMessage. -func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitSyncMessage(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitSyncMessage(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSyncMessage", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).SubmitSyncMessage), varargs...) } // SubmitValidatorRegistrations mocks base method. func (m *MockBeaconNodeValidatorClient) SubmitValidatorRegistrations(arg0 context.Context, arg1 *eth.SignedValidatorRegistrationsV1, arg2 ...grpc.CallOption) (*emptypb.Empty, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -492,16 +497,16 @@ func (m *MockBeaconNodeValidatorClient) SubmitValidatorRegistrations(arg0 contex } // SubmitValidatorRegistrations indicates an expected call of SubmitValidatorRegistrations. -func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitValidatorRegistrations(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) SubmitValidatorRegistrations(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitValidatorRegistrations", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).SubmitValidatorRegistrations), varargs...) } // SubscribeCommitteeSubnets mocks base method. func (m *MockBeaconNodeValidatorClient) SubscribeCommitteeSubnets(arg0 context.Context, arg1 *eth.CommitteeSubnetsSubscribeRequest, arg2 ...grpc.CallOption) (*emptypb.Empty, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -512,16 +517,16 @@ func (m *MockBeaconNodeValidatorClient) SubscribeCommitteeSubnets(arg0 context.C } // SubscribeCommitteeSubnets indicates an expected call of SubscribeCommitteeSubnets. -func (mr *MockBeaconNodeValidatorClientMockRecorder) SubscribeCommitteeSubnets(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) SubscribeCommitteeSubnets(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeCommitteeSubnets", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).SubscribeCommitteeSubnets), varargs...) } // ValidatorIndex mocks base method. func (m *MockBeaconNodeValidatorClient) ValidatorIndex(arg0 context.Context, arg1 *eth.ValidatorIndexRequest, arg2 ...grpc.CallOption) (*eth.ValidatorIndexResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -532,16 +537,16 @@ func (m *MockBeaconNodeValidatorClient) ValidatorIndex(arg0 context.Context, arg } // ValidatorIndex indicates an expected call of ValidatorIndex. -func (mr *MockBeaconNodeValidatorClientMockRecorder) ValidatorIndex(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) ValidatorIndex(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorIndex", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).ValidatorIndex), varargs...) } // ValidatorStatus mocks base method. func (m *MockBeaconNodeValidatorClient) ValidatorStatus(arg0 context.Context, arg1 *eth.ValidatorStatusRequest, arg2 ...grpc.CallOption) (*eth.ValidatorStatusResponse, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -552,16 +557,16 @@ func (m *MockBeaconNodeValidatorClient) ValidatorStatus(arg0 context.Context, ar } // ValidatorStatus indicates an expected call of ValidatorStatus. -func (mr *MockBeaconNodeValidatorClientMockRecorder) ValidatorStatus(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) ValidatorStatus(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorStatus", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).ValidatorStatus), varargs...) } // WaitForActivation mocks base method. func (m *MockBeaconNodeValidatorClient) WaitForActivation(arg0 context.Context, arg1 *eth.ValidatorActivationRequest, arg2 ...grpc.CallOption) (eth.BeaconNodeValidator_WaitForActivationClient, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -572,16 +577,16 @@ func (m *MockBeaconNodeValidatorClient) WaitForActivation(arg0 context.Context, } // WaitForActivation indicates an expected call of WaitForActivation. -func (mr *MockBeaconNodeValidatorClientMockRecorder) WaitForActivation(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) WaitForActivation(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForActivation", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).WaitForActivation), varargs...) } // WaitForChainStart mocks base method. func (m *MockBeaconNodeValidatorClient) WaitForChainStart(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (eth.BeaconNodeValidator_WaitForChainStartClient, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -592,9 +597,9 @@ func (m *MockBeaconNodeValidatorClient) WaitForChainStart(arg0 context.Context, } // WaitForChainStart indicates an expected call of WaitForChainStart. -func (mr *MockBeaconNodeValidatorClientMockRecorder) WaitForChainStart(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorClientMockRecorder) WaitForChainStart(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForChainStart", reflect.TypeOf((*MockBeaconNodeValidatorClient)(nil).WaitForChainStart), varargs...) } @@ -680,7 +685,7 @@ func (mr *MockBeaconNodeValidator_WaitForChainStartClientMockRecorder) Recv() *g } // RecvMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForChainStartClient) RecvMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForChainStartClient) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -688,13 +693,13 @@ func (m *MockBeaconNodeValidator_WaitForChainStartClient) RecvMsg(arg0 interface } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockBeaconNodeValidator_WaitForChainStartClientMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartClientMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartClient)(nil).RecvMsg), arg0) } // SendMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForChainStartClient) SendMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForChainStartClient) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -702,7 +707,7 @@ func (m *MockBeaconNodeValidator_WaitForChainStartClient) SendMsg(arg0 interface } // SendMsg indicates an expected call of SendMsg. -func (mr *MockBeaconNodeValidator_WaitForChainStartClientMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartClientMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartClient)(nil).SendMsg), arg0) } @@ -803,7 +808,7 @@ func (mr *MockBeaconNodeValidator_WaitForActivationClientMockRecorder) Recv() *g } // RecvMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForActivationClient) RecvMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForActivationClient) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -811,13 +816,13 @@ func (m *MockBeaconNodeValidator_WaitForActivationClient) RecvMsg(arg0 interface } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockBeaconNodeValidator_WaitForActivationClientMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationClientMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationClient)(nil).RecvMsg), arg0) } // SendMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForActivationClient) SendMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForActivationClient) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -825,7 +830,7 @@ func (m *MockBeaconNodeValidator_WaitForActivationClient) SendMsg(arg0 interface } // SendMsg indicates an expected call of SendMsg. -func (mr *MockBeaconNodeValidator_WaitForActivationClientMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationClientMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationClient)(nil).SendMsg), arg0) } @@ -926,7 +931,7 @@ func (mr *MockBeaconNodeValidator_StreamSlotsClientMockRecorder) Recv() *gomock. } // RecvMsg mocks base method. -func (m *MockBeaconNodeValidator_StreamSlotsClient) RecvMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_StreamSlotsClient) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -934,13 +939,13 @@ func (m *MockBeaconNodeValidator_StreamSlotsClient) RecvMsg(arg0 interface{}) er } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockBeaconNodeValidator_StreamSlotsClientMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsClientMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsClient)(nil).RecvMsg), arg0) } // SendMsg mocks base method. -func (m *MockBeaconNodeValidator_StreamSlotsClient) SendMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_StreamSlotsClient) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -948,7 +953,7 @@ func (m *MockBeaconNodeValidator_StreamSlotsClient) SendMsg(arg0 interface{}) er } // SendMsg indicates an expected call of SendMsg. -func (mr *MockBeaconNodeValidator_StreamSlotsClientMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsClientMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsClient)(nil).SendMsg), arg0) } diff --git a/testing/mock/beacon_validator_server_mock.go b/testing/mock/beacon_validator_server_mock.go index 6796f25fa480..c1722b39eaf7 100644 --- a/testing/mock/beacon_validator_server_mock.go +++ b/testing/mock/beacon_validator_server_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 (interfaces: BeaconNodeValidatorServer,BeaconNodeValidator_WaitForActivationServer,BeaconNodeValidator_WaitForChainStartServer,BeaconNodeValidator_StreamSlotsServer) +// +// Generated by this command: +// +// mockgen -package=mock -destination=testing/mock/beacon_validator_server_mock.go github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 BeaconNodeValidatorServer,BeaconNodeValidator_WaitForActivationServer,BeaconNodeValidator_WaitForChainStartServer,BeaconNodeValidator_StreamSlotsServer +// // Package mock is a generated GoMock package. package mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" metadata "google.golang.org/grpc/metadata" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -47,7 +52,7 @@ func (m *MockBeaconNodeValidatorServer) AggregatedSigAndAggregationBits(arg0 con } // AggregatedSigAndAggregationBits indicates an expected call of AggregatedSigAndAggregationBits. -func (mr *MockBeaconNodeValidatorServerMockRecorder) AggregatedSigAndAggregationBits(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) AggregatedSigAndAggregationBits(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AggregatedSigAndAggregationBits", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).AggregatedSigAndAggregationBits), arg0, arg1) } @@ -62,7 +67,7 @@ func (m *MockBeaconNodeValidatorServer) AssignValidatorToSubnet(arg0 context.Con } // AssignValidatorToSubnet indicates an expected call of AssignValidatorToSubnet. -func (mr *MockBeaconNodeValidatorServerMockRecorder) AssignValidatorToSubnet(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) AssignValidatorToSubnet(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignValidatorToSubnet", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).AssignValidatorToSubnet), arg0, arg1) } @@ -77,7 +82,7 @@ func (m *MockBeaconNodeValidatorServer) CheckDoppelGanger(arg0 context.Context, } // CheckDoppelGanger indicates an expected call of CheckDoppelGanger. -func (mr *MockBeaconNodeValidatorServerMockRecorder) CheckDoppelGanger(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) CheckDoppelGanger(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckDoppelGanger", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).CheckDoppelGanger), arg0, arg1) } @@ -92,7 +97,7 @@ func (m *MockBeaconNodeValidatorServer) DomainData(arg0 context.Context, arg1 *e } // DomainData indicates an expected call of DomainData. -func (mr *MockBeaconNodeValidatorServerMockRecorder) DomainData(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) DomainData(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DomainData", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).DomainData), arg0, arg1) } @@ -107,7 +112,7 @@ func (m *MockBeaconNodeValidatorServer) GetAttestationData(arg0 context.Context, } // GetAttestationData indicates an expected call of GetAttestationData. -func (mr *MockBeaconNodeValidatorServerMockRecorder) GetAttestationData(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) GetAttestationData(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttestationData", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).GetAttestationData), arg0, arg1) } @@ -122,7 +127,7 @@ func (m *MockBeaconNodeValidatorServer) GetBeaconBlock(arg0 context.Context, arg } // GetBeaconBlock indicates an expected call of GetBeaconBlock. -func (mr *MockBeaconNodeValidatorServerMockRecorder) GetBeaconBlock(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) GetBeaconBlock(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBeaconBlock", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).GetBeaconBlock), arg0, arg1) } @@ -137,7 +142,7 @@ func (m *MockBeaconNodeValidatorServer) GetDuties(arg0 context.Context, arg1 *et } // GetDuties indicates an expected call of GetDuties. -func (mr *MockBeaconNodeValidatorServerMockRecorder) GetDuties(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) GetDuties(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDuties", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).GetDuties), arg0, arg1) } @@ -152,7 +157,7 @@ func (m *MockBeaconNodeValidatorServer) GetFeeRecipientByPubKey(arg0 context.Con } // GetFeeRecipientByPubKey indicates an expected call of GetFeeRecipientByPubKey. -func (mr *MockBeaconNodeValidatorServerMockRecorder) GetFeeRecipientByPubKey(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) GetFeeRecipientByPubKey(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFeeRecipientByPubKey", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).GetFeeRecipientByPubKey), arg0, arg1) } @@ -167,7 +172,7 @@ func (m *MockBeaconNodeValidatorServer) GetSyncCommitteeContribution(arg0 contex } // GetSyncCommitteeContribution indicates an expected call of GetSyncCommitteeContribution. -func (mr *MockBeaconNodeValidatorServerMockRecorder) GetSyncCommitteeContribution(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) GetSyncCommitteeContribution(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncCommitteeContribution", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).GetSyncCommitteeContribution), arg0, arg1) } @@ -182,7 +187,7 @@ func (m *MockBeaconNodeValidatorServer) GetSyncMessageBlockRoot(arg0 context.Con } // GetSyncMessageBlockRoot indicates an expected call of GetSyncMessageBlockRoot. -func (mr *MockBeaconNodeValidatorServerMockRecorder) GetSyncMessageBlockRoot(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) GetSyncMessageBlockRoot(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncMessageBlockRoot", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).GetSyncMessageBlockRoot), arg0, arg1) } @@ -197,7 +202,7 @@ func (m *MockBeaconNodeValidatorServer) GetSyncSubcommitteeIndex(arg0 context.Co } // GetSyncSubcommitteeIndex indicates an expected call of GetSyncSubcommitteeIndex. -func (mr *MockBeaconNodeValidatorServerMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncSubcommitteeIndex", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).GetSyncSubcommitteeIndex), arg0, arg1) } @@ -212,7 +217,7 @@ func (m *MockBeaconNodeValidatorServer) MultipleValidatorStatus(arg0 context.Con } // MultipleValidatorStatus indicates an expected call of MultipleValidatorStatus. -func (mr *MockBeaconNodeValidatorServerMockRecorder) MultipleValidatorStatus(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) MultipleValidatorStatus(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MultipleValidatorStatus", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).MultipleValidatorStatus), arg0, arg1) } @@ -227,7 +232,7 @@ func (m *MockBeaconNodeValidatorServer) PrepareBeaconProposer(arg0 context.Conte } // PrepareBeaconProposer indicates an expected call of PrepareBeaconProposer. -func (mr *MockBeaconNodeValidatorServerMockRecorder) PrepareBeaconProposer(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) PrepareBeaconProposer(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareBeaconProposer", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).PrepareBeaconProposer), arg0, arg1) } @@ -242,7 +247,7 @@ func (m *MockBeaconNodeValidatorServer) ProposeAttestation(arg0 context.Context, } // ProposeAttestation indicates an expected call of ProposeAttestation. -func (mr *MockBeaconNodeValidatorServerMockRecorder) ProposeAttestation(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) ProposeAttestation(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeAttestation", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).ProposeAttestation), arg0, arg1) } @@ -257,7 +262,7 @@ func (m *MockBeaconNodeValidatorServer) ProposeBeaconBlock(arg0 context.Context, } // ProposeBeaconBlock indicates an expected call of ProposeBeaconBlock. -func (mr *MockBeaconNodeValidatorServerMockRecorder) ProposeBeaconBlock(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) ProposeBeaconBlock(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeBeaconBlock", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).ProposeBeaconBlock), arg0, arg1) } @@ -272,7 +277,7 @@ func (m *MockBeaconNodeValidatorServer) ProposeExit(arg0 context.Context, arg1 * } // ProposeExit indicates an expected call of ProposeExit. -func (mr *MockBeaconNodeValidatorServerMockRecorder) ProposeExit(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) ProposeExit(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeExit", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).ProposeExit), arg0, arg1) } @@ -286,7 +291,7 @@ func (m *MockBeaconNodeValidatorServer) StreamBlocksAltair(arg0 *eth.StreamBlock } // StreamBlocksAltair indicates an expected call of StreamBlocksAltair. -func (mr *MockBeaconNodeValidatorServerMockRecorder) StreamBlocksAltair(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) StreamBlocksAltair(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamBlocksAltair", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).StreamBlocksAltair), arg0, arg1) } @@ -300,7 +305,7 @@ func (m *MockBeaconNodeValidatorServer) StreamSlots(arg0 *eth.StreamSlotsRequest } // StreamSlots indicates an expected call of StreamSlots. -func (mr *MockBeaconNodeValidatorServerMockRecorder) StreamSlots(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) StreamSlots(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamSlots", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).StreamSlots), arg0, arg1) } @@ -315,7 +320,7 @@ func (m *MockBeaconNodeValidatorServer) SubmitAggregateSelectionProof(arg0 conte } // SubmitAggregateSelectionProof indicates an expected call of SubmitAggregateSelectionProof. -func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitAggregateSelectionProof(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitAggregateSelectionProof(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitAggregateSelectionProof", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).SubmitAggregateSelectionProof), arg0, arg1) } @@ -330,7 +335,7 @@ func (m *MockBeaconNodeValidatorServer) SubmitSignedAggregateSelectionProof(arg0 } // SubmitSignedAggregateSelectionProof indicates an expected call of SubmitSignedAggregateSelectionProof. -func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitSignedAggregateSelectionProof(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitSignedAggregateSelectionProof(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSignedAggregateSelectionProof", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).SubmitSignedAggregateSelectionProof), arg0, arg1) } @@ -345,7 +350,7 @@ func (m *MockBeaconNodeValidatorServer) SubmitSignedContributionAndProof(arg0 co } // SubmitSignedContributionAndProof indicates an expected call of SubmitSignedContributionAndProof. -func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitSignedContributionAndProof(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitSignedContributionAndProof(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSignedContributionAndProof", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).SubmitSignedContributionAndProof), arg0, arg1) } @@ -360,7 +365,7 @@ func (m *MockBeaconNodeValidatorServer) SubmitSyncMessage(arg0 context.Context, } // SubmitSyncMessage indicates an expected call of SubmitSyncMessage. -func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitSyncMessage(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitSyncMessage(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSyncMessage", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).SubmitSyncMessage), arg0, arg1) } @@ -375,7 +380,7 @@ func (m *MockBeaconNodeValidatorServer) SubmitValidatorRegistrations(arg0 contex } // SubmitValidatorRegistrations indicates an expected call of SubmitValidatorRegistrations. -func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitValidatorRegistrations(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) SubmitValidatorRegistrations(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitValidatorRegistrations", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).SubmitValidatorRegistrations), arg0, arg1) } @@ -390,7 +395,7 @@ func (m *MockBeaconNodeValidatorServer) SubscribeCommitteeSubnets(arg0 context.C } // SubscribeCommitteeSubnets indicates an expected call of SubscribeCommitteeSubnets. -func (mr *MockBeaconNodeValidatorServerMockRecorder) SubscribeCommitteeSubnets(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) SubscribeCommitteeSubnets(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeCommitteeSubnets", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).SubscribeCommitteeSubnets), arg0, arg1) } @@ -405,7 +410,7 @@ func (m *MockBeaconNodeValidatorServer) ValidatorIndex(arg0 context.Context, arg } // ValidatorIndex indicates an expected call of ValidatorIndex. -func (mr *MockBeaconNodeValidatorServerMockRecorder) ValidatorIndex(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) ValidatorIndex(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorIndex", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).ValidatorIndex), arg0, arg1) } @@ -420,7 +425,7 @@ func (m *MockBeaconNodeValidatorServer) ValidatorStatus(arg0 context.Context, ar } // ValidatorStatus indicates an expected call of ValidatorStatus. -func (mr *MockBeaconNodeValidatorServerMockRecorder) ValidatorStatus(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) ValidatorStatus(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorStatus", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).ValidatorStatus), arg0, arg1) } @@ -434,7 +439,7 @@ func (m *MockBeaconNodeValidatorServer) WaitForActivation(arg0 *eth.ValidatorAct } // WaitForActivation indicates an expected call of WaitForActivation. -func (mr *MockBeaconNodeValidatorServerMockRecorder) WaitForActivation(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) WaitForActivation(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForActivation", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).WaitForActivation), arg0, arg1) } @@ -448,7 +453,7 @@ func (m *MockBeaconNodeValidatorServer) WaitForChainStart(arg0 *emptypb.Empty, a } // WaitForChainStart indicates an expected call of WaitForChainStart. -func (mr *MockBeaconNodeValidatorServerMockRecorder) WaitForChainStart(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidatorServerMockRecorder) WaitForChainStart(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForChainStart", reflect.TypeOf((*MockBeaconNodeValidatorServer)(nil).WaitForChainStart), arg0, arg1) } @@ -491,7 +496,7 @@ func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) Context() } // RecvMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForActivationServer) RecvMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForActivationServer) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -499,7 +504,7 @@ func (m *MockBeaconNodeValidator_WaitForActivationServer) RecvMsg(arg0 interface } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationServer)(nil).RecvMsg), arg0) } @@ -513,7 +518,7 @@ func (m *MockBeaconNodeValidator_WaitForActivationServer) Send(arg0 *eth.Validat } // Send indicates an expected call of Send. -func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) Send(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) Send(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationServer)(nil).Send), arg0) } @@ -527,13 +532,13 @@ func (m *MockBeaconNodeValidator_WaitForActivationServer) SendHeader(arg0 metada } // SendHeader indicates an expected call of SendHeader. -func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SendHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationServer)(nil).SendHeader), arg0) } // SendMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForActivationServer) SendMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForActivationServer) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -541,7 +546,7 @@ func (m *MockBeaconNodeValidator_WaitForActivationServer) SendMsg(arg0 interface } // SendMsg indicates an expected call of SendMsg. -func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationServer)(nil).SendMsg), arg0) } @@ -555,7 +560,7 @@ func (m *MockBeaconNodeValidator_WaitForActivationServer) SetHeader(arg0 metadat } // SetHeader indicates an expected call of SetHeader. -func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SetHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationServer)(nil).SetHeader), arg0) } @@ -567,7 +572,7 @@ func (m *MockBeaconNodeValidator_WaitForActivationServer) SetTrailer(arg0 metada } // SetTrailer indicates an expected call of SetTrailer. -func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForActivationServerMockRecorder) SetTrailer(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockBeaconNodeValidator_WaitForActivationServer)(nil).SetTrailer), arg0) } @@ -610,7 +615,7 @@ func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) Context() } // RecvMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForChainStartServer) RecvMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForChainStartServer) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -618,7 +623,7 @@ func (m *MockBeaconNodeValidator_WaitForChainStartServer) RecvMsg(arg0 interface } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartServer)(nil).RecvMsg), arg0) } @@ -632,7 +637,7 @@ func (m *MockBeaconNodeValidator_WaitForChainStartServer) Send(arg0 *eth.ChainSt } // Send indicates an expected call of Send. -func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) Send(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) Send(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartServer)(nil).Send), arg0) } @@ -646,13 +651,13 @@ func (m *MockBeaconNodeValidator_WaitForChainStartServer) SendHeader(arg0 metada } // SendHeader indicates an expected call of SendHeader. -func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SendHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartServer)(nil).SendHeader), arg0) } // SendMsg mocks base method. -func (m *MockBeaconNodeValidator_WaitForChainStartServer) SendMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_WaitForChainStartServer) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -660,7 +665,7 @@ func (m *MockBeaconNodeValidator_WaitForChainStartServer) SendMsg(arg0 interface } // SendMsg indicates an expected call of SendMsg. -func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartServer)(nil).SendMsg), arg0) } @@ -674,7 +679,7 @@ func (m *MockBeaconNodeValidator_WaitForChainStartServer) SetHeader(arg0 metadat } // SetHeader indicates an expected call of SetHeader. -func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SetHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartServer)(nil).SetHeader), arg0) } @@ -686,7 +691,7 @@ func (m *MockBeaconNodeValidator_WaitForChainStartServer) SetTrailer(arg0 metada } // SetTrailer indicates an expected call of SetTrailer. -func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_WaitForChainStartServerMockRecorder) SetTrailer(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockBeaconNodeValidator_WaitForChainStartServer)(nil).SetTrailer), arg0) } @@ -729,7 +734,7 @@ func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) Context() *gomo } // RecvMsg mocks base method. -func (m *MockBeaconNodeValidator_StreamSlotsServer) RecvMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_StreamSlotsServer) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -737,7 +742,7 @@ func (m *MockBeaconNodeValidator_StreamSlotsServer) RecvMsg(arg0 interface{}) er } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsServer)(nil).RecvMsg), arg0) } @@ -751,7 +756,7 @@ func (m *MockBeaconNodeValidator_StreamSlotsServer) Send(arg0 *eth.StreamSlotsRe } // Send indicates an expected call of Send. -func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) Send(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) Send(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsServer)(nil).Send), arg0) } @@ -765,13 +770,13 @@ func (m *MockBeaconNodeValidator_StreamSlotsServer) SendHeader(arg0 metadata.MD) } // SendHeader indicates an expected call of SendHeader. -func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SendHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsServer)(nil).SendHeader), arg0) } // SendMsg mocks base method. -func (m *MockBeaconNodeValidator_StreamSlotsServer) SendMsg(arg0 interface{}) error { +func (m *MockBeaconNodeValidator_StreamSlotsServer) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -779,7 +784,7 @@ func (m *MockBeaconNodeValidator_StreamSlotsServer) SendMsg(arg0 interface{}) er } // SendMsg indicates an expected call of SendMsg. -func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsServer)(nil).SendMsg), arg0) } @@ -793,7 +798,7 @@ func (m *MockBeaconNodeValidator_StreamSlotsServer) SetHeader(arg0 metadata.MD) } // SetHeader indicates an expected call of SetHeader. -func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SetHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsServer)(nil).SetHeader), arg0) } @@ -805,7 +810,7 @@ func (m *MockBeaconNodeValidator_StreamSlotsServer) SetTrailer(arg0 metadata.MD) } // SetTrailer indicates an expected call of SetTrailer. -func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { +func (mr *MockBeaconNodeValidator_StreamSlotsServerMockRecorder) SetTrailer(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockBeaconNodeValidator_StreamSlotsServer)(nil).SetTrailer), arg0) } diff --git a/testing/mock/node_service_mock.go b/testing/mock/node_service_mock.go index 7baf76450cd3..57a0cde054f6 100644 --- a/testing/mock/node_service_mock.go +++ b/testing/mock/node_service_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 (interfaces: NodeClient) +// +// Generated by this command: +// +// mockgen -package=mock -destination=testing/mock/node_service_mock.go github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1 NodeClient +// // Package mock is a generated GoMock package. package mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" grpc "google.golang.org/grpc" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -40,7 +45,7 @@ func (m *MockNodeClient) EXPECT() *MockNodeClientMockRecorder { // GetETH1ConnectionStatus mocks base method. func (m *MockNodeClient) GetETH1ConnectionStatus(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.ETH1ConnectionStatus, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -51,16 +56,16 @@ func (m *MockNodeClient) GetETH1ConnectionStatus(arg0 context.Context, arg1 *emp } // GetETH1ConnectionStatus indicates an expected call of GetETH1ConnectionStatus. -func (mr *MockNodeClientMockRecorder) GetETH1ConnectionStatus(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetETH1ConnectionStatus(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetETH1ConnectionStatus", reflect.TypeOf((*MockNodeClient)(nil).GetETH1ConnectionStatus), varargs...) } // GetGenesis mocks base method. func (m *MockNodeClient) GetGenesis(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.Genesis, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -71,16 +76,16 @@ func (m *MockNodeClient) GetGenesis(arg0 context.Context, arg1 *emptypb.Empty, a } // GetGenesis indicates an expected call of GetGenesis. -func (mr *MockNodeClientMockRecorder) GetGenesis(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetGenesis(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGenesis", reflect.TypeOf((*MockNodeClient)(nil).GetGenesis), varargs...) } // GetHost mocks base method. func (m *MockNodeClient) GetHost(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.HostData, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -91,16 +96,16 @@ func (m *MockNodeClient) GetHost(arg0 context.Context, arg1 *emptypb.Empty, arg2 } // GetHost indicates an expected call of GetHost. -func (mr *MockNodeClientMockRecorder) GetHost(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetHost(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHost", reflect.TypeOf((*MockNodeClient)(nil).GetHost), varargs...) } // GetPeer mocks base method. func (m *MockNodeClient) GetPeer(arg0 context.Context, arg1 *eth.PeerRequest, arg2 ...grpc.CallOption) (*eth.Peer, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -111,16 +116,16 @@ func (m *MockNodeClient) GetPeer(arg0 context.Context, arg1 *eth.PeerRequest, ar } // GetPeer indicates an expected call of GetPeer. -func (mr *MockNodeClientMockRecorder) GetPeer(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetPeer(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeer", reflect.TypeOf((*MockNodeClient)(nil).GetPeer), varargs...) } // GetSyncStatus mocks base method. func (m *MockNodeClient) GetSyncStatus(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.SyncStatus, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -131,16 +136,16 @@ func (m *MockNodeClient) GetSyncStatus(arg0 context.Context, arg1 *emptypb.Empty } // GetSyncStatus indicates an expected call of GetSyncStatus. -func (mr *MockNodeClientMockRecorder) GetSyncStatus(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetSyncStatus(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncStatus", reflect.TypeOf((*MockNodeClient)(nil).GetSyncStatus), varargs...) } // GetVersion mocks base method. func (m *MockNodeClient) GetVersion(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.Version, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -151,16 +156,16 @@ func (m *MockNodeClient) GetVersion(arg0 context.Context, arg1 *emptypb.Empty, a } // GetVersion indicates an expected call of GetVersion. -func (mr *MockNodeClientMockRecorder) GetVersion(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetVersion(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockNodeClient)(nil).GetVersion), varargs...) } // ListImplementedServices mocks base method. func (m *MockNodeClient) ListImplementedServices(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.ImplementedServices, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -171,16 +176,16 @@ func (m *MockNodeClient) ListImplementedServices(arg0 context.Context, arg1 *emp } // ListImplementedServices indicates an expected call of ListImplementedServices. -func (mr *MockNodeClientMockRecorder) ListImplementedServices(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) ListImplementedServices(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListImplementedServices", reflect.TypeOf((*MockNodeClient)(nil).ListImplementedServices), varargs...) } // ListPeers mocks base method. func (m *MockNodeClient) ListPeers(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.Peers, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -191,8 +196,8 @@ func (m *MockNodeClient) ListPeers(arg0 context.Context, arg1 *emptypb.Empty, ar } // ListPeers indicates an expected call of ListPeers. -func (mr *MockNodeClientMockRecorder) ListPeers(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) ListPeers(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPeers", reflect.TypeOf((*MockNodeClient)(nil).ListPeers), varargs...) } diff --git a/testing/validator-mock/beacon_chain_client_mock.go b/testing/validator-mock/beacon_chain_client_mock.go index 7722ca447fd0..971547686796 100644 --- a/testing/validator-mock/beacon_chain_client_mock.go +++ b/testing/validator-mock/beacon_chain_client_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/validator/client/iface (interfaces: BeaconChainClient) +// +// Generated by this command: +// +// mockgen -package=validator_mock -destination=testing/validator-mock/beacon_chain_client_mock.go github.com/prysmaticlabs/prysm/v5/validator/client/iface BeaconChainClient +// // Package validator_mock is a generated GoMock package. package validator_mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -46,7 +51,7 @@ func (m *MockBeaconChainClient) GetChainHead(arg0 context.Context, arg1 *emptypb } // GetChainHead indicates an expected call of GetChainHead. -func (mr *MockBeaconChainClientMockRecorder) GetChainHead(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetChainHead(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChainHead", reflect.TypeOf((*MockBeaconChainClient)(nil).GetChainHead), arg0, arg1) } @@ -61,7 +66,7 @@ func (m *MockBeaconChainClient) GetValidatorParticipation(arg0 context.Context, } // GetValidatorParticipation indicates an expected call of GetValidatorParticipation. -func (mr *MockBeaconChainClientMockRecorder) GetValidatorParticipation(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidatorParticipation(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorParticipation", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidatorParticipation), arg0, arg1) } @@ -76,7 +81,7 @@ func (m *MockBeaconChainClient) GetValidatorPerformance(arg0 context.Context, ar } // GetValidatorPerformance indicates an expected call of GetValidatorPerformance. -func (mr *MockBeaconChainClientMockRecorder) GetValidatorPerformance(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidatorPerformance(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorPerformance", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidatorPerformance), arg0, arg1) } @@ -91,7 +96,7 @@ func (m *MockBeaconChainClient) GetValidatorQueue(arg0 context.Context, arg1 *em } // GetValidatorQueue indicates an expected call of GetValidatorQueue. -func (mr *MockBeaconChainClientMockRecorder) GetValidatorQueue(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) GetValidatorQueue(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorQueue", reflect.TypeOf((*MockBeaconChainClient)(nil).GetValidatorQueue), arg0, arg1) } @@ -106,7 +111,7 @@ func (m *MockBeaconChainClient) ListValidatorBalances(arg0 context.Context, arg1 } // ListValidatorBalances indicates an expected call of ListValidatorBalances. -func (mr *MockBeaconChainClientMockRecorder) ListValidatorBalances(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListValidatorBalances(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListValidatorBalances", reflect.TypeOf((*MockBeaconChainClient)(nil).ListValidatorBalances), arg0, arg1) } @@ -121,7 +126,7 @@ func (m *MockBeaconChainClient) ListValidators(arg0 context.Context, arg1 *eth.L } // ListValidators indicates an expected call of ListValidators. -func (mr *MockBeaconChainClientMockRecorder) ListValidators(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockBeaconChainClientMockRecorder) ListValidators(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListValidators", reflect.TypeOf((*MockBeaconChainClient)(nil).ListValidators), arg0, arg1) } diff --git a/testing/validator-mock/node_client_mock.go b/testing/validator-mock/node_client_mock.go index 335db80ac998..6e5790c6bc76 100644 --- a/testing/validator-mock/node_client_mock.go +++ b/testing/validator-mock/node_client_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/validator/client/iface (interfaces: NodeClient) +// +// Generated by this command: +// +// mockgen -package=validator_mock -destination=testing/validator-mock/node_client_mock.go github.com/prysmaticlabs/prysm/v5/validator/client/iface NodeClient +// // Package validator_mock is a generated GoMock package. package validator_mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -46,7 +51,7 @@ func (m *MockNodeClient) GetGenesis(arg0 context.Context, arg1 *emptypb.Empty) ( } // GetGenesis indicates an expected call of GetGenesis. -func (mr *MockNodeClientMockRecorder) GetGenesis(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetGenesis(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGenesis", reflect.TypeOf((*MockNodeClient)(nil).GetGenesis), arg0, arg1) } @@ -61,7 +66,7 @@ func (m *MockNodeClient) GetSyncStatus(arg0 context.Context, arg1 *emptypb.Empty } // GetSyncStatus indicates an expected call of GetSyncStatus. -func (mr *MockNodeClientMockRecorder) GetSyncStatus(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetSyncStatus(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncStatus", reflect.TypeOf((*MockNodeClient)(nil).GetSyncStatus), arg0, arg1) } @@ -76,7 +81,7 @@ func (m *MockNodeClient) GetVersion(arg0 context.Context, arg1 *emptypb.Empty) ( } // GetVersion indicates an expected call of GetVersion. -func (mr *MockNodeClientMockRecorder) GetVersion(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) GetVersion(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockNodeClient)(nil).GetVersion), arg0, arg1) } @@ -90,7 +95,7 @@ func (m *MockNodeClient) IsHealthy(arg0 context.Context) bool { } // IsHealthy indicates an expected call of IsHealthy. -func (mr *MockNodeClientMockRecorder) IsHealthy(arg0 interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) IsHealthy(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsHealthy", reflect.TypeOf((*MockNodeClient)(nil).IsHealthy), arg0) } @@ -105,7 +110,7 @@ func (m *MockNodeClient) ListPeers(arg0 context.Context, arg1 *emptypb.Empty) (* } // ListPeers indicates an expected call of ListPeers. -func (mr *MockNodeClientMockRecorder) ListPeers(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockNodeClientMockRecorder) ListPeers(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPeers", reflect.TypeOf((*MockNodeClient)(nil).ListPeers), arg0, arg1) } diff --git a/testing/validator-mock/prysm_beacon_chain_client_mock.go b/testing/validator-mock/prysm_beacon_chain_client_mock.go index 27e10377efba..15d88735d78d 100644 --- a/testing/validator-mock/prysm_beacon_chain_client_mock.go +++ b/testing/validator-mock/prysm_beacon_chain_client_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/validator/client/iface (interfaces: PrysmBeaconChainClient) +// +// Generated by this command: +// +// mockgen -package=validator_mock -destination=testing/validator-mock/prysm_beacon_chain_client_mock.go github.com/prysmaticlabs/prysm/v5/validator/client/iface PrysmBeaconChainClient +// // Package validator_mock is a generated GoMock package. package validator_mock @@ -8,9 +13,9 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" validator "github.com/prysmaticlabs/prysm/v5/consensus-types/validator" iface "github.com/prysmaticlabs/prysm/v5/validator/client/iface" + gomock "go.uber.org/mock/gomock" ) // MockPrysmBeaconChainClient is a mock of PrysmBeaconChainClient interface. @@ -46,7 +51,7 @@ func (m *MockPrysmBeaconChainClient) GetValidatorCount(arg0 context.Context, arg } // GetValidatorCount indicates an expected call of GetValidatorCount. -func (mr *MockPrysmBeaconChainClientMockRecorder) GetValidatorCount(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockPrysmBeaconChainClientMockRecorder) GetValidatorCount(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorCount", reflect.TypeOf((*MockPrysmBeaconChainClient)(nil).GetValidatorCount), arg0, arg1, arg2) } diff --git a/testing/validator-mock/validator_client_mock.go b/testing/validator-mock/validator_client_mock.go index 76c79b57fba2..e02bcf451fef 100644 --- a/testing/validator-mock/validator_client_mock.go +++ b/testing/validator-mock/validator_client_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/prysmaticlabs/prysm/v5/validator/client/iface (interfaces: ValidatorClient) +// +// Generated by this command: +// +// mockgen -package=validator_mock -destination=testing/validator-mock/validator_client_mock.go github.com/prysmaticlabs/prysm/v5/validator/client/iface ValidatorClient +// // Package validator_mock is a generated GoMock package. package validator_mock @@ -8,10 +13,10 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" iface "github.com/prysmaticlabs/prysm/v5/validator/client/iface" + gomock "go.uber.org/mock/gomock" emptypb "google.golang.org/protobuf/types/known/emptypb" ) @@ -48,7 +53,7 @@ func (m *MockValidatorClient) CheckDoppelGanger(arg0 context.Context, arg1 *eth. } // CheckDoppelGanger indicates an expected call of CheckDoppelGanger. -func (mr *MockValidatorClientMockRecorder) CheckDoppelGanger(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) CheckDoppelGanger(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckDoppelGanger", reflect.TypeOf((*MockValidatorClient)(nil).CheckDoppelGanger), arg0, arg1) } @@ -63,7 +68,7 @@ func (m *MockValidatorClient) DomainData(arg0 context.Context, arg1 *eth.DomainR } // DomainData indicates an expected call of DomainData. -func (mr *MockValidatorClientMockRecorder) DomainData(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) DomainData(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DomainData", reflect.TypeOf((*MockValidatorClient)(nil).DomainData), arg0, arg1) } @@ -92,7 +97,7 @@ func (m *MockValidatorClient) GetAggregatedSelections(arg0 context.Context, arg1 } // GetAggregatedSelections indicates an expected call of GetAggregatedSelections. -func (mr *MockValidatorClientMockRecorder) GetAggregatedSelections(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetAggregatedSelections(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAggregatedSelections", reflect.TypeOf((*MockValidatorClient)(nil).GetAggregatedSelections), arg0, arg1) } @@ -107,7 +112,7 @@ func (m *MockValidatorClient) GetAttestationData(arg0 context.Context, arg1 *eth } // GetAttestationData indicates an expected call of GetAttestationData. -func (mr *MockValidatorClientMockRecorder) GetAttestationData(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetAttestationData(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttestationData", reflect.TypeOf((*MockValidatorClient)(nil).GetAttestationData), arg0, arg1) } @@ -122,7 +127,7 @@ func (m *MockValidatorClient) GetBeaconBlock(arg0 context.Context, arg1 *eth.Blo } // GetBeaconBlock indicates an expected call of GetBeaconBlock. -func (mr *MockValidatorClientMockRecorder) GetBeaconBlock(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetBeaconBlock(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBeaconBlock", reflect.TypeOf((*MockValidatorClient)(nil).GetBeaconBlock), arg0, arg1) } @@ -137,7 +142,7 @@ func (m *MockValidatorClient) GetDuties(arg0 context.Context, arg1 *eth.DutiesRe } // GetDuties indicates an expected call of GetDuties. -func (mr *MockValidatorClientMockRecorder) GetDuties(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetDuties(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDuties", reflect.TypeOf((*MockValidatorClient)(nil).GetDuties), arg0, arg1) } @@ -152,7 +157,7 @@ func (m *MockValidatorClient) GetFeeRecipientByPubKey(arg0 context.Context, arg1 } // GetFeeRecipientByPubKey indicates an expected call of GetFeeRecipientByPubKey. -func (mr *MockValidatorClientMockRecorder) GetFeeRecipientByPubKey(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetFeeRecipientByPubKey(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFeeRecipientByPubKey", reflect.TypeOf((*MockValidatorClient)(nil).GetFeeRecipientByPubKey), arg0, arg1) } @@ -167,7 +172,7 @@ func (m *MockValidatorClient) GetSyncCommitteeContribution(arg0 context.Context, } // GetSyncCommitteeContribution indicates an expected call of GetSyncCommitteeContribution. -func (mr *MockValidatorClientMockRecorder) GetSyncCommitteeContribution(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetSyncCommitteeContribution(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncCommitteeContribution", reflect.TypeOf((*MockValidatorClient)(nil).GetSyncCommitteeContribution), arg0, arg1) } @@ -182,7 +187,7 @@ func (m *MockValidatorClient) GetSyncMessageBlockRoot(arg0 context.Context, arg1 } // GetSyncMessageBlockRoot indicates an expected call of GetSyncMessageBlockRoot. -func (mr *MockValidatorClientMockRecorder) GetSyncMessageBlockRoot(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetSyncMessageBlockRoot(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncMessageBlockRoot", reflect.TypeOf((*MockValidatorClient)(nil).GetSyncMessageBlockRoot), arg0, arg1) } @@ -197,7 +202,7 @@ func (m *MockValidatorClient) GetSyncSubcommitteeIndex(arg0 context.Context, arg } // GetSyncSubcommitteeIndex indicates an expected call of GetSyncSubcommitteeIndex. -func (mr *MockValidatorClientMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncSubcommitteeIndex", reflect.TypeOf((*MockValidatorClient)(nil).GetSyncSubcommitteeIndex), arg0, arg1) } @@ -212,7 +217,7 @@ func (m *MockValidatorClient) MultipleValidatorStatus(arg0 context.Context, arg1 } // MultipleValidatorStatus indicates an expected call of MultipleValidatorStatus. -func (mr *MockValidatorClientMockRecorder) MultipleValidatorStatus(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) MultipleValidatorStatus(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MultipleValidatorStatus", reflect.TypeOf((*MockValidatorClient)(nil).MultipleValidatorStatus), arg0, arg1) } @@ -227,7 +232,7 @@ func (m *MockValidatorClient) PrepareBeaconProposer(arg0 context.Context, arg1 * } // PrepareBeaconProposer indicates an expected call of PrepareBeaconProposer. -func (mr *MockValidatorClientMockRecorder) PrepareBeaconProposer(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) PrepareBeaconProposer(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareBeaconProposer", reflect.TypeOf((*MockValidatorClient)(nil).PrepareBeaconProposer), arg0, arg1) } @@ -242,7 +247,7 @@ func (m *MockValidatorClient) ProposeAttestation(arg0 context.Context, arg1 *eth } // ProposeAttestation indicates an expected call of ProposeAttestation. -func (mr *MockValidatorClientMockRecorder) ProposeAttestation(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) ProposeAttestation(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeAttestation", reflect.TypeOf((*MockValidatorClient)(nil).ProposeAttestation), arg0, arg1) } @@ -257,7 +262,7 @@ func (m *MockValidatorClient) ProposeBeaconBlock(arg0 context.Context, arg1 *eth } // ProposeBeaconBlock indicates an expected call of ProposeBeaconBlock. -func (mr *MockValidatorClientMockRecorder) ProposeBeaconBlock(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) ProposeBeaconBlock(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeBeaconBlock", reflect.TypeOf((*MockValidatorClient)(nil).ProposeBeaconBlock), arg0, arg1) } @@ -272,11 +277,25 @@ func (m *MockValidatorClient) ProposeExit(arg0 context.Context, arg1 *eth.Signed } // ProposeExit indicates an expected call of ProposeExit. -func (mr *MockValidatorClientMockRecorder) ProposeExit(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) ProposeExit(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeExit", reflect.TypeOf((*MockValidatorClient)(nil).ProposeExit), arg0, arg1) } +// RetrieveHost mocks base method. +func (m *MockValidatorClient) RetrieveHost() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RetrieveHost") + ret0, _ := ret[0].(string) + return ret0 +} + +// RetrieveHost indicates an expected call of RetrieveHost. +func (mr *MockValidatorClientMockRecorder) RetrieveHost() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RetrieveHost", reflect.TypeOf((*MockValidatorClient)(nil).RetrieveHost)) +} + // StartEventStream mocks base method. func (m *MockValidatorClient) StartEventStream(arg0 context.Context) error { m.ctrl.T.Helper() @@ -286,7 +305,7 @@ func (m *MockValidatorClient) StartEventStream(arg0 context.Context) error { } // StartEventStream indicates an expected call of StartEventStream. -func (mr *MockValidatorClientMockRecorder) StartEventStream(arg0 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) StartEventStream(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartEventStream", reflect.TypeOf((*MockValidatorClient)(nil).StartEventStream), arg0) } @@ -301,7 +320,7 @@ func (m *MockValidatorClient) StreamSlots(arg0 context.Context, arg1 *eth.Stream } // StreamSlots indicates an expected call of StreamSlots. -func (mr *MockValidatorClientMockRecorder) StreamSlots(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) StreamSlots(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StreamSlots", reflect.TypeOf((*MockValidatorClient)(nil).StreamSlots), arg0, arg1) } @@ -316,7 +335,7 @@ func (m *MockValidatorClient) SubmitAggregateSelectionProof(arg0 context.Context } // SubmitAggregateSelectionProof indicates an expected call of SubmitAggregateSelectionProof. -func (mr *MockValidatorClientMockRecorder) SubmitAggregateSelectionProof(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) SubmitAggregateSelectionProof(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitAggregateSelectionProof", reflect.TypeOf((*MockValidatorClient)(nil).SubmitAggregateSelectionProof), arg0, arg1) } @@ -331,7 +350,7 @@ func (m *MockValidatorClient) SubmitSignedAggregateSelectionProof(arg0 context.C } // SubmitSignedAggregateSelectionProof indicates an expected call of SubmitSignedAggregateSelectionProof. -func (mr *MockValidatorClientMockRecorder) SubmitSignedAggregateSelectionProof(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) SubmitSignedAggregateSelectionProof(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSignedAggregateSelectionProof", reflect.TypeOf((*MockValidatorClient)(nil).SubmitSignedAggregateSelectionProof), arg0, arg1) } @@ -346,7 +365,7 @@ func (m *MockValidatorClient) SubmitSignedContributionAndProof(arg0 context.Cont } // SubmitSignedContributionAndProof indicates an expected call of SubmitSignedContributionAndProof. -func (mr *MockValidatorClientMockRecorder) SubmitSignedContributionAndProof(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) SubmitSignedContributionAndProof(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSignedContributionAndProof", reflect.TypeOf((*MockValidatorClient)(nil).SubmitSignedContributionAndProof), arg0, arg1) } @@ -361,7 +380,7 @@ func (m *MockValidatorClient) SubmitSyncMessage(arg0 context.Context, arg1 *eth. } // SubmitSyncMessage indicates an expected call of SubmitSyncMessage. -func (mr *MockValidatorClientMockRecorder) SubmitSyncMessage(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) SubmitSyncMessage(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitSyncMessage", reflect.TypeOf((*MockValidatorClient)(nil).SubmitSyncMessage), arg0, arg1) } @@ -376,7 +395,7 @@ func (m *MockValidatorClient) SubmitValidatorRegistrations(arg0 context.Context, } // SubmitValidatorRegistrations indicates an expected call of SubmitValidatorRegistrations. -func (mr *MockValidatorClientMockRecorder) SubmitValidatorRegistrations(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) SubmitValidatorRegistrations(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubmitValidatorRegistrations", reflect.TypeOf((*MockValidatorClient)(nil).SubmitValidatorRegistrations), arg0, arg1) } @@ -391,11 +410,23 @@ func (m *MockValidatorClient) SubscribeCommitteeSubnets(arg0 context.Context, ar } // SubscribeCommitteeSubnets indicates an expected call of SubscribeCommitteeSubnets. -func (mr *MockValidatorClientMockRecorder) SubscribeCommitteeSubnets(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) SubscribeCommitteeSubnets(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeCommitteeSubnets", reflect.TypeOf((*MockValidatorClient)(nil).SubscribeCommitteeSubnets), arg0, arg1, arg2) } +// UpdateHost mocks base method. +func (m *MockValidatorClient) UpdateHost(arg0 string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "UpdateHost", arg0) +} + +// UpdateHost indicates an expected call of UpdateHost. +func (mr *MockValidatorClientMockRecorder) UpdateHost(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateHost", reflect.TypeOf((*MockValidatorClient)(nil).UpdateHost), arg0) +} + // ValidatorIndex mocks base method. func (m *MockValidatorClient) ValidatorIndex(arg0 context.Context, arg1 *eth.ValidatorIndexRequest) (*eth.ValidatorIndexResponse, error) { m.ctrl.T.Helper() @@ -406,7 +437,7 @@ func (m *MockValidatorClient) ValidatorIndex(arg0 context.Context, arg1 *eth.Val } // ValidatorIndex indicates an expected call of ValidatorIndex. -func (mr *MockValidatorClientMockRecorder) ValidatorIndex(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) ValidatorIndex(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorIndex", reflect.TypeOf((*MockValidatorClient)(nil).ValidatorIndex), arg0, arg1) } @@ -421,7 +452,7 @@ func (m *MockValidatorClient) ValidatorStatus(arg0 context.Context, arg1 *eth.Va } // ValidatorStatus indicates an expected call of ValidatorStatus. -func (mr *MockValidatorClientMockRecorder) ValidatorStatus(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) ValidatorStatus(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorStatus", reflect.TypeOf((*MockValidatorClient)(nil).ValidatorStatus), arg0, arg1) } @@ -436,7 +467,7 @@ func (m *MockValidatorClient) WaitForActivation(arg0 context.Context, arg1 *eth. } // WaitForActivation indicates an expected call of WaitForActivation. -func (mr *MockValidatorClientMockRecorder) WaitForActivation(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) WaitForActivation(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForActivation", reflect.TypeOf((*MockValidatorClient)(nil).WaitForActivation), arg0, arg1) } @@ -451,7 +482,7 @@ func (m *MockValidatorClient) WaitForChainStart(arg0 context.Context, arg1 *empt } // WaitForChainStart indicates an expected call of WaitForChainStart. -func (mr *MockValidatorClientMockRecorder) WaitForChainStart(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockValidatorClientMockRecorder) WaitForChainStart(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForChainStart", reflect.TypeOf((*MockValidatorClient)(nil).WaitForChainStart), arg0, arg1) } diff --git a/validator/client/beacon-api/json_rest_handler_test.go b/validator/client/beacon-api/json_rest_handler_test.go index 5c858f105e45..3e78cea323e9 100644 --- a/validator/client/beacon-api/json_rest_handler_test.go +++ b/validator/client/beacon-api/json_rest_handler_test.go @@ -42,7 +42,7 @@ func TestGet(t *testing.T) { jsonRestHandler := BeaconApiJsonRestHandler{ HttpClient: http.Client{Timeout: time.Second * 5}, - Host: server.URL, + Host: func() string { return server.URL }, } resp := &structs.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Get(ctx, endpoint+"?arg1=abc&arg2=def", resp)) @@ -88,7 +88,7 @@ func TestPost(t *testing.T) { jsonRestHandler := BeaconApiJsonRestHandler{ HttpClient: http.Client{Timeout: time.Second * 5}, - Host: server.URL, + Host: func() string { return server.URL }, } resp := &structs.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Post(ctx, endpoint, headers, bytes.NewBuffer(dataBytes), resp)) @@ -218,3 +218,18 @@ func Test_decodeResp(t *testing.T) { assert.ErrorContains(t, "failed to decode response body into error json", err) }) } + +func Test_Host(t *testing.T) { + servers := []string{"127.0.0.1:0", "127.0.0.2:0"} + jsonRestHandler := BeaconApiJsonRestHandler{ + HttpClient: http.Client{Timeout: time.Second * 5}, + Host: func() string { return servers[0] }, + } + + host := jsonRestHandler.GetHost() + require.Equal(t, servers[0], host) + + jsonRestHandler.SetHost(servers[1]) + host = jsonRestHandler.GetHost() + require.Equal(t, servers[1], host) +} diff --git a/validator/client/beacon-api/mock/beacon_block_converter_mock.go b/validator/client/beacon-api/mock/beacon_block_converter_mock.go index 6017b59fa6f4..f11c0e0ad7b6 100644 --- a/validator/client/beacon-api/mock/beacon_block_converter_mock.go +++ b/validator/client/beacon-api/mock/beacon_block_converter_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: validator/client/beacon-api/beacon_block_converter.go +// +// Generated by this command: +// +// mockgen -package=mock -source=validator/client/beacon-api/beacon_block_converter.go -destination=validator/client/beacon-api/mock/beacon_block_converter_mock.go +// // Package mock is a generated GoMock package. package mock @@ -7,9 +12,9 @@ package mock import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" structs "github.com/prysmaticlabs/prysm/v5/api/server/structs" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" ) // MockBeaconBlockConverter is a mock of BeaconBlockConverter interface. @@ -45,7 +50,7 @@ func (m *MockBeaconBlockConverter) ConvertRESTAltairBlockToProto(block *structs. } // ConvertRESTAltairBlockToProto indicates an expected call of ConvertRESTAltairBlockToProto. -func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTAltairBlockToProto(block interface{}) *gomock.Call { +func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTAltairBlockToProto(block any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConvertRESTAltairBlockToProto", reflect.TypeOf((*MockBeaconBlockConverter)(nil).ConvertRESTAltairBlockToProto), block) } @@ -60,7 +65,7 @@ func (m *MockBeaconBlockConverter) ConvertRESTBellatrixBlockToProto(block *struc } // ConvertRESTBellatrixBlockToProto indicates an expected call of ConvertRESTBellatrixBlockToProto. -func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTBellatrixBlockToProto(block interface{}) *gomock.Call { +func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTBellatrixBlockToProto(block any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConvertRESTBellatrixBlockToProto", reflect.TypeOf((*MockBeaconBlockConverter)(nil).ConvertRESTBellatrixBlockToProto), block) } @@ -75,7 +80,7 @@ func (m *MockBeaconBlockConverter) ConvertRESTCapellaBlockToProto(block *structs } // ConvertRESTCapellaBlockToProto indicates an expected call of ConvertRESTCapellaBlockToProto. -func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTCapellaBlockToProto(block interface{}) *gomock.Call { +func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTCapellaBlockToProto(block any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConvertRESTCapellaBlockToProto", reflect.TypeOf((*MockBeaconBlockConverter)(nil).ConvertRESTCapellaBlockToProto), block) } @@ -90,7 +95,7 @@ func (m *MockBeaconBlockConverter) ConvertRESTPhase0BlockToProto(block *structs. } // ConvertRESTPhase0BlockToProto indicates an expected call of ConvertRESTPhase0BlockToProto. -func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTPhase0BlockToProto(block interface{}) *gomock.Call { +func (mr *MockBeaconBlockConverterMockRecorder) ConvertRESTPhase0BlockToProto(block any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConvertRESTPhase0BlockToProto", reflect.TypeOf((*MockBeaconBlockConverter)(nil).ConvertRESTPhase0BlockToProto), block) } diff --git a/validator/client/beacon-api/mock/duties_mock.go b/validator/client/beacon-api/mock/duties_mock.go index d8e030852e72..b9527e0a04c0 100644 --- a/validator/client/beacon-api/mock/duties_mock.go +++ b/validator/client/beacon-api/mock/duties_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: validator/client/beacon-api/duties.go +// +// Generated by this command: +// +// mockgen -package=mock -source=validator/client/beacon-api/duties.go -destination=validator/client/beacon-api/mock/duties_mock.go +// // Package mock is a generated GoMock package. package mock @@ -8,9 +13,9 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" structs "github.com/prysmaticlabs/prysm/v5/api/server/structs" primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" + gomock "go.uber.org/mock/gomock" ) // MockdutiesProvider is a mock of dutiesProvider interface. @@ -46,7 +51,7 @@ func (m *MockdutiesProvider) GetAttesterDuties(ctx context.Context, epoch primit } // GetAttesterDuties indicates an expected call of GetAttesterDuties. -func (mr *MockdutiesProviderMockRecorder) GetAttesterDuties(ctx, epoch, validatorIndices interface{}) *gomock.Call { +func (mr *MockdutiesProviderMockRecorder) GetAttesterDuties(ctx, epoch, validatorIndices any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttesterDuties", reflect.TypeOf((*MockdutiesProvider)(nil).GetAttesterDuties), ctx, epoch, validatorIndices) } @@ -61,7 +66,7 @@ func (m *MockdutiesProvider) GetCommittees(ctx context.Context, epoch primitives } // GetCommittees indicates an expected call of GetCommittees. -func (mr *MockdutiesProviderMockRecorder) GetCommittees(ctx, epoch interface{}) *gomock.Call { +func (mr *MockdutiesProviderMockRecorder) GetCommittees(ctx, epoch any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommittees", reflect.TypeOf((*MockdutiesProvider)(nil).GetCommittees), ctx, epoch) } @@ -76,7 +81,7 @@ func (m *MockdutiesProvider) GetProposerDuties(ctx context.Context, epoch primit } // GetProposerDuties indicates an expected call of GetProposerDuties. -func (mr *MockdutiesProviderMockRecorder) GetProposerDuties(ctx, epoch interface{}) *gomock.Call { +func (mr *MockdutiesProviderMockRecorder) GetProposerDuties(ctx, epoch any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProposerDuties", reflect.TypeOf((*MockdutiesProvider)(nil).GetProposerDuties), ctx, epoch) } @@ -91,7 +96,7 @@ func (m *MockdutiesProvider) GetSyncDuties(ctx context.Context, epoch primitives } // GetSyncDuties indicates an expected call of GetSyncDuties. -func (mr *MockdutiesProviderMockRecorder) GetSyncDuties(ctx, epoch, validatorIndices interface{}) *gomock.Call { +func (mr *MockdutiesProviderMockRecorder) GetSyncDuties(ctx, epoch, validatorIndices any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncDuties", reflect.TypeOf((*MockdutiesProvider)(nil).GetSyncDuties), ctx, epoch, validatorIndices) } diff --git a/validator/client/beacon-api/mock/genesis_mock.go b/validator/client/beacon-api/mock/genesis_mock.go index df49e5fabaf4..dd8e35e36eed 100644 --- a/validator/client/beacon-api/mock/genesis_mock.go +++ b/validator/client/beacon-api/mock/genesis_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: validator/client/beacon-api/genesis.go +// +// Generated by this command: +// +// mockgen -package=mock -source=validator/client/beacon-api/genesis.go -destination=validator/client/beacon-api/mock/genesis_mock.go +// // Package mock is a generated GoMock package. package mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" structs "github.com/prysmaticlabs/prysm/v5/api/server/structs" + gomock "go.uber.org/mock/gomock" ) // MockGenesisProvider is a mock of GenesisProvider interface. @@ -45,7 +50,7 @@ func (m *MockGenesisProvider) GetGenesis(ctx context.Context) (*structs.Genesis, } // GetGenesis indicates an expected call of GetGenesis. -func (mr *MockGenesisProviderMockRecorder) GetGenesis(ctx interface{}) *gomock.Call { +func (mr *MockGenesisProviderMockRecorder) GetGenesis(ctx any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGenesis", reflect.TypeOf((*MockGenesisProvider)(nil).GetGenesis), ctx) } diff --git a/validator/client/beacon-api/mock/json_rest_handler_mock.go b/validator/client/beacon-api/mock/json_rest_handler_mock.go index b939c1221b1c..c906313b1e38 100644 --- a/validator/client/beacon-api/mock/json_rest_handler_mock.go +++ b/validator/client/beacon-api/mock/json_rest_handler_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: validator/client/beacon-api/json_rest_handler.go +// +// Generated by this command: +// +// mockgen -package=mock -source=validator/client/beacon-api/json_rest_handler.go -destination=validator/client/beacon-api/mock/json_rest_handler_mock.go +// // Package mock is a generated GoMock package. package mock @@ -9,7 +14,7 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockJsonRestHandler is a mock of JsonRestHandler interface. @@ -36,7 +41,7 @@ func (m *MockJsonRestHandler) EXPECT() *MockJsonRestHandlerMockRecorder { } // Get mocks base method. -func (m *MockJsonRestHandler) Get(ctx context.Context, endpoint string, resp interface{}) error { +func (m *MockJsonRestHandler) Get(ctx context.Context, endpoint string, resp any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Get", ctx, endpoint, resp) ret0, _ := ret[0].(error) @@ -44,13 +49,27 @@ func (m *MockJsonRestHandler) Get(ctx context.Context, endpoint string, resp int } // Get indicates an expected call of Get. -func (mr *MockJsonRestHandlerMockRecorder) Get(ctx, endpoint, resp interface{}) *gomock.Call { +func (mr *MockJsonRestHandlerMockRecorder) Get(ctx, endpoint, resp any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockJsonRestHandler)(nil).Get), ctx, endpoint, resp) } +// GetHost mocks base method. +func (m *MockJsonRestHandler) GetHost() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetHost") + ret0, _ := ret[0].(string) + return ret0 +} + +// GetHost indicates an expected call of GetHost. +func (mr *MockJsonRestHandlerMockRecorder) GetHost() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHost", reflect.TypeOf((*MockJsonRestHandler)(nil).GetHost)) +} + // Post mocks base method. -func (m *MockJsonRestHandler) Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp interface{}) error { +func (m *MockJsonRestHandler) Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Post", ctx, endpoint, headers, data, resp) ret0, _ := ret[0].(error) @@ -58,7 +77,19 @@ func (m *MockJsonRestHandler) Post(ctx context.Context, endpoint string, headers } // Post indicates an expected call of Post. -func (mr *MockJsonRestHandlerMockRecorder) Post(ctx, endpoint, headers, data, resp interface{}) *gomock.Call { +func (mr *MockJsonRestHandlerMockRecorder) Post(ctx, endpoint, headers, data, resp any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Post", reflect.TypeOf((*MockJsonRestHandler)(nil).Post), ctx, endpoint, headers, data, resp) } + +// SetHost mocks base method. +func (m *MockJsonRestHandler) SetHost(newHost string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetHost", newHost) +} + +// SetHost indicates an expected call of SetHost. +func (mr *MockJsonRestHandlerMockRecorder) SetHost(newHost any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHost", reflect.TypeOf((*MockJsonRestHandler)(nil).SetHost), newHost) +} diff --git a/validator/client/beacon-api/mock/state_validators_mock.go b/validator/client/beacon-api/mock/state_validators_mock.go index 1b5a9ef6ddf0..5b9850bbe018 100644 --- a/validator/client/beacon-api/mock/state_validators_mock.go +++ b/validator/client/beacon-api/mock/state_validators_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: validator/client/beacon-api/state_validators.go +// +// Generated by this command: +// +// mockgen -package=mock -source=validator/client/beacon-api/state_validators.go -destination=validator/client/beacon-api/mock/state_validators_mock.go +// // Package mock is a generated GoMock package. package mock @@ -8,9 +13,9 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" structs "github.com/prysmaticlabs/prysm/v5/api/server/structs" primitives "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" + gomock "go.uber.org/mock/gomock" ) // MockStateValidatorsProvider is a mock of StateValidatorsProvider interface. @@ -46,7 +51,7 @@ func (m *MockStateValidatorsProvider) GetStateValidators(arg0 context.Context, a } // GetStateValidators indicates an expected call of GetStateValidators. -func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidators(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidators(arg0, arg1, arg2, arg3 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateValidators", reflect.TypeOf((*MockStateValidatorsProvider)(nil).GetStateValidators), arg0, arg1, arg2, arg3) } @@ -61,7 +66,7 @@ func (m *MockStateValidatorsProvider) GetStateValidatorsForHead(arg0 context.Con } // GetStateValidatorsForHead indicates an expected call of GetStateValidatorsForHead. -func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidatorsForHead(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidatorsForHead(arg0, arg1, arg2, arg3 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateValidatorsForHead", reflect.TypeOf((*MockStateValidatorsProvider)(nil).GetStateValidatorsForHead), arg0, arg1, arg2, arg3) } @@ -76,7 +81,7 @@ func (m *MockStateValidatorsProvider) GetStateValidatorsForSlot(arg0 context.Con } // GetStateValidatorsForSlot indicates an expected call of GetStateValidatorsForSlot. -func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidatorsForSlot(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockStateValidatorsProviderMockRecorder) GetStateValidatorsForSlot(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStateValidatorsForSlot", reflect.TypeOf((*MockStateValidatorsProvider)(nil).GetStateValidatorsForSlot), arg0, arg1, arg2, arg3, arg4) } From 75c1059a8a457b1684fb0a9dad783a6b18fa8571 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 12:48:04 -0800 Subject: [PATCH 07/39] Tidy --- crypto/bls/common/mock/BUILD.bazel | 2 +- go.mod | 2 +- testing/mock/BUILD.bazel | 1 + testing/validator-mock/BUILD.bazel | 2 +- validator/client/beacon-api/mock/BUILD.bazel | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crypto/bls/common/mock/BUILD.bazel b/crypto/bls/common/mock/BUILD.bazel index 255945f5be1c..6f56bdbd6b6c 100644 --- a/crypto/bls/common/mock/BUILD.bazel +++ b/crypto/bls/common/mock/BUILD.bazel @@ -7,6 +7,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//crypto/bls/common:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/go.mod b/go.mod index a069a68e738a..636ebb23f02f 100644 --- a/go.mod +++ b/go.mod @@ -86,6 +86,7 @@ require ( go.etcd.io/bbolt v1.3.6 go.opencensus.io v0.24.0 go.uber.org/automaxprocs v1.5.2 + go.uber.org/mock v0.3.0 golang.org/x/crypto v0.17.0 golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 golang.org/x/mod v0.14.0 @@ -231,7 +232,6 @@ require ( github.com/yusufpapurcu/wmi v1.2.2 // indirect go.uber.org/dig v1.17.1 // indirect go.uber.org/fx v1.20.1 // indirect - go.uber.org/mock v0.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect diff --git a/testing/mock/BUILD.bazel b/testing/mock/BUILD.bazel index 8c711d44fda9..8a1ff9721ecd 100644 --- a/testing/mock/BUILD.bazel +++ b/testing/mock/BUILD.bazel @@ -20,5 +20,6 @@ go_library( "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//metadata:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/testing/validator-mock/BUILD.bazel b/testing/validator-mock/BUILD.bazel index 2f6838bed36e..21b67597988e 100644 --- a/testing/validator-mock/BUILD.bazel +++ b/testing/validator-mock/BUILD.bazel @@ -17,7 +17,7 @@ go_library( "//consensus-types/validator:go_default_library", "//proto/prysm/v1alpha1:go_default_library", "//validator/client/iface:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/validator/client/beacon-api/mock/BUILD.bazel b/validator/client/beacon-api/mock/BUILD.bazel index aae3920079ea..e8c821ec5198 100644 --- a/validator/client/beacon-api/mock/BUILD.bazel +++ b/validator/client/beacon-api/mock/BUILD.bazel @@ -15,6 +15,6 @@ go_library( "//api/server/structs:go_default_library", "//consensus-types/primitives:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) From 8903562bca754ae685c92c6d6776344fe68502e8 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 14:03:53 -0800 Subject: [PATCH 08/39] Add mock validator --- validator/accounts/testing/mock.go | 8 ++++++++ validator/client/testutil/mock_validator.go | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/validator/accounts/testing/mock.go b/validator/accounts/testing/mock.go index 1a591b06a9fb..f88e78222fb9 100644 --- a/validator/accounts/testing/mock.go +++ b/validator/accounts/testing/mock.go @@ -224,3 +224,11 @@ func (_ *Validator) EventStreamIsRunning() bool { func (_ *Validator) NodeIsHealthy(ctx context.Context) bool { panic("implement me") } + +func (_ *Validator) RetrieveHost() string { + panic("implement me") +} + +func (_ *Validator) UpdateHost(host string) { + panic("implement me") +} diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index 46c58d68258e..8e5e984869ea 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -297,3 +297,9 @@ func (fv *FakeValidator) EventStreamIsRunning() bool { func (fv *FakeValidator) NodeIsHealthy(context.Context) bool { return true } + +func (fv *FakeValidator) RetrieveHost() string { + return "127.0.0.1:0" +} + +func (fv *FakeValidator) UpdateHost(host string) {} From ea93b95cd1e5451ec9fe2be31926581731dfe9ea Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 15:43:29 -0800 Subject: [PATCH 09/39] Update gomock --- beacon-chain/rpc/eth/beacon/BUILD.bazel | 2 +- beacon-chain/rpc/eth/beacon/handlers_test.go | 3 ++- beacon-chain/rpc/eth/validator/BUILD.bazel | 2 +- beacon-chain/rpc/eth/validator/handlers_block_test.go | 2 +- beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go | 2 +- .../rpc/prysm/v1alpha1/validator/server_mainnet_test.go | 2 +- beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go | 2 +- cmd/helpers_test.go | 2 +- cmd/mock/BUILD.bazel | 2 +- cmd/mock/password_reader_mock.go | 2 +- cmd/validator/accounts/exit_test.go | 2 +- go.mod | 1 - go.sum | 3 --- testing/mock/BUILD.bazel | 1 - testing/mock/beacon_altair_validator_client_mock.go | 2 +- testing/mock/beacon_altair_validator_server_mock.go | 2 +- validator/accounts/accounts_list_test.go | 2 +- validator/client/aggregate_test.go | 2 +- validator/client/attest_protect_test.go | 2 +- validator/client/attest_test.go | 2 +- validator/client/beacon-api/BUILD.bazel | 1 + validator/client/beacon-api/activation_test.go | 2 +- validator/client/beacon-api/attestation_data_test.go | 2 +- .../client/beacon-api/beacon_api_beacon_chain_client_test.go | 2 +- validator/client/beacon-api/beacon_api_helpers_test.go | 2 +- validator/client/beacon-api/beacon_api_node_client_test.go | 2 +- .../client/beacon-api/beacon_api_validator_client_test.go | 2 +- .../client/beacon-api/beacon_committee_selections_test.go | 2 +- validator/client/beacon-api/domain_data_test.go | 2 +- validator/client/beacon-api/doppelganger_test.go | 2 +- validator/client/beacon-api/duties_test.go | 2 +- validator/client/beacon-api/genesis_test.go | 2 +- validator/client/beacon-api/get_beacon_block_test.go | 2 +- validator/client/beacon-api/index_test.go | 2 +- validator/client/beacon-api/prepare_beacon_proposer_test.go | 2 +- validator/client/beacon-api/propose_attestation_test.go | 2 +- .../client/beacon-api/propose_beacon_block_altair_test.go | 2 +- .../client/beacon-api/propose_beacon_block_bellatrix_test.go | 2 +- .../beacon-api/propose_beacon_block_blinded_bellatrix_test.go | 2 +- .../beacon-api/propose_beacon_block_blinded_capella_test.go | 2 +- .../beacon-api/propose_beacon_block_blinded_deneb_test.go | 2 +- .../client/beacon-api/propose_beacon_block_capella_test.go | 2 +- validator/client/beacon-api/propose_beacon_block_deneb_test.go | 2 +- .../client/beacon-api/propose_beacon_block_phase0_test.go | 2 +- validator/client/beacon-api/propose_beacon_block_test.go | 2 +- validator/client/beacon-api/propose_exit_test.go | 2 +- validator/client/beacon-api/registration_test.go | 2 +- validator/client/beacon-api/state_validators_test.go | 2 +- validator/client/beacon-api/status_test.go | 2 +- validator/client/beacon-api/stream_blocks_test.go | 2 +- .../client/beacon-api/submit_aggregate_selection_proof_test.go | 2 +- .../client/beacon-api/submit_signed_aggregate_proof_test.go | 2 +- .../beacon-api/submit_signed_contribution_and_proof_test.go | 2 +- .../client/beacon-api/subscribe_committee_subnets_test.go | 2 +- validator/client/beacon-api/sync_committee_test.go | 2 +- validator/client/beacon-api/validator_count_test.go | 2 +- validator/client/beacon-api/wait_for_chain_start_test.go | 2 +- .../client/grpc-api/grpc_prysm_beacon_chain_client_test.go | 2 +- validator/client/grpc-api/grpc_validator_client_test.go | 2 +- validator/client/key_reload_test.go | 2 +- validator/client/propose_test.go | 2 +- validator/client/registration_test.go | 2 +- validator/client/sync_committee_test.go | 2 +- validator/client/validator_test.go | 2 +- validator/client/wait_for_activation_test.go | 2 +- validator/rpc/BUILD.bazel | 1 + validator/rpc/handlers_accounts_test.go | 2 +- validator/rpc/handlers_beacon_test.go | 2 +- validator/rpc/handlers_health_test.go | 2 +- validator/rpc/handlers_keymanager_test.go | 2 +- 70 files changed, 68 insertions(+), 70 deletions(-) diff --git a/beacon-chain/rpc/eth/beacon/BUILD.bazel b/beacon-chain/rpc/eth/beacon/BUILD.bazel index 35e0b275b26d..71b7c541bb74 100644 --- a/beacon-chain/rpc/eth/beacon/BUILD.bazel +++ b/beacon-chain/rpc/eth/beacon/BUILD.bazel @@ -118,10 +118,10 @@ go_test( "//testing/util:go_default_library", "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_gorilla_mux//:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", "@com_github_stretchr_testify//mock:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/beacon-chain/rpc/eth/beacon/handlers_test.go b/beacon-chain/rpc/eth/beacon/handlers_test.go index 59f944f4d2a0..13143b9dc7fc 100644 --- a/beacon-chain/rpc/eth/beacon/handlers_test.go +++ b/beacon-chain/rpc/eth/beacon/handlers_test.go @@ -13,7 +13,8 @@ import ( "time" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" + "github.com/gorilla/mux" "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" diff --git a/beacon-chain/rpc/eth/validator/BUILD.bazel b/beacon-chain/rpc/eth/validator/BUILD.bazel index e118a97fbeea..5ab2597a0c09 100644 --- a/beacon-chain/rpc/eth/validator/BUILD.bazel +++ b/beacon-chain/rpc/eth/validator/BUILD.bazel @@ -90,9 +90,9 @@ go_test( "//testing/util:go_default_library", "//time/slots:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_gorilla_mux//:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/beacon-chain/rpc/eth/validator/handlers_block_test.go b/beacon-chain/rpc/eth/validator/handlers_block_test.go index e8afc7a2eb69..9cfe0b485aa4 100644 --- a/beacon-chain/rpc/eth/validator/handlers_block_test.go +++ b/beacon-chain/rpc/eth/validator/handlers_block_test.go @@ -10,7 +10,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api" "github.com/prysmaticlabs/prysm/v5/api/server/structs" blockchainTesting "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing" @@ -22,6 +21,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/assert" mock2 "github.com/prysmaticlabs/prysm/v5/testing/mock" "github.com/prysmaticlabs/prysm/v5/testing/require" + "go.uber.org/mock/gomock" ) func TestProduceBlockV2(t *testing.T) { diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go index 9ae793a5c710..c0151d9fb8ef 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/blocks_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" chainMock "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed" @@ -18,6 +17,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/mock" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/testing/util" + "go.uber.org/mock/gomock" ) func TestServer_StreamAltairBlocksVerified_ContextCanceled(t *testing.T) { diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_mainnet_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_mainnet_test.go index 1b05e1eb525d..d33836d704f9 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_mainnet_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_mainnet_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" mockChain "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v5/beacon-chain/cache/depositcache" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/signing" @@ -19,6 +18,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/mock" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/testing/util" + "go.uber.org/mock/gomock" ) func TestWaitForActivation_ValidatorOriginallyExists(t *testing.T) { diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go index aa3981774660..e8c5f66e7ae1 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/server_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/async/event" mockChain "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain/testing" "github.com/prysmaticlabs/prysm/v5/beacon-chain/cache/depositcache" @@ -24,6 +23,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/testing/util" logTest "github.com/sirupsen/logrus/hooks/test" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/cmd/helpers_test.go b/cmd/helpers_test.go index 0adc5bfa864d..d3917e1a68b5 100644 --- a/cmd/helpers_test.go +++ b/cmd/helpers_test.go @@ -6,12 +6,12 @@ import ( "os/user" "testing" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/cmd/mock" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/urfave/cli/v2" + "go.uber.org/mock/gomock" ) func TestEnterPassword(t *testing.T) { diff --git a/cmd/mock/BUILD.bazel b/cmd/mock/BUILD.bazel index 018ba083feaa..6a1288959a3a 100644 --- a/cmd/mock/BUILD.bazel +++ b/cmd/mock/BUILD.bazel @@ -6,5 +6,5 @@ go_library( srcs = ["password_reader_mock.go"], importpath = "github.com/prysmaticlabs/prysm/v5/cmd/mock", visibility = ["//visibility:public"], - deps = ["@com_github_golang_mock//gomock:go_default_library"], + deps = ["@org_uber_go_mock//gomock:go_default_library"], ) diff --git a/cmd/mock/password_reader_mock.go b/cmd/mock/password_reader_mock.go index bf4a7078ff82..e40a97b49ae7 100644 --- a/cmd/mock/password_reader_mock.go +++ b/cmd/mock/password_reader_mock.go @@ -7,7 +7,7 @@ package mock import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // PasswordReader is a mock of PasswordReader interface diff --git a/cmd/validator/accounts/exit_test.go b/cmd/validator/accounts/exit_test.go index b871e3ecbcce..c694dad257f2 100644 --- a/cmd/validator/accounts/exit_test.go +++ b/cmd/validator/accounts/exit_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/build/bazel" "github.com/prysmaticlabs/prysm/v5/io/file" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -18,6 +17,7 @@ import ( validatormock "github.com/prysmaticlabs/prysm/v5/testing/validator-mock" "github.com/prysmaticlabs/prysm/v5/validator/accounts" "github.com/prysmaticlabs/prysm/v5/validator/keymanager" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/timestamppb" ) diff --git a/go.mod b/go.mod index 636ebb23f02f..3c8981bad67e 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,6 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang/gddo v0.0.0-20200528160355-8d077c1d8f4c - github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb github.com/google/gofuzz v1.2.0 diff --git a/go.sum b/go.sum index 958c08975618..ef45c73a66e6 100644 --- a/go.sum +++ b/go.sum @@ -488,8 +488,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -1785,7 +1783,6 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= diff --git a/testing/mock/BUILD.bazel b/testing/mock/BUILD.bazel index 8a1ff9721ecd..ffbb688cae55 100644 --- a/testing/mock/BUILD.bazel +++ b/testing/mock/BUILD.bazel @@ -16,7 +16,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//proto/prysm/v1alpha1:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//metadata:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", diff --git a/testing/mock/beacon_altair_validator_client_mock.go b/testing/mock/beacon_altair_validator_client_mock.go index edd5d883e552..e7a513570740 100644 --- a/testing/mock/beacon_altair_validator_client_mock.go +++ b/testing/mock/beacon_altair_validator_client_mock.go @@ -8,8 +8,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" v2 "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" metadata "google.golang.org/grpc/metadata" ) diff --git a/testing/mock/beacon_altair_validator_server_mock.go b/testing/mock/beacon_altair_validator_server_mock.go index 9276b99b07aa..ff6ce5620795 100644 --- a/testing/mock/beacon_altair_validator_server_mock.go +++ b/testing/mock/beacon_altair_validator_server_mock.go @@ -8,8 +8,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" v2 "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" + gomock "go.uber.org/mock/gomock" metadata "google.golang.org/grpc/metadata" ) diff --git a/validator/accounts/accounts_list_test.go b/validator/accounts/accounts_list_test.go index 8af669914f9b..69703c8f6c11 100644 --- a/validator/accounts/accounts_list_test.go +++ b/validator/accounts/accounts_list_test.go @@ -11,7 +11,6 @@ import ( "strings" "testing" - "github.com/golang/mock/gomock" "github.com/google/uuid" "github.com/prysmaticlabs/prysm/v5/cmd/validator/flags" "github.com/prysmaticlabs/prysm/v5/config/params" @@ -27,6 +26,7 @@ import ( constant "github.com/prysmaticlabs/prysm/v5/validator/testing" "github.com/urfave/cli/v2" keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + "go.uber.org/mock/gomock" ) const ( diff --git a/validator/client/aggregate_test.go b/validator/client/aggregate_test.go index a66e5bc39307..683f48523454 100644 --- a/validator/client/aggregate_test.go +++ b/validator/client/aggregate_test.go @@ -7,7 +7,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/validator/client/iface" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/go-bitfield" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" @@ -20,6 +19,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/time" "github.com/prysmaticlabs/prysm/v5/time/slots" logTest "github.com/sirupsen/logrus/hooks/test" + "go.uber.org/mock/gomock" ) func TestSubmitAggregateAndProof_GetDutiesRequestFailure(t *testing.T) { diff --git a/validator/client/attest_protect_test.go b/validator/client/attest_protect_test.go index 4334110925ac..46b7620c664b 100644 --- a/validator/client/attest_protect_test.go +++ b/validator/client/attest_protect_test.go @@ -4,12 +4,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" + "go.uber.org/mock/gomock" ) func Test_slashableAttestationCheck(t *testing.T) { diff --git a/validator/client/attest_test.go b/validator/client/attest_test.go index d6213b4d9de1..bb1cb86067ed 100644 --- a/validator/client/attest_test.go +++ b/validator/client/attest_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/go-bitfield" "github.com/prysmaticlabs/prysm/v5/async/event" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/signing" @@ -25,6 +24,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/util" prysmTime "github.com/prysmaticlabs/prysm/v5/time" logTest "github.com/sirupsen/logrus/hooks/test" + "go.uber.org/mock/gomock" "gopkg.in/d4l3k/messagediff.v1" ) diff --git a/validator/client/beacon-api/BUILD.bazel b/validator/client/beacon-api/BUILD.bazel index 6c91f07f84a1..642dc838bd9d 100644 --- a/validator/client/beacon-api/BUILD.bazel +++ b/validator/client/beacon-api/BUILD.bazel @@ -137,5 +137,6 @@ go_test( "@com_github_sirupsen_logrus//hooks/test:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/validator/client/beacon-api/activation_test.go b/validator/client/beacon-api/activation_test.go index a4247f6a6439..604eb8e3d977 100644 --- a/validator/client/beacon-api/activation_test.go +++ b/validator/client/beacon-api/activation_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/config/params" @@ -16,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestComputeWaitElements_LastRecvTimeZero(t *testing.T) { diff --git a/validator/client/beacon-api/attestation_data_test.go b/validator/client/beacon-api/attestation_data_test.go index 939c3e447a88..ef3e212da501 100644 --- a/validator/client/beacon-api/attestation_data_test.go +++ b/validator/client/beacon-api/attestation_data_test.go @@ -8,12 +8,12 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestGetAttestationData_ValidAttestation(t *testing.T) { diff --git a/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go b/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go index dcb70283f3f6..3ed8dbe476be 100644 --- a/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go +++ b/validator/client/beacon-api/beacon_api_beacon_chain_client_test.go @@ -11,7 +11,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" @@ -20,6 +19,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/time/slots" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/validator/client/beacon-api/beacon_api_helpers_test.go b/validator/client/beacon-api/beacon_api_helpers_test.go index b5bacadd3da7..622d7e498c72 100644 --- a/validator/client/beacon-api/beacon_api_helpers_test.go +++ b/validator/client/beacon-api/beacon_api_helpers_test.go @@ -8,12 +8,12 @@ import ( "net/url" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestBeaconApiHelpers(t *testing.T) { diff --git a/validator/client/beacon-api/beacon_api_node_client_test.go b/validator/client/beacon-api/beacon_api_node_client_test.go index b705f8cd6142..16c9f39715f3 100644 --- a/validator/client/beacon-api/beacon_api_node_client_test.go +++ b/validator/client/beacon-api/beacon_api_node_client_test.go @@ -6,11 +6,11 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/timestamppb" ) diff --git a/validator/client/beacon-api/beacon_api_validator_client_test.go b/validator/client/beacon-api/beacon_api_validator_client_test.go index 39d5e56b4415..433685deadcc 100644 --- a/validator/client/beacon-api/beacon_api_validator_client_test.go +++ b/validator/client/beacon-api/beacon_api_validator_client_test.go @@ -6,9 +6,9 @@ import ( "fmt" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" + "go.uber.org/mock/gomock" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/prysmaticlabs/prysm/v5/config/params" diff --git a/validator/client/beacon-api/beacon_committee_selections_test.go b/validator/client/beacon-api/beacon_committee_selections_test.go index dd076fc9103f..d1f942a8487e 100644 --- a/validator/client/beacon-api/beacon_committee_selections_test.go +++ b/validator/client/beacon-api/beacon_committee_selections_test.go @@ -8,11 +8,11 @@ import ( "github.com/prysmaticlabs/prysm/v5/validator/client/iface" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestGetAggregatedSelections(t *testing.T) { diff --git a/validator/client/beacon-api/domain_data_test.go b/validator/client/beacon-api/domain_data_test.go index 0188e617a841..827955a39dd9 100644 --- a/validator/client/beacon-api/domain_data_test.go +++ b/validator/client/beacon-api/domain_data_test.go @@ -6,13 +6,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/config/params" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestGetDomainData_ValidDomainData(t *testing.T) { diff --git a/validator/client/beacon-api/doppelganger_test.go b/validator/client/beacon-api/doppelganger_test.go index 726e11be7ccf..a433007dac74 100644 --- a/validator/client/beacon-api/doppelganger_test.go +++ b/validator/client/beacon-api/doppelganger_test.go @@ -7,13 +7,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestCheckDoppelGanger_Nominal(t *testing.T) { diff --git a/validator/client/beacon-api/duties_test.go b/validator/client/beacon-api/duties_test.go index a4e86f08a976..a52382352e74 100644 --- a/validator/client/beacon-api/duties_test.go +++ b/validator/client/beacon-api/duties_test.go @@ -14,13 +14,13 @@ import ( "github.com/prysmaticlabs/prysm/v5/validator/client/iface" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) const getAttesterDutiesTestEndpoint = "/eth/v1/validator/duties/attester" diff --git a/validator/client/beacon-api/genesis_test.go b/validator/client/beacon-api/genesis_test.go index 6fa7e11174d0..4eca109f44b9 100644 --- a/validator/client/beacon-api/genesis_test.go +++ b/validator/client/beacon-api/genesis_test.go @@ -4,11 +4,11 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestGetGenesis_ValidGenesis(t *testing.T) { diff --git a/validator/client/beacon-api/get_beacon_block_test.go b/validator/client/beacon-api/get_beacon_block_test.go index 947021396942..cce3e2ae3c1e 100644 --- a/validator/client/beacon-api/get_beacon_block_test.go +++ b/validator/client/beacon-api/get_beacon_block_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/network/httputil" @@ -18,6 +17,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestGetBeaconBlock_RequestFailed(t *testing.T) { diff --git a/validator/client/beacon-api/index_test.go b/validator/client/beacon-api/index_test.go index 171d86e2493c..326abb811f9a 100644 --- a/validator/client/beacon-api/index_test.go +++ b/validator/client/beacon-api/index_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" @@ -16,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) const stringPubKey = "0x8000091c2ae64ee414a54c1cc1fc67dec663408bc636cb86756e0200e41a75c8f86603f104f02c856983d2783116be13" diff --git a/validator/client/beacon-api/prepare_beacon_proposer_test.go b/validator/client/beacon-api/prepare_beacon_proposer_test.go index e977ba75ef1b..82c006b2f7e0 100644 --- a/validator/client/beacon-api/prepare_beacon_proposer_test.go +++ b/validator/client/beacon-api/prepare_beacon_proposer_test.go @@ -7,13 +7,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) const prepareBeaconProposerTestEndpoint = "/eth/v1/validator/prepare_beacon_proposer" diff --git a/validator/client/beacon-api/propose_attestation_test.go b/validator/client/beacon-api/propose_attestation_test.go index 2d6ab788f257..90c844327877 100644 --- a/validator/client/beacon-api/propose_attestation_test.go +++ b/validator/client/beacon-api/propose_attestation_test.go @@ -7,12 +7,12 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestProposeAttestation(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_altair_test.go b/validator/client/beacon-api/propose_beacon_block_altair_test.go index ed0adf40a8fd..82a68d24c030 100644 --- a/validator/client/beacon-api/propose_beacon_block_altair_test.go +++ b/validator/client/beacon-api/propose_beacon_block_altair_test.go @@ -7,13 +7,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_Altair(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go b/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go index b3a028297ca8..c5fa61ba3428 100644 --- a/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go +++ b/validator/client/beacon-api/propose_beacon_block_bellatrix_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -15,6 +14,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_Bellatrix(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go b/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go index 59ed64e18cb3..8465ae065ba4 100644 --- a/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go +++ b/validator/client/beacon-api/propose_beacon_block_blinded_bellatrix_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" @@ -16,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_BlindedBellatrix(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go b/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go index d8aefab1d8ab..092fb75d3804 100644 --- a/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go +++ b/validator/client/beacon-api/propose_beacon_block_blinded_capella_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" @@ -16,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_BlindedCapella(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go b/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go index 30e088e6371e..1e583901a156 100644 --- a/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go +++ b/validator/client/beacon-api/propose_beacon_block_blinded_deneb_test.go @@ -6,12 +6,12 @@ import ( "encoding/json" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" rpctesting "github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared/testing" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_BlindedDeneb(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_capella_test.go b/validator/client/beacon-api/propose_beacon_block_capella_test.go index b3a6935444da..3f6dadb54459 100644 --- a/validator/client/beacon-api/propose_beacon_block_capella_test.go +++ b/validator/client/beacon-api/propose_beacon_block_capella_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -15,6 +14,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_Capella(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_deneb_test.go b/validator/client/beacon-api/propose_beacon_block_deneb_test.go index 4985768e5c88..f2f2bf14bf6e 100644 --- a/validator/client/beacon-api/propose_beacon_block_deneb_test.go +++ b/validator/client/beacon-api/propose_beacon_block_deneb_test.go @@ -6,12 +6,12 @@ import ( "encoding/json" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" rpctesting "github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared/testing" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_Deneb(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_phase0_test.go b/validator/client/beacon-api/propose_beacon_block_phase0_test.go index 6bef5498f396..dd8ef8bf89c9 100644 --- a/validator/client/beacon-api/propose_beacon_block_phase0_test.go +++ b/validator/client/beacon-api/propose_beacon_block_phase0_test.go @@ -7,13 +7,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_Phase0(t *testing.T) { diff --git a/validator/client/beacon-api/propose_beacon_block_test.go b/validator/client/beacon-api/propose_beacon_block_test.go index 02f625b86173..a1ed400d9f38 100644 --- a/validator/client/beacon-api/propose_beacon_block_test.go +++ b/validator/client/beacon-api/propose_beacon_block_test.go @@ -6,11 +6,11 @@ import ( "net/http" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/network/httputil" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestProposeBeaconBlock_Error(t *testing.T) { diff --git a/validator/client/beacon-api/propose_exit_test.go b/validator/client/beacon-api/propose_exit_test.go index e7b3caa0393b..be3dc50709c6 100644 --- a/validator/client/beacon-api/propose_exit_test.go +++ b/validator/client/beacon-api/propose_exit_test.go @@ -7,13 +7,13 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) const proposeExitTestEndpoint = "/eth/v1/beacon/pool/voluntary_exits" diff --git a/validator/client/beacon-api/registration_test.go b/validator/client/beacon-api/registration_test.go index 558adf807bf4..ed04a9ab7905 100644 --- a/validator/client/beacon-api/registration_test.go +++ b/validator/client/beacon-api/registration_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" @@ -15,6 +14,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestRegistration_Valid(t *testing.T) { diff --git a/validator/client/beacon-api/state_validators_test.go b/validator/client/beacon-api/state_validators_test.go index d91ebbda6c0f..c5d223716c44 100644 --- a/validator/client/beacon-api/state_validators_test.go +++ b/validator/client/beacon-api/state_validators_test.go @@ -7,13 +7,13 @@ import ( "net/url" "testing" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestGetStateValidators_Nominal_POST(t *testing.T) { diff --git a/validator/client/beacon-api/status_test.go b/validator/client/beacon-api/status_test.go index 21b6f54b28bf..23310a0d616f 100644 --- a/validator/client/beacon-api/status_test.go +++ b/validator/client/beacon-api/status_test.go @@ -10,13 +10,13 @@ import ( "github.com/prysmaticlabs/prysm/v5/validator/client/iface" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestValidatorStatus_Nominal(t *testing.T) { diff --git a/validator/client/beacon-api/stream_blocks_test.go b/validator/client/beacon-api/stream_blocks_test.go index a3d7475f74c7..3111c28a3d8c 100644 --- a/validator/client/beacon-api/stream_blocks_test.go +++ b/validator/client/beacon-api/stream_blocks_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" rpctesting "github.com/prysmaticlabs/prysm/v5/beacon-chain/rpc/eth/shared/testing" @@ -17,6 +16,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestStreamBlocks_UnsupportedConsensusVersion(t *testing.T) { diff --git a/validator/client/beacon-api/submit_aggregate_selection_proof_test.go b/validator/client/beacon-api/submit_aggregate_selection_proof_test.go index 91ae6ec8711d..26adfa6fc458 100644 --- a/validator/client/beacon-api/submit_aggregate_selection_proof_test.go +++ b/validator/client/beacon-api/submit_aggregate_selection_proof_test.go @@ -10,7 +10,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -19,6 +18,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/time/slots" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestSubmitAggregateSelectionProof(t *testing.T) { diff --git a/validator/client/beacon-api/submit_signed_aggregate_proof_test.go b/validator/client/beacon-api/submit_signed_aggregate_proof_test.go index 30b9ebc008f4..f717febf4346 100644 --- a/validator/client/beacon-api/submit_signed_aggregate_proof_test.go +++ b/validator/client/beacon-api/submit_signed_aggregate_proof_test.go @@ -6,7 +6,6 @@ import ( "encoding/json" "testing" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -14,6 +13,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" test_helpers "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/test-helpers" + "go.uber.org/mock/gomock" ) func TestSubmitSignedAggregateSelectionProof_Valid(t *testing.T) { diff --git a/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go b/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go index 0dfc851a28e5..00920f63c78b 100644 --- a/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go +++ b/validator/client/beacon-api/submit_signed_contribution_and_proof_test.go @@ -8,12 +8,12 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) const submitSignedContributionAndProofTestEndpoint = "/eth/v1/validator/contribution_and_proofs" diff --git a/validator/client/beacon-api/subscribe_committee_subnets_test.go b/validator/client/beacon-api/subscribe_committee_subnets_test.go index a8e8fea5e513..a6f412f60a38 100644 --- a/validator/client/beacon-api/subscribe_committee_subnets_test.go +++ b/validator/client/beacon-api/subscribe_committee_subnets_test.go @@ -8,7 +8,6 @@ import ( "strconv" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -16,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/time/slots" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) const subscribeCommitteeSubnetsTestEndpoint = "/eth/v1/validator/beacon_committee_subscriptions" diff --git a/validator/client/beacon-api/sync_committee_test.go b/validator/client/beacon-api/sync_committee_test.go index 7464a54dea8e..8888a3c63922 100644 --- a/validator/client/beacon-api/sync_committee_test.go +++ b/validator/client/beacon-api/sync_committee_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/server/structs" @@ -19,6 +18,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/time/slots" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" ) func TestSubmitSyncMessage_Valid(t *testing.T) { diff --git a/validator/client/beacon-api/validator_count_test.go b/validator/client/beacon-api/validator_count_test.go index cbfef22501dc..6ab9fafe62fa 100644 --- a/validator/client/beacon-api/validator_count_test.go +++ b/validator/client/beacon-api/validator_count_test.go @@ -5,12 +5,12 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/consensus-types/validator" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" "github.com/prysmaticlabs/prysm/v5/validator/client/iface" + "go.uber.org/mock/gomock" ) func TestGetValidatorCount(t *testing.T) { diff --git a/validator/client/beacon-api/wait_for_chain_start_test.go b/validator/client/beacon-api/wait_for_chain_start_test.go index 8b434042d987..5395546777a3 100644 --- a/validator/client/beacon-api/wait_for_chain_start_test.go +++ b/validator/client/beacon-api/wait_for_chain_start_test.go @@ -7,12 +7,12 @@ import ( "testing" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api/server/structs" "github.com/prysmaticlabs/prysm/v5/network/httputil" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" "github.com/prysmaticlabs/prysm/v5/validator/client/beacon-api/mock" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/validator/client/grpc-api/grpc_prysm_beacon_chain_client_test.go b/validator/client/grpc-api/grpc_prysm_beacon_chain_client_test.go index de185a989003..dc32f284597c 100644 --- a/validator/client/grpc-api/grpc_prysm_beacon_chain_client_test.go +++ b/validator/client/grpc-api/grpc_prysm_beacon_chain_client_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/consensus-types/validator" @@ -13,6 +12,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/util" mock "github.com/prysmaticlabs/prysm/v5/testing/validator-mock" "github.com/prysmaticlabs/prysm/v5/validator/client/iface" + "go.uber.org/mock/gomock" ) func TestGetValidatorCount(t *testing.T) { diff --git a/validator/client/grpc-api/grpc_validator_client_test.go b/validator/client/grpc-api/grpc_validator_client_test.go index 58e5e6af1002..d8710180f8fe 100644 --- a/validator/client/grpc-api/grpc_validator_client_test.go +++ b/validator/client/grpc-api/grpc_validator_client_test.go @@ -5,9 +5,9 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/testing/assert" mock2 "github.com/prysmaticlabs/prysm/v5/testing/mock" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/validator/client/key_reload_test.go b/validator/client/key_reload_test.go index 574dfaffb8df..82e7b5b723f2 100644 --- a/validator/client/key_reload_test.go +++ b/validator/client/key_reload_test.go @@ -7,7 +7,6 @@ import ( validator2 "github.com/prysmaticlabs/prysm/v5/consensus-types/validator" "github.com/prysmaticlabs/prysm/v5/validator/client/iface" - "github.com/golang/mock/gomock" "github.com/pkg/errors" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -16,6 +15,7 @@ import ( validatormock "github.com/prysmaticlabs/prysm/v5/testing/validator-mock" "github.com/prysmaticlabs/prysm/v5/validator/client/testutil" logTest "github.com/sirupsen/logrus/hooks/test" + "go.uber.org/mock/gomock" ) func TestValidator_HandleKeyReload(t *testing.T) { diff --git a/validator/client/propose_test.go b/validator/client/propose_test.go index 41471a99c1c2..03454a2b9c30 100644 --- a/validator/client/propose_test.go +++ b/validator/client/propose_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/signing" lruwrpr "github.com/prysmaticlabs/prysm/v5/cache/lru" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" @@ -28,6 +27,7 @@ import ( testing2 "github.com/prysmaticlabs/prysm/v5/validator/db/testing" "github.com/prysmaticlabs/prysm/v5/validator/graffiti" logTest "github.com/sirupsen/logrus/hooks/test" + "go.uber.org/mock/gomock" ) type mocks struct { diff --git a/validator/client/registration_test.go b/validator/client/registration_test.go index 3eecec9d3f77..e667a208b571 100644 --- a/validator/client/registration_test.go +++ b/validator/client/registration_test.go @@ -6,7 +6,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/pkg/errors" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" @@ -14,6 +13,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" + "go.uber.org/mock/gomock" ) func TestSubmitValidatorRegistrations(t *testing.T) { diff --git a/validator/client/sync_committee_test.go b/validator/client/sync_committee_test.go index cab575b68018..2dc0fe1817ce 100644 --- a/validator/client/sync_committee_test.go +++ b/validator/client/sync_committee_test.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "testing" - "github.com/golang/mock/gomock" "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" @@ -16,6 +15,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" logTest "github.com/sirupsen/logrus/hooks/test" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index e6eea7be184f..adcca25b9a18 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -13,7 +13,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/golang/protobuf/ptypes/empty" "github.com/prysmaticlabs/prysm/v5/async/event" "github.com/prysmaticlabs/prysm/v5/config/features" @@ -40,6 +39,7 @@ import ( remoteweb3signer "github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer" "github.com/sirupsen/logrus" logTest "github.com/sirupsen/logrus/hooks/test" + "go.uber.org/mock/gomock" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" diff --git a/validator/client/wait_for_activation_test.go b/validator/client/wait_for_activation_test.go index d1f30b532f3f..6d6a8d22eefa 100644 --- a/validator/client/wait_for_activation_test.go +++ b/validator/client/wait_for_activation_test.go @@ -11,7 +11,6 @@ import ( validatorType "github.com/prysmaticlabs/prysm/v5/consensus-types/validator" "github.com/prysmaticlabs/prysm/v5/validator/client/iface" - "github.com/golang/mock/gomock" "github.com/pkg/errors" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -26,6 +25,7 @@ import ( mock2 "github.com/stretchr/testify/mock" "github.com/tyler-smith/go-bip39" util "github.com/wealdtech/go-eth2-util" + "go.uber.org/mock/gomock" ) func TestWaitActivation_ContextCanceled(t *testing.T) { diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index 7b946dbfa72a..d67464cd1fbd 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -151,5 +151,6 @@ go_test( "@org_golang_google_grpc//metadata:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/validator/rpc/handlers_accounts_test.go b/validator/rpc/handlers_accounts_test.go index aa2abe4ed936..99779bf70038 100644 --- a/validator/rpc/handlers_accounts_test.go +++ b/validator/rpc/handlers_accounts_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/prysmaticlabs/prysm/v5/api" "github.com/prysmaticlabs/prysm/v5/cmd/validator/flags" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -29,6 +28,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/validator/keymanager" "github.com/prysmaticlabs/prysm/v5/validator/keymanager/derived" constant "github.com/prysmaticlabs/prysm/v5/validator/testing" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/timestamppb" ) diff --git a/validator/rpc/handlers_beacon_test.go b/validator/rpc/handlers_beacon_test.go index 40fa44f0712d..d9f17653bac3 100644 --- a/validator/rpc/handlers_beacon_test.go +++ b/validator/rpc/handlers_beacon_test.go @@ -9,12 +9,12 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/assert" "github.com/prysmaticlabs/prysm/v5/testing/require" validatormock "github.com/prysmaticlabs/prysm/v5/testing/validator-mock" + "go.uber.org/mock/gomock" "google.golang.org/protobuf/types/known/timestamppb" ) diff --git a/validator/rpc/handlers_health_test.go b/validator/rpc/handlers_health_test.go index d4a26560a264..4a6e22ec2cfe 100644 --- a/validator/rpc/handlers_health_test.go +++ b/validator/rpc/handlers_health_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/golang/protobuf/ptypes/empty" "github.com/prysmaticlabs/prysm/v5/api" "github.com/prysmaticlabs/prysm/v5/io/logs/mock" @@ -17,6 +16,7 @@ import ( pb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v5/testing/require" validatormock "github.com/prysmaticlabs/prysm/v5/testing/validator-mock" + "go.uber.org/mock/gomock" "google.golang.org/grpc" ) diff --git a/validator/rpc/handlers_keymanager_test.go b/validator/rpc/handlers_keymanager_test.go index 26f977218e56..7aa0d97bd6f7 100644 --- a/validator/rpc/handlers_keymanager_test.go +++ b/validator/rpc/handlers_keymanager_test.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/mock/gomock" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" @@ -37,6 +36,7 @@ import ( remoteweb3signer "github.com/prysmaticlabs/prysm/v5/validator/keymanager/remote-web3signer" "github.com/prysmaticlabs/prysm/v5/validator/slashing-protection-history/format" mocks "github.com/prysmaticlabs/prysm/v5/validator/testing" + "go.uber.org/mock/gomock" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/timestamppb" From e531899d3cf2129bd1a84665a9a9fe0651269766 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 16:06:14 -0800 Subject: [PATCH 10/39] Gaz --- cmd/BUILD.bazel | 2 +- cmd/validator/accounts/BUILD.bazel | 2 +- validator/accounts/BUILD.bazel | 2 +- validator/client/BUILD.bazel | 2 +- validator/client/beacon-api/BUILD.bazel | 1 - validator/client/grpc-api/BUILD.bazel | 2 +- validator/rpc/BUILD.bazel | 1 - 7 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/BUILD.bazel b/cmd/BUILD.bazel index 879747489391..d3dad8fe4bfe 100644 --- a/cmd/BUILD.bazel +++ b/cmd/BUILD.bazel @@ -38,8 +38,8 @@ go_test( "//config/params:go_default_library", "//testing/assert:go_default_library", "//testing/require:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/cmd/validator/accounts/BUILD.bazel b/cmd/validator/accounts/BUILD.bazel index d17fe2dbdaa7..e9b072c623f5 100644 --- a/cmd/validator/accounts/BUILD.bazel +++ b/cmd/validator/accounts/BUILD.bazel @@ -69,11 +69,11 @@ go_test( "//validator/node:go_default_library", "//validator/testing:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_google_uuid//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", "@com_github_wealdtech_go_eth2_wallet_encryptor_keystorev4//:go_default_library", "@org_golang_google_protobuf//types/known/timestamppb:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/validator/accounts/BUILD.bazel b/validator/accounts/BUILD.bazel index 059a30feab8b..4bb846318154 100644 --- a/validator/accounts/BUILD.bazel +++ b/validator/accounts/BUILD.bazel @@ -91,11 +91,11 @@ go_test( "//validator/keymanager/local:go_default_library", "//validator/testing:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_google_uuid//:go_default_library", "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", "@com_github_urfave_cli_v2//:go_default_library", "@com_github_wealdtech_go_eth2_wallet_encryptor_keystorev4//:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 8a7e5a167894..b1d281754924 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -161,7 +161,6 @@ go_test( "//validator/testing:go_default_library", "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_golang_protobuf//ptypes/empty", "@com_github_pkg_errors//:go_default_library", "@com_github_prysmaticlabs_go_bitfield//:go_default_library", @@ -176,5 +175,6 @@ go_test( "@org_golang_google_grpc//metadata:go_default_library", "@org_golang_google_grpc//status:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/validator/client/beacon-api/BUILD.bazel b/validator/client/beacon-api/BUILD.bazel index 642dc838bd9d..f7d1b6a57ebf 100644 --- a/validator/client/beacon-api/BUILD.bazel +++ b/validator/client/beacon-api/BUILD.bazel @@ -131,7 +131,6 @@ go_test( "//validator/client/beacon-api/test-helpers:go_default_library", "//validator/client/iface:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_golang_protobuf//ptypes/empty", "@com_github_pkg_errors//:go_default_library", "@com_github_sirupsen_logrus//hooks/test:go_default_library", diff --git a/validator/client/grpc-api/BUILD.bazel b/validator/client/grpc-api/BUILD.bazel index 2c16cacce0f3..254a49aceb17 100644 --- a/validator/client/grpc-api/BUILD.bazel +++ b/validator/client/grpc-api/BUILD.bazel @@ -43,7 +43,7 @@ go_test( "//testing/util:go_default_library", "//testing/validator-mock:go_default_library", "//validator/client/iface:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@org_golang_google_protobuf//types/known/emptypb:go_default_library", + "@org_uber_go_mock//gomock:go_default_library", ], ) diff --git a/validator/rpc/BUILD.bazel b/validator/rpc/BUILD.bazel index d67464cd1fbd..cd69bec0ca87 100644 --- a/validator/rpc/BUILD.bazel +++ b/validator/rpc/BUILD.bazel @@ -139,7 +139,6 @@ go_test( "@com_github_ethereum_go_ethereum//common:go_default_library", "@com_github_ethereum_go_ethereum//common/hexutil:go_default_library", "@com_github_golang_jwt_jwt_v4//:go_default_library", - "@com_github_golang_mock//gomock:go_default_library", "@com_github_golang_protobuf//ptypes/empty", "@com_github_google_uuid//:go_default_library", "@com_github_gorilla_mux//:go_default_library", From e0bd3042c83fbe2d5f492537b140e0f822489c35 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 16:06:59 -0800 Subject: [PATCH 11/39] Solve interface issues --- validator/client/grpc-api/grpc_validator_client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/validator/client/grpc-api/grpc_validator_client.go b/validator/client/grpc-api/grpc_validator_client.go index 53acda13f836..7ac667ab35c3 100644 --- a/validator/client/grpc-api/grpc_validator_client.go +++ b/validator/client/grpc-api/grpc_validator_client.go @@ -153,3 +153,11 @@ func (c *grpcValidatorClient) StartEventStream(context.Context) error { func (c *grpcValidatorClient) EventStreamIsRunning() bool { panic("function not supported for gRPC client") } + +func (c *grpcValidatorClient) RetrieveHost() string { + panic("function not supported for gRPC client") +} + +func (c *grpcValidatorClient) UpdateHost(_ string) { + panic("function not supported for gRPC client") +} From 5b498ee0556a21bc4284c876f62d32a7688b1c03 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 16:11:25 -0800 Subject: [PATCH 12/39] Fix host --- validator/accounts/cli_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/accounts/cli_manager.go b/validator/accounts/cli_manager.go index 4d7bc81db607..2d28986e1e8b 100644 --- a/validator/accounts/cli_manager.go +++ b/validator/accounts/cli_manager.go @@ -89,7 +89,7 @@ func (acm *CLIManager) prepareBeaconClients(ctx context.Context) (*iface.Validat restHandler := &beaconApi.BeaconApiJsonRestHandler{ HttpClient: http.Client{Timeout: acm.beaconApiTimeout}, - Host: acm.beaconApiEndpoint, + Host: func() string { return acm.beaconApiEndpoint }, } validatorClient := validatorClientFactory.NewValidatorClient(conn, restHandler) nodeClient := nodeClientFactory.NewNodeClient(conn, restHandler) From 0cbe1d2de08e1f71896421ed66e41652c0c981bf Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 16:39:51 -0800 Subject: [PATCH 13/39] Fix test --- validator/client/beacon-api/json_rest_handler.go | 8 ++++---- validator/client/beacon-api/json_rest_handler_test.go | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/validator/client/beacon-api/json_rest_handler.go b/validator/client/beacon-api/json_rest_handler.go index cd9e8e663c3d..5aaa26915cad 100644 --- a/validator/client/beacon-api/json_rest_handler.go +++ b/validator/client/beacon-api/json_rest_handler.go @@ -27,7 +27,7 @@ type BeaconApiJsonRestHandler struct { // Get sends a GET request and decodes the response body as a JSON object into the passed in object. // If an HTTP error is returned, the body is decoded as a DefaultJsonError JSON object and returned as the first return value. -func (c BeaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp interface{}) error { +func (c *BeaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp interface{}) error { url := c.Host() + endpoint req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) @@ -50,7 +50,7 @@ func (c BeaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp // Post sends a POST request and decodes the response body as a JSON object into the passed in object. // If an HTTP error is returned, the body is decoded as a DefaultJsonError JSON object and returned as the first return value. -func (c BeaconApiJsonRestHandler) Post( +func (c *BeaconApiJsonRestHandler) Post( ctx context.Context, apiEndpoint string, headers map[string]string, @@ -119,11 +119,11 @@ func decodeResp(httpResp *http.Response, resp interface{}) error { return nil } -func (c BeaconApiJsonRestHandler) GetHost() string { +func (c *BeaconApiJsonRestHandler) GetHost() string { return c.Host() } -func (c BeaconApiJsonRestHandler) SetHost(newHost string) { +func (c *BeaconApiJsonRestHandler) SetHost(newHost string) { c.Host = func() string { return newHost } diff --git a/validator/client/beacon-api/json_rest_handler_test.go b/validator/client/beacon-api/json_rest_handler_test.go index 3e78cea323e9..6fb666cf78ab 100644 --- a/validator/client/beacon-api/json_rest_handler_test.go +++ b/validator/client/beacon-api/json_rest_handler_test.go @@ -223,8 +223,9 @@ func Test_Host(t *testing.T) { servers := []string{"127.0.0.1:0", "127.0.0.2:0"} jsonRestHandler := BeaconApiJsonRestHandler{ HttpClient: http.Client{Timeout: time.Second * 5}, - Host: func() string { return servers[0] }, + Host: func() string { return "" }, } + jsonRestHandler.SetHost(servers[0]) host := jsonRestHandler.GetHost() require.Equal(t, servers[0], host) From 622e0329b3eee4034c7d850caac7c665c728bd24 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 20 Feb 2024 18:10:03 -0800 Subject: [PATCH 14/39] Add tests --- .../beacon_api_validator_client_test.go | 29 +++++++++++++++++++ validator/client/validator_test.go | 24 +++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/validator/client/beacon-api/beacon_api_validator_client_test.go b/validator/client/beacon-api/beacon_api_validator_client_test.go index 433685deadcc..d73bd079fa7d 100644 --- a/validator/client/beacon-api/beacon_api_validator_client_test.go +++ b/validator/client/beacon-api/beacon_api_validator_client_test.go @@ -208,3 +208,32 @@ func TestBeaconApiValidatorClient_ProposeBeaconBlockError(t *testing.T) { assert.ErrorContains(t, expectedErr.Error(), err) assert.DeepEqual(t, expectedResp, resp) } + +func TestBeaconApiValidatorClient_Host(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + hosts := []string{"http://localhost:8080", "http://localhost:8081"} + jsonRestHandler := mock.NewMockJsonRestHandler(ctrl) + jsonRestHandler.EXPECT().SetHost( + hosts[0], + ).Times(1) + jsonRestHandler.EXPECT().GetHost().Return( + hosts[0], + ).Times(1) + + validatorClient := beaconApiValidatorClient{jsonRestHandler: jsonRestHandler} + validatorClient.UpdateHost(hosts[0]) + host := validatorClient.RetrieveHost() + require.Equal(t, hosts[0], host) + + jsonRestHandler.EXPECT().SetHost( + hosts[1], + ).Times(1) + jsonRestHandler.EXPECT().GetHost().Return( + hosts[1], + ).Times(1) + validatorClient.UpdateHost(hosts[1]) + host = validatorClient.RetrieveHost() + require.Equal(t, hosts[1], host) +} diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index adcca25b9a18..b407e97f92a0 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -2506,3 +2506,27 @@ func TestValidator_buildSignedRegReqs_TimestampBeforeGenesis(t *testing.T) { actual := v.buildSignedRegReqs(ctx, pubkeys, signer) assert.Equal(t, 0, len(actual)) } + +func TestValidator_Host(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + hosts := []string{"http://localhost:8080", "http://localhost:8081"} + client := validatormock.NewMockValidatorClient(ctrl) + v := validator{ + validatorClient: client, + } + client.EXPECT().UpdateHost(hosts[0]).Times(1) + client.EXPECT().RetrieveHost().Return(hosts[0]).Times(1) + + v.validatorClient.UpdateHost(hosts[0]) + host := v.validatorClient.RetrieveHost() + require.Equal(t, hosts[0], host) + + client.EXPECT().UpdateHost(hosts[1]).Times(1) + client.EXPECT().RetrieveHost().Return(hosts[1]).Times(1) + + v.validatorClient.UpdateHost(hosts[1]) + host = v.validatorClient.RetrieveHost() + require.Equal(t, hosts[1], host) +} From 275b106dd93b7030f9c6a0bf8507c39e8573aba4 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Wed, 21 Feb 2024 16:25:20 -0800 Subject: [PATCH 15/39] Add endpoint change log --- validator/client/service.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/validator/client/service.go b/validator/client/service.go index 9389ea559bd7..e3c5dde59180 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -195,7 +195,8 @@ func (v *ValidatorService) Start() { return } - urls := strings.Split(v.conn.GetBeaconApiUrl(), ",") + u := strings.Replace(v.conn.GetBeaconApiUrl(), " ", "", -1) + urls := strings.Split(u, ",") restHandler := &beaconApi.BeaconApiJsonRestHandler{ HttpClient: http.Client{Timeout: v.conn.GetBeaconApiTimeout()}, Host: func() string { @@ -379,6 +380,7 @@ func runNodeSwitcherRoutine(ctx context.Context, v iface.Validator, endpoints [] for i, url := range endpoints { if url == v.RetrieveHost() { next := (i + 1) % len(endpoints) + log.Info("Beacon node at %s is not responding, switching to %s", url, endpoints[next]) v.UpdateHost(endpoints[next]) } } From de49ead8a6d761e6c7686d6abf3afcd7439c83ae Mon Sep 17 00:00:00 2001 From: Saolyn Date: Thu, 22 Feb 2024 11:50:08 -0800 Subject: [PATCH 16/39] Fix log --- validator/client/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/client/service.go b/validator/client/service.go index e3c5dde59180..e27f6117b368 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -380,7 +380,7 @@ func runNodeSwitcherRoutine(ctx context.Context, v iface.Validator, endpoints [] for i, url := range endpoints { if url == v.RetrieveHost() { next := (i + 1) % len(endpoints) - log.Info("Beacon node at %s is not responding, switching to %s", url, endpoints[next]) + log.Infof("Beacon node at %s is not responding, switching to %s", url, endpoints[next]) v.UpdateHost(endpoints[next]) } } From 7436737134e34d10f61848d87730591bdb829da4 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Thu, 21 Mar 2024 17:53:16 +0100 Subject: [PATCH 17/39] Gen mock --- testing/mock/node_service_mock.go | 20 ++++++++ testing/validator-mock/node_client_mock.go | 20 +++----- .../beacon-api/mock/json_rest_handler_mock.go | 46 ++++++++++++++++--- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/testing/mock/node_service_mock.go b/testing/mock/node_service_mock.go index 57a0cde054f6..72f268f582b4 100644 --- a/testing/mock/node_service_mock.go +++ b/testing/mock/node_service_mock.go @@ -82,6 +82,26 @@ func (mr *MockNodeClientMockRecorder) GetGenesis(arg0, arg1 any, arg2 ...any) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGenesis", reflect.TypeOf((*MockNodeClient)(nil).GetGenesis), varargs...) } +// GetHealth mocks base method. +func (m *MockNodeClient) GetHealth(arg0 context.Context, arg1 *eth.HealthRequest, arg2 ...grpc.CallOption) (*emptypb.Empty, error) { + m.ctrl.T.Helper() + varargs := []any{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetHealth", varargs...) + ret0, _ := ret[0].(*emptypb.Empty) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetHealth indicates an expected call of GetHealth. +func (mr *MockNodeClientMockRecorder) GetHealth(arg0, arg1 any, arg2 ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHealth", reflect.TypeOf((*MockNodeClient)(nil).GetHealth), varargs...) +} + // GetHost mocks base method. func (m *MockNodeClient) GetHost(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc.CallOption) (*eth.HostData, error) { m.ctrl.T.Helper() diff --git a/testing/validator-mock/node_client_mock.go b/testing/validator-mock/node_client_mock.go index 8f6250cd86e3..eabcd32e6b40 100644 --- a/testing/validator-mock/node_client_mock.go +++ b/testing/validator-mock/node_client_mock.go @@ -23,7 +23,6 @@ import ( type MockNodeClient struct { ctrl *gomock.Controller recorder *MockNodeClientMockRecorder - healthTracker *beacon.NodeHealthTracker } // MockNodeClientMockRecorder is the mock recorder for MockNodeClient. @@ -35,7 +34,6 @@ type MockNodeClientMockRecorder struct { func NewMockNodeClient(ctrl *gomock.Controller) *MockNodeClient { mock := &MockNodeClient{ctrl: ctrl} mock.recorder = &MockNodeClientMockRecorder{mock} - mock.healthTracker = beacon.NewNodeHealthTracker(mock) return mock } @@ -89,18 +87,18 @@ func (mr *MockNodeClientMockRecorder) GetVersion(arg0, arg1 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersion", reflect.TypeOf((*MockNodeClient)(nil).GetVersion), arg0, arg1) } -// IsHealthy mocks base method. -func (m *MockNodeClient) IsHealthy(arg0 context.Context) bool { +// HealthTracker mocks base method. +func (m *MockNodeClient) HealthTracker() *beacon.NodeHealthTracker { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsHealthy", arg0) - ret0, _ := ret[0].(bool) + ret := m.ctrl.Call(m, "HealthTracker") + ret0, _ := ret[0].(*beacon.NodeHealthTracker) return ret0 } -// IsHealthy indicates an expected call of IsHealthy. -func (mr *MockNodeClientMockRecorder) IsHealthy(arg0 any) *gomock.Call { +// HealthTracker indicates an expected call of HealthTracker. +func (mr *MockNodeClientMockRecorder) HealthTracker() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsHealthy", reflect.TypeOf((*MockNodeClient)(nil).IsHealthy), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealthTracker", reflect.TypeOf((*MockNodeClient)(nil).HealthTracker)) } // ListPeers mocks base method. @@ -117,7 +115,3 @@ func (mr *MockNodeClientMockRecorder) ListPeers(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPeers", reflect.TypeOf((*MockNodeClient)(nil).ListPeers), arg0, arg1) } - -func (m *MockNodeClient) HealthTracker() *beacon.NodeHealthTracker { - return m.healthTracker -} diff --git a/validator/client/beacon-api/mock/json_rest_handler_mock.go b/validator/client/beacon-api/mock/json_rest_handler_mock.go index b79df47828b9..b0faae298ead 100644 --- a/validator/client/beacon-api/mock/json_rest_handler_mock.go +++ b/validator/client/beacon-api/mock/json_rest_handler_mock.go @@ -36,17 +36,21 @@ func NewMockJsonRestHandler(ctrl *gomock.Controller) *MockJsonRestHandler { return mock } -func (mr *MockJsonRestHandler) HttpClient() *http.Client { - return nil +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockJsonRestHandler) EXPECT() *MockJsonRestHandlerMockRecorder { + return m.recorder } -func (mr *MockJsonRestHandler) Host() string { - return "" +// ChangeHost mocks base method. +func (m *MockJsonRestHandler) ChangeHost(newHost string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "ChangeHost", newHost) } -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockJsonRestHandler) EXPECT() *MockJsonRestHandlerMockRecorder { - return m.recorder +// ChangeHost indicates an expected call of ChangeHost. +func (mr *MockJsonRestHandlerMockRecorder) ChangeHost(newHost any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeHost", reflect.TypeOf((*MockJsonRestHandler)(nil).ChangeHost), newHost) } // Get mocks base method. @@ -63,6 +67,34 @@ func (mr *MockJsonRestHandlerMockRecorder) Get(ctx, endpoint, resp any) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockJsonRestHandler)(nil).Get), ctx, endpoint, resp) } +// Host mocks base method. +func (m *MockJsonRestHandler) Host() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Host") + ret0, _ := ret[0].(string) + return ret0 +} + +// Host indicates an expected call of Host. +func (mr *MockJsonRestHandlerMockRecorder) Host() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Host", reflect.TypeOf((*MockJsonRestHandler)(nil).Host)) +} + +// HttpClient mocks base method. +func (m *MockJsonRestHandler) HttpClient() *http.Client { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HttpClient") + ret0, _ := ret[0].(*http.Client) + return ret0 +} + +// HttpClient indicates an expected call of HttpClient. +func (mr *MockJsonRestHandlerMockRecorder) HttpClient() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HttpClient", reflect.TypeOf((*MockJsonRestHandler)(nil).HttpClient)) +} + // Post mocks base method. func (m *MockJsonRestHandler) Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp any) error { m.ctrl.T.Helper() From f0c5481cdd4c5dd7ceb9bddb66fd1230d03d610c Mon Sep 17 00:00:00 2001 From: Saolyn Date: Thu, 21 Mar 2024 17:59:47 +0100 Subject: [PATCH 18/39] Fix test --- .../client/beacon-api/beacon_api_validator_client_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/validator/client/beacon-api/beacon_api_validator_client_test.go b/validator/client/beacon-api/beacon_api_validator_client_test.go index 4031a318eac5..dcf1db527cc0 100644 --- a/validator/client/beacon-api/beacon_api_validator_client_test.go +++ b/validator/client/beacon-api/beacon_api_validator_client_test.go @@ -209,10 +209,10 @@ func TestBeaconApiValidatorClient_Host(t *testing.T) { hosts := []string{"http://localhost:8080", "http://localhost:8081"} jsonRestHandler := mock.NewMockJsonRestHandler(ctrl) - jsonRestHandler.EXPECT().SetHost( + jsonRestHandler.EXPECT().ChangeHost( hosts[0], ).Times(1) - jsonRestHandler.EXPECT().GetHost().Return( + jsonRestHandler.EXPECT().Host().Return( hosts[0], ).Times(1) @@ -221,10 +221,10 @@ func TestBeaconApiValidatorClient_Host(t *testing.T) { host := validatorClient.RetrieveHost() require.Equal(t, hosts[0], host) - jsonRestHandler.EXPECT().SetHost( + jsonRestHandler.EXPECT().ChangeHost( hosts[1], ).Times(1) - jsonRestHandler.EXPECT().GetHost().Return( + jsonRestHandler.EXPECT().Host().Return( hosts[1], ).Times(1) validatorClient.UpdateHost(hosts[1]) From 70cb837c5e3d2df103b7a3f1df3ef2661ca36cdf Mon Sep 17 00:00:00 2001 From: Saolyn Date: Thu, 21 Mar 2024 18:37:36 +0100 Subject: [PATCH 19/39] Fix deepsource --- validator/accounts/testing/mock.go | 4 ++-- .../client/grpc-api/grpc_validator_client.go | 12 +++++++----- validator/client/service.go | 2 +- validator/client/testutil/mock_validator.go | 16 ++++++++-------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/validator/accounts/testing/mock.go b/validator/accounts/testing/mock.go index 2a2606f991dd..106b87b53f54 100644 --- a/validator/accounts/testing/mock.go +++ b/validator/accounts/testing/mock.go @@ -250,10 +250,10 @@ func (*Validator) HealthTracker() *beacon.NodeHealthTracker { panic("implement me") } -func (_ *Validator) RetrieveHost() string { +func (*Validator) RetrieveHost() string { panic("implement me") } -func (_ *Validator) UpdateHost(host string) { +func (*Validator) UpdateHost(_ string) { panic("implement me") } diff --git a/validator/client/grpc-api/grpc_validator_client.go b/validator/client/grpc-api/grpc_validator_client.go index 59681a7944d2..fc4a4e046f8b 100644 --- a/validator/client/grpc-api/grpc_validator_client.go +++ b/validator/client/grpc-api/grpc_validator_client.go @@ -142,11 +142,11 @@ func (c *grpcValidatorClient) AggregatedSigAndAggregationBits( return c.beaconNodeValidatorClient.AggregatedSigAndAggregationBits(ctx, in) } -func (grpcValidatorClient) GetAggregatedSelections(context.Context, []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) { +func (*grpcValidatorClient) GetAggregatedSelections(context.Context, []iface.BeaconCommitteeSelection) ([]iface.BeaconCommitteeSelection, error) { return nil, iface.ErrNotSupported } -func (grpcValidatorClient) GetAggregatedSyncSelections(context.Context, []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) { +func (*grpcValidatorClient) GetAggregatedSyncSelections(context.Context, []iface.SyncCommitteeSelection) ([]iface.SyncCommitteeSelection, error) { return nil, iface.ErrNotSupported } @@ -246,10 +246,12 @@ func (c *grpcValidatorClient) EventStreamIsRunning() bool { return c.isEventStreamRunning } -func (c *grpcValidatorClient) RetrieveHost() string { - panic("function not supported for gRPC client") +func (*grpcValidatorClient) RetrieveHost() string { + log.Warn(iface.ErrNotSupported) + return "" } func (c *grpcValidatorClient) UpdateHost(_ string) { - panic("function not supported for gRPC client") + log.Warn(iface.ErrNotSupported) + return } diff --git a/validator/client/service.go b/validator/client/service.go index 190bcb1d75fe..1c2aef3a48bf 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -195,7 +195,7 @@ func (v *ValidatorService) Start() { return } - u := strings.Replace(v.conn.GetBeaconApiUrl(), " ", "", -1) + u := strings.ReplaceAll(v.conn.GetBeaconApiUrl(), " ", "") urls := strings.Split(u, ",") restHandler := beaconApi.NewBeaconApiJsonRestHandler( http.Client{Timeout: v.conn.GetBeaconApiTimeout()}, diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index 50ef4c58b959..746121a288b4 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -284,19 +284,19 @@ func (fv *FakeValidator) SetProposerSettings(_ context.Context, settings *propos } // GetGraffiti for mocking -func (f *FakeValidator) GetGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) ([]byte, error) { - return []byte(f.graffiti), nil +func (fv *FakeValidator) GetGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) ([]byte, error) { + return []byte(fv.graffiti), nil } // SetGraffiti for mocking -func (f *FakeValidator) SetGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte, graffiti []byte) error { - f.graffiti = string(graffiti) +func (fv *FakeValidator) SetGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte, graffiti []byte) error { + fv.graffiti = string(graffiti) return nil } // DeleteGraffiti for mocking -func (f *FakeValidator) DeleteGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) error { - f.graffiti = "" +func (fv *FakeValidator) DeleteGraffiti(_ context.Context, _ [fieldparams.BLSPubkeyLength]byte) error { + fv.graffiti = "" return nil } @@ -314,8 +314,8 @@ func (fv *FakeValidator) HealthTracker() *beacon.NodeHealthTracker { return fv.Tracker } -func (fv *FakeValidator) RetrieveHost() string { +func (*FakeValidator) RetrieveHost() string { return "127.0.0.1:0" } -func (fv *FakeValidator) UpdateHost(host string) {} +func (*FakeValidator) UpdateHost(host string) {} From 23476db36481623295a6858b9c4fcb458232e7f1 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Fri, 22 Mar 2024 10:42:40 +0100 Subject: [PATCH 20/39] Lint + deepsource --- validator/client/grpc-api/grpc_validator_client.go | 3 +-- validator/client/testutil/mock_validator.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/validator/client/grpc-api/grpc_validator_client.go b/validator/client/grpc-api/grpc_validator_client.go index fc4a4e046f8b..340a5c2f925e 100644 --- a/validator/client/grpc-api/grpc_validator_client.go +++ b/validator/client/grpc-api/grpc_validator_client.go @@ -251,7 +251,6 @@ func (*grpcValidatorClient) RetrieveHost() string { return "" } -func (c *grpcValidatorClient) UpdateHost(_ string) { +func (*grpcValidatorClient) UpdateHost(_ string) { log.Warn(iface.ErrNotSupported) - return } diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index 746121a288b4..99f06e7a47ae 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -318,4 +318,4 @@ func (*FakeValidator) RetrieveHost() string { return "127.0.0.1:0" } -func (*FakeValidator) UpdateHost(host string) {} +func (*FakeValidator) UpdateHost(_ string) {} From c8bcaa8014c75506dc4eeb66660067b1a035164b Mon Sep 17 00:00:00 2001 From: Saolyn Date: Wed, 3 Apr 2024 17:38:58 +0200 Subject: [PATCH 21/39] Move to healthCheckRoutine --- validator/client/runner.go | 32 ++++++++++++++++++++++++++--- validator/client/runner_test.go | 26 ++++++++++++------------ validator/client/service.go | 36 ++++----------------------------- 3 files changed, 46 insertions(+), 48 deletions(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index 71a7a4729f35..7d9cb62a3815 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -33,7 +33,7 @@ var backOffPeriod = 10 * time.Second // 4 - Update assignments // 5 - Determine role at current slot // 6 - Perform assigned role, if any -func run(ctx context.Context, v iface.Validator) { +func run(ctx context.Context, v iface.Validator, hosts []string) { cleanup := v.Done defer cleanup() @@ -46,7 +46,7 @@ func run(ctx context.Context, v iface.Validator) { } eventsChan := make(chan *event.Event, 1) healthTracker := v.HealthTracker() - runHealthCheckRoutine(ctx, v, eventsChan) + runHealthCheckRoutine(ctx, v, eventsChan, hosts) accountsChangedChan := make(chan [][fieldparams.BLSPubkeyLength]byte, 1) km, err := v.Keymanager() @@ -293,7 +293,7 @@ func handleAssignmentError(err error, slot primitives.Slot) { } } -func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan chan<- *event.Event) { +func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan chan<- *event.Event, hosts []string) { log.Info("Starting health check routine for beacon node apis") healthCheckTicker := time.NewTicker(time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second) tracker := v.HealthTracker() @@ -305,6 +305,32 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch return } isHealthy := tracker.CheckHealth(ctx) + for !isHealthy { + cSlot, err := v.CanonicalHeadSlot(ctx) + if err != nil { + log.WithError(err).Error("Could not get canonical head slot") + } + nSlot := <-v.NextSlot() + for { + if cSlot == nSlot { + for i, url := range hosts { + if url == v.RetrieveHost() { + next := (i + 1) % len(hosts) + log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) + v.UpdateHost(hosts[next]) + v.ProposerSettings() + } + } + break + } + time.Sleep(time.Second) + cSlot, err = v.CanonicalHeadSlot(ctx) + if err != nil { + log.WithError(err).Error("Could not get canonical head slot") + } + } + isHealthy = v.HealthTracker().CheckHealth(ctx) + } // in case of node returning healthy but event stream died if isHealthy && !v.EventStreamIsRunning() { log.Info("Event stream reconnecting...") diff --git a/validator/client/runner_test.go b/validator/client/runner_test.go index b617cb033f5c..b4e657a7f7dc 100644 --- a/validator/client/runner_test.go +++ b/validator/client/runner_test.go @@ -38,7 +38,7 @@ func TestCancelledContext_CleansUpValidator(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v) + run(cancelledContext(), v, "") assert.Equal(t, true, v.DoneCalled, "Expected Done() to be called") } @@ -51,7 +51,7 @@ func TestCancelledContext_WaitsForChainStart(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v) + run(cancelledContext(), v, "") assert.Equal(t, 1, v.WaitForChainStartCalled, "Expected WaitForChainStart() to be called") } @@ -69,7 +69,7 @@ func TestRetry_On_ConnectionError(t *testing.T) { } backOffPeriod = 10 * time.Millisecond ctx, cancel := context.WithCancel(context.Background()) - go run(ctx, v) + go run(ctx, v, "") // each step will fail (retry times)=10 this sleep times will wait more then // the time it takes for all steps to succeed before main loop. time.Sleep(time.Duration(retry*6) * backOffPeriod) @@ -90,7 +90,7 @@ func TestCancelledContext_WaitsForActivation(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v) + run(cancelledContext(), v, "") assert.Equal(t, 1, v.WaitForActivationCalled, "Expected WaitForActivation() to be called") } @@ -114,7 +114,7 @@ func TestUpdateDuties_NextSlot(t *testing.T) { cancel() }() - run(ctx, v) + run(ctx, v, "") require.Equal(t, true, v.UpdateDutiesCalled, "Expected UpdateAssignments(%d) to be called", slot) assert.Equal(t, uint64(slot), v.UpdateDutiesArg1, "UpdateAssignments was called with wrong argument") @@ -142,7 +142,7 @@ func TestUpdateDuties_HandlesError(t *testing.T) { }() v.UpdateDutiesRet = errors.New("bad") - run(ctx, v) + run(ctx, v, "") require.LogsContain(t, hook, "Failed to update assignments") } @@ -167,7 +167,7 @@ func TestRoleAt_NextSlot(t *testing.T) { cancel() }() - run(ctx, v) + run(ctx, v, "") require.Equal(t, true, v.RoleAtCalled, "Expected RoleAt(%d) to be called", slot) assert.Equal(t, uint64(slot), v.RoleAtArg1, "RoleAt called with the wrong arg") @@ -194,7 +194,7 @@ func TestAttests_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v) + run(ctx, v, "") <-timer.C require.Equal(t, true, v.AttestToBlockHeadCalled, "SubmitAttestation(%d) was not called", slot) assert.Equal(t, uint64(slot), v.AttestToBlockHeadArg1, "SubmitAttestation was called with wrong arg") @@ -221,7 +221,7 @@ func TestProposes_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v) + run(ctx, v, "") <-timer.C require.Equal(t, true, v.ProposeBlockCalled, "ProposeBlock(%d) was not called", slot) assert.Equal(t, uint64(slot), v.ProposeBlockArg1, "ProposeBlock was called with wrong arg") @@ -248,7 +248,7 @@ func TestBothProposesAndAttests_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v) + run(ctx, v, "") <-timer.C require.Equal(t, true, v.AttestToBlockHeadCalled, "SubmitAttestation(%d) was not called", slot) assert.Equal(t, uint64(slot), v.AttestToBlockHeadArg1, "SubmitAttestation was called with wrong arg") @@ -330,7 +330,7 @@ func TestUpdateProposerSettingsAt_EpochStart(t *testing.T) { cancel() }() - run(ctx, v) + run(ctx, v, "") assert.LogsContain(t, hook, "updated proposer settings") } @@ -363,7 +363,7 @@ func TestUpdateProposerSettingsAt_EpochEndOk(t *testing.T) { cancel() }() - run(ctx, v) + run(ctx, v, "") // can't test "Failed to update proposer settings" because of log.fatal assert.LogsContain(t, hook, "Mock updated proposer settings") } @@ -398,6 +398,6 @@ func TestUpdateProposerSettings_ContinuesAfterValidatorRegistrationFails(t *test cancel() }() - run(ctx, v) + run(ctx, v, "") assert.LogsContain(t, hook, ErrBuilderValidatorRegistration.Error()) } diff --git a/validator/client/service.go b/validator/client/service.go index 1c2aef3a48bf..d31e25e0f7fd 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -196,17 +196,16 @@ func (v *ValidatorService) Start() { } u := strings.ReplaceAll(v.conn.GetBeaconApiUrl(), " ", "") - urls := strings.Split(u, ",") + hosts := strings.Split(u, ",") restHandler := beaconApi.NewBeaconApiJsonRestHandler( http.Client{Timeout: v.conn.GetBeaconApiTimeout()}, func() string { - return urls[0] + return hosts[0] }, ) validatorClient := validatorClientFactory.NewValidatorClient(v.conn, restHandler) - if len(urls) > 1 && features.Get().EnableBeaconRESTApi { - runNodeSwitcherRoutine(v.ctx, v.validator, urls) + if len(hosts) > 1 && features.Get().EnableBeaconRESTApi { } valStruct := &validator{ @@ -245,7 +244,7 @@ func (v *ValidatorService) Start() { } v.validator = valStruct - go run(v.ctx, v.validator) + go run(v.ctx, v.validator, hosts) } // Stop the validator service. @@ -387,30 +386,3 @@ func (v *ValidatorService) DeleteGraffiti(ctx context.Context, pubKey [fieldpara } return v.validator.DeleteGraffiti(ctx, pubKey) } - -func runNodeSwitcherRoutine(ctx context.Context, v iface.Validator, endpoints []string) { - healthCheckTicker := time.NewTicker(time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second) - go func() { - for { - select { - case <-healthCheckTicker.C: - healthTracker := v.HealthTracker() - if !healthTracker.IsHealthy() { - for i, url := range endpoints { - if url == v.RetrieveHost() { - next := (i + 1) % len(endpoints) - log.Infof("Beacon node at %s is not responding, switching to %s", url, endpoints[next]) - v.UpdateHost(endpoints[next]) - } - } - } - case <-ctx.Done(): - if ctx.Err() != nil { - log.WithError(ctx.Err()).Error("Context cancelled") - } - log.Error("Context cancelled") - return - } - } - }() -} From db506e5ea4ee9c3974ab2b3bed6c362f02c2d84a Mon Sep 17 00:00:00 2001 From: Saolyn Date: Mon, 22 Apr 2024 13:16:11 +0200 Subject: [PATCH 22/39] Fix build errors --- validator/client/runner_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/validator/client/runner_test.go b/validator/client/runner_test.go index b4e657a7f7dc..1f45cdf2991a 100644 --- a/validator/client/runner_test.go +++ b/validator/client/runner_test.go @@ -38,7 +38,7 @@ func TestCancelledContext_CleansUpValidator(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v, "") + run(cancelledContext(), v, []string{"http://localhost:8081"}) assert.Equal(t, true, v.DoneCalled, "Expected Done() to be called") } @@ -51,7 +51,7 @@ func TestCancelledContext_WaitsForChainStart(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v, "") + run(cancelledContext(), v, []string{"http://localhost:8081"}) assert.Equal(t, 1, v.WaitForChainStartCalled, "Expected WaitForChainStart() to be called") } @@ -69,7 +69,7 @@ func TestRetry_On_ConnectionError(t *testing.T) { } backOffPeriod = 10 * time.Millisecond ctx, cancel := context.WithCancel(context.Background()) - go run(ctx, v, "") + go run(ctx, v, []string{"http://localhost:8081"}) // each step will fail (retry times)=10 this sleep times will wait more then // the time it takes for all steps to succeed before main loop. time.Sleep(time.Duration(retry*6) * backOffPeriod) @@ -90,7 +90,7 @@ func TestCancelledContext_WaitsForActivation(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v, "") + run(cancelledContext(), v, []string{"http://localhost:8081"}) assert.Equal(t, 1, v.WaitForActivationCalled, "Expected WaitForActivation() to be called") } @@ -114,7 +114,7 @@ func TestUpdateDuties_NextSlot(t *testing.T) { cancel() }() - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) require.Equal(t, true, v.UpdateDutiesCalled, "Expected UpdateAssignments(%d) to be called", slot) assert.Equal(t, uint64(slot), v.UpdateDutiesArg1, "UpdateAssignments was called with wrong argument") @@ -142,7 +142,7 @@ func TestUpdateDuties_HandlesError(t *testing.T) { }() v.UpdateDutiesRet = errors.New("bad") - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) require.LogsContain(t, hook, "Failed to update assignments") } @@ -167,7 +167,7 @@ func TestRoleAt_NextSlot(t *testing.T) { cancel() }() - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) require.Equal(t, true, v.RoleAtCalled, "Expected RoleAt(%d) to be called", slot) assert.Equal(t, uint64(slot), v.RoleAtArg1, "RoleAt called with the wrong arg") @@ -194,7 +194,7 @@ func TestAttests_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) <-timer.C require.Equal(t, true, v.AttestToBlockHeadCalled, "SubmitAttestation(%d) was not called", slot) assert.Equal(t, uint64(slot), v.AttestToBlockHeadArg1, "SubmitAttestation was called with wrong arg") @@ -221,7 +221,7 @@ func TestProposes_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) <-timer.C require.Equal(t, true, v.ProposeBlockCalled, "ProposeBlock(%d) was not called", slot) assert.Equal(t, uint64(slot), v.ProposeBlockArg1, "ProposeBlock was called with wrong arg") @@ -248,7 +248,7 @@ func TestBothProposesAndAttests_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) <-timer.C require.Equal(t, true, v.AttestToBlockHeadCalled, "SubmitAttestation(%d) was not called", slot) assert.Equal(t, uint64(slot), v.AttestToBlockHeadArg1, "SubmitAttestation was called with wrong arg") @@ -330,7 +330,7 @@ func TestUpdateProposerSettingsAt_EpochStart(t *testing.T) { cancel() }() - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) assert.LogsContain(t, hook, "updated proposer settings") } @@ -363,7 +363,7 @@ func TestUpdateProposerSettingsAt_EpochEndOk(t *testing.T) { cancel() }() - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) // can't test "Failed to update proposer settings" because of log.fatal assert.LogsContain(t, hook, "Mock updated proposer settings") } @@ -398,6 +398,6 @@ func TestUpdateProposerSettings_ContinuesAfterValidatorRegistrationFails(t *test cancel() }() - run(ctx, v, "") + run(ctx, v, []string{"http://localhost:8081"}) assert.LogsContain(t, hook, ErrBuilderValidatorRegistration.Error()) } From 836cbaa7eb53f11e389952f6fdb72b68440e9c81 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Mon, 22 Apr 2024 13:21:45 +0200 Subject: [PATCH 23/39] Switch host to string --- .../client/beacon-api/json_rest_handler.go | 14 +++--- .../beacon-api/json_rest_handler_test.go | 8 +--- validator/client/runner.go | 46 ++++++++++--------- validator/client/service.go | 7 +-- 4 files changed, 34 insertions(+), 41 deletions(-) diff --git a/validator/client/beacon-api/json_rest_handler.go b/validator/client/beacon-api/json_rest_handler.go index 37dac35630a6..5442881329f1 100644 --- a/validator/client/beacon-api/json_rest_handler.go +++ b/validator/client/beacon-api/json_rest_handler.go @@ -23,11 +23,11 @@ type JsonRestHandler interface { type BeaconApiJsonRestHandler struct { client http.Client - host func() string + host string } // NewBeaconApiJsonRestHandler returns a JsonRestHandler -func NewBeaconApiJsonRestHandler(client http.Client, host func() string) JsonRestHandler { +func NewBeaconApiJsonRestHandler(client http.Client, host string) JsonRestHandler { return &BeaconApiJsonRestHandler{ client: client, host: host, @@ -41,13 +41,13 @@ func (c *BeaconApiJsonRestHandler) HttpClient() *http.Client { // Host returns the underlying HTTP host func (c *BeaconApiJsonRestHandler) Host() string { - return c.host() + return c.host } // Get sends a GET request and decodes the response body as a JSON object into the passed in object. // If an HTTP error is returned, the body is decoded as a DefaultJsonError JSON object and returned as the first return value. func (c *BeaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp interface{}) error { - url := c.host() + endpoint + url := c.host + endpoint req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -79,7 +79,7 @@ func (c *BeaconApiJsonRestHandler) Post( return errors.New("data is nil") } - url := c.host() + apiEndpoint + url := c.host + apiEndpoint req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, data) if err != nil { return errors.Wrapf(err, "failed to create request for endpoint %s", url) @@ -137,7 +137,5 @@ func decodeResp(httpResp *http.Response, resp interface{}) error { } func (c *BeaconApiJsonRestHandler) ChangeHost(newHost string) { - c.host = func() string { - return newHost - } + c.host = newHost } diff --git a/validator/client/beacon-api/json_rest_handler_test.go b/validator/client/beacon-api/json_rest_handler_test.go index d840726bef8e..d28729eee652 100644 --- a/validator/client/beacon-api/json_rest_handler_test.go +++ b/validator/client/beacon-api/json_rest_handler_test.go @@ -42,9 +42,7 @@ func TestGet(t *testing.T) { jsonRestHandler := BeaconApiJsonRestHandler{ client: http.Client{Timeout: time.Second * 5}, - host: func() string { - return server.URL - }, + host: server.URL, } resp := &structs.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Get(ctx, endpoint+"?arg1=abc&arg2=def", resp)) @@ -90,9 +88,7 @@ func TestPost(t *testing.T) { jsonRestHandler := BeaconApiJsonRestHandler{ client: http.Client{Timeout: time.Second * 5}, - host: func() string { - return server.URL - }, + host: server.URL, } resp := &structs.GetGenesisResponse{} require.NoError(t, jsonRestHandler.Post(ctx, endpoint, headers, bytes.NewBuffer(dataBytes), resp)) diff --git a/validator/client/runner.go b/validator/client/runner.go index 7d9cb62a3815..9cd71cbe67d7 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -9,6 +9,7 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/api/client" "github.com/prysmaticlabs/prysm/v5/api/client/event" + "github.com/prysmaticlabs/prysm/v5/config/features" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" @@ -305,32 +306,35 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch return } isHealthy := tracker.CheckHealth(ctx) - for !isHealthy { - cSlot, err := v.CanonicalHeadSlot(ctx) - if err != nil { - log.WithError(err).Error("Could not get canonical head slot") - } - nSlot := <-v.NextSlot() - for { - if cSlot == nSlot { - for i, url := range hosts { - if url == v.RetrieveHost() { - next := (i + 1) % len(hosts) - log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) - v.UpdateHost(hosts[next]) - v.ProposerSettings() - } - } - break - } - time.Sleep(time.Second) - cSlot, err = v.CanonicalHeadSlot(ctx) + if len(hosts) > 1 && features.Get().EnableBeaconRESTApi { + for !isHealthy { + cSlot, err := v.CanonicalHeadSlot(ctx) if err != nil { log.WithError(err).Error("Could not get canonical head slot") } + nSlot := <-v.NextSlot() + for { + if cSlot == nSlot { + for i, url := range hosts { + if url == v.RetrieveHost() { + next := (i + 1) % len(hosts) + log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) + v.UpdateHost(hosts[next]) + v.ProposerSettings() + } + } + break + } + time.Sleep(time.Second) + cSlot, err = v.CanonicalHeadSlot(ctx) + if err != nil { + log.WithError(err).Error("Could not get canonical head slot") + } + } + isHealthy = v.HealthTracker().CheckHealth(ctx) } - isHealthy = v.HealthTracker().CheckHealth(ctx) } + // in case of node returning healthy but event stream died if isHealthy && !v.EventStreamIsRunning() { log.Info("Event stream reconnecting...") diff --git a/validator/client/service.go b/validator/client/service.go index d31e25e0f7fd..1e62f50057a9 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -15,7 +15,6 @@ import ( grpcutil "github.com/prysmaticlabs/prysm/v5/api/grpc" "github.com/prysmaticlabs/prysm/v5/async/event" lruwrpr "github.com/prysmaticlabs/prysm/v5/cache/lru" - "github.com/prysmaticlabs/prysm/v5/config/features" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/config/proposer" @@ -199,14 +198,10 @@ func (v *ValidatorService) Start() { hosts := strings.Split(u, ",") restHandler := beaconApi.NewBeaconApiJsonRestHandler( http.Client{Timeout: v.conn.GetBeaconApiTimeout()}, - func() string { - return hosts[0] - }, + hosts[0], ) validatorClient := validatorClientFactory.NewValidatorClient(v.conn, restHandler) - if len(hosts) > 1 && features.Get().EnableBeaconRESTApi { - } valStruct := &validator{ validatorClient: validatorClient, From ad070af548ac33532103a5f0cc878808cf594f7f Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 23 Apr 2024 13:28:13 +0200 Subject: [PATCH 24/39] Forgot a couple --- validator/accounts/cli_manager.go | 4 +--- validator/rpc/beacon.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/validator/accounts/cli_manager.go b/validator/accounts/cli_manager.go index 452955009a6e..3f0116e3c65a 100644 --- a/validator/accounts/cli_manager.go +++ b/validator/accounts/cli_manager.go @@ -89,9 +89,7 @@ func (acm *CLIManager) prepareBeaconClients(ctx context.Context) (*iface.Validat restHandler := beaconApi.NewBeaconApiJsonRestHandler( http.Client{Timeout: acm.beaconApiTimeout}, - func() string { - return acm.beaconApiEndpoint - }, + acm.beaconApiEndpoint, ) validatorClient := validatorClientFactory.NewValidatorClient(conn, restHandler) nodeClient := nodeClientFactory.NewNodeClient(conn, restHandler) diff --git a/validator/rpc/beacon.go b/validator/rpc/beacon.go index 5eb30454a276..c1f986e8c8c0 100644 --- a/validator/rpc/beacon.go +++ b/validator/rpc/beacon.go @@ -56,9 +56,7 @@ func (s *Server) registerBeaconClient() error { restHandler := beaconApi.NewBeaconApiJsonRestHandler( http.Client{Timeout: s.beaconApiTimeout}, - func() string { - return s.beaconApiEndpoint - }, + s.beaconApiEndpoint, ) s.beaconChainClient = beaconChainClientFactory.NewBeaconChainClient(conn, restHandler) From 991ccfef69eb2352b00282588da3aab7732199f2 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 23 Apr 2024 16:17:20 +0200 Subject: [PATCH 25/39] Radek' review --- validator/client/runner.go | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index 9cd71cbe67d7..7723ce2ce892 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -306,32 +306,28 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch return } isHealthy := tracker.CheckHealth(ctx) - if len(hosts) > 1 && features.Get().EnableBeaconRESTApi { - for !isHealthy { - cSlot, err := v.CanonicalHeadSlot(ctx) - if err != nil { - log.WithError(err).Error("Could not get canonical head slot") - } - nSlot := <-v.NextSlot() - for { - if cSlot == nSlot { - for i, url := range hosts { - if url == v.RetrieveHost() { - next := (i + 1) % len(hosts) - log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) - v.UpdateHost(hosts[next]) - v.ProposerSettings() - } - } - break + if !isHealthy && len(hosts) > 1 && features.Get().EnableBeaconRESTApi { + for i, url := range hosts { + if url == v.RetrieveHost() { + next := (i + 1) % len(hosts) + log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) + v.UpdateHost(hosts[next]) + km, err := v.Keymanager() + if err != nil { + log.WithError(err).Fatal("Could not get keymanager") + return } - time.Sleep(time.Second) - cSlot, err = v.CanonicalHeadSlot(ctx) + slot, err := v.CanonicalHeadSlot(ctx) if err != nil { log.WithError(err).Error("Could not get canonical head slot") + return + } + err = v.PushProposerSettings(ctx, km, slot, time.Now().Add(5*time.Minute)) + if err != nil { + log.WithError(err).Error("Could not push proposer settings") + return } } - isHealthy = v.HealthTracker().CheckHealth(ctx) } } From 1f9aebf9a8a09930e29ea962ed26c9a077138744 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Tue, 23 Apr 2024 16:36:53 +0200 Subject: [PATCH 26/39] Add PushProposerSettings to goroutine --- validator/client/runner.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index 7723ce2ce892..3e5ff969c8c7 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -312,21 +312,23 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch next := (i + 1) % len(hosts) log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) v.UpdateHost(hosts[next]) + km, err := v.Keymanager() if err != nil { log.WithError(err).Fatal("Could not get keymanager") - return } slot, err := v.CanonicalHeadSlot(ctx) if err != nil { log.WithError(err).Error("Could not get canonical head slot") return } - err = v.PushProposerSettings(ctx, km, slot, time.Now().Add(5*time.Minute)) - if err != nil { - log.WithError(err).Error("Could not push proposer settings") - return - } + go func() { + // deadline set for 1 epoch from call to not overlap. + epochDeadline := v.SlotDeadline(slot + params.BeaconConfig().SlotsPerEpoch - 1) + if err := v.PushProposerSettings(ctx, km, slot, epochDeadline); err != nil { + log.WithError(err).Warn("Failed to update proposer settings") + } + }() } } } From 11c56441db6e11a7c20fdd630ab765384d7da399 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Wed, 24 Apr 2024 11:35:30 +0200 Subject: [PATCH 27/39] Radek' review --- .../validator-mock/validator_client_mock.go | 52 +++++++++---------- validator/accounts/testing/mock.go | 4 +- .../beacon-api/beacon_api_validator_client.go | 4 +- .../beacon_api_validator_client_test.go | 8 +-- .../client/grpc-api/grpc_validator_client.go | 4 +- validator/client/iface/validator.go | 4 +- validator/client/iface/validator_client.go | 4 +- validator/client/runner.go | 4 +- validator/client/service.go | 4 ++ validator/client/testutil/mock_validator.go | 4 +- validator/client/validator.go | 8 +-- validator/client/validator_test.go | 8 +-- 12 files changed, 56 insertions(+), 52 deletions(-) diff --git a/testing/validator-mock/validator_client_mock.go b/testing/validator-mock/validator_client_mock.go index 602785412b74..e3fed68f596d 100644 --- a/testing/validator-mock/validator_client_mock.go +++ b/testing/validator-mock/validator_client_mock.go @@ -44,6 +44,18 @@ func (m *MockValidatorClient) EXPECT() *MockValidatorClientMockRecorder { return m.recorder } +// ChangeHost mocks base method. +func (m *MockValidatorClient) ChangeHost(arg0 string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "ChangeHost", arg0) +} + +// ChangeHost indicates an expected call of ChangeHost. +func (mr *MockValidatorClientMockRecorder) ChangeHost(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeHost", reflect.TypeOf((*MockValidatorClient)(nil).ChangeHost), arg0) +} + // CheckDoppelGanger mocks base method. func (m *MockValidatorClient) CheckDoppelGanger(arg0 context.Context, arg1 *eth.DoppelGangerRequest) (*eth.DoppelGangerResponse, error) { m.ctrl.T.Helper() @@ -223,6 +235,20 @@ func (mr *MockValidatorClientMockRecorder) GetSyncSubcommitteeIndex(arg0, arg1 a return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSyncSubcommitteeIndex", reflect.TypeOf((*MockValidatorClient)(nil).GetSyncSubcommitteeIndex), arg0, arg1) } +// Host mocks base method. +func (m *MockValidatorClient) Host() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Host") + ret0, _ := ret[0].(string) + return ret0 +} + +// Host indicates an expected call of Host. +func (mr *MockValidatorClientMockRecorder) Host() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Host", reflect.TypeOf((*MockValidatorClient)(nil).Host)) +} + // MultipleValidatorStatus mocks base method. func (m *MockValidatorClient) MultipleValidatorStatus(arg0 context.Context, arg1 *eth.MultipleValidatorStatusRequest) (*eth.MultipleValidatorStatusResponse, error) { m.ctrl.T.Helper() @@ -298,20 +324,6 @@ func (mr *MockValidatorClientMockRecorder) ProposeExit(arg0, arg1 any) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeExit", reflect.TypeOf((*MockValidatorClient)(nil).ProposeExit), arg0, arg1) } -// RetrieveHost mocks base method. -func (m *MockValidatorClient) RetrieveHost() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RetrieveHost") - ret0, _ := ret[0].(string) - return ret0 -} - -// RetrieveHost indicates an expected call of RetrieveHost. -func (mr *MockValidatorClientMockRecorder) RetrieveHost() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RetrieveHost", reflect.TypeOf((*MockValidatorClient)(nil).RetrieveHost)) -} - // StartEventStream mocks base method. func (m *MockValidatorClient) StartEventStream(arg0 context.Context, arg1 []string, arg2 chan<- *event.Event) { m.ctrl.T.Helper() @@ -414,18 +426,6 @@ func (mr *MockValidatorClientMockRecorder) SubscribeCommitteeSubnets(arg0, arg1, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeCommitteeSubnets", reflect.TypeOf((*MockValidatorClient)(nil).SubscribeCommitteeSubnets), arg0, arg1, arg2) } -// UpdateHost mocks base method. -func (m *MockValidatorClient) UpdateHost(arg0 string) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "UpdateHost", arg0) -} - -// UpdateHost indicates an expected call of UpdateHost. -func (mr *MockValidatorClientMockRecorder) UpdateHost(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateHost", reflect.TypeOf((*MockValidatorClient)(nil).UpdateHost), arg0) -} - // ValidatorIndex mocks base method. func (m *MockValidatorClient) ValidatorIndex(arg0 context.Context, arg1 *eth.ValidatorIndexRequest) (*eth.ValidatorIndexResponse, error) { m.ctrl.T.Helper() diff --git a/validator/accounts/testing/mock.go b/validator/accounts/testing/mock.go index 106b87b53f54..240febe00145 100644 --- a/validator/accounts/testing/mock.go +++ b/validator/accounts/testing/mock.go @@ -250,10 +250,10 @@ func (*Validator) HealthTracker() *beacon.NodeHealthTracker { panic("implement me") } -func (*Validator) RetrieveHost() string { +func (*Validator) Host() string { panic("implement me") } -func (*Validator) UpdateHost(_ string) { +func (*Validator) ChangeHost(_ string) { panic("implement me") } diff --git a/validator/client/beacon-api/beacon_api_validator_client.go b/validator/client/beacon-api/beacon_api_validator_client.go index e46488575546..c37e9536fc02 100644 --- a/validator/client/beacon-api/beacon_api_validator_client.go +++ b/validator/client/beacon-api/beacon_api_validator_client.go @@ -231,10 +231,10 @@ func wrapInMetrics[Resp any](action string, f func() (Resp, error)) (Resp, error return resp, err } -func (c *beaconApiValidatorClient) RetrieveHost() string { +func (c *beaconApiValidatorClient) Host() string { return c.jsonRestHandler.Host() } -func (c *beaconApiValidatorClient) UpdateHost(host string) { +func (c *beaconApiValidatorClient) ChangeHost(host string) { c.jsonRestHandler.ChangeHost(host) } diff --git a/validator/client/beacon-api/beacon_api_validator_client_test.go b/validator/client/beacon-api/beacon_api_validator_client_test.go index dcf1db527cc0..eae8bd847d33 100644 --- a/validator/client/beacon-api/beacon_api_validator_client_test.go +++ b/validator/client/beacon-api/beacon_api_validator_client_test.go @@ -217,8 +217,8 @@ func TestBeaconApiValidatorClient_Host(t *testing.T) { ).Times(1) validatorClient := beaconApiValidatorClient{jsonRestHandler: jsonRestHandler} - validatorClient.UpdateHost(hosts[0]) - host := validatorClient.RetrieveHost() + validatorClient.ChangeHost(hosts[0]) + host := validatorClient.Host() require.Equal(t, hosts[0], host) jsonRestHandler.EXPECT().ChangeHost( @@ -227,7 +227,7 @@ func TestBeaconApiValidatorClient_Host(t *testing.T) { jsonRestHandler.EXPECT().Host().Return( hosts[1], ).Times(1) - validatorClient.UpdateHost(hosts[1]) - host = validatorClient.RetrieveHost() + validatorClient.ChangeHost(hosts[1]) + host = validatorClient.Host() require.Equal(t, hosts[1], host) } diff --git a/validator/client/grpc-api/grpc_validator_client.go b/validator/client/grpc-api/grpc_validator_client.go index 340a5c2f925e..419a5c9df544 100644 --- a/validator/client/grpc-api/grpc_validator_client.go +++ b/validator/client/grpc-api/grpc_validator_client.go @@ -246,11 +246,11 @@ func (c *grpcValidatorClient) EventStreamIsRunning() bool { return c.isEventStreamRunning } -func (*grpcValidatorClient) RetrieveHost() string { +func (*grpcValidatorClient) Host() string { log.Warn(iface.ErrNotSupported) return "" } -func (*grpcValidatorClient) UpdateHost(_ string) { +func (*grpcValidatorClient) ChangeHost(_ string) { log.Warn(iface.ErrNotSupported) } diff --git a/validator/client/iface/validator.go b/validator/client/iface/validator.go index a600acca8585..e31750c85678 100644 --- a/validator/client/iface/validator.go +++ b/validator/client/iface/validator.go @@ -68,8 +68,8 @@ type Validator interface { SetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, graffiti []byte) error DeleteGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) error HealthTracker() *beacon.NodeHealthTracker - RetrieveHost() string - UpdateHost(host string) + Host() string + ChangeHost(host string) } // SigningFunc interface defines a type for the a function that signs a message diff --git a/validator/client/iface/validator_client.go b/validator/client/iface/validator_client.go index 5ed6f8ad5f7f..c1a01450d8db 100644 --- a/validator/client/iface/validator_client.go +++ b/validator/client/iface/validator_client.go @@ -150,6 +150,6 @@ type ValidatorClient interface { EventStreamIsRunning() bool GetAggregatedSelections(ctx context.Context, selections []BeaconCommitteeSelection) ([]BeaconCommitteeSelection, error) GetAggregatedSyncSelections(ctx context.Context, selections []SyncCommitteeSelection) ([]SyncCommitteeSelection, error) - RetrieveHost() string - UpdateHost(host string) + Host() string + ChangeHost(host string) } diff --git a/validator/client/runner.go b/validator/client/runner.go index 3e5ff969c8c7..f84122d38969 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -308,10 +308,10 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch isHealthy := tracker.CheckHealth(ctx) if !isHealthy && len(hosts) > 1 && features.Get().EnableBeaconRESTApi { for i, url := range hosts { - if url == v.RetrieveHost() { + if url == v.Host() { next := (i + 1) % len(hosts) log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) - v.UpdateHost(hosts[next]) + v.ChangeHost(hosts[next]) km, err := v.Keymanager() if err != nil { diff --git a/validator/client/service.go b/validator/client/service.go index 1e62f50057a9..10be65c30e77 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -196,6 +196,10 @@ func (v *ValidatorService) Start() { u := strings.ReplaceAll(v.conn.GetBeaconApiUrl(), " ", "") hosts := strings.Split(u, ",") + if len(hosts) == 0 { + log.WithError(err).Error("No beacon API hosts provided") + return + } restHandler := beaconApi.NewBeaconApiJsonRestHandler( http.Client{Timeout: v.conn.GetBeaconApiTimeout()}, hosts[0], diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index 99f06e7a47ae..83011f39c938 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -314,8 +314,8 @@ func (fv *FakeValidator) HealthTracker() *beacon.NodeHealthTracker { return fv.Tracker } -func (*FakeValidator) RetrieveHost() string { +func (*FakeValidator) Host() string { return "127.0.0.1:0" } -func (*FakeValidator) UpdateHost(_ string) {} +func (*FakeValidator) ChangeHost(_ string) {} diff --git a/validator/client/validator.go b/validator/client/validator.go index 7fbb6ccce69b..8f318dff3482 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -1107,12 +1107,12 @@ func (v *validator) HealthTracker() *beacon.NodeHealthTracker { return v.nodeClient.HealthTracker() } -func (v *validator) RetrieveHost() string { - return v.validatorClient.RetrieveHost() +func (v *validator) Host() string { + return v.validatorClient.Host() } -func (v *validator) UpdateHost(host string) { - v.validatorClient.UpdateHost(host) +func (v *validator) ChangeHost(host string) { + v.validatorClient.ChangeHost(host) } func (v *validator) filterAndCacheActiveKeys(ctx context.Context, pubkeys [][fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([][fieldparams.BLSPubkeyLength]byte, error) { diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index d976c4cf11c4..95f50c3bc53d 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -2603,14 +2603,14 @@ func TestValidator_Host(t *testing.T) { client.EXPECT().UpdateHost(hosts[0]).Times(1) client.EXPECT().RetrieveHost().Return(hosts[0]).Times(1) - v.validatorClient.UpdateHost(hosts[0]) - host := v.validatorClient.RetrieveHost() + v.validatorClient.ChangeHost(hosts[0]) + host := v.validatorClient.Host() require.Equal(t, hosts[0], host) client.EXPECT().UpdateHost(hosts[1]).Times(1) client.EXPECT().RetrieveHost().Return(hosts[1]).Times(1) - v.validatorClient.UpdateHost(hosts[1]) - host = v.validatorClient.RetrieveHost() + v.validatorClient.ChangeHost(hosts[1]) + host = v.validatorClient.Host() require.Equal(t, hosts[1], host) } From 29cb2914f11b9db6f34e21e2984b77d009e52631 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Wed, 24 Apr 2024 14:32:19 +0200 Subject: [PATCH 28/39] James' review + test fix --- validator/client/iface/validator.go | 1 + validator/client/runner.go | 21 ++++++++--------- validator/client/runner_test.go | 26 ++++++++++----------- validator/client/service.go | 3 ++- validator/client/testutil/mock_validator.go | 4 ++++ validator/client/validator.go | 5 ++++ validator/client/validator_test.go | 8 +++---- 7 files changed, 39 insertions(+), 29 deletions(-) diff --git a/validator/client/iface/validator.go b/validator/client/iface/validator.go index e31750c85678..e3c16477974b 100644 --- a/validator/client/iface/validator.go +++ b/validator/client/iface/validator.go @@ -70,6 +70,7 @@ type Validator interface { HealthTracker() *beacon.NodeHealthTracker Host() string ChangeHost(host string) + AvailableHosts() []string } // SigningFunc interface defines a type for the a function that signs a message diff --git a/validator/client/runner.go b/validator/client/runner.go index f84122d38969..e1823a551cd9 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -34,7 +34,7 @@ var backOffPeriod = 10 * time.Second // 4 - Update assignments // 5 - Determine role at current slot // 6 - Perform assigned role, if any -func run(ctx context.Context, v iface.Validator, hosts []string) { +func run(ctx context.Context, v iface.Validator) { cleanup := v.Done defer cleanup() @@ -47,7 +47,7 @@ func run(ctx context.Context, v iface.Validator, hosts []string) { } eventsChan := make(chan *event.Event, 1) healthTracker := v.HealthTracker() - runHealthCheckRoutine(ctx, v, eventsChan, hosts) + runHealthCheckRoutine(ctx, v, eventsChan) accountsChangedChan := make(chan [][fieldparams.BLSPubkeyLength]byte, 1) km, err := v.Keymanager() @@ -294,7 +294,7 @@ func handleAssignmentError(err error, slot primitives.Slot) { } } -func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan chan<- *event.Event, hosts []string) { +func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan chan<- *event.Event) { log.Info("Starting health check routine for beacon node apis") healthCheckTicker := time.NewTicker(time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second) tracker := v.HealthTracker() @@ -306,6 +306,7 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch return } isHealthy := tracker.CheckHealth(ctx) + hosts := v.AvailableHosts() if !isHealthy && len(hosts) > 1 && features.Get().EnableBeaconRESTApi { for i, url := range hosts { if url == v.Host() { @@ -315,20 +316,18 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch km, err := v.Keymanager() if err != nil { - log.WithError(err).Fatal("Could not get keymanager") + log.WithError(err).Error("Could not get keymanager") + return } slot, err := v.CanonicalHeadSlot(ctx) if err != nil { log.WithError(err).Error("Could not get canonical head slot") return } - go func() { - // deadline set for 1 epoch from call to not overlap. - epochDeadline := v.SlotDeadline(slot + params.BeaconConfig().SlotsPerEpoch - 1) - if err := v.PushProposerSettings(ctx, km, slot, epochDeadline); err != nil { - log.WithError(err).Warn("Failed to update proposer settings") - } - }() + deadline := time.Now().Add(5 * time.Minute) + if err := v.PushProposerSettings(ctx, km, slot, deadline); err != nil { + log.WithError(err).Warn("Failed to update proposer settings") + } } } } diff --git a/validator/client/runner_test.go b/validator/client/runner_test.go index 1f45cdf2991a..b617cb033f5c 100644 --- a/validator/client/runner_test.go +++ b/validator/client/runner_test.go @@ -38,7 +38,7 @@ func TestCancelledContext_CleansUpValidator(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v, []string{"http://localhost:8081"}) + run(cancelledContext(), v) assert.Equal(t, true, v.DoneCalled, "Expected Done() to be called") } @@ -51,7 +51,7 @@ func TestCancelledContext_WaitsForChainStart(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v, []string{"http://localhost:8081"}) + run(cancelledContext(), v) assert.Equal(t, 1, v.WaitForChainStartCalled, "Expected WaitForChainStart() to be called") } @@ -69,7 +69,7 @@ func TestRetry_On_ConnectionError(t *testing.T) { } backOffPeriod = 10 * time.Millisecond ctx, cancel := context.WithCancel(context.Background()) - go run(ctx, v, []string{"http://localhost:8081"}) + go run(ctx, v) // each step will fail (retry times)=10 this sleep times will wait more then // the time it takes for all steps to succeed before main loop. time.Sleep(time.Duration(retry*6) * backOffPeriod) @@ -90,7 +90,7 @@ func TestCancelledContext_WaitsForActivation(t *testing.T) { Km: &mockKeymanager{accountsChangedFeed: &event.Feed{}}, Tracker: tracker, } - run(cancelledContext(), v, []string{"http://localhost:8081"}) + run(cancelledContext(), v) assert.Equal(t, 1, v.WaitForActivationCalled, "Expected WaitForActivation() to be called") } @@ -114,7 +114,7 @@ func TestUpdateDuties_NextSlot(t *testing.T) { cancel() }() - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) require.Equal(t, true, v.UpdateDutiesCalled, "Expected UpdateAssignments(%d) to be called", slot) assert.Equal(t, uint64(slot), v.UpdateDutiesArg1, "UpdateAssignments was called with wrong argument") @@ -142,7 +142,7 @@ func TestUpdateDuties_HandlesError(t *testing.T) { }() v.UpdateDutiesRet = errors.New("bad") - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) require.LogsContain(t, hook, "Failed to update assignments") } @@ -167,7 +167,7 @@ func TestRoleAt_NextSlot(t *testing.T) { cancel() }() - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) require.Equal(t, true, v.RoleAtCalled, "Expected RoleAt(%d) to be called", slot) assert.Equal(t, uint64(slot), v.RoleAtArg1, "RoleAt called with the wrong arg") @@ -194,7 +194,7 @@ func TestAttests_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) <-timer.C require.Equal(t, true, v.AttestToBlockHeadCalled, "SubmitAttestation(%d) was not called", slot) assert.Equal(t, uint64(slot), v.AttestToBlockHeadArg1, "SubmitAttestation was called with wrong arg") @@ -221,7 +221,7 @@ func TestProposes_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) <-timer.C require.Equal(t, true, v.ProposeBlockCalled, "ProposeBlock(%d) was not called", slot) assert.Equal(t, uint64(slot), v.ProposeBlockArg1, "ProposeBlock was called with wrong arg") @@ -248,7 +248,7 @@ func TestBothProposesAndAttests_NextSlot(t *testing.T) { cancel() }() timer := time.NewTimer(200 * time.Millisecond) - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) <-timer.C require.Equal(t, true, v.AttestToBlockHeadCalled, "SubmitAttestation(%d) was not called", slot) assert.Equal(t, uint64(slot), v.AttestToBlockHeadArg1, "SubmitAttestation was called with wrong arg") @@ -330,7 +330,7 @@ func TestUpdateProposerSettingsAt_EpochStart(t *testing.T) { cancel() }() - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) assert.LogsContain(t, hook, "updated proposer settings") } @@ -363,7 +363,7 @@ func TestUpdateProposerSettingsAt_EpochEndOk(t *testing.T) { cancel() }() - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) // can't test "Failed to update proposer settings" because of log.fatal assert.LogsContain(t, hook, "Mock updated proposer settings") } @@ -398,6 +398,6 @@ func TestUpdateProposerSettings_ContinuesAfterValidatorRegistrationFails(t *test cancel() }() - run(ctx, v, []string{"http://localhost:8081"}) + run(ctx, v) assert.LogsContain(t, hook, ErrBuilderValidatorRegistration.Error()) } diff --git a/validator/client/service.go b/validator/client/service.go index 10be65c30e77..21b1b9a3978e 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -240,10 +240,11 @@ func (v *ValidatorService) Start() { validatorsRegBatchSize: v.validatorsRegBatchSize, distributed: v.distributed, attSelections: make(map[attSelectionKey]iface.BeaconCommitteeSelection), + beaconNodeHosts: hosts, } v.validator = valStruct - go run(v.ctx, v.validator, hosts) + go run(v.ctx, v.validator) } // Stop the validator service. diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index 83011f39c938..c141f7de564e 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -319,3 +319,7 @@ func (*FakeValidator) Host() string { } func (*FakeValidator) ChangeHost(_ string) {} + +func (*FakeValidator) AvailableHosts() []string { + return []string{"127.0.0.1:0", "127.0.0.1:1"} +} diff --git a/validator/client/validator.go b/validator/client/validator.go index 8f318dff3482..06344747c18f 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -114,6 +114,7 @@ type validator struct { proposerSettings *proposer.Settings walletInitializedChannel chan *wallet.Wallet validatorsRegBatchSize int + beaconNodeHosts []string } type validatorStatus struct { @@ -1115,6 +1116,10 @@ func (v *validator) ChangeHost(host string) { v.validatorClient.ChangeHost(host) } +func (v *validator) AvailableHosts() []string { + return v.beaconNodeHosts +} + func (v *validator) filterAndCacheActiveKeys(ctx context.Context, pubkeys [][fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([][fieldparams.BLSPubkeyLength]byte, error) { filteredKeys := make([][fieldparams.BLSPubkeyLength]byte, 0) statusRequestKeys := make([][]byte, 0) diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index 95f50c3bc53d..a4489a801b84 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -2600,15 +2600,15 @@ func TestValidator_Host(t *testing.T) { v := validator{ validatorClient: client, } - client.EXPECT().UpdateHost(hosts[0]).Times(1) - client.EXPECT().RetrieveHost().Return(hosts[0]).Times(1) + client.EXPECT().ChangeHost(hosts[0]).Times(1) + client.EXPECT().Host().Return(hosts[0]).Times(1) v.validatorClient.ChangeHost(hosts[0]) host := v.validatorClient.Host() require.Equal(t, hosts[0], host) - client.EXPECT().UpdateHost(hosts[1]).Times(1) - client.EXPECT().RetrieveHost().Return(hosts[1]).Times(1) + client.EXPECT().ChangeHost(hosts[1]).Times(1) + client.EXPECT().Host().Return(hosts[1]).Times(1) v.validatorClient.ChangeHost(hosts[1]) host = v.validatorClient.Host() From 26b1326dc3ad25b283126bb8d05e59dfa7355262 Mon Sep 17 00:00:00 2001 From: Sammy Rosso <15244892+saolyn@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:33:57 +0200 Subject: [PATCH 29/39] Radek' suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Radosław Kapka --- validator/client/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/client/service.go b/validator/client/service.go index 21b1b9a3978e..ec4478f4bade 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -197,7 +197,7 @@ func (v *ValidatorService) Start() { u := strings.ReplaceAll(v.conn.GetBeaconApiUrl(), " ", "") hosts := strings.Split(u, ",") if len(hosts) == 0 { - log.WithError(err).Error("No beacon API hosts provided") + log.WithError(err).Error("No API hosts provided") return } restHandler := beaconApi.NewBeaconApiJsonRestHandler( From be1186f2a18fe73cb89e20f1d1ee68963e6b63b3 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Thu, 25 Apr 2024 11:51:43 +0200 Subject: [PATCH 30/39] Check if new node is healthy --- validator/client/iface/validator.go | 2 +- validator/client/runner.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/validator/client/iface/validator.go b/validator/client/iface/validator.go index e3c16477974b..17ff9c2941a5 100644 --- a/validator/client/iface/validator.go +++ b/validator/client/iface/validator.go @@ -73,5 +73,5 @@ type Validator interface { AvailableHosts() []string } -// SigningFunc interface defines a type for the a function that signs a message +// SigningFunc interface defines a type for the function that signs a message type SigningFunc func(context.Context, *validatorpb.SignRequest) (bls.Signature, error) diff --git a/validator/client/runner.go b/validator/client/runner.go index e1823a551cd9..f0204dad38bb 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -311,9 +311,14 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch for i, url := range hosts { if url == v.Host() { next := (i + 1) % len(hosts) - log.Infof("Beacon node at %s is not responding, switching to %s", url, hosts[next]) + log.Infof("Beacon node API at %s is not responding, switching to %s", url, hosts[next]) v.ChangeHost(hosts[next]) + if !tracker.CheckHealth(ctx) { + log.Infof("New beacon node API at %s is also not responding", hosts[next]) + continue // Skip to the next ticker + } + km, err := v.Keymanager() if err != nil { log.WithError(err).Error("Could not get keymanager") From 046d1072c0ca23d349cf504b91a8c427c83bda71 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Thu, 25 Apr 2024 12:53:29 +0200 Subject: [PATCH 31/39] Fix linter errors --- validator/accounts/testing/mock.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/validator/accounts/testing/mock.go b/validator/accounts/testing/mock.go index 240febe00145..7f6ca3d11bc7 100644 --- a/validator/accounts/testing/mock.go +++ b/validator/accounts/testing/mock.go @@ -257,3 +257,7 @@ func (*Validator) Host() string { func (*Validator) ChangeHost(_ string) { panic("implement me") } + +func (*Validator) AvailableHosts() []string { + panic("implement me") +} From aeee310e5fe82ac775ab3373fc67daac93d70753 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Mon, 6 May 2024 14:22:43 -0700 Subject: [PATCH 32/39] Add host switch logic to ChangeHost --- validator/accounts/testing/mock.go | 6 +-- validator/client/iface/validator.go | 3 +- validator/client/runner.go | 49 +++++++++------------ validator/client/testutil/mock_validator.go | 6 +-- validator/client/validator.go | 18 +++++--- validator/client/validator_test.go | 24 ++++++++++ 6 files changed, 61 insertions(+), 45 deletions(-) diff --git a/validator/accounts/testing/mock.go b/validator/accounts/testing/mock.go index 7f6ca3d11bc7..f8f53f78f240 100644 --- a/validator/accounts/testing/mock.go +++ b/validator/accounts/testing/mock.go @@ -254,10 +254,6 @@ func (*Validator) Host() string { panic("implement me") } -func (*Validator) ChangeHost(_ string) { - panic("implement me") -} - -func (*Validator) AvailableHosts() []string { +func (*Validator) ChangeHost() { panic("implement me") } diff --git a/validator/client/iface/validator.go b/validator/client/iface/validator.go index 17ff9c2941a5..5d3cb0110453 100644 --- a/validator/client/iface/validator.go +++ b/validator/client/iface/validator.go @@ -69,8 +69,7 @@ type Validator interface { DeleteGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) error HealthTracker() *beacon.NodeHealthTracker Host() string - ChangeHost(host string) - AvailableHosts() []string + ChangeHost() } // SigningFunc interface defines a type for the function that signs a message diff --git a/validator/client/runner.go b/validator/client/runner.go index f0204dad38bb..607aeffa50f0 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -306,35 +306,28 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch return } isHealthy := tracker.CheckHealth(ctx) - hosts := v.AvailableHosts() - if !isHealthy && len(hosts) > 1 && features.Get().EnableBeaconRESTApi { - for i, url := range hosts { - if url == v.Host() { - next := (i + 1) % len(hosts) - log.Infof("Beacon node API at %s is not responding, switching to %s", url, hosts[next]) - v.ChangeHost(hosts[next]) - - if !tracker.CheckHealth(ctx) { - log.Infof("New beacon node API at %s is also not responding", hosts[next]) - continue // Skip to the next ticker - } - - km, err := v.Keymanager() - if err != nil { - log.WithError(err).Error("Could not get keymanager") - return - } - slot, err := v.CanonicalHeadSlot(ctx) - if err != nil { - log.WithError(err).Error("Could not get canonical head slot") - return - } - deadline := time.Now().Add(5 * time.Minute) - if err := v.PushProposerSettings(ctx, km, slot, deadline); err != nil { - log.WithError(err).Warn("Failed to update proposer settings") - } - } + if !isHealthy && features.Get().EnableBeaconRESTApi { + v.ChangeHost() + if !tracker.CheckHealth(ctx) { + log.Infof("New beacon node API at %s is also not responding", v.Host()) + continue // Skip to the next ticker + } + + km, err := v.Keymanager() + if err != nil { + log.WithError(err).Error("Could not get keymanager") + return } + slot, err := v.CanonicalHeadSlot(ctx) + if err != nil { + log.WithError(err).Error("Could not get canonical head slot") + return + } + deadline := time.Now().Add(5 * time.Minute) + if err := v.PushProposerSettings(ctx, km, slot, deadline); err != nil { + log.WithError(err).Warn("Failed to update proposer settings") + } + } // in case of node returning healthy but event stream died diff --git a/validator/client/testutil/mock_validator.go b/validator/client/testutil/mock_validator.go index c141f7de564e..7efd4c5d3373 100644 --- a/validator/client/testutil/mock_validator.go +++ b/validator/client/testutil/mock_validator.go @@ -318,8 +318,6 @@ func (*FakeValidator) Host() string { return "127.0.0.1:0" } -func (*FakeValidator) ChangeHost(_ string) {} - -func (*FakeValidator) AvailableHosts() []string { - return []string{"127.0.0.1:0", "127.0.0.1:1"} +func (fv *FakeValidator) ChangeHost() { + fv.Host() } diff --git a/validator/client/validator.go b/validator/client/validator.go index 06344747c18f..407b3f0ba69f 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -1112,12 +1112,18 @@ func (v *validator) Host() string { return v.validatorClient.Host() } -func (v *validator) ChangeHost(host string) { - v.validatorClient.ChangeHost(host) -} - -func (v *validator) AvailableHosts() []string { - return v.beaconNodeHosts +func (v *validator) ChangeHost() { + if len(v.beaconNodeHosts) <= 1 { + log.Infof("Beacon node API at %s is not responding, no backup node configured", v.Host()) + return + } + for i, url := range v.beaconNodeHosts { + if url == v.Host() { + next := (i + 1) % len(v.beaconNodeHosts) + log.Infof("Beacon node API at %s is not responding, switching to %s", url, v.beaconNodeHosts[next]) + v.validatorClient.ChangeHost(v.beaconNodeHosts[next]) + } + } } func (v *validator) filterAndCacheActiveKeys(ctx context.Context, pubkeys [][fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([][fieldparams.BLSPubkeyLength]byte, error) { diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index a4489a801b84..f88a7597709e 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -2614,3 +2614,27 @@ func TestValidator_Host(t *testing.T) { host = v.validatorClient.Host() require.Equal(t, hosts[1], host) } + +func TestValidator_ChangeHost(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + client := validatormock.NewMockValidatorClient(ctrl) + v := validator{ + validatorClient: client, + beaconNodeHosts: []string{"http://localhost:8080", "http://localhost:8081"}, + } + client.EXPECT().ChangeHost(v.beaconNodeHosts[0]).Times(2) + v.validatorClient.ChangeHost(v.beaconNodeHosts[0]) + + client.EXPECT().Host().Return(v.beaconNodeHosts[0]).Times(2) + host := v.Host() + require.Equal(t, v.beaconNodeHosts[0], host) + + client.EXPECT().Host().Return(v.beaconNodeHosts[1]).Times(1) + client.EXPECT().ChangeHost(v.beaconNodeHosts[1]).Times(1) + v.ChangeHost() + + client.EXPECT().Host().Return(v.beaconNodeHosts[1]).Times(1) + require.Equal(t, v.beaconNodeHosts[1], v.Host()) +} From 0a4e750c794b9a83bf45dc566c29f98254875976 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Mon, 6 May 2024 14:37:08 -0700 Subject: [PATCH 33/39] Lint + comment --- validator/client/runner.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index 607aeffa50f0..78d273ca53fc 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -323,11 +323,10 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch log.WithError(err).Error("Could not get canonical head slot") return } - deadline := time.Now().Add(5 * time.Minute) + deadline := time.Now().Add(5 * time.Minute) // Should consider changing to a constant if err := v.PushProposerSettings(ctx, km, slot, deadline); err != nil { log.WithError(err).Warn("Failed to update proposer settings") } - } // in case of node returning healthy but event stream died From 61e1f1ad11fb64692df5bb31c47754ade3c01385 Mon Sep 17 00:00:00 2001 From: Saolyn Date: Wed, 22 May 2024 14:14:54 -0700 Subject: [PATCH 34/39] Fix messy merge --- validator/client/service.go | 1 + 1 file changed, 1 insertion(+) diff --git a/validator/client/service.go b/validator/client/service.go index ca9fb66564bc..e499e0654783 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -3,6 +3,7 @@ package client import ( "context" "net/http" + "strings" "time" "github.com/dgraph-io/ristretto" From 02cd3c3ffe590d9b0ad5d596374eed92f1d27f1b Mon Sep 17 00:00:00 2001 From: rkapka Date: Tue, 28 May 2024 18:20:16 +0900 Subject: [PATCH 35/39] rename ChangeHost to SetHost --- testing/validator-mock/node_client_mock.go | 7 +++-- .../validator-mock/validator_client_mock.go | 24 ++++++++--------- .../beacon-api/beacon_api_validator_client.go | 4 +-- .../beacon_api_validator_client_test.go | 8 +++--- .../client/beacon-api/json_rest_handler.go | 4 +-- .../beacon-api/mock/json_rest_handler_mock.go | 26 +++++++++---------- .../client/grpc-api/grpc_validator_client.go | 2 +- validator/client/iface/validator_client.go | 2 +- validator/client/validator.go | 2 +- validator/client/validator_test.go | 16 ++++++------ 10 files changed, 47 insertions(+), 48 deletions(-) diff --git a/testing/validator-mock/node_client_mock.go b/testing/validator-mock/node_client_mock.go index 4b118cd2d063..fa8eb1b3d9fb 100644 --- a/testing/validator-mock/node_client_mock.go +++ b/testing/validator-mock/node_client_mock.go @@ -13,7 +13,7 @@ import ( context "context" reflect "reflect" - "github.com/prysmaticlabs/prysm/v5/api/client/beacon" + beacon "github.com/prysmaticlabs/prysm/v5/api/client/beacon" eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" gomock "go.uber.org/mock/gomock" emptypb "google.golang.org/protobuf/types/known/emptypb" @@ -21,9 +21,8 @@ import ( // MockNodeClient is a mock of NodeClient interface. type MockNodeClient struct { - ctrl *gomock.Controller - recorder *MockNodeClientMockRecorder - healthTracker *beacon.NodeHealthTracker + ctrl *gomock.Controller + recorder *MockNodeClientMockRecorder } // MockNodeClientMockRecorder is the mock recorder for MockNodeClient. diff --git a/testing/validator-mock/validator_client_mock.go b/testing/validator-mock/validator_client_mock.go index e3fed68f596d..bcb815d331d6 100644 --- a/testing/validator-mock/validator_client_mock.go +++ b/testing/validator-mock/validator_client_mock.go @@ -44,18 +44,6 @@ func (m *MockValidatorClient) EXPECT() *MockValidatorClientMockRecorder { return m.recorder } -// ChangeHost mocks base method. -func (m *MockValidatorClient) ChangeHost(arg0 string) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "ChangeHost", arg0) -} - -// ChangeHost indicates an expected call of ChangeHost. -func (mr *MockValidatorClientMockRecorder) ChangeHost(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeHost", reflect.TypeOf((*MockValidatorClient)(nil).ChangeHost), arg0) -} - // CheckDoppelGanger mocks base method. func (m *MockValidatorClient) CheckDoppelGanger(arg0 context.Context, arg1 *eth.DoppelGangerRequest) (*eth.DoppelGangerResponse, error) { m.ctrl.T.Helper() @@ -324,6 +312,18 @@ func (mr *MockValidatorClientMockRecorder) ProposeExit(arg0, arg1 any) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProposeExit", reflect.TypeOf((*MockValidatorClient)(nil).ProposeExit), arg0, arg1) } +// SetHost mocks base method. +func (m *MockValidatorClient) SetHost(arg0 string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetHost", arg0) +} + +// SetHost indicates an expected call of SetHost. +func (mr *MockValidatorClientMockRecorder) SetHost(arg0 any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHost", reflect.TypeOf((*MockValidatorClient)(nil).SetHost), arg0) +} + // StartEventStream mocks base method. func (m *MockValidatorClient) StartEventStream(arg0 context.Context, arg1 []string, arg2 chan<- *event.Event) { m.ctrl.T.Helper() diff --git a/validator/client/beacon-api/beacon_api_validator_client.go b/validator/client/beacon-api/beacon_api_validator_client.go index 2fb9d538dadb..667ac9a4710f 100644 --- a/validator/client/beacon-api/beacon_api_validator_client.go +++ b/validator/client/beacon-api/beacon_api_validator_client.go @@ -235,6 +235,6 @@ func (c *beaconApiValidatorClient) Host() string { return c.jsonRestHandler.Host() } -func (c *beaconApiValidatorClient) ChangeHost(host string) { - c.jsonRestHandler.ChangeHost(host) +func (c *beaconApiValidatorClient) SetHost(host string) { + c.jsonRestHandler.SetHost(host) } diff --git a/validator/client/beacon-api/beacon_api_validator_client_test.go b/validator/client/beacon-api/beacon_api_validator_client_test.go index eae8bd847d33..7e5872124a91 100644 --- a/validator/client/beacon-api/beacon_api_validator_client_test.go +++ b/validator/client/beacon-api/beacon_api_validator_client_test.go @@ -209,7 +209,7 @@ func TestBeaconApiValidatorClient_Host(t *testing.T) { hosts := []string{"http://localhost:8080", "http://localhost:8081"} jsonRestHandler := mock.NewMockJsonRestHandler(ctrl) - jsonRestHandler.EXPECT().ChangeHost( + jsonRestHandler.EXPECT().SetHost( hosts[0], ).Times(1) jsonRestHandler.EXPECT().Host().Return( @@ -217,17 +217,17 @@ func TestBeaconApiValidatorClient_Host(t *testing.T) { ).Times(1) validatorClient := beaconApiValidatorClient{jsonRestHandler: jsonRestHandler} - validatorClient.ChangeHost(hosts[0]) + validatorClient.SetHost(hosts[0]) host := validatorClient.Host() require.Equal(t, hosts[0], host) - jsonRestHandler.EXPECT().ChangeHost( + jsonRestHandler.EXPECT().SetHost( hosts[1], ).Times(1) jsonRestHandler.EXPECT().Host().Return( hosts[1], ).Times(1) - validatorClient.ChangeHost(hosts[1]) + validatorClient.SetHost(hosts[1]) host = validatorClient.Host() require.Equal(t, hosts[1], host) } diff --git a/validator/client/beacon-api/json_rest_handler.go b/validator/client/beacon-api/json_rest_handler.go index 5442881329f1..b42e96cdc528 100644 --- a/validator/client/beacon-api/json_rest_handler.go +++ b/validator/client/beacon-api/json_rest_handler.go @@ -18,7 +18,7 @@ type JsonRestHandler interface { Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp interface{}) error HttpClient() *http.Client Host() string - ChangeHost(newHost string) + SetHost(newHost string) } type BeaconApiJsonRestHandler struct { @@ -136,6 +136,6 @@ func decodeResp(httpResp *http.Response, resp interface{}) error { return nil } -func (c *BeaconApiJsonRestHandler) ChangeHost(newHost string) { +func (c *BeaconApiJsonRestHandler) SetHost(newHost string) { c.host = newHost } diff --git a/validator/client/beacon-api/mock/json_rest_handler_mock.go b/validator/client/beacon-api/mock/json_rest_handler_mock.go index b0faae298ead..78fdc40b28e5 100644 --- a/validator/client/beacon-api/mock/json_rest_handler_mock.go +++ b/validator/client/beacon-api/mock/json_rest_handler_mock.go @@ -12,7 +12,7 @@ package mock import ( bytes "bytes" context "context" - "net/http" + http "net/http" reflect "reflect" gomock "go.uber.org/mock/gomock" @@ -41,18 +41,6 @@ func (m *MockJsonRestHandler) EXPECT() *MockJsonRestHandlerMockRecorder { return m.recorder } -// ChangeHost mocks base method. -func (m *MockJsonRestHandler) ChangeHost(newHost string) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "ChangeHost", newHost) -} - -// ChangeHost indicates an expected call of ChangeHost. -func (mr *MockJsonRestHandlerMockRecorder) ChangeHost(newHost any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeHost", reflect.TypeOf((*MockJsonRestHandler)(nil).ChangeHost), newHost) -} - // Get mocks base method. func (m *MockJsonRestHandler) Get(ctx context.Context, endpoint string, resp any) error { m.ctrl.T.Helper() @@ -108,3 +96,15 @@ func (mr *MockJsonRestHandlerMockRecorder) Post(ctx, endpoint, headers, data, re mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Post", reflect.TypeOf((*MockJsonRestHandler)(nil).Post), ctx, endpoint, headers, data, resp) } + +// SetHost mocks base method. +func (m *MockJsonRestHandler) SetHost(newHost string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetHost", newHost) +} + +// SetHost indicates an expected call of SetHost. +func (mr *MockJsonRestHandlerMockRecorder) SetHost(newHost any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHost", reflect.TypeOf((*MockJsonRestHandler)(nil).SetHost), newHost) +} diff --git a/validator/client/grpc-api/grpc_validator_client.go b/validator/client/grpc-api/grpc_validator_client.go index 419a5c9df544..11ca01b0c2ef 100644 --- a/validator/client/grpc-api/grpc_validator_client.go +++ b/validator/client/grpc-api/grpc_validator_client.go @@ -251,6 +251,6 @@ func (*grpcValidatorClient) Host() string { return "" } -func (*grpcValidatorClient) ChangeHost(_ string) { +func (*grpcValidatorClient) SetHost(_ string) { log.Warn(iface.ErrNotSupported) } diff --git a/validator/client/iface/validator_client.go b/validator/client/iface/validator_client.go index c1a01450d8db..2e59a686f489 100644 --- a/validator/client/iface/validator_client.go +++ b/validator/client/iface/validator_client.go @@ -151,5 +151,5 @@ type ValidatorClient interface { GetAggregatedSelections(ctx context.Context, selections []BeaconCommitteeSelection) ([]BeaconCommitteeSelection, error) GetAggregatedSyncSelections(ctx context.Context, selections []SyncCommitteeSelection) ([]SyncCommitteeSelection, error) Host() string - ChangeHost(host string) + SetHost(host string) } diff --git a/validator/client/validator.go b/validator/client/validator.go index b0d2fb1e10dc..50ec1eb82dbe 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -1126,7 +1126,7 @@ func (v *validator) ChangeHost() { if url == v.Host() { next := (i + 1) % len(v.beaconNodeHosts) log.Infof("Beacon node API at %s is not responding, switching to %s", url, v.beaconNodeHosts[next]) - v.validatorClient.ChangeHost(v.beaconNodeHosts[next]) + v.validatorClient.SetHost(v.beaconNodeHosts[next]) } } } diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index e99cf246c75c..bcc84fa22588 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -2600,22 +2600,22 @@ func TestValidator_Host(t *testing.T) { v := validator{ validatorClient: client, } - client.EXPECT().ChangeHost(hosts[0]).Times(1) + client.EXPECT().SetHost(hosts[0]).Times(1) client.EXPECT().Host().Return(hosts[0]).Times(1) - v.validatorClient.ChangeHost(hosts[0]) + v.validatorClient.SetHost(hosts[0]) host := v.validatorClient.Host() require.Equal(t, hosts[0], host) - client.EXPECT().ChangeHost(hosts[1]).Times(1) + client.EXPECT().SetHost(hosts[1]).Times(1) client.EXPECT().Host().Return(hosts[1]).Times(1) - v.validatorClient.ChangeHost(hosts[1]) + v.validatorClient.SetHost(hosts[1]) host = v.validatorClient.Host() require.Equal(t, hosts[1], host) } -func TestValidator_ChangeHost(t *testing.T) { +func TestValidator_SetHost(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -2624,15 +2624,15 @@ func TestValidator_ChangeHost(t *testing.T) { validatorClient: client, beaconNodeHosts: []string{"http://localhost:8080", "http://localhost:8081"}, } - client.EXPECT().ChangeHost(v.beaconNodeHosts[0]).Times(2) - v.validatorClient.ChangeHost(v.beaconNodeHosts[0]) + client.EXPECT().SetHost(v.beaconNodeHosts[0]).Times(2) + v.validatorClient.SetHost(v.beaconNodeHosts[0]) client.EXPECT().Host().Return(v.beaconNodeHosts[0]).Times(2) host := v.Host() require.Equal(t, v.beaconNodeHosts[0], host) client.EXPECT().Host().Return(v.beaconNodeHosts[1]).Times(1) - client.EXPECT().ChangeHost(v.beaconNodeHosts[1]).Times(1) + client.EXPECT().SetHost(v.beaconNodeHosts[1]).Times(1) v.ChangeHost() client.EXPECT().Host().Return(v.beaconNodeHosts[1]).Times(1) From f822c3a67fec2f20b182d454de3a39f0381f2d42 Mon Sep 17 00:00:00 2001 From: rkapka Date: Tue, 28 May 2024 18:57:44 +0900 Subject: [PATCH 36/39] improve log --- validator/client/runner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index 78d273ca53fc..90a6a9fbbd89 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -309,7 +309,7 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch if !isHealthy && features.Get().EnableBeaconRESTApi { v.ChangeHost() if !tracker.CheckHealth(ctx) { - log.Infof("New beacon node API at %s is also not responding", v.Host()) + log.Infof("New beacon node at %s is also not responding, trying again...", v.Host()) continue // Skip to the next ticker } From bab817cdbfc7166aa177d75f3510860eda732b0d Mon Sep 17 00:00:00 2001 From: rkapka Date: Tue, 28 May 2024 20:06:43 +0900 Subject: [PATCH 37/39] remove log --- validator/client/runner.go | 1 - 1 file changed, 1 deletion(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index 90a6a9fbbd89..83c9fec2489b 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -309,7 +309,6 @@ func runHealthCheckRoutine(ctx context.Context, v iface.Validator, eventsChan ch if !isHealthy && features.Get().EnableBeaconRESTApi { v.ChangeHost() if !tracker.CheckHealth(ctx) { - log.Infof("New beacon node at %s is also not responding, trying again...", v.Host()) continue // Skip to the next ticker } From 600cfe8bedcb857926280392d71c7bec9975bf81 Mon Sep 17 00:00:00 2001 From: rkapka Date: Tue, 28 May 2024 20:06:59 +0900 Subject: [PATCH 38/39] switch one node --- validator/client/service.go | 3 ++- validator/client/validator.go | 18 +++++++------- validator/client/validator_test.go | 38 +++++++++--------------------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/validator/client/service.go b/validator/client/service.go index e499e0654783..a7bd4408c202 100644 --- a/validator/client/service.go +++ b/validator/client/service.go @@ -191,6 +191,8 @@ func (v *ValidatorService) Start() { graffiti: v.graffiti, graffitiStruct: v.graffitiStruct, graffitiOrderedIndex: graffitiOrderedIndex, + beaconNodeHosts: hosts, + currentHostIndex: 0, validatorClient: validatorClient, chainClient: beaconChainClientFactory.NewChainClient(v.conn, restHandler), nodeClient: nodeClientFactory.NewNodeClient(v.conn, restHandler), @@ -203,7 +205,6 @@ func (v *ValidatorService) Start() { validatorsRegBatchSize: v.validatorsRegBatchSize, interopKeysConfig: v.interopKeysConfig, attSelections: make(map[attSelectionKey]iface.BeaconCommitteeSelection), - beaconNodeHosts: hosts, aggregatedSlotCommitteeIDCache: aggregatedSlotCommitteeIDCache, domainDataCache: cache, voteStats: voteStats{startEpoch: primitives.Epoch(^uint64(0))}, diff --git a/validator/client/validator.go b/validator/client/validator.go index b5cefc459334..4bb0d1b4ab0a 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -84,6 +84,8 @@ type validator struct { graffiti []byte graffitiStruct *graffiti.Graffiti graffitiOrderedIndex uint64 + beaconNodeHosts []string + currentHostIndex uint64 validatorClient iface.ValidatorClient chainClient iface.ChainClient nodeClient iface.NodeClient @@ -94,7 +96,6 @@ type validator struct { proposerSettings *proposer.Settings signedValidatorRegistrations map[[fieldparams.BLSPubkeyLength]byte]*ethpb.SignedValidatorRegistrationV1 validatorsRegBatchSize int - beaconNodeHosts []string interopKeysConfig *local.InteropKeymanagerConfig attSelections map[attSelectionKey]iface.BeaconCommitteeSelection aggregatedSlotCommitteeIDCache *lru.Cache @@ -1120,17 +1121,14 @@ func (v *validator) Host() string { } func (v *validator) ChangeHost() { - if len(v.beaconNodeHosts) <= 1 { - log.Infof("Beacon node API at %s is not responding, no backup node configured", v.Host()) + if len(v.beaconNodeHosts) == 1 { + log.Infof("Beacon node at %s is not responding, no backup node configured", v.Host()) return } - for i, url := range v.beaconNodeHosts { - if url == v.Host() { - next := (i + 1) % len(v.beaconNodeHosts) - log.Infof("Beacon node API at %s is not responding, switching to %s", url, v.beaconNodeHosts[next]) - v.validatorClient.SetHost(v.beaconNodeHosts[next]) - } - } + next := (v.currentHostIndex + 1) % uint64(len(v.beaconNodeHosts)) + log.Infof("Beacon node at %s is not responding, switching to %s...", v.beaconNodeHosts[v.currentHostIndex], v.beaconNodeHosts[next]) + v.validatorClient.SetHost(v.beaconNodeHosts[next]) + v.currentHostIndex = next } func (v *validator) filterAndCacheActiveKeys(ctx context.Context, pubkeys [][fieldparams.BLSPubkeyLength]byte, slot primitives.Slot) ([][fieldparams.BLSPubkeyLength]byte, error) { diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index bcc84fa22588..884606bd1d52 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -2595,46 +2595,30 @@ func TestValidator_Host(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - hosts := []string{"http://localhost:8080", "http://localhost:8081"} client := validatormock.NewMockValidatorClient(ctrl) v := validator{ validatorClient: client, } - client.EXPECT().SetHost(hosts[0]).Times(1) - client.EXPECT().Host().Return(hosts[0]).Times(1) - v.validatorClient.SetHost(hosts[0]) - host := v.validatorClient.Host() - require.Equal(t, hosts[0], host) - - client.EXPECT().SetHost(hosts[1]).Times(1) - client.EXPECT().Host().Return(hosts[1]).Times(1) - - v.validatorClient.SetHost(hosts[1]) - host = v.validatorClient.Host() - require.Equal(t, hosts[1], host) + client.EXPECT().Host().Return("host").Times(1) + require.Equal(t, "host", v.Host()) } -func TestValidator_SetHost(t *testing.T) { +func TestValidator_ChangeHost(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() client := validatormock.NewMockValidatorClient(ctrl) v := validator{ - validatorClient: client, - beaconNodeHosts: []string{"http://localhost:8080", "http://localhost:8081"}, + validatorClient: client, + beaconNodeHosts: []string{"http://localhost:8080", "http://localhost:8081"}, + currentHostIndex: 0, } - client.EXPECT().SetHost(v.beaconNodeHosts[0]).Times(2) - v.validatorClient.SetHost(v.beaconNodeHosts[0]) - client.EXPECT().Host().Return(v.beaconNodeHosts[0]).Times(2) - host := v.Host() - require.Equal(t, v.beaconNodeHosts[0], host) - - client.EXPECT().Host().Return(v.beaconNodeHosts[1]).Times(1) - client.EXPECT().SetHost(v.beaconNodeHosts[1]).Times(1) + client.EXPECT().SetHost(v.beaconNodeHosts[1]) + client.EXPECT().SetHost(v.beaconNodeHosts[0]) v.ChangeHost() - - client.EXPECT().Host().Return(v.beaconNodeHosts[1]).Times(1) - require.Equal(t, v.beaconNodeHosts[1], v.Host()) + assert.Equal(t, uint64(1), v.currentHostIndex) + v.ChangeHost() + assert.Equal(t, uint64(0), v.currentHostIndex) } From d968a1d243972680d5bb1d954ff730be9619c3ef Mon Sep 17 00:00:00 2001 From: rkapka Date: Tue, 28 May 2024 20:10:14 +0900 Subject: [PATCH 39/39] rename param --- validator/client/beacon-api/json_rest_handler.go | 6 +++--- .../client/beacon-api/mock/json_rest_handler_mock.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/validator/client/beacon-api/json_rest_handler.go b/validator/client/beacon-api/json_rest_handler.go index b42e96cdc528..890a10e26be6 100644 --- a/validator/client/beacon-api/json_rest_handler.go +++ b/validator/client/beacon-api/json_rest_handler.go @@ -18,7 +18,7 @@ type JsonRestHandler interface { Post(ctx context.Context, endpoint string, headers map[string]string, data *bytes.Buffer, resp interface{}) error HttpClient() *http.Client Host() string - SetHost(newHost string) + SetHost(host string) } type BeaconApiJsonRestHandler struct { @@ -136,6 +136,6 @@ func decodeResp(httpResp *http.Response, resp interface{}) error { return nil } -func (c *BeaconApiJsonRestHandler) SetHost(newHost string) { - c.host = newHost +func (c *BeaconApiJsonRestHandler) SetHost(host string) { + c.host = host } diff --git a/validator/client/beacon-api/mock/json_rest_handler_mock.go b/validator/client/beacon-api/mock/json_rest_handler_mock.go index 78fdc40b28e5..1e2e98499cd3 100644 --- a/validator/client/beacon-api/mock/json_rest_handler_mock.go +++ b/validator/client/beacon-api/mock/json_rest_handler_mock.go @@ -98,13 +98,13 @@ func (mr *MockJsonRestHandlerMockRecorder) Post(ctx, endpoint, headers, data, re } // SetHost mocks base method. -func (m *MockJsonRestHandler) SetHost(newHost string) { +func (m *MockJsonRestHandler) SetHost(host string) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetHost", newHost) + m.ctrl.Call(m, "SetHost", host) } // SetHost indicates an expected call of SetHost. -func (mr *MockJsonRestHandlerMockRecorder) SetHost(newHost any) *gomock.Call { +func (mr *MockJsonRestHandlerMockRecorder) SetHost(host any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHost", reflect.TypeOf((*MockJsonRestHandler)(nil).SetHost), newHost) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHost", reflect.TypeOf((*MockJsonRestHandler)(nil).SetHost), host) }