Skip to content

Commit

Permalink
app: json_requests feature (#3110)
Browse files Browse the repository at this point in the history
Add `WithEnforceJSON(true)` parameter when `json_requests` feature is enabled in `featureset`.
This is needed for Nimbus BN to properly handle SubmitProposal requests.

category: feature
ticket: #3108
feature_flag: json_requests
  • Loading branch information
pinebit authored May 30, 2024
1 parent 249e476 commit 278bcf7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
16 changes: 10 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,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))
}
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.

0 comments on commit 278bcf7

Please sign in to comment.