Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore functionality of disableSSZRequests killswitch #108

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading