Skip to content
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
2 changes: 1 addition & 1 deletion api/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Binder interface {

var errInvalidType = errors.New("invalid type")

func Bind(r *http.Request, dest interface{}) error {
func Bind(r *http.Request, dest any) error {
if err := r.ParseForm(); err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions api/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type TestStructPointer struct {
}

// runTestBindForm is a helper that binds form data to dest and then runs the provided validation.
func runTestBindForm(t *testing.T, dest interface{}, validate func(*testing.T, interface{})) {
func runTestBindForm(t *testing.T, dest any, validate func(*testing.T, any)) {
form := url.Values{
"name": []string{"John Doe"},
"age": []string{"30"},
Expand All @@ -61,7 +61,7 @@ func TestBindFormNonPointer(t *testing.T) {
t.Parallel()

dest := &TestStructNonPointer{}
validate := func(t *testing.T, dest interface{}) {
validate := func(t *testing.T, dest any) {
s, ok := dest.(*TestStructNonPointer)

require.True(t, ok)
Expand All @@ -80,7 +80,7 @@ func TestBindFormPointer(t *testing.T) {
t.Parallel()

dest := &TestStructPointer{}
validate := func(t *testing.T, dest interface{}) {
validate := func(t *testing.T, dest any) {
s, ok := dest.(*TestStructPointer)

require.True(t, ok)
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestInvalidDestinationType(t *testing.T) {

testCases := []struct {
name string
dest interface{}
dest any
}{
{"non-pointer", TestStructNonPointer{}},
{"pointer to non-struct", new(string)},
Expand Down
18 changes: 9 additions & 9 deletions api/handlers/exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ func TestTransformToParticipantResponse(t *testing.T) {
func TestExporterDecideds(t *testing.T) {
tests := []struct {
name string
request map[string]interface{}
request map[string]any
setupMock func(*mockParticipantStore)
expectedStatus int
validateResp func(*testing.T, *httptest.ResponseRecorder)
}{
{
name: "valid request - roles & slot range",
request: map[string]interface{}{
request: map[string]any{
"from": 100,
"to": 200,
"roles": []string{"ATTESTER"},
Expand Down Expand Up @@ -197,7 +197,7 @@ func TestExporterDecideds(t *testing.T) {
},
{
name: "valid request - pubkeys filter",
request: map[string]interface{}{
request: map[string]any{
"from": 100,
"to": 200,
"roles": []string{"ATTESTER"},
Expand Down Expand Up @@ -232,7 +232,7 @@ func TestExporterDecideds(t *testing.T) {
},
{
name: "invalid request - from > to",
request: map[string]interface{}{
request: map[string]any{
"from": 200,
"to": 100,
"roles": []string{"ATTESTER"},
Expand All @@ -253,7 +253,7 @@ func TestExporterDecideds(t *testing.T) {
},
{
name: "invalid request - no roles",
request: map[string]interface{}{
request: map[string]any{
"from": 100,
"to": 200,
},
Expand All @@ -273,7 +273,7 @@ func TestExporterDecideds(t *testing.T) {
},
{
name: "multiple roles",
request: map[string]interface{}{
request: map[string]any{
"from": 100,
"to": 200,
"roles": []string{"ATTESTER", "PROPOSER"},
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestExporterDecideds(t *testing.T) {
},
{
name: "invalid request - invalid pubkey length",
request: map[string]interface{}{
request: map[string]any{
"from": 100,
"to": 200,
"roles": []string{"ATTESTER"},
Expand Down Expand Up @@ -403,7 +403,7 @@ func TestExporterDecideds_ErrorGetAllParticipantsInRange(t *testing.T) {
stores.Add(spectypes.BNRoleAttester, store)

exporter := NewExporter(zap.NewNop(), stores, nil, nil)
reqData := map[string]interface{}{
reqData := map[string]any{
"from": 100,
"to": 200,
"roles": []string{"ATTESTER"},
Expand Down Expand Up @@ -447,7 +447,7 @@ func TestExporterDecideds_ErrorGetParticipantsInRange(t *testing.T) {

exporter := NewExporter(zap.NewNop(), stores, nil, nil)

reqData := map[string]interface{}{
reqData := map[string]any{
"from": 100,
"to": 200,
"roles": []string{"ATTESTER"},
Expand Down
6 changes: 3 additions & 3 deletions api/handlers/node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,19 @@ func TestHealthCheckJSONString(t *testing.T) {
hc.Advanced.ListenAddresses = []string{"127.0.0.1:8000"}

s := hc.String()
var result map[string]interface{}
var result map[string]any

require.NoError(t, json.Unmarshal([]byte(s), &result))
require.Equal(t, "bad: not enough connected peers", result["p2p"])
require.Equal(t, "good", result["beacon_node"])
require.Equal(t, "good", result["execution_node"])
require.Equal(t, "good", result["event_syncer"])

advanced, ok := result["advanced"].(map[string]interface{})
advanced, ok := result["advanced"].(map[string]any)

require.True(t, ok)
require.Equal(t, float64(3), advanced["peers"])
require.Equal(t, float64(3), advanced["inbound_conns"])
require.Equal(t, float64(0), advanced["outbound_conns"])
require.Equal(t, []interface{}{"127.0.0.1:8000"}, advanced["p2p_listen_addresses"])
require.Equal(t, []any{"127.0.0.1:8000"}, advanced["p2p_listen_addresses"])
}
6 changes: 3 additions & 3 deletions api/handling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestRender(t *testing.T) {
{
name: "fallthrough json when no fmt.stringer with text/plain",
acceptHeader: "text/plain",
response: map[string]interface{}{"key": "value"},
response: map[string]any{"key": "value"},
wantContentType: "application/json",
wantBodySubstring: `"key":"value"`,
},
Expand All @@ -70,14 +70,14 @@ func TestRender(t *testing.T) {
{
name: "explicit json rendering",
acceptHeader: "application/json",
response: map[string]interface{}{"foo": "bar", "baz": 123},
response: map[string]any{"foo": "bar", "baz": 123},
wantContentType: "application/json",
wantBodySubstring: `"foo":"bar"`,
},
{
name: "default json when no accept header",
acceptHeader: "",
response: map[string]interface{}{"key": "value"},
response: map[string]any{"key": "value"},
wantContentType: "application/json",
wantBodySubstring: `"key":"value"`,
},
Expand Down
20 changes: 10 additions & 10 deletions api/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func setupTestServer(t *testing.T) *httptest.Server {
router.Use(middlewareNodeVersion)

nodeIdentityHandler := func(w http.ResponseWriter, r *http.Request) {
err := api.Render(w, r, map[string]interface{}{
err := api.Render(w, r, map[string]any{
"peer_id": "test-node-id",
"addresses": []string{"test-address"},
"subnets": "test-subnets",
Expand All @@ -48,7 +48,7 @@ func setupTestServer(t *testing.T) *httptest.Server {
}

nodePeersHandler := func(w http.ResponseWriter, r *http.Request) {
err := api.Render(w, r, []map[string]interface{}{
err := api.Render(w, r, []map[string]any{
{"id": "peer1", "addresses": []string{"addr1"}},
})
if err != nil {
Expand All @@ -57,9 +57,9 @@ func setupTestServer(t *testing.T) *httptest.Server {
}

nodeTopicsHandler := func(w http.ResponseWriter, r *http.Request) {
err := api.Render(w, r, map[string]interface{}{
err := api.Render(w, r, map[string]any{
"all_peers": []string{"peer1", "peer2"},
"peers_by_topic": []map[string]interface{}{
"peers_by_topic": []map[string]any{
{
"topic": "topic1",
"peers": []string{"peer1"},
Expand All @@ -72,12 +72,12 @@ func setupTestServer(t *testing.T) *httptest.Server {
}

nodeHealthHandler := func(w http.ResponseWriter, r *http.Request) {
err := api.Render(w, r, map[string]interface{}{
err := api.Render(w, r, map[string]any{
"p2p": "good",
"beacon_node": "good",
"execution_node": "good",
"event_syncer": "good",
"advanced": map[string]interface{}{
"advanced": map[string]any{
"peers": 2,
"inbound_conns": 1,
"outbound_conns": 1,
Expand All @@ -90,8 +90,8 @@ func setupTestServer(t *testing.T) *httptest.Server {
}

validatorsListHandler := func(w http.ResponseWriter, r *http.Request) {
err := api.Render(w, r, map[string]interface{}{
"data": []map[string]interface{}{
err := api.Render(w, r, map[string]any{
"data": []map[string]any{
{"validator": "1", "pubkey": "0x123"},
},
})
Expand All @@ -101,8 +101,8 @@ func setupTestServer(t *testing.T) *httptest.Server {
}

exporterDecidedsHandler := func(w http.ResponseWriter, r *http.Request) {
err := api.Render(w, r, map[string]interface{}{
"data": []map[string]interface{}{
err := api.Render(w, r, map[string]any{
"data": []map[string]any{
{"slot": 1, "role": "attester"},
},
})
Expand Down
4 changes: 2 additions & 2 deletions beacon/goclient/proposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func createProposalResponseSafe(slot phase0.Slot, feeRecipient bellatrix.Executi
block.Body.ExecutionPayloadHeader.FeeRecipient = feeRecipient

// Wrap in response structure
response := map[string]interface{}{
response := map[string]any{
"data": block,
}
data, _ := json.Marshal(response)
Expand All @@ -156,7 +156,7 @@ func createProposalResponseSafe(slot phase0.Slot, feeRecipient bellatrix.Executi
blockContents.Block.Body.ExecutionPayload.FeeRecipient = feeRecipient

// Wrap in response structure
response := map[string]interface{}{
response := map[string]any{
"data": blockContents,
}
data, _ := json.Marshal(response)
Expand Down
2 changes: 1 addition & 1 deletion beacon/goclient/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (gc *GoClient) DomainData(
// object_root=hash_tree_root(ssz_object),
// domain=domain,
// ))
func (gc *GoClient) ComputeSigningRoot(object interface{}, domain phase0.Domain) ([32]byte, error) {
func (gc *GoClient) ComputeSigningRoot(object any, domain phase0.Domain) ([32]byte, error) {
if object == nil {
return [32]byte{}, errors.New("cannot compute signing root of nil")
}
Expand Down
4 changes: 2 additions & 2 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Global struct {
}

// ProcessArgs processes and handles CLI arguments
func ProcessArgs(cfg interface{}, a *Args, cmd *cobra.Command) {
func ProcessArgs(cfg any, a *Args, cmd *cobra.Command) {
configFlag := "config"
cmd.PersistentFlags().StringVarP(&a.ConfigPath, configFlag, "c", "./config/config.yaml", "Path to configuration file")
_ = cmd.MarkFlagRequired(configFlag)
Expand All @@ -40,7 +40,7 @@ func ProcessArgs(cfg interface{}, a *Args, cmd *cobra.Command) {
cmd.SetUsageTemplate(envHelp + "\n" + cmd.UsageTemplate())
}

func Prepare(cfg interface{}, a *Args) error {
func Prepare(cfg any, a *Args) error {
if a.ConfigPath != "" {
err := cleanenv.ReadConfig(a.ConfigPath, cfg)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions eth/executionclient/execution_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func TestFetchHistoricalLogs_Subdivide(t *testing.T) {

wrapped := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
raw, _ := io.ReadAll(r.Body)
var req map[string]interface{}
var req map[string]any
_ = json.Unmarshal(raw, &req)

if req["method"] == "eth_getLogs" {
Expand All @@ -357,15 +357,15 @@ func TestFetchHistoricalLogs_Subdivide(t *testing.T) {
return
}

flt := req["params"].([]interface{})[0].(map[string]interface{})
flt := req["params"].([]any)[0].(map[string]any)
from, _ := strconv.ParseInt(strings.TrimPrefix(flt["fromBlock"].(string), "0x"), 16, 64)
to, _ := strconv.ParseInt(strings.TrimPrefix(flt["toBlock"].(string), "0x"), 16, 64)
if uint64(to-from) > tc.threshold {
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]interface{}{
_ = json.NewEncoder(w).Encode(map[string]any{
"jsonrpc": "2.0",
"id": req["id"],
"error": map[string]interface{}{
"error": map[string]any{
"code": -32005,
"message": "query limit exceeded",
},
Expand Down
20 changes: 10 additions & 10 deletions eth/localevents/local_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Event struct {
// Name is the event name used for internal representation.
Name string
// Data is the parsed event
Data interface{}
Data any
}

func Load(path string) ([]Event, error) {
Expand All @@ -37,7 +37,7 @@ func Load(path string) ([]Event, error) {
}

type eventData interface {
toEventData() (interface{}, error)
toEventData() (any, error)
}

type eventDataUnmarshaler struct {
Expand Down Expand Up @@ -88,21 +88,21 @@ type ValidatorExitedEventYAML struct {
OperatorIds []uint64 `yaml:"OperatorIds"`
}

func (e *OperatorAddedEventYAML) toEventData() (interface{}, error) {
func (e *OperatorAddedEventYAML) toEventData() (any, error) {
return contract.ContractOperatorAdded{
OperatorId: e.ID,
Owner: ethcommon.HexToAddress(e.Owner),
PublicKey: []byte(e.PublicKey),
}, nil
}

func (e *OperatorRemovedEventYAML) toEventData() (interface{}, error) {
func (e *OperatorRemovedEventYAML) toEventData() (any, error) {
return contract.ContractOperatorRemoved{
OperatorId: e.ID,
}, nil
}

func (e *ValidatorAddedEventYAML) toEventData() (interface{}, error) {
func (e *ValidatorAddedEventYAML) toEventData() (any, error) {
pubKey, err := hex.DecodeString(strings.TrimPrefix(e.PublicKey, "0x"))
if err != nil {
return nil, err
Expand All @@ -121,36 +121,36 @@ func (e *ValidatorAddedEventYAML) toEventData() (interface{}, error) {
}, nil
}

func (e *ValidatorRemovedEventYAML) toEventData() (interface{}, error) {
func (e *ValidatorRemovedEventYAML) toEventData() (any, error) {
return contract.ContractValidatorRemoved{
Owner: ethcommon.HexToAddress(e.Owner),
OperatorIds: e.OperatorIds,
PublicKey: []byte(strings.TrimPrefix(e.PublicKey, "0x")),
}, nil
}

func (e *ClusterLiquidatedEventYAML) toEventData() (interface{}, error) {
func (e *ClusterLiquidatedEventYAML) toEventData() (any, error) {
return contract.ContractClusterLiquidated{
Owner: ethcommon.HexToAddress(e.Owner),
OperatorIds: e.OperatorIds,
}, nil
}

func (e *ClusterReactivatedEventYAML) toEventData() (interface{}, error) {
func (e *ClusterReactivatedEventYAML) toEventData() (any, error) {
return contract.ContractClusterReactivated{
Owner: ethcommon.HexToAddress(e.Owner),
OperatorIds: e.OperatorIds,
}, nil
}

func (e *FeeRecipientAddressUpdatedEventYAML) toEventData() (interface{}, error) {
func (e *FeeRecipientAddressUpdatedEventYAML) toEventData() (any, error) {
return contract.ContractFeeRecipientAddressUpdated{
Owner: ethcommon.HexToAddress(e.Owner),
RecipientAddress: ethcommon.HexToAddress(e.RecipientAddress),
}, nil
}

func (e *ValidatorExitedEventYAML) toEventData() (interface{}, error) {
func (e *ValidatorExitedEventYAML) toEventData() (any, error) {
return contract.ContractValidatorExited{
PublicKey: []byte(strings.TrimPrefix(e.PublicKey, "0x")),
OperatorIds: e.OperatorIds,
Expand Down
Loading