Skip to content

Commit

Permalink
restore functionality of disableSSZRequests killswitch
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 21, 2024
1 parent 2995adc commit e8ab47e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
11 changes: 6 additions & 5 deletions clients/consensus/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
)

type ClientConfig struct {
URL string
Name string
Headers map[string]string
SshConfig *sshtunnel.SshConfig
URL string
Name string
Headers map[string]string
SshConfig *sshtunnel.SshConfig
DisableSSZ bool
}

type Client struct {
Expand Down Expand Up @@ -56,7 +57,7 @@ type Client struct {
func (pool *Pool) newPoolClient(clientIdx uint16, endpoint *ClientConfig) (*Client, error) {
logger := pool.logger.WithField("client", endpoint.Name)

rpcClient, err := rpc.NewBeaconClient(endpoint.Name, endpoint.URL, endpoint.Headers, endpoint.SshConfig, logger)
rpcClient, err := rpc.NewBeaconClient(endpoint.Name, endpoint.URL, endpoint.Headers, endpoint.SshConfig, endpoint.DisableSSZ, logger)
if err != nil {
return nil, err
}
Expand Down
30 changes: 17 additions & 13 deletions clients/consensus/rpc/beaconapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@ import (
)

type BeaconClient struct {
name string
endpoint string
headers map[string]string
sshtunnel *sshtunnel.SSHTunnel
clientSvc eth2client.Service
logger logrus.FieldLogger
name string
endpoint string
headers map[string]string
sshtunnel *sshtunnel.SSHTunnel
disableSSZ bool
clientSvc eth2client.Service
logger logrus.FieldLogger
}

// NewBeaconClient is used to create a new beacon client
func NewBeaconClient(name, endpoint string, headers map[string]string, sshcfg *sshtunnel.SshConfig, logger logrus.FieldLogger) (*BeaconClient, error) {
func NewBeaconClient(name, endpoint string, headers map[string]string, sshcfg *sshtunnel.SshConfig, disableSSZ bool, logger logrus.FieldLogger) (*BeaconClient, error) {
client := &BeaconClient{
name: name,
endpoint: endpoint,
headers: headers,
logger: logger,
name: name,
endpoint: endpoint,
headers: headers,
disableSSZ: disableSSZ,
logger: logger,
}

if sshcfg != nil {
Expand Down Expand Up @@ -104,8 +106,6 @@ func (bc *BeaconClient) Initialize(ctx context.Context) error {
http.WithAddress(bc.endpoint),
http.WithTimeout(10 * time.Minute),
http.WithLogLevel(zerolog.Disabled),
// TODO (when upstream PR is merged)
// http.WithConnectionCheck(false),
http.WithCustomSpecSupport(true),
}

Expand All @@ -114,6 +114,10 @@ func (bc *BeaconClient) Initialize(ctx context.Context) error {
cliParams = append(cliParams, http.WithExtraHeaders(bc.headers))
}

if bc.disableSSZ {
cliParams = append(cliParams, http.WithEnforceJSON(true))
}

clientSvc, err := http.New(ctx, cliParams...)
if err != nil {
return err
Expand Down
7 changes: 4 additions & 3 deletions services/chainservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ func (cs *ChainService) StartService() error {
// add consensus clients
for index, endpoint := range utils.Config.BeaconApi.Endpoints {
endpointConfig := &consensus.ClientConfig{
URL: endpoint.Url,
Name: endpoint.Name,
Headers: endpoint.Headers,
URL: endpoint.Url,
Name: endpoint.Name,
Headers: endpoint.Headers,
DisableSSZ: utils.Config.KillSwitch.DisableSSZRequests,
}

if endpoint.Ssh != nil {
Expand Down

0 comments on commit e8ab47e

Please sign in to comment.