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

app: json_requests feature #3110

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 13 additions & 6 deletions app/eth2wrap/eth2wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -74,13 +75,19 @@ 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),
}

if featureset.Enabled(featureset.JSONRequests) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can pass the result of Enabled to WithEnforceJSON, avoiding the if statement entirely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Fixed.

parameters = append(parameters, eth2http.WithEnforceJSON(true))
}

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))
}
Expand Down
4 changes: 4 additions & 0 deletions app/featureset/featureset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -46,6 +49,7 @@ var (
ConsensusParticipate: statusStable,
MockAlpha: statusAlpha,
AggSigDBV2: statusAlpha,
JSONRequests: statusAlpha,
// Add all features and there status here.
}

Expand Down
1 change: 1 addition & 0 deletions app/featureset/featureset_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestAllFeatureStatus(t *testing.T) {
MockAlpha,
EagerDoubleLinear,
ConsensusParticipate,
JSONRequests,
}

for _, feature := range features {
Expand Down
23 changes: 17 additions & 6 deletions app/featureset/status_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading