diff --git a/cli/builder/builder.go b/cli/builder/builder.go index af451d9e78..37617fd761 100644 --- a/cli/builder/builder.go +++ b/cli/builder/builder.go @@ -120,7 +120,7 @@ func (cb *CLIBuilder) InterceptConfigsPreRunHandler( cmd *cobra.Command, logger *phuslu.Logger, customAppConfigTemplate string, - customAppConfig interface{}, + customAppConfig any, cmtConfig *cmtcfg.Config, ) error { return config.SetupCommand( diff --git a/cli/commands/genesis/storage.go b/cli/commands/genesis/storage.go index 1d24e54118..143f03b26b 100644 --- a/cli/commands/genesis/storage.go +++ b/cli/commands/genesis/storage.go @@ -160,7 +160,7 @@ func writeGenesisAllocToFile( } // Unmarshal existing genesis using json.Number to preserve integer precision - var existingGenesis map[string]interface{} + var existingGenesis map[string]any decoder := json.NewDecoder(bytes.NewReader(existingBz)) decoder.UseNumber() if err = decoder.Decode(&existingGenesis); err != nil { @@ -168,7 +168,7 @@ func writeGenesisAllocToFile( } // Get existing alloc. - alloc, ok := existingGenesis[allocsKey].(map[string]interface{}) + alloc, ok := existingGenesis[allocsKey].(map[string]any) if !ok { return errors.New("invalid alloc format in genesis file") } diff --git a/cli/commands/genesis/storage_test.go b/cli/commands/genesis/storage_test.go index 3c55c74c66..afcbca3106 100644 --- a/cli/commands/genesis/storage_test.go +++ b/cli/commands/genesis/storage_test.go @@ -91,9 +91,9 @@ func setupMockGenesis(t *testing.T, tmpDir string) string { depositAddr := common.Address(chainSpec.DepositContractAddress()) mockGenesisPath := filepath.Join(tmpDir, "genesis.json") - mockGenesis := map[string]interface{}{ - "alloc": map[string]interface{}{ - depositAddr.Hex(): map[string]interface{}{ + mockGenesis := map[string]any{ + "alloc": map[string]any{ + depositAddr.Hex(): map[string]any{ "balance": "0x0", "code": "0x1234", }, @@ -113,12 +113,12 @@ func setupMockCLGenesis(t *testing.T, tmpDir string) string { require.NoError(t, os.MkdirAll(configDir, 0o755)) mockCLGenesisPath := filepath.Join(configDir, "genesis.json") - mockCLGenesis := map[string]interface{}{ - "app_state": map[string]interface{}{ - "beacon": map[string]interface{}{ - "deposits": []interface{}{ - map[string]interface{}{ - "data": map[string]interface{}{ + mockCLGenesis := map[string]any{ + "app_state": map[string]any{ + "beacon": map[string]any{ + "deposits": []any{ + map[string]any{ + "data": map[string]any{ "amount": "32000000000", "pubkey": "0x1234", "withdrawal_address": "0x5678", @@ -147,16 +147,16 @@ func verifyStorageOutput(t *testing.T, genesisPath string) { outputBz, err := afero.ReadFile(afero.NewOsFs(), genesisPath) require.NoError(t, err) - var output map[string]interface{} + var output map[string]any err = json.Unmarshal(outputBz, &output) require.NoError(t, err) // Check that the deposit contract storage was set correctly - alloc, ok := output["alloc"].(map[string]interface{}) + alloc, ok := output["alloc"].(map[string]any) require.True(t, ok) - depositContract, ok := alloc[depositAddr.Hex()].(map[string]interface{}) + depositContract, ok := alloc[depositAddr.Hex()].(map[string]any) require.True(t, ok) - storage, ok := depositContract["storage"].(map[string]interface{}) + storage, ok := depositContract["storage"].(map[string]any) require.True(t, ok) // Verify storage slots diff --git a/cli/commands/server/types/types.go b/cli/commands/server/types/types.go index de3c379057..dcbf2818e0 100644 --- a/cli/commands/server/types/types.go +++ b/cli/commands/server/types/types.go @@ -33,7 +33,7 @@ import ( type ( // AppOptions, usually implemented by Viper, holds the configuration for the application. AppOptions interface { - Get(string) interface{} + Get(string) any } // AppCreator is a function that allows us to lazily initialize an application using various diff --git a/config/config.go b/config/config.go index 556b813a7e..0dd062dae5 100644 --- a/config/config.go +++ b/config/config.go @@ -45,7 +45,7 @@ const ( // AppOptions is from the SDK, we should look to remove its usage. type AppOptions interface { - Get(string) interface{} + Get(string) any } // DefaultConfig returns the default configuration for a BeaconKit chain. diff --git a/config/config/toml.go b/config/config/toml.go index 5974d22245..271bc34575 100644 --- a/config/config/toml.go +++ b/config/config/toml.go @@ -70,7 +70,7 @@ func SetConfigTemplate(customTemplate string) error { // WriteConfigFile renders config using the template and writes it to // configFilePath. -func WriteConfigFile(configFilePath string, config interface{}) error { +func WriteConfigFile(configFilePath string, config any) error { var buffer bytes.Buffer if err := configTemplate.Execute(&buffer, config); err != nil { diff --git a/config/spec/creator_test.go b/config/spec/creator_test.go index 3b7f6c5da1..4c21c45d20 100644 --- a/config/spec/creator_test.go +++ b/config/spec/creator_test.go @@ -33,10 +33,10 @@ import ( // dummyAppOptions is a simple implementation of the AppOptions interface for testing. type dummyAppOptions struct { - values map[string]interface{} + values map[string]any } -func (d dummyAppOptions) Get(key string) interface{} { +func (d dummyAppOptions) Get(key string) any { return d.values[key] } @@ -44,7 +44,7 @@ func TestCreateChainSpec_Devnet(t *testing.T) { t.Parallel() // Set the app opts to force the devnet branch. - opts := dummyAppOptions{values: map[string]interface{}{ + opts := dummyAppOptions{values: map[string]any{ flags.ChainSpec: "devnet", }} cs, err := spec.Create(opts) @@ -59,7 +59,7 @@ func TestCreateChainSpec_Testnet(t *testing.T) { t.Parallel() // Set the app opts to force the testnet branch. - opts := dummyAppOptions{values: map[string]interface{}{ + opts := dummyAppOptions{values: map[string]any{ flags.ChainSpec: "testnet", }} cs, err := spec.Create(opts) @@ -74,7 +74,7 @@ func TestCreateChainSpec_Mainnet(t *testing.T) { t.Parallel() // Set the app opts to force the mainnet branch. - opts := dummyAppOptions{values: map[string]interface{}{ + opts := dummyAppOptions{values: map[string]any{ flags.ChainSpec: "mainnet", }} cs, err := spec.Create(opts) @@ -89,7 +89,7 @@ func TestCreateChainSpec_Default_NoSpecFlag(t *testing.T) { t.Parallel() // Provide an empty app opts so that no spec flag is present. - opts := dummyAppOptions{values: map[string]interface{}{}} + opts := dummyAppOptions{values: map[string]any{}} cs, err := spec.Create(opts) require.NoError(t, err) mainnetSpec, err := spec.MainnetChainSpec() @@ -101,7 +101,7 @@ func TestCreateChainSpec_File(t *testing.T) { t.Parallel() // Provide a non-empty value for the custom spec file of mainnet. - opts := dummyAppOptions{values: map[string]interface{}{ + opts := dummyAppOptions{values: map[string]any{ flags.ChainSpec: "file", flags.ChainSpecFilePath: "../../testing/networks/80094/spec.toml", }} @@ -180,7 +180,7 @@ consensus-enable-height = 2 specFile := filepath.Join(tempDir, tt.name+".toml") require.NoError(t, os.WriteFile(specFile, []byte(tt.specContent), 0600)) - opts := dummyAppOptions{values: map[string]interface{}{ + opts := dummyAppOptions{values: map[string]any{ flags.ChainSpec: "file", flags.ChainSpecFilePath: specFile, }} diff --git a/config/viper/parser.go b/config/viper/parser.go index a2112b547c..d1995d71a8 100644 --- a/config/viper/parser.go +++ b/config/viper/parser.go @@ -37,8 +37,8 @@ func NumericToDomainTypeFunc() mapstructure.DecodeHookFunc { return func( f reflect.Type, t reflect.Type, - data interface{}, - ) (interface{}, error) { + data any, + ) (any, error) { var dt common.DomainType if t != reflect.TypeOf(dt) { return data, nil @@ -92,8 +92,8 @@ func stringTo[T any]( return func( f reflect.Type, t reflect.Type, - data interface{}, - ) (interface{}, error) { + data any, + ) (any, error) { if f.Kind() != reflect.String { return data, nil } diff --git a/execution/client/ethclient/eth.go b/execution/client/ethclient/eth.go index 2e945c1f23..c320c0d638 100644 --- a/execution/client/ethclient/eth.go +++ b/execution/client/ethclient/eth.go @@ -70,8 +70,8 @@ func (s *Client) SubscribeFilterLogs( return nil, errors.New("not implemented") } -func toFilterArg(q ethereum.FilterQuery) (interface{}, error) { - arg := map[string]interface{}{ +func toFilterArg(q ethereum.FilterQuery) (any, error) { + arg := map[string]any{ "address": q.Addresses, "topics": q.Topics, } diff --git a/node-api/middleware/request.go b/node-api/middleware/request.go index 59cedc1a6a..fda2b75fd7 100644 --- a/node-api/middleware/request.go +++ b/node-api/middleware/request.go @@ -45,7 +45,7 @@ type CustomValidator struct { } // Validate validates the given interface. -func (cv *CustomValidator) Validate(i interface{}) error { +func (cv *CustomValidator) Validate(i any) error { if err := cv.Validator.Struct(i); err != nil { var validationErrors validator.ValidationErrors hasValidationErrors := errors.As(err, &validationErrors) diff --git a/node-core/services/registry/registry.go b/node-core/services/registry/registry.go index a724b2d127..219f95b133 100644 --- a/node-core/services/registry/registry.go +++ b/node-core/services/registry/registry.go @@ -132,7 +132,7 @@ func (s *Registry) RegisterService(service Basic) error { // to a service currently stored in the service registry. This ensures the // input argument is set to the right pointer that refers to the originally // registered service. -func (s *Registry) FetchService(service interface{}) error { +func (s *Registry) FetchService(service any) error { serviceType := reflect.TypeOf(service) if serviceType.Kind() != reflect.Ptr || serviceType.Elem().Kind() != reflect.Ptr { diff --git a/primitives/crypto/sha256/sha256.go b/primitives/crypto/sha256/sha256.go index 21bdaa4c85..99cc234fe0 100644 --- a/primitives/crypto/sha256/sha256.go +++ b/primitives/crypto/sha256/sha256.go @@ -30,7 +30,7 @@ import ( // sha256Pool is a pool of sha256 hash functions. // //nolint:gochecknoglobals // needed for pool. -var sha256Pool = sync.Pool{New: func() interface{} { +var sha256Pool = sync.Pool{New: func() any { return sha256.New() }} diff --git a/state-transition/core/state_processor_withdrawals.go b/state-transition/core/state_processor_withdrawals.go index 1420f7ad3b..de3fdf6aee 100644 --- a/state-transition/core/state_processor_withdrawals.go +++ b/state-transition/core/state_processor_withdrawals.go @@ -337,8 +337,8 @@ func verifyWithdrawalConditions(st *state.StateDB, validator *ctypes.Validator) // withdrawalFields returns the structured fields for logging any WithdrawalRequest. // error is optional -func withdrawalFields(req *ctypes.WithdrawalRequest, err error) []interface{} { - logFields := []interface{}{ +func withdrawalFields(req *ctypes.WithdrawalRequest, err error) []any { + logFields := []any{ "source_address", req.SourceAddress.String(), "validator_pubkey", req.ValidatorPubKey.String(), "amount", req.Amount, diff --git a/testing/e2e/e2e_comet_api_test.go b/testing/e2e/e2e_comet_api_test.go index d0fbbdc2c5..fd01bd2cdc 100644 --- a/testing/e2e/e2e_comet_api_test.go +++ b/testing/e2e/e2e_comet_api_test.go @@ -74,7 +74,7 @@ func (s *BeaconKitE2ESuite) TestABCIInfo() { wg.Wait() // Check for errors. - errorsMap.Range(func(key, value interface{}) bool { + errorsMap.Range(func(key, value any) bool { name := key.(string) //nolint:errcheck // Safe to ignore. err := value.(error) //nolint:errcheck // Safe to ignore. s.Require().NoError(err, "Error getting ABCI info from node %s", name) @@ -83,7 +83,7 @@ func (s *BeaconKitE2ESuite) TestABCIInfo() { // Collect heights into a map for comparison. heights := make(map[string]int64) - heightsMap.Range(func(key, value interface{}) bool { + heightsMap.Range(func(key, value any) bool { name := key.(string) //nolint:errcheck // Safe to ignore. height := value.(int64) //nolint:errcheck // Safe to ignore. heights[name] = height diff --git a/testing/e2e/suite/types/service_context.go b/testing/e2e/suite/types/service_context.go index ac138132a7..f5b48467db 100644 --- a/testing/e2e/suite/types/service_context.go +++ b/testing/e2e/suite/types/service_context.go @@ -75,7 +75,7 @@ func (s *WrappedServiceContext) Start( ctx context.Context, enclaveContext *enclaves.EnclaveContext, ) (*enclaves.StarlarkRunResult, error) { - res, err := s.RunHelper(ctx, "start_service", map[string]interface{}{ + res, err := s.RunHelper(ctx, "start_service", map[string]any{ "service_name": s.GetServiceName(), }) if err != nil { @@ -97,7 +97,7 @@ func (s *WrappedServiceContext) Start( func (s *WrappedServiceContext) Stop( ctx context.Context, ) (*enclaves.StarlarkRunResult, error) { - return s.RunHelper(ctx, "stop_service", map[string]interface{}{ + return s.RunHelper(ctx, "stop_service", map[string]any{ "service_name": s.GetServiceName(), }) } @@ -105,7 +105,7 @@ func (s *WrappedServiceContext) Stop( func (s *WrappedServiceContext) RunHelper( ctx context.Context, mainFunctionName string, - args map[string]interface{}, + args map[string]any, ) (*enclaves.StarlarkRunResult, error) { jsonBytes, err := json.Marshal(args) if err != nil {