diff --git a/app/eth2wrap/eth2wrap.go b/app/eth2wrap/eth2wrap.go index bdbe73dca..d9980670e 100644 --- a/app/eth2wrap/eth2wrap.go +++ b/app/eth2wrap/eth2wrap.go @@ -17,6 +17,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/obolnetwork/charon/app/errors" + "github.com/obolnetwork/charon/app/featureset" "github.com/obolnetwork/charon/app/forkjoin" "github.com/obolnetwork/charon/app/promauto" "github.com/obolnetwork/charon/app/z" @@ -74,13 +75,16 @@ func NewMultiHTTP(timeout time.Duration, addresses ...string) (Client, error) { for _, address := range addresses { address := address // Capture range variable. + parameters := []eth2http.Parameter{ + eth2http.WithLogLevel(zeroLogInfo), + eth2http.WithAddress(address), + eth2http.WithTimeout(timeout), + eth2http.WithAllowDelayedStart(true), + eth2http.WithEnforceJSON(featureset.Enabled(featureset.JSONRequests)), + } + cl := newLazy(func(ctx context.Context) (Client, error) { - eth2Svc, err := eth2http.New(ctx, - eth2http.WithLogLevel(zeroLogInfo), - eth2http.WithAddress(address), - eth2http.WithTimeout(timeout), - eth2http.WithAllowDelayedStart(true), - ) + eth2Svc, err := eth2http.New(ctx, parameters...) if err != nil { return nil, wrapError(ctx, err, "new eth2 client", z.Str("address", address)) } diff --git a/app/featureset/featureset.go b/app/featureset/featureset.go index 6fc3804fb..4b0eaf5e1 100644 --- a/app/featureset/featureset.go +++ b/app/featureset/featureset.go @@ -37,6 +37,9 @@ const ( // AggSigDBV2 enables a newer, simpler implementation of `aggsigdb`. AggSigDBV2 Feature = "aggsigdb_v2" + + // JSONRequests enables JSON requests for eth2 client. + JSONRequests Feature = "json_requests" ) var ( @@ -46,6 +49,7 @@ var ( ConsensusParticipate: statusStable, MockAlpha: statusAlpha, AggSigDBV2: statusAlpha, + JSONRequests: statusAlpha, // Add all features and there status here. } diff --git a/app/featureset/featureset_internal_test.go b/app/featureset/featureset_internal_test.go index 1f422b4e1..6c07a0ad5 100644 --- a/app/featureset/featureset_internal_test.go +++ b/app/featureset/featureset_internal_test.go @@ -14,6 +14,7 @@ func TestAllFeatureStatus(t *testing.T) { MockAlpha, EagerDoubleLinear, ConsensusParticipate, + JSONRequests, } for _, feature := range features { diff --git a/app/featureset/status_string.go b/app/featureset/status_string.go index 4272384ef..fb2430e58 100644 --- a/app/featureset/status_string.go +++ b/app/featureset/status_string.go @@ -10,19 +10,30 @@ func _() { // An "invalid array index" compiler error signifies that the constant values have changed. // Re-run the stringer command to generate them again. var x [1]struct{} + _ = x[enable-9223372036854775807] + _ = x[disable-0] _ = x[statusAlpha-1] _ = x[statusBeta-2] _ = x[statusStable-3] + _ = x[statusSentinel-4] } -const _status_name = "AlphaBetaStable" +const ( + _status_name_0 = "disableAlphaBetaStableSentinel" + _status_name_1 = "enable" +) -var _status_index = [...]uint8{0, 5, 9, 15} +var ( + _status_index_0 = [...]uint8{0, 7, 12, 16, 22, 30} +) func (i status) String() string { - i -= 1 - if i < 0 || i >= status(len(_status_index)-1) { - return "status(" + strconv.FormatInt(int64(i+1), 10) + ")" + switch { + case 0 <= i && i <= 4: + return _status_name_0[_status_index_0[i]:_status_index_0[i+1]] + case i == 9223372036854775807: + return _status_name_1 + default: + return "status(" + strconv.FormatInt(int64(i), 10) + ")" } - return _status_name[_status_index[i]:_status_index[i+1]] }